@sema-agent/server 1.322.0 → 2.0.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 (539) hide show
  1. package/dist/approval-hmac.d.ts +40 -0
  2. package/dist/approval-hmac.js +67 -0
  3. package/dist/approval.d.ts +31 -0
  4. package/dist/approval.js +72 -4
  5. package/dist/audit.d.ts +26 -0
  6. package/dist/audit.js +40 -1
  7. package/dist/auth-bridge.d.ts +10 -0
  8. package/dist/auth-bridge.js +47 -4
  9. package/dist/auth-keys.d.ts +19 -0
  10. package/dist/auth-keys.js +13 -0
  11. package/dist/bake-runner/main.d.ts +5 -0
  12. package/dist/bake-runner/main.js +43 -4
  13. package/dist/bake-runner/protocol.d.ts +57 -0
  14. package/dist/bake-runner/protocol.js +58 -3
  15. package/dist/bake-runner/runner.d.ts +54 -0
  16. package/dist/bake-runner/runner.js +87 -5
  17. package/dist/bench/l8/artifact.d.ts +63 -0
  18. package/dist/bench/l8/artifact.js +61 -2
  19. package/dist/bench/l8/escape.d.ts +36 -0
  20. package/dist/bench/l8/escape.js +25 -0
  21. package/dist/bench/l8/index.d.ts +14 -0
  22. package/dist/bench/l8/index.js +14 -0
  23. package/dist/bench/l8/probes.d.ts +74 -0
  24. package/dist/bench/l8/probes.js +60 -0
  25. package/dist/bench/l8/run-probes.d.ts +43 -0
  26. package/dist/bench/l8/run-probes.js +45 -2
  27. package/dist/bench/s1/arms.d.ts +126 -0
  28. package/dist/bench/s1/arms.js +188 -13
  29. package/dist/bench/s1/live-deps.d.ts +66 -0
  30. package/dist/bench/s1/live-deps.js +249 -11
  31. package/dist/bench/s1/oracle.d.ts +49 -0
  32. package/dist/bench/s1/oracle.js +36 -1
  33. package/dist/bench/s1/repair-oracle-adapter.d.ts +33 -0
  34. package/dist/bench/s1/repair-oracle-adapter.js +30 -0
  35. package/dist/bench/s1/reviewer.d.ts +38 -0
  36. package/dist/bench/s1/reviewer.js +34 -0
  37. package/dist/bench/s1/row.d.ts +77 -0
  38. package/dist/bench/s1/row.js +62 -0
  39. package/dist/bench/s1/run-firm.d.ts +47 -0
  40. package/dist/bench/s1/run-firm.js +70 -4
  41. package/dist/bench/s1/runner-ctx.d.ts +71 -0
  42. package/dist/bench/s1/runner-ctx.js +36 -0
  43. package/dist/bench/s1/tasks.d.ts +108 -0
  44. package/dist/bench/s1/tasks.js +115 -0
  45. package/dist/boot-reclaim.d.ts +19 -0
  46. package/dist/boot-reclaim.js +20 -0
  47. package/dist/brain.d.ts +25 -0
  48. package/dist/brain.js +61 -1
  49. package/dist/budget.d.ts +66 -0
  50. package/dist/budget.js +128 -4
  51. package/dist/capabilities/builtin-tools.d.ts +3 -0
  52. package/dist/capabilities/builtin-tools.js +3 -0
  53. package/dist/capabilities/center-plugins.d.ts +17 -1
  54. package/dist/capabilities/center-plugins.js +45 -4
  55. package/dist/capabilities/center-prompts.d.ts +46 -0
  56. package/dist/capabilities/center-prompts.js +57 -3
  57. package/dist/capabilities/code-review-council.d.ts +28 -0
  58. package/dist/capabilities/code-review-council.js +40 -7
  59. package/dist/capabilities/collab-wire.d.ts +2 -0
  60. package/dist/capabilities/collab-workflows.d.ts +7 -0
  61. package/dist/capabilities/collab-workflows.js +44 -1
  62. package/dist/capabilities/oa-tools.d.ts +6 -0
  63. package/dist/capabilities/oa-tools.js +10 -0
  64. package/dist/capabilities/prompt.d.ts +14 -0
  65. package/dist/capabilities/prompt.js +14 -0
  66. package/dist/capabilities/prompts/code-review.d.ts +14 -0
  67. package/dist/capabilities/prompts/code-review.js +14 -0
  68. package/dist/capabilities/prompts/identity.d.ts +6 -0
  69. package/dist/capabilities/prompts/identity.js +6 -0
  70. package/dist/capabilities/prompts/team.d.ts +4 -0
  71. package/dist/capabilities/prompts/team.js +4 -0
  72. package/dist/capabilities/repo-tools.d.ts +11 -0
  73. package/dist/capabilities/repo-tools.js +8 -0
  74. package/dist/capabilities/sandbox-file-send.d.ts +95 -0
  75. package/dist/capabilities/sandbox-file-send.js +91 -3
  76. package/dist/capabilities/scenarios.d.ts +130 -0
  77. package/dist/capabilities/scenarios.js +180 -7
  78. package/dist/capabilities/select-environment-tool.d.ts +7 -0
  79. package/dist/capabilities/select-environment-tool.js +30 -0
  80. package/dist/capabilities/send-user-file-tool.d.ts +33 -0
  81. package/dist/capabilities/send-user-file-tool.js +65 -1
  82. package/dist/capabilities/skills.d.ts +29 -0
  83. package/dist/capabilities/skills.js +13 -2
  84. package/dist/capabilities/team.d.ts +22 -0
  85. package/dist/capabilities/team.js +22 -2
  86. package/dist/capabilities/tool-defer.d.ts +26 -0
  87. package/dist/capabilities/tool-defer.js +3 -0
  88. package/dist/config-center/apply-effective.d.ts +65 -0
  89. package/dist/config-center/apply-effective.js +204 -12
  90. package/dist/config-center/http-client.d.ts +34 -0
  91. package/dist/config-center/http-client.js +68 -0
  92. package/dist/config-center/restart-signal.d.ts +22 -0
  93. package/dist/config-center/restart-signal.js +39 -0
  94. package/dist/config-center/skills-mcp.d.ts +20 -1
  95. package/dist/config-center/skills-mcp.js +42 -7
  96. package/dist/config-center/types.d.ts +92 -1
  97. package/dist/config-lkg.d.ts +12 -0
  98. package/dist/config-lkg.js +41 -0
  99. package/dist/config-provider.d.ts +78 -0
  100. package/dist/config-provider.js +165 -2
  101. package/dist/config-types.d.ts +546 -0
  102. package/dist/config.d.ts +64 -0
  103. package/dist/config.js +455 -60
  104. package/dist/degenerate-instrument.d.ts +38 -0
  105. package/dist/degenerate-instrument.js +55 -3
  106. package/dist/elicitation.d.ts +39 -0
  107. package/dist/elicitation.js +87 -3
  108. package/dist/env-facts.d.ts +61 -0
  109. package/dist/env-facts.js +73 -7
  110. package/dist/fleet/fleet-bus.d.ts +185 -0
  111. package/dist/fleet/fleet-bus.js +333 -27
  112. package/dist/fleet/subagent-tail-bus.d.ts +11 -0
  113. package/dist/fleet/subagent-tail-bus.js +33 -2
  114. package/dist/fleet-client.d.ts +38 -0
  115. package/dist/fleet-client.js +44 -9
  116. package/dist/fleet-lease.d.ts +46 -0
  117. package/dist/fleet-lease.js +73 -5
  118. package/dist/hooks/branch-transcript.d.ts +8 -0
  119. package/dist/hooks/branch-transcript.js +33 -0
  120. package/dist/hooks/cc-stop-prompt.d.ts +42 -0
  121. package/dist/hooks/cc-stop-prompt.js +43 -1
  122. package/dist/hooks/hook-llm.d.ts +15 -0
  123. package/dist/hooks/hook-llm.js +47 -0
  124. package/dist/hooks/hook-runner.d.ts +89 -0
  125. package/dist/hooks/hook-runner.js +327 -18
  126. package/dist/http/idempotency.d.ts +31 -0
  127. package/dist/http/idempotency.js +34 -0
  128. package/dist/http/principal-gate.d.ts +17 -0
  129. package/dist/http/principal-gate.js +35 -3
  130. package/dist/http/route-ctx.d.ts +36 -0
  131. package/dist/http/routes/approvals-assistant.d.ts +25 -0
  132. package/dist/http/routes/approvals-assistant.js +253 -23
  133. package/dist/http/routes/attachments.js +22 -4
  134. package/dist/http/routes/capabilities.d.ts +7 -0
  135. package/dist/http/routes/capabilities.js +202 -1
  136. package/dist/http/routes/fleet.d.ts +6 -0
  137. package/dist/http/routes/fleet.js +94 -5
  138. package/dist/http/routes/images.d.ts +17 -0
  139. package/dist/http/routes/images.js +222 -14
  140. package/dist/http/routes/leader.d.ts +7 -0
  141. package/dist/http/routes/leader.js +10 -0
  142. package/dist/http/routes/memory-policy.d.ts +6 -0
  143. package/dist/http/routes/memory-policy.js +38 -6
  144. package/dist/http/routes/notify-wake.d.ts +10 -0
  145. package/dist/http/routes/notify-wake.js +19 -3
  146. package/dist/http/routes/observability.d.ts +6 -0
  147. package/dist/http/routes/observability.js +19 -2
  148. package/dist/http/routes/runs.d.ts +15 -0
  149. package/dist/http/routes/runs.js +464 -41
  150. package/dist/http/routes/session-sync.d.ts +15 -0
  151. package/dist/http/routes/session-sync.js +229 -19
  152. package/dist/http/routes/sessions-list.d.ts +6 -0
  153. package/dist/http/routes/sessions-list.js +35 -4
  154. package/dist/http/routes/sessions.d.ts +14 -0
  155. package/dist/http/routes/sessions.js +176 -31
  156. package/dist/http/routes/side-query.d.ts +8 -0
  157. package/dist/http/routes/side-query.js +26 -1
  158. package/dist/http/routes/tasks.d.ts +18 -0
  159. package/dist/http/routes/tasks.js +501 -38
  160. package/dist/http/routes/trace-usage.d.ts +10 -0
  161. package/dist/http/routes/trace-usage.js +66 -14
  162. package/dist/http/routes/workflows.d.ts +12 -0
  163. package/dist/http/routes/workflows.js +180 -19
  164. package/dist/http/run-meta.d.ts +11 -0
  165. package/dist/http/run-meta.js +6 -0
  166. package/dist/http/send.d.ts +19 -0
  167. package/dist/http/send.js +11 -0
  168. package/dist/http/server.d.ts +255 -0
  169. package/dist/http/server.js +921 -75
  170. package/dist/http/sse-log.d.ts +15 -0
  171. package/dist/http/sse-log.js +16 -0
  172. package/dist/http/tar.d.ts +9 -0
  173. package/dist/http/tar.js +21 -5
  174. package/dist/http/wire-gate.d.ts +9 -0
  175. package/dist/http/wire-gate.js +9 -0
  176. package/dist/http/wire-types.d.ts +187 -0
  177. package/dist/http/workspace-content.d.ts +8 -0
  178. package/dist/http/workspace-content.js +10 -0
  179. package/dist/images/bake-validate.d.ts +63 -0
  180. package/dist/images/bake-validate.js +71 -1
  181. package/dist/images/manifest.d.ts +19 -0
  182. package/dist/images/manifest.js +6 -1
  183. package/dist/index.d.ts +1 -5
  184. package/dist/index.js +10 -5
  185. package/dist/key-resolver.d.ts +23 -0
  186. package/dist/key-resolver.js +27 -2
  187. package/dist/leader/diffout.d.ts +23 -0
  188. package/dist/leader/diffout.js +8 -1
  189. package/dist/leader/diffup.d.ts +32 -0
  190. package/dist/leader/diffup.js +43 -0
  191. package/dist/leader/endpoint.d.ts +20 -0
  192. package/dist/leader/endpoint.js +25 -2
  193. package/dist/leader/fanout.d.ts +60 -0
  194. package/dist/leader/fanout.js +29 -3
  195. package/dist/leader/grader-env-factory.d.ts +74 -0
  196. package/dist/leader/grader-env-factory.js +62 -3
  197. package/dist/leader/leader.d.ts +97 -0
  198. package/dist/leader/leader.js +151 -4
  199. package/dist/leader/merge.d.ts +94 -0
  200. package/dist/leader/merge.js +112 -9
  201. package/dist/leader/planner.d.ts +52 -0
  202. package/dist/leader/planner.js +47 -3
  203. package/dist/leader/repair-oracle.d.ts +61 -0
  204. package/dist/leader/repair-oracle.js +59 -1
  205. package/dist/leader/repair-wire.d.ts +78 -0
  206. package/dist/leader/repair-wire.js +79 -2
  207. package/dist/leader/wire.d.ts +79 -0
  208. package/dist/leader/wire.js +255 -8
  209. package/dist/lsp/e2b-bridge.d.ts +16 -0
  210. package/dist/lsp/e2b-bridge.js +32 -4
  211. package/dist/lsp/e2b-manager.d.ts +10 -0
  212. package/dist/lsp/e2b-manager.js +18 -2
  213. package/dist/lsp/lsp-frames.d.ts +12 -0
  214. package/dist/lsp/lsp-frames.js +12 -0
  215. package/dist/lsp/manager.d.ts +12 -0
  216. package/dist/lsp/manager.js +35 -2
  217. package/dist/lsp/types.d.ts +10 -0
  218. package/dist/lsp/ws-transport.d.ts +12 -0
  219. package/dist/lsp/ws-transport.js +53 -5
  220. package/dist/lsp-evict.d.ts +14 -0
  221. package/dist/lsp-evict.js +15 -1
  222. package/dist/main.js +2132 -96
  223. package/dist/memory-export.d.ts +1 -0
  224. package/dist/memory-export.js +4 -0
  225. package/dist/memory-scope.d.ts +49 -0
  226. package/dist/memory-scope.js +87 -4
  227. package/dist/memory-sync-client.d.ts +24 -0
  228. package/dist/memory-sync-client.js +41 -2
  229. package/dist/memory-sync.d.ts +23 -0
  230. package/dist/memory-sync.js +70 -1
  231. package/dist/model-select.d.ts +39 -0
  232. package/dist/model-select.js +42 -1
  233. package/dist/observability/cost-quota.d.ts +20 -0
  234. package/dist/observability/cost-quota.js +4 -0
  235. package/dist/observability/cost-taxonomy.d.ts +45 -0
  236. package/dist/observability/cost-taxonomy.js +34 -0
  237. package/dist/observability/logger.d.ts +1 -0
  238. package/dist/observability/logger.js +6 -0
  239. package/dist/observability/metrics.d.ts +13 -0
  240. package/dist/observability/metrics.js +63 -0
  241. package/dist/observability/otel-exporter.d.ts +9 -0
  242. package/dist/observability/otel-exporter.js +11 -3
  243. package/dist/observability/principal-context.d.ts +9 -0
  244. package/dist/observability/principal-context.js +9 -0
  245. package/dist/observability/prompt-manifest.d.ts +37 -0
  246. package/dist/observability/prompt-manifest.js +35 -1
  247. package/dist/observability/rate-limit.d.ts +10 -0
  248. package/dist/observability/rate-limit.js +1 -0
  249. package/dist/observability/tool-trace.d.ts +24 -0
  250. package/dist/observability/tool-trace.js +41 -1
  251. package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
  252. package/dist/orchestration/hardened-vm-runner.js +119 -4
  253. package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
  254. package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
  255. package/dist/orchestration/hardened-vm-worker.js +27 -0
  256. package/dist/orchestration/subagent-steer.d.ts +44 -0
  257. package/dist/orchestration/subagent-steer.js +45 -1
  258. package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
  259. package/dist/orchestration/workflow-agent-steer.js +80 -1
  260. package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
  261. package/dist/orchestration/workflow-completion-inbox.js +283 -32
  262. package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
  263. package/dist/orchestration/workflow-notify-journal.js +187 -13
  264. package/dist/parked-decide.d.ts +61 -0
  265. package/dist/parked-decide.js +58 -1
  266. package/dist/per-task-image.d.ts +54 -0
  267. package/dist/per-task-image.js +41 -0
  268. package/dist/plan-cache-probe.d.ts +35 -0
  269. package/dist/plan-cache-probe.js +18 -3
  270. package/dist/plugins/approval-exemption-store.d.ts +7 -0
  271. package/dist/plugins/approval-exemption-store.js +28 -2
  272. package/dist/plugins/approval-store-sql.d.ts +64 -0
  273. package/dist/plugins/approval-store-sql.js +32 -0
  274. package/dist/plugins/background-agent-store-sql.d.ts +55 -0
  275. package/dist/plugins/background-agent-store-sql.js +91 -4
  276. package/dist/plugins/background-shell-support.d.ts +98 -0
  277. package/dist/plugins/background-shell-support.js +117 -13
  278. package/dist/plugins/blob-backend.d.ts +104 -0
  279. package/dist/plugins/blob-backend.js +163 -6
  280. package/dist/plugins/breaker-state-sql.d.ts +65 -1
  281. package/dist/plugins/breaker-state-sql.js +46 -8
  282. package/dist/plugins/caching-session-store.d.ts +42 -0
  283. package/dist/plugins/caching-session-store.js +63 -3
  284. package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
  285. package/dist/plugins/checkpoint-store-sql.js +239 -11
  286. package/dist/plugins/file-outcome-sink.d.ts +4 -0
  287. package/dist/plugins/file-outcome-sink.js +9 -0
  288. package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
  289. package/dist/plugins/file-resume-anchor-store.js +43 -4
  290. package/dist/plugins/file-run-store.d.ts +90 -0
  291. package/dist/plugins/file-run-store.js +145 -13
  292. package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
  293. package/dist/plugins/file-snapshot-store-sql.js +178 -10
  294. package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
  295. package/dist/plugins/file-workflow-journal-store.js +10 -0
  296. package/dist/plugins/fork-routing-session-store.d.ts +47 -0
  297. package/dist/plugins/fork-routing-session-store.js +51 -3
  298. package/dist/plugins/host-platform.d.ts +69 -0
  299. package/dist/plugins/host-platform.js +81 -2
  300. package/dist/plugins/image-bake-store-sql.d.ts +136 -1
  301. package/dist/plugins/image-bake-store-sql.js +241 -7
  302. package/dist/plugins/image-index-sql.d.ts +46 -0
  303. package/dist/plugins/image-index-sql.js +113 -4
  304. package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
  305. package/dist/plugins/k8s-bg-scripts.js +88 -4
  306. package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
  307. package/dist/plugins/k8s-exec-protocol.js +41 -0
  308. package/dist/plugins/local-checkpoint-store.d.ts +40 -0
  309. package/dist/plugins/local-checkpoint-store.js +86 -7
  310. package/dist/plugins/local-session-store.d.ts +157 -0
  311. package/dist/plugins/local-session-store.js +289 -34
  312. package/dist/plugins/local-task-attachment-store.js +14 -2
  313. package/dist/plugins/mailbox-store-sql.d.ts +38 -0
  314. package/dist/plugins/mailbox-store-sql.js +39 -6
  315. package/dist/plugins/memory-engine-pg.d.ts +30 -0
  316. package/dist/plugins/memory-engine-pg.js +122 -4
  317. package/dist/plugins/memory-engine-tidb.d.ts +26 -0
  318. package/dist/plugins/memory-engine-tidb.js +115 -5
  319. package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
  320. package/dist/plugins/memory-engine-vector-util.js +5 -0
  321. package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
  322. package/dist/plugins/memory-resume-anchor-store.js +17 -0
  323. package/dist/plugins/memory-run-store.d.ts +63 -0
  324. package/dist/plugins/memory-run-store.js +73 -8
  325. package/dist/plugins/memory-session-policy-store.d.ts +17 -0
  326. package/dist/plugins/memory-session-policy-store.js +17 -0
  327. package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
  328. package/dist/plugins/memory-sync-store-pg.js +45 -2
  329. package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
  330. package/dist/plugins/memory-sync-store-tidb.js +31 -1
  331. package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
  332. package/dist/plugins/outcome-ledger-sql.js +97 -3
  333. package/dist/plugins/pg-approval-store.d.ts +7 -0
  334. package/dist/plugins/pg-approval-store.js +7 -0
  335. package/dist/plugins/pg-breaker-state.d.ts +6 -0
  336. package/dist/plugins/pg-breaker-state.js +6 -0
  337. package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
  338. package/dist/plugins/pg-checkpoint-store.js +8 -0
  339. package/dist/plugins/pg-cost-quota.d.ts +17 -0
  340. package/dist/plugins/pg-cost-quota.js +6 -0
  341. package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
  342. package/dist/plugins/pg-file-snapshot-store.js +6 -0
  343. package/dist/plugins/pg-image-bake.d.ts +9 -0
  344. package/dist/plugins/pg-image-bake.js +9 -0
  345. package/dist/plugins/pg-image-index.d.ts +9 -0
  346. package/dist/plugins/pg-image-index.js +9 -0
  347. package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
  348. package/dist/plugins/pg-outcome-ledger.js +9 -0
  349. package/dist/plugins/pg-pool.d.ts +50 -0
  350. package/dist/plugins/pg-pool.js +78 -0
  351. package/dist/plugins/pg-query.d.ts +11 -0
  352. package/dist/plugins/pg-rate-limiter.d.ts +23 -0
  353. package/dist/plugins/pg-rate-limiter.js +12 -2
  354. package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
  355. package/dist/plugins/pg-resume-anchor-store.js +5 -0
  356. package/dist/plugins/pg-run-store.d.ts +7 -0
  357. package/dist/plugins/pg-run-store.js +7 -0
  358. package/dist/plugins/pg-safe-json.d.ts +13 -0
  359. package/dist/plugins/pg-safe-json.js +40 -4
  360. package/dist/plugins/pg-session-policy-store.d.ts +5 -0
  361. package/dist/plugins/pg-session-policy-store.js +5 -0
  362. package/dist/plugins/pg-session-storage.d.ts +72 -0
  363. package/dist/plugins/pg-session-storage.js +152 -20
  364. package/dist/plugins/pg-session-store.d.ts +10 -0
  365. package/dist/plugins/pg-session-store.js +10 -0
  366. package/dist/plugins/pg-tool-result-store.d.ts +7 -0
  367. package/dist/plugins/pg-tool-result-store.js +7 -0
  368. package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
  369. package/dist/plugins/pg-workflow-journal-store.js +7 -0
  370. package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
  371. package/dist/plugins/pg-workflow-run-store.js +7 -0
  372. package/dist/plugins/posix-shell-fs.d.ts +3 -0
  373. package/dist/plugins/posix-shell-fs.js +31 -1
  374. package/dist/plugins/remote-env-adb.d.ts +25 -0
  375. package/dist/plugins/remote-env-adb.js +95 -12
  376. package/dist/plugins/remote-env-e2b.d.ts +146 -0
  377. package/dist/plugins/remote-env-e2b.js +371 -40
  378. package/dist/plugins/remote-env-file-error.d.ts +34 -0
  379. package/dist/plugins/remote-env-file-error.js +37 -0
  380. package/dist/plugins/remote-env-host.d.ts +151 -0
  381. package/dist/plugins/remote-env-host.js +468 -70
  382. package/dist/plugins/remote-env-k8s.d.ts +135 -0
  383. package/dist/plugins/remote-env-k8s.js +318 -32
  384. package/dist/plugins/remote-env-local-docker.d.ts +65 -0
  385. package/dist/plugins/remote-env-local-docker.js +149 -24
  386. package/dist/plugins/remote-env-ssh.d.ts +35 -0
  387. package/dist/plugins/remote-env-ssh.js +117 -20
  388. package/dist/plugins/remote-scratchpad.d.ts +38 -0
  389. package/dist/plugins/remote-scratchpad.js +32 -2
  390. package/dist/plugins/remote-shell.d.ts +22 -0
  391. package/dist/plugins/remote-shell.js +27 -1
  392. package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
  393. package/dist/plugins/resume-anchor-store-sql.js +11 -0
  394. package/dist/plugins/roster-store-sql.d.ts +27 -0
  395. package/dist/plugins/roster-store-sql.js +54 -0
  396. package/dist/plugins/run-store-sql.d.ts +194 -0
  397. package/dist/plugins/run-store-sql.js +210 -9
  398. package/dist/plugins/s3-presign.d.ts +20 -0
  399. package/dist/plugins/s3-presign.js +49 -2
  400. package/dist/plugins/scheduler-support.d.ts +12 -0
  401. package/dist/plugins/scheduler-support.js +75 -3
  402. package/dist/plugins/send-file-ledger.d.ts +15 -0
  403. package/dist/plugins/send-file-ledger.js +53 -4
  404. package/dist/plugins/send-user-file.d.ts +77 -0
  405. package/dist/plugins/send-user-file.js +92 -4
  406. package/dist/plugins/session-policy-store-sql.d.ts +15 -0
  407. package/dist/plugins/session-policy-store-sql.js +75 -3
  408. package/dist/plugins/session-store.d.ts +45 -0
  409. package/dist/plugins/session-store.js +51 -0
  410. package/dist/plugins/sql-driver.d.ts +77 -0
  411. package/dist/plugins/sql-driver.js +4 -0
  412. package/dist/plugins/sql-escape.d.ts +8 -0
  413. package/dist/plugins/sql-escape.js +8 -0
  414. package/dist/plugins/sql-row-helpers.d.ts +25 -0
  415. package/dist/plugins/sql-row-helpers.js +25 -0
  416. package/dist/plugins/store-backend.d.ts +103 -0
  417. package/dist/plugins/store-backend.js +120 -27
  418. package/dist/plugins/store-contracts.d.ts +62 -0
  419. package/dist/plugins/store-contracts.js +3 -0
  420. package/dist/plugins/task-attachment-store.d.ts +60 -0
  421. package/dist/plugins/task-attachment-store.js +49 -3
  422. package/dist/plugins/task-list-store-sql.d.ts +25 -0
  423. package/dist/plugins/task-list-store-sql.js +21 -0
  424. package/dist/plugins/tidb-approval-store.d.ts +6 -0
  425. package/dist/plugins/tidb-approval-store.js +6 -0
  426. package/dist/plugins/tidb-breaker-state.d.ts +5 -0
  427. package/dist/plugins/tidb-breaker-state.js +5 -0
  428. package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
  429. package/dist/plugins/tidb-checkpoint-store.js +7 -0
  430. package/dist/plugins/tidb-cost-quota.d.ts +6 -0
  431. package/dist/plugins/tidb-cost-quota.js +1 -0
  432. package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
  433. package/dist/plugins/tidb-file-snapshot-store.js +6 -0
  434. package/dist/plugins/tidb-image-bake.d.ts +8 -0
  435. package/dist/plugins/tidb-image-bake.js +8 -0
  436. package/dist/plugins/tidb-image-index.d.ts +8 -0
  437. package/dist/plugins/tidb-image-index.js +8 -0
  438. package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
  439. package/dist/plugins/tidb-outcome-ledger.js +10 -0
  440. package/dist/plugins/tidb-pool.d.ts +56 -0
  441. package/dist/plugins/tidb-pool.js +181 -1
  442. package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
  443. package/dist/plugins/tidb-rate-limiter.js +5 -2
  444. package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
  445. package/dist/plugins/tidb-resume-anchor-store.js +5 -0
  446. package/dist/plugins/tidb-run-store.d.ts +7 -0
  447. package/dist/plugins/tidb-run-store.js +7 -0
  448. package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
  449. package/dist/plugins/tidb-session-policy-store.js +5 -0
  450. package/dist/plugins/tidb-session-storage.d.ts +43 -0
  451. package/dist/plugins/tidb-session-storage.js +62 -3
  452. package/dist/plugins/tidb-session-store.d.ts +142 -0
  453. package/dist/plugins/tidb-session-store.js +264 -16
  454. package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
  455. package/dist/plugins/tidb-tool-result-store.js +7 -0
  456. package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
  457. package/dist/plugins/tidb-workflow-journal-store.js +7 -0
  458. package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
  459. package/dist/plugins/tidb-workflow-run-store.js +8 -0
  460. package/dist/plugins/tool-result-store-sql.d.ts +58 -0
  461. package/dist/plugins/tool-result-store-sql.js +38 -2
  462. package/dist/plugins/web-search.d.ts +35 -0
  463. package/dist/plugins/web-search.js +45 -9
  464. package/dist/plugins/workflow-journal-limits.d.ts +10 -0
  465. package/dist/plugins/workflow-journal-limits.js +10 -0
  466. package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
  467. package/dist/plugins/workflow-journal-store-sql.js +59 -3
  468. package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
  469. package/dist/plugins/workflow-run-store-sql.js +84 -6
  470. package/dist/plugins/worktree-isolation.d.ts +45 -0
  471. package/dist/plugins/worktree-isolation.js +105 -6
  472. package/dist/plugins/write-behind-counter.d.ts +56 -1
  473. package/dist/plugins/write-behind-counter.js +53 -14
  474. package/dist/principal-jwt.d.ts +24 -0
  475. package/dist/principal-jwt.js +60 -5
  476. package/dist/project-memory.d.ts +22 -0
  477. package/dist/project-memory.js +144 -15
  478. package/dist/prompts-domain-validate.d.ts +28 -0
  479. package/dist/prompts-domain-validate.js +42 -1
  480. package/dist/question.d.ts +33 -0
  481. package/dist/question.js +69 -2
  482. package/dist/resource-suspend.d.ts +21 -0
  483. package/dist/resource-suspend.js +16 -0
  484. package/dist/router/route-orchestration.d.ts +78 -0
  485. package/dist/router/route-orchestration.js +77 -0
  486. package/dist/run-local.d.ts +32 -0
  487. package/dist/run-local.js +172 -8
  488. package/dist/runs.d.ts +189 -4
  489. package/dist/runs.js +465 -24
  490. package/dist/runtime-caps-resolver.d.ts +106 -0
  491. package/dist/runtime-caps-resolver.js +89 -4
  492. package/dist/runtime-governance.d.ts +84 -0
  493. package/dist/runtime-governance.js +127 -1
  494. package/dist/sandbox-pkg-source.d.ts +23 -0
  495. package/dist/sandbox-pkg-source.js +37 -0
  496. package/dist/sealed-key.d.ts +54 -0
  497. package/dist/sealed-key.js +68 -3
  498. package/dist/security.d.ts +108 -0
  499. package/dist/security.js +145 -6
  500. package/dist/sema-registry.d.ts +21 -0
  501. package/dist/sema-registry.js +21 -0
  502. package/dist/session-leaf-bus.d.ts +31 -0
  503. package/dist/session-leaf-bus.js +32 -0
  504. package/dist/session-sync-content.d.ts +46 -0
  505. package/dist/session-sync-content.js +47 -1
  506. package/dist/session-sync-kernel.d.ts +89 -0
  507. package/dist/session-sync-kernel.js +48 -3
  508. package/dist/session-sync.d.ts +125 -0
  509. package/dist/session-sync.js +181 -8
  510. package/dist/session-titler.d.ts +26 -0
  511. package/dist/session-titler.js +41 -7
  512. package/dist/session-watch.d.ts +53 -1
  513. package/dist/session-watch.js +73 -9
  514. package/dist/sighup-idle.d.ts +30 -0
  515. package/dist/sighup-idle.js +12 -1
  516. package/dist/spec-fields.d.ts +91 -3
  517. package/dist/spec-fields.js +116 -4
  518. package/dist/task-cwd.d.ts +50 -0
  519. package/dist/task-cwd.js +68 -1
  520. package/dist/task-mcp.d.ts +47 -0
  521. package/dist/task-mcp.js +29 -0
  522. package/dist/task-settings.d.ts +175 -0
  523. package/dist/task-settings.js +226 -11
  524. package/dist/task-workflow.d.ts +67 -0
  525. package/dist/task-workflow.js +75 -8
  526. package/dist/tool-approval.d.ts +91 -0
  527. package/dist/tool-approval.js +215 -0
  528. package/dist/trace/artifacts.d.ts +9 -0
  529. package/dist/trace/artifacts.js +30 -5
  530. package/dist/trace/core-keyset-guard.d.ts +18 -0
  531. package/dist/trace/ledger-sink.d.ts +43 -0
  532. package/dist/trace/ledger-sink.js +64 -5
  533. package/dist/trace/project.d.ts +133 -0
  534. package/dist/trace/project.js +189 -2
  535. package/dist/trace/redact.d.ts +19 -0
  536. package/dist/trace/redact.js +66 -9
  537. package/dist/usage-analytics.d.ts +26 -0
  538. package/dist/usage-analytics.js +26 -3
  539. package/package.json +1 -1
package/dist/env-facts.js CHANGED
@@ -1,11 +1,29 @@
1
+ /**
2
+ * RFC A1 (docs/design/ENV-SELECT-AND-REGION-SOURCE.md) — the sandbox envFacts composer (service 半场).
3
+ * Shape ratified REV-1: `TaskSpec.envFacts?: { profile?, capabilities?[], pkgSource?, egress? }`.
4
+ * Core injects it into model context (escape+bound core-side); this module only COMPOSES the facts
5
+ * from deployment-trusted sources (image catalog entry + operator region config + exec-lane posture).
6
+ *
7
+ * Values are bounded here too (defense-in-depth, cheap): catalog data is trusted, but a hostile row must not
8
+ * become an unbounded prompt segment. Wire-up is flag-gated OFF until core lands the whitelist field
9
+ * (`SANDBOX_ENV_FACTS=true` — flipping early is inert: core ignores unknown spec fields).
10
+ */
1
11
  import { isAbsolute, join, resolve, sep } from "node:path";
2
12
  import { mkdir, readdir, rm, stat } from "node:fs/promises";
3
13
  import { createHash } from "node:crypto";
4
14
  const MAX_STR = 64;
5
15
  const MAX_CAPS = 16;
16
+ /** scratchpadDir gets its own cap: TRUNCATING a path points at a non-existent dir (worse than absence), so an
17
+ * over-long path DROPS the whole field instead. The threshold is aligned to core's RENDER limit (codex F4):
18
+ * core's buildScratchpadSection inlines the path via `inlineUntrusted` whose default cap is 160 CODE POINTS
19
+ * (untrusted-text LABEL_MAX) — a 161+ char path would be truncated with "…" in the prompt, i.e. the model would
20
+ * be handed a FAKE path. So any path core cannot render verbatim is omitted entirely (honest-facts). */
6
21
  const MAX_PATH = 160;
7
22
  const bound = (s) => (s.length > MAX_STR ? s.slice(0, MAX_STR) : s);
23
+ /** resumeFacts.note 是整句(64 截会砍在半句上);对齐 MAX_PATH 的 160 render 上限。 */
8
24
  const bound2 = (s) => (s.length > MAX_PATH ? s.slice(0, MAX_PATH) : s);
25
+ /** Compose envFacts from what the deployment knows at spec-prep. Returns undefined when nothing is known
26
+ * (no fact beats a vacuous one — an empty block would still spend prompt tokens). */
9
27
  export function buildEnvFacts(opts) {
10
28
  const caps = Object.entries(opts.capabilities ?? {})
11
29
  .filter(([, v]) => v === true)
@@ -23,6 +41,11 @@ export function buildEnvFacts(opts) {
23
41
  };
24
42
  return Object.keys(facts).length > 0 ? facts : undefined;
25
43
  }
44
+ /** resumeFacts 按车道能力面的单真源(部署静态;undefined=整域不声明)。取值依据见
45
+ * {@link SandboxEnvFacts.resumeFacts} 的逐车道注。
46
+ * codex 复审 medium:k8s 必须按**有效快照能力**分叉,不能只看车道名——s3Snapshot 未配=park-only,
47
+ * resume 是全新 pod 且**工作区不恢复**,「文件已从快照恢复」那句会让模型信赖不存在的文件(比缺席
48
+ * 更糟的谎)。 */
26
49
  export function resumeFactsForLane(provider, caps) {
27
50
  switch (provider) {
28
51
  case "e2b":
@@ -35,20 +58,39 @@ export function resumeFactsForLane(provider, caps) {
35
58
  case "adb":
36
59
  return { scratch: "preserved" };
37
60
  case "host":
38
- case undefined:
61
+ case undefined: // provider unset = in-process host lane
39
62
  return { scratch: "preserved" };
40
63
  default:
41
- return undefined;
64
+ return undefined; // local-docker:容器跨 leg 存续不保证——不知道的不说
42
65
  }
43
66
  }
67
+ // ── [820]③ scratchpad directory(single source for the FACT and the future exemptDirs)──────────────
68
+ /** Path-safe session segment: the session id can be CALLER-SUPPLIED (body.sessionId), so it must not be able to
69
+ * walk the tree ("../", separators, control bytes). Allowlist [A-Za-z0-9_-] (dots excluded so ".." cannot
70
+ * survive), everything else becomes "_". Empty after sanitize → "_".
71
+ *
72
+ * INJECTIVITY (codex F3): allowlist sanitization alone is NOT injective — "team/a" and "team?a" both map to
73
+ * "team_a", so two DIFFERENT sessions (possibly different principals) would collide onto ONE scratchpad dir.
74
+ * The segment is therefore `<readable prefix (sanitized, ≤24)>-<sha256(FULL ORIGINAL sessionId) hex ≤16>`:
75
+ * the hash is over the raw pre-sanitize id, so distinct ids always produce distinct segments (the prefix stays
76
+ * purely for human readability). Max length 24+1+16=41 (uuidv7 = 36 raw). */
44
77
  export function scratchpadSessionSegment(sessionId) {
45
78
  const cleaned = sessionId.replace(/[^A-Za-z0-9_-]/g, "_").slice(0, 24);
46
79
  const digest = createHash("sha256").update(sessionId).digest("hex").slice(0, 16);
47
80
  return `${cleaned.length > 0 ? cleaned : "_"}-${digest}`;
48
81
  }
82
+ /** THE scratchpad path convention: `<localDataRoot>/scratchpad/<sessionSegment>`. Session-scoped (core's
83
+ * prompt says "session-specific" — every task on the session shares one dir, which is the useful semantics:
84
+ * intermediate artifacts survive across turns/resume legs). Exported as the single source both the envFacts
85
+ * composer (below) and the future createFsWriteGatePolicy `exemptDirs` wiring ([820]①, 1.290) must use. */
49
86
  export function scratchpadDirFor(localDataRoot, sessionId) {
50
87
  return join(localDataRoot, "scratchpad", scratchpadSessionSegment(sessionId));
51
88
  }
89
+ /** Resolve + CREATE the session scratchpad dir (mkdir -p, idempotent). Returns the path, or undefined when
90
+ * creation fails (honest-facts posture: never advertise a directory that does not exist — same class as
91
+ * egress/pkgSource "don't declare what you don't know"). Lifecycle: the reaper primitives live below —
92
+ * {@link purgeScratchpadDir}(session delete)+ {@link sweepStaleScratchpads}(mtime 周期扫),keyed by the
93
+ * same scratchpadDirFor convention;接线(E21 DELETE purge + 周期 sweep)在 main.ts 侧(D 组)。 */
52
94
  export async function ensureScratchpadDir(localDataRoot, sessionId) {
53
95
  const dir = scratchpadDirFor(localDataRoot, sessionId);
54
96
  try {
@@ -59,9 +101,22 @@ export async function ensureScratchpadDir(localDataRoot, sessionId) {
59
101
  return undefined;
60
102
  }
61
103
  }
104
+ /** G3([816] 壳侧承诺③/[820]③,[1840]§四接单):**壳供** scratchpad 路径的验收门。
105
+ *
106
+ * 壳(cli)vendored getScratchpadDir 算出 per-session scratchpad 路径随 `TaskRequest.scratchpadDir` 发来;
107
+ * 接受后它**优先于** server 自算(ensureScratchpadDir),喂 main.ts 的同一单点(envFacts 事实 +
108
+ * fs-write gate exemptDirs + additionalDirectories 根围栏)。「没到货引擎忽略 = 无害 additive」。
109
+ *
110
+ * 信任边界:这是 exemptDirs **放宽**输入,验收 fail-closed(任何拒收形回落自算,不 fault 任务):
111
+ * - 多租户(requirePrincipal)一律拒——共享 worker 盘上租户自选豁免目录=越权面;
112
+ * - 仅 host-semantics lane——远程沙箱 lane 的 worker 本机路径对 hands 是谎言(honest-facts 同轴);
113
+ * - 绝对路径 + ≤{@link MAX_PATH}(core 渲染上限同源,超限=core 只能给模型假路径)+ canonical
114
+ * 深度 ≥3(裸 /、/tmp、/home 一整块系统目录不能当豁免域;穿越形按 resolve 归一后判);
115
+ * - mkdir -p 确保存在(gate 的 canonicalize 与 core 根围栏都要真目录)。
116
+ * 敏感路径的最后一道在 core gate 折叠里(sensitivePatterns deny 恒赢,exemptDirs 越不过)。 */
62
117
  export async function acceptShellScratchpadDir(raw, opts) {
63
118
  if (typeof raw !== "string" || raw.length === 0)
64
- return undefined;
119
+ return undefined; // additive 常态:键缺席/异形,零告警
65
120
  if (opts.requirePrincipal) {
66
121
  opts.warn("shell_scratchpad_ignored", { reason: "multi_tenant", note: "tenant-supplied exempt dir on a shared worker disk — server-computed scratchpad used instead" });
67
122
  return undefined;
@@ -79,6 +134,7 @@ export async function acceptShellScratchpadDir(raw, opts) {
79
134
  return undefined;
80
135
  }
81
136
  const canonical = resolve(raw);
137
+ // 深度 = 根后的非空路径段数;<3 即一整块系统级目录(/、/tmp、/home/x 之类),不能当写门豁免域。
82
138
  const depth = canonical.split(sep).filter((s) => s.length > 0).length;
83
139
  if (depth < 3) {
84
140
  opts.warn("shell_scratchpad_ignored", { reason: "too_shallow", canonical });
@@ -93,15 +149,23 @@ export async function acceptShellScratchpadDir(raw, opts) {
93
149
  return undefined;
94
150
  }
95
151
  }
152
+ // ── 三路复审修4:scratchpad 清理原语(此前 deferred 注释=无 reap 无界增长;这里只出原语,
153
+ // D 组把它们接到 E21 DELETE purge 与周期 sweep——签名即 seam,勿改名/改形)──────────────────────
154
+ /** 删除一个 session 的 scratchpad 目录(rm -rf,幂等:目录不存在=no-op)。失败吞 warn 不抛——
155
+ * 清理绝不 fault 调用它的 session-delete 路径;下一轮 {@link sweepStaleScratchpads} 仍会兜到它。 */
96
156
  export async function purgeScratchpadDir(localDataRoot, sessionId) {
97
157
  const dir = scratchpadDirFor(localDataRoot, sessionId);
98
158
  try {
99
- await rm(dir, { recursive: true, force: true });
159
+ await rm(dir, { recursive: true, force: true }); // force: ENOENT 静默=幂等
100
160
  }
101
161
  catch (err) {
102
162
  console.warn(`scratchpad_purge_failed dir=${dir}: ${err instanceof Error ? err.message : String(err)}`);
103
163
  }
104
164
  }
165
+ /** 周期 sweep:扫 `<localDataRoot>/scratchpad/` 下 mtime 早于 `olderThanMs` 且不属于 `activeSessionIds`
166
+ * (先经 {@link scratchpadSessionSegment} 映射到目录名域)的目录并删除,返回删除数。逐目录失败跳过
167
+ * (下一轮再兜);scratchpad 根不存在=0。mtime 取目录自身(子文件写入会碰父目录 mtime 的语义因平台而异
168
+ * ——诚实边界:一个只被读的活跃 session 目录可能被判过期,activeSessionIds 排除面才是活会话的真保险)。 */
105
169
  export async function sweepStaleScratchpads(localDataRoot, opts) {
106
170
  const root = join(localDataRoot, "scratchpad");
107
171
  let names;
@@ -109,7 +173,7 @@ export async function sweepStaleScratchpads(localDataRoot, opts) {
109
173
  names = await readdir(root);
110
174
  }
111
175
  catch {
112
- return 0;
176
+ return 0; // 根未建(还没任何 session 用过 scratchpad)= 无事可扫
113
177
  }
114
178
  const activeSegments = new Set([...(opts.activeSessionIds ?? [])].map((id) => scratchpadSessionSegment(id)));
115
179
  const cutoff = Date.now() - opts.olderThanMs;
@@ -126,17 +190,19 @@ export async function sweepStaleScratchpads(localDataRoot, opts) {
126
190
  removed++;
127
191
  }
128
192
  catch {
193
+ /* 单目录 stat/rm 失败(并发删除/权限)→ 跳过,本轮不计数 */
129
194
  }
130
195
  }
131
196
  return removed;
132
197
  }
198
+ /** Map the exec-lane posture to the egress fact (the model must know when downloads can't work). */
133
199
  export function egressForRemoteExec(remoteExec) {
134
200
  if (!remoteExec?.provider)
135
201
  return undefined;
136
202
  if (remoteExec.provider === "e2b")
137
203
  return remoteExec.allowInternetAccess === false ? "none" : "full";
138
204
  if (remoteExec.provider === "k8s")
139
- return "full";
140
- return undefined;
205
+ return "full"; // kata pods egress via the cluster CNI (no allowlist face yet)
206
+ return undefined; // host/ssh/adb: the deployment hasn't declared a posture — say nothing rather than guess
141
207
  }
142
208
  //# sourceMappingURL=env-facts.js.map
@@ -1,28 +1,94 @@
1
+ /** The fleet vocabulary the shell renders (MF-Fleet `FleetTask.status`). The service maps its run/workflow status
2
+ * onto this neutral set; `awaiting approval` = a needs-review/plan-approval park, `waiting` = a durable suspend.
3
+ *
4
+ * §K-7 (shell ASK 2026-06-28) asked for a `report_blocked` / `nesting` status extension to hide blocked internal-
5
+ * nesting agents from the picker. DELIBERATELY NOT EXTENDED — the need is already met without breaking the
6
+ * SDK byte-alignment (`@sema-agent/sdk` 0.0.39 keeps this exact 9-value set, and the SDK explicitly declined to add
7
+ * one unilaterally, awaiting a service decision): (1) `report_blocked` = a TERMINAL outcome (the agent gave up) →
8
+ * `runStatusToFleet("blocked")→"failed"` → the row is REMOVED (onTerminal), so a blocked agent never lingers in
9
+ * the picker (the leaked-stale-blocked-row bug that triggered the ask was fixed in 1.11.0); (2) "internal nesting"
10
+ * is already expressible — every subagent CHILD row carries `parentId`, so the picker filters its flat view to
11
+ * top-level rows (`parentId` absent) and shows the rest only in the tree. Adding a redundant status/flag that
12
+ * carries no non-derivable information would only create wire surface the SDK must mirror. The real picker fix is
13
+ * the additive `agentType` carrier above (a short type label instead of the objective). */
1
14
  export type FleetTaskStatus = "queued" | "running" | "waiting" | "stopping" | "awaiting approval" | "idle" | "completed" | "failed" | "killed";
15
+ /** One active task row (wire subset of the contract `FleetTask` — `depth`/`viewed`/tree-`selection` are
16
+ * shell-local render state the renderer composes; the wire carries the data that TRANSITIONS). */
2
17
  export interface FleetTaskRow {
3
18
  id: string;
4
19
  name: string;
5
20
  description?: string;
21
+ /** §K-7 (shell ASK 2026-06-28; byte-aligned to `@sema-agent/sdk` 0.0.39 `FleetTaskRow.agentType`/`agentName`) — a
22
+ * SHORT agent-TYPE label so the picker renders like CC 187 (`Explore`/`general-purpose`/`code-review`) instead of
23
+ * the full objective. `agentType` = the "what kind of agent" (a subagent's type / a delegated `taskName`);
24
+ * `agentName` = an in-process teammate's INSTANCE name. ADDITIVE / tolerate-absent: a TOP-LEVEL run carries NO
25
+ * native agentType (sema design — top-level runs have no agent-type; the analog is the SCENARIO, whose surfacing
26
+ * is the still-open "fleet-row name source" decision for clay/shell) → ABSENT, and the consumer FALLS BACK to
27
+ * `name` (the objective-preview). Populated TODAY on SUBAGENT CHILD rows, where `task_progress.name` IS the type
28
+ * (BC-2). SECRET-SAFE: redacted before emit, same discipline as `name`. */
6
29
  agentType?: string;
7
30
  agentName?: string;
31
+ /** Owning principal (= the run's scope). The `/v1/fleet/stream` route filters to the caller's scope (owner-gated)
32
+ * unless the caller is fleet-wide (operator / trace-token). NOT rendered — a tenant-isolation field. */
8
33
  scope?: string;
34
+ /** Fleet per-session scope: the run's rootTaskId (= sessionId). The
35
+ * `/v1/fleet/stream` route ALSO filters to the caller's `?session=` when present, so a TUI footer shows only the
36
+ * CURRENT session's rows, not OTHER sessions of the same principal (the "他会话 token" leak). NOT rendered — a
37
+ * scoping field like `scope`. Absent ⇒ the row is visible to any same-principal caller (back-compat, unscoped). */
9
38
  sessionId?: string;
10
39
  parentId?: string;
40
+ /** [1832] P1-2(core 1.432 BackgroundChildEvent.parentToolCallId,「出生就在场」语义):发起本子代的
41
+ * 父 tool_use id **原值**(E2 域,core-mint 不含用户内容)——与 `parentId`(解析后的行链接)是两个域:
42
+ * 本键给按 tool_use id 建卡树的消费端(cli 卡片树)直接绑定,无需 FIFO 猜/形状嗅探。
43
+ * ADDITIVE / tolerate-absent(旧 core 不发)。 */
11
44
  parentToolCallId?: string;
45
+ /** [1440] design/149:wa\* 行的 workflow 归属附注位(w\* runId)——面板按此分组;footer 树不按此嵌套
46
+ * ([1433] CC 锚:wa\* 不进 footer,壳按 taskId 前缀过滤)。ADDITIVE / tolerate-absent。 */
12
47
  workflowRunId?: string;
13
48
  status: FleetTaskStatus;
49
+ /** core 1.367 δ([1514]/[1515]④):launch 时刻 epoch ms(revive 行=本 revive 周期 wake 时刻)——
50
+ * cli 的 elapsed 锚直出(比 server 端 elapsedMs 快照更稳,消费方自算不漂)。ADDITIVE / tolerate-absent
51
+ * (a* 车道 spawn 即带;旧 core 帧无 startedAt 时回落 server 收帧时刻)。 */
14
52
  startedAt?: number;
15
53
  elapsedMs?: number;
16
54
  tokens?: number;
17
55
  queuedCount?: number;
18
56
  awaitingPlanApproval?: boolean;
57
+ /** core 1.262.0: the child's most recent tool intent as one
58
+ * human line ("Bash npm test") — from the bg sink tick's `currentAction` (core's only attachment point
59
+ * today). UNTRUSTED (tool argument head) → redacted before publish, same discipline as `name`.
60
+ * ADDITIVE / tolerate-absent. */
19
61
  currentAction?: string;
62
+ /** cli [1827]②(core 1.429 `currentTool`):`currentAction` 的**结构化**同源体 —— CC220 详情页
63
+ * Progress 段消费 `{toolName, target}` 结构(toolName 查工具注册表,自由文本塞不进去)。
64
+ * `toolName` = core 工具名 verbatim;`target` = UNTRUSTED 自由文本(命令行/路径可能秘密形)→
65
+ * redactSecrets + bound,与 `currentAction` 同信任边界。与 currentAction 同生命周期(未跑过工具前
66
+ * 缺席);ADDITIVE / tolerate-absent(旧 core 不发 ⇒ 键缺席,消费方回落 currentAction 文本)。 */
20
67
  currentTool?: {
21
68
  toolName: string;
22
69
  target?: string;
23
70
  };
71
+ /** cli [1748]①:该子代**累计**的工具调用次数(bg sink tick 的 `usage.toolUses`)——面板行与详情页的
72
+ * tool 计数。⚠️ **累计值,直接上行不累加**(与 `turn_end` 的每轮增量相反);⚠️ **缺席 ≠ 0** ——
73
+ * 老 core 不发这个数时本位缺席,消费方不得当 0 渲染(那会把「不知道」伪装成「跑了 0 个工具」)。
74
+ * ADDITIVE / tolerate-absent。 */
24
75
  toolUses?: number;
76
+ /** cli [1748]②:该子代的转录 id —— 壳侧据此去转录里取**委派 prompt**(详情页 `Prompt` 段)。
77
+ * ⚠️ 为什么给的是映射而不是 prompt 本身:`BackgroundChildEvent` 上**没有 prompt**(core `types.d.ts`),
78
+ * server 收不到的东西不能凭空造 —— 要 prompt 直出需要 core 先发。(旧注还说「也无 parentToolCallId」,
79
+ * core 1.432 已补该键,见 FleetTaskRow.parentToolCallId——本键的理由只剩 prompt 一半。)
80
+ * ADDITIVE / tolerate-absent。 */
25
81
  transcriptId?: string;
82
+ /** [1839]①/(a) 案:**终态行帧的残局键**——cli 实测裸 durable-run 完成时终态 task 帧键集只有
83
+ * [id,name,status,tokens,elapsedMs,description],idle 观察者(web 首屏形)从行卡拿不到终局。
84
+ * (b) 案(为顶层 run 造 bg_notification)被否:那族语义=观察者眼里的**子代**,伪造事件族比丰富行帧
85
+ * 更伤([1840]§二)。四键全部 ADDITIVE / tolerate-absent、**只在终态帧出现**:
86
+ * - `stoppedBy`:core open enum verbatim(与 BgNotification 同姿势);顶层 run 仅 cancel 路径有源
87
+ * (= "user",与 markStopSource 同源值),其余终态诚实缺席。
88
+ * - `usage`:与 {@link BgNotification.usage} **同形**(消费端一个形状)——bg 子代=terminal 事件的
89
+ * usage 逐键挑;顶层 run=TaskResult.stats 映射(tokens→totalTokens、toolCalls→toolUses)。
90
+ * - `resumable`/`editedFiles`:**仅 bg 子代有源**(BackgroundChildEvent.terminal);顶层 TaskResult
91
+ * 上没有这两位 ⇒ 顶层行帧永缺席,不造([1840]§二「没有就诚实缺席」)。 */
26
92
  stoppedBy?: string;
27
93
  usage?: {
28
94
  totalTokens?: number;
@@ -38,20 +104,31 @@ export interface FleetTaskRow {
38
104
  edits: number;
39
105
  }>;
40
106
  }
107
+ /** One workflow row (wire subset of contract `FleetWorkflow`). */
41
108
  export interface FleetWorkflowRow {
42
109
  id: string;
43
110
  name: string;
44
111
  description?: string;
112
+ /** Owning principal (= the workflow run's scope). Same owner-gate as FleetTaskRow. NOT rendered. */
45
113
  scope?: string;
114
+ /** #3 fleet per-session scope (rootTaskId = sessionId): the `/v1/fleet/stream` `?session=` filter. NOT rendered. */
46
115
  sessionId?: string;
47
116
  status: string;
48
117
  doneCount?: number;
118
+ /** 计划总数(= `run.agents.length`,**含排队中**)—— 注意它**不是**"已启动数",见 {@link FleetWorkflowRow.startedCount}。 */
49
119
  totalCount?: number;
50
120
  failedCount?: number;
121
+ /** MF-Fleet additive(cli [1726] 二①):**已启动**(非排队中)的 agent 数 —— CC 2.1.220 `⚠ Large workflow`
122
+ * 规模告警的分母。判别用 core 导出的 `deriveAgentDisplayStatus`(`startedAt` 未置 ⇒ 显示态 `queued`),
123
+ * **不自己重写谓词**:两端各写一遍必然漂移(本仓刚在治理面镜像上吃过同款)。
124
+ * ADDITIVE / tolerate-absent:缺席时消费方可退回 `doneCount + failedCount` 这个**诚实下界**(告警偏早)。 */
51
125
  startedCount?: number;
52
126
  elapsedMs?: number;
53
127
  tokens?: number;
54
128
  }
129
+ /** A push frame on the fleet stream. `snapshot` = the full current state on connect; `task`/`workflow` = a single
130
+ * row upsert (the row transitioned); `task_remove`/`workflow_remove` = the row left the active set (terminal +
131
+ * swept). Stable identity (`id`) lets the UI update/remove the right row in place. */
55
132
  export type FleetFrame = {
56
133
  type: "snapshot";
57
134
  tasks: FleetTaskRow[];
@@ -82,20 +159,56 @@ export type FleetFrame = {
82
159
  notice: HookNotice;
83
160
  ts: number;
84
161
  };
162
+ /**
163
+ * **一次 hook 判定「未能完成」**的观测帧(cli 黑板 [1786] 点名的需求;字段名由本仓定)。
164
+ *
165
+ * ── 它解决什么 ────────────────────────────────────────────────────────────────────────────────
166
+ * 用户设了 `/goal enforced`,产品对模型承诺「没达成不许停」。某一轮评估者没能给出判词
167
+ * (无内容 / 读不懂 / 被跳过)⇒ 按裁定**放行**。此刻的问题不是放行本身,是:
168
+ * **用户不知道这一轮的守卫没生效**,而模型拿到的是一个与「已达成」**无法区分**的放行。
169
+ * ⇒ **产品声称了一件它这一轮没做到的事。** 方向可以 fail-open,但不能连「我这轮没看住」都不说。
170
+ *
171
+ * ── 四条设计约束(逐条对应需求)──────────────────────────────────────────────────────────────
172
+ * 1. 语义是「**未能评估**」,**不是**「未通过」—— 两者必须可区分,否则壳侧只能说一句更模糊的话;
173
+ * 2. `reason` 机器可判(`no_content` / `unparsed` / `skipped`),与 server 侧那三行结构化日志同源;
174
+ * 3. **不只服务 `/goal`**:按「hook 判定未能完成」定义,带 `event` 位;`/goal` 只是第一个消费者;
175
+ * 4. 🔴 **纯 observe,不改变运行** —— 它走 fleet 流(常开推送道),**不是** `additionalContext`
176
+ * (那个通道本身会让这一轮不结束,见 hook-runner 折叠处那段旁注)。
177
+ *
178
+ * ⚠️ 可见性**与 `bg_notification` 同为 fail-CLOSED**:带 `ownerSessionId` 的帧只投给能证明是自己的
179
+ * 订阅方(`undefined` ⇒ 对 scoped 订阅方**丢弃**)。理由同源:一条关于别人会话的通知落到这个壳上,
180
+ * 会让用户以为是自己这轮出了问题。
181
+ */
85
182
  export interface HookNotice {
183
+ /** 目前只有一种;留成枚举位是为了下一类观测帧不必再开一个 frame 臂。 */
86
184
  kind: "hook_decision_unavailable";
185
+ /** 哪个 hook 事件(`Stop` / `PreToolUse` / …)。 */
87
186
  event: string;
187
+ /** 机器可判的原因(与 server 日志的三行同源)。 */
88
188
  reason: "no_content" | "unparsed" | "skipped";
189
+ /** 补充说明(已脱敏)。例如 `skipped` 的具体原因。 */
89
190
  detail?: string;
191
+ /** 租户可见性(发布前带,上 wire 前剥)。 */
90
192
  ownerScope?: string;
193
+ /** 宿主会话(发布前带,上 wire 前剥)——scoped 订阅方的 fail-closed 判据。 */
91
194
  ownerSessionId?: string;
92
195
  }
196
+ /** design/129-B 缺口② (帧契约): a background child's COMPLETION notification pushed on the
197
+ * ALWAYS-OPEN fleet stream — the only server-push lane an idle shell keeps subscribed, so a session-scoped bg
198
+ * child finishing while the host sits idle notifies IMMEDIATELY (no more "late by one input cycle" durable-drain).
199
+ * EVENT semantics, not state: never in the snapshot, no dedup key held here (the shell's task_notification
200
+ * injection queue dedups by (taskId,status) — the outer belt). Row visibility stays on `task` frames
201
+ * (行是状态、通知是事件,别合并). */
93
202
  export interface BgNotification {
203
+ /** Registry handle (`a*` domain — the TaskOutput/TaskStop key). */
94
204
  taskId: string;
205
+ /** The child RUN's session id (uuid domain — the a*↔uuid dual anchor), when known. */
95
206
  sessionId?: string;
207
+ /** Stop-cycle counter(core 1.352 terminal 帧补位;revive 周期判别键素材)——tolerate-absent。 */
96
208
  seq?: number;
97
209
  status: "completed" | "failed" | "killed";
98
210
  summary?: string;
211
+ /** Background lifetime scope (design/129), NOT the tenant scope. */
99
212
  scope: "task" | "session";
100
213
  parentTaskId?: string;
101
214
  stoppedBy?: string;
@@ -109,6 +222,8 @@ export interface BgNotification {
109
222
  path: string;
110
223
  edits: number;
111
224
  }>;
225
+ /** [1543]§二 LOW 补:完成通知的花费/转录锚(core BackgroundChildEvent.terminal 携带,此前被剥——
226
+ * 完成卡无花费显示、转录跳转无锚)。数值/id verbatim。 */
112
227
  usage?: {
113
228
  totalTokens?: number;
114
229
  toolUses?: number;
@@ -118,37 +233,67 @@ export interface BgNotification {
118
233
  costMicroUsd?: number;
119
234
  };
120
235
  transcriptId?: string;
236
+ /** P1-3(core 1.452,[1925] 一轮批):子代完成的**幂等锚**——同一完成的多路通知(bg_notification/
237
+ * task_notification/inbox 重放)带同一 id,消费端按它去重。verbatim;ADDITIVE/tolerate-absent。 */
121
238
  completionId?: string;
239
+ /** core 1.367 δ([1514]/[1515]④):委托树 root 宿主会话(固定点语义,嵌套孙代恒锚 root shell)——
240
+ * cli 跨壳重启按宿主会话归组([1500]② 台账判别 F2 残余闭环)。ADDITIVE / tolerate-absent。 */
122
241
  rootSessionId?: string;
242
+ /** Tenant/principal isolation key (same filter as FleetTaskRow.scope). STRIPPED before send. */
123
243
  ownerScope?: string;
244
+ /** The HOST session id (session-scoped children: registry owner) — the `?session=` filter key (the payload
245
+ * `sessionId` above is the CHILD's uuid and would never match the caller's session). STRIPPED before send. */
124
246
  ownerSessionId?: string;
125
247
  }
248
+ /**
249
+ * The process-local fleet aggregation bus. Holds the current active set + fans out deltas to SSE subscribers.
250
+ * Upserts MERGE (a partial delta patches the existing row), so a publisher can emit just the field that changed
251
+ * (e.g. only `tokens`) and the row stays whole. Removal drops the row (terminal). Subscribers get a snapshot of
252
+ * the current set immediately, then every subsequent delta.
253
+ */
126
254
  export declare class FleetEventBus {
127
255
  private readonly now;
128
256
  private readonly emitter;
129
257
  private readonly tasks;
130
258
  private readonly workflows;
131
259
  constructor(now?: () => number);
260
+ /** Upsert a task row (MERGE onto any existing row by `id`) + fan out the merged row. Publishers may send a
261
+ * partial `{ id, tokens }` etc.; the row keeps its other fields. */
132
262
  publishTask(delta: Partial<FleetTaskRow> & {
133
263
  id: string;
134
264
  }): void;
265
+ /** 推一帧 hook 判定未完成的观测通知(事件语义,不进 snapshot —— 与 `bg_notification` 同族)。 */
135
266
  publishHookNotice(notice: HookNotice): void;
267
+ /** Drop a task row (terminal + swept) + fan out the removal. Idempotent (a no-op if already gone). */
136
268
  removeTask(id: string): void;
269
+ /** Upsert a workflow row (MERGE by `id`) + fan out. */
137
270
  publishWorkflow(delta: Partial<FleetWorkflowRow> & {
138
271
  id: string;
139
272
  }): void;
273
+ /** Drop a workflow row + fan out the removal. Idempotent. */
140
274
  removeWorkflow(id: string): void;
275
+ /** design/129-B 缺口②: fan out a background-child completion notification (EVENT — not stored, never in the
276
+ * snapshot; a subscriber that connects later reads the durable inbox instead). */
141
277
  publishBgNotification(notification: BgNotification): void;
278
+ /** The current full state (the connect-time snapshot frame). */
142
279
  snapshot(): Extract<FleetFrame, {
143
280
  type: "snapshot";
144
281
  }>;
282
+ /** Subscribe to deltas. Returns an unsubscribe thunk. The caller typically sends `snapshot()` first, then every
283
+ * delta this delivers — the snapshot+delta sequence is the live fleet view. */
145
284
  subscribe(cb: (frame: FleetFrame) => void): () => void;
285
+ /** Live counts (test/observability). */
146
286
  get size(): {
147
287
  tasks: number;
148
288
  workflows: number;
149
289
  };
150
290
  private emit;
151
291
  }
292
+ /** A run-scoped lifecycle publisher — wire it into a run's TaskEvent loop so the fleet row TRANSITIONS with the
293
+ * run. `onStart()` adds the top-level row (running); `onEvent(ev)` accrues tokens (turn_end usage) + adds/updates
294
+ * subagent CHILD rows (core `task_progress`, keyed by its `taskId`, nested under the run via `parentId`);
295
+ * `onTerminal(status)` flips the row terminal + removes it (and its children) from the active set. No-op when no
296
+ * bus is wired. The token accrual is CUMULATIVE across the run's turns (turn_end carries a per-turn delta). */
152
297
  export declare function fleetRunPublisher(bus: FleetEventBus | undefined, run: {
153
298
  runId: string;
154
299
  scope: string;
@@ -175,14 +320,30 @@ export declare function fleetRunPublisher(bus: FleetEventBus | undefined, run: {
175
320
  parentToolCallId?: string;
176
321
  status?: string;
177
322
  }) => void;
323
+ /** Flip + remove one subagent CHILD row when its background completion notification arrives
324
+ * (task_progress never emits a terminal tick — without this a bg child sat "running" until parent settle).
325
+ * FLIP-THROUGH: publishes the terminal frame even when the row no longer exists — the parent leg's
326
+ * settle removes ALL child rows (it cannot tell a settled sync child from a still-running bg child), so a bg
327
+ * child that completes after parent settle otherwise had NO row to flip and the shell (auto-exit's fourth
328
+ * release condition watches the viewed cid's terminal) never saw a terminal transition. Returns whether the
329
+ * row EXISTED (hadRow — the observer logs it; false = the frame was synthesized flip-through). */
178
330
  onChildTerminal: (taskId: string, status: string, altId?: string, toolUseId?: string) => boolean;
331
+ /** [1839]①/(a) 案:`residuals` = 顶层 run 的终局残局键(有源才传,见 FleetTaskRow 上的键注)。
332
+ * 只有**真终态**(completed/failed/killed)帧带残局——parked(suspended/needs_review)的行还活着,
333
+ * 没有「终局」可言,误传也不上帧。 */
179
334
  onTerminal: (status: string, residuals?: {
180
335
  usage?: FleetTaskRow["usage"];
181
336
  stoppedBy?: string;
182
337
  transcriptId?: string;
183
338
  }) => void;
184
339
  };
340
+ /** The run-scoped publisher handle (returned by `fleetRunPublisher`). Threaded into `runInBackground` so a
341
+ * background run TRANSITIONS its fleet row exactly like the sync POST /v1/runs leg does. */
185
342
  export type FleetRunPublisher = ReturnType<typeof fleetRunPublisher>;
343
+ /** [1839]①/(a) 案:TaskResult → 终态行帧残局键映射(sync/background/resume 三条腿各自 settle,共用一处
344
+ * 映射——键名映射写三遍必漂移)。usage 与 {@link BgNotification.usage} 同形:stats.tokens→totalTokens、
345
+ * stats.toolCalls→toolUses(名对齐,消费端一个形状)。errorCode "cancelled" ⇒ stoppedBy:"user"(与
346
+ * markStopSource 的归因值同源);transcriptId 顶层 = run 的 sessionId([1840]§二拍)。缺源的键不铸。 */
186
347
  export declare function fleetRunResiduals(result: {
187
348
  sessionId?: string;
188
349
  errorCode?: string;
@@ -197,10 +358,34 @@ export declare function fleetRunResiduals(result: {
197
358
  stoppedBy?: string;
198
359
  transcriptId?: string;
199
360
  };
361
+ /**
362
+ * design/129-B (core 1.240.0) — the PROCESS-LEVEL background-child fleet publisher, wired once
363
+ * onto `RunnerDeps.onBackgroundChildEvent`. Unlike {@link fleetRunPublisher} (per-leg: dies at leg settle —
364
+ * the root cause: a session-scoped bg child outliving its turn had NO forward path, fleet showed zero
365
+ * child frames), this observer lives as long as the process and covers the child's WHOLE lifecycle:
366
+ * spawn → row appears the moment the child registers (launch→turn-tail 零帧 fixed: no more waiting for a
367
+ * first tick that a slow child never emits inside the turn);
368
+ * tick → token rollup onto the row; ALSO best-effort removes the per-leg uuid-keyed TWIN row the leg's
369
+ * onForwardEvent built for the same child (`${parentTaskId} ${progressTaskId}` composite — the
370
+ * per-leg childId shape), so the child shows ONCE, keyed by its stable a* handle;
371
+ * terminal → terminal frame under the a* row id, row leaves the fleet, and the contract
372
+ * `bg_notification` frame rides the always-open stream (缺口②'s immediate idle delivery).
373
+ * Rows are tagged `scope` (tenant filter) from the registry scope and `sessionId` (the `?session=` filter)
374
+ * from the registry owner when session-scoped (owner IS the host sessionId; task-scoped children have no
375
+ * session attribution → unscoped, back-compat visible). Names ride the same redactSecrets discipline.
376
+ */
200
377
  export declare function fleetBackgroundChildPublisher(bus?: FleetEventBus, log?: (msg: string, fields: Record<string, unknown>) => void): (e: import("@sema-agent/core").BackgroundChildEvent) => void;
378
+ /** BC-1 (clay-decided 2026-06-27): a top-level run's fleet-row `name` = a SHORT, single-line **objective preview**
379
+ * (the readable "what is this task" label) — NOT the full objective dumped in, and NOT duplicated into `description`.
380
+ * `description` is left to the publisher's LIVE-ACTIVITY update (`onEvent` tool_start → the current tool), so the row
381
+ * shows `name`=objective + `description`=current activity (two DISTINCT things, killing the earlier "objective shown
382
+ * twice" dup). Whitespace-collapsed + capped ≤48. (A subagent CHILD row's name = its agent-type — BC-2.)
383
+ * SECRET-SAFE: redact secret shapes (redactSecrets) BEFORE truncating — a secret in the objective must not leak in
384
+ * the row name. The durable objective is already redacted; the name preview was asymmetric (raw) until this. */
201
385
  export declare function fleetRunLabels(objective: string | undefined): {
202
386
  name: string;
203
387
  };
388
+ /** Map a service run status onto the neutral fleet vocabulary the shell renders. */
204
389
  export declare function runStatusToFleet(status: string, opts?: {
205
390
  awaitingPlanApproval?: boolean;
206
391
  }): FleetTaskStatus;