@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
@@ -144,7 +144,7 @@ export function mountedMcpOf(input) {
144
144
  return { server, tools };
145
145
  });
146
146
  const aggregate = input.roster.filter((t) => input.aggregateNames.has(t.name)).map((t) => t.name);
147
- return { servers, aggregate, ...(input.pool !== undefined ? { pool: input.pool } : {}), ...(input.hostSeats !== undefined ? { hostSeats: input.hostSeats } : {}) };
147
+ return { servers, aggregate, ...(input.hostSeats !== undefined ? { hostSeats: input.hostSeats } : {}) };
148
148
  }
149
149
  export function mountedMcpPoolRows(mounted) {
150
150
  return [
@@ -0,0 +1,24 @@
1
+ /**
2
+ * What a paused run waits on, named for the person who reads a resume's sentence — ONE reading of the parked row, by the
3
+ * kind of pause it is, for every resume sentence that says what is still waiting or what never started: an approval, a
4
+ * question's answer, a plan review, a paused run's continuation, a review, or a finished task waiting to be woken (which
5
+ * has no approval at all). A sentence that has no row in hand names the paused run, never a guessed kind.
6
+ */
7
+ import type { Checkpoint } from "./checkpoint-store.js";
8
+ /** The words one kind of pause is said in. */
9
+ export interface ParkNoun {
10
+ /** What is still waiting, as the subject of a sentence: "the approval request", "the finished task", … */
11
+ readonly waiting: string;
12
+ /** What to do to carry on: "resume it again", "wake it again". */
13
+ readonly again: string;
14
+ /** What never started when a resumed leg ended early: "the approved action", "the wake", … */
15
+ readonly started: string;
16
+ /** What the person gave that the resume redeems, for "the same …" and "a fresh …": "approval", "answer", "wake", … */
17
+ readonly grant: string;
18
+ }
19
+ /** The words for the pause `row` holds — a question's row (the engine's own question to a person) by its origin word, every
20
+ * other row by its pending action's kind; a row this engine does not know the kind of reads as {@link UNKNOWN_KIND}. */
21
+ export declare function parkNounOf(row: Pick<Checkpoint, "pendingAction"> | undefined): ParkNoun;
22
+ /** THE sentence of a resume cancelled before anything ran (`checkpoint.resume_aborted`): when it was cancelled, that nothing
23
+ * ran and the pause still waits, and what to do to carry on. */
24
+ export declare function resumeCancelledSentence(when: string, row: Pick<Checkpoint, "pendingAction"> | undefined): string;
@@ -0,0 +1,21 @@
1
+ const NOUNS = {
2
+ tool_approval: { waiting: "the approval request", again: "resume it again", started: "the approved action", grant: "approval" },
3
+ question: { waiting: "the question", again: "resume it again", started: "the answered question", grant: "answer" },
4
+ plan_review: { waiting: "the plan review", again: "resume it again", started: "the approved plan", grant: "plan approval" },
5
+ resource_limit: { waiting: "the paused run", again: "resume it again", started: "the continued run", grant: "continuation" },
6
+ review: { waiting: "the review", again: "resume it again", started: "the reviewed step", grant: "review" },
7
+ task_done: { waiting: "the finished task", again: "wake it again", started: "the wake", grant: "wake" },
8
+ };
9
+ const UNKNOWN_KIND = { waiting: "the paused run", again: "resume it again", started: "the resumed step", grant: "decision" };
10
+ export function parkNounOf(row) {
11
+ const pending = row?.pendingAction;
12
+ if (pending === undefined)
13
+ return UNKNOWN_KIND;
14
+ if (pending.kind === "tool_approval" && pending.origin === "content_question")
15
+ return NOUNS.question;
16
+ return Object.hasOwn(NOUNS, pending.kind) ? NOUNS[pending.kind] : UNKNOWN_KIND;
17
+ }
18
+ export function resumeCancelledSentence(when, row) {
19
+ const noun = parkNounOf(row);
20
+ return `the resume was cancelled ${when}: nothing ran, and ${noun.waiting} is still waiting — ${noun.again} to carry on`;
21
+ }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Can a park of this leg be resumed? — the one leg fact a park reads before it is minted, and the two sentences every refusal
3
+ * of such a leg shares. A park (a durable checkpoint row a decision or a limit waits on) is minted only on a leg someone resumes;
4
+ * the driver derives the fact once per leg ({@link approvalParkNotResumableOf}) and every park arm reads it by name.
5
+ */
6
+ /** Who says a leg's parks cannot be resumed — the closed set of {@link approvalParkNotResumableOf}'s two sources. `lane`: the leg was
7
+ * started in this run by an engine lane that holds no resume seat for it, so NO park of it (a decision or a resource one) can be
8
+ * resumed; `host`: the host declared its decision parks cannot be resumed (`TaskSpec.durableApproval: false`) — its resource parks can. */
9
+ export type ApprovalParkNotResumable = "lane" | "host";
10
+ /**
11
+ * THE leg fact "a park of this leg cannot be resumed", derived once per leg (the driver) and read by name: absent ⇔ every park the leg
12
+ * can mint has someone to resume it. Two sources, nothing else:
13
+ * · `lane` — this run started the leg on an engine lane (a delegated child, or an observer sidecar) and that lane did not say it holds
14
+ * the leg's parks (`RunInternals.parkLaneHeld`: a background lane that can park, a workflow whose park lane is armed). A synchronous
15
+ * or fork child, a background child whose lane cannot park, an observer, a retained agent's wake cycle: none of them is resumed by
16
+ * anyone, so none of their parks is minted. A host resuming a row of such a leg (`Runner.resume`) is not an engine lane: the resume
17
+ * is the host's, and only the host's word applies to it;
18
+ * · `host` — the host declared it cannot resume this leg's decision parks (`TaskSpec.durableApproval: false`, carried to every child).
19
+ */
20
+ export declare function approvalParkNotResumableOf(leg: {
21
+ engineLaneLeg: boolean;
22
+ parkLaneHeld: boolean;
23
+ hostDeclaredNotResumable: boolean;
24
+ }): ApprovalParkNotResumable | undefined;
25
+ /** The word every refusal on such a leg SAYS — its cause and its way out: the host's whenever the host declared it (its `false` rides
26
+ * to every child, so the parent leg and any background child are closed to a decision park too — the lane's way out would name roads
27
+ * that are not there), else the leg fact's own source. Park arms read the fact itself (a lane leg parks nothing, whatever the host said). */
28
+ export declare function notResumableSaysOf(fact: ApprovalParkNotResumable | undefined, hostDeclared: boolean): ApprovalParkNotResumable | undefined;
29
+ /** The way out a refusal on a leg whose parks cannot be resumed names, one clause per source (no capital, no stop: it is the tail of
30
+ * a sentence) — every refusal such a leg makes, to the model and to the person, says it in these words: the tool result of a refused
31
+ * ask or question (the deny exit's remedy, the mandated ask's refusal), the `delegation.ask_unresolvable` notice and the leg's
32
+ * `config.durable_gate_unavailable` announcement. `mandated`: the `forceDurableGate` entitlement binds the leg — nobody may answer its
33
+ * asks live, so the clause names only the roads where an approval can wait. `asks`: what the refused ask wanted of a person — an
34
+ * approval, or the answer to a question. */
35
+ export declare function notResumableWayOut(source: ApprovalParkNotResumable, mandated: boolean, asks?: "approval" | "answer"): string;
36
+ /** The refusal a plan-review request on such a leg answers with — the result of the call that asked (`ctx.requestReview()`). No
37
+ * plan_review row is minted there, so the call must not read as "presented": it says nobody will see the plan, then the way out —
38
+ * first the one a plan always has (hand it back in the final report: whoever reads this leg's result can present it for approval),
39
+ * then the roads where a review can wait (no person reviews a plan live, so the mandated form). */
40
+ export declare function reviewRefusalSentence(source: ApprovalParkNotResumable): string;
41
+ /** The clause naming why a leg's parks cannot be resumed, per source — the sentence's middle the refusals above share. */
42
+ export declare function notResumableClause(source: ApprovalParkNotResumable): string;
43
+ /** The facts a gate reads off a leg whose parks cannot be resumed: who says so, and whether the `forceDurableGate` entitlement binds the
44
+ * leg (`mandated`: nobody may answer its asks live). Absent ⇔ the leg's parks can be resumed. */
45
+ export interface NotResumableLeg {
46
+ readonly source: ApprovalParkNotResumable;
47
+ readonly mandated: boolean;
48
+ }
49
+ /** The refusal of an ask such a leg could not have answered, whatever asked it (the leg's own mandated ask, an inherited mandate, a
50
+ * question): `subject` says what wanted a person; the cause is the leg's (never a facility it lacks); how it was refused — without
51
+ * asking anyone, or after a live face was asked and gave no answer (`faced`: only a question that no mandate kept off its face is ever
52
+ * put to one here); then what came of it — a call did not run, a question got no answer — and that asking again on this leg is no use.
53
+ * No stop and no way out: the gate's deny exit appends the leg's way out ({@link notResumableWayOut}) and {@link NOT_RESUMABLE_CARRY_ON}
54
+ * to every ask nobody could answer. */
55
+ export declare function notResumableRefusal(subject: string, source: ApprovalParkNotResumable, asked: "call" | "question", faced?: boolean): string;
56
+ /** What the model does after such a refusal while the way out is not taken: say what was blocked, and go on with what needs no approval. */
57
+ export declare const NOT_RESUMABLE_CARRY_ON = "Meanwhile, tell the user what was blocked and why you needed it, and continue with the parts of the task that need no approval.";
58
+ /** The question tool's refusal on such a leg, read by both sites of the content route's not-shown refusal: the leg's cause; "once the
59
+ * live face gave no answer" only where a face was tried (one is wired and no mandate kept the question off it). */
60
+ export declare function questionNotShownOnLeg(leg: NotResumableLeg, faceWired: boolean): string;
@@ -0,0 +1,30 @@
1
+ export function approvalParkNotResumableOf(leg) {
2
+ if (leg.engineLaneLeg && !leg.parkLaneHeld)
3
+ return "lane";
4
+ return leg.hostDeclaredNotResumable ? "host" : undefined;
5
+ }
6
+ export function notResumableSaysOf(fact, hostDeclared) {
7
+ return fact === undefined ? undefined : hostDeclared ? "host" : fact;
8
+ }
9
+ export function notResumableWayOut(source, mandated, asks = "approval") {
10
+ const verb = asks === "answer" ? "answer" : "approve";
11
+ const later = source === "lane"
12
+ ? `ask from the parent leg itself, or delegate the work as a background agent on a lane that can park — its ${asks === "answer" ? "questions" : "approvals"} wait for a person to ${verb} later, and its result comes back`
13
+ : `run it where its host can resume a parked ${asks === "answer" ? "question" : "approval"} (this host declared it cannot: durableApproval: false)`;
14
+ return mandated ? later : `have a person who is present ${verb} it live, or ${later}`;
15
+ }
16
+ export function reviewRefusalSentence(source) {
17
+ return `This plan was not presented to anyone, and no one will review it: ${notResumableClause(source)}. To go on: give the plan in your final report — whoever reads this leg's result can present it to a person for approval; or ${notResumableWayOut(source, true)}.`;
18
+ }
19
+ export function notResumableClause(source) {
20
+ return source === "lane"
21
+ ? "this leg runs on a lane that holds no park of it (a synchronous or fork child, a background child whose lane cannot park, an observer, or a woken retained agent)"
22
+ : "its host declared that a parked approval of this run cannot be resumed (durableApproval: false)";
23
+ }
24
+ export function notResumableRefusal(subject, source, asked, faced = false) {
25
+ return `${subject}, and this leg cannot be resumed — ${notResumableClause(source)} — so it was refused ${faced ? "once the live face gave no answer" : "without asking anyone"} (fail-closed): ${asked === "call" ? "the call did not run (do not report it as done)" : "nobody answered it"}; do not retry it on this leg, where nothing can wait for a person`;
26
+ }
27
+ export const NOT_RESUMABLE_CARRY_ON = "Meanwhile, tell the user what was blocked and why you needed it, and continue with the parts of the task that need no approval.";
28
+ export function questionNotShownOnLeg(leg, faceWired) {
29
+ return `${notResumableRefusal("AskUserQuestion's question could not wait for a person's answer and no live face answered it", leg.source, "question", faceWired && !leg.mandated)}. Proceed with your best judgment and state the assumption you made.`;
30
+ }
@@ -37,11 +37,17 @@
37
37
  import type { PersistedRule, RuleScope } from "./permission-rule-model.js";
38
38
  import { type DurableRulePartitionProvider, type QuarantinedRuleAdd } from "./permission-rule-store.js";
39
39
  import { type RuleOwner } from "./rule-owner.js";
40
+ import { type RuleStoreFault } from "./rule-store-fault.js";
40
41
  import { type OrgRulePartitionConfig, type OrgRuleResolution } from "./permission-rule-org.js";
41
42
  import type { SessionRulePartition } from "./permission-rule-session.js";
42
43
  import type { StoreDurability, StoreFidelity } from "./checkpoint-store.js";
44
+ import { type AutoStripRowReason } from "./auto-strip.js";
45
+ /** The three sources a personal rule row can come from (every source but the org partition's), each word spelled here once — the
46
+ * closed set a reader of the words enumerates. The published faces that predate it read the same set as `Exclude<RuleSource, "org">`
47
+ * (a derivation of these words, kept so their declared types do not move). */
48
+ export type PersonalRuleSource = "user" | "project" | "session";
43
49
  /** The four sources a rule can come from — CC's settings-layer vocabulary folded onto sema's four. */
44
- export type RuleSource = "org" | "user" | "project" | "session";
50
+ export type RuleSource = "org" | PersonalRuleSource;
45
51
  /** The source of a row is a projection of its scope — `global` is the `user` source. */
46
52
  export declare function ruleSourceOf(scope: RuleScope): Exclude<RuleSource, "org">;
47
53
  /** One live personal rule in the effective view: the row itself, its source, and its standing under the
@@ -51,6 +57,14 @@ export declare function ruleSourceOf(scope: RuleScope): Exclude<RuleSource, "org
51
57
  export interface EffectivePermissionRule extends PersistedRule {
52
58
  source: Exclude<RuleSource, "org">;
53
59
  status: "live" | "shadowed-by-org";
60
+ /** Present iff auto mode does not use this ALLOW row — in `auto` it clears no call and the calls it names go to the classifier
61
+ * (the allow layer's strip, `storedRowAutoStrip`): `whole_shell` (it reaches every shell command) or `code_runner` (it opens a
62
+ * program that runs whatever code it is given). Derived here, like `source` and `status`, from the row alone: a run's own facts
63
+ * — a leg that declares `TaskSpec.classifyAllShell`, a tool that answers to the shell under another name — stand more rows down
64
+ * in that run, and that run tells the person (`permission.allow_rule_not_used_in_auto`). Absent on a row auto mode uses as
65
+ * written, on a row whose text reads as no allow rule (it grants nothing in any mode) and on every deny / ask row; read off the
66
+ * row's text, so a malformed row never fails the read. */
67
+ autoStrip?: AutoStripRowReason;
54
68
  }
55
69
  /** A durable rule identity every add of which is tombstoned — the rule no longer stands, and its
56
70
  * tombstone identity is still visible in the partition. Session rows never appear here (they die
@@ -72,6 +86,9 @@ export interface PersonRowsRead {
72
86
  readonly org?: OrgRuleResolution;
73
87
  /** Present iff a personal partition (or the whole read) could not be read: the failure's line. */
74
88
  readonly unreadable?: string;
89
+ /** Beside {@link unreadable}: why, as closed reason words — one fault per failed partition, or one over every partition a read that
90
+ * failed whole took out ({@link EffectivePermissionRules.unreadableFaults}). */
91
+ readonly unreadableFaults?: readonly RuleStoreFault[];
75
92
  }
76
93
  /** THE answer of the store's one read query. */
77
94
  export interface EffectivePermissionRules {
@@ -92,8 +109,13 @@ export interface EffectivePermissionRules {
92
109
  * and the leg's path-row read skip the failed partition's rows, disclosed, and judge by the rest. */
93
110
  unreadable?: string;
94
111
  /** Beside {@link unreadable}: the sources whose partition could not be read (`user` and `project` — the durable
95
- * partition; `session`), in that order — the rows `rules` does not carry. */
112
+ * partition; `session`), in that order — the rows `rules` does not carry. The flat list of {@link unreadableFaults}' sources. */
96
113
  unreadableSources?: readonly Exclude<RuleSource, "org">[];
114
+ /** Beside {@link unreadable}: WHY each failed partition could not be read — one fault per partition (the durable one covers the
115
+ * `user` and `project` sources together), each a closed reason word read off the refusal's code and members
116
+ * ({@link ruleStoreFaultReasonOf}); never the refusal's text and never a path. A store that reports `unreadable` without it states
117
+ * no cause, and the reader says so. */
118
+ unreadableFaults?: readonly RuleStoreFault[];
97
119
  /** Disclosure lines from the personal partitions (a session partition that could not be read, rows it
98
120
  * served that are not canonical session rows of this session). The org partition's lines ride
99
121
  * `org.disclosures`. */
@@ -1,9 +1,11 @@
1
1
  import { escapeForDisclosure, isRuleBehavior, parseRuleText } from "./permission-rule-model.js";
2
- import { PERMISSION_RULE_WRITER, errText, isValidDurableScope, normalizePersistedRule, sameRuleIdentity, writerOf, } from "./permission-rule-store.js";
2
+ import { PERMISSION_RULES_DAMAGED_BUCKET_CODE, PERMISSION_RULE_WRITER, errText, isValidDurableScope, normalizePersistedRule, sameRuleIdentity, writerOf, } from "./permission-rule-store.js";
3
3
  import { readRuleOwner } from "./rule-owner.js";
4
+ import { ruleStoreFaultReasonOf } from "./rule-store-fault.js";
4
5
  import { readPrincipal } from "./principal-name.js";
5
6
  import { optionKeys, receiveMembers } from "./own-property-receipt.js";
6
7
  import { UNGOVERNED_ORG_RESOLUTION, compileOrgShadowPredicate, createOrgRulePartition } from "./permission-rule-org.js";
8
+ import { storedRowAutoStrip } from "./auto-strip.js";
7
9
  export function ruleSourceOf(scope) {
8
10
  return scope.kind === "global" ? "user" : scope.kind;
9
11
  }
@@ -30,7 +32,7 @@ function durableReadOf(settled) {
30
32
  const row = rows[at];
31
33
  return {
32
34
  ok: false,
33
- e: new Error(`the persisted rule partition served a ${kind} row (#${at}, ${escapeForDisclosure(row?.rule)}) whose behavior word ${escapeForDisclosure(row?.behavior)} is outside deny/ask/allow — whether it refuses a call is unknown, so the partition is read as one that could not be read`),
35
+ e: Object.assign(new Error(`the persisted rule partition served a ${kind} row (#${at}, ${escapeForDisclosure(row?.rule)}) whose behavior word ${escapeForDisclosure(row?.behavior)} is outside deny/ask/allow — whether it refuses a call is unknown, so the partition is read as one that could not be read`), { code: PERMISSION_RULES_DAMAGED_BUCKET_CODE }),
34
36
  };
35
37
  }
36
38
  return settled;
@@ -89,16 +91,16 @@ class UnifiedPermissionRuleStore {
89
91
  ]);
90
92
  const orgResolution = orgSettled;
91
93
  const unreadable = [];
92
- const unreadableSources = [];
94
+ const faults = [];
93
95
  if (!durableSettled.ok) {
94
96
  unreadable.push(errText(durableSettled.e));
95
- unreadableSources.push("user", "project");
97
+ faults.push({ sources: ["user", "project"], reason: ruleStoreFaultReasonOf(durableSettled.e) });
96
98
  }
97
99
  if ("unreadable" in sessionRows) {
98
100
  unreadable.push(sessionRows.unreadable);
99
- unreadableSources.push("session");
101
+ faults.push({ sources: ["session"], reason: sessionRows.reason });
100
102
  }
101
- const failed = unreadable.length > 0 ? { unreadable: unreadable.join("; "), unreadableSources } : {};
103
+ const failed = faults.length > 0 ? { unreadable: unreadable.join("; "), unreadableSources: faults.flatMap((f) => f.sources), unreadableFaults: faults } : {};
102
104
  const durableRead = durableSettled.ok ? durableSettled.v : EMPTY_DURABLE;
103
105
  const sessionRead = "unreadable" in sessionRows ? [] : sessionRows;
104
106
  const shadowed = compileOrgShadowPredicate(orgResolution.rules);
@@ -108,7 +110,8 @@ class UnifiedPermissionRuleStore {
108
110
  if (illegal.length > 0)
109
111
  disclosures.push(`the persisted rule partition served ${illegal.length} row(s) whose project scope root is not a complete absolute path — dropped, not adjudicated: ${illegal.slice(0, 3).map((r) => `${escapeForDisclosure(r.rule)} (${escapeForDisclosure(r.scope.root)})`).join(", ")}`);
110
112
  for (const r of [...sessionRead, ...durableRead.rules.filter((x) => !illegal.includes(x))]) {
111
- rules.push({ ...r, source: ruleSourceOf(r.scope), status: r.behavior === "allow" && shadowed(r) ? "shadowed-by-org" : "live" });
113
+ const autoStrip = storedRowAutoStrip(r);
114
+ rules.push({ ...r, source: ruleSourceOf(r.scope), status: r.behavior === "allow" && shadowed(r) ? "shadowed-by-org" : "live", ...(autoStrip !== undefined ? { autoStrip } : {}) });
112
115
  }
113
116
  const removed = [];
114
117
  for (const t of durableRead.tombstones) {
@@ -139,7 +142,7 @@ class UnifiedPermissionRuleStore {
139
142
  catch (err) {
140
143
  const why = `the session rule partition could not be read: ${escapeForDisclosure(errText(err))}`;
141
144
  disclosures.push(why);
142
- return { unreadable: why };
145
+ return { unreadable: why, reason: ruleStoreFaultReasonOf(err) };
143
146
  }
144
147
  }
145
148
  }
@@ -71,7 +71,14 @@ export declare const PERMISSION_RULES_LATER_GRAMMAR_CODE = "permission_rules.lat
71
71
  * behavior word is outside the set, or a store directory this engine refuses to use. Every face refuses the bucket whole with it
72
72
  * (reads answer zero rules and disclose; a write refuses), so a caller tells "this bucket cannot be read and a retry reads the same" from
73
73
  * a read that failed ({@link PERMISSION_RULES_UNREADABLE_BUCKET_CODE}) and from a bucket a newer engine wrote
74
- * ({@link PERMISSION_RULES_LATER_GRAMMAR_CODE}). Decide by the code, never by the sentence.
74
+ * ({@link PERMISSION_RULES_LATER_GRAMMAR_CODE}). Decide by the code, never by the sentence. A refusal for a store directory that is
75
+ * unsafe in one of the two ways a directory's own state can be says which, in its own member `unsafe` (`"permissions"`: writable by
76
+ * group or others; `"owner"`: another account's) beside the code — absent on every other damaged-bucket refusal.
77
+ *
78
+ * The person is told this code as "the stored rules are damaged or not in a form this engine expects" — true of any store, so a host's
79
+ * own store (no file anywhere) may stamp it, and the provider stamps it on a served row whatever the backend. The `unsafe` member and
80
+ * {@link PERMISSION_RULES_UNREADABLE_BUCKET_CODE} are a file store's: they make the person's sentence name a folder or a file, so a store
81
+ * that is not a file stamps neither.
75
82
  */
76
83
  export declare const PERMISSION_RULES_DAMAGED_BUCKET_CODE = "permission_rules.bucket_damaged";
77
84
  /**
@@ -1,5 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
- import { canonicalize } from "./canonical-json.js";
2
+ import { canonicalize, textContentHashOf } from "./canonical-json.js";
3
3
  import { escapeForDisclosure, isRuleBehavior, isRuleLive, parseRuleText } from "./permission-rule-model.js";
4
4
  import { readRuleOwner } from "./rule-owner.js";
5
5
  import { PRINCIPAL_NAME_SPELLING } from "./principal-name.js";
@@ -472,8 +472,7 @@ export function assertRedemptionNotQuarantined(quarantined, delta) {
472
472
  }
473
473
  }
474
474
  export async function ruleStoreChecksum(payload) {
475
- const { createHash } = await import("node:crypto");
476
- return `sha256:${createHash("sha256").update(canonicalize(payload), "utf8").digest("hex")}`;
475
+ return textContentHashOf(canonicalize(payload));
477
476
  }
478
477
  export const REMOVAL_LIVENESS_WORDS = Object.freeze(["yes", "no", "unknown"]);
479
478
  export const RULE_WRITE_COMMITTED_WORDS = Object.freeze(["no", "unknown"]);
@@ -175,7 +175,8 @@ export interface PermissionRulePolicyOptions {
175
175
  * (maxRules) throws EVEN under `"skip"` — skipping it would compile an EMPTY table and fail-open. */
176
176
  onInvalidRule?: "throw" | "skip";
177
177
  /** Called once per dropped rule under `"skip"` (audit surface — silent drops are how a deployment
178
- * discovers, months later, that its deny never existed). Default: one aggregated `console.warn`. */
178
+ * discovers, months later, that its deny never existed). Default: one aggregated `config.permission_rules_skipped`
179
+ * notice on the process's default seat, else one process line. */
179
180
  onIssue?: (issue: PermissionRuleIssue) => void;
180
181
  /** What the policy returns when NO rule matches. Default `"allow"` = 本 policy 无意见(组合语义;不是同意)。
181
182
  * default-closed 部署用 `"ask"`/`"deny"` —— 必须在这 INSIDE the policy(链尾 ask policy 会改写整条链的答案)。 */
@@ -8,6 +8,7 @@ import { callTargetReadingOf, callTargetViewsOf } from "./effective-path-target.
8
8
  import { DEFAULT_MAX_SCALAR_VALUE_CHARS, paramRuleReaches } from "./param-rule-reach.js";
9
9
  import { bindPathRules, judgeRuleRows, policyAnchors, rowsWhereTheyLead } from "./path-rule-binding.js";
10
10
  import { ruleDenialSentence } from "./rule-denial-sentence.js";
11
+ import { deliverEngineNotice } from "./engine-notice.js";
11
12
  import { heldValues } from "./tool-name-readings.js";
12
13
  export { parsePermissionRule };
13
14
  function describeBehavior(v) {
@@ -281,7 +282,7 @@ function ruleDenial(req, ruleText, source, detail) {
281
282
  return ruleDenialSentence({ source: "permission", tool: req.toolName, rule: ruleText, ...(source ? { origin: source } : {}), ...(detail !== undefined ? { detail } : {}) });
282
283
  }
283
284
  function ruleAskMessage(ruleText, source) {
284
- return `flagged by permission rule "${ruleText}"${source ? ` (${source})` : ""}`;
285
+ return `the permission rule "${ruleText}"${source ? ` (${source})` : ""} requires approval before a call like this runs`;
285
286
  }
286
287
  const NO_LEADS = new Map();
287
288
  export function createPermissionRulePolicy(rules, opts) {
@@ -307,8 +308,11 @@ export function createPermissionRulePolicy(rules, opts) {
307
308
  }
308
309
  }
309
310
  else {
310
- console.warn(`createPermissionRulePolicy: skipped ${issues.length} invalid/unsupported rule(s): ` +
311
- issues.map((i) => `[${i.code}] ${i.rule}`).join("; "));
311
+ deliverEngineNotice(undefined, {
312
+ code: "config.permission_rules_skipped",
313
+ message: `createPermissionRulePolicy: skipped ${issues.length} invalid/unsupported rule(s): ` + issues.map((i) => `[${i.code}] ${i.rule}`).join("; "),
314
+ detail: { count: issues.length, codes: [...new Set(issues.map((i) => i.code))] },
315
+ });
312
316
  }
313
317
  }
314
318
  const defaultAction = opts?.defaultAction ?? "allow";
@@ -439,7 +443,7 @@ export function createPermissionRulePolicy(rules, opts) {
439
443
  };
440
444
  const unreadableAsk = (hit, lane, req) => ({
441
445
  action: "ask",
442
- message: `tool "${req.toolName}" needs approval: the call could not be read against the permission rule ${hit.rule.ruleText} (${hit.unreadable}) — a person must decide`,
446
+ message: `tool "${req.toolName}" needs approval: the call could not be read against the permission rule ${hit.rule.ruleText} (${hit.unreadable}), so the engine cannot tell whether that rule forbids it`,
443
447
  ruleUnreadable: lane,
444
448
  requiresRealApproval: true,
445
449
  });
@@ -23,7 +23,10 @@ export interface PersistedRuleRead {
23
23
  readonly unreadable?: true;
24
24
  /** The lexer's reason when the CALL could not be read against the person's deny/ask rows. */
25
25
  readonly reason?: string;
26
+ /** The store form's cause, when the lane said it: which partition(s) could not be read and why (closed reason words). */
27
+ readonly faults?: readonly RuleStoreFault[];
26
28
  }
29
+ import { type RuleStoreFault } from "./rule-store-fault.js";
27
30
  /** The answers of one store read judged under each of a call's names, folded as one table folds its rows (deny >
28
31
  * unreadable > ask > allow > coverage > nothing); among equals the first (the wire name's) stands. */
29
32
  export declare function strongestAnswer(answers: readonly PersistedRuleAnswer[]): PersistedRuleAnswer;
@@ -2,6 +2,7 @@ import { attest, attestationOf } from "./tool-policy.js";
2
2
  import { callPathFaceOf } from "./permission-rule-model.js";
3
3
  import { ownAskClassesOf } from "./ask-origin.js";
4
4
  import { inlineUntrusted } from "./untrusted-text.js";
5
+ import { ruleStoreUnreadableAskSentence } from "./rule-store-fault.js";
5
6
  export function strongestAnswer(answers) {
6
7
  const rank = (a) => (a === undefined ? 0 : "unreadable" in a ? 4 : "behavior" in a ? { deny: 5, ask: 3, allow: 2 }[a.behavior] : 1);
7
8
  return answers.reduce((best, a) => (rank(a) > rank(best) ? a : best), undefined);
@@ -18,7 +19,7 @@ export function applyPersistedTightening(decision, read, call) {
18
19
  const callForm = read.reason !== undefined;
19
20
  const message = callForm
20
21
  ? `this call could not be read against the person's standing deny/ask rules (${read.reason}) — whether one of them forbids it is unknown, so it needs a real approval`
21
- : "the person's standing permission rules could not be read — whether one of them forbids this call is unknown, so it needs a real approval";
22
+ : ruleStoreUnreadableAskSentence(read.faults);
22
23
  const unreadableCall = callForm ? { ruleUnreadable: "persisted_call" } : {};
23
24
  const tightened = callForm ? "unreadable" : "store_unreadable";
24
25
  if (decision.action === "allow") {
@@ -1,4 +1,4 @@
1
- import type { ToolSpec } from "./types.js";
1
+ import type { ToolExecuteContext, ToolSpec } from "./types.js";
2
2
  /** The first-party plan-review tool's name (design/80 D-B; CC `ExitPlanMode` parity). Reserved when
3
3
  * `TaskSpec.enablePlanMode` is set. */
4
4
  export declare const PRESENT_PLAN_TOOL_NAME = "ExitPlanMode";
@@ -25,14 +25,58 @@ export interface PlanFileSource {
25
25
  }
26
26
  /**
27
27
  * What the engine's plan-pause request primitive takes: the requester's own `reason`, and `requestedByCallId` — the id of
28
- * the call that asks, which the ENGINE binds from that call's own context (the first-party tool passes its ctx's
29
- * `toolCallId`; a caller tool's `ctx.requestReview` is wrapped per call), never a tool-supplied argument. Parked on the
28
+ * the call that asks, which the ENGINE binds from that call's own context through {@link reviewRequestFor} (both arms of the
29
+ * first-party tool and a caller tool's per-call `ctx.requestReview` alike), never a tool-supplied argument. Parked on the
30
30
  * `plan_review` row as provenance: which call presented the plan awaiting a decision.
31
31
  */
32
32
  export interface ReviewRequest {
33
33
  reason?: string;
34
34
  requestedByCallId?: string;
35
35
  }
36
+ /**
37
+ * A request a run holds until its next clean turn boundary: a {@link ReviewRequest}, plus what the requesting call's FINAL
38
+ * result showed, recorded by {@link notePresentedPlan} where that call's end is projected — `presented`, the plan text its
39
+ * card carried (the park mint digests it once onto the row), or `withdrawn`, the reason it showed a reviewer nothing (the
40
+ * mint then refuses the pause and says why). No requester hands either in.
41
+ */
42
+ export interface PendingReview extends ReviewRequest {
43
+ presented?: string;
44
+ /** Why the request was withdrawn at its own call's end: the call ended in error (its result failed or was withheld), or its
45
+ * plan card did not ride the frame (over the frame's bound, or with no plan string). Engine-internal: no wire face reads it. */
46
+ withdrawn?: "ended_in_error" | "plan_not_carried";
47
+ }
48
+ /**
49
+ * The leg's review-request cell: `pending`, the request the turn boundary hands to the park mint — the batch's FIRST request
50
+ * that may still show a plan — and `later`, the batch's other requests in the order they were made. A withdrawn `pending`
51
+ * yields to the first of `later` not withdrawn ({@link notePresentedPlan}); the boundary consumes both.
52
+ */
53
+ export interface ReviewRequestCell {
54
+ pending?: PendingReview;
55
+ later?: PendingReview[];
56
+ }
57
+ /** The clause the park mint's refusal says for a withdrawn request (its one sentence family: `plan_review park skipped: …`). */
58
+ export declare function reviewWithdrawalClause(why: NonNullable<PendingReview["withdrawn"]>): string;
59
+ /**
60
+ * The one binding of a plan-pause request to the call that asks: the requester's `reason` and the id of THIS call (the
61
+ * engine-minted `ctx.toolCallId`), so no tool can name another call as the requester. A revive context's id is minted for the
62
+ * revival and names no transcript call, and an empty id names none: neither is attributed. Nothing else crosses.
63
+ */
64
+ export declare function reviewRequestFor(ctx: Pick<ToolExecuteContext, "toolCallId" | "reviveClaim"> | undefined, reason: string | undefined): ReviewRequest;
65
+ /**
66
+ * Settle the pending request at its OWN call's end, by what that call's `tool_end` CARRIED — the leg's projection of the final
67
+ * result, after every post-execution station (a hook that withheld the result has already emptied it and marked the error).
68
+ * A person is asked only about a plan the card in front of them holds:
69
+ * · the frame carried a plan card ⇒ its `plan` is recorded (`presented`) and the pause carries its digest;
70
+ * · the call ended in error, or the result held a plan card the frame did not carry (left off for its size, or with no plan
71
+ * string) ⇒ the request is withdrawn (`withdrawn`): it showed a reviewer nothing, so no pause is minted for it;
72
+ * · the result held no plan card at all ⇒ nothing is recorded: a caller tool's own content is what it shows, and the pause
73
+ * carries no digest.
74
+ * Only the requests this call made, only once: another call's end never settles them. The batch's first request that may
75
+ * still show a plan stands in front — a withdrawn `pending` yields to the first of `later` not withdrawn, so a second plan
76
+ * whose call was told the run is pausing is the one put to the person; when every request is withdrawn, the first stays, and
77
+ * the mint says its reason. The card says what was SHOWN, whoever asked: a caller tool's card reads the same way.
78
+ */
79
+ export declare function notePresentedPlan(cell: ReviewRequestCell, toolCallId: string, result: unknown, card: unknown, isError: boolean): void;
36
80
  /**
37
81
  * design/80 D-B — the first-party `present_plan` tool (CC `ExitPlanMode` parity). A THIN composition over the
38
82
  * general `ctx.requestReview()` primitive: the model calls it with a plan; the tool returns the plan as its
@@ -2,6 +2,8 @@ import { Type } from "typebox";
2
2
  import { delimitUntrusted, inlineUntrusted } from "./untrusted-text.js";
3
3
  import { mountRuleFace, toolFace } from "./tool-catalog-entries.js";
4
4
  import { errorResult } from "./tools.js";
5
+ import { readMember } from "./thrown-value.js";
6
+ import { MAX_TOOL_CARD_CHARS, toolCardChars } from "./tool-card-bound.js";
5
7
  const READ_REASON_MAX = 600;
6
8
  export const PRESENT_PLAN_TOOL_NAME = "ExitPlanMode";
7
9
  export const ENTER_PLAN_MODE_TOOL_NAME = "EnterPlanMode";
@@ -79,6 +81,14 @@ Ensure your plan is complete and unambiguous:
79
81
 
80
82
  **Important:** Do NOT separately ask "Is this plan okay?" or "Should I proceed?" - that's exactly what THIS tool does. ExitPlanMode inherently requests user approval of your plan.`;
81
83
  const PAUSE_GAP_MAX = 400;
84
+ function planCardRefusal(card) {
85
+ const chars = toolCardChars(card);
86
+ if (chars <= MAX_TOOL_CARD_CHARS)
87
+ return undefined;
88
+ return errorResult(`The plan was NOT submitted for approval and plan mode was not exited: its approval card is ${chars.toFixed(0)} characters as JSON, over the ${MAX_TOOL_CARD_CHARS.toFixed(0)} that the card can carry. ` +
89
+ "A quote, backslash, tab or line break counts as two characters, any other control character as six, and a character outside the Basic Multilingual Plane (most emoji) as two. " +
90
+ "Shorten the plan and call ExitPlanMode again.");
91
+ }
82
92
  function createPresentPlanFileTool(requestReview, planFile, notPausing) {
83
93
  return {
84
94
  name: PRESENT_PLAN_TOOL_NAME,
@@ -93,17 +103,61 @@ function createPresentPlanFileTool(requestReview, planFile, notPausing) {
93
103
  if (read.text === undefined)
94
104
  return errorResult(`No plan file found at ${planFile.shown}. Please write your plan to this file before calling ExitPlanMode.`);
95
105
  const plan = read.text;
96
- requestReview({ reason: "ExitPlanMode" });
106
+ const card = exitPlanCard(plan, planFile.path);
107
+ const tooLarge = planCardRefusal(card);
108
+ if (tooLarge !== undefined)
109
+ return tooLarge;
110
+ requestReview(reviewRequestFor(ctx, "ExitPlanMode"));
97
111
  if (notPausing !== undefined)
98
112
  return notPausing();
99
113
  return {
100
114
  content: `Plan presented for human review (from ${planFile.shown}):\n\n${delimitUntrusted("plan", plan)}\n\n` +
101
115
  "(The run is pausing for approval — you will continue once the plan is approved, edited, or rejected.)",
102
- details: { type: "exit-plan-mode", plan, isAgent: false, filePath: planFile.path },
116
+ details: card,
103
117
  };
104
118
  },
105
119
  };
106
120
  }
121
+ export function reviewWithdrawalClause(why) {
122
+ return why === "ended_in_error"
123
+ ? "the call that requested it ended in error (its result failed or was withheld), so no plan card reached a reviewer"
124
+ : `the plan card of the call that requested it did not ride that call's tool_end (over the ${MAX_TOOL_CARD_CHARS} characters as JSON a frame carries, or with no plan string), so no plan reached a reviewer`;
125
+ }
126
+ export function reviewRequestFor(ctx, reason) {
127
+ return {
128
+ ...(reason !== undefined ? { reason } : {}),
129
+ ...(ctx !== undefined && ctx.reviveClaim === undefined && typeof ctx.toolCallId === "string" && ctx.toolCallId !== "" ? { requestedByCallId: ctx.toolCallId } : {}),
130
+ };
131
+ }
132
+ const EXIT_PLAN_CARD = "exit-plan-mode";
133
+ function exitPlanCard(plan, filePath) {
134
+ return { type: "exit-plan-mode", plan, isAgent: false, ...(filePath !== undefined ? { filePath } : {}) };
135
+ }
136
+ export function notePresentedPlan(cell, toolCallId, result, card, isError) {
137
+ const shown = shownBy(result, card, isError);
138
+ if (shown === undefined)
139
+ return;
140
+ const settle = (r) => (r.requestedByCallId === toolCallId && r.presented === undefined && r.withdrawn === undefined ? { ...r, ...shown } : r);
141
+ if (cell.pending !== undefined)
142
+ cell.pending = settle(cell.pending);
143
+ if (cell.later !== undefined)
144
+ cell.later = cell.later.map(settle);
145
+ if (cell.pending?.withdrawn === undefined || cell.later === undefined)
146
+ return;
147
+ const next = cell.later.findIndex((r) => r.withdrawn === undefined);
148
+ if (next < 0)
149
+ return;
150
+ cell.pending = cell.later[next];
151
+ cell.later = cell.later.slice(next + 1);
152
+ }
153
+ function shownBy(result, card, isError) {
154
+ if (isError)
155
+ return { withdrawn: "ended_in_error" };
156
+ if (readMember(readMember(result, "details"), "type") !== EXIT_PLAN_CARD)
157
+ return undefined;
158
+ const plan = readMember(card, "type") === EXIT_PLAN_CARD ? readMember(card, "plan") : undefined;
159
+ return typeof plan === "string" ? { presented: plan } : { withdrawn: "plan_not_carried" };
160
+ }
107
161
  export function createPresentPlanTool(requestReview, planFile, suspendGap) {
108
162
  const notPausing = suspendGap === undefined
109
163
  ? undefined
@@ -122,13 +176,17 @@ export function createPresentPlanTool(requestReview, planFile, suspendGap) {
122
176
  }),
123
177
  execute: async (args, ctx) => {
124
178
  const { plan } = args;
125
- requestReview({ reason: "ExitPlanMode", ...(typeof ctx?.toolCallId === "string" && ctx.toolCallId !== "" ? { requestedByCallId: ctx.toolCallId } : {}) });
179
+ const card = exitPlanCard(plan);
180
+ const tooLarge = planCardRefusal(card);
181
+ if (tooLarge !== undefined)
182
+ return tooLarge;
183
+ requestReview(reviewRequestFor(ctx, "ExitPlanMode"));
126
184
  if (notPausing !== undefined)
127
185
  return notPausing();
128
186
  return {
129
187
  content: `Plan presented for human review:\n\n${delimitUntrusted("plan", plan)}\n\n` +
130
188
  "(The run is pausing for approval — you will continue once the plan is approved, edited, or rejected.)",
131
- details: { type: "exit-plan-mode", plan, isAgent: false },
189
+ details: card,
132
190
  };
133
191
  },
134
192
  };
@@ -1,6 +1,6 @@
1
1
  /** The longest name any face keeps, in UTF-16 units: the principal's name rule and the box's name spelling (a receipt id, a lease owner, a
2
2
  * decision move's holder) read this one number. */
3
- export declare const NAME_MAX_CHARS = 256;
3
+ export declare const PRINCIPAL_NAME_MAX_CHARS = 256;
4
4
  /** The name rule as one clause for a refusal sentence that restates it ("must be a principal name (…)"): said once, so a face that spells the
5
5
  * rule out never drifts from {@link principalNameOf}. */
6
6
  export declare const PRINCIPAL_NAME_SPELLING = "a string with a visible character, no control or separator character, no format character but a joiner, and at most 256 characters";
@@ -1,12 +1,12 @@
1
1
  const NOT_IN_A_NAME = /[\p{Cc}\p{Zl}\p{Zp}]|(?![\u200c\u200d])\p{Cf}/u;
2
2
  const NOT_VISIBLE = /[\s\p{Cf}]+/gu;
3
- export const NAME_MAX_CHARS = 256;
4
- export const PRINCIPAL_NAME_SPELLING = `a string with a visible character, no control or separator character, no format character but a joiner, and at most ${NAME_MAX_CHARS} characters`;
3
+ export const PRINCIPAL_NAME_MAX_CHARS = 256;
4
+ export const PRINCIPAL_NAME_SPELLING = `a string with a visible character, no control or separator character, no format character but a joiner, and at most ${PRINCIPAL_NAME_MAX_CHARS} characters`;
5
5
  export function hasVisibleContent(raw) {
6
6
  return raw.replace(NOT_VISIBLE, "") !== "";
7
7
  }
8
8
  export function principalNameOf(raw) {
9
- return typeof raw === "string" && raw.length <= NAME_MAX_CHARS && hasVisibleContent(raw) && !NOT_IN_A_NAME.test(raw) ? raw : undefined;
9
+ return typeof raw === "string" && raw.length <= PRINCIPAL_NAME_MAX_CHARS && hasVisibleContent(raw) && !NOT_IN_A_NAME.test(raw) ? raw : undefined;
10
10
  }
11
11
  export function readPrincipal(raw) {
12
12
  if (raw === undefined || raw === "")
@@ -23,7 +23,7 @@ export function principalNameFault(raw) {
23
23
  return "a blank string";
24
24
  if (!hasVisibleContent(raw))
25
25
  return "a string with no visible character";
26
- if (raw.length > NAME_MAX_CHARS)
27
- return `a string longer than ${NAME_MAX_CHARS} characters`;
26
+ if (raw.length > PRINCIPAL_NAME_MAX_CHARS)
27
+ return `a string longer than ${PRINCIPAL_NAME_MAX_CHARS} characters`;
28
28
  return "a string holding a control, separator or format character";
29
29
  }