@sema-agent/core 7.69.0 → 7.69.1

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 (309) hide show
  1. package/CHANGELOG.md +583 -0
  2. package/dist/agents/repair-loop.js +6 -14
  3. package/dist/agents/subagent.js +2 -1
  4. package/dist/agents/verify.d.ts +1 -1
  5. package/dist/agents/verify.js +7 -1
  6. package/dist/brain/reasoning-request.d.ts +7 -0
  7. package/dist/brain/reasoning-request.js +6 -0
  8. package/dist/core/agent-config-dir.d.ts +39 -3
  9. package/dist/core/agent-config-dir.js +67 -11
  10. package/dist/core/allow-entry.d.ts +5 -5
  11. package/dist/core/allow-entry.js +12 -6
  12. package/dist/core/ask-headline.d.ts +2 -2
  13. package/dist/core/ask-origin.d.ts +31 -31
  14. package/dist/core/ask-origin.js +20 -13
  15. package/dist/core/attachment-source.d.ts +1 -1
  16. package/dist/core/attachment-source.js +1 -0
  17. package/dist/core/auto-compaction.d.ts +44 -62
  18. package/dist/core/auto-compaction.js +44 -103
  19. package/dist/core/cache-break-detector.d.ts +23 -11
  20. package/dist/core/cache-break-detector.js +11 -5
  21. package/dist/core/checkpoint-features.d.ts +1 -1
  22. package/dist/core/checkpoint-features.js +1 -1
  23. package/dist/core/checkpoint-requirements.d.ts +19 -1
  24. package/dist/core/checkpoint-requirements.js +6 -0
  25. package/dist/core/checkpoint-row-verdict.js +3 -0
  26. package/dist/core/checkpoint-store.d.ts +13 -2
  27. package/dist/core/child-clamp-seats.d.ts +30 -3
  28. package/dist/core/child-clamp-seats.js +24 -0
  29. package/dist/core/compaction-retired-members.d.ts +12 -0
  30. package/dist/core/compaction-retired-members.js +22 -0
  31. package/dist/core/config-refusal-codes.d.ts +1 -1
  32. package/dist/core/config-refusal-codes.js +2 -0
  33. package/dist/core/context-edit.d.ts +32 -17
  34. package/dist/core/context-edit.js +28 -0
  35. package/dist/core/cron.d.ts +68 -0
  36. package/dist/core/cron.js +259 -0
  37. package/dist/core/engine-attestation.d.ts +16 -0
  38. package/dist/core/engine-attestation.js +2 -0
  39. package/dist/core/engine-capabilities.d.ts +14 -1
  40. package/dist/core/engine-capabilities.js +1 -1
  41. package/dist/core/engine-notice.d.ts +18 -7
  42. package/dist/core/engine-version.js +1 -1
  43. package/dist/core/gate-outcome.d.ts +29 -2
  44. package/dist/core/gate-outcome.js +6 -0
  45. package/dist/core/git-read-only.d.ts +10 -0
  46. package/dist/core/git-read-only.js +1 -0
  47. package/dist/core/git-worktree-env.js +9 -8
  48. package/dist/core/governance-codes.d.ts +9 -2
  49. package/dist/core/governance-codes.js +9 -0
  50. package/dist/core/locked-config.js +7 -3
  51. package/dist/core/lsp.d.ts +3 -0
  52. package/dist/core/lsp.js +3 -2
  53. package/dist/core/memory-engine/engine.d.ts +48 -12
  54. package/dist/core/memory-engine/engine.js +108 -46
  55. package/dist/core/memory-engine/file-backend.d.ts +2 -1
  56. package/dist/core/memory-engine/index-copies.d.ts +47 -0
  57. package/dist/core/memory-engine/index-copies.js +88 -0
  58. package/dist/core/memory-engine/layout.d.ts +20 -3
  59. package/dist/core/memory-engine/layout.js +39 -3
  60. package/dist/core/memory-engine/origin-clearance.d.ts +9 -7
  61. package/dist/core/memory-engine/origin-clearance.js +2 -4
  62. package/dist/core/memory-engine/types.d.ts +16 -3
  63. package/dist/core/mode-policy.d.ts +7 -1
  64. package/dist/core/mode-policy.js +9 -0
  65. package/dist/core/mods/session-compact.js +3 -3
  66. package/dist/core/mods/stations.d.ts +2 -0
  67. package/dist/core/mods/stations.js +2 -1
  68. package/dist/core/path-guard-rows.d.ts +8 -3
  69. package/dist/core/path-guard-rows.js +18 -5
  70. package/dist/core/peer-seat.d.ts +3 -0
  71. package/dist/core/peer-seat.js +3 -0
  72. package/dist/core/permission-rule-model.js +3 -2
  73. package/dist/core/process-identity.d.ts +11 -3
  74. package/dist/core/process-identity.js +26 -16
  75. package/dist/core/runner/assemble-result.d.ts +5 -0
  76. package/dist/core/runner/assemble-result.js +1 -1
  77. package/dist/core/runner/cleared-results-record.d.ts +33 -0
  78. package/dist/core/runner/cleared-results-record.js +56 -0
  79. package/dist/core/runner/compact-session.js +14 -9
  80. package/dist/core/runner/compaction-knobs.d.ts +1 -1
  81. package/dist/core/runner/continuation-gate.js +2 -1
  82. package/dist/core/runner/continues-from.d.ts +1 -1
  83. package/dist/core/runner/continues-from.js +1 -1
  84. package/dist/core/runner/contracts.d.ts +83 -31
  85. package/dist/core/runner/conversation-segment.d.ts +19 -12
  86. package/dist/core/runner/conversation-segment.js +27 -7
  87. package/dist/core/runner/derived-route-fallback.d.ts +2 -12
  88. package/dist/core/runner/derived-route-fallback.js +0 -6
  89. package/dist/core/runner/gate-exit.d.ts +2 -1
  90. package/dist/core/runner/gate-exit.js +4 -2
  91. package/dist/core/runner/git-status-frame.d.ts +2 -2
  92. package/dist/core/runner/git-status-frame.js +2 -1
  93. package/dist/core/runner/initial-run-state.js +1 -1
  94. package/dist/core/runner/leg-caller-places.d.ts +39 -0
  95. package/dist/core/runner/leg-caller-places.js +23 -0
  96. package/dist/core/runner/leg-frame.d.ts +8 -2
  97. package/dist/core/runner/leg-receipt.d.ts +29 -2
  98. package/dist/core/runner/leg-receipt.js +37 -6
  99. package/dist/core/runner/media-removed-seat.d.ts +10 -6
  100. package/dist/core/runner/media-removed-seat.js +6 -3
  101. package/dist/core/runner/messages-omitted-seat.d.ts +2 -1
  102. package/dist/core/runner/messages-omitted-seat.js +15 -5
  103. package/dist/core/runner/person-path-rows.d.ts +25 -7
  104. package/dist/core/runner/person-path-rows.js +16 -2
  105. package/dist/core/runner/prefix-ledger.d.ts +120 -0
  106. package/dist/core/runner/prefix-ledger.js +176 -0
  107. package/dist/core/runner/prepare-advisor.d.ts +2 -0
  108. package/dist/core/runner/prepare-advisor.js +2 -1
  109. package/dist/core/runner/prepare-artifact.d.ts +3 -0
  110. package/dist/core/runner/prepare-artifact.js +2 -2
  111. package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
  112. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  113. package/dist/core/runner/prepare-config-doors.d.ts +9 -8
  114. package/dist/core/runner/prepare-config-doors.js +15 -12
  115. package/dist/core/runner/prepare-context-lane.d.ts +25 -6
  116. package/dist/core/runner/prepare-context-lane.js +82 -27
  117. package/dist/core/runner/prepare-gate-stations.d.ts +1 -2
  118. package/dist/core/runner/prepare-gate-stations.js +2 -4
  119. package/dist/core/runner/prepare-hands-readface.d.ts +18 -5
  120. package/dist/core/runner/prepare-hands-readface.js +41 -22
  121. package/dist/core/runner/prepare-inherited-gate.d.ts +5 -0
  122. package/dist/core/runner/prepare-inherited-gate.js +2 -0
  123. package/dist/core/runner/prepare-memory.d.ts +10 -2
  124. package/dist/core/runner/prepare-memory.js +51 -5
  125. package/dist/core/runner/prepare-policy-chain.d.ts +3 -0
  126. package/dist/core/runner/prepare-policy-chain.js +13 -2
  127. package/dist/core/runner/prepare-prompt-assembly.d.ts +12 -4
  128. package/dist/core/runner/prepare-prompt-assembly.js +10 -4
  129. package/dist/core/runner/prepare-prompt-inputs.d.ts +3 -7
  130. package/dist/core/runner/prepare-prompt-inputs.js +6 -7
  131. package/dist/core/runner/prepare-safety-scan.js +7 -0
  132. package/dist/core/runner/prepare-suspend-saga.d.ts +4 -0
  133. package/dist/core/runner/prepare-suspend-saga.js +3 -2
  134. package/dist/core/runner/prepare-task.js +59 -53
  135. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +5 -11
  136. package/dist/core/runner/prepare-tool-disclosure-mount.js +7 -8
  137. package/dist/core/runner/prepare-turn-wiring.d.ts +16 -25
  138. package/dist/core/runner/prepare-turn-wiring.js +8 -18
  139. package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
  140. package/dist/core/runner/prepare-wiring-manifest.js +3 -2
  141. package/dist/core/runner/prompt-suggestions.d.ts +3 -1
  142. package/dist/core/runner/prompt-suggestions.js +1 -1
  143. package/dist/core/runner/read-block-judge.d.ts +47 -0
  144. package/dist/core/runner/read-block-judge.js +33 -0
  145. package/dist/core/runner/role-resolution-table.d.ts +15 -10
  146. package/dist/core/runner/role-resolution-table.js +4 -5
  147. package/dist/core/runner/rule-store-unreadable-notice.d.ts +7 -4
  148. package/dist/core/runner/rule-store-unreadable-notice.js +4 -3
  149. package/dist/core/runner/run-compaction-machinery.d.ts +0 -10
  150. package/dist/core/runner/run-compaction-machinery.js +3 -39
  151. package/dist/core/runner/run-harness-handlers.js +4 -17
  152. package/dist/core/runner/run-identity-wiring.js +4 -1
  153. package/dist/core/runner/run-leg.js +11 -1
  154. package/dist/core/runner/run-recovery-lanes.d.ts +0 -4
  155. package/dist/core/runner/run-recovery-lanes.js +34 -18
  156. package/dist/core/runner/run-settle-and-teardown.d.ts +1 -3
  157. package/dist/core/runner/run-settle-and-teardown.js +14 -22
  158. package/dist/core/runner/run-telemetry-and-budget-seats.js +0 -1
  159. package/dist/core/runner/run-terminal-adoption.d.ts +11 -30
  160. package/dist/core/runner/run-terminal-adoption.js +5 -88
  161. package/dist/core/runner/run-tool-mount-facts.js +1 -5
  162. package/dist/core/runner/run-turn-boundary.js +56 -26
  163. package/dist/core/runner/runtask.js +7 -7
  164. package/dist/core/runner/session-hash-salt.d.ts +18 -0
  165. package/dist/core/runner/session-hash-salt.js +36 -0
  166. package/dist/core/runner/shell-env-withheld.d.ts +8 -5
  167. package/dist/core/runner/shell-env-withheld.js +3 -3
  168. package/dist/core/runner/side-call-account.d.ts +9 -1
  169. package/dist/core/runner/side-call-account.js +15 -4
  170. package/dist/core/runner/skill-mention.d.ts +12 -0
  171. package/dist/core/runner/skill-mention.js +50 -0
  172. package/dist/core/runner/stream-settle-backstop.js +1 -0
  173. package/dist/core/runner/synthetic-tools.js +2 -2
  174. package/dist/core/runner/tool-table-view.d.ts +5 -9
  175. package/dist/core/runner/tool-table-view.js +23 -21
  176. package/dist/core/runner/write-protection-station.d.ts +5 -2
  177. package/dist/core/runner/write-protection-station.js +1 -1
  178. package/dist/core/runner-deps.d.ts +25 -27
  179. package/dist/core/scheduler.d.ts +13 -3
  180. package/dist/core/scheduler.js +0 -12
  181. package/dist/core/secret-env.d.ts +47 -11
  182. package/dist/core/secret-env.js +65 -4
  183. package/dist/core/sensitive-path-policy.js +4 -0
  184. package/dist/core/session-checkout.js +10 -9
  185. package/dist/core/shell-read-silence.d.ts +2 -1
  186. package/dist/core/shell-run-candidates.d.ts +1 -1
  187. package/dist/core/shell-run-candidates.js +11 -3
  188. package/dist/core/task-event.d.ts +32 -10
  189. package/dist/core/task-intake.d.ts +5 -3
  190. package/dist/core/task-intake.js +6 -2
  191. package/dist/core/task-result.d.ts +39 -0
  192. package/dist/core/task-spec-members.d.ts +3 -0
  193. package/dist/core/task-spec-members.js +2 -2
  194. package/dist/core/task-spec.d.ts +37 -20
  195. package/dist/core/tool-policy.d.ts +30 -18
  196. package/dist/core/tool-policy.js +44 -32
  197. package/dist/core/tool-roster.d.ts +21 -7
  198. package/dist/core/tool-roster.js +34 -6
  199. package/dist/core/tool-spec-members.js +1 -1
  200. package/dist/core/tool-spec.d.ts +27 -0
  201. package/dist/core/tools.js +1 -0
  202. package/dist/core/trace.d.ts +42 -19
  203. package/dist/core/unc-spelling.d.ts +31 -0
  204. package/dist/core/unc-spelling.js +51 -0
  205. package/dist/core/wiring-manifest.d.ts +30 -3
  206. package/dist/core/wiring-manifest.js +10 -0
  207. package/dist/core/workflow-run-store-contract.js +22 -0
  208. package/dist/core/workflow-run-store.d.ts +17 -13
  209. package/dist/core/workflow-run-store.js +1 -1
  210. package/dist/core/write-protect.d.ts +4 -0
  211. package/dist/core/write-protect.js +17 -15
  212. package/dist/engine/compaction/compaction.d.ts +48 -98
  213. package/dist/engine/compaction/compaction.js +136 -216
  214. package/dist/engine/compaction/utils.d.ts +2 -11
  215. package/dist/engine/compaction/utils.js +4 -13
  216. package/dist/engine/execution-env/node-execution-env.js +17 -6
  217. package/dist/engine/harness/agent-harness.d.ts +19 -5
  218. package/dist/engine/harness/agent-harness.js +18 -7
  219. package/dist/engine/harness/types.d.ts +5 -7
  220. package/dist/engine/loop/agent-loop.d.ts +14 -1
  221. package/dist/engine/loop/agent-loop.js +31 -11
  222. package/dist/engine/loop/types.d.ts +8 -2
  223. package/dist/index.d.ts +9 -6
  224. package/dist/index.js +8 -6
  225. package/dist/internal/harness-types.d.ts +1 -1
  226. package/dist/internal/harness.d.ts +1 -1
  227. package/dist/internal/harness.js +1 -1
  228. package/dist/orchestration/run-spec.js +7 -2
  229. package/dist/orchestration/run-workflow-tool.js +5 -3
  230. package/dist/orchestration/workflow-park-adoption.d.ts +66 -8
  231. package/dist/orchestration/workflow-park-adoption.js +195 -45
  232. package/dist/orchestration/workflow-types.d.ts +20 -0
  233. package/dist/orchestration/workflow-types.js +1 -0
  234. package/dist/orchestration/workflow.d.ts +3 -2
  235. package/dist/orchestration/workflow.js +10 -4
  236. package/dist/prompt-assembly/catalog/core-behavior.js +6 -0
  237. package/dist/prompt-assembly/catalog/events.d.ts +8 -0
  238. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +6 -0
  239. package/dist/prompt-assembly/catalog/locales/zh-Hans/mechanism.js +1 -0
  240. package/dist/prompt-assembly/catalog/mechanism.d.ts +8 -0
  241. package/dist/prompt-assembly/catalog/mechanism.js +1 -0
  242. package/dist/prompt-assembly/catalog/schema.d.ts +1 -1
  243. package/dist/prompt-assembly/catalog/schema.js +1 -0
  244. package/dist/prompt-assembly/catalog/sections.js +8 -0
  245. package/dist/prompt-assembly/event-registry.js +1 -0
  246. package/dist/prompt-assembly/select.js +1 -0
  247. package/dist/prompt-assembly/turn-snapshot.d.ts +14 -27
  248. package/dist/prompt-assembly/turn-snapshot.js +6 -18
  249. package/dist/prompt-assembly/types.d.ts +3 -0
  250. package/dist/prompts/default.d.ts +9 -0
  251. package/dist/prompts/default.js +4 -0
  252. package/dist/shell/lex.d.ts +75 -11
  253. package/dist/shell/lex.js +340 -76
  254. package/dist/tools/fs/bash-program-position.js +2 -6
  255. package/dist/tools/fs/bash-readonly-classifier.d.ts +18 -3
  256. package/dist/tools/fs/bash-readonly-classifier.js +19 -9
  257. package/dist/tools/fs/containment-face.d.ts +12 -3
  258. package/dist/tools/fs/containment-face.js +16 -7
  259. package/dist/tools/fs/file-read-check.d.ts +26 -1
  260. package/dist/tools/fs/file-read-check.js +20 -2
  261. package/dist/tools/fs/fs-bash.js +4 -4
  262. package/dist/tools/fs/fs-read.d.ts +3 -0
  263. package/dist/tools/fs/fs-read.js +2 -2
  264. package/dist/tools/fs/fs-search-tools.d.ts +2 -2
  265. package/dist/tools/fs/fs-search-tools.js +4 -4
  266. package/dist/tools/fs/index.js +5 -3
  267. package/dist/tools/fs/pdf.js +12 -4
  268. package/dist/tools/fs/read-deny-home.d.ts +13 -2
  269. package/dist/tools/fs/read-deny-home.js +26 -22
  270. package/dist/tools/fs/read-deny.js +15 -6
  271. package/dist/tools/fs/removal-targets.d.ts +33 -17
  272. package/dist/tools/fs/removal-targets.js +160 -61
  273. package/dist/tools/fs/repo-map.d.ts +1 -1
  274. package/dist/tools/fs/repo-map.js +2 -2
  275. package/dist/tools/fs/safety.d.ts +28 -5
  276. package/dist/tools/fs/safety.js +72 -8
  277. package/dist/tools/fs/shell-read-bindings.d.ts +8 -2
  278. package/dist/tools/fs/shell-read-bindings.js +25 -6
  279. package/dist/tools/fs/shell-read-check.d.ts +3 -0
  280. package/dist/tools/fs/shell-read-check.js +22 -4
  281. package/dist/tools/fs/shell-read-establish.js +73 -43
  282. package/dist/tools/fs/shell-read-judge.d.ts +32 -14
  283. package/dist/tools/fs/shell-read-judge.js +13 -5
  284. package/dist/tools/fs/shell-read-object-path.d.ts +5 -1
  285. package/dist/tools/fs/shell-read-object-path.js +17 -4
  286. package/dist/tools/fs/shell-read-plan.d.ts +8 -2
  287. package/dist/tools/fs/shell-read-plan.js +36 -22
  288. package/dist/tools/fs/shell-read-sourced.js +12 -4
  289. package/dist/tools/fs/shell-read-start.d.ts +4 -2
  290. package/dist/tools/fs/shell-read-start.js +3 -3
  291. package/dist/tools/fs/shell-read-workdir.d.ts +14 -6
  292. package/dist/tools/fs/shell-read-workdir.js +35 -17
  293. package/dist/tools/scheduler-tools.d.ts +7 -17
  294. package/dist/tools/scheduler-tools.js +9 -85
  295. package/dist/tools/worktree.js +5 -4
  296. package/package.json +3 -2
  297. package/test/export-surface.snapshot.json +47 -1
  298. package/wire-changes/core-stores-sql@7.68.6.json +39 -0
  299. package/wire-changes/core-stores-sql@7.69.1.json +39 -0
  300. package/wire-changes/core@7.68.6.json +125 -0
  301. package/wire-changes/core@7.69.1.json +2561 -0
  302. package/wire-changes/mods-kernel@7.68.6.json +39 -0
  303. package/wire-changes/mods-kernel@7.69.1.json +39 -0
  304. package/wire-changes/primitives@7.68.6.json +39 -0
  305. package/wire-changes/primitives@7.69.1.json +39 -0
  306. package/wire-changes/wiki-gate@7.68.6.json +39 -0
  307. package/wire-changes/wiki-gate@7.69.1.json +39 -0
  308. package/dist/core/runner/prompt-hash-salt.d.ts +0 -1
  309. package/dist/core/runner/prompt-hash-salt.js +0 -2
@@ -409,7 +409,10 @@ export declare function isPathShapedToken(tok: string): boolean;
409
409
  * non-canonical spelling that resolves back inside is no longer refused). Two residuals stay here by
410
410
  * construction, and belong to the caller rather than to this function: the compound/approval-gate face
411
411
  * has no filesystem and stays lexical, and a REMOTE env keeps the lexical behaviour (its
412
- * `canonicalPath` is an RPC per candidate). */
412
+ * `canonicalPath` is an RPC per candidate).
413
+ *
414
+ * The place a word puts the command — a base it stands in, a directory it is proven to be — is never a stand-in
415
+ * ({@link OperandSpellings.standIn}): a stand-in is where the word MAY lead, unresolvable here. */
413
416
  export declare function resolveOperandLexically(base: string | undefined, operand: string, homeDir: string | undefined): string | undefined;
414
417
  /** One operand's two absolute spellings. `folded` has its `..` collapsed in the TEXT and is the
415
418
  * containment answer — every root comparison, deny judgment and verdict field here is built from it.
@@ -421,14 +424,26 @@ export interface OperandSpellings {
421
424
  folded: string;
422
425
  /** The uncollapsed absolute path, when the operand traverses `..`. */
423
426
  spelled?: string;
427
+ /** The word as written is a device spelling the tree's namespace screen refuses, and these spellings are the drive path it
428
+ * names ({@link localDriveSpellingOf}): a STAND-IN — where the word MAY lead, read only where a reading tightens: the deny
429
+ * views of the word itself (whose own question stands beside whatever the stand-in meets) and the deny floor of a walk that
430
+ * lost track at it. It is never a place the command is proven to stand in (a base after `cd`, a launcher's directory). */
431
+ standIn?: true;
424
432
  }
433
+ /** Does a spelling open with a tilde-prefix bash answers from the ACCOUNT DATABASE — `~user`, `~user/…` (that account's home
434
+ * directory; a name no account answers stays as written) — rather than from the shell's own state: the bare `~` and `~/…` (the
435
+ * home), `~+` / `~-` (`PWD` / `OLDPWD`), `~N` / `~+N` / `~-N` (the directory stack)? Where such a word leads only the environment
436
+ * answers; the text holds the whole word. Read on a candidate's spelling, where a quoted tilde is already spelled `./~`. */
437
+ export declare function tildeNamesAnAccount(spelled: string): boolean;
425
438
  /** Resolve one operand into {@link OperandSpellings}, or `undefined` on the same unresolvable operands
426
439
  * {@link resolveOperandLexically} reports (it is this function's folded half). */
427
440
  export declare function resolveOperandSpellings(base: string | undefined, operand: string, homeDir: string | undefined): OperandSpellings | undefined;
428
441
  /**
429
442
  * Does the shell REWRITE this word before the program sees it — a brace list, a parameter, command, process or
430
- * arithmetic expansion, or a `$` / backtick / brace character where bash reads it (unquoted; `$` and a backtick
431
- * also inside double quotes)? Read off the lexer's pieces. Brace expansion runs BEFORE tilde expansion and
443
+ * arithmetic expansion, or an unquoted brace character? Read off the lexer's pieces: the lexer reads every `$` and
444
+ * backtick as bash does, so one that opens an expansion is an expansion piece, and a `$` it left in a literal piece is
445
+ * one bash takes as written (`c$/x`, `"a$"`, `"\$"`: no name, digit, special parameter, `{`, `(` or `[` follows it) — as
446
+ * is a backtick there (only an escape leaves one). Brace expansion runs BEFORE tilde expansion and
432
447
  * before the word ever reaches the program, so `cat {<abs>,}` hands the program an absolute path no spelling
433
448
  * shows, and `ls {~,}` a home directory the `~` arm of {@link resolveOperandLexically} never got to refuse —
434
449
  * both were real out-of-root reads. Rather than emulate expansion (the classifier resolves paths lexically and
@@ -1,4 +1,5 @@
1
- import { anchorSpelling, isAbsoluteForFamily, isBlockedDevicePath, isShellRootedSpellingUnmapped, nativeUncSpellingOf, normalizeAbsPathLexically, win32NamespaceScreen, pathFamilyOf } from "./safety.js";
1
+ import { anchorSpelling, isAbsoluteForFamily, isBlockedDevicePath, isShellRootedSpellingUnmapped, nativeUncSpellingOf, normalizeAbsPathLexically, shellAnchoredSpellingOf, shellDriveSpellingOf, win32NamespaceScreen, pathFamilyOf } from "./safety.js";
2
+ import { localDriveSpellingOf } from "../../core/unc-spelling.js";
2
3
  import { PARSE_FAILURE_SENTENCE, UNRESOLVED_SENTENCE, argvOf, expansionHidesRun, lexShell, literalTildeSpelling, } from "../../shell/lex.js";
3
4
  import { shellWordsOf } from "../../shell/shell-words.js";
4
5
  import { textBindsHome } from "./shell-read-bindings.js";
@@ -203,9 +204,14 @@ export function isPathShapedToken(tok) {
203
204
  return tok.includes("/") || tok.startsWith("~") || tok === "." || tok === "..";
204
205
  }
205
206
  export function resolveOperandLexically(base, operand, homeDir) {
206
- return resolveOperandSpellings(base, operand, homeDir)?.folded;
207
+ const at = resolveOperandSpellings(base, operand, homeDir);
208
+ return at?.standIn === true ? undefined : at?.folded;
207
209
  }
208
210
  const PARENT_SEGMENT_RE = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
211
+ export function tildeNamesAnAccount(spelled) {
212
+ const prefix = /^~([^/]*)/.exec(spelled)?.[1];
213
+ return prefix !== undefined && prefix !== "" && !/^[+-]?\d*$/.test(prefix);
214
+ }
209
215
  export function resolveOperandSpellings(base, operand, homeDir) {
210
216
  let raw = operand;
211
217
  if (raw === "~" || raw.startsWith("~/")) {
@@ -217,15 +223,21 @@ export function resolveOperandSpellings(base, operand, homeDir) {
217
223
  return undefined;
218
224
  }
219
225
  const family = base === undefined ? undefined : pathFamilyOf({ root: base });
220
- if (!win32NamespaceScreen(raw, family).ok)
221
- return undefined;
226
+ if (!win32NamespaceScreen(raw, family).ok) {
227
+ const standIn = family === "win" && raw === operand ? localDriveSpellingOf(raw, family) : undefined;
228
+ return standIn === undefined ? undefined : { ...spellingsOf(standIn), standIn: true };
229
+ }
230
+ const shellAnchored = (anchored) => spellingsOf(shellAnchoredSpellingOf(family, anchored) ?? anchored);
222
231
  if (isAbsoluteForFamily(family ?? "own", raw))
223
- return spellingsOf(nativeUncSpellingOf(family, raw));
232
+ return raw === operand ? spellingsOf(nativeUncSpellingOf(family, raw)) : shellAnchored(nativeUncSpellingOf(family, raw));
233
+ const drive = shellDriveSpellingOf(family, raw);
234
+ if (drive !== undefined)
235
+ return spellingsOf(drive);
224
236
  if (base === undefined || family === undefined || !isAbsoluteForFamily(family, base))
225
237
  return undefined;
226
238
  if (isShellRootedSpellingUnmapped(family, raw))
227
239
  return undefined;
228
- return spellingsOf(anchorSpelling(family, base, raw));
240
+ return shellAnchored(anchorSpelling(family, base, raw));
229
241
  }
230
242
  function spellingsOf(absolute) {
231
243
  const folded = normalizeAbsPathLexically(absolute);
@@ -253,9 +265,7 @@ export function expansionInWord(w) {
253
265
  return true;
254
266
  if (p.literal === undefined)
255
267
  continue;
256
- if (p.quotedBy === undefined && /[{}$`]/.test(p.literal))
257
- return true;
258
- if (p.quotedBy === '"' && /[$`]/.test(p.literal))
268
+ if (p.quotedBy === undefined && /[{}]/.test(p.literal))
259
269
  return true;
260
270
  }
261
271
  return false;
@@ -10,6 +10,10 @@ export declare function skipsRootsContainment(face: ContainmentFace | undefined)
10
10
  /** Which band a face governs. Selects the seat spellings and the error codes below — never the
11
11
  * resolution ORDER, which is one body shared by both. */
12
12
  export type ContainmentFaceKind = "read" | "write";
13
+ /** Why a deployment-seat "open" is not in force on a leg (the clamp announcement's `detail.cause`): the read-only
14
+ * (verifier) mount, or — the read face alone — a leg that refuses reads outside its directories. */
15
+ export declare const FACE_CLAMP_CAUSES: readonly ["read_only_mount", "read_block"];
16
+ export type FaceClampCause = (typeof FACE_CLAMP_CAUSES)[number];
13
17
  /** Which layer a seat belongs to. The SPELLING is derived from (kind, layer), never re-typed at a
14
18
  * call site: three doors screen the same two seats, and the value gate's message is the only place
15
19
  * a deployment reads the seat's name back. */
@@ -37,6 +41,10 @@ export interface ContainmentFaceInputs {
37
41
  * containment is a LOAD-BEARING wall (bash_readonly is genuinely confined by it); for the write
38
42
  * face it is the absence of the band entirely. Neither is openable. */
39
43
  readOnlyMount: boolean;
44
+ /** The leg refuses reads outside its declared directories (`TaskSpec.blockReadsOutsideRoots`, the leg's resolved value):
45
+ * the READ face's row 1 stands on it as on the read-only mount — an "open" read face would answer the very reads the leg
46
+ * refuses. The read bands alone pass it; the write face has nothing to say about reads. */
47
+ readBlock?: boolean;
40
48
  /** Org governance declared (`RunnerDeps.permissionRuleStore.partitions.org === true`): default roots; the task layer
41
49
  * may not open (tighten-only under governance; the deps layer, being the deployment's own
42
50
  * declaration, still may). */
@@ -57,8 +65,9 @@ export interface ContainmentFaceInputs {
57
65
  * deciding seat and the mount overrode it — not when a task-level "roots" pinned the same value
58
66
  * anyway (the mount changed nothing there, and announcing it would claim a false cause), and
59
67
  * never on the throw rows (those are already loud). The resolver stays the single owner of the
60
- * clamp predicate; stations own delivery/dedup ({@link deploymentFaceClampNotice}). */
61
- onDeploymentClamp?: () => void;
68
+ * clamp predicate; stations own delivery/dedup ({@link deploymentFaceClampNotice}). Handed the row's CAUSE (the
69
+ * read-only mount, else the leg's read block) — the one fact the announcement's text and its ledger key differ on. */
70
+ onDeploymentClamp?: (cause: FaceClampCause) => void;
62
71
  }
63
72
  /**
64
73
  * The ONE resolution order, first hit wins — ONE body for BOTH faces. prepare-task AND
@@ -97,7 +106,7 @@ export declare function resolveContainmentFace(i: ContainmentFaceInputs): Contai
97
106
  * process's default seat, else prints the same line). Built here, import-free, so the message can never fork between
98
107
  * the stations OR between the two faces.
99
108
  */
100
- export declare function deploymentFaceClampNotice(kind: ContainmentFaceKind): {
109
+ export declare function deploymentFaceClampNotice(kind: ContainmentFaceKind, cause: FaceClampCause): {
101
110
  code: string;
102
111
  message: string;
103
112
  detail: Record<string, unknown>;
@@ -2,6 +2,7 @@ import { describeRejectedValue } from "../../core/tool-search-setting.js";
2
2
  export function skipsRootsContainment(face) {
3
3
  return face === "open";
4
4
  }
5
+ export const FACE_CLAMP_CAUSES = Object.freeze(["read_only_mount", "read_block"]);
5
6
  const FACE_DIALECT = {
6
7
  read: {
7
8
  key: "readFace",
@@ -46,14 +47,20 @@ export function resolveContainmentFace(i) {
46
47
  const d = FACE_DIALECT[i.kind];
47
48
  const spec = assertContainmentFaceValue(i.specFace, i.kind, "spec");
48
49
  const deps = assertContainmentFaceValue(i.depsFace, i.kind, "deps");
49
- if (i.readOnlyMount) {
50
+ const cause = i.readOnlyMount ? "read_only_mount" : i.kind === "read" && i.readBlock === true ? "read_block" : undefined;
51
+ if (cause !== undefined) {
50
52
  if (spec === "open") {
51
- const e = new Error(`${d.key}: "open" contradicts the read-only (verifier) mount — ${d.readOnlyWhy} Drop the ${d.key} declaration or the readOnly mount.`);
52
- e.code = d.readOnlyConflictCode;
53
+ if (cause === "read_only_mount") {
54
+ const e = new Error(`${d.key}: "open" contradicts the read-only (verifier) mount — ${d.readOnlyWhy} Drop the ${d.key} declaration or the readOnly mount.`);
55
+ e.code = d.readOnlyConflictCode;
56
+ throw e;
57
+ }
58
+ const e = new Error(`${d.key}: "open" contradicts blockReadsOutsideRoots — an open read face would read where this task refuses to read. Drop the ${d.key} declaration or blockReadsOutsideRoots.`);
59
+ e.code = "config.read_face_read_block_conflict";
53
60
  throw e;
54
61
  }
55
62
  if (deps === "open" && spec === undefined)
56
- i.onDeploymentClamp?.();
63
+ i.onDeploymentClamp?.(cause);
57
64
  return "roots";
58
65
  }
59
66
  if (i.orgGoverned) {
@@ -76,10 +83,12 @@ export function resolveContainmentFace(i) {
76
83
  return "roots";
77
84
  return "roots";
78
85
  }
79
- export function deploymentFaceClampNotice(kind) {
86
+ export function deploymentFaceClampNotice(kind, cause) {
80
87
  const d = FACE_DIALECT[kind];
81
- const message = `${d.depsSeat}: the deployment-wide "open" declaration is not in force on this read-only (verifier) mount — clamped to "roots" (stricter-wins: ${d.clampWhy}). Other mounts still honor "open".`;
82
- const detail = { seat: d.depsSeat, declared: "open", inForce: "roots", cause: "read_only_mount" };
88
+ const message = cause === "read_only_mount"
89
+ ? `${d.depsSeat}: the deployment-wide "open" declaration is not in force on this read-only (verifier) mount — clamped to "roots" (stricter-wins: ${d.clampWhy}). Other mounts still honor "open".`
90
+ : `${d.depsSeat}: the deployment-wide "open" declaration is not in force on this leg, which refuses reads outside its directories (blockReadsOutsideRoots) — clamped to "roots" (stricter-wins). Other legs still honor "open".`;
91
+ const detail = { seat: d.depsSeat, declared: "open", inForce: "roots", cause };
83
92
  return kind === "read"
84
93
  ? { code: "config.read_face_deployment_clamped", message, detail }
85
94
  : { code: "config.write_face_deployment_clamped", message, detail };
@@ -5,7 +5,10 @@
5
5
  * (`resolveKey` over the same spelling, base, roots, deny table and containment face), and a target OUTSIDE the read
6
6
  * roots is an ORDINARY question — a person answers it, a persisted `Read(//dir/**)` row or the auto-mode classifier
7
7
  * may, a permission mode arbitrates it — with the directory whose grant clears it on the card. The deny table and
8
- * every other refusal stay the tool's own: this station judges containment only, after the deny judgment.
8
+ * every other refusal stay the tool's own: this station judges containment only, after the deny judgment. On a leg that
9
+ * refuses reads outside its directories ({@link outsideReadDisposition} `refusal`) the station is the refusal instead: what
10
+ * the tool would refuse, it refuses at the gate, ahead of every question, in the tool's own words and card — and in the
11
+ * leg's words ({@link READ_BLOCK_REMEDY}) for a read outside the roots.
9
12
  *
10
13
  * A call whose out-of-root read the gate put to a question is ADMITTED for that one target when the gate applies the
11
14
  * verdict ({@link ShellReadVerdict.admit}): the tool reads it once ({@link FileReadStation.admitted}), on the canonical
@@ -16,6 +19,24 @@ import type { ExecutionEnv } from "../../internal/harness-types.js";
16
19
  import type { ContainmentFace } from "./containment-face.js";
17
20
  import { type ReadDenyMatcher } from "./read-deny.js";
18
21
  import { type ShellReadCheck } from "./shell-read-check.js";
22
+ /**
23
+ * How a leg answers a file tool's read outside its roots — ONE judgment over the two declarations that bear on it:
24
+ * `refusal` (the leg refuses reads outside its declared directories, `TaskSpec.blockReadsOutsideRoots`: the station refuses
25
+ * at the gate, before the gate's own questions — save a host policy that asks its approver inside its own `check`, which has
26
+ * asked by then, and the leg's approver re-asked about an approved edit that moves an in-root read outside), `tool_fence`
27
+ * (the read-only mount: no station, the tool's own fence refuses), or
28
+ * `question` (the station puts it to whoever answers). The station is mounted, and its arm chosen, off this answer alone.
29
+ */
30
+ export type OutsideReadDisposition = "question" | "refusal" | "tool_fence";
31
+ export declare function outsideReadDisposition(leg: {
32
+ readonly readOnlyMount: boolean;
33
+ readonly readBlock: boolean;
34
+ }): OutsideReadDisposition;
35
+ /** The remedy a refusal of a read outside the directories names on a leg that refuses such reads — ONE sentence for every
36
+ * place that says it: the station's refusal, and (in place of the escape hint) the file tools' own fence and the Artifact
37
+ * tool's local read, for a read that never passes the station. It names the declaration and the one way out its reader has
38
+ * (the directory added to the task's own); never another tool, and never the declaration's removal. */
39
+ export declare const READ_BLOCK_REMEDY = "This task refuses reads outside its directories (blockReadsOutsideRoots); ask the user to add the directory to the task's directories.";
19
40
  export interface FileReadStation {
20
41
  readonly check: ShellReadCheck;
21
42
  /** The station's membership: the tool names whose declared read target it judges. */
@@ -40,6 +61,10 @@ export interface FileReadStationOptions {
40
61
  /** A target the tools' own fence admits without the roots (the engine's background output file,
41
62
  * `backgroundOutputReadExemption`): no question is put for it. */
42
63
  readonly exempt?: (canonicalKey: string) => boolean;
64
+ /** The station's arm ({@link outsideReadDisposition}): `question` (absent) puts an out-of-root read to a question;
65
+ * `refusal` refuses at the gate every read the tool would refuse itself — outside the roots, on a deny row, a target it
66
+ * cannot resolve, the artifact store — with the resolution's own card, admits nothing, and refuses when it cannot judge. */
67
+ readonly outsideReads?: Exclude<OutsideReadDisposition, "tool_fence">;
43
68
  }
44
69
  export declare function createFileReadStation(opts: FileReadStationOptions): FileReadStation;
45
70
  /** One gate input over the leg's read stations: each call is judged by the station whose membership holds the first of
@@ -1,10 +1,16 @@
1
1
  import { effectivePathSpellingOf } from "../../core/effective-path-target.js";
2
2
  import { pathTargetOf } from "../../core/tool-registry.js";
3
3
  import { fitMiddle, READ_DENY_SENTENCE_PART_MAX, seatForCall } from "./read-deny.js";
4
- import { resolveKey, violationDetails } from "./safety.js";
4
+ import { resolveKey, violationDetails, violationText } from "./safety.js";
5
5
  import { readStationMemberOf } from "./shell-read-check.js";
6
6
  import { grantOfferFor, parentDirLexically } from "./shell-read-judge.js";
7
7
  const ADMISSION_MAX = 1024;
8
+ export function outsideReadDisposition(leg) {
9
+ if (leg.readBlock)
10
+ return "refusal";
11
+ return leg.readOnlyMount ? "tool_fence" : "question";
12
+ }
13
+ export const READ_BLOCK_REMEDY = "This task refuses reads outside its directories (blockReadsOutsideRoots); ask the user to add the directory to the task's directories.";
8
14
  const VOUCH = { disposition: "vouch", finding: "none" };
9
15
  export function createFileReadStation(opts) {
10
16
  const admissions = new Map();
@@ -29,6 +35,16 @@ export function createFileReadStation(opts) {
29
35
  return (async () => {
30
36
  const extra = seatForCall(opts.roots, callOpts.toolCallId)();
31
37
  const r = await resolveKey(opts.env, opts.rootCanonical, spelled, signal, selection.base, extra, undefined, seatForCall(opts.readDeny, callOpts.toolCallId), opts.readFace);
38
+ if (opts.outsideReads === "refusal") {
39
+ if (r.ok || (r.violation.code === "path_not_in_root" && r.violation.target !== undefined && opts.exempt?.(r.violation.target) === true))
40
+ return VOUCH;
41
+ const v = r.violation;
42
+ const details = violationDetails(v);
43
+ if (v.code !== "path_not_in_root" || v.target === undefined)
44
+ return { disposition: "refuse", finding: v.code === "read_path_denied" ? "deny_hit" : "none", sentence: violationText(toolName, v), ...(details !== undefined ? { details } : {}) };
45
+ const allowed = fitMiddle([opts.rootCanonical, ...extra].join(", "), READ_DENY_SENTENCE_PART_MAX);
46
+ return { disposition: "refuse", finding: "outside_roots", sentence: `Error (${toolName}): "${fitMiddle(v.target, READ_DENY_SENTENCE_PART_MAX)}" is outside the directories this task may read (${allowed}). ${READ_BLOCK_REMEDY}`, ...(details !== undefined ? { details } : {}) };
47
+ }
32
48
  if (r.ok || r.violation.code !== "path_not_in_root" || r.violation.target === undefined || opts.excluded?.(r.violation.target) === true || opts.exempt?.(r.violation.target) === true)
33
49
  return VOUCH;
34
50
  const target = r.violation.target;
@@ -52,7 +68,9 @@ export function createFileReadStation(opts) {
52
68
  };
53
69
  })();
54
70
  },
55
- unanswered: () => VOUCH,
71
+ unanswered: (call, cause) => opts.outsideReads === "refusal"
72
+ ? { disposition: "refuse", finding: "unanswered", environmentSilent: true, sentence: `Error (${call.toolName}): where this call reads could not be established (${cause}), and this task refuses reads it cannot place inside its directories (blockReadsOutsideRoots). Try the call again.` }
73
+ : VOUCH,
56
74
  };
57
75
  const admitted = (toolCallId, key) => {
58
76
  if (toolCallId === undefined || admissions.get(toolCallId) !== key)
@@ -6,7 +6,7 @@ import { RollingTailBuffer } from "../../core/exec-output-tail.js";
6
6
  import { createBackgroundOutputFile, envDeclaresRetain, hasBackgroundShell, retainsBackgroundProcesses } from "../../core/background-shell.js";
7
7
  import { delimitUntrusted } from "../../core/untrusted-text.js";
8
8
  import { resolveImageProcessor } from "../../core/image-downsample.js";
9
- import { withinAnyRoot } from "./safety.js";
9
+ import { shellDriveSpellingOf, withinAnyRoot } from "./safety.js";
10
10
  import { admitImageBytes, sniffImageMime } from "../../core/image-admission.js";
11
11
  import { isDeadCwd, diagnoseDeadCwd } from "./dead-cwd.js";
12
12
  import { boundaryIsTheSandbox, hasDestroy, isIsolated } from "../../core/remote-env.js";
@@ -430,11 +430,11 @@ async function runShell(env, cwd, toolName, command, timeoutSec, caps, signal, c
430
430
  if (epilogue.cwd !== undefined) {
431
431
  const captured = epilogue.cwd.trim();
432
432
  const windowsWorld = /^[A-Za-z]:[\\/]/.test(cwdRef.current);
433
- const msys = /^\/([A-Za-z])(\/.*)?$/.exec(captured);
433
+ const drive = windowsWorld ? shellDriveSpellingOf("win", captured) : undefined;
434
434
  if (/^[A-Za-z]:[\\/]/.test(captured))
435
435
  cwdRef.current = captured;
436
- else if (windowsWorld && msys)
437
- cwdRef.current = `${msys[1]}:${msys[2] ?? "/"}`;
436
+ else if (drive !== undefined)
437
+ cwdRef.current = drive;
438
438
  else if (captured.startsWith("/") && !windowsWorld)
439
439
  cwdRef.current = captured;
440
440
  }
@@ -216,6 +216,9 @@ export interface ModelFileReaderOptions {
216
216
  }) => boolean;
217
217
  readDeny?: import("./read-deny.js").ReadDenyMatcher;
218
218
  readFace?: import("./containment-face.js").ContainmentFace;
219
+ /** The remedy an out-of-root refusal names in place of the escape hint (`resolveKey`'s `outsideRemedy`): the run's read
220
+ * face carries it on a leg that refuses reads outside its declared directories. Absent ⇒ the escape hint. */
221
+ outsideRemedy?: string;
219
222
  reminderMark?: string;
220
223
  reminderDisclosureCounts?: ReminderDisclosureCounts;
221
224
  /** The bare-form disclosure throttle windows, keyed by canonical file key. Owned by whoever builds the
@@ -69,7 +69,7 @@ async function admitNotebookImages(blocks, imageProcessor) {
69
69
  }));
70
70
  }
71
71
  export function createModelFileReader(opts) {
72
- const { env, state, rootCanonical, cwdRef, imageProcessor, pdfCapabilities, bgOutputReadExemption, readFace, reminderMark, readDeny: readDenySeat, additionalRoots: rootsSeat, contextRoom } = opts;
72
+ const { env, state, rootCanonical, cwdRef, imageProcessor, pdfCapabilities, bgOutputReadExemption, readFace, reminderMark, readDeny: readDenySeat, additionalRoots: rootsSeat, contextRoom, outsideRemedy } = opts;
73
73
  const windows = opts.disclosureWindows ?? new Map();
74
74
  const refuse = (envelope, kind) => ({
75
75
  outcome: "not_attached",
@@ -87,7 +87,7 @@ export function createModelFileReader(opts) {
87
87
  const resolve = async (path, ctx) => {
88
88
  if (ctx.toolCallId === undefined)
89
89
  await seatReady(rootsSeat, ctx.signal);
90
- return resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, seatForCall(rootsSeat, ctx.toolCallId), bgOutputReadExemption === undefined ? undefined : (key) => bgOutputReadExemption(key, ctx), seatForCall(readDenySeat, ctx.toolCallId), readFace);
90
+ return resolveKey(env, rootCanonical, path, ctx.signal, cwdRef?.current, seatForCall(rootsSeat, ctx.toolCallId), bgOutputReadExemption === undefined ? undefined : (key) => bgOutputReadExemption(key, ctx), seatForCall(readDenySeat, ctx.toolCallId), readFace, outsideRemedy);
91
91
  };
92
92
  const judgedAgain = (path, ctx, key) => sameKeyAgain((signal) => resolve(path, { ...ctx, signal: signal ?? ctx.signal }), key);
93
93
  const readForModel = async (args, ctx, opts) => {
@@ -12,5 +12,5 @@ import { type CwdRef } from "./fs-shared.js";
12
12
  * honesty boundary.
13
13
  */
14
14
  export declare function grepDetailFields(text: string, mode: "files_with_matches" | "content" | "count", offset?: number, structuredRows?: readonly import("./search.js").GrepRow[]): Record<string, unknown>;
15
- export declare function createGrepTool(env: ExecutionEnv, rootCanonical: string, rootsSeat?: RootsSeat, denySeat?: ReadDenyMatcher, readFace?: ContainmentFace, cwdRef?: CwdRef, readAdmission?: (toolCallId: string | undefined, canonicalKey: string) => boolean): AgentTool;
16
- export declare function createGlobTool(env: ExecutionEnv, rootCanonical: string, rootsSeat?: RootsSeat, denySeat?: ReadDenyMatcher, readFace?: ContainmentFace, cwdRef?: CwdRef, readAdmission?: (toolCallId: string | undefined, canonicalKey: string) => boolean): AgentTool;
15
+ export declare function createGrepTool(env: ExecutionEnv, rootCanonical: string, rootsSeat?: RootsSeat, denySeat?: ReadDenyMatcher, readFace?: ContainmentFace, cwdRef?: CwdRef, readAdmission?: (toolCallId: string | undefined, canonicalKey: string) => boolean, outsideRemedy?: string): AgentTool;
16
+ export declare function createGlobTool(env: ExecutionEnv, rootCanonical: string, rootsSeat?: RootsSeat, denySeat?: ReadDenyMatcher, readFace?: ContainmentFace, cwdRef?: CwdRef, readAdmission?: (toolCallId: string | undefined, canonicalKey: string) => boolean, outsideRemedy?: string): AgentTool;
@@ -78,7 +78,7 @@ export function grepDetailFields(text, mode, offset, structuredRows) {
78
78
  }
79
79
  return detailFields;
80
80
  }
81
- export function createGrepTool(env, rootCanonical, rootsSeat, denySeat, readFace, cwdRef, readAdmission) {
81
+ export function createGrepTool(env, rootCanonical, rootsSeat, denySeat, readFace, cwdRef, readAdmission, outsideRemedy) {
82
82
  const declaredTarget = toolFace("grep").pathTarget;
83
83
  const grepReadFloor = readFloorSeat(denySeat);
84
84
  return defineTool({
@@ -151,7 +151,7 @@ export function createGrepTool(env, rootCanonical, rootsSeat, denySeat, readFace
151
151
  const scopeSpelling = declaredTarget === undefined ? undefined : pathTargetValue(a, declaredTarget);
152
152
  let scoped = scopeSpelling;
153
153
  if (scopeSpelling !== undefined) {
154
- const r = await resolveKey(env, rootCanonical, scopeSpelling, ctx.signal, baseCwd, additionalRoots, readAdmission && ((key) => readAdmission(ctx.toolCallId, key)), readDeny, readFace);
154
+ const r = await resolveKey(env, rootCanonical, scopeSpelling, ctx.signal, baseCwd, additionalRoots, readAdmission && ((key) => readAdmission(ctx.toolCallId, key)), readDeny, readFace, outsideRemedy);
155
155
  if (!r.ok)
156
156
  return errorResult(violationText("Grep", r.violation), violationDetails(r.violation));
157
157
  scoped = r.key;
@@ -185,7 +185,7 @@ export function createGrepTool(env, rootCanonical, rootsSeat, denySeat, readFace
185
185
  },
186
186
  });
187
187
  }
188
- export function createGlobTool(env, rootCanonical, rootsSeat, denySeat, readFace, cwdRef, readAdmission) {
188
+ export function createGlobTool(env, rootCanonical, rootsSeat, denySeat, readFace, cwdRef, readAdmission, outsideRemedy) {
189
189
  const declaredTarget = toolFace("glob").pathTarget;
190
190
  return defineTool({
191
191
  name: "Glob",
@@ -227,7 +227,7 @@ export function createGlobTool(env, rootCanonical, rootsSeat, denySeat, readFace
227
227
  const baseCwd = pathTargetBaseOf(declaredTarget, { root: rootCanonical, cwd: cwdRef?.current });
228
228
  let scoped = path;
229
229
  if (path !== undefined) {
230
- const r = await resolveKey(env, rootCanonical, path, ctx.signal, baseCwd, additionalRoots, readAdmission && ((key) => readAdmission(ctx.toolCallId, key)), readDeny, readFace);
230
+ const r = await resolveKey(env, rootCanonical, path, ctx.signal, baseCwd, additionalRoots, readAdmission && ((key) => readAdmission(ctx.toolCallId, key)), readDeny, readFace, outsideRemedy);
231
231
  if (!r.ok)
232
232
  return errorResult(violationText("Glob", r.violation), violationDetails(r.violation));
233
233
  scoped = r.key;
@@ -38,6 +38,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
38
38
  const { includeShell = false, readOnly = false, bashReadonlyAllow, commitCoAuthor = false, mountBackgroundTaskTools = true, additionalRoots, additionalReadRoots, } = opts;
39
39
  const carriedFace = opts.readDenyHomes !== undefined ? carriedReadFaceOf(opts.readDenyHomes) : undefined;
40
40
  const readFaceRoots = carriedFace?.readRoots ?? (additionalReadRoots === undefined ? additionalRoots : () => (additionalReadRoots.length === 0 ? additionalRoots : [...(additionalRoots ?? []), ...additionalReadRoots]));
41
+ const outsideRemedy = carriedFace?.outsideReadRemedy;
41
42
  const cwdRef = opts.cwdRef ?? { current: rootCanonical };
42
43
  const bgOutput = backgroundOutputReadExemption(opts.taskRegistry, opts, env);
43
44
  const readAdmission = opts.readAdmission;
@@ -55,7 +56,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
55
56
  readOnlyMount: readOnly,
56
57
  orgGoverned: false,
57
58
  fullShellReachable: includeShell && !readOnly,
58
- onDeploymentClamp: () => deliverEngineNotice(opts.onNotice, deploymentFaceClampNotice("read")),
59
+ onDeploymentClamp: (cause) => deliverEngineNotice(opts.onNotice, deploymentFaceClampNotice("read", cause)),
59
60
  });
60
61
  const writeFace = resolveContainmentFace({
61
62
  kind: "write",
@@ -63,7 +64,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
63
64
  readOnlyMount: readOnly,
64
65
  orgGoverned: false,
65
66
  fullShellReachable: includeShell && !readOnly,
66
- onDeploymentClamp: () => deliverEngineNotice(opts.onNotice, deploymentFaceClampNotice("write")),
67
+ onDeploymentClamp: (cause) => deliverEngineNotice(opts.onNotice, deploymentFaceClampNotice("write", cause)),
67
68
  });
68
69
  const writeFaceOf = opts.writeFaceLive ?? (() => writeFace);
69
70
  const readCwd = readOnly ? undefined : cwdRef;
@@ -78,6 +79,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
78
79
  ...(bgOutputReadExemption !== undefined ? { bgOutputReadExemption } : {}),
79
80
  ...(readDeny !== undefined ? { readDeny } : {}),
80
81
  ...(readFace !== undefined ? { readFace } : {}),
82
+ ...(outsideRemedy !== undefined ? { outsideRemedy } : {}),
81
83
  ...(opts.reminderMark !== undefined ? { reminderMark: opts.reminderMark } : {}),
82
84
  ...(opts.reminderDisclosureCounts !== undefined ? { reminderDisclosureCounts: opts.reminderDisclosureCounts } : {}),
83
85
  ...(opts.contextRoom !== undefined ? { contextRoom: opts.contextRoom } : {}),
@@ -93,7 +95,7 @@ export function createHandsToolkit(env, readFileState, rootCanonical, opts = {})
93
95
  if (keptBytes?.bytesOf !== undefined)
94
96
  tools.push(createSaveToolResultTool(env, keptBytes, opts.writeRoot ?? rootCanonical, cwdRef, additionalRoots, opts.beforeWrite, opts.trackFileEdit, opts.onFileEdited, writeFaceOf, writeDeny));
95
97
  }
96
- tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission)));
98
+ tools.push(afterPlacement(createGrepTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createGlobTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)), afterPlacement(createRepoMapTool(env, rootCanonical, readFaceRoots, readDeny, readFace, cwdRef, readAdmission, outsideRemedy)));
97
99
  if (includeShell) {
98
100
  tools.push(afterPlacement(readOnly
99
101
  ? createBashReadonlyTool(env, rootCanonical, new Set(bashReadonlyAllow ?? BASH_READONLY_DEFAULT_ALLOW), {
@@ -134,6 +134,10 @@ function jpegLooksComplete(bytes) {
134
134
  const n = bytes.length;
135
135
  return n >= 4 && bytes[0] === 0xff && bytes[1] === 0xd8 && bytes[n - 2] === 0xff && bytes[n - 1] === 0xd9;
136
136
  }
137
+ function renderedPageOf(path) {
138
+ const m = /-(\d+)\.jpe?g$/i.exec(path);
139
+ return m === null ? undefined : Number(m[1]);
140
+ }
137
141
  async function listRenderedJpegs(env, dir, signal) {
138
142
  const listing = await env.listDir(dir, signal);
139
143
  if (!listing.ok)
@@ -166,8 +170,10 @@ export async function extractPdfPagesAsImages(env, input, first, last, signal, r
166
170
  const listed = await listRenderedJpegs(env, dir, signal);
167
171
  const jpgs = listed.ok ? listed.jpgs : [];
168
172
  const pages = [];
169
- for (let i = 0; i < jpgs.length; i++) {
170
- const bin = await env.readBinaryFile(jpgs[i], signal);
173
+ for (const [i, jpg] of jpgs.entries()) {
174
+ if (renderedPageOf(jpg) !== first + i)
175
+ break;
176
+ const bin = await env.readBinaryFile(jpg, signal);
171
177
  if (!bin.ok || !jpegLooksComplete(bin.value))
172
178
  break;
173
179
  pages.push({ pageNumber: first + i, jpeg: bin.value });
@@ -195,8 +201,10 @@ export async function extractPdfPagesAsImages(env, input, first, last, signal, r
195
201
  if (jpgs.length === 0)
196
202
  return { ok: false, toolMissing: false, error: "pdftoppm produced no page images (page range past the end of the document?)" };
197
203
  const pages = [];
198
- for (let i = 0; i < jpgs.length; i++) {
199
- const bin = await env.readBinaryFile(jpgs[i], signal);
204
+ for (const [i, jpg] of jpgs.entries()) {
205
+ if (renderedPageOf(jpg) !== first + i)
206
+ return { ok: false, toolMissing: false, error: `the rendered image of page ${first + i} is missing` };
207
+ const bin = await env.readBinaryFile(jpg, signal);
200
208
  if (!bin.ok)
201
209
  return { ok: false, toolMissing: false, error: `cannot read the rendered page image: ${envErrorDetail(bin.error.message)}` };
202
210
  pages.push({ pageNumber: first + i, jpeg: bin.value });
@@ -142,6 +142,10 @@ export interface CarriedReadFace {
142
142
  readonly homeViews: HomeViewSource;
143
143
  };
144
144
  readonly readRoots: () => readonly string[];
145
+ /** The remedy the band's read tools name, in place of the escape hint, when they refuse a read outside the read roots
146
+ * (`resolveKey`'s `outsideRemedy`): present on a leg that refuses reads outside its declared directories, whose escape
147
+ * hint would name ways out the leg does not have. Absent ⇒ the escape hint. */
148
+ readonly outsideReadRemedy?: string;
145
149
  }
146
150
  /** The views of the placement that returned `homes` — the very list object, as the engine hands it on (the Runner's
147
151
  * tool band). `undefined` for any other list: a copy, or a host's own. A mount that was handed the engine's placement
@@ -182,9 +186,16 @@ export declare function carryHomeViews<T extends object>(judge: T, source: HomeV
182
186
  * · each AUXILIARY home (see the module head) read once under {@link AUXILIARY_HOME_PROBE_MS} — its spellings, its
183
187
  * chain, its rows' heads — at the same time; whatever of it did not answer costs that home alone and never `whole`;
184
188
  * · the ROOTED rows' heads ({@link readDenyLinksOf}), read whether or not a home answered: a head that did not answer
185
- * leaves the placement not WHOLE, and a placement that held the rows anywhere still places them.
189
+ * leaves the placement not WHOLE, and a placement that held the rows anywhere still places them;
190
+ * · the leg's declared places (`places`, the Runner's one mint — `runner/leg-caller-places.ts`): every CONFIGURATION ROOT
191
+ * is read as an auxiliary home is and places the rows that name the configuration directory below it; every CALLER HOME
192
+ * joins the home set as one more auxiliary home — only where the set places at all: a set that holds the rows anywhere
193
+ * (no declared home) is never narrowed to the caller's homes, and still takes the places a caller home's links lead to.
186
194
  * `compile` is the mount's own compile; the rows' patterns are read off its compile at no home. */
187
- export declare function placeReadDenyAtHome(env: ExecutionEnv, compile: (homes: readonly string[], linked?: ReadonlyMap<string, readonly string[]>) => ReadDenyMatcher, homes?: readonly string[], signal?: AbortSignal, configRoot?: string): Promise<{
195
+ export declare function placeReadDenyAtHome(env: ExecutionEnv, compile: (homes: readonly string[], linked?: ReadonlyMap<string, readonly string[]>) => ReadDenyMatcher, homes?: readonly string[], signal?: AbortSignal, places?: {
196
+ readonly configRoots?: readonly string[];
197
+ readonly callerHomes?: readonly string[];
198
+ }): Promise<{
188
199
  readonly matcher: PlacedReadDenyMatcher;
189
200
  readonly homes: readonly string[];
190
201
  readonly linked: ReadonlyMap<string, readonly string[]>;
@@ -3,7 +3,7 @@ import { canonicalizeTarget, isAbsoluteForFamily, joinForFamily, normalizeAbsPat
3
3
  import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, withGateTimeout } from "../../core/gate-bounded-await.js";
4
4
  import { thrownText } from "../../core/thrown-value.js";
5
5
  import { deliverEngineNotice } from "../../core/engine-notice.js";
6
- import { agentConfigDirTail } from "../../core/agent-config-dir.js";
6
+ import { agentConfigDirTail, declaredDirIdentity } from "../../core/agent-config-dir.js";
7
7
  import { validatePath } from "../../core/effective-path-target.js";
8
8
  import { readDenyPatternRun, readDenyRowAnchor, readDenyRunHead } from "./read-deny.js";
9
9
  import { isAbsence } from "./shell-read-environment.js";
@@ -58,7 +58,7 @@ function declaredReadDenyHomesAnswered(env) {
58
58
  const account = accountHomeOf();
59
59
  if (account.state === "unanswered")
60
60
  return { homes: [], whole: false };
61
- if (account.state === "none" || normalizeAbsPathLexically(account.home) === normalizeAbsPathLexically(home))
61
+ if (account.state === "none" || declaredDirIdentity(account.home) === declaredDirIdentity(home))
62
62
  return { homes: [home], whole: true };
63
63
  return { homes: [home, account.home], whole: true };
64
64
  }
@@ -66,7 +66,7 @@ export function declaredReadDenyHomes(env) {
66
66
  return declaredReadDenyHomesAnswered(env).homes;
67
67
  }
68
68
  function isDeclared(declared, home) {
69
- return declared !== undefined && normalizeAbsPathLexically(home) === normalizeAbsPathLexically(declared);
69
+ return declared !== undefined && declaredDirIdentity(home) === declaredDirIdentity(declared);
70
70
  }
71
71
  async function homeSpellingsOf(env, home, signal) {
72
72
  try {
@@ -417,22 +417,28 @@ export function carryHomeViews(judge, source) {
417
417
  Object.defineProperty(carried, "id", { value: id, enumerable: false });
418
418
  return carried;
419
419
  }
420
- export async function placeReadDenyAtHome(env, compile, homes, signal, configRoot) {
420
+ export async function placeReadDenyAtHome(env, compile, homes, signal, places) {
421
421
  const entries = compile([]).entries;
422
422
  const declared = declaredHomeOf(env);
423
- const relocated = configRoot === undefined ? undefined : readAuxiliaryHome(env, configRoot, { entries, configRoot: true }, signal);
423
+ const relocated = (places?.configRoots ?? []).map((root) => readAuxiliaryHome(env, root, { entries, configRoot: true }, signal));
424
424
  const rooted = readDenyLinksOf(env, entries, { at: "root" }, signal);
425
- const heldAnywhere = async (whole) => {
425
+ const foldLinked = (maps) => {
426
426
  const linked = new Map();
427
- for (const map of [(await relocated)?.linked, (await rooted).linked])
428
- for (const [pattern, locations] of map ?? [])
429
- linked.set(pattern, locations);
430
- return placementOf(carryHomeViews(linked.size === 0 ? compile([]) : compile([], linked), homeViewSourceOver(env, relocated === undefined ? [] : [relocated])), [], linked, whole);
427
+ for (const map of maps)
428
+ for (const [pattern, locations] of map)
429
+ linked.set(pattern, [...new Set([...(linked.get(pattern) ?? []), ...locations])]);
430
+ return linked;
431
+ };
432
+ const callerReads = (homeSet) => readAuxiliaryHomes(env, (places?.callerHomes ?? []).filter((h) => !homeSet.some((own) => declaredDirIdentity(own) === declaredDirIdentity(h))), { entries }, signal);
433
+ const heldAnywhere = async (whole) => {
434
+ const callers = callerReads([]);
435
+ const linked = foldLinked([...(await Promise.all(relocated)).map((r) => r.linked), ...(await Promise.all(callers)).map((r) => r.linked), (await rooted).linked]);
436
+ return placementOf(carryHomeViews(linked.size === 0 ? compile([]) : compile([], linked), homeViewSourceOver(env, [...relocated, ...callers])), [], linked, whole);
431
437
  };
432
- const listed = homes === undefined ? declaredReadDenyHomesAnswered(env) : { homes, whole: true };
433
- if (!listed.whole)
438
+ const answered = homes === undefined ? declaredReadDenyHomesAnswered(env) : { homes, whole: true };
439
+ if (!answered.whole)
434
440
  return await heldAnywhere(false);
435
- const own = listed.homes.filter((h) => isDeclared(declared, h));
441
+ const own = answered.homes.filter((h) => isDeclared(declared, h));
436
442
  let declaredAt = [];
437
443
  if (own.length > 0) {
438
444
  const ownSpellings = await withGateTimeout(homeSpellingsOf(env, own[0], signal), DEFAULT_GATE_AWAIT_TIMEOUT_MS, signal, "readDenyHomes");
@@ -440,16 +446,14 @@ export async function placeReadDenyAtHome(env, compile, homes, signal, configRoo
440
446
  return await heldAnywhere(false);
441
447
  declaredAt = [...new Set([...own, ...ownSpellings.spellings])];
442
448
  }
443
- const auxiliary = readAuxiliaryHomes(env, listed.homes, { entries }, signal);
444
- const [heads, readings, root, rootedHeads] = await Promise.all([readDenyLinksOf(env, entries, { at: "home", homes: declaredAt }, signal), Promise.all(auxiliary), relocated, rooted]);
445
- const at = [...new Set([...declaredAt, ...readings.flatMap((r) => r.place)])];
446
- const linked = new Map();
447
- for (const map of [heads.linked, ...readings.map((r) => r.linked), ...(root === undefined ? [] : [root.linked]), rootedHeads.linked]) {
448
- for (const [pattern, locations] of map)
449
- linked.set(pattern, [...new Set([...(linked.get(pattern) ?? []), ...locations])]);
450
- }
449
+ const auxiliary = readAuxiliaryHomes(env, answered.homes, { entries }, signal);
450
+ const callers = callerReads(answered.homes);
451
+ const [heads, readings, callerReadings, roots, rootedHeads] = await Promise.all([readDenyLinksOf(env, entries, { at: "home", homes: declaredAt }, signal), Promise.all(auxiliary), Promise.all(callers), Promise.all(relocated), rooted]);
452
+ const placing = answered.homes.length > 0;
453
+ const at = [...new Set([...declaredAt, ...readings.flatMap((r) => r.place), ...(placing ? callerReadings.flatMap((r) => r.place) : [])])];
454
+ const linked = foldLinked([heads.linked, ...readings.map((r) => r.linked), ...callerReadings.map((r) => r.linked), ...roots.map((r) => r.linked), rootedHeads.linked]);
451
455
  const matcher = linked.size === 0 ? compile(at) : compile(at, linked);
452
- return placementOf(carryHomeViews(matcher, homeViewSourceOver(env, relocated === undefined ? auxiliary : [...auxiliary, relocated])), at, linked, heads.whole && rootedHeads.whole);
456
+ return placementOf(carryHomeViews(matcher, homeViewSourceOver(env, [...auxiliary, ...relocated, ...callers])), at, linked, heads.whole && rootedHeads.whole);
453
457
  }
454
458
  export function readDenyPlacedLater(unplaced, place) {
455
459
  let current = unplaced;