@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,12 +1,54 @@
1
+ /**
2
+ * CC `execPromptHook` 的**逐字**移植面:两档系统提示 + `{ok, reason, impossible?}` 判词的解析与映射。
3
+ *
4
+ * ── 为什么单独一个文件 ──────────────────────────────────────────────────────────────────────────
5
+ * 本仓有 clay 的**提示词面锚定 CC 逐字**令(偏离仅限超集/品牌二类且需登记)。把这两段正文与它们的
6
+ * 判词形收在一处,才谈得上机器看守(见 `test/cc-stop-prompt.test.ts` 的字节钉)。
7
+ *
8
+ * ── 出处(我**第一手**核过,不是照抄转述)────────────────────────────────────────────────────────
9
+ * `sema-agent/cc-decoded` 的 `pretty220.js:609309` 起(219/218 同构)。逐字核实的四件:
10
+ * · 两档判据是 **hook 事件名**:`c = r === "Stop" || r === "SubagentStop"` ⇒ 这两个事件用**完整版**,其余用简版;
11
+ * · user 消息也被包装(见 {@link wrapCondition}),原文预设**会话就在上文**("transcript **above**");
12
+ * · 评估者 `thinkingConfig: { type: "disabled" }` + **`tools: []`** —— 它是**纯判官**,不能自己去查;
13
+ * · 会话消息**整段前置**(`s && s.length > 0 ? [...prepend(s), p] : [p]`),不是摘要。
14
+ * ⚠️ 语料把非 ASCII 存成 `\uXXXX` 六字符字面量(正文里那两个破折号是 `\u2014`)——**grep 真字符会全假阴**。
15
+ * 所以下面也用 `\u2014` 转义:源码保持 ASCII,运行时是同一个字符。
16
+ * ⚠️ **为什么必须自己核**:cli 报过他们移植的那段是**第三种措辞**(与 CC 220 的两个分支都不逐字相同,
17
+ * 应是从更早版本移植后 CC 改过而没跟)。转述会漂,语料不会。
18
+ */
19
+ /** 完整版(**Stop / SubagentStop** 用)。CC `pretty220.js` 逐字。 */
1
20
  export declare const CC_STOP_PROMPT_SYSTEM_FULL = "You are evaluating a stop-condition hook in Claude Code. Read the conversation transcript carefully, then judge whether the user-provided condition is satisfied.\n\nYour response must be a JSON object with one of these shapes:\n- {\"ok\": true, \"reason\": \"<quote evidence from the transcript that satisfies the condition>\"}\n- {\"ok\": false, \"reason\": \"<quote what is missing or what blocks the condition>\"}\n- {\"ok\": false, \"impossible\": true, \"reason\": \"<explain why the condition can never be satisfied>\"}\n\nAlways include a \"reason\" field, quoting specific text from the transcript whenever possible. If the transcript does not contain clear evidence that the condition is satisfied, return {\"ok\": false, \"reason\": \"insufficient evidence in transcript\"}.\n\nOnly use {\"ok\": false, \"impossible\": true} when the condition is genuinely unachievable in this session \u2014 for example: the condition is self-contradictory, it depends on a resource or capability that is unavailable, or the assistant has explicitly tried, exhausted reasonable approaches, and stated it cannot be done. Apply your own judgment when deciding this \u2014 the assistant claiming the goal is impossible is evidence, not proof; independently confirm the condition is genuinely unachievable rather than deferring to the assistant's self-assessment. Do not use it just because the goal has not been reached yet or because progress is slow. When in doubt, return {\"ok\": false} without \"impossible\".";
21
+ /** 简版(其余事件用)。CC `pretty220.js` 逐字。 */
2
22
  export declare const CC_STOP_PROMPT_SYSTEM_SIMPLE = "You are evaluating a hook condition in Claude Code. Judge whether the user-provided condition is met.\n\nYour response must be a JSON object with one of these shapes:\n- {\"ok\": true, \"reason\": \"<reason the condition is met>\"}\n- {\"ok\": false, \"reason\": \"<reason the condition is not met>\"}\n\nAlways include a \"reason\" field.";
23
+ /** 事件名 → 用哪一档。CC 判据逐字:`r === "Stop" || r === "SubagentStop"`。 */
3
24
  export declare function ccPromptSystemFor(event: string): string;
25
+ /**
26
+ * CC 对 user 消息的包装(**仅**完整版档位)。原文逐字,注意 "transcript **above**" ——
27
+ * 它预设会话已经在上文,所以调用方必须真的把会话放在前面,否则这句话本身就是在骗模型。
28
+ */
4
29
  export declare function wrapCondition(event: string, condition: string): string;
30
+ /** CC 的判词形:`{ ok, reason, impossible? }`(zod 原文:impossible = "only meaningful when ok is false")。 */
5
31
  export interface CcPromptVerdict {
6
32
  ok: boolean;
7
33
  reason?: string;
8
34
  impossible?: boolean;
9
35
  }
36
+ /**
37
+ * 解析模型判词。**解析不出来 ⇒ `undefined`**(= 无判决),绝不臆测成 `ok:false` ——
38
+ * 🔴 Stop 钩子的 `ok:false` **等于拦住停止**,把"读不懂"当成"没满足"会让一次解析失败变成一次拦停。
39
+ */
10
40
  export declare function parseCcVerdict(text: string): CcPromptVerdict | undefined;
41
+ /**
42
+ * CC 条件评估者的**输出额度**。
43
+ *
44
+ * 🔴 为什么不能用载体缺省(1024):CC 的系统提示**明确要求**评估者
45
+ * 「quote evidence from the transcript」——判词天然带引文;而**推理档模型的 thinking 与输出共用**这份额度。
46
+ * cli 的 live 围栏实测两种失败形,**同一根因**:①判词 JSON 被截断(`{"ok": true, "reason": "The first user…` 然后没了)
47
+ * ②一个字都没吐出来(thinking 吃光)。**两种都导致判词整条被丢弃 ⇒ fail-open(该拦没拦)** ——
48
+ * 而用户设 `enforced` 的全部意义就是「没达成别停」,这正是守卫在最需要它的时候静默失效。
49
+ *
50
+ * 4096 的取法:判词本身是个小 JSON + 一段引文(几百 token 足够),其余留给 thinking;
51
+ * 同时它安全地低于所有在用模型的输出硬顶(超硬顶会让整请求 400)。
52
+ */
11
53
  export declare const CC_EVALUATOR_MAX_OUTPUT_TOKENS = 4096;
12
54
  //# sourceMappingURL=cc-stop-prompt.d.ts.map
@@ -1,3 +1,22 @@
1
+ /**
2
+ * CC `execPromptHook` 的**逐字**移植面:两档系统提示 + `{ok, reason, impossible?}` 判词的解析与映射。
3
+ *
4
+ * ── 为什么单独一个文件 ──────────────────────────────────────────────────────────────────────────
5
+ * 本仓有 clay 的**提示词面锚定 CC 逐字**令(偏离仅限超集/品牌二类且需登记)。把这两段正文与它们的
6
+ * 判词形收在一处,才谈得上机器看守(见 `test/cc-stop-prompt.test.ts` 的字节钉)。
7
+ *
8
+ * ── 出处(我**第一手**核过,不是照抄转述)────────────────────────────────────────────────────────
9
+ * `sema-agent/cc-decoded` 的 `pretty220.js:609309` 起(219/218 同构)。逐字核实的四件:
10
+ * · 两档判据是 **hook 事件名**:`c = r === "Stop" || r === "SubagentStop"` ⇒ 这两个事件用**完整版**,其余用简版;
11
+ * · user 消息也被包装(见 {@link wrapCondition}),原文预设**会话就在上文**("transcript **above**");
12
+ * · 评估者 `thinkingConfig: { type: "disabled" }` + **`tools: []`** —— 它是**纯判官**,不能自己去查;
13
+ * · 会话消息**整段前置**(`s && s.length > 0 ? [...prepend(s), p] : [p]`),不是摘要。
14
+ * ⚠️ 语料把非 ASCII 存成 `\uXXXX` 六字符字面量(正文里那两个破折号是 `\u2014`)——**grep 真字符会全假阴**。
15
+ * 所以下面也用 `\u2014` 转义:源码保持 ASCII,运行时是同一个字符。
16
+ * ⚠️ **为什么必须自己核**:cli 报过他们移植的那段是**第三种措辞**(与 CC 220 的两个分支都不逐字相同,
17
+ * 应是从更早版本移植后 CC 改过而没跟)。转述会漂,语料不会。
18
+ */
19
+ /** 完整版(**Stop / SubagentStop** 用)。CC `pretty220.js` 逐字。 */
1
20
  export const CC_STOP_PROMPT_SYSTEM_FULL = `You are evaluating a stop-condition hook in Claude Code. Read the conversation transcript carefully, then judge whether the user-provided condition is satisfied.
2
21
 
3
22
  Your response must be a JSON object with one of these shapes:
@@ -8,6 +27,7 @@ Your response must be a JSON object with one of these shapes:
8
27
  Always include a "reason" field, quoting specific text from the transcript whenever possible. If the transcript does not contain clear evidence that the condition is satisfied, return {"ok": false, "reason": "insufficient evidence in transcript"}.
9
28
 
10
29
  Only use {"ok": false, "impossible": true} when the condition is genuinely unachievable in this session \u2014 for example: the condition is self-contradictory, it depends on a resource or capability that is unavailable, or the assistant has explicitly tried, exhausted reasonable approaches, and stated it cannot be done. Apply your own judgment when deciding this \u2014 the assistant claiming the goal is impossible is evidence, not proof; independently confirm the condition is genuinely unachievable rather than deferring to the assistant's self-assessment. Do not use it just because the goal has not been reached yet or because progress is slow. When in doubt, return {"ok": false} without "impossible".`;
30
+ /** 简版(其余事件用)。CC `pretty220.js` 逐字。 */
11
31
  export const CC_STOP_PROMPT_SYSTEM_SIMPLE = `You are evaluating a hook condition in Claude Code. Judge whether the user-provided condition is met.
12
32
 
13
33
  Your response must be a JSON object with one of these shapes:
@@ -15,16 +35,26 @@ Your response must be a JSON object with one of these shapes:
15
35
  - {"ok": false, "reason": "<reason the condition is not met>"}
16
36
 
17
37
  Always include a "reason" field.`;
38
+ /** 事件名 → 用哪一档。CC 判据逐字:`r === "Stop" || r === "SubagentStop"`。 */
18
39
  export function ccPromptSystemFor(event) {
19
40
  return event === "Stop" || event === "SubagentStop" ? CC_STOP_PROMPT_SYSTEM_FULL : CC_STOP_PROMPT_SYSTEM_SIMPLE;
20
41
  }
42
+ /**
43
+ * CC 对 user 消息的包装(**仅**完整版档位)。原文逐字,注意 "transcript **above**" ——
44
+ * 它预设会话已经在上文,所以调用方必须真的把会话放在前面,否则这句话本身就是在骗模型。
45
+ */
21
46
  export function wrapCondition(event, condition) {
22
47
  if (event !== "Stop" && event !== "SubagentStop")
23
48
  return condition;
24
49
  return `Based on the conversation transcript above, has the following stopping condition been satisfied? Answer based on transcript evidence only.\n\nCondition: ${condition}`;
25
50
  }
51
+ /**
52
+ * 解析模型判词。**解析不出来 ⇒ `undefined`**(= 无判决),绝不臆测成 `ok:false` ——
53
+ * 🔴 Stop 钩子的 `ok:false` **等于拦住停止**,把"读不懂"当成"没满足"会让一次解析失败变成一次拦停。
54
+ */
26
55
  export function parseCcVerdict(text) {
27
56
  const raw = text.trim();
57
+ // 模型常把 JSON 包在 ```json 围栏或散文里 —— 取第一个平衡的 {...} 块。
28
58
  const start = raw.indexOf("{");
29
59
  if (start < 0)
30
60
  return undefined;
@@ -38,7 +68,7 @@ export function parseCcVerdict(text) {
38
68
  try {
39
69
  const o = JSON.parse(raw.slice(start, i + 1));
40
70
  if (typeof o.ok !== "boolean")
41
- return undefined;
71
+ return undefined; // 没有 ok ⇒ 不是判词
42
72
  return {
43
73
  ok: o.ok,
44
74
  ...(typeof o.reason === "string" ? { reason: o.reason } : {}),
@@ -53,5 +83,17 @@ export function parseCcVerdict(text) {
53
83
  }
54
84
  return undefined;
55
85
  }
86
+ /**
87
+ * CC 条件评估者的**输出额度**。
88
+ *
89
+ * 🔴 为什么不能用载体缺省(1024):CC 的系统提示**明确要求**评估者
90
+ * 「quote evidence from the transcript」——判词天然带引文;而**推理档模型的 thinking 与输出共用**这份额度。
91
+ * cli 的 live 围栏实测两种失败形,**同一根因**:①判词 JSON 被截断(`{"ok": true, "reason": "The first user…` 然后没了)
92
+ * ②一个字都没吐出来(thinking 吃光)。**两种都导致判词整条被丢弃 ⇒ fail-open(该拦没拦)** ——
93
+ * 而用户设 `enforced` 的全部意义就是「没达成别停」,这正是守卫在最需要它的时候静默失效。
94
+ *
95
+ * 4096 的取法:判词本身是个小 JSON + 一段引文(几百 token 足够),其余留给 thinking;
96
+ * 同时它安全地低于所有在用模型的输出硬顶(超硬顶会让整请求 400)。
97
+ */
56
98
  export const CC_EVALUATOR_MAX_OUTPUT_TOKENS = 4096;
57
99
  //# sourceMappingURL=cc-stop-prompt.js.map
@@ -1,6 +1,19 @@
1
1
  import type { Model } from "@sema-agent/core";
2
2
  import type { ServiceConfig } from "../config-types.js";
3
3
  import type { HookLlmCall } from "./hook-runner.js";
4
+ /**
5
+ * hookLlm(prompt 条目/session titler 的模型载体)= 直连一次非流式 completion,从 main.ts 抽出成可注入
6
+ * 单元(fetchImpl/keyResolver 可假),因为这条 wire 在每个默认部署上都活(titler),必须可单测。
7
+ *
8
+ * api 形分派(2026-07-15,黑板 [851]③b 真缺陷修):被选模型按 `Model.api` 分家 ——
9
+ * - `openai-completions` ⇒ POST {base}/chat/completions(现状,字节不变);
10
+ * - `anthropic-messages` ⇒ POST {base}/v1/messages(x-api-key / Authorization: Bearer + anthropic-version
11
+ * 头,messages 数组,回包取 content[].text)。此前 hookLlm 只会说 openai 形且缺省 baseUrl 恒落
12
+ * `config.gatewayBaseUrl`(缺省 http://127.0.0.1:8000/v1)——anthropic 单路由部署(主模型
13
+ * provider=anthropic 走 ANTHROPIC_BASE_URL,没配 MODEL_GATEWAY_BASEURL)下 titler 每会话打死
14
+ * localhost:8000 ⇒ `session_title_failed: TypeError: fetch failed`;即使端点活着,anthropic-messages
15
+ * 模型也不能用 /chat/completions 形调。
16
+ */
4
17
  export type HookModelPick = {
5
18
  ok: true;
6
19
  catalogRef: string;
@@ -11,12 +24,14 @@ export type HookModelPick = {
11
24
  ok: false;
12
25
  error: string;
13
26
  };
27
+ /** The live object `createHookLlm` produces — model-pick resolution + the direct completion call, both capturing the hot-refreshed keyResolver/fetchImpl in closure. */
14
28
  export interface HookLlm {
15
29
  hookModelFor: (requested?: string) => HookModelPick;
16
30
  hookLlm: HookLlmCall;
17
31
  }
18
32
  export declare function createHookLlm(deps: {
19
33
  config: ServiceConfig;
34
+ /** 与 brain 同一 hot-refreshed per-model key 面(main.ts 热应用会整个换引用,故取函数不取值)。 */
20
35
  getKeyResolver: () => ((model: Model) => Promise<{
21
36
  apiKey: string;
22
37
  } | undefined>) | undefined;
@@ -1,6 +1,15 @@
1
1
  export function createHookLlm(deps) {
2
2
  const { config, metrics } = deps;
3
+ // anthropic 路由自己的 baseUrl(与 core createAnthropicBrain 同一解析链:model.baseUrl || config.baseUrl
4
+ // || 官方缺省)。路由未装(无 ANTHROPIC 凭据 ⇒ config.anthropic 缺席)⇒ undefined,分派据此判
5
+ // 「这个部署有没有 anthropic 腿」。
3
6
  const anthropicRouteBaseUrl = () => config.anthropic ? config.anthropic.baseUrl || "https://api.anthropic.com" : undefined;
7
+ // catalog KEY(name)≠ provider model id——registry 热应用后两者可分叉。分别返回:
8
+ // `catalogRef`(hookAgent 用,core resolveModel 按 deps.models 键解析;也是 keyResolver 的查键)与
9
+ // `providerModelId`+`baseUrl`+`api`(hookLlm 直连用)。baseUrl 缺省按 api 分家:openai 形落主网关
10
+ // (现状);anthropic 形落 anthropic 路由自己的 baseUrl——provider=anthropic 的模型在 brain 路由里
11
+ // 从不走 openai 网关,titler 兜到 gatewayBaseUrl 缺省值即上述每会话必现 fetch failed 的根因。
12
+ // anthropic 形两头都缺(模型无 per-model baseUrl 且路由未装)= 一句话诚实 fail,说清缺什么配置。
4
13
  const shapeFrom = (catalogRef, m, providerModelId) => {
5
14
  const api = m?.api === "anthropic-messages" || m?.provider === "anthropic" ? "anthropic-messages" : "openai-completions";
6
15
  if (api === "anthropic-messages") {
@@ -15,11 +24,16 @@ export function createHookLlm(deps) {
15
24
  }
16
25
  return { ok: true, catalogRef, providerModelId, baseUrl: m?.baseUrl || config.gatewayBaseUrl, api };
17
26
  };
27
+ // 默认=summarize 角色(cheap tier,council/压缩同款;缺角色→主模型);entry.model 覆盖须命中部署
28
+ // catalog(单用户=自家目录全开,与 workflow 模型 allowlist 同纪律),未命中=该条目 fail(非阻断记账)。
29
+ // ({select} 形态诚实落主模型——hook 是廉价判定调用,不值得拉 select 机制。)
18
30
  const hookModelFor = (requested) => {
19
31
  const shape = (ref) => shapeFrom(ref, config.models[ref], config.models[ref]?.id ?? ref);
20
32
  if (requested === undefined) {
21
33
  const sum = config.roles.summarize;
22
34
  const roleModel = typeof sum === "string" ? sum : sum && typeof sum === "object" && "model" in sum && typeof sum.model === "string" ? sum.model : undefined;
35
+ // 角色名不在目录 ⇒ 当作主模型路由上的 raw provider id(主 brain 家族就是它的真实服务面),
36
+ // 形状/缺省 baseUrl 跟主模型走,不再无条件钉死 openai 网关。
23
37
  if (roleModel !== undefined)
24
38
  return config.models[roleModel] ? shape(roleModel) : shapeFrom(config.model.id, config.model, roleModel);
25
39
  return shapeFrom(config.model.id, config.model, config.model.id);
@@ -38,7 +52,16 @@ export function createHookLlm(deps) {
38
52
  const ac = new AbortController();
39
53
  const t = setTimeout(() => ac.abort(), timeoutMs);
40
54
  try {
55
+ // 🔴 key resolution (2026-07-13 — the session titler widened this face from
56
+ // "deployments that configured hooks" to EVERY default deployment): per-model key (sealed-box custody /
57
+ // apiKeyEnv, via the SAME hot-refreshed keyResolver the brain uses) WINS; the MAIN gateway key rides ONLY
58
+ // to the main gateway's own baseUrl — a roster model pointing at a FOREIGN provider must NEVER receive
59
+ // the main key (credential exfiltration to whoever operates that URL). Foreign + no per-model key ⇒ the
60
+ // request goes out UNAUTHENTICATED (the provider 401s = honest failure, nothing leaked).
41
61
  const keyResolver = deps.getKeyResolver();
62
+ // 🔴 custody fail-closed(交叉评审 F1):resolver 抛错(sealed key 中毒/解密失败)≠「没配 per-model
63
+ // key」——吞成 undefined 会让 same-route 模型静默回落共享路由凭据照发。抛错=本次调用整体 fail,
64
+ // 不发任何请求(抽取前的内联版就有这个吞错,借抽取一并修死)。
42
65
  let perModelKey;
43
66
  if (keyResolver) {
44
67
  try {
@@ -48,6 +71,9 @@ export function createHookLlm(deps) {
48
71
  return { ok: false, error: `per-model key resolution for "${pick.catalogRef}" failed — refusing to fall back to the shared route credential (${String(e)})` };
49
72
  }
50
73
  }
74
+ // URL-normalized comparison (lens-A re-review: raw string compare false-negatives on host case /
75
+ // default-port forms and would strand the MAIN gateway without its own key — an availability bug in
76
+ // the safe direction, still a bug). new URL lowercases the host and drops a default port.
51
77
  const normUrl = (u) => {
52
78
  try {
53
79
  const x = new URL(u);
@@ -61,6 +87,10 @@ export function createHookLlm(deps) {
61
87
  let headers;
62
88
  let body;
63
89
  if (pick.api === "anthropic-messages") {
90
+ // anthropic 腿的同路纪律 = openai 腿 sameGateway 的镜像:anthropic 路由自己的凭据(authToken 压过
91
+ // apiKey,brain.ts 同序)只随路由自己的 baseUrl 走;per-model key 恒胜(x-api-key,core brain 的
92
+ // 同一注入位)。🔴 TRUE fail-closed 同款:foreign anthropic 端点无 per-model key ⇒ 连 prompt 都
93
+ // 不发(prompt 内嵌用户内容,未认证发射同样把数据外泄给该 URL 的运营方)。
64
94
  const routeBase = anthropicRouteBaseUrl();
65
95
  const sameRoute = routeBase !== undefined && normUrl(pick.baseUrl) === normUrl(routeBase);
66
96
  if (!perModelKey && !sameRoute) {
@@ -69,6 +99,8 @@ export function createHookLlm(deps) {
69
99
  url = `${pick.baseUrl.replace(/\/+$/, "")}/v1/messages`;
70
100
  headers = {
71
101
  "content-type": "application/json",
102
+ // anthropic-version 缺省与 core brain 一致;纯 per-model 端点(路由未装但 per-model key 在)
103
+ // 也带版本头,取同一缺省。
72
104
  "anthropic-version": config.anthropic?.version ?? "2023-06-01",
73
105
  ...(perModelKey
74
106
  ? { "x-api-key": perModelKey }
@@ -78,18 +110,31 @@ export function createHookLlm(deps) {
78
110
  ? { "x-api-key": config.anthropic.apiKey }
79
111
  : {}),
80
112
  };
113
+ // Messages API 必带 max_tokens:钳 1024 上限(交叉评审 F2)——hook 是廉价判定调用(titler 产出
114
+ // 一行标题),永远用不到更多;且 [854]③a 后 model.maxTokens 缺省抬到 32000,原样发给小输出上限的
115
+ // anthropic 形模型会整请求被拒(max_tokens 超模型硬顶=400),标题腿没必要陪这个险。
116
+ // 缺省 1024 是为 titler 那类"一行标题"调的;调用方可用 `maxOutputTokens` 声明自己需要更多
117
+ // (见该字段旁注:CC 评估者被要求引用转录,推理档的 thinking 还与输出共用额度)。
118
+ // 上限仍钳在模型自己的 maxTokens 以内 —— 超模型硬顶会整请求 400,这条原因没变。
81
119
  const want = maxOutputTokens ?? 1024;
82
120
  const maxTokens = Math.min(config.models[pick.catalogRef]?.maxTokens ?? want, want);
121
+ // `system` 走 Messages API 的**顶层字段**(不是一条 role:"system" 消息 —— anthropic 形不接受那个角色)。
83
122
  body = JSON.stringify({ model: pick.providerModelId, max_tokens: maxTokens, ...(system ? { system } : {}), messages: [{ role: "user", content: prompt }] });
84
123
  }
85
124
  else {
86
125
  const sameGateway = normUrl(pick.baseUrl) === normUrl(config.gatewayBaseUrl);
87
126
  const hookKey = perModelKey ?? (sameGateway ? config.gatewayApiKey : undefined);
127
+ // 🔴 TRUE fail-closed (lens-A HIGH): a FOREIGN endpoint with no per-model key must not receive the
128
+ // REQUEST BODY either — the hook prompt embeds user content (session-titler: the objective), so an
129
+ // unauthenticated fire still exfiltrates data to whoever operates that URL. Refuse before fetch.
88
130
  if (!sameGateway && !hookKey) {
89
131
  return { ok: false, error: `hook model "${pick.catalogRef}" points at a foreign baseUrl with no per-model key — refusing to send the prompt off-gateway` };
90
132
  }
91
133
  url = `${pick.baseUrl.replace(/\/+$/, "")}/chat/completions`;
92
134
  headers = { "content-type": "application/json", ...(hookKey ? { authorization: `Bearer ${hookKey}` } : {}) };
135
+ // `system` 在 openai 形是**前置的一条 system 消息**(与 anthropic 的顶层字段等价,两边同一语义)。
136
+ // openai 形此前**不发** max_tokens(用 provider 缺省)。只有调用方显式声明时才发 ——
137
+ // 不改 titler 那条腿的既有行为,同时让评估者能要到它需要的额度。
93
138
  body = JSON.stringify({ model: pick.providerModelId, ...(maxOutputTokens !== undefined ? { max_tokens: maxOutputTokens } : {}), messages: [...(system ? [{ role: "system", content: system }] : []), { role: "user", content: prompt }], stream: false });
94
139
  }
95
140
  const r = await fetchImpl(url, { method: "POST", headers, body, signal: ac.signal });
@@ -109,6 +154,8 @@ export function createHookLlm(deps) {
109
154
  return typeof text === "string" ? { ok: true, text } : { ok: false, error: "hook llm returned no content" };
110
155
  }
111
156
  catch (e) {
157
+ // 网络层失败原样只有 "TypeError: fetch failed"(不是人话):带上端点与 cause(ECONNREFUSED 等),
158
+ // 一句话说清打的是哪个 URL、为什么挂——titler 的 llm_failed 记账/warn 原样透出这条。
112
159
  const cause = e?.cause;
113
160
  return {
114
161
  ok: false,
@@ -3,40 +3,87 @@ import type { Hooks } from "@sema-agent/core";
3
3
  import type { Logger } from "../observability/logger.js";
4
4
  export declare const MAX_HOOK_ENTRIES_PER_EVENT = 32;
5
5
  export declare const MAX_HOOK_COMMAND_CHARS = 8192;
6
+ /** 单条 hook 超时上限(秒;条目可自设 timeout,但被此值夹住——一个 86400 的 timeout 会挂死工具门)。 */
6
7
  export declare const MAX_HOOK_TIMEOUT_SECONDS = 600;
8
+ /** 一次 hook 事件(一次 pre/post 调用)所有同步条目的墙钟总预算(秒;32 条 × 单条 600s
9
+ * 最坏可串行卡住工具门 ~320min。到点后不再起后续条目,记账降级)。 */
7
10
  export declare const MAX_HOOK_EVENT_TOTAL_SECONDS = 120;
11
+ /** 一次事件的 matcher 组数上限(配置广度的另一维,防组数爆炸)。 */
8
12
  export declare const MAX_HOOK_MATCHER_GROUPS = 16;
13
+ /** http 条目的 header 条数 / allowedEnvVars 个数上限(构造放大面)。 */
9
14
  export declare const MAX_HOOK_HTTP_HEADERS = 32;
15
+ /** hook 进程 stdout/stderr 各自的采集上限(字节)——防输出洪泛打爆内存/日志。 */
10
16
  export declare const MAX_HOOK_OUTPUT_BYTES: number;
11
17
  export interface ParseHooksConfigResult {
12
18
  config?: HooksConfig;
19
+ /** 人可读的第一条校验错误(HTTP 层用它 400 fail-loud;resume 防御路径用它 warn)。 */
13
20
  error?: string;
14
21
  }
22
+ /**
23
+ * 把 wire 上的 untrusted `settings.hooks` 校验成契约 {@link HooksConfig} + 服务侧上限。
24
+ * 错误返回 error 字符串而不 throw——submit 路径 400 fail-loud、resume 防御路径 warn-drop,由调用方选。
25
+ */
15
26
  export declare function parseHooksConfig(raw: unknown): ParseHooksConfigResult;
27
+ /** CC matcher 语义:精确名、`a|b` 交替、或 JS 正则(锚定全匹配,防 "Bash" 误配 "BashOutput");
28
+ * 空/`*`/缺省匹配一切;非法正则 → 该条不匹配(fail-closed 到"不跑",由调用方记账一次)。 */
16
29
  export declare function hookMatcherMatches(matcher: string | undefined, value: string): boolean | "invalid";
30
+ /** `if` 条目条件(CC-exact,对照 CC 2.1.187/198 实测行为核验的真语义,两版一致):
31
+ * 值 = permission-rule 模式(`ToolName` 或 `ToolName(arg-模式)`),【不是】表达式语言——按当前工具调用
32
+ * 求值:名部走 permission matcher(交替/正则同 matcher 字段),括号内 arg-模式(`*` 通配)匹配工具输入的
33
+ * 主字符串(Bash=command,文件工具=file_path/path)。CC 行为逐条目:不匹配 → 跳过该条目(记日志);
34
+ * 非工具事件(payload 无 tool_name)→ "cannot be evaluated" 跳过;解析失败 → 跳过。返回:
35
+ * true=跑 / "not_matched" / "unevaluable"(调用方分别记账;跳过永不静默)。 */
17
36
  export declare function hookIfMatches(cond: string, payload: unknown): true | "not_matched" | "unevaluable";
37
+ /** createTaskHooks 的装配上下文(payload 的 CC-verbatim 字段来源)。 */
18
38
  export interface HookRunnerContext {
19
39
  logger: Logger;
20
40
  sessionId: string;
41
+ /** hook 命令的工作目录 + payload `cwd` + `CLAUDE_PROJECT_DIR`(host lane 的 session cwd;无则 server cwd)。 */
21
42
  cwd: string;
22
43
  permissionMode?: string;
44
+ /** 请求自带的 `settings.env`(单用户闸后)——hook 进程 env 与 http $NAME 插值的用户变量通道。 */
23
45
  shellEnv?: Record<string, string>;
46
+ /** 阶段三b:`prompt` 条目的模型调用载体(部署组装:一次非流式 completion,费用不折 task budget)。
47
+ * 缺席 ⇒ prompt 条目跳过记账(部署没配模型面就诚实降级,不瞎猜)。fake 可注入 ⇒ hook-runner 保持单测性。 */
24
48
  hookLlm?: HookLlmCall;
49
+ /** 阶段三b:`agent` 条目的子代理载体(部署组装:runTask 读-only 手 + 可重入禁 + 独立小 budget)。 */
25
50
  hookAgent?: HookLlmCall;
51
+ /** 一次 hook 判定**未能完成**时的观测回调(纯 observe;部署把它接到 fleet 流)。
52
+ * 🔴 存在的理由:方向可以 fail-open,但**不能连「我这轮没看住」都不说** —— 否则模型拿到的放行
53
+ * 与「已达成」无法区分,而产品刚对它承诺过「没达成不许停」。
54
+ * ⚠️ 它**必须**是不改变运行的通道:`additionalContext` 不行(那个会让这一轮不结束)。缺席 ⇒ 只进日志。 */
26
55
  onHookNotice?: (n: {
27
56
  kind: "hook_decision_unavailable";
28
57
  event: string;
29
58
  reason: "no_content" | "unparsed" | "skipped";
30
59
  detail?: string;
31
60
  }) => void;
61
+ /** Stop × `type:"prompt"` 是否把**会话 transcript** 交给评估者(CC `execPromptHook` 形)。
62
+ * 缺省(undefined)= **开**。`false` ⇒ 整条路不启用(prompt 条目在 Stop 上被跳过并记账)——
63
+ * 部署侧的显式逃生口(`SEMA_STOP_PROMPT_TRANSCRIPT=0`)。见 `hooks.stop` 里那段三问。 */
32
64
  stopPromptTranscript?: boolean;
65
+ /** asyncRewake wake 管道(契约:Background + wake the model on exit 2)。部署组装:live 腿=同 session
66
+ * 的 TaskStream.steer(下个 turn 边界注入);返回 false=没有活流可投(任务已结束/挂起/别副本)——
67
+ * 调用方记账不重试(挂起腿的 pending-steer park 是后续切片)。缺席 ⇒ asyncRewake 降级纯 async(记账)。 */
33
68
  wake?: (text: string) => Promise<boolean>;
34
69
  }
70
+ /** 阶段三b 模型调用载体契约(prompt=直连一次 completion;agent=runTask 收敛后的 final text)。
71
+ * 返回 ok/text 或 ok:false/error——载体自己兜超时(timeoutMs 是硬顶,载体可更严),绝不 throw。 */
35
72
  export type HookLlmCall = (opts: {
36
73
  prompt: string;
37
74
  model?: string;
38
75
  timeoutMs: number;
76
+ /** 本次调用需要的**输出**上限(tokens)。缺席 ⇒ 载体用它自己的缺省(1024,为 titler 那类"一行标题"
77
+ * 的廉价判定调好的)。
78
+ * 🔴 **加这个位是因为共用缺省真的咬人了**:CC 的条件评估者被提示词**明确要求**「quote evidence from
79
+ * the transcript」,推理档模型的 thinking 还与输出**共用**这份额度 ⇒ 1024 会把判词截断、
80
+ * 甚至一个字都吐不出来 ⇒ 判词整条被丢弃 ⇒ **fail-open(该拦没拦)**。
81
+ * ⇒ 判据:**给一个载体加新消费者时,要重访它为旧工况调好的每一个参数** ——
82
+ * 那些参数的旁注里通常写着一句"永远用不到更多",而那句话是**对旧工况**说的。 */
39
83
  maxOutputTokens?: number;
84
+ /** 系统提示。CC 的 `execPromptHook` 给条件评估者套一段(见 `cc-stop-prompt.ts` 的逐字移植)——
85
+ * anthropic 形走 Messages API 的**顶层 `system` 字段**,openai 形走**前置的一条 system 消息**,
86
+ * 两边同一语义。缺席 ⇒ 与此前逐位相同(无 system)。 */
40
87
  system?: string;
41
88
  }) => Promise<{
42
89
  ok: true;
@@ -45,10 +92,52 @@ export type HookLlmCall = (opts: {
45
92
  ok: false;
46
93
  error: string;
47
94
  }>;
95
+ /**
96
+ * 阶段三a:`http` 条目——契约语义 = POST hook 输入 JSON 到 `url`;headers 里的 `$NAME` 仅当 NAME 列在
97
+ * `allowedEnvVars` 才从 worker 进程 env 插值(配置本身绝不携带密钥值,契约同边界)。
98
+ *
99
+ * 结果折算成伪 {@link CommandRunResult},让 9 事件的既有折叠逻辑零改动复用:
100
+ * - 2xx + JSON body → 同 exit-0-stdout-JSON(SyncHookOutput 决策面)。⚠️ 这是对 CC 行为的合理近似
101
+ * (契约只定"POST 输入";端点回非 JSON → 忽略,与 command 同姿势),板上已请壳确认 CC-exact。
102
+ * - 非 2xx → code=HTTP status(≥100,永远不会撞 exit-2 的阻断语义)→ 非阻断 warn 记账。
103
+ * - 超时/网络错 → timedOut / spawnError 同款,非阻断。
104
+ * 🔒 redirect:"error"——插值出的 Authorization 头绝不跟着重定向跨源;URL 指向哪由用户配置负责
105
+ * (hook 跑在单用户 host lane=用户自己机器,与 command 条目跑任意 sh 同一 class ② 信任面)。
106
+ */
107
+ /**
108
+ * 阶段三b:跑一条 `prompt`/`agent` 条目(design/HOOKS-PHASE3B-PROMPT-AGENT.md)。两者共此函数——
109
+ * 差异只在载体(prompt=ctx.hookLlm 直连一次 completion;agent=ctx.hookAgent 读-only 子代理)与默认
110
+ * 超时。`$ARGUMENTS` 占位符替换为 hook 输入 JSON(CC 语义;与 command stdin 同一份 payload,同
111
+ * 256K 截断纪律),模型输出折成伪 CommandRunResult{code:0, stdout:text} → 每个事件既有的
112
+ * `parseHookStdout` 决策面(SyncHookOutput)零改动继承:输出可解析 JSON=决策(allow/deny/ask/
113
+ * updatedInput/continue:false…),非 JSON=该事件对 plain text 的既有语义(与 command exit-0 同)。
114
+ * 载体失败/超时 → spawnError/timedOut 同款非阻断。可重入禁是【载体】的责任(部署组装的 runTask
115
+ * 不装 hooks——结构性,见 main.ts);hook-runner 自身不发模型调用,fake 载体即可单测。
116
+ */
117
+ /** Stop×prompt 专用的额外输入(见 `cc-stop-prompt.ts` / `branch-transcript.ts`)。 */
48
118
  export interface LlmHookExtra {
119
+ /** CC 逐字的系统提示。 */
49
120
  system: string;
121
+ /** **会话 transcript,放在条件之前** —— CC 的包装句写的是 "transcript **above**",
122
+ * 所以它必须真的在上文,否则那句话本身就是在骗模型。 */
50
123
  transcript: string;
51
124
  }
125
+ /**
126
+ * 把校验过的 {@link HooksConfig} 翻成 core `Hooks` 回调(阶段二:engine-owned 9 事件全点亮)。
127
+ * 没有可点亮的条目 → undefined(spec 不挂 hooks,deps 路径原样)。
128
+ */
52
129
  export declare function createTaskHooks(config: HooksConfig, ctx: HookRunnerContext): Hooks | undefined;
130
+ /**
131
+ * 把部署级 hooks 基线(deps.hooks,如 TOOL_TRACE 观测)折进 task 级 hooks——core 是整槽覆盖
132
+ * (`spec.hooks ?? deps.hooks`),不折叠就静默 shadow 部署观测(runtask gateBaseline 注释点名的坑)。
133
+ * 语义:部署槽先跑(观测看到原始输入/输出),task 槽后跑;结果合并:
134
+ * - preToolUse:deny > ask > allow 折叠;updatedInput 串行线程(部署重写喂给 task 槽);context 拼接。
135
+ * - postToolUse/postToolUseFailure/postToolBatch:双跑,additionalContext 拼接,updatedOutput 取
136
+ * 后者(task 槽)优先。
137
+ * - userPromptSubmit/stop:部署 block 优先短路(不再跑 task 槽),否则双跑、context 拼接、task block 生效。
138
+ * - preCompact:双跑,block 部署优先,additionalInstructions 拼接。
139
+ * - stopFailure/postCompact(observe-only void):顺序双跑,无返回可折。
140
+ * 单在则透传。
141
+ */
53
142
  export declare function composeHooks(deployment: Hooks | undefined, task: Hooks): Hooks;
54
143
  //# sourceMappingURL=hook-runner.d.ts.map