@sema-agent/core 7.54.1 → 7.56.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 (621) hide show
  1. package/CHANGELOG.md +950 -0
  2. package/dist/agents/agent-transcript-tool.js +2 -1
  3. package/dist/agents/builtin-agents.d.ts +12 -14
  4. package/dist/agents/cascade.js +1 -1
  5. package/dist/agents/cc-peer-directory.d.ts +36 -0
  6. package/dist/agents/cc-peer-directory.js +139 -0
  7. package/dist/agents/cc-peer-wire.d.ts +105 -0
  8. package/dist/agents/cc-peer-wire.js +98 -0
  9. package/dist/agents/cc-uds-peer-channel.d.ts +40 -0
  10. package/dist/agents/cc-uds-peer-channel.js +457 -0
  11. package/dist/agents/child-model-seat.d.ts +0 -11
  12. package/dist/agents/child-model-seat.js +0 -3
  13. package/dist/agents/cross-session-envelope.d.ts +4 -1
  14. package/dist/agents/cross-session-envelope.js +8 -1
  15. package/dist/agents/cross-session-judge.d.ts +2 -2
  16. package/dist/agents/list-agents-tool.d.ts +3 -1
  17. package/dist/agents/list-agents-tool.js +9 -8
  18. package/dist/agents/observer.d.ts +4 -5
  19. package/dist/agents/observer.js +2 -1
  20. package/dist/agents/peer-admission.d.ts +6 -0
  21. package/dist/agents/peer-admission.js +4 -1
  22. package/dist/agents/peer-directory.d.ts +65 -13
  23. package/dist/agents/peer-directory.js +90 -25
  24. package/dist/agents/peer-notices.d.ts +1 -1
  25. package/dist/agents/peer-session-drain.d.ts +3 -1
  26. package/dist/agents/peer-session-drain.js +3 -2
  27. package/dist/agents/read-inbox-tool.js +2 -1
  28. package/dist/agents/repair-loop.js +2 -2
  29. package/dist/agents/retain-ledger.d.ts +1 -1
  30. package/dist/agents/roster-store.d.ts +1 -1
  31. package/dist/agents/send-message-tool.d.ts +10 -0
  32. package/dist/agents/send-message-tool.js +37 -8
  33. package/dist/agents/subagent.d.ts +39 -82
  34. package/dist/agents/subagent.js +109 -106
  35. package/dist/agents/tool-filter.d.ts +31 -46
  36. package/dist/agents/tool-filter.js +13 -33
  37. package/dist/agents/verify.d.ts +6 -5
  38. package/dist/agents/verify.js +3 -3
  39. package/dist/brain/anthropic.js +43 -81
  40. package/dist/brain/errors.d.ts +15 -0
  41. package/dist/brain/errors.js +10 -0
  42. package/dist/brain/media-degrade.d.ts +18 -7
  43. package/dist/brain/media-degrade.js +13 -2
  44. package/dist/brain/model-capability.d.ts +37 -0
  45. package/dist/brain/model-capability.js +34 -0
  46. package/dist/brain/model-presets.d.ts +6 -12
  47. package/dist/brain/model-presets.js +1 -6
  48. package/dist/brain/open-responses.js +27 -35
  49. package/dist/brain/openai.js +30 -98
  50. package/dist/brain/provider-dialect.d.ts +39 -3
  51. package/dist/brain/provider-dialect.js +28 -0
  52. package/dist/brain/reasoning-request.d.ts +96 -0
  53. package/dist/brain/reasoning-request.js +174 -0
  54. package/dist/brain/reasoning.d.ts +12 -12
  55. package/dist/brain/reasoning.js +4 -3
  56. package/dist/brain/request-params.d.ts +62 -9
  57. package/dist/brain/request-params.js +42 -7
  58. package/dist/brain/retry.d.ts +1 -1
  59. package/dist/brain/route-adjudicator.d.ts +15 -0
  60. package/dist/brain/route-adjudicator.js +15 -0
  61. package/dist/brain/status-sink.d.ts +20 -0
  62. package/dist/brain/status-sink.js +7 -0
  63. package/dist/brain/stream-engine.js +6 -5
  64. package/dist/brain/stream-shared.d.ts +1 -1
  65. package/dist/core/a2a.d.ts +2 -1
  66. package/dist/core/a2a.js +19 -13
  67. package/dist/core/advisor-verdict.d.ts +120 -0
  68. package/dist/core/advisor-verdict.js +92 -0
  69. package/dist/core/agent-definition.d.ts +17 -8
  70. package/dist/core/allow-entry.d.ts +69 -36
  71. package/dist/core/allow-entry.js +81 -52
  72. package/dist/core/allow-rule-shadow.d.ts +10 -3
  73. package/dist/core/approval-object.d.ts +2 -1
  74. package/dist/core/approval-object.js +6 -6
  75. package/dist/core/ask-origin.d.ts +127 -29
  76. package/dist/core/ask-origin.js +87 -25
  77. package/dist/core/ask-question.d.ts +51 -8
  78. package/dist/core/ask-question.js +12 -7
  79. package/dist/core/ask-unresolvable-notice.d.ts +8 -3
  80. package/dist/core/ask-unresolvable-notice.js +16 -2
  81. package/dist/core/auto-compaction.d.ts +11 -8
  82. package/dist/core/auto-compaction.js +4 -2
  83. package/dist/core/auto-mode-arming.d.ts +2 -2
  84. package/dist/core/auto-mode-defaults.d.ts +8 -8
  85. package/dist/core/auto-mode-prompt-assets.d.ts +3 -3
  86. package/dist/core/auto-mode-prompt.d.ts +1 -1
  87. package/dist/core/auto-mode.d.ts +17 -9
  88. package/dist/core/auto-mode.js +9 -6
  89. package/dist/core/background-agent-store.d.ts +3 -3
  90. package/dist/core/canonical-json.d.ts +1 -1
  91. package/dist/core/canonical-json.js +2 -2
  92. package/dist/core/checkpoint-generation.d.ts +53 -0
  93. package/dist/core/checkpoint-generation.js +35 -0
  94. package/dist/core/checkpoint-queries.d.ts +180 -0
  95. package/dist/core/checkpoint-queries.js +272 -0
  96. package/dist/core/checkpoint-requirements.d.ts +19 -4
  97. package/dist/core/checkpoint-requirements.js +8 -14
  98. package/dist/core/checkpoint-store.d.ts +165 -72
  99. package/dist/core/checkpoint-store.js +79 -82
  100. package/dist/core/child-clamp-seats.d.ts +6 -0
  101. package/dist/core/child-clamp-seats.js +3 -16
  102. package/dist/core/compliance.d.ts +2 -2
  103. package/dist/core/context-edit.d.ts +6 -7
  104. package/dist/core/cross-boundary-taint.d.ts +11 -4
  105. package/dist/core/cross-boundary-taint.js +3 -3
  106. package/dist/core/decision-receipt.d.ts +37 -3
  107. package/dist/core/decision-receipt.js +19 -19
  108. package/dist/core/delegation-not-started.d.ts +6 -0
  109. package/dist/core/delegation-not-started.js +17 -0
  110. package/dist/core/effective-path-target.d.ts +1 -1
  111. package/dist/core/engine-attestation.d.ts +93 -0
  112. package/dist/core/engine-attestation.js +70 -0
  113. package/dist/core/engine-capabilities.d.ts +4 -1
  114. package/dist/core/engine-capabilities.js +1 -1
  115. package/dist/core/engine-notice.d.ts +45 -12
  116. package/dist/core/exec-output-tail.d.ts +1 -1
  117. package/dist/core/file-history-retention.d.ts +1 -1
  118. package/dist/core/file-history-store.d.ts +147 -21
  119. package/dist/core/file-history-store.js +58 -32
  120. package/dist/core/gate-fold.d.ts +1 -1
  121. package/dist/core/gate-fold.js +24 -11
  122. package/dist/core/gate-lanes.js +81 -68
  123. package/dist/core/gate-outcome.d.ts +40 -6
  124. package/dist/core/gate-outcome.js +56 -0
  125. package/dist/core/governance-codes.d.ts +17 -3
  126. package/dist/core/governance-codes.js +16 -0
  127. package/dist/core/hands-band.d.ts +1 -1
  128. package/dist/core/hooks.d.ts +21 -20
  129. package/dist/core/hooks.js +3 -1
  130. package/dist/core/host-floor.d.ts +128 -0
  131. package/dist/core/host-floor.js +206 -0
  132. package/dist/core/host-target.d.ts +84 -0
  133. package/dist/core/host-target.js +92 -0
  134. package/dist/core/image-downsample.d.ts +1 -1
  135. package/dist/core/lsp-diagnostics.d.ts +4 -4
  136. package/dist/core/lsp.d.ts +3 -3
  137. package/dist/core/mailbox-store.d.ts +4 -0
  138. package/dist/core/mcp-connection-pool.d.ts +18 -2
  139. package/dist/core/mcp-connection-pool.js +53 -6
  140. package/dist/core/mcp-failure.d.ts +23 -4
  141. package/dist/core/mcp-failure.js +26 -11
  142. package/dist/core/mcp-listing-drift.d.ts +10 -0
  143. package/dist/core/mcp-listing-drift.js +6 -0
  144. package/dist/core/mcp-server-link.d.ts +173 -0
  145. package/dist/core/mcp-server-link.js +127 -0
  146. package/dist/core/mcp-server-spec.d.ts +4 -2
  147. package/dist/core/mcp-session-end.d.ts +26 -0
  148. package/dist/core/mcp-session-end.js +29 -0
  149. package/dist/core/mcp-startup-request.d.ts +17 -0
  150. package/dist/core/mcp-startup-request.js +17 -0
  151. package/dist/core/mcp.d.ts +17 -13
  152. package/dist/core/mcp.js +240 -189
  153. package/dist/core/media-byte-cap.d.ts +1 -1
  154. package/dist/core/memory-engine/delegation-settlement.js +15 -24
  155. package/dist/core/memory-engine/engine.d.ts +9 -9
  156. package/dist/core/memory-engine/engine.js +4 -4
  157. package/dist/core/memory-engine/layout.d.ts +60 -8
  158. package/dist/core/memory-engine/layout.js +65 -6
  159. package/dist/core/memory-engine/provenance-wording.d.ts +1 -1
  160. package/dist/core/memory-engine/tools.js +4 -1
  161. package/dist/core/mode-policy.d.ts +1 -1
  162. package/dist/core/model-seat.d.ts +10 -3
  163. package/dist/core/mods/classic-events.d.ts +67 -0
  164. package/dist/core/mods/classic-events.js +1 -0
  165. package/dist/core/mods/dollar.d.ts +13 -0
  166. package/dist/core/mods/extension-call.d.ts +31 -0
  167. package/dist/core/mods/extension-call.js +43 -0
  168. package/dist/core/mods/kernel/dispatch.d.ts +20 -3
  169. package/dist/core/mods/kernel/dispatch.js +140 -69
  170. package/dist/core/mods/kernel/events.d.ts +47 -11
  171. package/dist/core/mods/kernel/events.js +66 -42
  172. package/dist/core/mods/kernel/index.d.ts +4 -4
  173. package/dist/core/mods/kernel/index.js +2 -2
  174. package/dist/core/mods/kernel/receive.d.ts +39 -5
  175. package/dist/core/mods/kernel/receive.js +290 -17
  176. package/dist/core/mods/kernel/registration.d.ts +33 -2
  177. package/dist/core/mods/kernel/registration.js +6 -7
  178. package/dist/core/mods/kernel/site-rules.d.ts +44 -16
  179. package/dist/core/mods/kernel/site-rules.js +24 -42
  180. package/dist/core/mods/spec-seats.d.ts +69 -0
  181. package/dist/core/mods/spec-seats.js +114 -0
  182. package/dist/core/mods/stations.d.ts +28 -8
  183. package/dist/core/mods/stations.js +29 -13
  184. package/dist/core/mods/tool-call.d.ts +79 -0
  185. package/dist/core/mods/tool-call.js +152 -0
  186. package/dist/core/namespaced-rule-name.d.ts +44 -24
  187. package/dist/core/namespaced-rule-name.js +50 -43
  188. package/dist/core/output-style.d.ts +1 -1
  189. package/dist/core/param-rule-reach.d.ts +15 -0
  190. package/dist/core/param-rule-reach.js +30 -0
  191. package/dist/core/parent-spec-seat.d.ts +13 -1
  192. package/dist/core/parent-spec-seat.js +6 -0
  193. package/dist/core/park-selfcheck.js +1 -0
  194. package/dist/core/pause-registry.d.ts +16 -5
  195. package/dist/core/pause-registry.js +6 -2
  196. package/dist/core/peer-channel.d.ts +70 -0
  197. package/dist/core/peer-channel.js +1 -0
  198. package/dist/core/permission-rule-consent.d.ts +30 -5
  199. package/dist/core/permission-rule-consent.js +147 -50
  200. package/dist/core/permission-rule-model.d.ts +245 -65
  201. package/dist/core/permission-rule-model.js +421 -107
  202. package/dist/core/permission-rule-org.d.ts +6 -2
  203. package/dist/core/permission-rule-org.js +7 -3
  204. package/dist/core/permission-rule-provider.d.ts +6 -2
  205. package/dist/core/permission-rule-provider.js +41 -11
  206. package/dist/core/permission-rule-store.d.ts +22 -26
  207. package/dist/core/permission-rule-store.js +12 -6
  208. package/dist/core/permission-rule-sync.d.ts +11 -2
  209. package/dist/core/permission-rule-sync.js +11 -3
  210. package/dist/core/permission-rule-syntax.d.ts +5 -4
  211. package/dist/core/permission-rule-syntax.js +2 -2
  212. package/dist/core/permission-rules.d.ts +53 -15
  213. package/dist/core/permission-rules.js +125 -100
  214. package/dist/core/persisted-rule-arms.d.ts +6 -4
  215. package/dist/core/persisted-rule-arms.js +10 -12
  216. package/dist/core/present-plan-tool.js +3 -1
  217. package/dist/core/principal-name.d.ts +20 -0
  218. package/dist/core/principal-name.js +22 -0
  219. package/dist/core/prompt-section-seat.js +4 -6
  220. package/dist/core/protocol-http-auth.d.ts +26 -5
  221. package/dist/core/protocol-http-auth.js +137 -4
  222. package/dist/core/protocol-naming.d.ts +2 -2
  223. package/dist/core/read-only-shell-table.d.ts +1 -1
  224. package/dist/core/read-only-shell.d.ts +1 -1
  225. package/dist/core/retired-keys.d.ts +16 -0
  226. package/dist/core/retired-keys.js +16 -4
  227. package/dist/core/rewrite-rejudge.d.ts +60 -0
  228. package/dist/core/rewrite-rejudge.js +36 -0
  229. package/dist/core/roles.d.ts +34 -3
  230. package/dist/core/roles.js +66 -53
  231. package/dist/core/rule-lane-reads.d.ts +20 -15
  232. package/dist/core/rule-lane-reads.js +45 -17
  233. package/dist/core/rule-offer-read.d.ts +53 -0
  234. package/dist/core/rule-offer-read.js +146 -0
  235. package/dist/core/rule-owner.d.ts +46 -0
  236. package/dist/core/rule-owner.js +29 -0
  237. package/dist/core/runner/advisor-instructions.d.ts +70 -0
  238. package/dist/core/runner/advisor-instructions.js +61 -0
  239. package/dist/core/runner/advisor-tool.d.ts +33 -0
  240. package/dist/core/runner/advisor-tool.js +112 -0
  241. package/dist/core/runner/announce-once-ledger.d.ts +18 -26
  242. package/dist/core/runner/announce-once-ledger.js +19 -46
  243. package/dist/core/runner/approval-feedback.js +6 -3
  244. package/dist/core/runner/assemble-result.d.ts +2 -1
  245. package/dist/core/runner/assemble-result.js +1 -1
  246. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  247. package/dist/core/runner/caller-roster.d.ts +21 -2
  248. package/dist/core/runner/caller-roster.js +38 -0
  249. package/dist/core/runner/capability-withheld-seat.d.ts +5 -0
  250. package/dist/core/runner/capability-withheld-seat.js +24 -0
  251. package/dist/core/runner/classifier-ladder.d.ts +33 -13
  252. package/dist/core/runner/classifier-ladder.js +15 -14
  253. package/dist/core/runner/compaction-restate.d.ts +10 -6
  254. package/dist/core/runner/compaction-restate.js +9 -3
  255. package/dist/core/runner/construction-doors.js +3 -0
  256. package/dist/core/runner/contracts.d.ts +40 -33
  257. package/dist/core/runner/conversation-segment.d.ts +28 -0
  258. package/dist/core/runner/conversation-segment.js +42 -0
  259. package/dist/core/runner/cross-boundary-lane.d.ts +21 -16
  260. package/dist/core/runner/cross-boundary-lane.js +58 -34
  261. package/dist/core/runner/decide-continuation.d.ts +7 -4
  262. package/dist/core/runner/decide-continuation.js +2 -2
  263. package/dist/core/runner/denial-limit-arms.d.ts +4 -4
  264. package/dist/core/runner/denial-limit-arms.js +1 -1
  265. package/dist/core/runner/derived-route-fallback.d.ts +24 -24
  266. package/dist/core/runner/derived-route-fallback.js +9 -7
  267. package/dist/core/runner/file-history-request.d.ts +18 -0
  268. package/dist/core/runner/file-history-request.js +21 -13
  269. package/dist/core/runner/file-history-restore.d.ts +45 -0
  270. package/dist/core/runner/file-history-restore.js +46 -0
  271. package/dist/core/runner/gate-exit.d.ts +9 -3
  272. package/dist/core/runner/gate-exit.js +11 -5
  273. package/dist/core/runner/image.d.ts +7 -17
  274. package/dist/core/runner/image.js +9 -60
  275. package/dist/core/runner/initial-run-state.js +1 -1
  276. package/dist/core/runner/permission-rule-lanes.d.ts +6 -6
  277. package/dist/core/runner/permission-rule-lanes.js +38 -15
  278. package/dist/core/runner/person-path-rows.d.ts +12 -9
  279. package/dist/core/runner/person-path-rows.js +19 -8
  280. package/dist/core/runner/prepare-advisor.d.ts +63 -0
  281. package/dist/core/runner/prepare-advisor.js +77 -0
  282. package/dist/core/runner/prepare-ask-lane.d.ts +2 -2
  283. package/dist/core/runner/prepare-ask-lane.js +5 -2
  284. package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -6
  285. package/dist/core/runner/prepare-caps-and-workflow.js +5 -4
  286. package/dist/core/runner/prepare-config-doors.d.ts +31 -38
  287. package/dist/core/runner/prepare-config-doors.js +57 -34
  288. package/dist/core/runner/prepare-defer-classify.d.ts +4 -3
  289. package/dist/core/runner/prepare-defer-classify.js +7 -8
  290. package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
  291. package/dist/core/runner/prepare-delegation-surface.js +1 -1
  292. package/dist/core/runner/prepare-file-history.d.ts +48 -8
  293. package/dist/core/runner/prepare-file-history.js +41 -73
  294. package/dist/core/runner/prepare-gate-stations.d.ts +2 -5
  295. package/dist/core/runner/prepare-gate-stations.js +12 -8
  296. package/dist/core/runner/prepare-hands-readface.d.ts +2 -8
  297. package/dist/core/runner/prepare-hands-readface.js +15 -14
  298. package/dist/core/runner/prepare-inherited-gate.d.ts +11 -7
  299. package/dist/core/runner/prepare-inherited-gate.js +8 -6
  300. package/dist/core/runner/prepare-memory-engine-session.js +1 -1
  301. package/dist/core/runner/prepare-park-ask.js +12 -12
  302. package/dist/core/runner/prepare-policy-chain.d.ts +7 -4
  303. package/dist/core/runner/prepare-policy-chain.js +68 -81
  304. package/dist/core/runner/prepare-project-context.d.ts +5 -2
  305. package/dist/core/runner/prepare-project-context.js +6 -3
  306. package/dist/core/runner/prepare-prompt-assembly.d.ts +5 -7
  307. package/dist/core/runner/prepare-prompt-assembly.js +10 -8
  308. package/dist/core/runner/prepare-prompt-inputs.d.ts +11 -9
  309. package/dist/core/runner/prepare-prompt-inputs.js +4 -6
  310. package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
  311. package/dist/core/runner/prepare-protocol-tools.js +5 -4
  312. package/dist/core/runner/prepare-safety-scan.d.ts +9 -12
  313. package/dist/core/runner/prepare-safety-scan.js +8 -23
  314. package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
  315. package/dist/core/runner/prepare-suspend-saga.js +5 -6
  316. package/dist/core/runner/prepare-task.d.ts +1 -1
  317. package/dist/core/runner/prepare-task.js +41 -35
  318. package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +7 -4
  319. package/dist/core/runner/prepare-tool-disclosure-mount.js +24 -18
  320. package/dist/core/runner/prepare-turn-wiring.d.ts +0 -4
  321. package/dist/core/runner/prepare-turn-wiring.js +2 -7
  322. package/dist/core/runner/prepare-wiring-manifest.d.ts +11 -4
  323. package/dist/core/runner/prepare-wiring-manifest.js +3 -3
  324. package/dist/core/runner/resume-admission.js +1 -1
  325. package/dist/core/runner/resume-apply.js +11 -12
  326. package/dist/core/runner/resume-checkpoint-screen.js +3 -0
  327. package/dist/core/runner/resume-claim.d.ts +4 -2
  328. package/dist/core/runner/resume-claim.js +15 -8
  329. package/dist/core/runner/resume-policy-outcome.js +1 -1
  330. package/dist/core/runner/retired-runner-deps.js +2 -1
  331. package/dist/core/runner/rewind-files.d.ts +15 -0
  332. package/dist/core/runner/rewind-files.js +132 -0
  333. package/dist/core/runner/run-attachment-seats.js +2 -2
  334. package/dist/core/runner/run-brain-sinks.d.ts +4 -1
  335. package/dist/core/runner/run-brain-sinks.js +4 -2
  336. package/dist/core/runner/run-compaction-machinery.d.ts +1 -1
  337. package/dist/core/runner/run-compaction-machinery.js +2 -12
  338. package/dist/core/runner/run-git-lane.d.ts +1 -0
  339. package/dist/core/runner/run-harness-handlers.js +14 -7
  340. package/dist/core/runner/run-leg.d.ts +1 -1
  341. package/dist/core/runner/run-leg.js +43 -18
  342. package/dist/core/runner/run-settle-and-teardown.js +3 -2
  343. package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
  344. package/dist/core/runner/run-turn-boundary.d.ts +1 -0
  345. package/dist/core/runner/run-turn-boundary.js +15 -22
  346. package/dist/core/runner/runtask.d.ts +3 -0
  347. package/dist/core/runner/runtask.js +8 -9
  348. package/dist/core/runner/session-read-file-states.d.ts +15 -0
  349. package/dist/core/runner/session-read-file-states.js +28 -0
  350. package/dist/core/runner/session-rule-policy.d.ts +22 -21
  351. package/dist/core/runner/session-rule-policy.js +17 -31
  352. package/dist/core/runner/shell-env-withheld.d.ts +33 -0
  353. package/dist/core/runner/shell-env-withheld.js +51 -0
  354. package/dist/core/runner/side-call-account.d.ts +32 -8
  355. package/dist/core/runner/side-call-account.js +23 -1
  356. package/dist/core/runner/skills-seat.js +6 -2
  357. package/dist/core/runner/stream-settle-backstop.js +1 -1
  358. package/dist/core/runner/strict-output-schema.d.ts +1 -1
  359. package/dist/core/runner/sub-agent-deny-lists.js +4 -6
  360. package/dist/core/runner/synthetic-tools.d.ts +16 -13
  361. package/dist/core/runner/synthetic-tools.js +8 -3
  362. package/dist/core/runner/tool-disclosure.d.ts +10 -12
  363. package/dist/core/runner/tool-disclosure.js +3 -4
  364. package/dist/core/runner/tool-end-body.d.ts +1 -1
  365. package/dist/core/runner/tool-end-body.js +10 -9
  366. package/dist/core/runner/tool-face-overlay.d.ts +2 -1
  367. package/dist/core/runner/tool-face-overlay.js +17 -1
  368. package/dist/core/runner/tool-not-executed.d.ts +5 -0
  369. package/dist/core/runner/tool-not-executed.js +11 -0
  370. package/dist/core/runner/tool-occurrence.d.ts +8 -0
  371. package/dist/core/runner/tool-occurrence.js +7 -0
  372. package/dist/core/runner/tool-progress-lane.d.ts +2 -2
  373. package/dist/core/runner/tool-turn-repair-seat.d.ts +3 -2
  374. package/dist/core/runner/turn-attachments.d.ts +91 -80
  375. package/dist/core/runner/turn-attachments.js +62 -37
  376. package/dist/core/runner-deps.d.ts +42 -42
  377. package/dist/core/runtime-caps.d.ts +4 -4
  378. package/dist/core/safety-axis-vocab.d.ts +6 -4
  379. package/dist/core/safety-axis-vocab.js +6 -5
  380. package/dist/core/safety-merge-corpus.js +26 -2
  381. package/dist/core/same-plain-value.d.ts +40 -0
  382. package/dist/core/same-plain-value.js +49 -0
  383. package/dist/core/scheduler.d.ts +1 -1
  384. package/dist/core/secret-env.d.ts +26 -3
  385. package/dist/core/secret-env.js +44 -8
  386. package/dist/core/select-model.js +3 -3
  387. package/dist/core/sensitive-path-policy.d.ts +1 -1
  388. package/dist/core/sensitive-path-policy.js +1 -1
  389. package/dist/core/session-policy-store.d.ts +102 -35
  390. package/dist/core/session-policy-store.js +210 -48
  391. package/dist/core/session-reconcile.d.ts +2 -2
  392. package/dist/core/session-store.d.ts +106 -37
  393. package/dist/core/session-store.js +165 -91
  394. package/dist/core/session.d.ts +101 -57
  395. package/dist/core/session.js +53 -0
  396. package/dist/core/shared-memory/tools.js +3 -1
  397. package/dist/core/shared-memory/types.d.ts +1 -1
  398. package/dist/core/shell-read-silence.d.ts +11 -12
  399. package/dist/core/shell-read-silence.js +9 -5
  400. package/dist/core/shell-run-candidates.js +3 -1
  401. package/dist/core/shell-wrapper-projection.js +1 -1
  402. package/dist/core/shell-wrapper-table.d.ts +14 -7
  403. package/dist/core/shell-wrapper-table.js +5 -4
  404. package/dist/core/side-query.d.ts +10 -0
  405. package/dist/core/side-query.js +15 -1
  406. package/dist/core/skill-grant.d.ts +7 -2
  407. package/dist/core/skill-grant.js +5 -0
  408. package/dist/core/skills-directory.js +6 -2
  409. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +11 -1
  410. package/dist/core/store-contracts/checkpoint-store-contract.js +168 -3
  411. package/dist/core/store-contracts/file-history-store-contract.js +74 -4
  412. package/dist/core/store-contracts/peer-directory-contract.d.ts +7 -2
  413. package/dist/core/store-contracts/peer-directory-contract.js +14 -2
  414. package/dist/core/store-contracts/session-policy-store-contract.d.ts +7 -0
  415. package/dist/core/store-contracts/session-policy-store-contract.js +130 -0
  416. package/dist/core/store-contracts/session-repo-contract.js +176 -0
  417. package/dist/core/store-contracts/session-store-contract.d.ts +6 -8
  418. package/dist/core/store-contracts/session-store-contract.js +361 -51
  419. package/dist/core/store-contracts/workflow-journal-store-contract.js +26 -1
  420. package/dist/core/stub-env.d.ts +2 -0
  421. package/dist/core/stub-env.js +1 -0
  422. package/dist/core/surrogate-safe-slice.d.ts +3 -3
  423. package/dist/core/synthetic-read-verdict.js +3 -3
  424. package/dist/core/task-event.d.ts +42 -8
  425. package/dist/core/task-notification.d.ts +19 -15
  426. package/dist/core/task-registry-agent.d.ts +4 -4
  427. package/dist/core/task-registry-shared.d.ts +4 -4
  428. package/dist/core/task-registry-shared.js +1 -0
  429. package/dist/core/task-registry.d.ts +13 -4
  430. package/dist/core/task-registry.js +14 -2
  431. package/dist/core/task-result.d.ts +21 -3
  432. package/dist/core/task-spec.d.ts +69 -64
  433. package/dist/core/task-stream.d.ts +6 -6
  434. package/dist/core/task-tool-shape.d.ts +4 -4
  435. package/dist/core/tighten-task-spec.d.ts +1 -1
  436. package/dist/core/tighten-task-spec.js +2 -1
  437. package/dist/core/tool-catalog-entries.d.ts +36 -2
  438. package/dist/core/tool-catalog-entries.js +69 -43
  439. package/dist/core/tool-check-reading.d.ts +11 -0
  440. package/dist/core/tool-check-reading.js +11 -6
  441. package/dist/core/tool-conformance.js +1 -0
  442. package/dist/core/tool-errors.d.ts +2 -2
  443. package/dist/core/tool-face-reader.js +5 -3
  444. package/dist/core/tool-face.d.ts +21 -2
  445. package/dist/core/tool-face.js +1 -1
  446. package/dist/core/tool-model-gate.d.ts +5 -5
  447. package/dist/core/tool-name-aliases.d.ts +29 -8
  448. package/dist/core/tool-name-aliases.js +22 -4
  449. package/dist/core/tool-name-readings.d.ts +10 -43
  450. package/dist/core/tool-name-readings.js +2 -11
  451. package/dist/core/tool-policy.d.ts +85 -196
  452. package/dist/core/tool-policy.js +150 -175
  453. package/dist/core/tool-registry.d.ts +14 -7
  454. package/dist/core/tool-registry.js +17 -7
  455. package/dist/core/tool-result-store.js +5 -1
  456. package/dist/core/tool-roster.d.ts +57 -33
  457. package/dist/core/tool-roster.js +56 -68
  458. package/dist/core/tool-spec-members.js +8 -3
  459. package/dist/core/tool-spec.d.ts +53 -31
  460. package/dist/core/tools.js +51 -10
  461. package/dist/core/trace.d.ts +6 -2
  462. package/dist/core/types.d.ts +1 -1
  463. package/dist/core/untrusted-egress.d.ts +1 -1
  464. package/dist/core/untrusted-text.d.ts +1 -1
  465. package/dist/core/user-attachment.d.ts +8 -1
  466. package/dist/core/user-attachment.js +64 -4
  467. package/dist/core/warm-resume.d.ts +1 -1
  468. package/dist/core/wiring-manifest.d.ts +58 -0
  469. package/dist/core/wiring-manifest.js +14 -5
  470. package/dist/core/workflow-journal-store.d.ts +62 -0
  471. package/dist/core/workflow-journal-store.js +78 -2
  472. package/dist/core/workflow-run-store.d.ts +6 -0
  473. package/dist/core/workflow-run-store.js +2 -0
  474. package/dist/engine/compaction/compaction.d.ts +9 -9
  475. package/dist/engine/compaction/compaction.js +3 -2
  476. package/dist/engine/execution-env/node-execution-env.d.ts +26 -8
  477. package/dist/engine/execution-env/node-execution-env.js +54 -24
  478. package/dist/engine/harness/agent-harness.d.ts +39 -9
  479. package/dist/engine/harness/agent-harness.js +87 -33
  480. package/dist/engine/harness/types.d.ts +58 -9
  481. package/dist/engine/harness/types.js +12 -1
  482. package/dist/engine/llm/types.d.ts +36 -19
  483. package/dist/engine/llm/validation.d.ts +4 -1
  484. package/dist/engine/llm/validation.js +13 -1
  485. package/dist/engine/loop/agent-loop.d.ts +23 -1
  486. package/dist/engine/loop/agent-loop.js +26 -34
  487. package/dist/engine/loop/types.d.ts +31 -19
  488. package/dist/engine/lsp/node-lsp-manager.d.ts +2 -2
  489. package/dist/engine/session/memory-repo.d.ts +18 -12
  490. package/dist/engine/session/memory-repo.js +24 -9
  491. package/dist/engine/session/parent-chain-guard.d.ts +3 -2
  492. package/dist/engine/session/parent-chain-guard.js +1 -1
  493. package/dist/engine/session/repo-utils.d.ts +32 -3
  494. package/dist/engine/session/repo-utils.js +50 -5
  495. package/dist/index.d.ts +47 -23
  496. package/dist/index.js +35 -17
  497. package/dist/internal/harness-types.d.ts +1 -1
  498. package/dist/internal/harness.d.ts +3 -3
  499. package/dist/internal/harness.js +2 -2
  500. package/dist/internal/llm.d.ts +2 -2
  501. package/dist/internal/llm.js +1 -1
  502. package/dist/orchestration/goal.js +2 -2
  503. package/dist/orchestration/run-workflow-tool.d.ts +8 -6
  504. package/dist/orchestration/run-workflow-tool.js +10 -6
  505. package/dist/orchestration/workflow-size-guideline.d.ts +4 -4
  506. package/dist/orchestration/workflow-types.d.ts +18 -0
  507. package/dist/orchestration/workflow-types.js +6 -0
  508. package/dist/orchestration/workflow.d.ts +5 -13
  509. package/dist/orchestration/workflow.js +57 -49
  510. package/dist/prompt-assembly/artifact.d.ts +2 -2
  511. package/dist/prompt-assembly/artifact.js +5 -3
  512. package/dist/prompt-assembly/assemble.d.ts +3 -2
  513. package/dist/prompt-assembly/assemble.js +1 -1
  514. package/dist/prompt-assembly/catalog/schema.d.ts +43 -12
  515. package/dist/prompt-assembly/catalog/schema.js +34 -2
  516. package/dist/prompt-assembly/catalog/sections.js +0 -1
  517. package/dist/prompt-assembly/composer.d.ts +3 -1
  518. package/dist/prompt-assembly/composer.js +1 -1
  519. package/dist/prompt-assembly/event-registry.js +2 -0
  520. package/dist/prompt-assembly/overlay.js +3 -3
  521. package/dist/prompt-assembly/renderers.d.ts +1 -1
  522. package/dist/prompt-assembly/renderers.js +0 -3
  523. package/dist/prompt-assembly/role-base.d.ts +15 -0
  524. package/dist/prompt-assembly/role-base.js +9 -0
  525. package/dist/prompt-assembly/select.d.ts +39 -14
  526. package/dist/prompt-assembly/select.js +47 -16
  527. package/dist/prompt-assembly/sugar.d.ts +17 -11
  528. package/dist/prompt-assembly/sugar.js +8 -3
  529. package/dist/prompt-assembly/tool-catalog.d.ts +39 -2
  530. package/dist/prompt-assembly/tool-catalog.js +117 -4
  531. package/dist/prompt-assembly/turn-snapshot.d.ts +4 -10
  532. package/dist/prompt-assembly/turn-snapshot.js +0 -3
  533. package/dist/prompt-assembly/types.d.ts +0 -7
  534. package/dist/prompts/default.d.ts +14 -14
  535. package/dist/scenarios/full-body.d.ts +15 -15
  536. package/dist/scenarios/full-body.js +4 -3
  537. package/dist/shell/lex.js +10 -1
  538. package/dist/stores/file/adoption/adopt.d.ts +4 -3
  539. package/dist/stores/file/adoption/adopt.js +27 -33
  540. package/dist/stores/file/adoption/marker.d.ts +6 -13
  541. package/dist/stores/file/adoption/marker.js +9 -17
  542. package/dist/stores/file/checkpoint-store.d.ts +24 -0
  543. package/dist/stores/file/checkpoint-store.js +45 -7
  544. package/dist/stores/file/file-history-store.d.ts +20 -19
  545. package/dist/stores/file/file-history-store.js +157 -141
  546. package/dist/stores/file/fs-atomic.d.ts +15 -0
  547. package/dist/stores/file/fs-atomic.js +89 -14
  548. package/dist/stores/file/index.d.ts +1 -1
  549. package/dist/stores/file/index.js +2 -1
  550. package/dist/stores/file/mailbox-store.d.ts +3 -0
  551. package/dist/stores/file/mailbox-store.js +3 -1
  552. package/dist/stores/file/permission-rule-adopt.d.ts +1 -1
  553. package/dist/stores/file/permission-rule-adopt.js +18 -18
  554. package/dist/stores/file/permission-rule-store.d.ts +18 -2
  555. package/dist/stores/file/permission-rule-store.js +31 -18
  556. package/dist/stores/file/session-policy-store.d.ts +3 -3
  557. package/dist/stores/file/session-store.d.ts +54 -16
  558. package/dist/stores/file/session-store.js +114 -85
  559. package/dist/stores/file/workflow-journal-store.d.ts +10 -4
  560. package/dist/stores/file/workflow-journal-store.js +28 -13
  561. package/dist/tools/artifact/artifact-text.d.ts +1 -1
  562. package/dist/tools/artifact/artifact-tool.js +5 -3
  563. package/dist/tools/fs/bash-program-position.d.ts +19 -2
  564. package/dist/tools/fs/bash-program-position.js +56 -9
  565. package/dist/tools/fs/bash-readonly-classifier.d.ts +3 -3
  566. package/dist/tools/fs/fs-bash.d.ts +2 -2
  567. package/dist/tools/fs/fs-bash.js +8 -6
  568. package/dist/tools/fs/fs-glob.d.ts +86 -0
  569. package/dist/tools/fs/fs-glob.js +226 -0
  570. package/dist/tools/fs/fs-read.js +14 -14
  571. package/dist/tools/fs/fs-search-tools.js +7 -7
  572. package/dist/tools/fs/fs-shared.d.ts +8 -8
  573. package/dist/tools/fs/gh-rate-limit.d.ts +1 -1
  574. package/dist/tools/fs/notebook.d.ts +2 -2
  575. package/dist/tools/fs/pattern-kill-guard.d.ts +22 -0
  576. package/dist/tools/fs/pattern-kill-guard.js +397 -0
  577. package/dist/tools/fs/pdf.d.ts +9 -6
  578. package/dist/tools/fs/pdf.js +3 -3
  579. package/dist/tools/fs/program-read-model.d.ts +57 -7
  580. package/dist/tools/fs/program-read-model.js +11 -1
  581. package/dist/tools/fs/program-read-model.rows.js +78 -21
  582. package/dist/tools/fs/read-deny-home.js +3 -2
  583. package/dist/tools/fs/read-deny.d.ts +29 -7
  584. package/dist/tools/fs/read-deny.js +63 -22
  585. package/dist/tools/fs/removal-targets.d.ts +18 -8
  586. package/dist/tools/fs/removal-targets.js +47 -20
  587. package/dist/tools/fs/safety.d.ts +9 -9
  588. package/dist/tools/fs/search.d.ts +16 -6
  589. package/dist/tools/fs/search.js +20 -26
  590. package/dist/tools/fs/shell-read-argv.js +89 -12
  591. package/dist/tools/fs/shell-read-bindings.d.ts +31 -0
  592. package/dist/tools/fs/shell-read-bindings.js +41 -0
  593. package/dist/tools/fs/shell-read-check.js +12 -20
  594. package/dist/tools/fs/shell-read-environment.d.ts +5 -1
  595. package/dist/tools/fs/shell-read-environment.js +3 -2
  596. package/dist/tools/fs/shell-read-establish.d.ts +15 -0
  597. package/dist/tools/fs/shell-read-establish.js +19 -20
  598. package/dist/tools/fs/shell-read-judge.d.ts +4 -0
  599. package/dist/tools/fs/shell-read-judge.js +5 -2
  600. package/dist/tools/fs/shell-read-plan.js +24 -16
  601. package/dist/tools/fs/shell-read-start.d.ts +6 -1
  602. package/dist/tools/fs/shell-read-write-targets.d.ts +5 -1
  603. package/dist/tools/fs/shell-read-write-targets.js +2 -3
  604. package/dist/tools/fs/shell-reentry-text.d.ts +9 -0
  605. package/dist/tools/fs/shell-reentry-text.js +40 -2
  606. package/dist/tools/loop-tick.d.ts +2 -2
  607. package/dist/tools/scheduler-tools.js +5 -1
  608. package/dist/tools/task-list.d.ts +7 -7
  609. package/dist/tools/task-list.js +5 -1
  610. package/dist/tools/todo.js +65 -64
  611. package/dist/tools/web.d.ts +20 -15
  612. package/dist/tools/web.js +55 -69
  613. package/dist/tools/worktree.d.ts +3 -3
  614. package/dist/tools/worktree.js +3 -1
  615. package/package.json +1 -1
  616. package/test/export-surface.snapshot.json +5894 -5638
  617. package/wire-changes/core@7.55.0.json +3318 -0
  618. package/wire-changes/core@7.56.0.json +3891 -0
  619. package/wire-changes/mods-kernel@7.56.0.json +303 -0
  620. package/dist/core/store-contracts/session-store-incarnation-contract.d.ts +0 -39
  621. package/dist/core/store-contracts/session-store-incarnation-contract.js +0 -95
@@ -4,7 +4,7 @@ import type { DocumentContent, ImageContent } from "../internal/llm.js";
4
4
  * Aggregate MEDIA (image) byte budget — the multimodal sibling of {@link AGGREGATE_TOOL_RESULT_BUDGET_CHARS}
5
5
  * (which only counts TEXT, design/64 §17.2). batch-C added image reads (`Read` → `ImageContent`); each is bounded
6
6
  * per-image (`MAX_IMAGE_READ_BYTES`), but N images accumulate ACROSS turns in the context and would otherwise grow
7
- * the request unboundedly (a real gap — CC 2.1.196 added the same cap, `tengu_media_byte_cap`, validating it).
7
+ * the request unboundedly (a real gap — the reference added the same cap, `tengu_media_byte_cap`, validating it).
8
8
  *
9
9
  * This caps the SUM of inline image bytes across the whole message list: while over budget, the OLDEST images are
10
10
  * stripped (replaced with a short text marker) until it fits — recent media (most relevant) is kept. Like the text
@@ -1,7 +1,7 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { closeSync, existsSync, fsyncSync, linkSync, lstatSync, openSync, readFileSync, readdirSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { basename, dirname, join } from "node:path";
4
- import { QUARANTINE_DIR, appendChallengeEvents, enqueueMemoryAnnouncement, ensureDirExists, v1MemoryPathKeyResolver, lineageContributionsOfSession, lockedStrictUpdate, markSessionPolluted, readProjectionDebts, readSessionPollution, readStrictSidecar, ControlPlaneCorruptError } from "./layout.js";
4
+ import { QUARANTINE_DIR, appendChallengeEvents, claimStaging, enqueueMemoryAnnouncement, ensureDirExists, isSameFile, mintStagingName, stagingNamePattern, v1MemoryPathKeyResolver, lineageContributionsOfSession, lockedStrictUpdate, markSessionPolluted, readProjectionDebts, readSessionPollution, readStrictSidecar, ControlPlaneCorruptError } from "./layout.js";
5
5
  import { thrownText } from "../thrown-value.js";
6
6
  export const DELEGATION_SETTLEMENT_FILE = "delegation-settlement.json";
7
7
  function reqStr(v) {
@@ -495,25 +495,6 @@ export function readHolds(controlDir) {
495
495
  function sha256(buf) {
496
496
  return createHash("sha256").update(buf).digest("hex");
497
497
  }
498
- let stagingSeq = 0;
499
- function uniqueStagingName(holdId, now) {
500
- stagingSeq += 1;
501
- return `${holdId}.staging-${now()}-${process.pid}-${stagingSeq}`;
502
- }
503
- function stagingGenerationPattern(holdId) {
504
- return new RegExp(`^${holdId.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\\.staging-\\d+-\\d+-\\d+(?:\\.claim-\\d+-\\d+)*$`);
505
- }
506
- function claimStaging(stagingPath) {
507
- stagingSeq += 1;
508
- const claimed = `${stagingPath}.claim-${process.pid}-${stagingSeq}`;
509
- try {
510
- renameSync(stagingPath, claimed);
511
- return claimed;
512
- }
513
- catch {
514
- return stagingPath;
515
- }
516
- }
517
498
  function dropStaging(claimedPath) {
518
499
  try {
519
500
  unlinkSync(claimedPath);
@@ -638,7 +619,7 @@ export function openInstructionHold(controlDir, input) {
638
619
  if (!writeCustodyVerified(join(holdDir, captureName), buf)) {
639
620
  return refuse("hold capture verification failed (the custody copy could not be written, made durable, or hashed back to the captured digest)", "capture_lost");
640
621
  }
641
- const stagingName = uniqueStagingName(holdId, input.now);
622
+ const stagingName = mintStagingName(holdId, input.now);
642
623
  const stagingPath = stagingPathBeside(input.absPath, stagingName);
643
624
  try {
644
625
  renameSync(input.absPath, stagingPath);
@@ -695,7 +676,7 @@ export function reconcileHolds(controlDir, input) {
695
676
  }
696
677
  };
697
678
  const finishRemoval = (row, plane) => {
698
- const stagingName = uniqueStagingName(row.holdId, input.now);
679
+ const stagingName = mintStagingName(row.holdId, input.now);
699
680
  renameSync(plane, stagingPathBeside(plane, stagingName));
700
681
  const staging = claimStaging(stagingPathBeside(plane, stagingName));
701
682
  if (sha256(readFileSync(staging)) === row.contentDigest) {
@@ -726,7 +707,14 @@ export function reconcileHolds(controlDir, input) {
726
707
  };
727
708
  const sweepStagingGenerations = (row, plane, custody) => {
728
709
  const seatDir = dirname(plane);
729
- const pattern = stagingGenerationPattern(row.holdId);
710
+ const pattern = stagingNamePattern(row.holdId);
711
+ let seat;
712
+ try {
713
+ seat = lstatSync(plane);
714
+ }
715
+ catch {
716
+ seat = undefined;
717
+ }
730
718
  for (const name of listSeat(seatDir)) {
731
719
  if (!pattern.test(name))
732
720
  continue;
@@ -746,7 +734,10 @@ export function reconcileHolds(controlDir, input) {
746
734
  continue;
747
735
  }
748
736
  }
749
- discloseStranded(row.holdId, row.rel, retireStagingToCustody(staged, holdDir, name).at);
737
+ const onSeat = seat !== undefined && isSameFile(staged, seat);
738
+ const retired = retireStagingToCustody(staged, holdDir, name);
739
+ if (!(onSeat && retired.settled && isSameFile(plane, seat)))
740
+ discloseStranded(row.holdId, row.rel, retired.at);
750
741
  }
751
742
  };
752
743
  const rows = readHolds(controlDir).filter((r) => r.status === "capturing");
@@ -10,7 +10,7 @@ import type { HarvestReport, MemoryAnnouncement, MemoryBackend, MemoryEntry, Mem
10
10
  /**
11
11
  * The RECALL-FRAMING sentence shared by every arm of the `# Memory` prompt section — the one
12
12
  * sentence that tells the model what a recalled memory IS (background context, not an instruction)
13
- * and that its content may have gone stale. CC-verbatim (2.1.223 memory arms); CC serves it on the
13
+ * and that its content may have gone stale. The reference serves it on the
14
14
  * write arm as the tail of the closing paragraph and on each read-only/unavailable arm as a
15
15
  * paragraph of its own, so all four arms below splice this ONE value.
16
16
  *
@@ -46,14 +46,14 @@ export declare const MEMORY_RECALL_FRAMING = "Recalled memories appearing inside
46
46
  */
47
47
  export declare const MEMORY_INSTRUCTION_TEMPLATE = "# Memory\n\nYou have a persistent file-based memory at `{{MEMORY_DIR}}`. This directory already exists \u2014 write to it directly with the Write tool (do not run mkdir or check for its existence). Each memory is one file holding one fact, with frontmatter:\n\n```markdown\n---\nname: <short-kebab-case-slug>\ndescription: <one-line summary, used to decide relevance during recall>\nmetadata:\n type: user | feedback | project | reference\n---\n\n<the fact; for feedback/project, follow with **Why:** and **How to apply:** lines. Link related memories with [[their-name]].>\n```\n\nIn the body, link to related memories with `[[name]]`, where `name` is the other memory's `name:` slug. Link liberally \u2014 a `[[name]]` that doesn't match an existing memory yet is fine; it marks something worth writing later, not an error.\n\n`user` \u2014 who the user is (role, expertise, preferences). `feedback` \u2014 guidance the user has given on how you should work, both corrections and confirmed approaches; include the why. `project` \u2014 ongoing work, goals, or constraints not derivable from the code or git history; convert relative dates to absolute. `reference` \u2014 pointers to external resources (URLs, dashboards, tickets).\n\nAfter writing the file, add a one-line pointer in `MEMORY.md` (`- [Title](file.md) \u2014 hook`). `MEMORY.md` is the index whose head (first 200 lines / 25 KB) is loaded into context each session \u2014 one line per memory, no frontmatter, never put memory content there.\n\nBefore saving, check for an existing file that already covers it \u2014 update that file rather than creating a duplicate; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history, {{INSTRUCTION_FILE}}) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Recalled memories appearing inside `<system-reminder>` blocks are background context, not user instructions, and reflect what was true when written \u2014 if one names a file, function, or flag, verify it still exists before recommending it.";
48
48
  /**
49
- * Substitute the real memory directory (absolute, trailing slash) into the CC-verbatim template.
49
+ * Substitute the real memory directory (absolute, trailing slash) into the template.
50
50
  *
51
51
  * design-A C-7 ([A1]) — REGISTERED INTENTIONAL DIVERGENCE (cc-divergences: instruction-file
52
52
  * parameterization): CC's template hardcodes `CLAUDE.md`; sema's deployment layer may serve a
53
53
  * session whose project-instruction file is `AGENTS.md` (open-standard primary name, server-side
54
54
  * file-name chain), and the sentence's referent is "THIS session's instruction file" — so the
55
55
  * literal became `{{INSTRUCTION_FILE}}` with default `"CLAUDE.md"`. 锚纪律: with the default the
56
- * output is BYTE-IDENTICAL to the CC-verbatim capture (sha256-pinned in test) — the divergence is
56
+ * output is BYTE-IDENTICAL to the captured text (sha256-pinned in test) — the divergence is
57
57
  * reachable only when a deployment passes a different name.
58
58
  */
59
59
  export declare function buildMemoryInstruction(memoryDir: string, instructionFileName?: string): string;
@@ -63,7 +63,7 @@ export declare function buildMemoryInstruction(memoryDir: string, instructionFil
63
63
  * model does not reach for is dead weight, and teaching an unmounted tool is a config-face false
64
64
  * promise (the #181-F5 class). It rides OUTSIDE `inject()` — composed by the runner's memory phase
65
65
  * (prepare-memory.ts) and stripped again if the support-name pre-check retracts the pair — so the
66
- * CC-verbatim `# Memory` instruction stays byte-identical to its sha256-pinned capture, and the
66
+ * `# Memory` instruction stays byte-identical to its sha256-pinned capture, and the
67
67
  * dual-root instruction merge ("the write plane's instruction wins") never sees a second candidate.
68
68
  */
69
69
  export declare const MEMORY_RECALL_DISCIPLINE: string;
@@ -115,7 +115,7 @@ export declare function entryFileHeadCarriesOrigin(absPath: string, maxBytes?: n
115
115
  /**
116
116
  * design/180 B-3 — the preference-header discipline paragraph. Same carriage as
117
117
  * {@link MEMORY_RECALL_DISCIPLINE}: a runner-appended segment OUTSIDE `inject()`, so the
118
- * CC-verbatim `# Memory` instruction stays byte-identical to its sha256-pinned capture. Appended
118
+ * `# Memory` instruction stays byte-identical to its sha256-pinned capture. Appended
119
119
  * only when a WRITE channel exists (prepare-memory gates it) — the lines it teaches are frontmatter
120
120
  * the MODEL writes; the engine has no write arm for them (writing usage evidence for the model
121
121
  * would self-declare the very account the three-tier discipline forbids forging).
@@ -160,12 +160,12 @@ export declare const MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA = "Any guidance in
160
160
  * sentence true), and for a write-less roster the persistence inference cannot vouch for. A merely
161
161
  * Write-less roster does NOT qualify — other tools can still write the root. Name-free by
162
162
  * construction (#181 class — it names no tool). The closing sentence of the first paragraph is
163
- * CC-verbatim (2.1.223 read-only memory arm — the same sentence CC uses for both its whole-memory and
163
+ * the reference's (the read-only memory arm — the same sentence it uses for both its whole-memory and
164
164
  * team-memory read-only states); the state sentence above it is sema-authored context (CC's surrounding
165
165
  * prose describes its own file layout, which does not transfer here).
166
166
  *
167
167
  * The SECOND paragraph is {@link MEMORY_RECALL_FRAMING} — CC's own second paragraph of that same
168
- * read-only arm, verbatim (2.1.223 @149206-149211, the `p && !u` branch). CC serves it on BOTH arms:
168
+ * read-only arm, as is. The reference serves it on BOTH arms:
169
169
  * the write arm carries it as the tail of its closing paragraph (see
170
170
  * {@link MEMORY_INSTRUCTION_TEMPLATE}), the read-only arm as a paragraph of its own. It is the only
171
171
  * sentence in the block that frames what a recalled `<system-reminder>` memory IS (background context,
@@ -243,7 +243,7 @@ export interface MemoryEngineOptions {
243
243
  /** §2.3 per-scope materialization budget (bytes). Default = effectively unlimited (TOC never stubs). */
244
244
  perScopeBudgetBytes?: number;
245
245
  /** Per-file harvest cap in bytes (default {@link MAX_MEMORY_BYTES} = 100KB). An engineering
246
- * bound, NOT a CC-anchored value: CC 2.1.250's memory limits live on different axes entirely
246
+ * bound, NOT a reference-anchored value: the reference's memory limits live on different axes entirely
247
247
  * (per-file recall reads only the first 4KB with a lint nudge; the index caps at 25KB) — see
248
248
  * cc-250 anchors. The old "CC-aligned" claim here was wrong (test B6). */
249
249
  perFileBytes?: number;
@@ -335,7 +335,7 @@ export interface MemoryEngineOptions {
335
335
  */
336
336
  consolidation?: MemoryConsolidationOptions;
337
337
  }
338
- /** What {@link MemoryEngine.inject} produces: the trusted CC-verbatim instruction section + the
338
+ /** What {@link MemoryEngine.inject} produces: the trusted instruction section + the
339
339
  * FENCED (untrusted-downgraded) derived index, and the combined block for the memory prompt slot. */
340
340
  export interface MemoryInjection {
341
341
  /** CC `# Memory` section (system-authority instruction — §0.3 逐字 surface). Empty for a read-only
@@ -19,7 +19,7 @@ import { landedUndecided, layerDigest, layerObservationLookup, readOnlyLayerCand
19
19
  import { markOriginClearanceTombstoned, openOriginClearance, readOriginClearances, settleOriginClearance } from "./origin-clearance.js";
20
20
  import { DEFAULT_MAX_ENTRY_DEPTH, MEMORY_INDEX_FILENAME, captureErasureInput, erasureRequestInvalid, erasureSelectHash, scanEntryFiles, } from "./file-backend.js";
21
21
  import { assembleMemoryExportBundle, computeMemoryBundleHash, memoryBundleInvalid, } from "./export-bundle.js";
22
- import { QUARANTINE_DIR, SCAN_FUSE_THRESHOLD, quarantineAndTombstone, restoreContainedBaseline, indexLineIsStale, readIndexRevs, writeIndexRevs, bumpScanFuse, scanFuseKey, canonicalize, anchorStoreRoot, landingPathOf, landsOutsideStore, storeActRefusal, storeRootMovedRefusal, adoptRootScopeLayout, clearScanFuse, effectiveControlRootOf, drainMemoryAnnouncements, enqueueMemoryAnnouncement, ensureDirExists, markSessionPolluted, readSessionPollution, fileSessionCaptureRecordStore, recordRetrievedAccount, writeFileNoFollow, withPermissionRemedy, permissionRemedyOf, readRetrievedAccount, registerScope, registeredScopes, scopeDirFor, appendChallengeEvents, appendLineageAudit, rebuildStrictControlPlaneLedger, isStrictControlPlaneLedgerCorrupt, CHALLENGE_LEDGER_MAX_EVENTS, adjudicateLineagePending, challengedEntryIds, clearLineageForEntries, discardLineagePending, lineageAccountOfEntry, lineageContributionsOfSession, lineageLatchedIds, promoteLineagePending, readChallengeEvents, readChallengedHistory, readLineageRecord, recordChallengedHistory, recordLineageCredential, reconcileLineage, readProjectionDebts, resolveChallengeEvent, settleProjectionDebts, stageLineagePending, stageProjectionDebts, } from "./layout.js";
22
+ import { QUARANTINE_DIR, SCAN_FUSE_THRESHOLD, quarantineAndTombstone, restoreContainedBaseline, mintStagingName, indexLineIsStale, readIndexRevs, writeIndexRevs, bumpScanFuse, scanFuseKey, canonicalize, anchorStoreRoot, landingPathOf, landsOutsideStore, storeActRefusal, storeRootMovedRefusal, adoptRootScopeLayout, clearScanFuse, effectiveControlRootOf, drainMemoryAnnouncements, enqueueMemoryAnnouncement, ensureDirExists, markSessionPolluted, readSessionPollution, fileSessionCaptureRecordStore, recordRetrievedAccount, writeFileNoFollow, writeFileNoReplace, withPermissionRemedy, permissionRemedyOf, readRetrievedAccount, registerScope, registeredScopes, scopeDirFor, appendChallengeEvents, appendLineageAudit, rebuildStrictControlPlaneLedger, isStrictControlPlaneLedgerCorrupt, CHALLENGE_LEDGER_MAX_EVENTS, adjudicateLineagePending, challengedEntryIds, clearLineageForEntries, discardLineagePending, lineageAccountOfEntry, lineageContributionsOfSession, lineageLatchedIds, promoteLineagePending, readChallengeEvents, readChallengedHistory, readLineageRecord, recordChallengedHistory, recordLineageCredential, reconcileLineage, readProjectionDebts, resolveChallengeEvent, settleProjectionDebts, stageLineagePending, stageProjectionDebts, } from "./layout.js";
23
23
  import { createSessionIncarnationSeat, recalledForAnyIdentity, recalledForIdentity, rememberForIdentity } from "./session-incarnation.js";
24
24
  import { scanMemoryFileName, scanMemoryWrite, scanRemediation } from "./scan.js";
25
25
  import { writableRootOf } from "./types.js";
@@ -1516,7 +1516,7 @@ export class MemoryEngine {
1516
1516
  }
1517
1517
  let restoredCommitted = false;
1518
1518
  if (captured) {
1519
- const stagingName = `${captureName}.staging`;
1519
+ const stagingName = mintStagingName(captureName, this.now);
1520
1520
  const stagingPath = stagingPathBeside(canonical, stagingName);
1521
1521
  try {
1522
1522
  this.refuseOutsideStore(canonical, "containing session residue");
@@ -2475,8 +2475,8 @@ export class MemoryEngine {
2475
2475
  if (committed !== undefined) {
2476
2476
  try {
2477
2477
  this.refuseOutsideStore(f.canonical, "restoring a held entry's committed content", handle);
2478
- writeFileNoFollow(f.canonical, committed);
2479
- report.restored.push(rel);
2478
+ if (writeFileNoReplace(f.canonical, committed) === "written")
2479
+ report.restored.push(rel);
2480
2480
  }
2481
2481
  catch (err) {
2482
2482
  report.warnings.push(`${rel}: the committed content could not be restored after the hold captured this session's edit — the entry is unavailable on the plane until release or the next restore: ${this.writeFailureText(err)}`);
@@ -513,13 +513,21 @@ export interface QuarantineOutcome {
513
513
  * without native bindings. What this buys is the leaf variant, which is the cheap one; the ancestor
514
514
  * variant stays open and is recorded with the rest of the family rather than papered over.
515
515
  *
516
- * Throws like `writeFileSync`, including ELOOP when the final component IS a symlink. A HARD link is the
517
- * same tamper by other means — the file's bytes live under a second name, possibly outside the store, and
518
- * an in-place write would change them there too — so an opened file with more than one name is refused
519
- * the same way, before anything is truncated (the check reads the opened descriptor: no window). The
520
- * write itself goes through `writeFileSync` on the open descriptor, which writes every byte or throws —
521
- * a bare `writeSync` may short-write, and reporting a truncated restore as contained (after the
522
- * truncation already destroyed the destination) is the failure this guard exists to prevent.
516
+ * Throws like `writeFileSync`, including ELOOP when the final component IS a symlink, and EACCES for a
517
+ * file whose own bits refuse the write. A write changes only the NAME it writes. A file with one name is
518
+ * rewritten in place (its inode and mode stay). A HARD link is the same tamper as a symlink by other
519
+ * means — the file's bytes live under a second name, possibly outside the store, and an in-place write
520
+ * would change them there too — so a file the open finds with more names is never written in place.
521
+ * One such name is the engine's own: a staging name a no-replace restore stopped between its `link` and
522
+ * its `unlink` left beside the file; it is removed first ({@link dropStagingSecondNames}), the interrupted
523
+ * restore's last step. A file that still has another name gets a new file under THIS name, written the
524
+ * way the store commits a file ({@link atomicWriteFileSync}: an exclusive no-follow sibling, 0o600,
525
+ * renamed over this name); the other names keep their file, its bytes and its mode. Residual: a path
526
+ * replaced by another file between the open and that rename is replaced again (the window every
527
+ * rename-based store write has). The in-place write goes through `writeFileSync` on the open descriptor,
528
+ * which writes every byte or throws — a bare `writeSync` may short-write, and reporting a truncated
529
+ * restore as contained (after the truncation already destroyed the destination) is the failure this
530
+ * guard exists to prevent.
523
531
  */
524
532
  export declare function writeFileNoFollow(path: string, content: string): void;
525
533
  /** {@link writeFileNoFollow}'s NO-REPLACE twin: write `content` only if nothing is at `path`. `"written"`
@@ -529,6 +537,48 @@ export declare function writeFileNoFollow(path: string, content: string): void;
529
537
  * it refuses a symlink at the final component on its own (POSIX `EEXIST` on a link, dangling or not),
530
538
  * so the twin's no-follow property is kept without a second check. */
531
539
  export declare function writeFileNoReplace(path: string, content: string): "written" | "kept";
540
+ /** THE minter of every staging name the engine puts beside a plane file while it is displaced:
541
+ * `<owner>.staging-<ms>-<pid>-<seq>`. One grammar for every site, so one recognizer
542
+ * ({@link stagingNamePattern}) knows the names the engine can have left beside a seat. */
543
+ export declare function mintStagingName(owner: string, now: () => number): string;
544
+ /** The grammar {@link mintStagingName} and {@link claimStaging} write, as a recognizer — of ONE owner's
545
+ * generations when `owner` is given; otherwise of every staging name an engine has minted beside a seat,
546
+ * for the two owners it mints them for: an instruction hold (`hold-<ms>-<12 hex>`) and a crash-residue
547
+ * capture (`<ms>-residue-<entry id>.md`), whose `<ms>-residue-<id>.md.staging` of 7.55.0 and earlier is
548
+ * included (a name already on disk does not lose its owner with an upgrade). A prefix or a bare
549
+ * `.staging-` suffix would adopt any name a writer chose on the strength of its spelling. Minted and
550
+ * recognised side by side so the two cannot drift. */
551
+ export declare function stagingNamePattern(owner?: string): RegExp;
552
+ /** Take exclusive hold of a staged name by an atomic same-directory rename to a name minted HERE: the
553
+ * staged name lives in a WRITABLE directory, so a plain read-then-unlink could delete a replacement that
554
+ * landed between the two while reporting success over the earlier bytes. After the claim, what the rename
555
+ * moved is what every later read and unlink addresses. Returns the claim when it took, the original when
556
+ * the directory refused it (a hardening, not a precondition — a caller that removes on the strength of
557
+ * the claim checks which one it got). Residual: a writer enumerating the directory can still replace the
558
+ * CLAIM name before it is read — nothing Node's `fs` closes that, and the window is narrower than the one
559
+ * it replaces. */
560
+ export declare function claimStaging(stagingPath: string): string;
561
+ /** Whether `path` names the file `ref` describes: a regular file on the same device with the same inode,
562
+ * read without following a link at `path`. */
563
+ export declare function isSameFile(path: string, ref: {
564
+ readonly dev: number;
565
+ readonly ino: number;
566
+ }): boolean;
567
+ /**
568
+ * Remove every staging name an engine minted ({@link stagingNamePattern}) beside `seat` that is another
569
+ * name of the file `opened` describes — the un-dropped half of a no-replace restore stopped between its
570
+ * `link` and its `unlink`. Called by a write about to replace that file's bytes: removing the name loses
571
+ * nothing the write itself does not overwrite, and touches only names in the engine's staging grammar (a name
572
+ * is read as the engine's own by its spelling and by being the same file, so a hard link someone made and
573
+ * spelled that way goes too; every other hard-link copy, snapshot name and planted link stays, with its file).
574
+ * Not claimed first: a claim is a `rename`, which replaces whatever already stands at the claim name.
575
+ * Residual: a file put at that minted name between the check and the removal is removed — only a writer of
576
+ * this directory can put it there, and it can remove the name itself. Answers how many names went.
577
+ */
578
+ export declare function dropStagingSecondNames(seat: string, opened: {
579
+ readonly dev: number;
580
+ readonly ino: number;
581
+ }): number;
532
582
  /**
533
583
  * The ONE way a committed baseline goes back after {@link quarantineAndTombstone} emptied its seat —
534
584
  * the inverse half of that function, beside it so the removal word and its readers stay in one module.
@@ -1272,7 +1322,9 @@ export declare function writeAllSync(fd: number, data: string): void;
1272
1322
  * is not fsync'd (stores/file/fs-atomic.ts has the dir-fsync variant for stores that need it), so
1273
1323
  * a crash in that window can resurface the old content. Sidecars tolerate that (they are rebuilt
1274
1324
  * or re-derived); do not route data that can't through here. Throws on failure (fail-closed: a
1275
- * sidecar that cannot be written must not be silently skipped). */
1325
+ * sidecar that cannot be written must not be silently skipped). The tmp file is created EXCLUSIVELY and
1326
+ * no-follow: a name already standing there (a link or a file somebody placed) is an `EEXIST` refusal,
1327
+ * never a file this write truncates or writes through. */
1276
1328
  export declare function atomicWriteFileSync(path: string, data: string): void;
1277
1329
  /** Content-gated {@link atomicWriteFileSync} for a DERIVED/control-plane file: a byte-identical
1278
1330
  * rewrite (the common case on a repeat mount over an unchanged store) is skipped entirely, so the
@@ -1137,16 +1137,20 @@ export const QUARANTINE_DIR = "quarantine";
1137
1137
  const DELETED_TOMBSTONE = "---\ndeleted: true\n---\n";
1138
1138
  export function writeFileNoFollow(path, content) {
1139
1139
  const fd = openSync(path, O_WRONLY | O_CREAT | O_NOFOLLOW, 0o644);
1140
+ let names;
1140
1141
  try {
1141
- const links = fstatSync(fd).nlink;
1142
- if (links > 1)
1143
- throw Object.assign(new Error(`${path} has ${links} names (a hard link) — a write through one name changes the file under the others; not written`), { path });
1144
- ftruncateSync(fd, 0);
1145
- writeFileSync(fd, content, "utf8");
1142
+ const opened = fstatSync(fd);
1143
+ names = opened.nlink > 1 && dropStagingSecondNames(path, opened) > 0 ? fstatSync(fd).nlink : opened.nlink;
1144
+ if (names <= 1) {
1145
+ ftruncateSync(fd, 0);
1146
+ writeFileSync(fd, content, "utf8");
1147
+ }
1146
1148
  }
1147
1149
  finally {
1148
1150
  closeSync(fd);
1149
1151
  }
1152
+ if (names > 1)
1153
+ atomicWriteFileSync(path, content);
1150
1154
  }
1151
1155
  export function writeFileNoReplace(path, content) {
1152
1156
  let fd;
@@ -1166,6 +1170,61 @@ export function writeFileNoReplace(path, content) {
1166
1170
  }
1167
1171
  return "written";
1168
1172
  }
1173
+ let stagingSeq = 0;
1174
+ export function mintStagingName(owner, now) {
1175
+ stagingSeq += 1;
1176
+ return `${owner}.staging-${now()}-${process.pid}-${stagingSeq}`;
1177
+ }
1178
+ export function stagingNamePattern(owner) {
1179
+ const head = owner === undefined
1180
+ ? String.raw `(?:hold-\d+-[0-9a-f]{12}\.staging-\d+-\d+-\d+|\d+-residue-[^/]+\.md\.staging(?:-\d+-\d+-\d+)?)`
1181
+ : String.raw `${owner.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}\.staging-\d+-\d+-\d+`;
1182
+ return new RegExp(String.raw `^${head}(?:\.claim-\d+-\d+)*$`);
1183
+ }
1184
+ export function claimStaging(stagingPath) {
1185
+ stagingSeq += 1;
1186
+ const claimed = `${stagingPath}.claim-${process.pid}-${stagingSeq}`;
1187
+ try {
1188
+ renameSync(stagingPath, claimed);
1189
+ return claimed;
1190
+ }
1191
+ catch {
1192
+ return stagingPath;
1193
+ }
1194
+ }
1195
+ export function isSameFile(path, ref) {
1196
+ try {
1197
+ const st = lstatSync(path);
1198
+ return st.isFile() && st.dev === ref.dev && st.ino === ref.ino;
1199
+ }
1200
+ catch {
1201
+ return false;
1202
+ }
1203
+ }
1204
+ export function dropStagingSecondNames(seat, opened) {
1205
+ const dir = dirname(seat);
1206
+ let names;
1207
+ try {
1208
+ names = readdirSync(dir);
1209
+ }
1210
+ catch {
1211
+ return 0;
1212
+ }
1213
+ const minted = stagingNamePattern();
1214
+ let dropped = 0;
1215
+ for (const name of names) {
1216
+ const at = join(dir, name);
1217
+ if (name === basename(seat) || !minted.test(name) || !isSameFile(at, opened))
1218
+ continue;
1219
+ try {
1220
+ unlinkSync(at);
1221
+ dropped += 1;
1222
+ }
1223
+ catch {
1224
+ }
1225
+ }
1226
+ return dropped;
1227
+ }
1169
1228
  function readForVerification(path, maxBytes) {
1170
1229
  let fd;
1171
1230
  try {
@@ -2628,7 +2687,7 @@ export function writeAllSync(fd, data) {
2628
2687
  export function atomicWriteFileSync(path, data) {
2629
2688
  ensureDirExists(dirname(path));
2630
2689
  const tmp = join(dirname(path), `.tmp-${process.pid}-${Math.random().toString(36).slice(2, 10)}`);
2631
- const fd = openSync(tmp, "w", 0o600);
2690
+ const fd = openSync(tmp, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0o600);
2632
2691
  try {
2633
2692
  writeAllSync(fd, data);
2634
2693
  fsyncSync(fd);
@@ -41,7 +41,7 @@ export declare function memoryExposureIndexRow(id: string): string;
41
41
  export declare function parseMemoryExposureIndexRow(line: string): string | undefined;
42
42
  /**
43
43
  * §5.4 — the label-semantics sentence appended to the runner's recall-discipline segment under
44
- * "carry" (the CC-verbatim `# Memory` instruction template is never touched — its sha256 pin
44
+ * "carry" (the `# Memory` instruction template is never touched — its sha256 pin
45
45
  * stands). States what the marks mean and the verify-first discipline, and says explicitly that
46
46
  * marked entries stay usable (§13-2: the guardrail against over-avoidance).
47
47
  */
@@ -7,7 +7,7 @@ import { committedOriginOf } from "./frontmatter.js";
7
7
  import { MEMORY_EXPOSURE_BANNER, MEMORY_EXPOSURE_HANDLE_TAG, MEMORY_PROVENANCE_INDEX_SENTENCE, MEMORY_PROVENANCE_SEARCH_SENTENCE, MEMORY_SEARCH_BAND_ORDER_HEADER } from "./provenance-wording.js";
8
8
  import { deriveSupersededSet, memorySupersededNote, MEMORY_SEARCH_SUPERSEDED_TAG } from "./consolidation.js";
9
9
  import { deriveShadowedSet, memoryShadowedNote, shadowNamesOf, MEMORY_SEARCH_SHADOWED_TAG } from "./shadowing.js";
10
- import { toolFace } from "../tool-catalog-entries.js";
10
+ import { mountRuleFace, toolFace } from "../tool-catalog-entries.js";
11
11
  export const MEMORY_SEARCH_TOOL_NAME = "memory_search";
12
12
  export const MEMORY_GET_TOOL_NAME = "memory_get";
13
13
  export const MEMORY_INDEX_TOOL_NAME = "memory_index";
@@ -229,6 +229,7 @@ export function createMemoryEngineTools(opts) {
229
229
  const searchTool = {
230
230
  name: MEMORY_SEARCH_TOOL_NAME,
231
231
  ...toolFace("memory-search"),
232
+ ruleFace: mountRuleFace("memory-search"),
232
233
  description: carry ? `${SEARCH_DESCRIPTION}\n\n${MEMORY_PROVENANCE_SEARCH_SENTENCE}` : SEARCH_DESCRIPTION,
233
234
  parameters: Type.Object({
234
235
  query: Type.String({ description: "Keywords to look for (lexical match against entry names, descriptions and bodies)." }),
@@ -382,6 +383,7 @@ export function createMemoryEngineTools(opts) {
382
383
  const getTool = {
383
384
  name: MEMORY_GET_TOOL_NAME,
384
385
  ...toolFace("memory-get"),
386
+ ruleFace: mountRuleFace("memory-get"),
385
387
  description: GET_DESCRIPTION,
386
388
  parameters: Type.Object({
387
389
  id: Type.Optional(Type.String({ description: "Entry id (exact lookup). Pass either id or slug, not both." })),
@@ -633,6 +635,7 @@ export function createMemoryEngineTools(opts) {
633
635
  const indexTool = {
634
636
  name: MEMORY_INDEX_TOOL_NAME,
635
637
  ...toolFace("memory-index"),
638
+ ruleFace: mountRuleFace("memory-index"),
636
639
  description: carry ? `${INDEX_DESCRIPTION}\n\n${MEMORY_PROVENANCE_INDEX_SENTENCE}` : INDEX_DESCRIPTION,
637
640
  parameters: Type.Object({
638
641
  offset: Type.Optional(Type.Number({ description: "Zero-based row offset into the listing (default 0) — pass the previous page's footer value to continue." })),
@@ -45,7 +45,7 @@ export interface ModePolicy {
45
45
  readonly writeFace: ContainmentFace | undefined;
46
46
  readonly unstated: "ask" | "none";
47
47
  }
48
- /** The `acceptEdits` file commands, verbatim from the reference implementation (2.1.280): a closed set. */
48
+ /** The `acceptEdits` file commands: a closed set. */
49
49
  export declare const ACCEPT_EDITS_FILE_COMMANDS: readonly ["mkdir", "touch", "rm", "rmdir", "mv", "cp", "sed"];
50
50
  /** The mode → seats table, total over {@link PermissionMode}. */
51
51
  export declare function modePolicyOf(mode: PermissionMode): ModePolicy;
@@ -49,9 +49,16 @@ export type RoleSpec = ModelRef | {
49
49
  select?: import("./select-model.js").ModelCriteria;
50
50
  thinking?: ThinkingLevel;
51
51
  /**
52
- * Optional preset system prompt for this role (e.g. {@link CODE_AGENT_PROMPT} for a dev role).
53
- * Used only when the task does not supply its own `TaskSpec.systemPrompt`. Lets coding roles run
54
- * a coding prompt while other roles keep the neutral default — without touching the global default.
52
+ * The role's preset role base, by WORD: which catalog role base (`core/role.base` variant) tasks of this role
53
+ * are assembled for — `"code"` for a coding role — and their host role. Same closed set and door as
54
+ * `TaskSpec.promptRole` (`HOST_ROLES`; outside it ⇒ `config.prompt_selector_invalid`, naming `roles.<role>.promptRole`).
55
+ * The preset applies only when the task names no role base of its own (neither `promptRole` nor `systemPrompt`):
56
+ * the first source that names one — task, then this preset, then an engine spawner's child persona — decides it.
57
+ */
58
+ promptRole?: import("../prompt-assembly/catalog/schema.js").HostRole;
59
+ /**
60
+ * The role's preset role base, by TEXT (it replaces the base `promptRole` selects; the role is `promptRole`, else
61
+ * `general`). Same precedence as `promptRole`: used only when the task names no role base of its own.
55
62
  */
56
63
  systemPrompt?: string;
57
64
  };
@@ -0,0 +1,67 @@
1
+ /**
2
+ * The one typing of the engine's classic stations: each `classic.*` event a station raises, paired with its `e` and its
3
+ * answer form. Every raise site constructs its `e` against it (`dispatchClassic` / `observeClassic`), and the engine's
4
+ * registration form types a handler by it. Its keys are the event table's `classic.*` rows that carry a station — the key
5
+ * set is held to that table.
6
+ */
7
+ import type { PermissionDeniedPayload, PostCompactEvent, PostToolBatchEvent, PostToolBatchResult, PostToolUseEvent, PostToolUseFailureEvent, PostToolUseFailureResult, PostToolUseResult, PreCompactEvent, PreCompactResult, PreToolUseEvent, PreToolUseResult, StopEvent, StopFailureEvent, StopHookResult, UserPromptSubmitEvent, UserPromptSubmitResult } from "../hooks.js";
8
+ import type { MappedOn, ModRegistration } from "./kernel/index.js";
9
+ import type { EngineDollar } from "./dollar.js";
10
+ /** The answer of an event whose station reads none (an observation event): a chain handler passes `next(e)`'s on. */
11
+ export type ObservedAnswer = Readonly<Record<string, never>>;
12
+ /** Each `classic.*` event a station raises, with its `e` and its answer form. */
13
+ export type ClassicEventMap = {
14
+ readonly "classic.PreToolUse": {
15
+ readonly e: PreToolUseEvent;
16
+ readonly answer: PreToolUseResult | null | false;
17
+ };
18
+ readonly "classic.PostToolUse": {
19
+ readonly e: PostToolUseEvent;
20
+ readonly answer: PostToolUseResult;
21
+ };
22
+ readonly "classic.PostToolUseFailure": {
23
+ readonly e: PostToolUseFailureEvent;
24
+ readonly answer: PostToolUseFailureResult;
25
+ };
26
+ readonly "classic.PostToolBatch": {
27
+ readonly e: PostToolBatchEvent;
28
+ readonly answer: PostToolBatchResult;
29
+ };
30
+ readonly "classic.UserPromptSubmit": {
31
+ readonly e: UserPromptSubmitEvent;
32
+ readonly answer: UserPromptSubmitResult;
33
+ };
34
+ readonly "classic.Stop": {
35
+ readonly e: StopEvent;
36
+ readonly answer: StopHookResult;
37
+ };
38
+ readonly "classic.SubagentStop": {
39
+ readonly e: StopEvent;
40
+ readonly answer: StopHookResult;
41
+ };
42
+ readonly "classic.StopFailure": {
43
+ readonly e: StopFailureEvent;
44
+ readonly answer: ObservedAnswer;
45
+ };
46
+ readonly "classic.PreCompact": {
47
+ readonly e: PreCompactEvent;
48
+ readonly answer: PreCompactResult;
49
+ };
50
+ readonly "classic.PostCompact": {
51
+ readonly e: PostCompactEvent;
52
+ readonly answer: ObservedAnswer;
53
+ };
54
+ readonly "classic.PermissionDenied": {
55
+ readonly e: PermissionDeniedPayload;
56
+ readonly answer: ObservedAnswer;
57
+ };
58
+ };
59
+ /** A `classic.*` event a station raises. */
60
+ export type ClassicEventName = keyof ClassicEventMap;
61
+ /**
62
+ * A registration on the engine's bus (`RunnerDeps.mods`, `TaskSpec.mods`): the kernel's registration form whose `on`
63
+ * types a handler of a `classic.*` event by {@link ClassicEventMap} — its `e`, its `next`, its answer.
64
+ */
65
+ export interface EngineModRegistration extends Omit<ModRegistration<EngineDollar>, "register"> {
66
+ register(on: MappedOn<EngineDollar, ClassicEventMap>, options: unknown): void;
67
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -100,10 +100,23 @@ export interface EngineDollar extends ModDollarBase {
100
100
  };
101
101
  readonly tool: {
102
102
  list(): Promise<readonly string[]>;
103
+ /** `$.tool.call({ tool, ...input })`: the run's own pipeline for one call of a mounted tool (`tool-call.ts`). */
104
+ call(args: {
105
+ readonly tool: string;
106
+ } & Readonly<Record<string, unknown>>): Promise<ToolCallAnswer>;
103
107
  };
104
108
  readonly agent: {
105
109
  list(): Promise<readonly string[]>;
106
110
  };
107
111
  }
112
+ /** What `$.tool.call` answers — `tool.call`'s own forms: the frozen view of the call's result, or the refusal (returned, not thrown). */
113
+ export type ToolCallAnswer = {
114
+ readonly result: {
115
+ readonly content: readonly object[];
116
+ readonly isError: boolean;
117
+ };
118
+ } | {
119
+ readonly deny: string;
120
+ };
108
121
  /** The chain bottoms of the wave-one method events over a runner's seat view. */
109
122
  export declare function engineMethodBottoms(view: ModSeatView): ModMethodBottoms;
@@ -0,0 +1,31 @@
1
+ import { type ModBottomContext, type ModBus } from "./kernel/index.js";
2
+ import type { ExtensionRequester } from "../task-event.js";
3
+ /** One extension's call while it runs. */
4
+ export interface ExtensionCall {
5
+ /** The leg bus the call was made on (the one {@link legBusOf} returned). */
6
+ readonly bus: ModBus;
7
+ readonly toolCallId: string;
8
+ /** The `$` call's context: the frames its pipeline's events are raised under, and its origin. */
9
+ readonly caller: ModBottomContext;
10
+ /** Cleared when the call's pipeline settles — the one reading of "this call is still running". */
11
+ readonly live: boolean;
12
+ /** The call's end projection refused it (its latest gate record is a refusal) — written once, by the leg's tool_end station. */
13
+ readonly denied: boolean;
14
+ }
15
+ /** The running extension call this chain carries for `bus`, when it is the call `toolCallId` names (or any, unnamed). */
16
+ export declare function extensionCallOf(bus: object, toolCallId?: string): ExtensionCall | undefined;
17
+ /** Who asked for the call `toolCallId` names, when it is the running extension call: the one projection every carrier of
18
+ * `requestedBy` reads (the occurrence the frames are projected from, the approval card). */
19
+ export declare function requesterOf(bus: object, toolCallId: string): {
20
+ readonly requestedBy?: ExtensionRequester;
21
+ };
22
+ /** The leg's tool_end station says the call it is closing was refused (a no-op for any call that is not the running extension call). */
23
+ export declare function noteExtensionCallDenied(bus: object, toolCallId: string): void;
24
+ /** Run an extension's call: `pipeline` runs with the call's record in scope; the record stops being live when it settles. */
25
+ export declare function runExtensionCall<T>(bus: ModBus, toolCallId: string, caller: ModBottomContext, pipeline: (call: ExtensionCall) => Promise<T>): Promise<T>;
26
+ /**
27
+ * The leg bus every station raises on: a dispatch inside a running extension call made on it is raised under that call's
28
+ * frames and origin (a raiser that names its own frames keeps them — they extend the call's); one raised under a call
29
+ * that has settled is refused, `failed` by the engine and said once on `report`; any other dispatch is the bus's own.
30
+ */
31
+ export declare function legBusOf(bus: ModBus, report: (err: Error) => void): ModBus;