@sema-agent/core 7.73.0 → 7.74.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.
Files changed (177) hide show
  1. package/CHANGELOG.md +246 -0
  2. package/dist/agents/list-agents-tool.js +1 -1
  3. package/dist/agents/retain-ledger.js +3 -3
  4. package/dist/agents/send-message-tool.js +4 -4
  5. package/dist/brain/anthropic.d.ts +42 -1
  6. package/dist/brain/anthropic.js +54 -4
  7. package/dist/brain/failover.d.ts +5 -0
  8. package/dist/brain/failover.js +51 -22
  9. package/dist/brain/model-lane.d.ts +12 -3
  10. package/dist/brain/model-lane.js +5 -5
  11. package/dist/brain/open-responses.js +3 -3
  12. package/dist/brain/openai.js +1 -1
  13. package/dist/brain/route-adjudicator.d.ts +33 -4
  14. package/dist/brain/route-adjudicator.js +49 -12
  15. package/dist/brain/stream-engine.js +9 -7
  16. package/dist/brain/stream-shared.d.ts +4 -3
  17. package/dist/brain/stream-shared.js +2 -2
  18. package/dist/core/allow-entry.js +1 -1
  19. package/dist/core/ask-class.d.ts +2 -2
  20. package/dist/core/ask-headline.d.ts +1 -1
  21. package/dist/core/ask-origin.d.ts +44 -4
  22. package/dist/core/ask-origin.js +29 -10
  23. package/dist/core/background-agent-store.d.ts +1 -0
  24. package/dist/core/background-agent-store.js +49 -8
  25. package/dist/core/checkpoint-row-verdict.d.ts +1 -1
  26. package/dist/core/checkpoint-row-verdict.js +2 -2
  27. package/dist/core/checkpoint-store.d.ts +2 -0
  28. package/dist/core/checkpoint-store.js +8 -2
  29. package/dist/core/config-refusal-codes.d.ts +1 -1
  30. package/dist/core/config-refusal-codes.js +1 -0
  31. package/dist/core/cron.js +9 -1
  32. package/dist/core/deployment-shape.d.ts +7 -0
  33. package/dist/core/deployment-shape.js +19 -0
  34. package/dist/core/engine-capabilities.d.ts +9 -1
  35. package/dist/core/engine-capabilities.js +1 -1
  36. package/dist/core/engine-notice.d.ts +14 -9
  37. package/dist/core/engine-version.js +1 -1
  38. package/dist/core/gate-fold.js +5 -4
  39. package/dist/core/gate-lanes.js +8 -12
  40. package/dist/core/gate-outcome.d.ts +8 -2
  41. package/dist/core/gate-outcome.js +10 -3
  42. package/dist/core/governance-codes.d.ts +8 -2
  43. package/dist/core/governance-codes.js +9 -1
  44. package/dist/core/hook-condition.d.ts +37 -0
  45. package/dist/core/hook-condition.js +567 -0
  46. package/dist/core/hooks.d.ts +2 -0
  47. package/dist/core/mode-policy.d.ts +4 -0
  48. package/dist/core/mode-policy.js +18 -2
  49. package/dist/core/model-seat.d.ts +8 -5
  50. package/dist/core/model-shell.d.ts +129 -0
  51. package/dist/core/model-shell.js +249 -0
  52. package/dist/core/mods/kernel/digest.d.ts +4 -0
  53. package/dist/core/mods/kernel/digest.js +5 -0
  54. package/dist/core/mods/kernel/dispatch.d.ts +3 -0
  55. package/dist/core/mods/kernel/dispatch.js +15 -6
  56. package/dist/core/mods/kernel/events.d.ts +21 -5
  57. package/dist/core/mods/kernel/events.js +19 -10
  58. package/dist/core/mods/kernel/hash-mirror.d.ts +1 -0
  59. package/dist/core/mods/kernel/hash-mirror.js +55 -0
  60. package/dist/core/mods/kernel/index.d.ts +1 -0
  61. package/dist/core/mods/kernel/index.js +1 -0
  62. package/dist/core/mods/kernel/package-reader.d.ts +48 -0
  63. package/dist/core/mods/kernel/package-reader.js +149 -0
  64. package/dist/core/mods/kernel/site-rules.d.ts +4 -0
  65. package/dist/core/mods/kernel/site-rules.js +13 -0
  66. package/dist/core/mods/package.d.ts +7 -3
  67. package/dist/core/mods/package.js +47 -80
  68. package/dist/core/permission-rule-org.js +13 -3
  69. package/dist/core/permission-rules.js +4 -1
  70. package/dist/core/retain-seat.d.ts +42 -0
  71. package/dist/core/retain-seat.js +76 -0
  72. package/dist/core/rewind-refusal-codes.d.ts +8 -0
  73. package/dist/core/rewind-refusal-codes.js +12 -0
  74. package/dist/core/roles.d.ts +2 -2
  75. package/dist/core/roles.js +15 -1
  76. package/dist/core/rule-store-fault.d.ts +9 -7
  77. package/dist/core/rule-store-fault.js +8 -3
  78. package/dist/core/runner/checkpoint-scope.d.ts +1 -0
  79. package/dist/core/runner/checkpoint-scope.js +4 -2
  80. package/dist/core/runner/compact-session.js +1 -1
  81. package/dist/core/runner/construction-doors.js +2 -0
  82. package/dist/core/runner/cross-boundary-lane.d.ts +8 -1
  83. package/dist/core/runner/cross-boundary-lane.js +4 -0
  84. package/dist/core/runner/gate-exit.d.ts +7 -0
  85. package/dist/core/runner/gate-exit.js +2 -1
  86. package/dist/core/runner/model-lane-seat.d.ts +3 -0
  87. package/dist/core/runner/model-lane-seat.js +4 -0
  88. package/dist/core/runner/person-path-rows.d.ts +6 -0
  89. package/dist/core/runner/person-path-rows.js +13 -0
  90. package/dist/core/runner/prepare-config-doors.js +9 -5
  91. package/dist/core/runner/prepare-gate-stations.d.ts +6 -0
  92. package/dist/core/runner/prepare-gate-stations.js +3 -1
  93. package/dist/core/runner/prepare-hands-readface.js +3 -2
  94. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  95. package/dist/core/runner/prepare-task.js +6 -3
  96. package/dist/core/runner/prepare-wiring-manifest.js +3 -4
  97. package/dist/core/runner/resume-policy-outcome.js +5 -2
  98. package/dist/core/runner/role-seat-defaulted.d.ts +3 -3
  99. package/dist/core/runner/role-seat-defaulted.js +1 -1
  100. package/dist/core/runner/rule-store-unreadable-notice.d.ts +1 -1
  101. package/dist/core/runner/rule-store-unreadable-notice.js +3 -3
  102. package/dist/core/runner/run-harness-handlers.js +1 -1
  103. package/dist/core/runner/run-leg.js +2 -2
  104. package/dist/core/runner/shell-env-withheld.d.ts +3 -2
  105. package/dist/core/runner/shell-env-withheld.js +24 -1
  106. package/dist/core/runner/sub-agent-deny-lists.js +9 -5
  107. package/dist/core/runner/tool-end-body.d.ts +1 -1
  108. package/dist/core/runner/tool-not-executed.d.ts +27 -8
  109. package/dist/core/runner/tool-not-executed.js +22 -11
  110. package/dist/core/runner/write-protection-station.d.ts +1 -1
  111. package/dist/core/runner/write-protection-station.js +1 -1
  112. package/dist/core/runner-deps.d.ts +4 -0
  113. package/dist/core/secret-env.d.ts +8 -0
  114. package/dist/core/secret-env.js +5 -2
  115. package/dist/core/shell-read-silence.d.ts +40 -2
  116. package/dist/core/shell-read-silence.js +23 -4
  117. package/dist/core/task-event.d.ts +4 -4
  118. package/dist/core/task-notification.js +6 -1
  119. package/dist/core/task-registry-agent.d.ts +1 -0
  120. package/dist/core/task-registry-agent.js +1 -1
  121. package/dist/core/task-registry.d.ts +1 -0
  122. package/dist/core/task-registry.js +4 -3
  123. package/dist/core/task-result.d.ts +5 -3
  124. package/dist/core/task-spec-members.js +8 -0
  125. package/dist/core/tool-gate-phase.d.ts +6 -3
  126. package/dist/core/tool-gate-phase.js +1 -0
  127. package/dist/core/tool-mount-facts.d.ts +7 -3
  128. package/dist/core/tool-mount-facts.js +6 -2
  129. package/dist/core/tool-mount-plan.d.ts +1 -1
  130. package/dist/core/tool-mount-plan.js +4 -3
  131. package/dist/core/tool-result-store.d.ts +37 -1
  132. package/dist/core/tool-result-store.js +168 -23
  133. package/dist/core/trace.d.ts +3 -3
  134. package/dist/engine/execution-env/node-execution-env.d.ts +75 -1
  135. package/dist/engine/execution-env/node-execution-env.js +225 -13
  136. package/dist/engine/harness/types.d.ts +25 -0
  137. package/dist/engine/llm/types.d.ts +8 -0
  138. package/dist/engine/llm/validation.d.ts +8 -1
  139. package/dist/engine/llm/validation.js +31 -2
  140. package/dist/host-env.d.ts +10 -0
  141. package/dist/host-env.js +1 -0
  142. package/dist/index.d.ts +10 -2
  143. package/dist/index.js +9 -2
  144. package/dist/internal/harness-types.d.ts +1 -1
  145. package/dist/orchestration/goal.js +1 -1
  146. package/dist/orchestration/workflow-primitives.js +10 -1
  147. package/dist/orchestration/workflow-script-runner.d.ts +2 -2
  148. package/dist/orchestration/workflow.d.ts +1 -1
  149. package/dist/orchestration/workflow.js +2 -2
  150. package/dist/shell/lex.d.ts +2 -2
  151. package/dist/shell/lex.js +1 -1
  152. package/dist/tools/fs/bash-model-shell.d.ts +23 -0
  153. package/dist/tools/fs/bash-model-shell.js +25 -0
  154. package/dist/tools/fs/bash-readonly-classifier.d.ts +6 -0
  155. package/dist/tools/fs/bash-readonly-classifier.js +3 -0
  156. package/dist/tools/fs/fs-bash.js +13 -11
  157. package/dist/tools/fs/shell-read-argv.js +1 -0
  158. package/dist/tools/fs/shell-read-check.js +39 -9
  159. package/dist/tools/fs/shell-read-plan.d.ts +2 -3
  160. package/dist/tools/fs/shell-read-plan.js +8 -5
  161. package/dist/tools/fs/shell-read-word.d.ts +8 -0
  162. package/dist/tools/fs/shell-read-word.js +13 -4
  163. package/dist/tools/monitor.js +12 -8
  164. package/dist/tools/scheduler-tools.d.ts +1 -0
  165. package/dist/tools/scheduler-tools.js +5 -2
  166. package/package.json +3 -2
  167. package/test/export-surface.snapshot.json +62 -3
  168. package/wire-changes/answers/core-stores-sql@7.74.0.json +7 -0
  169. package/wire-changes/answers/core@7.74.0.json +68 -0
  170. package/wire-changes/answers/mods-kernel@7.74.0.json +21 -0
  171. package/wire-changes/answers/primitives@7.74.0.json +7 -0
  172. package/wire-changes/answers/wiki-gate@7.74.0.json +8 -0
  173. package/wire-changes/core-stores-sql@7.74.0.json +143 -0
  174. package/wire-changes/core@7.74.0.json +2210 -0
  175. package/wire-changes/mods-kernel@7.74.0.json +421 -0
  176. package/wire-changes/primitives@7.74.0.json +174 -0
  177. package/wire-changes/wiki-gate@7.74.0.json +145 -0
@@ -9,7 +9,7 @@ import { delimitUntrusted } from "./untrusted-text.js";
9
9
  import { createSafeNotifier } from "./safe-notify.js";
10
10
  import { stripCwdSentinel } from "../tools/fs/fs-shared.js";
11
11
  import { readExtensionRequester } from "./extension-requester.js";
12
- import { persistTaskArtifact, taskArtifactOriginOf } from "./tool-result-store.js";
12
+ import { persistTaskArtifact, taskArtifactOriginOf, waitForOffloadPuts } from "./tool-result-store.js";
13
13
  import { registerMonitorLane, pollMonitorLane, stopMonitorLane } from "./task-registry-monitor.js";
14
14
  import { registerWorkflowLane, pollWorkflowLane, stopWorkflowLane, workflowParkWaitsOf } from "./task-registry-workflow.js";
15
15
  import { taskReadHandleText, canAccessWorkflowRun, formatWorkflowRun, clipTaskOutput, assertOwnership, sleepPollStep, statusFromBackground, rollSpoolText, accountDroppedBytes, dropFactsOf, renderSpoolBody, stdoutHeadingOf, REPLAY_FACE, SPOOL_REPLAY, INCREMENT_REPLAY, spoolDropNote, droppedGapNote, alreadyTerminalStopNote, terminalTaskSummary, TASK_OUTPUT_MAX_CHARS, MONITOR_BATCH_WINDOW_MS, MONITOR_DEFAULT_TIMEOUT_MS, MONITOR_MAX_TIMEOUT_MS, MONITOR_MAX_BATCHES_PER_MINUTE, canAccess, isLiveSessionResidentAgent, DURABLE_AGENT_HANDLE_RE, SEMA_TASK_HANDLE_PREFIXES, activityStamp, stampActivity, occupantStamp, callOccupant, } from "./task-registry-shared.js";
@@ -113,8 +113,9 @@ function commandRecordSink(rowOf, record, guarded, sink) {
113
113
  if (row.taskArtifacts === undefined || retained === undefined)
114
114
  return sink(gap === "incomplete" ? { ...n, summary: n.summary + commandRecordGapNote(row, gap, undefined) } : n);
115
115
  const body = renderSpoolBody(retained, { running: false, handleStatus: row.status, shape: (text) => text, drainNote: "" });
116
- void persistTaskArtifact(row.taskArtifacts, row.id, body).then((artifact) => {
117
- const ref = artifact.kind === "stored" ? artifact.ref : undefined;
116
+ void waitForOffloadPuts([persistTaskArtifact(row.taskArtifacts, row.id, body)]).then((waited) => {
117
+ const first = waited.outcomes[0];
118
+ const ref = first.status === "settled" && first.value.kind === "stored" ? first.value.ref : undefined;
118
119
  if (ref !== undefined)
119
120
  record(row.id, ref, n.completionId);
120
121
  guarded(() => sink(ref === undefined && gap === "missing" ? n : { ...n, summary: n.summary + commandRecordGapNote(row, gap, ref) }));
@@ -309,9 +309,11 @@ export interface TaskResult {
309
309
  /** The PROVIDER'S OWN name for the model that answered this run's FINAL turn, when it DIFFERS from the
310
310
  * id the request was sent with — the result-face twin of `turn_end.responseModel`. {@link model} above
311
311
  * stays the ENGINE-SELECTED id a resume re-seeds and a catalog resolves; a UI echoing "served by X"
312
- * prints this one when it is here and {@link model} when it is not. **In-presence condition**: the final
313
- * assistant message carried one. ABSENT ⇒ the provider named the requested id or named nothing (one
314
- * reading, not two), there was no final assistant message, or the final turn AGREED while an earlier one
312
+ * prints this one when it is here, and when it is not says no name was reported — absence is not agreement.
313
+ * **In-presence condition**: the final assistant message carried one. ABSENT ⇒ the provider named the
314
+ * requested id or named nothing (one reading, not two), it named one the engine dropped (outside the echo
315
+ * shape, or holding a value the request was declared with; counted as the trace frame `brain.echo_dropped`,
316
+ * field `responseModel`), there was no final assistant message, or the final turn AGREED while an earlier one
315
317
  * did not — the per-turn frames are the complete record, this is the terminal one. Never present on the
316
318
  * engine's synthetic messages, which carry no provider report; a mismatch is announced either way as
317
319
  * `route.response_model_mismatch`. */
@@ -1,6 +1,7 @@
1
1
  import { RETIRED_TASK_SPEC_KEYS, retiredKeyOf, retiredKeyRefusal } from "./retired-keys.js";
2
2
  import { codedRefusal, thrownText } from "./thrown-value.js";
3
3
  import { screenProjectSeat } from "./project-seat.js";
4
+ import { retainSeatError, screenRetainSeat } from "./retain-seat.js";
4
5
  import { callerKey } from "./caller-text.js";
5
6
  import { strayMembersOf } from "./own-property-receipt.js";
6
7
  const SESSION = "session";
@@ -118,6 +119,13 @@ export function readCallerSpec(spec, takeSeat) {
118
119
  else
119
120
  refusal = codedRefusal(screened.code, screened.message);
120
121
  }
122
+ if (refusal === undefined && "retainSubagentSessions" in values) {
123
+ const screened = screenRetainSeat(values["retainSubagentSessions"]);
124
+ if (!screened.ok)
125
+ refusal = retainSeatError(screened);
126
+ else if (screened.seat !== undefined)
127
+ values["retainSubagentSessions"] = screened.seat;
128
+ }
121
129
  const members = {};
122
130
  for (const name of TASK_SPEC_MEMBERS)
123
131
  if (name in values)
@@ -1,3 +1,4 @@
1
+ import type { AssertAllKeysHandled } from "./ask-origin.js";
1
2
  /**
2
3
  * WHO holds a tool call at its gate — the closed set behind `tool_progress.gate`, exported at the package root as a frozen word list; the type
3
4
  * is read off the list, so the two cannot part. `classifier` = an auto-mode classification of the call is in flight; `approval` = a question
@@ -10,7 +11,9 @@ export type ToolGatePhase = (typeof TOOL_GATE_PHASES)[number];
10
11
  /**
11
12
  * WHOSE model call a liveness frame is about, when it is not the run's own turn — the closed set behind `BrainStatus.seat`. `classifier` = a
12
13
  * call made for the auto-mode classifier lane (the classifier seat's model, or the main model standing in behind it): a side call beside the
13
- * person's turn, never the turn itself. The word IS the gate phase `classifier` (one definition, read in two places): the type is the
14
- * phase set's member, so the two cannot be spelled apart.
14
+ * person's turn, never the turn itself. The list is spelled for the release manifest and held to the gate-phase set by the fence below: a seat
15
+ * word that is not a gate phase reds `tsc`.
15
16
  */
16
- export type BrainStatusSeat = Extract<ToolGatePhase, "classifier">;
17
+ export declare const BRAIN_STATUS_SEATS: readonly ["classifier"];
18
+ export type BrainStatusSeat = (typeof BRAIN_STATUS_SEATS)[number];
19
+ export type BrainStatusSeatsArePhases = AssertAllKeysHandled<Exclude<BrainStatusSeat, ToolGatePhase>>;
@@ -1 +1,2 @@
1
1
  export const TOOL_GATE_PHASES = Object.freeze(["classifier", "approval", "hook"]);
2
+ export const BRAIN_STATUS_SEATS = Object.freeze(["classifier"]);
@@ -58,6 +58,10 @@ export declare function legSeatMountFacts(deps: Pick<RunnerDeps, "onQuestion" |
58
58
  * a background lane, both read from its `execute` where the factory bound them ({@link delegationHasBackgroundLane}): a copy whose face
59
59
  * dropped `run_in_background` still launches in the background by default, and a synchronous one whose face gained it does not. */
60
60
  export declare function backgroundAgentsFact(callerTools: readonly unknown[], leaves: (identity: ToolMountIdentity) => boolean): boolean;
61
- /** The execution environment's reach: hands at all, a target its shell faces reach, the two daemon capabilities. A leg hands in the
62
- * scheduler reading it took ({@link readSchedulerDeclaration}), so the declaration is read once per leg; a static reader takes its own. */
63
- export declare function envMountFacts(handsEnabled: boolean, env: ExecutionEnv, scheduler?: SchedulerReading): ToolMountFacts;
61
+ /** The execution environment's reach: hands at all, a target its shell faces reach, its start for model text, the two daemon
62
+ * capabilities (a background shell counts only beside a start with a background face — its commands are the model's text). A leg
63
+ * hands in the scheduler reading and the start's reading it took ({@link readSchedulerDeclaration}, `readModelShell`: `mounted` or
64
+ * not), so each declaration is read once per leg; a static reader takes its own — for the start, the same declaration before
65
+ * anything is asked (`modelShellFactBeforeAsking`): a start whose `ready` the leg still asks is not stated, so the rows that read it
66
+ * stay conditional on it. */
67
+ export declare function envMountFacts(handsEnabled: boolean, env: ExecutionEnv, scheduler?: SchedulerReading, modelShellMounted?: boolean): ToolMountFacts;
@@ -1,5 +1,6 @@
1
1
  import { workflowsCapability } from "../orchestration/workflow-script-runner.js";
2
2
  import { hasBackgroundShell } from "./background-shell.js";
3
+ import { modelShellFactBeforeAsking, modelShellOf, startsInBackground } from "./model-shell.js";
3
4
  import { performsIo } from "./remote-env.js";
4
5
  import { readSchedulerDeclaration } from "./scheduler.js";
5
6
  import { durableParkOptInDeclared } from "./tool-policy.js";
@@ -51,11 +52,14 @@ export function legSeatMountFacts(deps, spec, leg) {
51
52
  export function backgroundAgentsFact(callerTools, leaves) {
52
53
  return callerTools.some((t) => delegationHasBackgroundLane(t) && leaves(t));
53
54
  }
54
- export function envMountFacts(handsEnabled, env, scheduler = readSchedulerDeclaration(env)) {
55
+ export function envMountFacts(handsEnabled, env, scheduler = readSchedulerDeclaration(env), modelShellMounted) {
56
+ const start = modelShellOf(env);
57
+ const modelShell = modelShellMounted ?? modelShellFactBeforeAsking(env);
55
58
  return {
56
59
  "env.hands": handsEnabled,
57
60
  "env.performsIo": performsIo(env) === true,
58
- "env.backgroundShell": hasBackgroundShell(env),
61
+ ...(modelShell !== undefined ? { "env.modelShell": modelShell } : {}),
62
+ "env.backgroundShell": hasBackgroundShell(env) && startsInBackground(start),
59
63
  "env.scheduler": scheduler.kind === "mounted",
60
64
  };
61
65
  }
@@ -1,6 +1,6 @@
1
1
  import type { ToolCallPathTarget, ToolCatalogEntry, ToolMountTag } from "./tool-face.js";
2
2
  /** The closed set of facts a mount row may read. */
3
- export declare const TOOL_MOUNT_FACTS: readonly ["runner.self", "leg.parentNotify", "leg.peerLane", "leg.taskNotification", "leg.session", "leg.backgroundAgents", "env.hands", "env.performsIo", "env.backgroundShell", "env.scheduler", "spec.enableBlockedReport", "spec.planMode", "spec.interactiveTools.on", "spec.interactiveTools.off", "spec.planFile", "spec.selfOrchestration", "spec.outputSchema", "spec.handsReadOnly", "spec.runLedger", "spec.mcp", "spec.advisorModel", "spec.selector", "seat.checkpoint", "seat.workflows", "seat.offload", "seat.offloadBytes", "seat.lsp", "seat.artifact", "seat.question", "seat.sharedMemory", "seat.memoryEngine", "caps.allowWorkflows", "model.gate", "listing.skills", "listing.mcp", "listing.mcp.resources", "listing.a2a", "artifact.verdict", "advisor.route", "lsp.readFace", "names.declared", "names.occupied.sharedMemory", "names.occupied.memoryEngine", "names.deferred", "names.retracted"];
3
+ export declare const TOOL_MOUNT_FACTS: readonly ["runner.self", "leg.parentNotify", "leg.peerLane", "leg.taskNotification", "leg.session", "leg.backgroundAgents", "env.hands", "env.performsIo", "env.modelShell", "env.backgroundShell", "env.scheduler", "spec.enableBlockedReport", "spec.planMode", "spec.interactiveTools.on", "spec.interactiveTools.off", "spec.planFile", "spec.selfOrchestration", "spec.outputSchema", "spec.handsReadOnly", "spec.runLedger", "spec.mcp", "spec.advisorModel", "spec.selector", "seat.checkpoint", "seat.workflows", "seat.offload", "seat.offloadBytes", "seat.lsp", "seat.artifact", "seat.question", "seat.sharedMemory", "seat.memoryEngine", "caps.allowWorkflows", "model.gate", "listing.skills", "listing.mcp", "listing.mcp.resources", "listing.a2a", "artifact.verdict", "advisor.route", "lsp.readFace", "names.declared", "names.occupied.sharedMemory", "names.occupied.memoryEngine", "names.deferred", "names.retracted"];
4
4
  export type ToolMountFact = (typeof TOOL_MOUNT_FACTS)[number];
5
5
  /** The name identity a mount judgment reads: a name and the spellings that dispatch to it. */
6
6
  export interface ToolMountIdentity {
@@ -9,6 +9,7 @@ export const TOOL_MOUNT_FACTS = Object.freeze([
9
9
  "leg.backgroundAgents",
10
10
  "env.hands",
11
11
  "env.performsIo",
12
+ "env.modelShell",
12
13
  "env.backgroundShell",
13
14
  "env.scheduler",
14
15
  "spec.enableBlockedReport",
@@ -62,7 +63,7 @@ const HANDS = F("env.hands");
62
63
  const WRITES = ALL(HANDS, NOT(F("spec.handsReadOnly")));
63
64
  const SHELL = ALL(HANDS, F("env.performsIo"));
64
65
  const FULL_SHELL = ALL(SHELL, NOT(F("spec.handsReadOnly")));
65
- const BACKGROUND = ALL(FULL_SHELL, F("env.backgroundShell"));
66
+ const BACKGROUND = ALL(FULL_SHELL, F("env.modelShell"), F("env.backgroundShell"));
66
67
  const DELEGATION = ANY(BACKGROUND, ROW("workflow"), F("leg.backgroundAgents"));
67
68
  const PLAN_PAIR = ALL(F("spec.planMode"), NOT(F("spec.interactiveTools.off")), ANY(F("spec.interactiveTools.on"), F("seat.checkpoint")));
68
69
  const ENTRY_BY_ID = new Map(TOOL_CATALOG_ENTRIES.map((e) => [e.id, e]));
@@ -94,8 +95,8 @@ export const TOOL_MOUNT_RULES = Object.freeze([
94
95
  { id: "grep", segment: "hands", tag: "hands", when: HANDS, envHand: true },
95
96
  { id: "glob", segment: "hands", tag: "hands", when: HANDS, envHand: true },
96
97
  { id: "repo-map", segment: "hands", tag: "hands", when: HANDS, envHand: true },
97
- { id: "bash", segment: "hands", tag: "hands", when: FULL_SHELL, envHand: true },
98
- { id: "bash-readonly", segment: "hands", tag: "hands", when: ALL(SHELL, F("spec.handsReadOnly")), envHand: true },
98
+ { id: "bash", segment: "hands", tag: "hands", when: ALL(FULL_SHELL, F("env.modelShell")), envHand: true },
99
+ { id: "bash-readonly", segment: "hands", tag: "hands", when: ALL(SHELL, F("spec.handsReadOnly"), F("env.modelShell")), envHand: true },
99
100
  { id: "task-stop", segment: "delegation", tag: "delegation", when: DELEGATION },
100
101
  { id: "send-message", segment: "delegation", tag: "delegation", when: ALL(ANY(DELEGATION, F("leg.parentNotify"), F("leg.peerLane")), F("runner.self"), NOT(DECLARED("SendMessage"))) },
101
102
  { id: "agent-transcript", segment: "delegation", tag: "delegation", when: ALL(DELEGATION, F("runner.self"), NOT(DECLARED("SendMessage")), NOT(DECLARED("AgentTranscript"))) },
@@ -818,6 +818,39 @@ export declare function offloadRefOf(sessionId: string, toolCallId: string, full
818
818
  * batch of clears that long on a store that is not answering, where the release before waited for none.
819
819
  */
820
820
  export declare const OFFLOAD_PUT_WAIT_BOUND_MS = 10000;
821
+ /** Per-put outcome reported by {@link waitForOffloadPuts}: settled with its value, rejected with its reason, or still pending when the bound or abort ended the wait. */
822
+ export type OffloadPutWaitOutcome<T> = {
823
+ readonly status: "settled";
824
+ readonly value: T;
825
+ } | {
826
+ readonly status: "rejected";
827
+ readonly reason: unknown;
828
+ } | {
829
+ readonly status: "pending";
830
+ };
831
+ /** Aggregate result of {@link waitForOffloadPuts}: per-put outcomes fixed at the moment the wait ended, plus whether the bound or an abort ended it. */
832
+ export interface OffloadPutWaitResult<T> {
833
+ readonly outcomes: readonly OffloadPutWaitOutcome<T>[];
834
+ readonly timedOut: boolean;
835
+ readonly aborted: boolean;
836
+ }
837
+ /** Shared deadline handle so one tool call's `details` and content waits draw from one {@link OFFLOAD_PUT_WAIT_BOUND_MS} timer from the first wait. */
838
+ interface OffloadWaitWindow {
839
+ readonly expired: boolean;
840
+ start(): void;
841
+ onExpire(fn: () => void): () => void;
842
+ dispose(): void;
843
+ }
844
+ /**
845
+ * Wait for one or more engine-awaited tool-result store writes at most {@link OFFLOAD_PUT_WAIT_BOUND_MS}, ending at once on
846
+ * `signal` abort when given. Every promise gets a settlement handler at entry so a write abandoned at the bound or on abort
847
+ * keeps running in the background without ever raising `unhandledRejection` (late rejections are reported nowhere, and late
848
+ * settlements never mutate the returned outcomes). Internal — not exported from the package root.
849
+ */
850
+ export declare function waitForOffloadPuts<T>(puts: readonly Promise<T>[], opts?: {
851
+ readonly signal?: AbortSignal;
852
+ readonly window?: OffloadWaitWindow;
853
+ }): Promise<OffloadPutWaitResult<T>>;
821
854
  /** The run's offload persist: called, it starts the put under this session's ref and returns the ref at once; `flush` settles
822
855
  * when every put started so far has settled (a rejected put settles too — it is reported, never rethrown), when `signal`
823
856
  * aborts (a cut ends the wait, not the put), or at {@link OFFLOAD_PUT_WAIT_BOUND_MS}: the puts still owed then are told once
@@ -975,7 +1008,9 @@ export declare function withToolResultOffload(tool: AgentTool, store: ToolResult
975
1008
  * so a mid-run ToolSearch activation is reflected by the next preview). Absent/`undefined`-returning
976
1009
  * ⇒ byte-identical historic preview. An accessor (not a snapshot) because the wrap happens at
977
1010
  * prepare time, before the deferred classification exists and before any activation can. */
978
- reachableTools?: () => ReadonlySet<string> | undefined): AgentTool;
1011
+ reachableTools?: () => ReadonlySet<string> | undefined,
1012
+ /** Structured notice seat for reporting tool-call offload writes still unsettled at {@link OFFLOAD_PUT_WAIT_BOUND_MS}. */
1013
+ onNotice?: (notice: EngineNotice) => void): AgentTool;
979
1014
  /** The injected `read_tool_result` tool: pages through an offloaded result. `effect:"read"` (verifier/reconcile-safe).
980
1015
  * `legsOfRef` = the legs a page-back of one ref travels: a ref holding a background task's result (`persistTaskArtifact`, its
981
1016
  * origin in the ref — {@link taskArtifactOriginOf}) travels the legs a poll of that task travels — content from another tree is
@@ -985,3 +1020,4 @@ reachableTools?: () => ReadonlySet<string> | undefined): AgentTool;
985
1020
  * reach of SaveToolResult); a ref holding neither is the honest miss. `store` is the run's {@link LegToolResultView}: a ref this
986
1021
  * run may not read reads as absent, so it takes the miss sentence too. */
987
1022
  export declare function createReadToolResultTool(store: LegToolResultView, legsOfRef?: (ref: string, tree: import("./cross-boundary-taint.js").CrossBoundaryTreeToken) => import("./cross-boundary-taint.js").BoundaryLegsGiven, bytesSeat?: ToolResultBytesSeat): AgentTool;
1023
+ export {};
@@ -460,6 +460,106 @@ export function offloadRefOf(sessionId, toolCallId, fullText) {
460
460
  return buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(fullText));
461
461
  }
462
462
  export const OFFLOAD_PUT_WAIT_BOUND_MS = 10_000;
463
+ function createOffloadWaitWindow() {
464
+ let expired = false;
465
+ let started = false;
466
+ let timer;
467
+ const listeners = new Set();
468
+ return {
469
+ get expired() {
470
+ return expired;
471
+ },
472
+ start() {
473
+ if (started || expired)
474
+ return;
475
+ started = true;
476
+ timer = setTimeout(() => {
477
+ timer = undefined;
478
+ expired = true;
479
+ for (const fn of [...listeners])
480
+ fn();
481
+ listeners.clear();
482
+ }, OFFLOAD_PUT_WAIT_BOUND_MS);
483
+ },
484
+ onExpire(fn) {
485
+ if (expired) {
486
+ fn();
487
+ return () => { };
488
+ }
489
+ listeners.add(fn);
490
+ return () => {
491
+ listeners.delete(fn);
492
+ };
493
+ },
494
+ dispose() {
495
+ if (timer !== undefined) {
496
+ clearTimeout(timer);
497
+ timer = undefined;
498
+ }
499
+ listeners.clear();
500
+ },
501
+ };
502
+ }
503
+ export function waitForOffloadPuts(puts, opts) {
504
+ const outcomes = puts.map(() => ({ status: "pending" }));
505
+ if (puts.length === 0) {
506
+ return Promise.resolve({ outcomes, timedOut: false, aborted: opts?.signal?.aborted === true });
507
+ }
508
+ const signal = opts?.signal;
509
+ let remaining = puts.length;
510
+ let finished = false;
511
+ let finish;
512
+ for (let i = 0; i < puts.length; i++) {
513
+ const idx = i;
514
+ puts[idx].then((value) => {
515
+ if (finished)
516
+ return;
517
+ outcomes[idx] = { status: "settled", value };
518
+ remaining -= 1;
519
+ if (remaining === 0)
520
+ finish?.(false, false);
521
+ }, (reason) => {
522
+ if (finished)
523
+ return;
524
+ outcomes[idx] = { status: "rejected", reason };
525
+ remaining -= 1;
526
+ if (remaining === 0)
527
+ finish?.(false, false);
528
+ });
529
+ }
530
+ if (signal?.aborted === true) {
531
+ finished = true;
532
+ return Promise.resolve({ outcomes, timedOut: false, aborted: true });
533
+ }
534
+ if (opts?.window?.expired === true) {
535
+ finished = true;
536
+ return Promise.resolve({ outcomes, timedOut: true, aborted: false });
537
+ }
538
+ return new Promise((resolve) => {
539
+ const ownWindow = opts?.window === undefined ? createOffloadWaitWindow() : undefined;
540
+ const win = opts?.window ?? ownWindow;
541
+ let unsubExpire;
542
+ const onAbort = () => {
543
+ finish?.(false, true);
544
+ };
545
+ finish = (timedOut, aborted) => {
546
+ if (finished)
547
+ return;
548
+ finished = true;
549
+ unsubExpire?.();
550
+ ownWindow?.dispose();
551
+ signal?.removeEventListener("abort", onAbort);
552
+ resolve({ outcomes, timedOut, aborted });
553
+ };
554
+ if (remaining === 0) {
555
+ finish(false, false);
556
+ return;
557
+ }
558
+ signal?.addEventListener("abort", onAbort, { once: true });
559
+ unsubExpire = win.onExpire(() => finish?.(true, false));
560
+ win.start();
561
+ });
562
+ }
463
563
  export function createOffloadPersist(store, sessionId, onNotice, tellOnce) {
464
564
  const provenance = toolResultProvenanceOf(sessionId);
465
565
  const pending = new Map();
@@ -648,38 +748,76 @@ export function buildPreview(full, ref, sizes, reachableTools) {
648
748
  `${tail}\n` +
649
749
  `</persisted-output>`);
650
750
  }
651
- export function withToolResultOffload(tool, store, thresholdChars, sessionId, reachableTools) {
751
+ export function withToolResultOffload(tool, store, thresholdChars, sessionId, reachableTools, onNotice) {
652
752
  if (!(Number.isFinite(thresholdChars) && thresholdChars > 0))
653
753
  return tool;
654
754
  const provenance = toolResultProvenanceOf(sessionId);
655
755
  const wrappedExecute = async (toolCallId, params, signal, onUpdate) => {
656
756
  const res = await tool.execute(toolCallId, params, signal, onUpdate);
657
- const offloadedDetails = res.details === undefined ? undefined : await offloadOversizedDetailStrings(res.details, store, thresholdChars, sessionId, toolCallId, provenance);
658
- if (offloadedDetails !== undefined)
659
- carryNotStartedReceipt(res.details, offloadedDetails.value);
660
- const withDetails = (r) => offloadedDetails === undefined || offloadedDetails.value === res.details ? r : { ...r, details: offloadedDetails.value };
661
- if (totalTextChars(res.content) <= thresholdChars)
662
- return withDetails(res);
663
- const full = res.content
664
- .filter((b) => b.type === "text")
665
- .map((b) => b.text)
666
- .join("\n");
667
- if (full.length <= PREVIEW_HEAD_CHARS + PREVIEW_TAIL_CHARS)
668
- return withDetails(res);
669
- const ref = buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(full));
757
+ const waitWindow = createOffloadWaitWindow();
758
+ const unsettledRefs = [];
759
+ let abortedDuringWait = false;
670
760
  try {
671
- await store.put(ref, full, provenance);
761
+ const offloadedDetails = res.details === undefined ? undefined : await offloadOversizedDetailStrings(res.details, store, thresholdChars, sessionId, toolCallId, provenance, signal, waitWindow);
762
+ if (offloadedDetails !== undefined) {
763
+ if (offloadedDetails.aborted)
764
+ abortedDuringWait = true;
765
+ for (const r of offloadedDetails.unsettledRefs)
766
+ unsettledRefs.push(r);
767
+ carryNotStartedReceipt(res.details, offloadedDetails.value);
768
+ }
769
+ const withDetails = (r) => offloadedDetails === undefined || offloadedDetails.value === res.details ? r : { ...r, details: offloadedDetails.value };
770
+ if (abortedDuringWait)
771
+ return withDetails(res);
772
+ if (totalTextChars(res.content) <= thresholdChars)
773
+ return withDetails(res);
774
+ const full = res.content
775
+ .filter((b) => b.type === "text")
776
+ .map((b) => b.text)
777
+ .join("\n");
778
+ if (full.length <= PREVIEW_HEAD_CHARS + PREVIEW_TAIL_CHARS)
779
+ return withDetails(res);
780
+ if (waitWindow.expired)
781
+ return withDetails(res);
782
+ const ref = buildToolResultRef(sessionId, toolCallId, toolResultContentSegment(full));
783
+ let put;
784
+ try {
785
+ put = Promise.resolve(store.put(ref, full, provenance));
786
+ }
787
+ catch {
788
+ return withDetails(res);
789
+ }
790
+ const waited = await waitForOffloadPuts([put], { signal, window: waitWindow });
791
+ if (waited.aborted) {
792
+ abortedDuringWait = true;
793
+ return withDetails(res);
794
+ }
795
+ const outcome = waited.outcomes[0];
796
+ if (outcome.status !== "settled") {
797
+ if (outcome.status === "pending")
798
+ unsettledRefs.push(ref);
799
+ return withDetails(res);
800
+ }
801
+ const images = res.content.filter((b) => b.type !== "text");
802
+ return withDetails({ ...res, content: [{ type: "text", text: buildPreview(full, ref, undefined, reachableTools?.()) }, ...images] });
672
803
  }
673
- catch {
674
- return withDetails(res);
804
+ finally {
805
+ waitWindow.dispose();
806
+ if (unsettledRefs.length > 0 && !abortedDuringWait) {
807
+ const refs = [...new Set(unsettledRefs)];
808
+ deliverEngineNotice(onNotice, {
809
+ code: "tool_result.offload_put_unsettled",
810
+ message: `tool-result offload: ${refs.length} tool-call offload write(s) had not settled after ${OFFLOAD_PUT_WAIT_BOUND_MS} ms — ` +
811
+ `the call finished as unconfirmed (content returned as is; unsettled details members carry no ref). Each write runs on in the background.`,
812
+ detail: { refs, sessionId, boundMs: OFFLOAD_PUT_WAIT_BOUND_MS, occurrenceId: uuidv7() },
813
+ });
814
+ }
675
815
  }
676
- const images = res.content.filter((b) => b.type !== "text");
677
- return withDetails({ ...res, content: [{ type: "text", text: buildPreview(full, ref, undefined, reachableTools?.()) }, ...images] });
678
816
  };
679
817
  return { ...tool, execute: wrappedExecute };
680
818
  }
681
819
  const OFFLOADED_DETAIL_NOTICE_ALLOWANCE_CHARS = MAX_MINTED_TOOL_RESULT_REF_CHARS + 200;
682
- async function offloadOversizedDetailStrings(details, store, thresholdChars, sessionId, toolCallId, provenance) {
820
+ async function offloadOversizedDetailStrings(details, store, thresholdChars, sessionId, toolCallId, provenance, signal, waitWindow) {
683
821
  const isPlainObject = (v) => {
684
822
  if (typeof v !== "object" || v === null)
685
823
  return false;
@@ -690,6 +828,8 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
690
828
  const pending = [];
691
829
  const rebuilt = new Set();
692
830
  const replace = (full, path) => {
831
+ if (waitWindow.expired)
832
+ return mintOffloadedDetailNotice(full, undefined);
693
833
  const detailRef = buildToolResultRef(sessionId, toolCallId, path, toolResultContentSegment(full));
694
834
  let done;
695
835
  try {
@@ -701,6 +841,7 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
701
841
  const marker = {};
702
842
  pending.push({
703
843
  marker,
844
+ ref: detailRef,
704
845
  done,
705
846
  render: (stored) => mintOffloadedDetailNotice(full, stored ? detailRef : undefined),
706
847
  });
@@ -761,10 +902,14 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
761
902
  return v;
762
903
  };
763
904
  const value = walk(details, []);
764
- const settled = await Promise.allSettled(pending.map((p) => p.done));
905
+ const waited = await waitForOffloadPuts(pending.map((p) => p.done), { signal, window: waitWindow });
906
+ const unsettledRefs = [];
765
907
  const notices = new Map();
766
908
  pending.forEach((p, i) => {
767
- notices.set(p.marker, p.render(settled[i].status === "fulfilled"));
909
+ const outcome = waited.outcomes[i];
910
+ if (outcome.status === "pending" && !waited.aborted)
911
+ unsettledRefs.push(p.ref);
912
+ notices.set(p.marker, p.render(outcome.status === "settled"));
768
913
  });
769
914
  const seen = new Set();
770
915
  const finalize = (node) => {
@@ -789,7 +934,7 @@ async function offloadOversizedDetailStrings(details, store, thresholdChars, ses
789
934
  Object.defineProperty(obj, k, { value: finalize(obj[k]), enumerable: true, writable: true, configurable: true });
790
935
  return node;
791
936
  };
792
- return { value: finalize(value) };
937
+ return { value: finalize(value), unsettledRefs, aborted: waited.aborted };
793
938
  }
794
939
  export function createReadToolResultTool(store, legsOfRef, bytesSeat) {
795
940
  return defineTool({
@@ -537,9 +537,9 @@ export type TraceEvent = {
537
537
  } | {
538
538
  /**
539
539
  * design/179 — the person's persisted rule store could not be read (at prepare, or for one call), so
540
- * that read's rows took no part: a call it served was judged without them — and, at a call, asks a person (the
541
- * rows could hold a deny). The operator's per-read record; the person hears it once per run
542
- * (`permission.rule_store_unavailable`).
540
+ * that read's allow rows took no part (retained deny/ask rows still apply; under asking modes calls ask, under
541
+ * `auto` the classifier judges, under `bypassPermissions` the class is released). The operator's per-read record;
542
+ * the person hears it via `permission.rule_store_unavailable` (once per session when met at prepare, once per run at a call).
543
543
  */
544
544
  kind: "permission.rule_store_unreadable";
545
545
  version: 1;
@@ -2,7 +2,8 @@ import { type FileHandle } from "node:fs/promises";
2
2
  import { type BoundFileObject, type ExecResult, type ExecutionEnv, ExecutionError, type ExecutionEnvExecOptions, FileError, type FileInfo, type Result } from "../harness/types.js";
3
3
  import { type SecretEnvFinding } from "../../core/secret-env.js";
4
4
  import { type EngineNotice } from "../../core/engine-notice.js";
5
- import type { ExecutionEnvCapabilities, SymlinkChain } from "../harness/types.js";
5
+ import type { ExecutionEnvModelShell, ExecutionEnvCapabilities, SymlinkChain } from "../harness/types.js";
6
+ import { type ShellKindAnswer, type DroppedShellState } from "../../core/model-shell.js";
6
7
  import type { BackgroundHardKillOutcome, BackgroundShellCapability, BackgroundShellId, BackgroundPoll, BackgroundSpawnOptions } from "../../core/background-shell.js";
7
8
  import { BackgroundShellError } from "../../core/background-shell.js";
8
9
  import type { SchedulerCapability, ScheduledIntent, SchedulerContext, ScheduledTaskId, ScheduledTaskSummary } from "../../core/scheduler.js";
@@ -22,6 +23,37 @@ export declare function getShellConfig(customShellPath?: string): Promise<Result
22
23
  shell: string;
23
24
  args: string[];
24
25
  }, ExecutionError>>;
26
+ /** What {@link resolveModelShell} looks at: the platform, whether a path exists, whether it is an executable file, the Program Files roots. */
27
+ export interface ModelShellCandidateProbe {
28
+ readonly platform: NodeJS.Platform;
29
+ readonly exists: (path: string) => Promise<boolean>;
30
+ readonly executable: (path: string) => Promise<boolean>;
31
+ readonly programFiles: readonly (string | undefined)[];
32
+ }
33
+ /** Where a start runs: the environment's working directory and the PATH its child receives. */
34
+ export interface ModelShellPlace {
35
+ readonly cwd: string;
36
+ readonly searchPath: readonly string[];
37
+ }
38
+ /** The entries of the PATH a composed child environment holds, as `platform` reads it: the name compared as the platform compares
39
+ * names (win32 case-blind: `Path`), the list split on the platform's separator (`;` on win32, `:` elsewhere); `[]` when there is none. */
40
+ export declare function modelShellSearchPath(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform): readonly string[];
41
+ /** One candidate asked what it is ({@link SHELL_KIND_QUESTION}), once per environment: the absolute program (what makes the asked
42
+ * and the started one the same), in the environment's own cwd (not a call's — the question is asked before any call), in the fixed
43
+ * least environment {@link shellKindQuestionEnv} reads out of this process's own as the scrub hands it on when the question is asked
44
+ * (no `shellEnv`, no earlier snapshot), stdin closed, five seconds. Only a run that ends with status 0 and answers as
45
+ * {@link readShellKindAnswer} reads is an answer. The answer is the program's own report of what it is. */
46
+ export declare function askShellKind(path: string, cwd: string): Promise<ShellKindAnswer>;
47
+ /** The absolute program a start for model text runs on, the one that was asked, with the version it reported: the host's `shellPath`
48
+ * alone, fixed as one absolute program ({@link programOf}; nothing there keeps {@link getShellConfig}'s sentence); else on win32 Git
49
+ * Bash under each Program Files root, else `/bin/bash` — each asked when it exists — and only after those `bash` found by the same
50
+ * {@link programOf} on the child's PATH (one lookup for both); never `sh`, never zsh (this version starts only a bash), never a
51
+ * candidate that is not fully qualified (a relative `ProgramFiles`). The first that answers bash 3.2 or later is taken; a candidate
52
+ * that answers zsh is not; otherwise `shell_unavailable` names each candidate and why. */
53
+ export declare function resolveModelShell(shellPath: string | undefined, place: ModelShellPlace, probe?: ModelShellCandidateProbe, ask?: (path: string, cwd: string) => Promise<ShellKindAnswer>): Promise<Result<{
54
+ readonly path: string;
55
+ readonly version: string;
56
+ }, ExecutionError>>;
25
57
  /** test seam (mirrors the notice-seat announce reset): the once-per-process fallback latches. */
26
58
  export declare function __resetSecretScrubAnnouncement(): void;
27
59
  /** RB-235: the spool-reclaim decision, extracted PURE so every rule is unit-pinnable.
@@ -80,6 +112,11 @@ export declare function openSpoolPair(base: string): {
80
112
  errPath: string;
81
113
  fds: [number, number];
82
114
  };
115
+ /** How many dropped variables an environment's {@link NodeExecutionEnv.modelShellDropped} record keeps. */
116
+ export declare const MODEL_SHELL_DROPPED_KEPT = 32;
117
+ /** The keys of the two shared start routines: module symbols, so no ordinary subclass method takes their place (reflection can still reach them). */
118
+ declare const RUN_SHELL: unique symbol;
119
+ declare const START_BACKGROUND: unique symbol;
83
120
  export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCapability, SchedulerCapability {
84
121
  cwd: string;
85
122
  /** `ExecutionEnv.capabilities`: the engine's own host — commands are this process's children on its own disk, not
@@ -207,6 +244,39 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
207
244
  * host does not apply, is the reason the start is refused (the command never runs, confined or not). */
208
245
  private startOf;
209
246
  exec(command: string, options?: ExecutionEnvExecOptions): Promise<Result<ExecResult, ExecutionError>>;
247
+ /** `ExecutionEnv.modelShell`: the start for model-written shell text, on the one absolute program {@link resolveModelShell} asked for this
248
+ * environment (asked once, in the environment's cwd; `ready` reports its answer, `{ shell: "bash", version }`), with the child
249
+ * environment of {@link modelShellSpawnEnv}. Each start ends in `this.exec` / `this.spawnBackground`, so a subclass's override of either
250
+ * sees every start for model text; the start rides on the call's options under a module symbol, and the base's method reached with
251
+ * those options (an override's `super` call that hands them on, spread or not) starts the asked bash with that environment. Each start
252
+ * reads `shellEnv` once; the PATH the program is found on comes from this process's inheritance as it stands at the lookup, the
253
+ * question is asked in its own least environment ({@link askShellKind}), and the child's is composed when the child is started — a
254
+ * declaration made in between is judged by the child's. A composition that refuses is that start's failure (`spawn_error` /
255
+ * `spawn_failed`), and the next start composes again. A start an override hands on to ANOTHER environment's method is started by
256
+ * that environment's own start (its asked bash, its composition), never by this one's. */
257
+ get modelShell(): Required<ExecutionEnvModelShell>;
258
+ /** The bash this environment starts model text on, resolved once per environment object, on the PATH of the first question's composition
259
+ * ({@link modelShellSearchPath}) — kept while it holds: a resolution that found no bash while a candidate gave no answer at all (it
260
+ * could not be started, timed out or was ended by a signal: `askShellKindOnce`'s `ran: false`) is not kept, and the next reading or
261
+ * start asks again; a candidate that answered (not a bash, a bash below 3.2, a zsh) or a path that is not there is kept. */
262
+ private modelShellResolved?;
263
+ private modelShellPath;
264
+ /** `ExecutionEnv.modelShellDropped`: what the starts of this environment did not pass ({@link DroppedShellState}), each variable once
265
+ * (by where it came from), up to {@link MODEL_SHELL_DROPPED_KEPT} variables; past that, `more` says there were others and nothing else
266
+ * is kept. One record object for the environment's life, which the run tells as each tool call ends; an environment made from this one
267
+ * by `Object.create` shares it. */
268
+ get modelShellDropped(): {
269
+ readonly entries: readonly DroppedShellState[];
270
+ readonly more: boolean;
271
+ };
272
+ private readonly modelShellDroppedRecord;
273
+ /** A bash start's child environment: the start's one composition with the call's `env` laid over it (a copy without any variable a
274
+ * row of `SHELL_STATE_ENV` holds, `configuredShellLayer`), then the host process's own variables by each row's rule
275
+ * (`inheritedShellState`); what was left out is recorded in {@link modelShellDropped}. */
276
+ private modelShellSpawnEnv;
277
+ /** The one foreground start: `exec` on the shell {@link getShellConfig} finds, a bash start on its bash. Keyed by a module symbol and
278
+ * read off this prototype, so no ordinary subclass method takes its place (reflection can reach the symbol). */
279
+ private [RUN_SHELL];
210
280
  readTextFile(path: string, abortSignal?: AbortSignal): Promise<Result<string, FileError>>;
211
281
  readTextLines(path: string, options?: {
212
282
  maxLines?: number;
@@ -307,6 +377,9 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
307
377
  spawnBackground(command: string, options?: BackgroundSpawnOptions): Promise<Result<{
308
378
  shellId: BackgroundShellId;
309
379
  }, BackgroundShellError>>;
380
+ /** The one background start: `spawnBackground` on the shell {@link getShellConfig} finds, a bash start on its bash. Keyed by a module
381
+ * symbol and read off this prototype, so no ordinary subclass method takes its place (reflection can reach the symbol). */
382
+ private [START_BACKGROUND];
310
383
  pollBackground(shellId: BackgroundShellId): Promise<Result<BackgroundPoll, BackgroundShellError>>;
311
384
  killBackground(shellId: BackgroundShellId): Promise<Result<void, BackgroundShellError>>;
312
385
  /** The synchronous hard kill seat ({@link BackgroundShellCapability.killBackgroundNow}). Reads process truth,
@@ -346,3 +419,4 @@ export declare class NodeExecutionEnv implements ExecutionEnv, BackgroundShellCa
346
419
  }): Promise<void>;
347
420
  cleanup(): Promise<void>;
348
421
  }
422
+ export {};