@sema-agent/core 5.19.0 → 5.21.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 (329) hide show
  1. package/CHANGELOG.md +102 -4
  2. package/dist/agents/agent-definition.d.ts +7 -0
  3. package/dist/agents/agent-transcript-tool.d.ts +30 -0
  4. package/dist/agents/builtin-agents.d.ts +60 -0
  5. package/dist/agents/cascade.d.ts +107 -0
  6. package/dist/agents/cumulative-stats.d.ts +56 -0
  7. package/dist/agents/observer.d.ts +162 -0
  8. package/dist/agents/peer-admission.d.ts +95 -0
  9. package/dist/agents/repair-loop.d.ts +226 -0
  10. package/dist/agents/retain-ledger.d.ts +141 -0
  11. package/dist/agents/roster-store.d.ts +105 -0
  12. package/dist/agents/roster-store.js +3 -0
  13. package/dist/agents/send-message-tool.d.ts +92 -0
  14. package/dist/agents/session-util.d.ts +5 -0
  15. package/dist/agents/subagent-steps.d.ts +66 -0
  16. package/dist/agents/subagent.d.ts +600 -0
  17. package/dist/agents/suspend-guard.d.ts +29 -0
  18. package/dist/agents/teacher.d.ts +75 -0
  19. package/dist/agents/team.d.ts +120 -1
  20. package/dist/agents/tool-filter.d.ts +34 -0
  21. package/dist/agents/verify.d.ts +198 -0
  22. package/dist/bench/metrics.d.ts +455 -0
  23. package/dist/brain/anthropic.d.ts +30 -0
  24. package/dist/brain/circuit-breaker.d.ts +33 -0
  25. package/dist/brain/circuit-breaker.js +14 -3
  26. package/dist/brain/context-overflow.d.ts +60 -3
  27. package/dist/brain/degrading.d.ts +67 -0
  28. package/dist/brain/errors.d.ts +42 -0
  29. package/dist/brain/failover.d.ts +15 -0
  30. package/dist/brain/media-degrade.d.ts +39 -0
  31. package/dist/brain/model-presets.d.ts +31 -0
  32. package/dist/brain/open-responses.d.ts +19 -0
  33. package/dist/brain/openai.d.ts +46 -0
  34. package/dist/brain/reasoning.d.ts +106 -1
  35. package/dist/brain/repetition.d.ts +83 -0
  36. package/dist/brain/request-params.d.ts +56 -0
  37. package/dist/brain/retry.d.ts +46 -0
  38. package/dist/brain/routing.d.ts +12 -0
  39. package/dist/brain/status-sink.d.ts +30 -1
  40. package/dist/brain/stream-engine.d.ts +147 -0
  41. package/dist/brain/stream-shared.d.ts +34 -0
  42. package/dist/brain/terminal-cause.d.ts +31 -0
  43. package/dist/brain/timeout.d.ts +108 -0
  44. package/dist/brain/timeout.js +11 -0
  45. package/dist/brain/tool-call-id.d.ts +20 -0
  46. package/dist/brain/tool-call-repair.d.ts +13 -0
  47. package/dist/config/catalog.d.ts +47 -0
  48. package/dist/config/defaults.d.ts +33 -0
  49. package/dist/core/a2a-task-state.d.ts +53 -0
  50. package/dist/core/a2a.d.ts +51 -0
  51. package/dist/core/arg-summary.d.ts +62 -0
  52. package/dist/core/ask-question.d.ts +272 -2
  53. package/dist/core/auto-compaction.d.ts +467 -0
  54. package/dist/core/auto-compaction.js +20 -6
  55. package/dist/core/auto-mode-prompt-assets.d.ts +8 -0
  56. package/dist/core/auto-mode-prompt.d.ts +27 -0
  57. package/dist/core/auto-mode.d.ts +54 -3
  58. package/dist/core/auto-promote.d.ts +100 -0
  59. package/dist/core/background-agent-store.d.ts +293 -0
  60. package/dist/core/background-agent-store.js +5 -0
  61. package/dist/core/background-shell.d.ts +110 -0
  62. package/dist/core/cache-break-detector.d.ts +34 -0
  63. package/dist/core/canonical-json.d.ts +57 -0
  64. package/dist/core/checkpoint-store.d.ts +1574 -16
  65. package/dist/core/compliance.d.ts +30 -0
  66. package/dist/core/consolidate-scope.d.ts +75 -0
  67. package/dist/core/context-edit.d.ts +99 -0
  68. package/dist/core/context-guard.d.ts +46 -0
  69. package/dist/core/exec-gate.d.ts +44 -0
  70. package/dist/core/exec-output-tail.d.ts +61 -0
  71. package/dist/core/file-snapshot-store.d.ts +104 -0
  72. package/dist/core/fs-write-gate-policy.d.ts +36 -0
  73. package/dist/core/git-worktree-env.d.ts +31 -0
  74. package/dist/core/governance-codes.d.ts +19 -0
  75. package/dist/core/hooks.d.ts +609 -1
  76. package/dist/core/human-input-projection.d.ts +37 -0
  77. package/dist/core/human-input-projection.js +13 -0
  78. package/dist/core/image-downsample.d.ts +74 -0
  79. package/dist/core/locked-config.d.ts +37 -0
  80. package/dist/core/lsp-diagnostics.d.ts +77 -0
  81. package/dist/core/lsp-protocol.d.ts +29 -0
  82. package/dist/core/lsp-session.d.ts +60 -1
  83. package/dist/core/lsp.d.ts +150 -1
  84. package/dist/core/mailbox-store.d.ts +57 -0
  85. package/dist/core/mailbox-store.js +2 -0
  86. package/dist/core/mcp.d.ts +385 -0
  87. package/dist/core/mcp.js +58 -11
  88. package/dist/core/media-byte-cap.d.ts +21 -0
  89. package/dist/core/memory-admission.d.ts +71 -0
  90. package/dist/core/memory-engine/content-origin.d.ts +64 -0
  91. package/dist/core/memory-engine/data-plane.d.ts +43 -0
  92. package/dist/core/memory-engine/dual-root.d.ts +24 -0
  93. package/dist/core/memory-engine/engine.d.ts +230 -0
  94. package/dist/core/memory-engine/engine.js +103 -35
  95. package/dist/core/memory-engine/file-backend.d.ts +155 -0
  96. package/dist/core/memory-engine/frontmatter.d.ts +16 -0
  97. package/dist/core/memory-engine/layout.d.ts +217 -0
  98. package/dist/core/memory-engine/memory-backend-contract.d.ts +12 -0
  99. package/dist/core/memory-engine/migrate.d.ts +9 -0
  100. package/dist/core/memory-engine/scan.d.ts +12 -0
  101. package/dist/core/memory-engine/scope-contract.d.ts +61 -1
  102. package/dist/core/memory-engine/sync-client.d.ts +87 -0
  103. package/dist/core/memory-engine/sync.d.ts +60 -0
  104. package/dist/core/memory-engine/tools.d.ts +41 -0
  105. package/dist/core/memory-engine/types.d.ts +188 -0
  106. package/dist/core/memory-recall.d.ts +141 -0
  107. package/dist/core/memory-vector.d.ts +20 -0
  108. package/dist/core/memory.d.ts +458 -0
  109. package/dist/core/message-utils.d.ts +6 -0
  110. package/dist/core/oracle-isolation.d.ts +69 -0
  111. package/dist/core/permission-rule-consent.d.ts +138 -0
  112. package/dist/core/permission-rule-model.d.ts +122 -0
  113. package/dist/core/permission-rule-store.d.ts +119 -3
  114. package/dist/core/permission-rules.d.ts +87 -1
  115. package/dist/core/present-plan-tool.d.ts +20 -0
  116. package/dist/core/pricing.d.ts +26 -0
  117. package/dist/core/property-harness.d.ts +86 -0
  118. package/dist/core/protocol-naming.d.ts +38 -0
  119. package/dist/core/protocol-table.d.ts +61 -0
  120. package/dist/core/push-queue.d.ts +1 -0
  121. package/dist/core/remote-env.d.ts +383 -1
  122. package/dist/core/retention-policy.d.ts +40 -0
  123. package/dist/core/retention-policy.js +21 -0
  124. package/dist/core/retention.d.ts +51 -0
  125. package/dist/core/roles.d.ts +59 -0
  126. package/dist/core/runner/active-skill-scope.d.ts +34 -0
  127. package/dist/core/runner/assemble-result.d.ts +134 -0
  128. package/dist/core/runner/compaction-call-options.d.ts +97 -1
  129. package/dist/core/runner/grounding-signal.d.ts +10 -0
  130. package/dist/core/runner/image.d.ts +17 -0
  131. package/dist/core/runner/image.js +29 -15
  132. package/dist/core/runner/memory-consolidation.d.ts +60 -0
  133. package/dist/core/runner/prepare-memory.d.ts +59 -0
  134. package/dist/core/runner/prepare-task.d.ts +1011 -2
  135. package/dist/core/runner/prepare-task.js +51 -14
  136. package/dist/core/runner/prompt-suggestions.d.ts +7 -0
  137. package/dist/core/runner/runtask.d.ts +304 -3
  138. package/dist/core/runner/runtask.js +17 -2
  139. package/dist/core/runner/session-file-state-replay.d.ts +49 -0
  140. package/dist/core/runner/session-rule-policy.d.ts +58 -0
  141. package/dist/core/runner/strict-output-schema.d.ts +18 -3
  142. package/dist/core/runner/synthetic-tools.d.ts +113 -0
  143. package/dist/core/runner/teardown-bounded.d.ts +34 -0
  144. package/dist/core/runner/tool-disclosure.d.ts +227 -0
  145. package/dist/core/runner/tool-output-projection.d.ts +6 -0
  146. package/dist/core/runner/turn-attachments.d.ts +634 -0
  147. package/dist/core/runner/usage-accounting.d.ts +32 -0
  148. package/dist/core/runtime.d.ts +9 -0
  149. package/dist/core/safe-notify.d.ts +64 -0
  150. package/dist/core/safety-axis-vocab.d.ts +23 -0
  151. package/dist/core/safety-merge-corpus.d.ts +37 -0
  152. package/dist/core/scheduler.d.ts +121 -0
  153. package/dist/core/secret-env.d.ts +32 -0
  154. package/dist/core/select-model.d.ts +15 -0
  155. package/dist/core/sensitive-path-policy.d.ts +42 -0
  156. package/dist/core/session-policy-store.d.ts +94 -0
  157. package/dist/core/session-reconcile.d.ts +80 -0
  158. package/dist/core/session-store.d.ts +85 -0
  159. package/dist/core/session.d.ts +153 -0
  160. package/dist/core/shared-memory/contract.d.ts +22 -0
  161. package/dist/core/shared-memory/normalize.d.ts +123 -2
  162. package/dist/core/shared-memory/tools.d.ts +14 -0
  163. package/dist/core/shared-memory/types.d.ts +105 -0
  164. package/dist/core/shutdown-debug.d.ts +6 -0
  165. package/dist/core/side-query.d.ts +38 -0
  166. package/dist/core/side-query.js +6 -1
  167. package/dist/core/skill-tool-specifier.d.ts +72 -0
  168. package/dist/core/skills-directory.d.ts +100 -1
  169. package/dist/core/spec-contract.d.ts +89 -0
  170. package/dist/core/store-contracts/background-agent-store-contract.d.ts +31 -0
  171. package/dist/core/store-contracts/checkpoint-store-contract.d.ts +26 -0
  172. package/dist/core/store-contracts/contract-harness.d.ts +20 -0
  173. package/dist/core/store-contracts/contract-kit-version.d.ts +27 -0
  174. package/dist/core/store-contracts/file-snapshot-store-contract.d.ts +8 -0
  175. package/dist/core/store-contracts/mailbox-store-contract.d.ts +42 -0
  176. package/dist/core/store-contracts/tool-result-store-contract.d.ts +13 -0
  177. package/dist/core/strategy-store.d.ts +37 -0
  178. package/dist/core/stub-env.d.ts +7 -0
  179. package/dist/core/surrogate-safe-slice.d.ts +35 -0
  180. package/dist/core/task-notification.d.ts +202 -0
  181. package/dist/core/task-outcome.d.ts +53 -0
  182. package/dist/core/task-registry-agent.d.ts +337 -1
  183. package/dist/core/task-registry-agent.js +2 -0
  184. package/dist/core/task-registry-monitor.d.ts +12 -0
  185. package/dist/core/task-registry-shared.d.ts +540 -0
  186. package/dist/core/task-registry.d.ts +343 -0
  187. package/dist/core/task-registry.js +13 -2
  188. package/dist/core/task-tool-shape.d.ts +44 -0
  189. package/dist/core/tighten-task-spec.d.ts +21 -0
  190. package/dist/core/tool-detach.d.ts +21 -0
  191. package/dist/core/tool-errors.d.ts +131 -0
  192. package/dist/core/tool-errors.js +4 -0
  193. package/dist/core/tool-name-aliases.d.ts +27 -0
  194. package/dist/core/tool-policy.d.ts +555 -0
  195. package/dist/core/tool-policy.js +3 -0
  196. package/dist/core/tool-result-budget.d.ts +32 -0
  197. package/dist/core/tool-result-store.d.ts +174 -1
  198. package/dist/core/tools.d.ts +45 -0
  199. package/dist/core/trace.d.ts +323 -0
  200. package/dist/core/types.d.ts +3859 -2
  201. package/dist/core/untrusted-egress.d.ts +8 -0
  202. package/dist/core/untrusted-text.d.ts +156 -0
  203. package/dist/core/usage-window-store.d.ts +95 -0
  204. package/dist/core/version.d.ts +1 -0
  205. package/dist/core/warm-resume.d.ts +17 -0
  206. package/dist/core/wiring-manifest.d.ts +169 -0
  207. package/dist/core/with-retry.d.ts +24 -0
  208. package/dist/core/workflow-journal-store.d.ts +160 -0
  209. package/dist/core/workflow-run-store-contract.d.ts +25 -0
  210. package/dist/core/workflow-run-store.d.ts +119 -0
  211. package/dist/core/workflow-run-store.js +2 -0
  212. package/dist/engine/compaction/compaction.d.ts +256 -1
  213. package/dist/engine/compaction/utils.d.ts +94 -0
  214. package/dist/engine/execution-env/kill-tree.d.ts +29 -0
  215. package/dist/engine/execution-env/node-execution-env.d.ts +94 -0
  216. package/dist/engine/harness/agent-harness.d.ts +116 -0
  217. package/dist/engine/harness/agent-harness.js +3 -14
  218. package/dist/engine/harness/messages.d.ts +15 -0
  219. package/dist/engine/harness/types.d.ts +464 -2
  220. package/dist/engine/llm/diagnostics.d.ts +4 -0
  221. package/dist/engine/llm/event-stream.d.ts +3 -0
  222. package/dist/engine/llm/index.d.ts +7 -0
  223. package/dist/engine/llm/types.d.ts +500 -3
  224. package/dist/engine/llm/validation.d.ts +3 -0
  225. package/dist/engine/loop/agent-loop.d.ts +87 -2
  226. package/dist/engine/loop/runtime-deps.d.ts +7 -0
  227. package/dist/engine/loop/types.d.ts +424 -0
  228. package/dist/engine/lsp/frame-decoder.d.ts +13 -0
  229. package/dist/engine/lsp/node-lsp-manager.d.ts +107 -0
  230. package/dist/engine/lsp/stdio-lsp-transport.d.ts +7 -0
  231. package/dist/engine/session/import-validate.d.ts +27 -0
  232. package/dist/engine/session/log-digest.d.ts +93 -0
  233. package/dist/engine/session/memory-repo.d.ts +6 -0
  234. package/dist/engine/session/memory-storage.d.ts +2 -0
  235. package/dist/engine/session/session.d.ts +75 -0
  236. package/dist/engine/session/storage-base.d.ts +8 -0
  237. package/dist/fixtures/index.d.ts +36 -0
  238. package/dist/index.d.ts +17 -2
  239. package/dist/index.js +1 -2
  240. package/dist/internal/harness-types.d.ts +6 -0
  241. package/dist/internal/harness.d.ts +11 -0
  242. package/dist/internal/llm.d.ts +6 -0
  243. package/dist/orchestration/builtin-workflows.d.ts +53 -0
  244. package/dist/orchestration/dev-vm-script-runner.d.ts +19 -0
  245. package/dist/orchestration/goal.d.ts +57 -0
  246. package/dist/orchestration/goal.js +3 -0
  247. package/dist/orchestration/run-spec.d.ts +42 -0
  248. package/dist/orchestration/run-spec.js +4 -0
  249. package/dist/orchestration/run-workflow-tool.d.ts +169 -0
  250. package/dist/orchestration/workflow-governance.d.ts +61 -0
  251. package/dist/orchestration/workflow-meta.d.ts +28 -0
  252. package/dist/orchestration/workflow-observe.d.ts +60 -0
  253. package/dist/orchestration/workflow-primitives.d.ts +23 -1
  254. package/dist/orchestration/workflow-sandbox-conformance.d.ts +38 -0
  255. package/dist/orchestration/workflow-script-runner.d.ts +88 -0
  256. package/dist/orchestration/workflow-script-store.d.ts +98 -0
  257. package/dist/orchestration/workflow-size-guideline.d.ts +67 -0
  258. package/dist/orchestration/workflow-types.d.ts +169 -2
  259. package/dist/orchestration/workflow.d.ts +358 -0
  260. package/dist/orchestration/workflow.js +13 -2
  261. package/dist/prompt-assembly/artifact-store.d.ts +33 -0
  262. package/dist/prompt-assembly/artifact.d.ts +25 -0
  263. package/dist/prompt-assembly/assemble.d.ts +20 -0
  264. package/dist/prompt-assembly/composer.d.ts +29 -0
  265. package/dist/prompt-assembly/epoch.d.ts +55 -1
  266. package/dist/prompt-assembly/event-registry.d.ts +35 -0
  267. package/dist/prompt-assembly/explain.d.ts +12 -0
  268. package/dist/prompt-assembly/tool-catalog.d.ts +38 -0
  269. package/dist/prompt-assembly/turn-snapshot.d.ts +40 -0
  270. package/dist/prompt-assembly/types.d.ts +115 -0
  271. package/dist/prompts/coordinator.d.ts +27 -0
  272. package/dist/prompts/default.d.ts +539 -0
  273. package/dist/prompts/simple-sections.d.ts +45 -0
  274. package/dist/prompts/supervisor.d.ts +66 -0
  275. package/dist/scenarios/env.d.ts +28 -0
  276. package/dist/scenarios/full-body.d.ts +50 -0
  277. package/dist/scenarios/scenario-registry.d.ts +60 -0
  278. package/dist/scenarios/teacher-quickstart.d.ts +27 -0
  279. package/dist/server/http.d.ts +17 -0
  280. package/dist/stores/cc/lockfile.d.ts +6 -0
  281. package/dist/stores/cc/mailbox-store.d.ts +8 -0
  282. package/dist/stores/cc/roster-adapter.d.ts +4 -0
  283. package/dist/stores/cc/sidecar-transcript.d.ts +66 -0
  284. package/dist/stores/file/background-agent-store.d.ts +24 -0
  285. package/dist/stores/file/background-agent-store.js +2 -1
  286. package/dist/stores/file/checkpoint-store.d.ts +38 -0
  287. package/dist/stores/file/file-snapshot-store.d.ts +25 -0
  288. package/dist/stores/file/fs-atomic.d.ts +155 -0
  289. package/dist/stores/file/index.d.ts +89 -0
  290. package/dist/stores/file/mailbox-store.d.ts +36 -0
  291. package/dist/stores/file/mailbox-store.js +2 -0
  292. package/dist/stores/file/memory-store.d.ts +82 -0
  293. package/dist/stores/file/permission-rule-store.d.ts +79 -0
  294. package/dist/stores/file/session-policy-store.d.ts +28 -0
  295. package/dist/stores/file/session-store.d.ts +40 -0
  296. package/dist/stores/file/shared-ledger.d.ts +83 -0
  297. package/dist/stores/file/tool-result-store.d.ts +11 -0
  298. package/dist/stores/file/usage-window-store.d.ts +18 -0
  299. package/dist/stores/file/workflow-journal-store.d.ts +100 -0
  300. package/dist/stores/file/workflow-run-store.d.ts +11 -0
  301. package/dist/stores/file/workflow-run-store.js +2 -0
  302. package/dist/tools/fs/bash-readonly-classifier.d.ts +282 -0
  303. package/dist/tools/fs/encoding.d.ts +60 -0
  304. package/dist/tools/fs/fs-bash.d.ts +133 -0
  305. package/dist/tools/fs/fs-pdf.d.ts +28 -0
  306. package/dist/tools/fs/fs-search-tools.d.ts +5 -0
  307. package/dist/tools/fs/fs-shared.d.ts +360 -0
  308. package/dist/tools/fs/fs-write.d.ts +16 -0
  309. package/dist/tools/fs/gh-rate-limit.d.ts +22 -0
  310. package/dist/tools/fs/index.d.ts +79 -0
  311. package/dist/tools/fs/notebook.d.ts +56 -0
  312. package/dist/tools/fs/pdf.d.ts +70 -0
  313. package/dist/tools/fs/pdf.js +8 -2
  314. package/dist/tools/fs/repo-map.d.ts +10 -0
  315. package/dist/tools/fs/safety.d.ts +376 -0
  316. package/dist/tools/fs/search.d.ts +131 -0
  317. package/dist/tools/loop-tick.d.ts +24 -0
  318. package/dist/tools/monitor.d.ts +55 -0
  319. package/dist/tools/scheduler-tools.d.ts +51 -0
  320. package/dist/tools/sql-adapters.d.ts +18 -0
  321. package/dist/tools/sql.d.ts +25 -0
  322. package/dist/tools/task-list.d.ts +77 -0
  323. package/dist/tools/todo.d.ts +8 -0
  324. package/dist/tools/web.d.ts +184 -0
  325. package/dist/tools/web.js +32 -5
  326. package/dist/tools/worktree.d.ts +81 -0
  327. package/package.json +2 -2
  328. package/dist/tools/gitea-issue.d.ts +0 -13
  329. package/dist/tools/gitea-issue.js +0 -75
@@ -2,17 +2,78 @@ import { type BackgroundAgentRecord, type BackgroundAgentStore } from "./backgro
2
2
  import { type StopSource, type TaskAccess, type TaskRetrievalStatus, type UnifiedTaskOutput, type UnifiedTaskResult, type BackgroundAgentTaskHandle, type DurableAgentCore, type ParkedClaimTicket, type RegisterBackgroundAgentInput } from "./task-registry-shared.js";
3
3
  import { type ToolResultStore } from "./tool-result-store.js";
4
4
  export declare function ensureDurableHeartbeatLane(core: DurableAgentCore): void;
5
+ /** design/151 S1a — enqueue one durable-row write (see {@link DurableAgentLane} for the lane
6
+ * contract). `patch` is captured at CALL time (the settle-site values), applied in chain order.
7
+ *
8
+ * codex S1a F1 hardening — failure taxonomy, decided by EVIDENCE not by exception class:
9
+ * - thrown store errors get a bounded in-lane retry (a transient outage must not permanently
10
+ * strand a terminal write — the settle is often the row's LAST write);
11
+ * - `already_exists` on a put and a lost CAS both trigger a read-back writerId check first: an
12
+ * AMBIGUOUS earlier commit (backend committed, response failed) or a stale-arm flip
13
+ * (reap wrote rev up under a live run) is OUR row wearing a newer rev — ADOPT the rev and
14
+ * re-apply (the real terminal truth must beat a reaper's guess); only a row carrying a
15
+ * FOREIGN writerId poisons the lane (never clobber another writer). */
5
16
  export declare function durableAgentWriteLane(handle: BackgroundAgentTaskHandle, patch: Partial<BackgroundAgentRecord>, clear?: readonly (keyof BackgroundAgentRecord)[]): void;
17
+ /** design/151 S1b — is this row's durable lane ARMED (store wired at registration, not poisoned)?
18
+ * Observability/test face. ⚠️ NOT the lifecycle-flip key: arming says a row was ATTEMPTED, not
19
+ * that it EXISTS — release anchors gate on {@link durableAgentRowProbe} (codex r2 F2). */
6
20
  export declare function durableAgentArmedLane(core: DurableAgentCore, id: string): boolean;
21
+ /** design/151 S1b (codex r2 F2) — the AWAITABLE lifecycle-flip key. Returns undefined when no
22
+ * lane was armed; otherwise a probe CLOSURE over the HANDLE (outlives its eviction from the map —
23
+ * retain-ledger TTL arms fire hours after terminal GC) that flushes the queued writes and answers
24
+ * whether a durable row actually EXISTS right now (initial put confirmed, not poisoned). A store
25
+ * that never accepted the put answers false — the caller then RELEASES the session (pre-151 path)
26
+ * instead of stranding an unreachable transcript.
27
+ *
28
+ * The closure reads `handle.durable` at CALL time rather than capturing the lane: a revive's claim
29
+ * hands the row to a fresh lane and retires the one that was current when the probe was minted, and
30
+ * a probe bound to the retired object would answer "no row" for a row that plainly exists — and the
31
+ * caller acts on that by releasing the child's transcript session, the exact strand this probe was
32
+ * built to prevent. Reading through the handle also survives the map eviction (the closure keeps the
33
+ * handle object alive), so the outlives-terminal-GC property the retain arms rely on is unchanged. */
7
34
  export declare function durableAgentRowProbeLane(core: DurableAgentCore, id: string): (() => Promise<boolean>) | undefined;
35
+ /** design/151 §7.3 (F-8) — open the in-process claim window for a tier-3 revival of `id`.
36
+ * SYNCHRONOUS admission check + mark in one call: refuses (false) while the handle is live
37
+ * running/pending in THIS process (the live delivery ladder owns it), while a reap sweep is
38
+ * adjudicating it, or while another claim holds the window. The caller MUST call
39
+ * {@link endDurableClaim} in a finally — the window spans its whole claim-CAS→spawn/rollback
40
+ * sequence, and a leaked mark would permanently fence the handle from revival, reap AND the
41
+ * terminal-handle GC (which skips ids inside this window), i.e. it would also leak the handle. */
8
42
  export declare function beginDurableClaimLane(core: DurableAgentCore, id: string): boolean;
43
+ /** Close the {@link beginDurableClaim} window (idempotent). */
9
44
  export declare function endDurableClaimLane(core: DurableAgentCore, id: string): void;
45
+ /** design/151 §3.1 MED-7 / codex r2 F1 — the BLESSED retention path: the joint reap that drops a
46
+ * doomed row under its rev guard and THEN releases its transcript session (raw `store.reap`
47
+ * strands transcripts — its contract says so). Policy semantics mirror the store sweep (double
48
+ * bound + stale-running flip; running rows are never deleted).
49
+ *
50
+ * codex 终审 C-2 — ORDER: conditional DELETE first, release only after the delete WINS. The
51
+ * reverse (release→delete) destroyed a live transcript whenever a concurrent writer revived the
52
+ * row between the release and the losing CAS (stale-flip heal / retained-session revive: row
53
+ * back to running, session already gone). Failure economics of this order: a crash (or release
54
+ * throw) after the winning delete LEAKS the session to the deployment's session TTL sweep —
55
+ * recoverable — instead of stranding a live transcript — not. The release must therefore treat
56
+ * a missing/already-released id as a no-op (idempotent; 全景复审 F-8 — a release that throws on
57
+ * not_found merely forfeits this bookkeeping, the TTL sweep still owns the orphan). An
58
+ * IN-PROCESS handle running again gates the row out entirely (a revive flips memory before its
59
+ * durable write flushes). `sessions` is structural (unpin/release) so any SessionStore fits
60
+ * without an import cycle.
61
+ * ⚠️ [1522] server 复审案: passing `sessions` DECLARES that its `release` truly ends the
62
+ * transcript's addressability (durable deletion or an equivalent lifecycle handoff). A face
63
+ * whose release only clears in-memory state must NOT be passed — omit `sessions` instead
64
+ * (fail-closed: rows are kept and counted in `skippedNoSessions`, and the deployment's own
65
+ * session GC owns the joint lifecycle). A half-true release deletes the row while the
66
+ * transcript lives on unanchored — the exact strand this orchestration exists to prevent. */
10
67
  export declare function reapDurableAgentsLane(core: DurableAgentCore, scope: string, deps: {
11
68
  store: BackgroundAgentStore;
12
69
  sessions?: {
13
70
  unpin?(sessionId: string): unknown;
14
71
  release(sessionId: string): Promise<void> | void;
15
72
  };
73
+ /** design/151 §7.7 (F-13) — the row's mailbox dies with the row: a WINNING delete also drops
74
+ * the (scope, handle) mailbox (advisory — a mailbox fault never blocks the reap; an orphaned
75
+ * box is bounded by the mailbox's own `reap` policy). Structural face (drop only), so the
76
+ * deployment passes its `RunnerDeps.mailboxStore` directly. */
16
77
  mailbox?: {
17
78
  drop(scope: string, handle: string): Promise<void>;
18
79
  };
@@ -26,15 +87,63 @@ export declare function reapDurableAgentsLane(core: DurableAgentCore, scope: str
26
87
  sessionsReleased: number;
27
88
  skippedNoSessions: number;
28
89
  }>;
90
+ /** codex 终审 C-4 half — after a probe-false RELEASE the row must stop claiming a transcript:
91
+ * the heartbeat's F-1 arm keeps re-driving a flush-failed lane, so a later successful flush
92
+ * would otherwise persist a row whose sessionId points at the session the caller just released.
93
+ * Clearing the anchor makes the eventual row honest: state/result survive, transcript does not. */
29
94
  export declare function releaseDurableTranscriptAnchorLane(core: DurableAgentCore, id: string): void;
95
+ /** design/151 S1a — bind the child's freshly-minted store session id onto the row (the transcript /
96
+ * resume anchor; absent at register time because the child session is created after registration). */
30
97
  export declare function bindBackgroundAgentSessionLane(core: DurableAgentCore, id: string, sessionId: string): void;
98
+ /**
99
+ * #22 — record the org-memory admission verdict THIS leg adjudicated onto the durable row, so the
100
+ * next CROSS-PROCESS revival (which rebuilds the spec from the reviving caller's mount and cannot
101
+ * see this process's memory) starts from it instead of re-adjudicating unconstrained. Called once
102
+ * per leg at the injector-ready barrier (prepare has succeeded by then, so the verdict exists); a
103
+ * revival cycle overwrites the previous cycle's record with its own, which the admission door
104
+ * guarantees is a subset. Same durable write lane as every other post-registration fact — a
105
+ * store-less registration is a no-op, and a poisoned lane stays poisoned.
106
+ *
107
+ * A DROPPED write is disclosed. This record is the only carrier a narrowing has across a process
108
+ * boundary, so what stands on the row when the write does not land is the PREVIOUS leg's wider
109
+ * verdict — which the next revival then seeds from. Two drop shapes, one message each: a poisoned
110
+ * lane refuses at its front door, and an exhausted flush leaves the value unwritten with the lane
111
+ * still armed. The channel is the same durable-agents warning channel the lane uses for the poison
112
+ * itself (that one says writes stopped; this one says WHICH fact stopped with them). The write
113
+ * remains best-effort: no leg faults because its bookkeeping failed.
114
+ *
115
+ * The FORK background lane deliberately does not call this: a fork row refuses the tier-3 claim
116
+ * (subagent.ts, revival preflight), so it has no reader.
117
+ */
31
118
  export declare function recordBackgroundAgentOrgAdmissionLane(core: DurableAgentCore, id: string, verdict: import("./memory-admission.js").OwnOrgAdmissionVerdict): void;
119
+ /** design/115 P3: register a background sub-agent run. The CALLER owns driving the child promise and
120
+ * calling {@link settleBackgroundAgent} at the end; the registry provides the unified task_id, the
121
+ * owner/scope guard, poll/stop dispatch, and terminal GC — exactly like the other two kinds. */
32
122
  export declare function registerBackgroundAgentLane(core: DurableAgentCore, input: RegisterBackgroundAgentInput): string;
123
+ /**
124
+ * design/153 §7.1 — the SINGLE running→parked transition point (r4 F-02: every parked-related
125
+ * transition goes through registry discipline, never a bare store-status write). Called by the bg
126
+ * watcher's `suspended` branch AFTER the durable checkpoint exists and the deployment attested the
127
+ * child session durable (§7.3 capability). First-writer-wins like settle: a TaskStop that already
128
+ * flipped killed refuses the park (returns undefined — the CALLER must then EXPIRE the checkpoint,
129
+ * the §7.1 no-orphans compensation). Releases the delivery channel like the other non-running
130
+ * transitions (a parked child has no live lane; a SendMessage parks per session as with terminal).
131
+ */
33
132
  export declare function parkBackgroundAgentLane(core: DurableAgentCore, id: string, park: {
34
133
  checkpointToken: string;
35
134
  seq?: number;
36
135
  resolveStop?: () => Promise<boolean>;
37
136
  }): "parked" | undefined;
137
+ /**
138
+ * design/153 §7.1 (件1 codex HIGH split-brain fence) — the registry-aware reconciliation entry an
139
+ * IN-PROCESS deployment calls on its retention cadence. Two halves, one call:
140
+ * 1. LIVE half: this instance's own parked handles are probed against their checkpoint and, on
141
+ * expired/missing, settled failed THROUGH the handle (poll/stop/durable row stay coherent —
142
+ * quiescence poked, arbitration closure dropped, durable clear rides the settle write).
143
+ * 2. STORE half: delegates to the store-level {@link reconcileParkedAgents} with
144
+ * `excludeWriterId` = this instance's writerId, so foreign (dead-process) rows are cleaned
145
+ * without ever touching a row this process is live-managing.
146
+ */
38
147
  export declare function reconcileParkedAgentsLane(core: DurableAgentCore, stores: {
39
148
  agentStore: import("./background-agent-store.js").BackgroundAgentStore;
40
149
  checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
@@ -44,6 +153,21 @@ export declare function reconcileParkedAgentsLane(core: DurableAgentCore, stores
44
153
  failed: number;
45
154
  rolledBack: number;
46
155
  }>;
156
+ /**
157
+ * design/153 §7.2c (件3b) — the RESERVATION half of the parked-resume claim. Pure reservation
158
+ * (r6 H-1): the row STAYS `parked` — only `parkClaimId` is written (guarded CAS binding
159
+ * rev+status+token+claim-absence, single-claimer by construction), the live handle keeps its
160
+ * parked state AND its TaskStop arbitration closure (an expire during the reservation window
161
+ * still wins — by design; the resume's token-consume CAS is the only thing that can beat it).
162
+ * parked→running happens ONLY at the 件3c consume flip, never here.
163
+ *
164
+ * AUTHORIZATION LAYERING (r4 F-06, doc-pinned): `access` is ROW VISIBILITY only
165
+ * ({@link canAccessAgentRecord}); the operator's approval authority (/decide) is the SERVER's
166
+ * front gate — this verb must only be reached by an already-authorized decision path.
167
+ * Binding (r6): the token comes FROM THE ROW (never caller-supplied), the checkpoint must be
168
+ * `pending`, and `cp.sessionId === row.sessionId` (same child transcript — blocks swapping in a
169
+ * different child's checkpoint).
170
+ */
47
171
  export declare function claimParkedAgentLane(stores: {
48
172
  agentStore: import("./background-agent-store.js").BackgroundAgentStore;
49
173
  checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
@@ -54,14 +178,49 @@ export declare function claimParkedAgentLane(stores: {
54
178
  ok: false;
55
179
  reason: "not_found" | "not_parked" | "binding_broken" | "checkpoint_not_pending" | "claim_lost" | "store_unreachable";
56
180
  }>;
181
+ /**
182
+ * design/153 §7.2c (件3b) — roll back / settle a reservation whose resume could not proceed.
183
+ * Disposition follows the CHECKPOINT truth re-read at call time (r6: never blind):
184
+ * - `pending` → the reservation is cleared, the row returns to plainly-redeemable `parked`
185
+ * ("rolled_back"); no ownership change (a reservation never transferred it, so no epoch churn).
186
+ * - `expired`/`missing` → honest terminal `failed` ("failed") — same shape reconciliation mints.
187
+ * - `resolved` → the approval was CONSUMED (the resume died post-consume): NON-COMPENSABLE
188
+ * (r6 H-4) — terminal `failed`/outcome-unknown ("failed"); NEVER back to parked.
189
+ * - store unreachable → "retry" (nothing written; the reconciliation cadence is the backstop).
190
+ * A LOCAL live parked handle follows the failed dispositions (poll/stop stay coherent).
191
+ */
57
192
  export declare function rollbackParkedClaimLane(core: DurableAgentCore, stores: {
58
193
  agentStore: import("./background-agent-store.js").BackgroundAgentStore;
59
194
  checkpointStore: Pick<import("./checkpoint-store.js").CheckpointStore, "get">;
60
195
  }, ticket: ParkedClaimTicket): Promise<"rolled_back" | "failed" | "lost" | "retry">;
196
+ /**
197
+ * design/153 §7.2d (件3c, codex 3c H-1) — the CONSUME FLIP, SERIALIZED THROUGH THE DURABLE LANE:
198
+ * the guarded parked→running store CAS runs INSIDE the lane chain (ordered after every seeded
199
+ * write — the session-bind CAS included), so no in-flight lane write can race it, CAS-fail on the
200
+ * flip's rev bump, read the new epoch as foreign, and poison the lane (which would permanently
201
+ * drop finalize/terminal/re-park writes). On a won CAS the lane record/rev swap happens in the
202
+ * SAME chain step and the live handle adopts (running, arbitration dropped — the token is
203
+ * consumed; `parkClaimId` stays visible until finalize). Returns false when the row moved
204
+ * (claim/status/token guard lost) — the caller aborts the resume.
205
+ */
61
206
  export declare function consumeParkedFlipLane(core: DurableAgentCore, id: string, stores: {
62
207
  agentStore: import("./background-agent-store.js").BackgroundAgentStore;
63
208
  }, ticket: ParkedClaimTicket): Promise<boolean>;
209
+ /**
210
+ * design/153 §7.2d (件3c) — attach finalize: the resume's delivery lane is live, the claim is
211
+ * complete — clear `parkClaimId` (handle + durable row) so reconciliation stops seeing an
212
+ * in-flight claim. Idempotent; a terminal settle that lands first clears the same keys itself.
213
+ */
64
214
  export declare function finalizeParkedResumeLane(core: DurableAgentCore, id: string): void;
215
+ /** Terminal update for a background agent (the spawn-side then/catch calls this exactly once).
216
+ * Reap sentinel note: {@link BG_AGENT_REAP_STOP_ERROR} is never STORED as `error` — status "killed"
217
+ * + stoppedBy already carry that fact, and an `error:` line beside a salvaged partial result reads
218
+ * as "the child's work failed" (review A1 follow-up). Real errors (e.g. "session released", a
219
+ * child crash) still land.
220
+ * design/129-B: returns the WINNING terminal status — the earlier writer's when this settle is refused
221
+ * (first-writer-wins), `undefined` when the handle is gone (evicted). Callers report THIS in their
222
+ * notification/terminal event so the push never contradicts the registry row (a completed-notify over a
223
+ * killed row — the TaskStop-then-late-resolve race — was an observable incoherence). */
65
224
  export declare function settleBackgroundAgentLane(core: DurableAgentCore, id: string, outcome: {
66
225
  status: "completed" | "failed" | "killed";
67
226
  result?: string;
@@ -75,10 +234,30 @@ export declare function settleBackgroundAgentLane(core: DurableAgentCore, id: st
75
234
  seq?: number;
76
235
  cycle?: number;
77
236
  }): "completed" | "failed" | "killed" | undefined;
237
+ /** Abort every background agent belonging to `access` (parent-task teardown — a finished parent must
238
+ * not leave orphan child runs burning tokens; mirrors clearBackgroundForOwner for bash). */
78
239
  export declare function abortBackgroundAgentsForOwnerLane(core: DurableAgentCore, access: TaskAccess, opts?: {
79
240
  skipSessionScoped?: boolean;
80
241
  sessionScopedOnly?: boolean;
81
242
  }): number;
243
+ /** CC206-B name resolution over the caller-visible background_agent rows (CC `cgo`/`gvy`, 206:575142-575178
244
+ * and 206:575199-575210 — sema's single-lane subset: no teammate/name-registry branches).
245
+ *
246
+ * [c209-D] PUBLIC + explicit-name layer 0: the single resolver both TaskStop (:1839 leg) and
247
+ * SendMessage consume, so the two verbs can never drift. Ladder:
248
+ * 0a. verbatim `handle.name` match — LATEST-WINS (CC SendMessage.md: "a newer agent took the name
249
+ * (latest wins)"; older rows stay task_id-addressable), any status (names keep working after
250
+ * completion — the resume face is the CC "resumes it from its transcript" counterpart);
251
+ * 0b. normalized `handle.name` match — same latest-wins (the spawn regex bans whitespace, so
252
+ * normalization here is effectively NFKC+lowercase: "Builder"/"builder" share the name pool);
253
+ * 1+. the pre-[c209] description layers, UNCHANGED (exact → normalized, running-preferred +
254
+ * ambiguous posture — TaskStop's anchored behavior does not regress).
255
+ * Matching key of the legacy layers = normalized description (the spawn label that IS the agent's
256
+ * name on this face). Running rows are preferred over terminal ones (CC `gvy`), so a re-used label
257
+ * addresses the live agent, while a lone terminal match still resolves. */
258
+ /** NOTE (server[1523] 对等复审 4b, recorded): the name pool scans LIVE handles only — durable-only
259
+ * rows (restart survivors) are deliberately NOT name-addressable through this rung (canonical-only
260
+ * 裁决); tier-3 revival's name rung goes through the roster instead (design/151 §7.4). */
82
261
  export declare function resolveBackgroundAgentByNameLane(core: DurableAgentCore, name: string, access: TaskAccess, opts?: {
83
262
  preferRunning?: boolean;
84
263
  }): {
@@ -91,7 +270,42 @@ export declare function resolveBackgroundAgentByNameLane(core: DurableAgentCore,
91
270
  status: "not_found";
92
271
  suggestion?: string;
93
272
  };
273
+ /** S2b codex R2-F1': flip the park-redeemability bit AFTER retention is actually secured
274
+ * (tryRetainChild success) — registration happens before the retain attempt, and session-scope
275
+ * alone does NOT retain the child session, so declaring at register time acknowledged parks that
276
+ * a capacity/pin failure (or plain session-scope) could never drain. No-op on unknown ids. */
94
277
  export declare function markRetainedContinuationLane(core: DurableAgentCore, id: string): void;
278
+ /** S2b RB-27② — REVIVE a settled background-agent row for a retained-session RESUME cycle: the
279
+ * row flips back to "running" with a fresh "attaching" channel and a bumped revive-cycle stamp
280
+ * (returned; the resume leg threads it through attach and settle so a stale cycle's late calls
281
+ * can never clobber the new cycle's channel). Only terminal rows revive; running rows refuse
282
+ * (the SendMessage still_running path owns that story).
283
+ *
284
+ * The DURABLE transition is a {@link claimTerminalRowForRevive} claim, awaited BEFORE the in-memory
285
+ * flip — the two orders are not equivalent: flipping memory first (the pre-arbitration shape, a plain lane
286
+ * write with no row guard) let a foreign claim win the row while this process kept serving
287
+ * `running`, and every later write of this cycle then died in the poisoned lane without a trace.
288
+ * Three lane shapes, three treatments:
289
+ * - NO lane (store-less registration): the pre-arbitration in-memory-only transition, unchanged — there is
290
+ * no row, hence no arbitration domain and no competitor;
291
+ * - lane whose initial put never CREATED a row: same — nothing exists for a foreign claim to have
292
+ * won, and the write lane keeps retrying the put. This is decided by the claim's own read INSIDE
293
+ * the chain (row absent AND the put still unconfirmed after the chain drained), never by the
294
+ * entry-time flag: a put merely in flight, or one that committed under a failed response, would
295
+ * otherwise exempt a row that does exist — the split-brain window this claim exists to close;
296
+ * - POISONED lane (stale-flip ownership transfer / row reaped mid-write / heartbeat re-drive
297
+ * ceiling): the claim runs DIRECTLY through the store — the dead lane's chain is no longer a
298
+ * serialization point, the rev guard is. Re-arming that lane object in place is what is NOT
299
+ * done: an in-flight write from it would then see its own writerId on the re-claimed row and
300
+ * adopt it. It stays poisoned (its record keeps the pre-claim writerId/epoch, so its read-back
301
+ * answers "foreign" and it stops), and a row that cannot be claimed — gone, or live under
302
+ * another writer — REFUSES the revive rather than resuming with a durably unreachable row.
303
+ * A WON claim always hands the row to a FRESH lane for the claimed generation (both paths), for the
304
+ * reason spelled out at the handoff: a write appended while the claim was in flight speaks for the
305
+ * cycle that just ended and must not be applied under the new ownership.
306
+ * While the claim is in flight the handle holds the in-process claim window
307
+ * ({@link beginDurableClaimLane}'s mark), so a tier-3 claim, a reap sweep and a second revive of
308
+ * the same row all observe it and take their existing refusals. */
95
309
  export declare function reviveBackgroundAgentLane(core: DurableAgentCore, id: string, access: TaskAccess, abort?: AbortController): Promise<{
96
310
  ok: true;
97
311
  cycle: number;
@@ -99,6 +313,8 @@ export declare function reviveBackgroundAgentLane(core: DurableAgentCore, id: st
99
313
  ok: false;
100
314
  reason: "not_found" | "still_running";
101
315
  }>;
316
+ /** S2b RB-27② — settle a REVIVED cycle (cycle-stamped: a stale cycle's late settle is a no-op so
317
+ * it can never flip a newer revived cycle back to terminal / clear its channel). */
102
318
  export declare function settleRevivedAgentLane(core: DurableAgentCore, id: string, cycle: number, outcome: {
103
319
  status: "completed" | "failed" | "killed";
104
320
  result?: string;
@@ -109,10 +325,48 @@ export declare function settleRevivedAgentLane(core: DurableAgentCore, id: strin
109
325
  errorKind?: string;
110
326
  retryAfterMs?: number;
111
327
  }): "completed" | "failed" | "killed" | undefined;
328
+ /**
329
+ * design/164 — record LIVE ACTIVITY on a running background-agent row (one tool-lifecycle beat).
330
+ *
331
+ * Why this exists: retiring `SESSION_BG_DEFAULT_TIMEOUT_SEC` removed the wall-clock ceiling that used to
332
+ * bound a session-scoped background child, and the design/129 F3 anti-zombie duty had to land somewhere
333
+ * that does not punish a legitimately long task. Collecting by STALL needs a stall signal, and the
334
+ * in-memory row had none: `updatedAt` moved only at registration / park / settle, so a child grinding
335
+ * through a two-hour job looked exactly like one whose lane died. This is that signal — the same
336
+ * tool-lifecycle beat the fleet view already samples, recorded on the row.
337
+ *
338
+ * Cheap and idempotent: a timestamp write on a running row, no-op for anything else.
339
+ */
112
340
  export declare function noteBackgroundAgentActivityLane(core: DurableAgentCore, id: string, now?: number): void;
341
+ /**
342
+ * design/164 — collect SESSION-SCOPED background agents that have gone SILENT, the replacement for the
343
+ * retired 30-minute wall-clock ceiling on that lane.
344
+ *
345
+ * By STALL, not by age, deliberately: the old ceiling killed a child at thirty minutes whether it was
346
+ * wedged or working, and "this task has run a long time" is not evidence of anything. `staleMs` is the
347
+ * caller's policy — there is no default here either, matching every other retention policy in this file
348
+ * (`maxAgeMs` / `keep` / `staleRunningMaxAgeMs` are all caller-supplied). Size it well above the child's
349
+ * expected quiet stretches; the durable twin's guidance (≥10× the heartbeat) is the reference point.
350
+ *
351
+ * A collected row is settled `killed` with attribution `"system"` and the SAME wording the durable
352
+ * stale-running sweep writes, so an operator reading either face sees one explanation, and its run is
353
+ * aborted. Returns how many rows were collected.
354
+ */
113
355
  export declare function reapStaleSessionBackgroundAgentsLane(core: DurableAgentCore, staleMs: number, now?: number, onTerminal?: (note: () => void) => void): number;
356
+ /** S2b codex R7 — retention is REVOCABLE: every retain-ledger eviction path (TTL / LRU / abandon /
357
+ * parent-teardown disposeAll) runs the entry's release closure, and the spawner wraps that closure
358
+ * to call this — so a park can never be acknowledged against a continuation that was already
359
+ * released (the write-once bit was a lie window during parent teardown). */
114
360
  export declare function unmarkRetainedContinuationLane(core: DurableAgentCore, id: string): void;
361
+ /** design/147 S2a — park a RUNNING child's live notification injector on its handle (called by the
362
+ * spawner once the child's lane binds). No-op for unknown / non-agent / already-terminal rows —
363
+ * the lane can outrace a fast child, and a stale attach must never resurrect a settled handle. */
115
364
  export declare function attachAgentNotifyLane(core: DurableAgentCore, id: string, notify: NonNullable<BackgroundAgentTaskHandle["notify"]>, cycle?: number): void;
365
+ /** design/147 S2a — deliver a message TO a RUNNING background agent at its next turn boundary
366
+ * (CC's in-memory pendingMessages pedestal). Access-checked like every registry verb; returns a
367
+ * typed refusal instead of throwing so the SendMessage face can phrase honestly:
368
+ * `not_running` (row isn't running any more — race with settle; caller re-reads status) or
369
+ * `no_channel` (running but its lane never attached — e.g. a non-core spawner). */
116
370
  export declare function deliverToRunningAgentLane(core: DurableAgentCore, id: string, access: TaskAccess, notification: import("./task-notification.js").TaskNotificationPayload, opts?: {
117
371
  priority?: import("./task-notification.js").SystemInjectionPriority;
118
372
  }): Promise<{
@@ -122,15 +376,50 @@ export declare function deliverToRunningAgentLane(core: DurableAgentCore, id: st
122
376
  ok: false;
123
377
  reason: "not_found" | "not_running" | "no_channel" | "queue_full";
124
378
  }>;
379
+ /** CC `ugo`/`rxo` (206:575227-575243 = 220:467937-467951): `id (label)` rows for a not-found footer —
380
+ * running bg agents the CALLER can address (canAccess scopes; CC's self/observer exclusions have no
381
+ * counterpart rows here). This variant is the SENDMESSAGE footer's source and lists EVERY running
382
+ * agent, named or not: SendMessage addresses by name AND by id, so dropping named rows here (the way
383
+ * {@link runningAgentFooterLane} does for the task faces, per CC `rxo`'s `!n.has(i.id)`) would hide the
384
+ * very rows a retry needs. The task faces' split lives in `runningAgentFooterLane` (RB-332). */
125
385
  export declare function runningBackgroundAgentLabelsLane(core: DurableAgentCore, access: TaskAccess): string[];
386
+ /**
387
+ * RB-332 — the not-found FOOTER's two rows, split the way CC 220 assembles them:
388
+ * - `named` = CC `uG_` (220:467941-467953): the agentNameRegistry's KEYS whose task is a running local
389
+ * agent, listed as BARE NAMES — the string a retry should pass verbatim. sema's counterpart
390
+ * of "has a registry entry" is the handle carrying an explicit `name` (spawn-time label),
391
+ * the same field TaskStop's name leg and SendMessage address by.
392
+ * - `background` = CC `rxo` (220:467937-467951): the remaining running background agents as `id (label)`
393
+ * rows. CC filters `!n.has(i.id)` — a NAMED agent is deliberately NOT repeated here, because
394
+ * its addressable form is the name, not the id. The pre-RB-332 sema code merged both legs
395
+ * into one list and justified it with "named has no counterpart", a claim [c209-D] retired
396
+ * when the explicit `name` field landed.
397
+ * CC's `YEd` "Running teammates:" leg has no sema counterpart (no teammate registry on this face) and is
398
+ * honestly absent rather than faked.
399
+ */
126
400
  export declare function runningAgentFooterLane(core: DurableAgentCore, access: TaskAccess): {
127
401
  named: string[];
128
402
  background: string[];
129
403
  };
404
+ /** RB-332/RB-333 — the not-found TAIL both task faces share (CC `rxo`, appended by `uMs` for TaskStop
405
+ * and by `xwd` 220:472095-472097 for TaskOutput). Empty string when the caller has nothing running. */
130
406
  export declare function notFoundRunningAgentsTail(footer: {
131
407
  named: string[];
132
408
  background: string[];
133
409
  }): string;
410
+ /** design/151 S1a (RB-425) — the SINGLE construction of a background-agent row's poll `details`. The
411
+ * live in-process poll ({@link pollBackgroundAgentLane}) and the cross-restart durable fallback
412
+ * ({@link serveDurableAgentRowLane}) must serve the IDENTICAL field set: that symmetry IS the S1a
413
+ * contract ("a consumer cannot tell a fallback read from a live one except by the row being older than
414
+ * the process"), and two hand-maintained object literals had already drifted — `error` was live-only,
415
+ * so a structured consumer lost the failure FACT at exactly the moment it could no longer reach the
416
+ * live handle, left to scrape the prose body's `error:` line.
417
+ *
418
+ * The status GATES live here too (killed ⇒ stoppedBy, failed ⇒ error/errorCode/retryable) rather than
419
+ * at the call sites: which facts a given status may carry is part of the same contract, and a gate
420
+ * copied per face is the same drift with extra steps. `error` is model/provider-influenceable text, so
421
+ * the fencing + bounding (RB-386②'s posture) happens once, here, for both faces.
422
+ * The parked projection is this builder with fewer facts, not a third literal. */
134
423
  export interface AgentPollDetailsInput {
135
424
  taskId: string;
136
425
  status: UnifiedTaskOutput["status"];
@@ -144,8 +433,55 @@ export interface AgentPollDetailsInput {
144
433
  resultIsPartial?: boolean;
145
434
  completionId?: string;
146
435
  }
436
+ /** PUBLIC (see the doc above): a serving layer that renders its own protocol projection of a row
437
+ * builds the structured facts HERE, so the status gates and the untrusted-text fencing apply to it
438
+ * too — a third literal is exactly the drift this builder exists to prevent. Input only; it reads no
439
+ * store and authorizes nothing, so the caller must already have passed the row through
440
+ * {@link import("./background-agent-store.js").canAccessAgentRecord}. */
147
441
  export declare function buildAgentPollDetails(input: AgentPollDetailsInput): UnifiedTaskOutput;
442
+ /** design/151 S1a — serve a TERMINAL durable row in the exact pollBackgroundAgent terminal shape
443
+ * (same body grammar, same details fields — {@link buildAgentPollDetails} is the shared source of
444
+ * the latter), so a consumer cannot tell a fallback read from a live one except by the row being
445
+ * older than the process.
446
+ *
447
+ * PUBLIC: a serving layer answering for a row whose writing process is gone renders it through THIS,
448
+ * not through a hand-written projection that would drift from the live poll's. It takes a row the
449
+ * caller has ALREADY read and authorized — it reads no store and applies no predicate, so a
450
+ * deployment passes every row through
451
+ * {@link import("./background-agent-store.js").canAccessAgentRecord} before it gets here. */
148
452
  export declare function serveDurableAgentRowLane(row: BackgroundAgentRecord): UnifiedTaskResult;
453
+ /**
454
+ * design/158 S1 (RB-205-B 半) — spill the FULL text behind a CLIPPED background_agent result to the
455
+ * offload store, and append a ref-disclosure so the middle `clipTaskOutput` drops is not gone for good.
456
+ * `RegisterBackgroundAgentInput` deliberately carries no `outputFile` (ref-not-path is the design/158
457
+ * §2.4 divergence — TOC/TOB compatible, unlike a local path), so this is the only pageback this lane
458
+ * gets; it reuses the SAME vocabulary as the offload face (design/108: {@link OFFLOAD_TOOL_NAME},
459
+ * {@link buildToolResultRef} — RB-273's single mint point) instead of inventing a parallel one.
460
+ *
461
+ * Lazy: only writes on the FIRST poll whose clip actually cut something (`clipped !== full`) — a short
462
+ * result never touches the store, matching design/158 §2.1 ("spill is a fidelity layer, not a new
463
+ * source of truth"). Idempotent PER REVIVE CYCLE: the ref folds in `handle.reviveCycle` (a revive clears
464
+ * `handle.spillRef` — see {@link reviveBackgroundAgentLane} — but `handle.id` itself does NOT change
465
+ * across a revive, so without the cycle in the ref, cycle 2's spill would mint the SAME ref string as
466
+ * cycle 1's and the store's write-once contract would silently keep cycle 1's STALE text under a ref
467
+ * now disclosed as cycle 2's current result). Caching the minted ref on the handle (rather than just
468
+ * re-deriving+re-`put`ting every poll and trusting the store's own write-once no-op) keeps the disclosed
469
+ * ref byte-stable across polls and avoids a redundant round-trip to a durable backend on every poll.
470
+ *
471
+ * No store configured (a deployment that never wired a `toolResultStore`) ⇒ returns `clipped` UNCHANGED
472
+ * — the legal degrade design/158 §2.2 calls for, byte-identical to pre-S1 behavior.
473
+ */
149
474
  export declare function spillClippedAgentResult(handle: BackgroundAgentTaskHandle, full: string, clipped: string, store: ToolResultStore | undefined, sessionId: string | undefined): Promise<string>;
150
- export declare function pollBackgroundAgentLane(handle: BackgroundAgentTaskHandle, deadline?: number, signal?: AbortSignal, oneShot?: boolean, store?: ToolResultStore, sessionId?: string): Promise<UnifiedTaskResult>;
475
+ export declare function pollBackgroundAgentLane(handle: BackgroundAgentTaskHandle, deadline?: number, signal?: AbortSignal,
476
+ /** RB-220 — mirrors {@link import("./types.js").TaskSpec.oneShot} (see
477
+ * {@link import("./task-registry.js").TaskToolOptions.oneShot} for the full contract): this run has
478
+ * no later turn for an async background notification to land in, so the still-running body must
479
+ * not teach "you will be notified when it completes". */
480
+ oneShot?: boolean,
481
+ /** design/158 S1 — the offload store a clipped result's full text spills to (see
482
+ * {@link spillClippedAgentResult}). Absent ⇒ legal degrade, byte-identical to pre-S1 output. */
483
+ store?: ToolResultStore,
484
+ /** design/158 S1 — the caller's session id, folded into the minted ref for global uniqueness (same
485
+ * role `sessionId` plays at every other {@link buildToolResultRef} call site). */
486
+ sessionId?: string): Promise<UnifiedTaskResult>;
151
487
  export declare function stopBackgroundAgentLane(core: DurableAgentCore, handle: BackgroundAgentTaskHandle): Promise<UnifiedTaskResult>;
@@ -1,4 +1,5 @@
1
1
  import { randomBytes } from "node:crypto";
2
+ import { assertRetentionPolicy } from "./retention-policy.js";
2
3
  import { uuidv7 } from "../internal/harness.js";
3
4
  import { canAccessAgentRecord, BackgroundAgentStoreError, clearRevivedRowTerminalPayload, REVIVED_ROW_CLEARED_FIELDS, STALE_RUNNING_REAP_ATTRIBUTION, } from "./background-agent-store.js";
4
5
  import { shutdownDebug } from "./shutdown-debug.js";
@@ -163,6 +164,7 @@ export function endDurableClaimLane(core, id) {
163
164
  core.claimingHandles.delete(id);
164
165
  }
165
166
  export async function reapDurableAgentsLane(core, scope, deps, policy) {
167
+ assertRetentionPolicy("reapDurableAgents", policy);
166
168
  const now = policy.now ?? Date.now();
167
169
  if (policy.staleRunningMaxAgeMs !== undefined) {
168
170
  await deps.store.reap(scope, now, { staleRunningMaxAgeMs: policy.staleRunningMaxAgeMs });
@@ -1,13 +1,25 @@
1
1
  import type { TaskNotificationPayload } from "./task-notification.js";
2
2
  import { type RegistryCore, type RegisterMonitorInput, type MonitorTaskHandle, type UnifiedTaskResult } from "./task-registry-shared.js";
3
3
  export declare function registerMonitorLane(core: RegistryCore, input: RegisterMonitorInput): string;
4
+ /** RB-239 ([1937] M2): ONE absorption arithmetic for a monitor poll — env-side-loss accounting
5
+ * (RB-238), the spool roll (registry memory bound) and the completed-line split — shared by the
6
+ * watcher tick and the stop-time final drain. A hand-copied twin in stopMonitor is how half-fixes
7
+ * happen: any change to the roll/line rules must reach both consumers through this method. Returns
8
+ * the COMPLETE lines (the newline-less tail stays in `lineBuf` for the next poll / terminal flush). */
4
9
  export declare function absorbMonitorPollLane(handle: MonitorTaskHandle, v: {
5
10
  stdout: string;
6
11
  stderr: string;
7
12
  truncated?: boolean;
8
13
  bytesDroppedBeforeCursor?: number;
9
14
  }): string[];
15
+ /** RB-239: the swallow-guarded event sink, shared by the watcher's emits and the stop-time drain. */
10
16
  export declare function emitMonitorEventLane(handle: MonitorTaskHandle, n: TaskNotificationPayload): void;
17
+ /** The monitor watcher tick loop. Same zombie-proofing discipline as {@link startBashWatcher}
18
+ * (re-entrancy guard / stop on eviction / stop on vanished shell / stop on a throwing adapter),
19
+ * plus the three monitor-only exits: watcher-enforced timeout, event-storm auto-stop, and the
20
+ * line→batched-event emission path. All time reads go through the INJECTED clock (design/87). */
11
21
  export declare function startMonitorWatcherLane(core: RegistryCore, id: string): void;
22
+ /** design/135 G2: TaskOutput over a monitor — a RE-READABLE spool snapshot (the watcher owns the env
23
+ * cursor, exactly the bash G2b spool posture): repeated polls return the same accumulated output. */
12
24
  export declare function pollMonitorLane(handle: MonitorTaskHandle, filter: string | undefined, deadline?: number, signal?: AbortSignal): Promise<UnifiedTaskResult>;
13
25
  export declare function stopMonitorLane(core: RegistryCore, handle: MonitorTaskHandle): Promise<UnifiedTaskResult>;