better-dsh 0.0.0 → 0.2.3

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.
Files changed (142) hide show
  1. package/LICENSE +24 -0
  2. package/README.md +294 -4
  3. package/control-prompt.md +37 -0
  4. package/cordis.patch.yml +53 -0
  5. package/docs/00_adr/0001-bridge-tool-layer-not-service-layer.md +14 -0
  6. package/docs/00_adr/0002-masking-is-presentation-only.md +15 -0
  7. package/docs/10_plans/A2A-messaging-channel-test-archive.md +256 -0
  8. package/docs/10_plans/code-mode-vs-rlm-ipython-comparison.md +137 -0
  9. package/docs/10_plans/dashr-blueprint-review.md +201 -0
  10. package/docs/10_plans/dashr-blueprint.md +561 -0
  11. package/docs/10_plans/dashr-compaction-window-and-archive.md +307 -0
  12. package/docs/10_plans/dashr-profile-layer-feasibility.md +367 -0
  13. package/docs/10_plans/dashr-sandbox-escalation-semantics-gap.md +171 -0
  14. package/docs/10_plans/dashr-security-sandbox-analysis.md +187 -0
  15. package/docs/10_plans/dashr-surface-invariant-and-omp-imports.md +97 -0
  16. package/docs/10_plans/ipython-kernel-interactive-interface-test-report.md +152 -0
  17. package/docs/10_plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft.md +146 -0
  18. package/docs/10_plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v3.md +50 -0
  19. package/docs/10_plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v4.md +79 -0
  20. package/docs/10_plans/kernel-refactoring/Dash-vs-PrimeAgent-systemprompt-toolcatalog-comparison.md +138 -0
  21. package/docs/10_plans/kernel-refactoring/RLM-system-prompt-injection-gap-report.md +161 -0
  22. package/docs/10_plans/kernel-refactoring/V0.1.5-development-plan.md +109 -0
  23. package/docs/10_plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_dsh.md +50 -0
  24. package/docs/10_plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_prime.md +113 -0
  25. package/docs/10_plans/recallable-compaction.md +147 -0
  26. package/docs/10_plans/spike-tag-repro.mjs +102 -0
  27. package/docs/10_plans/upstream-analysis.md +128 -0
  28. package/docs/50_test-reports/REPL-/345/267/245/345/205/267/350/260/203/347/224/250-/346/210/252/346/226/255/350/257/212/346/226/255.md +110 -0
  29. package/docs/50_test-reports/kernel-provisioning.md +44 -0
  30. package/docs/50_test-reports/repl-kernel-provisioning-test-report.md +87 -0
  31. package/docs/50_test-reports/upstream-dsh-0.1.2-alpha.5-local-test-report.md +81 -0
  32. package/docs/50_test-reports/upstream-dsh-0.1.2-alpha.5-report.md +93 -0
  33. package/docs/50_test-reports/v0.1.8-improved-/345/256/236/346/265/213/346/212/245/345/221/212.md +142 -0
  34. package/docs/50_test-reports/v0.1.8-/345/256/236/346/265/213/346/212/245/345/221/212.md +193 -0
  35. package/docs/50_test-reports/v0.1.8b-/345/256/236/346/265/213/346/212/245/345/221/212.md +96 -0
  36. package/docs/50_test-reports/v0.1.8c-/345/256/236/346/265/213/346/212/245/345/221/212.md +127 -0
  37. package/docs/50_test-reports/v0.1.8d-/345/256/236/346/265/213/346/212/245/345/221/212.md +150 -0
  38. package/docs/50_test-reports/v0.1.8d_artifacts/README.md +138 -0
  39. package/docs/50_test-reports/v0.1.8d_artifacts/code-mode-repl-only.observation.md +74 -0
  40. package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.jsonl +3890 -0
  41. package/docs/50_test-reports/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.w-sample-0435.jsonl +544 -0
  42. package/docs/50_test-reports/v0.1.8d_artifacts/functions.json +592 -0
  43. package/docs/50_test-reports/v0.1.8d_artifacts/skills-catalog.snapshot.md +30 -0
  44. package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.output-schemas.json +1236 -0
  45. package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.python.txt +592 -0
  46. package/docs/50_test-reports/v0.1.8d_artifacts/tools-sdk.typescript.txt +516 -0
  47. package/docs/50_test-reports/v0.1.8d_artifacts/wire-vs-transcription.diff.md +54 -0
  48. package/docs/50_test-reports/v0.1.8e-/345/256/236/346/265/213/346/212/245/345/221/212.md +224 -0
  49. package/docs/50_test-reports/v0.1.9a-/345/256/236/346/265/213/346/212/245/345/221/212.md +168 -0
  50. package/docs/50_test-reports/v0.2.0b-/345/256/236/346/265/213/346/212/245/345/221/212.md +123 -0
  51. package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.lock +7 -0
  52. package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/Cargo.toml +6 -0
  53. package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/bin/messy.rs +8 -0
  54. package/docs/50_test-reports/v0.2.0b_artifacts/f2probe/src/main.rs +4 -0
  55. package/docs/50_test-reports/v0.2.0b_artifacts/hashline-probe.md +5 -0
  56. package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.lock +7 -0
  57. package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/Cargo.toml +7 -0
  58. package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/build.rs +4 -0
  59. package/docs/50_test-reports/v0.2.0b_artifacts/slowprobe/src/main.rs +13 -0
  60. package/docs/50_test-reports/v0.2.1-/345/256/236/346/265/213/346/212/245/345/221/212.md +110 -0
  61. package/docs/50_test-reports/v0.2.1b-/345/256/236/346/265/213/346/212/245/345/221/212.md +86 -0
  62. package/docs/50_test-reports/v0.2.1c-/345/256/236/346/265/213/346/212/245/345/221/212.md +66 -0
  63. package/docs/50_test-reports/v0.2.1d-/345/256/236/346/265/213/346/212/245/345/221/212.md +67 -0
  64. package/docs/50_test-reports/v0.2.1e-P1-/345/256/236/346/265/213/346/212/245/345/221/212.md +136 -0
  65. package/docs/50_test-reports/v0.2.1ef-dev-audit-report.md +73 -0
  66. package/docs/50_test-reports/v0.2.1f-plugin-shipped-ui-patches/345/256/236/346/265/213/346/212/245/345/221/212.md +102 -0
  67. package/docs/60_exploration-and-research/cordis-research.md +350 -0
  68. package/docs/60_exploration-and-research/dsh-web-profile-package-map.md +186 -0
  69. package/docs/60_exploration-and-research/dsh-web-ui-slot-system-research.md +310 -0
  70. package/docs/60_exploration-and-research/dsh-webui-strip-boundary-research.md +300 -0
  71. package/docs/60_exploration-and-research/ios-chat-app-bridge-research.md +324 -0
  72. package/docs/60_exploration-and-research/web-frontend-composability-research.md +191 -0
  73. package/docs/REPL-/345/267/245/345/205/267/350/260/203/347/224/250-/346/210/252/346/226/255/350/257/212/346/226/255.md +110 -0
  74. package/docs/adr/0001-bridge-tool-layer-not-service-layer.md +14 -0
  75. package/docs/adr/0002-masking-is-presentation-only.md +15 -0
  76. package/docs/distro-blueprint.md +81 -0
  77. package/docs/dsh-webUI-with-rlm-mode.png +0 -0
  78. package/docs/plans/A2A-messaging-channel-test-archive.md +256 -0
  79. package/docs/plans/code-mode-vs-rlm-ipython-comparison.md +137 -0
  80. package/docs/plans/dashr-blueprint-review.md +201 -0
  81. package/docs/plans/dashr-blueprint.md +561 -0
  82. package/docs/plans/dashr-compaction-window-and-archive.md +307 -0
  83. package/docs/plans/dashr-profile-layer-feasibility.md +367 -0
  84. package/docs/plans/dashr-sandbox-escalation-semantics-gap.md +171 -0
  85. package/docs/plans/dashr-security-sandbox-analysis.md +187 -0
  86. package/docs/plans/dashr-surface-invariant-and-omp-imports.md +97 -0
  87. package/docs/plans/ipython-kernel-interactive-interface-test-report.md +152 -0
  88. package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft.md +146 -0
  89. package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v3.md +50 -0
  90. package/docs/plans/kernel-refactoring/Dash-IPython-Control-Prompt-draft_v4.md +79 -0
  91. package/docs/plans/kernel-refactoring/Dash-vs-PrimeAgent-systemprompt-toolcatalog-comparison.md +138 -0
  92. package/docs/plans/kernel-refactoring/RLM-system-prompt-injection-gap-report.md +161 -0
  93. package/docs/plans/kernel-refactoring/V0.1.5-development-plan.md +109 -0
  94. package/docs/plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_dsh.md +50 -0
  95. package/docs/plans/kernel-refactoring/actinoable-surface-to-llm-in-agent-runtime_prime.md +113 -0
  96. package/docs/plans/recallable-compaction.md +147 -0
  97. package/docs/plans/spike-tag-repro.mjs +102 -0
  98. package/docs/plans/upstream-analysis.md +128 -0
  99. package/docs/repositioning-and-rebranding.md +102 -0
  100. package/docs/v0.1.8-improved-/345/256/236/346/265/213/346/212/245/345/221/212.md +142 -0
  101. package/docs/v0.1.8-/345/256/236/346/265/213/346/212/245/345/221/212.md +193 -0
  102. package/docs/v0.1.8b-/345/256/236/346/265/213/346/212/245/345/221/212.md +96 -0
  103. package/docs/v0.1.8c-/345/256/236/346/265/213/346/212/245/345/221/212.md +127 -0
  104. package/docs/v0.1.8d-/345/256/236/346/265/213/346/212/245/345/221/212.md +150 -0
  105. package/docs/v0.1.8d_artifacts/README.md +138 -0
  106. package/docs/v0.1.8d_artifacts/code-mode-repl-only.observation.md +74 -0
  107. package/docs/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.jsonl +3890 -0
  108. package/docs/v0.1.8d_artifacts/dsh-session-session-4a293388-9ae1-474b-87a0-9e17bb556d94.w-sample-0435.jsonl +544 -0
  109. package/docs/v0.1.8d_artifacts/functions.json +592 -0
  110. package/docs/v0.1.8d_artifacts/skills-catalog.snapshot.md +30 -0
  111. package/docs/v0.1.8d_artifacts/tools-sdk.output-schemas.json +1236 -0
  112. package/docs/v0.1.8d_artifacts/tools-sdk.python.txt +592 -0
  113. package/docs/v0.1.8d_artifacts/tools-sdk.typescript.txt +516 -0
  114. package/docs/v0.1.8d_artifacts/wire-vs-transcription.diff.md +54 -0
  115. package/docs/v0.1.8e-/345/256/236/346/265/213/346/212/245/345/221/212.md +224 -0
  116. package/docs/v0.1.9a-/345/256/236/346/265/213/346/212/245/345/221/212.md +168 -0
  117. package/docs/v0.2.0b-/345/256/236/346/265/213/346/212/245/345/221/212.md +123 -0
  118. package/docs/v0.2.0b_artifacts/f2probe/Cargo.lock +7 -0
  119. package/docs/v0.2.0b_artifacts/f2probe/Cargo.toml +6 -0
  120. package/docs/v0.2.0b_artifacts/f2probe/src/bin/messy.rs +8 -0
  121. package/docs/v0.2.0b_artifacts/f2probe/src/main.rs +4 -0
  122. package/docs/v0.2.0b_artifacts/hashline-probe.md +5 -0
  123. package/docs/v0.2.0b_artifacts/slowprobe/Cargo.lock +7 -0
  124. package/docs/v0.2.0b_artifacts/slowprobe/Cargo.toml +7 -0
  125. package/docs/v0.2.0b_artifacts/slowprobe/build.rs +4 -0
  126. package/docs/v0.2.0b_artifacts/slowprobe/src/main.rs +13 -0
  127. package/docs/v0.2.1-/345/256/236/346/265/213/346/212/245/345/221/212.md +110 -0
  128. package/docs/v0.2.1b-/345/256/236/346/265/213/346/212/245/345/221/212.md +86 -0
  129. package/docs/v0.2.1c-/345/256/236/346/265/213/346/212/245/345/221/212.md +66 -0
  130. package/lib/client/index.js +473 -0
  131. package/lib/index.d.ts +736 -0
  132. package/lib/index.js +11518 -0
  133. package/lib/kernel-env-hxaihi9C.js +195 -0
  134. package/lib/kernel-env.d.ts +80 -0
  135. package/lib/kernel-env.js +3 -0
  136. package/lib/py-sdk-BCaOGYz7.d.ts +125 -0
  137. package/lib/py-sdk-CbgYiX8O.js +691 -0
  138. package/lib/py-sdk.d.ts +2 -0
  139. package/lib/py-sdk.js +3 -0
  140. package/package.json +325 -4
  141. package/scripts/kernel-provision.mjs +35 -0
  142. package/index.js +0 -3
package/lib/index.d.ts ADDED
@@ -0,0 +1,736 @@
1
+ import { t as DASHRSdkSchema } from "./py-sdk-BCaOGYz7.js";
2
+ import { Context, Service } from "@deepseek-ai/cordis";
3
+ import z from "@deepseek-ai/schemastery";
4
+ import { ToolDefinition, ToolExecutionInput, ToolRunContext, ToolRuntime } from "@deepseek-ai/dsh-tools";
5
+ import { ContentBlock, HarnessError } from "@deepseek-ai/dsh-llm";
6
+ import { ScopeKey, Scoped } from "@deepseek-ai/dsh-scope";
7
+ import { Agent } from "@deepseek-ai/dsh-agent";
8
+
9
+ //#region src/vendored/types.d.ts
10
+
11
+ /**
12
+ * Vocabulary types for the code-execution seam: what a caller hands a
13
+ * {@link ./repl-runtime.ts | ReplRuntime} and what it gets back. Pure types — no
14
+ * runtime code lives here.
15
+ *
16
+ * Vendored from `@deepseek-ai/dsh-code-runtime@0.1.0-rc.6` (`src/types.ts`)
17
+ * per blueprint v0.5 §7.6: type shapes are the interop contract our
18
+ * presentation/SDK work builds against, so they are carried unchanged apart
19
+ * from the recorded deltas:
20
+ *
21
+ * 1. the module header and the two `../index.ts` doc links were rewritten for
22
+ * this location;
23
+ * 2. `CodeRunRequest.principal` is a DASHR-OWNED field (M3-A, blueprint §6
24
+ * "kernel per-session 键控"): upstream's seam deliberately has no session
25
+ * concept, but a stateful backend must key its persistent substrate by the
26
+ * calling session or every session sharing one service instance would
27
+ * share one namespace. Optional so upstream-shaped requests stay valid —
28
+ * an absent principal addresses the provider's shared default key.
29
+ * 3. `CodeBindingNamespace.callable` is a DASHR-OWNED field (M3-B, blueprint
30
+ * §9, introduced for the rlm() bare-callable binding family — deleted in
31
+ * v0.1.8, kept for shape compatibility): upstream's object-holder model
32
+ * (a global whose MEMBERS are callable) cannot express a bare callable
33
+ * global. `callable: true` declares the global itself is a
34
+ * function; `functions` then carries exactly one entry — the single host
35
+ * function the global call dispatches. Optional so upstream-shaped
36
+ * namespaces stay valid.
37
+ *
38
+ * @module dashr/vendored/types
39
+ */
40
+ /**
41
+ * One host-side function exposed to the program as an async callable. The
42
+ * runtime bridges calls to it (possibly across a serialization boundary), so
43
+ * `args` and the resolution value MUST be lossless JSON. A runtime rejects a
44
+ * lossy or non-cloneable value with a descriptive error rather than corrupting
45
+ * the run. No seam-level byte cap applies to a binding resolution. A rejection
46
+ * of this function surfaces inside the program as a rejection of the
47
+ * corresponding call.
48
+ */
49
+ type CodeBindingFunction = (args: unknown) => Promise<CodeJsonValue>;
50
+ /** A lossless JSON value transferable through the dependency-light Service Definition. */
51
+ type CodeJsonValue = null | boolean | number | string | CodeJsonValue[] | {
52
+ [key: string]: CodeJsonValue;
53
+ };
54
+ /**
55
+ * Program-visible typed rejection for one binding namespace. The runtime
56
+ * injects a real error constructor under `name`; rejected member calls become
57
+ * its instances and expose the exact member name through
58
+ * `memberNameProperty`. Both strings are runtime data rather than knowledge
59
+ * of a particular consumer such as Code Mode.
60
+ */
61
+ interface CodeBindingErrorClass {
62
+ /** Constructor global and resulting `Error.name`; same portable identifier rule as {@link CodeBindingNamespace.global}. */
63
+ name: string;
64
+ /**
65
+ * Non-empty own property for the member name. The portable exclusion set is
66
+ * `RESERVED_ERROR_MEMBERS` plus dunder-form names (`__x__`, non-empty
67
+ * middle), enforced identically by every backend; any other name —
68
+ * identifiers or not — is accepted everywhere.
69
+ */
70
+ memberNameProperty: string;
71
+ }
72
+ /**
73
+ * A named group of {@link CodeBindingFunction}s the runtime exposes to the
74
+ * program as one global object (e.g. `tools`). Function names are arbitrary
75
+ * strings — a runtime must treat names like `__proto__` or `constructor` as
76
+ * ordinary own properties (null-prototype construction), never as prototype
77
+ * collisions.
78
+ */
79
+ interface CodeBindingNamespace {
80
+ /**
81
+ * The global identifier the program sees. Must match the LANGUAGE-PORTABLE
82
+ * identifier subset `[A-Za-z_][A-Za-z0-9_]*` and no language's reserved
83
+ * words, so the same namespace list works against every backend regardless
84
+ * of `language` — a JS-only spelling like `$tools` is rejected by design,
85
+ * not just by the Python backend. Names that satisfy the identifier rule but
86
+ * name a backend-owned slot (`RESERVED_BINDING_GLOBALS`, e.g. `console`,
87
+ * `__dsh_main__`) are also refused everywhere; see its declaration for the
88
+ * exact set and why each entry is reserved.
89
+ */
90
+ global: string;
91
+ /** The callable members, keyed by the exact name the program calls. */
92
+ functions: Record<string, CodeBindingFunction>;
93
+ /**
94
+ * Materialize the global itself as a callable function rather than an
95
+ * object whose members are callable. When true, `functions` must contain
96
+ * EXACTLY ONE entry — the single host function the bare global call
97
+ * dispatches (its key is a transport detail, not a program-visible member).
98
+ * DASHR-owned delta (M3-B, blueprint §9): introduced for the rlm()
99
+ * bare-callable family (deleted in v0.1.8; the flat per-tool bindings
100
+ * succeeded it under the object-holder model).
101
+ */
102
+ callable?: true;
103
+ /** Optional program-visible typed rejection contract for this namespace. */
104
+ errorClass?: CodeBindingErrorClass;
105
+ }
106
+ /**
107
+ * One run: the program source plus everything the runtime acts on. Per the
108
+ * explicit-over-implicit convention, defaulting (time budgets, output caps)
109
+ * is the implementation's validated config — a request carries no optional
110
+ * tuning knobs for a hidden `??` to fill in.
111
+ */
112
+ interface CodeRunRequest {
113
+ /**
114
+ * The program source, in the runtime's {@link ./repl-runtime.ts | language}. It
115
+ * runs as the body of an async function: top-level `await` and `return`
116
+ * are available, and the completion value becomes
117
+ * {@link CodeRunResult.value}.
118
+ */
119
+ program: string;
120
+ /** Host functions exposed to the program, one global object per namespace. */
121
+ bindings: CodeBindingNamespace[];
122
+ /**
123
+ * Abort the run: the runtime stops the program (hard, even mid-loop) and
124
+ * resolves with a {@link CodeRunFailure} of kind `'abort'`. In-flight
125
+ * binding calls are the CALLER's to settle — the runtime only stops asking.
126
+ */
127
+ signal?: AbortSignal;
128
+ /**
129
+ * The calling session/agent identity the run's state belongs to — a
130
+ * STATEFUL backend keys its persistent substrate by this (one namespace per
131
+ * principal) so sessions sharing one service instance never share state.
132
+ * DASHR-owned delta on the upstream seam (which is session-less); see the
133
+ * module header. The presentation layer passes the calling `Agent`'s id; an
134
+ * absent or empty principal addresses the provider's shared default key
135
+ * (upstream-shaped requests keep their M1 meaning).
136
+ */
137
+ principal?: string;
138
+ /**
139
+ * The kernel's working directory: the calling SESSION's workspace
140
+ * (`agent.session.header.cwd`), threaded by the presentation layer. Never
141
+ * the daemon's `process.cwd()`: a kernel is per-session state, so its cwd
142
+ * is per-session state, and inheriting the host cwd leaked the systemd
143
+ * unit's WorkingDirectory into every kernel regardless of the workspace the
144
+ * session was opened in. Absent (older caller, agentless run) → spawn-time
145
+ * inherit. Resolved ONLY on first spawn of a principal; a reused kernel
146
+ * keeps the cwd it booted with (a session's workspace is fixed in its
147
+ * header).
148
+ */
149
+ cwd?: string;
150
+ /**
151
+ * Per-run wall budget override, in milliseconds. Absent → the runtime's
152
+ * configured `runTimeoutMs`. DASHR-owned delta: upstream's one-shot seam
153
+ * fixes the budget in config alone; a stateful REPL wants a cell to be
154
+ * able to say "this one is slow" without reconfiguring the whole mount.
155
+ */
156
+ timeoutMs?: number;
157
+ /**
158
+ * Reset the persistent namespace to empty BEFORE this run. The runtime
159
+ * disposes the principal's kernel and clears its on-disk snapshot, so the
160
+ * next spawn restores nothing and starts a fresh, empty namespace.
161
+ * DASHR-owned delta: the M3-B snapshot/restore chain owns state revival;
162
+ * a model must be able to abandon that state deliberately.
163
+ */
164
+ reset?: boolean;
165
+ }
166
+ /**
167
+ * Why a run failed. The kinds are orthogonal outcomes reported independently
168
+ * (per docs/defensive-patterns.md): a budget expiry is not an exception, an
169
+ * abort is not a timeout, and a substrate death is neither.
170
+ *
171
+ * - `'exception'` — the program threw or failed to parse/transform.
172
+ * - `'timeout'` — an implementation-owned budget expired; the message says which.
173
+ * - `'abort'` — {@link CodeRunRequest.signal} fired.
174
+ * - `'worker-exit'` — the execution substrate died without settling (e.g. OOM).
175
+ * - `'invalid-output'` — the completion value was not lossless JSON.
176
+ * - `'output-limit'` — the serialized outer logs/value/diagnostic exceeded the configured cap.
177
+ */
178
+ interface CodeRunFailure {
179
+ /** The failure class (see the interface doc for each kind's meaning). */
180
+ kind: 'exception' | 'timeout' | 'abort' | 'worker-exit' | 'invalid-output' | 'output-limit';
181
+ /** Human-readable detail, suitable for feeding back to a model to self-correct. */
182
+ message: string;
183
+ }
184
+ /**
185
+ * The outcome of one run. An error is a FIELD on a resolved result, never a
186
+ * rejection of `run()` — reporting a failed program is the caller's job, not
187
+ * an exception path.
188
+ */
189
+ interface CodeRunResult {
190
+ /**
191
+ * The program's completion value (its top-level `return`), when it ran to
192
+ * completion and the value crossed the runtime's lossless-JSON boundary.
193
+ * Invalid or over-limit completions fail the run instead of substituting a
194
+ * rendered string; a failed or value-less run leaves this absent.
195
+ */
196
+ value?: CodeJsonValue;
197
+ /** Text the program emitted, in order, bounded only as part of the outer result. */
198
+ logs: string[];
199
+ /** Present iff the run failed; see {@link CodeRunFailure} for the taxonomy. */
200
+ error?: CodeRunFailure;
201
+ }
202
+ //#endregion
203
+ //#region src/vendored/repl-runtime.d.ts
204
+
205
+ declare module '@deepseek-ai/cordis' {
206
+ interface Context {
207
+ replRuntime: ReplRuntime;
208
+ }
209
+ }
210
+ /**
211
+ * Registers one `ctx.replRuntime` implementation. Program, budget, abort, and substrate
212
+ * failures resolve in {@link CodeRunResult}; only Service Definition contract misuse rejects. Implementations bridge
213
+ * structured-cloneable bindings, materialize each declared namespace rejection
214
+ * class, treat programs as hostile peers — budget, interrupt, and substrate
215
+ * semantics apply per program and are unchanged by this seam's statefulness —
216
+ * share one persistent per-session user namespace across runs (state
217
+ * codification across runs IS the product; this replaces upstream's
218
+ * isolate-runs-from-one-another clause), and terminate and await in-flight
219
+ * runs during disposal.
220
+ */
221
+ declare abstract class ReplRuntime extends Service {
222
+ /**
223
+ * The source language {@link run} expects `program` to be written in, as a
224
+ * lowercase identifier. Informational, not gating — a consumer that
225
+ * generates language-specific presentation (typed SDK stubs, usage
226
+ * instructions) switches on it and fails loud on a language it cannot
227
+ * present. Well-known values: `'typescript'` and `'python'`, those
228
+ * `dsh-tools` presents; only `'typescript'` has a published backend.
229
+ */
230
+ abstract readonly language: string;
231
+ /**
232
+ * The execution substrate, as a lowercase identifier. Informational, not
233
+ * gating — a descriptor so deployments and diagnostics can tell backends
234
+ * apart, not a security claim. Well-known values: `'worker-thread'`,
235
+ * `'process'`, `'container'`.
236
+ */
237
+ abstract readonly isolation: string;
238
+ constructor(ctx: Context);
239
+ /**
240
+ * Execute one program against the request's bindings and capture what it
241
+ * emitted. See the class doc for the resolution contract (error is a result
242
+ * field; rejection means Service Definition contract misuse only).
243
+ * @param request - the program, its bindings, and the abort signal; the
244
+ * request carries everything the runtime acts on, with no hidden defaults.
245
+ * @returns the run's outcome: completion value (when transferable), the
246
+ * ordered log capture, and the failure (if any).
247
+ */
248
+ abstract run(request: CodeRunRequest): Promise<CodeRunResult>;
249
+ }
250
+ //#endregion
251
+ //#region src/runtime-surface.d.ts
252
+ /**
253
+ * The `replRuntime` seam surface, as the presentation half of this plugin
254
+ * consumes it — a STRUCTURAL MIRROR of the vendored Service Definition
255
+ * (`src/vendored/repl-runtime.ts`, itself vendored verbatim from
256
+ * `@deepseek-ai/dsh-code-runtime@0.1.0-rc.6` `src/types.ts`).
257
+ *
258
+ * Why a mirror instead of a direct import, even inside one package: the
259
+ * presentation programs against a NARROW view of the runtime contract
260
+ * (bindings, dispatch logs, results) — the same shape a third-party
261
+ * `ctx.replRuntime` implementation would expose. Structural typing is what
262
+ * the Cordis service boundary is built on (contexts resolve implementations
263
+ * by key, not by class identity), so depending on the shape — not on our own
264
+ * `DashrRuntime` class — keeps the presentation implementation-agnostic.
265
+ *
266
+ * Drift control: `test/compat.spec.ts` statically asserts this surface is
267
+ * exactly compatible with the vendored types — a contract change there
268
+ * fails this package's typecheck.
269
+ * @module dashr-repl/runtime-surface
270
+ */
271
+ /** One host-side function exposed to the program as an async callable; args and resolution must be lossless JSON. */
272
+ type ReplBindingFunction = (args: unknown) => Promise<ReplJsonValue>;
273
+ /** A lossless JSON value transferable through the dependency-light Service Definition. */
274
+ type ReplJsonValue = null | boolean | number | string | ReplJsonValue[] | {
275
+ [key: string]: ReplJsonValue;
276
+ };
277
+ /** Program-visible typed rejection for one binding namespace (constructor name + member carrying the called name). */
278
+ interface ReplBindingErrorClass {
279
+ /** Constructor global and resulting `Error.name`. */
280
+ name: string;
281
+ /** Non-empty own property for the member name. */
282
+ memberNameProperty: string;
283
+ }
284
+ /** A named group of binding functions exposed as one global object (e.g. `tools`). */
285
+ interface ReplBindingNamespace {
286
+ /** The global identifier the program sees (portable identifier subset, no reserved words). */
287
+ global: string;
288
+ /** The callable members, keyed by the exact name the program calls. */
289
+ functions: Record<string, ReplBindingFunction>;
290
+ /**
291
+ * Materialize the global itself as a callable function rather than an
292
+ * object whose members are callable. When true, `functions` must contain
293
+ * EXACTLY ONE entry — the single host function the bare global call
294
+ * dispatches. Mirrors the vendored seam's DASHR-owned `callable` field
295
+ * (M3-B: the bridge callables and the v0.1.5 flat per-tool bindings).
296
+ */
297
+ callable?: true;
298
+ /** Optional program-visible typed rejection contract for this namespace. */
299
+ errorClass?: ReplBindingErrorClass;
300
+ }
301
+ /** One run: the program source plus everything the runtime acts on. */
302
+ interface ReplRunRequest {
303
+ /** The program source; runs as one cell with top-level `await`/`return` available. */
304
+ program: string;
305
+ /** Host functions exposed to the program, one global object per namespace. */
306
+ bindings: ReplBindingNamespace[];
307
+ /** Abort the run; resolves with a failure of kind `'abort'`. */
308
+ signal?: AbortSignal;
309
+ /**
310
+ * The calling session/agent identity (the `Agent` id): a stateful backend
311
+ * keys its persistent namespace by this, so sessions sharing one service
312
+ * instance never share state (kernel-per-session, M3-A). DASHR-owned delta
313
+ * on the upstream seam — see the vendored Service Definition's types.
314
+ principal?: string
315
+ /** Per-run wall budget override in milliseconds; absent → the runtime's configured default. */
316
+ timeoutMs?: number;
317
+ /** Reset the persistent namespace to empty before this run. */
318
+ reset?: boolean;
319
+ }
320
+ /** Why a run failed; an error is a FIELD on the resolved result, never a rejection of `run()`. */
321
+ interface ReplRunFailure {
322
+ /** The failure class. */
323
+ kind: 'exception' | 'timeout' | 'abort' | 'worker-exit' | 'invalid-output' | 'output-limit';
324
+ /** Human-readable detail, suitable for feeding back to a model to self-correct. */
325
+ message: string;
326
+ }
327
+ /** The outcome of one run. */
328
+ interface ReplRunResult {
329
+ /** The program's completion value, when it crossed the lossless-JSON boundary. */
330
+ value?: ReplJsonValue;
331
+ /** Text the program emitted, in order. */
332
+ logs: string[];
333
+ /** Present iff the run failed. */
334
+ error?: ReplRunFailure;
335
+ }
336
+ /** How one user-namespace variable query resolved. */
337
+ type ReplVarQuery = /** The value crossed the lossless-JSON boundary; `text` is its JSON text. */
338
+ {
339
+ kind: 'json';
340
+ text: string;
341
+ }
342
+ /** The value is not JSON-serializable; `text` is its `repr` text (annotate it as repr). */ | {
343
+ kind: 'repr';
344
+ text: string;
345
+ }
346
+ /** A bare/empty name: `names` lists the user-namespace variable names. */ | {
347
+ kind: 'names';
348
+ names: string[];
349
+ }
350
+ /** No such variable in the namespace (or no live kernel holds state). */ | {
351
+ kind: 'missing';
352
+ };
353
+ /**
354
+ * The `ctx.replRuntime` service as this plugin reads it. The language check
355
+ * belongs to the presentation: only `'python'` has an SDK renderer here.
356
+ */
357
+ interface ReplRuntimeSurface {
358
+ /** The source language {@link run} expects `program` to be written in (lowercase identifier). */
359
+ readonly language: string;
360
+ /** Execute one program against the request's bindings and capture what it emitted. */
361
+ run(request: ReplRunRequest): Promise<ReplRunResult>;
362
+ /**
363
+ * Read one user-namespace variable by name on the session's kernel. A
364
+ * bare/empty `name` lists the namespace's variable names; a JSON-serializable
365
+ * value resolves to its JSON text, any other value to its `repr` text, and a
366
+ * missing name to `{ kind: 'missing' }`. `principal` selects the session
367
+ * kernel (absent → the shared default), mirroring {@link ReplRunRequest.principal}.
368
+ * Optional so a third-party `ctx.replRuntime` provider without this DASHR
369
+ * channel stays structurally valid.
370
+ */
371
+ queryVar?(name: string, principal?: string): Promise<ReplVarQuery>;
372
+ /**
373
+ * Assign one lossless-JSON value into the user namespace under `name` on the
374
+ * session's kernel. `name` must be a usable identifier; `value` must be
375
+ * lossless JSON. Optional for the same reason as {@link queryVar}.
376
+ */
377
+ setVar?(name: string, value: unknown, principal?: string): Promise<void>;
378
+ }
379
+ //#endregion
380
+ //#region src/runtime.d.ts
381
+ /** Plugin config: every tunable, changeable from `cordis.yml` (no hardcoded tunables). */
382
+ interface Config$1 {
383
+ /** Python interpreter with `ipykernel` installed. The bare sentinel `python3` (or absent) selects a managed venv under {@link Config.kernelEnvDir}. */
384
+ python?: string;
385
+ /** Budget for kernel spawn → ready, in milliseconds. */
386
+ startupTimeoutMs?: number;
387
+ /** Wall budget per run; expiry interrupts the kernel then force-settles. */
388
+ runTimeoutMs?: number;
389
+ /** Grace between a timeout/abort interrupt and the force-settle, in milliseconds. */
390
+ interruptGraceMs?: number;
391
+ /**
392
+ * Confirm window between the control-channel interrupt and the SIGALRM
393
+ * escalation, in milliseconds; must stay below {@link Config.interruptGraceMs}.
394
+ * See the bridge's two-phase interrupt for why the escalation is deferred.
395
+ */
396
+ interruptConfirmMs?: number;
397
+ /** Budget for graceful kernel teardown (shutdown_request → SIGKILL), in milliseconds. */
398
+ disposeTimeoutMs?: number;
399
+ /** Budget for internal snapshot/restore cells (dill dump/load), in milliseconds. */
400
+ snapshotTimeoutMs?: number;
401
+ /** Hard cap for serialized log-array, completion-value, and failure-message payloads. */
402
+ maxOutputBytes?: number;
403
+ /** Directory for per-session namespace snapshots (`state.dill` + `manifest.json`); none when absent. */
404
+ snapshotDir?: string;
405
+ /** Serialized-size cap for a turn-end snapshot, in bytes; over-cap snapshots are skipped with a one-time model warning. */
406
+ snapshotSizeCapBytes?: number;
407
+ /** Managed venv directory (used when `python` is absent/`python3`); defaults to `<package>/.venv-kernel`. */
408
+ kernelEnvDir?: string;
409
+ /** Preferred CPython version for a managed venv. */
410
+ kernelPythonVersion?: string;
411
+ /** Provision the managed venv (ipykernel + dill) on first use; default true. */
412
+ kernelAutoInstall?: boolean;
413
+ username?: string;
414
+ }
415
+ /**
416
+ * The {@link ReplRuntime} backend this package registers (`ctx.replRuntime`)
417
+ * — the standing-mount layer of the v0.1.5 architecture, the de facto daemon
418
+ * while the profile-level DashrDaemon stays an empty shell. One service
419
+ * instance per mount holds one lazily-spawned kernel per session principal;
420
+ * each kernel's lifecycle — snapshot and shutdown on session end, snapshot
421
+ * and shutdown of every key on plugin disposal — is effect-owned.
422
+ */
423
+ declare class DashrRuntime extends ReplRuntime {
424
+ static Config: z<Config$1>;
425
+ readonly language = "python";
426
+ readonly isolation = "process";
427
+ private readonly config;
428
+ private readonly logger;
429
+ /** One entry per session principal that has run code (lazy — never pre-seeded). */
430
+ private readonly kernels;
431
+ private disposed;
432
+ /** Lazily-resolved (and, when managed, provisioned) kernel interpreter. */
433
+ private kernelEnvPromise;
434
+ constructor(ctx: Context, config: Config$1);
435
+ /**
436
+ * The agentless-default kernel's pid, for lifecycle diagnostics; absent
437
+ * before the first agentless run. Per-session pids: {@link kernelPids}.
438
+ */
439
+ get kernelPid(): number | undefined;
440
+ /** Every live kernel subprocess pid, one per session that has run code. */
441
+ get kernelPids(): number[];
442
+ /**
443
+ * Execute one program as one cell on the persistent kernel. Program
444
+ * outcomes — including kernel startup failure — resolve with
445
+ * `result.error`; the method rejects only for Service Definition contract
446
+ * misuse (a disposed runtime, an invalid binding namespace).
447
+ * @param request - the program, its bindings, and the abort signal.
448
+ * @returns the run's outcome per the seam contract.
449
+ */
450
+ run(request: CodeRunRequest): Promise<CodeRunResult>;
451
+ /**
452
+ * Read one user-namespace variable by name on the session's kernel. A
453
+ * bare/empty name lists the namespace's user-variable names; a
454
+ * JSON-serializable value resolves to its JSON text, any other value to its
455
+ * `repr` text, and a missing name to `{ kind: 'missing' }`. When no live
456
+ * kernel holds state for the key the namespace is empty (no spawn — this
457
+ * channel never creates a kernel). Pure additive: the run/execute/snapshot
458
+ * lifecycle is untouched.
459
+ * @param name - the variable name, or empty to list namespace names.
460
+ * @param principal - the session key (absent → the shared default).
461
+ */
462
+ queryVar(name: string, principal?: string): Promise<ReplVarQuery>;
463
+ /**
464
+ * Assign one lossless-JSON value into the user namespace under `name` on
465
+ * the session's kernel. `name` must be a usable identifier (and not a
466
+ * kernel-shim name); `value` must be lossless JSON. Requires a live kernel
467
+ * for the key — the channel never spawns one, so a session that has not yet
468
+ * run a cell must `run` first. Pure additive to the existing lifecycle.
469
+ * @param name - the identifier to assign under.
470
+ * @param value - the lossless-JSON value to bind.
471
+ * @param principal - the session key (absent → the shared default).
472
+ */
473
+ setVar(name: string, value: unknown, principal?: string): Promise<void>;
474
+ /** Map one cell outcome onto the seam's result shape under the output ledger. */
475
+ private assembleResult;
476
+ /** Reject malformed binding globals or typed-error declarations as contract misuse. */
477
+ private validateBindings;
478
+ /** Dispatch one kernel-side host request; unknown types and bad payloads become error replies. */
479
+ private dispatchHostRequest;
480
+ /** Resolve (and provision, when managed) the kernel interpreter once per runtime. */
481
+ private resolveKernelPython;
482
+ /**
483
+ * Spawn-or-reuse the kernel for one key. The lazy map guarantees one
484
+ * entry is created here and nowhere else, so a key that never runs never
485
+ * holds a subprocess — the subagent fan-out guarantee (blueprint §6:
486
+ * subagent ×N spawns nothing until a child actually executes code).
487
+ * @param key - the run principal (or the agentless default).
488
+ */
489
+ private ensureKernel;
490
+ /**
491
+ * Restore a key's on-disk snapshot into a freshly booted kernel, when one
492
+ * exists and its manifest is plausible. Called once per entry boot. The
493
+ * kernel-side restore cell performs the authoritative environment checks
494
+ * (python version, interpreter identity, skills); this method only gates on
495
+ * the manifest the host can read cheaply, then records the turn so the
496
+ * first-run notice and the revive chain can name it.
497
+ */
498
+ private restoreEntry;
499
+ /** Read the per-key manifest's host-relevant fields; absent when unreadable/missing. */
500
+ private readSnapshotManifest;
501
+ /**
502
+ * Revive one session's kernel after death: respawn a fresh kernel, restore
503
+ * the nearest replayable snapshot onto it (the normal restore path), and
504
+ * return the death-observing run's explicit error naming the turn. When no
505
+ * replayable snapshot exists the message falls back to M3-A's fresh-empty
506
+ * contract. The run itself does NOT execute — an error that lies about a
507
+ * NameError costs the model more than one dropped cell (blueprint §8.3).
508
+ * @param key - the run principal.
509
+ * @param dead - the entry that died (its `turn` is the last completed turn).
510
+ */
511
+ private reviveAfterDeath;
512
+ /**
513
+ * Write one key's turn-end snapshot, when a snapshot directory is
514
+ * configured. A size-cap skip is reported (so the run can warn the model
515
+ * once); other failures log without disturbing the run.
516
+ */
517
+ private snapshotTurnEnd;
518
+ /**
519
+ * Dispose to quiescence: snapshot every live key's namespace when a
520
+ * snapshot directory is configured (each under its own per-key
521
+ * subdirectory), then shut the subprocesses down. Registered as the
522
+ * plugin's `ctx.effect` disposer.
523
+ */
524
+ private teardown;
525
+ /**
526
+ * Tear one session's kernel down (session end via the `agent/disposed`
527
+ * listener). A no-op for keys that never ran code through this instance —
528
+ * which is what makes hearing every agent's disposal safe.
529
+ */
530
+ private destroyKey;
531
+ /**
532
+ * Reset one session's kernel to a fresh, empty namespace: dispose the live
533
+ * subprocess WITHOUT a turn-end snapshot and clear its on-disk snapshot, so
534
+ * the next ensureKernel spawns empty (restore finds nothing to replay).
535
+ */
536
+ private resetKey;
537
+ /** Snapshot (when configured) then dispose one key's kernel; failures log, never throw into a listener. */
538
+ private teardownKernel;
539
+ }
540
+ //#endregion
541
+ //#region src/tool-call-id.d.ts
542
+ /** The host's tool-call id brand, as carried by `ToolExecutionInput.callId`. */
543
+ type ToolCallId = ToolExecutionInput['callId'];
544
+ //#endregion
545
+ //#region src/web-trust.d.ts
546
+ /** Page-authority + mobile config slice of the plugin config. */
547
+ interface WebTrustConfig {
548
+ /** Hostnames this operator declares their own devices' pages run on. */
549
+ trustedPageAuthorities?: readonly string[];
550
+ /** Mobile responsiveness knobs (client half consumes via page global). */
551
+ mobile?: {
552
+ enabled?: boolean;
553
+ breakpoint?: number;
554
+ swipeDistancePx?: number;
555
+ dominanceRatio?: number;
556
+ leftEdgeBandPx?: number;
557
+ rightZoneRatio?: number;
558
+ swipeVelocityPxPerMs?: number;
559
+ };
560
+ }
561
+ //#endregion
562
+ //#region src/index.d.ts
563
+ /** Cordis plugin name. */
564
+ declare const name = "dashr-repl";
565
+ /**
566
+ * Required services. `replRuntime` is NOT listed: see the module doc — the
567
+ * mode-dependent wait is declared inside {@link apply} instead, and the
568
+ * execution path re-reads the service at use time with an actionable error.
569
+ */
570
+ declare const inject: string[];
571
+ /** Plugin config. */
572
+ interface Config extends Config$1 {
573
+ maxParallelSubCalls?: number;
574
+ /** Page hostnames this operator declares their own (web-trust boot script). */
575
+ trustedPageAuthorities?: string[];
576
+ /** Mobile responsiveness knobs (delivered to the client half as a page global). */
577
+ mobile?: WebTrustConfig['mobile'];
578
+ }
579
+ /** Runtime schema. */
580
+ declare const Config: z<Config>;
581
+ /** The model-facing name of the DASHR cell transport. */
582
+ declare const EVAL_NAME = "eval";
583
+ /**
584
+ * The wire-mask deny list (design D1): the upstream delegation and
585
+ * guidance tools DASHR displaces from the model's surface. The list feeds
586
+ * ONE registry-level mechanism — `tools.restrict({deny})` on the agent's
587
+ * own scope layer at session-start — which removes every name from ALL
588
+ * registry projections at once (wire schemas, catalog, SDK, REPL bindings,
589
+ * by-name dispatch): the restricted-away names are gone for the model on
590
+ * every surface, not hidden per-presentation. Two exemptions are registry
591
+ * facts, not list policy: a name the host never registered is skipped (a
592
+ * restriction may only name inherited tools), and a name registered on the
593
+ * agent's OWN layer (the child-scoped native `report`, this composition's
594
+ * bridges below, never through the masked name. `subagent` is deliberately
595
+ * NOT in this list (v0.2.1b): its standard-preset registration
596
+ * (`modelSelectionSettings: true`) lands on the agent's OWN layer, outside
597
+ * registry restriction reach, so it stays visible on every surface and the
598
+ * control prompt annotates it as an alias of the `agent` delegation tool.
599
+ * own URL wrappers) is exempt from restrictions by construction — the
600
+ * capability it carries stays reachable through the captured-definition
601
+ * bridges below, never through the masked name.
602
+ */
603
+ declare const MASKED_TOOL_NAMES: ReadonlySet<string>;
604
+ /**
605
+ * The effective deny list the session-start wiring restricts. An alias of
606
+ * {@link MASKED_TOOL_NAMES} today; a config override (a deployment naming
607
+ * its own mask) slots in HERE and nowhere else — the constant is the single
608
+ * source, so the mask never drifts between capture, restrict, and the
609
+ * bridges that read captured definitions.
610
+ */
611
+ declare const WIRE_MASKED_NAMES: ReadonlySet<string>;
612
+ /** The `dashr:control-prompt` section order: the FIRST section in the 100–199 tool-guidance band, so the cell paradigm is taught before the Tool Catalog renders its signatures. */
613
+ declare const CONTROL_SECTION_ORDER = 100;
614
+ /** The `dashr:tool-catalog` section order: the 100–199 tool-guidance band's SDK position, matching upstream `tools:sdk`. */
615
+ declare const SDK_SECTION_ORDER = 150;
616
+ /**
617
+ * The `dashr:escalation-guidance` CONTEXT order: sits inside the runtime-context snapshot
618
+ * band between upstream `approval:policy` (115) and `subagent:delegation` (120) — the
619
+ * sandbox policy statement is order 110, the approval policy 115. Re-check if upstream
620
+ * adds context entries in this band (dsh-system-prompt CONTEXT_ORDERS).
621
+ */
622
+ declare const ESCALATION_GUIDANCE_ORDER = 116;
623
+ /**
624
+ * Thrown by `eval` when the cell itself failed — a program exception, a
625
+ * budget expiry, an abort, or kernel death. Extends {@link HarnessError} with
626
+ * the same `code: 'CODE_RUN_FAILED'` as upstream `CodeRunFailedError`, so
627
+ * registry-side error taxonomy and session-log consumers see the shape they
628
+ * already know; the registry's execution pipeline converts it into a
629
+ * structured `isError` result whose text carries the failure kind plus the
630
+ * captured logs, so the model can self-correct.
631
+ */
632
+ declare class DASHRRunFailedError extends HarnessError {
633
+ constructor(message: string);
634
+ }
635
+ /** Resolve the eval overlap cap at the config boundary (schemastery already validated the range; direct construction in tests bypasses it). */
636
+ declare function resolveMaxParallelSubCalls(value: number | undefined): number;
637
+ /**
638
+ * One settled `eval` sub-dispatch about to be logged, as seen by the
639
+ * `dashr/repl-dispatch-log` waterfall — dashr's OWN dispatch-log event,
640
+ * self-registered via the cordis Events merge below. Decoupled from
641
+ * upstream's `tools/ptc-dispatch-log` (PTC `run_code` sub-dispatches): `eval`
642
+ * is a broader session-persistent REPL (IPython kernel) than upstream's
643
+ * `run_code` TS-worker tool, so its durable-log reshape extension point is
644
+ * dashr-owned and version-independent — no coupling to upstream's
645
+ * `CodeDispatchLog`/`PtcDispatchLog` rename or the PTC tool's event name.
646
+ */
647
+ interface ReplDispatchLog {
648
+ /** The outer `eval` execution. */
649
+ readonly exec: ToolRunContext;
650
+ /** The calling agent (scope routing key + spill owner), when present. */
651
+ readonly agent?: Agent;
652
+ /** Deterministic sub-call id (`<parent>:code:<n>`). */
653
+ readonly subCallId: ToolCallId;
654
+ /** The dispatched sub-tool name. */
655
+ readonly name: string;
656
+ /** Whether the sub-call settled as an error. */
657
+ readonly isError: boolean;
658
+ /** The sub-call's complete model-facing content (the settle event's default payload). */
659
+ readonly content: ContentBlock[];
660
+ }
661
+ declare module '@deepseek-ai/cordis' {
662
+ interface Events {
663
+ /**
664
+ * Allow a listener to replace content in the DURABLE LOG COPY of one
665
+ * `eval` sub-dispatch outcome before the bridge appends its
666
+ * `tool/code-dispatch` event. `next()` keeps the content unchanged; a
667
+ * listener may return replacement blocks (e.g. the spill policy's preview
668
+ * + locator for an oversized text result). Scope-filtered dispatch
669
+ * (`@deepseek-ai/dsh-scope`): agent-scoped listeners receive only that
670
+ * agent's dispatches.
671
+ * @param dispatch - the parent execution, sub-call identity, and settled content to log.
672
+ * @mode waterfall
673
+ */
674
+ 'dashr/repl-dispatch-log'(this: Scoped<ToolRuntime>, dispatch: ReplDispatchLog, next: () => Promise<ContentBlock[]>): Promise<ContentBlock[]>;
675
+ }
676
+ }
677
+ /**
678
+ * Capabilities the `eval` bridge closes over, mirroring upstream's
679
+ * `RunCodeBridgeOptions` (the `requireRuntime` idiom): the registry-private
680
+ * staged scheduler travels through the exported `TOOL_RUNTIME_SCHEDULER`
681
+ * symbol-keyed property rather than a closure, because — unlike upstream —
682
+ * the registry does not mint this tool for us.
683
+ */
684
+ interface RunCellBridgeOptions {
685
+ /** Resolves `ctx.replRuntime` or throws the loud misconfiguration error (use-time read). */
686
+ requireRuntime: () => ReplRuntimeSurface;
687
+ /** The run's overlap cap for parallel-classified sub-calls (validated config). */
688
+ maxParallel: number;
689
+ /**
690
+ * Runs the `dashr/repl-dispatch-log` waterfall over one settled
691
+ * sub-dispatch and returns the content the bridge should log — dashr's own
692
+ * dispatch-log reshape extension point (self-registered, decoupled from
693
+ * upstream's PTC `tools/ptc-dispatch-log`). Built in {@link apply}.
694
+ */
695
+ shapeDispatchLog: (dispatch: ReplDispatchLog) => Promise<ContentBlock[]>;
696
+ /**
697
+ * Named logger warn from the mounting context, used for lane-failure
698
+ * warnings (v0.2.1c drive() backstop) — the lane must log-and-settle,
699
+ * never rethrow.
700
+ */
701
+ warn: (message: string) => void;
702
+ }
703
+ /**
704
+ * Build the `eval` {@link ToolDefinition}: required `cell` and
705
+ * `description` parameters, executed through the dispatch bridge described
706
+ * in the module doc. Sub-calls ride the registry's exported staged scheduler
707
+ * (`prepare`/`dispatch`/`finalize`/`finish`) under the native concurrency
708
+ * contract; each sub-dispatch is logged for reconstruction
709
+ * (`tool/code-dispatch-start` / `tool/code-dispatch`) while only the outer
710
+ * curated result enters model history.
711
+ * @param registry - the host tool registry (sub-calls go through its staged
712
+ * scheduler, bindings cover its registered tools).
713
+ * @param options - the bridge capabilities described above.
714
+ * @returns the registry-ready definition.
715
+ */
716
+ declare function createRunCellTool(registry: ToolRuntime, options: RunCellBridgeOptions): ToolDefinition;
717
+ /**
718
+ * Collect one calling scope's bridge-declaration schemas through the
719
+ * registry's public projection APIs: `schemas(scope)` for the model-facing
720
+ * view (scoped tools join, restrictions apply — the wire mask is a
721
+ * registry-level restriction installed at session-start, so every masked
722
+ * name is ALREADY absent from this projection; no second name filter
723
+ * exists to drift), `get(name, scope)` for the canonical output schema,
724
+ * snapshotted so a live definition cannot mutate under the render. `eval`
725
+ * itself is excluded — it is the transport, not a binding.
726
+ */
727
+ declare function collectSdkSchemas(registry: ToolRuntime, scope?: ScopeKey): DASHRSdkSchema[];
728
+ declare function apply(ctx: Context, config: Config): void;
729
+ declare const _default: {
730
+ name: string;
731
+ inject: string[];
732
+ Config: z<Config>;
733
+ apply: typeof apply;
734
+ };
735
+ //#endregion
736
+ export { CONTROL_SECTION_ORDER, Config, DASHRRunFailedError, DashrRuntime, ESCALATION_GUIDANCE_ORDER, EVAL_NAME, MASKED_TOOL_NAMES, ReplDispatchLog, ReplRuntime, RunCellBridgeOptions, type Config$1 as RuntimeConfig, SDK_SECTION_ORDER, WIRE_MASKED_NAMES, apply, collectSdkSchemas, createRunCellTool, _default as default, inject, name, resolveMaxParallelSubCalls };