()
| 320 | }; |
| 321 | |
| 322 | const main = async () => { |
| 323 | if (!(await Bun.file(BINARY).exists())) { |
| 324 | fail( |
| 325 | `binary not found at ${BINARY}. Run \`bun ./scripts/build-sidecar.ts\` from apps/desktop first.`, |
| 326 | ); |
| 327 | } |
| 328 | |
| 329 | const scopeDir = await mkdtemp(join(tmpdir(), "executor-smoke-scope-")); |
| 330 | const dataDir = await mkdtemp(join(tmpdir(), "executor-smoke-data-")); |
| 331 | await seedLegacyScopedSqlite(dataDir, makeScopeId(scopeDir)); |
| 332 | // v2 connections reference credentials by provider item instead of carrying |
| 333 | // raw values, so seed the file-secrets provider (auth.json under |
| 334 | // XDG_DATA_HOME) with the token the sandbox's connections.create points at. |
| 335 | const xdgDir = await mkdtemp(join(tmpdir(), "executor-smoke-xdg-")); |
| 336 | await Bun.write( |
| 337 | join(xdgDir, "executor", "auth.json"), |
| 338 | `${JSON.stringify({ "petstore-token": "smoke-token" })}\n`, |
| 339 | ); |
| 340 | const openapi = startOpenApiServer(); |
| 341 | |
| 342 | console.log(`[smoke-sidecar] scope: ${scopeDir}`); |
| 343 | console.log(`[smoke-sidecar] data: ${dataDir}`); |
| 344 | console.log(`[smoke-sidecar] openapi: ${openapi.origin}`); |
| 345 | |
| 346 | const proc = spawn({ |
| 347 | cmd: [ |
| 348 | BINARY, |
| 349 | "daemon", |
| 350 | "run", |
| 351 | "--foreground", |
| 352 | "--port", |
| 353 | "0", |
| 354 | "--hostname", |
| 355 | "127.0.0.1", |
| 356 | "--auth-token", |
| 357 | AUTH_TOKEN, |
| 358 | ], |
| 359 | env: { |
| 360 | ...process.env, |
| 361 | EXECUTOR_SCOPE_DIR: scopeDir, |
| 362 | EXECUTOR_DATA_DIR: dataDir, |
| 363 | EXECUTOR_CLIENT: "desktop", |
| 364 | XDG_DATA_HOME: xdgDir, |
| 365 | }, |
| 366 | stdin: "ignore", |
| 367 | stdout: "pipe", |
| 368 | stderr: "pipe", |
| 369 | }); |
| 370 | |
| 371 | let exitCode: number | null = null; |
| 372 | void proc.exited.then((code) => { |
| 373 | exitCode = code; |
| 374 | }); |
| 375 | |
| 376 | const cleanup = async () => { |
| 377 | if (exitCode === null) { |
| 378 | proc.kill("SIGTERM"); |
| 379 | await Promise.race([proc.exited, Bun.sleep(3000)]); |
no test coverage detected