@sema-agent/server 1.323.0 → 2.0.1

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 (565) 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/budget-tracing.d.ts +48 -0
  46. package/dist/boot/budget-tracing.js +86 -0
  47. package/dist/boot/config-center.d.ts +62 -0
  48. package/dist/boot/config-center.js +995 -0
  49. package/dist/boot/coordinators.d.ts +33 -0
  50. package/dist/boot/coordinators.js +97 -0
  51. package/dist/boot/execution-env.d.ts +26 -0
  52. package/dist/boot/execution-env.js +370 -0
  53. package/dist/boot/leader.d.ts +27 -0
  54. package/dist/boot/leader.js +81 -0
  55. package/dist/boot/reapers.d.ts +53 -0
  56. package/dist/boot/reapers.js +252 -0
  57. package/dist/boot/resolve-spec.d.ts +70 -0
  58. package/dist/boot/resolve-spec.js +1072 -0
  59. package/dist/boot/runner-deps.d.ts +101 -0
  60. package/dist/boot/runner-deps.js +343 -0
  61. package/dist/boot/runtime-caps.d.ts +21 -0
  62. package/dist/boot/runtime-caps.js +62 -0
  63. package/dist/boot/session-faces.d.ts +57 -0
  64. package/dist/boot/session-faces.js +157 -0
  65. package/dist/boot/shutdown.d.ts +50 -0
  66. package/dist/boot/shutdown.js +129 -0
  67. package/dist/boot/stores.d.ts +32 -0
  68. package/dist/boot/stores.js +361 -0
  69. package/dist/boot/workflow-orchestration.d.ts +46 -0
  70. package/dist/boot/workflow-orchestration.js +150 -0
  71. package/dist/boot-reclaim.d.ts +19 -0
  72. package/dist/boot-reclaim.js +20 -0
  73. package/dist/brain.d.ts +25 -0
  74. package/dist/brain.js +61 -1
  75. package/dist/budget.d.ts +66 -0
  76. package/dist/budget.js +128 -4
  77. package/dist/capabilities/builtin-tools.d.ts +3 -0
  78. package/dist/capabilities/builtin-tools.js +3 -0
  79. package/dist/capabilities/center-plugins.d.ts +17 -1
  80. package/dist/capabilities/center-plugins.js +45 -4
  81. package/dist/capabilities/center-prompts.d.ts +46 -0
  82. package/dist/capabilities/center-prompts.js +57 -3
  83. package/dist/capabilities/code-review-council.d.ts +28 -0
  84. package/dist/capabilities/code-review-council.js +40 -7
  85. package/dist/capabilities/collab-wire.d.ts +2 -0
  86. package/dist/capabilities/collab-workflows.d.ts +7 -0
  87. package/dist/capabilities/collab-workflows.js +44 -1
  88. package/dist/capabilities/oa-tools.d.ts +6 -0
  89. package/dist/capabilities/oa-tools.js +10 -0
  90. package/dist/capabilities/prompt.d.ts +14 -0
  91. package/dist/capabilities/prompt.js +14 -0
  92. package/dist/capabilities/prompts/code-review.d.ts +14 -0
  93. package/dist/capabilities/prompts/code-review.js +14 -0
  94. package/dist/capabilities/prompts/identity.d.ts +6 -0
  95. package/dist/capabilities/prompts/identity.js +6 -0
  96. package/dist/capabilities/prompts/team.d.ts +4 -0
  97. package/dist/capabilities/prompts/team.js +4 -0
  98. package/dist/capabilities/repo-tools.d.ts +11 -0
  99. package/dist/capabilities/repo-tools.js +8 -0
  100. package/dist/capabilities/sandbox-file-send.d.ts +95 -0
  101. package/dist/capabilities/sandbox-file-send.js +91 -3
  102. package/dist/capabilities/scenarios.d.ts +130 -0
  103. package/dist/capabilities/scenarios.js +180 -7
  104. package/dist/capabilities/select-environment-tool.d.ts +7 -0
  105. package/dist/capabilities/select-environment-tool.js +30 -0
  106. package/dist/capabilities/send-user-file-tool.d.ts +33 -0
  107. package/dist/capabilities/send-user-file-tool.js +65 -1
  108. package/dist/capabilities/skills.d.ts +29 -0
  109. package/dist/capabilities/skills.js +13 -2
  110. package/dist/capabilities/team.d.ts +22 -0
  111. package/dist/capabilities/team.js +22 -2
  112. package/dist/capabilities/tool-defer.d.ts +26 -0
  113. package/dist/capabilities/tool-defer.js +3 -0
  114. package/dist/config-center/apply-effective.d.ts +65 -0
  115. package/dist/config-center/apply-effective.js +204 -12
  116. package/dist/config-center/http-client.d.ts +34 -0
  117. package/dist/config-center/http-client.js +68 -0
  118. package/dist/config-center/restart-signal.d.ts +22 -0
  119. package/dist/config-center/restart-signal.js +39 -0
  120. package/dist/config-center/skills-mcp.d.ts +20 -1
  121. package/dist/config-center/skills-mcp.js +42 -7
  122. package/dist/config-center/types.d.ts +92 -1
  123. package/dist/config-lkg.d.ts +12 -0
  124. package/dist/config-lkg.js +41 -0
  125. package/dist/config-provider.d.ts +78 -0
  126. package/dist/config-provider.js +165 -2
  127. package/dist/config-types.d.ts +585 -1
  128. package/dist/config.d.ts +78 -2
  129. package/dist/config.js +874 -301
  130. package/dist/degenerate-instrument.d.ts +38 -0
  131. package/dist/degenerate-instrument.js +55 -3
  132. package/dist/elicitation.d.ts +39 -0
  133. package/dist/elicitation.js +87 -3
  134. package/dist/env-facts.d.ts +61 -0
  135. package/dist/env-facts.js +73 -7
  136. package/dist/fleet/fleet-bus.d.ts +185 -0
  137. package/dist/fleet/fleet-bus.js +333 -27
  138. package/dist/fleet/subagent-tail-bus.d.ts +11 -0
  139. package/dist/fleet/subagent-tail-bus.js +33 -2
  140. package/dist/fleet-client.d.ts +38 -0
  141. package/dist/fleet-client.js +44 -9
  142. package/dist/fleet-lease.d.ts +46 -0
  143. package/dist/fleet-lease.js +73 -5
  144. package/dist/hooks/branch-transcript.d.ts +8 -0
  145. package/dist/hooks/branch-transcript.js +33 -0
  146. package/dist/hooks/cc-stop-prompt.d.ts +42 -0
  147. package/dist/hooks/cc-stop-prompt.js +43 -1
  148. package/dist/hooks/hook-llm.d.ts +15 -0
  149. package/dist/hooks/hook-llm.js +47 -0
  150. package/dist/hooks/hook-runner.d.ts +89 -0
  151. package/dist/hooks/hook-runner.js +327 -18
  152. package/dist/http/idempotency.d.ts +31 -0
  153. package/dist/http/idempotency.js +34 -0
  154. package/dist/http/principal-gate.d.ts +17 -0
  155. package/dist/http/principal-gate.js +35 -3
  156. package/dist/http/route-ctx.d.ts +36 -0
  157. package/dist/http/routes/approvals-assistant.d.ts +25 -0
  158. package/dist/http/routes/approvals-assistant.js +253 -23
  159. package/dist/http/routes/attachments.js +22 -4
  160. package/dist/http/routes/capabilities.d.ts +7 -0
  161. package/dist/http/routes/capabilities.js +202 -1
  162. package/dist/http/routes/fleet.d.ts +6 -0
  163. package/dist/http/routes/fleet.js +94 -5
  164. package/dist/http/routes/images.d.ts +17 -0
  165. package/dist/http/routes/images.js +222 -14
  166. package/dist/http/routes/leader.d.ts +7 -0
  167. package/dist/http/routes/leader.js +10 -0
  168. package/dist/http/routes/memory-policy.d.ts +6 -0
  169. package/dist/http/routes/memory-policy.js +38 -6
  170. package/dist/http/routes/notify-wake.d.ts +10 -0
  171. package/dist/http/routes/notify-wake.js +19 -3
  172. package/dist/http/routes/observability.d.ts +6 -0
  173. package/dist/http/routes/observability.js +19 -2
  174. package/dist/http/routes/runs.d.ts +15 -0
  175. package/dist/http/routes/runs.js +464 -41
  176. package/dist/http/routes/session-sync.d.ts +15 -0
  177. package/dist/http/routes/session-sync.js +229 -19
  178. package/dist/http/routes/sessions-list.d.ts +6 -0
  179. package/dist/http/routes/sessions-list.js +35 -4
  180. package/dist/http/routes/sessions.d.ts +14 -0
  181. package/dist/http/routes/sessions.js +176 -31
  182. package/dist/http/routes/side-query.d.ts +8 -0
  183. package/dist/http/routes/side-query.js +26 -1
  184. package/dist/http/routes/tasks.d.ts +18 -0
  185. package/dist/http/routes/tasks.js +501 -38
  186. package/dist/http/routes/trace-usage.d.ts +10 -0
  187. package/dist/http/routes/trace-usage.js +66 -14
  188. package/dist/http/routes/workflows.d.ts +12 -0
  189. package/dist/http/routes/workflows.js +180 -19
  190. package/dist/http/run-meta.d.ts +11 -0
  191. package/dist/http/run-meta.js +6 -0
  192. package/dist/http/send.d.ts +19 -0
  193. package/dist/http/send.js +11 -0
  194. package/dist/http/server.d.ts +255 -0
  195. package/dist/http/server.js +921 -75
  196. package/dist/http/sse-log.d.ts +15 -0
  197. package/dist/http/sse-log.js +16 -0
  198. package/dist/http/tar.d.ts +9 -0
  199. package/dist/http/tar.js +21 -5
  200. package/dist/http/wire-gate.d.ts +9 -0
  201. package/dist/http/wire-gate.js +9 -0
  202. package/dist/http/wire-types.d.ts +187 -0
  203. package/dist/http/workspace-content.d.ts +8 -0
  204. package/dist/http/workspace-content.js +10 -0
  205. package/dist/images/bake-validate.d.ts +63 -0
  206. package/dist/images/bake-validate.js +71 -1
  207. package/dist/images/manifest.d.ts +19 -0
  208. package/dist/images/manifest.js +6 -1
  209. package/dist/index.d.ts +1 -5
  210. package/dist/index.js +10 -5
  211. package/dist/key-resolver.d.ts +23 -0
  212. package/dist/key-resolver.js +27 -2
  213. package/dist/leader/diffout.d.ts +23 -0
  214. package/dist/leader/diffout.js +8 -1
  215. package/dist/leader/diffup.d.ts +32 -0
  216. package/dist/leader/diffup.js +43 -0
  217. package/dist/leader/endpoint.d.ts +20 -0
  218. package/dist/leader/endpoint.js +25 -2
  219. package/dist/leader/fanout.d.ts +60 -0
  220. package/dist/leader/fanout.js +29 -3
  221. package/dist/leader/grader-env-factory.d.ts +74 -0
  222. package/dist/leader/grader-env-factory.js +62 -3
  223. package/dist/leader/leader.d.ts +97 -0
  224. package/dist/leader/leader.js +151 -4
  225. package/dist/leader/merge.d.ts +94 -0
  226. package/dist/leader/merge.js +112 -9
  227. package/dist/leader/planner.d.ts +52 -0
  228. package/dist/leader/planner.js +47 -3
  229. package/dist/leader/repair-oracle.d.ts +61 -0
  230. package/dist/leader/repair-oracle.js +59 -1
  231. package/dist/leader/repair-wire.d.ts +78 -0
  232. package/dist/leader/repair-wire.js +79 -2
  233. package/dist/leader/wire.d.ts +79 -0
  234. package/dist/leader/wire.js +255 -8
  235. package/dist/lsp/e2b-bridge.d.ts +16 -0
  236. package/dist/lsp/e2b-bridge.js +32 -4
  237. package/dist/lsp/e2b-manager.d.ts +10 -0
  238. package/dist/lsp/e2b-manager.js +18 -2
  239. package/dist/lsp/lsp-frames.d.ts +12 -0
  240. package/dist/lsp/lsp-frames.js +12 -0
  241. package/dist/lsp/manager.d.ts +12 -0
  242. package/dist/lsp/manager.js +35 -2
  243. package/dist/lsp/types.d.ts +10 -0
  244. package/dist/lsp/ws-transport.d.ts +12 -0
  245. package/dist/lsp/ws-transport.js +53 -5
  246. package/dist/lsp-evict.d.ts +14 -0
  247. package/dist/lsp-evict.js +15 -1
  248. package/dist/main.js +530 -2129
  249. package/dist/memory-export.d.ts +1 -0
  250. package/dist/memory-export.js +4 -0
  251. package/dist/memory-scope.d.ts +49 -0
  252. package/dist/memory-scope.js +87 -4
  253. package/dist/memory-sync-client.d.ts +24 -0
  254. package/dist/memory-sync-client.js +41 -2
  255. package/dist/memory-sync.d.ts +23 -0
  256. package/dist/memory-sync.js +70 -1
  257. package/dist/model-select.d.ts +39 -0
  258. package/dist/model-select.js +42 -1
  259. package/dist/observability/cost-quota.d.ts +20 -0
  260. package/dist/observability/cost-quota.js +4 -0
  261. package/dist/observability/cost-taxonomy.d.ts +45 -0
  262. package/dist/observability/cost-taxonomy.js +34 -0
  263. package/dist/observability/logger.d.ts +1 -0
  264. package/dist/observability/logger.js +6 -0
  265. package/dist/observability/metrics.d.ts +13 -0
  266. package/dist/observability/metrics.js +63 -0
  267. package/dist/observability/otel-exporter.d.ts +9 -0
  268. package/dist/observability/otel-exporter.js +11 -3
  269. package/dist/observability/principal-context.d.ts +9 -0
  270. package/dist/observability/principal-context.js +9 -0
  271. package/dist/observability/prompt-manifest.d.ts +37 -0
  272. package/dist/observability/prompt-manifest.js +35 -1
  273. package/dist/observability/rate-limit.d.ts +10 -0
  274. package/dist/observability/rate-limit.js +1 -0
  275. package/dist/observability/tool-trace.d.ts +24 -0
  276. package/dist/observability/tool-trace.js +41 -1
  277. package/dist/orchestration/hardened-vm-runner.d.ts +107 -0
  278. package/dist/orchestration/hardened-vm-runner.js +119 -4
  279. package/dist/orchestration/hardened-vm-worker-runner.d.ts +14 -0
  280. package/dist/orchestration/hardened-vm-worker-runner.js +26 -1
  281. package/dist/orchestration/hardened-vm-worker.js +27 -0
  282. package/dist/orchestration/subagent-steer.d.ts +44 -0
  283. package/dist/orchestration/subagent-steer.js +45 -1
  284. package/dist/orchestration/workflow-agent-steer.d.ts +54 -0
  285. package/dist/orchestration/workflow-agent-steer.js +80 -1
  286. package/dist/orchestration/workflow-completion-inbox.d.ts +189 -2
  287. package/dist/orchestration/workflow-completion-inbox.js +283 -32
  288. package/dist/orchestration/workflow-notify-journal.d.ts +132 -1
  289. package/dist/orchestration/workflow-notify-journal.js +187 -13
  290. package/dist/parked-decide.d.ts +61 -0
  291. package/dist/parked-decide.js +58 -1
  292. package/dist/per-task-image.d.ts +54 -0
  293. package/dist/per-task-image.js +41 -0
  294. package/dist/plan-cache-probe.d.ts +35 -0
  295. package/dist/plan-cache-probe.js +18 -3
  296. package/dist/plugins/approval-exemption-store.d.ts +7 -0
  297. package/dist/plugins/approval-exemption-store.js +28 -2
  298. package/dist/plugins/approval-store-sql.d.ts +64 -0
  299. package/dist/plugins/approval-store-sql.js +32 -0
  300. package/dist/plugins/background-agent-store-sql.d.ts +55 -0
  301. package/dist/plugins/background-agent-store-sql.js +91 -4
  302. package/dist/plugins/background-shell-support.d.ts +98 -0
  303. package/dist/plugins/background-shell-support.js +117 -13
  304. package/dist/plugins/blob-backend.d.ts +104 -0
  305. package/dist/plugins/blob-backend.js +163 -6
  306. package/dist/plugins/breaker-state-sql.d.ts +65 -1
  307. package/dist/plugins/breaker-state-sql.js +46 -8
  308. package/dist/plugins/caching-session-store.d.ts +42 -0
  309. package/dist/plugins/caching-session-store.js +63 -3
  310. package/dist/plugins/checkpoint-store-sql.d.ts +179 -0
  311. package/dist/plugins/checkpoint-store-sql.js +239 -11
  312. package/dist/plugins/file-outcome-sink.d.ts +4 -0
  313. package/dist/plugins/file-outcome-sink.js +9 -0
  314. package/dist/plugins/file-resume-anchor-store.d.ts +20 -0
  315. package/dist/plugins/file-resume-anchor-store.js +43 -4
  316. package/dist/plugins/file-run-store.d.ts +90 -0
  317. package/dist/plugins/file-run-store.js +145 -13
  318. package/dist/plugins/file-snapshot-store-sql.d.ts +133 -1
  319. package/dist/plugins/file-snapshot-store-sql.js +178 -10
  320. package/dist/plugins/file-workflow-journal-store.d.ts +10 -0
  321. package/dist/plugins/file-workflow-journal-store.js +10 -0
  322. package/dist/plugins/fork-routing-session-store.d.ts +47 -0
  323. package/dist/plugins/fork-routing-session-store.js +51 -3
  324. package/dist/plugins/host-platform.d.ts +69 -0
  325. package/dist/plugins/host-platform.js +81 -2
  326. package/dist/plugins/image-bake-store-sql.d.ts +136 -1
  327. package/dist/plugins/image-bake-store-sql.js +241 -7
  328. package/dist/plugins/image-index-sql.d.ts +46 -0
  329. package/dist/plugins/image-index-sql.js +113 -4
  330. package/dist/plugins/k8s-bg-scripts.d.ts +34 -0
  331. package/dist/plugins/k8s-bg-scripts.js +88 -4
  332. package/dist/plugins/k8s-exec-protocol.d.ts +33 -0
  333. package/dist/plugins/k8s-exec-protocol.js +41 -0
  334. package/dist/plugins/local-checkpoint-store.d.ts +40 -0
  335. package/dist/plugins/local-checkpoint-store.js +86 -7
  336. package/dist/plugins/local-session-store.d.ts +157 -0
  337. package/dist/plugins/local-session-store.js +289 -34
  338. package/dist/plugins/local-task-attachment-store.js +14 -2
  339. package/dist/plugins/mailbox-store-sql.d.ts +38 -0
  340. package/dist/plugins/mailbox-store-sql.js +39 -6
  341. package/dist/plugins/memory-engine-pg.d.ts +30 -0
  342. package/dist/plugins/memory-engine-pg.js +122 -4
  343. package/dist/plugins/memory-engine-tidb.d.ts +26 -0
  344. package/dist/plugins/memory-engine-tidb.js +115 -5
  345. package/dist/plugins/memory-engine-vector-util.d.ts +5 -0
  346. package/dist/plugins/memory-engine-vector-util.js +5 -0
  347. package/dist/plugins/memory-resume-anchor-store.d.ts +8 -0
  348. package/dist/plugins/memory-resume-anchor-store.js +17 -0
  349. package/dist/plugins/memory-run-store.d.ts +63 -0
  350. package/dist/plugins/memory-run-store.js +73 -8
  351. package/dist/plugins/memory-session-policy-store.d.ts +17 -0
  352. package/dist/plugins/memory-session-policy-store.js +17 -0
  353. package/dist/plugins/memory-sync-store-pg.d.ts +42 -0
  354. package/dist/plugins/memory-sync-store-pg.js +45 -2
  355. package/dist/plugins/memory-sync-store-tidb.d.ts +9 -0
  356. package/dist/plugins/memory-sync-store-tidb.js +31 -1
  357. package/dist/plugins/outcome-ledger-sql.d.ts +63 -0
  358. package/dist/plugins/outcome-ledger-sql.js +97 -3
  359. package/dist/plugins/pg-approval-store.d.ts +7 -0
  360. package/dist/plugins/pg-approval-store.js +7 -0
  361. package/dist/plugins/pg-breaker-state.d.ts +6 -0
  362. package/dist/plugins/pg-breaker-state.js +6 -0
  363. package/dist/plugins/pg-checkpoint-store.d.ts +8 -0
  364. package/dist/plugins/pg-checkpoint-store.js +8 -0
  365. package/dist/plugins/pg-cost-quota.d.ts +17 -0
  366. package/dist/plugins/pg-cost-quota.js +6 -0
  367. package/dist/plugins/pg-file-snapshot-store.d.ts +6 -0
  368. package/dist/plugins/pg-file-snapshot-store.js +6 -0
  369. package/dist/plugins/pg-image-bake.d.ts +9 -0
  370. package/dist/plugins/pg-image-bake.js +9 -0
  371. package/dist/plugins/pg-image-index.d.ts +9 -0
  372. package/dist/plugins/pg-image-index.js +9 -0
  373. package/dist/plugins/pg-outcome-ledger.d.ts +9 -0
  374. package/dist/plugins/pg-outcome-ledger.js +9 -0
  375. package/dist/plugins/pg-pool.d.ts +50 -0
  376. package/dist/plugins/pg-pool.js +78 -0
  377. package/dist/plugins/pg-query.d.ts +11 -0
  378. package/dist/plugins/pg-rate-limiter.d.ts +23 -0
  379. package/dist/plugins/pg-rate-limiter.js +12 -2
  380. package/dist/plugins/pg-resume-anchor-store.d.ts +5 -0
  381. package/dist/plugins/pg-resume-anchor-store.js +5 -0
  382. package/dist/plugins/pg-run-store.d.ts +7 -0
  383. package/dist/plugins/pg-run-store.js +7 -0
  384. package/dist/plugins/pg-safe-json.d.ts +13 -0
  385. package/dist/plugins/pg-safe-json.js +40 -4
  386. package/dist/plugins/pg-session-policy-store.d.ts +5 -0
  387. package/dist/plugins/pg-session-policy-store.js +5 -0
  388. package/dist/plugins/pg-session-storage.d.ts +72 -0
  389. package/dist/plugins/pg-session-storage.js +152 -20
  390. package/dist/plugins/pg-session-store.d.ts +10 -0
  391. package/dist/plugins/pg-session-store.js +10 -0
  392. package/dist/plugins/pg-tool-result-store.d.ts +7 -0
  393. package/dist/plugins/pg-tool-result-store.js +7 -0
  394. package/dist/plugins/pg-workflow-journal-store.d.ts +7 -0
  395. package/dist/plugins/pg-workflow-journal-store.js +7 -0
  396. package/dist/plugins/pg-workflow-run-store.d.ts +7 -0
  397. package/dist/plugins/pg-workflow-run-store.js +7 -0
  398. package/dist/plugins/posix-shell-fs.d.ts +3 -0
  399. package/dist/plugins/posix-shell-fs.js +31 -1
  400. package/dist/plugins/remote-env-adb.d.ts +25 -0
  401. package/dist/plugins/remote-env-adb.js +95 -12
  402. package/dist/plugins/remote-env-e2b.d.ts +146 -0
  403. package/dist/plugins/remote-env-e2b.js +371 -40
  404. package/dist/plugins/remote-env-file-error.d.ts +34 -0
  405. package/dist/plugins/remote-env-file-error.js +37 -0
  406. package/dist/plugins/remote-env-host.d.ts +151 -0
  407. package/dist/plugins/remote-env-host.js +468 -70
  408. package/dist/plugins/remote-env-k8s.d.ts +135 -0
  409. package/dist/plugins/remote-env-k8s.js +318 -32
  410. package/dist/plugins/remote-env-local-docker.d.ts +65 -0
  411. package/dist/plugins/remote-env-local-docker.js +149 -24
  412. package/dist/plugins/remote-env-ssh.d.ts +35 -0
  413. package/dist/plugins/remote-env-ssh.js +117 -20
  414. package/dist/plugins/remote-scratchpad.d.ts +38 -0
  415. package/dist/plugins/remote-scratchpad.js +32 -2
  416. package/dist/plugins/remote-shell.d.ts +22 -0
  417. package/dist/plugins/remote-shell.js +27 -1
  418. package/dist/plugins/resume-anchor-store-sql.d.ts +28 -0
  419. package/dist/plugins/resume-anchor-store-sql.js +11 -0
  420. package/dist/plugins/roster-store-sql.d.ts +27 -0
  421. package/dist/plugins/roster-store-sql.js +54 -0
  422. package/dist/plugins/run-store-sql.d.ts +194 -0
  423. package/dist/plugins/run-store-sql.js +210 -9
  424. package/dist/plugins/s3-presign.d.ts +20 -0
  425. package/dist/plugins/s3-presign.js +49 -2
  426. package/dist/plugins/scheduler-support.d.ts +12 -0
  427. package/dist/plugins/scheduler-support.js +75 -3
  428. package/dist/plugins/send-file-ledger.d.ts +15 -0
  429. package/dist/plugins/send-file-ledger.js +53 -4
  430. package/dist/plugins/send-user-file.d.ts +77 -0
  431. package/dist/plugins/send-user-file.js +92 -4
  432. package/dist/plugins/session-policy-store-sql.d.ts +15 -0
  433. package/dist/plugins/session-policy-store-sql.js +75 -3
  434. package/dist/plugins/session-store.d.ts +45 -0
  435. package/dist/plugins/session-store.js +51 -0
  436. package/dist/plugins/sql-driver.d.ts +77 -0
  437. package/dist/plugins/sql-driver.js +4 -0
  438. package/dist/plugins/sql-escape.d.ts +8 -0
  439. package/dist/plugins/sql-escape.js +8 -0
  440. package/dist/plugins/sql-row-helpers.d.ts +25 -0
  441. package/dist/plugins/sql-row-helpers.js +25 -0
  442. package/dist/plugins/store-backend.d.ts +103 -0
  443. package/dist/plugins/store-backend.js +120 -27
  444. package/dist/plugins/store-contracts.d.ts +62 -0
  445. package/dist/plugins/store-contracts.js +3 -0
  446. package/dist/plugins/task-attachment-store.d.ts +60 -0
  447. package/dist/plugins/task-attachment-store.js +49 -3
  448. package/dist/plugins/task-list-store-sql.d.ts +25 -0
  449. package/dist/plugins/task-list-store-sql.js +21 -0
  450. package/dist/plugins/tidb-approval-store.d.ts +6 -0
  451. package/dist/plugins/tidb-approval-store.js +6 -0
  452. package/dist/plugins/tidb-breaker-state.d.ts +5 -0
  453. package/dist/plugins/tidb-breaker-state.js +5 -0
  454. package/dist/plugins/tidb-checkpoint-store.d.ts +7 -0
  455. package/dist/plugins/tidb-checkpoint-store.js +7 -0
  456. package/dist/plugins/tidb-cost-quota.d.ts +6 -0
  457. package/dist/plugins/tidb-cost-quota.js +1 -0
  458. package/dist/plugins/tidb-file-snapshot-store.d.ts +6 -0
  459. package/dist/plugins/tidb-file-snapshot-store.js +6 -0
  460. package/dist/plugins/tidb-image-bake.d.ts +8 -0
  461. package/dist/plugins/tidb-image-bake.js +8 -0
  462. package/dist/plugins/tidb-image-index.d.ts +8 -0
  463. package/dist/plugins/tidb-image-index.js +8 -0
  464. package/dist/plugins/tidb-outcome-ledger.d.ts +10 -0
  465. package/dist/plugins/tidb-outcome-ledger.js +10 -0
  466. package/dist/plugins/tidb-pool.d.ts +56 -0
  467. package/dist/plugins/tidb-pool.js +181 -1
  468. package/dist/plugins/tidb-rate-limiter.d.ts +11 -0
  469. package/dist/plugins/tidb-rate-limiter.js +5 -2
  470. package/dist/plugins/tidb-resume-anchor-store.d.ts +5 -0
  471. package/dist/plugins/tidb-resume-anchor-store.js +5 -0
  472. package/dist/plugins/tidb-run-store.d.ts +7 -0
  473. package/dist/plugins/tidb-run-store.js +7 -0
  474. package/dist/plugins/tidb-session-policy-store.d.ts +5 -0
  475. package/dist/plugins/tidb-session-policy-store.js +5 -0
  476. package/dist/plugins/tidb-session-storage.d.ts +43 -0
  477. package/dist/plugins/tidb-session-storage.js +62 -3
  478. package/dist/plugins/tidb-session-store.d.ts +142 -0
  479. package/dist/plugins/tidb-session-store.js +264 -16
  480. package/dist/plugins/tidb-tool-result-store.d.ts +5 -0
  481. package/dist/plugins/tidb-tool-result-store.js +7 -0
  482. package/dist/plugins/tidb-workflow-journal-store.d.ts +7 -0
  483. package/dist/plugins/tidb-workflow-journal-store.js +7 -0
  484. package/dist/plugins/tidb-workflow-run-store.d.ts +8 -0
  485. package/dist/plugins/tidb-workflow-run-store.js +8 -0
  486. package/dist/plugins/tool-result-store-sql.d.ts +58 -0
  487. package/dist/plugins/tool-result-store-sql.js +38 -2
  488. package/dist/plugins/web-search.d.ts +35 -0
  489. package/dist/plugins/web-search.js +45 -9
  490. package/dist/plugins/workflow-journal-limits.d.ts +10 -0
  491. package/dist/plugins/workflow-journal-limits.js +10 -0
  492. package/dist/plugins/workflow-journal-store-sql.d.ts +78 -0
  493. package/dist/plugins/workflow-journal-store-sql.js +58 -2
  494. package/dist/plugins/workflow-run-store-sql.d.ts +84 -0
  495. package/dist/plugins/workflow-run-store-sql.js +84 -6
  496. package/dist/plugins/worktree-isolation.d.ts +45 -0
  497. package/dist/plugins/worktree-isolation.js +105 -6
  498. package/dist/plugins/write-behind-counter.d.ts +56 -1
  499. package/dist/plugins/write-behind-counter.js +53 -14
  500. package/dist/principal-jwt.d.ts +24 -0
  501. package/dist/principal-jwt.js +60 -5
  502. package/dist/project-memory.d.ts +22 -0
  503. package/dist/project-memory.js +144 -15
  504. package/dist/prompts-domain-validate.d.ts +28 -0
  505. package/dist/prompts-domain-validate.js +42 -1
  506. package/dist/question.d.ts +33 -0
  507. package/dist/question.js +69 -2
  508. package/dist/resource-suspend.d.ts +21 -0
  509. package/dist/resource-suspend.js +16 -0
  510. package/dist/router/route-orchestration.d.ts +78 -0
  511. package/dist/router/route-orchestration.js +77 -0
  512. package/dist/run-local.d.ts +32 -0
  513. package/dist/run-local.js +172 -8
  514. package/dist/runs.d.ts +189 -4
  515. package/dist/runs.js +465 -24
  516. package/dist/runtime-caps-resolver.d.ts +106 -0
  517. package/dist/runtime-caps-resolver.js +89 -4
  518. package/dist/runtime-governance.d.ts +84 -0
  519. package/dist/runtime-governance.js +127 -1
  520. package/dist/sandbox-pkg-source.d.ts +23 -0
  521. package/dist/sandbox-pkg-source.js +37 -0
  522. package/dist/sealed-key.d.ts +54 -0
  523. package/dist/sealed-key.js +68 -3
  524. package/dist/security.d.ts +108 -0
  525. package/dist/security.js +145 -6
  526. package/dist/sema-registry.d.ts +21 -0
  527. package/dist/sema-registry.js +21 -0
  528. package/dist/session-leaf-bus.d.ts +31 -0
  529. package/dist/session-leaf-bus.js +32 -0
  530. package/dist/session-sync-content.d.ts +46 -0
  531. package/dist/session-sync-content.js +47 -1
  532. package/dist/session-sync-kernel.d.ts +89 -0
  533. package/dist/session-sync-kernel.js +48 -3
  534. package/dist/session-sync.d.ts +125 -0
  535. package/dist/session-sync.js +181 -8
  536. package/dist/session-titler.d.ts +26 -0
  537. package/dist/session-titler.js +41 -7
  538. package/dist/session-watch.d.ts +53 -1
  539. package/dist/session-watch.js +73 -9
  540. package/dist/sighup-idle.d.ts +30 -0
  541. package/dist/sighup-idle.js +12 -1
  542. package/dist/spec-fields.d.ts +91 -3
  543. package/dist/spec-fields.js +116 -4
  544. package/dist/task-cwd.d.ts +50 -0
  545. package/dist/task-cwd.js +68 -1
  546. package/dist/task-mcp.d.ts +47 -0
  547. package/dist/task-mcp.js +29 -0
  548. package/dist/task-settings.d.ts +175 -0
  549. package/dist/task-settings.js +226 -11
  550. package/dist/task-workflow.d.ts +67 -0
  551. package/dist/task-workflow.js +75 -8
  552. package/dist/tool-approval.d.ts +91 -0
  553. package/dist/tool-approval.js +215 -0
  554. package/dist/trace/artifacts.d.ts +9 -0
  555. package/dist/trace/artifacts.js +30 -5
  556. package/dist/trace/core-keyset-guard.d.ts +18 -0
  557. package/dist/trace/ledger-sink.d.ts +43 -0
  558. package/dist/trace/ledger-sink.js +64 -5
  559. package/dist/trace/project.d.ts +133 -0
  560. package/dist/trace/project.js +189 -2
  561. package/dist/trace/redact.d.ts +19 -0
  562. package/dist/trace/redact.js +66 -9
  563. package/dist/usage-analytics.d.ts +26 -0
  564. package/dist/usage-analytics.js +26 -3
  565. package/package.json +1 -1
@@ -1,64 +1,191 @@
1
+ /** design/158 A1: the ServiceConfig TYPE face, split out of the 1.8k-line loader module (config.ts)
2
+ * so pure-type consumers (http/server, plugins/*, hooks/hook-llm, security, brain, sema-registry)
3
+ * depend on a LEAF with zero runtime edges — this is the substantive step that dissolves the
4
+ * type-closed edges into config.ts (lens2 §A). TYPES ONLY: loadConfig and every runtime value stay
5
+ * in config.ts, which re-exports these names so existing `from "./config.js"` importers keep
6
+ * compiling unchanged. All imports below are top-level `import type` (erased — never a load edge,
7
+ * see test/module-cycle-gate.test.ts header on verbatimModuleSyntax). */
1
8
  import type { SealedKeyPoison } from "./sealed-key.js";
2
9
  import type { McpServerSpec, Model, ModelRoles } from "@sema-agent/core";
3
10
  import type { ApprovalHmacKey, PrincipalJwtKey } from "./auth-keys.js";
4
11
  import type { ElicitationThrottle } from "./elicitation.js";
5
12
  import type { InfraCostRates } from "./observability/cost-taxonomy.js";
6
13
  import type { Autonomy, CommandRule } from "./runtime-governance.js";
14
+ /** A sema-registry MCP server resolved to a core spec (env-NAME refs already → real values) plus the
15
+ * scenarios it applies to (empty = all). `resolveSpec` filters by scenario and passes `spec` to core. */
7
16
  export interface ScopedMcpServer {
8
17
  scenarios: string[];
9
18
  spec: McpServerSpec;
10
19
  }
20
+ /** Sandbox-image-pool BAKE config (IMAGE-API-DESIGN.md §P2). `enabled=false` ⇒ the /v1/images/bakes* block is
21
+ * off (the control plane never mounts). The runner-facing facts (the runner principal, the build-host CACHE_BASE,
22
+ * the default base ref) live here so image-api injects only VETTED, server-fixed values into the build.sh argv —
23
+ * operator free-text never reaches the runner. */
11
24
  export interface ImageBakeConfig {
12
25
  enabled: boolean;
26
+ /** The dedicated operator principal the bake-runner authenticates as on the internal claim/ingest routes
27
+ * (§P2.4e). A runner-only route requires the resolved principal to EXACTLY equal this. `BAKE_RUNNER_PRINCIPAL`
28
+ * (default `system:bake-runner`). */
13
29
  runnerPrincipal: string;
30
+ /** The registry host prefix the auto-registered repo/ref is built under, so an `push:true` bake row's
31
+ * `repo = ${registry}/${profile}` matches the P1 seed convention (seed-image-index.ts) and the index id
32
+ * `sha256(repo@digest)` is stable across seed and bake. `BAKE_IMAGE_REGISTRY` env; **code default = null**
33
+ * ⇒ the host-less `sema-images/<profile>` (node-local, documented non-pullable). Fleet posture (clay 拍
34
+ * 2026-07-13, SWR 弃用): `docker.io/claybobby`(海外主源;CN 兜底=内网 Gitea registry)。 */
14
35
  registry: string | null;
36
+ /** The build-host promoted fetch-once cache base injected as `--cache-base` (NEVER caller-settable — a foreign
37
+ * origin would defeat the domestic-only iron rule). `BAKE_CACHE_BASE` (e.g. http://172.17.0.1:8099). */
15
38
  cacheBase: string | null;
39
+ /** The pinned current sandbox-base ref injected as `--base-ref` when the caller omits `baseRef` (§P2.4c default).
40
+ * When NULL the server falls back to the index's latest published `sandbox-base` digest (design §P2.4c
41
+ * "SANDBOX_BASE_REF / the index's latest published base"), so a deployment that publishes a sandbox-base needs
42
+ * no separate pin. A caller-supplied baseRef must additionally be a known-published sandbox-base digest in the
43
+ * index. `SANDBOX_BASE_REF` (sha256:…). */
16
44
  defaultBaseRef: string | null;
45
+ /** The lease duration / heartbeat window (ms) — the runner heartbeats `lease_until` forward within this and
46
+ * the reaper steals an expired lease. `BAKE_LEASE_MS` (default 90000 ≈ 3× a 30s heartbeat). */
17
47
  leaseMs: number;
48
+ /** A `running` bake whose lease is stale by more than this (ms) is reaped → failed (§P2.7). Must exceed >2
49
+ * lease-heartbeat intervals. `BAKE_STALE_MS` (default 180000). */
18
50
  staleMs: number;
51
+ /** Per-principal submission rate guard window seconds + max (§P2.4c — fills the register DoS gap). 0 = off.
52
+ * `BAKE_SUBMIT_RATE_MAX` / `BAKE_SUBMIT_RATE_WINDOW_SEC` (default 10 per 60s). */
19
53
  submitRateMax: number;
20
54
  submitRateWindowSec: number;
21
55
  }
22
- export interface ServiceConfig {
56
+ /** Service configuration, read from environment — the **平铺面**(the ONE storage location for every
57
+ * field). `ServiceConfig` (bottom of this file) = this flat face **plus** nine read-only group views;
58
+ * fixtures that CONSTRUCT a config literal build this type and hand it to `attachConfigGroups`. */
59
+ export interface ServiceConfigFlat {
23
60
  port: number;
61
+ /** OpenAI-compatible model gateway base URL (without /chat/completions). */
24
62
  gatewayBaseUrl: string;
25
63
  gatewayApiKey?: string;
64
+ /** Secondary openai-compatible gateways for cross-gateway FAILOVER (same protocol + same model id).
65
+ * Tried in order after the primary when a gateway fails before streaming any content. */
26
66
  gatewayFallbackUrls: string[];
67
+ /** Optional Anthropic Messages API ROUTE (cloud). Selected for models whose `provider` is
68
+ * "anthropic" (routing is by model.provider); the local gateway serves every other provider. */
27
69
  anthropic?: {
70
+ /** `x-api-key` auth. OPTIONAL since the Anthropic-compatible Bearer path: a Bearer-only
71
+ * provider may auth by `authToken` alone. When BOTH are set, authToken wins. */
28
72
  apiKey?: string;
73
+ /** Anthropic-compatible-ecosystem `ANTHROPIC_AUTH_TOKEN` (many such providers use Bearer, not x-api-key):
74
+ * sent as `Authorization: Bearer <token>`; when set, `apiKey` is NOT sent (二选一, AUTH_TOKEN priority). */
29
75
  authToken?: string;
76
+ /** Default https://api.anthropic.com (overridden by model.baseUrl). */
30
77
  baseUrl?: string;
78
+ /** `anthropic-version` header; core default 2023-06-01. */
31
79
  version?: string;
80
+ /** Prompt-cache breakpoints on system + last tool (stable prefix). Default true. */
32
81
  cacheBreakpoints: boolean;
33
82
  maxRetries: number;
34
83
  };
84
+ /** Resilience brain stack (1.38, design/27): tiered timeouts + an optional circuit breaker layered
85
+ * UNDER the existing failover (gatewayFallbackUrls). Every field defaults to off/disabled, so the
86
+ * brain composition stays byte-identical until an operator opts in. The breaker only changes
87
+ * behaviour when paired with ≥2 gateway routes (it fast-fails a tripped primary so failover switches
88
+ * immediately instead of waiting out timeouts). BreakerState is core's in-process Map for now —
89
+ * cross-replica shared state (TiDB adapter) is a documented follow-up. */
35
90
  resilience: {
91
+ /** Abort fetch if response headers don't arrive within this many ms → retryable [network].
92
+ * Default 30s ([880] fleet audit). 0 = off. */
36
93
  connectTimeoutMs: number;
94
+ /** Cancel an open SSE stream if no content/thinking delta arrives within this many ms.
95
+ * Default 120s ([880] fleet audit — core's idle timer only arms after the first token,
96
+ * so this is the only guard for a stream that opens and never emits). 0 = off. */
37
97
  firstTokenTimeoutMs: number;
98
+ /** Mid-stream stall watchdog (1.40.1): after output starts, re-armed on every delta; silence for
99
+ * this many ms → cancel + retryable [network]. Catches a gateway that hangs AFTER the first token
100
+ * (firstTokenTimeoutMs only covers the first). 0 = off. */
38
101
  idleTimeoutMs: number;
102
+ /** Wrap the primary gateway route(s) in a circuit breaker (in-process state, per model+provider). */
39
103
  circuitBreaker: boolean;
104
+ /** Consecutive transient failures (network/server/rate_limit) that trip the breaker. */
40
105
  failureThreshold: number;
106
+ /** How long the breaker stays open before a half-open probe (ms). */
41
107
  cooldownMs: number;
42
108
  };
109
+ /** Default model the service runs tasks on. */
43
110
  model: Model;
111
+ /** Model catalog by name (1.24): always `default` + the main model's id, plus an optional cheap model.
112
+ * Used to resolve roles and to allow-list `@-model` mentions. */
44
113
  models: Record<string, Model>;
114
+ /** Per-model API-key override: catalog model NAME → the env var NAME holding that model's key (from
115
+ * sema-registry `apiKeyEnv`). Drives the spec's `getApiKeyAndHeaders` so each model/rung authenticates
116
+ * with its own upstream account; a model absent here falls back to the gateway key. Env path: empty. */
45
117
  modelApiKeyEnv: Record<string, string>;
118
+ /** sealed-box 托管密钥的解封产物:catalog model NAME → PLAINTEXT api key(`ModelEntry.
119
+ * sealedApiKey` 按 publicKeyId 选本机私钥 crypto_box_seal_open 解封,src/sealed-key.ts)。
120
+ * 🔴 只活在内存 —— 绝不落日志/盘/任何序列化面。互斥语义(registry-core 契约):模型带 sealedApiKey
121
+ * ⇒ 它的 apiKeyEnv 引用不采(sealed 压过 env-NAME,解封失败也不回落——fail-loud 见 applyEffective)。
122
+ * Env path: empty;populated ONLY by applyEffective(重赋值;keyResolver 随 boot/refresh 重建)。 */
123
+ /** 值=解封明文 或 SealedKeyPoison 毒丸(解封失败标记;key-resolver 对其任务级 throw,恒不落 gateway key 兜底)。 */
46
124
  modelApiKeys: Record<string, string | SealedKeyPoison>;
125
+ /** 配额倍率表(name+id 双键→ModelEntry.quotaWeight):weight-at-burn 的运行时源——tracer 在
126
+ * brain.call 记账点读它算 weightedTokens(lease 双轴+usage 批报)。registry apply IN-PLACE hot-apply;
127
+ * env lane 恒空(无倍率概念,weight=1 兜底)。 */
47
128
  modelQuotaWeights: Record<string, number>;
129
+ /** registry-core 0.9.0 档位组: the resolved active tier table (`tier word → catalog model name`,
130
+ * e.g. `{pro: "ds-pro"}`) fed to `RunnerDeps.tiers` (core 1.265 expandTiers — tier words + CC aliases become
131
+ * catalog keys). NO env source — populated ONLY by applyEffective from `models.tierGroups`/`activeTierGroup`
132
+ * via registry-core `resolveActiveTiers` (single semantic source). Empty = INERT (core contract). Consumed at
133
+ * Runner CONSTRUCTION (restart-to-apply, same tier as models/roles); mutateInPlace keeps the reference. */
48
134
  tiers: Record<string, string>;
135
+ /** 142-S4(registry-core 0.10.0 projects 域):center 项目登记簿的 service 消费面 —
136
+ * 键=projectId(PROJECT_ID_REGEX,generic lowercase UUID)。消费点:①`memoryScopeFor` 第三参数
137
+ * (projectId 在场 ⇒ 项目盘 v2 键 `proj:<tenant>/<projectId>`);②`defaultScopes` 作
138
+ * `TaskSpec.memory.scopes` 的种子(v2 scope 键串,OPEN 值域——本表只登记不解释)。NO env source —
139
+ * populated ONLY by applyEffective(mutateInPlace,boot+refresh 整表替换);env lane 恒空(INERT)。
140
+ * ProjectRegistration 的审计字段(registeredBy/registeredAt/notes)不进 ServiceConfig(runtime 不消费)。 */
49
141
  projects: Record<string, {
50
142
  displayName?: string;
51
143
  gitRemotes?: string[];
52
144
  defaultScopes?: string[];
53
145
  }>;
146
+ /** Role → model map (1.24): `subagent`/`summarize` → the cheap model when `MODEL_CHEAP_ID` is set
147
+ * (council lenses + compaction get cheap), `default`/`team`/`synthesize` stay on the main model. */
54
148
  roles: ModelRoles;
149
+ /**
150
+ * Session backend: in-memory (default), tidb (durable L1 event-log center), or `auto` — probe a
151
+ * configured DB at startup and fall back to in-memory if it's unreachable (for local/intranet binaries:
152
+ * "use my DB if I can reach it, else memory"). `auto` is resolved to a concrete value during startup.
153
+ * NOTE (clay 2026-07-06 wording): the env value `mysql` is accepted as an alias and normalized to the
154
+ * internal `tidb` label here — `"tidb"` in code reads as "the durable SQL store" generically (whichever
155
+ * engine DB_BACKEND picks), a historical label kept to avoid churning every comparison site.
156
+ */
55
157
  sessionBackend: "memory" | "tidb" | "auto";
158
+ /** Warm-cache idle TTL (seconds) for woken TiDB sessions; 0 disables. Requires session affinity. */
56
159
  sessionCacheTtlSec: number;
160
+ /** Rewind snapshot bounds: byte cap in MB (env REWIND_SNAPSHOT_MAX_MB). Unset = core DEFAULT_SNAPSHOT_BOUNDS
161
+ * (256 MiB / 10000 files as of core 2026-06-26 — was 2000/64MiB). BYTE-ONLY knob: raises OR lowers just the byte
162
+ * cap; file-count/ignoreDirs stay core defaults (more knobs when a case shows up). */
57
163
  rewindSnapshotMaxMb?: number;
164
+ /** Long-term memory (design/138 S1, clay 2026-07-08): the injection-first file-based memory ENGINE
165
+ * (core `RunnerDeps.memoryBackend` + `MemoryEngine`) is the ONLY memory plane — the legacy MemoryStore
166
+ * path (MEMORY_BACKEND/EMBEDDING_* SQL/file note stores) was dropped without migration. Default ON;
167
+ * `MEMORY_ENGINE=off` is the explicit kill-switch. Single-user only — main.ts gates the wiring on
168
+ * `requirePrincipal !== true` (the file basement has no tenant isolation → multi-tenant stays dark). */
58
169
  memoryEngineEnabled: boolean;
170
+ /** Memory-engine config root override (env `MEMORY_ENGINE_DIR`). Unset → core's
171
+ * `resolveMemoryEngineRoot` default chain (`AGENT_DATA_DIR` env → `~/.ai-agent`). */
59
172
  memoryEngineDir?: string;
173
+ /** N0 (夜测 2026-07-09) remote-lane plane-split override (env `MEMORY_ENGINE_REMOTE_LANE=allow`). The file
174
+ * memory engine materializes/harvests on the WORKER's local fs, while a remote exec lane (e2b/k8s/ssh/adb/
175
+ * local-docker) routes the model's file tools to the SANDBOX fs — the two planes never meet (sandbox writes
176
+ * are never harvested; the injected memory instructions just burn failing turns). Default: a remote lane
177
+ * forces memory DARK (fail-closed). `allow` re-enables it for operators whose lane genuinely shares the
178
+ * worker fs (e.g. ssh to a host on the same NFS mount). */
60
179
  memoryEngineRemoteLaneAllowed: boolean;
180
+ /** The single-user deployment's one memory scope name (env MEMORY_SCOPE; default "local" under
181
+ * single-user). Feeds `spec.memory.scope` — the new engine consumes the same normalized scopes. */
61
182
  memoryScope?: string;
183
+ /** 142-S2.5-W1: TOC 同步 client 腿 —— file memory 形态把本地记忆盘与中心(DB 权威,
184
+ * POST /v1/memory/sync/:scope)做一轮一 RTT 双向同步。env 三键:`MEMORY_SYNC_URL`(设了=开;缺省
185
+ * undefined=纯本地现状零变化)/`MEMORY_SYNC_TOKEN`(Bearer)/`MEMORY_SYNC_SCOPE`(可选,缺省=
186
+ * formatUserScope(memoryScope);已是 v2 typed key 则原样直通,见 loadConfig)。半配置 fail-loud
187
+ * (memoryEngineBackend 同款姿势);DB backend(pg/tidb)配了这些键=boot throw(中心侧自己就是
188
+ * 同步权威,不该再跑 client 腿)。 */
62
189
  memorySync?: {
63
190
  url: string;
64
191
  token: string;
@@ -66,6 +193,13 @@ export interface ServiceConfig {
66
193
  maxPushEntries?: number;
67
194
  maxPullEntries?: number;
68
195
  };
196
+ /** design/48 v1b + design/61: opt-in remote execution backend (PEER adapters, chosen by REMOTE_EXEC). Unset
197
+ * (OA/review deployments) → in-process stub env, zero behavior change. Secrets (apiKey/privateKey) ONLY from env.
198
+ * - `e2b` → per-task E2B Firecracker VM (isolated, suspendable). The default code-agent worker.
199
+ * - `k8s` → per-task Kata pod on our k3s (isolated, NOT suspendable — no managed memory
200
+ * snapshot). Self-hosted sandbox lane; auth = explicit K8S_* env or in-cluster service account.
201
+ * - `ssh` → a real host over SSH (NOT isolated/suspendable; design/61 §5). AI-orchestrated batch deploy.
202
+ * - `adb` → a real device over ADB (NOT isolated/suspendable). On-device APP testing. */
69
203
  remoteExec?: {
70
204
  provider: "e2b";
71
205
  apiKey: string;
@@ -86,6 +220,7 @@ export interface ServiceConfig {
86
220
  runtimeClass?: string;
87
221
  mountPath?: string;
88
222
  timeoutMs?: number;
223
+ /** Resource-profile knobs: sandbox pod limits (adapter defaults: 2Gi / 1 cpu). */
89
224
  memory?: string;
90
225
  cpu?: string;
91
226
  s3Snapshot?: {
@@ -127,11 +262,25 @@ export interface ServiceConfig {
127
262
  commandTimeoutMs?: number;
128
263
  env?: Record<string, string>;
129
264
  };
265
+ /**
266
+ * SVC-3 git-WORKTREE ISOLATION (design/97 CORE-6). Opt-in (WORKTREE_ISOLATION_ENABLED + WORKTREE_REPO_ROOT).
267
+ * When set, the deployment's `executionEnvFactory` is wrapped so an agent core marks `isolation:"worktree"`
268
+ * (via the TRUSTED RunInternals — never a TaskSpec) runs in its OWN detached git worktree under `repoRoot`.
269
+ * Operator-supplied ONLY (never a task input). v1 covers the `host` lane (the TOC fan-out lane); other lanes
270
+ * pass through unwrapped (a worktree-rooted REMOTE env is a follow-on). See plugins/worktree-isolation.ts.
271
+ */
130
272
  worktreeIsolation?: {
273
+ /** Operator-trusted base repo root where `git worktree add/remove/prune` run. Absolute, a git repo. */
131
274
  repoRoot: string;
275
+ /** Operator-trusted allowlist of permitted roots; `repoRoot` must be within one (defence in depth).
276
+ * Default `[repoRoot]`. */
132
277
  allowedRoots?: string[];
278
+ /** Base commit/ref for every worktree (default core's `HEAD` at creation time). */
133
279
  commit?: string;
134
280
  };
281
+ /** MCP servers from sema-registry (`/effective.mcp`), resolved at startup (env-NAME refs → values) and
282
+ * filtered per scenario in `resolveSpec`. Not env-derived — populated by the sema-registry adapter when
283
+ * present (restart-to-apply, like models/roles); undefined = no center MCP (scenarios use no MCP). */
135
284
  mcpServers?: ScopedMcpServer[];
136
285
  tidb?: {
137
286
  host: string;
@@ -141,9 +290,27 @@ export interface ServiceConfig {
141
290
  database: string;
142
291
  connectionLimit?: number;
143
292
  };
293
+ /** Which SQL engine the durable stores run on (clay 2026-06-21 PG migration; 2026-07-06 wording: canonical
294
+ * value is `mysql` = any MySQL-protocol server — MySQL, TiDB, MariaDB — over the same mysql2 pool; the env
295
+ * value `tidb` is a back-compat alias normalized to `mysql` at parse). `mysql` reads the `tidb`-named
296
+ * connection coords above (MYSQL_* env preferred, TIDB_* accepted); `pg` (PostgreSQL dialect) reads `pg`
297
+ * below. A subsystem that selects a DB backend (sessionBackend === "tidb", read as "the SQL DB") then
298
+ * runs on the engine `dbBackend` picks. TiDB is fully supported (any MySQL-protocol engine works —
299
+ * memory no longer needs a VECTOR column since design/138 moved it onto the file engine). Env: DB_BACKEND. */
144
300
  dbBackend: "mysql" | "pg" | "local" | "memory";
301
+ /** clay 拍(2026-07-27):operator 是否显式设了 DB_BACKEND。main.ts 的降级判据——**默认推导**的
302
+ * local(裸 boot)在 mkdir/ensure 失败时降级 memory + warn + gauge(auto-DB 不可达先例);
303
+ * **显式** DB_BACKEND=local 失败仍 fail-loud(operator 要了 durable,静默丢=丢数据)。 */
145
304
  dbBackendExplicit: boolean;
305
+ /** Data root for the file-backed `local` StoreBackend (clay 2026-06-26 P0.5 variant-2): the dir core's
306
+ * `FileStorageBackend` opens (sessions/memory/policy/snapshots) so a locally-run HTTP service's sessions
307
+ * SURVIVE a process restart + the resume picker is restart-visible. Resolved from `LOCAL_DATA_ROOT ??
308
+ * AGENT_DATA_DIR ?? ~/.ai-agent` — the SAME root main.ts:102 + run-local.ts:198 resolve, so the HTTP
309
+ * service and a run-local on the same box agree on one data dir (boot-locked single-instance). Only the
310
+ * `local` backend reads it. */
146
311
  localDataRoot?: string;
312
+ /** PostgreSQL connection (used iff dbBackend === "pg"). Mirror of `tidb`. Env: PG_HOST/PG_PORT/PG_USER/
313
+ * PG_PASSWORD/PG_DATABASE/PG_POOL_SIZE. */
147
314
  pg?: {
148
315
  host: string;
149
316
  port: number;
@@ -152,7 +319,20 @@ export interface ServiceConfig {
152
319
  database: string;
153
320
  connectionLimit?: number;
154
321
  };
322
+ /** S9 deeper fix (SILENT-FALLBACK): per-query DB timeout in ms — a DB-side stall must surface as a rejected
323
+ * query (which the S9 flush-streak / stalled-watchdog telemetry already counts), not an unbounded hang.
324
+ * Scope differs by engine (native support): on `pg` it is POOL-WIDE (`statement_timeout` server-side cancel +
325
+ * `query_timeout` client-side backstop — see pgPoolOptions); on `mysql` mysql2 has NO pool-level knob, so it
326
+ * overrides only the write-behind counter family's per-query timeout (the S9 pain face; default 30s there even
327
+ * when this is unset). Unset = pool-wide OFF (byte-compat: legit heavyweight statements — boot DDL, ≤64 MiB
328
+ * snapshot-blob rows — make a universal default unsafe). Env: DB_QUERY_TIMEOUT_MS (soft knob, S20 warn-on-typo). */
155
329
  dbQueryTimeoutMs?: number;
330
+ /** Object-store offload for the E19/2c file-snapshot BLOBS (clay 2026-06-26). The conversation TRANSCRIPT stays
331
+ * DB-first; ONLY the snapshot BYTES (binary file content, up to ~64 MiB/file — a perf-suboptimal TiDB blob row) move
332
+ * to MinIO. The snapshot MANIFEST (relPath→hash) STAYS in SQL (`snapshot_manifest`), so the transcript hot read never
333
+ * touches MinIO. Built (by the tidb/pg StoreBackend) into a MinioBlobBackend iff MINIO_ENDPOINT + MINIO_ACCESS_KEY +
334
+ * MINIO_SECRET_KEY are all set — else the file-snapshot stores keep the SQL `snapshot_blob` default (byte-identical to
335
+ * today). Reuses the SAME MinIO env names as the k8s workspace-snapshot lane (zero remap). */
156
336
  snapshotBlobStore?: {
157
337
  endpoint: string;
158
338
  bucket: string;
@@ -162,104 +342,428 @@ export interface ServiceConfig {
162
342
  keyPrefix?: string;
163
343
  presignTtlSec?: number;
164
344
  };
345
+ /** (a)(clay 拍 a+c,2026-07-27)SQL 默认店的 per-blob 帽显式覆写(字节)。未设 ⇒ SqlBlobBackend
346
+ * 的方言默认(tidb=6MiB=TiDB 默认 txn-entry-size-limit 真库实测矮墙,pg=不设帽);设了 ⇒ 两方言
347
+ * 都生效(调高过 entry/packet 限的部署放宽用)。软旋钮:坏值=undefined 走默认。 */
165
348
  snapshotBlobSqlMaxBytes?: number;
349
+ /** (c) 的显式逃生口:云形(mysql|pg 后端)缺 MinIO 本应 boot fail-loud(bytes-in-DB 撞包墙已两役
350
+ * 实证,大字节归对象存储);`SNAPSHOT_BLOB_ALLOW_SQL_BYTES=true` 显式接受 SQL 店 + (a) 的帽
351
+ * (单机/测试台形)。严格 "true" 判——这是安全姿势开关,不收宽松真值。 */
166
352
  snapshotBlobAllowSql: boolean;
353
+ /** plugins 域 clone host 白名单(`PLUGINS_ALLOW_HOSTS`,缺省 github.com;契约 [1361]① 双保险面,
354
+ * 消费在 capabilities/center-plugins.ts)。 */
167
355
  pluginsAllowHosts: string[];
356
+ /** 监听绑址([1934] cli 实锤:此前 `HOST` **零消费**、`listen(port)` 恒绑所有接口)。
357
+ * `BIND_HOST`(兼容 `HOST`)。显式值恒生效;缺省见 {@link resolveBindHost}——**无鉴权写面
358
+ * (allowUnauthedWrites 且零凭证)自动收窄到 127.0.0.1**,其余维持全接口(既有部署零影响)。 */
168
359
  bindHost?: string;
360
+ /** D-1 附件孤儿对象 GC 的 grace(毫秒;`ATTACHMENT_ORPHAN_GRACE_MS`,默认 1h,**0=关掉本腿**)。
361
+ * 复审 F10:同 tick 邻居(workflowOrphanGraceMs/attachmentUnboundTtlMs/scratchpadSweepTtlMs)都有
362
+ * 旋钮——存量对象巨大的部署要调慢/停掉,不该被迫取消 MinIO 配置(那会连带关掉整个附件面)。 */
169
363
  attachmentOrphanGraceMs: number;
364
+ /** workspace 浏览面(#3,[1894]①)单文件读上限(字节;`WORKSPACE_FILE_MAX_BYTES`,默认 8MiB)。
365
+ * 超限=413 结构化信封 {sizeBytes, limit} 指路 archive 口。软旋钮:坏值走默认。 */
170
366
  workspaceFileMaxBytes: number;
367
+ /** SendUserFile dual-track public-link issuance (design settled cross-repo 2026-07-14; S3_PUBLIC_* are
368
+ * [766]② cross-repo contract names — never rename). Enabled iff the adapter-held MinIO/S3 creds are set:
369
+ * `endpoint` = MINIO_ENDPOINT (the shared snapshot-lane name, wins when both are set) with S3_ENDPOINT
370
+ * as the external-S3 compat alias (one address serving both internal + public faces), plus
371
+ * MINIO_ACCESS_KEY + MINIO_SECRET_KEY (optional MINIO_REGION) — any of the three unset/empty ⇒ the whole
372
+ * block is absent and the tool is honestly not mounted (prior behavior, fail-safe default).
373
+ * `publicEndpoint` = S3_PUBLIC_ENDPOINT (falls back to S3_ENDPOINT when that is already public); absent ⇒
374
+ * the tool mounts but fail-louds at issue time with the fix (never mints an internal-host link).
375
+ * Buckets: S3_PUBLIC_BUCKET (default "sema-public") for the permanent track — its anonymous policy MUST
376
+ * be GetObject-only (`mc anonymous set-json`, NOT `set download` which also enables ListBucket and lets
377
+ * the unguessable-key capability URLs be enumerated); the private presigned track shares
378
+ * SESSION_SNAPSHOT_BUCKET (default "session-snapshots") under a "sendfile/" prefix.
379
+ * SEND_USER_FILE_URL_TTL = default ttl seconds when the tool call omits one; 0 = permanent (the settled
380
+ * default). Unset/non-integer/negative fail-SAFE to 0 — never NaN into a signature. */
171
381
  sendUserFile?: {
172
382
  endpoint: string;
173
383
  publicEndpoint?: string;
174
384
  publicBucket: string;
175
385
  privateBucket: string;
176
386
  privateKeyPrefix: string;
387
+ /** v2: endpoint the SANDBOX's presigned PUT is Host-bound to. Default publicEndpoint (an e2b cloud
388
+ * sandbox only reaches the public face); in-cluster k8s pods may prefer the internal endpoint.
389
+ * Env: SEND_USER_FILE_SANDBOX_PUT_ENDPOINT. */
177
390
  sandboxPutEndpoint?: string;
178
391
  accessKey: string;
179
392
  secretKey: string;
180
393
  region?: string;
181
394
  defaultTtlSec: number;
182
395
  };
396
+ /** Bearer token the service requires from callers (optional). Single-token deployment tier (one-tenant /
397
+ * on-prem): authenticates, but the request's `source` stays NULL (no system identity to derive). */
183
398
  authToken?: string;
399
+ /** Per-SYSTEM service credentials: token → system name (`SERVICE_AUTH_TOKENS="<tok>=oa,<tok>=cc-mcp"`).
400
+ * The request's `source` is DERIVED from which credential authenticated — never self-declared by the
401
+ * caller — and persisted on the run row (audit / per-door value attribution). Rotation/revocation is
402
+ * per system. Coexists with `authToken` during migration (that one authenticates with source=NULL). */
184
403
  authTokens: Record<string, string>;
404
+ /** Escape hatch for local dev: when true, task-submission endpoints (POST /v1/tasks[/stream], /v1/runs,
405
+ * /v1/leader) accept requests even when no `authToken` is configured. Default false = fail-closed, so a
406
+ * deploy that forgets `SERVICE_AUTH_TOKEN` REFUSES submissions (center: a worker must validate a
407
+ * service-to-service token, else anything in-cluster can submit & bill directly). `ALLOW_UNAUTHED_WRITES`.
408
+ * 有意设计(文档化):本开关只豁免「零凭证形态」的 fail-closed 503;一旦配了凭证
409
+ * (SERVICE_AUTH_TOKEN 或 TOKENS 名录),凭证必须使用——unauthed 仍 401,两 env 不叠加
410
+ * (半配置绕行=后门,刻意优先级)。 */
185
411
  allowUnauthedWrites?: boolean;
412
+ /** Optional READ-ONLY token that ALSO authorizes GET /metrics + /metrics/summary (in addition to
413
+ * authToken). Set the SAME value fleet-wide so a control plane (sema-registry) can pull every worker's
414
+ * metrics with ONE token it holds — without ever holding each worker's full `authToken`. */
186
415
  metricsToken?: string;
416
+ /** Read-only Task Trace API token (S1). Like `metricsToken` but for GET /v1/tasks[/:id/turns|/stream] — lets
417
+ * sema-registry pull worker traces fleet-wide with ONE read-only token, never holding each worker's full
418
+ * `authToken`. Read-only: cannot run tasks or change config. `TRACE_TOKEN`. */
187
419
  traceToken?: string;
420
+ /** CORS v2(2026-07-11):`CORS_ORIGIN` 接受 CSV **白名单**。单值=v1 兼容
421
+ * (无请求 Origin 也回显该值——curl/同源读者不受影响);多值=按请求 Origin 匹配回显+`Vary: Origin`
422
+ * (缓存正确性),不匹配=不设 allow-origin(浏览器拒)。未设=无 CORS 面(默认关)。 */
188
423
  corsOrigins: string[];
424
+ /** D-1 附件上传:单文件字节上限(server 权威;缺省 32 MiB)。字节本体在对象存储(clay 裁 2026-07-27
425
+ * 云形必配 MinIO),故上限不是 DB 行约束而是:①上传路径整段在内存缓冲(readRawBody reject-not-OOM,
426
+ * 上限=单请求 RAM 束)②物化路径 env.writeFile 一次成写。32 MiB 真三方(TiDB+PG+MinIO)整程回读
427
+ * 实证在店套件。`ATTACHMENT_MAX_BYTES`。 */
189
428
  attachmentMaxBytes: number;
429
+ /** D-1 附件 mime 白名单(部署策略旋钮,`ATTACHMENT_MIME_ALLOWLIST` CSV;支持 `type/*` 通配)。
430
+ * **缺省不设限**:声明 mime 是客户端自述、不可验证,不构成安全边界——真防线=尺寸上限+沙箱内消费;
431
+ * 设它是部署方的内容策略选择,不是安全开关(拒答带 415 + 明示允许集)。 */
190
432
  attachmentMimeAllowlist?: string[];
433
+ /** D-1 未绑定附件 TTL(上传后从未被任何 task 引用的行,过期由 reaper 收割;缺省 24h)。 */
191
434
  attachmentUnboundTtlMs: number;
435
+ /** Header carrying the authenticated principal (S6). Identity never comes from the body. */
192
436
  principalHeader: string;
437
+ /** Require the principal header on task requests (set true in multi-tenant production). */
193
438
  requirePrincipal: boolean;
439
+ /** Runtime governance "second baton" (center §10): operator autonomy mode, expanded TIGHTEN-ONLY onto each
440
+ * task's TaskSpec (`read-only`/`plan` → read-only hands, `ask` → shellGate always, `auto`/unset → no extra
441
+ * tightening). Per-request HOT (read live in resolveSpec); primarily sema-registry-managed, `AUTONOMY` env for
442
+ * the env/local path. See runtime-governance.ts. undefined = unmanaged. */
194
443
  autonomy?: Autonomy;
444
+ /** Runtime governance "second baton" (center §10): per-command coarse name-level rules, compiled into a
445
+ * `combinePolicies`-layered ToolPolicy on top of the deployment baseline (deny-wins, tighten-only). COARSE
446
+ * filter, NOT a sandbox (sh -c/$()/pipes bypass argv[0] → fail toward ask). Per-request HOT; sourced from
447
+ * sema-registry `EffectiveConfig.runtime` (structured config, not an env scalar). undefined = unmanaged. */
195
448
  commandPolicy?: CommandRule[];
449
+ /** Tool names that require operator approval before running (F4). Empty = no approval gate. */
196
450
  approvalRequire: string[];
451
+ /** Principals allowed to act as OPERATORS on the F4 approval queue (`/v1/approvals`): list ANY
452
+ * owner's pending + decide (approve/deny). A non-operator principal may only LIST ITS OWN pending and
453
+ * CANNOT decide (a requester approving its own high-risk op would defeat the gate). **Empty/unset =
454
+ * legacy behavior** (the shared service token IS the operator boundary — back-compat). */
197
455
  operatorPrincipals: string[];
456
+ /** Tool names that are always denied. */
198
457
  approvalDeny: string[];
458
+ /** Poll interval (ms) for an approval decision. */
199
459
  approvalPollMs: number;
460
+ /** design/45 durable-checkpoint (core 1.67): when true (+ a TiDB pool), F4 uses durable **suspend/resume**
461
+ * instead of poll-blocking — a gated tool `ask` suspends the task (status:"suspended" + checkpoint), an
462
+ * operator resumes it on any replica. Default OFF → unchanged poll-policy. `DURABLE_APPROVAL=true`. */
200
463
  durableApproval: boolean;
464
+ /** design/80 seam #2 (preemption) / design/74 ("失败≠没做完" third state): when true (+ durable mode), the
465
+ * /v1/runs durable path opts every task into core `resourceSuspend` — a budget/turns/walltime limit OR a
466
+ * scheduler preempt (`POST /v1/assistant/tasks/:id/preempt`) durably SUSPENDS the task (resumable via
467
+ * `POST /v1/assistant/tasks/:id/resume`) instead of FAILING. 🔴 PRECONDITION for `preemptSignal` to fire at
468
+ * all (core eligibility: resourceSuspend opt-in AND a durable checkpointStore AND durable tool-results AND a
469
+ * remote suspendable env — else preempt is a silent no-op). Default OFF → unchanged fail-on-limit behavior.
470
+ * `RESOURCE_SUSPEND=true`. */
201
471
  resourceSuspend: boolean;
472
+ /** Retention TTL (seconds) stamped on a resource/preempt checkpoint's `deadline` so the durable reaper GCs an
473
+ * ABANDONED (never-resumed) suspend. 0 ⇒ core default (30d, `DEFAULT_RESOURCE_SUSPEND_TTL`). A legitimate
474
+ * resume happens long before this; the deadline only reaps abandonment. `RESOURCE_SUSPEND_TTL_SEC`. */
202
475
  resourceSuspendTtlSec: number;
476
+ /** design/80 D-E (upgrade-budget): max NORMAL gated tool calls AUTO-APPROVED per run-leg before the rest
477
+ * escalate to a human — a circuit-breaker against a runaway/inflated approval loop (an AI stuck re-asking),
478
+ * NOT a cap on safety asks. 0 = OFF (every gated tool asks a human — unchanged, back-compat default). Clamped
479
+ * to ≤10000 (the hard ceiling). A Supervisor deployment sets this high to get "the AI auto-approves routine
480
+ * asks, the human only sees the rest". `APPROVAL_AUTO_BUDGET`. */
203
481
  approvalAutoBudget: number;
482
+ /** design/80 D-E (inv#2 — safety asks are never budgetable): gated tools that ALWAYS require a human even when
483
+ * the auto-budget is on — the "irreversible / never auto-approve" set. Subset of approvalRequire; empty = the
484
+ * budget may auto-approve any required tool. (In-service every gated ask is gate.kind="human", so this set is
485
+ * the ONLY way to keep an irreversible tool human-gated under an auto-budget.) `APPROVAL_NEVER_AUTO`. */
204
486
  approvalNeverAuto: string[];
487
+ /** design/80 D-G (HMAC = integrity, not identity; ✅ WIRED — the "SCAFFOLD, not yet wired" note here was STALE,
488
+ * corrected 2026-07-25: consumed by `verifyDirectDoorProof` → `verifyApprovalHmac`, reached from the live decide
489
+ * routes `http/server.ts:4796`/`:4907`): the sema-registry-managed, ROTATING key-set used to verify an
490
+ * approval-decision envelope's integrity on a direct-connect door. Empty (unset `APPROVAL_HMAC_KEYS`) ⇒ D-G
491
+ * inactive (BFF-minted-principal is the only /decide door — back-compat), which is why "wired but off" is the
492
+ * accurate description of every stock deployment. sema-registry mints + rotates the set; the shape is
493
+ * provisional (ASK-CENTER-2026-06-17). */
205
494
  approvalHmacKeys: ApprovalHmacKey[];
495
+ /** design/80 D-G: open the DIRECT-connect /decide door (a CLI/desktop client without the BFF). When true, this
496
+ * worker is in DIRECT MODE — it REQUIRES the crypto direct-door proof (signed principal JWT + HMAC envelope) and
497
+ * treats the trusted `x-agent-principal` header as UNTRUSTED (the BFF runs on a separate non-direct worker). Off
498
+ * (default) ⇒ the BFF trusted-header door is byte-identical. `DIRECT_APPROVAL_DOOR=true`. */
206
499
  directApprovalDoor: boolean;
500
+ /** design/80 D-G: the issuer's PUBLIC JWKS (non-secret, config-projected like operatorPrincipals) the worker
501
+ * verifies a direct client's principal JWT against. Empty ⇒ no trust anchor ⇒ the direct door cannot open.
502
+ * `PRINCIPAL_JWT_PUBKEYS` (JSON [{kid,alg,key(PEM),status}]). */
207
503
  principalJwtPubkeys: PrincipalJwtKey[];
504
+ /** Expected `iss` / `aud` of a direct client's principal JWT. `PRINCIPAL_JWT_ISS` / `PRINCIPAL_JWT_AUD`. */
208
505
  principalJwtIss?: string;
209
506
  principalJwtAud?: string;
507
+ /** Max accepted principal-JWT lifetime (exp − now), seconds — caps the replay window past the short-lived mandate.
508
+ * 0 = no cap. `PRINCIPAL_JWT_MAX_TTL_SEC` (default 120). */
210
509
  principalJwtMaxTtlSec: number;
510
+ /** Computed: the direct door is truly active (all anchors present). Off ⇒ direct branch never runs. */
211
511
  directDoorActive: boolean;
512
+ /** design/80 b (item 3): the INFRA cost rates the service owns (the engine prices only LLM tokens), composed
513
+ * with core's costBreakdown for the supervisor cost surface. All default 0 (= not priced, like MODEL_COST_*).
514
+ * `INFRA_COST_TOOL_CALL` / `INFRA_COST_SANDBOX_SEC` / `INFRA_COST_EGRESS_GB` (micro-USD). */
212
515
  infraCostRates: InfraCostRates;
516
+ /** v2 leader endpoint (design/50): enable POST/GET /v1/leader. Requires an ISOLATED remote-exec backend —
517
+ * REMOTE_EXEC=e2b, OR REMOTE_EXEC=k8s (Kata pod-sandbox) WITH an S3/MinIO config for the workspace-durable
518
+ * snapshot/merge (main.ts:524) — + (deploy) git on the host + a durable remote with creds. Orthogonal to the
519
+ * D-G direct door (auth axis) — a worker can be direct-mode + kata + leader at once. Default OFF. `LEADER_ENABLED=true`. */
213
520
  leaderEnabled: boolean;
521
+ /** design/68 A6 (correctness-first knob): `LEADER_FANOUT_ENABLED=false` pins the leader router to the
522
+ * deterministic single route (never fans out, zero router cost). Default true (router decides). */
214
523
  leaderFanoutEnabled: boolean;
524
+ /** A value router (S1 verdict §6.3 cash-out, src/router/route-orchestration.ts): auto-decide per-task
525
+ * orchestration — default single, escalate to the SUP prevention posture (shellGate gate) on a DETERMINISTIC
526
+ * capability-danger signal (write/exec on a NON-isolated env). DEFAULT OFF (`ROUTER_ENABLED=true`): ships the
527
+ * mechanism dark; enable after a live validation (the router only ever TIGHTENS via tightenTaskSpec + honors
528
+ * caller-explicit modes, so enabling can't loosen any gate). */
215
529
  routerEnabled: boolean;
530
+ /** S8 LLM self-orchestration (design/98): mount core's `run_workflow` tool so a strong model can author a
531
+ * deterministic JS orchestration script, run under the HARDENED-vm sandbox (src/orchestration/hardened-vm-runner.ts).
532
+ * DEFAULT OFF (`SELF_ORCHESTRATION_ENABLED=true`). When off, core is FAIL-CLOSED (tool not mounted, prompt not
533
+ * injected) — zero impact. When on: the hard runner + a CONSERVATIVE governance baseline (workflow children are
534
+ * `handsReadOnly` by default) are wired into RunnerDeps; loosen deliberately via SELF_ORCHESTRATION_MODELS etc. */
216
535
  selfOrchestrationEnabled: boolean;
536
+ /** §4 (Fork): deployment enablement for CC `/fork` (the core `Fork` tool wire). Posture default (single-user
537
+ * turnkey → ON; multi-tenant OFF); `FORK_ENABLED` overrides. 🆕 In single-user turnkey the Fork tool is mounted for
538
+ * the LLM BY DEFAULT (clay 2026-07-01; per-task opt-OUT via `body.enableFork:false`); multi-tenant is honored only
539
+ * with a per-principal entitlement resolver wired (core enforces `allowFork` per-principal, registry-core 0.1.47) —
540
+ * else fail-closed (see enableForkFromBody). */
217
541
  forkEnabled: boolean;
542
+ /** observer 开闸线(core 1.270.0/1.273.0 `RuntimeCaps.allowObservers`,`=== true` 显式
543
+ * opt-in、默认 OFF —— 极性与 allowWorkflows/allowFork 相反):`EXPERIMENTAL_OBSERVER_AGENTS=true` 在
544
+ * **单用户部署**直开(env 基线;命名先例=CC 的 CLAUDE_CODE_EXPERIMENTAL_OBSERVER_AGENTS
545
+ * 对儿)。**多租户(REQUIRE_PRINCIPAL=true)不认 env,只认 center caps 的 allowObservers 键**
546
+ * (置了也只 boot warn 一次,行为零变——半配置 fail-loud)。⚠️ 非 postureOn:observer 是实验面,
547
+ * core ships dark,单用户 turnkey 也不默认开 —— 只认显式 "true"。合成序见 applyObserverEnvOptIn。 */
218
548
  experimentalObserverAgents: boolean;
549
+ /** S8 governance baseline: the model NAMES an LLM-authored workflow script may pick (design/98 §2.5). Empty ⇒
550
+ * FAIL-CLOSED (the script cannot pick a model → spawned children use the workflow's default role). NEVER the
551
+ * whole catalog. `SELF_ORCHESTRATION_MODELS=a,b`. */
219
552
  selfOrchestrationModels: string[];
553
+ /** S8 v2 resource isolation: run the workflow script in a `worker_thread` (heap cap + terminate) instead of
554
+ * in-process. Adds DoS isolation (memory-bomb / microtask-starvation) on top of the escape membrane. Default
555
+ * OFF (in-process, faster). `SELF_ORCHESTRATION_WORKER_ISOLATION=true`. */
220
556
  selfOrchestrationWorkerIsolation: boolean;
557
+ /** SVC-1: the durable WorkflowRunStore backend for BACKGROUND workflow runs.
558
+ * `file` (DEFAULT) = the crash-safe `FileWorkflowRunStore` ledger under `localDataRoot/workflows` — a
559
+ * background run's record SURVIVES a restart, which is what lets the at-least-once completion notify re-derive
560
+ * a run's terminal state after a crash. `memory` = the ephemeral `InMemoryWorkflowRunStore` (process-local; no
561
+ * crash recovery, no notify journal) — an explicit opt-out for a single-instance/ephemeral deployment.
562
+ * `WORKFLOW_RUN_STORE=file|memory`. Only consulted when SELF_ORCHESTRATION_ENABLED. */
221
563
  workflowRunStoreBackend: "auto" | "file" | "memory";
564
+ /** SVC-1 (adversarial-review): a workflow still `running` past this age is deemed a crash-orphan by the periodic
565
+ * notify-recovery sweep (core never resumes/reaps a prior `running` row) → finalized-as-abandoned so the
566
+ * originator learns it died + the journal entry stops leaking. MUST exceed the max expected workflow runtime
567
+ * (the run store has no cross-replica liveness signal). Default 24h. `WORKFLOW_ORPHAN_GRACE_MS`. */
222
568
  workflowOrphanGraceMs: number;
569
+ /** R7 self-wake: opt-in self-wake scheduler on the single-user TOC host lane. When true (and
570
+ * the host lane is single-user, `requirePrincipal:false`), a `FileSchedulerBackend` is injected into the host
571
+ * `RemoteHostExecutionEnv` → `hasScheduler(env)` mounts core's CronCreate/CronDelete/CronList tools(L8 订正:CronCancel 旧名、Sleep 已撤除), and
572
+ * the TOC shell `SchedulerDaemon` reads the SAME store to fire due intents. DEFAULT OFF (the model self-scheduling
573
+ * is a power; multi-tenant deployments route scheduling to center, not this host daemon). `SCHEDULER_ENABLED=true`. */
223
574
  schedulerEnabled: boolean;
575
+ /** design/113 C4: host-lane project-memory injection (CLAUDE.md + git narrative). Default **ON** (subject to the
576
+ * host-lane + single-user gate), so "open like CC" works without config. `PROJECT_MEMORY_ENABLED=false` opts out.
577
+ * design/158 B4 (lens4 N8): this was `projectMemoryDisabled` — the ONE negative boolean on a ServiceConfig whose
578
+ * other 16 flags are positive `*Enabled`/`*Allowed`, so every read site had to invert twice. The retired env name
579
+ * `PROJECT_MEMORY_DISABLED` still works for one deprecation window (inverted, with a boot notice). */
224
580
  projectMemoryEnabled: boolean;
581
+ /** R7: override the shared scheduler store path. Default `SEMA_CONFIG_DIR`→`~/.sema/scheduled_tasks.json` (the
582
+ * server writer + the shell daemon reader MUST agree). `SCHEDULER_STORE_PATH`. */
225
583
  schedulerStorePath?: string;
584
+ /** Boot config-fetch budget (ms): the remote first pull races this window — inside it, boot applies
585
+ * the config synchronously (今日常态,健康中心 <300ms);过窗则 server 立即以 env/兜底起服,该次拉取
586
+ * 转后台,到货即触发一次刷新 tick 热应用(roster 开门/restartRequired 语义照旧)。真机实测:黑洞形
587
+ * 中心让同步 boot 挂 ~5.7s(SYN 重传节奏,8s fetch 超时内)——本地 TOC 用户的「启动 5 秒」就是它。
588
+ * 默认 1500;调大(≥8000)≈旧的全阻塞行为。`CONFIG_BOOT_FETCH_BUDGET_MS`。 */
226
589
  configBootFetchBudgetMs: number;
590
+ /** [1009]②/[1014]③ supportsSessionWakeup host-signal (core 1.309 ScheduleWakeup 治本位): the SHELL knows
591
+ * whether a resident daemon exists to honor session wakeups — when it spawns a headless engine with none,
592
+ * it sets `SCHEDULER_SESSION_WAKEUP=false` and core's ScheduleWakeup refuses up front (fail-loud) instead
593
+ * of parking a wakeup that would never fire (TB background-reap族 [991]②b). Default ON (the co-resident
594
+ * TOC daemon does honor its own sessions' wakeups); opt-out only — SCHEDULER_ENABLED 同门. */
227
595
  schedulerSessionWakeup: boolean;
596
+ /** R-survey/EnterPlanMode (core 1.167): MODEL-DRIVEN plan mode. When true, runs start with
597
+ * `TaskSpec.enablePlanMode:true` but NOT `handsReadOnly` (writable-start) → core auto-mounts `enter_plan_mode`
598
+ * (+ `present_plan`) so the model can self-call `enter_plan_mode` at ANY time it judges a task needs planning
599
+ * (CC EnterPlanMode parity). 🆕 DEFAULT ON (clay: model-driven plan is resident — the model decides when to plan);
600
+ * set `PLAN_MODE_ENABLED=false` to opt out. USER-driven plan (`body.permissionMode=plan` → enablePlanMode +
601
+ * handsReadOnly, read-only from start) is unaffected/independent. */
228
602
  planModeEnabled: boolean;
603
+ /** SVC-2 (adversarial-review): the workflow_journal GC retention — the reaper purges journal rows older than
604
+ * this (bounds the heaviest, TaskResult-bearing table; a resume older than it re-runs live). Default 7 days.
605
+ * `WORKFLOW_JOURNAL_RETENTION_MS`. */
229
606
  workflowJournalRetentionMs: number;
607
+ /** Retention (the store never auto-purges; reap is explicit and the
608
+ * deployer's job): the reaper deletes TERMINAL workflow_run rows older than this. SQL twins only (the
609
+ * cross-replica backend is where unbounded growth bites; the contract has no cross-scope enumeration, so the
610
+ * twins add a DISTINCT-scope sweep — the File store keeps the transcripts-like keep-everything posture).
611
+ * Running rows are never reaped (that is the orphan-grace sweep's job). Default 30 days, floor 1m.
612
+ * `WORKFLOW_RUN_RETENTION_MS`. */
230
613
  workflowRunRetentionMs: number;
614
+ /** core 1.364 durable background agents([1503] 提货单③):reaper 经 `TaskRegistry.reapDurableAgents`
615
+ * (联合 reap——条件删赢了才 release 转录 session;裸 store.reap 会 strand 转录)按 scope 清 TERMINAL
616
+ * `a*` 行,老于此值的删。SQL twins 走 DISTINCT-scope 枚举;local FileBackgroundAgentStore 单租户
617
+ * scope="default"。Default 7 days, floor 1m。`BG_AGENT_RETENTION_MS`。 */
231
618
  backgroundAgentRetentionMs: number;
619
+ /** 同批:stale-running 翻转窗——running 行的写者心跳(core 60s)断更超过此值 = 宿主进程死,行翻
620
+ * failed/stoppedBy=system(诚实终态,跨实例读面永不虚构存活)。core 契约要求 ≥10min(60s 心跳的
621
+ * 安全裕度),**下限 10min 硬钳**。Default 15min。`BG_AGENT_STALE_RUNNING_MS`。 */
232
622
  backgroundAgentStaleRunningMs: number;
623
+ /** core 1.382(design/153,[1561] 提货单④)`TaskRegistry.reconcileParkedAgents` 的 stale-claim 清算窗
624
+ * ——core 该整块逻辑被 `opts.staleClaimMaxAgeMs !== undefined` 门住,缺席 = **整块清算永不运行**
625
+ * (claim 后 claimer 进程崩死的行永久卡在"已 claim 不可再 claim"态,只能等 checkpoint TTL 自然过期;
626
+ * checkpoint 已 resolved 但 finalize 未落的行——人已做出的审批决定——同样不会被诚实翻 failed)。
627
+ * cli 复查([1575] F1)抓获:server 侧此前调用漏传本项,清算臂结构性不可达。Default 1h(claim→drive→
628
+ * finalize 正常全链本应秒级完成,1h 是给"进程慢但仍在跑"的宽松裕度)。`BG_AGENT_PARK_CLAIM_STALE_MS`。 */
233
629
  backgroundAgentParkClaimStaleMs: number;
630
+ /** [1522] MED2:agent_roster 的 TTL 清理窗(core RB-23②③ 派给部署的半场——task-scoped 具名 spawn
631
+ * 每 run 一新行,无清理=线性无界)。按行的 recorded_at_ms(最后 upsert 触碰)删;SQL twins 扩展面,
632
+ * File/Memory 店 core 自带 maxAgeMs。Default 30 days, floor 1m。`ROSTER_RETENTION_MS`。 */
234
633
  rosterRetentionMs: number;
634
+ /** 修8(三路复审 absorb-2):periodic scratchpad sweep TTL — the reaper removes per-session scratchpad dirs
635
+ * ([820]③ ensureScratchpadDir) whose mtime is older than this (env-facts.ts `sweepStaleScratchpads`; the E21
636
+ * session-DELETE purge is the primary lifecycle, this sweep is the orphan backstop). Default 7 days, floor 1m
637
+ * when enabled; `SCRATCHPAD_SWEEP_TTL_MS=0`(or negative)disables the sweep entirely. */
235
638
  scratchpadSweepTtlMs: number;
639
+ /** RFC B5 (ENV-SELECT-AND-REGION-SOURCE 抽象点②): the deployment-region package-source selector injected into
640
+ * every sandbox (`SEMA_PKG_SOURCE=cn|global|custom` — the image's pkg-source.sh hook materializes apt/pip/uv/
641
+ * npm sources at start). 🆕 Default `global` (clay 拍 2026-07-13 全部以海外为准 — official endpoints ride
642
+ * env-first onto EXISTING images, no rebake); CN deployments set `SANDBOX_PKG_SOURCE=cn`; `none` = inject
643
+ * nothing (the pre-2026-07-13 unset behavior — byte-identical sandbox). Operator env `SANDBOX_PKG_SOURCE`;
644
+ * per-region via the registry effective-config (shell B3) later. */
236
645
  sandboxPkgSource?: string;
646
+ /** Auto-generate a session title at first submit (one cheap-model call per
647
+ * session, write-once; the user rename layer is BFF-side). Default ON; `SESSION_AUTO_TITLE=false` opts out. */
237
648
  sessionAutoTitle: boolean;
649
+ /** RFC A2 (clay 拍 A 切片先行): mount the model-facing `SelectEnvironment` tool (spec.tools, 判定②(a)) when
650
+ * the per-task image chain is live (k8s + image catalog). Default ON; `SELECT_ENVIRONMENT_TOOL=false` opts out. */
238
651
  selectEnvironmentTool: boolean;
652
+ /** RFC A1: inject structured sandbox envFacts into the task (`TaskSpec.envFacts` — core 1.240.0 whitelist
653
+ * field; rendered as the `# Environment` block, sanitized+bounded core-side). Default ON —
654
+ * facts only ride when the deployment actually knows them (image binding/pkgSource/egress), absent = block
655
+ * unchanged. `SANDBOX_ENV_FACTS=false` opts out. */
239
656
  envFactsEnabled: boolean;
657
+ /** ③ sensitive-path write DENY set (core 1.295 `createSensitivePathPolicy`, composed into the fs-write gate
658
+ * fold on host-semantics lanes — task-settings.ts). The PATTERN SET is core's call (RECOMMENDED_SENSITIVE_PATTERNS
659
+ * — .env/.ssh/keys/.git hooks+config/cloud creds/histories, rationale documented core-side); the server only
660
+ * passes it through. `SENSITIVE_WRITE_PATTERNS` (comma-separated): explicitly set = FULL REPLACEMENT of the
661
+ * recommended set (not a merge); `off` or an empty value = disabled (empty array); unset = core's recommended
662
+ * set. Deny composes deny-wins, so a session exemption / acceptEdits auto-allow never crosses it. */
240
663
  sensitiveWritePatterns: string[];
664
+ /** [1557]§四 opt-in (cli[1555]② finding, core[1556] suggested mechanism): CC manual-family permission modes
665
+ * (default/auto/acceptEdits) gate every fs WRITE hand tool (Write/Edit/NotebookEdit) but never touched Bash —
666
+ * a model can `echo -n '…' > file` straight past the write-approval card. `MANUAL_MODE_SHELL_GATE` opts a
667
+ * deployment into ALSO tightening `TaskSpec.shellGate` on those same modes (core `bashReversibilityProbe`
668
+ * under `"classify"` only asks on constructively-irreversible commands — shell redirects etc.; plain reads
669
+ * auto-allow). Absent/unset = `undefined` = **zero behavior change** (this is a tighten-ONLY opt-in, never a
670
+ * default — a deployment must explicitly choose it); `"always"` = CC-strict parity (every Bash asks). Any
671
+ * other value (incl. `"off"`) is treated as unset — this knob has no "off" value to opt BACK OUT with once a
672
+ * session's baseline already tightened elsewhere (tightenTaskSpec would reject that as a loosen anyway). */
241
673
  manualModeShellGate?: "always" | "classify";
674
+ /** [803]④ defer face (EXPERIMENTAL, default OFF): mark the default scenario's LONG-TAIL first-party tools
675
+ * (today = SelectEnvironment only) `defer:true` (core tool-disclosure: the model sees a placeholder until it
676
+ * ToolSearch-loads the schema). Assessment says the win is marginal for us (spec.tools total ≈4.2k tokens, of
677
+ * which Agent + the Task quartet ≈3.2k are CC-core posture = must stay inline; the deferrable tail is
678
+ * ≈200-500 tokens/turn) and SendUserFile is deliberately NOT in the defer set (proactive-delivery tool —
679
+ * hiding it behind ToolSearch suppresses exactly the spontaneous use it exists for). MCP tools are ALWAYS
680
+ * auto-deferred by core regardless of this flag. `TOOL_DEFER_LONGTAIL=true` opts in. */
242
681
  toolDeferLongtail: boolean;
682
+ /** LSP code-intelligence tool (design/64 §13.1): mount core's `lsp` tool, routed to an E2B LSP sidecar. Requires
683
+ * REMOTE_EXEC=e2b. Default OFF (the on-the-fly language-server install is heavy until an E2B template bakes it).
684
+ * `LSP_ENABLED=true`. */
243
685
  lspEnabled: boolean;
686
+ /** TOC local LSP (core 1.190 `NodeLspManager`, host lane only): mount core's `lsp` tool over LOCAL `child_process`
687
+ * language servers (CC `services/lsp` parity). Unlike the sandbox lane it needs NO baked template — just the
688
+ * server binary on PATH, and it DEGRADES gracefully (ENOENT → grep/read) + spawns lazily/cached, so it is DEFAULT
689
+ * ON for the host lane (CC-parity); set `LSP_HOST_ENABLED=false` to opt out. (`REMOTE_EXEC=host` only — ssh/adb/
690
+ * local-docker can't reach a local child process to the right filesystem.)
691
+ * design/158 B4 (lens4 N7): this lane used to share `LSP_ENABLED` with `lspEnabled` above — one env name driving
692
+ * two OPPOSITE defaults. It now has its own knob; `LSP_ENABLED=false` remains a back-compat host opt-out (with a
693
+ * boot notice naming the replacement) and `LSP_HOST_ENABLED` wins whenever it is set. */
244
694
  lspHostEnabled: boolean;
695
+ /** Graceful drain: how long SIGTERM waits for in-flight turns (live streams + bg/resume legs on this
696
+ * instance) to finish before the hard shutdown. During drain, new billable submissions get 503+Retry-After and
697
+ * /health carries `draining:true`. Default 10min (an interactive turn is minutes, not seconds — a
698
+ * 10s hard-cut would kill long turns); floor 10s. Env: DRAIN_GRACE_MS. SIGINT (Ctrl-C dev
699
+ * ergonomics) and a SECOND SIGTERM skip the drain and hard-stop immediately. */
245
700
  drainGraceMs: number;
701
+ /** B3 (shell [771]②): SIGHUP idle window. SIGHUP means "the process-group owner's terminal went away" — but
702
+ * under the shared-engine shape (several shell sessions on one config, engine rides the FIRST shell's process
703
+ * group per the T11 anti-orphan call) other live sessions may still be using this engine, so an unconditional
704
+ * drain kills a peer mid-turn (499) and 503s new submits. Instead SIGHUP arms an idle watch: shut down only
705
+ * after `inflight()` (bg/resume legs + live streams) has been 0 for this long, WITHOUT flipping `draining`
706
+ * (peers stay fully served). A true orphan (last window closed) self-terminates when the window expires —
707
+ * T11 stands, just bounded instead of immediate. A SECOND SIGHUP (or SIGTERM) escalates to the normal drain
708
+ * path. Default 120s, floor 5s. Env: SIGHUP_IDLE_GRACE_MS. */
246
709
  sighupIdleGraceMs: number;
710
+ /** E23 (shell-host contract): inbound MCP elicitation HITL. When enabled, the service mounts `RunnerDeps.onElicit` + the
711
+ * `POST /v1/elicitations/:id/respond` route so an opted-in MCP server (`McpServerSpec.elicitation`, itself default
712
+ * OFF) can ask the END USER for input mid-tool-call. LIVE-ONLY (no durable suspend; lost on crash/replica-change).
713
+ * DEFAULT OFF (fail-closed): absent ⇒ `onElicit` is not wired ⇒ core advertises NO elicitation capability to any
714
+ * server (doubly fail-closed with the per-server opt-in). `MCP_ELICITATION_ENABLED=true`. The throttle is the
715
+ * deployment's job (core caps nothing) — bound concurrency/total/burst/TTL so an over-eager server can't flood. */
247
716
  mcpElicitation: {
248
717
  enabled: boolean;
249
718
  throttle: ElicitationThrottle;
250
719
  };
720
+ /** §4④: AskUserQuestion LIVE-stream HITL — mount the QuestionCoordinator on `RunnerDeps.onQuestion` + the
721
+ * `POST /v1/questions/:id/respond` route so the agent's AskUserQuestion tool routes to a live human over the run's
722
+ * stream (the durable-suspend leg is wired separately). A CC cap → posture-gated (single-user turnkey →
723
+ * ON; multi-tenant opt-in); `ASK_QUESTION_ENABLED=true/false` overrides. */
251
724
  askQuestionEnabled: boolean;
725
+ /** [816]/[820]② live tool-approval HITL — mount the ToolApprovalCoordinator on `RunnerDeps.onAsk` + the
726
+ * `POST /v1/tool-approvals/:id/respond` route so a policy `ask` (the fs-write gate, ask-lists, non-durable safety
727
+ * asks) routes to the live human as the CC three-choice card on the run's stream (core 1.290 sync-ask leg). A CC
728
+ * cap → posture-gated like askQuestion (single-user turnkey → ON; multi-tenant opt-in);
729
+ * `TOOL_APPROVAL_ENABLED=true/false` overrides. Absent ⇒ core's headless auto-deny stands ([819]⑤ fail-closed). */
252
730
  toolApprovalEnabled: boolean;
731
+ /** [824]① (clay A 案 = workflow 权限全面 CC parity): workflow 子 agent 的默认权限基线与主 LLM 同权(base `{}`)。
732
+ * 安全论证:主 LLM 与子 agent 同 root 同信任域,主 LLM 本就能写这棵树([816] ask 门照管),单独钳子 agent 的
733
+ * 安全增益≈0(只防绕路不防直路的门不是边界);实测产品代价=[814]A 死锁。`WORKFLOW_AGENTS_READONLY=true` =
734
+ * TOB 保守部署的可选旋钮:workflow 子 agent 基线加 handsReadOnly(1.190 前的旧默认)。默认 off。 */
253
735
  workflowAgentsReadOnly: boolean;
736
+ /** Sandbox-image-pool BAKE job API (IMAGE-API-DESIGN.md §P2): enable /v1/images/bakes* (operator-submit + the
737
+ * bake-runner claim/ingest control plane). Requires a TiDB pool (the durable bake row/event/lease tables) AND
738
+ * a NON-EMPTY `operatorPrincipals` (boot-asserted — never a world-writable build-host-RCE door). Default OFF.
739
+ * `IMAGE_BAKES_ENABLED=true`. */
254
740
  imageBakes: ImageBakeConfig;
741
+ /** prove-before-scale stopgap: log every tool call (pre+post, incl. resumed legs) for diagnosis. `TOOL_TRACE=true`. Default OFF. */
255
742
  toolTrace: boolean;
743
+ /** Task Trace API (S1): persist the agent's reasoning/thinking into the durable run event log (for the CC-style
744
+ * trace UI). Default ON; `TRACE_THINKING=false` disables capture for sensitive deployments. Redacted on persist. */
256
745
  traceThinking: boolean;
746
+ /** Structured log level. */
257
747
  logLevel: "debug" | "info" | "warn" | "error";
748
+ /** Per-principal request cap per minute on task/run endpoints. 0 disables. */
258
749
  rateLimitPerMin: number;
750
+ /** Operator CEILING on per-task cost (USD) / tokens (1.37 budget gate). A request may ask for a
751
+ * LOWER limit but is capped to this; 0/unset = no ceiling. The review gateway sets these to stop a
752
+ * single task from burning the shared cloud key. Enforced by core (failed + errorCode budget.*). */
259
753
  maxTaskCostUsd: number;
260
754
  maxTaskTokens: number;
755
+ /** Per-principal CUMULATIVE cost ceiling (USD) within a rolling window — blocks a tenant's NEXT task
756
+ * once their accumulated spend crosses it. 0/unset = no per-principal quota. */
261
757
  maxPrincipalCostUsd: number;
758
+ /** Rolling window (seconds) for the per-principal cost quota. Default 86400 (1 day). */
262
759
  costQuotaWindowSec: number;
760
+ /** Degradation to a cheaper model `to` (a catalog name) instead of hard-failing (core 1.39/1.40):
761
+ * - **prospective** (1.40, `atCostFraction`): near-budget — at `atCostFraction × maxCostUsd` switch at
762
+ * the turn boundary (needs a per-task cost ceiling).
763
+ * - **reactive** (1.39, `reactive`): brain-level — on `rate_limit` / `breaker_open` from the primary,
764
+ * serve `to` instead (a degrading brain wrapped OUTERMOST). `downgradeOn` picks the triggers.
765
+ * Unset (`MODEL_DEGRADE_TO` absent) = disabled. NOTE: pick a `to` whose gateway/account is NOT the one
766
+ * being rate-limited, else reactive degrade hits the same limit. */
263
767
  degrade?: {
264
768
  to: string;
265
769
  atCostFraction: number;
@@ -267,26 +771,59 @@ export interface ServiceConfig {
267
771
  downgradeOn?: ("rate_limit" | "breaker_open")[];
268
772
  toSupportsImages: boolean;
269
773
  };
774
+ /** Quality-gate cascade ladder (core 1.45 `runCascade`, opt-in via `cascade:true`): catalog model
775
+ * names cheapest→strongest. A task runs on the cheap rung; if it doesn't pass the gate (default =
776
+ * `status==="completed"`, i.e. the cheap model failed) it escalates to the next. Empty/unset =
777
+ * cascade unavailable. e.g. MODEL_CASCADE_LADDER=deepseek-flash,deepseek-pro. ⚠️ each rung is a COLD
778
+ * re-run (write tools execute again) — use it for read-only / idempotent tasks. */
270
779
  cascadeLadder: string[];
780
+ /** Optional OTLP/HTTP metrics export (1.37 observability). When the endpoint is set, the metric
781
+ * registry is periodically pushed to an OTel collector; unset = disabled (zero overhead). */
271
782
  otel?: {
272
783
  endpoint: string;
273
784
  intervalMs: number;
274
785
  serviceName: string;
275
786
  headers: Record<string, string>;
276
787
  };
788
+ /** Expire pending approvals older than this (seconds). 0 disables the reaper. */
277
789
  approvalTimeoutSec: number;
790
+ /** Background reaper interval (seconds) for stale runs / expired approvals / rate windows. */
278
791
  reapIntervalSec: number;
792
+ /** TTL (seconds) for offloaded tool results in the durable store. Must comfortably exceed a run's
793
+ * recoverable window (a resumed run may re-fetch an old ref after a cross-replica wake); a completed
794
+ * run only needs the preview. Reaped by the background reaper. Default 86400 (24h). */
279
795
  toolResultTtlSec: number;
796
+ /** A `running` run whose heartbeat is older than this is treated as stalled/dead. The running
797
+ * instance heartbeats every 30s, so this only needs to exceed a couple of heartbeat intervals
798
+ * (default 120s) — it is NOT tied to event cadence (a quiet-but-alive subagent still heartbeats). */
280
799
  runStaleSec: number;
800
+ /** §4 staged-import 的**每会话租约**判定为陈旧的秒数(默认 600)。Phase A 遇到超过这个时长没有活动的租约就
801
+ * **接管**它 —— 这是「客户端在 Phase A 与 Phase B 之间崩掉」的自愈通道(此前那种会话到进程重启前永远
802
+ * 推不上云,而且没有任何客户端可调的释放动作)。租约按 entries 上传腿的活动刷新,所以大会话不会被误判。
803
+ * 设 0 = 关掉接管(退回旧行为:只能靠重启释放)。 */
281
804
  syncImportLeaseStaleSec: number;
805
+ /** Git host API base (e.g. https://git.example.com) for the read-only repo tools (code-review). */
282
806
  gitApiBaseUrl?: string;
807
+ /** Read-only Git host token (server-side only; never reaches the model). */
283
808
  gitApiToken?: string;
809
+ /** S3-TOB 设计 §1.3:memory 持久面方言(env MEMORY_ENGINE_BACKEND,缺省 file)。boot-only。 */
284
810
  memoryEngineBackend: "file" | "pg" | "tidb";
811
+ /** CC `workflowSizeGuideline` (advisory, injected into the Workflow tool card via
812
+ * core `RunnerDeps.workflowLimits.sizeGuideline`). env WORKFLOW_SIZE_GUIDELINE; unset = absent =
813
+ * byte-compat (core treats missing/unrestricted identically). boot-only (per-task card snapshot). */
285
814
  workflowSizeGuideline?: "small" | "medium" | "large" | "unrestricted";
815
+ /** Scenario used when a request omits `scenario`. NOTE: per-principal scenario governance does
816
+ * NOT live on config — the ruling `{scenario, allowlist}` arrives per-request via center's caps view
817
+ * (runtime-caps-resolver.scenarioRuling), single semantic source in center; raw assignments never hit a wire. */
286
818
  defaultScenario: string;
819
+ /** Directory of baked-in skill Markdown files, loaded once at startup. */
287
820
  skillsDir: string;
821
+ /** OA backend base URL for the `oa` scenario tools (read /api/v1, write /api/assets). */
288
822
  oaApiBaseUrl?: string;
823
+ /** Shared trust token forwarded to OA (= OA AGENT_SERVICE_TOKEN); OA enforces per-principal RBAC. */
289
824
  oaServiceToken?: string;
825
+ /** `oa` 场景的"开 Gitea issue"工具配置(OA AI 请求#5);仅当 OA_ISSUE_TOKEN 配置时启用。token 来自 env,不入模型/日志。
826
+ * 上线建议:OA_ISSUE_TOKEN 用**最小权限**(仅 issue:write 的 scope),别用全权 token。 */
290
827
  oaIssue?: {
291
828
  baseUrl: string;
292
829
  owner: string;
@@ -294,13 +831,60 @@ export interface ServiceConfig {
294
831
  token: string;
295
832
  defaultLabels?: number[];
296
833
  };
834
+ /** Central sema registry (sema-registry). When set, the service pulls the effective config
835
+ * on boot (and refreshes) and applies it OVER the env defaults — env is the fallback. Logical config
836
+ * only (model roster/roles/teams); secrets/gateways stay in this service's env.
837
+ * `dryRun` (SEMA_REGISTRY_DRY_RUN=true, legacy CONFIG_CENTER_DRY_RUN): pull + LOG what the registry would change vs the env-derived
838
+ * config, but do NOT apply it — a safe-rollout verification step before flipping to live.
839
+ * `worker` (SEMA_REGISTRY_WORKER=<name>, legacy CONFIG_CENTER_WORKER; injected per-worker by the reconciler): scopes the pull to
840
+ * that worker's roster via `/effective?worker=<name>`. Unset → the global roster (backward compatible). */
297
841
  configCenter?: {
298
842
  baseUrl: string;
299
843
  token: string;
300
844
  dryRun: boolean;
301
845
  worker?: string;
302
846
  };
847
+ /** Dual-mode config SOURCE (DUAL-MODE-DESIGN §4): "remote" (sema-registry HTTP) | "local" (.env + config.d
848
+ * via @sema-agent/registry-core FileConfigStore) | unset → remote if SEMA_REGISTRY_URL (legacy CONFIG_CENTER_URL) is set, else pure-env.
849
+ * Env: CONFIG_PROVIDER. The same resolver/EffectiveConfig either way (can't drift). */
303
850
  configProvider?: string;
851
+ /** Root dir holding `config.d/<domain>.json` for the local config source. Env: CONFIG_LOCAL_DIR. */
304
852
  configLocalDir?: string;
305
853
  }
854
+ /** 组:store(持久化)—— DB 引擎三态、session 后端、SQL coords、快照 BLOB / SendUserFile 对象存储。 */
855
+ export type ServiceStoreConfig = Pick<ServiceConfigFlat, "sessionBackend" | "sessionCacheTtlSec" | "rewindSnapshotMaxMb" | "dbBackend" | "dbBackendExplicit" | "localDataRoot" | "tidb" | "pg" | "dbQueryTimeoutMs" | "snapshotBlobStore" | "snapshotBlobSqlMaxBytes" | "snapshotBlobAllowSql" | "sendUserFile">;
856
+ /** 组:modelPlane(模型面)—— 网关坐标、Anthropic 路线、韧性旋钮、主/廉价 model entry、role 表、降级梯。 */
857
+ export type ServiceModelPlaneConfig = Pick<ServiceConfigFlat, "gatewayBaseUrl" | "gatewayApiKey" | "gatewayFallbackUrls" | "anthropic" | "resilience" | "model" | "models" | "modelApiKeyEnv" | "modelApiKeys" | "modelQuotaWeights" | "tiers" | "projects" | "roles" | "cascadeLadder" | "degrade">;
858
+ /** 组:approval(审批 / HITL 门)。`directDoorActive` 无 env 解析腿(装配层三域合取的产物),但语义上
859
+ * 就是本组的门状态,故进组;`parseApprovalDomain` 的返回类型相应是 `Omit<…, "directDoorActive">`。 */
860
+ export type ServiceApprovalConfig = Pick<ServiceConfigFlat, "approvalRequire" | "approvalDeny" | "approvalPollMs" | "approvalTimeoutSec" | "approvalAutoBudget" | "approvalNeverAuto" | "approvalHmacKeys" | "durableApproval" | "directApprovalDoor" | "directDoorActive" | "resourceSuspend" | "resourceSuspendTtlSec" | "askQuestionEnabled" | "toolApprovalEnabled" | "mcpElicitation" | "sensitiveWritePatterns" | "manualModeShellGate">;
861
+ /** 组:memory(记忆面 + TOC 同步腿)。 */
862
+ export type ServiceMemoryConfig = Pick<ServiceConfigFlat, "memoryEngineEnabled" | "memoryEngineDir" | "memoryEngineRemoteLaneAllowed" | "memoryEngineBackend" | "memoryScope" | "memorySync" | "projectMemoryEnabled" | "syncImportLeaseStaleSec">;
863
+ /** 组:auth(鉴权 / 身份 / 治理棒)。`commandPolicy` 只有 sema-registry 腿(无 env 标量形),故 env 解析
864
+ * 函数不产出它,但它与 `autonomy` 是同一根治理棒的两半,归本组。 */
865
+ export type ServiceAuthConfig = Pick<ServiceConfigFlat, "authToken" | "authTokens" | "allowUnauthedWrites" | "corsOrigins" | "principalHeader" | "requirePrincipal" | "autonomy" | "commandPolicy" | "operatorPrincipals" | "principalJwtPubkeys" | "principalJwtIss" | "principalJwtAud" | "principalJwtMaxTtlSec" | "bindHost">;
866
+ /** 组:orchestration(编排 + 执行车道 + 沙箱面 + workflow/后台 agent 存留)。 */
867
+ export type ServiceOrchestrationConfig = Pick<ServiceConfigFlat, "remoteExec" | "worktreeIsolation" | "leaderEnabled" | "leaderFanoutEnabled" | "routerEnabled" | "selfOrchestrationEnabled" | "selfOrchestrationModels" | "selfOrchestrationWorkerIsolation" | "forkEnabled" | "experimentalObserverAgents" | "schedulerEnabled" | "schedulerSessionWakeup" | "schedulerStorePath" | "planModeEnabled" | "workflowRunStoreBackend" | "workflowOrphanGraceMs" | "workflowJournalRetentionMs" | "workflowRunRetentionMs" | "workflowAgentsReadOnly" | "workflowSizeGuideline" | "backgroundAgentRetentionMs" | "backgroundAgentStaleRunningMs" | "backgroundAgentParkClaimStaleMs" | "rosterRetentionMs" | "scratchpadSweepTtlMs" | "sandboxPkgSource" | "sessionAutoTitle" | "selectEnvironmentTool" | "envFactsEnabled" | "toolDeferLongtail" | "lspEnabled" | "lspHostEnabled" | "imageBakes">;
868
+ /** 组:limitsHttp(HTTP 面 + 各类上限/配额/回收窗)。 */
869
+ export type ServiceLimitsHttpConfig = Pick<ServiceConfigFlat, "port" | "attachmentOrphanGraceMs" | "workspaceFileMaxBytes" | "attachmentMaxBytes" | "attachmentMimeAllowlist" | "attachmentUnboundTtlMs" | "infraCostRates" | "drainGraceMs" | "sighupIdleGraceMs" | "rateLimitPerMin" | "maxTaskCostUsd" | "maxTaskTokens" | "maxPrincipalCostUsd" | "costQuotaWindowSec" | "reapIntervalSec" | "runStaleSec" | "toolResultTtlSec">;
870
+ /** 组:observability(可观测)。 */
871
+ export type ServiceObservabilityConfig = Pick<ServiceConfigFlat, "metricsToken" | "traceToken" | "toolTrace" | "traceThinking" | "logLevel" | "otel">;
872
+ /** 组:integrations(外部集成)。`mcpServers` 由 sema-registry 适配器填(无 env 腿),归本组。 */
873
+ export type ServiceIntegrationsConfig = Pick<ServiceConfigFlat, "pluginsAllowHosts" | "mcpServers" | "configBootFetchBudgetMs" | "gitApiBaseUrl" | "gitApiToken" | "defaultScenario" | "skillsDir" | "oaApiBaseUrl" | "oaServiceToken" | "oaIssue" | "configCenter" | "configProvider" | "configLocalDir">;
874
+ /** 九个组槽。每组恒在场(`loadConfig` / `attachConfigGroups` 装好才交出配置),故不可选——新代码写
875
+ * `config.modelPlane.model` 不需要 `?.`(可选组会把 `Model` 污染成 `Model | undefined`)。 */
876
+ export interface ServiceConfigGroups {
877
+ store: ServiceStoreConfig;
878
+ modelPlane: ServiceModelPlaneConfig;
879
+ approval: ServiceApprovalConfig;
880
+ memory: ServiceMemoryConfig;
881
+ auth: ServiceAuthConfig;
882
+ orchestration: ServiceOrchestrationConfig;
883
+ limitsHttp: ServiceLimitsHttpConfig;
884
+ observability: ServiceObservabilityConfig;
885
+ integrations: ServiceIntegrationsConfig;
886
+ }
887
+ /** Service configuration = 平铺面(唯一存储处,消费点原样) ∩ 九个组视图(additive,不可枚举)。 */
888
+ export interface ServiceConfig extends ServiceConfigFlat, ServiceConfigGroups {
889
+ }
306
890
  //# sourceMappingURL=config-types.d.ts.map