@struktoai/mirage-dsh 0.0.1 → 0.0.6

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.
@@ -1,108 +0,0 @@
1
- import { Context } from '@deepseek-ai/cordis';
2
- import { ShellExecutor, ShellExecRequest, ShellExecSpec, ShellRunResult, ShellProcess } from '@deepseek-ai/dsh-shell';
3
-
4
- /** Configuration for the mirage shell executor. */
5
- interface MirageShellConfig {
6
- /**
7
- * Default working directory for commands. Defaults to `/`. With
8
- * `sessionId` it instead seeds the bound session's initial cwd, and the
9
- * session's own cwd is the default from then on.
10
- */
11
- workdir?: string;
12
- /** Default foreground timeout in milliseconds. Defaults to 120000. */
13
- defaultTimeoutMs?: number;
14
- /** Upper cap on any requested timeout. Defaults to 600000. */
15
- maxTimeoutMs?: number;
16
- /** Default stdout capture budget in bytes. Defaults to 200000. */
17
- stdoutMaxBytes?: number;
18
- /** stderr capture budget in bytes. Defaults to 64000. */
19
- stderrMaxBytes?: number;
20
- /**
21
- * Bind every command to this named workspace session. By default each
22
- * command runs in an ephemeral fork of the workspace's default session,
23
- * so nothing persists between calls, which is the one-shot contract of
24
- * dsh's bash tool. With a session bound, `cd`, `export`, and function
25
- * definitions persist across calls, the persistent-shell contract. The
26
- * session is created on first use if the workspace does not have it; an
27
- * existing session is adopted as is. A spec carrying an explicit
28
- * `workdir` or `env` still runs as a one-call subshell of the bound
29
- * session, per mirage's `ExecuteOptions` semantics.
30
- */
31
- sessionId?: string;
32
- /**
33
- * When set, a background command whose streamed output overruns its
34
- * delta budget spills its full stdout and stderr to files under this
35
- * workspace directory, and `readOutput()` points at them so a reader
36
- * can recover what the delta dropped. The directory is a workspace
37
- * path (e.g. `/tmp` on a ram mount), so the agent reads the spill
38
- * through the same VFS as everything else; the writes go through the
39
- * workspace, so they appear in history like any other write. Unset
40
- * (the default) means no spill: output that overruns is simply
41
- * flagged `lossy`, the honest "no safe path available" answer.
42
- */
43
- spillDir?: string;
44
- }
45
- /**
46
- * Mirage-backed implementation of `ctx.shell`: `run` executes the command
47
- * line with mirage's own shell (coreutils-faithful commands, installed
48
- * CLIs, the policy layer) against the shared `ctx.mirage` workspace, so a
49
- * path from `ctx.fs` means the same file here. There is no OS process
50
- * behind a command: `signal` in results is a compatibility value for kills,
51
- * and abort/timeout act cooperatively at the executor's own boundaries.
52
- *
53
- * Every command runs in an ephemeral fork of the workspace's default
54
- * session, so no shell state survives from one call to the next, matching
55
- * the one-shot contract of dsh's bash tool. Configuring a `sessionId`
56
- * binds all commands to one named session instead, whose cwd, exports,
57
- * and functions persist across calls.
58
- */
59
- declare class MirageShellExecutor extends ShellExecutor {
60
- static readonly inject: string[];
61
- private readonly workdir;
62
- private readonly defaultTimeoutMs;
63
- private readonly maxTimeoutMs;
64
- private readonly stdoutMaxBytes;
65
- private readonly stderrMaxBytes;
66
- private readonly sessionId;
67
- private readonly spillDir;
68
- private sessionReady;
69
- constructor(ctx: Context, config?: MirageShellConfig);
70
- private workspace;
71
- private newSpill;
72
- /**
73
- * With every runtime in the world reaching only the vfs
74
- * (`ctx.mirage.vfsOnly`), the workspace dispatch is the single gate
75
- * for anything a command can do, so this executor behaves like a
76
- * workspace-write sandbox: reads and writes land only where mounts
77
- * (and their modes) allow. Declaring it lets sandbox-aware plugins
78
- * (dsh's permission presets) compose over this executor. A world
79
- * holding a runtime with doors around the gate (the host `local`
80
- * python, a remote sandbox) voids that claim, so this answers
81
- * undefined then (the base contract's "does not sandbox") and those
82
- * plugins refuse to compose instead of trusting a lie.
83
- */
84
- get sandboxMode(): ShellExecutor['sandboxMode'];
85
- /**
86
- * The sandbox facts to stamp on this run's result and process handle,
87
- * or undefined when the world is not fully workspace-bound (no claim).
88
- *
89
- * `enforcement` is 'full': when every runtime reaches only the vfs, the
90
- * workspace gate cannot be bypassed, so unlike an OS sandbox on an older
91
- * kernel there is no promised effect it fails to govern. `denied` is
92
- * false because mirage has no out-of-band denial channel: a refused write
93
- * (a read-only mount) fails in-band as an ordinary command error with a
94
- * nonzero exit, the way EROFS would, not as a separate sandbox verdict,
95
- * so there is nothing here to distinguish from the command's own failure.
96
- * `runnerFailed` is false because the workspace executor is the runner
97
- * and a failure to run surfaces as a rejected/aborted execution, not a
98
- * runner that never started.
99
- */
100
- private sandboxInfo;
101
- resolve(request: ShellExecRequest): ShellExecSpec;
102
- private ensureSession;
103
- private provisionSession;
104
- run(spec: ShellExecSpec): Promise<ShellRunResult>;
105
- start(spec: ShellExecSpec): ShellProcess;
106
- }
107
-
108
- export { type MirageShellConfig as M, MirageShellExecutor as a };