@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
@@ -540,7 +540,7 @@ function memberNamed(s) {
540
540
  const listed = `${s.entries.join(", ")}${s.omitted !== undefined ? ` and ${s.omitted} more` : ""}`;
541
541
  switch (s.member) {
542
542
  case "hook":
543
- return "a PreToolUse hook's allow";
543
+ return "a hook's allow";
544
544
  case "deployment":
545
545
  return `the deployment's allowedTools (${listed})`;
546
546
  case "persisted":
@@ -16,8 +16,8 @@
16
16
  * (name/pattern confirmation lists). Sandbox containment answers it.
17
17
  * - `external_authority` — an ask whose whole point is real judgment (the safety-rule policies with
18
18
  * `requiresRealApproval`); containment answers nothing about it.
19
- * - `hook` — a screening-face ask (a deployment's PreToolUse verdict folded to policy
20
- * form); the face's authority is the deployment's, not the sandbox's.
19
+ * - `hook` — a screening-face ask (a deployment's PreToolUse or tool.check verdict folded to policy form);
20
+ * the face's authority is the deployment's, not the sandbox's.
21
21
  * - `mandate` — an ask bound to durable-park semantics (inherited durable mandate /
22
22
  * approver-unavailable float); it must reach the park untouched.
23
23
  * - `unknown` — everything unregistered, every deployment policy. Fail-closed: never
@@ -28,8 +28,8 @@ type NoHeadlineClass = (typeof NO_HEADLINE_CLASSES)[number];
28
28
  /** The WHY row of each class that has one: `core/engine.ask-headline.<class>`. */
29
29
  export declare const ASK_HEADLINE_WHY: Readonly<{
30
30
  readonly mode: "core/engine.ask-headline.mode";
31
- readonly hook: "core/engine.ask-headline.hook";
32
31
  readonly ancestor: "core/engine.ask-headline.ancestor";
32
+ readonly hook: "core/engine.ask-headline.hook";
33
33
  readonly org_rule: "core/engine.ask-headline.org_rule";
34
34
  readonly write_protection: "core/engine.ask-headline.write_protection";
35
35
  readonly target_unresolved: "core/engine.ask-headline.target_unresolved";
@@ -63,7 +63,7 @@ import type { AssertAllKeysHandled } from "@sema-agent/primitives";
63
63
  * lane may answer (the class `call_unreadable`). A store (or a partition of it) that could not be READ is this
64
64
  * word too — a row inside it may forbid the call and nobody can tell (the class `rule_unreadable`, which the
65
65
  * two relaxed modes answer: auto mode's classifier, the bypass release); the run then also carries one
66
- * `permission.rule_store_unavailable` notice where a mode puts such a call to a person.
66
+ * `permission.rule_store_unavailable` notice under every mode (plus `permission.rule_store_unreadable_relaxed` for the operator under relaxed modes).
67
67
  * - `hook` — a deployment's PreToolUse screening face raised or co-raised the ask; the word is
68
68
  * engine-stamped at the fold and is the deployment's own per-call adjudication.
69
69
  * - `ask_rule` — an EXPLICIT `ask` permission rule matched: a person's standing "ask me each time",
@@ -276,6 +276,8 @@ export declare function stampAskOrigin<T extends Extract<PermissionResult, {
276
276
  */
277
277
  export declare const RULE_OFFERS_ABSENCES: readonly ["mandated", "allow_outranked", "ask_rule_matched", "lane_cannot_speak"];
278
278
  export type RuleOffersAbsence = (typeof RULE_OFFERS_ABSENCES)[number];
279
+ /** Membership test for {@link RuleOffersAbsence} — screens a parked row's value before publishing it on a summary. */
280
+ export declare function isRuleOffersAbsence(v: unknown): v is RuleOffersAbsence;
279
281
  /**
280
282
  * CAN a persisted allow rule clear this ask — and, if not, which door closed? ONE derivation with TWO
281
283
  * readers, which is the whole point of the shape: the approval card's `ruleOffersAbsence` word and the
@@ -1012,6 +1014,10 @@ export type AskFace = (typeof ASK_FACES)[number];
1012
1014
  * wears does not count): the catalog's shell face for exactly the names that declare the command grammar, `other` for every
1013
1015
  * other name. */
1014
1016
  export declare function askFaceOf(toolName: string): AskFace;
1017
+ /** The classes `bypassPermissions` releases on a CONFINED Runner (`RunnerDeps.deploymentShape` declared) although their row says
1018
+ * immune — the same kind of reading as {@link RELEASED_ON_SHELL_FACE}: one column, read at the mode point only (the fold, the
1019
+ * classifier, the card and the park row read the table's rows). A read check that did not finish. */
1020
+ export declare const RELEASED_ON_CONFINED_RUNNER: readonly ["unfinished_check"];
1015
1021
  /** The classes whose own mint puts the `requiresRealApproval` bit on the ask — a bit one of them explains is not
1016
1022
  * the bare bit `policy_rra` names. The mark classes (probe / write protection / tool marks / operator forced / the
1017
1023
  * shell floor) mint no bit and explain none — except `requires_user_interaction`, whose declaration the origin stamp
@@ -1024,8 +1030,13 @@ export declare const RRA_EXPLAINERS: ReadonlySet<AskClass>;
1024
1030
  export declare function explainsRealApprovalBit(classes: Iterable<AskClass>): boolean;
1025
1031
  /** The classes a permission mode can RELEASE for a call on `face`, in {@link ASK_CLASSES} order. The same list on every face
1026
1032
  * but one class — {@link RELEASED_ON_SHELL_FACE}. A frozen list: a caller holding it cannot change the next read. A word
1027
- * outside {@link ASK_FACES} throws. */
1033
+ * outside {@link ASK_FACES} throws. A Runner that declares its shape releases more: {@link confinedReleasableAskClassesFor}. */
1028
1034
  export declare function releasableAskClassesFor(face: AskFace): readonly AskClass[];
1035
+ /** {@link releasableAskClassesFor} on a Runner that declares its shape (`RunnerDeps.deploymentShape`): the list with
1036
+ * {@link RELEASED_ON_CONFINED_RUNNER} in it — released only where no person was already required on the question, the call's own
1037
+ * destination stays on the leg's hands and what the check did not see guards nothing ({@link ConfinedCall}); a release that stood on
1038
+ * it says `confined: true`. A word outside {@link ASK_FACES} throws. */
1039
+ export declare function confinedReleasableAskClassesFor(face: AskFace): readonly AskClass[];
1029
1040
  /**
1030
1041
  * The closed set of `reason` words a mode release carries (`GateDisposition.released.reason`, the `released` arm of
1031
1042
  * {@link Arbitration}): each is a releasable class the release record names on its own — `target_unresolved`, a release
@@ -1276,7 +1287,8 @@ export declare function headlessApprovalRemedy(input: {
1276
1287
  };
1277
1288
  readonly approverSeat?: HeadlessApproverSeat;
1278
1289
  readonly ruleShape?: string;
1279
- readonly notResumableWayOut?: string;
1290
+ readonly notResumableWayOut?: string; /** a confined Runner's facts for the call: bypass is a way out exactly where the mode point would release ({@link ConfinedCall}) */
1291
+ readonly confined?: ConfinedCall;
1280
1292
  }): HeadlessApprovalRemedy;
1281
1293
  /** The reference implementation's sentence for a `cp` / `mv` the mode will not answer because it carries option
1282
1294
  * words — the approval card's message under `acceptEdits` and the head of the headless remedy. */
@@ -1299,12 +1311,36 @@ export type Arbitration = {
1299
1311
  origin?: AskOrigin;
1300
1312
  mandate?: PersistedRuleMandate;
1301
1313
  reason?: ModeReleaseReason;
1314
+ confined?: true;
1302
1315
  } | {
1303
1316
  kind: "denied_by_mode";
1304
1317
  mode: "bypassPermissions" | "dontAsk";
1305
1318
  askClass: AskClass;
1306
1319
  classes: readonly AskClass[];
1307
1320
  };
1321
+ /**
1322
+ * What a CONFINED Runner (`RunnerDeps.deploymentShape` declared) lends the mode point for one call — three facts (and, for the headless
1323
+ * way out, whether bypass would arm), each read only in the one cell that needs it (`bypassPermissions`, a class set that only {@link RELEASED_ON_CONFINED_RUNNER} keeps immune), never by the
1324
+ * other modes or the other readers of the class set:
1325
+ * - `personAlreadyRequired` — a person was already required on this question when the read check went silent (the real-approval
1326
+ * bit stood before the silence put its own there; the silence's class explains the bit, so the class set cannot say it). The gate's
1327
+ * answer is the engine's record of the silence; a question with no such record answers `true`.
1328
+ * - `destinationOnHands` — the call's own declared destination, on the arguments that run, stays on the leg's hands: a hand of the
1329
+ * environment, no egress mark, every boundary leg the call declares is the environment's.
1330
+ * - `unseenGuardsNothing` — what the check that did not finish left unseen can hold no write a deny row protects: where the read
1331
+ * station answered, no row that guards writes stands on the call's own table or on the one in force now, or the engine's read-only
1332
+ * reader proves the command read-only; where the gate put the station's fallback in its place (the station gave no answer), no deny
1333
+ * row at all stands on either table. Rows that could not be read count as rows.
1334
+ * The mode releases only when the first is `false` and the other two `true`.
1335
+ */
1336
+ export interface ConfinedCall {
1337
+ readonly personAlreadyRequired: () => boolean;
1338
+ readonly destinationOnHands: () => boolean;
1339
+ readonly unseenGuardsNothing: () => boolean;
1340
+ /** Asking for `bypassPermissions` now would run the leg under it — the leg's own mode fold over its ceiling and the deployment's
1341
+ * arming facts (`PermissionModeController.armsAs`). Read by the headless way out alone: the mode point is already in the mode. */
1342
+ readonly bypassArmed: () => boolean;
1343
+ }
1308
1344
  /** Whether `mode` answers an ask of class `c` with nobody asked — the class's row read under the mode, on the face-less reading:
1309
1345
  * `bypassPermissions` releases a class it is not immune to, auto mode's classifier judges a class it may answer; the other modes put
1310
1346
  * it to a person (`dontAsk` refuses it, which a person is still told about). For a reader that tells a person what a class costs them
@@ -1323,11 +1359,15 @@ export declare function modeAnswersUnasked(mode: PermissionMode, c: AskClass): b
1323
1359
  * (`call.fileCommand`, `accepted`); `plan`, `default` and `auto` hand every ask on (plan's own questions were raised by
1324
1360
  * its write gate; the reference implementation refuses nothing at this point under plan — auto's classifier reads the
1325
1361
  * row at its own station). Reads the class SET on the face the classification records ({@link bypassImmuneOf}) and the folded
1326
- * row's face-free `hookAskFloor` — never the row's `bypassImmune`, never the disclosed word.
1362
+ * row's face-free `hookAskFloor` — never the row's `bypassImmune`, never the disclosed word. On a CONFINED Runner (`call.confined`,
1363
+ * {@link ConfinedCall}) `bypassPermissions` also releases a set that only {@link RELEASED_ON_CONFINED_RUNNER} keeps immune — where no
1364
+ * person was already required on the question, the call's destination stays on the hands and what the check did not see guards
1365
+ * nothing — and the release says `confined: true`; every other cell reads as on any Runner.
1327
1366
  */
1328
1367
  export declare function arbitrateByMode(mode: PermissionMode, c: AskClassification, disclosure?: {
1329
1368
  origin?: AskOrigin;
1330
1369
  mandate?: PersistedRuleMandate;
1331
1370
  }, call?: {
1332
1371
  readonly fileCommand?: boolean;
1372
+ readonly confined?: ConfinedCall;
1333
1373
  }): Arbitration;
@@ -106,6 +106,10 @@ export function stampAskOrigin(decision, facts, classification) {
106
106
  return { ...kept, origin, ...classed };
107
107
  }
108
108
  export const RULE_OFFERS_ABSENCES = Object.freeze(["mandated", "allow_outranked", "ask_rule_matched", "lane_cannot_speak"]);
109
+ const RULE_OFFERS_ABSENCE_SET = new Set(RULE_OFFERS_ABSENCES);
110
+ export function isRuleOffersAbsence(v) {
111
+ return RULE_OFFERS_ABSENCE_SET.has(v);
112
+ }
109
113
  const RULE_SPEAKING_CLASSES = new Set(["ask_rule"]);
110
114
  const BOUND_GRANT_CLASSES = new Set(["a2a_inside"]);
111
115
  export function ruleClearanceOf(ask, marks) {
@@ -372,11 +376,13 @@ export function askFaceOf(toolName) {
372
376
  return isShellFaceToolName(toolName) ? "shell" : "other";
373
377
  }
374
378
  const RELEASED_ON_SHELL_FACE = new Set(["target_unresolved"]);
375
- function bypassImmuneOn(c, face) {
376
- return MODE_ARBITRATION[c].bypassImmune && !(face === "shell" && RELEASED_ON_SHELL_FACE.has(c));
379
+ export const RELEASED_ON_CONFINED_RUNNER = Object.freeze(["unfinished_check"]);
380
+ const CONFINED_RELEASE = new Set(RELEASED_ON_CONFINED_RUNNER);
381
+ function bypassImmuneOn(c, face, confined = false) {
382
+ return MODE_ARBITRATION[c].bypassImmune && !(face === "shell" && RELEASED_ON_SHELL_FACE.has(c)) && !(confined && CONFINED_RELEASE.has(c));
377
383
  }
378
- function bypassImmuneOf(c) {
379
- return [...c.classes].some((k) => bypassImmuneOn(k, c.askFace));
384
+ function bypassImmuneOf(c, confined = false) {
385
+ return [...c.classes].some((k) => bypassImmuneOn(k, c.askFace, confined));
380
386
  }
381
387
  const CLASSIFIER_WITHHELD_ON_ROOTS = new Set(["probe"]);
382
388
  function bareBit(d, classes) {
@@ -389,13 +395,20 @@ export function explainsRealApprovalBit(classes) {
389
395
  return true;
390
396
  return false;
391
397
  }
398
+ const releasableOn = (face, confined) => Object.freeze(ASK_CLASSES.filter((c) => !bypassImmuneOn(c, face, confined)));
392
399
  const RELEASABLE_BY_FACE = Object.freeze({
393
- shell: Object.freeze(ASK_CLASSES.filter((c) => !bypassImmuneOn(c, "shell"))),
394
- other: Object.freeze(ASK_CLASSES.filter((c) => !bypassImmuneOn(c, "other"))),
400
+ shell: Object.freeze({ unconfined: releasableOn("shell", false), confined: releasableOn("shell", true) }),
401
+ other: Object.freeze({ unconfined: releasableOn("other", false), confined: releasableOn("other", true) }),
395
402
  });
396
403
  export function releasableAskClassesFor(face) {
404
+ return releasableListFor(face, "releasableAskClassesFor").unconfined;
405
+ }
406
+ export function confinedReleasableAskClassesFor(face) {
407
+ return releasableListFor(face, "confinedReleasableAskClassesFor").confined;
408
+ }
409
+ function releasableListFor(face, reader) {
397
410
  if (!ASK_FACES.includes(face))
398
- throw new TypeError(`releasableAskClassesFor: "${String(face)}" is not an ask face (${ASK_FACES.join(", ")})`);
411
+ throw new TypeError(`${reader}: "${String(face)}" is not an ask face (${ASK_FACES.join(", ")})`);
399
412
  return RELEASABLE_BY_FACE[face];
400
413
  }
401
414
  export const MODE_RELEASE_REASONS = Object.freeze(["target_unresolved"]);
@@ -613,12 +626,13 @@ export function headlessApprovalRemedy(input) {
613
626
  const c = input.classification;
614
627
  if (input.mode === "acceptEdits" && input.unplacedOptions !== undefined && (c === undefined || (c.classes.size === 1 && c.classes.has("ordinary"))))
615
628
  return way(orApprover(`${fileCommandOptionsSentence(input.unplacedOptions.program)} Spell the ${input.unplacedOptions.program} without option words for the mode to answer it`));
616
- if (c !== undefined && bypassImmuneOf(c)) {
629
+ const confinedRelease = c !== undefined && bypassImmuneOf(c) && releasedOnConfinedRunner(c, input.confined) && input.confined?.bypassArmed() === true;
630
+ if (c !== undefined && bypassImmuneOf(c) && !confinedRelease) {
617
631
  const earlierYes = c.classes.has("cross_boundary") ? ` — ${CROSS_BOUNDARY_EARLIER_YES}` : "";
618
632
  return way(approver !== undefined ? `no permission mode releases this ask: ${approver}, or change the call${earlierYes}` : `no permission mode releases this ask: change the call${earlierYes}; ${NOBODY_CAN_APPROVE}`);
619
633
  }
620
634
  if (input.mode === "plan" && c?.classes.has("mode") === true)
621
- return way(orApprover(`the plan permission mode asks before every write and every call to a tool the engine does not define that is not read-only — leave plan mode (\`setPermissionMode\` to another mode${approver !== undefined ? ", or approve the plan" : ""}) to run it`));
635
+ return way(orApprover(`the plan permission mode asks before every write and every call to a tool the engine does not define that is not read-only — leave plan mode (\`setPermissionMode\` to another mode${approver !== undefined ? ", or approve the plan" : ""}) to run it`), confinedRelease);
622
636
  if (c !== undefined && boundGrantMayClear(c.classes))
623
637
  return way(orApprover(`${A2A_INSIDE_GRANT_SENTENCE} answers it`), true);
624
638
  if (c !== undefined && c.classes.size === 1 && c.classes.has("unstated"))
@@ -635,6 +649,9 @@ export function headlessApprovalRemedy(input) {
635
649
  export function fileCommandOptionsSentence(program) {
636
650
  return `${program} with flags requires manual approval to ensure path safety: the mode cannot automatically validate ${program} commands that use flags, as some flags like --target-directory=PATH can bypass path validation.`;
637
651
  }
652
+ function releasedOnConfinedRunner(c, confined) {
653
+ return confined !== undefined && bypassImmuneOf(c) && !bypassImmuneOf(c, true) && !confined.personAlreadyRequired() && confined.destinationOnHands() && confined.unseenGuardsNothing();
654
+ }
638
655
  export function modeAnswersUnasked(mode, c) {
639
656
  return mode === "bypassPermissions" ? !bypassImmuneOn(c, undefined) : mode === "auto" ? MODE_ARBITRATION[c].classifierEligible : false;
640
657
  }
@@ -647,7 +664,8 @@ export function arbitrateByMode(mode, c, disclosure, call) {
647
664
  case "bypassPermissions":
648
665
  if (has("target_unresolved") && bypassImmuneOn("target_unresolved", c.askFace))
649
666
  return { kind: "denied_by_mode", mode, askClass: c.askClass, classes };
650
- if (bypassImmuneOf(c))
667
+ const confined = releasedOnConfinedRunner(c, call?.confined);
668
+ if (bypassImmuneOf(c) && !confined)
651
669
  return { kind: "ask" };
652
670
  const reason = [...MODE_RELEASE_REASON_SET].find((r) => has(r));
653
671
  return {
@@ -658,6 +676,7 @@ export function arbitrateByMode(mode, c, disclosure, call) {
658
676
  ...(disclosure?.origin !== undefined ? { origin: disclosure.origin } : {}),
659
677
  ...(disclosure?.mandate !== undefined ? { mandate: disclosure.mandate } : {}),
660
678
  ...(reason !== undefined ? { reason } : {}),
679
+ ...(confined ? { confined: true } : {}),
661
680
  };
662
681
  case "acceptEdits":
663
682
  return call?.fileCommand === true && c.classes.size === 1 && c.classes.has("ordinary") ? { kind: "accepted", mode } : { kind: "ask" };
@@ -667,6 +667,7 @@ export declare function reconcileParkedAgents(stores: {
667
667
  }): Promise<{
668
668
  failed: number;
669
669
  rolledBack: number;
670
+ unreadable: number;
670
671
  }>;
671
672
  /** A background agent row's ending as every face reads it: the row's own outcome when it is this row's (it reads, and its word
672
673
  * projects onto the row's status — {@link memberRowStatusOf}), taken in sealed; else the one derived from the row's status words
@@ -264,6 +264,32 @@ export async function parkedCardState(store, card) {
264
264
  }
265
265
  export async function reconcileParkedAgents(stores, scope, now, opts) {
266
266
  const out = { failed: 0, rolledBack: 0 };
267
+ const unreadable = new Set();
268
+ const isMalformedRowError = (e) => e?.code === BACKGROUND_AGENT_ROW_MALFORMED_CODE;
269
+ const readRow = async (handle) => {
270
+ try {
271
+ return await stores.agentStore.get(handle, scope);
272
+ }
273
+ catch (e) {
274
+ if (isMalformedRowError(e)) {
275
+ unreadable.add(handle);
276
+ return null;
277
+ }
278
+ throw e;
279
+ }
280
+ };
281
+ const updateRowIf = async (row, next, expect) => {
282
+ try {
283
+ return await stores.agentStore.updateIf(row.handle, scope, next, expect);
284
+ }
285
+ catch (e) {
286
+ if (isMalformedRowError(e)) {
287
+ unreadable.add(row.handle);
288
+ return false;
289
+ }
290
+ throw e;
291
+ }
292
+ };
267
293
  const excluded = (row) => (opts?.excludeHandles?.has(row.handle) ?? false) ||
268
294
  (opts?.excludeWriterId !== undefined && row.writerId === opts.excludeWriterId);
269
295
  const failRow = async (row, why) => {
@@ -277,13 +303,24 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
277
303
  delete next.parkedCheckpointToken;
278
304
  delete next.parkClaimId;
279
305
  delete next.parkedAt;
280
- return stores.agentStore.update(row.handle, scope, next, { rev: row.rev });
306
+ try {
307
+ return await stores.agentStore.update(row.handle, scope, next, { rev: row.rev });
308
+ }
309
+ catch (e) {
310
+ if (isMalformedRowError(e)) {
311
+ unreadable.add(row.handle);
312
+ return false;
313
+ }
314
+ throw e;
315
+ }
281
316
  };
282
317
  const checkpointState = (row, token) => parkedCardState(stores.checkpointStore, { token, handle: row.handle, scope, sessionId: row.sessionId });
283
318
  for (const summary of await stores.agentStore.listByScope(scope, { status: "parked" })) {
284
- if ("rowVerdict" in summary)
319
+ if ("rowVerdict" in summary) {
320
+ unreadable.add(summary.handle);
285
321
  continue;
286
- const row = await stores.agentStore.get(summary.handle, scope);
322
+ }
323
+ const row = await readRow(summary.handle);
287
324
  if (!row || row.status !== "parked")
288
325
  continue;
289
326
  if (excluded(row))
@@ -305,9 +342,13 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
305
342
  const staleClaims = [];
306
343
  for (const status of ["parked", "running"]) {
307
344
  for (const summary of await stores.agentStore.listByScope(scope, { status })) {
308
- if ("rowVerdict" in summary || now - summary.updatedAt <= staleMs)
345
+ if ("rowVerdict" in summary) {
346
+ unreadable.add(summary.handle);
347
+ continue;
348
+ }
349
+ if (now - summary.updatedAt <= staleMs)
309
350
  continue;
310
- const row = await stores.agentStore.get(summary.handle, scope);
351
+ const row = await readRow(summary.handle);
311
352
  if (!row || row.status !== status)
312
353
  continue;
313
354
  if (row.parkClaimId === undefined && !(status === "parked" && row.parkedCheckpointToken !== undefined))
@@ -337,7 +378,7 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
337
378
  next.writerEpoch = (row.writerEpoch ?? 0) + 1;
338
379
  next.updatedAt = now;
339
380
  delete next.parkClaimId;
340
- if (await stores.agentStore.updateIf(row.handle, scope, next, { rev: row.rev, status: "parked", parkClaimId: row.parkClaimId }))
381
+ if (await updateRowIf(row, next, { rev: row.rev, status: "parked", parkClaimId: row.parkClaimId }))
341
382
  out.rolledBack++;
342
383
  }
343
384
  else if (state === "resolved") {
@@ -352,7 +393,7 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
352
393
  next.status = "parked";
353
394
  next.updatedAt = now;
354
395
  delete next.parkClaimId;
355
- if (await stores.agentStore.updateIf(row.handle, scope, next, { rev: row.rev, status: "running", parkClaimId: row.parkClaimId }))
396
+ if (await updateRowIf(row, next, { rev: row.rev, status: "running", parkClaimId: row.parkClaimId }))
356
397
  out.rolledBack++;
357
398
  }
358
399
  else if (state === "expired" || state === "missing") {
@@ -366,7 +407,7 @@ export async function reconcileParkedAgents(stores, scope, now, opts) {
366
407
  }
367
408
  }
368
409
  }
369
- return out;
410
+ return { failed: out.failed, rolledBack: out.rolledBack, unreadable: unreadable.size };
370
411
  }
371
412
  export function agentOutcomeOf(row) {
372
413
  if (!isBackgroundAgentSettledStatus(row.status))
@@ -87,7 +87,7 @@ export declare const ROW_REFUSAL_SENTENCES: Readonly<{
87
87
  readonly "checkpoint.invalid_outcome|read_face_damaged": "This engine cannot resume this checkpoint: its read-face section is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.";
88
88
  readonly "checkpoint.invalid_outcome|write_face_damaged": "This engine cannot resume this checkpoint: its write-face section is malformed (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.";
89
89
  readonly "checkpoint.invalid_outcome|skill_grants_damaged": "This engine cannot resume this checkpoint: its skill-grant section does not read as grant rows under this engine — damaged, or written by an earlier release whose entries this release reads differently. The checkpoint stays pending. Expire it and run the work again.";
90
- readonly "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it and run the work again.";
90
+ readonly "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it, then start the task again.";
91
91
  readonly "checkpoint.invalid_outcome|hands_coordinates_damaged": "This engine cannot resume this checkpoint: one of its recorded workspace coordinates is not an absolute path (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.";
92
92
  readonly "checkpoint.invalid_outcome|constraint_chain_missing": "This engine cannot resume this checkpoint: it requires parent constraints but does not carry both their frozen chain and its digest (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.";
93
93
  readonly "checkpoint.walltime_axis_retired|": "This engine cannot resume this checkpoint: its budget carries a wall-clock allocation, an axis this engine retired, so resuming here would run the work with that ceiling unenforced. The checkpoint stays pending. Expire it and start a fresh task bounded by tokens or budget.";
@@ -42,7 +42,7 @@ export const ROW_REFUSAL_SENTENCES = Object.freeze({
42
42
  "checkpoint.invalid_outcome|read_face_damaged": "This engine cannot resume this checkpoint: its read-face section is missing or malformed (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.",
43
43
  "checkpoint.invalid_outcome|write_face_damaged": "This engine cannot resume this checkpoint: its write-face section is malformed (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.",
44
44
  "checkpoint.invalid_outcome|skill_grants_damaged": "This engine cannot resume this checkpoint: its skill-grant section does not read as grant rows under this engine — damaged, or written by an earlier release whose entries this release reads differently. The checkpoint stays pending. Expire it and run the work again.",
45
- "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it and run the work again.",
45
+ "checkpoint.invalid_outcome|skill_scopes_damaged": "This engine cannot resume this checkpoint: its skill-scope section does not read as a list of named skills (a damaged section). The checkpoint stays pending. Expire it, then start the task again.",
46
46
  "checkpoint.invalid_outcome|hands_coordinates_damaged": "This engine cannot resume this checkpoint: one of its recorded workspace coordinates is not an absolute path (a corruption guard). The checkpoint stays pending. Expire it, then start the task again.",
47
47
  "checkpoint.invalid_outcome|constraint_chain_missing": "This engine cannot resume this checkpoint: it requires parent constraints but does not carry both their frozen chain and its digest (a corruption or downgrade guard). The checkpoint stays pending. Expire it, then start the task again.",
48
48
  "checkpoint.walltime_axis_retired|": "This engine cannot resume this checkpoint: its budget carries a wall-clock allocation, an axis this engine retired, so resuming here would run the work with that ceiling unenforced. The checkpoint stays pending. Expire it and start a fresh task bounded by tokens or budget.",
@@ -62,7 +62,7 @@ export const ROW_REFUSAL_TERMINAL = Object.freeze({
62
62
  "checkpoint.invalid_outcome|read_face_damaged": true,
63
63
  "checkpoint.invalid_outcome|write_face_damaged": true,
64
64
  "checkpoint.invalid_outcome|skill_grants_damaged": false,
65
- "checkpoint.invalid_outcome|skill_scopes_damaged": false,
65
+ "checkpoint.invalid_outcome|skill_scopes_damaged": true,
66
66
  "checkpoint.invalid_outcome|hands_coordinates_damaged": true,
67
67
  "checkpoint.invalid_outcome|constraint_chain_missing": true,
68
68
  "checkpoint.walltime_axis_retired|": false,
@@ -2260,6 +2260,8 @@ export interface CheckpointSummary {
2260
2260
  fromApprovalList?: true;
2261
2261
  /** The row's `PendingAction.tool_approval.mandate`, echoed ONLY as a member of the closed set. ECHO-ONLY. */
2262
2262
  mandate?: import("./ask-origin.js").PersistedRuleMandate;
2263
+ /** The parked ask's word for why its card offers no persisted rule (the row's pendingAction.ruleOffersAbsence), present only when that member is one of RULE_OFFERS_ABSENCES; any other value is left out, never echoed. */
2264
+ ruleOffersAbsence?: import("./ask-origin.js").RuleOffersAbsence;
2263
2265
  /** The row's `PendingAction.tool_approval.denialLimitFallback`, projected BESIDE the preview
2264
2266
  * for the same one-call reason: a card that shows the fallback's counts and limit must not re-open
2265
2267
  * the row to learn them (`autoDenyAfterMs` is `0` on every row — see the row member). Pure echo;
@@ -10,7 +10,7 @@ import { planReviewFactsOf } from "./plan-review-facts.js";
10
10
  import { carriesBidiControls } from "./tool-policy.js";
11
11
  import { agentIdOf, legTaskIdOf } from "./leg-identity.js";
12
12
  import { isAutoModeFallbackCause, readDenialLimitFallback } from "./auto-mode.js";
13
- import { isAskOrigin, isPersistedRuleMandate, receiveAskReasons } from "./ask-origin.js";
13
+ import { isAskOrigin, isPersistedRuleMandate, isRuleOffersAbsence, receiveAskReasons } from "./ask-origin.js";
14
14
  import { approvalMessageOf } from "./approval-display.js";
15
15
  import { isRunOrigin, RUN_ORIGINS } from "./run-origin.js";
16
16
  import { describeRejectedValue } from "./tool-search-setting.js";
@@ -401,7 +401,13 @@ function projectCheckpoint(cp, rowVerdict, disclose) {
401
401
  const origin = tool?.origin;
402
402
  const mandate = tool?.mandate;
403
403
  const why = tool?.classifierNoRuling;
404
- return { ...(isAskOrigin(origin) ? { origin } : {}), ...(isPersistedRuleMandate(mandate) ? { mandate } : {}), ...(isAutoModeFallbackCause(why) ? { classifierNoRuling: why } : {}) };
404
+ const absence = tool?.ruleOffersAbsence;
405
+ return {
406
+ ...(isAskOrigin(origin) ? { origin } : {}),
407
+ ...(isPersistedRuleMandate(mandate) ? { mandate } : {}),
408
+ ...(isAutoModeFallbackCause(why) ? { classifierNoRuling: why } : {}),
409
+ ...(isRuleOffersAbsence(absence) ? { ruleOffersAbsence: absence } : {}),
410
+ };
405
411
  })(),
406
412
  ...((askReasons) => (askReasons !== undefined ? { askReasons } : {}))(receiveAskReasons(tool?.askReasons)),
407
413
  ...((cardMessage) => (cardMessage !== undefined ? { cardMessage } : {}))(approvalMessageOf(tool?.cardMessage)),
@@ -18,7 +18,7 @@
18
18
  * A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`; `gate:closed-sets` holds the whole family to it: every family literal under
19
19
  * `src/` is a member, a notice word in a notice's `code`, or a ledgered non-word, and every member is still spelled somewhere.
20
20
  */
21
- export declare const CONFIG_REFUSAL_CODES: readonly ["config.a2a_inside_incomplete", "config.a2a_peer_name_collision", "config.advisor_model_invalid", "config.advisor_tool_invalid", "config.agent.duplicate", "config.agent.invalid", "config.agent.reserved_name", "config.agent.unknown_model", "config.agent.unknown_tool", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid", "config.agents.no_delegation_tool", "config.approval_reach_invalid", "config.attachment_invalid", "config.auto_consolidation", "config.auto_mode_classifier_fallback_invalid", "config.auto_mode_denial_limit_invalid", "config.auto_mode_rate_limit_break_invalid", "config.auto_mode_timeout_invalid", "config.brain_call_guardrail_invalid", "config.cascade_invalid", "config.circuit_breaker_invalid", "config.command_sandbox_unavailable", "config.compliance_denied", "config.compliance_posture", "config.compliance_required", "config.context_settings_unknown_word", "config.credential_in_declaration", "config.credential_ref_invalid", "config.cross_boundary_posture", "config.cwd_conflicts_restore", "config.cwd_not_honored", "config.cwd_outside_root", "config.cwd_unsupported", "config.defer_mode_invalid", "config.delegation_entry_caps", "config.deps_retired_key", "config.egress_requires_write_effect", "config.empty_objective", "config.env_lifetime_invalid", "config.execution_env_home_dir_invalid", "config.extra_body_output_cap", "config.extra_tool_names", "config.host_floor_invalid", "config.host_floor_refused", "config.image_invalid", "config.interaction_posture", "config.interaction_wiring", "config.invalid_argument", "config.invalid_checkpoint_store", "config.invalid_file_history_capture", "config.invalid_file_history_store", "config.invalid_governance_baseline", "config.invalid_on_track_failure", "config.invalid_output_schema", "config.invalid_permission_rules", "config.invalid_session_store", "config.invalid_task_registry", "config.invalid_tool_name_set", "config.language_invalid", "config.legacy_tool_name", "config.limit_invalid", "config.limit_unknown_key", "config.locked_key", "config.locked_registry", "config.mcp_content_class", "config.mcp_dialable_failed", "config.mcp_fingerprint_invalid", "config.mcp_first_request_wait_invalid", "config.mcp_host_seat_missing", "config.mcp_host_seat_undeclared", "config.mcp_pool_foreign_connection", "config.mcp_probe_option", "config.mcp_server_name_collision", "config.mcp_startup_timeout_invalid", "config.memory_capture_policy", "config.memory_capture_spelling", "config.memory_capture_unsupported", "config.memory_challenge_request", "config.memory_consolidation", "config.memory_consolidation_driver", "config.memory_consolidation_lease_required", "config.memory_consolidation_provenance_off", "config.memory_consolidation_replica_local", "config.memory_consolidation_write_gate", "config.memory_delegation_evidence", "config.memory_dir_not_backend_root", "config.memory_distiller_purity_contract", "config.memory_dual_root_overlap", "config.memory_erasure_request", "config.memory_erasure_scope", "config.memory_export_request", "config.memory_hold_timeout", "config.memory_import_request", "config.memory_persistence_invalid", "config.memory_project_identity", "config.memory_project_key_spelling", "config.memory_project_marker", "config.memory_project_marker_nested", "config.memory_provenance", "config.memory_reanchor", "config.memory_rebuild_reason", "config.memory_scope_key", "config.memory_scope_placement", "config.memory_scope_spelling", "config.memory_sync_cursor_mismatch", "config.memory_sync_store", "config.memory_sync_target_mismatch", "config.memory_write_scope_mismatch", "config.microcompact_invalid", "config.missing_scope", "config.model_fallback_invalid", "config.mods_invalid", "config.nothing_to_wake", "config.output_style_invalid", "config.parent_spec_seat_missing", "config.peer_answer_invalid", "config.peer_presence_invalid", "config.peer_seat_missing", "config.permission_mode_invalid", "config.persisted_rule_bucket_missing", "config.placement_not_honored", "config.placement_root_invalid", "config.plan_file_invalid", "config.principal_inbox_consumer_invalid", "config.project_id_invalid", "config.project_identity_mismatch", "config.prompt_selector_invalid", "config.prompt_trait_unknown", "config.protocol_endpoint_unbound", "config.protocol_header_collision", "config.protocol_plaintext_credentials", "config.read_deny_floor_unkept", "config.read_face_invalid", "config.read_face_org_task_escalation", "config.read_face_read_block_conflict", "config.read_face_readonly_conflict", "config.read_face_seat", "config.registry_scope_mismatch", "config.reserved_tool_name", "config.retention_capability", "config.retention_policy", "config.retention_policy_invalid", "config.run_origin_invalid", "config.safe_vars_reserved_name", "config.sandbox_admission_unavailable", "config.sandbox_settings_invalid", "config.session_box_floor_mismatch", "config.session_rules_unreadable", "config.session_workspace_changed", "config.session_workspace_invalid", "config.shell_gate_value_retired", "config.skill_base_dir_invalid", "config.skill_deny_unreadable", "config.skill_listing_budget_invalid", "config.spec_member_unreadable", "config.spec_retired_key", "config.spec_unknown_key", "config.stale_tool_result_offload_invalid", "config.stall_timeout_invalid", "config.stall_timeout_retired", "config.store_durability_invalid", "config.store_fidelity_invalid", "config.tool_contract_too_long", "config.tool_face_control", "config.tool_face_invalid", "config.tool_materialize_invalid", "config.tool_materialize_unreachable", "config.tool_model_gate_env_invalid", "config.tool_model_gate_invalid", "config.tool_mount_denied", "config.tool_name_invalid", "config.tool_name_too_long", "config.tool_roster_bound", "config.tool_roster_mount_tag", "config.tool_roster_origin", "config.tool_schema_bound", "config.tool_search_invalid", "config.toolpolicy.unmatched_names", "config.unknown_role", "config.usage_window_invalid", "config.usage_window_unpriced", "config.user_attachment_invalid", "config.user_invoked_skill_unknown", "config.verify_internals_invalid", "config.web_max_bytes_invalid", "config.web_search_max_results_invalid", "config.web_summary_max_content_invalid", "config.web_timeout_invalid", "config.write_exempt_dir_covers_root", "config.write_face_invalid", "config.write_face_org_task_escalation", "config.write_face_readonly_conflict", "resume_at.before_root_unsupported", "resume_at.before_target_not_user", "resume_at.conflicts_resume", "resume_at.empty_branch", "resume_at.invalid_mode", "resume_at.mode_without_target", "resume_at.no_session", "resume_at.not_found", "resume_at.open_tool_call", "resume_at.outside_window"];
21
+ export declare const CONFIG_REFUSAL_CODES: readonly ["config.a2a_inside_incomplete", "config.a2a_peer_name_collision", "config.advisor_model_invalid", "config.advisor_tool_invalid", "config.agent.duplicate", "config.agent.invalid", "config.agent.reserved_name", "config.agent.unknown_model", "config.agent.unknown_tool", "config.agent_config_dir_invalid", "config.agent_home_dir_invalid", "config.agents.no_delegation_tool", "config.approval_reach_invalid", "config.attachment_invalid", "config.auto_consolidation", "config.auto_mode_classifier_fallback_invalid", "config.auto_mode_denial_limit_invalid", "config.auto_mode_rate_limit_break_invalid", "config.auto_mode_timeout_invalid", "config.brain_call_guardrail_invalid", "config.cascade_invalid", "config.circuit_breaker_invalid", "config.command_sandbox_unavailable", "config.compliance_denied", "config.compliance_posture", "config.compliance_required", "config.context_settings_unknown_word", "config.credential_in_declaration", "config.credential_ref_invalid", "config.cross_boundary_posture", "config.cwd_conflicts_restore", "config.cwd_not_honored", "config.cwd_outside_root", "config.cwd_unsupported", "config.defer_mode_invalid", "config.delegation_entry_caps", "config.deployment_shape", "config.deps_retired_key", "config.egress_requires_write_effect", "config.empty_objective", "config.env_lifetime_invalid", "config.execution_env_home_dir_invalid", "config.extra_body_output_cap", "config.extra_tool_names", "config.host_floor_invalid", "config.host_floor_refused", "config.image_invalid", "config.interaction_posture", "config.interaction_wiring", "config.invalid_argument", "config.invalid_checkpoint_store", "config.invalid_file_history_capture", "config.invalid_file_history_store", "config.invalid_governance_baseline", "config.invalid_on_track_failure", "config.invalid_output_schema", "config.invalid_permission_rules", "config.invalid_session_store", "config.invalid_task_registry", "config.invalid_tool_name_set", "config.language_invalid", "config.legacy_tool_name", "config.limit_invalid", "config.limit_unknown_key", "config.locked_key", "config.locked_registry", "config.mcp_content_class", "config.mcp_dialable_failed", "config.mcp_fingerprint_invalid", "config.mcp_first_request_wait_invalid", "config.mcp_host_seat_missing", "config.mcp_host_seat_undeclared", "config.mcp_pool_foreign_connection", "config.mcp_probe_option", "config.mcp_server_name_collision", "config.mcp_startup_timeout_invalid", "config.memory_capture_policy", "config.memory_capture_spelling", "config.memory_capture_unsupported", "config.memory_challenge_request", "config.memory_consolidation", "config.memory_consolidation_driver", "config.memory_consolidation_lease_required", "config.memory_consolidation_provenance_off", "config.memory_consolidation_replica_local", "config.memory_consolidation_write_gate", "config.memory_delegation_evidence", "config.memory_dir_not_backend_root", "config.memory_distiller_purity_contract", "config.memory_dual_root_overlap", "config.memory_erasure_request", "config.memory_erasure_scope", "config.memory_export_request", "config.memory_hold_timeout", "config.memory_import_request", "config.memory_persistence_invalid", "config.memory_project_identity", "config.memory_project_key_spelling", "config.memory_project_marker", "config.memory_project_marker_nested", "config.memory_provenance", "config.memory_reanchor", "config.memory_rebuild_reason", "config.memory_scope_key", "config.memory_scope_placement", "config.memory_scope_spelling", "config.memory_sync_cursor_mismatch", "config.memory_sync_store", "config.memory_sync_target_mismatch", "config.memory_write_scope_mismatch", "config.microcompact_invalid", "config.missing_scope", "config.model_fallback_invalid", "config.mods_invalid", "config.nothing_to_wake", "config.output_style_invalid", "config.parent_spec_seat_missing", "config.peer_answer_invalid", "config.peer_presence_invalid", "config.peer_seat_missing", "config.permission_mode_invalid", "config.persisted_rule_bucket_missing", "config.placement_not_honored", "config.placement_root_invalid", "config.plan_file_invalid", "config.principal_inbox_consumer_invalid", "config.project_id_invalid", "config.project_identity_mismatch", "config.prompt_selector_invalid", "config.prompt_trait_unknown", "config.protocol_endpoint_unbound", "config.protocol_header_collision", "config.protocol_plaintext_credentials", "config.read_deny_floor_unkept", "config.read_face_invalid", "config.read_face_org_task_escalation", "config.read_face_read_block_conflict", "config.read_face_readonly_conflict", "config.read_face_seat", "config.registry_scope_mismatch", "config.reserved_tool_name", "config.retention_capability", "config.retention_policy", "config.retention_policy_invalid", "config.run_origin_invalid", "config.safe_vars_reserved_name", "config.sandbox_admission_unavailable", "config.sandbox_settings_invalid", "config.session_box_floor_mismatch", "config.session_rules_unreadable", "config.session_workspace_changed", "config.session_workspace_invalid", "config.shell_gate_value_retired", "config.skill_base_dir_invalid", "config.skill_deny_unreadable", "config.skill_listing_budget_invalid", "config.spec_member_unreadable", "config.spec_retired_key", "config.spec_unknown_key", "config.stale_tool_result_offload_invalid", "config.stall_timeout_invalid", "config.stall_timeout_retired", "config.store_durability_invalid", "config.store_fidelity_invalid", "config.tool_contract_too_long", "config.tool_face_control", "config.tool_face_invalid", "config.tool_materialize_invalid", "config.tool_materialize_unreachable", "config.tool_model_gate_env_invalid", "config.tool_model_gate_invalid", "config.tool_mount_denied", "config.tool_name_invalid", "config.tool_name_too_long", "config.tool_roster_bound", "config.tool_roster_mount_tag", "config.tool_roster_origin", "config.tool_schema_bound", "config.tool_search_invalid", "config.toolpolicy.unmatched_names", "config.unknown_role", "config.usage_window_invalid", "config.usage_window_unpriced", "config.user_attachment_invalid", "config.user_invoked_skill_unknown", "config.verify_internals_invalid", "config.web_max_bytes_invalid", "config.web_search_max_results_invalid", "config.web_summary_max_content_invalid", "config.web_timeout_invalid", "config.write_exempt_dir_covers_root", "config.write_face_invalid", "config.write_face_org_task_escalation", "config.write_face_readonly_conflict", "resume_at.before_root_unsupported", "resume_at.before_target_not_user", "resume_at.conflicts_resume", "resume_at.empty_branch", "resume_at.invalid_mode", "resume_at.mode_without_target", "resume_at.no_session", "resume_at.not_found", "resume_at.open_tool_call", "resume_at.outside_window"];
22
22
  export type ConfigRefusalCode = (typeof CONFIG_REFUSAL_CODES)[number];
23
23
  /**
24
24
  * The CLASS of every `resume_at.*` word the ENGINE throws, declared beside the words — so a client that must decide "is the request still
@@ -35,6 +35,7 @@ export const CONFIG_REFUSAL_CODES = Object.freeze([
35
35
  "config.cwd_unsupported",
36
36
  "config.defer_mode_invalid",
37
37
  "config.delegation_entry_caps",
38
+ "config.deployment_shape",
38
39
  "config.deps_retired_key",
39
40
  "config.egress_requires_write_effect",
40
41
  "config.empty_objective",
package/dist/core/cron.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { SchedulerError } from "./scheduler.js";
2
+ import { foldToOneLine, inlineUntrusted } from "./untrusted-text.js";
2
3
  const MAX_EXPR_LENGTH = 100;
3
4
  const CRON_ALPHABET = /^[0-9*/,\-\s]+$/;
4
5
  export const CRON_FIELD_SEPARATOR = /\s+/;
@@ -47,8 +48,15 @@ function expandCronField(field, { min, max }) {
47
48
  }
48
49
  return out.size > 0 ? [...out] : null;
49
50
  }
51
+ function foldedAwayClause(text) {
52
+ const parts = [
53
+ ...(foldToOneLine(text) !== text.trim().replace(/ +/g, " ") ? ["control or non-printing characters, shown folded"] : []),
54
+ ...(/^\s|\s$/u.test(text) ? ["white space at its start or end"] : []),
55
+ ];
56
+ return parts.length === 0 ? "" : ` (the text given holds ${parts.join(", and ")})`;
57
+ }
50
58
  function quoted(expr) {
51
- return expr.length <= MAX_EXPR_LENGTH ? JSON.stringify(expr) : `(${expr.length} characters)`;
59
+ return expr.length <= MAX_EXPR_LENGTH ? `${JSON.stringify(inlineUntrusted(expr, MAX_EXPR_LENGTH))}${foldedAwayClause(expr)}` : `(${expr.length} characters)`;
52
60
  }
53
61
  function parseCron(expr) {
54
62
  if (typeof expr !== "string")
@@ -0,0 +1,7 @@
1
+ /** The words of `RunnerDeps.deploymentShape`. A CLOSED SET with one home, registered in `docs/CLOSED-SETS.md`. */
2
+ export declare const DEPLOYMENT_SHAPES: readonly ["isolated_sandbox", "own_device", "single_user_host"];
3
+ export type DeploymentShape = (typeof DEPLOYMENT_SHAPES)[number];
4
+ /** The seat's door, at `new Runner` (the seat is fixed there — `swapDeps` does not carry it): absent, or one of the words beside a
5
+ * posture that is not `multi_tenant`. A word outside the set, or a shape beside `crossBoundaryPosture: "multi_tenant"` (a
6
+ * deployment that says it serves several tenants is not confined), is refused by name (`config.deployment_shape`, about `deps`). */
7
+ export declare function screenDeploymentShape(shape: unknown, crossBoundaryPosture: unknown): DeploymentShape | undefined;
@@ -0,0 +1,19 @@
1
+ import { stampConfigInput } from "./config-refusal-input.js";
2
+ import { describeRejectedValue } from "./tool-search-setting.js";
3
+ export const DEPLOYMENT_SHAPES = Object.freeze(["isolated_sandbox", "own_device", "single_user_host"]);
4
+ export function screenDeploymentShape(shape, crossBoundaryPosture) {
5
+ if (shape === undefined)
6
+ return undefined;
7
+ const word = DEPLOYMENT_SHAPES.find((w) => w === shape);
8
+ const why = word === undefined
9
+ ? `RunnerDeps.deploymentShape must be ${DEPLOYMENT_SHAPES.map((w) => `"${w}"`).join(", ")} when present (got ${describeRejectedValue(shape)}) — an unreadable shape is refused, never read as any shape or as none`
10
+ : crossBoundaryPosture === "multi_tenant"
11
+ ? `RunnerDeps.deploymentShape "${word}" contradicts RunnerDeps.crossBoundaryPosture "multi_tenant" — a shape is declared only by a deployment with one owner; drop one of the two`
12
+ : undefined;
13
+ if (why === undefined)
14
+ return word;
15
+ const e = new Error(`${why} (refused at new Runner)`);
16
+ e.code = "config.deployment_shape";
17
+ stampConfigInput(e, "deps");
18
+ throw e;
19
+ }
@@ -212,7 +212,15 @@
212
212
  * (lane-discovered and host-text withholds, with `blockedAfterApproval` on `outside_its_root` when Read admission still refuses after
213
213
  * approval), and `Runner.previewInstructions(spec)` returns that identical object before any turn with no model call, session/read-state
214
214
  * write, checkpoint, or notice (coded refusal on invalid specs). A host that prompts for external includes before Turn 1 gates on the word.
215
+ * - `brain.anthropic_oauth_bearer` — the Anthropic adapter gives a qualifying Bearer the header its protocol requires: a credential
216
+ * whose value opens with `sk-ant-oat` rides as `Authorization: Bearer <value>` from the key seat while no header bag filled that
217
+ * header (a bag's own `Authorization` stays the host's, the key then keeps `x-api-key`) or from an `Authorization` header itself,
218
+ * and a request whose one `Authorization` header is such a Bearer carries `oauth-2025-04-20` in its `anthropic-beta` list; no
219
+ * header that states a client identity is added, and a refusal is the run's terminal as the provider stated it (`auth` /
220
+ * `rate_limit` / `invalid_request` with `provider_rejected`; re-sent only as any request is). The word says the
221
+ * request's shape only: whether the endpoint accepts the credential, and whether the account may use it, it does not answer. A
222
+ * shell may offer "a subscription token can be entered" on it, never "it works".
215
223
  */
216
- export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"];
224
+ export declare const ENGINE_CAPABILITIES: readonly ["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under", "brain.anthropic_oauth_bearer"];
217
225
  /** One word of {@link ENGINE_CAPABILITIES}. */
218
226
  export type EngineCapability = (typeof ENGINE_CAPABILITIES)[number];
@@ -1 +1 @@
1
- export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under"]);
1
+ export const ENGINE_CAPABILITIES = Object.freeze(["inherit_env.own_credentials_withheld", "inherit_env.own_credential_values_withheld", "mods.skill_seat", "user_attachments.read_state", "task.wake", "file_history.recorded_place", "ask.workflow_member", "task.fast_mode", "user_attachments.instruction_access", "task_notification.note_key", "task.continues_from", "execution_env.workspace_sync", "session.rewind_conversation", "instruction_family.external_includes", "instruction_family.host_text", "instruction_family.local_files", "instruction_family.preview", "session_changes.checkpoints", "session_changes.git", "task.agent_config_dirs", "task.agent_home_dirs", "artifact_host.libraries", "file_history.unplaced_recorded_under", "brain.anthropic_oauth_bearer"]);