@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,16 +1,41 @@
1
+ /**
2
+ * plugins 域 worker 消费半场(契约冻结 board [1361]②/[1362] 四收紧/[1366]①;2026-07-28 开工车)。
3
+ *
4
+ * center 只存"插件从哪来"(PluginSpec 引用,永不承载可执行字节);worker 半场 = 把引用物化成本地
5
+ * 目录并把其中的 **skills** 装进 baseline(v1 装载面;commands 由 cli 壳消费——board [1363] 即 cli
6
+ * 答的命令契约稿,worker 侧本无命令面,这是分工不是降级)。挂 applyCenterSkills 同 reconcile 周期
7
+ * (boot 期,buildScenarios 之前)。
8
+ *
9
+ * 契约条款落点(与 test/center-plugins.test.ts 逐条对应):
10
+ * - https-only + `PLUGINS_ALLOW_HOSTS`(缺省 github.com):{@link validatePluginDecl}。registry-core
11
+ * 0.10.23 已在 schema 层单真源拒非 https,worker 侧**仍复验**——纵深:wire 可能来自旧 center。
12
+ * - sha 全 40hex + checkout 强制:{@link gitClonePlan}(有 sha = init+fetch-by-sha+checkout,不信
13
+ * 分支名也不拉全史;无 sha = `--depth 1` HEAD)。
14
+ * - clone 姿势隔离:GIT_CONFIG_GLOBAL/SYSTEM=/dev/null + GIT_TERMINAL_PROMPT=0(无凭据仓 fail 而非
15
+ * 挂交互 prompt)。私仓凭据走各机自己的 credential helper,永不入声明。
16
+ * - manifest 路径逃逸(../ /绝对路径/symlink 出根)= 整条拒装:{@link resolvePluginSkillsRoot}
17
+ * (realpath 后前缀判定)。
18
+ * - 撞名让位(收紧④):plugin 的 skill 与 baseline(builtin/center 直发)同名 ⇒ **plugin 让位**
19
+ * (跳过+letGo 留痕)。⚠️ 方向与 applyCenterSkills 的 center-wins 相反——center 直发 skills 过了
20
+ * publisher RBAC+发布审批,plugin 内容只是 git 仓字节,信任级不同,让位方向因此相反。
21
+ * - fail-loud 单条不连坐 + LKG(上次成功物化留盘,拉取失败沿用):{@link applyCenterPlugins}。
22
+ */
1
23
  import { execFile } from "node:child_process";
2
24
  import { promisify } from "node:util";
3
25
  import { promises as fsp, realpathSync, existsSync, readFileSync } from "node:fs";
4
26
  import { join, resolve, isAbsolute, sep } from "node:path";
5
27
  import { loadSkills } from "./skills.js";
6
28
  const execFileP = promisify(execFile);
29
+ /** 缺省 clone host 白名单(契约条款 1;国内镜像走本名单加 https 镜像域,不开 http 口)。 */
7
30
  export const DEFAULT_PLUGIN_ALLOW_HOSTS = ["github.com"];
31
+ /** 条款 1/2/4:https-only、host 全等白名单、sha 40hex。纯函数,worker 侧纵深复验(不信任 wire 已验过)。 */
8
32
  export function validatePluginDecl(decl, allowHosts) {
9
33
  const name = typeof decl.name === "string" && decl.name !== "" ? decl.name : "(unnamed)";
10
34
  if (decl.enabled === false)
11
35
  return { ok: false, skip: true, name, reason: "enabled:false" };
12
36
  const kind = decl.source?.kind;
13
37
  if (kind === "marketplace") {
38
+ // v1 暂缓:marketplace 物化(add-by-url + install-by-name)是 v2 面;skip 不连坐,warn 留痕。
14
39
  return { ok: false, skip: true, name, reason: "marketplace source: not materialized in v1 (skills lane ships git-form first)" };
15
40
  }
16
41
  if (kind !== "git")
@@ -26,6 +51,7 @@ export function validatePluginDecl(decl, allowHosts) {
26
51
  catch {
27
52
  return { ok: false, name, reason: "https url does not parse" };
28
53
  }
54
+ // host 全等匹配——evil-github.com / github.com.evil.io 都不隐含放行。
29
55
  if (!allowHosts.some((h) => h.toLowerCase() === host)) {
30
56
  return { ok: false, name, reason: `host ${host} not in PLUGINS_ALLOW_HOSTS (default github.com; extend with a comma-separated https mirror domain list)` };
31
57
  }
@@ -37,15 +63,17 @@ export function validatePluginDecl(decl, allowHosts) {
37
63
  }
38
64
  return { ok: true, name, url };
39
65
  }
66
+ /** 条款 3/5:clone 计划(argv 序列 + 隔离 env)。纯数据,让"姿势"可被钉死。 */
40
67
  export function gitClonePlan(o) {
41
68
  const env = {
42
- GIT_CONFIG_GLOBAL: "/dev/null",
69
+ GIT_CONFIG_GLOBAL: "/dev/null", // 收紧③:宿主 git 配置(insteadOf/credential/hooks)一概不继承
43
70
  GIT_CONFIG_SYSTEM: "/dev/null",
44
- GIT_TERMINAL_PROMPT: "0",
71
+ GIT_TERMINAL_PROMPT: "0", // 无凭据仓 ⇒ fail-loud,绝不挂在交互 prompt 上
45
72
  };
46
73
  if (o.sha === undefined) {
47
74
  return { steps: [["clone", "--depth", "1", "--quiet", o.url, o.dest]], env };
48
75
  }
76
+ // 有 sha:init + fetch-by-sha + checkout —— 不信分支名、不拉全史;fetch 不到该 sha = 该条失败。
49
77
  return {
50
78
  steps: [
51
79
  ["init", "--quiet", o.dest],
@@ -55,6 +83,9 @@ export function gitClonePlan(o) {
55
83
  env,
56
84
  };
57
85
  }
86
+ /** 条款 5 的 manifest 半场:`.claude-plugin/plugin.json` 的 `skillsPath`(缺省 `skills/`;cli plugin
87
+ * 布局同族)。返回 ok:true+dir:undefined = 插件没有 skills 目录(可以只有 commands——那是 cli 壳的
88
+ * 半场,worker 装 0 个 skill 不算失败);ok:false = 路径逃逸,整条拒装。 */
58
89
  export function resolvePluginSkillsRoot(cloneRoot) {
59
90
  let skillsPath = "skills";
60
91
  try {
@@ -63,22 +94,27 @@ export function resolvePluginSkillsRoot(cloneRoot) {
63
94
  skillsPath = manifest.skillsPath;
64
95
  }
65
96
  catch {
97
+ /* 无 manifest / 坏 JSON ⇒ 缺省 skills/(manifest 是可选面) */
66
98
  }
67
99
  if (isAbsolute(skillsPath))
68
100
  return { ok: false, reason: `skillsPath must be relative (got ${skillsPath})` };
69
101
  const rootReal = realpathSync(cloneRoot);
70
102
  const candidate = resolve(rootReal, skillsPath);
103
+ // 先做词法前缀判定(../ 逃逸在 realpath 之前就拒——目标可能不存在)
71
104
  if (candidate !== rootReal && !candidate.startsWith(rootReal + sep)) {
72
105
  return { ok: false, reason: `skillsPath escapes the plugin root (${skillsPath})` };
73
106
  }
74
107
  if (!existsSync(candidate))
75
108
  return { ok: true };
109
+ // symlink 出根:对存在的目标 realpath 再判一次
76
110
  const real = realpathSync(candidate);
77
111
  if (real !== rootReal && !real.startsWith(rootReal + sep)) {
78
112
  return { ok: false, reason: `skillsPath resolves outside the plugin root via symlink (${skillsPath})` };
79
113
  }
80
114
  return { ok: true, dir: candidate };
81
115
  }
116
+ /** 总入口(条款 3/7/8):逐条物化 + 装载 + 让位合并。materialize 盘位 = `<cacheRoot>/<name>/live`
117
+ * (成功后原子 rename 替换,失败保留旧盘位 = LKG)。 */
82
118
  export async function applyCenterPlugins(baseline, eff, opts) {
83
119
  const declared = Array.isArray(eff.plugins)
84
120
  ? (eff.plugins)
@@ -91,7 +127,7 @@ export async function applyCenterPlugins(baseline, eff, opts) {
91
127
  const runGit = opts.runGit ?? (async (args, env) => {
92
128
  await execFileP("git", args, { env: { ...process.env, ...env }, timeout: 120_000, maxBuffer: 4 * 1024 * 1024 });
93
129
  });
94
- const taken = new Set(baseline.map((s) => s.spec.name));
130
+ const taken = new Set(baseline.map((s) => s.spec.name)); // 让位判据:baseline(builtin+center 直发)恒赢
95
131
  for (const decl of declared) {
96
132
  const v = opts.skipValidate
97
133
  ? { ok: true, name: String(decl.name), url: String(decl.source?.url), ...(typeof decl.sha === "string" ? { sha: decl.sha } : {}) }
@@ -106,12 +142,14 @@ export async function applyCenterPlugins(baseline, eff, opts) {
106
142
  continue;
107
143
  }
108
144
  const liveDir = join(opts.cacheRoot, v.name, "live");
145
+ // ── 物化:clone 到 staging,成功后原子替换 live;失败保留旧 live = LKG ──
109
146
  const staging = join(opts.cacheRoot, v.name, `staging-${process.pid}`);
110
147
  let materialized = false;
111
148
  try {
112
149
  await fsp.rm(staging, { recursive: true, force: true });
113
150
  await fsp.mkdir(staging, { recursive: true });
114
151
  const plan = gitClonePlan({ url: v.url, dest: staging, sha: v.sha });
152
+ // clone 目标目录已建:单步 clone 允许空目录;init 形对空目录同样成立。
115
153
  for (const step of plan.steps)
116
154
  await runGit(step, plan.env);
117
155
  await fsp.rm(liveDir, { recursive: true, force: true });
@@ -122,6 +160,7 @@ export async function applyCenterPlugins(baseline, eff, opts) {
122
160
  catch (err) {
123
161
  await fsp.rm(staging, { recursive: true, force: true }).catch(() => undefined);
124
162
  if (existsSync(liveDir)) {
163
+ // LKG:拉取失败沿用上次成功物化(applyCenterSkills 同款语义)。
125
164
  opts.logger?.warn("center_plugin_fetch_failed_lkg", { plugin: v.name, error: err instanceof Error ? err.message : String(err) });
126
165
  out.lkgUsed.push(v.name);
127
166
  }
@@ -131,6 +170,7 @@ export async function applyCenterPlugins(baseline, eff, opts) {
131
170
  continue;
132
171
  }
133
172
  }
173
+ // ── 装载:skills 目录(路径逃逸=整条拒装;fail-loud 单条不连坐)──
134
174
  try {
135
175
  const rootCheck = resolvePluginSkillsRoot(liveDir);
136
176
  if (!rootCheck.ok) {
@@ -139,10 +179,11 @@ export async function applyCenterPlugins(baseline, eff, opts) {
139
179
  continue;
140
180
  }
141
181
  if (!rootCheck.dir)
142
- continue;
182
+ continue; // 无 skills 目录:合法(commands-only 插件,cli 壳的半场)
143
183
  const loaded = loadSkills(rootCheck.dir);
144
184
  for (const skill of loaded) {
145
185
  if (taken.has(skill.spec.name)) {
186
+ // 收紧④:plugin 让位(方向与 center-wins 相反,理由见模块顶注)。
146
187
  out.letGo.push({ plugin: v.name, skill: skill.spec.name });
147
188
  opts.logger?.warn("center_plugin_skill_shadowed", { plugin: v.name, skill: skill.spec.name, note: "name taken by builtin/center skill — plugin yields (contract tightening-4)" });
148
189
  continue;
@@ -1,6 +1,34 @@
1
+ /**
2
+ * center prompts 消费投影腿([1043]④/[1050]③ 分工:web 承存储+covering 解析+下发,server 承本模块;
3
+ * [1057] 下发形定稿 / [1061] registry-core 0.10.16 schema / [1062]⑤「server 零新义务=逐字透传」)。
4
+ *
5
+ * 链路:center(sema-web)把 covering 走完的**基线终形**经 `GET /api/config/effective` 的 additive
6
+ * `prompts` key 下发 → 本模块按任务 scenario 选包(`scenarioOverrides[s] ?? sections`,整包替换非增量,
7
+ * [1057]①c)→ 声明数组**逐字**(含 opt-in `contentHash`,core 1.315 校验+manifest 透传)喂 core 既有
8
+ * typed `stableBlocks` 钩子。守卫全在 core(id 规范/slot 闭集/core/ 命名空间拒绝/identity 三锚
9
+ * pass-through/锁定槽不可写)——server 不做语义复检([1057]①f:identity 完整角色层由 center 编辑面把关)。
10
+ *
11
+ * 仅有的一层「形校验」不是语义复检,是**防炸底线**(详见其现居所 `src/prompts-domain-validate.ts`——
12
+ * 判形半场已下沉到该中立叶子,本文件 re-export 保兼容;design/158 S6,lens2 §G):core 对坏形声明的
13
+ * 守卫是 THROW(assemble 期),server 在采用前做结构判形,坏形=拒绝采用该候选的 prompts 面。
14
+ *
15
+ * 生效语义(两段史):1.222 时 core 1.315 的 epoch 是 bundled-only(声明不进 descriptor),热换=resume
16
+ * 三失真,故临时 restart-to-apply;core 1.316([1068] 裁 a/[1070]d)把声明以 (id,slot,chars,contentHash?)
17
+ * 纳入 artifactDigest——声明变=digest 变=**下任务边界自动重 pin**(既有 legacy_migration 机制接手),
18
+ * 进行中会话 epoch pin 保稳。自此恢复**热采用**(main.ts boot+refresh 双点 adopt),与 center
19
+ * 「发布=新任务生效」产品语义对齐([1051]②b)。字节级检测只认 opt-in contentHash(文本不进 digest,
20
+ * 防会话可导出面字典预映)——center 链路恒逐 section 铸([1065]),本投影逐字透传即全强度。
21
+ */
1
22
  import { type PromptProvider, type PublishedPromptArtifactEnvelope } from "@sema-agent/core";
2
23
  import { type EffectiveCenterPrompts, type PromptsDomainFaces } from "../prompts-domain-validate.js";
24
+ /** 判形半场(validateCenterPrompts/validatePromptsDomain/CORE_ENGINE_VERSION 及两 interface)已下沉到
25
+ * 中立叶子 `src/prompts-domain-validate.ts`(design/158 S6,lens2 §G:消 config-lkg → capabilities 的
26
+ * 唯一分层反向边)。此处 re-export 保兼容——既有消费者(main/run-local/测试)零改动。 */
3
27
  export { validateCenterPrompts, validatePromptsDomain, CORE_ENGINE_VERSION, type EffectiveCenterPrompts, type PromptsDomainFaces } from "../prompts-domain-validate.js";
28
+ /** [985]b / [1285] — §9.4 by-digest 补拉组合店:local miss ⇒ fetchRaw(digest) 从 center 拉 envelope ⇒
29
+ * core verifyPromptArtifact 全管线 + **回验「拿到的=要的」digest 逐位**(center 答非所问=丢弃)⇒
30
+ * best-effort 回写 inner(下次直命中)。任何失败=undefined(诚实缺席,fail-loud 归 core 的
31
+ * prompt_snapshot_unavailable——绝不拼杂交)。 */
4
32
  export declare function withPromptArtifactBackfill(inner: {
5
33
  get(d: string, o: {
6
34
  engineVersion: string;
@@ -10,6 +38,11 @@ export declare function withPromptArtifactBackfill(inner: {
10
38
  info: (msg: string, meta?: Record<string, unknown>) => void;
11
39
  warn: (msg: string, meta?: Record<string, unknown>) => void;
12
40
  }): typeof inner;
41
+ /** e/b 接线([1236]① seam/[985]e):catalog 轴的两态过渡推进 core 的 CenterPromptSource——
42
+ * present(且身份变)⇒ applySnapshot(core 重验+落盘+原子换 candidate;validate 已过 core verify,
43
+ * 此处失败=磁盘/状态写问题,warn 不挡 declaration 轴);absent-after-present / prompts 键整体消失
44
+ * ⇒ applyDisabled(闸关=显式撤下语义的 catalog 轴半场,离线重启不复活)。幂等安全:同 envelope
45
+ * 重放=同 digest 覆盖写。 */
13
46
  export declare function applyCatalogToSource(source: {
14
47
  applySnapshot(raw: unknown): Promise<{
15
48
  ok: true;
@@ -20,11 +53,24 @@ export declare function applyCatalogToSource(source: {
20
53
  reason: string;
21
54
  }>;
22
55
  applyDisabled(sourceRevision: string): Promise<void>;
56
+ /** codex-2 F2(restart-owed disable):撤下写盘失败后重启,内存 prev 丢了但持久态还 active——
57
+ * 以 source 自身的 live candidate 为准判「欠 disable」,不是只看内存 prev。 */
23
58
  current?(): unknown;
24
59
  }, next: PromptsDomainFaces | undefined, prev: PromptsDomainFaces | undefined, log: {
25
60
  info: (msg: string, meta?: Record<string, unknown>) => void;
26
61
  warn: (msg: string, meta?: Record<string, unknown>) => void;
27
62
  }, phase: string): Promise<boolean>;
63
+ /**
64
+ * 选包+投影:该 scenario 的终形声明数组(`scenarioOverrides[s] ?? sections`)→ typed `stableBlocks`
65
+ * 钩子(声明**逐字**透传,含 contentHash——core 1.315 校验后进 manifest)。空数组在 validate 已拒
66
+ * (F4:空替换集非 v1 语义),所以这里恒有非空声明——恒返回 provider(center-wins 无死分支)。
67
+ */
28
68
  export declare function centerPromptProvider(prompts: EffectiveCenterPrompts, scenarioName: string): PromptProvider;
69
+ /** codex R3(appendSystemPrompt 案):该 scenario 的终形 center 声明里是否有「已组装 identity」——core 的
70
+ * M9 迁移卫在 provider.stableBlocks 的 identity 声明上探同三锚,命中即走 pass-through 臂(其保留集无
71
+ * `core/role.append`,任何 append rider/outputStyle 会被静默丢)。选包与 {@link centerPromptProvider}
72
+ * 同式(`overrides[s] ?? sections`);锚谓词由调用方注入(task-settings `hasConstitutionAnchors` 单真源)。
73
+ * [1057]①f 的「server 不做语义复检」不动:这不是复检语义,是为 capabilities.appendSystemPrompt 的诚实面
74
+ * 探 core 会走哪条臂。 */
29
75
  export declare function centerIdentityAssembled(prompts: EffectiveCenterPrompts, scenarioName: string, isAssembled: (text: unknown) => boolean): boolean;
30
76
  //# sourceMappingURL=center-prompts.d.ts.map
@@ -1,14 +1,46 @@
1
+ /**
2
+ * center prompts 消费投影腿([1043]④/[1050]③ 分工:web 承存储+covering 解析+下发,server 承本模块;
3
+ * [1057] 下发形定稿 / [1061] registry-core 0.10.16 schema / [1062]⑤「server 零新义务=逐字透传」)。
4
+ *
5
+ * 链路:center(sema-web)把 covering 走完的**基线终形**经 `GET /api/config/effective` 的 additive
6
+ * `prompts` key 下发 → 本模块按任务 scenario 选包(`scenarioOverrides[s] ?? sections`,整包替换非增量,
7
+ * [1057]①c)→ 声明数组**逐字**(含 opt-in `contentHash`,core 1.315 校验+manifest 透传)喂 core 既有
8
+ * typed `stableBlocks` 钩子。守卫全在 core(id 规范/slot 闭集/core/ 命名空间拒绝/identity 三锚
9
+ * pass-through/锁定槽不可写)——server 不做语义复检([1057]①f:identity 完整角色层由 center 编辑面把关)。
10
+ *
11
+ * 仅有的一层「形校验」不是语义复检,是**防炸底线**(详见其现居所 `src/prompts-domain-validate.ts`——
12
+ * 判形半场已下沉到该中立叶子,本文件 re-export 保兼容;design/158 S6,lens2 §G):core 对坏形声明的
13
+ * 守卫是 THROW(assemble 期),server 在采用前做结构判形,坏形=拒绝采用该候选的 prompts 面。
14
+ *
15
+ * 生效语义(两段史):1.222 时 core 1.315 的 epoch 是 bundled-only(声明不进 descriptor),热换=resume
16
+ * 三失真,故临时 restart-to-apply;core 1.316([1068] 裁 a/[1070]d)把声明以 (id,slot,chars,contentHash?)
17
+ * 纳入 artifactDigest——声明变=digest 变=**下任务边界自动重 pin**(既有 legacy_migration 机制接手),
18
+ * 进行中会话 epoch pin 保稳。自此恢复**热采用**(main.ts boot+refresh 双点 adopt),与 center
19
+ * 「发布=新任务生效」产品语义对齐([1051]②b)。字节级检测只认 opt-in contentHash(文本不进 digest,
20
+ * 防会话可导出面字典预映)——center 链路恒逐 section 铸([1065]),本投影逐字透传即全强度。
21
+ */
1
22
  import { verifyPromptArtifact } from "@sema-agent/core";
2
23
  import { CORE_ENGINE_VERSION } from "../prompts-domain-validate.js";
24
+ /** 判形半场(validateCenterPrompts/validatePromptsDomain/CORE_ENGINE_VERSION 及两 interface)已下沉到
25
+ * 中立叶子 `src/prompts-domain-validate.ts`(design/158 S6,lens2 §G:消 config-lkg → capabilities 的
26
+ * 唯一分层反向边)。此处 re-export 保兼容——既有消费者(main/run-local/测试)零改动。 */
3
27
  export { validateCenterPrompts, validatePromptsDomain, CORE_ENGINE_VERSION } from "../prompts-domain-validate.js";
28
+ /** [985]b / [1285] — §9.4 by-digest 补拉组合店:local miss ⇒ fetchRaw(digest) 从 center 拉 envelope ⇒
29
+ * core verifyPromptArtifact 全管线 + **回验「拿到的=要的」digest 逐位**(center 答非所问=丢弃)⇒
30
+ * best-effort 回写 inner(下次直命中)。任何失败=undefined(诚实缺席,fail-loud 归 core 的
31
+ * prompt_snapshot_unavailable——绝不拼杂交)。 */
4
32
  export function withPromptArtifactBackfill(inner, fetchRaw, log) {
33
+ // codex F1(补拉批):per-canonical-digest 单飞——冷副本上 N 个 pinned resume 同时 miss 同一 artifact
34
+ // 只发一次远拉(finally 清账);裸/大写形入口即正则化(FilePromptArtifactStore 只认 canonical 键,
35
+ // 不正则化=非 canonical 请求缓存永 miss 重拉)。坏形 digest 直拒(不上网)。负缓存有意不设:每次
36
+ // miss 都是用户驱动的 resume 尝试,量有界;404 重复由单飞在并发窗内已并。
5
37
  const inFlight = new Map();
6
38
  return {
7
39
  put: (e) => inner.put(e),
8
40
  get: async (digest, opts) => {
9
41
  const hex = digest.replace(/^sha256:/i, "").toLowerCase();
10
42
  if (!/^[0-9a-f]{64}$/.test(hex))
11
- return undefined;
43
+ return undefined; // malformed request — never a network trip
12
44
  const canonical = `sha256:${hex}`;
13
45
  const local = await inner.get(canonical, opts);
14
46
  if (local)
@@ -24,7 +56,7 @@ export function withPromptArtifactBackfill(inner, fetchRaw, log) {
24
56
  log.warn("center_prompts_backfill_rejected", { digest: canonical, ...(v.ok ? { got: v.artifact.artifactDigest, code: "digest_mismatch" } : { code: v.code, reason: v.reason }) });
25
57
  return undefined;
26
58
  }
27
- await inner.put(raw).catch(() => undefined);
59
+ await inner.put(raw).catch(() => undefined); // cache best-effort
28
60
  log.info("center_prompts_backfilled", { digest: canonical });
29
61
  return raw;
30
62
  }
@@ -41,11 +73,18 @@ export function withPromptArtifactBackfill(inner, fetchRaw, log) {
41
73
  },
42
74
  };
43
75
  }
76
+ /** e/b 接线([1236]① seam/[985]e):catalog 轴的两态过渡推进 core 的 CenterPromptSource——
77
+ * present(且身份变)⇒ applySnapshot(core 重验+落盘+原子换 candidate;validate 已过 core verify,
78
+ * 此处失败=磁盘/状态写问题,warn 不挡 declaration 轴);absent-after-present / prompts 键整体消失
79
+ * ⇒ applyDisabled(闸关=显式撤下语义的 catalog 轴半场,离线重启不复活)。幂等安全:同 envelope
80
+ * 重放=同 digest 覆盖写。 */
44
81
  export async function applyCatalogToSource(source, next, prev, log, phase) {
82
+ // codex-2 F2:返回「过渡是否成功」——false 时 caller **不推进** centerPrompts(身份留在 prev),
83
+ // 下一拍 refresh 身份仍不等=同一过渡自动重试;吞错推进曾让失败的 apply/withdraw 永久静默。
45
84
  try {
46
85
  if (next?.catalog) {
47
86
  if (prev?.identity === next.identity)
48
- return true;
87
+ return true; // unchanged face — no state churn
49
88
  const r = await source.applySnapshot(next.catalog);
50
89
  if (r.ok) {
51
90
  log.info("center_prompts_catalog_applied", { phase, artifactDigest: r.artifactDigest });
@@ -55,6 +94,8 @@ export async function applyCatalogToSource(source, next, prev, log, phase) {
55
94
  return false;
56
95
  }
57
96
  if (prev?.catalog || source.current?.() !== undefined) {
97
+ // the axis was live (in-memory marker OR a persisted candidate surviving a restart whose disable was
98
+ // owed) and the face now has no catalog: fail-closed mirror of the cleared semantics — disable durably.
58
99
  await source.applyDisabled(`${phase}:catalog-absent`);
59
100
  log.info("center_prompts_catalog_disabled", { phase, note: "catalog axis withdrawn — core candidate cleared (does not revive offline)" });
60
101
  }
@@ -65,10 +106,23 @@ export async function applyCatalogToSource(source, next, prev, log, phase) {
65
106
  return false;
66
107
  }
67
108
  }
109
+ /**
110
+ * 选包+投影:该 scenario 的终形声明数组(`scenarioOverrides[s] ?? sections`)→ typed `stableBlocks`
111
+ * 钩子(声明**逐字**透传,含 contentHash——core 1.315 校验后进 manifest)。空数组在 validate 已拒
112
+ * (F4:空替换集非 v1 语义),所以这里恒有非空声明——恒返回 provider(center-wins 无死分支)。
113
+ */
68
114
  export function centerPromptProvider(prompts, scenarioName) {
69
115
  const decls = prompts.scenarioOverrides?.[scenarioName] ?? prompts.sections;
116
+ // 声明数组在候选采用时已判形+冻结(main.ts ref 整体替换,数组不原位变异)——闭包直接引用,core 侧
117
+ // 1.315 还有声明边界快照(getter 无法让「验过的」≠「发出的」)。
70
118
  return { stableBlocks: () => decls };
71
119
  }
120
+ /** codex R3(appendSystemPrompt 案):该 scenario 的终形 center 声明里是否有「已组装 identity」——core 的
121
+ * M9 迁移卫在 provider.stableBlocks 的 identity 声明上探同三锚,命中即走 pass-through 臂(其保留集无
122
+ * `core/role.append`,任何 append rider/outputStyle 会被静默丢)。选包与 {@link centerPromptProvider}
123
+ * 同式(`overrides[s] ?? sections`);锚谓词由调用方注入(task-settings `hasConstitutionAnchors` 单真源)。
124
+ * [1057]①f 的「server 不做语义复检」不动:这不是复检语义,是为 capabilities.appendSystemPrompt 的诚实面
125
+ * 探 core 会走哪条臂。 */
72
126
  export function centerIdentityAssembled(prompts, scenarioName, isAssembled) {
73
127
  const decls = prompts.scenarioOverrides?.[scenarioName] ?? prompts.sections;
74
128
  return decls.some((d) => d.slot === "identity" && isAssembled(d.text));
@@ -2,20 +2,48 @@ import { runTeamDiscussion, type Runner, type ToolSpec } from "@sema-agent/core"
2
2
  import type { Metrics } from "../observability/metrics.js";
3
3
  import type { Logger } from "../observability/logger.js";
4
4
  type TeamFn = typeof runTeamDiscussion;
5
+ /**
6
+ * Code-review council (Option C+, layers L1 + L3) packaged as ONE tool, so the run model is unchanged
7
+ * and the orchestration is **code-driven** (deterministic — we don't rely on the model to follow a
8
+ * multi-step orchestration prompt, which live runs showed it doesn't do reliably).
9
+ *
10
+ * - L1 (gather): one isolated, read-only-repo-tooled subagent PER differential lens, run in PARALLEL.
11
+ * - L3 (arbitrate): a neutral arbiter grounds/dedups/buckets/ranks. It does not add findings.
12
+ * - L2 (peer debate over findings + dispute verification with member tools) is the next layer.
13
+ *
14
+ * Research basis (core's design): tooled differential exploration is the main source of real bugs;
15
+ * grounding + bucketing kill "imagined requirements" and stop a design preference being filed as a bug.
16
+ */
5
17
  interface Lens {
6
18
  name: string;
7
19
  brief: string;
8
20
  }
21
+ /**
22
+ * Caller-tunable lens COUNT (OA request) — a structured cost/coverage dial, sibling of `@model` / `council` /
23
+ * `debate`. The deployment owns WHICH lenses (the `LENSES` order = the priority: security/correctness first =
24
+ * the bug-finders); the caller only picks HOW MANY. Clamp to [1, LENSES.length]; absent / non-numeric = ALL
25
+ * (the current default → zero regression). A named subset is deliberately NOT supported (it would force a
26
+ * published, maintained lens vocabulary contract; the count is the verifiable knob a "light/standard" UI needs).
27
+ */
9
28
  export declare function pickLenses(count?: number): readonly Lens[];
29
+ /** Caller-settable debate rounds: a FINITE integer clamped to [1,3]; non-number / NaN / ±Infinity = undefined
30
+ * (→ the council's default of 1). Mirrors `pickLenses`'s `Number.isFinite` guard — the previous inline clamp let
31
+ * `NaN` through (`typeof NaN === "number"`, `Math.min(3, NaN) === NaN`), corrupting the cost metric (council). */
10
32
  export declare function clampRounds(rounds: unknown): number | undefined;
11
33
  export interface CouncilToolOptions {
34
+ /** Aggregate the council's (otherwise invisible) sub-task cost into metrics. */
12
35
  metrics?: Metrics;
13
36
  logger?: Logger;
37
+ /** L1+L2+L3: add a peer-team debate (tool-grounded) before arbitration. Default L1+L3 only. */
14
38
  debate?: boolean;
39
+ /** Debate rounds (when `debate`). Default 1. */
15
40
  rounds?: number;
41
+ /** Caller-chosen lens COUNT (cost/coverage dial). Clamped to [1, LENSES.length]; absent = all lenses. */
16
42
  lensCount?: number;
43
+ /** Injectable for tests; defaults to core's runTeamDiscussion. */
17
44
  teamFn?: TeamFn;
18
45
  }
46
+ /** Build the `run_council` tool. The lead calls it once; it returns the final arbitrated review. */
19
47
  export declare function createCouncilTool(subRunner: Runner, repoTools: ToolSpec[], objective: string, opts?: CouncilToolOptions): ToolSpec;
20
48
  export {};
21
49
  //# sourceMappingURL=code-review-council.d.ts.map
@@ -1,30 +1,45 @@
1
1
  import { Type } from "typebox";
2
2
  import { runTeamDiscussion } from "@sema-agent/core";
3
- import { REVIEW_LENSES, GROUNDING, LENS_SYSTEM_TPL, DEBATE_MEMBER_TPL, DEBATE_TOPIC_TPL, ARBITER_SYSTEM, ARBITER_FALLBACK_HEADER } from "./prompts/code-review.js";
4
- const LENSES = REVIEW_LENSES;
3
+ import { REVIEW_LENSES, GROUNDING, LENS_SYSTEM_TPL, DEBATE_MEMBER_TPL, DEBATE_TOPIC_TPL, ARBITER_SYSTEM, ARBITER_FALLBACK_HEADER } from "./prompts/code-review.js"; // bundle-data layer
4
+ const LENSES = REVIEW_LENSES; // roster copy lives in prompts/code-review.ts
5
+ /**
6
+ * Caller-tunable lens COUNT (OA request) — a structured cost/coverage dial, sibling of `@model` / `council` /
7
+ * `debate`. The deployment owns WHICH lenses (the `LENSES` order = the priority: security/correctness first =
8
+ * the bug-finders); the caller only picks HOW MANY. Clamp to [1, LENSES.length]; absent / non-numeric = ALL
9
+ * (the current default → zero regression). A named subset is deliberately NOT supported (it would force a
10
+ * published, maintained lens vocabulary contract; the count is the verifiable knob a "light/standard" UI needs).
11
+ */
5
12
  export function pickLenses(count) {
6
13
  if (count == null || !Number.isFinite(count))
7
14
  return LENSES;
8
15
  const n = Math.min(LENSES.length, Math.max(1, Math.floor(count)));
9
16
  return LENSES.slice(0, n);
10
17
  }
18
+ /** Caller-settable debate rounds: a FINITE integer clamped to [1,3]; non-number / NaN / ±Infinity = undefined
19
+ * (→ the council's default of 1). Mirrors `pickLenses`'s `Number.isFinite` guard — the previous inline clamp let
20
+ * `NaN` through (`typeof NaN === "number"`, `Math.min(3, NaN) === NaN`), corrupting the cost metric (council). */
11
21
  export function clampRounds(rounds) {
12
22
  if (typeof rounds !== "number" || !Number.isFinite(rounds))
13
23
  return undefined;
14
24
  return Math.min(3, Math.max(1, Math.floor(rounds)));
15
25
  }
26
+ // Guardrail COPY (GROUNDING/templates/arbiter) lives in prompts/code-review.ts — this file keeps
27
+ // only the fill logic. `fillPrompt` is a plain `{key}` substitution (no escaping: values are our own lens
28
+ // names/briefs and the objective/findings the model already sees verbatim elsewhere).
16
29
  function fillPrompt(tpl, vars) {
17
30
  return tpl.replace(/\{(\w+)\}/g, (m, k) => (k in vars ? vars[k] : m));
18
31
  }
19
32
  function lensSystem(lens) {
20
33
  return fillPrompt(LENS_SYSTEM_TPL, { name: lens.name, brief: lens.brief, grounding: GROUNDING });
21
34
  }
35
+ // L2 — peer debate persona (guardrails 5,6): cross-examine, adjust confidence, verify disputes with tools.
22
36
  function debateMemberSystem(lens) {
23
37
  return fillPrompt(DEBATE_MEMBER_TPL, { name: lens.name, brief: lens.brief });
24
38
  }
25
39
  function debateTopic(objective, findings) {
26
40
  return fillPrompt(DEBATE_TOPIC_TPL, { objective, grounding: GROUNDING, findings });
27
41
  }
42
+ /** Build the `run_council` tool. The lead calls it once; it returns the final arbitrated review. */
28
43
  export function createCouncilTool(subRunner, repoTools, objective, opts = {}) {
29
44
  return {
30
45
  name: "run_council",
@@ -33,17 +48,23 @@ export function createCouncilTool(subRunner, repoTools, objective, opts = {}) {
33
48
  effect: "read",
34
49
  parameters: Type.Object({}),
35
50
  execute: async (_args, ctx) => {
51
+ // Caller-chosen lens subset (OA cost/coverage dial); default = all lenses.
36
52
  const active = pickLenses(opts.lensCount);
37
- const lenses = await runLensReviews(subRunner, repoTools, objective, ctx.signal, active);
53
+ // Forward the parent task's AbortSignal (core ≥1.18) so the lenses/arbiter stop the instant the
54
+ // parent is cancelled, instead of each burning to its own timeoutSec (design/16 feature request).
55
+ const lenses = await runLensReviews(subRunner, repoTools, objective, ctx.signal, active); // L1
38
56
  const findings = lenses.map((l) => `### ${l.lens} reviewer\n${l.text}`).join("\n\n");
39
- const converge = await runConvergence(subRunner, repoTools, objective, findings, opts, ctx.signal, active);
57
+ const converge = await runConvergence(subRunner, repoTools, objective, findings, opts, ctx.signal, active); // L2?+L3
58
+ // Cost is otherwise invisible — the sub-tasks run on a separate runner, so the parent run's
59
+ // stats only count the lead. Surface the real (~Nx) cost three ways:
40
60
  const totalTokens = lenses.reduce((s, l) => s + l.tokens, 0) + converge.tokens;
41
61
  const totalTurns = lenses.reduce((s, l) => s + l.turns, 0) + converge.turns;
42
62
  const tasks = active.length + (opts.debate ? active.length * (opts.rounds ?? 1) + 1 : 1);
63
+ // ① into the PARENT run's TaskResult.stats.nested (core 1.11 reportUsage):
43
64
  ctx.reportUsage?.({ tokens: totalTokens, turns: totalTurns, tasks });
44
65
  const mode = opts.debate ? "L1+L2+L3" : "L1+L3";
45
66
  opts.metrics?.inc("council_runs_total", { mode });
46
- opts.metrics?.inc("task_tokens_total", {}, totalTokens);
67
+ opts.metrics?.inc("task_tokens_total", {}, totalTokens); // global counter, no labels — keep it honest
47
68
  opts.metrics?.observe("council_tokens", totalTokens);
48
69
  opts.logger?.info("council_done", { mode, lenses: lenses.length, totalTokens, totalTurns });
49
70
  return {
@@ -53,10 +74,15 @@ export function createCouncilTool(subRunner, repoTools, objective, opts = {}) {
53
74
  },
54
75
  };
55
76
  }
77
+ /** L1 — one isolated, repo-tooled subagent per lens, run in parallel. A single lens that throws
78
+ * (gateway 5xx / timeout) must NOT collapse the whole council, so failures degrade to a noted
79
+ * empty lens and arbitration proceeds on the survivors. */
56
80
  async function runLensReviews(subRunner, repoTools, objective, signal, lenses) {
57
81
  const settled = await Promise.allSettled(lenses.map(async (lens) => {
58
82
  const r = await subRunner.runTask({
59
83
  objective: `${objective}\n\nReview ONLY through the ${lens.name} lens.`,
84
+ // Cost tiering (1.24): lenses run on the `subagent` role — cheap when MODEL_CHEAP_ID is set,
85
+ // else the main model. Scanning for leads doesn't need the strong model; the arbiter does.
60
86
  modelRole: "subagent",
61
87
  tools: repoTools,
62
88
  systemPrompt: lensSystem(lens),
@@ -75,6 +101,7 @@ async function runLensReviews(subRunner, repoTools, objective, signal, lenses) {
75
101
  turns: 0,
76
102
  });
77
103
  }
104
+ /** L2 (peer debate, tool-grounded) + L3 synthesis, or — when `debate` is off — L3 arbiter alone. */
78
105
  async function runConvergence(subRunner, repoTools, objective, findings, opts, signal, lenses) {
79
106
  if (opts.debate) {
80
107
  const team = await (opts.teamFn ?? runTeamDiscussion)({
@@ -83,12 +110,14 @@ async function runConvergence(subRunner, repoTools, objective, findings, opts, s
83
110
  members: lenses.map((l) => ({ role: l.name, systemPrompt: debateMemberSystem(l) })),
84
111
  topic: debateTopic(objective, findings),
85
112
  rounds: opts.rounds ?? 1,
86
- tools: repoTools,
113
+ tools: repoTools, // members may verify a disputed claim against the real code (Tool-MAD)
87
114
  maxTranscriptTokens: 8000,
88
115
  synthesizer: { role: "arbiter", systemPrompt: ARBITER_SYSTEM },
89
116
  limits: { timeoutSec: 400 },
90
- signal,
117
+ signal, // 1.28: a parent abort now cascades into the debate members
91
118
  });
119
+ // 1.32: synthesizer 两次都失败时 `conclusion` 是 `[unavailable…]` 垃圾串,与真结论无法区分。别当结论
120
+ // 返回——退回未经仲裁的各 lens 原始发现(findings 在手),用户至少看到真实发现,而不是把垃圾当评审。
92
121
  if (!team.conclusionValid) {
93
122
  opts.logger?.warn("council_arbiter_failed", { failures: team.failures });
94
123
  return {
@@ -99,14 +128,18 @@ async function runConvergence(subRunner, repoTools, objective, findings, opts, s
99
128
  }
100
129
  return { review: team.conclusion, tokens: team.stats.tokens, turns: team.stats.turns };
101
130
  }
131
+ // L3 only — a single neutral arbiter (ground / dedup / bucket / rank). No new findings.
102
132
  const arb = await subRunner.runTask({
103
133
  objective: `Arbitrate these specialist findings into ONE final review:\n\n${findings}`,
134
+ // The arbiter grounds/dedups/ranks — keep it on the strong `synthesize` role (= main model).
104
135
  modelRole: "synthesize",
105
136
  systemPrompt: ARBITER_SYSTEM,
106
137
  limits: { timeoutSec: 240 },
107
138
  enableBlockedReport: false,
108
139
  signal,
109
140
  });
141
+ // Mirror the debate path's fallback: an empty/failed arbiter result must not surface as an empty review —
142
+ // hand back the raw lens findings so the caller still sees real findings, not nothing.
110
143
  const review = arb.result?.trim() || `${ARBITER_FALLBACK_HEADER}${findings}`;
111
144
  return { review, tokens: arb.stats.tokens, turns: arb.stats.turns };
112
145
  }
@@ -1,3 +1,5 @@
1
+ /** center /effective `collab.templates[]` 条目的服务侧结构子集(registry-core 0.7 CollabTemplate 出参兼容;
2
+ * wire 类型独立成模块——投影实现随切片演进[①=TeamTemplate,1.5=named workflow defaultArgs],wire 形状不动)。 */
1
3
  export interface CollabTemplateWire {
2
4
  id: string;
3
5
  name: string;
@@ -1,9 +1,11 @@
1
1
  import type { CollabTemplateWire } from "./collab-wire.js";
2
+ /** core WorkflowScriptStore.list() 行(name+description+whenToUse)——LLM 工具卡/roster 投影面。 */
2
3
  export interface CollabWorkflowListing {
3
4
  name: string;
4
5
  description?: string;
5
6
  whenToUse?: string;
6
7
  }
8
+ /** 一条已注册的 collab 命名 workflow:执行体恒为 core 内置 team-discussion 脚本,个性全在 defaultArgs。 */
7
9
  export interface CollabWorkflowEntry {
8
10
  defaultArgs: {
9
11
  members: Array<{
@@ -32,9 +34,14 @@ export interface CollabWorkflowProjection {
32
34
  }
33
35
  export declare function projectCollabToWorkflows(templates: readonly CollabTemplateWire[] | undefined): CollabWorkflowProjection;
34
36
  export declare function registerCollabWorkflows(workflows: Record<string, CollabWorkflowEntry>): void;
37
+ /** composite WorkflowScriptStore 的 resolveName 前段:collab 命中 ⇒ 内置 team-discussion 脚本+本模板
38
+ * defaultArgs(同名 SHADOW core 内置,design/140 §6 1c)。🔴 Object.hasOwn — `name` 是模型供给的
39
+ * (run-workflow-tool 原样传 rawName):裸索引会让 Object.prototype 成员名("constructor"/"toString"/
40
+ * "__proto__"…)假命中 ⇒ 零模板注册也能烧真讨论、且同名文件 store 条目被遮蔽(对抗评审 2026-07-11 MED)。 */
35
41
  export declare function resolveCollabWorkflow(name: string): {
36
42
  script: string;
37
43
  defaultArgs: unknown;
38
44
  } | undefined;
45
+ /** composite store 的 list() 段(同步——workflow 工具卡只吃同步 list,core 契约注释)。 */
39
46
  export declare function listCollabWorkflows(): CollabWorkflowListing[];
40
47
  //# sourceMappingURL=collab-workflows.d.ts.map