{"version":3,"file":"sandboxHarness.cjs","names":[],"sources":["../../src/schemas/sandboxHarness.ts"],"sourcesContent":["/**\n * Sandbox harness contract.\n *\n * A layer package that owns sandboxed launches exports a module at the\n * `./sandbox-harness` subpath. The harness resolves that module from the\n * selected composition and delegates the whole launch to it, so core never\n * depends on a concrete sandbox technology.\n */\n\n/** Exports subpath a sandbox-owning layer package declares. */\nexport const SANDBOX_HARNESS_EXPORT_SUBPATH = './sandbox-harness';\n\n/** Marks a process that already runs inside a DoomPi sandbox. */\nexport const DOOMPI_SANDBOX_ENV = 'DOOMPI_SANDBOX';\n\nconst SANDBOX_FLAG = '1';\n\n/** True inside a sandboxed session, which is how a provider refuses to nest. */\nexport function insideSandbox(environment: NodeJS.ProcessEnv = process.env): boolean {\n  return environment[DOOMPI_SANDBOX_ENV] === SANDBOX_FLAG;\n}\n\n/** One sandboxed launch, owned end to end by the providing layer. */\nexport interface SandboxLaunchRequest {\n  /** Repository the sandbox mounts and works against. */\n  repoRoot: string;\n  /** Working directory of the launch, expected to sit inside the mounted repository. */\n  cwd: string;\n  /**\n   * Harness arguments the in-sandbox launcher replays. Never contains the\n   * sandbox flag itself: a sandboxed launch must not provision another.\n   */\n  forwardArgs: string[];\n  /** Host environment the provider filters before any of it enters the sandbox. */\n  environment: NodeJS.ProcessEnv;\n  /** Receives one human-readable line per provisioning decision. */\n  onProgress?: (message: string) => void;\n}\n\nexport interface SandboxHarnessModule {\n  /** Provisions the sandbox, runs the launch inside it, and reports the exit code. */\n  launchSandbox(request: SandboxLaunchRequest): Promise<number>;\n}\n\n/** Narrowing guard for a dynamically imported sandbox harness entry. */\nexport function isSandboxHarnessModule(value: unknown): value is SandboxHarnessModule {\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    typeof (value as { launchSandbox?: unknown }).launchSandbox === 'function'\n  );\n}\n"],"mappings":"AAUA,MAGa,EAAqB,iBAKlC,SAAgB,EAAc,EAAiC,QAAQ,IAAc,CACnF,OAAO,EAAY,KAAwB,GAC7C,CAyBA,SAAgB,EAAuB,EAA+C,CACpF,OACE,OAAO,GAAU,YACjB,GACA,OAAQ,EAAsC,eAAkB,UAEpE"}