()
| 411 | }; |
| 412 | |
| 413 | const main = async () => { |
| 414 | if (!(await Bun.file(BINARY).exists())) { |
| 415 | fail( |
| 416 | `binary not found at ${BINARY}. Run \`bun ./scripts/build-sidecar.ts\` from apps/desktop first.`, |
| 417 | ); |
| 418 | } |
| 419 | |
| 420 | const scopeDir = await mkdtemp(join(tmpdir(), "executor-smoke-scope-")); |
| 421 | const dataDir = await mkdtemp(join(tmpdir(), "executor-smoke-data-")); |
| 422 | const sidecarRoot = await mkdtemp(join(tmpdir(), "executor-smoke-sidecar-")); |
| 423 | const sidecar = await stageSidecarWithUnavailableOp(sidecarRoot); |
| 424 | let hiddenWorkspaceWasm: HiddenWorkspaceWasm | null = null; |
| 425 | await seedLegacyScopedSqlite(dataDir, makeScopeId(scopeDir)); |
| 426 | // v2 connections reference credentials by provider item instead of carrying |
| 427 | // raw values, so seed the file-secrets provider (auth.json under |
| 428 | // XDG_DATA_HOME) with the token the sandbox's connections.create points at. |
| 429 | const xdgDir = await mkdtemp(join(tmpdir(), "executor-smoke-xdg-")); |
| 430 | await Bun.write( |
| 431 | join(xdgDir, "executor", "auth.json"), |
| 432 | `${JSON.stringify({ "petstore-token": "smoke-token" })}\n`, |
| 433 | ); |
| 434 | const openapi = startOpenApiServer(); |
| 435 | |
| 436 | console.log(`[smoke-sidecar] scope: ${scopeDir}`); |
| 437 | console.log(`[smoke-sidecar] data: ${dataDir}`); |
| 438 | console.log(`[smoke-sidecar] openapi: ${openapi.origin}`); |
| 439 | console.log(`[smoke-sidecar] sidecar: ${sidecar.binary}`); |
| 440 | |
| 441 | const proc = spawn({ |
| 442 | cmd: [ |
| 443 | sidecar.binary, |
| 444 | "daemon", |
| 445 | "run", |
| 446 | "--foreground", |
| 447 | "--port", |
| 448 | "0", |
| 449 | "--hostname", |
| 450 | "127.0.0.1", |
| 451 | "--auth-token", |
| 452 | AUTH_TOKEN, |
| 453 | ], |
| 454 | env: { |
| 455 | ...process.env, |
| 456 | EXECUTOR_SCOPE_DIR: scopeDir, |
| 457 | EXECUTOR_DATA_DIR: dataDir, |
| 458 | EXECUTOR_CLIENT: "desktop", |
| 459 | XDG_DATA_HOME: xdgDir, |
| 460 | }, |
| 461 | stdin: "ignore", |
| 462 | stdout: "pipe", |
| 463 | stderr: "pipe", |
| 464 | }); |
| 465 | |
| 466 | let exitCode: number | null = null; |
| 467 | void proc.exited.then((code) => { |
| 468 | exitCode = code; |
| 469 | }); |
| 470 |
no test coverage detected