@sema-agent/core 7.66.0 → 7.67.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 (903) hide show
  1. package/CHANGELOG.md +3498 -0
  2. package/LICENSE +2 -1
  3. package/dist/agents/agent-definition.js +2 -1
  4. package/dist/agents/agent-transcript-tool.d.ts +1 -1
  5. package/dist/agents/agent-transcript-tool.js +4 -3
  6. package/dist/agents/builtin-agents.d.ts +10 -7
  7. package/dist/agents/builtin-agents.js +1 -0
  8. package/dist/agents/cascade.d.ts +24 -11
  9. package/dist/agents/cascade.js +21 -9
  10. package/dist/agents/child-failure.d.ts +30 -0
  11. package/dist/agents/child-failure.js +25 -1
  12. package/dist/agents/composition-placement.d.ts +6 -2
  13. package/dist/agents/composition-placement.js +7 -3
  14. package/dist/agents/cross-session-envelope.d.ts +10 -1
  15. package/dist/agents/cross-session-envelope.js +6 -2
  16. package/dist/agents/cross-session-judge.d.ts +7 -1
  17. package/dist/agents/cross-session-judge.js +1 -0
  18. package/dist/agents/cumulative-stats.d.ts +36 -2
  19. package/dist/agents/cumulative-stats.js +44 -9
  20. package/dist/agents/delegation-registry-seat.js +2 -3
  21. package/dist/agents/inherited-tool-pool.d.ts +9 -4
  22. package/dist/agents/inherited-tool-pool.js +7 -1
  23. package/dist/agents/leg-label.d.ts +28 -0
  24. package/dist/agents/leg-label.js +9 -0
  25. package/dist/agents/list-agents-tool.d.ts +1 -1
  26. package/dist/agents/list-agents-tool.js +4 -4
  27. package/dist/agents/org-delivery-gate.d.ts +129 -23
  28. package/dist/agents/org-delivery-gate.js +41 -20
  29. package/dist/agents/peer-held-queue.d.ts +15 -10
  30. package/dist/agents/peer-held-queue.js +47 -19
  31. package/dist/agents/peer-notice-route.js +2 -2
  32. package/dist/agents/peer-notices.d.ts +13 -2
  33. package/dist/agents/peer-notices.js +12 -2
  34. package/dist/agents/peer-session-drain.d.ts +65 -15
  35. package/dist/agents/peer-session-drain.js +198 -41
  36. package/dist/agents/read-inbox-tool.d.ts +3 -2
  37. package/dist/agents/read-inbox-tool.js +7 -5
  38. package/dist/agents/repair-loop.js +20 -16
  39. package/dist/agents/retain-ledger.d.ts +1 -1
  40. package/dist/agents/retain-ledger.js +2 -4
  41. package/dist/agents/root-session-lane.d.ts +27 -0
  42. package/dist/agents/root-session-lane.js +57 -0
  43. package/dist/agents/roster-store.js +1 -2
  44. package/dist/agents/send-message-tool.js +6 -4
  45. package/dist/agents/subagent.d.ts +20 -4
  46. package/dist/agents/subagent.js +218 -183
  47. package/dist/agents/tool-filter.d.ts +3 -10
  48. package/dist/agents/tool-filter.js +0 -13
  49. package/dist/agents/verifier-independence.d.ts +31 -0
  50. package/dist/agents/verifier-independence.js +23 -0
  51. package/dist/agents/verify.d.ts +23 -11
  52. package/dist/agents/verify.js +28 -12
  53. package/dist/agents/yield-adoption.d.ts +24 -0
  54. package/dist/agents/yield-adoption.js +84 -0
  55. package/dist/bench/metrics.d.ts +2 -2
  56. package/dist/brain/anthropic.d.ts +4 -2
  57. package/dist/brain/anthropic.js +49 -35
  58. package/dist/brain/brain-faces.d.ts +11 -0
  59. package/dist/brain/brain-faces.js +6 -0
  60. package/dist/brain/cache-retention.d.ts +2 -0
  61. package/dist/brain/cache-retention.js +9 -0
  62. package/dist/brain/circuit-breaker.js +51 -26
  63. package/dist/brain/errors.d.ts +15 -1
  64. package/dist/brain/errors.js +8 -0
  65. package/dist/brain/failover.d.ts +6 -0
  66. package/dist/brain/failover.js +52 -37
  67. package/dist/brain/media-degrade.d.ts +5 -0
  68. package/dist/brain/media-degrade.js +4 -0
  69. package/dist/brain/model-capability.d.ts +2 -1
  70. package/dist/brain/model-lane.d.ts +145 -0
  71. package/dist/brain/model-lane.js +444 -0
  72. package/dist/brain/open-responses.js +19 -22
  73. package/dist/brain/openai.js +23 -22
  74. package/dist/brain/provider-message.d.ts +9 -0
  75. package/dist/brain/provider-message.js +18 -0
  76. package/dist/brain/reasoning-request.d.ts +9 -7
  77. package/dist/brain/reasoning-request.js +9 -10
  78. package/dist/brain/reasoning.d.ts +47 -13
  79. package/dist/brain/reasoning.js +20 -10
  80. package/dist/brain/route-adjudicator.d.ts +8 -2
  81. package/dist/brain/route-adjudicator.js +35 -1
  82. package/dist/brain/route-conformance.js +17 -0
  83. package/dist/brain/routing.d.ts +2 -0
  84. package/dist/brain/routing.js +19 -8
  85. package/dist/brain/status-sink.d.ts +5 -4
  86. package/dist/brain/status-sink.js +2 -2
  87. package/dist/brain/stream-engine.js +8 -2
  88. package/dist/brain/stream-shared.d.ts +12 -0
  89. package/dist/brain/stream-shared.js +18 -0
  90. package/dist/brain/timeout.d.ts +28 -0
  91. package/dist/brain/timeout.js +13 -4
  92. package/dist/brain/tool-schema-projection.d.ts +2 -0
  93. package/dist/brain/tool-schema-projection.js +108 -0
  94. package/dist/brain/usage-reading.d.ts +49 -0
  95. package/dist/brain/usage-reading.js +44 -0
  96. package/dist/brain/usage-reasoning.d.ts +38 -0
  97. package/dist/brain/usage-reasoning.js +9 -0
  98. package/dist/config/catalog.d.ts +3 -0
  99. package/dist/config/catalog.js +18 -9
  100. package/dist/core/a2a.d.ts +22 -4
  101. package/dist/core/a2a.js +191 -50
  102. package/dist/core/agent-definition.d.ts +3 -1
  103. package/dist/core/agent-state.d.ts +29 -16
  104. package/dist/core/agent-state.js +36 -9
  105. package/dist/core/allow-entry.d.ts +12 -3
  106. package/dist/core/allow-entry.js +10 -3
  107. package/dist/core/approval-display.d.ts +18 -0
  108. package/dist/core/approval-display.js +26 -0
  109. package/dist/core/approval-object.js +2 -2
  110. package/dist/core/approval-route.d.ts +16 -0
  111. package/dist/core/approval-route.js +5 -0
  112. package/dist/core/approval-words.d.ts +43 -0
  113. package/dist/core/approval-words.js +37 -0
  114. package/dist/core/ask-origin.d.ts +37 -10
  115. package/dist/core/ask-origin.js +19 -7
  116. package/dist/core/ask-question.d.ts +36 -8
  117. package/dist/core/ask-question.js +24 -9
  118. package/dist/core/ask-unresolvable-notice.d.ts +3 -2
  119. package/dist/core/ask-unresolvable-notice.js +3 -2
  120. package/dist/core/attachment-source.d.ts +50 -0
  121. package/dist/core/attachment-source.js +46 -0
  122. package/dist/core/auto-compaction.d.ts +151 -40
  123. package/dist/core/auto-compaction.js +115 -50
  124. package/dist/core/auto-mode.d.ts +5 -0
  125. package/dist/core/auto-mode.js +11 -4
  126. package/dist/core/background-agent-store.d.ts +151 -23
  127. package/dist/core/background-agent-store.js +201 -61
  128. package/dist/core/background-shell.d.ts +4 -1
  129. package/dist/core/background-shell.js +1 -0
  130. package/dist/core/cache-break-detector.d.ts +49 -25
  131. package/dist/core/cache-break-detector.js +99 -44
  132. package/dist/core/caller-text.d.ts +28 -0
  133. package/dist/core/caller-text.js +12 -0
  134. package/dist/core/canonical-json.d.ts +5 -0
  135. package/dist/core/canonical-json.js +7 -0
  136. package/dist/core/checkpoint-features.d.ts +80 -9
  137. package/dist/core/checkpoint-features.js +1 -1
  138. package/dist/core/checkpoint-generation.d.ts +8 -1
  139. package/dist/core/checkpoint-generation.js +3 -0
  140. package/dist/core/checkpoint-queries.d.ts +47 -14
  141. package/dist/core/checkpoint-queries.js +63 -30
  142. package/dist/core/checkpoint-requirements.d.ts +36 -3
  143. package/dist/core/checkpoint-requirements.js +11 -1
  144. package/dist/core/checkpoint-row-verdict.d.ts +0 -2
  145. package/dist/core/checkpoint-row-verdict.js +5 -8
  146. package/dist/core/checkpoint-store.d.ts +166 -41
  147. package/dist/core/checkpoint-store.js +96 -15
  148. package/dist/core/child-clamp-seats.d.ts +10 -2
  149. package/dist/core/child-clamp-seats.js +2 -2
  150. package/dist/core/classifier-unavailable-arm.d.ts +11 -9
  151. package/dist/core/classifier-unavailable-arm.js +4 -2
  152. package/dist/core/command-sandbox-dispatch.d.ts +13 -0
  153. package/dist/core/command-sandbox-dispatch.js +8 -0
  154. package/dist/core/command-sandbox.d.ts +231 -0
  155. package/dist/core/command-sandbox.js +344 -0
  156. package/dist/core/completion-id.d.ts +21 -0
  157. package/dist/core/completion-id.js +14 -0
  158. package/dist/core/config-refusal-codes.d.ts +22 -0
  159. package/dist/core/config-refusal-codes.js +196 -0
  160. package/dist/core/context-edit.d.ts +26 -0
  161. package/dist/core/context-edit.js +4 -2
  162. package/dist/core/context-guard.d.ts +80 -7
  163. package/dist/core/context-guard.js +126 -25
  164. package/dist/core/context-settings.d.ts +32 -0
  165. package/dist/core/context-settings.js +41 -3
  166. package/dist/core/contract-faces.d.ts +22 -0
  167. package/dist/core/contract-faces.js +1 -0
  168. package/dist/core/credential-echo.d.ts +2 -2
  169. package/dist/core/credential-echo.js +2 -2
  170. package/dist/core/cross-boundary-taint.d.ts +10 -8
  171. package/dist/core/decision-receipt.d.ts +3 -2
  172. package/dist/core/decision-receipt.js +1 -1
  173. package/dist/core/definition-entry-grammar.d.ts +42 -0
  174. package/dist/core/definition-entry-grammar.js +15 -0
  175. package/dist/core/engine-attestation.d.ts +19 -4
  176. package/dist/core/engine-attestation.js +4 -0
  177. package/dist/core/engine-capabilities.d.ts +8 -1
  178. package/dist/core/engine-capabilities.js +1 -1
  179. package/dist/core/engine-contracts/open-face-contract.d.ts +39 -0
  180. package/dist/core/engine-contracts/open-face-contract.js +57 -0
  181. package/dist/core/engine-notice.d.ts +161 -33
  182. package/dist/core/exclusive-temp.d.ts +25 -0
  183. package/dist/core/exclusive-temp.js +19 -0
  184. package/dist/core/existing-target.d.ts +112 -0
  185. package/dist/core/existing-target.js +88 -0
  186. package/dist/core/file-history-store.d.ts +14 -6
  187. package/dist/core/gate-lanes.js +8 -3
  188. package/dist/core/gate-outcome.d.ts +2 -1
  189. package/dist/core/git-worktree-env.d.ts +92 -1
  190. package/dist/core/git-worktree-env.js +87 -6
  191. package/dist/core/governance-codes.d.ts +49 -8
  192. package/dist/core/governance-codes.js +59 -8
  193. package/dist/core/hands-band.d.ts +10 -6
  194. package/dist/core/hooks.d.ts +60 -6
  195. package/dist/core/hooks.js +10 -2
  196. package/dist/core/host-floor.d.ts +24 -8
  197. package/dist/core/host-floor.js +45 -16
  198. package/dist/core/human-input-projection.d.ts +7 -0
  199. package/dist/core/human-input-projection.js +11 -3
  200. package/dist/core/image-admission.d.ts +16 -4
  201. package/dist/core/image-admission.js +29 -17
  202. package/dist/core/input-author.d.ts +43 -1
  203. package/dist/core/input-author.js +19 -0
  204. package/dist/core/isolation-scope.d.ts +41 -0
  205. package/dist/core/isolation-scope.js +10 -0
  206. package/dist/core/json-schema-seats.d.ts +11 -0
  207. package/dist/core/json-schema-seats.js +5 -0
  208. package/dist/core/leg-identity.d.ts +53 -5
  209. package/dist/core/leg-identity.js +32 -1
  210. package/dist/core/locked-config.d.ts +33 -38
  211. package/dist/core/locked-config.js +21 -3
  212. package/dist/core/lsp.js +2 -1
  213. package/dist/core/mailbox-store.d.ts +111 -18
  214. package/dist/core/mailbox-store.js +101 -13
  215. package/dist/core/mcp-call-meta.js +1 -1
  216. package/dist/core/mcp-connection-pool.d.ts +8 -2
  217. package/dist/core/mcp-connection-pool.js +3 -1
  218. package/dist/core/mcp-failure.d.ts +6 -1
  219. package/dist/core/mcp-failure.js +10 -0
  220. package/dist/core/mcp-host-read.d.ts +293 -0
  221. package/dist/core/mcp-host-read.js +428 -0
  222. package/dist/core/mcp-server-link.d.ts +28 -6
  223. package/dist/core/mcp-server-link.js +35 -7
  224. package/dist/core/mcp-server-spec.d.ts +22 -29
  225. package/dist/core/mcp-server-spec.js +7 -14
  226. package/dist/core/mcp-server-unavailable-notice.d.ts +32 -0
  227. package/dist/core/mcp-server-unavailable-notice.js +15 -0
  228. package/dist/core/mcp-session-end.d.ts +5 -2
  229. package/dist/core/mcp-session-end.js +7 -2
  230. package/dist/core/mcp-tool-meta.d.ts +6 -0
  231. package/dist/core/mcp-tool-meta.js +1 -0
  232. package/dist/core/mcp.d.ts +54 -19
  233. package/dist/core/mcp.js +194 -241
  234. package/dist/core/memory-engine/committed-shadow-read.d.ts +16 -0
  235. package/dist/core/memory-engine/committed-shadow-read.js +21 -0
  236. package/dist/core/memory-engine/consolidation-driver.js +2 -1
  237. package/dist/core/memory-engine/consolidation.d.ts +3 -3
  238. package/dist/core/memory-engine/control-objects.d.ts +4 -3
  239. package/dist/core/memory-engine/control-objects.js +6 -4
  240. package/dist/core/memory-engine/delegation-settlement.d.ts +127 -25
  241. package/dist/core/memory-engine/delegation-settlement.js +145 -18
  242. package/dist/core/memory-engine/distiller.d.ts +2 -1
  243. package/dist/core/memory-engine/distiller.js +10 -5
  244. package/dist/core/memory-engine/dual-root.js +2 -2
  245. package/dist/core/memory-engine/engine.d.ts +127 -33
  246. package/dist/core/memory-engine/engine.js +774 -323
  247. package/dist/core/memory-engine/entry-scan.d.ts +3 -0
  248. package/dist/core/memory-engine/entry-scan.js +8 -0
  249. package/dist/core/memory-engine/export-bundle.d.ts +4 -0
  250. package/dist/core/memory-engine/export-bundle.js +2 -0
  251. package/dist/core/memory-engine/file-backend.d.ts +62 -17
  252. package/dist/core/memory-engine/file-backend.js +155 -99
  253. package/dist/core/memory-engine/index.d.ts +1 -1
  254. package/dist/core/memory-engine/index.js +1 -1
  255. package/dist/core/memory-engine/layer-observations.d.ts +7 -1
  256. package/dist/core/memory-engine/layer-observations.js +6 -0
  257. package/dist/core/memory-engine/layout.d.ts +88 -26
  258. package/dist/core/memory-engine/layout.js +105 -29
  259. package/dist/core/memory-engine/memory-deployment.js +4 -4
  260. package/dist/core/memory-engine/mount-failed-notice.d.ts +24 -0
  261. package/dist/core/memory-engine/mount-failed-notice.js +22 -0
  262. package/dist/core/memory-engine/origin-clearance.d.ts +15 -1
  263. package/dist/core/memory-engine/origin-clearance.js +30 -10
  264. package/dist/core/memory-engine/scan.js +1 -1
  265. package/dist/core/memory-engine/scope-contract.js +4 -3
  266. package/dist/core/memory-engine/session-write-home.js +13 -1
  267. package/dist/core/memory-engine/sync-client.d.ts +1 -1
  268. package/dist/core/memory-engine/sync-client.js +3 -1
  269. package/dist/core/memory-engine/tools.d.ts +5 -4
  270. package/dist/core/memory-engine/tools.js +1 -1
  271. package/dist/core/memory-engine/types.d.ts +18 -1
  272. package/dist/core/memory-engine/types.js +1 -0
  273. package/dist/core/memory.d.ts +1 -1
  274. package/dist/core/memory.js +2 -6
  275. package/dist/core/mode-policy.d.ts +8 -1
  276. package/dist/core/mode-policy.js +6 -2
  277. package/dist/core/model-fallbacks.d.ts +103 -0
  278. package/dist/core/model-fallbacks.js +79 -0
  279. package/dist/core/model-receipt.d.ts +15 -3
  280. package/dist/core/model-receipt.js +22 -1
  281. package/dist/core/model-seat.d.ts +1 -1
  282. package/dist/core/mods/classic-events.d.ts +5 -1
  283. package/dist/core/mods/dollar.d.ts +47 -2
  284. package/dist/core/mods/dollar.js +28 -5
  285. package/dist/core/mods/kernel/budget.d.ts +6 -0
  286. package/dist/core/mods/kernel/budget.js +6 -0
  287. package/dist/core/mods/kernel/dispatch.d.ts +23 -2
  288. package/dist/core/mods/kernel/dispatch.js +104 -15
  289. package/dist/core/mods/kernel/events.d.ts +18 -1
  290. package/dist/core/mods/kernel/events.js +7 -6
  291. package/dist/core/mods/kernel/index.d.ts +2 -2
  292. package/dist/core/mods/kernel/index.js +1 -1
  293. package/dist/core/mods/kernel/receive.d.ts +2 -1
  294. package/dist/core/mods/lifecycle-stations.d.ts +13 -4
  295. package/dist/core/mods/lifecycle-stations.js +8 -3
  296. package/dist/core/mods/message-display.d.ts +81 -0
  297. package/dist/core/mods/message-display.js +369 -0
  298. package/dist/core/mods/prompt-submit.d.ts +1 -1
  299. package/dist/core/mods/prompt-submit.js +5 -2
  300. package/dist/core/mods/session-append.d.ts +2 -2
  301. package/dist/core/mods/session-append.js +2 -1
  302. package/dist/core/mods/session-compact.js +2 -2
  303. package/dist/core/mods/stations.d.ts +48 -18
  304. package/dist/core/mods/stations.js +100 -19
  305. package/dist/core/mods/stop-answers.d.ts +23 -0
  306. package/dist/core/mods/stop-answers.js +20 -0
  307. package/dist/core/mounted-mcp.d.ts +48 -8
  308. package/dist/core/mounted-mcp.js +82 -16
  309. package/dist/core/namespaced-rule-name.js +2 -1
  310. package/dist/core/own-property-receipt.js +3 -5
  311. package/dist/core/parent-spec-seat.d.ts +20 -1
  312. package/dist/core/parent-spec-seat.js +13 -3
  313. package/dist/core/park-selfcheck.js +1 -0
  314. package/dist/core/path-identity.js +2 -1
  315. package/dist/core/peer-seat.d.ts +21 -7
  316. package/dist/core/peer-seat.js +25 -16
  317. package/dist/core/permission-rule-consent.js +15 -5
  318. package/dist/core/permission-rule-model.d.ts +4 -2
  319. package/dist/core/permission-rule-model.js +43 -23
  320. package/dist/core/permission-rule-store.d.ts +31 -16
  321. package/dist/core/permission-rule-store.js +27 -18
  322. package/dist/core/present-plan-tool.d.ts +6 -1
  323. package/dist/core/present-plan-tool.js +11 -3
  324. package/dist/core/pricing.d.ts +8 -6
  325. package/dist/core/pricing.js +1 -1
  326. package/dist/core/principal-name.d.ts +13 -0
  327. package/dist/core/principal-name.js +9 -2
  328. package/dist/core/process-identity.d.ts +140 -0
  329. package/dist/core/process-identity.js +215 -0
  330. package/dist/core/protocol-http-auth.d.ts +28 -6
  331. package/dist/core/protocol-http-auth.js +22 -5
  332. package/dist/core/protocol-naming.d.ts +7 -0
  333. package/dist/core/protocol-naming.js +12 -2
  334. package/dist/core/protocol-revocation.d.ts +72 -0
  335. package/dist/core/protocol-revocation.js +98 -0
  336. package/dist/core/protocol-table.d.ts +4 -4
  337. package/dist/core/protocol-table.js +3 -2
  338. package/dist/core/push-queue.d.ts +35 -2
  339. package/dist/core/push-queue.js +60 -4
  340. package/dist/core/read-only-shell.d.ts +19 -0
  341. package/dist/core/read-only-shell.js +38 -11
  342. package/dist/core/real-approval.d.ts +26 -0
  343. package/dist/core/real-approval.js +15 -0
  344. package/dist/core/redaction-marks.d.ts +6 -2
  345. package/dist/core/redaction-marks.js +3 -0
  346. package/dist/core/reminder-mint.d.ts +6 -0
  347. package/dist/core/reminder-mint.js +9 -8
  348. package/dist/core/remote-env.d.ts +31 -15
  349. package/dist/core/remote-env.js +29 -0
  350. package/dist/core/request-copy-projection.d.ts +51 -0
  351. package/dist/core/request-copy-projection.js +410 -0
  352. package/dist/core/resume-config-judge.d.ts +69 -0
  353. package/dist/core/resume-config-judge.js +78 -0
  354. package/dist/core/resume-startup-cause.d.ts +14 -4
  355. package/dist/core/resume-startup-cause.js +12 -2
  356. package/dist/core/retention-policy.js +2 -1
  357. package/dist/core/retention.d.ts +119 -24
  358. package/dist/core/retention.js +60 -16
  359. package/dist/core/retired-keys.d.ts +0 -10
  360. package/dist/core/retired-keys.js +2 -3
  361. package/dist/core/roles.d.ts +6 -0
  362. package/dist/core/roles.js +65 -4
  363. package/dist/core/row-shape.d.ts +149 -0
  364. package/dist/core/row-shape.js +184 -0
  365. package/dist/core/runner/advertised-writable-dirs.js +10 -9
  366. package/dist/core/runner/advisor-instructions.d.ts +11 -27
  367. package/dist/core/runner/advisor-instructions.js +18 -20
  368. package/dist/core/runner/advisor-tool.js +1 -0
  369. package/dist/core/runner/announce-once-ledger.js +4 -1
  370. package/dist/core/runner/approval-feedback.d.ts +17 -8
  371. package/dist/core/runner/approval-feedback.js +18 -13
  372. package/dist/core/runner/approver-defect-announcer.d.ts +17 -0
  373. package/dist/core/runner/approver-defect-announcer.js +22 -0
  374. package/dist/core/runner/assemble-result.d.ts +29 -14
  375. package/dist/core/runner/assemble-result.js +16 -25
  376. package/dist/core/runner/cache-hit-account.d.ts +77 -0
  377. package/dist/core/runner/cache-hit-account.js +46 -0
  378. package/dist/core/runner/call-hook-stations.d.ts +3 -2
  379. package/dist/core/runner/call-hook-stations.js +5 -4
  380. package/dist/core/runner/changed-files-scan.d.ts +43 -0
  381. package/dist/core/runner/changed-files-scan.js +34 -0
  382. package/dist/core/runner/checkpoint-scope.d.ts +33 -9
  383. package/dist/core/runner/checkpoint-scope.js +27 -1
  384. package/dist/core/runner/classifier-ladder.d.ts +2 -2
  385. package/dist/core/runner/classifier-ladder.js +18 -9
  386. package/dist/core/runner/clock-and-limits.d.ts +15 -4
  387. package/dist/core/runner/clock-and-limits.js +19 -1
  388. package/dist/core/runner/compact-session.js +84 -14
  389. package/dist/core/runner/compaction-call-options.d.ts +2 -29
  390. package/dist/core/runner/compaction-call-options.js +2 -9
  391. package/dist/core/runner/compaction-restate.d.ts +18 -2
  392. package/dist/core/runner/compaction-restate.js +36 -2
  393. package/dist/core/runner/construction-doors.js +8 -0
  394. package/dist/core/runner/context-room.d.ts +55 -0
  395. package/dist/core/runner/context-room.js +71 -0
  396. package/dist/core/runner/contracts.d.ts +313 -205
  397. package/dist/core/runner/conversation-segment.d.ts +49 -14
  398. package/dist/core/runner/conversation-segment.js +92 -19
  399. package/dist/core/runner/cross-boundary-lane.d.ts +4 -0
  400. package/dist/core/runner/cross-boundary-lane.js +9 -6
  401. package/dist/core/runner/decide-continuation.js +1 -1
  402. package/dist/core/runner/deferred-ask.d.ts +62 -0
  403. package/dist/core/runner/deferred-ask.js +44 -0
  404. package/dist/core/runner/delegation-owner.d.ts +19 -0
  405. package/dist/core/runner/delegation-owner.js +27 -1
  406. package/dist/core/runner/denial-limit-arms.d.ts +10 -6
  407. package/dist/core/runner/denial-limit-arms.js +13 -7
  408. package/dist/core/runner/env-capability-census.d.ts +1 -1
  409. package/dist/core/runner/file-history-request.js +2 -1
  410. package/dist/core/runner/file-history-restore.d.ts +16 -2
  411. package/dist/core/runner/file-history-restore.js +9 -1
  412. package/dist/core/runner/gate-exit.d.ts +18 -5
  413. package/dist/core/runner/gate-exit.js +26 -15
  414. package/dist/core/runner/git-status-frame.d.ts +26 -8
  415. package/dist/core/runner/git-status-frame.js +14 -9
  416. package/dist/core/runner/halt-attribution.d.ts +29 -12
  417. package/dist/core/runner/halt-attribution.js +38 -11
  418. package/dist/core/runner/image.js +3 -2
  419. package/dist/core/runner/initial-run-state.d.ts +1 -1
  420. package/dist/core/runner/initial-run-state.js +4 -4
  421. package/dist/core/runner/language-frame.d.ts +66 -0
  422. package/dist/core/runner/language-frame.js +76 -0
  423. package/dist/core/runner/leg-frame.d.ts +81 -0
  424. package/dist/core/runner/leg-frame.js +68 -0
  425. package/dist/core/runner/main-call-account.d.ts +34 -0
  426. package/dist/core/runner/main-call-account.js +50 -0
  427. package/dist/core/runner/mcp-redial.d.ts +9 -7
  428. package/dist/core/runner/mcp-redial.js +20 -21
  429. package/dist/core/runner/memory-consolidation-driver.d.ts +2 -0
  430. package/dist/core/runner/memory-consolidation-driver.js +5 -3
  431. package/dist/core/runner/messages-omitted-seat.d.ts +2 -0
  432. package/dist/core/runner/messages-omitted-seat.js +21 -0
  433. package/dist/core/runner/model-fallback-seat.d.ts +20 -0
  434. package/dist/core/runner/model-fallback-seat.js +43 -0
  435. package/dist/core/runner/model-lane-seat.d.ts +12 -0
  436. package/dist/core/runner/model-lane-seat.js +35 -0
  437. package/dist/core/runner/nested-memory-content.d.ts +33 -0
  438. package/dist/core/runner/nested-memory-content.js +171 -0
  439. package/dist/core/runner/nested-memory-lane.d.ts +181 -0
  440. package/dist/core/runner/nested-memory-lane.js +673 -0
  441. package/dist/core/runner/park-commit.d.ts +7 -0
  442. package/dist/core/runner/park-commit.js +3 -0
  443. package/dist/core/runner/prepare-advisor.d.ts +7 -9
  444. package/dist/core/runner/prepare-advisor.js +11 -5
  445. package/dist/core/runner/prepare-artifact.d.ts +1 -1
  446. package/dist/core/runner/prepare-artifact.js +8 -3
  447. package/dist/core/runner/prepare-ask-lane.d.ts +21 -3
  448. package/dist/core/runner/prepare-ask-lane.js +32 -28
  449. package/dist/core/runner/prepare-boundary-parks.d.ts +2 -2
  450. package/dist/core/runner/prepare-boundary-parks.js +21 -17
  451. package/dist/core/runner/prepare-caps-and-workflow.d.ts +10 -2
  452. package/dist/core/runner/prepare-caps-and-workflow.js +24 -18
  453. package/dist/core/runner/prepare-config-doors.d.ts +51 -5
  454. package/dist/core/runner/prepare-config-doors.js +73 -73
  455. package/dist/core/runner/prepare-context-lane.d.ts +68 -3
  456. package/dist/core/runner/prepare-context-lane.js +137 -27
  457. package/dist/core/runner/prepare-defer-classify.d.ts +0 -4
  458. package/dist/core/runner/prepare-defer-classify.js +9 -13
  459. package/dist/core/runner/prepare-delegation-surface.d.ts +8 -8
  460. package/dist/core/runner/prepare-delegation-surface.js +72 -64
  461. package/dist/core/runner/prepare-execution-env.js +1 -9
  462. package/dist/core/runner/prepare-file-history.d.ts +3 -2
  463. package/dist/core/runner/prepare-file-history.js +11 -4
  464. package/dist/core/runner/prepare-gate-stations.d.ts +21 -11
  465. package/dist/core/runner/prepare-gate-stations.js +13 -13
  466. package/dist/core/runner/prepare-hands-readface.d.ts +23 -6
  467. package/dist/core/runner/prepare-hands-readface.js +18 -12
  468. package/dist/core/runner/prepare-inherited-gate.d.ts +12 -5
  469. package/dist/core/runner/prepare-inherited-gate.js +14 -10
  470. package/dist/core/runner/prepare-lsp.js +2 -1
  471. package/dist/core/runner/prepare-memory-engine-session.js +30 -10
  472. package/dist/core/runner/prepare-memory.d.ts +4 -0
  473. package/dist/core/runner/prepare-memory.js +38 -16
  474. package/dist/core/runner/prepare-offload-wrappers.d.ts +3 -16
  475. package/dist/core/runner/prepare-offload-wrappers.js +6 -5
  476. package/dist/core/runner/prepare-park-ask.d.ts +13 -3
  477. package/dist/core/runner/prepare-park-ask.js +25 -19
  478. package/dist/core/runner/prepare-policy-chain.d.ts +17 -3
  479. package/dist/core/runner/prepare-policy-chain.js +144 -120
  480. package/dist/core/runner/prepare-project-context.d.ts +15 -53
  481. package/dist/core/runner/prepare-project-context.js +20 -83
  482. package/dist/core/runner/prepare-prompt-assembly.d.ts +7 -1
  483. package/dist/core/runner/prepare-prompt-assembly.js +9 -7
  484. package/dist/core/runner/prepare-prompt-inputs.d.ts +9 -3
  485. package/dist/core/runner/prepare-prompt-inputs.js +5 -3
  486. package/dist/core/runner/prepare-protocol-tools.d.ts +9 -4
  487. package/dist/core/runner/prepare-protocol-tools.js +46 -27
  488. package/dist/core/runner/prepare-question-face.d.ts +7 -6
  489. package/dist/core/runner/prepare-question-face.js +7 -6
  490. package/dist/core/runner/prepare-suspend-saga.d.ts +3 -0
  491. package/dist/core/runner/prepare-suspend-saga.js +1 -1
  492. package/dist/core/runner/prepare-task.d.ts +3 -3
  493. package/dist/core/runner/prepare-task.js +113 -61
  494. package/dist/core/runner/prepare-tool-disclosure-mount.js +6 -5
  495. package/dist/core/runner/prepare-turn-wiring.d.ts +33 -7
  496. package/dist/core/runner/prepare-turn-wiring.js +53 -17
  497. package/dist/core/runner/prepare-wiring-manifest.d.ts +42 -5
  498. package/dist/core/runner/prepare-wiring-manifest.js +81 -42
  499. package/dist/core/runner/prepare-workspace-restore.js +3 -2
  500. package/dist/core/runner/read-root-grant.js +2 -1
  501. package/dist/core/runner/reply-pricing.d.ts +31 -18
  502. package/dist/core/runner/reply-pricing.js +10 -15
  503. package/dist/core/runner/resume-admission.js +10 -15
  504. package/dist/core/runner/resume-apply.js +20 -9
  505. package/dist/core/runner/resume-checkpoint-screen.js +2 -4
  506. package/dist/core/runner/resume-internals-and-config.d.ts +12 -9
  507. package/dist/core/runner/resume-internals-and-config.js +37 -9
  508. package/dist/core/runner/resume-preflight.js +3 -3
  509. package/dist/core/runner/retired-runner-deps.js +3 -0
  510. package/dist/core/runner/rewind-files.js +6 -6
  511. package/dist/core/runner/run-attachment-seats.d.ts +1 -3
  512. package/dist/core/runner/run-attachment-seats.js +1 -6
  513. package/dist/core/runner/run-brain-sinks.d.ts +4 -7
  514. package/dist/core/runner/run-brain-sinks.js +7 -10
  515. package/dist/core/runner/run-clock-and-content.d.ts +8 -5
  516. package/dist/core/runner/run-clock-and-content.js +18 -3
  517. package/dist/core/runner/run-compaction-machinery.d.ts +8 -4
  518. package/dist/core/runner/run-compaction-machinery.js +4 -19
  519. package/dist/core/runner/run-git-lane.d.ts +8 -3
  520. package/dist/core/runner/run-git-lane.js +5 -3
  521. package/dist/core/runner/run-harness-handlers.d.ts +4 -1
  522. package/dist/core/runner/run-harness-handlers.js +70 -45
  523. package/dist/core/runner/run-identity-wiring.d.ts +6 -0
  524. package/dist/core/runner/run-identity-wiring.js +17 -8
  525. package/dist/core/runner/run-leg.d.ts +5 -2
  526. package/dist/core/runner/run-leg.js +156 -71
  527. package/dist/core/runner/run-notification-lane.d.ts +1 -1
  528. package/dist/core/runner/run-notification-lane.js +22 -10
  529. package/dist/core/runner/run-recovery-lanes.js +8 -6
  530. package/dist/core/runner/run-settle-and-teardown.d.ts +4 -0
  531. package/dist/core/runner/run-settle-and-teardown.js +77 -26
  532. package/dist/core/runner/run-stop-and-final-verify.js +46 -12
  533. package/dist/core/runner/run-telemetry-and-budget-seats.js +13 -28
  534. package/dist/core/runner/run-terminal-adoption.d.ts +2 -2
  535. package/dist/core/runner/run-terminal-adoption.js +14 -9
  536. package/dist/core/runner/run-tool-mount-facts.js +5 -9
  537. package/dist/core/runner/run-turn-boundary.d.ts +3 -2
  538. package/dist/core/runner/run-turn-boundary.js +112 -106
  539. package/dist/core/runner/runtask.d.ts +28 -8
  540. package/dist/core/runner/runtask.js +132 -41
  541. package/dist/core/runner/session-file-state-replay.d.ts +5 -3
  542. package/dist/core/runner/session-file-state-replay.js +10 -3
  543. package/dist/core/runner/session-rule-policy.d.ts +3 -3
  544. package/dist/core/runner/session-verb-doors.d.ts +18 -3
  545. package/dist/core/runner/session-verb-doors.js +38 -6
  546. package/dist/core/runner/shell-env-withheld.d.ts +8 -5
  547. package/dist/core/runner/shell-env-withheld.js +4 -4
  548. package/dist/core/runner/side-call-account.d.ts +12 -8
  549. package/dist/core/runner/side-call-account.js +24 -15
  550. package/dist/core/runner/stream-halt-verbs.js +1 -0
  551. package/dist/core/runner/stream-mode-verb.js +2 -1
  552. package/dist/core/runner/stream-settle-backstop.js +4 -1
  553. package/dist/core/runner/stream-steer-verb.js +35 -19
  554. package/dist/core/runner/sub-agent-deny-lists.d.ts +47 -11
  555. package/dist/core/runner/sub-agent-deny-lists.js +140 -39
  556. package/dist/core/runner/teardown-bounded.d.ts +6 -0
  557. package/dist/core/runner/teardown-bounded.js +12 -7
  558. package/dist/core/runner/terminal-account.d.ts +2 -0
  559. package/dist/core/runner/terminal-account.js +6 -1
  560. package/dist/core/runner/tool-disclosure.js +2 -1
  561. package/dist/core/runner/tool-end-body.js +3 -1
  562. package/dist/core/runner/tool-face-overlay.d.ts +1 -1
  563. package/dist/core/runner/tool-face-overlay.js +1 -1
  564. package/dist/core/runner/tool-occurrence.d.ts +34 -9
  565. package/dist/core/runner/tool-occurrence.js +32 -21
  566. package/dist/core/runner/tool-progress-lane.d.ts +20 -5
  567. package/dist/core/runner/tool-progress-lane.js +27 -5
  568. package/dist/core/runner/tool-result-media-seat.d.ts +15 -4
  569. package/dist/core/runner/tool-result-media-seat.js +17 -1
  570. package/dist/core/runner/tool-table-view.js +1 -1
  571. package/dist/core/runner/turn-attachments.d.ts +44 -71
  572. package/dist/core/runner/turn-attachments.js +52 -104
  573. package/dist/core/runner/usage-accounting.d.ts +3 -2
  574. package/dist/core/runner/usage-accounting.js +3 -2
  575. package/dist/core/runner/void-verifier-pause.js +1 -1
  576. package/dist/core/runner-deps.d.ts +42 -158
  577. package/dist/core/runtime-caps.d.ts +16 -4
  578. package/dist/core/secret-env.d.ts +20 -3
  579. package/dist/core/secret-env.js +46 -23
  580. package/dist/core/sensitive-path-policy.d.ts +8 -0
  581. package/dist/core/sensitive-path-policy.js +10 -2
  582. package/dist/core/session-checkout.d.ts +32 -27
  583. package/dist/core/session-checkout.js +109 -61
  584. package/dist/core/session-log-transfer.js +2 -1
  585. package/dist/core/session-policy-store.d.ts +24 -11
  586. package/dist/core/session-policy-store.js +11 -2
  587. package/dist/core/session-store.d.ts +16 -2
  588. package/dist/core/session-store.js +43 -17
  589. package/dist/core/session.d.ts +31 -3
  590. package/dist/core/session.js +33 -2
  591. package/dist/core/shell-run-candidates.d.ts +20 -8
  592. package/dist/core/shell-run-candidates.js +44 -21
  593. package/dist/core/side-query.d.ts +17 -5
  594. package/dist/core/side-query.js +17 -14
  595. package/dist/core/skill-grant.js +2 -3
  596. package/dist/core/skills-directory.js +3 -66
  597. package/dist/core/snapshot-frame-seat.d.ts +8 -0
  598. package/dist/core/snapshot-frame-seat.js +24 -0
  599. package/dist/core/steer-replay.d.ts +19 -3
  600. package/dist/core/steer-replay.js +8 -1
  601. package/dist/core/store-contracts/background-agent-store-contract.d.ts +17 -2
  602. package/dist/core/store-contracts/background-agent-store-contract.js +131 -2
  603. package/dist/core/store-contracts/checkpoint-store-contract.js +63 -1
  604. package/dist/core/store-contracts/mailbox-store-contract.d.ts +15 -2
  605. package/dist/core/store-contracts/mailbox-store-contract.js +213 -3
  606. package/dist/core/store-contracts/permission-rule-write-contract.js +24 -0
  607. package/dist/core/store-contracts/session-deletion-cascade-contract.d.ts +15 -0
  608. package/dist/core/store-contracts/session-deletion-cascade-contract.js +288 -0
  609. package/dist/core/store-contracts/session-policy-store-contract.js +57 -36
  610. package/dist/core/store-contracts/session-repo-contract.js +130 -5
  611. package/dist/core/store-contracts/session-store-contract.d.ts +1 -1
  612. package/dist/core/store-contracts/session-store-contract.js +17 -0
  613. package/dist/core/store-contracts/task-list-store-contract.d.ts +32 -0
  614. package/dist/core/store-contracts/task-list-store-contract.js +240 -0
  615. package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
  616. package/dist/core/store-contracts/tool-result-store-contract.js +41 -0
  617. package/dist/core/stub-env.d.ts +2 -2
  618. package/dist/core/stub-env.js +1 -0
  619. package/dist/core/synthetic-read-verdict.d.ts +38 -28
  620. package/dist/core/synthetic-read-verdict.js +19 -28
  621. package/dist/core/task-event.d.ts +171 -19
  622. package/dist/core/task-intake.d.ts +26 -0
  623. package/dist/core/task-intake.js +31 -0
  624. package/dist/core/task-limits.d.ts +8 -6
  625. package/dist/core/task-notification.d.ts +88 -8
  626. package/dist/core/task-notification.js +45 -5
  627. package/dist/core/task-registry-agent.d.ts +24 -7
  628. package/dist/core/task-registry-agent.js +51 -28
  629. package/dist/core/task-registry-monitor.js +16 -14
  630. package/dist/core/task-registry-shared.d.ts +177 -35
  631. package/dist/core/task-registry-shared.js +44 -17
  632. package/dist/core/task-registry-workflow.js +8 -5
  633. package/dist/core/task-registry-yield.d.ts +32 -0
  634. package/dist/core/task-registry-yield.js +85 -0
  635. package/dist/core/task-registry.d.ts +88 -10
  636. package/dist/core/task-registry.js +124 -33
  637. package/dist/core/task-result.d.ts +115 -31
  638. package/dist/core/task-spec-members.d.ts +140 -1
  639. package/dist/core/task-spec-members.js +23 -8
  640. package/dist/core/task-spec.d.ts +181 -51
  641. package/dist/core/task-spec.js +1 -1
  642. package/dist/core/task-stream.d.ts +12 -2
  643. package/dist/core/terminal-cause.d.ts +12 -4
  644. package/dist/core/thrown-value.d.ts +49 -7
  645. package/dist/core/thrown-value.js +38 -2
  646. package/dist/core/tool-catalog-entries.js +13 -3
  647. package/dist/core/tool-data-door.d.ts +7 -0
  648. package/dist/core/tool-data-door.js +13 -0
  649. package/dist/core/tool-face-lists.d.ts +25 -0
  650. package/dist/core/tool-face-lists.js +38 -0
  651. package/dist/core/tool-face-reader.d.ts +0 -10
  652. package/dist/core/tool-face-reader.js +5 -3
  653. package/dist/core/tool-list-grammar.d.ts +103 -0
  654. package/dist/core/tool-list-grammar.js +130 -0
  655. package/dist/core/tool-mount-facts.d.ts +47 -0
  656. package/dist/core/tool-mount-facts.js +50 -0
  657. package/dist/core/tool-mount-plan.d.ts +196 -0
  658. package/dist/core/tool-mount-plan.js +404 -0
  659. package/dist/core/tool-mount-static.d.ts +12 -0
  660. package/dist/core/tool-mount-static.js +174 -0
  661. package/dist/core/tool-name-aliases.d.ts +60 -2
  662. package/dist/core/tool-name-aliases.js +22 -2
  663. package/dist/core/tool-name-list.d.ts +3 -0
  664. package/dist/core/tool-name-readings.d.ts +4 -0
  665. package/dist/core/tool-name-readings.js +1 -0
  666. package/dist/core/tool-policy.d.ts +246 -51
  667. package/dist/core/tool-policy.js +165 -71
  668. package/dist/core/tool-registry.d.ts +4 -11
  669. package/dist/core/tool-registry.js +0 -3
  670. package/dist/core/tool-result-bytes.d.ts +94 -0
  671. package/dist/core/tool-result-bytes.js +34 -0
  672. package/dist/core/tool-result-store.d.ts +97 -13
  673. package/dist/core/tool-result-store.js +52 -4
  674. package/dist/core/tool-roster.d.ts +71 -10
  675. package/dist/core/tool-roster.js +71 -21
  676. package/dist/core/tool-search-setting.d.ts +7 -9
  677. package/dist/core/tool-search-setting.js +23 -7
  678. package/dist/core/tool-spec.d.ts +32 -2
  679. package/dist/core/tools.js +6 -20
  680. package/dist/core/trace.d.ts +63 -11
  681. package/dist/core/trace.js +19 -0
  682. package/dist/core/types.d.ts +8 -6
  683. package/dist/core/types.js +3 -1
  684. package/dist/core/unmatched-tool-names.d.ts +37 -0
  685. package/dist/core/unmatched-tool-names.js +18 -0
  686. package/dist/core/untrusted-egress.d.ts +16 -5
  687. package/dist/core/untrusted-egress.js +202 -32
  688. package/dist/core/untrusted-text.d.ts +29 -8
  689. package/dist/core/untrusted-text.js +6 -3
  690. package/dist/core/user-attachment.d.ts +129 -35
  691. package/dist/core/user-attachment.js +124 -57
  692. package/dist/core/user-row-origin.d.ts +63 -0
  693. package/dist/core/user-row-origin.js +61 -0
  694. package/dist/core/wiring-manifest.d.ts +161 -39
  695. package/dist/core/wiring-manifest.js +42 -6
  696. package/dist/core/workflow-run-store-contract.d.ts +11 -1
  697. package/dist/core/workflow-run-store-contract.js +60 -7
  698. package/dist/core/workflow-run-store.d.ts +61 -12
  699. package/dist/core/workflow-run-store.js +100 -15
  700. package/dist/core/workspace-snapshot.d.ts +10 -14
  701. package/dist/core/workspace-snapshot.js +3 -22
  702. package/dist/core/write-protect.d.ts +3 -5
  703. package/dist/core/write-protect.js +2 -4
  704. package/dist/engine/compaction/compaction.d.ts +3 -0
  705. package/dist/engine/compaction/compaction.js +4 -3
  706. package/dist/engine/execution-env/node-execution-env.d.ts +15 -4
  707. package/dist/engine/execution-env/node-execution-env.js +80 -27
  708. package/dist/engine/harness/agent-harness.d.ts +143 -27
  709. package/dist/engine/harness/agent-harness.js +162 -74
  710. package/dist/engine/harness/types.d.ts +84 -13
  711. package/dist/engine/harness/types.js +21 -1
  712. package/dist/engine/llm/tool-turns.d.ts +4 -0
  713. package/dist/engine/llm/tool-turns.js +7 -2
  714. package/dist/engine/llm/types.d.ts +111 -24
  715. package/dist/engine/llm/types.js +69 -5
  716. package/dist/engine/llm/validation.js +2 -1
  717. package/dist/engine/loop/agent-loop.d.ts +39 -6
  718. package/dist/engine/loop/agent-loop.js +172 -82
  719. package/dist/engine/loop/types.d.ts +43 -4
  720. package/dist/engine/lsp/node-lsp-manager.d.ts +5 -3
  721. package/dist/engine/lsp/node-lsp-manager.js +14 -10
  722. package/dist/engine/session/import-validate.js +9 -0
  723. package/dist/engine/session/memory-repo.d.ts +8 -1
  724. package/dist/engine/session/memory-repo.js +20 -12
  725. package/dist/engine/session/repo-utils.d.ts +10 -0
  726. package/dist/engine/session/repo-utils.js +11 -5
  727. package/dist/engine/session/row-cells.d.ts +32 -0
  728. package/dist/engine/session/row-cells.js +25 -0
  729. package/dist/index.d.ts +63 -34
  730. package/dist/index.js +44 -21
  731. package/dist/internal/harness.d.ts +8 -6
  732. package/dist/internal/harness.js +6 -4
  733. package/dist/internal/llm.d.ts +2 -2
  734. package/dist/internal/llm.js +1 -1
  735. package/dist/orchestration/governance-baseline-validity.d.ts +7 -0
  736. package/dist/orchestration/governance-baseline-validity.js +33 -9
  737. package/dist/orchestration/run-workflow-tool.d.ts +2 -0
  738. package/dist/orchestration/run-workflow-tool.js +25 -12
  739. package/dist/orchestration/workflow-governance.d.ts +19 -4
  740. package/dist/orchestration/workflow-governance.js +30 -9
  741. package/dist/orchestration/workflow-primitives.d.ts +4 -1
  742. package/dist/orchestration/workflow-primitives.js +2 -2
  743. package/dist/orchestration/workflow-script-runner.d.ts +1 -1
  744. package/dist/orchestration/workflow-size-guideline.d.ts +1 -1
  745. package/dist/orchestration/workflow-types.d.ts +21 -12
  746. package/dist/orchestration/workflow-types.js +15 -4
  747. package/dist/orchestration/workflow.d.ts +37 -7
  748. package/dist/orchestration/workflow.js +81 -35
  749. package/dist/prompt-assembly/artifact-store.js +6 -9
  750. package/dist/prompt-assembly/assemble.d.ts +4 -10
  751. package/dist/prompt-assembly/assemble.js +1 -3
  752. package/dist/prompt-assembly/catalog/constitution.d.ts +0 -20
  753. package/dist/prompt-assembly/catalog/constitution.js +2 -0
  754. package/dist/prompt-assembly/catalog/core-behavior.js +5 -3
  755. package/dist/prompt-assembly/catalog/engine.d.ts +108 -0
  756. package/dist/prompt-assembly/catalog/engine.js +19 -0
  757. package/dist/prompt-assembly/catalog/environment.d.ts +276 -0
  758. package/dist/prompt-assembly/catalog/environment.js +61 -0
  759. package/dist/prompt-assembly/catalog/index.d.ts +9 -2
  760. package/dist/prompt-assembly/catalog/index.js +73 -2
  761. package/dist/prompt-assembly/catalog/locales/index.d.ts +16 -0
  762. package/dist/prompt-assembly/catalog/locales/index.js +22 -0
  763. package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.d.ts +7 -0
  764. package/dist/prompt-assembly/catalog/locales/zh-Hans/constitution.js +124 -0
  765. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.d.ts +6 -0
  766. package/dist/prompt-assembly/catalog/locales/zh-Hans/core-behavior.js +120 -0
  767. package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.d.ts +8 -0
  768. package/dist/prompt-assembly/catalog/locales/zh-Hans/cowork.js +442 -0
  769. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +7 -0
  770. package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +15 -0
  771. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.d.ts +7 -0
  772. package/dist/prompt-assembly/catalog/locales/zh-Hans/environment.js +50 -0
  773. package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.d.ts +7 -0
  774. package/dist/prompt-assembly/catalog/locales/zh-Hans/modes.js +163 -0
  775. package/dist/prompt-assembly/catalog/locales/zh-Hans/role.d.ts +7 -0
  776. package/dist/prompt-assembly/catalog/locales/zh-Hans/role.js +148 -0
  777. package/dist/prompt-assembly/catalog/locales/zh-Hans/team.d.ts +6 -0
  778. package/dist/prompt-assembly/catalog/locales/zh-Hans/team.js +246 -0
  779. package/dist/prompt-assembly/catalog/role.js +3 -6
  780. package/dist/prompt-assembly/catalog/schema.d.ts +23 -1
  781. package/dist/prompt-assembly/catalog/schema.js +2 -0
  782. package/dist/prompt-assembly/composer.d.ts +6 -11
  783. package/dist/prompt-assembly/composer.js +7 -7
  784. package/dist/prompt-assembly/engine-text.d.ts +9 -0
  785. package/dist/prompt-assembly/engine-text.js +33 -0
  786. package/dist/prompt-assembly/event-registry.js +3 -3
  787. package/dist/prompt-assembly/explain.d.ts +1 -0
  788. package/dist/prompt-assembly/explain.js +1 -1
  789. package/dist/prompt-assembly/locale-review.d.ts +13 -0
  790. package/dist/prompt-assembly/locale-review.js +19 -0
  791. package/dist/prompt-assembly/overlay.d.ts +7 -3
  792. package/dist/prompt-assembly/overlay.js +27 -5
  793. package/dist/prompt-assembly/renderers.d.ts +4 -4
  794. package/dist/prompt-assembly/renderers.js +26 -17
  795. package/dist/prompt-assembly/role-base.d.ts +1 -1
  796. package/dist/prompt-assembly/select.d.ts +26 -5
  797. package/dist/prompt-assembly/select.js +25 -2
  798. package/dist/prompt-assembly/slots.d.ts +19 -0
  799. package/dist/prompt-assembly/slots.js +16 -0
  800. package/dist/prompt-assembly/sugar.d.ts +4 -7
  801. package/dist/prompt-assembly/sugar.js +1 -2
  802. package/dist/prompt-assembly/tool-catalog.d.ts +5 -1
  803. package/dist/prompt-assembly/tool-catalog.js +5 -1
  804. package/dist/prompt-assembly/turn-snapshot.d.ts +38 -10
  805. package/dist/prompt-assembly/turn-snapshot.js +43 -13
  806. package/dist/prompt-assembly/types.d.ts +3 -0
  807. package/dist/prompts/cowork.d.ts +6 -25
  808. package/dist/prompts/cowork.js +10 -12
  809. package/dist/prompts/default.d.ts +10 -32
  810. package/dist/prompts/default.js +37 -63
  811. package/dist/shell/lex.d.ts +39 -13
  812. package/dist/shell/lex.js +70 -30
  813. package/dist/stores/file/background-agent-store.d.ts +5 -0
  814. package/dist/stores/file/background-agent-store.js +35 -61
  815. package/dist/stores/file/checkpoint-store.d.ts +5 -3
  816. package/dist/stores/file/checkpoint-store.js +8 -10
  817. package/dist/stores/file/fs-atomic.d.ts +27 -70
  818. package/dist/stores/file/fs-atomic.js +52 -148
  819. package/dist/stores/file/index.d.ts +12 -0
  820. package/dist/stores/file/index.js +27 -2
  821. package/dist/stores/file/mailbox-store.d.ts +10 -1
  822. package/dist/stores/file/mailbox-store.js +40 -12
  823. package/dist/stores/file/permission-rule-adopt.js +5 -2
  824. package/dist/stores/file/permission-rule-store.d.ts +81 -20
  825. package/dist/stores/file/permission-rule-store.js +126 -33
  826. package/dist/stores/file/session-policy-store.d.ts +2 -2
  827. package/dist/stores/file/session-store.d.ts +21 -2
  828. package/dist/stores/file/session-store.js +27 -14
  829. package/dist/stores/file/task-list-store.js +23 -25
  830. package/dist/stores/file/tool-result-store.d.ts +45 -7
  831. package/dist/stores/file/tool-result-store.js +99 -36
  832. package/dist/stores/file/workflow-run-store.d.ts +1 -0
  833. package/dist/stores/file/workflow-run-store.js +14 -11
  834. package/dist/tools/artifact/artifact-tool.js +2 -0
  835. package/dist/tools/artifact/local-stub.js +6 -6
  836. package/dist/tools/fs/bash-program-position.d.ts +1 -2
  837. package/dist/tools/fs/bash-readonly-classifier.d.ts +35 -0
  838. package/dist/tools/fs/bash-readonly-classifier.js +50 -12
  839. package/dist/tools/fs/env-error-detail.d.ts +1 -0
  840. package/dist/tools/fs/env-error-detail.js +7 -0
  841. package/dist/tools/fs/fs-bash.d.ts +24 -6
  842. package/dist/tools/fs/fs-bash.js +73 -25
  843. package/dist/tools/fs/fs-pdf.js +6 -4
  844. package/dist/tools/fs/fs-read.d.ts +76 -31
  845. package/dist/tools/fs/fs-read.js +159 -79
  846. package/dist/tools/fs/fs-search-tools.d.ts +1 -1
  847. package/dist/tools/fs/fs-search-tools.js +3 -1
  848. package/dist/tools/fs/fs-shared.d.ts +59 -63
  849. package/dist/tools/fs/fs-shared.js +31 -18
  850. package/dist/tools/fs/fs-write.d.ts +13 -0
  851. package/dist/tools/fs/fs-write.js +69 -13
  852. package/dist/tools/fs/index.d.ts +19 -1
  853. package/dist/tools/fs/index.js +10 -2
  854. package/dist/tools/fs/pdf.js +10 -9
  855. package/dist/tools/fs/read-deny.js +4 -10
  856. package/dist/tools/fs/read-floor.d.ts +5 -4
  857. package/dist/tools/fs/removal-targets.d.ts +11 -5
  858. package/dist/tools/fs/removal-targets.js +62 -32
  859. package/dist/tools/fs/safety.d.ts +26 -19
  860. package/dist/tools/fs/safety.js +13 -8
  861. package/dist/tools/fs/search.d.ts +1 -1
  862. package/dist/tools/fs/shell-read-argv.js +1 -0
  863. package/dist/tools/fs/shell-read-bindings.d.ts +128 -26
  864. package/dist/tools/fs/shell-read-bindings.js +667 -139
  865. package/dist/tools/fs/shell-read-check.js +1 -1
  866. package/dist/tools/fs/shell-read-judge.d.ts +4 -1
  867. package/dist/tools/fs/shell-read-judge.js +5 -1
  868. package/dist/tools/fs/shell-read-plan.d.ts +4 -0
  869. package/dist/tools/fs/shell-read-plan.js +21 -19
  870. package/dist/tools/fs/shell-read-sourced.d.ts +4 -3
  871. package/dist/tools/fs/shell-read-sourced.js +18 -1
  872. package/dist/tools/fs/shell-read-start.d.ts +6 -6
  873. package/dist/tools/fs/shell-read-start.js +1 -6
  874. package/dist/tools/fs/shell-read-word.d.ts +4 -2
  875. package/dist/tools/fs/shell-read-word.js +7 -6
  876. package/dist/tools/fs/shell-read-workdir.d.ts +1 -1
  877. package/dist/tools/fs/shell-reentry-text.d.ts +24 -9
  878. package/dist/tools/fs/shell-reentry-text.js +50 -20
  879. package/dist/tools/monitor.d.ts +4 -0
  880. package/dist/tools/monitor.js +14 -4
  881. package/dist/tools/scheduler-tools.d.ts +5 -2
  882. package/dist/tools/scheduler-tools.js +8 -6
  883. package/dist/tools/task-list.d.ts +49 -20
  884. package/dist/tools/task-list.js +115 -35
  885. package/dist/tools/web.d.ts +13 -3
  886. package/dist/tools/web.js +17 -6
  887. package/dist/tools/worktree.d.ts +3 -2
  888. package/dist/tools/worktree.js +24 -25
  889. package/package.json +10 -3
  890. package/test/export-surface.snapshot.json +330 -32
  891. package/wire-changes/core-stores-sql@7.66.1.json +30 -0
  892. package/wire-changes/core-stores-sql@7.67.0.json +39 -0
  893. package/wire-changes/core@7.66.1.json +46 -0
  894. package/wire-changes/core@7.67.0.json +12578 -0
  895. package/wire-changes/mods-kernel@7.66.1.json +30 -0
  896. package/wire-changes/mods-kernel@7.67.0.json +167 -0
  897. package/wire-changes/primitives@7.66.1.json +30 -0
  898. package/wire-changes/primitives@7.67.0.json +325 -0
  899. package/wire-changes/wiki-gate@7.67.0.json +1636 -0
  900. package/dist/brain/degrading.d.ts +0 -93
  901. package/dist/brain/degrading.js +0 -189
  902. package/dist/core/tool-conformance.d.ts +0 -20
  903. package/dist/core/tool-conformance.js +0 -37
@@ -133,17 +133,32 @@ interface DirVetting {
133
133
  readonly platform?: NodeJS.Platform;
134
134
  /** Said when the group/other-writable judgment was NOT made because the platform reports no permission bits. */
135
135
  readonly modeBitsUnjudged?: (dir: string) => void;
136
+ /** `true` the first time this host meets the case-variant bucket name at `location`, `false` after: a refusal of one is disclosed once. */
137
+ readonly caseVariantFirstMet?: (location: string) => boolean;
136
138
  }
137
- /** One principal's rule file. */
139
+ /** Where a bucket handle came from, as its write face reads it at every write. */
140
+ interface BucketHandleOrigin {
141
+ /** `full` — an owner door's handle ({@link FileDurableRulePartitionProvider.forPrincipal} / `forLocalOwner`): every write arm. `retire-only` —
142
+ * a listed bucket's handle ({@link FileDurableRulePartitionProvider.listBucketOwners}): it reads as every handle reads, and writes only
143
+ * the retirement of rows (a `tighten-delete`, and the `nextDot` its tombstone takes); it never creates a bucket. */
144
+ readonly posture: "full" | "retire-only";
145
+ /** Judged under the writer lock before every write: the directory still lets this handle write its file — the adoption marker does not
146
+ * name the file as the handle's door forbids (an owner door: as the source; a listed bucket: as the source or the target). */
147
+ readonly stillOpens: () => boolean;
148
+ }
149
+ /** One owner's rule file. */
138
150
  declare class FileDurableRulePartition implements WritableDurableRulePartition {
139
151
  private readonly dir;
140
152
  private readonly file;
141
153
  private readonly acquireWriteLock;
154
+ private readonly origin;
142
155
  private readonly onError?;
143
156
  private readonly vetting?;
144
157
  readonly durability: StoreDurability;
145
158
  readonly fidelity: StoreFidelity;
146
- constructor(dir: string, file: string, acquireWriteLock: () => void, onError?: ((message: string) => void) | undefined, vetting?: DirVetting | undefined);
159
+ /** The bucket's file name, as the directory must spell its entry for the file to be read as this bucket. */
160
+ private readonly name;
161
+ constructor(dir: string, file: string, acquireWriteLock: () => void, origin: BucketHandleOrigin, onError?: ((message: string) => void) | undefined, vetting?: DirVetting | undefined);
147
162
  /** Read and validate. Any refusal answers with an empty set AND says so — never a silent empty store. The answer's
148
163
  * sentence names no location ({@link refusalText}); the disclosure that accompanies it does. */
149
164
  private read;
@@ -179,6 +194,13 @@ declare class FileDurableRulePartition implements WritableDurableRulePartition {
179
194
  * went wrong. Reads already answer zero rules for the same condition, so the lane stays fail-closed
180
195
  * while a person looks at the file. A bucket a newer engine wrote is one of these: writing it in this
181
196
  * engine's grammar would stamp rows this engine cannot read with a grammar that claims it can.
197
+ *
198
+ * Every write first holds the writer lock (taken again after a `dispose()`, refused while an adoption holds it) and, under it, asks
199
+ * the handle's origin whether the directory still lets it write this file. A handle opened before an adoption of its bucket began
200
+ * would otherwise write the retired source back into being: read past the flip it is a grave nothing reads, and while an adoption
201
+ * rests between its rename and its flip the readers read the revived source — the new row alone, every row the bucket held before
202
+ * (its denies too) gone from the view. A listed bucket's handle never creates its file: one that is gone refuses as a read that
203
+ * failed ({@link PERMISSION_RULES_UNREADABLE_BUCKET_CODE}, `errno` `ENOENT`), and the next census lists what is there.
182
204
  */
183
205
  private current;
184
206
  /**
@@ -199,6 +221,28 @@ declare class FileDurableRulePartition implements WritableDurableRulePartition {
199
221
  get [PERMISSION_RULE_WRITER](): PermissionRuleWriter;
200
222
  private readonly writer;
201
223
  }
224
+ /** A bucket the directory cannot name, as the census classifies it: its id (the file name without `.json`) and the host's name for it. */
225
+ interface UnnamedBucket {
226
+ readonly bucketId: string;
227
+ readonly knownAs?: string;
228
+ }
229
+ /**
230
+ * The census of a store directory from its entry names, the adoption record and the host's known names — a pure classification
231
+ * ({@link FileDurableRulePartitionProvider.listBucketOwners} reads the directory and hands each unnamed bucket its handle):
232
+ * - an entry spelled like a bucket in another letter case refuses the whole census (`caseVariant`, the first such name in sorted order);
233
+ * - `owners`: `local-owner` when its file is present, then the marker's target and its principal source when their files are present;
234
+ * - `unnamed`: every other digest-named entry, ascending by `bucketId`, each once; `knownAs` is the host's name whose digest names it —
235
+ * a label that never moves an entry out of the list.
236
+ */
237
+ export declare function bucketCensusOf(names: Iterable<string>, rec: {
238
+ readonly from: RuleOwner;
239
+ readonly toPrincipal: string;
240
+ } | undefined, knownOwners: readonly string[]): {
241
+ readonly owners: readonly RuleOwner[];
242
+ readonly unnamed: readonly UnnamedBucket[];
243
+ } | {
244
+ readonly caseVariant: string;
245
+ };
202
246
  /**
203
247
  * The file-backed provider. One file per principal, named by a digest of the principal so no identity
204
248
  * string ever becomes a path component.
@@ -234,11 +278,18 @@ export declare class FileDurableRulePartitionProvider implements DurableRulePart
234
278
  * this provider's writer lock — an install is a write. */
235
279
  /** {@link judgeRuleAdoptionFile} at request time (owner resolution runs on every read), in {@link refusalText}'s voice. */
236
280
  private adoptionMarker;
281
+ /** The bucket files the adoption marker names ({@link adoptionBucketFiles}), read now; `undefined` without a marker. */
282
+ private markerFiles;
283
+ /** A handle's origin ({@link BucketHandleOrigin}) over the bucket file `name`: an owner door's handle may not write the file the marker
284
+ * names as its source; a listed bucket's handle may write neither file the marker names. */
285
+ private originOf;
237
286
  orgStatePersistence(): OrgRuleStatePersistence;
238
287
  private fileOrgPersistence;
239
288
  /** Take the writer lock, once, on first use of a write face. Reading never calls this. */
240
289
  private acquireWriteLock;
241
290
  forPrincipal(principal: string | undefined): DurableRulePartition;
291
+ /** An owner door's handle over the bucket file `name`. */
292
+ private ownerPartition;
242
293
  /** The read-only resolution of an adoption SOURCE: post-flip (phase ≥ 4 / terminal) always the
243
294
  * target; pre-flip, whichever path currently holds the bytes (source first — it is the pre-flip
244
295
  * truth when both somehow exist, which the resume path refuses loudly anyway). */
@@ -252,26 +303,32 @@ export declare class FileDurableRulePartitionProvider implements DurableRulePart
252
303
  */
253
304
  forLocalOwner(): DurableRulePartition;
254
305
  /**
255
- * The owners this directory can NAME that hold a bucket here, and how many buckets it cannot name — the one listing a host
256
- * that must visit every bucket (a one-time migration over the rules of every owner) reads, so a bucket no record points at is
257
- * not skipped. Names only: no rule, tombstone or revision is read, and no bucket file is opened.
306
+ * Every bucket in this directory, once — the one listing a host that must visit every bucket (a one-time migration over the rules
307
+ * of every owner) reads. Names only: no rule, tombstone or revision is read, and no bucket file is opened.
258
308
  *
259
- * A bucket's file is named by a one-way digest of its owner (`principalRuleFileName`) and holds no owner name, so the
260
- * directory names an owner only by what it records: `local-owner` when the local-owner bucket file is present, and the principals
261
- * the adoption marker names (the adopted principal, and a principal source) when their bucket file is present. After an adoption
262
- * the renamed bucket is the adopted principal's, so it is listed under that name whether or not any approval record ever named it.
263
- * Every other digest-named bucket file is counted in `unnamedBuckets` — present, unreadable as to whose, and never silently
264
- * dropped. A host reads `owners` through {@link forPrincipal} / {@link forLocalOwner} like any owner it knows; `unnamedBuckets > 0`
265
- * says its census of owners is incomplete by that many, not that they are empty.
309
+ * A bucket's file is named by a one-way digest of its owner (`principalRuleFileName`) and holds no owner name, so the directory
310
+ * names an owner only by what it records, and `owners` is those: `local-owner` when the local-owner bucket file is present, then the
311
+ * principals the adoption marker names (the adopted principal, and a principal source) when their bucket file is present — after an
312
+ * adoption the renamed bucket is the adopted principal's whether or not any approval record named it. A host reads them through
313
+ * {@link forPrincipal} / {@link forLocalOwner} like any owner it knows.
314
+ *
315
+ * `unnamedBuckets` is every other bucket — present, digest-named, named by no adoption marker — ascending by `bucketId` (its file
316
+ * name without `.json`: an opaque key to report and compare, never parsed and never handed back), each once. Its `partition` is the
317
+ * list's own handle on that bucket, the only door to a bucket nobody can name: it does no I/O until it is used, reads as every
318
+ * handle reads, and writes only the retirement of rows — `nextDot` and an `apply` of a `tighten-delete`; every other write, and
319
+ * `readRaw`, refuses `config.invalid_argument`. It never creates its file: a bucket gone since the listing refuses the write
320
+ * {@link PERMISSION_RULES_UNREADABLE_BUCKET_CODE} with `errno` `ENOENT`; a bucket an adoption has since come to name refuses it too
321
+ * (no code — the next listing has it under `owners`).
266
322
  *
267
323
  * A host may know owners the directory does not record (a File store beside this one derives some from its own import records):
268
- * `opts.knownOwners` hands those principal names over, and each one whose bucket file is present here (the file the one digest,
269
- * {@link principalRuleFileName}, names for it — the host never computes a bucket name) is listed in `owners`, after the ones the
270
- * directory names, and is no longer counted in `unnamedBuckets`; so `unnamedBuckets` is then the count of buckets neither the
271
- * directory nor the host can name (#3494). A name the host gives whose file is absent lists nothing and changes nothing, and a
272
- * name given twice (or one the marker names too) is one owner. It is a plain object with that one member, and a list of
273
- * principal names ({@link principalNameOf}: the one reading every face that takes a name judges by) — anything else refuses
274
- * (`config.invalid_argument`), before the directory is looked at, rather than being read as "no known owners".
324
+ * `opts.knownOwners` hands those principal names over, and an unnamed bucket the one digest names for one of them
325
+ * ({@link principalRuleFileName} — the host never computes a bucket name) carries it as `knownAs`, a label that never moves the
326
+ * bucket out of the list. `opts` is a plain object with that one member and a list of principal names ({@link principalNameOf}) —
327
+ * anything else refuses (`config.invalid_argument`) before the directory is looked at, rather than being read as "no known owners".
328
+ *
329
+ * Only a file whose name is spelled exactly as a bucket's is one: an entry spelled like a bucket in another letter case
330
+ * (`<HEX>.json`, `Local-Owner.json`) refuses the whole listing with {@link PERMISSION_RULES_DAMAGED_BUCKET_CODE}, its location
331
+ * disclosed once — a volume that ignores letter case would open it for its owner, and a census that skipped it would not be whole.
275
332
  *
276
333
  * Reading takes no lock and writes nothing. A directory this engine refuses to use refuses with
277
334
  * {@link PERMISSION_RULES_DAMAGED_BUCKET_CODE}, as the read faces refuse it; a listing that failed to read refuses with
@@ -283,7 +340,11 @@ export declare class FileDurableRulePartitionProvider implements DurableRulePart
283
340
  readonly knownOwners?: readonly string[];
284
341
  }): {
285
342
  readonly owners: readonly RuleOwner[];
286
- readonly unnamedBuckets: number;
343
+ readonly unnamedBuckets: readonly {
344
+ readonly bucketId: string;
345
+ readonly knownAs?: string;
346
+ readonly partition: DurableRulePartition;
347
+ }[];
287
348
  };
288
349
  /** Release the writer lock. A long-lived deployment holds it for its lifetime; a test or a short-lived
289
350
  * tool releases so the next holder is not told a live process owns the directory. */
@@ -1,5 +1,5 @@
1
1
  import { closeSync, constants as FS, existsSync, fsyncSync, lstatSync, mkdirSync, openSync, readdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
2
- import { join } from "node:path";
2
+ import { basename, join } from "node:path";
3
3
  import { createHash, randomBytes } from "node:crypto";
4
4
  import { isRuleBehavior } from "../../core/permission-rule-model.js";
5
5
  import { posixModeBitsMeaningful } from "../../core/posix-mode-face.js";
@@ -9,7 +9,7 @@ import { PERMISSION_RULES_DAMAGED_BUCKET_CODE, PERMISSION_RULES_LATER_GRAMMAR_CO
9
9
  import { sameOrgPolicyContent } from "../../core/permission-rule-org.js";
10
10
  import { SESSION_RULES_GRAMMAR, readRuleGrammarStamp } from "../../core/session-policy-store.js";
11
11
  import { canonicalize } from "../../core/canonical-json.js";
12
- import { BootLock, FileStoreLockError } from "./fs-atomic.js";
12
+ import { BootLock, FileStoreLockError, uncheckableOwnerClause } from "./fs-atomic.js";
13
13
  import { assertAdoptionBootGate } from "./adoption/marker.js";
14
14
  import { CONFIG_RECEIPT_MODE, optionKeys, receiptRefusal, receiveMembers, receiveOptions } from "../../core/own-property-receipt.js";
15
15
  import { describeFault, receive } from "../../core/mods/kernel/receive.js";
@@ -33,6 +33,23 @@ export class OrgRevisionRefusal extends Error {
33
33
  }
34
34
  const LOCAL_OWNER_FILE = "local-owner.json";
35
35
  const HASHED_BUCKET_FILE = /^[0-9a-f]{64}\.json$/;
36
+ function isBucketFileName(name) {
37
+ return name === LOCAL_OWNER_FILE || HASHED_BUCKET_FILE.test(name);
38
+ }
39
+ function foldCase(s) {
40
+ return s.toUpperCase().toLowerCase();
41
+ }
42
+ function isCaseVariantBucketName(name) {
43
+ return !isBucketFileName(name) && isBucketFileName(foldCase(name));
44
+ }
45
+ const CASE_VARIANT_FAULT = "is named like a permission-rule bucket in another letter case — only a file spelled exactly as a bucket's name is one; rename it to lower case, or remove it";
46
+ function entrySpelling(dir, name) {
47
+ const entries = readdirSync(dir);
48
+ if (entries.includes(name))
49
+ return name;
50
+ const folded = foldCase(name);
51
+ return entries.find((entry) => foldCase(entry) === folded);
52
+ }
36
53
  const ADOPTION_FILE = "PERMISSION-RULES-ADOPTION.json";
37
54
  function judgeRuleAdoptionFile(dir) {
38
55
  let raw;
@@ -165,6 +182,10 @@ function discloseTo(onError, message) {
165
182
  catch {
166
183
  }
167
184
  }
185
+ function caseVariantRefusal(onError, vetting, sentence, location) {
186
+ const sink = vetting?.caseVariantFirstMet?.(location) === false ? undefined : onError;
187
+ return { unreadable: refusalText(sink, sentence, location), code: PERMISSION_RULES_DAMAGED_BUCKET_CODE };
188
+ }
168
189
  function assertSafeDirAtRequest(dir, onError, act, vetting) {
169
190
  let fault;
170
191
  try {
@@ -179,9 +200,14 @@ function assertSafeDirAtRequest(dir, onError, act, vetting) {
179
200
  function writerLockRefusal(err, onError) {
180
201
  let sentence;
181
202
  switch (err.code) {
182
- case "store.dir_in_use":
183
- sentence = `another live process${err.ownerPid !== undefined ? ` (pid ${err.ownerPid})` : ""} holds the permission-rule store's writer lock — refusing to interleave writes with it; write through that process, or stop it`;
203
+ case "store.dir_in_use": {
204
+ const unchecked = uncheckableOwnerClause(err);
205
+ sentence =
206
+ unchecked !== undefined
207
+ ? `the permission-rule store's writer lock is held and ${unchecked} — refusing to interleave writes with it`
208
+ : `another live process${err.ownerPid !== undefined ? ` (pid ${err.ownerPid})` : ""} holds the permission-rule store's writer lock — refusing to interleave writes with it; write through that process, or stop it`;
184
209
  break;
210
+ }
185
211
  case "store.dir_claiming":
186
212
  sentence = "another process is reclaiming the permission-rule store's writer lock from a crashed owner — retry";
187
213
  break;
@@ -193,22 +219,29 @@ function writerLockRefusal(err, onError) {
193
219
  sentence = `the permission-rule store's writer lock refused (${String(unhandled)})`;
194
220
  }
195
221
  }
196
- return new FileStoreLockError(err.code, refusalText(onError, sentence, `${err.lockPath}: ${err.message}`), err.lockPath, err.ownerPid);
222
+ return new FileStoreLockError(err.code, refusalText(onError, sentence, `${err.lockPath}: ${err.message}`), err.lockPath, err.ownerPid, err.ownerUncheckable);
223
+ }
224
+ function retireOnlyRefusal(rest) {
225
+ return receiptRefusal(`a listed permission-rule bucket's handle only retires rows (a tighten-delete, and the nextDot its tombstone takes) — ${rest}`);
197
226
  }
198
227
  class FileDurableRulePartition {
199
228
  dir;
200
229
  file;
201
230
  acquireWriteLock;
231
+ origin;
202
232
  onError;
203
233
  vetting;
204
234
  durability = "durable";
205
235
  fidelity = "json";
206
- constructor(dir, file, acquireWriteLock, onError, vetting) {
236
+ name;
237
+ constructor(dir, file, acquireWriteLock, origin, onError, vetting) {
207
238
  this.dir = dir;
208
239
  this.file = file;
209
240
  this.acquireWriteLock = acquireWriteLock;
241
+ this.origin = origin;
210
242
  this.onError = onError;
211
243
  this.vetting = vetting;
244
+ this.name = basename(file);
212
245
  }
213
246
  read() {
214
247
  const bucket = "this owner's permission-rule bucket";
@@ -222,6 +255,11 @@ class FileDurableRulePartition {
222
255
  const st = lstatSync(this.file);
223
256
  if (st.isSymbolicLink() || !st.isFile())
224
257
  return unreadable(`${bucket} is a symlink or not a regular file; refusing to load any rule from it`);
258
+ const spelled = entrySpelling(this.dir, this.name);
259
+ if (spelled === undefined)
260
+ return { absent: true };
261
+ if (spelled !== this.name)
262
+ return caseVariantRefusal(this.onError, this.vetting, `the file ${bucket} would open ${CASE_VARIANT_FAULT}; loading zero rules`, join(this.dir, spelled));
225
263
  raw = readFileSync(this.file, "utf8");
226
264
  }
227
265
  catch (err) {
@@ -306,11 +344,18 @@ class FileDurableRulePartition {
306
344
  return "file" in r ? this.screenDurableRows(r.file).quarantined : [];
307
345
  }
308
346
  current() {
347
+ this.acquireWriteLock();
348
+ if (!this.origin.stillOpens()) {
349
+ throw new Error("this permission-rule bucket is no longer this handle's to write — an adoption names its file; open it again through its owner");
350
+ }
309
351
  const r = this.read();
310
352
  if ("unreadable" in r) {
311
353
  throw unreadableError(r, `refusing to write the permission-rule store while it cannot be read: ${r.unreadable}`);
312
354
  }
313
355
  if ("absent" in r) {
356
+ if (this.origin.posture === "retire-only") {
357
+ throw unreadableError({ unreadable: refusalText(this.onError, "this listed permission-rule bucket is no longer there (ENOENT); refusing to write it — list the store directory again", this.file), code: PERMISSION_RULES_UNREADABLE_BUCKET_CODE, errno: "ENOENT" });
358
+ }
314
359
  return { schemaVersion: 4, actor: `file-${randomBytes(6).toString("hex")}`, counter: 0, rev: 0, rules: [], tombstones: [] };
315
360
  }
316
361
  return {
@@ -349,6 +394,8 @@ class FileDurableRulePartition {
349
394
  return dot;
350
395
  }),
351
396
  readRaw: async () => this.serialize(() => {
397
+ if (this.origin.posture === "retire-only")
398
+ throw retireOnlyRefusal("its raw sync state is read through its owner");
352
399
  const cur = this.current();
353
400
  const screened = this.screenDurableRows(cur);
354
401
  return {
@@ -363,8 +410,12 @@ class FileDurableRulePartition {
363
410
  }),
364
411
  apply: async (delta, opts) => this.serialize(() => {
365
412
  delta = structuredClone(delta);
413
+ const { expectedRev } = opts;
414
+ if (this.origin.posture === "retire-only" && delta?.kind !== "tighten-delete") {
415
+ throw retireOnlyRefusal("every other write goes through its owner");
416
+ }
366
417
  const cur = this.current();
367
- if (cur.rev !== opts.expectedRev)
418
+ if (cur.rev !== expectedRev)
368
419
  return { conflict: true, rev: cur.rev };
369
420
  let next;
370
421
  switch (delta.kind) {
@@ -442,12 +493,41 @@ function receiveKnownOwners(opts) {
442
493
  const element = Object.hasOwn(list, index) ? list[index] : undefined;
443
494
  const name = principalNameOf(element);
444
495
  if (name === undefined) {
445
- throw receiptRefusal(`listBucketOwners options.knownOwners[${index}] is not a principal name (got ${principalNameFault(element)}); refused rather than skipped — a skipped name would be counted as a bucket nobody can name`);
496
+ throw receiptRefusal(`listBucketOwners options.knownOwners[${index}] is not a principal name (got ${principalNameFault(element)}); refused rather than skipped — a skipped name would leave its bucket unlabelled`);
446
497
  }
447
498
  names.add(name);
448
499
  }
449
500
  return [...names];
450
501
  }
502
+ function adoptionBucketFiles(rec) {
503
+ return { source: rec.from.kind === "local-owner" ? LOCAL_OWNER_FILE : principalRuleFileName(rec.from.principal), target: principalRuleFileName(rec.toPrincipal) };
504
+ }
505
+ export function bucketCensusOf(names, rec, knownOwners) {
506
+ const present = new Set(names);
507
+ const [variant] = [...present].filter(isCaseVariantBucketName).sort();
508
+ if (variant !== undefined)
509
+ return { caseVariant: variant };
510
+ const owners = [];
511
+ if (present.has(LOCAL_OWNER_FILE))
512
+ owners.push({ kind: "local-owner" });
513
+ let named;
514
+ if (rec !== undefined) {
515
+ named = adoptionBucketFiles(rec);
516
+ if (present.has(named.target))
517
+ owners.push({ kind: "principal", principal: rec.toPrincipal });
518
+ if (rec.from.kind === "principal" && named.source !== named.target && present.has(named.source))
519
+ owners.push({ kind: "principal", principal: rec.from.principal });
520
+ }
521
+ const knownFiles = [];
522
+ for (const principal of knownOwners)
523
+ knownFiles.push({ file: principalRuleFileName(principal), principal });
524
+ const unnamed = [];
525
+ for (const name of [...present].filter((n) => HASHED_BUCKET_FILE.test(n) && n !== named?.source && n !== named?.target).sort()) {
526
+ const knownAs = knownFiles.find((known) => known.file === name)?.principal;
527
+ unnamed.push({ bucketId: name.slice(0, -".json".length), ...(knownAs !== undefined ? { knownAs } : {}) });
528
+ }
529
+ return { owners, unnamed };
530
+ }
451
531
  export class FileDurableRulePartitionProvider {
452
532
  dir;
453
533
  onError;
@@ -461,6 +541,7 @@ export class FileDurableRulePartitionProvider {
461
541
  if (options.dataRoot !== undefined)
462
542
  assertAdoptionBootGate(options.dataRoot, "FileDurableRulePartitionProvider");
463
543
  let said = false;
544
+ const caseVariantsMet = new Set();
464
545
  this.vetting = {
465
546
  platform: options.platform,
466
547
  modeBitsUnjudged: (where) => {
@@ -469,6 +550,12 @@ export class FileDurableRulePartitionProvider {
469
550
  said = true;
470
551
  discloseTo(this.onError, `the permission-rule store directory is not checked for being writable by other accounts: this platform reports no POSIX permission bits, so who else can write there is not verified here (at ${where})`);
471
552
  },
553
+ caseVariantFirstMet: (location) => {
554
+ if (caseVariantsMet.has(location))
555
+ return false;
556
+ caseVariantsMet.add(location);
557
+ return true;
558
+ },
472
559
  };
473
560
  }
474
561
  adoptionMarker() {
@@ -479,6 +566,19 @@ export class FileDurableRulePartitionProvider {
479
566
  }
480
567
  return judged.marker;
481
568
  }
569
+ markerFiles() {
570
+ const adoption = this.adoptionMarker();
571
+ return adoption === undefined ? undefined : adoptionBucketFiles("adopted" in adoption ? adoption.adopted : adoption.marker);
572
+ }
573
+ originOf(name, door) {
574
+ return {
575
+ posture: door === "owner" ? "full" : "retire-only",
576
+ stillOpens: () => {
577
+ const named = this.markerFiles();
578
+ return named === undefined || (named.source !== name && (door === "owner" || named.target !== name));
579
+ },
580
+ };
581
+ }
482
582
  orgStatePersistence() {
483
583
  return this.fileOrgPersistence();
484
584
  }
@@ -515,11 +615,14 @@ export class FileDurableRulePartitionProvider {
515
615
  return this.readOnlySourceView(principalRuleFileName(name), principalRuleFileName(rec.toPrincipal), "adopted" in adoption || adoption.marker.phase >= 4);
516
616
  }
517
617
  }
518
- return new FileDurableRulePartition(this.dir, join(this.dir, principalRuleFileName(name)), this.acquireWriteLock, this.onError, this.vetting);
618
+ return this.ownerPartition(principalRuleFileName(name));
619
+ }
620
+ ownerPartition(name) {
621
+ return new FileDurableRulePartition(this.dir, join(this.dir, name), this.acquireWriteLock, this.originOf(name, "owner"), this.onError, this.vetting);
519
622
  }
520
623
  readOnlySourceView(sourceName, targetName, flipped) {
521
624
  const pick = flipped ? targetName : existsSync(join(this.dir, sourceName)) ? sourceName : targetName;
522
- return readOnlyRuleStoreView(new FileDurableRulePartition(this.dir, join(this.dir, pick), this.acquireWriteLock, this.onError, this.vetting));
625
+ return readOnlyRuleStoreView(this.ownerPartition(pick));
523
626
  }
524
627
  forLocalOwner() {
525
628
  const adoption = this.adoptionMarker();
@@ -529,7 +632,7 @@ export class FileDurableRulePartitionProvider {
529
632
  return this.readOnlySourceView(LOCAL_OWNER_FILE, principalRuleFileName(rec.toPrincipal), "adopted" in adoption || adoption.marker.phase >= 4);
530
633
  }
531
634
  }
532
- return new FileDurableRulePartition(this.dir, join(this.dir, LOCAL_OWNER_FILE), this.acquireWriteLock, this.onError, this.vetting);
635
+ return this.ownerPartition(LOCAL_OWNER_FILE);
533
636
  }
534
637
  listBucketOwners(opts) {
535
638
  const knownOwners = receiveKnownOwners(opts);
@@ -539,7 +642,7 @@ export class FileDurableRulePartitionProvider {
539
642
  }
540
643
  catch (err) {
541
644
  if (err?.code === "ENOENT")
542
- return Object.freeze({ owners: Object.freeze([]), unnamedBuckets: 0 });
645
+ return Object.freeze({ owners: Object.freeze([]), unnamedBuckets: Object.freeze([]) });
543
646
  throw faulted(err, "examined");
544
647
  }
545
648
  let dirFault;
@@ -556,31 +659,21 @@ export class FileDurableRulePartitionProvider {
556
659
  const rec = adoption === undefined ? undefined : "adopted" in adoption ? adoption.adopted : adoption.marker;
557
660
  let names;
558
661
  try {
559
- names = new Set(readdirSync(this.dir));
662
+ names = readdirSync(this.dir);
560
663
  }
561
664
  catch (err) {
562
665
  throw faulted(err, "listed");
563
666
  }
564
- const owners = [];
565
- if (names.has(LOCAL_OWNER_FILE))
566
- owners.push({ kind: "local-owner" });
567
- const claimed = new Set();
568
- const named = new Set();
569
- for (const principal of [rec?.toPrincipal, rec?.from.kind === "principal" ? rec.from.principal : undefined, ...knownOwners]) {
570
- if (principal === undefined || named.has(principal))
571
- continue;
572
- named.add(principal);
573
- const file = principalRuleFileName(principal);
574
- if (!names.has(file))
575
- continue;
576
- claimed.add(file);
577
- owners.push({ kind: "principal", principal });
578
- }
579
- let unnamedBuckets = 0;
580
- for (const name of names)
581
- if (HASHED_BUCKET_FILE.test(name) && !claimed.has(name))
582
- unnamedBuckets++;
583
- return Object.freeze({ owners: Object.freeze(owners), unnamedBuckets });
667
+ const census = bucketCensusOf(names, rec, knownOwners);
668
+ if ("caseVariant" in census) {
669
+ throw unreadableError(caseVariantRefusal(this.onError, this.vetting, `a file in the permission-rule store directory ${CASE_VARIANT_FAULT}; refusing to list its buckets`, join(this.dir, census.caseVariant)));
670
+ }
671
+ const unnamedBuckets = census.unnamed.map(({ bucketId, knownAs }) => {
672
+ const file = `${bucketId}.json`;
673
+ const partition = new FileDurableRulePartition(this.dir, join(this.dir, file), this.acquireWriteLock, this.originOf(file, "listed"), this.onError, this.vetting);
674
+ return Object.freeze({ bucketId, ...(knownAs !== undefined ? { knownAs } : {}), partition });
675
+ });
676
+ return Object.freeze({ owners: Object.freeze([...census.owners]), unnamedBuckets: Object.freeze(unnamedBuckets) });
584
677
  }
585
678
  dispose() {
586
679
  this.lock?.release();
@@ -1,4 +1,4 @@
1
- import { type PutRulesOptions, type SessionPolicyStoreOptions, type SessionPermissionRules, type SessionPolicyStore, type SessionRulesRecord, type StoredSessionRules } from "../../core/session-policy-store.js";
1
+ import { type PutRulesOptions, type SessionPolicyStoreOptions, type SessionPolicyStore, type SessionRulesInGrammar, type SessionRulesRecord, type StoredSessionRules } from "../../core/session-policy-store.js";
2
2
  /**
3
3
  * design/99 §E6 — file-backed {@link SessionPolicyStore} for the local (TOC) backend: one JSON row file per
4
4
  * `(sessionId, principal)`, plus — once that key has ever been stamped — a second, tiny file beside it holding
@@ -196,7 +196,7 @@ export declare class FileSessionPolicyStore implements SessionPolicyStore {
196
196
  * ABSENCE (ENOENT — also a row unlinked under a sweep, an honest absence). Every face reads a row through here. */
197
197
  private readRowFile;
198
198
  getRules(sessionId: string, principal?: string): Promise<StoredSessionRules | null>;
199
- putRules(sessionId: string, principal: string | undefined, rules: SessionPermissionRules, opts?: PutRulesOptions): Promise<StoredSessionRules>;
199
+ putRules(sessionId: string, principal: string | undefined, rules: SessionRulesInGrammar, opts?: PutRulesOptions): Promise<StoredSessionRules>;
200
200
  listBySession(sessionId: string): Promise<SessionRulesRecord[]>;
201
201
  deleteBySession(sessionId: string): Promise<void>;
202
202
  /** Erase ONE row this session owns: the number must outlive it, so it is folded into the key's mark BEFORE the
@@ -1,5 +1,5 @@
1
- import type { Session, SessionCreateOptions, SessionForkOptions, SessionHead, SessionMetadata, SessionPlacementRecord, SessionRepo, SessionRow, SessionRowExpectation, SessionRowRead, SessionTreeEntry } from "../../internal/harness.js";
2
- import type { PlacedSessionRow } from "../../core/session.js";
1
+ import type { Session, SessionCreateOptions, SessionForkOptions, SessionHead, SessionMetadata, SessionPlacementRecord, SessionRepo, SessionRepoRowCells, SessionRow, SessionRowExpectation, SessionRowRead, SessionTreeEntry } from "../../internal/harness.js";
2
+ import { type PlacedSessionRow } from "../../core/session.js";
3
3
  import { type CorruptReadInfo } from "./corrupt-read-sink.js";
4
4
  export interface FileSessionRepoOptions {
5
5
  /**
@@ -24,6 +24,15 @@ export interface FileSessionRepoOptions {
24
24
  onCorruptRead?: (info: CorruptReadInfo & {
25
25
  sessionId?: string;
26
26
  }) => void;
27
+ /**
28
+ * Who holds the rows' occupant cells ({@link SessionRepoRowCells}). Absent / `"engine"`: this repo — a row's header records its
29
+ * `incarnation` (and a fork's `forkedFromIncarnation`) and every read hands them out. `"host"`: the host's own store — a content repo:
30
+ * no header this repo writes holds either cell, no read hands either out (a header an engine-mode write laid down is read without
31
+ * them, and a cell there that names nobody is not disclosed), the shared authority over a file is judged by the file alone, and a
32
+ * conditional write by the owner and the log. The host's session store then puts the occupant on the metadata its sessions answer
33
+ * and on its head read; `TtlSessionStore` refuses a repo of this mode.
34
+ */
35
+ rowCells?: SessionRepoRowCells;
27
36
  }
28
37
  export declare class FileSessionRepo implements SessionRepo {
29
38
  private readonly dir;
@@ -33,6 +42,8 @@ export declare class FileSessionRepo implements SessionRepo {
33
42
  * `dispose()` walks it and releases each holder share; the weak value is what makes the identity
34
43
  * check on the way out possible without pinning a storage the table itself only holds weakly. */
35
44
  private readonly joined;
45
+ /** {@link FileSessionRepoOptions.rowCells}, read once. */
46
+ readonly rowCells: SessionRepoRowCells;
36
47
  constructor(root: string, options?: FileSessionRepoOptions);
37
48
  /** The one delivery point for {@link FileSessionRepoOptions.onCorruptRead}'s whole-file level; `sessionId` when the file is one session's log. */
38
49
  private disclose;
@@ -60,6 +71,8 @@ export declare class FileSessionRepo implements SessionRepo {
60
71
  * whose placement cell is no placement tuple ({@link readPlacementCell}): the placement is the cell that says which lane the row lives
61
72
  * in, so every reader of the row, of any other cell, goes through its judge. The other cells are each read by their own reader
62
73
  * ({@link headerOf} for the whole header, `placementOf` for the placement tuple alone): a reader of one cell does not answer for the others.
74
+ * The header is read as this repo holds a row ({@link heldRowCells}): every reader of a cell reads it here, so in `"host"` mode no reader
75
+ * sees an occupant cell an engine-mode write left behind.
63
76
  */
64
77
  private metaLineOf;
65
78
  /**
@@ -141,6 +154,12 @@ export declare class FileSessionRepo implements SessionRepo {
141
154
  * refuse that row; this probe is not one of them). `undefined` = missing file OR unplaced; a log with no header record rejects. */
142
155
  placementOf(sessionId: string): Promise<SessionPlacementRecord | undefined>;
143
156
  delete(metadata: SessionMetadata, expect?: SessionRowExpectation): Promise<void>;
157
+ /** {@link SessionRepo.deleteUnreadable}: the head read and the removal are one synchronous step (no await between them, so no write of
158
+ * this process lands in between; another process is kept off the root by its boot lock) — a row that reads in this step, or no row,
159
+ * is never removed. */
160
+ deleteUnreadable(sessionId: string): Promise<boolean>;
161
+ /** The one removal tail of every deletion here: the shared authority evicted, then the file removed — a failure loud. */
162
+ private removeRow;
144
163
  fork(sourceMetadata: SessionMetadata, options?: SessionForkOptions & SessionCreateOptions): Promise<Session>;
145
164
  /** 2c session-sync (the FILE half): the FULL oldest-first log for export. The file backend
146
165
  * has NO F3 floor — `read` returns EVERY persisted entry (`id`/`parentId` verbatim) — so this is the complete