@banzhe/dsh-devcontainer 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -0
- package/README.zh-CN.md +33 -0
- package/lib/client.js +151 -10
- package/lib/client.js.map +1 -1
- package/lib/{exec-CKAAz2zz.js → exec-Bcojrag9.js} +5 -4
- package/lib/exec-Bcojrag9.js.map +1 -0
- package/lib/fs.d.ts +62 -16
- package/lib/fs.d.ts.map +1 -1
- package/lib/fs.js +256 -68
- package/lib/fs.js.map +1 -1
- package/lib/helper/main.mjs +22 -3
- package/lib/index.d.ts +19 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +51 -5
- package/lib/index.js.map +1 -1
- package/lib/{sbx-1GsFjQBk.js → sbx-Blgjzzoe.js} +918 -135
- package/lib/sbx-Blgjzzoe.js.map +1 -0
- package/lib/shell.d.ts +3 -3
- package/lib/shell.d.ts.map +1 -1
- package/lib/shell.js +11 -4
- package/lib/shell.js.map +1 -1
- package/lib/{types-DsF9Hz5P.d.ts → types-B2cQmBTx.d.ts} +4 -2
- package/lib/types-B2cQmBTx.d.ts.map +1 -0
- package/package.json +3 -1
- package/lib/exec-CKAAz2zz.js.map +0 -1
- package/lib/sbx-1GsFjQBk.js.map +0 -1
- package/lib/types-DsF9Hz5P.d.ts.map +0 -1
package/lib/shell.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.js","names":[],"sources":["../src/argv.ts","../src/shell.ts"],"sourcesContent":["/**\n * The argv one container-executed command becomes.\n *\n * Two shapes, one contract: the command runs under the configured Linux shell,\n * in the container directory that mirrors the host workdir, with ONLY the\n * environment this Bundle deliberately forwards. The host's `PATH`,\n * `SystemRoot`, and every other Windows entry stay out of the container — a\n * Linux `bash` reading a Windows `PATH` finds no binaries at all.\n *\n * @module @banzhe/dsh-devcontainer/argv\n */\n\nimport type { ContainerTarget } from './container.ts'\nimport { CONTAINER_MARKER_KEYS } from './refusal.ts'\nimport type { RepoContainerSpec } from './types.ts'\n\n/**\n * The host-side scheduling markers. They tell this Bundle's executor whose\n * command it is holding; inside the runtime they mean nothing, so they are\n * never forwarded.\n */\nconst INTERNAL_ENV_KEYS: ReadonlySet<string> = new Set(CONTAINER_MARKER_KEYS)\n\n/**\n * Terminal facts every container command gets. They replace what\n * `LocalBashExecutor` normally sets on the child: colors, pagers, and\n * interactive prompts have no place in captured tool output.\n */\nexport const BASE_CONTAINER_ENV: Readonly<Record<string, string>> = {\n TERM: 'dumb',\n GIT_TERMINAL_PROMPT: '0',\n NO_COLOR: '1',\n}\n\n/** One command's container argv inputs. */\nexport interface ExecArgvInput {\n /** The repository container specification. */\n readonly spec: RepoContainerSpec\n /** The resolved container target. */\n readonly target: ContainerTarget\n /** POSIX directory inside the container the command runs in. */\n readonly containerWorkdir: string\n /** The command source the model asked for. */\n readonly command: string\n /** Already-merged environment entries; only these reach the container. */\n readonly env: Readonly<Record<string, string>>\n}\n\n/**\n * Merge the container environment: base facts first, then the configuration's\n * `remoteEnv`, then the caller's own entries. Nothing from the host process\n * participates.\n * @param spec - the repository container specification.\n * @param env - the caller's ordinary environment entries.\n * @param dshEnv - the harness-managed `DSH_*` snapshot for this execution.\n * @returns the merged map, or `{}` when nothing is forwarded.\n */\nexport function containerEnv(\n spec: RepoContainerSpec,\n env?: Readonly<Record<string, string>>,\n dshEnv?: Readonly<Record<string, string>>,\n): Record<string, string> {\n const managed: Record<string, string> = {}\n for (const [key, value] of Object.entries(dshEnv ?? {})) {\n if (INTERNAL_ENV_KEYS.has(key)) continue\n managed[key] = value\n }\n return {\n ...BASE_CONTAINER_ENV,\n ...spec.remoteEnv,\n ...env,\n ...managed,\n }\n}\n\n/**\n * Split a configured shell into its program and any fixed arguments, so\n * `/bin/bash -l` reaches the container as two words followed by `-c`.\n * @param shell - the configured shell string.\n * @returns the program followed by its arguments; `/bin/bash` when empty.\n */\nexport function shellParts(shell: string): string[] {\n const parts = shell.trim().split(/\\s+/).filter(part => part !== '')\n return parts.length === 0 ? ['/bin/bash'] : parts\n}\n\n/** `-e KEY=VALUE` flags, sorted so one command always yields one argv. */\nfunction envFlags(env: Readonly<Record<string, string>>): string[] {\n return Object.keys(env).sort().map((key) => `${key}=${env[key] as string}`)\n}\n\n/** Single-quote one shell word, so an inner command survives unchanged. */\nfunction quote(value: string): string {\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\n/**\n * Assemble the argv for one command.\n * @param input - target, workdir, command, and the merged environment.\n * @returns the complete argv to hand to the subprocess seam.\n */\nexport function buildExecArgv(input: ExecArgvInput): readonly string[] {\n const { spec, target, containerWorkdir, command } = input\n const flags = envFlags(input.env)\n const user = spec.remoteUser\n switch (target.kind) {\n case 'docker':\n return [\n 'docker', 'exec', '-i', '-w', containerWorkdir,\n ...user === undefined ? [] : ['-u', user],\n ...flags.flatMap(entry => ['-e', entry]),\n target.containerId,\n ...shellParts(spec.shell), '-c', command,\n ]\n case 'devcontainer-cli':\n // `devcontainer exec` starts its own process, so the subdirectory has to be\n // entered by a POSIX shell wrapper inside the container.\n return [\n 'devcontainer', 'exec', '--workspace-folder', target.workspaceFolder,\n ...user === undefined ? [] : ['--remote-user', user],\n ...flags.flatMap(entry => ['--remote-env', entry]),\n '--', '/bin/sh', '-c', shellWrapper(input, []),\n ]\n case 'sbx':\n // `sbx exec` takes no environment flags on the sandbox CLI version this\n // Bundle targets, and it starts its own process, so both the workdir and the\n // environment are applied by the same POSIX wrapper: `env` sets the entries\n // for the shell about to replace the wrapper, and `exec` keeps the exit code\n // and signal of the real command.\n return [\n 'sbx', 'exec', target.sandboxName, '--', '/bin/sh', '-c',\n shellWrapper(input, envProgram(flags)),\n ]\n }\n}\n\n/**\n * The POSIX wrapper one sandbox or CLI command runs under.\n * @param input - the command and where it runs.\n * @param program - words that precede the shell (an `env` prefix, or nothing).\n * @returns the wrapper script.\n */\nfunction shellWrapper(input: ExecArgvInput, program: readonly string[]): string {\n const shell = [...program, ...shellParts(input.spec.shell).map(quote)].join(' ')\n return `cd -- ${quote(input.containerWorkdir)} && exec ${shell} -c ${quote(input.command)}`\n}\n\n/**\n * An `env` prefix carrying the merged environment, so a sandbox command sees the\n * same entries a `docker exec -e` would have given it.\n * @param flags - the sorted `KEY=VALUE` entries.\n * @returns the prefix words, or an empty list when nothing is forwarded.\n */\nfunction envProgram(flags: readonly string[]): string[] {\n return flags.length === 0 ? [] : ['env', ...flags.map(quote)]\n}\n","/**\n * Report a container-bound result as what it is: the host process was not\n * confined, because the container confines the command instead. Permission\n * bookkeeping therefore never attributes a host-sandbox denial to it.\n * @param execution - the handle returned for a `docker exec` run.\n * @returns the same handle, with its settled result stamped unconfined.\n */\nfunction stampUnconfined(execution: ShellExecution): ShellExecution {\n const base = execution.result.bind(execution)\n let stamped: Promise<ShellRunResult> | undefined\n execution.result = () => {\n stamped ??= base().then(result => ({ ...result, sandbox: { mode: 'danger-full-access' as const, denied: false } }))\n return stamped\n }\n return execution\n}\n\n/**\n * `ctx.shell` for repositories that declare a Dev Container, or run in a Docker\n * Sandbox.\n *\n * The executor IS the sandboxed local bash executor — same deadlines, same\n * output caps, same job/background semantics, same host-side confinement — with\n * two changes at the execution boundary:\n *\n * - {@link DevcontainerShellExecutor.resolve} reports the workdir as the\n * container's POSIX path, so `result.cwd` and every subsequent `workdir` the\n * model writes are Linux paths;\n * - {@link DevcontainerShellExecutor.execute} runs `docker exec` (or\n * `devcontainer exec`) instead of an in-process `bash -c`, from the HOST\n * repository root: `child_process` cannot chdir into `/workspaces/…`, which\n * does not exist on Windows.\n *\n * Everything outside a Dev Container repository keeps the LOCAL provider this\n * platform had before this Bundle existed — bash on POSIX, PowerShell on Windows\n * (`packages/shell/pwsh-local`). That is not cosmetic: on Windows the shipped\n * presets mount `tool-pwsh`, whose commands are PowerShell source, and a Windows\n * `bash` reading them would fail where it used to work.\n *\n * @module @banzhe/dsh-devcontainer/shell\n */\n\nimport { Context, type Volatile } from '@deepseek-ai/cordis'\nimport z from '@deepseek-ai/schemastery'\nimport { SandboxBashExecutor } from '@deepseek-ai/dsh-bash-sandbox'\nimport type { Config as LocalBashConfig } from '@deepseek-ai/dsh-bash-local'\nimport { ENCODING_PREAMBLE, resolvePwshPath } from '@deepseek-ai/dsh-pwsh-local'\nimport type { ShellExecRequest, ShellExecSpec, ShellExecution } from '@deepseek-ai/dsh-shell'\nimport { buildExecArgv, containerEnv } from './argv.ts'\nimport { resolveContainerTarget } from './container.ts'\nimport type { ContainerTarget } from './container.ts'\nimport { runContainerCommand } from './exec.ts'\nimport type { ContainerRun } from './exec.ts'\nimport { containerOptionFields, containerOptions } from './options.ts'\nimport { toContainerPath } from './paths.ts'\nimport {\n markedContainerOnly, markedPreset, markedVariantKind, refusalText, refusedExecution, sbxRefusalText,\n} from './refusal.ts'\nimport type { ShellRunResult } from '@deepseek-ai/dsh-shell'\nimport { repoRegistry } from './registry.ts'\nimport { bindSbxMount, sandboxHostPathFor, sbxSpecFor, sbxWorkspaceRootFor } from './sbx.ts'\nimport type { SandboxHostAttribution } from './sbx.ts'\nimport type { ContainerOptions, RepoContainerSpec } from './types.ts'\nimport type { VariantKind } from './ids.ts'\n\n/** Plugin name used by the Loader row. */\nexport const name = 'devcontainer-shell'\n\n/** The seams this executor spawns and confines through. */\nexport const inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n/** The local shell used when a workdir belongs to no Dev Container repository. */\nexport type LocalShell = 'auto' | 'bash' | 'powershell'\n\n/**\n * Whether one container run failed because the container or sandbox is gone.\n *\n * A target is cached per repository, so a container that was restarted or\n * recreated shows up as these errors on the next command; the cache entry is\n * dropped so the following command re-probes instead of failing forever. The\n * sandbox half covers `sbx`: it reports a missing sandbox on stderr AND with\n * exit code 125, which is Docker's generic \"could not run the command\" status.\n * @param result - the settled foreground result.\n * @returns true when the failure is about the runtime itself.\n */\nfunction containerGone(result: ShellRunResult): boolean {\n if (result.exitCode === 0) return false\n if (result.exitCode === 125) return true\n return /no such container|is not running|cannot connect to the docker daemon|container .* is not running/i.test(result.stderr.text)\n || /no such sandbox|sandbox .* (?:not found|does not exist|is not running|is stopped|has stopped)/i.test(result.stderr.text)\n}\n\n/**\n * The host directory a sandbox-spelled workdir names.\n *\n * Only a Windows host maps a drive directory into its sandbox without the drive\n * colon, so only there does a container path need reversing: everywhere else a\n * sandbox mounts the directory at the absolute path it already has, which is the\n * workdir a caller wrote.\n * @param workdir - the directory the command named.\n * @returns the attribution, or undefined when the path names no host directory.\n */\nfunction sandboxHostAttribution(workdir: string): SandboxHostAttribution | undefined {\n return process.platform === 'win32' ? sandboxHostPathFor(workdir) : undefined\n}\n\n/** The local executor's knobs plus this Bundle's container options. */\nexport interface Config extends LocalBashConfig, ContainerOptions {\n /** Explicit pwsh executable for the Windows local fallback (empty = probe well-known paths). */\n pwshPath?: Volatile<string>\n /**\n * Local fallback shell (default `auto`: PowerShell on Windows, bash elsewhere).\n * `bash` keeps the inherited executor; `powershell` runs\n * `pwsh -NoProfile -Command`, the same invocation `@deepseek-ai/dsh-pwsh-local`\n * uses.\n */\n localShell?: LocalShell\n}\n\n/**\n * Mirrors `@deepseek-ai/dsh-bash-local`'s schema field for field — the inherited\n * `resolve()` validates these through `assertServiceableBashConfig` — and adds\n * the shared container options plus the local-fallback knobs.\n */\nconst ConfigSchema = z.object({\n cwd: z.string().volatile(),\n timeoutMs: z.number().default(120_000).volatile(),\n maxTimeoutMs: z.number().default(600_000).volatile(),\n maxOutputBytes: z.number().default(64_000).volatile(),\n maxSpillBytes: z.number().default(64 * 1024 * 1024).volatile(),\n graceMs: z.number().default(3_000).volatile(),\n pwshPath: z.string().default('').volatile(),\n localShell: z.union(['auto', 'bash', 'powershell'] as const).default('auto'),\n ...containerOptionFields(),\n})\n\n/** The row's schema, typed for callers; the loader reads the class's static copy. */\nexport const Config = ConfigSchema as unknown as z<Config>\n\n/**\n * Container-backed bash executor. Falls through to the platform's local shell\n * for every workdir that belongs to no Dev Container repository, so a session\n * that never touches such a repository behaves exactly like the provider this\n * Bundle replaced.\n */\nexport class DevcontainerShellExecutor extends SandboxBashExecutor {\n /**\n * The schema the Loader resolves this row's config through.\n *\n * It has to be a STATIC: the module's `default` export is this class, and the\n * Loader's `unwrapExports` hands Cordis the class itself — module-level exports\n * such as `Config` never reach it. Without this static the row would be mounted\n * with the inherited bash-local schema, silently dropping every container knob.\n */\n static override Config = ConfigSchema\n\n /**\n * The seams this executor spawns and confines through.\n *\n * This row REPLACES the sandboxed executor rather than the plain local one:\n * `ctx.shell.sandboxMode` is the capability fact permission presets read, and\n * an executor that cannot report one makes them refuse to compose at all.\n * Host-side commands therefore keep the confinement this platform shipped;\n * only a command that enters the container runs unconfined on the host,\n * because the container is what confines it.\n */\n static override inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n /** Test seam: replaces the host CLI runner. */\n internals: { run?: ContainerRun; localShell?: LocalShell; requireContainer?: boolean } = {}\n\n /** This row's own configuration (the inherited `config` is typed by the local executor). */\n private readonly ownConfig: Config\n\n /** The container options this row was configured with. */\n private readonly options: ContainerOptions\n\n /** One resolved target per repository, so a burst of commands probes Docker once. */\n private readonly targets = new Map<string, Promise<ContainerTarget>>()\n\n /** Whether the configured directory has been walked for a declaration yet. */\n private warmed = false\n\n constructor(ctx: Context, config: Config) {\n super(ctx, config)\n this.ownConfig = config\n this.options = containerOptions(config)\n ctx.effect(() => {\n const cache = repoRegistry(ctx)\n return () => { cache.reset() }\n })\n }\n\n /**\n * Report the container's POSIX workdir so the model sees Linux paths.\n *\n * Only an execution that must reach a container is rewritten. An ordinary\n * session in the same repository keeps host paths, because its commands keep\n * running on the host — reporting `/workspaces/…` for a command that never\n * enters a container would describe a directory that does not exist.\n * @param request - the caller's request.\n * @returns the resolved spec, with a container workdir when this execution is container-bound.\n */\n override resolve(request: ShellExecRequest): ShellExecSpec {\n const spec = super.resolve(request)\n if (!this.requiresContainer(request)) return spec\n const repository = this.locate(spec.workdir, markedVariantKind(spec.dshEnv))\n if (repository === undefined) return spec\n const workdir = toContainerPath(spec.workdir, repository)\n return workdir === spec.workdir ? spec : { ...spec, workdir }\n }\n\n /**\n * Run the command inside the repository's container, or through the platform's\n * local shell when the workdir belongs to no Dev Container repository.\n * @param spec - a resolved spec from {@link DevcontainerShellExecutor.resolve}.\n * @returns the prepared execution handle.\n */\n override async execute(spec: ShellExecSpec): Promise<ShellExecution> {\n // A repository that declares a container does not make every session run in\n // it: only a container-bound execution is routed there. An ordinary preset\n // keeps the platform shell it had, even with a `.devcontainer` in the tree.\n if (!this.requiresContainer(spec)) return this.executeLocal(spec)\n const kind = markedVariantKind(spec.dshEnv)\n const repository = this.locate(spec.workdir, kind)\n if (repository === undefined) {\n // A derived preset promises container execution. Falling back to the host\n // would hand the model a host result it reads as a Linux one, so the command\n // is refused instead of silently misdirected.\n const preset = this.presetOf(spec)\n return refusedExecution(spec, kind === 'sbx'\n ? sbxRefusalText(spec.workdir, preset)\n : refusalText(spec.workdir, preset))\n }\n const key = this.targetKey(repository)\n // The host process must start in a directory that exists on THIS host.\n const hostSpec: ShellExecSpec = { ...spec, workdir: repository.hostWorkspaceRoot }\n const execution = await this.executeArgv(hostSpec, async (signal) => {\n const target = await this.containerTarget(key, repository, signal)\n // A sandbox may mount the workspace under a path of its own, which only its\n // listing knows: the workdir is translated against the folder it reported.\n const bound = bindSbxMount(repository, target)\n return buildExecArgv({\n spec: bound,\n target,\n containerWorkdir: toContainerPath(spec.workdir, bound),\n command: spec.command,\n env: containerEnv(repository, spec.env, spec.dshEnv),\n })\n })\n // A container that was restarted or recreated out from under a cached target\n // must be re-probed rather than reported as a permanent failure.\n void execution.result().then(\n (result) => { if (containerGone(result)) this.forgetTarget(key) },\n () => { this.forgetTarget(key) },\n )\n return stampUnconfined(execution)\n }\n\n /**\n * The local fallback: the inherited bash path (host confinement included), or\n * the PowerShell invocation `@deepseek-ai/dsh-pwsh-local` uses on Windows,\n * wrapped through the provider `@deepseek-ai/dsh-pwsh-sandbox` used. Both keep\n * the inherited deadline, output, and cancellation mechanics.\n */\n private executeLocal(spec: ShellExecSpec): Promise<ShellExecution> {\n const localShell = this.internals.localShell ?? this.ownConfig.localShell ?? 'auto'\n const powershell = localShell === 'powershell' || (localShell === 'auto' && process.platform === 'win32')\n if (!powershell) return super.execute(spec)\n const argv = [\n resolvePwshPath(this.ownConfig.pwshPath?.get()),\n '-NoLogo', '-NoProfile', '-NonInteractive',\n '-Command', `${ENCODING_PREAMBLE}${spec.command}`,\n ]\n const policy = spec.sandboxPolicy\n // No policy, or one that asks for host-wide access: spawn as before. A\n // confining policy wraps the same argv the sandboxed pwsh executor wrapped.\n if (policy === undefined) return this.executeArgv(spec, argv)\n const { mode } = policy\n if (mode === 'danger-full-access') return this.executeArgv(spec, argv)\n return this.executeArgv(spec, async (signal) => {\n const prepared = await this.ctx.sandbox.confine(argv, { ...policy, mode }, signal)\n signal.throwIfAborted()\n return prepared.argv\n })\n }\n\n /** Whether this execution must reach a container or not run at all. */\n private requiresContainer(request: ShellExecRequest | ShellExecSpec): boolean {\n if (this.internals.requireContainer === true) return true\n if (this.options.requireContainer) return true\n return markedContainerOnly(request.dshEnv)\n }\n\n /** The preset id the marker carries, so the refusal can name it. */\n private presetOf(spec: ShellExecSpec): string | undefined {\n return markedPreset(spec.dshEnv)\n }\n\n /**\n * The repository container specification governing one workdir.\n *\n * A `(devContainer)` session needs a declaration: without one there is nowhere\n * to run, which is what the refusal above reports. A `(sbx)` session needs\n * none — a sandbox mounts the host workspace at its own path — so a directory\n * with no declaration is described by {@link sbxSpecFor} instead, and only a\n * missing host directory (no configured cwd to fall back on) stays unresolved.\n *\n * A sandbox-spelled workdir is reversed onto the host before the registry is\n * asked, because `/f/personal/repo` has no host ancestry of its own.\n * @param workdir - the directory the command names.\n * @param kind - the runtime the calling preset selects, when one does.\n * @returns the specification, or undefined when this directory cannot be run in.\n */\n private locate(workdir: string, kind: VariantKind | undefined): RepoContainerSpec | undefined {\n const cwd = this.config.cwd.get()\n this.warmUp(cwd)\n const registry = repoRegistry(this.ctx)\n const options = { ...this.options, cwd }\n // A (sbx) session names its workdir the way its sandbox spells it, and that\n // spelling has no host ancestry to walk: `/f/personal/repo` resolves to no\n // host repository on a Windows host, where the directory is\n // `F:\\personal\\repo`. The host directory is recovered first, so a command\n // that already carries a container path still finds its repository.\n const attributed = kind === 'sbx' ? sandboxHostAttribution(workdir) : undefined\n const declared = registry.locate(attributed?.host ?? workdir, options)\n if (kind !== 'sbx') return declared\n const root = this.sbxHostRootOf(workdir, cwd, declared, attributed)\n return root === undefined ? undefined : sbxSpecFor(root, this.options, declared)\n }\n\n /**\n * The host directory a `(sbx)` session mounts for one workdir.\n *\n * A declaration wins, because a sandbox mounts the repository it was found in.\n * The directory the row was configured with comes next: that is the workspace\n * the sandbox was created around, and a workdir below it belongs to the same\n * mount. Only a row configured with no directory at all takes the workspace from\n * the workdir itself — the host directory a reported mount covers, else the\n * drive directory its sandbox spelling names — which is what makes a workdir of\n * `/f/personal/repo` reach the sandbox of `F:\\personal\\repo`.\n * @param workdir - the directory the command named.\n * @param cwd - the directory the row was configured with.\n * @param declared - the specification a declaration produced, when one exists.\n * @param attributed - the host directory the workdir's sandbox spelling names.\n * @returns the absolute host path to mount, or undefined when none can be named.\n */\n private sbxHostRootOf(\n workdir: string,\n cwd: string | undefined,\n declared: RepoContainerSpec | undefined,\n attributed: SandboxHostAttribution | undefined,\n ): string | undefined {\n if (declared !== undefined) return declared.hostWorkspaceRoot\n if (cwd !== undefined && cwd !== '') return cwd\n if (attributed !== undefined) return attributed.workspaceRoot ?? attributed.host\n return sbxWorkspaceRootFor(workdir, undefined, undefined)\n }\n\n /**\n * Discover the configured directory once, so a first call that already speaks\n * in container paths can still be attributed to its repository.\n */\n private warmUp(cwd: string | undefined): void {\n if (this.warmed || cwd === undefined) return\n this.warmed = true\n repoRegistry(this.ctx).discover(cwd, { ...this.options, cwd })\n }\n\n /** The cache key of one repository's container target. */\n private targetKey(repository: RepoContainerSpec): string {\n return [\n repository.hostWorkspaceRoot,\n repository.cli,\n repository.container ?? '',\n repository.sandbox ?? '',\n String(repository.ensureUp),\n ].join('\\u0000')\n }\n\n /** Drop one cached target, so the next command probes the container again. */\n private forgetTarget(key: string): void {\n this.targets.delete(key)\n }\n\n /** Resolve (once per repository) where commands run. */\n private containerTarget(key: string, repository: RepoContainerSpec, signal: AbortSignal): Promise<ContainerTarget> {\n const cached = this.targets.get(key)\n if (cached !== undefined) return cached\n const pending = resolveContainerTarget(repository, this.internals.run ?? runContainerCommand, signal)\n this.targets.set(key, pending)\n pending.catch(() => {\n // A failed probe must not cache its failure: the next command retries.\n if (this.targets.get(key) === pending) this.targets.delete(key)\n })\n return pending\n }\n}\n\nexport default DevcontainerShellExecutor\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,oBAAyC,IAAI,IAAI,qBAAqB;;;;;;AAO5E,MAAa,qBAAuD;CAClE,MAAM;CACN,qBAAqB;CACrB,UAAU;AACZ;;;;;;;;;;AAyBA,SAAgB,aACd,MACA,KACA,QACwB;CACxB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,GAAG;EACvD,IAAI,kBAAkB,IAAI,GAAG,GAAG;EAChC,QAAQ,OAAO;CACjB;CACA,OAAO;EACL,GAAG;EACH,GAAG,KAAK;EACR,GAAG;EACH,GAAG;CACL;AACF;;;;;;;AAQA,SAAgB,WAAW,OAAyB;CAClD,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,QAAO,SAAQ,SAAS,EAAE;CAClE,OAAO,MAAM,WAAW,IAAI,CAAC,WAAW,IAAI;AAC9C;;AAGA,SAAS,SAAS,KAAiD;CACjE,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,MAAgB;AAC5E;;AAGA,SAAS,MAAM,OAAuB;CACpC,OAAO,IAAI,MAAM,W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G;EACnC,IAAI,WAAW,KAAA,GAAW,OAAO;EACjC,MAAM,UAAU,uBAAuB,YAAY,KAAK,UAAU,OAAO,qBAAqB,MAAM;EACpG,KAAK,QAAQ,IAAI,KAAK,OAAO;EAC7B,QAAQ,YAAY;GAElB,IAAI,KAAK,QAAQ,IAAI,GAAG,MAAM,SAAS,KAAK,QAAQ,OAAO,GAAG;EAChE,CAAC;EACD,OAAO;CACT;AACF"}
|
|
1
|
+
{"version":3,"file":"shell.js","names":[],"sources":["../src/argv.ts","../src/shell.ts"],"sourcesContent":["/**\n * The argv one container-executed command becomes.\n *\n * Two shapes, one contract: the command runs under the configured Linux shell,\n * in the container directory that mirrors the host workdir, with ONLY the\n * environment this Bundle deliberately forwards. The host's `PATH`,\n * `SystemRoot`, and every other Windows entry stay out of the container — a\n * Linux `bash` reading a Windows `PATH` finds no binaries at all.\n *\n * @module @banzhe/dsh-devcontainer/argv\n */\n\nimport type { ContainerTarget } from './container.ts'\nimport { CONTAINER_MARKER_KEYS } from './refusal.ts'\nimport type { RepoContainerSpec } from './types.ts'\n\n/**\n * The host-side scheduling markers. They tell this Bundle's executor whose\n * command it is holding; inside the runtime they mean nothing, so they are\n * never forwarded.\n */\nconst INTERNAL_ENV_KEYS: ReadonlySet<string> = new Set(CONTAINER_MARKER_KEYS)\n\n/**\n * Terminal facts every container command gets. They replace what\n * `LocalBashExecutor` normally sets on the child: colors, pagers, and\n * interactive prompts have no place in captured tool output.\n */\nexport const BASE_CONTAINER_ENV: Readonly<Record<string, string>> = {\n TERM: 'dumb',\n GIT_TERMINAL_PROMPT: '0',\n NO_COLOR: '1',\n}\n\n/** One command's container argv inputs. */\nexport interface ExecArgvInput {\n /** The repository container specification. */\n readonly spec: RepoContainerSpec\n /** The resolved container target. */\n readonly target: ContainerTarget\n /** POSIX directory inside the container the command runs in. */\n readonly containerWorkdir: string\n /** The command source the model asked for. */\n readonly command: string\n /** Already-merged environment entries; only these reach the container. */\n readonly env: Readonly<Record<string, string>>\n}\n\n/**\n * Merge the container environment: base facts first, then the configuration's\n * `remoteEnv`, then the caller's own entries. Nothing from the host process\n * participates.\n * @param spec - the repository container specification.\n * @param env - the caller's ordinary environment entries.\n * @param dshEnv - the harness-managed `DSH_*` snapshot for this execution.\n * @returns the merged map, or `{}` when nothing is forwarded.\n */\nexport function containerEnv(\n spec: RepoContainerSpec,\n env?: Readonly<Record<string, string>>,\n dshEnv?: Readonly<Record<string, string>>,\n): Record<string, string> {\n const managed: Record<string, string> = {}\n for (const [key, value] of Object.entries(dshEnv ?? {})) {\n if (INTERNAL_ENV_KEYS.has(key)) continue\n managed[key] = value\n }\n return {\n ...BASE_CONTAINER_ENV,\n ...spec.remoteEnv,\n ...env,\n ...managed,\n }\n}\n\n/**\n * Split a configured shell into its program and any fixed arguments, so\n * `/bin/bash -l` reaches the container as two words followed by `-c`.\n * @param shell - the configured shell string.\n * @returns the program followed by its arguments; `/bin/bash` when empty.\n */\nexport function shellParts(shell: string): string[] {\n const parts = shell.trim().split(/\\s+/).filter(part => part !== '')\n return parts.length === 0 ? ['/bin/bash'] : parts\n}\n\n/** `-e KEY=VALUE` flags, sorted so one command always yields one argv. */\nfunction envFlags(env: Readonly<Record<string, string>>): string[] {\n return Object.keys(env).sort().map((key) => `${key}=${env[key] as string}`)\n}\n\n/** Single-quote one shell word, so an inner command survives unchanged. */\nfunction quote(value: string): string {\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\n/**\n * Assemble the argv for one command.\n * @param input - target, workdir, command, and the merged environment.\n * @returns the complete argv to hand to the subprocess seam.\n */\nexport function buildExecArgv(input: ExecArgvInput): readonly string[] {\n const { spec, target, containerWorkdir, command } = input\n const flags = envFlags(input.env)\n const user = spec.remoteUser\n switch (target.kind) {\n case 'docker':\n return [\n 'docker', 'exec', '-i', '-w', containerWorkdir,\n ...user === undefined ? [] : ['-u', user],\n ...flags.flatMap(entry => ['-e', entry]),\n target.containerId,\n ...shellParts(spec.shell), '-c', command,\n ]\n case 'devcontainer-cli':\n // `devcontainer exec` starts its own process, so the subdirectory has to be\n // entered by a POSIX shell wrapper inside the container.\n return [\n 'devcontainer', 'exec', '--workspace-folder', target.workspaceFolder,\n ...user === undefined ? [] : ['--remote-user', user],\n ...flags.flatMap(entry => ['--remote-env', entry]),\n '--', '/bin/sh', '-c', shellWrapper(input, []),\n ]\n case 'sbx':\n // `sbx exec` takes no environment flags on the sandbox CLI version this\n // Bundle targets, and it starts its own process, so both the workdir and the\n // environment are applied by the same POSIX wrapper: `env` sets the entries\n // for the shell about to replace the wrapper, and `exec` keeps the exit code\n // and signal of the real command.\n return [\n 'sbx', 'exec', target.sandboxName, '--', '/bin/sh', '-c',\n shellWrapper(input, envProgram(flags)),\n ]\n }\n}\n\n/**\n * The POSIX wrapper one sandbox or CLI command runs under.\n * @param input - the command and where it runs.\n * @param program - words that precede the shell (an `env` prefix, or nothing).\n * @returns the wrapper script.\n */\nfunction shellWrapper(input: ExecArgvInput, program: readonly string[]): string {\n const shell = [...program, ...shellParts(input.spec.shell).map(quote)].join(' ')\n return `cd -- ${quote(input.containerWorkdir)} && exec ${shell} -c ${quote(input.command)}`\n}\n\n/**\n * An `env` prefix carrying the merged environment, so a sandbox command sees the\n * same entries a `docker exec -e` would have given it.\n * @param flags - the sorted `KEY=VALUE` entries.\n * @returns the prefix words, or an empty list when nothing is forwarded.\n */\nfunction envProgram(flags: readonly string[]): string[] {\n return flags.length === 0 ? [] : ['env', ...flags.map(quote)]\n}\n","/**\n * Report a container-bound result as what it is: the host process was not\n * confined, because the container confines the command instead. Permission\n * bookkeeping therefore never attributes a host-sandbox denial to it.\n * @param execution - the handle returned for a `docker exec` run.\n * @returns the same handle, with its settled result stamped unconfined.\n */\nfunction stampUnconfined(execution: ShellExecution): ShellExecution {\n const base = execution.result.bind(execution)\n let stamped: Promise<ShellRunResult> | undefined\n execution.result = () => {\n stamped ??= base().then(result => ({ ...result, sandbox: { mode: 'danger-full-access' as const, denied: false } }))\n return stamped\n }\n return execution\n}\n\n/**\n * `ctx.shell` for repositories that declare a Dev Container, or run in a Docker\n * Sandbox.\n *\n * The executor IS the sandboxed local bash executor — same deadlines, same\n * output caps, same job/background semantics, same host-side confinement — with\n * two changes at the execution boundary:\n *\n * - {@link DevcontainerShellExecutor.resolve} reports the workdir as the\n * container's POSIX path, so `result.cwd` and every subsequent `workdir` the\n * model writes are Linux paths;\n * - {@link DevcontainerShellExecutor.execute} runs `docker exec` (or\n * `devcontainer exec`) instead of an in-process `bash -c`, from the HOST\n * repository root: `child_process` cannot chdir into `/workspaces/…`, which\n * does not exist on Windows.\n *\n * Everything outside a Dev Container repository keeps the LOCAL provider this\n * platform had before this Bundle existed — bash on POSIX, PowerShell on Windows\n * (`packages/shell/pwsh-local`). That is not cosmetic: on Windows the shipped\n * presets mount `tool-pwsh`, whose commands are PowerShell source, and a Windows\n * `bash` reading them would fail where it used to work.\n *\n * @module @banzhe/dsh-devcontainer/shell\n */\n\nimport { Context, type Volatile } from '@deepseek-ai/cordis'\nimport z from '@deepseek-ai/schemastery'\nimport { SandboxBashExecutor } from '@deepseek-ai/dsh-bash-sandbox'\nimport type { Config as LocalBashConfig } from '@deepseek-ai/dsh-bash-local'\nimport { ENCODING_PREAMBLE, resolvePwshPath } from '@deepseek-ai/dsh-pwsh-local'\nimport type { ShellExecRequest, ShellExecSpec, ShellExecution } from '@deepseek-ai/dsh-shell'\nimport { buildExecArgv, containerEnv } from './argv.ts'\nimport { resolveContainerTarget } from './container.ts'\nimport type { ContainerTarget } from './container.ts'\nimport { runContainerCommand } from './exec.ts'\nimport type { ContainerRun } from './exec.ts'\nimport { containerOptionFields, containerOptions } from './options.ts'\nimport { toContainerPath } from './paths.ts'\nimport {\n markedContainerOnly, markedPreset, markedVariantKind, refusalText, refusedExecution, sbxRefusalText,\n} from './refusal.ts'\nimport type { ShellRunResult } from '@deepseek-ai/dsh-shell'\nimport { liveHostMountRejections, liveSbxOptions, repoRegistry, warnOnce } from './registry.ts'\nimport { bindSbxMount, sandboxHostPathFor, sbxSpecFor, sbxWorkspaceRootFor } from './sbx.ts'\nimport type { SandboxHostAttribution } from './sbx.ts'\nimport type { ContainerOptions, RepoContainerSpec } from './types.ts'\nimport type { VariantKind } from './ids.ts'\n\n/** Plugin name used by the Loader row. */\nexport const name = 'devcontainer-shell'\n\n/** The seams this executor spawns and confines through. */\nexport const inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n/** The local shell used when a workdir belongs to no Dev Container repository. */\nexport type LocalShell = 'auto' | 'bash' | 'powershell'\n\n/**\n * Whether one container run failed because the container or sandbox is gone.\n *\n * A target is cached per repository, so a container that was restarted or\n * recreated shows up as these errors on the next command; the cache entry is\n * dropped so the following command re-probes instead of failing forever. The\n * sandbox half covers `sbx`: it reports a missing sandbox on stderr AND with\n * exit code 125, which is Docker's generic \"could not run the command\" status.\n * @param result - the settled foreground result.\n * @returns true when the failure is about the runtime itself.\n */\nfunction containerGone(result: ShellRunResult): boolean {\n if (result.exitCode === 0) return false\n if (result.exitCode === 125) return true\n return /no such container|is not running|cannot connect to the docker daemon|container .* is not running/i.test(result.stderr.text)\n || /no such sandbox|sandbox .* (?:not found|does not exist|is not running|is stopped|has stopped)/i.test(result.stderr.text)\n}\n\n/**\n * The host directory a sandbox-spelled workdir names.\n *\n * Only a Windows host maps a drive directory into its sandbox without the drive\n * colon, so only there does a container path need reversing: everywhere else a\n * sandbox mounts the directory at the absolute path it already has, which is the\n * workdir a caller wrote.\n * @param workdir - the directory the command named.\n * @returns the attribution, or undefined when the path names no host directory.\n */\nfunction sandboxHostAttribution(workdir: string): SandboxHostAttribution | undefined {\n return process.platform === 'win32' ? sandboxHostPathFor(workdir) : undefined\n}\n\n/** The local executor's knobs plus this Bundle's container options. */\nexport interface Config extends LocalBashConfig, ContainerOptions {\n /** Explicit pwsh executable for the Windows local fallback (empty = probe well-known paths). */\n pwshPath?: Volatile<string>\n /**\n * Local fallback shell (default `auto`: PowerShell on Windows, bash elsewhere).\n * `bash` keeps the inherited executor; `powershell` runs\n * `pwsh -NoProfile -Command`, the same invocation `@deepseek-ai/dsh-pwsh-local`\n * uses.\n */\n localShell?: LocalShell\n}\n\n/**\n * Mirrors `@deepseek-ai/dsh-bash-local`'s schema field for field — the inherited\n * `resolve()` validates these through `assertServiceableBashConfig` — and adds\n * the shared container options plus the local-fallback knobs.\n */\nconst ConfigSchema = z.object({\n cwd: z.string().volatile(),\n timeoutMs: z.number().default(120_000).volatile(),\n maxTimeoutMs: z.number().default(600_000).volatile(),\n maxOutputBytes: z.number().default(64_000).volatile(),\n maxSpillBytes: z.number().default(64 * 1024 * 1024).volatile(),\n graceMs: z.number().default(3_000).volatile(),\n pwshPath: z.string().default('').volatile(),\n localShell: z.union(['auto', 'bash', 'powershell'] as const).default('auto'),\n ...containerOptionFields(),\n})\n\n/** The row's schema, typed for callers; the loader reads the class's static copy. */\nexport const Config = ConfigSchema as unknown as z<Config>\n\n/**\n * Container-backed bash executor. Falls through to the platform's local shell\n * for every workdir that belongs to no Dev Container repository, so a session\n * that never touches such a repository behaves exactly like the provider this\n * Bundle replaced.\n */\nexport class DevcontainerShellExecutor extends SandboxBashExecutor {\n /**\n * The schema the Loader resolves this row's config through.\n *\n * It has to be a STATIC: the module's `default` export is this class, and the\n * Loader's `unwrapExports` hands Cordis the class itself — module-level exports\n * such as `Config` never reach it. Without this static the row would be mounted\n * with the inherited bash-local schema, silently dropping every container knob.\n */\n static override Config = ConfigSchema\n\n /**\n * The seams this executor spawns and confines through.\n *\n * This row REPLACES the sandboxed executor rather than the plain local one:\n * `ctx.shell.sandboxMode` is the capability fact permission presets read, and\n * an executor that cannot report one makes them refuse to compose at all.\n * Host-side commands therefore keep the confinement this platform shipped;\n * only a command that enters the container runs unconfined on the host,\n * because the container is what confines it.\n */\n static override inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n /** Test seam: replaces the host CLI runner. */\n internals: { run?: ContainerRun; localShell?: LocalShell; requireContainer?: boolean } = {}\n\n /** This row's own configuration (the inherited `config` is typed by the local executor). */\n private readonly ownConfig: Config\n\n /** The container options this row was configured with. */\n private readonly options: ContainerOptions\n\n /** One resolved target per repository, so a burst of commands probes Docker once. */\n private readonly targets = new Map<string, Promise<ContainerTarget>>()\n\n /** Whether the configured directory has been walked for a declaration yet. */\n private warmed = false\n\n constructor(ctx: Context, config: Config) {\n super(ctx, config)\n this.ownConfig = config\n this.options = containerOptions(config)\n ctx.effect(() => {\n const cache = repoRegistry(ctx)\n return () => { cache.reset() }\n })\n }\n\n /**\n * Report the container's POSIX workdir so the model sees Linux paths.\n *\n * Only an execution that must reach a container is rewritten. An ordinary\n * session in the same repository keeps host paths, because its commands keep\n * running on the host — reporting `/workspaces/…` for a command that never\n * enters a container would describe a directory that does not exist.\n * @param request - the caller's request.\n * @returns the resolved spec, with a container workdir when this execution is container-bound.\n */\n override resolve(request: ShellExecRequest): ShellExecSpec {\n const spec = super.resolve(request)\n if (!this.requiresContainer(request)) return spec\n const repository = this.locate(spec.workdir, markedVariantKind(spec.dshEnv))\n if (repository === undefined) return spec\n const workdir = toContainerPath(spec.workdir, repository)\n return workdir === spec.workdir ? spec : { ...spec, workdir }\n }\n\n /**\n * Run the command inside the repository's container, or through the platform's\n * local shell when the workdir belongs to no Dev Container repository.\n * @param spec - a resolved spec from {@link DevcontainerShellExecutor.resolve}.\n * @returns the prepared execution handle.\n */\n override async execute(spec: ShellExecSpec): Promise<ShellExecution> {\n // A repository that declares a container does not make every session run in\n // it: only a container-bound execution is routed there. An ordinary preset\n // keeps the platform shell it had, even with a `.devcontainer` in the tree.\n if (!this.requiresContainer(spec)) return this.executeLocal(spec)\n const kind = markedVariantKind(spec.dshEnv)\n const repository = this.locate(spec.workdir, kind)\n if (repository === undefined) {\n // A derived preset promises container execution. Falling back to the host\n // would hand the model a host result it reads as a Linux one, so the command\n // is refused instead of silently misdirected.\n const preset = this.presetOf(spec)\n return refusedExecution(spec, kind === 'sbx'\n ? sbxRefusalText(spec.workdir, preset)\n : refusalText(spec.workdir, preset))\n }\n const key = this.targetKey(repository)\n // The host process must start in a directory that exists on THIS host.\n const hostSpec: ShellExecSpec = { ...spec, workdir: repository.hostWorkspaceRoot }\n const execution = await this.executeArgv(hostSpec, async (signal) => {\n const target = await this.containerTarget(key, repository, signal)\n // A sandbox may mount the workspace under a path of its own, which only its\n // listing knows: the workdir is translated against the folder it reported.\n const bound = bindSbxMount(repository, target)\n return buildExecArgv({\n spec: bound,\n target,\n containerWorkdir: toContainerPath(spec.workdir, bound),\n command: spec.command,\n env: containerEnv(repository, spec.env, spec.dshEnv),\n })\n })\n // A container that was restarted or recreated out from under a cached target\n // must be re-probed rather than reported as a permanent failure.\n void execution.result().then(\n (result) => { if (containerGone(result)) this.forgetTarget(key) },\n () => { this.forgetTarget(key) },\n )\n return stampUnconfined(execution)\n }\n\n /**\n * The local fallback: the inherited bash path (host confinement included), or\n * the PowerShell invocation `@deepseek-ai/dsh-pwsh-local` uses on Windows,\n * wrapped through the provider `@deepseek-ai/dsh-pwsh-sandbox` used. Both keep\n * the inherited deadline, output, and cancellation mechanics.\n */\n private executeLocal(spec: ShellExecSpec): Promise<ShellExecution> {\n const localShell = this.internals.localShell ?? this.ownConfig.localShell ?? 'auto'\n const powershell = localShell === 'powershell' || (localShell === 'auto' && process.platform === 'win32')\n if (!powershell) return super.execute(spec)\n const argv = [\n resolvePwshPath(this.ownConfig.pwshPath?.get()),\n '-NoLogo', '-NoProfile', '-NonInteractive',\n '-Command', `${ENCODING_PREAMBLE}${spec.command}`,\n ]\n const policy = spec.sandboxPolicy\n // No policy, or one that asks for host-wide access: spawn as before. A\n // confining policy wraps the same argv the sandboxed pwsh executor wrapped.\n if (policy === undefined) return this.executeArgv(spec, argv)\n const { mode } = policy\n if (mode === 'danger-full-access') return this.executeArgv(spec, argv)\n return this.executeArgv(spec, async (signal) => {\n const prepared = await this.ctx.sandbox.confine(argv, { ...policy, mode }, signal)\n signal.throwIfAborted()\n return prepared.argv\n })\n }\n\n /** Whether this execution must reach a container or not run at all. */\n private requiresContainer(request: ShellExecRequest | ShellExecSpec): boolean {\n if (this.internals.requireContainer === true) return true\n if (this.options.requireContainer) return true\n return markedContainerOnly(request.dshEnv)\n }\n\n /** The preset id the marker carries, so the refusal can name it. */\n private presetOf(spec: ShellExecSpec): string | undefined {\n return markedPreset(spec.dshEnv)\n }\n\n /**\n * The repository container specification governing one workdir.\n *\n * A `(devContainer)` session needs a declaration: without one there is nowhere\n * to run, which is what the refusal above reports. A `(sbx)` session needs\n * none — a sandbox mounts the host workspace at its own path — so a directory\n * with no declaration is described by {@link sbxSpecFor} instead, and only a\n * missing host directory (no configured cwd to fall back on) stays unresolved.\n *\n * A sandbox-spelled workdir is reversed onto the host before the registry is\n * asked, because `/f/personal/repo` has no host ancestry of its own.\n * @param workdir - the directory the command names.\n * @param kind - the runtime the calling preset selects, when one does.\n * @returns the specification, or undefined when this directory cannot be run in.\n */\n private locate(workdir: string, kind: VariantKind | undefined): RepoContainerSpec | undefined {\n const cwd = this.config.cwd.get()\n this.warmUp(cwd)\n const registry = repoRegistry(this.ctx)\n const options = { ...this.options, cwd }\n // A (sbx) session names its workdir the way its sandbox spells it, and that\n // spelling has no host ancestry to walk: `/f/personal/repo` resolves to no\n // host repository on a Windows host, where the directory is\n // `F:\\personal\\repo`. The host directory is recovered first, so a command\n // that already carries a container path still finds its repository.\n const attributed = kind === 'sbx' ? sandboxHostAttribution(workdir) : undefined\n const declared = registry.locate(attributed?.host ?? workdir, options)\n if (kind !== 'sbx') return declared\n const root = this.sbxHostRootOf(workdir, cwd, declared, attributed)\n return root === undefined\n ? undefined\n : sbxSpecFor(root, liveSbxOptions(this.ctx, this.options), declared)\n }\n\n /**\n * The host directory a `(sbx)` session mounts for one workdir.\n *\n * A declaration wins, because a sandbox mounts the repository it was found in.\n * The directory the row was configured with comes next: that is the workspace\n * the sandbox was created around, and a workdir below it belongs to the same\n * mount. Only a row configured with no directory at all takes the workspace from\n * the workdir itself — the host directory a reported mount covers, else the\n * drive directory its sandbox spelling names — which is what makes a workdir of\n * `/f/personal/repo` reach the sandbox of `F:\\personal\\repo`.\n * @param workdir - the directory the command named.\n * @param cwd - the directory the row was configured with.\n * @param declared - the specification a declaration produced, when one exists.\n * @param attributed - the host directory the workdir's sandbox spelling names.\n * @returns the absolute host path to mount, or undefined when none can be named.\n */\n private sbxHostRootOf(\n workdir: string,\n cwd: string | undefined,\n declared: RepoContainerSpec | undefined,\n attributed: SandboxHostAttribution | undefined,\n ): string | undefined {\n if (declared !== undefined) return declared.hostWorkspaceRoot\n if (cwd !== undefined && cwd !== '') return cwd\n if (attributed !== undefined) return attributed.workspaceRoot ?? attributed.host\n return sbxWorkspaceRootFor(workdir, undefined, undefined)\n }\n\n /**\n * Discover the configured directory once, so a first call that already speaks\n * in container paths can still be attributed to its repository.\n */\n private warmUp(cwd: string | undefined): void {\n if (this.warmed || cwd === undefined) return\n this.warmed = true\n repoRegistry(this.ctx).discover(cwd, { ...this.options, cwd })\n }\n\n /** The cache key of one repository's container target. */\n private targetKey(repository: RepoContainerSpec): string {\n return [\n repository.hostWorkspaceRoot,\n repository.cli,\n repository.container ?? '',\n repository.sandbox ?? '',\n String(repository.ensureUp),\n ].join('\\u0000')\n }\n\n /** Drop one cached target, so the next command probes the container again. */\n private forgetTarget(key: string): void {\n this.targets.delete(key)\n }\n\n /** Resolve (once per repository) where commands run. */\n private containerTarget(key: string, repository: RepoContainerSpec, signal: AbortSignal): Promise<ContainerTarget> {\n const cached = this.targets.get(key)\n if (cached !== undefined) return cached\n for (const rejection of liveHostMountRejections(this.ctx)) {\n warnOnce(this.ctx, text => { this.ctx.logger.warn(text) }, rejection)\n }\n const pending = resolveContainerTarget(\n repository,\n this.internals.run ?? runContainerCommand,\n signal,\n message => { warnOnce(this.ctx, text => { this.ctx.logger.warn(text) }, message) },\n )\n this.targets.set(key, pending)\n pending.catch(() => {\n // A failed probe must not cache its failure: the next command retries.\n if (this.targets.get(key) === pending) this.targets.delete(key)\n })\n return pending\n }\n}\n\nexport default D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AAQ,IAAI,GAAG,MAAM,SAAS,KAAK,QAAQ,OAAO,GAAG;EAChE,CAAC;EACD,OAAO;CACT;AACF"}
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
* specification describes.
|
|
15
15
|
*/
|
|
16
16
|
type ContainerCli = 'auto' | 'devcontainer' | 'docker' | 'sbx';
|
|
17
|
+
/** How the Host row configures the extra read-only host paths a Docker Sandbox mounts. */
|
|
18
|
+
type HostMountsConfig = 'auto' | 'off' | readonly string[];
|
|
17
19
|
/** The options a Loader row contributes to discovery, before the file overrides them. */
|
|
18
20
|
interface ContainerOptions {
|
|
19
21
|
shell: string;
|
|
@@ -29,5 +31,5 @@ interface ContainerOptions {
|
|
|
29
31
|
requireContainer: boolean;
|
|
30
32
|
}
|
|
31
33
|
//#endregion
|
|
32
|
-
export { ContainerOptions as t };
|
|
33
|
-
//# sourceMappingURL=types-
|
|
34
|
+
export { HostMountsConfig as n, ContainerOptions as t };
|
|
35
|
+
//# sourceMappingURL=types-B2cQmBTx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-B2cQmBTx.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;;KAeY;;KAGA;;UAsEK;EACf;EACA,KAAK;EACL;EACA;;;;;;;EAOA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@banzhe/dsh-devcontainer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Run every agent command inside the repository's Linux Dev Container or a Docker Sandbox: a Docker/sbx-backed ctx.shell, a ctx.fs that delegates every file operation to a runtime-resident Node helper, a Linux prompt context, and devContainer / sbx agent-preset variants",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"@deepseek-ai/dsh-fs": "^0.2.1-alpha.2",
|
|
63
63
|
"@deepseek-ai/dsh-fs-local": "^0.2.1-alpha.2",
|
|
64
64
|
"@deepseek-ai/dsh-fs-sandbox": "^0.2.1-alpha.2",
|
|
65
|
+
"@deepseek-ai/dsh-home-paths": "^0.2.1-alpha.2",
|
|
65
66
|
"@deepseek-ai/dsh-ptc-runtime": "^0.2.1-alpha.2",
|
|
66
67
|
"@deepseek-ai/dsh-pwsh-local": "^0.2.1-alpha.2",
|
|
67
68
|
"@deepseek-ai/dsh-sandbox": "^0.2.1-alpha.2",
|
|
@@ -88,6 +89,7 @@
|
|
|
88
89
|
"@deepseek-ai/dsh-fs": "0.2.1-alpha.2",
|
|
89
90
|
"@deepseek-ai/dsh-fs-local": "0.2.1-alpha.2",
|
|
90
91
|
"@deepseek-ai/dsh-fs-sandbox": "0.2.1-alpha.2",
|
|
92
|
+
"@deepseek-ai/dsh-home-paths": "0.2.1-alpha.2",
|
|
91
93
|
"@deepseek-ai/dsh-ptc-runtime": "0.2.1-alpha.2",
|
|
92
94
|
"@deepseek-ai/dsh-pwsh-local": "0.2.1-alpha.2",
|
|
93
95
|
"@deepseek-ai/dsh-sandbox": "0.2.1-alpha.2",
|
package/lib/exec-CKAAz2zz.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exec-CKAAz2zz.js","names":[],"sources":["../src/container.ts","../src/exec.ts"],"sourcesContent":["/**\n * Finding or starting the repository's container.\n *\n * Three drivers, in the order `cli: 'auto'` tries them:\n *\n * 1. an explicit `container` / `containerName` from the configuration;\n * 2. a running container the Dev Container CLI labelled with\n * `devcontainer.local_folder=<host root>`, which needs no CLI of our own;\n * 3. `devcontainer up`, which builds and starts the container from the\n * configuration and reports the container id it produced.\n *\n * @module @banzhe/dsh-devcontainer/container\n */\n\nimport type { ContainerRun } from './exec.ts'\nimport { toPosixSlashes } from './paths.ts'\nimport { resolveSbxTarget } from './sbx.ts'\nimport type { RepoContainerSpec } from './types.ts'\n\n/** Where agent commands run. */\nexport type ContainerTarget =\n | { readonly kind: 'docker'; readonly containerId: string; readonly workspaceFolder: string }\n | { readonly kind: 'devcontainer-cli'; readonly workspaceFolder: string }\n | { readonly kind: 'sbx'; readonly sandboxName: string; readonly workspaceFolder: string }\n\n/** Label the Dev Container CLI stamps on every container it creates. */\nexport const CONTAINER_FOLDER_LABEL = 'devcontainer.local_folder'\n\nconst PS_FORMAT = '{{.ID}}\\t{{.Label \"devcontainer.local_folder\"}}'\n\n/** Compare two host folders as one repository, folding separators and win32 case. */\nfunction sameFolder(left: string, right: string): boolean {\n return toPosixSlashes(left).replace(/\\/+$/, '').toLowerCase()\n === toPosixSlashes(right).replace(/\\/+$/, '').toLowerCase()\n}\n\n/**\n * Find the running container the Dev Container CLI started for this repository.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe.\n * @returns the container id, or undefined when none is running (or Docker is absent).\n */\nexport async function findRunningContainer(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<string | undefined> {\n const result = await run(\n ['docker', 'ps', '--filter', `label=${CONTAINER_FOLDER_LABEL}`, '--format', PS_FORMAT],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n if (result.exitCode !== 0) return undefined\n for (const line of result.stdout.split('\\n')) {\n const [id, folder] = line.split('\\t')\n if (id === undefined || folder === undefined) continue\n if (id.trim() === '' || folder.trim() === '') continue\n if (sameFolder(folder.trim(), spec.hostWorkspaceRoot)) return id.trim()\n }\n return undefined\n}\n\n/**\n * Read the container id out of `devcontainer up` output (its last JSON line).\n * @param stdout - the CLI's standard output.\n * @returns the container id, or undefined when the output carries none.\n */\nexport function parseUpOutput(stdout: string): string | undefined {\n const lines = stdout.split('\\n').map(line => line.trim()).filter(line => line.startsWith('{'))\n for (const line of lines.reverse()) {\n try {\n const parsed: unknown = JSON.parse(line)\n if (typeof parsed === 'object' && parsed !== null) {\n const { containerId } = parsed as { containerId?: unknown }\n if (typeof containerId === 'string' && containerId !== '') return containerId\n }\n } catch {\n // A non-JSON line is progress output, not the result envelope.\n }\n }\n return undefined\n}\n\n/**\n * Build and start the repository's container through the Dev Container CLI.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the CLI call.\n * @returns the produced container id when the CLI reported one.\n * @throws Error when the CLI failed and reported no container.\n */\nexport async function startContainer(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<{ containerId?: string; workspaceFolder: string }> {\n const result = await run(\n ['devcontainer', 'up', '--workspace-folder', spec.hostWorkspaceRoot],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n const containerId = parseUpOutput(result.stdout)\n if (result.exitCode !== 0 && containerId === undefined) {\n const detail = (result.stderr.trim() || result.stdout.trim() || 'no output').split('\\n').slice(-3).join(' ')\n throw new Error(`devcontainer: \"${spec.configPath}\": devcontainer up failed for ${spec.hostWorkspaceRoot}: ${detail}`)\n }\n return {\n ...containerId === undefined ? {} : { containerId },\n workspaceFolder: spec.hostWorkspaceRoot,\n }\n}\n\n/**\n * Resolve the container agent commands run in.\n *\n * `cli: 'sbx'` is not a container at all: a Docker Sandbox mounts the host\n * workspace at its own absolute path, so it is discovered and started by\n * {@link resolveSbxTarget} instead of by the Dev Container drivers below.\n * @param spec - the repository container specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe / start sequence.\n * @returns the docker target when a container id is known, else the CLI or sandbox target.\n * @throws Error when `cli: 'docker'` was demanded and no container is running, or `sbx` cannot be prepared.\n */\nexport async function resolveContainerTarget(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<ContainerTarget> {\n if (spec.cli === 'sbx') return await resolveSbxTarget(spec, run, signal)\n if (spec.container !== undefined) {\n return { kind: 'docker', containerId: spec.container, workspaceFolder: spec.containerWorkspaceFolder }\n }\n if (spec.cli !== 'devcontainer') {\n const running = await findRunningContainer(spec, run, signal)\n if (running !== undefined) {\n return { kind: 'docker', containerId: running, workspaceFolder: spec.containerWorkspaceFolder }\n }\n if (spec.cli === 'docker') {\n throw new Error('devcontainer: \"' + spec.configPath + '\": cli is \"docker\" but no running container carries '\n + `${CONTAINER_FOLDER_LABEL}=${spec.hostWorkspaceRoot}; start it or set cli: \"auto\"`)\n }\n }\n if (spec.ensureUp) {\n const started = await startContainer(spec, run, signal)\n if (started.containerId !== undefined) {\n return {\n kind: 'docker',\n containerId: started.containerId,\n workspaceFolder: spec.containerWorkspaceFolder,\n }\n }\n return { kind: 'devcontainer-cli', workspaceFolder: started.workspaceFolder }\n }\n return { kind: 'devcontainer-cli', workspaceFolder: spec.hostWorkspaceRoot }\n}\n","/**\n * The one place this Bundle starts a host process: the Docker / Dev Container\n * CLI probes that find or start the container, and the `docker exec` that runs\n * the agent's command. Kept behind an interface so the container argv logic is\n * testable without a Docker daemon.\n * @module @banzhe/dsh-devcontainer/exec\n */\n\nimport { execFile } from 'node:child_process'\nimport { SENSITIVE_ENV_PATTERN } from '@deepseek-ai/dsh-subprocess'\n\n/** One finished CLI call. */\nexport interface ContainerCommandResult {\n readonly stdout: string\n readonly stderr: string\n /** Exit code, or null when the CLI could not be started at all. */\n readonly exitCode: number | null\n}\n\n/** Options for one CLI call. */\nexport interface ContainerCommandOptions {\n readonly signal?: AbortSignal | undefined\n readonly timeoutMs?: number | undefined\n readonly cwd?: string | undefined\n}\n\n/** Runs one host CLI command and resolves with its output. */\nexport type ContainerRun = (argv: readonly string[], options?: ContainerCommandOptions) => Promise<ContainerCommandResult>\n\n/**\n * Cap for one probe's captured output. The agent's own commands do not come\n * through here — they run through the subprocess seam, which streams and caps\n * them — so this only has to hold `devcontainer up`'s build log.\n */\nconst MAX_CLI_OUTPUT_BYTES = 32 * 1024 * 1024\n\n/**\n * The parent variables a Docker / Dev Container CLI is started with.\n *\n * The CLI is a host program the harness runs on the user's behalf, not a proxy\n * for the session: starting it with the ambient environment would hand the\n * harness's own credentials, the session's `DSH_*` facts, and every unrelated\n * host-only variable to a build that the container's `Dockerfile` can read.\n * Only the names below survive, because the CLI itself needs each one:\n * executable lookup and the platform runtime, the per-user Docker configuration\n * under `HOME`/`APPDATA` (where the credential helper is named), scratch space,\n * locale, and proxy routing.\n */\nconst CONTAINER_CLI_ENV_NAMES: readonly string[] = [\n 'PATH', 'PATHEXT', 'SYSTEMROOT', 'SYSTEMDRIVE', 'WINDIR', 'COMSPEC',\n 'HOME', 'USERPROFILE', 'HOMEDRIVE', 'HOMEPATH', 'APPDATA', 'LOCALAPPDATA',\n 'PROGRAMDATA', 'PROGRAMFILES', 'PROGRAMFILES(X86)', 'PROGRAMW6432',\n 'TEMP', 'TMP', 'TMPDIR',\n 'LANG', 'LANGUAGE', 'LC_ALL', 'LC_CTYPE', 'TZ',\n 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY', 'ALL_PROXY',\n]\n\n/** Families the CLIs own end to end; a user's Docker/XDG settings belong to them. */\nconst CONTAINER_CLI_ENV_PREFIXES: readonly string[] = ['DOCKER_', 'XDG_']\n\n/**\n * The environment one Docker / Dev Container CLI call is started with.\n *\n * Names are matched case-insensitively because Windows environment names are,\n * and a credential-shaped name is dropped even when it is otherwise listed (see\n * `SENSITIVE_ENV_PATTERN`, the one heuristic every in-repo spawner shares).\n * @param parent - the environment to filter; the host process environment by default.\n * @returns a fresh environment object, safe to hand to `execFile`.\n */\nexport function containerCliEnv(parent: NodeJS.ProcessEnv = process.env): Record<string, string> {\n const allowed = new Set(CONTAINER_CLI_ENV_NAMES)\n const env: Record<string, string> = {}\n for (const [name, value] of Object.entries(parent)) {\n if (value === undefined || SENSITIVE_ENV_PATTERN.test(name)) continue\n const folded = name.toUpperCase()\n if (!allowed.has(folded) && !CONTAINER_CLI_ENV_PREFIXES.some(prefix => folded.startsWith(prefix))) continue\n env[name] = value\n }\n return env\n}\n\n/**\n * Run one CLI command without a shell, capturing bounded output.\n * @param argv - program and arguments, never shell-interpreted.\n * @param options - cancellation, timeout, and working directory.\n * @returns the captured result; a missing program is reported as `exitCode: null`.\n */\nexport const runContainerCommand: ContainerRun = (argv, options = {}) => {\n const [program, ...args] = argv\n if (program === undefined) return Promise.reject(new Error('devcontainer: empty command'))\n return new Promise((resolvePromise, reject) => {\n execFile(program, args, {\n encoding: 'utf8',\n maxBuffer: MAX_CLI_OUTPUT_BYTES,\n windowsHide: true,\n env: containerCliEnv(),\n // `signal` kills the child on abort; naming the signal keeps the kill\n // deterministic instead of relying on the platform default.\n killSignal: 'SIGTERM',\n ...options.signal === undefined ? {} : { signal: options.signal },\n ...options.timeoutMs === undefined ? {} : { timeout: options.timeoutMs },\n ...options.cwd === undefined ? {} : { cwd: options.cwd },\n }, (error, stdout, stderr) => {\n if (error !== null && options.signal?.aborted === true) {\n reject(options.signal.reason instanceof Error ? options.signal.reason : new Error('devcontainer: command aborted'))\n return\n }\n const exitCode = error === null\n ? 0\n : typeof error.code === 'number' ? error.code : null\n resolvePromise({ stdout, stderr, exitCode })\n })\n })\n}\n"],"mappings":";;;;;AA0BA,MAAa,yBAAyB;AAEtC,MAAM,YAAY;;AAGlB,SAAS,WAAW,MAAc,OAAwB;CACxD,OAAO,eAAe,IAAI,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC,YAAY,MACtD,eAAe,KAAK,CAAC,CAAC,QAAQ,QAAQ,EAAE,CAAC,CAAC,YAAY;AAC9D;;;;;;;;AASA,eAAsB,qBACpB,MACA,KACA,QAC6B;CAC7B,MAAM,SAAS,MAAM,IACnB;EAAC;EAAU;EAAM;EAAY,SAAS;EAA0B;EAAY;CAAS,GACrF;EAAE,GAAG,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,OAAO;EAAG,WAAW,KAAK;CAAmB,CAClF;CACA,IAAI,OAAO,aAAa,GAAG,OAAO,KAAA;CAClC,KAAK,MAAM,QAAQ,OAAO,OAAO,MAAM,IAAI,GAAG;EAC5C,MAAM,CAAC,IAAI,UAAU,KAAK,MAAM,GAAI;EACpC,IAAI,OAAO,KAAA,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ts","../src/refusal.ts","../src/jsonc.ts","../src/config-loader.ts","../src/registry.ts","../src/sbx.ts"],"sourcesContent":["/**\n * The configuration fields every row of this Bundle shares. The three rows are\n * separate Cordis plugins (one service each), and a repository's own file may\n * override each of these per repository — the row's value is only the default\n * discovery applies.\n * @module @banzhe/dsh-devcontainer/options\n */\n\nimport z from '@deepseek-ai/schemastery'\nimport type { ContainerOptions } from './types.ts'\n\n/** Defaults for {@link ContainerOptions}. */\nexport const CONTAINER_OPTION_DEFAULTS: ContainerOptions = {\n shell: '/bin/bash',\n cli: 'auto',\n ensureUp: true,\n containerTimeoutMs: 300_000,\n requireContainer: false,\n}\n\n/**\n * Apply {@link CONTAINER_OPTION_DEFAULTS} to a possibly-partial configuration, so\n * a programmatic `apply()` behaves like a Loader row whose schema already filled\n * the defaults in.\n * @param config - the row's configuration, or nothing.\n * @returns the complete container options.\n */\nexport function containerOptions(config: Partial<ContainerOptions> = {}): ContainerOptions {\n return {\n shell: config.shell ?? CONTAINER_OPTION_DEFAULTS.shell,\n cli: config.cli ?? CONTAINER_OPTION_DEFAULTS.cli,\n ensureUp: config.ensureUp ?? CONTAINER_OPTION_DEFAULTS.ensureUp,\n containerTimeoutMs: config.containerTimeoutMs ?? CONTAINER_OPTION_DEFAULTS.containerTimeoutMs,\n requireContainer: config.requireContainer ?? CONTAINER_OPTION_DEFAULTS.requireContainer,\n }\n}\n\n/**\n * The shared Schemastery fields, spread into each row's `Config` so the three\n * rows cannot drift apart. `cli` is `auto`: an explicit container wins, the\n * running-container label lookup comes next, and the Dev Container CLI is the\n * fallback that can start the container. `sbx` selects the Docker Sandbox\n * driver, which mounts the host workspace instead of reading a declaration.\n * @returns schemastery fields for {@link ContainerOptions}.\n */\nexport function containerOptionFields() {\n return {\n shell: z.string().default(CONTAINER_OPTION_DEFAULTS.shell),\n cli: z.union(['auto', 'devcontainer', 'docker', 'sbx'] as const).default(CONTAINER_OPTION_DEFAULTS.cli),\n ensureUp: z.boolean().default(CONTAINER_OPTION_DEFAULTS.ensureUp),\n containerTimeoutMs: z.number().default(CONTAINER_OPTION_DEFAULTS.containerTimeoutMs),\n requireContainer: z.boolean().default(CONTAINER_OPTION_DEFAULTS.requireContainer),\n }\n}\n\n/** The two preset-source lists, which only the Host row owns. */\nexport interface PresetSourceOptions {\n /** Preset ids to derive a `… (devContainer)` variant from. */\n sources: readonly string[]\n /** Preset ids to derive a `… (sbx)` variant from. */\n sbxSources: readonly string[]\n}\n\n/** Defaults for {@link PresetSourceOptions}: nothing is derived until asked for. */\nexport const PRESET_SOURCE_DEFAULTS: PresetSourceOptions = {\n sources: [],\n sbxSources: [],\n}\n\n/**\n * The two preset-source fields as the Loader validates them.\n *\n * They are `volatile`, so a settings write lands in the live reference the Host\n * row reads on its next sync instead of needing a reload, and they are defaults\n * of the Host row only: the shell and filesystem rows have no preset set.\n * @returns schemastery fields for {@link PresetSourceOptions}.\n */\nexport function presetSourceFields() {\n return {\n sources: z.array(z.string()).default([]).volatile(),\n sbxSources: z.array(z.string()).default([]).volatile(),\n }\n}\n","/**\n * Two-way translation between the host workspace path a session carries and the\n * POSIX path the same directory has inside the container.\n *\n * The model writes container paths (`/workspaces/repo/src`), and on Windows it\n * sometimes writes them after something win32 resolved the leading slash into a\n * drive (`F:\\\\workspaces\\\\repo\\\\src`); the host hands over native paths with\n * either separator style. Every function here is pure and idempotent: a value it\n * cannot attribute to the repository comes back unchanged.\n * @module @banzhe/dsh-devcontainer/paths\n */\n\nimport { posix, win32 } from 'node:path'\nimport type { RepoContainerSpec } from './types.ts'\n\nconst DRIVE_PREFIX = /^[A-Za-z]:[\\\\/]/\nconst UNC_PREFIX = /^\\\\\\\\/\n\n/**\n * Whether a path is written in Windows form (drive letter or UNC share).\n * @param path - the path to classify.\n * @returns true for `F:\\\\x`, `f:/x`, and `\\\\\\\\server\\\\share`.\n */\nexport function isWindowsPath(path: string): boolean {\n return DRIVE_PREFIX.test(path) || UNC_PREFIX.test(path)\n}\n\n/** Replace every backslash with a forward slash. */\nexport function toPosixSlashes(path: string): string {\n return path.replaceAll('\\\\', '/')\n}\n\n/**\n * Whether a path is a POSIX-absolute path rather than a host path. A bare\n * `/workspaces/x` is what the model writes; the win32 module also calls it\n * absolute, so callers must consult the container mount point first.\n * @param path - the path to classify.\n * @returns true when the path starts at the POSIX root.\n */\nexport function isPosixAbsolute(path: string): boolean {\n return path.startsWith('/') && !isWindowsPath(path)\n}\n\n/**\n * Which path module owns this host root.\n * @param hostRoot - an absolute host directory.\n * @returns `'win32'` for a drive/UNC root, `'posix'` otherwise.\n */\nexport function hostPathStyle(hostRoot: string): 'win32' | 'posix' {\n return isWindowsPath(hostRoot) ? 'win32' : 'posix'\n}\n\n/** Normalize a host root into its native absolute spelling. */\nexport function normalizeHostRoot(hostRoot: string): string {\n return hostPathStyle(hostRoot) === 'win32' ? win32.resolve(hostRoot) : posix.resolve(hostRoot)\n}\n\n/** Join a POSIX relative path onto a host root using that root's separator style. */\nexport function joinHostRoot(hostRoot: string, relative: string): string {\n return hostPathStyle(hostRoot) === 'win32'\n ? win32.join(hostRoot, toPosixSlashes(relative))\n : posix.join(hostRoot, relative)\n}\n\n/**\n * The mount point the Dev Container specification uses when the configuration\n * omits `workspaceFolder`: `/workspaces/<basename of the repository root>`.\n * @param hostRoot - the absolute host repository root.\n * @returns the POSIX mount point.\n */\nexport function defaultContainerWorkspaceFolder(hostRoot: string): string {\n const base = hostPathStyle(hostRoot) === 'win32' ? win32.basename(hostRoot) : posix.basename(hostRoot)\n return posix.join('/workspaces', base === '' ? 'workspace' : base)\n}\n\n/**\n * Match a path against a container mount point.\n * @param path - candidate path, in either separator style.\n * @param folder - the container mount point.\n * @returns the POSIX remainder (`''` for the mount point itself), or undefined when the path is elsewhere.\n */\nexport function containerRemainder(path: string, folder: string): string | undefined {\n const normalized = posix.normalize(toPosixSlashes(path))\n const root = posix.normalize(toPosixSlashes(folder))\n if (normalized === root) return ''\n const prefix = root.endsWith('/') ? root : `${root}/`\n return normalized.startsWith(prefix) ? normalized.slice(prefix.length) : undefined\n}\n\n/** The spellings a model-supplied container path may have degraded into. */\nfunction containerCandidates(path: string): string[] {\n const candidates = [toPosixSlashes(path)]\n if (DRIVE_PREFIX.test(path)) candidates.push(toPosixSlashes(path).slice(2))\n return candidates\n}\n\n/**\n * Whether the path names something inside the repository's container mount.\n * @param path - candidate path, in either separator style.\n * @param spec - the repository container specification.\n * @returns true when the path is the mount point or lies under it.\n */\nexport function isPathInsideContainer(path: string, spec: RepoContainerSpec): boolean {\n return containerCandidates(path).some(candidate => containerRemainder(candidate, spec.containerWorkspaceFolder) !== undefined)\n}\n\n/**\n * The POSIX relative path from a host root, or undefined when the path escapes it.\n * Comparison folds case on win32 (drive letters and Windows paths are\n * case-insensitive) and preserves it elsewhere.\n * @param path - candidate host path.\n * @param hostRoot - the absolute host repository root.\n * @returns the relative path (`''` for the root itself), or undefined when it is outside.\n */\nexport function relativeWithinHostRoot(path: string, hostRoot: string): string | undefined {\n const style = hostPathStyle(hostRoot)\n const module = style === 'win32' ? win32 : posix\n const absolutePath = toPosixSlashes(module.resolve(path))\n const absoluteRoot = toPosixSlashes(module.resolve(hostRoot))\n const folder = (value: string): string => (style === 'win32' ? value.toLowerCase() : value)\n const foldedPath = folder(absolutePath)\n const foldedRoot = folder(absoluteRoot)\n if (foldedPath === foldedRoot) return ''\n const prefix = foldedRoot.endsWith('/') ? foldedRoot : `${foldedRoot}/`\n if (!foldedPath.startsWith(prefix)) return undefined\n return absolutePath.slice(prefix.length)\n}\n\n/**\n * Join a relative path onto a mount point, in that mount's own style.\n *\n * A Dev Container mount is POSIX, so this is `posix.join` for every container.\n * A Docker Sandbox mounts the host directory under its own absolute path, so its\n * mount point can be a Windows path, and joining it as POSIX would produce the\n * mixed `F:\\\\repo/src` spelling no shell on either side accepts.\n * @param folder - the mount point.\n * @param relative - the relative path inside it.\n * @returns the joined path, using the mount point's separator style.\n */\nexport function joinMount(folder: string, relative: string): string {\n return isWindowsPath(folder) ? joinHostRoot(folder, relative) : posix.join(folder, toPosixSlashes(relative))\n}\n\n/**\n * Translate one model/plugin-supplied path into the container's POSIX view.\n * @param path - a host path, a mixed-separator host path, an already-container\n * path, or a path relative to the mount point.\n * @param spec - the repository container specification.\n * @returns the POSIX container path; a path outside the repository comes back slash-normalized.\n */\nexport function toContainerPath(path: string, spec: RepoContainerSpec): string {\n const folder = spec.containerWorkspaceFolder\n if (path === '') return folder\n for (const candidate of containerCandidates(path)) {\n const remainder = containerRemainder(candidate, folder)\n if (remainder !== undefined) return remainder === '' ? folder : joinMount(folder, remainder)\n }\n if (!isWindowsPath(path) && !path.startsWith('/')) {\n // A relative path is resolved against the mount point, and one that climbs\n // out of it must not silently land somewhere else in the container: it comes\n // back unchanged so the failure is visible.\n const normalized = posix.normalize(toPosixSlashes(path))\n if (normalized === '..' || normalized.startsWith('../')) return path\n return normalized === '.' ? folder : joinMount(folder, normalized)\n }\n // A path that is absolute in some namespace is translated only when it is a\n // host path of this repository. A POSIX path this mount does not hold belongs\n // to the container's own namespace, and re-basing it onto the mount would\n // invent a path no caller named; it comes back unchanged so the mount check\n // can refuse it.\n const relative = relativeWithinHostRoot(path, spec.hostWorkspaceRoot)\n if (relative === undefined) return toPosixSlashes(path)\n return relative === '' ? folder : joinMount(folder, relative)\n}\n\n/**\n * Translate one container path back into the host path of the bind mount.\n * @param path - a container path, a drive-mangled container path, a host path, or a relative path.\n * @param spec - the repository container specification.\n * @returns the native host path inside the repository, or `path` unchanged when it is not container-side.\n */\nexport function toHostPath(path: string, spec: RepoContainerSpec): string {\n for (const candidate of containerCandidates(path)) {\n const remainder = containerRemainder(candidate, spec.containerWorkspaceFolder)\n if (remainder === undefined) continue\n return remainder === '' ? normalizeHostRoot(spec.hostWorkspaceRoot) : joinHostRoot(spec.hostWorkspaceRoot, remainder)\n }\n return path\n}\n","/**\n * The suffixes and display labels that mark a derived preset, shared by both\n * halves of the Bundle.\n *\n * Two independent tracks exist: a `… (devContainer)` variant for repositories\n * that declare a Dev Container, and a `… (sbx)` variant for Docker Sandbox\n * (`sbx`) sessions. They differ only in the suffix, the label, and the\n * `DSH_*` marker the shell row injects; everything else about a derived preset\n * is identical, so one module owns the naming for both.\n *\n * The browser half needs these to keep derived presets out of its own picker\n * list, and must not import the Host modules to get them: this file has no\n * imports.\n */\n\n/** Appended to a source preset id to name its Dev Container variant. */\nexport const DEVCONTAINER_VARIANT_SUFFIX = '-devcontainer'\n\n/** Appended to a source preset id to name its Docker Sandbox variant. */\nexport const SBX_VARIANT_SUFFIX = '-sbx'\n\n/** Appended to a source preset's display name for the Dev Container variant. */\nexport const DEVCONTAINER_NAME_SUFFIX = ' (devContainer)'\n\n/** Appended to a source preset's display name for the Docker Sandbox variant. */\nexport const SBX_NAME_SUFFIX = ' (sbx)'\n\n/** Which runtime a derived preset targets. */\nexport type VariantKind = 'devcontainer' | 'sbx'\n\n/** Every kind, in the order the planner emits them. */\nexport const VARIANT_KINDS: readonly VariantKind[] = ['devcontainer', 'sbx']\n\n/**\n * The id suffix of one track.\n * @param kind - the track.\n * @returns `-devcontainer` or `-sbx`.\n */\nexport function variantSuffixOf(kind: VariantKind): string {\n return kind === 'sbx' ? SBX_VARIANT_SUFFIX : DEVCONTAINER_VARIANT_SUFFIX\n}\n\n/**\n * The display-name suffix of one track.\n * @param kind - the track.\n * @returns ` (devContainer)` or ` (sbx)`.\n */\nexport function variantNameSuffixOf(kind: VariantKind): string {\n return kind === 'sbx' ? SBX_NAME_SUFFIX : DEVCONTAINER_NAME_SUFFIX\n}\n\n/**\n * The derived id of one source preset on one track.\n * @param source - the source preset id.\n * @param kind - the track the variant belongs to.\n * @returns the variant id.\n */\nexport function variantIdOf(source: string, kind: VariantKind): string {\n return `${source}${variantSuffixOf(kind)}`\n}\n\n/**\n * The track one variant id belongs to.\n * @param id - any preset id.\n * @returns the track, or undefined when the id names no derived preset.\n */\nexport function variantKindOf(id: string): VariantKind | undefined {\n // The Dev Container suffix is checked first: it is the older of the two, and\n // no id can carry both.\n if (id.endsWith(DEVCONTAINER_VARIANT_SUFFIX)) return 'devcontainer'\n if (id.endsWith(SBX_VARIANT_SUFFIX)) return 'sbx'\n return undefined\n}\n\n/**\n * Whether an id names a `… (devContainer)` preset.\n * @param id - any preset id.\n * @returns true when the id carries the Dev Container suffix.\n */\nexport function isDevcontainerVariantId(id: string): boolean {\n return id.endsWith(DEVCONTAINER_VARIANT_SUFFIX)\n}\n\n/**\n * Whether an id names a `… (sbx)` preset.\n * @param id - any preset id.\n * @returns true when the id carries the Docker Sandbox suffix.\n */\nexport function isSbxVariantId(id: string): boolean {\n return id.endsWith(SBX_VARIANT_SUFFIX)\n}\n\n/**\n * Whether an id names a preset this Bundle derived, on either track.\n * @param id - any preset id.\n * @returns true when the id carries either variant suffix.\n */\nexport function isAnyVariantId(id: string): boolean {\n return variantKindOf(id) !== undefined\n}\n","/**\n * The refusal boundary for a `(devContainer)` preset in a repository that\n * declares no container.\n *\n * A derived preset promises \"every command runs in the container\". When the\n * repository has no configuration, silently running the command on the host\n * breaks that promise in the worst way: the model still believes it is in Linux,\n * so it writes Linux commands and reads their host-side failures as its own\n * mistakes. So the executor refuses instead, and the prompt says why before the\n * first command is even attempted.\n *\n * The marker travels in the managed `DSH_*` environment: `ctx.shellEnv`'s\n * contributor resolves the calling agent's preset for every shell call, and the\n * shell tools hand that snapshot to the executor as `dshEnv`. The executor\n * therefore never has to guess whose command this is.\n *\n * A filesystem call carries no such snapshot, and its own refusal is worse than\n * a misdirected command: reading or writing the host leaves a real file changed\n * while the model still believes it is in the container. {@link callingContainerPreset}\n * answers the same question from the one fact the composition does expose — the\n * Agent that initiated the current asynchronous chain — and\n * {@link fsRefusalText} is the diagnostic the filesystem row raises.\n *\n * The same two facts decide WHICH runtime a session is bound to: a\n * `(devContainer)` preset marks its commands with `DSH_DEVCONTAINER`, a `(sbx)`\n * preset with `DSH_SBX`. {@link markedVariantKind} and {@link callingVariantKind}\n * read that back, so the shell, filesystem, subprocess, and PTC seams each route\n * a call without asking four different questions.\n * @module @banzhe/dsh-devcontainer/refusal\n */\n\nimport type { Context } from '@deepseek-ai/cordis'\nimport { DSH_ENV_PREFIX } from '@deepseek-ai/dsh-shell'\nimport type {\n CollectedOutput, DshEnvironment, ShellExecSpec, ShellExecution, ShellProcessRead, ShellRunResult,\n} from '@deepseek-ai/dsh-shell'\nimport { variantKindOf } from './ids.ts'\nimport type { VariantKind } from './ids.ts'\n\n/** The managed `DSH_*` variable that marks a command issued from a derived preset. */\nexport const DEVCONTAINER_ENV_KEY = `${DSH_ENV_PREFIX}DEVCONTAINER` as `${typeof DSH_ENV_PREFIX}DEVCONTAINER`\n\n/** Its only value: present means \"this command must reach a container\". */\nexport const DEVCONTAINER_ENV_VALUE = '1'\n\n/** The preset id that set the marker, so a refusal can name it. */\nexport const DEVCONTAINER_PRESET_ENV_KEY = `${DSH_ENV_PREFIX}DEVCONTAINER_PRESET` as `${typeof DSH_ENV_PREFIX}DEVCONTAINER_PRESET`\n\n/** The managed `DSH_*` variable that marks a command issued from a `(sbx)` preset. */\nexport const SBX_ENV_KEY = `${DSH_ENV_PREFIX}SBX` as `${typeof DSH_ENV_PREFIX}SBX`\n\n/** Its only value: present means \"this command must reach the Docker Sandbox\". */\nexport const SBX_ENV_VALUE = '1'\n\n/** The preset id that set the sandbox marker, so a diagnostic can name it. */\nexport const SBX_PRESET_ENV_KEY = `${DSH_ENV_PREFIX}SBX_PRESET` as `${typeof DSH_ENV_PREFIX}SBX_PRESET`\n\n/** Every scheduling marker this Bundle owns; none of them is forwarded into a runtime. */\nexport const CONTAINER_MARKER_KEYS: readonly string[] = [\n DEVCONTAINER_ENV_KEY, DEVCONTAINER_PRESET_ENV_KEY, SBX_ENV_KEY, SBX_PRESET_ENV_KEY,\n]\n\n/** The preset-registry slice this module reads. */\nexport interface PresetLookup {\n /**\n * Read the preset a Session committed to.\n * @param session - the session whose selection is read.\n * @returns the preset id, or null when the session committed to none.\n */\n presetForSession(session: never): string | null\n}\n\n/**\n * The derived preset an agent runs under, on either track.\n * @param presets - the Host preset registry, when the composition supplies one.\n * @param session - the calling agent's session, when the call has one.\n * @returns the derived preset id, or undefined for an ordinary preset or no lookup.\n */\nexport function containerPresetOf(\n presets: PresetLookup | undefined,\n session: unknown,\n): string | undefined {\n if (presets === undefined || session === undefined || session === null) return undefined\n let id: string | null\n try {\n id = presets.presetForSession(session as never)\n } catch {\n // A registry that cannot answer must not break a command that would otherwise run.\n return undefined\n }\n return id !== null && variantKindOf(id) !== undefined ? id : undefined\n}\n\n/**\n * Which runtime one preset id targets.\n * @param preset - a preset id, or undefined when the session committed to none.\n * @returns the track, or undefined for an ordinary preset.\n */\nexport function presetKindOf(preset: string | undefined): VariantKind | undefined {\n return preset === undefined ? undefined : variantKindOf(preset)\n}\n\n/** The `ctx.agents` slice this module reads: the Agent that initiated an asynchronous chain. */\nexport interface InitiatorLookup {\n /**\n * Read the Agent that initiated the inherited asynchronous driver chain.\n * @returns the inherited Agent, or undefined outside an initiator boundary.\n */\n currentInitiator(): { session: unknown } | undefined\n}\n\n/** Read one service without a typed `Context` augmentation, as the Host row does. */\nfunction serviceOf(ctx: Context, service: string): unknown {\n return (ctx as unknown as { get(name: string): unknown }).get(service)\n}\n\n/**\n * The derived preset the CALLING agent runs, on either track.\n *\n * A shell call carries its agent in `spec.dshEnv`; a filesystem call carries\n * nothing, so this reads the initiator the loop establishes around every turn —\n * a subagent's own Session answers `presetForSession`, so a delegated agent is\n * attributed to its own preset exactly as it is for a command. A call made\n * outside any turn (a file read by the settings page, a plugin's own\n * bookkeeping) inherits no initiator and therefore no requirement.\n * @param ctx - the calling row's context.\n * @returns the derived preset id, or undefined for an ordinary or agentless call.\n */\nexport function callingContainerPreset(ctx: Context): string | undefined {\n const agents = serviceOf(ctx, 'agents') as InitiatorLookup | undefined\n const presets = serviceOf(ctx, 'agentPresets') as PresetLookup | undefined\n if (agents === undefined) return undefined\n let initiator: { session: unknown } | undefined\n try {\n initiator = agents.currentInitiator()\n } catch {\n // A registry that is closing cannot answer; a call that would otherwise run must not break.\n return undefined\n }\n return containerPresetOf(presets, initiator?.session)\n}\n\n/**\n * Which runtime the CALLING agent's preset targets.\n *\n * The filesystem, subprocess, and PTC seams carry no per-call marker, so they ask\n * the initiator boundary the same way {@link callingContainerPreset} does.\n * @param ctx - the calling row's context.\n * @returns the track, or undefined for an ordinary or agentless call.\n */\nexport function callingVariantKind(ctx: Context): VariantKind | undefined {\n return presetKindOf(callingContainerPreset(ctx))\n}\n\n/**\n * Whether one execution is marked as bound to a derived preset's runtime.\n * @param dshEnv - the managed environment the shell tool passed down.\n * @returns true when either marker is present.\n */\nexport function markedContainerOnly(dshEnv: DshEnvironment | undefined): boolean {\n if (dshEnv === undefined) return false\n return Reflect.get(dshEnv, DEVCONTAINER_ENV_KEY) === DEVCONTAINER_ENV_VALUE\n || Reflect.get(dshEnv, SBX_ENV_KEY) === SBX_ENV_VALUE\n}\n\n/**\n * Which runtime one execution is marked for.\n *\n * The sandbox marker is checked first: a `(sbx)` preset never sets the Dev\n * Container one, and a call that somehow carried both must be answered by the\n * marker whose runtime mounts the workspace without a declaration.\n * @param dshEnv - the managed environment the shell tool passed down.\n * @returns the track, or undefined when the call is unmarked.\n */\nexport function markedVariantKind(dshEnv: DshEnvironment | undefined): VariantKind | undefined {\n if (dshEnv === undefined) return undefined\n if (Reflect.get(dshEnv, SBX_ENV_KEY) === SBX_ENV_VALUE) return 'sbx'\n if (Reflect.get(dshEnv, DEVCONTAINER_ENV_KEY) === DEVCONTAINER_ENV_VALUE) return 'devcontainer'\n return undefined\n}\n\n/**\n * The preset id recorded alongside the marker.\n * @param dshEnv - the managed environment the shell tool passed down.\n * @returns the derived preset id, or undefined when no marker carries one.\n */\nexport function markedPreset(dshEnv: DshEnvironment | undefined): string | undefined {\n if (dshEnv === undefined) return undefined\n for (const key of [SBX_PRESET_ENV_KEY, DEVCONTAINER_PRESET_ENV_KEY]) {\n const value: unknown = Reflect.get(dshEnv, key)\n if (typeof value === 'string' && value.length > 0) return value\n }\n return undefined\n}\n\n/**\n * The diagnostic a refused command reports.\n * @param workdir - the host directory the command named.\n * @param preset - the derived preset the session runs, when it is known.\n * @returns the stderr text.\n */\nexport function refusalText(workdir: string, preset: string | undefined): string {\n const owner = preset === undefined ? 'a (devContainer) preset' : `the (devContainer) preset \"${preset}\"`\n return [\n `devcontainer: refused to run this command on the host.`,\n `This session uses ${owner}, so every command must run inside the repository's Linux container, but \"${workdir}\" declares none.`,\n `Looked for .devcontainer/devcontainer.json, .devcontainer.json, .dsh/devcontainer.json, or .dsh/docker.json in that directory and its ancestors.`,\n `Add one of those files to the repository, or switch to an ordinary preset without the (devContainer) suffix.`,\n '',\n ].join('\\n')\n}\n\n/**\n * The diagnostic a refused `(sbx)` command reports.\n *\n * A sandbox needs no declaration, so this refusal only happens when the session\n * has no host directory at all to mount — a row mounted without `cwd` and a\n * relative workdir. Naming the row's own setting is the way out.\n * @param workdir - the directory the command named.\n * @param preset - the derived preset the session runs, when it is known.\n * @returns the stderr text.\n */\nexport function sbxRefusalText(workdir: string, preset: string | undefined): string {\n const owner = preset === undefined ? 'a (sbx) preset' : `the (sbx) preset \"${preset}\"`\n return [\n 'sbx: refused to run this command on the host.',\n `This session uses ${owner}, so every command must run inside its Docker Sandbox, but no host workspace directory could be resolved for \"${workdir}\".`,\n 'A Docker Sandbox mounts a host directory, and this row was configured without a \"cwd\" to fall back on.',\n 'Set the row\\'s \"cwd\" to the repository directory, or switch to a preset without the (sbx) suffix.',\n '',\n ].join('\\n')\n}\n\n/**\n * The diagnostic a refused filesystem call reports.\n *\n * It names the preset, the path, and every file discovery looked for, then the\n * two ways out — adding a declaration or switching to an ordinary preset — so\n * the refusal cannot be mistaken for a broken tool.\n * @param path - the path the call named.\n * @param preset - the derived preset the session runs, when it is known.\n * @returns the refusal text.\n */\nexport function fsRefusalText(path: string, preset: string | undefined): string {\n const owner = preset === undefined ? 'a (devContainer) preset' : `the (devContainer) preset \"${preset}\"`\n return [\n `devcontainer: refused to access this path on the host.`,\n `This session uses ${owner}, so every file it reads or writes must live in the repository its Linux container mounts, but the repository that owns \"${path}\" declares none.`,\n `Looked for .devcontainer/devcontainer.json, .devcontainer.json, .dsh/devcontainer.json, or .dsh/docker.json next to that path and in its ancestors.`,\n `Add one of those files to the repository, or switch to an ordinary preset without the (devContainer) suffix.`,\n '',\n ].join('\\n')\n}\n\n/**\n * The diagnostic a filesystem call reports when the target escapes the repository mount.\n *\n * A path inside the repository can still name something outside it: a symbolic\n * link resolves wherever it points, and a target resolved before the session\n * became container-bound carries a host spelling. Both are refused, and the two\n * spellings are both reported so the link can be found and removed instead of\n * the refusal reading as a bug.\n * @param displayPath - the path the call named.\n * @param targetKey - the resolved path the backend would have used for I/O.\n * @param preset - the derived preset the session runs, when it is known.\n * @returns the refusal text.\n */\nexport function fsEscapeRefusalText(displayPath: string, targetKey: string, preset: string | undefined): string {\n const owner = preset === undefined ? 'a (devContainer) preset' : `the (devContainer) preset \"${preset}\"`\n return [\n `devcontainer: refused to access this path.`,\n `This session uses ${owner}, so everything it reads or writes must stay inside the repository its Linux container mounts.`,\n `\"${displayPath}\" resolves to \"${targetKey}\", which is outside that repository.`,\n `A symbolic link inside the repository must not point out of it, and a location resolved on the host must be resolved again inside the container.`,\n `Switch to an ordinary preset without the (devContainer) suffix to work on host files.`,\n '',\n ].join('\\n')\n}\n\n/** One offset read over a stream that already holds its whole text. */\ninterface SettledReader {\n readFrom(fromByte: number): { text: string, nextOffset: number, lossy: boolean }\n}\n\n/** A captured stream that already holds its whole text. */\nfunction settledReader(text: string): SettledReader {\n return {\n readFrom: (fromByte: number) => ({\n text: text.slice(fromByte),\n nextOffset: text.length,\n lossy: false,\n }),\n }\n}\n\n/** A captured stream with no truncation. */\nfunction collected(text: string): CollectedOutput {\n return { text, truncated: false }\n}\n\n/**\n * The completed execution a refused command returns.\n *\n * A command that never ran still has to answer in the shape the tool expects:\n * `exitCode: 1` and the diagnostic on stderr, so the model reads a failure it can\n * act on instead of a host-side result that looks like success.\n * @param spec - the resolved spec that was refused.\n * @param text - the diagnostic to report.\n * @returns the settled execution handle.\n */\nexport function refusedExecution(spec: ShellExecSpec, text: string): ShellExecution {\n let drained = false\n const stderr = settledReader(text)\n const stdout = settledReader('')\n const result: ShellRunResult = {\n exitCode: 1,\n signal: null,\n timedOut: false,\n aborted: false,\n timeoutMs: spec.timeoutMs,\n stdout: collected(''),\n stderr: collected(text),\n }\n return {\n status: 'completed',\n exitCode: 1,\n signal: null,\n done: Promise.resolve(),\n readOutput: (): ShellProcessRead => {\n if (drained) return { delta: '', lossy: false }\n drained = true\n return { delta: text, lossy: false }\n },\n observed: { stdout, stderr },\n kill: () => false,\n result: () => Promise.resolve(result),\n }\n}\n","/**\n * Just enough JSONC for `devcontainer.json`: the Dev Container specification\n * allows `//` and `/* *\\/` comments plus trailing commas, and no shipped parser\n * accepts them. Stripping happens string-aware, so a `//` inside a value (a URL,\n * a shell fragment) survives.\n * @module @banzhe/dsh-devcontainer/jsonc\n */\n\n/** Copy one double-quoted literal starting at `start`, honoring escapes. */\nfunction stringEnd(text: string, start: number): number {\n let index = start + 1\n while (index < text.length) {\n const character = text.charAt(index)\n if (character === '\\\\') {\n index += 2\n continue\n }\n index += 1\n if (character === '\"') return index\n }\n return text.length\n}\n\n/** Remove comments and trailing commas so strict `JSON.parse` accepts the text. */\nexport function stripJsonComments(text: string): string {\n let out = ''\n let index = 0\n while (index < text.length) {\n const character = text.charAt(index)\n const next = text[index + 1]\n if (character === '\"') {\n const end = stringEnd(text, index)\n out += text.slice(index, end)\n index = end\n continue\n }\n if (character === '/' && next === '/') {\n while (index < text.length && text[index] !== '\\n') index += 1\n continue\n }\n if (character === '/' && next === '*') {\n index += 2\n while (index < text.length && !(text[index] === '*' && text[index + 1] === '/')) index += 1\n index += 2\n continue\n }\n out += character\n index += 1\n }\n return stripTrailingCommas(out)\n}\n\n/** Drop commas that are followed only by whitespace and a closing bracket. */\nfunction stripTrailingCommas(text: string): string {\n let out = ''\n let index = 0\n while (index < text.length) {\n const character = text.charAt(index)\n if (character === '\"') {\n const end = stringEnd(text, index)\n out += text.slice(index, end)\n index = end\n continue\n }\n if (character === ',') {\n let lookahead = index + 1\n while (lookahead < text.length && /\\s/.test(text[lookahead] as string)) lookahead += 1\n const closing = text[lookahead]\n if (closing === '}' || closing === ']') {\n index += 1\n continue\n }\n }\n out += character\n index += 1\n }\n return out\n}\n\n/**\n * Parse one JSONC document (a leading BOM is tolerated).\n * @param text - the file content.\n * @returns the parsed value.\n * @throws SyntaxError when the document is not valid JSONC.\n */\nexport function parseJsonc(text: string): unknown {\n return JSON.parse(stripJsonComments(text.replace(/^\\uFEFF/, '')))\n}\n","/**\n * Repository-level Dev Container discovery and parsing.\n *\n * Discovery walks the ancestors of whatever directory a tool call arrives with\n * and takes the nearest repository declaration. Three shapes are honoured, in\n * this order:\n *\n * 1. `.dsh/devcontainer.json` and `.dsh/docker.json` — the lightweight form this\n * Bundle adds: it may name an already-running `container` instead of asking\n * the Dev Container CLI to build one.\n * 2. `.devcontainer/devcontainer.json` — the Dev Container specification.\n * 3. `.devcontainer.json` — the single-file variant of the same specification.\n *\n * @module @banzhe/dsh-devcontainer/config-loader\n */\n\nimport { readFileSync, statSync } from 'node:fs'\nimport { posix, win32 } from 'node:path'\nimport { parseJsonc } from './jsonc.ts'\nimport {\n defaultContainerWorkspaceFolder,\n hostPathStyle,\n isPathInsideContainer,\n isWindowsPath,\n normalizeHostRoot,\n relativeWithinHostRoot,\n toPosixSlashes,\n} from './paths.ts'\nimport { CONTAINER_OPTION_DEFAULTS } from './options.ts'\nimport type { ContainerCli, ContainerOptions, RepoContainerSpec } from './types.ts'\n\n/** One repository-level container configuration file. */\nexport interface ConfigFileCandidate {\n /** Path relative to the repository root. */\n readonly relativePath: string\n}\n\n/** The configuration files to probe in each ancestor directory, most specific first. */\nexport const CONFIG_CANDIDATES: readonly ConfigFileCandidate[] = [\n { relativePath: '.dsh/devcontainer.json' },\n { relativePath: '.dsh/docker.json' },\n { relativePath: '.devcontainer/devcontainer.json' },\n { relativePath: '.devcontainer.json' },\n]\n\n/** Reads a file, or returns undefined when it is absent or unreadable. */\nexport type ReadTextFile = (path: string) => string | undefined\n\n/** The filesystem read discovery uses unless a caller supplies one. */\nexport const readTextFile: ReadTextFile = (path) => {\n try {\n return readFileSync(path, 'utf8')\n } catch {\n return undefined\n }\n}\n\n/** One configuration file found by the ancestor walk. */\nexport interface FoundConfig {\n /** Absolute host path of the configuration file. */\n readonly configPath: string\n /** Absolute host path of the repository root that owns it. */\n readonly hostRoot: string\n}\n\n/** Options a caller adds on top of {@link ContainerOptions} for one lookup. */\nexport interface LocateOptions extends Partial<ContainerOptions> {\n /** Directory relative paths resolve against, and the fallback discovery start. */\n readonly cwd?: string | undefined\n}\n\nconst MAX_ANCESTOR_DEPTH = 64\n\nfunction asRecord(value: unknown): Record<string, unknown> | undefined {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n ? value as Record<string, unknown>\n : undefined\n}\n\nfunction asString(value: unknown): string | undefined {\n return typeof value === 'string' && value.trim() !== '' ? value.trim() : undefined\n}\n\nfunction asBoolean(value: unknown): boolean | undefined {\n return typeof value === 'boolean' ? value : undefined\n}\n\nfunction asStringMap(value: unknown): Record<string, string> | undefined {\n const record = asRecord(value)\n if (record === undefined) return undefined\n const entries: [string, string][] = []\n for (const [key, entry] of Object.entries(record)) {\n if (typeof entry === 'string') entries.push([key, entry])\n else if (typeof entry === 'number' || typeof entry === 'boolean') entries.push([key, String(entry)])\n }\n return entries.length === 0 ? undefined : Object.fromEntries(entries)\n}\n\nfunction asCli(value: unknown): ContainerCli | undefined {\n return value === 'auto' || value === 'devcontainer' || value === 'docker' || value === 'sbx' ? value : undefined\n}\n\n/**\n * Build one specification from a configuration file's text.\n *\n * A declared `workspaceFolder` wins over the specification's default mount\n * point, and both must be POSIX: a Windows-shaped value would produce a\n * container path no shell in the container could enter.\n * @param input - the repository root, the configuration path, its text, and the row's defaults.\n * @returns the resolved specification.\n * @throws Error when the document is unparsable or a field is unusable.\n */\nexport function buildSpec(input: {\n hostRoot: string\n configPath: string\n text: string\n options?: Partial<ContainerOptions> | undefined\n}): RepoContainerSpec {\n let parsed: unknown\n try {\n parsed = parseJsonc(input.text)\n } catch (error) {\n throw new Error(`devcontainer: cannot parse ${input.configPath}: ${(error as Error).message}`)\n }\n const record = asRecord(parsed) ?? {}\n const hostRoot = normalizeHostRoot(input.hostRoot)\n const declaredFolder = asString(record.workspaceFolder)\n const containerWorkspaceFolder = declaredFolder === undefined\n ? defaultContainerWorkspaceFolder(hostRoot)\n : toPosixSlashes(declaredFolder).replace(/\\/+$/, '')\n if (!posix.isAbsolute(containerWorkspaceFolder)) {\n throw new Error(`devcontainer: ${input.configPath}: workspaceFolder must be an absolute POSIX path, got ${JSON.stringify(declaredFolder)}`)\n }\n const remoteEnv = asStringMap(record.remoteEnv)\n const container = asString(record.container) ?? asString(record.containerName)\n const composeService = asString(record.service)\n const remoteUser = asString(record.remoteUser)\n const sandbox = asString(record.sandbox) ?? asString(record.sandboxName)\n const shell = asString(record.shell) ?? input.options?.shell ?? CONTAINER_OPTION_DEFAULTS.shell\n const cli = asCli(record.cli) ?? input.options?.cli ?? CONTAINER_OPTION_DEFAULTS.cli\n const ensureUp = asBoolean(record.ensureUp) ?? input.options?.ensureUp ?? CONTAINER_OPTION_DEFAULTS.ensureUp\n const containerTimeoutMs = input.options?.containerTimeoutMs ?? CONTAINER_OPTION_DEFAULTS.containerTimeoutMs\n return {\n hostWorkspaceRoot: hostRoot,\n containerWorkspaceFolder,\n configPath: input.configPath,\n ...container === undefined ? {} : { container },\n ...composeService === undefined ? {} : { composeService },\n ...remoteUser === undefined ? {} : { remoteUser },\n ...remoteEnv === undefined ? {} : { remoteEnv },\n ...sandbox === undefined ? {} : { sandbox },\n shell,\n cli,\n ensureUp,\n containerTimeoutMs,\n }\n}\n\n/**\n * Walk the ancestors of one directory and return the nearest configuration file.\n * @param startDir - absolute host path of a file or directory inside the repository.\n * @param read - file reader; absent files return undefined.\n * @returns the found file and its repository root, or undefined when no ancestor declares one.\n */\nexport function findConfigFile(startDir: string, read: ReadTextFile = readTextFile): FoundConfig | undefined {\n // One path module owns the whole walk: a Windows-shaped start normalized by\n // win32 and then split by the platform module (or the reverse) builds ancestor\n // paths no reader answers for, and the declaration above them is never found.\n const paths = hostPathStyle(startDir) === 'win32' ? win32 : posix\n let current = normalizeHostRoot(startDir)\n for (let depth = 0; depth < MAX_ANCESTOR_DEPTH; depth += 1) {\n for (const candidate of CONFIG_CANDIDATES) {\n const configPath = paths.join(current, ...candidate.relativePath.split('/'))\n if (read(configPath) === undefined) continue\n return { configPath, hostRoot: current }\n }\n const parent = paths.dirname(current)\n if (parent === current) break\n current = parent\n }\n return undefined\n}\n\n\n/** One cached specification and the file state it was parsed from. */\ninterface CachedSpec {\n readonly spec: RepoContainerSpec\n /** `mtimeMs` of the configuration file at parse time; undefined when it could not be read. */\n readonly mtimeMs: number | undefined\n}\n\n/** How many repositories the container-path index keeps before dropping the oldest. */\nconst MAX_DISCOVERED = 64\n\n/**\n * Last-modified time of one file, or undefined when it cannot be stat'd.\n * @param path - absolute path of the file.\n * @returns the mtime in milliseconds.\n */\nexport function statMtimeMs(path: string): number | undefined {\n try {\n return statSync(path).mtimeMs\n } catch {\n return undefined\n }\n}\n\n/**\n * Per-context cache of discovered specifications.\n *\n * Every shell command and every filesystem call asks for the repository\n * specification, so the ancestor walk is memoized per directory and the parse\n * per option signature. Two rules keep the cache honest:\n *\n * - a directory that declares nothing is NOT remembered: a person who adds\n * `.dsh/docker.json` after being told the repository declares none must be\n * picked up by the very next command;\n * - a parse is remembered together with the configuration file's `mtimeMs` and\n * re-used only while the file still exists with that exact mtime, so editing or\n * deleting a declaration takes effect immediately.\n */\nexport class RepoContainerRegistry {\n /** Directory → found config. Only hits are remembered. */\n private readonly directories = new Map<string, FoundConfig>()\n /** Option signature → parsed specification. */\n private readonly specifications = new Map<string, CachedSpec>()\n /** Configuration path → the parse it produced most recently. */\n private readonly latest = new Map<string, CachedSpec>()\n /** Every specification discovered so far, for container-path matching. */\n private readonly discovered: RepoContainerSpec[] = []\n\n /**\n * @param read - file reader; an absent file returns undefined.\n * @param mtime - file clock used to detect edits; undefined means \"cannot tell\".\n */\n constructor(\n private readonly read: ReadTextFile = readTextFile,\n private readonly mtime: (path: string) => number | undefined = statMtimeMs,\n ) {}\n\n /** Drop every cached discovery and parse. */\n reset(): void {\n this.directories.clear()\n this.specifications.clear()\n this.latest.clear()\n this.discovered.length = 0\n }\n\n /** Every specification discovered so far. */\n knownSpecs(): readonly RepoContainerSpec[] {\n return this.discovered\n }\n\n /**\n * Find the repository container specification that governs one path.\n *\n * Container paths carry no host ancestry, so the caller's host `cwd` is asked\n * first: it reaches the repository from disk without any earlier call, and it\n * separates two repositories that happen to mount at the same container folder.\n * @param path - the path a tool call carries: a host path, a container path, or a relative path.\n * @param options - the calling row's defaults plus the directory relative paths resolve against.\n * @returns the governing specification, or undefined when the path belongs to no Dev Container repository.\n */\n locate(path: string | undefined, options: LocateOptions = {}): RepoContainerSpec | undefined {\n const cwd = options.cwd\n const target = path === undefined || path === '' ? cwd : path\n if (target === undefined || target === '') return undefined\n if (cwd !== undefined && cwd !== '' && cwd !== target && !isWindowsPath(target)) {\n const fromCwd = this.discover(cwd, options)\n if (fromCwd !== undefined\n && isPathInsideContainer(target, fromCwd)\n && relativeWithinHostRoot(target, fromCwd.hostWorkspaceRoot) === undefined) {\n return fromCwd\n }\n }\n const stale: string[] = []\n const match = this.discovered.find((spec) => {\n if (!isPathInsideContainer(target, spec)) return false\n if (this.isStale(spec)) {\n stale.push(spec.configPath)\n return false\n }\n return true\n })\n for (const configPath of stale) this.forgetConfig(configPath)\n if (match !== undefined) return match\n const direct = this.discover(target, options)\n if (direct !== undefined) return direct\n if (cwd === undefined || cwd === target) return undefined\n const fromCwd = this.discover(cwd, options)\n if (fromCwd === undefined) return undefined\n // Only claim the path for the cwd's repository when it really is inside it:\n // an unrelated absolute host path must keep running on the host.\n return this.belongsTo(target, fromCwd) ? fromCwd : undefined\n }\n\n /** Whether one path lies inside a specification's host root or container mount. */\n private belongsTo(path: string, spec: RepoContainerSpec): boolean {\n return isPathInsideContainer(path, spec) || relativeWithinHostRoot(path, spec.hostWorkspaceRoot) !== undefined\n }\n\n /**\n * Discover from one path's ancestry, memoized per directory.\n * @param start - a file or directory inside the repository.\n * @param options - the calling row's defaults.\n * @returns the specification, or undefined when no ancestor declares one.\n */\n discover(start: string, options: LocateOptions = {}): RepoContainerSpec | undefined {\n const found = this.findConfig(start)\n if (found === undefined) return undefined\n return this.specFor(found, options)\n }\n\n /** The cached hit for one start directory, or a fresh walk. Misses are not cached. */\n private findConfig(start: string): FoundConfig | undefined {\n const absolute = start.startsWith('/') || start.startsWith('\\\\\\\\') || /^[A-Za-z]:[\\\\/]/.test(start)\n if (!absolute) return findConfigFile(start, this.read)\n const cached = this.directories.get(start)\n if (cached !== undefined) return cached\n const found = findConfigFile(start, this.read)\n if (found !== undefined) this.directories.set(start, found)\n return found\n }\n\n /** Parse one found file for one option signature, re-using the parse only while the file is unchanged. */\n private specFor(found: FoundConfig, options: LocateOptions): RepoContainerSpec | undefined {\n const signature = [\n found.configPath,\n options.cli ?? '',\n options.shell ?? '',\n options.ensureUp ?? '',\n options.containerTimeoutMs ?? '',\n options.requireContainer ?? '',\n ].join('\\u0000')\n const cached = this.specifications.get(signature)\n if (cached !== undefined && !this.isStale(cached.spec)) return cached.spec\n if (cached !== undefined) this.forgetConfig(found.configPath)\n const text = this.read(found.configPath)\n if (text === undefined) {\n this.forgetConfig(found.configPath)\n return undefined\n }\n const entry: CachedSpec = {\n spec: buildSpec({ hostRoot: found.hostRoot, configPath: found.configPath, text, options }),\n mtimeMs: this.mtime(found.configPath),\n }\n this.specifications.set(signature, entry)\n this.latest.set(found.configPath, entry)\n this.remember(entry.spec)\n return entry.spec\n }\n\n /** Whether the file behind one specification is gone or has been edited since it was parsed. */\n private isStale(spec: RepoContainerSpec): boolean {\n const entry = this.latest.get(spec.configPath)\n if (entry === undefined) return true\n const clock = this.mtime(spec.configPath)\n return clock === undefined || clock !== entry.mtimeMs\n }\n\n /** Keep the container-path index free of duplicates and bounded. */\n private remember(spec: RepoContainerSpec): void {\n const index = this.discovered.findIndex(known => known.configPath === spec.configPath && known.cli === spec.cli)\n if (index >= 0) this.discovered[index] = spec\n else this.discovered.push(spec)\n while (this.discovered.length > MAX_DISCOVERED) this.discovered.shift()\n }\n\n /** Forget every trace of one configuration file, so the next call walks the disk again. */\n private forgetConfig(configPath: string): void {\n for (const [start, found] of this.directories) {\n if (found.configPath === configPath) this.directories.delete(start)\n }\n for (const [signature, entry] of this.specifications) {\n if (entry.spec.configPath === configPath) this.specifications.delete(signature)\n }\n this.latest.delete(configPath)\n const index = this.discovered.findIndex(known => known.configPath === configPath)\n if (index >= 0) this.discovered.splice(index, 1)\n }\n}\n","/**\n * The discovery cache each composition shares between the Bundle's three Loader\n * rows, and nothing else.\n *\n * The rows are separate Cordis plugins (one service each) but they must agree on\n * what \"this repository's container\" means. Keying the cache by the composition\n * root gives them one answer without letting two DSH instances in the same\n * process — or a reloaded plugin — inherit another's discoveries.\n * @module @banzhe/dsh-devcontainer/registry\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { RepoContainerRegistry } from './config-loader.ts'\n\nconst REGISTRIES = new WeakMap<object, RepoContainerRegistry>()\nconst DEFAULT = new RepoContainerRegistry()\n\n/** The composition root one context belongs to. */\nfunction rootOf(scope: Context | object): object {\n const root: unknown = (scope as { root?: unknown }).root\n return typeof root === 'object' && root !== null ? root : scope\n}\n\n/**\n * The discovery cache for one composition.\n * @param scope - a row's context, or the composition root; omitted for a bare cache.\n * @returns the registry shared by every row of that composition.\n */\nexport function repoRegistry(scope?: Context | object): RepoContainerRegistry {\n if (scope === undefined) return DEFAULT\n const key = rootOf(scope)\n const cached = REGISTRIES.get(key)\n if (cached !== undefined) return cached\n const registry = new RepoContainerRegistry()\n REGISTRIES.set(key, registry)\n return registry\n}\n","/**\n * Docker Sandbox (`sbx`) target discovery.\n *\n * A sandbox is not a Dev Container: a `(sbx)` preset needs no\n * `.devcontainer/devcontainer.json` at all. This module therefore answers two\n * questions the Dev Container driver answers from a declaration: which sandbox\n * belongs to a host directory (a naming convention makes it deterministic), and\n * where commands run inside it (the sandbox's own mount of that directory).\n *\n * That second answer is not the host spelling. A Linux or macOS sandbox mounts a\n * workspace at the same absolute path it has on the host, while a Windows host's\n * MicroVM maps `F:\\personal\\repo` to `/f/personal/repo`. `sbx ls --json` reports\n * the mounts, so the listing decides the folder; a sandbox whose mounts say\n * nothing about the workspace keeps the host path as its fallback.\n *\n * The CLI surface used here is the documented one: `sbx ls --json` lists\n * sandboxes, `sbx create --name <name> shell <path>` creates one around a host\n * directory without attaching, and `sbx run -d --name <name>` starts an existing\n * sandbox detached. `sbx exec` reports a missing sandbox with exit code 125.\n * @module @banzhe/dsh-devcontainer/sbx\n */\n\nimport { createHash } from 'node:crypto'\nimport { posix, win32 } from 'node:path'\nimport type { ContainerTarget } from './container.ts'\nimport type { ContainerRun } from './exec.ts'\nimport {\n containerRemainder,\n hostPathStyle,\n isPosixAbsolute,\n isWindowsPath,\n joinHostRoot,\n normalizeHostRoot,\n relativeWithinHostRoot,\n toPosixSlashes,\n} from './paths.ts'\nimport type { ContainerOptions, RepoContainerSpec } from './types.ts'\n\n/** Prefix every sandbox this Bundle creates carries, so it is recognizable on a host. */\nexport const SANDBOX_NAME_PREFIX = 'dsh-'\n\n/** The template a created sandbox runs: Docker's agent-less shell template. */\nexport const SANDBOX_TEMPLATE = 'shell'\n\n/**\n * What a missing `sbx` CLI means for the person reading the diagnostic.\n *\n * The name is deliberately long-form: `command not found: sbx` says nothing\n * about what to install, and a `(sbx)` preset otherwise looks like a broken\n * shell tool.\n */\nexport const SBX_INSTALL_HINT = 'Install the Docker Sandbox CLI (\"sbx\", shipped with Docker Desktop) so it is on PATH, '\n + 'sign in with \"sbx login\", or switch to a preset without the (sbx) suffix.'\n\n/** One host directory a sandbox mounts, with the path it has inside the sandbox. */\nexport interface SandboxMount {\n /** The host directory the mount originates from, in the host's own path style. */\n readonly host: string\n /** Absolute POSIX path the same directory has inside the sandbox. */\n readonly sandbox: string\n}\n\n/** One sandbox as `sbx ls` reports it. */\nexport interface ListedSandbox {\n /** The sandbox name. */\n readonly name: string\n /** Whether it is running right now. */\n readonly running: boolean\n /** The mounts it reported; empty when the row carried none this module can read. */\n readonly mounts: readonly SandboxMount[]\n}\n\n/**\n * The deterministic sandbox name of one host workspace.\n *\n * `dsh-<repo>-<hash>`: the readable part so a person recognizes the project in\n * `sbx ls`, the digest so two repositories with the same directory name never\n * share a sandbox. The digest folds case only for a Windows-rooted path, because\n * that host reports one directory with either spelling; a case-sensitive host\n * keeps the spelling it was given, where `Repo` and `repo` are two directories\n * that must not share a sandbox.\n * @param hostWorkspaceRoot - absolute host path of the workspace.\n * @returns the sandbox name.\n */\nexport function sandboxNameFor(hostWorkspaceRoot: string): string {\n const root = normalizeHostRoot(hostWorkspaceRoot)\n const windows = hostPathStyle(root) === 'win32'\n const base = windows ? win32.basename(root) : posix.basename(root)\n const slug = (base === '' ? 'workspace' : base)\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n const spelled = root.replaceAll('\\\\', '/')\n const digest = createHash('sha256')\n .update(windows ? spelled.toLowerCase() : spelled)\n .digest('hex')\n .slice(0, 8)\n return `${SANDBOX_NAME_PREFIX}${slug === '' ? 'workspace' : slug}-${digest}`\n}\n\n/** The state names a listed sandbox may report while it is running. */\nconst RUNNING_STATES: ReadonlySet<string> = new Set(['running', 'ready', 'up', 'started'])\n\n/**\n * Read one mount entry a listing reports.\n *\n * The separator is the LAST `:/` of the entry: a Windows host directory carries a\n * drive colon of its own, while the sandbox side of a mount is always\n * POSIX-absolute. An entry that does not split into two absolute paths is\n * dropped rather than guessed at, which leaves its sandbox on the host-path\n * fallback instead of a path that exists nowhere.\n * @param value - one entry of a row's `mounts` array.\n * @returns the mount, or undefined when the entry names none.\n */\nfunction sandboxMount(value: unknown): SandboxMount | undefined {\n if (typeof value !== 'string') return undefined\n const separator = value.lastIndexOf(':/')\n if (separator <= 0) return undefined\n const host = value.slice(0, separator).trim()\n const sandbox = value.slice(separator + 1).trim()\n if (!isWindowsPath(host) && !isPosixAbsolute(host)) return undefined\n if (!isPosixAbsolute(sandbox)) return undefined\n return { host, sandbox }\n}\n\n/** The mounts one row reports, in the order it reports them. */\nfunction mountsOf(row: Record<string, unknown>): SandboxMount[] {\n const listed = row['mounts']\n if (!Array.isArray(listed)) return []\n return listed.map(sandboxMount).filter((mount): mount is SandboxMount => mount !== undefined)\n}\n\n/**\n * Read one listed sandbox, tolerating the field names the CLI has used across\n * releases (snake_case JSON, a `detached` flag, or a plain `running` boolean).\n *\n * A row that says nothing about its state is reported as NOT running: starting an\n * existing sandbox again is harmless, while treating a stopped sandbox as running\n * would make every later `sbx exec` fail with exit code 125 and never recover.\n * @param value - one row of the listing.\n * @returns the sandbox, or undefined when the row names none.\n */\nfunction listedSandbox(value: unknown): ListedSandbox | undefined {\n if (typeof value !== 'object' || value === null) return undefined\n const row = value as Record<string, unknown>\n const name = row['name']\n if (typeof name !== 'string' || name.trim() === '') return undefined\n const mounts = mountsOf(row)\n if (row['running'] === true || row['detached'] === true) return { name: name.trim(), running: true, mounts }\n for (const field of ['status', 'state']) {\n const state = row[field]\n if (typeof state === 'string') {\n return { name: name.trim(), running: RUNNING_STATES.has(state.trim().toLowerCase()), mounts }\n }\n }\n return { name: name.trim(), running: false, mounts }\n}\n\n/**\n * Parse `sbx ls --json`.\n *\n * Both the current array form and the older `{ \"sandboxes\": [...] }` envelope are\n * accepted, and anything unparsable yields no sandboxes rather than throwing: a\n * listing this module cannot read must fall through to \"create or start it\", not\n * fail the command.\n * @param stdout - the CLI's standard output.\n * @returns the listed sandboxes.\n */\nexport function parseSandboxList(stdout: string): ListedSandbox[] {\n const text = stdout.trim()\n if (text === '') return []\n let parsed: unknown\n try {\n parsed = JSON.parse(text)\n } catch {\n return []\n }\n const rows = Array.isArray(parsed)\n ? parsed\n : typeof parsed === 'object' && parsed !== null && Array.isArray((parsed as { sandboxes?: unknown }).sandboxes)\n ? (parsed as { sandboxes: unknown[] }).sandboxes\n : []\n return rows.map(listedSandbox).filter((row): row is ListedSandbox => row !== undefined)\n}\n\n/** One listing attempt: whether the CLI answered at all, and what it listed. */\nexport interface SandboxListing {\n /** False when the CLI is missing (exit code `null`), which no retry can fix. */\n readonly available: boolean\n /** The sandboxes it reported; empty when the listing failed. */\n readonly sandboxes: readonly ListedSandbox[]\n}\n\n/**\n * Ask the CLI which sandboxes exist.\n *\n * The mounts of a successful listing are remembered, because the specification\n * builders below are synchronous and have no CLI in reach.\n * @param run - the CLI runner.\n * @param timeoutMs - budget for the call.\n * @param signal - cancellation.\n * @returns the listing, with `available: false` when `sbx` could not be started.\n */\nexport async function listSandboxes(\n run: ContainerRun,\n timeoutMs: number,\n signal?: AbortSignal,\n): Promise<SandboxListing> {\n const result = await run(\n ['sbx', 'ls', '--json'],\n { ...signal === undefined ? {} : { signal }, timeoutMs },\n )\n if (result.exitCode === null) return { available: false, sandboxes: [] }\n if (result.exitCode !== 0) return { available: true, sandboxes: [] }\n const sandboxes = parseSandboxList(result.stdout)\n recordMounts(sandboxes)\n return { available: true, sandboxes }\n}\n\n/** Whether this host spells directories the Windows way. */\nconst WINDOWS_HOST = process.platform === 'win32'\n\n/**\n * The host directory a `(sbx)` session mounts.\n *\n * A declaration wins, because the sandbox mounts the repository the declaration\n * was found in. Without one, the row's configured cwd is the workspace — that is\n * the directory the session was started in, and the only one a sandbox may\n * claim. The path a call names is the last resort, and only when it is an\n * absolute HOST path: a POSIX-absolute path is a host path on a POSIX host only,\n * since on Windows `/workspaces/<repo>` is the Dev Container spelling.\n * @param workdir - the directory the call named.\n * @param cwd - the directory the row was configured with.\n * @param declared - the specification a declaration produced, when one exists.\n * @returns the absolute host path to mount, or undefined when none can be named.\n */\nexport function sbxWorkspaceRootFor(\n workdir: string,\n cwd: string | undefined,\n declared?: RepoContainerSpec,\n): string | undefined {\n if (declared !== undefined) return declared.hostWorkspaceRoot\n if (cwd !== undefined && cwd !== '') return cwd\n if (isWindowsPath(workdir) || (!WINDOWS_HOST && isPosixAbsolute(workdir))) return workdir\n return undefined\n}\n\n/**\n * The path a sandbox has for one host workspace, from the host convention alone.\n *\n * A sandbox is a Linux machine, so it cannot mount a Windows drive path: its\n * MicroVM maps the directory without the drive colon, which turns\n * `F:\\personal\\asmr-manager` into `/f/personal/asmr-manager`. A Linux or macOS\n * sandbox mounts a directory at the absolute path it already has.\n *\n * This answers the attribution question a call must settle before the listing\n * has run or when the listing reported no mounts; mounts a listing did report\n * always win over it.\n * @param hostWorkspaceRoot - absolute host path of the workspace.\n * @returns the absolute POSIX path the sandbox has for it, or undefined for a UNC path no convention maps.\n */\nexport function sandboxWorkspacePath(hostWorkspaceRoot: string): string | undefined {\n const root = normalizeHostRoot(hostWorkspaceRoot)\n if (hostPathStyle(root) !== 'win32') return toPosixSlashes(root)\n // A UNC share has no drive letter a sandbox could reproduce.\n if (root.startsWith('\\\\\\\\')) return undefined\n const slashed = toPosixSlashes(root)\n // `posix.normalize` keeps the trailing slash of a drive root, which no mount\n // point carries.\n return posix.normalize(`/${slashed.slice(0, 1).toLowerCase()}${slashed.slice(2)}`).replace(/\\/+$/, '') || '/'\n}\n\n/**\n * The path one host workspace has inside a sandbox, from the mounts it reported.\n *\n * The deepest mount containing the workspace wins, so a sandbox created around a\n * parent directory still maps the repository inside it. A host whose sandbox\n * mounts directories at their own absolute path — Linux and macOS both do —\n * yields that same path, which is the fallback anyway.\n * @param hostWorkspaceRoot - absolute host path of the workspace.\n * @param mounts - the mounts a listing reported.\n * @returns the absolute POSIX sandbox path, or undefined when no mount covers the workspace.\n */\nexport function sandboxMountFor(\n hostWorkspaceRoot: string,\n mounts: readonly SandboxMount[],\n): string | undefined {\n const root = normalizeHostRoot(hostWorkspaceRoot)\n let found: { readonly hostLength: number, readonly path: string } | undefined\n for (const mount of mounts) {\n if (!isPosixAbsolute(mount.sandbox)) continue\n const relative = relativeWithinHostRoot(root, mount.host)\n if (relative === undefined) continue\n if (found !== undefined && found.hostLength >= mount.host.length) continue\n const base = posix.normalize(mount.sandbox)\n found = { hostLength: mount.host.length, path: relative === '' ? base : posix.join(base, relative) }\n }\n return found?.path\n}\n\n/**\n * The mounts the last listing reported, per sandbox name.\n *\n * {@link sbxSpecFor} and {@link asSbxSpec} are synchronous — the preset builder,\n * the filesystem route, and the spawn-cwd mapping all build a specification on a\n * path that a listing has already answered for — so the listing leaves its mounts\n * here for them. Mounts handed to those functions explicitly always win.\n */\nconst reportedMounts = new Map<string, readonly SandboxMount[]>()\n\n/**\n * Remember one listing's mounts.\n * @param sandboxes - the sandboxes the listing reported.\n */\nfunction recordMounts(sandboxes: readonly ListedSandbox[]): void {\n for (const sandbox of sandboxes) reportedMounts.set(sandbox.name, sandbox.mounts)\n}\n\n/** Where a sandbox-spelled path really is, as far as the host can tell. */\nexport interface SandboxHostAttribution {\n /** Absolute host path the sandbox path stands for. */\n readonly host: string\n /**\n * The host directory the sandbox mounts that path from — present only when a\n * listing reported the mount, because only a mount says which directory a\n * sandbox has, while the host convention says just what the path is called.\n */\n readonly workspaceRoot?: string\n}\n\n/**\n * The host directory a path inside a sandbox names.\n *\n * This is the inverse of {@link sandboxWorkspacePath} and {@link sandboxMountFor},\n * and a `(sbx)` session's filesystem calls need it: the paths such a session names\n * exist only inside its sandbox, so walking their ancestors on the host finds no\n * repository — on a Windows host `/f/personal/repo` is `F:\\personal\\repo`, one\n * namespace away from the directory that declares the container.\n *\n * A mount the last listing reported is direct evidence and wins, deepest first, so\n * a sandbox that mounts its workspace somewhere of its own is attributed correctly\n * — and only a mount says which host directory the sandbox has, which is the\n * workspace root a caller needs. Without one, only the host convention can answer:\n * a Windows host maps `F:\\personal\\repo` to `/f/personal/repo`, so a path whose\n * first segment is a single letter spells a drive. Anything else —\n * `/workspaces/repo`, `/etc` — names no host directory, and the caller keeps\n * whatever it had.\n * @param sandboxPath - absolute POSIX path inside a sandbox.\n * @returns the host path it stands for, or undefined when nothing attributes it.\n */\nexport function sandboxHostPathFor(sandboxPath: string): SandboxHostAttribution | undefined {\n const normalized = posix.normalize(toPosixSlashes(sandboxPath))\n if (!isPosixAbsolute(normalized)) return undefined\n const mounted = mountedHostFor(normalized)\n if (mounted !== undefined) {\n return { host: mounted.host, workspaceRoot: normalizeHostRoot(mounted.root) }\n }\n const drive = driveHostFor(normalized)\n return drive === undefined ? undefined : { host: drive }\n}\n\n/** The host directory and workspace a reported mount covers, the deepest mount winning. */\nfunction mountedHostFor(sandboxPath: string): { readonly host: string, readonly root: string } | undefined {\n let found: { readonly depth: number, readonly host: string, readonly root: string } | undefined\n for (const mounts of reportedMounts.values()) {\n for (const mount of mounts) {\n const relative = containerRemainder(sandboxPath, mount.sandbox)\n if (relative === undefined) continue\n const depth = posix.normalize(mount.sandbox).length\n if (found !== undefined && found.depth >= depth) continue\n found = {\n depth,\n root: mount.host,\n host: relative === '' ? normalizeHostRoot(mount.host) : joinHostRoot(mount.host, relative),\n }\n }\n }\n return found === undefined ? undefined : { host: found.host, root: found.root }\n}\n\n/** The drive-letter directory a sandbox path spells on a Windows host, when its first segment is a letter. */\nfunction driveHostFor(sandboxPath: string): string | undefined {\n const match = /^\\/([A-Za-z])(?:\\/|$)/.exec(sandboxPath)\n if (match === null) return undefined\n const drive = (match[1] ?? '').toUpperCase()\n const rest = sandboxPath.slice(2).replaceAll('/', '\\\\')\n return rest === '' ? `${drive}:\\\\` : win32.resolve(`${drive}:${rest}`)\n}\n\n/**\n * The sandbox one specification runs in.\n * @param spec - the repository container specification.\n * @returns the declared sandbox name, or the deterministic name of the host root.\n */\nfunction sandboxNameOf(spec: RepoContainerSpec): string {\n return spec.sandbox ?? sandboxNameFor(spec.hostWorkspaceRoot)\n}\n\n/**\n * The path a specification's workspace has inside its sandbox, as last listed.\n * @param spec - the repository container specification.\n * @returns the absolute sandbox path, or undefined when no listing covered the workspace.\n */\nexport function sbxMountOf(spec: RepoContainerSpec): string | undefined {\n const mounts = reportedMounts.get(sandboxNameOf(spec))\n return mounts === undefined ? undefined : sandboxMountFor(spec.hostWorkspaceRoot, mounts)\n}\n\n/**\n * The target one specification's sandbox becomes.\n * @param spec - the repository container specification.\n * @param mounts - the mounts of a fresh listing; when absent, the mounts the last one reported are used.\n * @returns the sandbox target, with the folder the sandbox really has for this workspace.\n */\nexport function sbxTargetOf(spec: RepoContainerSpec, mounts?: readonly SandboxMount[]): ContainerTarget {\n const mounted = mounts === undefined\n ? sbxMountOf(spec)\n : sandboxMountFor(spec.hostWorkspaceRoot, mounts)\n return {\n kind: 'sbx',\n sandboxName: sandboxNameOf(spec),\n workspaceFolder: mounted ?? spec.containerWorkspaceFolder,\n }\n}\n\n/**\n * The sandbox view of a declared repository.\n *\n * A Dev Container declaration's `/workspaces/<repo>` describes a directory a\n * sandbox may not have, so the mount takes its place: the folder a listing\n * reported for this workspace, else {@link sandboxWorkspacePath} — the same path\n * on a Linux or macOS host, and the drive-letter spelling (`/f/…` for `F:\\…`) on\n * a Windows one. The one exception is a declaration that names `cli: \"sbx\"`\n * itself — that repository opted into the sandbox driver, so its own\n * `workspaceFolder` is the fallback when no mount was reported.\n * @param spec - the declared specification.\n * @param mounts - the mounts of a fresh listing; when absent, the mounts the last one reported are used.\n * @returns the same repository, reachable through `sbx`.\n */\nexport function asSbxSpec(spec: RepoContainerSpec, mounts?: readonly SandboxMount[]): RepoContainerSpec {\n const root = normalizeHostRoot(spec.hostWorkspaceRoot)\n const declared = spec.cli === 'sbx' ? spec.containerWorkspaceFolder : sandboxWorkspacePath(root) ?? root\n const mounted = mounts === undefined ? sbxMountOf(spec) : sandboxMountFor(root, mounts)\n return { ...spec, hostWorkspaceRoot: root, containerWorkspaceFolder: mounted ?? declared, cli: 'sbx' }\n}\n\n/**\n * The sandbox specification of one host directory, declared or not.\n * @param hostWorkspaceRoot - absolute host path of the workspace.\n * @param options - the row's container defaults.\n * @param declared - the specification a declaration produced, when one exists.\n * @param mounts - the mounts of a fresh listing; when absent, the mounts the last one reported are used.\n * @returns the specification a `(sbx)` session runs under.\n */\nexport function sbxSpecFor(\n hostWorkspaceRoot: string,\n options: ContainerOptions,\n declared?: RepoContainerSpec,\n mounts?: readonly SandboxMount[],\n): RepoContainerSpec {\n const root = normalizeHostRoot(hostWorkspaceRoot)\n if (declared !== undefined && normalizeHostRoot(declared.hostWorkspaceRoot) === root) {\n return asSbxSpec(declared, mounts)\n }\n return asSbxSpec({\n hostWorkspaceRoot: root,\n containerWorkspaceFolder: sandboxWorkspacePath(root) ?? root,\n configPath: '',\n shell: options.shell,\n cli: 'sbx',\n ensureUp: options.ensureUp,\n containerTimeoutMs: options.containerTimeoutMs,\n }, mounts)\n}\n\n/**\n * Align a specification with the mount its resolved target reports.\n *\n * A specification is built on a path alone, while the folder a sandbox really has\n * arrives with the listing the resolver performs. Only a sandbox target carries a\n * different folder; a container the Dev Container CLI declared keeps its own.\n * @param spec - the specification the caller built.\n * @param target - the resolved target.\n * @returns the specification whose mount point is the target's folder.\n */\nexport function bindSbxMount(spec: RepoContainerSpec, target: ContainerTarget): RepoContainerSpec {\n return target.kind === 'sbx' && target.workspaceFolder !== spec.containerWorkspaceFolder\n ? { ...spec, containerWorkspaceFolder: target.workspaceFolder }\n : spec\n}\n\n/** The last lines of a CLI failure, for a diagnostic that fits in one sentence. */\nfunction failureDetail(result: { stdout: string; stderr: string }): string {\n return (result.stderr.trim() || result.stdout.trim() || 'no output').split('\\n').slice(-3).join(' ')\n}\n\n/**\n * Create one sandbox around a host workspace, without attaching to it.\n * @param spec - the sandbox specification.\n * @param sandboxName - the name to create.\n * @param run - the CLI runner.\n * @param signal - cancellation.\n * @throws Error when `sbx` is missing or the creation failed.\n */\nexport async function createSandbox(\n spec: RepoContainerSpec,\n sandboxName: string,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<void> {\n const result = await run(\n // The documented core form: the template (an agent-less shell) then the host\n // directory to mount. Progress output goes to the captured stream and is not\n // shown, so no suppression flag is needed — and no flag this CLI may not have.\n ['sbx', 'create', '--name', sandboxName, SANDBOX_TEMPLATE, spec.hostWorkspaceRoot],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n if (result.exitCode === null) throw new Error(`sbx: the CLI could not be started. ${SBX_INSTALL_HINT}`)\n if (result.exitCode !== 0) {\n throw new Error(`sbx: \"sbx create\" failed for ${spec.hostWorkspaceRoot} (sandbox \"${sandboxName}\"): ${failureDetail(result)}`)\n }\n}\n\n/**\n * Start one existing sandbox detached, so it survives the command that needed it.\n * @param spec - the sandbox specification.\n * @param sandboxName - the sandbox to start.\n * @param run - the CLI runner.\n * @param signal - cancellation.\n * @throws Error when `sbx` is missing or the start failed.\n */\nexport async function startSandbox(\n spec: RepoContainerSpec,\n sandboxName: string,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<void> {\n const result = await run(\n ['sbx', 'run', '--detach', '--name', sandboxName],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n if (result.exitCode === null) throw new Error(`sbx: the CLI could not be started. ${SBX_INSTALL_HINT}`)\n if (result.exitCode !== 0) {\n throw new Error(`sbx: \"sbx run\" could not start sandbox \"${sandboxName}\": ${failureDetail(result)}`)\n }\n}\n\n/**\n * Confirm the sandbox can run the filesystem helper.\n *\n * The helper is a `.mjs` program the sandbox starts with its own `node`, so a\n * sandbox image without one answers that exec with prose on the helper's pipe\n * instead of frames. Probing first turns that into a diagnostic that names the\n * missing runtime and the sandbox that lacks it.\n * @param spec - the sandbox specification, for its time budget.\n * @param sandboxName - the running sandbox to probe.\n * @param run - the CLI runner.\n * @param signal - cancellation.\n * @throws Error when the sandbox has no `node` on PATH.\n */\nexport async function assertSandboxNode(\n spec: RepoContainerSpec,\n sandboxName: string,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<void> {\n const result = await run(\n ['sbx', 'exec', sandboxName, '--', 'which', 'node'],\n { ...signal === undefined ? {} : { signal }, timeoutMs: spec.containerTimeoutMs },\n )\n if (result.exitCode === 0 && result.stdout.trim() !== '') return\n throw new Error(\n `sbx: Docker Sandbox \"${sandboxName}\" does not have Node.js installed, so the filesystem bridge and the tools `\n + 'that use it cannot run there. Install Node.js 18 or newer inside the sandbox (for example '\n + `\"sbx exec ${sandboxName} -- sudo apt-get install -y nodejs\", or an official tarball from nodejs.org `\n + 'unpacked into /usr/local), then retry. '\n + `The probe \"sbx exec ${sandboxName} -- which node\" reported: ${failureDetail(result)}`,\n )\n}\n\n/**\n * Resolve the sandbox agent commands run in, creating or starting it when asked.\n *\n * A sandbox that `sbx ls` lists as running is used as it is. Otherwise, and only\n * with `ensureUp`, a missing sandbox is created around the host workspace and an\n * existing one is started detached. Without `ensureUp` the resolver reports the\n * state instead of changing it.\n *\n * Either way the sandbox is probed for `node` before it is returned: without one\n * it cannot start the filesystem helper, and reporting the missing runtime here\n * is more useful than the broken pipe it would otherwise cause.\n *\n * The listing also names the mounts, so the returned target carries the folder\n * the sandbox really has for this workspace instead of the host spelling.\n * @param spec - the sandbox specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe / start sequence.\n * @returns the sandbox target.\n * @throws Error when `sbx` is missing, the sandbox cannot be prepared, one is required and absent, or it has no Node.js.\n */\nexport async function resolveSbxTarget(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n): Promise<ContainerTarget> {\n const name = sandboxNameOf(spec)\n const listing = await listSandboxes(run, spec.containerTimeoutMs, signal)\n if (!listing.available) throw new Error(`sbx: ${SBX_INSTALL_HINT}`)\n const listed = listing.sandboxes.find(sandbox => sandbox.name === name)\n // The mounts this row reports decide where the workspace really is inside the\n // sandbox; a row that mounts nothing of this workspace, or no row at all, keeps\n // the specification's own folder.\n const target = sbxTargetOf(spec, listed?.mounts ?? [])\n if (listed?.running === true) {\n await assertSandboxNode(spec, name, run, signal)\n return target\n }\n if (!spec.ensureUp) {\n throw new Error(listed === undefined\n ? `sbx: no Docker Sandbox named \"${name}\" exists for \"${spec.hostWorkspaceRoot}\"; create it with \"sbx create --name ${name} ${SANDBOX_TEMPLATE} ${spec.hostWorkspaceRoot}\", or set ensureUp: true`\n : `sbx: Docker Sandbox \"${name}\" for \"${spec.hostWorkspaceRoot}\" is not running; start it with \"sbx run --detach --name ${name}\", or set ensureUp: true`)\n }\n if (listed === undefined) await createSandbox(spec, name, run, signal)\n await startSandbox(spec, name, run, signal)\n await assertSandboxNode(spec, name, run, signal)\n return target\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,4BAA8C;CACzD,OAAO;CACP,KAAK;CACL,UAAU;CACV,oBAAoB;CACpB,kBAAkB;AACpB;;;;;;;;AASA,SAAgB,iBAAiB,SAAoC,CAAC,GAAqB;CACzF,OAAO;EACL,OAAO,OAAO,SAAS,0BAA0B;EACjD,KAAK,OAAO,OAAO,0BAA0B;EAC7C,UAAU,OAAO,YAAY,0BAA0B;EACvD,oBAAoB,OAAO,sBAAsB,0BAA0B;EAC3E,kBAAkB,OAAO,oBAAoB,0BAA0B;CACzE;AACF;;;;;;;;;AAUA,SAAgB,wBAAwB;CACtC,OAAO;EACL,OAAO,EAAE,OAAO,CAAC,CAAC,QAAQ,0BAA0B,KAAK;EACzD,KAAK,EAAE,MAAM;GAAC;GAAQ;GAAgB;GAAU;EAAK,CAAU,CAAC,CAAC,QAAQ,0BAA0B,GAAG;EACtG,UAAU,EAAE,QAAQ,CAAC,CAAC,QAAQ,0BAA0B,QAAQ;EAChE,oBAAoB,EAAE,OAAO,CAAC,CAAC,QAAQ,0BAA0B,kBAAkB;EACnF,kBAAkB,EAAE,QAAQ,CAAC,CAAC,QAAQ,0BAA0B,gBAAgB;CAClF;AACF;;;;;;;;;AAwBA,SAAgB,qBAAqB;CACnC,OAAO;EACL,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,QAAQ,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