MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / main

Function main

apps/desktop/scripts/smoke-sidecar.ts:413–590  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

411};
412
413const 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

Callers 1

smoke-sidecar.tsFile · 0.70

Calls 15

mkdtempFunction · 0.85
seedLegacyScopedSqliteFunction · 0.85
makeScopeIdFunction · 0.85
startOpenApiServerFunction · 0.85
completePausedResultFunction · 0.85
logMethod · 0.80
failFunction · 0.70
waitForReadyPortFunction · 0.70

Tested by

no test coverage detected