| 146 | const MAX_CODE_ATTR_CHARS = 10_000; |
| 147 | |
| 148 | const executeCodeAttrs = ( |
| 149 | name: string | undefined, |
| 150 | args: Record<string, unknown> | undefined, |
| 151 | ): Record<string, unknown> => { |
| 152 | if (name !== "execute" && name !== "execute-action") return {}; |
| 153 | const code = args?.["code"]; |
| 154 | if (typeof code !== "string") return {}; |
| 155 | return { |
| 156 | "mcp.execute.code": |
| 157 | code.length > MAX_CODE_ATTR_CHARS |
| 158 | ? `${code.slice(0, MAX_CODE_ATTR_CHARS)}\n… [truncated ${code.length - MAX_CODE_ATTR_CHARS} chars]` |
| 159 | : code, |
| 160 | }; |
| 161 | }; |
| 162 | |
| 163 | const methodAttrs = (envelope: JsonRpcEnvelope): Record<string, unknown> => { |
| 164 | const params = envelope.params ?? {}; |