|
7 | 7 | * |
8 | 8 | * Flow: |
9 | 9 | * 1. Spin up a tiny local OpenAPI server (one operation, returns 42). |
10 | | - * 2. Write a temp executor.jsonc that points at it as a source. |
11 | | - * 3. Spawn the compiled `executor-sidecar` binary with EXECUTOR_PORT=0 |
| 10 | + * 2. Spawn the compiled `executor-sidecar` binary with EXECUTOR_PORT=0 |
12 | 11 | * and parse the `EXECUTOR_READY:<port>` sentinel. |
13 | | - * 4. Connect via MCP streamable HTTP, call the `execute` tool with code |
14 | | - * that invokes the OpenAPI tool, assert the answer round-trips as 42. |
| 12 | + * 3. Connect via MCP streamable HTTP, call the `execute` tool with code |
| 13 | + * that registers and invokes the OpenAPI tool, assert the answer |
| 14 | + * round-trips as 42. |
15 | 15 | * |
16 | 16 | * Run after `bun ./scripts/build-sidecar.ts`. Exits non-zero on any |
17 | 17 | * deviation so it can gate CI. |
18 | 18 | */ |
19 | | -import { mkdtemp, rm, writeFile } from "node:fs/promises"; |
| 19 | +import { mkdtemp, rm } from "node:fs/promises"; |
20 | 20 | import { tmpdir } from "node:os"; |
21 | 21 | import { join, resolve } from "node:path"; |
22 | 22 | import { spawn, type Subprocess } from "bun"; |
@@ -182,18 +182,6 @@ const main = async () => { |
182 | 182 | console.log(`[smoke-sidecar] scope: ${scopeDir}`); |
183 | 183 | console.log(`[smoke-sidecar] openapi: ${openapi.origin}`); |
184 | 184 |
|
185 | | - const config = { |
186 | | - sources: [ |
187 | | - { |
188 | | - kind: "openapi", |
189 | | - spec: `${openapi.origin}/openapi.json`, |
190 | | - baseUrl: openapi.origin, |
191 | | - namespace: "petstore", |
192 | | - }, |
193 | | - ], |
194 | | - }; |
195 | | - await writeFile(join(scopeDir, "executor.jsonc"), JSON.stringify(config, null, 2)); |
196 | | - |
197 | 185 | const proc = spawn({ |
198 | 186 | cmd: [BINARY], |
199 | 187 | env: { |
@@ -241,9 +229,17 @@ const main = async () => { |
241 | 229 | if (!hasExecute) fail(`MCP tools/list missing "execute": ${JSON.stringify(tools.tools)}`); |
242 | 230 |
|
243 | 231 | // Drive the running OpenAPI server through a multi-step orchestration |
244 | | - // in one execute. Covers: array list response, path param dispatch, and |
245 | | - // object responses — all going out over real HTTP from inside QuickJS. |
| 232 | + // in one execute. Covers: source registration, array list response, path |
| 233 | + // param dispatch, and object responses — all going out over real HTTP from |
| 234 | + // inside QuickJS. |
246 | 235 | const code = ` |
| 236 | +const scope = (await tools.executor.scopes.list({})).scopes[0].name; |
| 237 | +await tools.executor.openapi.addSource({ |
| 238 | + scope, |
| 239 | + spec: ${JSON.stringify(`${openapi.origin}/openapi.json`)}, |
| 240 | + baseUrl: ${JSON.stringify(openapi.origin)}, |
| 241 | + namespace: "petstore", |
| 242 | +}); |
247 | 243 | const list = await tools.petstore.pets.listPets({}); |
248 | 244 | const fetched = await tools.petstore.pets.getPet({ petId: list[1].id }); |
249 | 245 | return { |
|
0 commit comments