@banzhe/dsh-devcontainer 0.0.0-stage → 0.2.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/lib/shell.js ADDED
@@ -0,0 +1,454 @@
1
+ import { E as sbxRefusalText, H as containerOptions, R as toContainerPath, S as markedVariantKind, T as refusedExecution, V as containerOptionFields, b as markedContainerOnly, c as sbxWorkspaceRootFor, i as sandboxHostPathFor, l as repoRegistry, n as bindSbxMount, s as sbxSpecFor, u as CONTAINER_MARKER_KEYS, w as refusalText, x as markedPreset } from "./sbx-1GsFjQBk.js";
2
+ import { n as runContainerCommand, r as resolveContainerTarget } from "./exec-CKAAz2zz.js";
3
+ import z from "@deepseek-ai/schemastery";
4
+ import "@deepseek-ai/cordis";
5
+ import { SandboxBashExecutor } from "@deepseek-ai/dsh-bash-sandbox";
6
+ import { ENCODING_PREAMBLE, resolvePwshPath } from "@deepseek-ai/dsh-pwsh-local";
7
+ //#region src/argv.ts
8
+ /**
9
+ * The host-side scheduling markers. They tell this Bundle's executor whose
10
+ * command it is holding; inside the runtime they mean nothing, so they are
11
+ * never forwarded.
12
+ */
13
+ const INTERNAL_ENV_KEYS = new Set(CONTAINER_MARKER_KEYS);
14
+ /**
15
+ * Terminal facts every container command gets. They replace what
16
+ * `LocalBashExecutor` normally sets on the child: colors, pagers, and
17
+ * interactive prompts have no place in captured tool output.
18
+ */
19
+ const BASE_CONTAINER_ENV = {
20
+ TERM: "dumb",
21
+ GIT_TERMINAL_PROMPT: "0",
22
+ NO_COLOR: "1"
23
+ };
24
+ /**
25
+ * Merge the container environment: base facts first, then the configuration's
26
+ * `remoteEnv`, then the caller's own entries. Nothing from the host process
27
+ * participates.
28
+ * @param spec - the repository container specification.
29
+ * @param env - the caller's ordinary environment entries.
30
+ * @param dshEnv - the harness-managed `DSH_*` snapshot for this execution.
31
+ * @returns the merged map, or `{}` when nothing is forwarded.
32
+ */
33
+ function containerEnv(spec, env, dshEnv) {
34
+ const managed = {};
35
+ for (const [key, value] of Object.entries(dshEnv ?? {})) {
36
+ if (INTERNAL_ENV_KEYS.has(key)) continue;
37
+ managed[key] = value;
38
+ }
39
+ return {
40
+ ...BASE_CONTAINER_ENV,
41
+ ...spec.remoteEnv,
42
+ ...env,
43
+ ...managed
44
+ };
45
+ }
46
+ /**
47
+ * Split a configured shell into its program and any fixed arguments, so
48
+ * `/bin/bash -l` reaches the container as two words followed by `-c`.
49
+ * @param shell - the configured shell string.
50
+ * @returns the program followed by its arguments; `/bin/bash` when empty.
51
+ */
52
+ function shellParts(shell) {
53
+ const parts = shell.trim().split(/\s+/).filter((part) => part !== "");
54
+ return parts.length === 0 ? ["/bin/bash"] : parts;
55
+ }
56
+ /** `-e KEY=VALUE` flags, sorted so one command always yields one argv. */
57
+ function envFlags(env) {
58
+ return Object.keys(env).sort().map((key) => `${key}=${env[key]}`);
59
+ }
60
+ /** Single-quote one shell word, so an inner command survives unchanged. */
61
+ function quote(value) {
62
+ return `'${value.replaceAll("'", "'\\''")}'`;
63
+ }
64
+ /**
65
+ * Assemble the argv for one command.
66
+ * @param input - target, workdir, command, and the merged environment.
67
+ * @returns the complete argv to hand to the subprocess seam.
68
+ */
69
+ function buildExecArgv(input) {
70
+ const { spec, target, containerWorkdir, command } = input;
71
+ const flags = envFlags(input.env);
72
+ const user = spec.remoteUser;
73
+ switch (target.kind) {
74
+ case "docker": return [
75
+ "docker",
76
+ "exec",
77
+ "-i",
78
+ "-w",
79
+ containerWorkdir,
80
+ ...user === void 0 ? [] : ["-u", user],
81
+ ...flags.flatMap((entry) => ["-e", entry]),
82
+ target.containerId,
83
+ ...shellParts(spec.shell),
84
+ "-c",
85
+ command
86
+ ];
87
+ case "devcontainer-cli": return [
88
+ "devcontainer",
89
+ "exec",
90
+ "--workspace-folder",
91
+ target.workspaceFolder,
92
+ ...user === void 0 ? [] : ["--remote-user", user],
93
+ ...flags.flatMap((entry) => ["--remote-env", entry]),
94
+ "--",
95
+ "/bin/sh",
96
+ "-c",
97
+ shellWrapper(input, [])
98
+ ];
99
+ case "sbx": return [
100
+ "sbx",
101
+ "exec",
102
+ target.sandboxName,
103
+ "--",
104
+ "/bin/sh",
105
+ "-c",
106
+ shellWrapper(input, envProgram(flags))
107
+ ];
108
+ }
109
+ }
110
+ /**
111
+ * The POSIX wrapper one sandbox or CLI command runs under.
112
+ * @param input - the command and where it runs.
113
+ * @param program - words that precede the shell (an `env` prefix, or nothing).
114
+ * @returns the wrapper script.
115
+ */
116
+ function shellWrapper(input, program) {
117
+ const shell = [...program, ...shellParts(input.spec.shell).map(quote)].join(" ");
118
+ return `cd -- ${quote(input.containerWorkdir)} && exec ${shell} -c ${quote(input.command)}`;
119
+ }
120
+ /**
121
+ * An `env` prefix carrying the merged environment, so a sandbox command sees the
122
+ * same entries a `docker exec -e` would have given it.
123
+ * @param flags - the sorted `KEY=VALUE` entries.
124
+ * @returns the prefix words, or an empty list when nothing is forwarded.
125
+ */
126
+ function envProgram(flags) {
127
+ return flags.length === 0 ? [] : ["env", ...flags.map(quote)];
128
+ }
129
+ //#endregion
130
+ //#region src/shell.ts
131
+ /**
132
+ * Report a container-bound result as what it is: the host process was not
133
+ * confined, because the container confines the command instead. Permission
134
+ * bookkeeping therefore never attributes a host-sandbox denial to it.
135
+ * @param execution - the handle returned for a `docker exec` run.
136
+ * @returns the same handle, with its settled result stamped unconfined.
137
+ */
138
+ function stampUnconfined(execution) {
139
+ const base = execution.result.bind(execution);
140
+ let stamped;
141
+ execution.result = () => {
142
+ stamped ??= base().then((result) => ({
143
+ ...result,
144
+ sandbox: {
145
+ mode: "danger-full-access",
146
+ denied: false
147
+ }
148
+ }));
149
+ return stamped;
150
+ };
151
+ return execution;
152
+ }
153
+ /** Plugin name used by the Loader row. */
154
+ const name = "devcontainer-shell";
155
+ /** The seams this executor spawns and confines through. */
156
+ const inject = [
157
+ "subprocess",
158
+ "sandbox",
159
+ "sandboxPolicy"
160
+ ];
161
+ /**
162
+ * Whether one container run failed because the container or sandbox is gone.
163
+ *
164
+ * A target is cached per repository, so a container that was restarted or
165
+ * recreated shows up as these errors on the next command; the cache entry is
166
+ * dropped so the following command re-probes instead of failing forever. The
167
+ * sandbox half covers `sbx`: it reports a missing sandbox on stderr AND with
168
+ * exit code 125, which is Docker's generic "could not run the command" status.
169
+ * @param result - the settled foreground result.
170
+ * @returns true when the failure is about the runtime itself.
171
+ */
172
+ function containerGone(result) {
173
+ if (result.exitCode === 0) return false;
174
+ if (result.exitCode === 125) return true;
175
+ return /no such container|is not running|cannot connect to the docker daemon|container .* is not running/i.test(result.stderr.text) || /no such sandbox|sandbox .* (?:not found|does not exist|is not running|is stopped|has stopped)/i.test(result.stderr.text);
176
+ }
177
+ /**
178
+ * The host directory a sandbox-spelled workdir names.
179
+ *
180
+ * Only a Windows host maps a drive directory into its sandbox without the drive
181
+ * colon, so only there does a container path need reversing: everywhere else a
182
+ * sandbox mounts the directory at the absolute path it already has, which is the
183
+ * workdir a caller wrote.
184
+ * @param workdir - the directory the command named.
185
+ * @returns the attribution, or undefined when the path names no host directory.
186
+ */
187
+ function sandboxHostAttribution(workdir) {
188
+ return process.platform === "win32" ? sandboxHostPathFor(workdir) : void 0;
189
+ }
190
+ /**
191
+ * Mirrors `@deepseek-ai/dsh-bash-local`'s schema field for field — the inherited
192
+ * `resolve()` validates these through `assertServiceableBashConfig` — and adds
193
+ * the shared container options plus the local-fallback knobs.
194
+ */
195
+ const ConfigSchema = z.object({
196
+ cwd: z.string().volatile(),
197
+ timeoutMs: z.number().default(12e4).volatile(),
198
+ maxTimeoutMs: z.number().default(6e5).volatile(),
199
+ maxOutputBytes: z.number().default(64e3).volatile(),
200
+ maxSpillBytes: z.number().default(67108864).volatile(),
201
+ graceMs: z.number().default(3e3).volatile(),
202
+ pwshPath: z.string().default("").volatile(),
203
+ localShell: z.union([
204
+ "auto",
205
+ "bash",
206
+ "powershell"
207
+ ]).default("auto"),
208
+ ...containerOptionFields()
209
+ });
210
+ /** The row's schema, typed for callers; the loader reads the class's static copy. */
211
+ const Config = ConfigSchema;
212
+ /**
213
+ * Container-backed bash executor. Falls through to the platform's local shell
214
+ * for every workdir that belongs to no Dev Container repository, so a session
215
+ * that never touches such a repository behaves exactly like the provider this
216
+ * Bundle replaced.
217
+ */
218
+ var DevcontainerShellExecutor = class extends SandboxBashExecutor {
219
+ /**
220
+ * The schema the Loader resolves this row's config through.
221
+ *
222
+ * It has to be a STATIC: the module's `default` export is this class, and the
223
+ * Loader's `unwrapExports` hands Cordis the class itself — module-level exports
224
+ * such as `Config` never reach it. Without this static the row would be mounted
225
+ * with the inherited bash-local schema, silently dropping every container knob.
226
+ */
227
+ static Config = ConfigSchema;
228
+ /**
229
+ * The seams this executor spawns and confines through.
230
+ *
231
+ * This row REPLACES the sandboxed executor rather than the plain local one:
232
+ * `ctx.shell.sandboxMode` is the capability fact permission presets read, and
233
+ * an executor that cannot report one makes them refuse to compose at all.
234
+ * Host-side commands therefore keep the confinement this platform shipped;
235
+ * only a command that enters the container runs unconfined on the host,
236
+ * because the container is what confines it.
237
+ */
238
+ static inject = [
239
+ "subprocess",
240
+ "sandbox",
241
+ "sandboxPolicy"
242
+ ];
243
+ /** Test seam: replaces the host CLI runner. */
244
+ internals = {};
245
+ /** This row's own configuration (the inherited `config` is typed by the local executor). */
246
+ ownConfig;
247
+ /** The container options this row was configured with. */
248
+ options;
249
+ /** One resolved target per repository, so a burst of commands probes Docker once. */
250
+ targets = /* @__PURE__ */ new Map();
251
+ /** Whether the configured directory has been walked for a declaration yet. */
252
+ warmed = false;
253
+ constructor(ctx, config) {
254
+ super(ctx, config);
255
+ this.ownConfig = config;
256
+ this.options = containerOptions(config);
257
+ ctx.effect(() => {
258
+ const cache = repoRegistry(ctx);
259
+ return () => {
260
+ cache.reset();
261
+ };
262
+ });
263
+ }
264
+ /**
265
+ * Report the container's POSIX workdir so the model sees Linux paths.
266
+ *
267
+ * Only an execution that must reach a container is rewritten. An ordinary
268
+ * session in the same repository keeps host paths, because its commands keep
269
+ * running on the host — reporting `/workspaces/…` for a command that never
270
+ * enters a container would describe a directory that does not exist.
271
+ * @param request - the caller's request.
272
+ * @returns the resolved spec, with a container workdir when this execution is container-bound.
273
+ */
274
+ resolve(request) {
275
+ const spec = super.resolve(request);
276
+ if (!this.requiresContainer(request)) return spec;
277
+ const repository = this.locate(spec.workdir, markedVariantKind(spec.dshEnv));
278
+ if (repository === void 0) return spec;
279
+ const workdir = toContainerPath(spec.workdir, repository);
280
+ return workdir === spec.workdir ? spec : {
281
+ ...spec,
282
+ workdir
283
+ };
284
+ }
285
+ /**
286
+ * Run the command inside the repository's container, or through the platform's
287
+ * local shell when the workdir belongs to no Dev Container repository.
288
+ * @param spec - a resolved spec from {@link DevcontainerShellExecutor.resolve}.
289
+ * @returns the prepared execution handle.
290
+ */
291
+ async execute(spec) {
292
+ if (!this.requiresContainer(spec)) return this.executeLocal(spec);
293
+ const kind = markedVariantKind(spec.dshEnv);
294
+ const repository = this.locate(spec.workdir, kind);
295
+ if (repository === void 0) {
296
+ const preset = this.presetOf(spec);
297
+ return refusedExecution(spec, kind === "sbx" ? sbxRefusalText(spec.workdir, preset) : refusalText(spec.workdir, preset));
298
+ }
299
+ const key = this.targetKey(repository);
300
+ const hostSpec = {
301
+ ...spec,
302
+ workdir: repository.hostWorkspaceRoot
303
+ };
304
+ const execution = await this.executeArgv(hostSpec, async (signal) => {
305
+ const target = await this.containerTarget(key, repository, signal);
306
+ const bound = bindSbxMount(repository, target);
307
+ return buildExecArgv({
308
+ spec: bound,
309
+ target,
310
+ containerWorkdir: toContainerPath(spec.workdir, bound),
311
+ command: spec.command,
312
+ env: containerEnv(repository, spec.env, spec.dshEnv)
313
+ });
314
+ });
315
+ execution.result().then((result) => {
316
+ if (containerGone(result)) this.forgetTarget(key);
317
+ }, () => {
318
+ this.forgetTarget(key);
319
+ });
320
+ return stampUnconfined(execution);
321
+ }
322
+ /**
323
+ * The local fallback: the inherited bash path (host confinement included), or
324
+ * the PowerShell invocation `@deepseek-ai/dsh-pwsh-local` uses on Windows,
325
+ * wrapped through the provider `@deepseek-ai/dsh-pwsh-sandbox` used. Both keep
326
+ * the inherited deadline, output, and cancellation mechanics.
327
+ */
328
+ executeLocal(spec) {
329
+ const localShell = this.internals.localShell ?? this.ownConfig.localShell ?? "auto";
330
+ if (!(localShell === "powershell" || localShell === "auto" && process.platform === "win32")) return super.execute(spec);
331
+ const argv = [
332
+ resolvePwshPath(this.ownConfig.pwshPath?.get()),
333
+ "-NoLogo",
334
+ "-NoProfile",
335
+ "-NonInteractive",
336
+ "-Command",
337
+ `${ENCODING_PREAMBLE}${spec.command}`
338
+ ];
339
+ const policy = spec.sandboxPolicy;
340
+ if (policy === void 0) return this.executeArgv(spec, argv);
341
+ const { mode } = policy;
342
+ if (mode === "danger-full-access") return this.executeArgv(spec, argv);
343
+ return this.executeArgv(spec, async (signal) => {
344
+ const prepared = await this.ctx.sandbox.confine(argv, {
345
+ ...policy,
346
+ mode
347
+ }, signal);
348
+ signal.throwIfAborted();
349
+ return prepared.argv;
350
+ });
351
+ }
352
+ /** Whether this execution must reach a container or not run at all. */
353
+ requiresContainer(request) {
354
+ if (this.internals.requireContainer === true) return true;
355
+ if (this.options.requireContainer) return true;
356
+ return markedContainerOnly(request.dshEnv);
357
+ }
358
+ /** The preset id the marker carries, so the refusal can name it. */
359
+ presetOf(spec) {
360
+ return markedPreset(spec.dshEnv);
361
+ }
362
+ /**
363
+ * The repository container specification governing one workdir.
364
+ *
365
+ * A `(devContainer)` session needs a declaration: without one there is nowhere
366
+ * to run, which is what the refusal above reports. A `(sbx)` session needs
367
+ * none — a sandbox mounts the host workspace at its own path — so a directory
368
+ * with no declaration is described by {@link sbxSpecFor} instead, and only a
369
+ * missing host directory (no configured cwd to fall back on) stays unresolved.
370
+ *
371
+ * A sandbox-spelled workdir is reversed onto the host before the registry is
372
+ * asked, because `/f/personal/repo` has no host ancestry of its own.
373
+ * @param workdir - the directory the command names.
374
+ * @param kind - the runtime the calling preset selects, when one does.
375
+ * @returns the specification, or undefined when this directory cannot be run in.
376
+ */
377
+ locate(workdir, kind) {
378
+ const cwd = this.config.cwd.get();
379
+ this.warmUp(cwd);
380
+ const registry = repoRegistry(this.ctx);
381
+ const options = {
382
+ ...this.options,
383
+ cwd
384
+ };
385
+ const attributed = kind === "sbx" ? sandboxHostAttribution(workdir) : void 0;
386
+ const declared = registry.locate(attributed?.host ?? workdir, options);
387
+ if (kind !== "sbx") return declared;
388
+ const root = this.sbxHostRootOf(workdir, cwd, declared, attributed);
389
+ return root === void 0 ? void 0 : sbxSpecFor(root, this.options, declared);
390
+ }
391
+ /**
392
+ * The host directory a `(sbx)` session mounts for one workdir.
393
+ *
394
+ * A declaration wins, because a sandbox mounts the repository it was found in.
395
+ * The directory the row was configured with comes next: that is the workspace
396
+ * the sandbox was created around, and a workdir below it belongs to the same
397
+ * mount. Only a row configured with no directory at all takes the workspace from
398
+ * the workdir itself — the host directory a reported mount covers, else the
399
+ * drive directory its sandbox spelling names — which is what makes a workdir of
400
+ * `/f/personal/repo` reach the sandbox of `F:\personal\repo`.
401
+ * @param workdir - the directory the command named.
402
+ * @param cwd - the directory the row was configured with.
403
+ * @param declared - the specification a declaration produced, when one exists.
404
+ * @param attributed - the host directory the workdir's sandbox spelling names.
405
+ * @returns the absolute host path to mount, or undefined when none can be named.
406
+ */
407
+ sbxHostRootOf(workdir, cwd, declared, attributed) {
408
+ if (declared !== void 0) return declared.hostWorkspaceRoot;
409
+ if (cwd !== void 0 && cwd !== "") return cwd;
410
+ if (attributed !== void 0) return attributed.workspaceRoot ?? attributed.host;
411
+ return sbxWorkspaceRootFor(workdir, void 0, void 0);
412
+ }
413
+ /**
414
+ * Discover the configured directory once, so a first call that already speaks
415
+ * in container paths can still be attributed to its repository.
416
+ */
417
+ warmUp(cwd) {
418
+ if (this.warmed || cwd === void 0) return;
419
+ this.warmed = true;
420
+ repoRegistry(this.ctx).discover(cwd, {
421
+ ...this.options,
422
+ cwd
423
+ });
424
+ }
425
+ /** The cache key of one repository's container target. */
426
+ targetKey(repository) {
427
+ return [
428
+ repository.hostWorkspaceRoot,
429
+ repository.cli,
430
+ repository.container ?? "",
431
+ repository.sandbox ?? "",
432
+ String(repository.ensureUp)
433
+ ].join("\0");
434
+ }
435
+ /** Drop one cached target, so the next command probes the container again. */
436
+ forgetTarget(key) {
437
+ this.targets.delete(key);
438
+ }
439
+ /** Resolve (once per repository) where commands run. */
440
+ containerTarget(key, repository, signal) {
441
+ const cached = this.targets.get(key);
442
+ if (cached !== void 0) return cached;
443
+ const pending = resolveContainerTarget(repository, this.internals.run ?? runContainerCommand, signal);
444
+ this.targets.set(key, pending);
445
+ pending.catch(() => {
446
+ if (this.targets.get(key) === pending) this.targets.delete(key);
447
+ });
448
+ return pending;
449
+ }
450
+ };
451
+ //#endregion
452
+ export { Config, DevcontainerShellExecutor, DevcontainerShellExecutor as default, inject, name };
453
+
454
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","names":[],"sources":["../src/argv.ts","../src/shell.ts"],"sourcesContent":["/**\n * The argv one container-executed command becomes.\n *\n * Two shapes, one contract: the command runs under the configured Linux shell,\n * in the container directory that mirrors the host workdir, with ONLY the\n * environment this Bundle deliberately forwards. The host's `PATH`,\n * `SystemRoot`, and every other Windows entry stay out of the container — a\n * Linux `bash` reading a Windows `PATH` finds no binaries at all.\n *\n * @module @banzhe/dsh-devcontainer/argv\n */\n\nimport type { ContainerTarget } from './container.ts'\nimport { CONTAINER_MARKER_KEYS } from './refusal.ts'\nimport type { RepoContainerSpec } from './types.ts'\n\n/**\n * The host-side scheduling markers. They tell this Bundle's executor whose\n * command it is holding; inside the runtime they mean nothing, so they are\n * never forwarded.\n */\nconst INTERNAL_ENV_KEYS: ReadonlySet<string> = new Set(CONTAINER_MARKER_KEYS)\n\n/**\n * Terminal facts every container command gets. They replace what\n * `LocalBashExecutor` normally sets on the child: colors, pagers, and\n * interactive prompts have no place in captured tool output.\n */\nexport const BASE_CONTAINER_ENV: Readonly<Record<string, string>> = {\n TERM: 'dumb',\n GIT_TERMINAL_PROMPT: '0',\n NO_COLOR: '1',\n}\n\n/** One command's container argv inputs. */\nexport interface ExecArgvInput {\n /** The repository container specification. */\n readonly spec: RepoContainerSpec\n /** The resolved container target. */\n readonly target: ContainerTarget\n /** POSIX directory inside the container the command runs in. */\n readonly containerWorkdir: string\n /** The command source the model asked for. */\n readonly command: string\n /** Already-merged environment entries; only these reach the container. */\n readonly env: Readonly<Record<string, string>>\n}\n\n/**\n * Merge the container environment: base facts first, then the configuration's\n * `remoteEnv`, then the caller's own entries. Nothing from the host process\n * participates.\n * @param spec - the repository container specification.\n * @param env - the caller's ordinary environment entries.\n * @param dshEnv - the harness-managed `DSH_*` snapshot for this execution.\n * @returns the merged map, or `{}` when nothing is forwarded.\n */\nexport function containerEnv(\n spec: RepoContainerSpec,\n env?: Readonly<Record<string, string>>,\n dshEnv?: Readonly<Record<string, string>>,\n): Record<string, string> {\n const managed: Record<string, string> = {}\n for (const [key, value] of Object.entries(dshEnv ?? {})) {\n if (INTERNAL_ENV_KEYS.has(key)) continue\n managed[key] = value\n }\n return {\n ...BASE_CONTAINER_ENV,\n ...spec.remoteEnv,\n ...env,\n ...managed,\n }\n}\n\n/**\n * Split a configured shell into its program and any fixed arguments, so\n * `/bin/bash -l` reaches the container as two words followed by `-c`.\n * @param shell - the configured shell string.\n * @returns the program followed by its arguments; `/bin/bash` when empty.\n */\nexport function shellParts(shell: string): string[] {\n const parts = shell.trim().split(/\\s+/).filter(part => part !== '')\n return parts.length === 0 ? ['/bin/bash'] : parts\n}\n\n/** `-e KEY=VALUE` flags, sorted so one command always yields one argv. */\nfunction envFlags(env: Readonly<Record<string, string>>): string[] {\n return Object.keys(env).sort().map((key) => `${key}=${env[key] as string}`)\n}\n\n/** Single-quote one shell word, so an inner command survives unchanged. */\nfunction quote(value: string): string {\n return `'${value.replaceAll(\"'\", \"'\\\\''\")}'`\n}\n\n/**\n * Assemble the argv for one command.\n * @param input - target, workdir, command, and the merged environment.\n * @returns the complete argv to hand to the subprocess seam.\n */\nexport function buildExecArgv(input: ExecArgvInput): readonly string[] {\n const { spec, target, containerWorkdir, command } = input\n const flags = envFlags(input.env)\n const user = spec.remoteUser\n switch (target.kind) {\n case 'docker':\n return [\n 'docker', 'exec', '-i', '-w', containerWorkdir,\n ...user === undefined ? [] : ['-u', user],\n ...flags.flatMap(entry => ['-e', entry]),\n target.containerId,\n ...shellParts(spec.shell), '-c', command,\n ]\n case 'devcontainer-cli':\n // `devcontainer exec` starts its own process, so the subdirectory has to be\n // entered by a POSIX shell wrapper inside the container.\n return [\n 'devcontainer', 'exec', '--workspace-folder', target.workspaceFolder,\n ...user === undefined ? [] : ['--remote-user', user],\n ...flags.flatMap(entry => ['--remote-env', entry]),\n '--', '/bin/sh', '-c', shellWrapper(input, []),\n ]\n case 'sbx':\n // `sbx exec` takes no environment flags on the sandbox CLI version this\n // Bundle targets, and it starts its own process, so both the workdir and the\n // environment are applied by the same POSIX wrapper: `env` sets the entries\n // for the shell about to replace the wrapper, and `exec` keeps the exit code\n // and signal of the real command.\n return [\n 'sbx', 'exec', target.sandboxName, '--', '/bin/sh', '-c',\n shellWrapper(input, envProgram(flags)),\n ]\n }\n}\n\n/**\n * The POSIX wrapper one sandbox or CLI command runs under.\n * @param input - the command and where it runs.\n * @param program - words that precede the shell (an `env` prefix, or nothing).\n * @returns the wrapper script.\n */\nfunction shellWrapper(input: ExecArgvInput, program: readonly string[]): string {\n const shell = [...program, ...shellParts(input.spec.shell).map(quote)].join(' ')\n return `cd -- ${quote(input.containerWorkdir)} && exec ${shell} -c ${quote(input.command)}`\n}\n\n/**\n * An `env` prefix carrying the merged environment, so a sandbox command sees the\n * same entries a `docker exec -e` would have given it.\n * @param flags - the sorted `KEY=VALUE` entries.\n * @returns the prefix words, or an empty list when nothing is forwarded.\n */\nfunction envProgram(flags: readonly string[]): string[] {\n return flags.length === 0 ? [] : ['env', ...flags.map(quote)]\n}\n","/**\n * Report a container-bound result as what it is: the host process was not\n * confined, because the container confines the command instead. Permission\n * bookkeeping therefore never attributes a host-sandbox denial to it.\n * @param execution - the handle returned for a `docker exec` run.\n * @returns the same handle, with its settled result stamped unconfined.\n */\nfunction stampUnconfined(execution: ShellExecution): ShellExecution {\n const base = execution.result.bind(execution)\n let stamped: Promise<ShellRunResult> | undefined\n execution.result = () => {\n stamped ??= base().then(result => ({ ...result, sandbox: { mode: 'danger-full-access' as const, denied: false } }))\n return stamped\n }\n return execution\n}\n\n/**\n * `ctx.shell` for repositories that declare a Dev Container, or run in a Docker\n * Sandbox.\n *\n * The executor IS the sandboxed local bash executor — same deadlines, same\n * output caps, same job/background semantics, same host-side confinement — with\n * two changes at the execution boundary:\n *\n * - {@link DevcontainerShellExecutor.resolve} reports the workdir as the\n * container's POSIX path, so `result.cwd` and every subsequent `workdir` the\n * model writes are Linux paths;\n * - {@link DevcontainerShellExecutor.execute} runs `docker exec` (or\n * `devcontainer exec`) instead of an in-process `bash -c`, from the HOST\n * repository root: `child_process` cannot chdir into `/workspaces/…`, which\n * does not exist on Windows.\n *\n * Everything outside a Dev Container repository keeps the LOCAL provider this\n * platform had before this Bundle existed — bash on POSIX, PowerShell on Windows\n * (`packages/shell/pwsh-local`). That is not cosmetic: on Windows the shipped\n * presets mount `tool-pwsh`, whose commands are PowerShell source, and a Windows\n * `bash` reading them would fail where it used to work.\n *\n * @module @banzhe/dsh-devcontainer/shell\n */\n\nimport { Context, type Volatile } from '@deepseek-ai/cordis'\nimport z from '@deepseek-ai/schemastery'\nimport { SandboxBashExecutor } from '@deepseek-ai/dsh-bash-sandbox'\nimport type { Config as LocalBashConfig } from '@deepseek-ai/dsh-bash-local'\nimport { ENCODING_PREAMBLE, resolvePwshPath } from '@deepseek-ai/dsh-pwsh-local'\nimport type { ShellExecRequest, ShellExecSpec, ShellExecution } from '@deepseek-ai/dsh-shell'\nimport { buildExecArgv, containerEnv } from './argv.ts'\nimport { resolveContainerTarget } from './container.ts'\nimport type { ContainerTarget } from './container.ts'\nimport { runContainerCommand } from './exec.ts'\nimport type { ContainerRun } from './exec.ts'\nimport { containerOptionFields, containerOptions } from './options.ts'\nimport { toContainerPath } from './paths.ts'\nimport {\n markedContainerOnly, markedPreset, markedVariantKind, refusalText, refusedExecution, sbxRefusalText,\n} from './refusal.ts'\nimport type { ShellRunResult } from '@deepseek-ai/dsh-shell'\nimport { repoRegistry } from './registry.ts'\nimport { bindSbxMount, sandboxHostPathFor, sbxSpecFor, sbxWorkspaceRootFor } from './sbx.ts'\nimport type { SandboxHostAttribution } from './sbx.ts'\nimport type { ContainerOptions, RepoContainerSpec } from './types.ts'\nimport type { VariantKind } from './ids.ts'\n\n/** Plugin name used by the Loader row. */\nexport const name = 'devcontainer-shell'\n\n/** The seams this executor spawns and confines through. */\nexport const inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n/** The local shell used when a workdir belongs to no Dev Container repository. */\nexport type LocalShell = 'auto' | 'bash' | 'powershell'\n\n/**\n * Whether one container run failed because the container or sandbox is gone.\n *\n * A target is cached per repository, so a container that was restarted or\n * recreated shows up as these errors on the next command; the cache entry is\n * dropped so the following command re-probes instead of failing forever. The\n * sandbox half covers `sbx`: it reports a missing sandbox on stderr AND with\n * exit code 125, which is Docker's generic \"could not run the command\" status.\n * @param result - the settled foreground result.\n * @returns true when the failure is about the runtime itself.\n */\nfunction containerGone(result: ShellRunResult): boolean {\n if (result.exitCode === 0) return false\n if (result.exitCode === 125) return true\n return /no such container|is not running|cannot connect to the docker daemon|container .* is not running/i.test(result.stderr.text)\n || /no such sandbox|sandbox .* (?:not found|does not exist|is not running|is stopped|has stopped)/i.test(result.stderr.text)\n}\n\n/**\n * The host directory a sandbox-spelled workdir names.\n *\n * Only a Windows host maps a drive directory into its sandbox without the drive\n * colon, so only there does a container path need reversing: everywhere else a\n * sandbox mounts the directory at the absolute path it already has, which is the\n * workdir a caller wrote.\n * @param workdir - the directory the command named.\n * @returns the attribution, or undefined when the path names no host directory.\n */\nfunction sandboxHostAttribution(workdir: string): SandboxHostAttribution | undefined {\n return process.platform === 'win32' ? sandboxHostPathFor(workdir) : undefined\n}\n\n/** The local executor's knobs plus this Bundle's container options. */\nexport interface Config extends LocalBashConfig, ContainerOptions {\n /** Explicit pwsh executable for the Windows local fallback (empty = probe well-known paths). */\n pwshPath?: Volatile<string>\n /**\n * Local fallback shell (default `auto`: PowerShell on Windows, bash elsewhere).\n * `bash` keeps the inherited executor; `powershell` runs\n * `pwsh -NoProfile -Command`, the same invocation `@deepseek-ai/dsh-pwsh-local`\n * uses.\n */\n localShell?: LocalShell\n}\n\n/**\n * Mirrors `@deepseek-ai/dsh-bash-local`'s schema field for field — the inherited\n * `resolve()` validates these through `assertServiceableBashConfig` — and adds\n * the shared container options plus the local-fallback knobs.\n */\nconst ConfigSchema = z.object({\n cwd: z.string().volatile(),\n timeoutMs: z.number().default(120_000).volatile(),\n maxTimeoutMs: z.number().default(600_000).volatile(),\n maxOutputBytes: z.number().default(64_000).volatile(),\n maxSpillBytes: z.number().default(64 * 1024 * 1024).volatile(),\n graceMs: z.number().default(3_000).volatile(),\n pwshPath: z.string().default('').volatile(),\n localShell: z.union(['auto', 'bash', 'powershell'] as const).default('auto'),\n ...containerOptionFields(),\n})\n\n/** The row's schema, typed for callers; the loader reads the class's static copy. */\nexport const Config = ConfigSchema as unknown as z<Config>\n\n/**\n * Container-backed bash executor. Falls through to the platform's local shell\n * for every workdir that belongs to no Dev Container repository, so a session\n * that never touches such a repository behaves exactly like the provider this\n * Bundle replaced.\n */\nexport class DevcontainerShellExecutor extends SandboxBashExecutor {\n /**\n * The schema the Loader resolves this row's config through.\n *\n * It has to be a STATIC: the module's `default` export is this class, and the\n * Loader's `unwrapExports` hands Cordis the class itself — module-level exports\n * such as `Config` never reach it. Without this static the row would be mounted\n * with the inherited bash-local schema, silently dropping every container knob.\n */\n static override Config = ConfigSchema\n\n /**\n * The seams this executor spawns and confines through.\n *\n * This row REPLACES the sandboxed executor rather than the plain local one:\n * `ctx.shell.sandboxMode` is the capability fact permission presets read, and\n * an executor that cannot report one makes them refuse to compose at all.\n * Host-side commands therefore keep the confinement this platform shipped;\n * only a command that enters the container runs unconfined on the host,\n * because the container is what confines it.\n */\n static override inject = ['subprocess', 'sandbox', 'sandboxPolicy']\n\n /** Test seam: replaces the host CLI runner. */\n internals: { run?: ContainerRun; localShell?: LocalShell; requireContainer?: boolean } = {}\n\n /** This row's own configuration (the inherited `config` is typed by the local executor). */\n private readonly ownConfig: Config\n\n /** The container options this row was configured with. */\n private readonly options: ContainerOptions\n\n /** One resolved target per repository, so a burst of commands probes Docker once. */\n private readonly targets = new Map<string, Promise<ContainerTarget>>()\n\n /** Whether the configured directory has been walked for a declaration yet. */\n private warmed = false\n\n constructor(ctx: Context, config: Config) {\n super(ctx, config)\n this.ownConfig = config\n this.options = containerOptions(config)\n ctx.effect(() => {\n const cache = repoRegistry(ctx)\n return () => { cache.reset() }\n })\n }\n\n /**\n * Report the container's POSIX workdir so the model sees Linux paths.\n *\n * Only an execution that must reach a container is rewritten. An ordinary\n * session in the same repository keeps host paths, because its commands keep\n * running on the host — reporting `/workspaces/…` for a command that never\n * enters a container would describe a directory that does not exist.\n * @param request - the caller's request.\n * @returns the resolved spec, with a container workdir when this execution is container-bound.\n */\n override resolve(request: ShellExecRequest): ShellExecSpec {\n const spec = super.resolve(request)\n if (!this.requiresContainer(request)) return spec\n const repository = this.locate(spec.workdir, markedVariantKind(spec.dshEnv))\n if (repository === undefined) return spec\n const workdir = toContainerPath(spec.workdir, repository)\n return workdir === spec.workdir ? spec : { ...spec, workdir }\n }\n\n /**\n * Run the command inside the repository's container, or through the platform's\n * local shell when the workdir belongs to no Dev Container repository.\n * @param spec - a resolved spec from {@link DevcontainerShellExecutor.resolve}.\n * @returns the prepared execution handle.\n */\n override async execute(spec: ShellExecSpec): Promise<ShellExecution> {\n // A repository that declares a container does not make every session run in\n // it: only a container-bound execution is routed there. An ordinary preset\n // keeps the platform shell it had, even with a `.devcontainer` in the tree.\n if (!this.requiresContainer(spec)) return this.executeLocal(spec)\n const kind = markedVariantKind(spec.dshEnv)\n const repository = this.locate(spec.workdir, kind)\n if (repository === undefined) {\n // A derived preset promises container execution. Falling back to the host\n // would hand the model a host result it reads as a Linux one, so the command\n // is refused instead of silently misdirected.\n const preset = this.presetOf(spec)\n return refusedExecution(spec, kind === 'sbx'\n ? sbxRefusalText(spec.workdir, preset)\n : refusalText(spec.workdir, preset))\n }\n const key = this.targetKey(repository)\n // The host process must start in a directory that exists on THIS host.\n const hostSpec: ShellExecSpec = { ...spec, workdir: repository.hostWorkspaceRoot }\n const execution = await this.executeArgv(hostSpec, async (signal) => {\n const target = await this.containerTarget(key, repository, signal)\n // A sandbox may mount the workspace under a path of its own, which only its\n // listing knows: the workdir is translated against the folder it reported.\n const bound = bindSbxMount(repository, target)\n return buildExecArgv({\n spec: bound,\n target,\n containerWorkdir: toContainerPath(spec.workdir, bound),\n command: spec.command,\n env: containerEnv(repository, spec.env, spec.dshEnv),\n })\n })\n // A container that was restarted or recreated out from under a cached target\n // must be re-probed rather than reported as a permanent failure.\n void execution.result().then(\n (result) => { if (containerGone(result)) this.forgetTarget(key) },\n () => { this.forgetTarget(key) },\n )\n return stampUnconfined(execution)\n }\n\n /**\n * The local fallback: the inherited bash path (host confinement included), or\n * the PowerShell invocation `@deepseek-ai/dsh-pwsh-local` uses on Windows,\n * wrapped through the provider `@deepseek-ai/dsh-pwsh-sandbox` used. Both keep\n * the inherited deadline, output, and cancellation mechanics.\n */\n private executeLocal(spec: ShellExecSpec): Promise<ShellExecution> {\n const localShell = this.internals.localShell ?? this.ownConfig.localShell ?? 'auto'\n const powershell = localShell === 'powershell' || (localShell === 'auto' && process.platform === 'win32')\n if (!powershell) return super.execute(spec)\n const argv = [\n resolvePwshPath(this.ownConfig.pwshPath?.get()),\n '-NoLogo', '-NoProfile', '-NonInteractive',\n '-Command', `${ENCODING_PREAMBLE}${spec.command}`,\n ]\n const policy = spec.sandboxPolicy\n // No policy, or one that asks for host-wide access: spawn as before. A\n // confining policy wraps the same argv the sandboxed pwsh executor wrapped.\n if (policy === undefined) return this.executeArgv(spec, argv)\n const { mode } = policy\n if (mode === 'danger-full-access') return this.executeArgv(spec, argv)\n return this.executeArgv(spec, async (signal) => {\n const prepared = await this.ctx.sandbox.confine(argv, { ...policy, mode }, signal)\n signal.throwIfAborted()\n return prepared.argv\n })\n }\n\n /** Whether this execution must reach a container or not run at all. */\n private requiresContainer(request: ShellExecRequest | ShellExecSpec): boolean {\n if (this.internals.requireContainer === true) return true\n if (this.options.requireContainer) return true\n return markedContainerOnly(request.dshEnv)\n }\n\n /** The preset id the marker carries, so the refusal can name it. */\n private presetOf(spec: ShellExecSpec): string | undefined {\n return markedPreset(spec.dshEnv)\n }\n\n /**\n * The repository container specification governing one workdir.\n *\n * A `(devContainer)` session needs a declaration: without one there is nowhere\n * to run, which is what the refusal above reports. A `(sbx)` session needs\n * none — a sandbox mounts the host workspace at its own path — so a directory\n * with no declaration is described by {@link sbxSpecFor} instead, and only a\n * missing host directory (no configured cwd to fall back on) stays unresolved.\n *\n * A sandbox-spelled workdir is reversed onto the host before the registry is\n * asked, because `/f/personal/repo` has no host ancestry of its own.\n * @param workdir - the directory the command names.\n * @param kind - the runtime the calling preset selects, when one does.\n * @returns the specification, or undefined when this directory cannot be run in.\n */\n private locate(workdir: string, kind: VariantKind | undefined): RepoContainerSpec | undefined {\n const cwd = this.config.cwd.get()\n this.warmUp(cwd)\n const registry = repoRegistry(this.ctx)\n const options = { ...this.options, cwd }\n // A (sbx) session names its workdir the way its sandbox spells it, and that\n // spelling has no host ancestry to walk: `/f/personal/repo` resolves to no\n // host repository on a Windows host, where the directory is\n // `F:\\personal\\repo`. The host directory is recovered first, so a command\n // that already carries a container path still finds its repository.\n const attributed = kind === 'sbx' ? sandboxHostAttribution(workdir) : undefined\n const declared = registry.locate(attributed?.host ?? workdir, options)\n if (kind !== 'sbx') return declared\n const root = this.sbxHostRootOf(workdir, cwd, declared, attributed)\n return root === undefined ? undefined : sbxSpecFor(root, this.options, declared)\n }\n\n /**\n * The host directory a `(sbx)` session mounts for one workdir.\n *\n * A declaration wins, because a sandbox mounts the repository it was found in.\n * The directory the row was configured with comes next: that is the workspace\n * the sandbox was created around, and a workdir below it belongs to the same\n * mount. Only a row configured with no directory at all takes the workspace from\n * the workdir itself — the host directory a reported mount covers, else the\n * drive directory its sandbox spelling names — which is what makes a workdir of\n * `/f/personal/repo` reach the sandbox of `F:\\personal\\repo`.\n * @param workdir - the directory the command named.\n * @param cwd - the directory the row was configured with.\n * @param declared - the specification a declaration produced, when one exists.\n * @param attributed - the host directory the workdir's sandbox spelling names.\n * @returns the absolute host path to mount, or undefined when none can be named.\n */\n private sbxHostRootOf(\n workdir: string,\n cwd: string | undefined,\n declared: RepoContainerSpec | undefined,\n attributed: SandboxHostAttribution | undefined,\n ): string | undefined {\n if (declared !== undefined) return declared.hostWorkspaceRoot\n if (cwd !== undefined && cwd !== '') return cwd\n if (attributed !== undefined) return attributed.workspaceRoot ?? attributed.host\n return sbxWorkspaceRootFor(workdir, undefined, undefined)\n }\n\n /**\n * Discover the configured directory once, so a first call that already speaks\n * in container paths can still be attributed to its repository.\n */\n private warmUp(cwd: string | undefined): void {\n if (this.warmed || cwd === undefined) return\n this.warmed = true\n repoRegistry(this.ctx).discover(cwd, { ...this.options, cwd })\n }\n\n /** The cache key of one repository's container target. */\n private targetKey(repository: RepoContainerSpec): string {\n return [\n repository.hostWorkspaceRoot,\n repository.cli,\n repository.container ?? '',\n repository.sandbox ?? '',\n String(repository.ensureUp),\n ].join('\\u0000')\n }\n\n /** Drop one cached target, so the next command probes the container again. */\n private forgetTarget(key: string): void {\n this.targets.delete(key)\n }\n\n /** Resolve (once per repository) where commands run. */\n private containerTarget(key: string, repository: RepoContainerSpec, signal: AbortSignal): Promise<ContainerTarget> {\n const cached = this.targets.get(key)\n if (cached !== undefined) return cached\n const pending = resolveContainerTarget(repository, this.internals.run ?? runContainerCommand, signal)\n this.targets.set(key, pending)\n pending.catch(() => {\n // A failed probe must not cache its failure: the next command retries.\n if (this.targets.get(key) === pending) this.targets.delete(key)\n })\n return pending\n }\n}\n\nexport default DevcontainerShellExecutor\n"],"mappings":";;;;;;;;;;;;AAqBA,MAAM,oBAAyC,IAAI,IAAI,qBAAqB;;;;;;AAO5E,MAAa,qBAAuD;CAClE,MAAM;CACN,qBAAqB;CACrB,UAAU;AACZ;;;;;;;;;;AAyBA,SAAgB,aACd,MACA,KACA,QACwB;CACxB,MAAM,UAAkC,CAAC;CACzC,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,GAAG;EACvD,IAAI,kBAAkB,IAAI,GAAG,GAAG;EAChC,QAAQ,OAAO;CACjB;CACA,OAAO;EACL,GAAG;EACH,GAAG,KAAK;EACR,GAAG;EACH,GAAG;CACL;AACF;;;;;;;AAQA,SAAgB,WAAW,OAAyB;CAClD,MAAM,QAAQ,MAAM,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,QAAO,SAAQ,SAAS,EAAE;CAClE,OAAO,MAAM,WAAW,IAAI,CAAC,WAAW,IAAI;AAC9C;;AAGA,SAAS,SAAS,KAAiD;CACjE,OAAO,OAAO,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,MAAgB;AAC5E;;AAGA,SAAS,MAAM,OAAuB;CACpC,OAAO,IAAI,MAAM,WAAW,KAAK,OAAO,EAAE;AAC5C;;;;;;AAOA,SAAgB,cAAc,OAAyC;CACrE,MAAM,EAAE,MAAM,QAAQ,kBAAkB,YAAY;CACpD,MAAM,QAAQ,SAAS,MAAM,GAAG;CAChC,MAAM,OAAO,KAAK;CAClB,QAAQ,OAAO,MAAf;EACE,KAAK,UACH,OAAO;GACL;GAAU;GAAQ;GAAM;GAAM;GAC9B,GAAG,SAAS,KAAA,IAAY,CAAC,IAAI,CAAC,M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region src/types.d.ts
2
+ /**
3
+ * Repository container vocabulary: the discovered specification every module in
4
+ * this Bundle passes around, and the shared executor options each Loader row
5
+ * resolves from its own config.
6
+ * @module @banzhe/dsh-devcontainer/types
7
+ */
8
+ /**
9
+ * How the executor reaches the repository's Linux runtime.
10
+ *
11
+ * `sbx` is the Docker Sandbox CLI: a sandbox mounts the host workspace at the
12
+ * same absolute path, so a repository needs no Dev Container declaration to run
13
+ * in one. `devcontainer` / `docker` reach a container the Dev Container
14
+ * specification describes.
15
+ */
16
+ type ContainerCli = 'auto' | 'devcontainer' | 'docker' | 'sbx';
17
+ /** The options a Loader row contributes to discovery, before the file overrides them. */
18
+ interface ContainerOptions {
19
+ shell: string;
20
+ cli: ContainerCli;
21
+ ensureUp: boolean;
22
+ containerTimeoutMs: number;
23
+ /**
24
+ * Refuse to run commands on the host when a workdir names no Dev Container
25
+ * repository (default false). This is what a `(devContainer)` preset implies
26
+ * on its own; the flag exists for a deployment that wants that guarantee for
27
+ * every preset.
28
+ */
29
+ requireContainer: boolean;
30
+ }
31
+ //#endregion
32
+ export { ContainerOptions as t };
33
+ //# sourceMappingURL=types-DsF9Hz5P.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-DsF9Hz5P.d.ts","names":[],"sources":["../src/types.ts"],"mappings":";;;;;;;;;;;;;;;KAeY;;UA4CK;EACf;EACA,KAAK;EACL;EACA;;;;;;;EAOA"}