@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
@@ -1,10 +1,30 @@
1
- export const TITLE_MAX_CHARS = 80;
2
- const OBJECTIVE_SNIPPET_CHARS = 600;
1
+ /**
2
+ * Auto-generated session titles.
3
+ *
4
+ * SHAPE: fire-and-forget at FIRST task submit for a session (the objective is known then — no need to wait
5
+ * for the run to finish, and the web Recents gets the title sooner). Write-once (`setTitleIfNull`, store-side
6
+ * `WHERE title IS NULL`) — the USER-facing rename lives BFF-side as a label overlay (user label wins
7
+ * over engine title, two layers never fight). Generation = one cheap-model one-liner via the deployment's
8
+ * hookLlm face (summarize role → MODEL_CHEAP_ID when configured, else the main model; bounded + timed out).
9
+ *
10
+ * FAILURE POSTURE: everything is best-effort — a generation/store failure logs and leaves title null (the
11
+ * list falls back to objectivePreview). An in-process pending set dedupes concurrent submits on the same
12
+ * session; the store's IS NULL guard closes the cross-replica race (double generation costs one extra cheap
13
+ * call at worst, and exactly one title lands).
14
+ */
15
+ export const TITLE_MAX_CHARS = 80; // display budget (column holds 120; leave headroom for future prefixing)
16
+ const OBJECTIVE_SNIPPET_CHARS = 600; // prompt input bound — a title needs the gist, not the whole objective
3
17
  const LLM_TIMEOUT_MS = 15_000;
4
- const NO_ROW_RETRY_MS = 20_000;
18
+ const NO_ROW_RETRY_MS = 20_000; // session_meta register lag grace (MED3) — one in-process retry before releasing
19
+ /** 失败日志 per-cause 去重的归一窗口:取 error 文案前 N 字符当 cause 键(错误文案尾部常带
20
+ * 会话/请求级变量,前缀足以区分「凭据缺失」vs「超时」这类配置性差异)。 */
5
21
  const FAIL_CAUSE_KEY_CHARS = 80;
22
+ /** cause 键集合上限——错误文案前缀本身含变量时防无界;满了整体清空,代价只是偶发多一条 warn。 */
6
23
  const FAIL_CAUSE_CAP = 100;
24
+ /** Sessions already handled (titled, failed, or in flight) this process — one attempt per session per process.
25
+ * Bounded: evict-oldest past the cap (a worker sees a bounded set of NEW sessions between restarts anyway). */
7
26
  const SEEN_CAP = 10_000;
27
+ /** Single line, control chars stripped, hard cap; surrounding quotes (a common LLM tic) trimmed. */
8
28
  export function sanitizeTitle(raw) {
9
29
  const oneLine = raw.replace(/[\r\n]+/g, " ").replace(/[\u0000-\u001f\u007f\u200e\u200f\u202a-\u202e\u2066-\u2069]/g, "").trim();
10
30
  const unquoted = oneLine.replace(/^["'「『]+/, "").replace(/["'」』]+$/, "").trim();
@@ -12,6 +32,10 @@ export function sanitizeTitle(raw) {
12
32
  }
13
33
  export function buildTitlePrompt(objective) {
14
34
  const snippet = objective.length > OBJECTIVE_SNIPPET_CHARS ? `${objective.slice(0, OBJECTIVE_SNIPPET_CHARS)}…` : objective;
35
+ // The task text is DATA here, not instructions — fence it (with the closing tag DEFUSED inside the data so
36
+ // the objective cannot terminate the fence early) and pin the output contract. A prompt-injection attempt
37
+ // can at worst produce a weird title, which the sanitizer bounds to one line; titles are display-only and
38
+ // never re-enter any model context.
15
39
  const fenced = snippet.replace(/<(\/?)request>/gi, "<\u200b$1request>");
16
40
  return ("Write a short title (at most 8 words) summarizing the user request below. " +
17
41
  "Reply with ONLY the title on a single line — no quotes, no preamble. " +
@@ -21,6 +45,12 @@ export function buildTitlePrompt(objective) {
21
45
  }
22
46
  export function createSessionTitler(deps) {
23
47
  const seen = new Set();
48
+ // [854]⑤ 失败日志锐化:titler 失败本是 fail-soft(标题留空、列表回退 objectivePreview,零用户面),
49
+ // 但同一部署级配置性失败(凭据缺失/模型面不可达)会随每次 trial/每个新会话反复触发——per-session
50
+ // warn 在评测跑批时是纯噪音。取舍=「首条 warn + 后续同 cause 全 debug」:完全静默会让运维发现不了
51
+ // 配置问题(违背 fail-loud),每条都 warn 又淹日志;同 cause 每进程恰好 warn 一次是两全。观测面不靠
52
+ // 日志靠 metrics(session_title_total outcome 族照常逐次记账)。cause=error 文案前缀归一(见常量注释);
53
+ // 集合挂在 titler 实例上,部署里每进程恰建一只 titler ⇒ 等价 per-process。
24
54
  const warnedCauses = new Set();
25
55
  const logFailure = (sessionId, error) => {
26
56
  const cause = error.slice(0, FAIL_CAUSE_KEY_CHARS);
@@ -39,7 +69,7 @@ export function createSessionTitler(deps) {
39
69
  if (!sessionId || !objective.trim())
40
70
  return;
41
71
  if (seen.has(sessionId))
42
- return;
72
+ return; // one attempt per session per process (resubmits/turns don't re-fire)
43
73
  if (seen.size >= SEEN_CAP) {
44
74
  const oldest = seen.values().next().value;
45
75
  if (oldest !== undefined)
@@ -47,12 +77,14 @@ export function createSessionTitler(deps) {
47
77
  }
48
78
  seen.add(sessionId);
49
79
  void (async () => {
50
- let state = await deps.probeTitle(sessionId).catch(() => "untitled");
80
+ // pre-LLM probe: a point-read is orders cheaper than an LLM call (MED2 restarts/evicted seen/other
81
+ // replicas must not re-pay), and it detects the register-lag "no row yet" window (MED3).
82
+ let state = await deps.probeTitle(sessionId).catch(() => "untitled"); // probe error ⇒ optimistic (IS NULL still guards)
51
83
  if (state === "none") {
52
84
  await new Promise((r) => setTimeout(r, NO_ROW_RETRY_MS));
53
85
  state = await deps.probeTitle(sessionId).catch(() => "untitled");
54
86
  if (state === "none") {
55
- seen.delete(sessionId);
87
+ seen.delete(sessionId); // release: the NEXT submit on this session retries (no permanent miss)
56
88
  deps.metrics?.inc("session_title_total", { outcome: "row_not_yet" });
57
89
  return;
58
90
  }
@@ -74,6 +106,8 @@ export function createSessionTitler(deps) {
74
106
  }
75
107
  const landed = await deps.setTitleIfNull(sessionId, title);
76
108
  if (!landed) {
109
+ // distinguish "another writer titled it" (fine) from "row STILL absent" (UPDATE-0 on a missing row —
110
+ // release the seen slot so a later submit retries; never leave the session permanently untitled).
77
111
  const after = await deps.probeTitle(sessionId).catch(() => "titled");
78
112
  if (after === "none")
79
113
  seen.delete(sessionId);
@@ -81,7 +115,7 @@ export function createSessionTitler(deps) {
81
115
  return;
82
116
  }
83
117
  deps.metrics?.inc("session_title_total", { outcome: "set" });
84
- deps.logger?.info?.("session_titled", { sessionId, titleChars: title.length });
118
+ deps.logger?.info?.("session_titled", { sessionId, titleChars: title.length }); // content stays OUT of logs (R10 posture) — it's user-derived data
85
119
  })().catch((e) => {
86
120
  deps.metrics?.inc("session_title_total", { outcome: "error" });
87
121
  logFailure(sessionId, String(e));
@@ -1,28 +1,80 @@
1
+ /**
2
+ * Session-watch registry — the server half of the session-level SSE subscription
3
+ * (design: sema-internal `server/docs/SESSION-SSE-DESIGN.md`, 黑板 [1164]①/[1196]).
4
+ *
5
+ * One entry per watched session; N subscribers SHARE one probe loop (this is the whole point:
6
+ * it converts web-side per-client polling into one per-replica probe). Two change channels:
7
+ * - fast path: `notifyLocal(sessionId, leafId)` — an append that lands on THIS replica fans out
8
+ * synchronously (zero latency on single-replica deployments, the common TOC/local shape);
9
+ * - slow path: the probe loop reads leafId through the SAME storage face the /head probe uses.
10
+ *
11
+ * codex 复审(1.230 一轮)后的三条硬语义:
12
+ * - **revision 守卫**:notifyLocal 每次推进 bump `rev`;探针起读前抓拍 rev,读回后 rev 变=结果作废
13
+ * (陈旧慢读不得把 B 倒退回 A——latest-wins 的机制保证,不靠时序运气)。
14
+ * - **replay-on-subscribe**:已有条目携带 `last` 时,新订阅者同步补发一帧(「join 与基线原子化」的
15
+ * registry 半场;连接层再配 lastSent 去重,乱序/重复帧对下游不可见)。
16
+ * - **冷启动 warm**:新条目 lastChangeAt=0(没观测到变化就不算热)——首拍一次 hotMs 快确认后即落
17
+ * warm 拍距,直到真观测到跳变才进热窗(codex:重连风暴下 256 会话×200ms=对存储的自造尖峰)。
18
+ *
19
+ * Deliberately backend-agnostic (tidb|pg|local all go through getLeafId — the seamless-local-cloud
20
+ * invariant): no PG LISTEN/NOTIFY specialization, no shared bus. Latest-wins semantics: subscribers
21
+ * converge on the newest leafId; intermediate hops may be dropped (content still comes from tail faces).
22
+ */
23
+ /** [1196] 二轮复审:SSE 资源旋钮的 env 解析——有界正整数,坏形(NaN/0/负/超界)一律回缺省并可观测
24
+ * (坏 `SESSION_EVENTS_MAX_PROBES=foo` 若直进 Number() 会把帽谓词变恒假=无帽,拍距 NaN 进 setTimeout
25
+ * =0ms 紧循环打爆存储)。 */
1
26
  export declare function posIntEnv(raw: string | undefined, fallback: number, max?: number): number;
2
27
  export interface SessionWatchOptions {
28
+ /** Probe interval while a change was OBSERVED within `hotWindowMs` (default 200ms). */
3
29
  hotMs?: number;
30
+ /** Probe interval otherwise (default 2000ms). */
4
31
  warmMs?: number;
32
+ /** How long after the last observed change the probe stays hot (default 60s). */
5
33
  hotWindowMs?: number;
34
+ /** Cap on concurrently-probed sessions per replica (default 512). Exceeding = subscribe refused. */
6
35
  maxWatchedSessions?: number;
7
36
  }
8
37
  export declare class SessionWatchRegistry {
38
+ /** 五轮复审:owner 与 leaf **同拍原子读**——探针每拍先核 owner(被删=undefined/换主=≠条目 owner
39
+ * ⇒ dropSession 断全部订阅者),匹配才应用 leaf。跨副本 reclaim 的披露窗从 25s 心跳收紧到
40
+ * ≤一个探针拍(hot 200ms/warm 2s),且旧流在新主推进**之前**先死(owner 检查先于 leaf 应用)。 */
9
41
  private readonly getHead;
10
42
  private readonly entries;
11
43
  private readonly hotMs;
12
44
  private readonly warmMs;
13
45
  private readonly hotWindowMs;
14
46
  private readonly maxWatched;
15
- constructor(getHead: (sessionId: string) => Promise<{
47
+ constructor(
48
+ /** 五轮复审:owner 与 leaf **同拍原子读**——探针每拍先核 owner(被删=undefined/换主=≠条目 owner
49
+ * ⇒ dropSession 断全部订阅者),匹配才应用 leaf。跨副本 reclaim 的披露窗从 25s 心跳收紧到
50
+ * ≤一个探针拍(hot 200ms/warm 2s),且旧流在新主推进**之前**先死(owner 检查先于 leaf 应用)。 */
51
+ getHead: (sessionId: string) => Promise<{
16
52
  leafId: string | null | undefined;
17
53
  owner: string | null | undefined;
18
54
  }>, opts?: SessionWatchOptions);
55
+ /** Number of sessions currently probed (observability + the cap predicate). */
19
56
  watchedCount(): number;
57
+ /**
58
+ * Subscribe to head changes. Returns undefined when the per-replica probe cap is reached
59
+ * (caller answers 503 + Retry-After — the client falls back to /head polling).
60
+ * If the shared entry already knows a head (`last`), it is REPLAYED synchronously into
61
+ * `onHead` before returning — a subscriber joining an advanced entry can never miss the
62
+ * newest value (connection-level dedupe absorbs any overlap with the caller's own read).
63
+ */
20
64
  subscribe(sessionId: string, owner: string | null, onHead: (leafId: string | null) => void, onEnd?: () => void): (() => void) | undefined;
65
+ /** [1196] 三轮复审(租户轮转围栏,同副本半场):session 删除即终结条目——通知全部订阅者(onEnd,
66
+ * 路由据此断流)+ 停探针 + 弃缓存 head(新租户同键重订阅=全新世代,旧 replay 不可能渗入)。 */
21
67
  dropSession(sessionId: string): void;
68
+ /** S2 fast path: an append that landed on THIS replica. Safe to call for unwatched sessions (no-op).
69
+ * `owner` 给了就 owner-限定(五轮复审):不符=条目属旧世代 ⇒ drop(断旧流),值不投——S2 接线时
70
+ * append 落点必然知道 session owner,应当传。 */
22
71
  notifyLocal(sessionId: string, leafId: string | null, owner?: string | null, leafSeq?: number): void;
72
+ /** 立即压缩下一拍到 0ms(owner 疑云的权威核验)。探针自身 probing 串行 + 世代守卫照旧;urgent 旗
73
+ * 保证「疑云到达时已有读在飞(其快照摄于 reclaim 前=陈旧)」也必有一次**疑云后开始**的权威读。 */
23
74
  private probeNow;
24
75
  private arm;
25
76
  private probe;
77
+ /** 对**给定世代**应用一次推进(fan-out 恒按 rev 单调序)。 */
26
78
  private applyAdvance;
27
79
  }
28
80
  //# sourceMappingURL=session-watch.d.ts.map
@@ -1,3 +1,28 @@
1
+ /**
2
+ * Session-watch registry — the server half of the session-level SSE subscription
3
+ * (design: sema-internal `server/docs/SESSION-SSE-DESIGN.md`, 黑板 [1164]①/[1196]).
4
+ *
5
+ * One entry per watched session; N subscribers SHARE one probe loop (this is the whole point:
6
+ * it converts web-side per-client polling into one per-replica probe). Two change channels:
7
+ * - fast path: `notifyLocal(sessionId, leafId)` — an append that lands on THIS replica fans out
8
+ * synchronously (zero latency on single-replica deployments, the common TOC/local shape);
9
+ * - slow path: the probe loop reads leafId through the SAME storage face the /head probe uses.
10
+ *
11
+ * codex 复审(1.230 一轮)后的三条硬语义:
12
+ * - **revision 守卫**:notifyLocal 每次推进 bump `rev`;探针起读前抓拍 rev,读回后 rev 变=结果作废
13
+ * (陈旧慢读不得把 B 倒退回 A——latest-wins 的机制保证,不靠时序运气)。
14
+ * - **replay-on-subscribe**:已有条目携带 `last` 时,新订阅者同步补发一帧(「join 与基线原子化」的
15
+ * registry 半场;连接层再配 lastSent 去重,乱序/重复帧对下游不可见)。
16
+ * - **冷启动 warm**:新条目 lastChangeAt=0(没观测到变化就不算热)——首拍一次 hotMs 快确认后即落
17
+ * warm 拍距,直到真观测到跳变才进热窗(codex:重连风暴下 256 会话×200ms=对存储的自造尖峰)。
18
+ *
19
+ * Deliberately backend-agnostic (tidb|pg|local all go through getLeafId — the seamless-local-cloud
20
+ * invariant): no PG LISTEN/NOTIFY specialization, no shared bus. Latest-wins semantics: subscribers
21
+ * converge on the newest leafId; intermediate hops may be dropped (content still comes from tail faces).
22
+ */
23
+ /** [1196] 二轮复审:SSE 资源旋钮的 env 解析——有界正整数,坏形(NaN/0/负/超界)一律回缺省并可观测
24
+ * (坏 `SESSION_EVENTS_MAX_PROBES=foo` 若直进 Number() 会把帽谓词变恒假=无帽,拍距 NaN 进 setTimeout
25
+ * =0ms 紧循环打爆存储)。 */
1
26
  export function posIntEnv(raw, fallback, max = 3_600_000) {
2
27
  if (raw === undefined || raw === "")
3
28
  return fallback;
@@ -11,19 +36,33 @@ export class SessionWatchRegistry {
11
36
  warmMs;
12
37
  hotWindowMs;
13
38
  maxWatched;
14
- constructor(getHead, opts) {
39
+ constructor(
40
+ /** 五轮复审:owner 与 leaf **同拍原子读**——探针每拍先核 owner(被删=undefined/换主=≠条目 owner
41
+ * ⇒ dropSession 断全部订阅者),匹配才应用 leaf。跨副本 reclaim 的披露窗从 25s 心跳收紧到
42
+ * ≤一个探针拍(hot 200ms/warm 2s),且旧流在新主推进**之前**先死(owner 检查先于 leaf 应用)。 */
43
+ getHead, opts) {
15
44
  this.getHead = getHead;
16
45
  this.hotMs = opts?.hotMs ?? 200;
17
46
  this.warmMs = opts?.warmMs ?? 2000;
18
47
  this.hotWindowMs = opts?.hotWindowMs ?? 60_000;
19
48
  this.maxWatched = opts?.maxWatchedSessions ?? 512;
20
49
  }
50
+ /** Number of sessions currently probed (observability + the cap predicate). */
21
51
  watchedCount() {
22
52
  return this.entries.size;
23
53
  }
54
+ /**
55
+ * Subscribe to head changes. Returns undefined when the per-replica probe cap is reached
56
+ * (caller answers 503 + Retry-After — the client falls back to /head polling).
57
+ * If the shared entry already knows a head (`last`), it is REPLAYED synchronously into
58
+ * `onHead` before returning — a subscriber joining an advanced entry can never miss the
59
+ * newest value (connection-level dedupe absorbs any overlap with the caller's own read).
60
+ */
24
61
  subscribe(sessionId, owner, onHead, onEnd) {
25
62
  let e = this.entries.get(sessionId);
26
63
  if (e && e.owner !== owner) {
64
+ // 四轮复审跨副本围栏:同键不同 owner=本副本条目属被删/被 reclaim 的旧世代——整体作废
65
+ // (旧订阅者 onEnd 断流),新 owner 拿全新条目,旧租户缓存 head 绝不 replay。
27
66
  this.dropSession(sessionId);
28
67
  e = undefined;
29
68
  }
@@ -32,7 +71,7 @@ export class SessionWatchRegistry {
32
71
  return undefined;
33
72
  e = { subs: new Set(), ends: new Map(), owner, last: undefined, rev: 0, lastChangeAt: 0, probing: false };
34
73
  this.entries.set(sessionId, e);
35
- this.arm(sessionId, e, this.hotMs);
74
+ this.arm(sessionId, e, this.hotMs); // one fast confirmation tick, then warm until a REAL change
36
75
  }
37
76
  e.subs.add(onHead);
38
77
  e.ends.set(onHead, onEnd);
@@ -41,21 +80,24 @@ export class SessionWatchRegistry {
41
80
  onHead(e.last);
42
81
  }
43
82
  catch {
83
+ /* subscriber callback must not break subscribe */
44
84
  }
45
85
  }
46
86
  return () => {
47
87
  const cur = this.entries.get(sessionId);
48
88
  if (cur !== e)
49
- return;
89
+ return; // entry already replaced/removed
50
90
  e.subs.delete(onHead);
51
91
  e.ends.delete(onHead);
52
92
  if (e.subs.size === 0) {
53
93
  if (e.timer)
54
94
  clearTimeout(e.timer);
55
- this.entries.delete(sessionId);
95
+ this.entries.delete(sessionId); // cold: last subscriber gone → probe stops, entry dies
56
96
  }
57
97
  };
58
98
  }
99
+ /** [1196] 三轮复审(租户轮转围栏,同副本半场):session 删除即终结条目——通知全部订阅者(onEnd,
100
+ * 路由据此断流)+ 停探针 + 弃缓存 head(新租户同键重订阅=全新世代,旧 replay 不可能渗入)。 */
59
101
  dropSession(sessionId) {
60
102
  const e = this.entries.get(sessionId);
61
103
  if (!e)
@@ -68,17 +110,27 @@ export class SessionWatchRegistry {
68
110
  end?.();
69
111
  }
70
112
  catch {
113
+ /* 单个订阅者收尾失败不挡其余 */
71
114
  }
72
115
  }
73
116
  }
117
+ /** S2 fast path: an append that landed on THIS replica. Safe to call for unwatched sessions (no-op).
118
+ * `owner` 给了就 owner-限定(五轮复审):不符=条目属旧世代 ⇒ drop(断旧流),值不投——S2 接线时
119
+ * append 落点必然知道 session owner,应当传。 */
74
120
  notifyLocal(sessionId, leafId, owner, leafSeq) {
75
121
  const e = this.entries.get(sessionId);
76
122
  if (!e)
77
123
  return;
78
124
  if (owner !== undefined && owner !== e.owner) {
125
+ // codex-4(S2 批):owner 不符的帧**绝不凭帧行刑**——leaf_seq 随行删建归零,跨世代序不可比:
126
+ // 迟到的旧租户高序帧会假装「新于」新租户的 seq 1(凭帧 drop=误杀新流);反向新租户低序真帧也
127
+ // 会被旧条目的高水位吞掉。裁决交给**立即权威探针**(owner 原子 getHead,本就是围栏权威):
128
+ // 真 reclaim=探针 dropSession(零等待,不再候 warm 拍),误报=条目安然。值不投。
79
129
  this.probeNow(sessionId, e);
80
130
  return;
81
131
  }
132
+ // codex-3:同 owner 内的乱序守卫——post-commit continuation 不保序,迟到低序=忽略不倒退。
133
+ // (同 owner 的 delete/recreate 归零序被高水位吞=良性新鲜度问题,探针自纠——条目头注既有口径。)
82
134
  if (leafSeq !== undefined && e.lastLocalSeq !== undefined && leafSeq <= e.lastLocalSeq)
83
135
  return;
84
136
  if (leafSeq !== undefined)
@@ -87,8 +139,12 @@ export class SessionWatchRegistry {
87
139
  return;
88
140
  this.applyAdvance(e, leafId);
89
141
  }
142
+ /** 立即压缩下一拍到 0ms(owner 疑云的权威核验)。探针自身 probing 串行 + 世代守卫照旧;urgent 旗
143
+ * 保证「疑云到达时已有读在飞(其快照摄于 reclaim 前=陈旧)」也必有一次**疑云后开始**的权威读。 */
90
144
  probeNow(sessionId, e) {
91
145
  e.urgent = true;
146
+ // codex-6:读在飞时**只置旗不排拍**——0ms 拍撞 probing 会跳读后又按旗补 0ms=事件环忙转直到慢读落定
147
+ // (存储降级时整副本被搅)。在飞读的拍尾独占排拍权,旗在那里兑现。
92
148
  if (e.probing)
93
149
  return;
94
150
  if (e.timer)
@@ -101,40 +157,47 @@ export class SessionWatchRegistry {
101
157
  }
102
158
  async probe(sessionId, e) {
103
159
  if (this.entries.get(sessionId) !== e)
104
- return;
160
+ return; // entry died while the timer was pending
105
161
  if (e.probing)
106
- return;
162
+ return; // 撞上在飞读:不读不排拍(其拍尾独占排拍权,urgent 旗在那兑现——codex-6)
107
163
  {
108
164
  e.probing = true;
109
- e.urgent = false;
165
+ e.urgent = false; // 本读始于旗后=消费旗(读期间新疑云会重新置旗)
110
166
  const revAtStart = e.rev;
111
167
  try {
112
168
  const head = await this.getHead(sessionId);
169
+ // 世代守卫(二轮复审):读期间末订阅者退出+重连=同键**新条目**——陈旧读绝不许经按键查找
170
+ // 渗入新世代;只对抓拍的旧条目本体应用(旧条目已无订阅者=自然无害)。
113
171
  if (this.entries.get(sessionId) !== e)
114
172
  return;
173
+ // 五轮复审跨副本围栏(探针拍级):session 被删(owner undefined)或被 reclaim(owner 变)
174
+ // ⇒ 条目作废+订阅者断流,leaf **不应用不 fan-out**——新租户的 leafId 绝不流向旧 owner 的流。
115
175
  if (head.owner === undefined || head.owner !== e.owner) {
116
176
  this.dropSession(sessionId);
117
177
  return;
118
178
  }
119
179
  const leafId = head.leafId ?? null;
180
+ // revision 守卫:读期间 notifyLocal 推进过(rev 变)=本读陈旧,丢弃——绝不把新值倒退回旧值。
120
181
  if (e.rev === revAtStart && leafId !== e.last)
121
182
  this.applyAdvance(e, leafId);
122
183
  }
123
184
  catch {
185
+ /* transient storage error: keep probing — the SSE stream stays up */
124
186
  }
125
187
  finally {
126
188
  e.probing = false;
127
189
  }
128
190
  }
129
191
  if (this.entries.get(sessionId) !== e)
130
- return;
192
+ return; // last subscriber left during the read
131
193
  if (e.urgent) {
132
- this.arm(sessionId, e, 0);
194
+ this.arm(sessionId, e, 0); // codex-5:in-flight 吞掉的急拍在拍尾补上——欠的权威读绝不滑到 warm 拍
133
195
  return;
134
196
  }
135
197
  const hot = e.lastChangeAt !== 0 && Date.now() - e.lastChangeAt < this.hotWindowMs;
136
198
  this.arm(sessionId, e, hot ? this.hotMs : this.warmMs);
137
199
  }
200
+ /** 对**给定世代**应用一次推进(fan-out 恒按 rev 单调序)。 */
138
201
  applyAdvance(e, leafId) {
139
202
  const wasKnown = e.last !== undefined;
140
203
  e.last = leafId;
@@ -146,6 +209,7 @@ export class SessionWatchRegistry {
146
209
  fn(leafId);
147
210
  }
148
211
  catch {
212
+ /* one broken subscriber must not break the fan-out */
149
213
  }
150
214
  }
151
215
  }
@@ -1,13 +1,43 @@
1
+ /**
2
+ * B3(壳侧 [771]② 取证):SIGHUP 的 hup-pending 空闲窗。
3
+ *
4
+ * SIGHUP(壳窗口关闭打到整个进程组)≠「没人在用这只引擎」:共享引擎形态(同 config 多壳会话,引擎按
5
+ * T11 防孤儿拍骑在首壳进程组里)下 peer 会话还活着——无条件 drain 会把 peer mid-turn 斩掉(499)且窗内
6
+ * 新提交 503。这里改为:SIGHUP 不翻 draining(peer 零感知),armed 一只空闲窗——`inflight()`(bg/resume
7
+ * legs + live streams)连续 idleGraceMs 为 0 才 shutdown,任何在飞 leg 重置窗口。真孤儿(最后一窗关掉)
8
+ * 有界自灭=T11 保留;第二个 SIGHUP 升级 escalate(既有 drain 路径,操作员硬梯子)。
9
+ *
10
+ * 诚实边界:idle-but-live 的 peer(两 turn 之间静默超过窗口)会碰到引擎已退→壳 dead-respawn 1-2s 自愈
11
+ * (伤害面从 mid-turn 斩降级为冷启动)。若壳侧确认每活会话对引擎持长连,可把连接数并入 inflight 判据。
12
+ */
1
13
  export interface SighupIdleDeps {
14
+ /** This replica's in-flight legs (drainState.inflight). */
2
15
  inflight: () => number;
16
+ /** MONOTONIC-clock ms of the last non-probe HTTP request (drainState.lastActivityAt). Covers what inflight
17
+ * can't: admitted-but-not-yet-registered requests (auth/prepare/claim phases) and sub-tick short requests —
18
+ * and keeps an idle-but-live peer (still listing/browsing) alive. Absent ⇒ inflight-only semantics.
19
+ * ⚠️ 时基契约(三路复审修3,seam 对齐 D 组):lastActivityAt() 必须与本模块的 `now` 同为
20
+ * performance.now() 单调域(server.ts 的 lastActivityAt 由 D 组切 performance.now())——混用 Date.now()
21
+ * 域会让 `now() - lastActivity` 差出 epoch 量级,活性判据恒真/恒假。 */
3
22
  lastActivityAt?: () => number;
23
+ /** True once another shutdown owner is active (closing || draining) — the watch stands down. */
4
24
  isStopped: () => boolean;
25
+ /** Second SIGHUP → the normal drain path. */
5
26
  escalate: () => void;
27
+ /** Idle window expired → hard shutdown. */
6
28
  shutdown: () => void;
7
29
  idleGraceMs: number;
8
30
  log: (event: string, fields: Record<string, unknown>) => void;
31
+ /** Watch poll period (test seam). Default 1s. */
9
32
  tickMs?: number;
33
+ /** 时钟 seam(三路复审修3):armedAt/idleSince/去抖判定全走它,缺省 `() => performance.now()`(单调)。
34
+ * 之前用 Date.now():NTP/手动前跳 > grace 会让 idle-elapsed 与 activity-quiet 两个检查同 tick 通过 →
35
+ * 过早关停 peer;后跳让窗口等墙钟追回才到期;回拨还可能把操作员真第二信号误判进 1s 去抖窗。
36
+ * 本文件不对外报告 epoch 时间戳,故 Date.now() 一律不再出现。 */
10
37
  now?: () => number;
11
38
  }
39
+ /** Returns the SIGHUP handler. Call it on every SIGHUP; it arms the idle watch on the first signal and
40
+ * escalates on the second. The interval is deliberately NOT unref'd — in the orphan case it IS the
41
+ * shutdown driver (same posture as the drain tick). */
12
42
  export declare function createSighupIdleHandler(deps: SighupIdleDeps): () => void;
13
43
  //# sourceMappingURL=sighup-idle.d.ts.map
@@ -1,15 +1,24 @@
1
+ /** Returns the SIGHUP handler. Call it on every SIGHUP; it arms the idle watch on the first signal and
2
+ * escalates on the second. The interval is deliberately NOT unref'd — in the orphan case it IS the
3
+ * shutdown driver (same posture as the drain tick). */
1
4
  export function createSighupIdleHandler(deps) {
2
5
  const tickMs = deps.tickMs ?? 1_000;
3
- const now = deps.now ?? (() => performance.now());
6
+ const now = deps.now ?? (() => performance.now()); // 单调时钟(修3)——绝不用 Date.now()
4
7
  let watch;
5
8
  let idleSince = null;
6
9
  let armedAt = 0;
7
10
  return () => {
8
11
  if (deps.isStopped()) {
12
+ // A drain/shutdown owner is already active. Do NOT escalate: escalating during a graceful SIGTERM
13
+ // drain would hard-kill every in-flight leg because one terminal window closed — the exact harm B3
14
+ // exists to prevent. The operator's hard ladder stays SIGTERM×2 / SIGINT (复审 M5b).
9
15
  deps.log("sighup_ignored_shutdown_in_progress", {});
10
16
  return;
11
17
  }
12
18
  if (watch !== undefined) {
19
+ // Debounce (复审 M5a): a window close can deliver SIGHUP twice within milliseconds (kernel pty hangup
20
+ // + shell forwarding) — treating the echo as the operator's deliberate second signal would flip
21
+ // draining and 503 the peers B3 protects. A human double-press is comfortably > 1s.
13
22
  if (now() - armedAt < 1_000) {
14
23
  deps.log("sighup_duplicate_ignored", {});
15
24
  return;
@@ -39,6 +48,8 @@ export function createSighupIdleHandler(deps) {
39
48
  idleSince = now();
40
49
  return;
41
50
  }
51
+ // Activity clock: a request between ticks (or one still in its pre-registration phase) resets the
52
+ // window even though inflight sampled 0 — both clocks must be quiet for a full grace period.
42
53
  const lastActivity = deps.lastActivityAt?.() ?? 0;
43
54
  if (now() - lastActivity < deps.idleGraceMs)
44
55
  return;
@@ -1,23 +1,102 @@
1
+ /**
2
+ * Request-body → TaskSpec field normalizers (shell-host contract). Kept out of main.ts (which auto-runs the service
3
+ * on import) so they are unit-testable in isolation. Each is DEFENSIVE: a RESUME re-runs resolveSpec from the stored
4
+ * body WITHOUT the HTTP-layer 400 validation, so a malformed value must fall back to a safe default, never throw.
5
+ */
1
6
  import { type AgentDefinition, type TaskSpec } from "@sema-agent/core";
7
+ /**
8
+ * E12 — normalize `body.suggestNextPrompts` → `TaskSpec.suggestNextPrompts`. `true` = on with core defaults
9
+ * (count 3, cheap role); an object tunes `count` (clamped 1..10) / `role` (a free string — core validates it against
10
+ * `ModelRole`, an unknown role falls back to the task model). `false` / absent / non-object / garbage ⇒ undefined (off).
11
+ */
2
12
  export declare function normalizeSuggestNextPrompts(v: unknown): TaskSpec["suggestNextPrompts"];
13
+ /**
14
+ * design/131 (core 1.246) — normalize `body.resilience` → `TaskSpec.resilience`. INTENT flags only:
15
+ * `allowDegrade:false` / `allowFailover:false` let a bench/eval or critical task say "fail rather than fall back".
16
+ * `bypassBreaker` is OPERATOR-FACING (不给 wire 用户直开 — it punches through a shared circuit breaker,
17
+ * which exists to protect the provider): honored only when the request principal is an explicit operator; silently
18
+ * dropped otherwise (not a 4xx — resume re-runs this without HTTP validation, and a stripped intent flag degrades
19
+ * to today's behavior, core's own "all absent = byte-compat" posture). Only literal booleans pass; all-empty ⇒
20
+ * undefined (never an empty object — keeps the spec byte-identical for non-users).
21
+ */
3
22
  export declare function normalizeResilience(v: unknown, operator: boolean): TaskSpec["resilience"];
23
+ /**
24
+ * design/133 (core 1.251) — normalize `body.attachments` → `TaskSpec.attachments`. Core's contract is
25
+ * literal-true unions ("关闭=删 key,勿传 false"): only `true` (or, for changedFiles, an object with a sane
26
+ * `maxFiles`) survives; `false`/garbage per key is DROPPED, not forwarded. maxFiles clamped 1..100 (core caps its
27
+ * own stat cost at 20 by default; the clamp only guards against a resume replaying a wild persisted value).
28
+ * All-empty ⇒ undefined. NB resume audit: our persisted body is the FULL request JSON and resolveSpec
29
+ * is the single translation point, so consuming the field here IS the whitelist inclusion — nothing else to add.
30
+ */
4
31
  export declare function normalizeAttachments(v: unknown): TaskSpec["attachments"];
32
+ /**
33
+ * [833] rewind exclusive mode (core 1.292) — normalize `body.resumeAtMode` → `TaskSpec.resumeAtMode`. DEFENSIVE
34
+ * (the resume path re-runs resolveSpec WITHOUT the HTTP 400 gate): only the two enum values survive, and only when
35
+ * the resume-at handle actually RESOLVED (core ignores the field without `resumeAt`; keep the spec tight instead of
36
+ * shipping a dangling qualifier). Absent/garbage ⇒ undefined = core default "at" (zero regression).
37
+ */
5
38
  export declare function normalizeResumeAtMode(v: unknown, resumeAtResolved: boolean): "at" | "before" | undefined;
39
+ /** [876] 防御上限:一份请求最多带多少个 agent 定义。core 侧无上限;这里封一个防御值 —— 每个定义都进
40
+ * 系统提示(whenToUse/skills/systemPrompt 全是 prompt 载荷),不设界就是 per-turn token 成本洞(与
41
+ * MAX_USER_SKILLS 同轴)。32 足够覆盖 CC 式 `.claude/agents/` 全家桶还有余量。 */
6
42
  export declare const MAX_TASK_AGENTS = 32;
43
+ /** [876] 单条 agent 定义的形状裁决:null=合法;否则一句可 400 的英文错误(不带索引,调用方自己加)。
44
+ * 白名单外键 fail-loud —— 与 resilience/limits 的「容忍未知键」相反:agents 是能力定义,静默丢字段 =
45
+ * 定义被悄悄削(一个丢掉的 isolation 就是放宽),比 400 更危险,故整条拒。⚠️ 已知残账(core 半场):
46
+ * core 只对 allowTools 未知项 fail-loud,denyTools 未知项(如 typo)静默失效 —— 已上板请 core 镜像。
47
+ * ⚠️ 键判断必须 Object.hasOwn:`in` 走原型链,JSON 里的 "toString"/"constructor"/"__proto__" 键会被
48
+ * 误判为白名单字段,随后 SHAPES[k].ok 不是函数 ⇒ TypeError(fresh 500 / resume 砖;cross-review 复现)。 */
7
49
  export declare function taskAgentIssue(item: unknown): string | null;
50
+ /** [876] HTTP 门(fresh submit,server.ts prepareSpec):body.agents 在场必须是非空数组、每条过
51
+ * {@link taskAgentIssue}、name 数组内唯一、条数 ≤ {@link MAX_TASK_AGENTS}。返回 400 错误串或 null。
52
+ * RESUME 重放不过这道门 —— {@link taskAgentsFromBody} defensive(按条 DROP+warn,不砖 resume)。 */
8
53
  export declare function validateTaskAgents(v: unknown): string | null;
54
+ /** [876] body.agents → `TaskSpec.agents`(resolveSpec 的唯一装配点;main.ts 只 spread)。两层门:
55
+ * - 🔒 TOB 租户门:多租户(requirePrincipal===true)暂不放行 —— [876] 原文「TOB 面按租户 caps 门」,
56
+ * 当前没有 per-tenant caps 面可挂,先 fail-closed 关多租(warn `task_agents_ignored`,capabilities
57
+ * 的 `taskAgents` 同步 advertise false);单机/单用户直通(caller 是自己 worker 的 super-admin,
58
+ * 与 mcpInjection/hooks 同一姿势)。
59
+ * - defensive 归一化(RESUME 重放持久化 body 不过 HTTP 400 门):非法项按条 DROP + warn
60
+ * `task_agent_dropped`(绝不 throw 砖 resume);重名后到者 DROP;超上限截断。幸存字段按白名单拷贝
61
+ * (不透传未知键 —— 非法项已整条 drop,这里只是让持久化 body 的杂键不上 spec)。全空 ⇒ undefined。 */
9
62
  export declare function taskAgentsFromBody(raw: unknown, requirePrincipal: boolean | undefined, warn: (event: string, fields: Record<string, unknown>) => void): AgentDefinition[] | undefined;
63
+ /** [876] main.ts resolveSpec 的 agents 装配片段(可 import 真 fold,[1.211 codex L]:此前 main.ts 用内联
64
+ * 闭包,测试只能 SOURCE PIN 文本+重写同构表达式——文本锚可被「移出 resolveSpec 但保留同文」静默骗过;
65
+ * 现在行为测试直接调这个真出口,main.ts 只剩一次调用点可锚)。语义=taskAgentsFromBody 的条件 spread:
66
+ * 有幸存 agents 才挂键(absent/全 drop ⇒ 空对象,spec byte-compat)。 */
10
67
  export declare function taskAgentsSpecFragment(raw: unknown, requirePrincipal: boolean | undefined, warn: (event: string, fields: Record<string, unknown>) => void): {
11
68
  agents?: AgentDefinition[];
12
69
  };
70
+ /** [854]② — body.retainBackgroundProcesses → `TaskSpec.retainBackgroundProcesses`。core 语义(1.295
71
+ * runtask/task-registry dist 亲读):`=== true` 时任务收尾不主动收割 session 后台进程 —— host lane 上是
72
+ * 资源驻留授予,与 backgroundShell 同款单用户闸:多租户 warn 忽略(`task_retain_bg_ignored`,capability
73
+ * 同步 advertise false)。只 literal `true` 上 spec(false=core 缺省,不挂键保持 byte-compat);非 boolean
74
+ * 由 HTTP 门 400,resume 重放这里 defensive DROP(不 throw)。 */
13
75
  export declare function retainBackgroundProcessesFromBody(raw: unknown, requirePrincipal: boolean | undefined, warn: (event: string, fields: Record<string, unknown>) => void): true | undefined;
76
+ /** [1052]② — body.{excludeTools,deferTools} → `TaskSpec.{excludeTools,deferTools}`(core 1.314 工具面
77
+ * 控制批)。语义:excludeTools=roster 真卸载(schema 字节不上 wire,manifest 如实收窄);deferTools=
78
+ * design/36 延迟披露(占位上 wire,ToolSearch 激活 materialize)。两位 tighten-only(core 继承不变量:
79
+ * union 进全部子 spawn 路径),per-run 工具面收窄无跨租户面 ⇒ 无租户门(interactiveTools 同姿势)。
80
+ * DEFENSIVE(resume 重放不过 HTTP 400 门):非数组 ⇒ undefined;项非非空字符串 ⇒ 逐项 DROP;空数组 ⇒
81
+ * undefined(不挂键=core 缺省,byte-compat)。HTTP 门另有 fail-loud 400(提交面邻居姿势)。 */
14
82
  export declare function toolNameListFromBody(raw: unknown): string[] | undefined;
83
+ /** [1144]/[1146] — body.promptProfile → `TaskSpec.promptProfile`(core 1.328 R2 主件,CC LT(model_id)
84
+ * 同构双形轴)。语义:纯呈现轴不碰策略(simple=CC 212 短形面缺省;classic=长形面,可按任务/模型试分)
85
+ * ⇒ 无租户门(deferTools 同姿势);全委托树继承由 core 管。缺省不挂键(引擎缺省 simple,byte-compat)。
86
+ * DEFENSIVE(resume 重放不过 HTTP 400 门):非法值 ⇒ undefined;提交面另有 fail-loud 400(邻居姿势)。 */
15
87
  export declare function promptProfileFromBody(raw: unknown): "simple" | "classic" | undefined;
88
+ /** [854]④ — 每键的运营方上限旋钮(env,缺省不设=不封顶)。 */
16
89
  export interface TaskLimitCaps {
17
- timeoutSec?: number;
18
- maxOutputTokens?: number;
19
- maxTurns?: number;
90
+ /** TASK_TIMEOUT_MAX_SEC */ timeoutSec?: number;
91
+ /** TASK_MAX_OUTPUT_TOKENS_MAX */ maxOutputTokens?: number;
92
+ /** TASK_MAX_TURNS_MAX */ maxTurns?: number;
20
93
  }
94
+ /**
95
+ * [854]④ — normalize `body.limits` → 请求方配速意图 {timeoutSec?, maxOutputTokens?, maxTurns?}。DEFENSIVE
96
+ * (resume 重放持久化 body 不过 HTTP 400 门):仅正的有限数字存活(floor 取整),0/负/垃圾按键 DROP —— core 侧
97
+ * `timeoutSec > 0` 才生效(0=不设墙,会绕过运营方封顶)、maxTurns/maxOutputTokens 的 0 无意义。每键各自被
98
+ * 运营方上限旋钮 clamp(Math.min;旋钮缺省不设=不封顶)。全空 ⇒ undefined。
99
+ */
21
100
  export declare function normalizeLimits(v: unknown, caps: TaskLimitCaps): {
22
101
  timeoutSec?: number;
23
102
  maxOutputTokens?: number;
@@ -26,5 +105,14 @@ export declare function normalizeLimits(v: unknown, caps: TaskLimitCaps): {
26
105
  callCapByDeadline?: false;
27
106
  gracefulFinalize?: false;
28
107
  } | undefined;
108
+ /**
109
+ * [854]④ — body.limits 与 env 墙钟的合成规则(resolveSpec 的唯一 limits 装配点;run-local 无 body 车道不经此):
110
+ * - `timeoutSec`:body 给了就用 body(caller 明确配速;已在 normalizeLimits 里被 TASK_TIMEOUT_MAX_SEC 封顶)。
111
+ * body 缺席保持既有姿势 = tenancy 墙钟 + env `TASK_TIMEOUT_SEC` 只抬不降(taskWallClockSec 内 Math.max,
112
+ * 误配低值不能砍 council 预算)。注意两条纪律不叠加:「只抬不降」是 env 对内建缺省墙的规则,body 是
113
+ * caller 的显式意图,直接生效(可低于 env 墙 —— 交互短任务要更紧的配速正是本件诉求)。
114
+ * - `maxOutputTokens` / `maxTurns`:直透传(各自可选 env 上限已 clamp)。
115
+ * 全空 ⇒ undefined(spec 不挂 limits 键,byte-compat)。
116
+ */
29
117
  export declare function resolveTaskLimits(bodyLimits: unknown, caps: TaskLimitCaps, envTimeoutSec: number, requirePrincipal: boolean | undefined, big: boolean): TaskSpec["limits"];
30
118
  //# sourceMappingURL=spec-fields.d.ts.map