@sema-agent/server 1.323.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 +58 -2
  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
@@ -33,65 +33,195 @@ import { coarseStatusForState, errorCodeForExit } from "./routes/images.js";
33
33
  export { coarseStatusForState, errorCodeForExit };
34
34
  import { explicitOperatorOk, isOperator, explicitOperator } from "./principal-gate.js";
35
35
  export { explicitOperatorOk, isOperator, explicitOperator };
36
+ /** Per-request authorization context resolved before building the spec (identity, owned session). */
36
37
  export interface RequestAuth {
37
38
  principal?: string;
38
39
  sessionId: string;
39
40
  memoryScope?: string;
41
+ /** 142-S4:the SHAPE-VALIDATED `body.projectId`(authorizer 的 PROJECT_ID_REGEX 门通过后回传)。
42
+ * main.ts 拿它查 config.projects 的 defaultScopes(memory.scopes 种子)。resume 腿(checkpoint 重建
43
+ * auth)缺席 — main.ts 回落持久化 body.projectId(原始提交已验形)。 */
40
44
  resolvedProjectId?: string;
41
45
  }
46
+ /**
47
+ * design/158 A8 —— ServiceDeps 的**分组窄接口**。
48
+ *
49
+ * 病:69 个平铺可选字段里 29 个只被单一路由域读、跨 ≥9 域的只有 4 个(config/logger/runStore/metrics)。
50
+ * 平铺形的直接后果 = main.ts 一个上千行的装配字面量,键与键之间没有任何「属于同一件事」的编译期表达,
51
+ * 键落错家/从未接线只能靠源码钉逐个盯(1.300/1.301/1.304/1.307/1.310 五起真缺陷都是这个病族)。
52
+ *
53
+ * 药:七个**窄**接口 + 顶层必填三件。装配点按组构造(每组一个带类型标注的中间 const ⇒ 受 TS 多余
54
+ * 属性检查保护),键放错组当场编译红。
55
+ *
56
+ * 兼容形(本批**不动消费点**):`ServiceDeps` = 平铺视图 ∩ 组槽。旧的平铺构造(96 个测试文件 +
57
+ * index.ts 的嵌入方)逐字不变仍编译通过;新的分组构造由 `flattenServiceDeps` 在 createHttpServer
58
+ * 入口摊平回平铺视图,server.ts 内的 ~700 处 `deps.x` 消费点原样保留。消费点迁移是后批的事——
59
+ * 一步到位需要同批改 ~700 处 src + ~800 处 test 键位,与「先立形、后搬家」相比没有额外收益。
60
+ */
61
+ /** createHttpServer 的**必填三件**——引擎、部署配置、请求→TaskSpec 的映射。三者恒在场,
62
+ * 故留在顶层(不进任何可选组):没有它们 server 根本起不来,包一层可选组只会把编译期错误推迟到运行期。 */
42
63
  export interface ServiceCoreDeps {
43
64
  runner: Runner;
44
65
  config: ServiceConfig;
66
+ /**
67
+ * Map an inbound request body + resolved auth to a full TaskSpec. The SERVICE/deployment owns model
68
+ * + tools + mcp here (callers only supply content). `auth` carries the ownership-checked sessionId
69
+ * and the principal-derived memory scope — prefer them over anything in the body.
70
+ */
71
+ /** `opts.leg` (codex R4, appendSystemPrompt 案): "fresh" ⇒ a NEW submit — resolveSpec may fail-loud 400 on
72
+ * combos that would silently discard caller payload (append rider / outputStyle on an append-less pack).
73
+ * Absent/"resume" ⇒ a stored-body replay — the same combos drop+warn instead (a 4xx would brick the stored
74
+ * task). The disposition lives INSIDE resolveSpec because only it derives the effective scenario (principal
75
+ * ruling + defaultScenario) and holds the center-pack snapshot the provider pick uses — an HTTP-side probe
76
+ * could disagree with the actual assembly (scenario mismatch / centerPrompts refresh TOCTOU). */
45
77
  resolveSpec: (body: TaskRequestBody, req: IncomingMessage | undefined, auth?: RequestAuth, opts?: {
46
78
  leg?: "fresh" | "resume";
47
79
  }) => TaskSpec | Promise<TaskSpec>;
48
80
  }
81
+ /** **durable 持久面**:每个键 present ⇔ 对应路由/能力位在场,absent ⇒ 501(诚实缺席),
82
+ * 绝不静默降级。装配点 = main.ts 的 store backend 开箱段。 */
49
83
  export interface ServiceStoreDeps {
84
+ /** Durable async-run registry + event log (S1/S2). Enables /v1/runs when present. */
50
85
  runStore?: RunStore;
86
+ /** E18 resume-at: the eventId→entryId anchor map (tidb/pg/local). Present whenever a backend is — resolveSpec
87
+ * resolves body.resumeAt(eventId)→entryId, the run lifecycle captures per-turn anchors, E21 purges them. */
51
88
  resumeAnchorStore?: ResumeAnchorStore;
89
+ /** Human-in-the-loop approval store (F4 poll gate). Enables /v1/approvals when present. */
52
90
  approvalStore?: ApprovalStore;
91
+ /** Per-session approval exemption store — enables decide body `remember:"session"` + the
92
+ * exemptions list/revoke surfaces on /v1/approvals. The ask-gate probe is wired separately (main.ts). */
53
93
  approvalExemptionStore?: ApprovalExemptionStore;
94
+ /** Durable-checkpoint store (design/45, core 1.67): durable F4 suspend/resume. When present, the resume
95
+ * endpoint + suspended-run surfacing are active. Set only when DURABLE_APPROVAL + a TiDB pool. */
54
96
  checkpointStore?: CheckpointStoreFull;
97
+ /** E6 durable SessionPolicyStore (operator-tightened per-session tool rules). Enables PUT/GET /v1/sessions/:id/policy
98
+ * when present; core reads the rules at prepare-time (subtract-only) via RunnerDeps.sessionPolicyStore (wired separately). */
55
99
  sessionPolicyStore?: ServiceSessionPolicyStore;
100
+ /** E19 rewind-files snapshot store. Present ⇒ the `rewindFiles` capability is advertised; core uses it via
101
+ * RunnerDeps.fileSnapshotStore (snapshot per turn + restore on resumeAt, ANY env since gate-split 1.134.0). Also the 2c artifact store. */
56
102
  fileSnapshotStore?: ServiceFileSnapshotStore;
103
+ /** D-1 通用文件上传(clay 拍 2026-07-27:独立附件 store,不骑 snapshot blob 面):enables
104
+ * POST/GET/DELETE /v1/attachments*。缺席 ⇒ 501(与其他可选 store 面同姿)。绑定/物化半场在
105
+ * main.ts(resolveSpec + env factory 包装);本面只管上传/取回/删除三动词 + server 权威上限。 */
57
106
  taskAttachmentStore?: TaskAttachmentStore;
107
+ /** design/153 件3d(/decide parked 赎回腿)——与 RunnerDeps/scenarioDeps **同实例**:durable bg
108
+ * 行店 + boot 期从生产装配(buildScenarios)取的裸 Agent ToolSpec。**这两件**与 checkpointStore
109
+ * 齐备时,POST /v1/approvals/:sessionId/decide 对 parked 后台子代的 pending checkpoint 走
110
+ * claim→execute 赎回腿(src/parked-decide.ts);任一缺席=分支不存在(legacy 腿现状:getCtx
111
+ * null → 409,诚实不误驱)。 */
58
112
  backgroundAgentStore?: import("@sema-agent/core").BackgroundAgentStore;
113
+ /** §0.5 session-ownership: the durable session abstraction (`SessionRepo`-style) the service OWNS — session
114
+ * IDENTITY/enumeration (E16 list) + lifecycle (E17 fork, E21 history delete) come from HERE, not the
115
+ * `task_run` runs ledger. When it carries `listSessions`, GET /v1/sessions sources sessions from the session
116
+ * store (task_run only joins for run preview); `fork`/`deleteSession` enable the fork/delete routes. */
59
117
  sessionStorage?: OwnerAwareSessionStore;
118
+ /** S8 workflow-run store (design/97/98): enables GET /v1/workflows (list) + /v1/workflows/:id (detail).
119
+ * Set when SELF_ORCHESTRATION_ENABLED. Live progress (/v1/workflows/:id/stream) is in-process
120
+ * (subscribeWorkflow) and works whenever self-orchestration is on, store or not. Runs are owner-gated by
121
+ * `scope` (= the creating principal). Also drives `capabilities.workflowsList` (= "can durably LIST runs"). */
60
122
  workflowRunStore?: WorkflowRunStore;
123
+ /** [1402] journal 读面(PAIR-REVIEW 修车批):GET /v1/workflows/:runId/journal 的数据源——与 runner 侧
124
+ * workflowJournalStore 同一实例(main.ts backend.workflowJournal());缺席=501(与 workflowRunStore 同门)。 */
61
125
  workflowJournalStore?: import("@sema-agent/core").WorkflowJournalStore;
126
+ /** Sandbox-image-pool index (IMAGE-API-DESIGN.md §2, pool design §8): enables /v1/images* (query + select).
127
+ * Set when a TiDB pool is present. The bake/publish job API (P2/P3) layers on top later. */
62
128
  imageIndex?: ImageIndex;
129
+ /** Sandbox-image-pool BAKE store (IMAGE-API-DESIGN.md §P2): enables /v1/images/bakes* (operator-gated async
130
+ * bake + resumable SSE + runner claim/ingest + status-monotonic auto-register). Set when a TiDB pool is
131
+ * present AND `IMAGE_BAKES_ENABLED`. The auto-register path writes into `imageIndex` (so both are wired
132
+ * together). 🔴 main.ts boot-asserts `operatorPrincipals` is non-empty when this is on (never a
133
+ * world-writable build-host-RCE door, §P2.4a). */
63
134
  imageBakes?: ImageBake;
135
+ /** P2 (design/73 §7.2): the outcome-fact sink, for the `GET /v1/outcomes` read aggregate. `summary` is
136
+ * present on the SQL ledgers; a File sink (no query surface) → the endpoint 501s honestly. */
64
137
  outcomeSink?: import("../plugins/file-outcome-sink.js").OutcomeSink;
138
+ /** SendUserFile 账本(多租户治理面):scope↔object 映射的读面 GET /v1/sendfile-links。present ⇔ 签发面
139
+ * 已配 AND 有 store backend(main.ts 建;写点在两条 send lane 的 withLedgerRecording)。 */
65
140
  sendFileLedger?: import("../plugins/send-file-ledger.js").SendFileLedger;
141
+ /** 2c session-sync (P1d) — the WHOLE durable backend, so the `/v1/sessions/:id/sync/*` routes can call
142
+ * exportSession/importSession (src/session-sync.ts), which fan out across ALL four session subsystems
143
+ * (session entries + fileSnapshot blobs/manifests + sessionPolicy + resumeAnchor) in the §8 fail-closed atomic
144
+ * order. The individual stores above are wired for the per-feature routes; the sync routes need the backend
145
+ * itself because the orchestrator coordinates the four together (a route can't reassemble it from the parts —
146
+ * `backend.session()`/`fileSnapshot()`/`sessionPolicy()`/`resumeAnchor()` must come from ONE backend). Present
147
+ * whenever a durable backend (tidb/pg/local) is; absent on the env-only/no-backend worker (the routes 501). */
66
148
  backend?: StoreBackend;
67
149
  }
150
+ /** **进程内活体协调面**(本副本 only,重启即空):HITL 协调器、可 steer 句柄注册表、事件总线、
151
+ * 收件箱。跨副本一律不可见——每个消费点都按「不在本副本 ⇒ 409/降级」写,不假装全局。 */
68
152
  export interface ServiceCoordinatorDeps {
153
+ /** E23 (shell-host contract): inbound MCP elicitation coordinator (live-only HITL). Set when MCP_ELICITATION_ENABLED.
154
+ * Wired onto the runner's onElicit seam AND consumed here by `POST /v1/elicitations/:id/respond` + the per-run
155
+ * ALS context wraps (background/inline-stream/resume). Absent ⇒ the capability is false + no server can elicit. */
69
156
  elicitation?: ElicitationCoordinator;
157
+ /** §4④: AskUserQuestion LIVE coordinator. Set when ASK_QUESTION_ENABLED. Wired onto the runner's onQuestion
158
+ * seam AND consumed here by `POST /v1/questions/:id/respond` + the per-run ALS wraps on the streaming legs. Absent ⇒
159
+ * the capability is false + the AskUserQuestion tool headless-defaults (never a live human). */
70
160
  question?: QuestionCoordinator;
161
+ /** [816]/[820]②: live tool-approval coordinator (core onAsk → CC three-choice card). Set when
162
+ * TOOL_APPROVAL_ENABLED. Wired onto the runner's onAsk seam AND consumed here by
163
+ * `POST /v1/tool-approvals/:id/respond` + the per-run ALS wrap on the SYNC streaming leg (live-only by design —
164
+ * every other leg keeps core's fail-closed headless auto-deny, [819]⑤/[820]④). */
71
165
  toolApproval?: ToolApprovalCoordinator;
166
+ /** SVC-5 (design/97 CORE-5 #6): the process-local registry of STEERABLE workflow-agent handles
167
+ * (`ctx.agentStream`) live on THIS replica. Enables POST /v1/workflows/:id/agents/:label/steer. See
168
+ * workflow-agent-steer.ts for the handle-visibility seam status (the registry is real + ready; core does not
169
+ * yet hand the deployment a handle to register, so the route returns steering.not_running until it does). */
72
170
  workflowAgentRegistry?: WorkflowAgentRegistry;
171
+ /** C2 (core 1.219): the process-local registry of STEERABLE Task-subagent handles live on THIS
172
+ * replica (populated by the per-run-leg `onSubagentSpawn` internals sink). Enables
173
+ * POST /v1/runs/:runId/subagents/:target/steer (`target` = the child's parentToolCallId, or its agentName
174
+ * when unambiguous). Sync delegations only (core F3 scope: background children have no steer handle). */
73
175
  subagentSteerRegistry?: SubagentSteerRegistry;
176
+ /** P1 ①②: the async-workflow COMPLETION INBOX. A finished background workflow's completion
177
+ * is enqueued here (in main.ts's `deliverWorkflowCompletion`) keyed by the originating session; when that
178
+ * session next opens a stream (`POST /v1/runs` or a resume), we `drain` it and emit a `workflow_complete`
179
+ * out-of-band SSE frame the shell turns into a `<task-notification>` (deduped by runId). Present when
180
+ * self-orchestration is on. */
74
181
  workflowCompletionInbox?: WorkflowCompletionInbox;
182
+ /** MF-Fleet (shell-host data contract) — the in-process fleet aggregation bus backing `GET /v1/fleet/stream`
183
+ * (the live multi-row task/workflow fleet view: status/elapsed/tokens/doneCount transitions pushed over time).
184
+ * Present when wired in main.ts; the run + workflow lifecycle publish their per-row deltas to it. */
75
185
  fleetBus?: FleetEventBus;
186
+ /** [1196] session-watch registry(SSE 订阅共享探针面)。present ⇔ sessionStorage 有 getLeafId/ownerOf
187
+ * (main.ts 建);absent ⇒ /v1/sessions/:id/events 501(capabilities.sessionEvents 同谓词,永不漂)。 */
76
188
  sessionWatch?: import("../session-watch.js").SessionWatchRegistry;
189
+ /** asyncRewake wake 管道 holder(main.ts 建壳,server 启动装 deliver=session→本副本活流 steer)。 */
77
190
  hookWakeBus?: {
78
191
  deliver?: (sessionId: string, text: string) => Promise<boolean>;
79
192
  };
193
+ /** SendUserFile(切片2):per-run file_link 帧发射 ALS;undefined ⇒ 工具未建(非 host lane / 未配签发面)。 */
80
194
  sendUserFile?: import("../capabilities/send-user-file-tool.js").SendUserFileEmitter;
195
+ /** v2 leader endpoint (design/50): enables POST /v1/leader (async) + GET /v1/leader/:id. Set when
196
+ * LEADER_ENABLED + the leader wiring (e2b workers + git push) is configured. */
81
197
  leaderEndpoint?: LeaderEndpoint;
198
+ /** Fire-and-forget session auto-titler (first-submit hook; absent = feature dark). */
82
199
  sessionTitler?: {
83
200
  maybeTitle(sessionId: string, objective: string): void;
84
201
  };
85
202
  }
203
+ /** **函数/构件缝**:main.ts 把跨多个子系统的动作编译成一个可调用面交给路由(路由不该自己
204
+ * 重组零件——见 backend 的同款论证)。parked-revive 三件是同族的构件缝(boot 期从生产装配取的裸
205
+ * ToolSpec + 成员集 + 父约束重建器),与 backgroundAgentStore 齐备才构成赎回腿。 */
86
206
  export interface ServiceSeamDeps {
207
+ /** Audit回溯: current context (+ summary) for a session, plus its owner. Enables GET /v1/sessions/:id. */
87
208
  sessionAudit?: (sessionId: string) => Promise<({
88
209
  owner: string | null;
89
210
  } & Record<string, unknown>) | undefined>;
211
+ /** E21 session delete coordinator: purge a session's history (sessionStorage) PLUS the service-owned
212
+ * run-ledger/checkpoint/tool-result rows, owner-guarded, in one call. Returns `{ deleted }` (idempotent) — or
213
+ * `{ active }` when the runs-ledger TX re-asserted a still-live run (a concurrent createRun raced the route's
214
+ * pre-check), which the route maps to 409. Enables DELETE /v1/sessions/:id. Wired by main.ts (all the stores). */
90
215
  purgeSession?: (sessionId: string, owner: string | null) => Promise<{
91
216
  deleted: boolean;
92
217
  } | {
93
218
  active: string;
94
219
  }>;
220
+ /** [1488]③(b): read a BACKGROUND agent-handle child's final report / current status out of the core
221
+ * TaskRegistry (the same face the TaskOutput tool reads — agent handles are NEVER in the run store).
222
+ * Wired in main.ts to `defaultTaskRegistry.pollTask` (non-blocking). Access is the REGISTRATION tuple:
223
+ * owner = the parent run's taskId (resume legs register children under the sessionId — the registry's
224
+ * sessionScoped arm matches via `access.sessionId`), scope = the run's principal ?? "default". */
95
225
  subagentTaskOutput?: (handle: string, access: {
96
226
  owner: string;
97
227
  scope: string;
@@ -100,6 +230,10 @@ export interface ServiceSeamDeps {
100
230
  content: string;
101
231
  details: unknown;
102
232
  }>;
233
+ /** [1499] CC TaskOutput 人侧对位 — the GENERIC task-handle read (background_bash cursor-consuming stdout /
234
+ * monitor batches / background_agent final report; `workflow` refused at the seam — journal face owns it).
235
+ * Same registration-tuple access derivation as subagentTaskOutput. Wired in main.ts to the seam over
236
+ * defaultTaskRegistry.pollTask. */
103
237
  taskHandleOutput?: (handle: string, access: {
104
238
  owner: string;
105
239
  scope: string;
@@ -108,6 +242,8 @@ export interface ServiceSeamDeps {
108
242
  content: string;
109
243
  details: unknown;
110
244
  }>;
245
+ /** [1499] CC TaskStop 人侧对位 — stop a background task handle (bash kill / monitor stop / agent abort),
246
+ * attributed "user". Same kind gate + access derivation as taskHandleOutput. */
111
247
  taskHandleStop?: (handle: string, access: {
112
248
  owner: string;
113
249
  scope: string;
@@ -116,10 +252,30 @@ export interface ServiceSeamDeps {
116
252
  content: string;
117
253
  details: unknown;
118
254
  }>;
255
+ /** 142-S5 §1.4: per-scope memory export reader (main.ts wires `exportMemoryScope` over the DB memory
256
+ * backend). Enables GET /v1/memory/export — present ONLY on a DB memory plane (MEMORY_ENGINE_BACKEND=
257
+ * pg|tidb); absent / file posture ⇒ 501 (single-user file memory exports by copying the memory dir). */
119
258
  memoryExport?: (scope: string) => Promise<MemoryEntry[]>;
259
+ /** 142-S2.5(设计 §2.5;裁定 plan 随数据走,core 零运行时半场):one full sync round for one
260
+ * (scope, peer) — main.ts wires `performMemorySync` over the DB memory backend + the sync-cursor
261
+ * store. Enables POST /v1/memory/sync/:scope — present ONLY on a DB memory plane
262
+ * (MEMORY_ENGINE_BACKEND=pg|tidb); absent / file posture ⇒ 501 honestly (a single-user file plane
263
+ * IS the TOC side of a sync — it has no central-authority half to serve). */
120
264
  memorySync?: (scope: string, syncReq: MemorySyncRequest) => Promise<MemorySyncResponse>;
265
+ /** WEB-SETUP-RECON 附B — org sessionMirror 治理态的 SERVICE 半场 = **观测面(audit),非执法面**。
266
+ * 裁定 (c):「该镜像而未镜像」发生在数据产生端(壳)——本 server 是镜像**目标**,只看得见到达的 push;
267
+ * 没到达的会话对 server 不存在(无客户端会话清单、无心跳契约),required 锁的真执法只能在壳(CC
268
+ * managed-settings 心智;registry-core 域头注同判)。server 能诚实观测的最小面 = 镜像 PUSH 到达时该
269
+ * principal 的治理态(required + 指定 engineUrl)入 audit 日志/metrics,供运营关联「治理生效 vs 到达流」。
270
+ * per-principal 查询走 caps client 的 executionRuling 同车(零额外 RTT);absent = 无 center(单用户/
271
+ * dry-run)⇒ 观测面不接线,零行为差。fail-open:观测失败绝不影响 sync 面本身。 */
121
272
  sessionMirrorRuling?: (principal: string | undefined) => Promise<SessionMirrorRuling | undefined>;
273
+ /** Degenerate-output a/b instrument: on errorCode=output.degenerate, inspect the session's turns to
274
+ * classify where the salvageable answer was (counter + log). Fire-and-forget; no-op otherwise. */
122
275
  instrumentDegenerate?: (result: TaskResult) => void;
276
+ /** [1469] side-query 记账 seam(budget.ts createSideQueryAccountant——与 createTracer 同一装配点、
277
+ * 同一组 sink 实例:costQuota/model_cost 指标/fleetUsage/fleetLease,四路同语义)。缺席=零记账
278
+ * (手搭测试 deps;生产 main.ts 恒传)。 */
123
279
  sideQueryAccounting?: (principal: string | undefined, r: {
124
280
  model: string;
125
281
  family?: "input-includes-cached" | "input-excludes-cached";
@@ -134,55 +290,131 @@ export interface ServiceSeamDeps {
134
290
  };
135
291
  }) => void;
136
292
  parkedReviveTool?: import("@sema-agent/core").ToolSpec;
293
+ /** 可选第三件:revive args 的 `subagent_type` roster 成员集([1588] Q1 成员性规则)。当前生产装配
294
+ * **恒缺席**(boot 内建 default 无自定义 agents roster,per-request 的 spec.agents 不进 boot 工具)
295
+ * = 恒省略 subagent_type,typed 子代按 general-purpose 形复活(保真度 caveat 已报 core,[1588]
296
+ * 批复审 G-F1;center roster 接线是候件,字段先留给它与测试口)。 */
137
297
  parkedKnownAgentTypes?: ReadonlySet<string>;
298
+ /** [1596]/[1597] 跨进程父约束重供:decide 腿按部署配置重建 host 任务的同语义父策略链(exempt 锚=
299
+ * row.rootSessionId),经 core 1.396 的 `parkedResume.inheritedGate` 席位透传——缺席时重启后带
300
+ * requiresParentConstraint 的 parked checkpoint 恒被 core pre-CAS 门诚实拒(不可赎回)。 */
138
301
  parkedReviveInheritedGate?: (row: import("@sema-agent/core").BackgroundAgentRecord) => unknown;
139
302
  }
303
+ /** **可观测面**:日志/指标/累加器。全体 fail-open——观测失败绝不改变业务面行为。 */
140
304
  export interface ServiceObservabilityDeps {
305
+ /** Structured logger (access log + errors). */
141
306
  logger?: Logger;
307
+ /** Metrics registry; when present, exposed at GET /metrics (token-gated). */
142
308
  metrics?: Metrics;
309
+ /** E8 (shell-host contract): per-task × per-model usage accumulator fed by the cost tracer. Shared with `createTracer`
310
+ * so the durable run lifecycle drains it into `model_usage` events → the `TaskStats.modelUsage` echo. */
143
311
  modelUsage?: ModelUsageTracker;
312
+ /** [998]②: the shared prompt-manifest accumulator (tracer records at prepare; the durable legs drain it
313
+ * into `prompt_assembled` events for turns/stream). Same register-fence lifecycle as modelUsage. */
144
314
  promptManifests?: PromptManifestTracker;
315
+ /** Plan-cache recurrence probe (core design/42): per-scope objective recurrence rate, dumped at
316
+ * GET /metrics/plan-cache. Pure in-memory; recorded per finished task on both result paths. */
145
317
  planCacheProbe?: PlanCacheProbe;
146
318
  }
319
+ /** **准入/治理面**:身份解析与配额/限流/租约。每一件都是**拒绝**的权力(400/403/429),
320
+ * 缺席 = 该道门不存在(不是「默认放行的门」——两者在事故复盘里语义完全不同)。 */
147
321
  export interface ServiceGovernanceDeps {
322
+ /**
323
+ * Resolve identity + the owned session BEFORE the spec is built (S6). Throw `HttpError` to reject.
324
+ * Optional: when omitted, no principal/ownership enforcement (the body's sessionId is used as-is).
325
+ */
148
326
  authorize?: (ctx: {
149
327
  req: IncomingMessage;
150
328
  body: TaskRequestBody;
151
329
  }) => Promise<RequestAuth>;
330
+ /** 鉴权桥(registry-core api/auth-bridge):registry 用户 JWT → principal。缺席=分支不存在
331
+ * (bearer 只认 SERVICE_AUTH_TOKEN(S),现状不变)。 */
152
332
  registryJwtVerifier?: {
153
333
  verify: (bearer: string) => Promise<import("../auth-bridge.js").VerifyOutcome>;
154
334
  };
335
+ /** Per-principal rate limiter for task/run endpoints. In-memory (single replica) or TiDB-backed
336
+ * (cross-replica soft limit) — both satisfy RateGate. */
155
337
  rateLimiter?: RateGate;
338
+ /** Per-principal cumulative cost quota (refuses a tenant's next task once over for the window).
339
+ * In-memory (single replica) or TiDB-backed (cross-replica) — both satisfy QuotaTracker. */
156
340
  costQuota?: QuotaTracker;
341
+ /** D4 AP:worker 侧 quota-lease admission(协商式;center lane 未配 = 缺席 = 零行为)。 */
157
342
  fleetLease?: FleetLeaseManager;
158
343
  }
344
+ /** **部署自述面**:只被 /health、/v1/capabilities 与提交前置门读的部署事实(多为 live getter,
345
+ * 不是快照——/health 必须回答「此刻」)。 */
159
346
  export interface ServiceDeploymentDeps {
347
+ /** Stable per-process id recorded on runs (audit / stale recovery). */
160
348
  instanceId?: string;
349
+ /** Deployment-level capability facts merged into GET /v1/capabilities: e.g.
350
+ * scenarios list, version, pricingConfigured. The store-derived booleans (asyncRuns/artifacts/approvals/
351
+ * leader) are computed here from the deps — this bag is for what only main.ts knows. Open set. */
161
352
  capabilities?: Record<string, unknown>;
353
+ /** 场景详情只读面(GET /v1/capabilities/scenarios/:name 数据源):main.ts 在 boot 组装
354
+ * (内建 details+center 条目同判定源盖同名)。absent = 404(与 capabilities 缺席同姿势)。 */
162
355
  scenarioDetails?: Record<string, import("../capabilities/scenarios.js").ScenarioDetail>;
356
+ /** Honest /health `sessionBackend` label — the wiring coerces the config enum to "tidb"
357
+ * (meaning "durable, generically"), which on a pg deployment reads as SQL-TiDB and misleads triage.
358
+ * main.ts passes the effective store label (`durable(pg)` / `durable(mysql)` / `durable(local)` / "memory",
359
+ * same derivation as the boot `listening` log). Absent → fall back to the raw config enum. */
163
360
  sessionStoreLabel?: string;
361
+ /** S5 (SILENT-FALLBACK P0-b): true when the boot auto-probe degraded the store backend to in-memory. */
164
362
  storeDegraded?: boolean;
363
+ /**
364
+ * Graceful drain — shared mutable state between main.ts (flips `draining` on SIGTERM) and this server:
365
+ * • while `draining`, NEW model-running submissions (the billable submit paths) get 503 + Retry-After, so an
366
+ * orchestrator/shell retries against the replacement instance; read paths + in-flight verbs (steer/cancel/
367
+ * respond/subagent) stay open so the runs we are waiting on can still finish/interact.
368
+ * • `inflight` is ASSIGNED BY createServer (a live union of this replica's in-flight legs: durable bg/resume
369
+ * `inflightRuns` + live sync/resume streams `steerableRuns`) — main.ts polls it to know when drain is done.
370
+ * • /health carries `draining:true` (k8s readiness 摘流信号) + `version` (build self-description).
371
+ */
165
372
  drainState?: {
166
373
  draining: boolean;
167
374
  since?: number;
168
375
  inflight?: () => number;
169
376
  lastActivityAt?: () => number;
170
377
  };
378
+ /** boot ready 门(b):false = registry 部署无显式 env 模型且首次 effective pull 尚未落 roster
379
+ * (worker 只有占位模型)。计费提交 503 + /health 加性 `ready:false`。absent = 恒 ready(env 模型在/非
380
+ * registry 部署),现有部署零影响。main.ts 在 applyEffective 落模型后翻 true(one-way latch)。 */
171
381
  modelReady?: () => boolean;
382
+ /** Sema-registry restart signal: the refresh loop sets this when a pull carries restart-to-apply
383
+ * changes (skills/mcp/scenarios/runtime-gates baked at boot) that DIFFER from this process's boot config.
384
+ * Surfaced at GET /health as `restartRequired` + `restart{reasons,version,since}` so the orchestrator can
385
+ * auto rolling-restart the worker. Change-detected (not presence) — absent when nothing baked-at-boot
386
+ * changed, so polling it never causes a restart loop. */
172
387
  restartState?: () => RestartSignal | undefined;
388
+ /** codex R18 (models-tiers deferral): the persistent "deferred WITHOUT a next-boot handoff" state — set when a
389
+ * changed model plane could not hot-apply (tier-frozen Runner / tiered candidate) AND no restart-surviving LKG
390
+ * exists to justify forcing a restart. Surfaced on /health (`modelPlaneDeferred`) so the stuck-degraded state
391
+ * outlives the one-shot warn (the etag advances → later ticks 304 and never re-enter the defer branch). */
173
392
  planeDeferredState?: () => {
174
393
  version: number;
175
394
  since: number;
176
395
  blocked?: string[];
177
396
  } | undefined;
397
+ /** ① core ruling — SPLIT: `capabilities.workflows` = the ENGINE-CAN axis, boot-computed from core's own
398
+ * `workflowsCapability(deps)` (hardened script runner ∧ governance), NOT the `Boolean(workflowRunStore)` store
399
+ * proxy. Orthogonal to `workflowsList` (the durable-list axis = `workflowRunStore`). Falls back to the store
400
+ * proxy when absent (older callers / tests that don't pass it). */
178
401
  workflowsCapable?: boolean;
179
402
  }
403
+ /** **数值旋钮**:部署可调的上限/拍距。缺省值写在消费点(`?? 256` 之类),此处只承载覆写。 */
180
404
  export interface ServiceKnobDeps {
405
+ /** (a)(clay 拍 a+c,2026-07-27)当快照 blob 走 SQL 默认店时(逃生口形/覆写形),该店的 per-blob
406
+ * 承载帽——PUT /sync/blobs 面据此**前置 413**(typed `blob_too_large_for_sql`)。不设=不前置(MinIO
407
+ * 形无帽)。为什么在 HTTP 面重复店里的检查:店的 never-throw 结果形把一切写失败折成 502,而 502
408
+ * 语义=可重试,对端会对一个永远过不去的 blob 无限重试——413 才是「别再送了」的诚实形。 */
181
409
  snapshotBlobSqlCapBytes?: number;
410
+ /** [1196] SSE 连接帽(缺省 256/副本;超限 503+Retry-After=消费方回落 /head 轮询)。 */
182
411
  sessionEventsMaxConnections?: number;
412
+ /** [1196] SSE 心跳/owner 复核拍距 ms(缺省 25s;测试注入用)。 */
183
413
  sessionEventsHeartbeatMs?: number;
414
+ /** [1196] 背压阻塞断流阈 ms(缺省 60s;write 持续 false 超过即断——僵消费者不无界积压)。 */
184
415
  sessionEventsStallMs?: number;
185
416
  }
417
+ /** 组槽本身。每组可选:一个只跑 env-only 的 worker 可以一组都不给。 */
186
418
  export interface ServiceDepGroups {
187
419
  stores?: ServiceStoreDeps;
188
420
  coordinators?: ServiceCoordinatorDeps;
@@ -192,16 +424,39 @@ export interface ServiceDepGroups {
192
424
  deployment?: ServiceDeploymentDeps;
193
425
  knobs?: ServiceKnobDeps;
194
426
  }
427
+ /** 平铺视图 = 必填三件 + 其余七组的全可选并集。**派生**自组接口,故与分组形永不漂。 */
195
428
  export type FlatServiceDeps = ServiceCoreDeps & Partial<ServiceStoreDeps & ServiceCoordinatorDeps & ServiceSeamDeps & ServiceObservabilityDeps & ServiceGovernanceDeps & ServiceDeploymentDeps & ServiceKnobDeps>;
429
+ /** createHttpServer 的入参:两形皆可(平铺=存量,分组=推荐)。同名键两形都给时,**顶层显式键赢**
430
+ * (含显式 `undefined`)——一处装配点只该用一形,混用时以肉眼最近的那个为准。 */
196
431
  export type ServiceDeps = FlatServiceDeps & ServiceDepGroups;
432
+ /** 分组入参 → 平铺视图(createHttpServer 的第一件事)。一组都没给 ⇒ 原样返回(存量调用零开销、零形变)。 */
197
433
  export declare function flattenServiceDeps(deps: ServiceDeps): FlatServiceDeps;
198
434
  export type { TaskRequestBody } from "./wire-types.js";
435
+ /** Personalization caps: server-pinned hard limits — a UI may be stricter, never looser. */
199
436
  export declare const MAX_USER_SKILLS = 10;
437
+ /** = core `SKILL_CONTENT_MAX_CHARS`(1MB 加载门,core 1.293 起 invoke 全文零截断、超 1MB 整拒;常量在
438
+ * dist/core/runner/synthetic-tools.js:84,未从 core 包根导出,故钉本地孪生+本出处注记)。修7 曾对齐旧
439
+ * 20k 截断门([845] 飞轮考据:20k 是压缩保留区口径,invoke 时刻用错),core 1.293 撤门后本门跟随回收
440
+ * ([853]① 收口)——HTTP 面与引擎加载门同值,超限 400 fail-loud 而非引擎侧整拒后难诊断。 */
200
441
  export declare const MAX_SKILL_CONTENT_CHARS = 1048576;
201
442
  export declare const MAX_SYSTEM_PROMPT_CHARS = 16384;
443
+ /** Cap on a request's `outputSchema` (JSON-serialized) — an uncapped schema bloats the prompt + the per-turn
444
+ * validation cost. 32KB comfortably holds a rich nested schema while bounding the abuse surface. */
202
445
  export declare const MAX_OUTPUT_SCHEMA_CHARS = 32768;
446
+ /** Validate `body.skills` (caps + shape). Returns an error string (→ 400) or null when acceptable. */
203
447
  export declare function validateUserSkills(skills: unknown): string | null;
448
+ /** Verification rounds requested by a caller, clamped to a safe [1,5] (default 2). */
204
449
  export declare function clampVerifyRounds(v: unknown): number;
450
+ /**
451
+ * Managed-Agents-style HTTP/SSE service surface.
452
+ * GET /health
453
+ * POST /v1/tasks → run to completion, TaskResult JSON (synchronous)
454
+ * POST /v1/tasks/stream → SSE of TaskEvent, live tokens (synchronous, same instance)
455
+ * POST /v1/runs → async: 202 {taskId, sessionId, status}, runs in background (S1)
456
+ * GET /v1/runs/:id → run status + result (poll)
457
+ * GET /v1/runs/:id/events → SSE replay from Last-Event-ID, then tail to terminal (S2)
458
+ * POST /v1/sessions/:id/wake→ 501 (resume is implicit: re-issue a task with the same sessionId)
459
+ */
205
460
  export declare function createHttpServer(rawDeps: ServiceDeps): http.Server & {
206
461
  denyExpiredApprovals: (now: number) => Promise<void>;
207
462
  };