(msg)
| 64 | } |
| 65 | |
| 66 | const handle = (msg) => { |
| 67 | if (msg.method === "initialize") { |
| 68 | send({ |
| 69 | jsonrpc: "2.0", |
| 70 | id: msg.id, |
| 71 | result: { |
| 72 | // Echo the client's protocol version so we never fail version |
| 73 | // negotiation against whatever SDK build is on the other end. |
| 74 | protocolVersion: msg.params?.protocolVersion ?? "2025-06-18", |
| 75 | capabilities: { tools: {} }, |
| 76 | serverInfo: { name: "executor-e2e-stdio", version: "1.0.0" }, |
| 77 | }, |
| 78 | }); |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | // Notifications carry no id and expect no response. |
| 83 | if (msg.id === undefined || msg.id === null) return; |
| 84 | |
| 85 | if (msg.method === "ping") { |
| 86 | send({ jsonrpc: "2.0", id: msg.id, result: {} }); |
| 87 | return; |
| 88 | } |
| 89 | |
| 90 | if (msg.method === "tools/list") { |
| 91 | send({ jsonrpc: "2.0", id: msg.id, result: { tools: TOOLS } }); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | if (msg.method === "tools/call") { |
| 96 | const name = msg.params?.name; |
| 97 | const text = |
| 98 | name === "whoami" |
| 99 | ? (process.env.EXECUTOR_E2E_SECRET ?? "") |
| 100 | : String(msg.params?.arguments?.text ?? ""); |
| 101 | send({ |
| 102 | jsonrpc: "2.0", |
| 103 | id: msg.id, |
| 104 | result: { content: [{ type: "text", text }] }, |
| 105 | }); |
| 106 | return; |
| 107 | } |
| 108 | |
| 109 | send({ |
| 110 | jsonrpc: "2.0", |
| 111 | id: msg.id, |
| 112 | error: { code: -32601, message: `Method not found: ${msg.method}` }, |
| 113 | }); |
| 114 | }; |
| 115 | |
| 116 | const rl = createInterface({ input: process.stdin }); |
| 117 | rl.on("line", (line) => { |
no test coverage detected