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