@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sbx-Blgjzzoe.js","names":[],"sources":["../src/paths.ts","../src/host-mounts.ts","../src/sbx-template.ts","../src/options.ts","../src/ids.ts","../src/refusal.ts","../src/jsonc.ts","../src/config-loader.ts","../src/registry.ts","../src/sbx.ts"],"sourcesContent":["/**\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/** How one mount point is matched. */\nexport interface RemainderOptions {\n /** Compare case-insensitively, keeping the caller's spelling in the answer. */\n readonly fold?: boolean\n}\n\n/**\n * Match a path against a container mount point.\n *\n * A Windows drive path reaches a sandbox as a lowercase drive segment and a caller\n * may write it either way, so a fold belongs to the comparison only: the answer is\n * always sliced from the candidate, never from the mount point.\n * @param path - candidate path, in either separator style.\n * @param folder - the container mount point.\n * @param options - whether to fold case while comparing.\n * @returns the POSIX remainder (`''` for the mount point itself), or undefined when the path is elsewhere.\n */\nexport function containerRemainder(\n path: string, folder: string, options: RemainderOptions = {},\n): string | undefined {\n const normalized = posix.normalize(toPosixSlashes(path))\n const root = posix.normalize(toPosixSlashes(folder))\n const left = options.fold === true ? normalized.toLowerCase() : normalized\n const right = options.fold === true ? root.toLowerCase() : root\n if (left === right) return ''\n const prefix = right.endsWith('/') ? right : `${right}/`\n return left.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/** One extra mount a runtime reported: a host path and the path it has inside. */\nexport interface ExtraMount {\n /** The host path the mount originates from, in the host's own path style. */\n readonly host: string\n /** Absolute POSIX path the same path has inside the runtime. */\n readonly sandbox: string\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 * @param mounts - extra read-only mounts the runtime reported beside the workspace.\n * @returns the POSIX container path; a path outside the repository comes back slash-normalized.\n */\nexport function toContainerPath(path: string, spec: RepoContainerSpec, mounts: readonly ExtraMount[] = []): 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 relative === '' ? folder : joinMount(folder, relative)\n // A mount the runtime reported beside the workspace is a second host directory\n // the session may name — the host's global skills and AGENTS.md. The translation\n // is the mount's, so the path the fence is asked about is the one that exists.\n for (const mount of mounts) {\n const withinMount = relativeWithinHostRoot(path, mount.host)\n if (withinMount === undefined) continue\n return withinMount === '' ? mount.sandbox : posix.join(mount.sandbox, withinMount)\n }\n return toPosixSlashes(path)\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 * @param mounts - extra read-only mounts the runtime reported beside the workspace.\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, mounts: readonly ExtraMount[] = []): 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 for (const candidate of containerCandidates(path)) {\n for (const mount of mounts) {\n const withinMount = containerRemainder(candidate, mount.sandbox, { fold: isWindowsPath(mount.host) })\n if (withinMount === undefined) continue\n return withinMount === '' ? normalizeHostRoot(mount.host) : joinHostRoot(mount.host, withinMount)\n }\n }\n return path\n}\n\n","/**\n * The extra read-only host paths a Docker Sandbox mounts beside the workspace.\n *\n * A `(sbx)` session's filesystem fence ends at the workspace mount, so the host's\n * global agent configuration — its `AGENTS.md` and its skill trees — is invisible\n * from inside the sandbox. `sbx create` takes further host paths as positional\n * arguments (`PATH[:TARGET][:ro]`), which is the one place they can be added: a\n * single file must carry `:ro`, and a source that does not exist is a hard CLI\n * failure, so this module decides what may be mounted before the argv is built.\n * @module @banzhe/dsh-devcontainer/host-mounts\n */\n\nimport { access } from 'node:fs/promises'\nimport { posix } from 'node:path'\nimport { resolveAgentsHome, resolveDshHome } from '@deepseek-ai/dsh-home-paths'\nimport { isPosixAbsolute, isWindowsPath, joinHostRoot, normalizeHostRoot, toPosixSlashes } from './paths.ts'\nimport type { HostMount, HostMountsConfig } from './types.ts'\n\n/** What a row that configures nothing mounts: every default path that exists. */\nexport const HOST_MOUNT_DEFAULTS = 'auto'\n\n/** The two user roots the default mount set is read from. */\nexport interface HostMountHomes {\n /** The DeepSeek Harness home (`$DSH_HOME`, `~/.dsh` by default). */\n readonly dshHome: string\n /** The shared agent configuration root (`$DSH_AGENTS_HOME`, `~/.agents` by default). */\n readonly agentsHome: string\n}\n\n/**\n * Resolve the two user roots through DSH's own home rules, so an override the\n * harness honours is the directory the sandbox mounts.\n * @returns both roots, resolved and normalized.\n */\nexport function hostMountHomes(): HostMountHomes {\n return {\n dshHome: normalizeHostRoot(resolveDshHome()),\n agentsHome: normalizeHostRoot(resolveAgentsHome()),\n }\n}\n\n/** The optional mode token a mount expression ends with. */\nconst MODE_SUFFIX = /:(ro|rw)$/i\n\n/**\n * Strip the mode token a mount expression or a listing entry ends with.\n *\n * `sbx` reports a read-only mount as `host:sandbox:ro`, so the token has to come\n * off before the two paths are split — otherwise it stays on the sandbox side and\n * names a path no sandbox has. One implementation serves the row's own entries and\n * the listing, so the two cannot drift apart.\n * @param entry - one mount expression, or one entry of a row's `mounts`/`workspaces` array.\n * @returns the entry without its mode token, and whether it asked for read-only.\n */\nexport function splitMountMode(entry: string): { readonly text: string, readonly readOnly: boolean } {\n const match = MODE_SUFFIX.exec(entry)\n if (match === null) return { text: entry, readOnly: false }\n return { text: entry.slice(0, match.index), readOnly: match[1]?.toLowerCase() === 'ro' }\n}\n\n/** A drive letter left dangling at the end of a path, as a split would leave it. */\nconst TRAILING_DRIVE = /:[A-Za-z]$/\n\n/**\n * Split a `PATH[:/TARGET]` body into its host path and the sandbox path it asks for.\n *\n * The split point is the last `:/` whose left side is an absolute host path, so a\n * drive colon stays part of the path however the drive is spelled: `D:\\data\\x`\n * and `D:/data/x` both name no target, while `D:/data/x:/mnt/x` names `/mnt/x`.\n * A body that splits nowhere names its tail as the target, which lets the reader\n * reject the entry instead of mistaking a second path for part of the first.\n * @param text - the expression with its mode token already removed.\n * @returns the host path as written, and the target when the entry names one.\n */\nexport function splitHostTarget(text: string): { readonly host: string, readonly target?: string } {\n let separator = text.lastIndexOf(':/')\n while (separator > 0) {\n const candidate = text.slice(0, separator)\n // A candidate ending in a bare drive letter is the tail of a second drive path,\n // not a host path: `C:/a/b.md:D:/c.md` must not be read as host `C:/a/b.md:D`.\n if ((isWindowsPath(candidate) || isPosixAbsolute(candidate)) && !TRAILING_DRIVE.test(candidate)) {\n return { host: candidate, target: text.slice(separator + 1) }\n }\n separator = text.lastIndexOf(':/', separator - 1)\n }\n // Nothing splits into an absolute host path and a sandbox path, so the entry is\n // malformed: name the tail after the host path, which is what a diagnostic about\n // an unusable target has to show.\n const colon = text.indexOf(':', 2)\n return colon === -1 ? { host: text } : { host: text.slice(0, colon), target: text.slice(colon + 1) }\n}\n\n/** One configured entry, read into what the argv can carry — or rejected with the reason. */\ninterface MountEntry {\n /** The mount the entry names, when it names a usable one. */\n readonly mount?: HostMount\n /** The sentence to report instead, when it does not. */\n readonly rejection?: string\n}\n\n/**\n * The sentence one entry with an unusable target is reported with.\n * @param expression - the entry as the row configured it.\n * @param target - the sandbox path it named.\n * @returns the diagnostic, naming the entry and the rule it breaks.\n */\nfunction targetRejection(expression: string, target: string): string {\n return 'devcontainer: the host mount \"' + expression.trim() + '\" names the sandbox path \"' + target\n + '\", which is not an absolute path inside the sandbox; a target must start with \"/\" (for example'\n + ' \"/mnt/x.md\"), so this mount is skipped'\n}\n\n/**\n * The sentence one entry whose target IS the sandbox root is reported with.\n *\n * Mounting a host directory at `/` would put it over everything the sandbox has,\n * including the workspace, so the entry is refused rather than obeyed.\n * @param expression - the entry as the row configured it.\n * @param target - the sandbox path it named.\n * @returns the diagnostic, naming the entry and the rule it breaks.\n */\nfunction rootTargetRejection(expression: string, target: string): string {\n return 'devcontainer: the host mount \"' + expression.trim() + '\" names the sandbox path \"' + target\n + '\", which is the sandbox root; a target must name a path inside the sandbox (for example'\n + ' \"/mnt/x.md\"), so this mount is skipped'\n}\n\n/**\n * Read one entry of the row's list.\n *\n * The mode token goes first because only it is at the very end. A path in neither\n * host style is kept as written: it cannot be mounted, and the diagnostic that\n * names it should show what was typed. A target that is not POSIX-absolute — a\n * second drive path, say — or that names the sandbox root makes the whole entry\n * unusable: it is reported as such rather than re-read as part of the host path,\n * which would turn a spelling mistake into a misleading \"the source does not exist\".\n * @param expression - one entry of the row's `hostMounts` list.\n * @returns the entry, or undefined for a blank one.\n */\nfunction readEntry(expression: string): MountEntry | undefined {\n const text = expression.trim().replace(MODE_SUFFIX, '').trim()\n if (text === '') return undefined\n const { host: spelled, target } = splitHostTarget(text)\n const host = isWindowsPath(spelled) || isPosixAbsolute(spelled) ? normalizeHostRoot(spelled) : spelled\n if (target === undefined) return { mount: { host } }\n if (!isPosixAbsolute(target)) return { rejection: targetRejection(expression, target) }\n if (posix.normalize(toPosixSlashes(target)) === '/') return { rejection: rootTargetRejection(expression, target) }\n return { mount: { host, target } }\n}\n\n/**\n * Read one `PATH[:TARGET][:ro]` expression.\n * @param expression - one entry of the row's `hostMounts` list.\n * @returns the mount, or undefined for a blank entry or one naming an unusable target.\n */\nexport function parseHostMount(expression: string): HostMount | undefined {\n return readEntry(expression)?.mount\n}\n\n/**\n * The configured entries that cannot be mounted as written.\n * @param value - the row's `hostMounts` value.\n * @returns one diagnostic per entry whose target is not a sandbox path.\n */\nexport function hostMountRejections(value: HostMountsConfig | undefined): string[] {\n const configured = value ?? HOST_MOUNT_DEFAULTS\n if (configured === 'off' || configured === 'auto') return []\n return configured.flatMap((expression) => {\n const rejection = readEntry(expression)?.rejection\n return rejection === undefined ? [] : [rejection]\n })\n}\n\n/**\n * Expand one configured value into the mounts a created sandbox asks for.\n *\n * `auto` is the host's shared agent configuration: the `AGENTS.md` each root may\n * carry and the skill tree each may carry. `off` asks for nothing. A list is\n * taken as written, in order, with the read-only token the CLI needs added by\n * {@link hostMountArgument}. Nothing here looks at the host: whether a source\n * exists is decided in {@link hostMountSourceExists}, at the moment a sandbox is\n * created or started.\n * @param value - the row's `hostMounts` value; omitted means {@link HOST_MOUNT_DEFAULTS}.\n * @param homes - the two user roots, resolved by {@link hostMountHomes} by default.\n * @returns the declared mounts, in the order the argv carries them.\n */\nexport function hostMountPlan(\n value: HostMountsConfig | undefined,\n homes: HostMountHomes = hostMountHomes(),\n): HostMount[] {\n const configured = value ?? HOST_MOUNT_DEFAULTS\n if (configured === 'off') return []\n if (configured === 'auto') {\n return [\n { host: joinHostRoot(homes.dshHome, 'AGENTS.md') },\n { host: joinHostRoot(homes.agentsHome, 'AGENTS.md') },\n { host: joinHostRoot(homes.dshHome, 'skills') },\n { host: joinHostRoot(homes.agentsHome, 'skills') },\n ]\n }\n return configured.flatMap((expression) => {\n const mount = readEntry(expression)?.mount\n return mount === undefined ? [] : [mount]\n })\n}\n\n/**\n * The positional argument one mount becomes.\n *\n * Always read-only: the token is what lets `sbx` mount a single file at all, and\n * a session that could write the host's skills or `AGENTS.md` would be editing\n * configuration the container is not supposed to own.\n * @param mount - the declared mount.\n * @returns `host` or `host:target`, followed by `:ro`.\n */\nexport function hostMountArgument(mount: HostMount): string {\n const target = mount.target === undefined ? '' : `:${mount.target}`\n return `${mount.host}${target}:ro`\n}\n\n/**\n * Whether the host path one mount names exists right now.\n *\n * `sbx` fails the whole `create` — or, once the sandbox exists, the automatic\n * start behind `exec` — when a mount source is gone, and an interactive CLI may\n * offer to create it. Neither is acceptable here: the source is the user's, so a\n * missing one is reported and the mount is dropped instead.\n * @param mount - the declared mount.\n * @returns true when the host path is present.\n */\nexport async function hostMountSourceExists(mount: HostMount): Promise<boolean> {\n try {\n await access(mount.host)\n return true\n } catch {\n return false\n }\n}\n\n/**\n * Normalize a configured value a settings write or a Loader row may hand over.\n *\n * The field is volatile, so what a row holds is the live reference rather than the\n * value inside it, and a write may land between two reads: it is unwrapped here,\n * at the moment of use. A value the schema never validated — an absent row, a\n * programmatic `apply` — reads as {@link HOST_MOUNT_DEFAULTS}, which is what the\n * field defaults to.\n * @param value - the configured value, in any state.\n * @returns the value as {@link HostMountsConfig}.\n */\nexport function hostMountsConfig(value: unknown): HostMountsConfig {\n const held: unknown = typeof (value as { get?: unknown } | undefined)?.get === 'function'\n ? (value as { get(): unknown }).get()\n : value\n if (held === 'auto' || held === 'off') return held\n if (Array.isArray(held)) {\n return held.filter((entry): entry is string => typeof entry === 'string')\n }\n return HOST_MOUNT_DEFAULTS\n}\n","/**\n * The image a Docker Sandbox is created with, as one argv token.\n *\n * The rule is shared by three callers that cannot reach each other's modules: the\n * row schema that validates the setting, the settings page in the browser that\n * writes it, and the argv builder that hands it to `sbx`. It therefore lives in a\n * module of its own — no Node import — so all three read one definition instead of\n * three copies.\n * @module @banzhe/dsh-devcontainer/sbx-template\n */\n\n/**\n * What a configured image may look like: nothing at all, or one argv token with\n * no whitespace of its own and no leading `-`.\n *\n * Surrounding whitespace is tolerated and trimmed, because the value is a person's\n * typing and the token is what reaches the CLI. A leading `-` is not, because the\n * CLI would read the value as another flag, and neither is an inner space, which\n * `sbx` would split into two arguments.\n */\nexport const SANDBOX_TEMPLATE_PATTERN = /^\\s*(?:[^\\s-]\\S*)?\\s*$/u\n\n/**\n * The image one configured value names, trimmed, or undefined when it names none.\n * @param value - the configured `sbxTemplate`.\n * @returns the image to pass as `--template`, or undefined for the CLI's own template.\n * @throws Error when the value cannot travel as one argv token.\n */\nexport function sandboxTemplateOf(value: string): string | undefined {\n if (!SANDBOX_TEMPLATE_PATTERN.test(value)) {\n throw new Error(`sbx: sbxTemplate ${JSON.stringify(value)} cannot be passed as one image name: it must contain no whitespace and must not start with \"-\"`)\n }\n const image = value.trim()\n return image === '' ? undefined : image\n}\n","/**\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 { HOST_MOUNT_DEFAULTS } from './host-mounts.ts'\nimport { SANDBOX_TEMPLATE_PATTERN } from './sbx-template.ts'\nimport type { ContainerOptions, HostMountsConfig } 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/** Defaults for {@link SandboxTemplateOptions}: no image, so the CLI template stands. */\nexport const SANDBOX_TEMPLATE_DEFAULTS: SandboxTemplateOptions = {\n sbxTemplate: '',\n}\n\n/** The sandbox image a created Docker Sandbox runs, owned by the Host row. */\nexport interface SandboxTemplateOptions {\n /** Image `sbx create --template` takes; blank keeps Docker's `shell` template. */\n sbxTemplate: string\n}\n\n/**\n * The image field as the Loader validates it.\n *\n * It is `volatile`, so the settings page writes it into the live reference the\n * rows read on their next command instead of needing a reload, and it is a default\n * of the Host row only: the shell and filesystem rows have no settings page, and\n * two more copies would be two more values to keep in step.\n * @returns schemastery fields for {@link SandboxTemplateOptions}.\n */\nexport function sandboxTemplateFields() {\n return {\n sbxTemplate: z.string().default(SANDBOX_TEMPLATE_DEFAULTS.sbxTemplate).pattern(SANDBOX_TEMPLATE_PATTERN).volatile(),\n }\n}\n\n/** The extra read-only host paths a created Docker Sandbox mounts, owned by the Host row. */\nexport interface HostMountOptions {\n /**\n * `auto` mounts the host's `AGENTS.md` and skill trees when they exist, `off`\n * mounts none, and a list names the `PATH[:TARGET][:ro]` entries to mount. Every\n * entry is mounted read-only and skipped when its source is missing.\n */\n hostMounts: HostMountsConfig\n}\n\n/**\n * The extra-mount field as the Loader validates it.\n *\n * A default of the Host row only, like the image: the rows that create a sandbox\n * read it through the registry reader, so the value has one owner and one shape. It\n * is `volatile` for the same reason the image is, so a settings write lands in the\n * live reference the rows read on their next command.\n * @returns schemastery fields for {@link HostMountOptions}.\n */\nexport function hostMountFields() {\n return {\n hostMounts: z\n .union([z.const('auto'), z.const('off'), z.array(z.string())])\n .default(HOST_MOUNT_DEFAULTS)\n .volatile(),\n }\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 metadata probe outside every mount reports.\n *\n * A sandbox filesystem holds its workspace and the mounts its row declares; a probe\n * of anything else is answered as the absence it is, in one line, without the escape\n * wording a refused read or write gets.\n * @param path - the path the probe named.\n * @returns the diagnostic, ending without a newline so the seam reports it verbatim.\n */\nexport function fsUnmountedText(path: string): string {\n return `devcontainer: \"${path}\" is not inside any mount of this session's container, so its filesystem has no such path`\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 state each composition shares between the Bundle's three Loader rows: the\n * discovery cache, and the sandbox image the Host row configures.\n *\n * The rows are separate Cordis plugins (one service each) but they must agree on\n * what \"this repository's container\" means, and the rows that create sandboxes\n * must see the image the settings page writes into the Host row. Keying both by\n * the composition root gives them one answer without letting two DSH instances in\n * the same process — or a reloaded plugin — inherit another's.\n * @module @banzhe/dsh-devcontainer/registry\n */\nimport type { Context } from '@deepseek-ai/cordis'\nimport { RepoContainerRegistry } from './config-loader.ts'\nimport { HOST_MOUNT_DEFAULTS, hostMountRejections } from './host-mounts.ts'\nimport type { ContainerOptions, HostMountsConfig } from './types.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/** The live sandbox image one row publishes, per composition root. */\nconst SANDBOX_TEMPLATES = new WeakMap<object, () => string | undefined>()\n\n/**\n * Publish the image the Host row configures right now to the composition's other\n * rows.\n *\n * `sbxTemplate` belongs to the Host row alone — the row the settings page writes,\n * because a page writes its own namespace — while the rows that run commands and\n * files are the ones that create a sandbox. The reader is registered once and\n * called at the moment a specification is built, so a settings write is answered\n * by the very next command instead of the next reload; nothing is copied at mount\n * time, when the profile patch may not have landed yet.\n * @param scope - the registering row's context.\n * @param read - the reader; returning undefined means \"no image configured\".\n * @returns the disposer that withdraws the reader.\n */\nexport function registerSandboxTemplate(\n scope: Context | object, read: () => string | undefined,\n): () => void {\n const key = rootOf(scope)\n SANDBOX_TEMPLATES.set(key, read)\n return () => {\n if (SANDBOX_TEMPLATES.get(key) === read) SANDBOX_TEMPLATES.delete(key)\n }\n}\n\n/**\n * The image this composition's Host row configures right now.\n * @param scope - the calling row's context.\n * @returns the image, or undefined when that row configured none or is not loaded.\n */\nexport function liveSandboxTemplate(scope?: Context | object): string | undefined {\n return scope === undefined ? undefined : SANDBOX_TEMPLATES.get(rootOf(scope))?.()\n}\n\n/** The live extra-host-mount configuration one row publishes, per composition root. */\nconst HOST_MOUNTS = new WeakMap<object, () => HostMountsConfig>()\n\n/**\n * Publish the extra host mounts the Host row configures right now.\n *\n * `hostMounts` belongs to the Host row alone, while the rows that create a sandbox\n * are the shell, filesystem, and subprocess ones — the same split `sbxTemplate`\n * has, and it is answered the same way: the reader is called when a specification\n * is built, never copied at mount time.\n * @param scope - the registering row's context.\n * @param read - the reader; it answers the value in force at this moment.\n * @returns the disposer that withdraws the reader.\n */\nexport function registerHostMounts(scope: Context | object, read: () => HostMountsConfig): () => void {\n const key = rootOf(scope)\n HOST_MOUNTS.set(key, read)\n return () => {\n if (HOST_MOUNTS.get(key) === read) HOST_MOUNTS.delete(key)\n }\n}\n\n/**\n * The extra host mounts this composition's Host row configures right now.\n * @param scope - the calling row's context.\n * @returns the configured value, or the schema default when no row published one.\n */\nexport function liveHostMounts(scope?: Context | object): HostMountsConfig {\n return scope === undefined ? HOST_MOUNT_DEFAULTS : HOST_MOUNTS.get(rootOf(scope))?.() ?? HOST_MOUNT_DEFAULTS\n}\n\n/** The specification-builder options every sandbox seam passes: the row's defaults plus the Host row's live values. */\nexport interface SandboxSpecOptions extends ContainerOptions {\n /** Image a created sandbox runs, or undefined for the CLI's own template. */\n readonly sbxTemplate?: string | undefined\n /** The extra read-only host paths a created sandbox mounts beside the workspace. */\n readonly hostMounts?: HostMountsConfig | undefined\n}\n\n/** The diagnostics one composition already reported, so a row cannot repeat another's. */\nconst REPORTED = new WeakMap<object, Set<string>>()\n\n/**\n * Report one diagnostic once per composition.\n *\n * The shell, filesystem, and subprocess rows each resolve the same sandbox from\n * their own cache, so the same configuration mistake reaches several of them: a\n * person should read it once. The message carries the setting it is about, so a\n * changed setting is a new message and is reported again.\n * @param scope - the reporting row's context.\n * @param warn - where the message goes; nothing happens without one.\n * @param message - the diagnostic.\n */\nexport function warnOnce(\n scope: Context | object | undefined, warn: ((message: string) => void) | undefined, message: string,\n): void {\n if (warn === undefined) return\n if (scope === undefined) {\n warn(message)\n return\n }\n const key = rootOf(scope)\n let reported = REPORTED.get(key)\n if (reported === undefined) {\n reported = new Set()\n REPORTED.set(key, reported)\n }\n if (reported.has(message)) return\n reported.add(message)\n warn(message)\n}\n\n/**\n * The entries this composition's Host row configures that no argv can carry.\n * @param scope - the calling row's context.\n * @returns one diagnostic per unusable entry, empty when every entry is usable.\n */\nexport function liveHostMountRejections(scope?: Context | object): readonly string[] {\n return hostMountRejections(liveHostMounts(scope))\n}\n\n/**\n * Read the live sandbox settings once, for one specification.\n * @param scope - the calling row's context.\n * @param options - the row's own container defaults.\n * @returns the builder options, carrying whatever the Host row configures right now.\n */\nexport function liveSbxOptions(scope: Context | object, options: ContainerOptions): SandboxSpecOptions {\n const template = liveSandboxTemplate(scope)\n return {\n ...options,\n ...template === undefined ? {} : { sbxTemplate: template },\n hostMounts: liveHostMounts(scope),\n }\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> [--template <image>] shell <path>` creates\n * one around a host directory without attaching, and `sbx run -d --name <name>`\n * starts an existing sandbox detached. `sbx exec` reports a missing sandbox with\n * 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 { ExtraMount } from './paths.ts'\nimport {\n hostMountArgument,\n hostMountPlan,\n hostMountSourceExists,\n splitHostTarget,\n splitMountMode,\n} from './host-mounts.ts'\nimport type { SandboxSpecOptions } from './registry.ts'\nimport { sandboxTemplateOf } from './sbx-template.ts'\nimport type { HostMount, 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 positional agent a created sandbox runs: Docker's agent-less shell agent. */\nexport const SANDBOX_TEMPLATE = 'shell'\n\n/**\n * The flag that picks the IMAGE a created sandbox runs, as opposed to\n * {@link SANDBOX_TEMPLATE}, which is the agent it starts.\n */\nexport const SANDBOX_TEMPLATE_FLAG = '--template'\n\n/**\n * The `--template` arguments one specification adds to `sbx create`.\n * @param spec - the sandbox specification.\n * @returns `['--template', image]`, or nothing when the row configured no image.\n * @throws Error when the configured value cannot travel as one argv token.\n */\nexport function sandboxTemplateArgs(spec: RepoContainerSpec): string[] {\n const image = spec.sbxTemplate === undefined ? undefined : sandboxTemplateOf(spec.sbxTemplate)\n return image === undefined ? [] : [SANDBOX_TEMPLATE_FLAG, image]\n}\n\n/**\n * The extra read-only positionals one specification asks for, as declared.\n *\n * This is the argv shape without asking the host whether the sources exist, which\n * is what a diagnostic that names the command should show; `createSandbox`\n * filters it against the host before it runs.\n * @param spec - the sandbox specification.\n * @returns one `PATH[:TARGET]:ro` argument per declared mount, in declaration order.\n */\nfunction hostMountArgsOf(spec: RepoContainerSpec): string[] {\n return (spec.hostMounts ?? []).map(hostMountArgument)\n}\n\n/**\n * The tail of the `sbx create` argv one specification issues: the image flags,\n * the agent, the host directory to mount, and the extra read-only host paths.\n * @param spec - the sandbox specification.\n * @param extra - the extra mount arguments to append; the declared ones by default.\n * @returns the flags and positionals that follow `--name`.\n * @throws Error when the configured image cannot travel as one argv token.\n */\nfunction createTailOf(spec: RepoContainerSpec, extra: readonly string[] = hostMountArgsOf(spec)): string[] {\n return [...sandboxTemplateArgs(spec), SANDBOX_TEMPLATE, spec.hostWorkspaceRoot, ...extra]\n}\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 path a sandbox mounts, with the path it has inside the sandbox. */\nexport interface SandboxMount extends ExtraMount {\n /**\n * Whether the sandbox mounted it read-only, which the listing reports as a\n * `:ro` token on the entry and not as a field. Absent means read-write, or an\n * entry whose form says nothing about it.\n */\n readonly readOnly?: boolean\n}\n\n/** One host path a sandbox takes as a workspace, as its `workspaces` list reports it. */\nexport interface SandboxWorkspace {\n /** The host path the sandbox mounted as a workspace, in the host's own path style. */\n readonly host: string\n /** Whether the sandbox mounted that workspace read-only. */\n readonly readOnly?: boolean\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 * The paths it was asked to mount: the workspace first, then every host path the\n * `create` named, in order. Empty when the row reported none this module can read.\n *\n * This is what tells a workspace from an extra mount: `mounts` also carries the\n * mounts `sbx` injects for itself, such as its agent skill store.\n */\n readonly workspaces: readonly SandboxWorkspace[]\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/** The first string-valued field of a row, when it carries one. */\nfunction firstString(row: Record<string, unknown>, names: readonly string[]): string | undefined {\n for (const name of names) {\n const value = row[name]\n if (typeof value === 'string' && value.trim() !== '') return value.trim()\n }\n return undefined\n}\n\n/**\n * Read one mount entry a listing reports.\n *\n * The mode token and the two paths are read by the same splitter the row's own\n * `hostMounts` entries go through ({@link splitMountMode} and\n * {@link splitHostTarget}), so a listing and a configuration cannot disagree about\n * what one entry means. 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. The object form is accepted\n * with the field names a later listing may use, so a release that switches from\n * the `host:sandbox` string to an object does not silently report no mounts.\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') {\n const { text, readOnly } = splitMountMode(value.trim())\n const { host: spelled, target } = splitHostTarget(text)\n const host = spelled.trim()\n const sandbox = target?.trim()\n if (sandbox === undefined) return undefined\n if (!isWindowsPath(host) && !isPosixAbsolute(host)) return undefined\n if (!isPosixAbsolute(sandbox)) return undefined\n return { host, sandbox, readOnly }\n }\n if (typeof value !== 'object' || value === null) return undefined\n const row = value as Record<string, unknown>\n const host = firstString(row, ['host', 'source', 'src', 'hostPath'])\n const sandbox = firstString(row, ['sandbox', 'destination', 'dst', 'target'])\n if (host === undefined || sandbox === undefined) return undefined\n if (!isWindowsPath(host) && !isPosixAbsolute(host)) return undefined\n if (!isPosixAbsolute(sandbox)) return undefined\n return { host, sandbox, readOnly: row['readOnly'] === true || row['read_only'] === true }\n}\n\n/**\n * Read one `workspaces` entry, which is an absolute host path that may end in `:ro`.\n * @param value - one entry of a row's `workspaces` array.\n * @returns the workspace, or undefined when the entry names no absolute host path.\n */\nfunction sandboxWorkspace(value: unknown): SandboxWorkspace | undefined {\n if (typeof value !== 'string') return undefined\n const { text, readOnly } = splitMountMode(value.trim())\n if (!isWindowsPath(text) && !isPosixAbsolute(text)) return undefined\n return { host: text, readOnly }\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/** The workspaces one row reports, in the order it reports them. */\nfunction workspacesOf(row: Record<string, unknown>): SandboxWorkspace[] {\n const listed = row['workspaces']\n if (!Array.isArray(listed)) return []\n return listed.map(sandboxWorkspace).filter((workspace): workspace is SandboxWorkspace => workspace !== 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 const workspaces = workspacesOf(row)\n if (row['running'] === true || row['detached'] === true) return { name: name.trim(), running: true, mounts, workspaces }\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, workspaces }\n }\n }\n return { name: name.trim(), running: false, mounts, workspaces }\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 recordListing(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 * What one sandbox's last listing reported, together with what the last\n * specification built for it declares.\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 */\ninterface SandboxRecord {\n /** The mounts the last listing reported, which include the ones `sbx` injects itself. */\n mounts: readonly SandboxMount[]\n /** The `workspaces` the last listing reported: the workspace first, then the declared extra hosts. */\n workspaces: readonly SandboxWorkspace[]\n /** The extra host paths the last specification built for this sandbox declares. */\n declared: readonly HostMount[]\n /** The host workspace that specification mounted. */\n workspaceRoot?: string\n}\n\n/** What is known about each sandbox, for the life of the process. */\nconst sandboxRecords = new Map<string, SandboxRecord>()\n\n/** The record of one sandbox, created empty when nothing is known about it yet. */\nfunction recordOf(name: string): SandboxRecord {\n const existing = sandboxRecords.get(name)\n if (existing !== undefined) return existing\n const created: SandboxRecord = { mounts: [], workspaces: [], declared: [] }\n sandboxRecords.set(name, created)\n return created\n}\n\n/**\n * Remember one listing, so the synchronous builders below can read it.\n * @param sandboxes - the sandboxes the listing reported.\n */\nfunction recordListing(sandboxes: readonly ListedSandbox[]): void {\n for (const sandbox of sandboxes) {\n const record = recordOf(sandbox.name)\n record.mounts = sandbox.mounts\n record.workspaces = sandbox.workspaces\n }\n}\n\n/**\n * Remember what one specification asks for, so a later attribution can name it.\n *\n * Only a specification a row BUILT carries a declared plan: one adopted from a\n * declaration has no say in what its host mounts, so it must not erase the plan\n * the row configured.\n * @param spec - the specification just built.\n */\nfunction recordSpec(spec: RepoContainerSpec): void {\n const record = recordOf(sandboxNameOf(spec))\n record.workspaceRoot = spec.hostWorkspaceRoot\n if (spec.hostMounts !== undefined) record.declared = spec.hostMounts\n}\n\n/** The host workspace of one sandbox, as its specification or its listing names it. */\nfunction workspaceRootOf(record: SandboxRecord): string | undefined {\n return record.workspaceRoot ?? record.workspaces[0]?.host\n}\n\n/**\n * The host paths one sandbox accepts beside its workspace.\n *\n * Only the workspace and the mounts the row itself declares are here. The rest of\n * a listing — the agent skill store `sbx` injects, for one — belongs to the\n * sandbox's own machinery, and a session must not be able to name it, so nothing\n * is admitted merely because the listing reported it.\n *\n * A listing without `workspaces` still names its workspace through the mount that\n * covers this specification's workspace root; that mount is the only one such a\n * row can be given outside the declared set.\n * @param record - what is known about the sandbox.\n * @returns the accepted mounts, the workspace first.\n */\nfunction acceptedMounts(record: SandboxRecord): readonly SandboxMount[] {\n const accepted: SandboxMount[] = []\n const reported = record.workspaces[0]\n const root = workspaceRootOf(record) ?? reported?.host\n if (root !== undefined) {\n const sandbox = sandboxMountFor(root, record.mounts)\n if (sandbox !== undefined) {\n accepted.push({\n host: normalizeHostRoot(root),\n sandbox,\n ...reported?.readOnly === undefined ? {} : { readOnly: reported.readOnly },\n })\n }\n }\n for (const mount of declaredMounts(record.declared, record.mounts, record.mounts.length > 0)) {\n if (accepted.some(candidate => sameHost(candidate.host, mount.host))) continue\n accepted.push(mount)\n }\n return accepted\n}\n\n/**\n * Resolve declared host paths to the paths the sandbox really has for them.\n *\n * The listing is the authority: it reports where each host path was mounted, so a\n * declaration it does not mention was never mounted and is left out. A declaration\n * that names its own target needs no lookup, and the host convention answers only\n * before any listing has run — the same drive-letter rule a sandbox uses for its\n * workspace, and the only thing available at that point.\n *\n * That convention guess is a deliberate, accepted exception to \"only what the\n * listing reported\": the paths it admits are the row's own declarations, which are\n * exactly the ones just handed to `sbx create`, so it widens nothing a listing\n * would have named. If the sandbox mounted one of them elsewhere, a read there\n * fails with `FS_NOT_FOUND` — a missing file inside an accepted root, never a\n * fence that opens onto something else.\n * @param declared - the host paths a row asked to mount.\n * @param mounts - the mounts a listing reported.\n * @param listed - whether a listing has reported this sandbox at all.\n * @returns one read-only mount per declaration the sandbox carries.\n */\nfunction declaredMounts(\n declared: readonly HostMount[], mounts: readonly SandboxMount[], listed: boolean,\n): SandboxMount[] {\n const resolved: SandboxMount[] = []\n for (const mount of declared) {\n const host = normalizeHostRoot(mount.host)\n const reported = sandboxMountFor(host, mounts)\n const sandbox = mount.target ?? reported ?? (listed ? undefined : sandboxWorkspacePath(host))\n if (sandbox === undefined) continue\n resolved.push({ host, sandbox, readOnly: true })\n }\n return resolved\n}\n\n/** Whether two host paths name the same file or directory, folding win32 case. */\nfunction sameHost(left: string, right: string): boolean {\n return relativeWithinHostRoot(left, right) === '' || relativeWithinHostRoot(right, left) === ''\n}\n\n/**\n * The extra read-only mounts one specification's sandbox carries.\n *\n * These are the paths a session may name beside its workspace, and nothing else a\n * listing reports: the fence, the path translation, and the helper's own guard are\n * all built from this list.\n * @param spec - the repository container specification.\n * @returns the declared mounts with their sandbox spellings; empty when none resolves.\n */\nexport function sbxExtraMountsOf(spec: RepoContainerSpec): readonly SandboxMount[] {\n if (spec.cli !== 'sbx') return []\n const record = sandboxRecords.get(sandboxNameOf(spec))\n const declared = spec.hostMounts ?? record?.declared ?? []\n if (declared.length === 0) return []\n const mounts = record?.mounts ?? []\n return declaredMounts(declared, mounts, mounts.length > 0)\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 workspace of the sandbox that mounts the path — present only when a\n * reported mount answered, because only a mount says which workspace a sandbox\n * has, while the host convention says just what the path is called.\n */\n readonly workspaceRoot?: string\n /**\n * The sandbox that mounts the path, present only when a reported mount answered.\n * It is the sandbox a call naming the path must run in, which is not the sandbox\n * of the host directory the path itself happens to live in — a mount of one host\n * file belongs to the workspace that mounted it, not to a sandbox named after it.\n */\n readonly sandbox?: 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) return mounted\n const drive = driveHostFor(normalized)\n return drive === undefined ? undefined : { host: drive }\n}\n\n/**\n * The sandbox whose workspace or declared extra mount covers one HOST path.\n *\n * A session names `C:\\Users\\me\\.dsh\\AGENTS.md` the way the host spells it, while\n * the sandbox that mounted it is the one whose workspace the session runs in — not\n * a sandbox invented around that file. This answers which one it is.\n * @param hostPath - an absolute host path.\n * @returns the host path and its sandbox, or undefined when no sandbox mounts it.\n */\nexport function sbxMountAttribution(hostPath: string): SandboxHostAttribution | undefined {\n const normalized = normalizeHostRoot(hostPath)\n let found: { readonly length: number, readonly attribution: SandboxHostAttribution } | undefined\n for (const [name, record] of sandboxRecords) {\n for (const mount of acceptedMounts(record)) {\n const relative = relativeWithinHostRoot(normalized, mount.host)\n if (relative === undefined) continue\n if (found !== undefined && found.length >= mount.host.length) continue\n const workspaceRoot = workspaceRootOf(record)\n found = {\n length: mount.host.length,\n attribution: {\n host: relative === '' ? normalizeHostRoot(mount.host) : joinHostRoot(mount.host, relative),\n ...workspaceRoot === undefined ? {} : { workspaceRoot: normalizeHostRoot(workspaceRoot) },\n sandbox: name,\n },\n }\n }\n }\n return found?.attribution\n}\n\n/** The host directory and workspace a reported mount covers, the deepest mount winning. */\nfunction mountedHostFor(sandboxPath: string): SandboxHostAttribution | undefined {\n let found: { readonly depth: number, readonly attribution: SandboxHostAttribution } | undefined\n for (const [name, record] of sandboxRecords) {\n const workspaceRoot = workspaceRootOf(record)\n for (const mount of acceptedMounts(record)) {\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 attribution: {\n host: relative === '' ? normalizeHostRoot(mount.host) : joinHostRoot(mount.host, relative),\n workspaceRoot: normalizeHostRoot(workspaceRoot ?? mount.host),\n sandbox: name,\n },\n }\n }\n }\n return found?.attribution\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 = sandboxRecords.get(sandboxNameOf(spec))?.mounts\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 *\n * The image a created sandbox runs is the Host row's `sbxTemplate` and nothing\n * else's: a declaration cannot choose the image of the host that mounts it. The\n * caller passes the value the Host row configures at this moment\n * (`liveSandboxTemplate`) on `options.sbxTemplate`, so a settings write is\n * answered by the next command, and it is carried on the specification so\n * `createSandbox` and the diagnostic that names the command both read the same one.\n *\n * The extra host mounts are the Host row's too, for the same reason: they are the\n * paths a sandbox mounts beside this workspace, and a declaration has no say in\n * them. The plan is carried on the specification, where the fence, the path\n * translation, and the helper's guard read it.\n * @param hostWorkspaceRoot - absolute host path of the workspace.\n * @param options - the row's container defaults, plus the image and mounts configured right now.\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: SandboxSpecOptions,\n declared?: RepoContainerSpec,\n mounts?: readonly SandboxMount[],\n): RepoContainerSpec {\n const root = normalizeHostRoot(hostWorkspaceRoot)\n const spec = declared !== undefined && normalizeHostRoot(declared.hostWorkspaceRoot) === root\n ? asSbxSpec(declared, mounts)\n : 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 // The image and the extra mounts are the row's, never a declaration's: a\n // repository cannot choose the sandbox image or the host configuration of the\n // host that mounts it, so the specification is rebuilt without whatever a\n // declaration carried and the live values decide alone.\n const image = options.sbxTemplate?.trim() ?? ''\n const { sbxTemplate: _declared, hostMounts: _declaredMounts, ...rest } = spec\n return {\n ...rest,\n hostMounts: hostMountPlan(options.hostMounts),\n ...image === '' ? {} : { sbxTemplate: image },\n }\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/** Reports a mount this Bundle could not establish, where a person running the session can see it. */\nexport type SandboxWarning = (message: string) => void\n\n/**\n * The declared mounts whose host source is gone.\n * @param spec - the sandbox specification.\n * @returns the declarations whose path does not exist right now.\n */\nasync function missingHostMounts(spec: RepoContainerSpec): Promise<HostMount[]> {\n const missing: HostMount[] = []\n for (const mount of spec.hostMounts ?? []) {\n if (!(await hostMountSourceExists(mount))) missing.push(mount)\n }\n return missing\n}\n\n/**\n * The declared mounts one existing sandbox did not take.\n *\n * The listing's `workspaces` is what answers, in order: the first entry is the\n * workspace, so a declaration missing from the rest was never mounted — it did not\n * exist when the sandbox was created. A listing that reports no `workspaces` is\n * read through its mounts, which is all an older CLI offers.\n * @param spec - the sandbox specification.\n * @param listed - the sandbox as the listing reports it.\n * @returns the declarations that sandbox does not mount.\n */\nfunction unmountedHostMounts(spec: RepoContainerSpec, listed: ListedSandbox): HostMount[] {\n const declared = spec.hostMounts ?? []\n if (declared.length === 0) return []\n const mounted = listed.workspaces.length === 0\n ? listed.mounts.map(mount => mount.host)\n : listed.workspaces.map(workspace => workspace.host)\n return declared.filter(mount => !mounted.some(host => sameHost(host, mount.host)))\n}\n\n/** The one sentence a mount whose source is gone is reported with. */\nfunction missingHostMountText(mount: HostMount, sandboxName: string): string {\n return 'devcontainer: the host mount source \"' + mount.host + '\" does not exist, so it is not mounted in sandbox \"'\n + sandboxName + '\"; create it, then remove the sandbox (\"sbx rm ' + sandboxName + '\") so it is created with that mount'\n}\n\n/** The one sentence a mount the sandbox carries whose host source vanished is reported with. */\nfunction brokenHostMountText(mount: HostMount, sandboxName: string): string {\n return 'devcontainer: sandbox \"' + sandboxName + '\" mounts \"' + mount.host\n + '\", whose source no longer exists on the host; restore it, or remove the sandbox (\"sbx rm '\n + sandboxName + '\") so it is created without that mount'\n}\n\n/** The one sentence a declaration an existing sandbox never took is reported with. */\nfunction unmountedHostMountText(mount: HostMount, sandboxName: string): string {\n return 'devcontainer: sandbox \"' + sandboxName + '\" does not mount \"' + mount.host + '\", which this row declares; '\n + 'remove the sandbox (\"sbx rm ' + sandboxName + '\") so it is created with that mount'\n}\n\n/** The failure of a start that cannot succeed, worded as what to do about it. */\nfunction missingMountStartText(sandboxName: string, mounts: readonly HostMount[]): string {\n const paths = mounts.map(mount => '\"' + mount.host + '\"').join(', ')\n return 'sbx: Docker Sandbox \"' + sandboxName + '\" cannot start: the host mount source ' + paths\n + ' no longer exists. Restore it, or remove the sandbox (\"sbx rm ' + sandboxName\n + '\") so it is created without that mount.'\n}\n\n/**\n * Report every declared mount the host or the sandbox does not carry.\n *\n * Only a mount the sandbox actually carries can make a start fail, so that is the\n * one case reported as a state a start cannot survive. A declaration whose source\n * is gone and that the sandbox never took is the ordinary `auto` situation — the\n * host has no `~/.agents/AGENTS.md`, say — and a sandbox without that mount starts\n * exactly as it always did; it is reported, never refused.\n * @param spec - the sandbox specification.\n * @param listed - the sandbox as the listing reports it.\n * @param warn - where the reports go; nothing is reported without one.\n * @returns the declarations the sandbox mounts whose host source is gone.\n */\nasync function reportMountState(\n spec: RepoContainerSpec, listed: ListedSandbox, warn: SandboxWarning | undefined,\n): Promise<HostMount[]> {\n const name = sandboxNameOf(spec)\n const missing = await missingHostMounts(spec)\n const unmounted = unmountedHostMounts(spec, listed)\n const broken: HostMount[] = []\n for (const mount of missing) {\n if (unmounted.some(candidate => sameHost(candidate.host, mount.host))) {\n warn?.(missingHostMountText(mount, name))\n continue\n }\n warn?.(brokenHostMountText(mount, name))\n broken.push(mount)\n }\n for (const mount of unmounted) {\n if (missing.some(candidate => sameHost(candidate.host, mount.host))) continue\n warn?.(unmountedHostMountText(mount, name))\n }\n return broken\n}\n\n/**\n * Create one sandbox around a host workspace, without attaching to it.\n *\n * The extra host mounts are appended as positional arguments, and only the ones\n * whose source exists right now: `sbx` fails the whole creation for a missing\n * source, and an interactive CLI offers to create one, which a session must never\n * do to a host path it was only given to read.\n * @param spec - the sandbox specification.\n * @param sandboxName - the name to create.\n * @param run - the CLI runner.\n * @param signal - cancellation.\n * @param warn - reports each declared mount whose source is gone.\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 warn?: SandboxWarning,\n): Promise<void> {\n recordSpec(spec)\n const extra: string[] = []\n for (const mount of spec.hostMounts ?? []) {\n if (await hostMountSourceExists(mount)) extra.push(hostMountArgument(mount))\n else warn?.(missingHostMountText(mount, sandboxName))\n }\n const result = await run(\n // The documented core form: an optional image, then the agent (an agent-less\n // shell), then the host directory to mount, then any further read-only host\n // paths. Progress output goes to the captured stream and is not shown, so no\n // suppression flag is needed — and no flag this CLI may not have.\n ['sbx', 'create', '--name', sandboxName, ...createTailOf(spec, extra)],\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 *\n * The extra host mounts are the one thing a sandbox cannot gain after it exists,\n * so this is also where their state is reported: a missing source is a diagnostic\n * (and, for a sandbox that has to start, a refusal worded as what to do), and a\n * declaration the sandbox never took is the same `sbx rm` advice. Nothing here\n * removes or recreates a sandbox — that is the user's call.\n * @param spec - the sandbox specification.\n * @param run - the CLI runner.\n * @param signal - cancellation of the probe / start sequence.\n * @param warn - reports a mount the sandbox does not carry, and a source that is gone.\n * @returns the sandbox target.\n * @throws Error when `sbx` is missing, the sandbox cannot be prepared, one is required and absent, it has no Node.js, or a start would fail on a mount the sandbox carries whose source is gone.\n */\nexport async function resolveSbxTarget(\n spec: RepoContainerSpec,\n run: ContainerRun,\n signal?: AbortSignal,\n warn?: SandboxWarning,\n): Promise<ContainerTarget> {\n const name = sandboxNameOf(spec)\n recordSpec(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 // A running sandbox keeps reading its mounts, so a source that is gone is\n // reported rather than refused: only the next start needs it.\n await reportMountState(spec, listed, warn)\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} ${createTailOf(spec).join(' ')}\", 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) {\n await createSandbox(spec, name, run, signal, warn)\n await startSandbox(spec, name, run, signal)\n await assertSandboxNode(spec, name, run, signal)\n // A sandbox that has just been created carries its extra mounts now, and only a\n // fresh listing says where `sbx` put them: the fence and the path translation\n // are built from what is recorded here. A create that asked for none has\n // nothing to learn, so it costs no second listing.\n if ((spec.hostMounts ?? []).length === 0) return target\n const refreshed = await listSandboxes(run, spec.containerTimeoutMs, signal)\n return sbxTargetOf(spec, refreshed.sandboxes.find(sandbox => sandbox.name === name)?.mounts ?? [])\n }\n const missing = await reportMountState(spec, listed, warn)\n if (missing.length > 0) throw new Error(missingMountStartText(name, missing))\n await startSandbox(spec, name, run, signal)\n await assertSandboxNode(spec, name, run, signal)\n return target\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAeA,MAAM,eAAe;AACrB,MAAM,aAAa;;;;;;AAOnB,SAAgB,cAAc,MAAuB;CACnD,OAAO,aAAa,KAAK,IAAI,KAAK,WAAW,KAAK,IAAI;AACxD;;AAGA,SAAgB,eAAe,MAAsB;CACnD,OAAO,KAAK,WAAW,MAAM,GAAG;AAClC;;;;;;;;AASA,SAAgB,gBAAgB,MAAuB;CACrD,OAAO,KAAK,WAAW,GAAG,KAAK,CAAC,cAAc,IAAI;AACpD;;;;;;AAOA,SAAgB,cAAc,UAAqC;CACjE,OAAO,cAAc,QAAQ,IAAI,UAAU;AAC7C;;AAGA,SAAgB,kBAAkB,UAA0B;CAC1D,OAAO,cAAc,QAAQ,MAAM,UAAU,MAAM,QAAQ,QAAQ,IAAI,MAAM,QAAQ,QAAQ;AAC/F;;AAGA,SAAgB,aAAa,UAAkB,UAA0B;CACvE,OAAO,cAAc,QAAQ,MAAM,UAC/B,MAAM,KAAK,UAAU,eAAe,QAAQ,CAAC,IAC7C,MAAM,KAAK,UAAU,QAAQ;AACnC;;;;;;;AAQA,SAAgB,gCAAgC,UAA0B;CACxE,MAAM,OAAO,cAAc,QAAQ,MAAM,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,CAAC,CAAC;CACrD,IAAI,QAAQ,YAAY,MAAM;EAG5B,MAAM,iBAAiB,MAAM,QAAQ,IAAI;EACzC,MAAM,kBAAkB,MAAM,MAAM,KAAK,MAAM;EAC/C,OAAO;CACT;CACA,IAAI,CAAC,KAAK,UACR,MAAM,IAAI,MAAM,WAAW,KAAA,IACvB,iCAAiC,KAAK,gBAAgB,KAAK,kBAAkB,uCAAuC,KAAK,GAAG,aAAa,IAAI,CAAC,CAAC,KAAK,GAAG,EAAE,4BACzJ,wBAAwB,KAAK,SAAS,KAAK,kBAAkB,2DAA2D,KAAK,yBAAyB;CAE5J,IAAI,WAAW,KAAA,GAAW;EACxB,MAAM,cAAc,MAAM,MAAM,KAAK,QAAQ,IAAI;EACjD,MAAM,aAAa,MAAM,MAAM,KAAK,MAAM;EAC1C,MAAM,kBAAkB,MAAM,MAAM,KAAK,MAAM;EAK/C,KAAK,KAAK,cAAc,CAAC,EAAA,CAAG,WAAW,GAAG,OAAO;EAEjD,OAAO,YAAY,OAAM,MADD,cAAc,KAAK,KAAK,oBAAoB,MAAM,EAAA,CACvC,UAAU,MAAK,YAAW,QAAQ,SAAS,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC;CACnG;CACA,MAAM,UAAU,MAAM,iBAAiB,MAAM,QAAQ,IAAI;CACzD,IAAI,QAAQ,SAAS,GAAG,MAAM,IAAI,MAAM,sBAAsB,MAAM,OAAO,CAAC;CAC5E,MAAM,aAAa,MAAM,MAAM,KAAK,MAAM;CAC1C,MAAM,kBAAkB,MAAM,MAAM,KAAK,MAAM;CAC/C,OAAO;AACT"}
|
package/lib/shell.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as ContainerRun } from "./exec-_8g5fdSx.js";
|
|
2
|
-
import { t as ContainerOptions } from "./types-
|
|
2
|
+
import { t as ContainerOptions } from "./types-B2cQmBTx.js";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
4
|
import { ShellExecRequest, ShellExecSpec, ShellExecution } from "@deepseek-ai/dsh-shell";
|
|
5
5
|
import { Context, Volatile } from "@deepseek-ai/cordis";
|
|
@@ -43,7 +43,7 @@ declare class DevcontainerShellExecutor extends SandboxBashExecutor {
|
|
|
43
43
|
*/
|
|
44
44
|
static Config: z<Schemastery.ObjectS<NoInfer<{
|
|
45
45
|
shell: z<string, string, "defined">;
|
|
46
|
-
cli: z<"
|
|
46
|
+
cli: z<"auto" | "devcontainer" | "docker" | "sbx", "auto" | "devcontainer" | "docker" | "sbx", "defined">;
|
|
47
47
|
ensureUp: z<boolean, boolean, "defined">;
|
|
48
48
|
containerTimeoutMs: z<number, number, "defined">;
|
|
49
49
|
requireContainer: z<boolean, boolean, "defined">;
|
|
@@ -57,7 +57,7 @@ declare class DevcontainerShellExecutor extends SandboxBashExecutor {
|
|
|
57
57
|
localShell: z<"auto" | "bash" | "powershell", "auto" | "bash" | "powershell", "defined">;
|
|
58
58
|
}>>, Schemastery.ObjectT<NoInfer<{
|
|
59
59
|
shell: z<string, string, "defined">;
|
|
60
|
-
cli: z<"
|
|
60
|
+
cli: z<"auto" | "devcontainer" | "docker" | "sbx", "auto" | "devcontainer" | "docker" | "sbx", "defined">;
|
|
61
61
|
ensureUp: z<boolean, boolean, "defined">;
|
|
62
62
|
containerTimeoutMs: z<number, number, "defined">;
|
|
63
63
|
requireContainer: z<boolean, boolean, "defined">;
|
package/lib/shell.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","names":[],"sources":["../src/shell.ts"],"mappings":";;;;;;;;;cAkEa;;cAGA;;KAGD;;UAmCK,eAAe,UAAiB;;EAE/C,WAAW;;;;;;;EAOX,aAAa;;;cAqBF,QAAoC,EAAE;;;;;;;cAQtC,kCAAkC;;;;;;;;;SAS7B,QAAM,EAAA,YAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAYN;;EAGhB;IAAa,MAAM;IAAc,aAAa;IAAY;;;mBAGzC;;mBAGA;;mBAGA;;UAGT;EAEI,YAAA,KAAK,SAAS,QAAQ;;;;;;;;;;;EAoBzB,QAAQ,SAAS,mBAAmB;;;;;;;EAe9B,QAAQ,MAAM,gBAAgB,QAAQ;;;;;;;UA+C7C;;UAuBA;;UAOA;;;;;;;;;;;;;;;;UAmBA;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"shell.d.ts","names":[],"sources":["../src/shell.ts"],"mappings":";;;;;;;;;cAkEa;;cAGA;;KAGD;;UAmCK,eAAe,UAAiB;;EAE/C,WAAW;;;;;;;EAOX,aAAa;;;cAqBF,QAAoC,EAAE;;;;;;;cAQtC,kCAAkC;;;;;;;;;SAS7B,QAAM,EAAA,YAAA,QAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAYN;;EAGhB;IAAa,MAAM;IAAc,aAAa;IAAY;;;mBAGzC;;mBAGA;;mBAGA;;UAGT;EAEI,YAAA,KAAK,SAAS,QAAQ;;;;;;;;;;;EAoBzB,QAAQ,SAAS,mBAAmB;;;;;;;EAe9B,QAAQ,MAAM,gBAAgB,QAAQ;;;;;;;UA+C7C;;UAuBA;;UAOA;;;;;;;;;;;;;;;;UAmBA;;;;;;;;;;;;;;;;;UAmCA;;;;;UAgBA;;UAOA;;UAWA;;UAKA"}
|
package/lib/shell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as runContainerCommand, r as resolveContainerTarget } from "./exec-
|
|
1
|
+
import { A as markedVariantKind, B as containerOptions, M as refusalText, N as refusedExecution, O as markedContainerOnly, P as sbxRefusalText, Q as toContainerPath, _ as CONTAINER_MARKER_KEYS, d as liveHostMountRejections, f as liveSbxOptions, g as warnOnce, h as repoRegistry, i as sandboxHostPathFor, k as markedPreset, l as sbxSpecFor, n as bindSbxMount, u as sbxWorkspaceRootFor, z as containerOptionFields } from "./sbx-Blgjzzoe.js";
|
|
2
|
+
import { n as runContainerCommand, r as resolveContainerTarget } from "./exec-Bcojrag9.js";
|
|
3
3
|
import z from "@deepseek-ai/schemastery";
|
|
4
4
|
import "@deepseek-ai/cordis";
|
|
5
5
|
import { SandboxBashExecutor } from "@deepseek-ai/dsh-bash-sandbox";
|
|
@@ -386,7 +386,7 @@ var DevcontainerShellExecutor = class extends SandboxBashExecutor {
|
|
|
386
386
|
const declared = registry.locate(attributed?.host ?? workdir, options);
|
|
387
387
|
if (kind !== "sbx") return declared;
|
|
388
388
|
const root = this.sbxHostRootOf(workdir, cwd, declared, attributed);
|
|
389
|
-
return root === void 0 ? void 0 : sbxSpecFor(root, this.options, declared);
|
|
389
|
+
return root === void 0 ? void 0 : sbxSpecFor(root, liveSbxOptions(this.ctx, this.options), declared);
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
392
392
|
* The host directory a `(sbx)` session mounts for one workdir.
|
|
@@ -440,7 +440,14 @@ var DevcontainerShellExecutor = class extends SandboxBashExecutor {
|
|
|
440
440
|
containerTarget(key, repository, signal) {
|
|
441
441
|
const cached = this.targets.get(key);
|
|
442
442
|
if (cached !== void 0) return cached;
|
|
443
|
-
const
|
|
443
|
+
for (const rejection of liveHostMountRejections(this.ctx)) warnOnce(this.ctx, (text) => {
|
|
444
|
+
this.ctx.logger.warn(text);
|
|
445
|
+
}, rejection);
|
|
446
|
+
const pending = resolveContainerTarget(repository, this.internals.run ?? runContainerCommand, signal, (message) => {
|
|
447
|
+
warnOnce(this.ctx, (text) => {
|
|
448
|
+
this.ctx.logger.warn(text);
|
|
449
|
+
}, message);
|
|
450
|
+
});
|
|
444
451
|
this.targets.set(key, pending);
|
|
445
452
|
pending.catch(() => {
|
|
446
453
|
if (this.targets.get(key) === pending) this.targets.delete(key);
|