@sema-agent/server 1.322.0 → 2.0.0

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