@sema-agent/core 7.67.3 → 7.68.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 (496) hide show
  1. package/CHANGELOG.md +1516 -0
  2. package/README.md +18 -9
  3. package/README.zh-CN.md +16 -8
  4. package/dist/agents/agent-definition.d.ts +1 -1
  5. package/dist/agents/agent-definition.js +4 -1
  6. package/dist/agents/cascade.d.ts +2 -2
  7. package/dist/agents/cascade.js +3 -1
  8. package/dist/agents/cumulative-stats.d.ts +2 -1
  9. package/dist/agents/cumulative-stats.js +4 -1
  10. package/dist/agents/list-agents-tool.d.ts +30 -0
  11. package/dist/agents/list-agents-tool.js +45 -3
  12. package/dist/agents/peer-admission.d.ts +2 -2
  13. package/dist/agents/peer-session-drain.d.ts +2 -0
  14. package/dist/agents/peer-session-drain.js +1 -0
  15. package/dist/agents/repair-loop.js +3 -1
  16. package/dist/agents/retain-ledger.d.ts +61 -8
  17. package/dist/agents/retain-ledger.js +25 -3
  18. package/dist/agents/roster-store.d.ts +4 -2
  19. package/dist/agents/send-message-tool.d.ts +1 -1
  20. package/dist/agents/send-message-tool.js +20 -15
  21. package/dist/agents/subagent-steps.js +2 -10
  22. package/dist/agents/subagent.d.ts +3 -0
  23. package/dist/agents/subagent.js +106 -76
  24. package/dist/agents/tool-filter.d.ts +20 -11
  25. package/dist/agents/tool-filter.js +8 -4
  26. package/dist/agents/verify.d.ts +3 -1
  27. package/dist/agents/verify.js +2 -0
  28. package/dist/brain/anthropic.js +4 -4
  29. package/dist/brain/open-responses.js +3 -1
  30. package/dist/brain/openai.js +3 -1
  31. package/dist/brain/reasoning-request.d.ts +73 -19
  32. package/dist/brain/reasoning-request.js +164 -72
  33. package/dist/brain/reasoning-stamp.d.ts +26 -0
  34. package/dist/brain/reasoning-stamp.js +10 -0
  35. package/dist/brain/reasoning.d.ts +95 -162
  36. package/dist/brain/reasoning.js +31 -86
  37. package/dist/brain/route-adjudicator.d.ts +9 -7
  38. package/dist/brain/route-adjudicator.js +12 -10
  39. package/dist/brain/status-sink.d.ts +19 -64
  40. package/dist/brain/status-sink.js +5 -21
  41. package/dist/brain/stream-engine.d.ts +11 -2
  42. package/dist/brain/stream-engine.js +10 -0
  43. package/dist/core/a2a.d.ts +17 -5
  44. package/dist/core/a2a.js +11 -3
  45. package/dist/core/allow-entry.d.ts +35 -15
  46. package/dist/core/allow-entry.js +47 -60
  47. package/dist/core/ask-headline.d.ts +68 -0
  48. package/dist/core/ask-headline.js +23 -0
  49. package/dist/core/ask-origin.d.ts +36 -8
  50. package/dist/core/ask-origin.js +17 -10
  51. package/dist/core/ask-question.d.ts +34 -7
  52. package/dist/core/ask-question.js +10 -1
  53. package/dist/core/ask-unresolvable-notice.d.ts +7 -0
  54. package/dist/core/ask-unresolvable-notice.js +9 -3
  55. package/dist/core/auto-strip.d.ts +53 -0
  56. package/dist/core/auto-strip.js +76 -0
  57. package/dist/core/background-agent-store.d.ts +45 -5
  58. package/dist/core/background-agent-store.js +69 -15
  59. package/dist/core/background-shell.d.ts +2 -2
  60. package/dist/core/caller-text.js +2 -2
  61. package/dist/core/canonical-json.d.ts +13 -0
  62. package/dist/core/canonical-json.js +7 -0
  63. package/dist/core/checkpoint-features.d.ts +66 -20
  64. package/dist/core/checkpoint-features.js +12 -1
  65. package/dist/core/checkpoint-generation.d.ts +1 -1
  66. package/dist/core/checkpoint-queries.d.ts +1 -1
  67. package/dist/core/checkpoint-queries.js +4 -1
  68. package/dist/core/checkpoint-requirements.d.ts +25 -1
  69. package/dist/core/checkpoint-requirements.js +5 -1
  70. package/dist/core/checkpoint-row-verdict.d.ts +1 -0
  71. package/dist/core/checkpoint-row-verdict.js +4 -0
  72. package/dist/core/checkpoint-store.d.ts +66 -38
  73. package/dist/core/checkpoint-store.js +15 -6
  74. package/dist/core/child-clamp-seats.d.ts +6 -0
  75. package/dist/core/child-clamp-seats.js +1 -0
  76. package/dist/core/config-refusal-codes.d.ts +1 -1
  77. package/dist/core/config-refusal-codes.js +1 -0
  78. package/dist/core/delegation-frames.d.ts +9 -12
  79. package/dist/core/delegation-frames.js +9 -8
  80. package/dist/core/engine-capabilities.d.ts +21 -8
  81. package/dist/core/engine-capabilities.js +1 -1
  82. package/dist/core/engine-notice.d.ts +147 -34
  83. package/dist/core/engine-notice.js +27 -16
  84. package/dist/core/engine-storage-backend.d.ts +2 -1
  85. package/dist/core/env-budget.js +3 -3
  86. package/dist/core/env-knob-announce.d.ts +10 -10
  87. package/dist/core/env-knob-announce.js +3 -6
  88. package/dist/core/file-history-store.d.ts +29 -4
  89. package/dist/core/file-history-store.js +13 -0
  90. package/dist/core/frame-settlement.d.ts +2 -1
  91. package/dist/core/gate-fold.js +1 -1
  92. package/dist/core/gate-lanes.js +56 -49
  93. package/dist/core/governance-codes.d.ts +39 -3
  94. package/dist/core/governance-codes.js +61 -3
  95. package/dist/core/hooks.d.ts +29 -11
  96. package/dist/core/hooks.js +5 -2
  97. package/dist/core/human-input-projection.js +3 -3
  98. package/dist/core/input-author.d.ts +17 -3
  99. package/dist/core/input-author.js +15 -3
  100. package/dist/core/leg-identity.d.ts +10 -28
  101. package/dist/core/leg-identity.js +1 -21
  102. package/dist/core/lsp.d.ts +18 -13
  103. package/dist/core/lsp.js +30 -22
  104. package/dist/core/mailbox-store.d.ts +1 -1
  105. package/dist/core/mailbox-store.js +4 -4
  106. package/dist/core/mcp-connection-pool.d.ts +93 -4
  107. package/dist/core/mcp-connection-pool.js +104 -1
  108. package/dist/core/mcp-failure.d.ts +38 -12
  109. package/dist/core/mcp-failure.js +9 -13
  110. package/dist/core/mcp-probe.d.ts +4 -3
  111. package/dist/core/mcp-server-link.d.ts +4 -2
  112. package/dist/core/mcp-server-link.js +4 -5
  113. package/dist/core/mcp-server-spec.d.ts +3 -3
  114. package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
  115. package/dist/core/mcp-server-unavailable-notice.js +18 -4
  116. package/dist/core/mcp.d.ts +40 -6
  117. package/dist/core/mcp.js +39 -13
  118. package/dist/core/memory-engine/content-origin.js +2 -2
  119. package/dist/core/memory-engine/control-objects.d.ts +2 -4
  120. package/dist/core/memory-engine/control-objects.js +2 -10
  121. package/dist/core/memory-engine/delegation-settlement.js +6 -1
  122. package/dist/core/memory-engine/dual-root.js +3 -0
  123. package/dist/core/memory-engine/engine.d.ts +6 -4
  124. package/dist/core/memory-engine/engine.js +32 -29
  125. package/dist/core/memory-engine/file-backend.d.ts +20 -5
  126. package/dist/core/memory-engine/file-backend.js +21 -31
  127. package/dist/core/memory-engine/frontmatter.d.ts +2 -0
  128. package/dist/core/memory-engine/frontmatter.js +4 -0
  129. package/dist/core/memory-engine/layout.d.ts +114 -20
  130. package/dist/core/memory-engine/layout.js +340 -22
  131. package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
  132. package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
  133. package/dist/core/memory-engine/mount-failed-notice.js +43 -10
  134. package/dist/core/memory-engine/sync-client.js +4 -5
  135. package/dist/core/model-fallbacks.d.ts +5 -1
  136. package/dist/core/model-fallbacks.js +3 -3
  137. package/dist/core/model-receipt.d.ts +2 -1
  138. package/dist/core/model-receipt.js +12 -1
  139. package/dist/core/mods/kernel/dispatch.d.ts +2 -2
  140. package/dist/core/mods/kernel/dispatch.js +14 -6
  141. package/dist/core/mods/kernel/events.d.ts +8 -5
  142. package/dist/core/mods/kernel/events.js +2 -2
  143. package/dist/core/mods/kernel/index.d.ts +1 -1
  144. package/dist/core/mods/kernel/registration.d.ts +9 -0
  145. package/dist/core/mods/package.js +1 -1
  146. package/dist/core/mods/session-append.d.ts +4 -2
  147. package/dist/core/mods/session-append.js +3 -0
  148. package/dist/core/mods/stations.d.ts +7 -11
  149. package/dist/core/mods/stations.js +4 -7
  150. package/dist/core/mods/tool-call.d.ts +10 -8
  151. package/dist/core/mods/tool-call.js +15 -18
  152. package/dist/core/mounted-mcp.d.ts +0 -4
  153. package/dist/core/mounted-mcp.js +1 -1
  154. package/dist/core/park-noun.d.ts +24 -0
  155. package/dist/core/park-noun.js +21 -0
  156. package/dist/core/park-resumability.d.ts +60 -0
  157. package/dist/core/park-resumability.js +30 -0
  158. package/dist/core/permission-rule-provider.d.ts +24 -2
  159. package/dist/core/permission-rule-provider.js +11 -8
  160. package/dist/core/permission-rule-store.d.ts +8 -1
  161. package/dist/core/permission-rule-store.js +2 -3
  162. package/dist/core/permission-rules.d.ts +2 -1
  163. package/dist/core/permission-rules.js +8 -4
  164. package/dist/core/persisted-rule-arms.d.ts +3 -0
  165. package/dist/core/persisted-rule-arms.js +2 -1
  166. package/dist/core/present-plan-tool.d.ts +47 -3
  167. package/dist/core/present-plan-tool.js +62 -4
  168. package/dist/core/principal-name.d.ts +1 -1
  169. package/dist/core/principal-name.js +5 -5
  170. package/dist/core/process-identity.js +10 -5
  171. package/dist/core/protocol-http-auth.d.ts +20 -14
  172. package/dist/core/protocol-http-auth.js +70 -50
  173. package/dist/core/read-only-shell.js +9 -5
  174. package/dist/core/redaction-marks.d.ts +4 -26
  175. package/dist/core/redaction-marks.js +9 -21
  176. package/dist/core/remote-env.d.ts +43 -16
  177. package/dist/core/remote-env.js +1 -1
  178. package/dist/core/request-copy-projection.d.ts +1 -1
  179. package/dist/core/request-copy-projection.js +40 -50
  180. package/dist/core/resume-config-judge.js +1 -1
  181. package/dist/core/resume-startup-cause.d.ts +35 -18
  182. package/dist/core/resume-startup-cause.js +13 -10
  183. package/dist/core/retention.d.ts +167 -25
  184. package/dist/core/retention.js +100 -20
  185. package/dist/core/roles.d.ts +6 -0
  186. package/dist/core/roles.js +11 -5
  187. package/dist/core/rule-lane-reads.d.ts +3 -0
  188. package/dist/core/rule-lane-reads.js +5 -1
  189. package/dist/core/rule-store-fault.d.ts +70 -0
  190. package/dist/core/rule-store-fault.js +102 -0
  191. package/dist/core/runner/advertised-writable-dirs.js +16 -31
  192. package/dist/core/runner/announce-once-ledger.d.ts +19 -2
  193. package/dist/core/runner/announce-once-ledger.js +24 -2
  194. package/dist/core/runner/assemble-result.d.ts +6 -0
  195. package/dist/core/runner/assemble-result.js +1 -1
  196. package/dist/core/runner/auto-strip-notice.d.ts +36 -0
  197. package/dist/core/runner/auto-strip-notice.js +59 -0
  198. package/dist/core/runner/branch-window.d.ts +3 -0
  199. package/dist/core/runner/branch-window.js +37 -0
  200. package/dist/core/runner/caller-roster.d.ts +8 -3
  201. package/dist/core/runner/capability-withheld-seat.js +3 -9
  202. package/dist/core/runner/clock-and-limits.d.ts +22 -1
  203. package/dist/core/runner/clock-and-limits.js +30 -0
  204. package/dist/core/runner/contracts.d.ts +58 -35
  205. package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
  206. package/dist/core/runner/credential-refusal-seat.js +47 -0
  207. package/dist/core/runner/cross-boundary-lane.js +6 -4
  208. package/dist/core/runner/decide-continuation.js +1 -1
  209. package/dist/core/runner/file-history-restore.d.ts +53 -2
  210. package/dist/core/runner/file-history-restore.js +29 -10
  211. package/dist/core/runner/forward-sink.d.ts +14 -1
  212. package/dist/core/runner/forward-sink.js +14 -12
  213. package/dist/core/runner/gate-exit.d.ts +8 -7
  214. package/dist/core/runner/gate-exit.js +13 -13
  215. package/dist/core/runner/git-status-frame.js +2 -4
  216. package/dist/core/runner/initial-run-state.js +1 -1
  217. package/dist/core/runner/main-call-account.d.ts +3 -1
  218. package/dist/core/runner/main-call-account.js +5 -3
  219. package/dist/core/runner/mcp-redial.d.ts +2 -5
  220. package/dist/core/runner/mcp-redial.js +2 -2
  221. package/dist/core/runner/nested-memory-content.d.ts +7 -1
  222. package/dist/core/runner/nested-memory-content.js +73 -13
  223. package/dist/core/runner/nested-memory-lane.d.ts +44 -19
  224. package/dist/core/runner/nested-memory-lane.js +152 -76
  225. package/dist/core/runner/park-commit.js +3 -1
  226. package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
  227. package/dist/core/runner/permission-rule-lanes.js +29 -3
  228. package/dist/core/runner/person-path-rows.d.ts +3 -11
  229. package/dist/core/runner/person-path-rows.js +21 -24
  230. package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
  231. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  232. package/dist/core/runner/prepare-artifact.js +20 -14
  233. package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
  234. package/dist/core/runner/prepare-ask-lane.js +6 -5
  235. package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
  236. package/dist/core/runner/prepare-boundary-parks.js +27 -24
  237. package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
  238. package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
  239. package/dist/core/runner/prepare-config-doors.d.ts +9 -24
  240. package/dist/core/runner/prepare-config-doors.js +58 -41
  241. package/dist/core/runner/prepare-context-lane.d.ts +2 -2
  242. package/dist/core/runner/prepare-context-lane.js +3 -5
  243. package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
  244. package/dist/core/runner/prepare-defer-classify.js +1 -1
  245. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  246. package/dist/core/runner/prepare-delegation-surface.js +3 -2
  247. package/dist/core/runner/prepare-file-history.d.ts +62 -26
  248. package/dist/core/runner/prepare-file-history.js +117 -46
  249. package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
  250. package/dist/core/runner/prepare-gate-stations.js +6 -5
  251. package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
  252. package/dist/core/runner/prepare-hands-readface.js +8 -4
  253. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
  254. package/dist/core/runner/prepare-inherited-gate.js +6 -6
  255. package/dist/core/runner/prepare-listings.d.ts +1 -1
  256. package/dist/core/runner/prepare-listings.js +1 -1
  257. package/dist/core/runner/prepare-memory.js +2 -2
  258. package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
  259. package/dist/core/runner/prepare-offload-wrappers.js +1 -1
  260. package/dist/core/runner/prepare-park-ask.d.ts +10 -3
  261. package/dist/core/runner/prepare-park-ask.js +7 -9
  262. package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
  263. package/dist/core/runner/prepare-policy-chain.js +18 -13
  264. package/dist/core/runner/prepare-project-context.d.ts +1 -1
  265. package/dist/core/runner/prepare-project-context.js +5 -3
  266. package/dist/core/runner/prepare-prompt-assembly.js +2 -1
  267. package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
  268. package/dist/core/runner/prepare-prompt-inputs.js +1 -1
  269. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
  270. package/dist/core/runner/prepare-protocol-tools.js +7 -7
  271. package/dist/core/runner/prepare-question-face.d.ts +4 -2
  272. package/dist/core/runner/prepare-run-refs.d.ts +7 -2
  273. package/dist/core/runner/prepare-run-refs.js +8 -7
  274. package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
  275. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
  276. package/dist/core/runner/prepare-suspend-saga.js +4 -3
  277. package/dist/core/runner/prepare-task.js +66 -53
  278. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
  279. package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
  280. package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
  281. package/dist/core/runner/prepare-turn-wiring.js +1 -1
  282. package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
  283. package/dist/core/runner/prepare-wiring-manifest.js +14 -6
  284. package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
  285. package/dist/core/runner/prepare-workspace-restore.js +15 -6
  286. package/dist/core/runner/remote-env-retry.d.ts +3 -3
  287. package/dist/core/runner/restore-seat.d.ts +41 -0
  288. package/dist/core/runner/restore-seat.js +38 -0
  289. package/dist/core/runner/resume-admission.js +1 -1
  290. package/dist/core/runner/resume-apply.js +4 -3
  291. package/dist/core/runner/resume-checkpoint-screen.js +2 -1
  292. package/dist/core/runner/resume-internals-and-config.js +2 -1
  293. package/dist/core/runner/resume-preflight.js +2 -1
  294. package/dist/core/runner/rewind-files.js +22 -6
  295. package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
  296. package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
  297. package/dist/core/runner/run-brain-sinks.d.ts +3 -6
  298. package/dist/core/runner/run-brain-sinks.js +6 -6
  299. package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
  300. package/dist/core/runner/run-git-lane.d.ts +2 -0
  301. package/dist/core/runner/run-git-lane.js +2 -1
  302. package/dist/core/runner/run-harness-handlers.js +5 -4
  303. package/dist/core/runner/run-identity-wiring.js +20 -12
  304. package/dist/core/runner/run-leg.js +31 -72
  305. package/dist/core/runner/run-notification-lane.d.ts +3 -0
  306. package/dist/core/runner/run-notification-lane.js +2 -4
  307. package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
  308. package/dist/core/runner/run-reasoning-seat.js +13 -18
  309. package/dist/core/runner/run-settle-and-teardown.js +13 -9
  310. package/dist/core/runner/run-terminal-adoption.js +4 -8
  311. package/dist/core/runner/run-turn-boundary.js +6 -3
  312. package/dist/core/runner/runtask.d.ts +9 -4
  313. package/dist/core/runner/runtask.js +29 -22
  314. package/dist/core/runner/session-rule-policy.d.ts +11 -1
  315. package/dist/core/runner/shell-env-withheld.js +2 -7
  316. package/dist/core/runner/side-call-account.d.ts +5 -6
  317. package/dist/core/runner/side-call-account.js +2 -2
  318. package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
  319. package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
  320. package/dist/core/runner/stream-settle-backstop.js +4 -6
  321. package/dist/core/runner/stream-steer-verb.d.ts +1 -1
  322. package/dist/core/runner/stream-steer-verb.js +4 -4
  323. package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
  324. package/dist/core/runner/sub-agent-deny-lists.js +7 -4
  325. package/dist/core/runner/teardown-bounded.d.ts +7 -0
  326. package/dist/core/runner/teardown-bounded.js +7 -0
  327. package/dist/core/runner/terminal-account.js +41 -13
  328. package/dist/core/runner/terminal-projection.d.ts +1 -5
  329. package/dist/core/runner/tool-end-body.d.ts +9 -3
  330. package/dist/core/runner/tool-end-body.js +6 -3
  331. package/dist/core/runner/tool-output-projection.d.ts +13 -4
  332. package/dist/core/runner/tool-output-projection.js +10 -14
  333. package/dist/core/runner/turn-attachments.d.ts +3 -2
  334. package/dist/core/runner/turn-attachments.js +12 -5
  335. package/dist/core/runner-deps.d.ts +6 -6
  336. package/dist/core/runtime-caps.d.ts +2 -1
  337. package/dist/core/secret-env.d.ts +20 -3
  338. package/dist/core/secret-env.js +13 -15
  339. package/dist/core/session-checkout.d.ts +115 -15
  340. package/dist/core/session-checkout.js +435 -136
  341. package/dist/core/session-policy-store.js +21 -3
  342. package/dist/core/session-reconcile.js +1 -0
  343. package/dist/core/session-store.js +2 -0
  344. package/dist/core/session.d.ts +11 -1
  345. package/dist/core/shell-run-candidates.d.ts +1 -0
  346. package/dist/core/shell-run-candidates.js +1 -1
  347. package/dist/core/shutdown-debug.d.ts +6 -5
  348. package/dist/core/shutdown-debug.js +5 -1
  349. package/dist/core/skill-grant.js +4 -1
  350. package/dist/core/skills-directory.js +5 -3
  351. package/dist/core/spec-contract.d.ts +1 -1
  352. package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
  353. package/dist/core/store-contracts/file-history-store-contract.js +26 -2
  354. package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
  355. package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
  356. package/dist/core/store-contracts/task-list-store-contract.js +28 -1
  357. package/dist/core/task-event.d.ts +48 -27
  358. package/dist/core/task-notification.d.ts +15 -9
  359. package/dist/core/task-notification.js +12 -0
  360. package/dist/core/task-registry-agent.d.ts +24 -22
  361. package/dist/core/task-registry-agent.js +65 -46
  362. package/dist/core/task-registry-shared.d.ts +17 -5
  363. package/dist/core/task-registry.d.ts +17 -6
  364. package/dist/core/task-registry.js +6 -1
  365. package/dist/core/task-result.d.ts +71 -25
  366. package/dist/core/task-spec-members.d.ts +0 -1
  367. package/dist/core/task-spec-members.js +1 -1
  368. package/dist/core/task-spec.d.ts +60 -52
  369. package/dist/core/task-stream.d.ts +45 -12
  370. package/dist/core/terminal-cause.d.ts +45 -8
  371. package/dist/core/terminal-cause.js +5 -0
  372. package/dist/core/tool-card-bound.d.ts +32 -0
  373. package/dist/core/tool-card-bound.js +33 -0
  374. package/dist/core/tool-catalog-entries.d.ts +9 -0
  375. package/dist/core/tool-catalog-entries.js +48 -0
  376. package/dist/core/tool-errors.d.ts +4 -3
  377. package/dist/core/tool-face.d.ts +3 -3
  378. package/dist/core/tool-mount-facts.d.ts +3 -2
  379. package/dist/core/tool-mount-facts.js +1 -1
  380. package/dist/core/tool-mount-static.js +7 -5
  381. package/dist/core/tool-policy.d.ts +21 -19
  382. package/dist/core/tool-policy.js +5 -6
  383. package/dist/core/tool-registry.d.ts +3 -1
  384. package/dist/core/tool-registry.js +15 -1
  385. package/dist/core/tool-result-store.d.ts +9 -3
  386. package/dist/core/tool-result-store.js +14 -1
  387. package/dist/core/tool-roster.d.ts +6 -0
  388. package/dist/core/tool-roster.js +18 -0
  389. package/dist/core/tool-spec.d.ts +17 -8
  390. package/dist/core/trace.d.ts +35 -31
  391. package/dist/core/types.d.ts +2 -2
  392. package/dist/core/untrusted-egress.d.ts +10 -9
  393. package/dist/core/untrusted-egress.js +9 -9
  394. package/dist/core/untrusted-text.d.ts +0 -18
  395. package/dist/core/untrusted-text.js +7 -3
  396. package/dist/core/user-attachment.d.ts +9 -6
  397. package/dist/core/user-attachment.js +12 -10
  398. package/dist/core/user-row-origin.d.ts +44 -25
  399. package/dist/core/user-row-origin.js +30 -20
  400. package/dist/core/wiring-manifest.d.ts +26 -7
  401. package/dist/core/wiring-manifest.js +14 -11
  402. package/dist/core/workspace-snapshot.d.ts +3 -1
  403. package/dist/core/workspace-snapshot.js +1 -0
  404. package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
  405. package/dist/engine/execution-env/node-execution-env.js +127 -67
  406. package/dist/engine/harness/agent-harness.d.ts +4 -5
  407. package/dist/engine/harness/agent-harness.js +2 -7
  408. package/dist/engine/harness/types.d.ts +51 -19
  409. package/dist/engine/harness/types.js +28 -1
  410. package/dist/engine/llm/types.d.ts +26 -14
  411. package/dist/engine/llm/types.js +2 -2
  412. package/dist/engine/loop/agent-loop.d.ts +2 -2
  413. package/dist/engine/loop/agent-loop.js +51 -275
  414. package/dist/engine/loop/types.d.ts +0 -18
  415. package/dist/engine/session/import-validate.d.ts +3 -0
  416. package/dist/engine/session/import-validate.js +34 -2
  417. package/dist/engine/session/repo-utils.d.ts +42 -4
  418. package/dist/engine/session/repo-utils.js +33 -5
  419. package/dist/engine/session/session.d.ts +41 -14
  420. package/dist/engine/session/session.js +96 -25
  421. package/dist/index.d.ts +21 -16
  422. package/dist/index.js +16 -10
  423. package/dist/orchestration/run-spec.d.ts +1 -1
  424. package/dist/orchestration/run-workflow-tool.d.ts +12 -9
  425. package/dist/orchestration/run-workflow-tool.js +15 -19
  426. package/dist/orchestration/workflow-governance.js +13 -21
  427. package/dist/orchestration/workflow-observe.d.ts +4 -3
  428. package/dist/orchestration/workflow-primitives.d.ts +1 -1
  429. package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
  430. package/dist/orchestration/workflow-record-artifact.js +32 -0
  431. package/dist/orchestration/workflow-script-store.d.ts +9 -0
  432. package/dist/orchestration/workflow-script-store.js +20 -1
  433. package/dist/orchestration/workflow-types.d.ts +33 -3
  434. package/dist/orchestration/workflow.d.ts +24 -14
  435. package/dist/orchestration/workflow.js +52 -23
  436. package/dist/prompt-assembly/artifact.js +4 -8
  437. package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
  438. package/dist/prompt-assembly/catalog/engine.js +30 -0
  439. package/dist/prompt-assembly/catalog/index.d.ts +1 -1
  440. package/dist/prompt-assembly/catalog/index.js +2 -2
  441. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
  442. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
  443. package/dist/prompt-assembly/epoch.js +6 -8
  444. package/dist/prompt-assembly/turn-snapshot.js +8 -9
  445. package/dist/stores/file/background-agent-store.js +5 -6
  446. package/dist/stores/file/checkpoint-store.d.ts +0 -4
  447. package/dist/stores/file/checkpoint-store.js +7 -3
  448. package/dist/stores/file/file-history-store.d.ts +8 -0
  449. package/dist/stores/file/file-history-store.js +72 -0
  450. package/dist/stores/file/fs-atomic.js +17 -12
  451. package/dist/stores/file/index.js +11 -5
  452. package/dist/stores/file/mailbox-store.js +13 -4
  453. package/dist/stores/file/permission-rule-store.js +14 -13
  454. package/dist/stores/file/shared-ledger.d.ts +4 -0
  455. package/dist/stores/file/shared-ledger.js +4 -0
  456. package/dist/stores/file/task-list-store.js +12 -3
  457. package/dist/stores/file/workflow-run-store.js +1 -0
  458. package/dist/tools/fs/bash-program-position.d.ts +4 -2
  459. package/dist/tools/fs/bash-program-position.js +1 -1
  460. package/dist/tools/fs/bash-readonly-classifier.js +1 -1
  461. package/dist/tools/fs/bound-open.d.ts +97 -0
  462. package/dist/tools/fs/bound-open.js +103 -0
  463. package/dist/tools/fs/containment-face.d.ts +2 -2
  464. package/dist/tools/fs/fs-pdf.d.ts +7 -1
  465. package/dist/tools/fs/fs-pdf.js +31 -23
  466. package/dist/tools/fs/fs-read.d.ts +24 -17
  467. package/dist/tools/fs/fs-read.js +84 -53
  468. package/dist/tools/fs/fs-shared.d.ts +14 -12
  469. package/dist/tools/fs/fs-shared.js +5 -4
  470. package/dist/tools/fs/fs-write.d.ts +2 -2
  471. package/dist/tools/fs/fs-write.js +20 -12
  472. package/dist/tools/fs/index.d.ts +4 -4
  473. package/dist/tools/fs/index.js +2 -2
  474. package/dist/tools/fs/notebook.d.ts +1 -1
  475. package/dist/tools/fs/pdf.d.ts +12 -3
  476. package/dist/tools/fs/pdf.js +22 -9
  477. package/dist/tools/fs/read-deny-home.d.ts +3 -2
  478. package/dist/tools/fs/read-deny-home.js +8 -11
  479. package/dist/tools/fs/safety.d.ts +3 -2
  480. package/dist/tools/fs/shell-read-check.js +10 -9
  481. package/dist/tools/monitor.d.ts +6 -5
  482. package/dist/tools/task-list.d.ts +16 -6
  483. package/dist/tools/task-list.js +4 -0
  484. package/dist/tools/web.d.ts +9 -1
  485. package/dist/tools/web.js +8 -3
  486. package/dist/tools/worktree.d.ts +7 -5
  487. package/dist/tools/worktree.js +4 -3
  488. package/package.json +4 -3
  489. package/test/export-surface.snapshot.json +93 -7
  490. package/wire-changes/core-stores-sql@7.68.0.json +39 -0
  491. package/wire-changes/core@7.68.0.json +4257 -0
  492. package/wire-changes/mods-kernel@7.68.0.json +129 -0
  493. package/wire-changes/primitives@7.68.0.json +253 -0
  494. package/wire-changes/wiki-gate@7.68.0.json +39 -0
  495. package/dist/core/runner/credential-origin-seat.d.ts +0 -2
  496. package/dist/core/runner/credential-origin-seat.js +0 -20
@@ -6,12 +6,12 @@ import { nearMissSpellingOf, splitNamespacedName, toolNameFaultOf } from "./tool
6
6
  import { catalogToolNames, isShellFaceToolName } from "./tool-registry.js";
7
7
  import { ALLOW_RULE_MEMBERS } from "./allow-rule-shadow.js";
8
8
  import { callHostTargetOf } from "./host-target.js";
9
- import { adjudicatePersistedDomainRules, wholeToolRuleReaches, adjudicatePersistedNameRules, commandCoverageOf, ruleWordsOf, ruleContentOf, noticeRuleText, parseRuleText, programRunReachOf, ruleToolGrammarOf, unusableDeclaredBase, PATH_RULE_BASES, PATH_RULE_BASE_LABEL, commandPatternMayRun } from "./permission-rule-model.js";
9
+ import { adjudicatePersistedDomainRules, wholeToolRuleReaches, adjudicatePersistedNameRules, commandCoverageOf, ruleWordsOf, ruleContentOf, noticeRuleText, parseRuleText, programRunReachOf, ruleToolGrammarOf, unusableDeclaredBase, PATH_RULE_BASES, PATH_RULE_BASE_LABEL } from "./permission-rule-model.js";
10
+ import { autoStripReasonOf as stripReasonOf, entryOfRow, readFaceAutoStrip } from "./auto-strip.js";
10
11
  import { pathRuleLaneAnswer } from "./runner/permission-rule-lanes.js";
11
12
  import { policyAnchors } from "./path-rule-binding.js";
12
13
  import { receiptRefusal, receiveOwnProperties } from "./own-property-receipt.js";
13
14
  import { callTargetReadingOf } from "./effective-path-target.js";
14
- import { splitShellCompoundSegments } from "../tools/fs/bash-readonly-classifier.js";
15
15
  import { ASK_RULE_DISCLOSURE, MANDATE_DISCLOSURE, mandateDisclosureOf } from "./ask-origin.js";
16
16
  import { inlineUntrusted, isMintableProbeReason } from "./untrusted-text.js";
17
17
  import { callerText } from "./caller-text.js";
@@ -109,68 +109,42 @@ export function compileAllowList(entries, behavior, roster) {
109
109
  function answersTo(req, has) {
110
110
  return heldBy("allowEntry.names", { has }, req);
111
111
  }
112
- export const AUTO_STRIPPED_PROGRAMS = Object.freeze([
113
- "python", "python3", "python2", "node", "deno", "tsx", "ruby", "perl", "php", "lua", "npx", "bunx", "npm run", "yarn run", "pnpm run", "bun run", "bash", "sh", "ssh",
114
- "zsh", "fish", "eval", "exec", "env", "xargs", "sudo",
115
- ]);
116
- function shellContentStripped(content) {
117
- if (content === undefined || content === "" || /^[\s*]+$/.test(content))
118
- return true;
119
- const n = content.trim().toLowerCase();
120
- if (n === "*")
121
- return true;
122
- for (const program of AUTO_STRIPPED_PROGRAMS) {
123
- const g = program.toLowerCase();
124
- if (n === g || n === `${g}:*` || n === `${g} *` || n === `${g}*`)
125
- return true;
126
- if (n.startsWith(`${g} `) && n.endsWith("*")) {
127
- const tail = n.slice(g.length + 1);
128
- if (tail.startsWith("-") && !(/^python[\d.]*$/.test(g) && /^-m\s+\w+\.[\w.]+(\s*:|\s+)$/.test(tail.slice(0, -1))))
129
- return true;
130
- }
131
- }
132
- return false;
133
- }
134
- function shellRuleContent(rule) {
135
- const split = splitShellCompoundSegments(rule.command, { trailingTerminator: "keep", redirection: "reject" });
136
- const body = "reject" in split ? rule.command : (split.segments[split.segments.length - 1] ?? rule.command).trim();
137
- return rule.match === "prefix" ? `${body}:*` : rule.match === "wildcard" ? `${body} *` : body;
112
+ export function autoStripReasonOf(compiled, call, allShell) {
113
+ return stripReasonOf(compiled, () => call !== undefined && answersTo(call, isShellFaceToolName), allShell);
138
114
  }
139
115
  export function autoStripped(compiled, call, allShell) {
140
- switch (compiled.kind) {
141
- case "shell":
142
- return true;
143
- case "tool":
144
- return call !== undefined && answersTo(call, isShellFaceToolName);
145
- case "command":
146
- if (allShell)
147
- return true;
148
- return compiled.rule.match === "pattern" ? commandPatternMayRun(compiled.rule.command, AUTO_STRIPPED_PROGRAMS) : shellContentStripped(shellRuleContent(compiled.rule));
149
- case "covering":
150
- case "path":
151
- case "name":
152
- case "domain":
153
- return allShell && call !== undefined && answersTo(call, isShellFaceToolName);
154
- default: {
155
- const exhaustive = compiled;
156
- return exhaustive;
157
- }
158
- }
116
+ return autoStripReasonOf(compiled, call, allShell) !== undefined;
159
117
  }
160
118
  export function strippedInAuto(compiled, call, mode, allShell) {
161
119
  return mode === "auto" && autoStripped(compiled, call, allShell);
162
120
  }
163
- export function autoStrippedRule(rule, call, mode, allShell) {
164
- if (rule.behavior !== "allow")
121
+ function allowEntrySpeaksFor(compiled, call, names) {
122
+ if (compiled.kind === "tool" || compiled.kind === "shell" || compiled.kind === "covering")
123
+ return nameRowReaches(compiled, call, names);
124
+ return ruleWordsOf(call, "allow").includes(compiled.rule.tool);
125
+ }
126
+ function strippedFor(row, call, mode, allShell, names, told) {
127
+ if (mode !== "auto")
165
128
  return false;
129
+ const reason = autoStripReasonOf(row.compiled, call, allShell);
130
+ if (reason === undefined)
131
+ return false;
132
+ if (told !== undefined && row.behavior === "allow" && allowEntrySpeaksFor(row.compiled, call, names))
133
+ told(row, reason);
134
+ return true;
135
+ }
136
+ export function autoStripReasonOfRow(rule, call, mode, allShell) {
137
+ if (mode !== "auto" || rule.behavior !== "allow")
138
+ return undefined;
166
139
  const entry = entryOfRow(rule);
167
- return entry !== undefined && strippedInAuto(entry, call, mode, allShell);
140
+ return entry === undefined ? undefined : autoStripReasonOf(entry, call, allShell);
141
+ }
142
+ export function autoStrippedRule(rule, call, mode, allShell) {
143
+ return autoStripReasonOfRow(rule, call, mode, allShell) !== undefined;
168
144
  }
169
- function entryOfRow(rule) {
170
- if (rule.match === "tool")
171
- return isShellFaceToolName(rule.tool) ? { kind: "shell", name: rule.tool } : { kind: "tool", name: rule.tool };
172
- const grammar = ruleToolGrammarOf(rule.tool);
173
- return grammar === undefined ? undefined : { kind: grammar, rule };
145
+ export function allowEntryAutoStrip(entry) {
146
+ const read = readRuleEntry(entry, "allow");
147
+ return read.kind === "row" ? readFaceAutoStrip(read.compiled) : undefined;
174
148
  }
175
149
  export function classifiesAllShell(spec) {
176
150
  return spec.classifyAllShell === true;
@@ -279,8 +253,8 @@ export function judgeAllowEntries(rows, req, behavior, ctx, posture = "grant", n
279
253
  }
280
254
  return undefined;
281
255
  }
282
- export function allowingRows(rows, req, mode, allShell) {
283
- return rows.filter((r) => !strippedInAuto(r.compiled, req, mode, allShell));
256
+ export function allowingRows(rows, req, mode, allShell, told, names = "every_name") {
257
+ return rows.filter((r) => !strippedFor(r, req, mode, allShell, names, told));
284
258
  }
285
259
  function allowListMemberOf(entry) {
286
260
  return typeof entry === "string" ? { rule: entry } : entry;
@@ -335,7 +309,9 @@ export class AllowEntryTable {
335
309
  lane(ctx) {
336
310
  return {
337
311
  allowing: (req, mode) => {
338
- const hit = judgeAllowEntries(allowingRows(this.held, req, mode, ctx.classifyAllShell === true), req, "allow", ctx, "grant", "wire_name");
312
+ const told = ctx.onAutoStripped;
313
+ const kept = allowingRows(this.held, req, mode, ctx.classifyAllShell === true, told === undefined ? undefined : (r, reason) => told({ entry: r.entry, reason }, req), "wire_name");
314
+ const hit = judgeAllowEntries(kept, req, "allow", ctx, "grant", "wire_name");
339
315
  if (hit === undefined)
340
316
  return undefined;
341
317
  const entries = hit.map((r) => r.entry);
@@ -521,9 +497,18 @@ function memberPhrase(s) {
521
497
  }
522
498
  }
523
499
  }
500
+ function ruleUnreadableReason(origin, ruleUnreadable) {
501
+ if (origin === "org_unavailable")
502
+ return "this deployment's organization policy cannot currently be read, so whether one of its rules forbids this call is unknown";
503
+ if (origin === "rule_store_unavailable" && ruleUnreadable === "persisted_call")
504
+ return "this call cannot be read against the person's standing deny and ask rules, so whether one of them forbids it is unknown";
505
+ if (origin === "rule_store_unavailable" && (ruleUnreadable === undefined || ruleUnreadable === "persisted_rows"))
506
+ return "the person's standing permission rules cannot currently be read, so whether one of them forbids this call is unknown";
507
+ return SHADOW_REASON.rule_unreadable;
508
+ }
524
509
  export function allowRuleShadowSentence(shadows, ask) {
525
510
  const one = shadows.length === 1 && (shadows[0].member === "hook" || shadows[0].entries.length + (shadows[0].omitted ?? 0) === 1);
526
- const { askClass, mandate, authoredBy, probeReason } = ask;
511
+ const { askClass, origin, ruleUnreadable, mandate, authoredBy, probeReason } = ask;
527
512
  const account = typeof probeReason === "string" && probeReason.trim().length > 0 && isMintableProbeReason(probeReason) ? probeReason : undefined;
528
513
  const why = mandate !== undefined
529
514
  ? mandateDisclosureOf(mandate, account)
@@ -531,7 +516,9 @@ export function allowRuleShadowSentence(shadows, ask) {
531
516
  ? "this deployment requires a person's confirmation for this call"
532
517
  : askClass === "probe"
533
518
  ? account
534
- : SHADOW_REASON[askClass ?? "ordinary"];
519
+ : askClass === "rule_unreadable"
520
+ ? ruleUnreadableReason(origin, ruleUnreadable)
521
+ : SHADOW_REASON[askClass ?? "ordinary"];
535
522
  return `${shadows.map(memberPhrase).join("; ")} ${one ? "matches this call but does not clear the ask" : "match this call but do not clear the ask"}${why !== undefined ? ` — ${why}` : ""}`;
536
523
  }
537
524
  export const askFallbackMessage = (toolName) => `approval required for "${toolName}"`;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * An approval card's headline — the line a person reads first: why they are being asked, and whether a saved allow rule
3
+ * could ever stop the question. It is read off the ask's class word ({@link AskClass}) and nothing else, so each face — the live
4
+ * card, the parked row, the inbox listing (which echoes the row) — says the line of the class word it carries; the card's
5
+ * `message` stays the detailed account beside it.
6
+ *
7
+ * Two halves, one row each, joined by the catalog's joiner in the run's locale:
8
+ * · WHY — one catalog row per class ({@link ASK_HEADLINE_WHY}, fenced to the class set);
9
+ * · REMEDY — the class's own `ruleMayClear` column of {@link MODE_ARBITRATION}: whether saving an allow rule would stop it
10
+ * being asked again. Reading the class word's row is the same answer as reading the folded row of the ask's whole
11
+ * class set, because the classes a saved rule may clear are the last ones in {@link ASK_CLASSES} order and the class word is
12
+ * the first member of the set in that order — a set holding any class no rule clears discloses one of those.
13
+ *
14
+ * A display line, never an input: no gate, settlement, CAS or resume path reads it, and a reader branches on the class
15
+ * words. ABSENT when the ask carries no class word (a request a host built itself, the shared-artifact read
16
+ * confirmation, a row an earlier engine parked) or a class with nothing to say beyond the card's own header
17
+ * ({@link NO_HEADLINE_CLASSES}) — the engine gave no headline, the reader shows `message`. No row only repeats the card.
18
+ */
19
+ import { type AskClass, type AssertAllKeysHandled } from "./ask-origin.js";
20
+ import { type EngineText } from "../prompt-assembly/engine-text.js";
21
+ import type { AskRequest } from "./tool-policy.js";
22
+ /** The classes whose card has nothing to say first beyond its own header, so they carry no headline (the reader shows
23
+ * `message`) rather than a line that only repeats the card: the agent's own question is the question itself. Module-private:
24
+ * a reader learns it from the member's absence, not from a list. */
25
+ declare const NO_HEADLINE_CLASSES: readonly ["content_question"];
26
+ type NoHeadlineClass = (typeof NO_HEADLINE_CLASSES)[number];
27
+ /** The WHY row of each class that has one: `core/engine.ask-headline.<class>`. */
28
+ export declare const ASK_HEADLINE_WHY: Readonly<{
29
+ readonly mode: "core/engine.ask-headline.mode";
30
+ readonly hook: "core/engine.ask-headline.hook";
31
+ readonly org_rule: "core/engine.ask-headline.org_rule";
32
+ readonly write_protection: "core/engine.ask-headline.write_protection";
33
+ readonly ancestor: "core/engine.ask-headline.ancestor";
34
+ readonly dangerous_delete: "core/engine.ask-headline.dangerous_delete";
35
+ readonly unverifiable_delete: "core/engine.ask-headline.unverifiable_delete";
36
+ readonly unverifiable_shell_text: "core/engine.ask-headline.unverifiable_shell_text";
37
+ readonly transcript_write: "core/engine.ask-headline.transcript_write";
38
+ readonly rule_unreadable: "core/engine.ask-headline.rule_unreadable";
39
+ readonly ask_rule: "core/engine.ask-headline.ask_rule";
40
+ readonly denial_limit_fallback: "core/engine.ask-headline.denial_limit_fallback";
41
+ readonly classifier_no_ruling: "core/engine.ask-headline.classifier_no_ruling";
42
+ readonly requires_user_interaction: "core/engine.ask-headline.requires_user_interaction";
43
+ readonly cross_boundary: "core/engine.ask-headline.cross_boundary";
44
+ readonly operator_forced: "core/engine.ask-headline.operator_forced";
45
+ readonly shell_floor: "core/engine.ask-headline.shell_floor";
46
+ readonly target_unresolved: "core/engine.ask-headline.target_unresolved";
47
+ readonly probe: "core/engine.ask-headline.probe";
48
+ readonly write_protection_on_disk: "core/engine.ask-headline.write_protection_on_disk";
49
+ readonly tool_marks_mcp: "core/engine.ask-headline.tool_marks_mcp";
50
+ readonly tool_marks_a2a: "core/engine.ask-headline.tool_marks_a2a";
51
+ readonly policy_rra: "core/engine.ask-headline.policy_rra";
52
+ readonly artifact_shared_read: "core/engine.ask-headline.artifact_shared_read";
53
+ readonly unstated: "core/engine.ask-headline.unstated";
54
+ readonly ordinary: "core/engine.ask-headline.ordinary";
55
+ }>;
56
+ /** The fence over the WHY rows: `never` while every class has a row or is named in {@link NO_HEADLINE_CLASSES}. */
57
+ export type HeadlineTableCoversEveryClass = AssertAllKeysHandled<Exclude<AskClass, keyof typeof ASK_HEADLINE_WHY | NoHeadlineClass>>;
58
+ /** The headline of an ask whose class word is `askClass`, in `say`'s locale (absent ⇒ the canonical text); `undefined` when
59
+ * `askClass` is not a word of the class set or is one of {@link NO_HEADLINE_CLASSES}. */
60
+ export declare function askHeadlineOf(askClass: unknown, say?: EngineText): string | undefined;
61
+ /** The member as a request, a parked row and a listing carry it: present exactly when the class word mints one. */
62
+ export declare function askHeadlineMember(askClass: unknown, say?: EngineText): {
63
+ headline?: string;
64
+ };
65
+ /** The request with the engine's {@link AskRequest.headline} for its class word and no other — what the resolver's chokepoint
66
+ * hands on; the same object when there is nothing to mint and nothing to drop. */
67
+ export declare function withEngineHeadline(req: AskRequest, say: EngineText | undefined): AskRequest;
68
+ export {};
@@ -0,0 +1,23 @@
1
+ import { ASK_CLASSES, MODE_ARBITRATION, isAskClass } from "./ask-origin.js";
2
+ import { engineTextFor } from "../prompt-assembly/engine-text.js";
3
+ const NO_HEADLINE_CLASSES = Object.freeze(["content_question"]);
4
+ const NO_HEADLINE = new Set(NO_HEADLINE_CLASSES);
5
+ const hasHeadline = (c) => !NO_HEADLINE.has(c);
6
+ export const ASK_HEADLINE_WHY = Object.freeze(Object.fromEntries(ASK_CLASSES.filter((c) => !NO_HEADLINE.has(c)).map((c) => [c, `core/engine.ask-headline.${c}`])));
7
+ const REMEDY = { true: "core/engine.ask-headline-remedy.rule-clears", false: "core/engine.ask-headline-remedy.rule-cannot" };
8
+ export function askHeadlineOf(askClass, say = engineTextFor()) {
9
+ if (!isAskClass(askClass) || !hasHeadline(askClass))
10
+ return undefined;
11
+ return say("core/engine.ask-headline-join", { why: say(ASK_HEADLINE_WHY[askClass]), remedy: say(REMEDY[`${MODE_ARBITRATION[askClass].ruleMayClear}`]) });
12
+ }
13
+ export function askHeadlineMember(askClass, say) {
14
+ const headline = askHeadlineOf(askClass, say);
15
+ return headline !== undefined ? { headline } : {};
16
+ }
17
+ export function withEngineHeadline(req, say) {
18
+ const minted = askHeadlineMember(req.askClass, say);
19
+ if (minted.headline === undefined && !Object.hasOwn(req, "headline"))
20
+ return req;
21
+ const { headline: _claimed, ...rest } = req;
22
+ return { ...rest, ...minted };
23
+ }
@@ -100,11 +100,21 @@ export declare function isAskOrigin(v: unknown): v is AskOrigin;
100
100
  * hook entry of {@link AskReason}: `asked` — the hook itself asks, in its own words (the answer's `message`); `verdict_unreadable`
101
101
  * — the hook's host could not read the verdict the hook gave, so it asks a person instead; `verdict_unfinished` — the hook did not
102
102
  * finish with a verdict (it timed out, exited, could not be run), so its host asks a person. On the two `verdict_*` words the
103
- * answer's `message` is the host's own account and is not the hook's words: no entry carries it. An answer that states no cause
104
- * reads as `asked`.
103
+ * answer's `message` is the host's own account and is not the hook's words: no entry carries it — the entry's `words` are the
104
+ * engine's own sentence for the cause ({@link HOOK_CAUSE_WORDS}). An answer that states no cause reads as `asked`.
105
105
  */
106
106
  export declare const HOOK_QUESTION_CAUSES: readonly ["asked", "verdict_unreadable", "verdict_unfinished"];
107
107
  export type HookQuestionCause = (typeof HOOK_QUESTION_CAUSES)[number];
108
+ /**
109
+ * The engine's own words for a hook cause that is not the hook's own question — the ONE sentence of each, minted into the hook
110
+ * entry's `words` and read back by the request's sentence ({@link import("./tool-policy.js").extensionQuestionText}) and by the
111
+ * row's screen ({@link receiveAskReasons}). Whose words an entry's `words` are is read off its `cause`: the hook's for `asked`, the
112
+ * engine's for these two.
113
+ */
114
+ export declare const HOOK_CAUSE_WORDS: Readonly<{
115
+ readonly verdict_unreadable: "the hook's verdict could not be read";
116
+ readonly verdict_unfinished: "the hook did not finish with a verdict";
117
+ }>;
108
118
  /** Membership test for {@link HookQuestionCause} — the receipt's screen of the hook seat's member. */
109
119
  export declare function isHookQuestionCause(v: unknown): v is HookQuestionCause;
110
120
  /**
@@ -113,8 +123,9 @@ export declare function isHookQuestionCause(v: unknown): v is HookQuestionCause;
113
123
  * guard's, a rule's —, a hook's or an extension's reason, a hook host's cause word); a sentence the engine composes about a call
114
124
  * whose fact already rides a typed member (a tool mark, an allow layer's shadow, a classifier's no-ruling, a generic question)
115
125
  * is no entry. `by` names the asker with the {@link AskOrigin} word for it; a hook entry names its registration when the engine
116
- * knows it and the {@link HookQuestionCause}, and carries `words` only when the hook itself asked (`asked`). `words` is
117
- * untrusted display text, already one line and capped ({@link ASK_REASON_WORDS_MAX}).
126
+ * knows it and the {@link HookQuestionCause}, and carries `words` — the hook's own on `asked` (absent when it gave no reason), the
127
+ * engine's sentence for the cause on the two `verdict_*` words ({@link HOOK_CAUSE_WORDS}); whose words they are is read off `cause`.
128
+ * `words` is untrusted display text, already one line and capped ({@link ASK_REASON_WORDS_MAX}).
118
129
  */
119
130
  export type AskReason = {
120
131
  readonly by: "hook";
@@ -140,8 +151,10 @@ export declare const ASK_REASON_WORDS_MAX = 500;
140
151
  * whose entry names the asker its own members say ({@link chainAskReasonsOf}) — not a word the gate's later layers would add.
141
152
  */
142
153
  export declare const INHERITED_STATION_FACTS: Omit<AskOriginFacts, "call">;
143
- /** A hook's entry ({@link AskReason}): the registration that answered (when the engine knows it), the cause, and — only when the hook
144
- * itself asked — its reason as untrusted display text. Every station that reads a hook's or an extension's `ask` mints it here. */
154
+ /** A hook's entry ({@link AskReason}): the registration that answered (when the engine knows it), the cause, and its words — the
155
+ * hook's own reason as untrusted display text when the hook itself asked (none when it gave none), the engine's sentence for the
156
+ * cause otherwise ({@link HOOK_CAUSE_WORDS}; the host's account in `reason` is carried by no entry). Every station that reads a
157
+ * hook's or an extension's `ask` mints it here. */
145
158
  export declare function hookAskReasonOf(registration: string | undefined, cause: HookQuestionCause, reason: string | undefined): Extract<AskReason, {
146
159
  by: "hook";
147
160
  }>;
@@ -562,6 +575,19 @@ export declare function safetyAxisOf(marks: MandateMarks & {
562
575
  irreversible: boolean;
563
576
  shell?: boolean;
564
577
  } | undefined;
578
+ /**
579
+ * The engine's judgment of WHAT a call is, on the two axes a person scrutinizes differently — "cannot be undone" and "data
580
+ * leaves the machine" — as the live approval card (`AskRequest.riskAxes`) and the parked row (`RiskDescriptor.riskAxes`) both
581
+ * carry it: one type, one mint (the policy chain's `riskAxesOf`). Each member is three-valued: `true` and `false` are
582
+ * judgments; ABSENT means the engine did not judge that axis (read it as unjudged, never as `false`), and the whole member is
583
+ * absent when neither was judged. It is NOT the set of axes that TRIPPED the gate ({@link SafetyAxis} / `RiskDescriptor.axes`,
584
+ * which says why a gate fired: a shell-seat ask trips `shell` and never `irreversible`, though its `"maybe"` tier reads
585
+ * `irreversible: true` here). Display / triage metadata: nothing reads it to gate.
586
+ */
587
+ export interface CallRiskAxes {
588
+ readonly irreversible?: boolean;
589
+ readonly egress?: boolean;
590
+ }
565
591
  /**
566
592
  * The permission-mode closed set — the ONE key a caller sets (`TaskSpec.permissionMode`), spelled as the wire and
567
593
  * the reference implementation spell it. A root task's absent key reads `default`; a child's absent key inherits
@@ -1006,7 +1032,7 @@ export declare function unresolvedAskQuestionOf(cause: UnresolvedAskCause, toolN
1006
1032
  export declare function headlessDenialMessage(toolName: string, askMessage: string): string;
1007
1033
  /**
1008
1034
  * The refusal the model reads when the `dontAsk` permission mode refuses an ask (`deniedBy: "mode"`): the reference implementation's
1009
- * head (whose permission, which mode — with the ask's class beside it) and its guidance ({@link REFUSED_CAPABILITY_GUIDANCE}), then
1035
+ * head (whose permission, which mode — with the ask's own question beside it, which says where and why; the ask's class word only when the ask carries no message) and its guidance ({@link REFUSED_CAPABILITY_GUIDANCE}), then
1010
1036
  * the way out, the ONE remedy function's `dontAsk` arm ({@link headlessApprovalRemedy}) — the same sentence a headless refusal's
1011
1037
  * remedy is written by, so a mode refusal and a headless one say the way out in one voice. `ruleShape` is the shape of the allow
1012
1038
  * rule that would speak for the call (`ruleShapeOf` under `allow`, the rule model's reading of the call's grammar). The sentence
@@ -1018,7 +1044,8 @@ export declare function dontAskRefusalMessage(input: {
1018
1044
  readonly toolName: string;
1019
1045
  readonly classification: AskClassification;
1020
1046
  readonly coveredWrite: boolean;
1021
- readonly ruleShape: string;
1047
+ readonly ruleShape: string; /** the ask's own message, untrusted display text (see the body) */
1048
+ readonly question?: string;
1022
1049
  }): string;
1023
1050
  /** The state of the approver seat a remedy is written for: `absent` — no approver is wired for the leg; `unavailable` — one is
1024
1051
  * wired and answered that nobody is reachable for this ask; `policy` — the approver wired is the deployment's approval policy
@@ -1085,6 +1112,7 @@ export declare function headlessApprovalRemedy(input: {
1085
1112
  };
1086
1113
  readonly approverSeat?: HeadlessApproverSeat;
1087
1114
  readonly ruleShape?: string;
1115
+ readonly notResumableWayOut?: string;
1088
1116
  }): HeadlessApprovalRemedy;
1089
1117
  /** The reference implementation's sentence for a `cp` / `mv` the mode will not answer because it carries option
1090
1118
  * words — the approval card's message under `acceptEdits` and the head of the headless remedy. */
@@ -8,13 +8,17 @@ export function isAskOrigin(v) {
8
8
  }
9
9
  export const HOOK_QUESTION_CAUSES = Object.freeze(["asked", "verdict_unreadable", "verdict_unfinished"]);
10
10
  const HOOK_QUESTION_CAUSE_SET = new Set(HOOK_QUESTION_CAUSES);
11
+ export const HOOK_CAUSE_WORDS = Object.freeze({
12
+ verdict_unreadable: "the hook's verdict could not be read",
13
+ verdict_unfinished: "the hook did not finish with a verdict",
14
+ });
11
15
  export function isHookQuestionCause(v) {
12
16
  return HOOK_QUESTION_CAUSE_SET.has(v);
13
17
  }
14
18
  export const ASK_REASON_WORDS_MAX = 500;
15
19
  export const INHERITED_STATION_FACTS = { contentQuestion: false, markedUnresolvable: false, org: undefined, tightened: undefined, mandateMarks: {} };
16
20
  export function hookAskReasonOf(registration, cause, reason) {
17
- const words = cause === "asked" && reason !== undefined ? inlineUntrusted(reason, ASK_REASON_WORDS_MAX) : undefined;
21
+ const words = cause === "asked" ? (reason !== undefined ? inlineUntrusted(reason, ASK_REASON_WORDS_MAX) : undefined) : HOOK_CAUSE_WORDS[cause];
18
22
  return Object.freeze({ by: "hook", ...(registration !== undefined ? { registration } : {}), cause, ...(words !== undefined ? { words } : {}) });
19
23
  }
20
24
  export function chainAskReasonsOf(receipt, call) {
@@ -61,7 +65,7 @@ function receivedEntry(e) {
61
65
  const registration = ownEntryMember(e, "registration");
62
66
  if (!isHookQuestionCause(cause) || (registration !== undefined && typeof registration !== "string"))
63
67
  return undefined;
64
- if (words !== undefined && (typeof words !== "string" || cause !== "asked"))
68
+ if (words !== undefined && (typeof words !== "string" || (cause !== "asked" && words !== HOOK_CAUSE_WORDS[cause])))
65
69
  return undefined;
66
70
  return Object.freeze({ by: "hook", ...(registration !== undefined ? { registration } : {}), cause, ...(words !== undefined ? { words } : {}) });
67
71
  }
@@ -489,7 +493,8 @@ export function headlessDenialMessage(toolName, askMessage) {
489
493
  const REFUSED_CAPABILITY_GUIDANCE = "IMPORTANT: you may try to accomplish this with other tools that would naturally be used for it (for example `head` instead of `cat`), but do not work around this denial in malicious ways — for example, do not use your ability to run tests to run non-test actions; only work around it in reasonable ways that keep to the intent behind it. If you believe this capability is essential to complete the user's request, STOP and explain to the user what you were trying to do and why you need this permission, and let the user decide how to proceed.";
490
494
  export function dontAskRefusalMessage(input) {
491
495
  const remedy = headlessApprovalRemedy({ mode: "dontAsk", classification: input.classification, coveredWrite: input.coveredWrite, ruleShape: input.ruleShape }).sentence;
492
- return `Permission to use ${input.toolName} has been denied because this run is in the dontAsk permission mode (this call needed approval: ${input.classification.askClass}). ${REFUSED_CAPABILITY_GUIDANCE} To let a call like this run: ${remedy}.`;
496
+ const question = input.question !== undefined ? inlineUntrusted(input.question, ASK_REASON_WORDS_MAX) : "";
497
+ return `Permission to use ${input.toolName} has been denied because this run is in the dontAsk permission mode (this call needed approval: ${question !== "" ? question : input.classification.askClass}). ${REFUSED_CAPABILITY_GUIDANCE} To let a call like this run: ${remedy}.`;
493
498
  }
494
499
  export const APPROVAL_REMEDY_KINDS = Object.freeze(["approver", "permission_mode"]);
495
500
  const APPROVAL_REMEDY_KIND_SET = new Set(APPROVAL_REMEDY_KINDS);
@@ -529,13 +534,15 @@ export function headlessApprovalRemedy(input) {
529
534
  ? `an allow rule covering this call answers it under dontAsk — add one${input.ruleShape !== undefined ? ` in this tool's rule shape (\`${input.ruleShape}\`)` : ""} to the allow rules (a settings file's \`permissions.allow\`, or the request's or the deployment's allow list), or run under a mode with an approver`
530
535
  : `no allow rule answers this ask${c !== undefined ? ` (${c.askClass})` : ""} — only a person can: run under a mode with an approver, or change the call`);
531
536
  }
532
- const approver = input.approverSeat === "unavailable"
533
- ? "make a person reachable through the approver that is wired (it answered `unavailable` for this ask)"
534
- : input.approverSeat === "policy"
535
- ? "the deployment's approval policy answered `unavailable` for this ask — arm a durable approval park so the ask waits for a person, or run it where a person can be asked"
536
- : input.approverSeat === "declared_none"
537
- ? 'run it where a person can be asked — this run declares `approvalReach: "none"` (nobody on it can be asked) — or arm a durable approval park so the ask waits for a person'
538
- : "wire an approver (`onAsk`) to put it to a person";
537
+ const approver = input.notResumableWayOut !== undefined
538
+ ? input.notResumableWayOut
539
+ : input.approverSeat === "unavailable"
540
+ ? "make a person reachable through the approver that is wired (it answered `unavailable` for this ask)"
541
+ : input.approverSeat === "policy"
542
+ ? "the deployment's approval policy answered `unavailable` for this ask — arm a durable approval park so the ask waits for a person, or run it where a person can be asked"
543
+ : input.approverSeat === "declared_none"
544
+ ? 'run it where a person can be asked — this run declares `approvalReach: "none"` (nobody on it can be asked) — or arm a durable approval park so the ask waits for a person'
545
+ : "wire an approver (`onAsk`) to put it to a person";
539
546
  const c = input.classification;
540
547
  if (input.mode === "acceptEdits" && input.unplacedOptions !== undefined && (c === undefined || (c.classes.size === 1 && c.classes.has("ordinary"))))
541
548
  return way(`${fileCommandOptionsSentence(input.unplacedOptions.program)} Spell the ${input.unplacedOptions.program} without option words for the mode to answer it, or ${approver}`);
@@ -1,5 +1,5 @@
1
1
  import type { AgentTool } from "../internal/harness-types.js";
2
- import type { ToolPolicy } from "./tool-policy.js";
2
+ import type { PermissionResult, ToolPolicy } from "./tool-policy.js";
3
3
  import type { AssertAllKeysHandled } from "./ask-origin.js";
4
4
  /** The reserved tool name for AskUserQuestion — shared so the durable-resume path (runtask) can recognize it
5
5
  * as a content-ask whose SHOWN questions must not be rewritten by an operator `updatedInput` (design/80 D-F).
@@ -21,6 +21,15 @@ export declare const isEngineQuestionFace: (face: {
21
21
  readonly engineMounted?: true;
22
22
  readonly contractId: string;
23
23
  } | undefined) => boolean;
24
+ /** The sentence of a question that waits on a person's answer on a durable seat: the durable-question policy asks with it,
25
+ * and the gate a parked question files carries it as its reason — one string, so the card and the row say the same thing. */
26
+ export declare const durableQuestionAwaitingSentence: (toolName: string) => string;
27
+ /** The sentence of any other call that waits on a person's approval on a durable seat: both plain gate kinds a park files carry it as their reason. */
28
+ export declare const durableApprovalAwaitingSentence: (toolName: string) => string;
29
+ /** What the model reads when no live face answered its question: no checkpoint facility took it for a durable answer, and a
30
+ * permission approver's yes / no cannot carry one. The gate's content route refuses with it, at the first adjudication and at an
31
+ * approved edit's re-judge alike. */
32
+ export declare const CONTENT_ASK_NOT_SHOWN: string;
24
33
  /**
25
34
  * AskUserQuestion (design/64 §5). A model-callable tool that lets the agent ask the USER a structured
26
35
  * multiple-choice question (which approach? which of these?) — distinct from the design/37 permission `ask`
@@ -125,13 +134,19 @@ export interface QuestionAnswer {
125
134
  /**
126
135
  * The "nobody could be reached for this one" arm of {@link OnQuestionOutcome}. Its contract is narrow and
127
136
  * load-bearing: return it ONLY when the deployment made ZERO interaction on this question — no card was
128
- * shown, no partial selection was collected, nothing was submitted. That is what lets the engine re-route
129
- * the same question (park it durably for a later human, or answer the honest "it was NOT shown" refusal)
130
- * without any risk of the same question being decided twice.
137
+ * shown, no partial selection was collected, nothing was submitted. "Shown" means presented on a live question
138
+ * face (a face a person can answer on now): a delivery to a ledger or an inbox with no live face is not shown,
139
+ * so `unavailable` is the right return for it. That is what lets the engine re-route the same question (park
140
+ * it durably for a later human, or refuse it with the sentence that no live face answered it) without any risk
141
+ * of the same question being decided twice.
131
142
  *
132
- * A face that DID show the question and then failed (disconnect, deadline after render, adapter error)
133
- * must THROW instead — the two are deliberately different values with different engine handling, and
134
- * folding a failure into this arm is what would put one question in front of two deciders.
143
+ * A face that DID present the question on a live face and then failed (disconnect, deadline after render,
144
+ * adapter error) must THROW instead — the two are deliberately different values with different engine
145
+ * handling, and folding a failure into this arm is what would put one question in front of two deciders.
146
+ *
147
+ * Returning this arm once the card was presented on a live question face — a window that elapsed with nobody
148
+ * answering included — is a violation of that contract: the engine reads the arm as "zero interaction" and
149
+ * re-routes the question, so a person who already saw the card is asked the same question again by a second route.
135
150
  */
136
151
  export interface QuestionUnavailable {
137
152
  readonly kind: "unavailable";
@@ -354,6 +369,18 @@ export interface AskUserQuestionToolOptions {
354
369
  * driving a policy outside a Runner stamps the face itself, `toolCallFaceOf(roster, name)`).
355
370
  */
356
371
  export declare function createDurableQuestionPolicy(): ToolPolicy;
372
+ /**
373
+ * The ask the engine's question tool carries by its nature — a CONTENT ask: the question goes to a person, it is never a
374
+ * permission verdict (the reference implementation's question tool answers `ask` from its own permission check). One mint for
375
+ * both forms a question takes: {@link createDurableQuestionPolicy} answers with it (the park, or the gate's routing to the live
376
+ * face), and the gate's mode read point reads it for a call no layer asked about (the tool then calls its live face itself) —
377
+ * so the permission mode reads ONE question whichever form delivers it, and refuses it, under `dontAsk`, in one sentence.
378
+ * The sentence is the parked row's card text; on the live form nobody reads it (a refusal speaks in the mode's words, and every
379
+ * other verdict leaves the call's allow standing). A fresh value per call.
380
+ */
381
+ export declare function questionToolAsk(): Extract<PermissionResult, {
382
+ action: "ask";
383
+ }>;
357
384
  /**
358
385
  * Placeholder {@link OnQuestion} that mounts the AskUserQuestion tool on a worker with NO live human
359
386
  * (the durable-ask suspend side, TC-5.4). It must never actually run — the durable-question policy
@@ -7,6 +7,12 @@ import { engineMountedAs, mountRuleFace, toolFace } from "./tool-catalog-entries
7
7
  import { thrownIs, thrownText } from "./thrown-value.js";
8
8
  export const ASK_USER_QUESTION_TOOL_NAME = "AskUserQuestion";
9
9
  export const isEngineQuestionFace = engineMountedAs(["ask-user-question"]);
10
+ export const durableQuestionAwaitingSentence = (toolName) => `${toolName}: awaiting a human answer (durable)`;
11
+ export const durableApprovalAwaitingSentence = (toolName) => `human approval required for tool "${toolName}"`;
12
+ export const CONTENT_ASK_NOT_SHOWN = "AskUserQuestion could not be parked for a durable human answer on this path (no checkpoint " +
13
+ "facility, or the suspend failed) and a synchronous permission approver cannot carry an answer — " +
14
+ "no live face answered it. Proceed with your best judgment and state the assumption " +
15
+ "you made.";
10
16
  export const QUESTION_OUTCOME_FAULTS = Object.freeze(["unreadable", "both_arms", "neither_arm", "not_capturable"]);
11
17
  export const QUESTION_OUTCOME_FAULT_TEXT = {
12
18
  unreadable: "a member of the value threw when it was read",
@@ -90,10 +96,13 @@ export function createDurableQuestionPolicy() {
90
96
  if (!isEngineQuestionFace(req.face)) {
91
97
  return { action: "allow" };
92
98
  }
93
- return { action: "ask", message: "AskUserQuestion: awaiting a human answer (durable)" };
99
+ return questionToolAsk();
94
100
  },
95
101
  };
96
102
  }
103
+ export function questionToolAsk() {
104
+ return { action: "ask", message: durableQuestionAwaitingSentence(ASK_USER_QUESTION_TOOL_NAME) };
105
+ }
97
106
  export const QUESTION_AWAITS_RESUME = async () => {
98
107
  const err = new Error("QUESTION_AWAITS_RESUME executed: durable ask is miswired — combine createDurableQuestionPolicy() " +
99
108
  "into the task's toolPolicy and run with durableApproval + a durable CheckpointStore, or supply " +
@@ -64,6 +64,9 @@ export interface AskUnresolvableFacts {
64
64
  * released by one — for a host that chooses which to offer. Rides exactly when {@link remedy} is the headless remedy's sentence
65
65
  * (`headlessApprovalRemedy`); a binding's own sentence, which has no way out to offer, carries none. */
66
66
  readonly remedies?: readonly ApprovalRemedy[];
67
+ /** The way out of a leg whose parks nobody resumes (`notResumableWayOut`, tool-policy.ts — the gate's leg seat, carried verbatim): the
68
+ * sentence's last clause says it, in place of the store-and-opt-in advice that cannot let such a leg's approvals wait. */
69
+ readonly notResumableWayOut?: string;
67
70
  }
68
71
  /**
69
72
  * Which causes take the caller-side remedy (`headlessApprovalRemedy`, ask-origin.ts), and in which seat's clause — the table IS
@@ -86,6 +89,10 @@ export type CauseRemedySeatCoversEveryCause = AssertAllKeysHandled<Exclude<AskUn
86
89
  /** The seat whose clause the refusal for `cause` carries its remedy in, or `undefined` when the cause takes no remedy
87
90
  * ({@link CAUSE_REMEDY_SEAT}); read once at the deny exit, which hands the sentence to the tool text and the notice alike. */
88
91
  export declare function askUnresolvableRemedySeat(cause: AskUnresolvableCause): HeadlessApproverSeat | undefined;
92
+ /** The run's record of one refused ask (`TaskResult.refusedAsks`), off the same facts its notice is composed from: the call, the cause,
93
+ * and the way out the refusal named — the headless remedy's sentence or a binding's own, else the way out of a leg whose parks cannot
94
+ * be resumed. */
95
+ export declare function refusedAskOf(facts: Pick<AskUnresolvableFacts, "toolName" | "toolCallId" | "cause" | "remedy" | "notResumableWayOut">): import("./task-result.js").RefusedAsk;
89
96
  /**
90
97
  * Compose the `delegation.ask_unresolvable` notice from the gate's deny-exit facts.
91
98
  *
@@ -19,8 +19,12 @@ const CAUSE_REMEDY_SEAT = {
19
19
  export function askUnresolvableRemedySeat(cause) {
20
20
  return CAUSE_REMEDY_SEAT[cause];
21
21
  }
22
+ export function refusedAskOf(facts) {
23
+ const remedy = facts.remedy ?? facts.notResumableWayOut;
24
+ return { toolName: facts.toolName, toolCallId: facts.toolCallId, cause: facts.cause, ...(remedy !== undefined ? { remedy } : {}) };
25
+ }
22
26
  export function askUnresolvableNotice(facts) {
23
- const { sessionId, sourceSessionId, agentId, toolName, toolCallId, cause, parkLaneExisted, remedy, remedies } = facts;
27
+ const { sessionId, sourceSessionId, agentId, toolName, toolCallId, cause, parkLaneExisted, remedy, remedies, notResumableWayOut } = facts;
24
28
  if (typeof sessionId !== "string" || sessionId.length === 0) {
25
29
  throw new TypeError("delegation.ask_unresolvable: sessionId is required — a user-audience notice with no session routes nowhere");
26
30
  }
@@ -57,8 +61,10 @@ export function askUnresolvableNotice(facts) {
57
61
  return {
58
62
  code: "delegation.ask_unresolvable",
59
63
  message: `approval for "${toolName}"${delegated ? ` (a ${DELEGATED}'s call)` : ""} could not be resolved: ${CAUSE_CLAUSE[cause]} and ${park} — ` +
60
- `the call was denied fail-closed and did not run. ${typeof remedy === "string" && remedy.length > 0 ? `To let it run: ${remedy}. ` : ""}To let such approvals wait for a person, run with a checkpoint store and a ` +
61
- `durable approval opt-in (or a live approver reachable for ${DELEGATED}s).`,
64
+ `the call was denied fail-closed and did not run. ${typeof remedy === "string" && remedy.length > 0 ? `To let it run: ${remedy}. ` : ""}` +
65
+ (typeof notResumableWayOut === "string" && notResumableWayOut.length > 0
66
+ ? `This leg's approvals cannot wait for a person — nobody resumes its parks${typeof remedy === "string" && remedy.length > 0 ? "." : `. To go on: ${notResumableWayOut}.`}`
67
+ : `To let such approvals wait for a person, run with a checkpoint store and a durable approval opt-in (or a live approver reachable for ${DELEGATED}s).`),
62
68
  detail: { sessionId, ...(delegated ? { sourceSessionId } : {}), ...(agentId !== undefined ? { agentId } : {}), toolName, toolCallId, cause, parkLaneExisted: parkLaneExisted === true, ...(typeof remedy === "string" && remedy.length > 0 ? { remedy } : {}), ...(remedyList !== undefined ? { remedies: remedyList } : {}) },
63
69
  };
64
70
  }