@sema-agent/server 7.135.0 → 7.137.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (342) hide show
  1. package/MIGRATION.md +237 -2
  2. package/USAGE.md +146 -41
  3. package/deploy/sema-up/README.md +15 -1
  4. package/deploy/sema-up/chart/templates/NOTES.txt +1 -1
  5. package/deploy/sema-up/chart/templates/sandbox-rbac.yaml +7 -1
  6. package/deploy/sema-up/chart/values.yaml +1 -1
  7. package/deploy/sema-up/stack/sema-stack-cluster.yaml +7 -1
  8. package/dist/approval-card.d.ts +60 -4
  9. package/dist/approval-card.js +18 -1
  10. package/dist/approval-content-kind.d.ts +7 -0
  11. package/dist/approval-content-kind.js +8 -1
  12. package/dist/approval-gate-currency.d.ts +48 -6
  13. package/dist/approval-gate-currency.js +16 -9
  14. package/dist/approval-hmac.d.ts +13 -1
  15. package/dist/approval-hmac.js +1 -1
  16. package/dist/approval.js +3 -3
  17. package/dist/auth-bridge.d.ts +34 -5
  18. package/dist/auth-bridge.js +22 -5
  19. package/dist/boot/budget-tracing.d.ts +1 -2
  20. package/dist/boot/budget-tracing.js +2 -2
  21. package/dist/boot/execution-env.d.ts +24 -1
  22. package/dist/boot/execution-env.js +69 -6
  23. package/dist/boot/org-memory.js +1 -1
  24. package/dist/boot/reapers.d.ts +3 -0
  25. package/dist/boot/reapers.js +15 -1
  26. package/dist/boot/resolve-spec.d.ts +4 -0
  27. package/dist/boot/resolve-spec.js +24 -22
  28. package/dist/boot/runner-deps.js +4 -2
  29. package/dist/boot/stage-03-store-backend.d.ts +1 -1
  30. package/dist/boot/stage-04-stores.d.ts +2 -2
  31. package/dist/boot/stage-05-execution-env.d.ts +4 -2
  32. package/dist/boot/stage-05-execution-env.js +11 -2
  33. package/dist/boot/stage-06-runners.d.ts +4 -2
  34. package/dist/boot/stage-06-runners.js +5 -1
  35. package/dist/boot/stage-07-capability-layer.d.ts +5 -2
  36. package/dist/boot/stage-07-capability-layer.js +1 -1
  37. package/dist/boot/stage-08-reapers.d.ts +5 -2
  38. package/dist/boot/stage-08-reapers.js +2 -1
  39. package/dist/boot/stage-09-leader.d.ts +5 -2
  40. package/dist/boot/stage-10-http-server.d.ts +5 -2
  41. package/dist/boot/stage-10-http-server.js +3 -2
  42. package/dist/boot/stores.d.ts +1 -1
  43. package/dist/boot/stores.js +2 -3
  44. package/dist/boot/web-admin.js +10 -17
  45. package/dist/brain.js +12 -3
  46. package/dist/broker/broker.d.ts +89 -0
  47. package/dist/broker/broker.js +287 -0
  48. package/dist/broker/constants.d.ts +39 -0
  49. package/dist/broker/constants.js +15 -0
  50. package/dist/broker/http1.d.ts +111 -0
  51. package/dist/broker/http1.js +256 -0
  52. package/dist/broker/lease-book.d.ts +87 -0
  53. package/dist/broker/lease-book.js +142 -0
  54. package/dist/broker/lease-file.d.ts +60 -0
  55. package/dist/broker/lease-file.js +127 -0
  56. package/dist/broker/main.d.ts +2 -0
  57. package/dist/broker/main.js +20 -0
  58. package/dist/budget.d.ts +3 -3
  59. package/dist/budget.js +4 -0
  60. package/dist/capabilities/composite-members.d.ts +2 -1
  61. package/dist/capabilities/composite-members.js +2 -1
  62. package/dist/capabilities/engine-capabilities.js +1 -0
  63. package/dist/capabilities/mcp-probe.d.ts +5 -4
  64. package/dist/capabilities/scenarios.d.ts +23 -8
  65. package/dist/capabilities/scenarios.js +13 -8
  66. package/dist/capabilities/skills.d.ts +28 -5
  67. package/dist/capabilities/skills.js +8 -0
  68. package/dist/capability-facts.d.ts +3 -7
  69. package/dist/capability-facts.js +3 -5
  70. package/dist/center-credential-renewer.js +5 -1
  71. package/dist/center-credential.d.ts +18 -4
  72. package/dist/center-credential.js +18 -3
  73. package/dist/checkpoint-ctx-seal-m28.d.ts +3 -10
  74. package/dist/checkpoint-ctx-seal-m28.js +1 -1
  75. package/dist/checkpoint-identity.d.ts +3 -3
  76. package/dist/config-catalog.js +21 -16
  77. package/dist/config-d-migration.js +1 -1
  78. package/dist/config-invariants.d.ts +1 -1
  79. package/dist/config-invariants.js +8 -0
  80. package/dist/config-lkg.d.ts +0 -38
  81. package/dist/config-lkg.js +1 -83
  82. package/dist/config-types.d.ts +21 -4
  83. package/dist/config.d.ts +1 -1
  84. package/dist/config.js +60 -16
  85. package/dist/deployment-governance.d.ts +2 -2
  86. package/dist/deployment-governance.js +7 -9
  87. package/dist/deployment-shape.d.ts +1 -1
  88. package/dist/device-ws-protocol.d.ts +1 -0
  89. package/dist/device-ws-protocol.js +2 -1
  90. package/dist/elicitation.d.ts +8 -7
  91. package/dist/elicitation.js +9 -8
  92. package/dist/file-history-disclosure.d.ts +8 -4
  93. package/dist/file-history-disclosure.js +24 -6
  94. package/dist/fleet-client.d.ts +32 -1
  95. package/dist/fleet-client.js +24 -4
  96. package/dist/fleet-lease.d.ts +7 -3
  97. package/dist/fleet-lease.js +31 -23
  98. package/dist/hooks/classic-stations.d.ts +11 -54
  99. package/dist/hooks/hook-llm.js +14 -8
  100. package/dist/hooks/hook-runner.d.ts +4 -4
  101. package/dist/hooks/hook-runner.js +2 -2
  102. package/dist/http/admission.js +10 -7
  103. package/dist/http/approval-sweeps.js +4 -3
  104. package/dist/http/caller-trust.d.ts +2 -1
  105. package/dist/http/caller-trust.js +1 -3
  106. package/dist/http/checkpoint-ctx.d.ts +76 -16
  107. package/dist/http/checkpoint-ctx.js +45 -1
  108. package/dist/http/dispatch.js +24 -19
  109. package/dist/http/durable-run-leg.d.ts +5 -1
  110. package/dist/http/durable-run-leg.js +1 -1
  111. package/dist/http/health-self-report.d.ts +2 -2
  112. package/dist/http/mcp-remote-text.d.ts +5 -0
  113. package/dist/http/mcp-remote-text.js +7 -0
  114. package/dist/http/principal-gate.d.ts +15 -10
  115. package/dist/http/principal-gate.js +48 -9
  116. package/dist/http/resume-ctx-read.d.ts +2 -16
  117. package/dist/http/resume-ctx-read.js +2 -3
  118. package/dist/http/resume-legs.d.ts +2 -20
  119. package/dist/http/resume-legs.js +52 -38
  120. package/dist/http/route-ctx.d.ts +8 -2
  121. package/dist/http/routes/approvals-assistant.d.ts +0 -2
  122. package/dist/http/routes/approvals-assistant.js +65 -16
  123. package/dist/http/routes/capabilities.js +11 -1
  124. package/dist/http/routes/mcp-reconnect.d.ts +1 -1
  125. package/dist/http/routes/mcp-reconnect.js +5 -7
  126. package/dist/http/routes/runs.js +4 -3
  127. package/dist/http/routes/session-sync.js +70 -12
  128. package/dist/http/routes/sessions.js +20 -15
  129. package/dist/http/routes/tasks.js +8 -6
  130. package/dist/http/server.d.ts +4 -0
  131. package/dist/http/stored-body-replay.d.ts +3 -3
  132. package/dist/http/stored-body-replay.js +6 -1
  133. package/dist/http/submit-ctx.js +1 -1
  134. package/dist/http/wire-types.d.ts +57 -30
  135. package/dist/identity-source.d.ts +65 -0
  136. package/dist/identity-source.js +45 -0
  137. package/dist/index.d.ts +1 -0
  138. package/dist/index.js +1 -0
  139. package/dist/memory-store-refusal.d.ts +3 -3
  140. package/dist/model-entry-refusal.d.ts +2 -0
  141. package/dist/model-entry-refusal.js +11 -0
  142. package/dist/model-route-gap.d.ts +49 -4
  143. package/dist/model-route-gap.js +34 -1
  144. package/dist/model-select.d.ts +6 -17
  145. package/dist/model-select.js +0 -3
  146. package/dist/namespaced-rule-name.d.ts +1 -1
  147. package/dist/object-store-buckets.d.ts +13 -0
  148. package/dist/object-store-buckets.js +3 -0
  149. package/dist/observability/fail-open.d.ts +19 -7
  150. package/dist/observability/fail-open.js +19 -7
  151. package/dist/observability/metrics.js +2 -2
  152. package/dist/observability/principal-context.d.ts +4 -1
  153. package/dist/observability/principal-context.js +6 -1
  154. package/dist/observability/run-terminal.js +1 -0
  155. package/dist/operator-ask.d.ts +2 -2
  156. package/dist/org-delivery-gate.js +1 -1
  157. package/dist/org-memory-admission.d.ts +2 -2
  158. package/dist/org-memory-admission.js +39 -2
  159. package/dist/parked-decide.d.ts +4 -3
  160. package/dist/parked-decide.js +29 -9
  161. package/dist/peer-directory.d.ts +2 -1
  162. package/dist/peer-directory.js +7 -5
  163. package/dist/permission-rule-list.d.ts +2 -2
  164. package/dist/plugins/approval-ask-store-sql.d.ts +8 -0
  165. package/dist/plugins/approval-ask-store-sql.js +3 -0
  166. package/dist/plugins/blob-backend.js +2 -1
  167. package/dist/plugins/checkpoint-index-columns.d.ts +50 -1
  168. package/dist/plugins/checkpoint-index-columns.js +28 -0
  169. package/dist/plugins/checkpoint-store-sql.d.ts +46 -12
  170. package/dist/plugins/checkpoint-store-sql.js +64 -35
  171. package/dist/plugins/file-history-store-sql.d.ts +6 -0
  172. package/dist/plugins/file-history-store-sql.js +37 -37
  173. package/dist/plugins/file-run-store.js +8 -2
  174. package/dist/plugins/k8s-exec-protocol.d.ts +69 -13
  175. package/dist/plugins/k8s-exec-protocol.js +116 -28
  176. package/dist/plugins/k8s-pod-delete-failure.d.ts +25 -0
  177. package/dist/plugins/k8s-pod-delete-failure.js +17 -0
  178. package/dist/plugins/k8s-pod-reaper.d.ts +112 -0
  179. package/dist/plugins/k8s-pod-reaper.js +122 -0
  180. package/dist/plugins/local-checkpoint-store.d.ts +3 -6
  181. package/dist/plugins/local-checkpoint-store.js +7 -6
  182. package/dist/plugins/memory-run-store.js +2 -0
  183. package/dist/plugins/one-time-migrations.d.ts +49 -37
  184. package/dist/plugins/one-time-migrations.js +87 -128
  185. package/dist/plugins/permission-rule-store-file.js +2 -2
  186. package/dist/plugins/permission-rule-store-sql.d.ts +17 -17
  187. package/dist/plugins/permission-rule-store-sql.js +16 -17
  188. package/dist/plugins/pg-pool.js +4 -0
  189. package/dist/plugins/pg-session-storage.js +2 -2
  190. package/dist/plugins/remote-env-adb.d.ts +3 -0
  191. package/dist/plugins/remote-env-adb.js +1 -0
  192. package/dist/plugins/remote-env-device.d.ts +3 -0
  193. package/dist/plugins/remote-env-device.js +4 -0
  194. package/dist/plugins/remote-env-e2b.d.ts +3 -0
  195. package/dist/plugins/remote-env-e2b.js +1 -0
  196. package/dist/plugins/remote-env-file-error.d.ts +8 -1
  197. package/dist/plugins/remote-env-file-error.js +7 -1
  198. package/dist/plugins/remote-env-host.d.ts +7 -1
  199. package/dist/plugins/remote-env-host.js +7 -1
  200. package/dist/plugins/remote-env-k8s.d.ts +154 -14
  201. package/dist/plugins/remote-env-k8s.js +300 -21
  202. package/dist/plugins/remote-env-local-docker.d.ts +3 -0
  203. package/dist/plugins/remote-env-local-docker.js +1 -0
  204. package/dist/plugins/remote-env-ssh.d.ts +3 -0
  205. package/dist/plugins/remote-env-ssh.js +1 -0
  206. package/dist/plugins/run-store-sql.js +10 -4
  207. package/dist/plugins/s3-answer.d.ts +15 -0
  208. package/dist/plugins/s3-answer.js +5 -0
  209. package/dist/plugins/session-ownership.d.ts +17 -3
  210. package/dist/plugins/session-ownership.js +19 -5
  211. package/dist/plugins/snapshot-bucket-presence.d.ts +39 -4
  212. package/dist/plugins/snapshot-bucket-presence.js +35 -7
  213. package/dist/plugins/sql-errors.d.ts +60 -0
  214. package/dist/plugins/sql-errors.js +64 -1
  215. package/dist/plugins/store-contracts.d.ts +10 -1
  216. package/dist/plugins/store-fault.d.ts +4 -0
  217. package/dist/plugins/store-fault.js +10 -0
  218. package/dist/plugins/tidb-pool.js +8 -1
  219. package/dist/plugins/tidb-session-store.js +2 -2
  220. package/dist/plugins/web-search.d.ts +1 -1
  221. package/dist/plugins/web-search.js +2 -2
  222. package/dist/request-declaration-refusal.d.ts +94 -0
  223. package/dist/request-declaration-refusal.js +78 -0
  224. package/dist/request-image-urls.d.ts +6 -0
  225. package/dist/request-image-urls.js +27 -0
  226. package/dist/request-key-closure.d.ts +5 -0
  227. package/dist/request-key-closure.js +5 -2
  228. package/dist/request-value-closure.d.ts +31 -2
  229. package/dist/request-value-closure.js +7 -1
  230. package/dist/rule-entry-list.d.ts +3 -2
  231. package/dist/rule-entry-list.js +2 -2
  232. package/dist/rules-consent.js +7 -4
  233. package/dist/run-local.d.ts +2 -2
  234. package/dist/runs.js +2 -1
  235. package/dist/runtime-caps-resolver.js +1 -1
  236. package/dist/runtime-governance.d.ts +5 -5
  237. package/dist/sandbox-git-lease.d.ts +49 -0
  238. package/dist/sandbox-git-lease.js +60 -0
  239. package/dist/sandbox-git-plane.d.ts +84 -0
  240. package/dist/sandbox-git-plane.js +105 -0
  241. package/dist/sandbox-pkg-source.d.ts +28 -1
  242. package/dist/sandbox-pkg-source.js +1 -2
  243. package/dist/sealed-key.d.ts +19 -0
  244. package/dist/sealed-key.js +47 -4
  245. package/dist/security.d.ts +16 -4
  246. package/dist/security.js +8 -3
  247. package/dist/server-secret-env.d.ts +6 -0
  248. package/dist/server-secret-env.js +14 -0
  249. package/dist/session-error-wire.d.ts +14 -6
  250. package/dist/session-error-wire.js +2 -1
  251. package/dist/session-incarnation.d.ts +16 -5
  252. package/dist/session-incarnation.js +7 -4
  253. package/dist/session-policy-wire.d.ts +1 -1
  254. package/dist/session-policy-wire.js +2 -2
  255. package/dist/session-row.d.ts +3 -17
  256. package/dist/session-row.js +4 -0
  257. package/dist/session-sync.d.ts +15 -3
  258. package/dist/session-sync.js +5 -2
  259. package/dist/spec-fields.d.ts +43 -13
  260. package/dist/spec-fields.js +33 -12
  261. package/dist/stored-request-prompt-profile-m30.d.ts +49 -0
  262. package/dist/stored-request-prompt-profile-m30.js +25 -0
  263. package/dist/task-a2a.d.ts +52 -81
  264. package/dist/task-a2a.js +219 -89
  265. package/dist/task-mcp.d.ts +7 -15
  266. package/dist/task-mcp.js +16 -51
  267. package/dist/task-settings.d.ts +2 -2
  268. package/dist/tool-approval.d.ts +35 -12
  269. package/dist/tool-approval.js +59 -39
  270. package/dist/tool-rule-names.d.ts +5 -0
  271. package/dist/trace/core-keyset-guard.d.ts +5 -5
  272. package/dist/trace/engine-notice-wire.d.ts +1 -1
  273. package/dist/trace/engine-notice-wire.js +2 -0
  274. package/dist/trace/exit-seat.js +37 -13
  275. package/dist/trace/ledger-sink.d.ts +4 -5
  276. package/dist/trace/ledger-sink.js +3 -7
  277. package/dist/trace/project.d.ts +37 -3
  278. package/dist/trace/project.js +20 -6
  279. package/dist/trace/redact.d.ts +40 -12
  280. package/dist/trace/redact.js +332 -128
  281. package/dist/trace/self-minted-wire.d.ts +641 -0
  282. package/dist/trace/self-minted-wire.js +201 -0
  283. package/dist/trace/wire-projection-faces.d.ts +5 -3
  284. package/dist/trace/wire-projection-faces.js +7 -3
  285. package/dist/url-credential-refusal.d.ts +52 -0
  286. package/dist/url-credential-refusal.js +14 -0
  287. package/dist/url-refusal.d.ts +13 -4
  288. package/dist/url-refusal.js +8 -2
  289. package/dist/web-admin-client/apply-effective.js +0 -1
  290. package/dist/web-admin-client/center-request.d.ts +20 -2
  291. package/dist/web-admin-client/center-request.js +40 -5
  292. package/dist/web-admin-client/http-client.js +6 -6
  293. package/dist/web-admin-client/types.d.ts +5 -5
  294. package/dist/workspace-space.d.ts +27 -0
  295. package/dist/workspace-space.js +26 -0
  296. package/docs/DEVICE-EXECUTOR-PROTOCOL.md +11 -5
  297. package/package.json +4 -3
  298. package/scripts/drain-check-local.mjs +2 -1
  299. package/scripts/drain-check.mysql.sql +3 -1
  300. package/scripts/drain-check.pg.sql +3 -1
  301. package/skills/schedule.md +1 -1
  302. package/wire-changes/server@7.104.0.json +134 -0
  303. package/wire-changes/server@7.105.0.json +53 -0
  304. package/wire-changes/server@7.106.0.json +475 -0
  305. package/wire-changes/server@7.107.0.json +64 -0
  306. package/wire-changes/server@7.108.0.json +153 -0
  307. package/wire-changes/server@7.109.0.json +46 -0
  308. package/wire-changes/server@7.110.0.json +90 -0
  309. package/wire-changes/server@7.111.0.json +86 -0
  310. package/wire-changes/server@7.112.0.json +60 -0
  311. package/wire-changes/server@7.113.0.json +26 -0
  312. package/wire-changes/server@7.114.0.json +26 -0
  313. package/wire-changes/server@7.115.0.json +97 -0
  314. package/wire-changes/server@7.116.0.json +218 -0
  315. package/wire-changes/server@7.116.1.json +26 -0
  316. package/wire-changes/server@7.117.0.json +65 -0
  317. package/wire-changes/server@7.118.0.json +129 -0
  318. package/wire-changes/server@7.119.0.json +65 -0
  319. package/wire-changes/server@7.120.0.json +89 -0
  320. package/wire-changes/server@7.121.0.json +219 -0
  321. package/wire-changes/server@7.122.0.json +54 -0
  322. package/wire-changes/server@7.123.0.json +26 -0
  323. package/wire-changes/server@7.124.0.json +336 -0
  324. package/wire-changes/server@7.124.1.json +26 -0
  325. package/wire-changes/server@7.125.0.json +111 -0
  326. package/wire-changes/server@7.126.0.json +285 -0
  327. package/wire-changes/server@7.127.0.json +77 -0
  328. package/wire-changes/server@7.127.1.json +26 -0
  329. package/wire-changes/server@7.127.2.json +53 -0
  330. package/wire-changes/server@7.128.0.json +26 -0
  331. package/wire-changes/server@7.129.0.json +106 -0
  332. package/wire-changes/server@7.129.1.json +26 -0
  333. package/wire-changes/server@7.130.0.json +26 -0
  334. package/wire-changes/server@7.131.0.json +118 -0
  335. package/wire-changes/server@7.132.0.json +226 -0
  336. package/wire-changes/server@7.133.0.json +1155 -0
  337. package/wire-changes/server@7.134.0.json +107 -0
  338. package/wire-changes/server@7.135.0.json +174 -0
  339. package/wire-changes/server@7.136.0.json +448 -0
  340. package/wire-changes/server@7.137.0.json +825 -0
  341. package/dist/url-credential.d.ts +0 -52
  342. package/dist/url-credential.js +0 -49
@@ -213,11 +213,14 @@ export declare function carriesDeploymentListQuestion(deploymentListAsks: boolea
213
213
  * 本仓**策略层自己交出去的一问**的 {@link StandingAnswerFacts}。读者两个:部署名单门(`approval.ts`,`deploymentListQuestion: true`)与 workflow 问句门
214
214
  * (`task-settings.ts`,`false`)—— 它们在交出这一问之前先读按工具名记的耐久豁免店(「本会话不再询问」在本层兑现,继承链上的同一问才够得着;审批席依约不退役
215
215
  * 继承问),而**能不能读**与审批席 / 回决写侧是同一只判据({@link standingAnswerDurablyRecordable}):记得下的才代答,记不下的(带授予绑定的问 ……)不代答,
216
- * 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link NO_GATE_FACTS});`requiresRealApproval` /
216
+ * 存量行也不例外 —— 一事一读。事实取自**这一问本身**:类集经 core 包根唯一的类派生 `classifyAsk`({@link noGateFacts},调用坐标取 `req`);`requiresRealApproval` /
217
217
  * `mandated` 读这一问自报的成员;治理位恒假(本层不是治理层);授予绑定读**调用**(`callGrantBindingOf` —— 本层手里还没有引擎铸的卡,core 7.51.0 不在
218
218
  * `ToolCallRequest` 上盖绑定词,[ref] 载体问题见 `standing-answer-grant.ts` 头注)。
219
219
  */
220
- export declare function policyAskStandingAnswerFacts(req: StandingAnswerCall, ask: Extract<PermissionResult, {
220
+ export declare function policyAskStandingAnswerFacts(req: StandingAnswerCall & {
221
+ readonly toolCallId: string;
222
+ readonly toolName: string;
223
+ }, ask: Extract<PermissionResult, {
221
224
  action: "ask";
222
225
  }>, deploymentListQuestion: boolean): StandingAnswerFacts;
223
226
  /**
@@ -507,7 +510,8 @@ export interface ToolApprovalFrame {
507
510
  * `approval-content-kind.ts` 的 `readApprovalCard` 闭集窄读(集外 ⇒ 缺席 + 计一次 closed-word-out-of-set)。`question` = 问用户的问题(引擎保留的
508
511
  * 问答工具),不是副作用工具。**本仓不从工具名回推卡**(工具名只作展示):此前按名字铸的 `livePending` 行 / 队列行 `contentKind` 随本键删。
509
512
  * 停驻孪生 = 门的 `gate.approvalCard`(运维队列行顶层同名键,两只店读同一只 `parkedApprovalCard`)。display:本仓不按它裁决。
510
- * 🔴 缺席即缺席(宿主自建的 ask / 老引擎),不编 `generic`。⚠️ `card_json` 卡面不带本键(`ApprovalCardSchema` `.strict()`,与 `mandated` 同)。
513
+ * 🔴 缺席即缺席(宿主自建的 ask / 老引擎),不编 `generic`。7.136.0 起卡面同带(`ApprovalCardSchema.approvalCard`:发帧点把这一格交给铸卡 ⇒
514
+ * `card_json` 与断连重放帧的卡上是同一个词)。
511
515
  */
512
516
  approvalCard?: ToolApprovalCard;
513
517
  /**
@@ -1026,6 +1030,13 @@ export type UnattendedAskOutcome = Extract<AskOutcome, "unavailable"> | Unattend
1026
1030
  /** [ref] 候裁 16:耐久会话授权店(`src/plugins/approval-exemption-store.ts` 的同一只店):审批席读它(引擎的问),活卡上部署名单那一问的
1027
1031
  * 「本会话放行」写它(名单门在出问之前读同一行)。 */
1028
1032
  export type SessionGrantStore = Pick<ApprovalExemptionStore, "has" | "grant">;
1033
+ /** redactDeep + size-bound the UNTRUSTED tool args before they are streamed. Over the cap / unserializable ⇒
1034
+ * undefined (frame rides argsOmitted — see MAX_APPROVAL_ARGS_BYTES). */
1035
+ /**
1036
+ * 给审批人看的一份入参 —— 卡上 `args` 的**同一种读法**({@link boundArgs}:脱敏 + 字节帽;超帽 / 序列化不出 ⇒ `undefined`)。
1037
+ * 读者:卡帧 / 卡面(经 `boundArgs` 本体)与续跑拒体的 `acceptableForm`(core 7.56.0 [ref]:编辑复判只收改写后的那一形,人在决定口看到它、批准它)。
1038
+ */
1039
+ export declare function approverFacingArgs(args: unknown): unknown;
1029
1040
  /**
1030
1041
  * [ref] 车3 刀 3b —— 「流内审批协议到底上不上场」的**单一谓词**(设计稿 §2.3 注入 / §2.4 能力面 /
1031
1042
  * §8.4 park 设施自检,三处同一份判据)。
@@ -1969,16 +1980,21 @@ export declare class ToolApprovalCoordinator {
1969
1980
  status: number;
1970
1981
  body: unknown;
1971
1982
  }>;
1983
+ /** [ref]:这条登记**有没有问账行**(有 ⇒ 属主的唯一来源是行上当下的 owner 列;没有 ⇒ 登记记下的那一位是唯一可读的属主事实)。 */
1984
+ private registrationHasRow;
1972
1985
  /**
1973
- * [ref]:**接管登记**的应答。接管登记是行的投影(没有引擎腿在等它),所以它的属主门读**行当下的** owner —— 接管时记下的那一格可能已被
1974
- * `/v1/adoption` 改写(契约:应答口的授权判据取当下的持久事实,收编之后旧属主手里的卡作废)。行仍 `STREAM_PENDING` ⇒ 与活登记同一条应答路
1975
- * ({@link answerRegistration}:同一把 `decideAsk` CAS);行已有终局(别处答了 / 对账器收了,本副本的轮询还没到)⇒ 按行的真相答(与晚答口同一张表)。
1986
+ * [ref]([ref] 的接管登记一臂并进来):**读行判属主**的应答 —— 接管登记恒走这里;活登记在登记记下的属主不认调用方时走这里(行可能已被收编改给调用方)。
1987
+ * 属主门读**行当下的** owner:登记上记下的那一格是铸卡(或接管)那一刻的进程内快照,`/v1/adoption` 改写行之后它就落后了(契约:应答口的授权判据取
1988
+ * 当下的持久事实,收编之后旧属主手里的卡作废、新属主照常答得了 —— 与耐久决断口同答)。行仍 `STREAM_PENDING` ⇒ {@link answerRegistration}(同一把
1989
+ * `decideAsk` CAS,绑门刚读到的那位属主,[ref];活登记上那条在等的腿照常收到决议);行已有终局(别处答了 / 对账器收了,本副本还没闻讯)⇒ 按行的真相答
1990
+ * (与晚答口同一张表)。读不出行 ⇒ 不知道属主是谁 ⇒ 与未知 id 同形同码(属主门 fail-closed)。
1976
1991
  */
1977
- private respondAdopted;
1992
+ private respondByRow;
1978
1993
  /** 一条已过属主门的登记(活登记或接管登记)的应答 —— 两者同一条路:规则文本前门 → 要人门 → CAS → 兑付。
1979
1994
  * `judgedOwner` = 门判过的那位属主([ref]:决议作用域的属主维,CAS 与确认读都绑它;见 `askRowCarriesOwner`)。 */
1980
1995
  private answerRegistration;
1981
- /** 一次 live 回决**落定之后**的两件兑付(部署名单那一问的豁免、「不再询问」的规则)—— 两件都只在 200 那一支、都读同一只资格。 */
1996
+ /** 一次 live 回决**落定之后**的两件兑付(部署名单那一问的豁免、「不再询问」的规则)—— 两件都只在 200 那一支、都读同一只资格。
1997
+ * `judgedOwner` = 这次决议的门判过的那位属主([ref]:一次决议只读一次属主 —— 决议 CAS、会话放行、规则落店、豁免记账都用这一份,不回头重读登记上的那一格)。 */
1982
1998
  private afterLiveDecision;
1983
1999
  /**
1984
2000
  * **部署名单(`APPROVAL_REQUIRE`)那一问的「本会话放行」只落 server 的会话豁免店**(谁问的,谁的站着的答案算数):名单的问是 server 铸的,
@@ -2026,8 +2042,13 @@ export declare class ToolApprovalCoordinator {
2026
2042
  status: number;
2027
2043
  body: unknown;
2028
2044
  }>;
2029
- /** [ref]:接管登记的按问读口 —— 行可见且仍 `STREAM_PENDING` ⇒ `pending`(列表面同一只行投影);否则按行的态答(与读行半场同一张表)。 */
2030
- private readAdopted;
2045
+ /**
2046
+ * [ref]:有行的登记的按问读口 —— 行可见且仍 `STREAM_PENDING` ⇒ `pending`(列表面同一只行投影);否则按行的态答(与读行半场同一张表)。
2047
+ * 🔴 行**读不出**(店抛 / 超时)⇒ 只有**本协调器自己铸的活登记**回落:登记记下的属主认调用方 ⇒ `pending`,否则与未知 id 同答 —— 与同一刻的应答口同答
2048
+ * (活登记的应答拿登记属主当候选、不多读一次店,店抖动不挡真实回决,D5),也与 7.135.x 的读口同答。**接管登记**([ref],起服从问账接管、没有引擎腿在等)的
2049
+ * 属主跟着行走,登记上那一格不是权威 —— 应答口对它恒读行判、读不出 ⇒ 404,读口同样 404(两口同答;7.135.x 两口都 404)。读得出的「没有这一行」不回落(那是行的真相)。
2050
+ */
2051
+ private readByRow;
2031
2052
  /** {@link readApproval} 的读行半场。 */
2032
2053
  private readAskRowState;
2033
2054
  /**
@@ -2068,8 +2089,10 @@ export declare class ToolApprovalCoordinator {
2068
2089
  /** {@link respondLate} 的读行:按 id 读出行,交 {@link dispatchRowTruth}。 */
2069
2090
  private dispatchLateByRow;
2070
2091
  /**
2071
- * 按 wire 身份(= 行的键)读行。读不出 ⇒ 记账并按「查无」交回:读不出 = **不知道**这只 ask 落在哪一态,而晚答口的三条受理臂(200/200/202)
2072
- * 都在对客户端做承诺 —— 不知道 ⇒ 回那句 404,绝不把未知说成受理(D5 的 fail-open 只覆盖「不挡人的真实回决」那一面,这条腿方向相反)。
2092
+ * 按 wire 身份(= 行的键)读行 —— 三态分开交回({@link AskRowRead}):读到了 / 读得出的「没有这一行」/ 读不出(店抛或超时,记账)。
2093
+ * 「读不出」与「不在」不折成一个值:调用点各自表态 —— 应答口与晚答口按「查无」答(读不出 = **不知道**这只 ask 落在哪一态,而受理臂都在对客户端做承诺,
2094
+ * 不知道 ⇒ 回那句 404,绝不把未知说成受理;D5 的 fail-open 只覆盖「不挡人的真实回决」那一面,这条腿方向相反),按问读口对本协调器自己铸的活登记回落那一份登记
2095
+ * (接管登记不回落,{@link readByRow})。
2073
2096
  */
2074
2097
  private askRowFor;
2075
2098
  /**
@@ -13,7 +13,7 @@ import { recordFailOpen } from "./observability/fail-open.js";
13
13
  import { ownerOfCheckpointScope } from "./security.js";
14
14
  import { deriveAskId, deriveAskScopedBatchId, deriveBatchId, MAX_DECISION_NOTE_CHARS, noteLandedOnRow, noteRecordedReceipt } from "./approval-ask-machine.js";
15
15
  import { currentParkArm, MAX_RULE_OFFERS, buildApprovalCard, buildApprovalCardEnvelope, buildApprovalRequestFrame, buildReplayFrame, buildRevokeFrame, readDenialLimitFallback, readProbeCause, readProbeReason, readReadRootCandidate, readStoredCardEnvelope, readRuleEvidence, readAllowRuleShadowed, readRuleOffersAbsence, readRuleOffersAbsenceSeat, readParkRowTrueSeat, readAskClassPair, readClosedWordSeat, buildApprovalCompleteFrame, readRuleOfferList, } from "./approval-card.js";
16
- import { askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
16
+ import { askOwnerAdmits, askRowCarriesOwner, POLICY_REFUSAL_DECISION, projectAskTerminalClaimTruth } from "./plugins/approval-ask-store-sql.js";
17
17
  import { APPROVAL_ENDING_CAUSES, SETTLE_OUTCOME, causeOfAskRow } from "./approval-deny-reasons.js";
18
18
  import { settleByPolicy } from "./approval-policy-settlement.js";
19
19
  import { governanceAskMarksFor, runWithGovernanceAskScope } from "./governance-ask-marks.js";
@@ -123,8 +123,10 @@ function askStandingAnswerFacts(req, governanceForced, deploymentListAsks) {
123
123
  deploymentListQuestion,
124
124
  };
125
125
  }
126
- const NO_GATE_FACTS = { contentQuestion: false, markedUnresolvable: false, org: undefined, tightened: undefined, mandateMarks: {} };
127
- const DEPLOYMENT_LIST_ASK_CLASSES = new Set(classifyAsk(operatorAsk("APPROVAL_REQUIRE", ""), NO_GATE_FACTS).classes);
126
+ function noGateFacts(call) {
127
+ return { call, contentQuestion: false, markedUnresolvable: false, org: undefined, tightened: undefined, mandateMarks: {} };
128
+ }
129
+ const DEPLOYMENT_LIST_ASK_CLASSES = new Set(classifyAsk(operatorAsk("APPROVAL_REQUIRE", ""), noGateFacts({ toolCallId: "", toolName: "" })).classes);
128
130
  export function carriesDeploymentListQuestion(deploymentListAsks, classes) {
129
131
  return deploymentListAsks && classes !== undefined && classes.some((c) => DEPLOYMENT_LIST_ASK_CLASSES.has(c));
130
132
  }
@@ -134,7 +136,7 @@ export function policyAskStandingAnswerFacts(req, ask, deploymentListQuestion) {
134
136
  requiresRealApproval: ask.requiresRealApproval === true,
135
137
  mandated: ask.mandated === true,
136
138
  grantBinding: callGrantBindingOf(req),
137
- classes: [...classifyAsk(ask, NO_GATE_FACTS).classes],
139
+ classes: [...classifyAsk(ask, noGateFacts({ toolCallId: req.toolCallId, toolName: req.toolName })).classes],
138
140
  deploymentListQuestion,
139
141
  };
140
142
  }
@@ -195,8 +197,11 @@ function mandatedFromSeat(seat) {
195
197
  return false;
196
198
  }
197
199
  }
200
+ function rowOrUnknown(read) {
201
+ return read.kind === "row" ? read.row : null;
202
+ }
198
203
  function askRowVisibleTo(row, principal) {
199
- return row !== null && (row.owner === null || row.owner === principal);
204
+ return row !== null && askOwnerAdmits(row.owner, principal);
200
205
  }
201
206
  function waitingLegsReached(entry, othersReached) {
202
207
  return (entry.adopted === true ? 0 : 1) + othersReached;
@@ -206,7 +211,7 @@ function withConsumerDisclosure(result, waitingLegs) {
206
211
  }
207
212
  function livePendingRowOf(e) {
208
213
  const listFrame = e.adopted === true ? e.cardFrame : (e.cardFrame ?? e.frame);
209
- const approvalCard = e.adopted === true ? e.cardFrame.approvalCard : e.frame.approvalCard;
214
+ const approvalCard = e.adopted === true ? e.cardFrame.card.approvalCard : e.frame.approvalCard;
210
215
  return {
211
216
  approvalId: e.approvalId,
212
217
  toolName: e.toolName,
@@ -332,6 +337,9 @@ function unattendedRefusalReason(site) {
332
337
  function isChildAsk(req) {
333
338
  return req.fromSubagent === true;
334
339
  }
340
+ export function approverFacingArgs(args) {
341
+ return boundArgs(args).args;
342
+ }
335
343
  function boundArgs(args) {
336
344
  const redacted = redactDeep(args);
337
345
  let hasBidi = false;
@@ -2049,17 +2057,21 @@ export class ToolApprovalCoordinator {
2049
2057
  }
2050
2058
  const entry = this.liveEntryFor(id);
2051
2059
  if (entry?.adopted === true)
2052
- return this.respondAdopted(entry, id, principal, parsed, httpReq);
2053
- if (!entry || (entry.owner !== null && entry.owner !== principal)) {
2054
- return this.respondLate(id, principal, parsed, httpReq);
2055
- }
2056
- return this.answerRegistration(entry, entry.owner, id, principal, parsed, httpReq);
2060
+ return this.respondByRow(entry, id, principal, parsed, httpReq);
2061
+ if (entry !== undefined && askOwnerAdmits(entry.owner, principal))
2062
+ return this.answerRegistration(entry, entry.owner, id, principal, parsed, httpReq);
2063
+ if (entry !== undefined && this.registrationHasRow(entry))
2064
+ return this.respondByRow(entry, id, principal, parsed, httpReq);
2065
+ return this.respondLate(id, principal, parsed, httpReq);
2066
+ }
2067
+ registrationHasRow(entry) {
2068
+ return this.askStore !== undefined && entry.askId !== undefined;
2057
2069
  }
2058
- async respondAdopted(entry, id, principal, parsed, httpReq) {
2070
+ async respondByRow(entry, id, principal, parsed, httpReq) {
2059
2071
  const store = this.askStore;
2060
2072
  if (!store)
2061
2073
  return this.notPending();
2062
- const row = await this.askRowFor(store, id, "getAsk(respond-adopted)");
2074
+ const row = rowOrUnknown(await this.askRowFor(store, id, "getAsk(respond-by-row)"));
2063
2075
  if (!askRowVisibleTo(row, principal))
2064
2076
  return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
2065
2077
  if (row.state !== "STREAM_PENDING")
@@ -2067,7 +2079,7 @@ export class ToolApprovalCoordinator {
2067
2079
  return this.answerRegistration(entry, row.owner, id, principal, parsed, httpReq);
2068
2080
  }
2069
2081
  answerRegistration(entry, judgedOwner, id, principal, parsed, httpReq) {
2070
- const preRule = this.precheckEditedRuleBeforeDecision(entry, parsed);
2082
+ const preRule = this.precheckEditedRuleBeforeDecision(entry, judgedOwner, parsed);
2071
2083
  if (preRule !== undefined)
2072
2084
  return preRule;
2073
2085
  if (parsed.value !== "deny" && policyCannotAnswer(heldAskOf(entry.requiresRealApproval === true), parsed.decidedBy)) {
@@ -2076,17 +2088,17 @@ export class ToolApprovalCoordinator {
2076
2088
  const ruleEligibility = { eligible: true };
2077
2089
  const store = this.askStore;
2078
2090
  if (store && entry.askId !== undefined && entry.batchId !== undefined) {
2079
- return this.respondWithCas(store, entry.askId, entry.batchId, judgedOwner, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, parsed, principal, ruleEligibility));
2091
+ return this.respondWithCas(store, entry.askId, entry.batchId, judgedOwner, entry, parsed, ruleEligibility).then((cas) => cas.lost ? this.dispatchRowTruth(cas.row, id, parsed, httpReq, principal) : this.afterLiveDecision(cas.result, entry, judgedOwner, parsed, principal, ruleEligibility));
2080
2092
  }
2081
- return this.afterLiveDecision(this.finishRespond(entry, parsed), entry, parsed, principal, ruleEligibility);
2093
+ return this.afterLiveDecision(this.finishRespond(entry, judgedOwner, parsed), entry, judgedOwner, parsed, principal, ruleEligibility);
2082
2094
  }
2083
- afterLiveDecision(decided, entry, parsed, principal, ruleEligibility) {
2084
- const settled = this.recordDeploymentListAnswer(decided, entry, parsed, principal, ruleEligibility);
2095
+ afterLiveDecision(decided, entry, judgedOwner, parsed, principal, ruleEligibility) {
2096
+ const settled = this.recordDeploymentListAnswer(decided, entry, judgedOwner, parsed, principal, ruleEligibility);
2085
2097
  if (parsed.persistRule === undefined)
2086
2098
  return settled;
2087
- return this.persistRuleAfterDecision(settled, entry, parsed.persistRule, parsed.updatedInput !== undefined, ruleEligibility);
2099
+ return this.persistRuleAfterDecision(settled, entry, judgedOwner, parsed.persistRule, parsed.updatedInput !== undefined, ruleEligibility);
2088
2100
  }
2089
- recordDeploymentListAnswer(decided, entry, parsed, principal, eligibility) {
2101
+ recordDeploymentListAnswer(decided, entry, judgedOwner, parsed, principal, eligibility) {
2090
2102
  const store = this.sessionGrants;
2091
2103
  const sessionId = entry.sessionId;
2092
2104
  if (parsed.value !== "allow_session" || !sessionId || store === undefined)
@@ -2101,9 +2113,9 @@ export class ToolApprovalCoordinator {
2101
2113
  return { ...result, body: { ...result.body, rememberApplied: false } };
2102
2114
  let rememberApplied = false;
2103
2115
  try {
2104
- await this.withStoreDeadline(store.grant(sessionId, entry.toolName, principal ?? entry.owner), "sessionGrants.grant(deployment-list)", DURABLE_CALL_TIMEOUT_MS);
2116
+ await this.withStoreDeadline(store.grant(sessionId, entry.toolName, principal ?? judgedOwner), "sessionGrants.grant(deployment-list)", DURABLE_CALL_TIMEOUT_MS);
2105
2117
  rememberApplied = true;
2106
- defaultLogger.info("approval_exemption_granted", { sessionId, toolName: entry.toolName, grantedBy: principal ?? entry.owner });
2118
+ defaultLogger.info("approval_exemption_granted", { sessionId, toolName: entry.toolName, grantedBy: principal ?? judgedOwner });
2107
2119
  }
2108
2120
  catch (err) {
2109
2121
  defaultLogger.warn("approval_exemption_grant_failed", { sessionId, toolName: entry.toolName, error: String(err).slice(0, 200) });
@@ -2111,7 +2123,7 @@ export class ToolApprovalCoordinator {
2111
2123
  return { ...result, body: { ...result.body, rememberApplied } };
2112
2124
  })();
2113
2125
  }
2114
- precheckEditedRuleBeforeDecision(entry, parsed) {
2126
+ precheckEditedRuleBeforeDecision(entry, judgedOwner, parsed) {
2115
2127
  const persistRule = parsed.persistRule;
2116
2128
  if (persistRule === undefined || persistRule.kind !== "text" || !persistRule.edited)
2117
2129
  return undefined;
@@ -2120,7 +2132,7 @@ export class ToolApprovalCoordinator {
2120
2132
  if (entry.governanceForced === true)
2121
2133
  return undefined;
2122
2134
  const command = entry.ruleLane?.command;
2123
- if (this.ruleConsent === undefined || command === undefined || entry.owner === null)
2135
+ if (this.ruleConsent === undefined || command === undefined || judgedOwner === null)
2124
2136
  return undefined;
2125
2137
  const verdict = precheckCardRuleText(persistRule.rule, command);
2126
2138
  if (verdict === undefined || verdict.ok)
@@ -2155,9 +2167,9 @@ export class ToolApprovalCoordinator {
2155
2167
  }
2156
2168
  readApproval(id, principal) {
2157
2169
  const entry = this.liveEntryFor(id);
2158
- if (entry?.adopted === true)
2159
- return this.readAdopted(entry, id, principal);
2160
- if (entry !== undefined && (entry.owner === null || entry.owner === principal)) {
2170
+ if (entry !== undefined && this.registrationHasRow(entry))
2171
+ return this.readByRow(entry, id, principal);
2172
+ if (entry !== undefined && askOwnerAdmits(entry.owner, principal)) {
2161
2173
  const body = { state: "pending", ...livePendingRowOf(entry) };
2162
2174
  return { status: 200, body };
2163
2175
  }
@@ -2166,11 +2178,18 @@ export class ToolApprovalCoordinator {
2166
2178
  return this.notPending();
2167
2179
  return this.readAskRowState(store, id, principal);
2168
2180
  }
2169
- async readAdopted(entry, id, principal) {
2181
+ async readByRow(entry, id, principal) {
2170
2182
  const store = this.askStore;
2171
2183
  if (!store)
2172
2184
  return this.notPending();
2173
- const row = await this.askRowFor(store, id, "getAsk(read-adopted)");
2185
+ const read = await this.askRowFor(store, id, "getAsk(read-by-row)");
2186
+ if (read.kind === "unreadable") {
2187
+ if (entry.adopted === true || !askOwnerAdmits(entry.owner, principal))
2188
+ return this.notPending(NOT_PENDING_UNKNOWN_CAUSE);
2189
+ const body = { state: "pending", ...livePendingRowOf(entry) };
2190
+ return { status: 200, body };
2191
+ }
2192
+ const row = rowOrUnknown(read);
2174
2193
  if (askRowVisibleTo(row, principal) && row.state === "STREAM_PENDING") {
2175
2194
  const body = { state: "pending", ...livePendingRowOf(entry) };
2176
2195
  return { status: 200, body };
@@ -2178,7 +2197,7 @@ export class ToolApprovalCoordinator {
2178
2197
  return this.readStateOfRow(row, principal);
2179
2198
  }
2180
2199
  async readAskRowState(store, id, principal) {
2181
- return this.readStateOfRow(await this.askRowFor(store, id, "getAsk(read)"), principal);
2200
+ return this.readStateOfRow(rowOrUnknown(await this.askRowFor(store, id, "getAsk(read)")), principal);
2182
2201
  }
2183
2202
  async readParkedGate(row) {
2184
2203
  const gate = this.parkedGate;
@@ -2310,15 +2329,16 @@ export class ToolApprovalCoordinator {
2310
2329
  return undefined;
2311
2330
  }
2312
2331
  async dispatchLateByRow(store, id, parsed, httpReq, principal) {
2313
- return this.dispatchRowTruth(await this.askRowFor(store, id, "getAsk(respond-late)"), id, parsed, httpReq, principal);
2332
+ return this.dispatchRowTruth(rowOrUnknown(await this.askRowFor(store, id, "getAsk(respond-late)")), id, parsed, httpReq, principal);
2314
2333
  }
2315
2334
  async askRowFor(store, id, label) {
2316
2335
  try {
2317
- return await this.withStoreDeadline(store.getAsk(id), label, DURABLE_CONVERGE_READ_TIMEOUT_MS);
2336
+ const row = await this.withStoreDeadline(store.getAsk(id), label, DURABLE_CONVERGE_READ_TIMEOUT_MS);
2337
+ return row === null ? { kind: "absent" } : { kind: "row", row };
2318
2338
  }
2319
2339
  catch (err) {
2320
2340
  this.noteStoreError(err, label);
2321
- return null;
2341
+ return { kind: "unreadable" };
2322
2342
  }
2323
2343
  }
2324
2344
  async dispatchRowTruth(row, id, parsed, httpReq, principal) {
@@ -2580,13 +2600,13 @@ export class ToolApprovalCoordinator {
2580
2600
  },
2581
2601
  };
2582
2602
  }
2583
- async persistRuleAfterDecision(settled, entry, persistRule, inputWasEdited, ruleEligibility) {
2603
+ async persistRuleAfterDecision(settled, entry, judgedOwner, persistRule, inputWasEdited, ruleEligibility) {
2584
2604
  const result = await settled;
2585
2605
  if (result.status !== 200)
2586
2606
  return result;
2587
2607
  const lane = this.ruleConsent;
2588
2608
  const material = entry.ruleLane;
2589
- const owner = entry.owner;
2609
+ const owner = judgedOwner;
2590
2610
  const withFlag = (rulePersisted, ruleRefusal, echo) => ({
2591
2611
  status: result.status,
2592
2612
  body: { ...result.body, rulePersisted, ...(ruleRefusal !== undefined ? { ruleRefusal } : {}), ...(echo ?? {}) },
@@ -2708,11 +2728,11 @@ export class ToolApprovalCoordinator {
2708
2728
  if (!converged) {
2709
2729
  return { lost: false, result: this.notPending() };
2710
2730
  }
2711
- return { lost: false, result: withConsumerDisclosure(this.finishRespond(entry, parsed, { updatedInputDelivered: false, noteRecorded: noteLanded }), waitingLegsReached(entry, othersReached)) };
2731
+ return { lost: false, result: withConsumerDisclosure(this.finishRespond(entry, owner, parsed, { updatedInputDelivered: false, noteRecorded: noteLanded }), waitingLegsReached(entry, othersReached)) };
2712
2732
  }
2713
2733
  const payloadIsMine = ambiguousConfirmedRow === undefined ||
2714
2734
  approvalPayloadFingerprint({ updatedInput: ambiguousConfirmedRow.updatedInput }) === approvalPayloadFingerprint({ updatedInput: parsed.updatedInput });
2715
- const result = this.finishRespond(entry, parsed, {
2735
+ const result = this.finishRespond(entry, owner, parsed, {
2716
2736
  noteRecorded: noteLanded,
2717
2737
  ...(winnerRow !== undefined ? { settleOutcome: outcomeOfDecidedRow(winnerRow), settleOutcomeIsThisRequest: ambiguousConfirmedRow === undefined } : {}),
2718
2738
  ...(entry.adopted === true ? { updatedInputDelivered: false } : ambiguousConfirmedRow !== undefined ? { updatedInputDelivered: payloadIsMine } : {}),
@@ -2720,7 +2740,7 @@ export class ToolApprovalCoordinator {
2720
2740
  const othersReached = winnerRow !== undefined ? this.notifyExternalDecision(askId, outcomeOfDecidedRow(winnerRow)).settled : 0;
2721
2741
  return { lost: false, result: withConsumerDisclosure(result, waitingLegsReached(entry, othersReached)) };
2722
2742
  }
2723
- finishRespond(entry, parsed, opts) {
2743
+ finishRespond(entry, judgedOwner, parsed, opts) {
2724
2744
  let rememberApplied;
2725
2745
  const home = standingAnswerHome(pendingEntryStandingAnswerFacts(entry));
2726
2746
  let grantable;
@@ -2745,7 +2765,7 @@ export class ToolApprovalCoordinator {
2745
2765
  if (oldest !== undefined)
2746
2766
  this.allowAllSessions.delete(oldest);
2747
2767
  }
2748
- this.allowAllSessions.add(sessionAllowKey(entry.owner, entry.sessionId, sessionAllowCategory(entry.toolName), entry.grantBinding));
2768
+ this.allowAllSessions.add(sessionAllowKey(judgedOwner, entry.sessionId, sessionAllowCategory(entry.toolName), entry.grantBinding));
2749
2769
  }
2750
2770
  const allowed = parsed.value !== "deny";
2751
2771
  const settleArgs = opts?.settleOutcome !== undefined ? settleArgsOfDecided(opts.settleOutcome) : { allowed, updatedInput: parsed.updatedInput, settledBy: liveSettledBy(parsed.decidedBy) };
@@ -22,6 +22,11 @@
22
22
  * 7.53.x 及以前,`MyShell` 的 `egress: true` / `irreversibility: "always"` 会让引擎 `Bash` 的调用多问一次(收紧),它的恒可逆探针会让引擎 `Bash` 的
23
23
  * `touch` 不问就跑(放宽);7.54.0 起两者都不再作用于引擎 shell。要收紧引擎 shell:给**正名**叫 `Bash` 的工具声明标记(同名标记仍作用),或请求
24
24
  * `TaskSpec.shellGate: "always"`(本仓的入口 `MANUAL_MODE_SHELL_GATE` / 请求 `shellGate`)。
25
+ * ⚠️ **反方向(core 7.56.0 [ref])**:一次调用的安全轴只按它答得上的名字读,别名不带副本;两个名字的层级**平局时归 wire 名**(真正跑的那只工具)。
26
+ * 于是 `MyShell{irreversibility:"maybe", aliases:["Bash"]}` 在引擎 shell 被选择器卸下的腿上按 `Bash` 被调时,判它的是 **`MyShell` 自己的探针**
27
+ * (7.55.x 及以前是引擎 shell 席的形状探针:`ls` 不问就跑、`MyShell` 的探针从未被问)。⇒ 嵌入方给这类工具**照实声明**判它自己命令的探针,
28
+ * 或不声明层级、或 `irreversibility: "always"`;不声明层级时引擎 shell 席的层级仍够得着它(引擎侧候设计车,问的模式下按 shell 探针问,
29
+ * `bypassPermissions` 下照放)。本仓自身不声明带别名的工具,零码;这一形只有经 `resolveSpec` 席挂别名工具的嵌入方走得到。
25
30
  *
26
31
  * 返回**命中的那个名字**(调用答得上的名字里第一个被规则够到的,拼写在先)—— 规则归因(`matchedAskRule`)写运维名单里的那个名,
27
32
  * 不写一个名单里查不到的 wire 名;够不到 ⇒ `undefined`。判定式(精确集 / covering 规则)由调用方给,本函数只管「读哪些名字」。
@@ -45,7 +45,7 @@ type RosterProjected = "name" | "agentId" | "sessionId" | "toolUseId" | "owner"
45
45
  type _GuardRoster = AssertAllKeysHandled<Exclude<keyof RosterEntry, RosterProjected>>;
46
46
  type _GuardRosterReverse = AssertAllKeysHandled<Exclude<RosterProjected, keyof RosterEntry>>;
47
47
  type AskProjected = "toolName" | "toolCallId" | "args" | "message" | "sourceTaskId" | "fromSubagent" | "sourceAgentName" | "delegation" | "ruleOffers" | "ruleOffersAbsence" | "allowRuleShadowed" | "probeCause" | "probeReason" | "ruleEvidence" | "requiresRealApproval" | "denialLimitFallback" | "origin" | "readRootCandidate" | "mandated" | "mandate" | "askClass" | "classes" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling" | "approvalCard" | "boundGrantAbsence";
48
- type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy";
48
+ type AskExcluded = "preview" | "principal" | "riskAxes" | "boundInputHash" | "isDelegatedChild" | "hasBidiControls" | "previewWithheld" | "execCwd" | "authoredBy" | "requestedBy" | "editRewritten";
49
49
  type _GuardAsk = AssertAllKeysHandled<Exclude<keyof AskRequest, AskProjected | AskExcluded>>;
50
50
  type _GuardAskReverse = AssertAllKeysHandled<Exclude<AskProjected | AskExcluded, keyof AskRequest>>;
51
51
  type AskFrameServerMinted = "type" | "approvalId" | "argsOmitted" | "outcome" | "governanceForced" | "expiresAtMs" | "expiresInMs" | "serverNowMs" | "parked" | "cause" | "inputHasBidi" | "rememberRefused";
@@ -218,17 +218,17 @@ type _GuardInboxSummaryReverse = AssertAllKeysHandled<Exclude<SummaryProjected |
218
218
  type ParkArmKeys = keyof Extract<PendingAction, {
219
219
  kind: "tool_approval";
220
220
  }>;
221
- type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts;
222
- type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "boundGrantDigest" | "boundGrants" | "classifierNoRuling";
221
+ type ParkArmQueueProjected = "toolName" | "toolCallId" | "boundInputHash" | "ruleOffers" | "hasBidiControls" | keyof import("../approval-card.js").ParkRowFacts | keyof import("../approval-card.js").SkillCardFacts;
222
+ type ParkArmQueueExcluded = "kind" | "args" | "batchToolCallIds" | "completedCallIds" | "capabilityId" | "contractId" | "shapeDigest" | "implementationRevision" | "family" | "pathTarget" | "hostTarget" | "targets" | "names" | "preview" | "previewWithheld" | "execCwd" | "denialLimitFallback" | "authoredBy" | "engineMounted";
223
223
  type _GuardParkArmQueue = AssertAllKeysHandled<Exclude<ParkArmKeys, ParkArmQueueProjected | ParkArmQueueExcluded>>;
224
224
  type _GuardParkArmQueueReverse = AssertAllKeysHandled<Exclude<ParkArmQueueProjected | ParkArmQueueExcluded, ParkArmKeys>>;
225
225
  type _NoDoubleBookParkArmQueue = AssertAllKeysHandled<Extract<ParkArmQueueProjected, ParkArmQueueExcluded>>;
226
- type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptProfile" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
226
+ type TaskSpecWired = "objective" | "principal" | "images" | "sessionId" | "requireExistingSession" | "oneShot" | "clientContext" | "resumeAt" | "resumeAtMode" | "model" | "compactionModel" | "thinking" | "systemPrompt" | "appendSystemPrompt" | "promptRole" | "promptBinding" | "memory" | "suggestNextPrompts" | "restoreFiles" | "acceptPartialRestore" | "rewindFilesTo" | "tools" | "excludeTools" | "deferTools" | "toolMaterializeStrategy" | "promptLean" | "toolPolicy" | "onAsk" | "onQuestion" | "mods" | "durableApproval" | "resourceSuspend" | "resilience" | "finalVerification" | "checkpointStore" | "handsReadOnly" | "memoryPersistenceCapable" | "additionalDirectories" | "additionalReadDirectories" | "enablePlanMode" | "interactiveTools" | "enableFork" | "shellGate" | "approvalReach" | "writeFace" | "mcp" | "a2a" | "skills" | "backgroundScope" | "envFacts" | "limits" | "configOverrides" | "forwardSubagentEvents" | "retainSubagentSessions" | "retainBackgroundProcesses" | "outputSchema" | "outputRetries" | "compaction" | "attachments" | "selfOrchestration" | "getApiKeyAndHeaders" | "interactionPosture" | "agents" | "permissionMode" | "taskId" | "signal" | "preemptSignal" | "maxSuspends" | "skillListingBudgetFraction" | "skillListingMaxDescChars" | "excludeAllTools" | "fileHistory" | "userInvokedSkills" | "outputStyle" | "projectMemory" | "allowedTools" | "allowTools" | "userAttachments" | "readDenyPatterns" | "writeProtectedAdditions" | "complianceAdditionalDenies";
227
227
  /** 导出:请求体键闭集门(`request-key-closure.ts`)据它锁「本仓记为未接线的引擎座,提交口不许受理」—— 两处分类只能同向。 */
228
228
  export type TaskSpecUnwired = "actor" | "roles" | "lspManager" | "tracer" | "readFace" | "interactiveQuestionFallback" | "alwaysLoadTools" | "restoreGatedTools" | "deferSelfResolve" | "basePolicyForResumeEdit" | "lspDiagnostics" | "streamingToolExecution" | "toolResultThresholdChars" | "peerPresence" | "modelRole" | "enableBlockedReport" | "promptForm" | "advisorModel";
229
229
  type _GuardTaskSpec = AssertAllKeysHandled<Exclude<keyof TaskSpec, TaskSpecWired | TaskSpecUnwired>>;
230
230
  type _GuardTaskSpecReverse = AssertAllKeysHandled<Exclude<TaskSpecWired | TaskSpecUnwired, keyof TaskSpec>>;
231
- type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction";
231
+ type TaskResultForwarded = "taskId" | "runId" | "sessionId" | "terminal" | "model" | "effectiveReasoning" | "result" | "salvagedOutput" | "remoteEnvFailures" | "apiFailure" | "retryAfterMs" | "degraded" | "structuredOutput" | "rewindNotes" | "haltedOnUserRejection" | "haltedByUser" | "strandedHumanAnswers" | "pendingApproval" | "approvalWaitedMs" | "effectiveReadFace" | "effectiveReadDenyPatterns" | "effectiveWriteFace" | "effectiveMemoryScopes" | "stats" | "editedFiles" | "responseModel" | "compaction" | "resultEntryIds";
232
232
  type TaskResultStripped = never;
233
233
  type _GuardTaskResult = AssertAllKeysHandled<Exclude<keyof TaskResult, TaskResultForwarded | TaskResultStripped>>;
234
234
  type _GuardTaskResultReverse = AssertAllKeysHandled<Exclude<TaskResultForwarded | TaskResultStripped, keyof TaskResult>>;
@@ -16,7 +16,7 @@
16
16
  * 同文件 G1 e2e 的全码扇出夹具、以及契约文档附录 D.3 那张表(含**小节标题里的码数** —— 那道门本批
17
17
  * 刚立,立完就在下一次加码时自己咬住了)。
18
18
  */
19
- export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached"];
19
+ export declare const ENGINE_NOTICE_WIRE_CODES: readonly ["memory.session_polluted", "memory.harvest_quarantined", "memory.delegation_static_mark_waived", "memory.hold_opened", "memory.hold_released", "memory.hold_disposed", "task.turn_interrupted", "steering.parked_input_blocked", "task.user_steer_undrained", "task.user_followup_undrained", "memory.capture_opted_out", "memory.capture_optout_unpersisted", "task.halt_unconsumed", "task.late_approval", "config.durable_gate_unavailable", "peer.inbound_disposition", "peer.held_settled", "peer.idle_subscription", "classifier.denial_limit", "mcp.injection_dropped", "delegation.ask_unresolvable", "task.interrupt_unconsumed", "approval.read_root_granted", "approval.read_root_grant_rejected", "instructions.source_changed", "session.records_skipped", "server.model_unreachable", "permission.entry_mode_clamped", "classifier.unavailable", "config.permission_mode_unavailable", "permission.ask_released_by_mode", "permission.read_deny_unapplied", "permission.rule_store_unavailable", "permission.rule_row_dropped", "permission.allowed_tool_not_granted", "task.tool_turn_incomplete", "route.finish_reason_unknown", "route.stream_end_ignored", "route.credential_origin_mismatch", "mods.registration_refused", "config.session_rules_earlier_grammar", "advisor.not_attached", "inherit_env.names_withheld", "model.capability_downgraded"];
20
20
  export type EngineNoticeWireCode = (typeof ENGINE_NOTICE_WIRE_CODES)[number];
21
21
  /** 白名单谓词(单点):路由与门都读这一个,不许第二处手抄码串。 */
22
22
  export declare function isEngineNoticeWireCode(code: string): code is EngineNoticeWireCode;
@@ -44,6 +44,8 @@ export const ENGINE_NOTICE_WIRE_CODES = [
44
44
  "mods.registration_refused",
45
45
  "config.session_rules_earlier_grammar",
46
46
  "advisor.not_attached",
47
+ "inherit_env.names_withheld",
48
+ "model.capability_downgraded",
47
49
  ];
48
50
  const WIRE_CODES = new Set(ENGINE_NOTICE_WIRE_CODES);
49
51
  export function isEngineNoticeWireCode(code) {
@@ -3,7 +3,7 @@ import { CALLER_TEXT_CUT_MARK } from "../caller-text-echo.js";
3
3
  import { errorKindOf } from "../observability/err-text.js";
4
4
  import { recordFailOpen } from "../observability/fail-open.js";
5
5
  import { OVERSIZED_REDACTION_PLACEHOLDER } from "../observability/run-terminal.js";
6
- import { proposeRedactionSpans, REDACTION_TOKEN_RE_SRC } from "./redact.js";
6
+ import { proposeRedactionSpans, readingHeadEnd, REDACTION_TOKEN_RE_SRC, WHOLE_EXTENT } from "./redact.js";
7
7
  const EXIT_SEATS = {
8
8
  "trace-frame-text": { scope: "free-text" },
9
9
  "trace-frame-line": { scope: "free-text", maxChars: 300 },
@@ -38,8 +38,7 @@ function mergeSpans(spans) {
38
38
  return out;
39
39
  }
40
40
  const TOKEN_AT = new RegExp(REDACTION_TOKEN_RE_SRC, "y");
41
- function cutPlain(gap, room) {
42
- let cut = room;
41
+ function safeCutPoint(gap, cut) {
43
42
  const hi = gap.charCodeAt(cut - 1);
44
43
  if (cut > 0 && hi >= 0xd800 && hi <= 0xdbff && (gap.charCodeAt(cut) & 0xfc00) === 0xdc00)
45
44
  cut -= 1;
@@ -50,16 +49,19 @@ function cutPlain(gap, room) {
50
49
  if (m !== null && open + m[0].length > cut)
51
50
  cut = open;
52
51
  }
53
- return gap.slice(0, cut);
52
+ return cut;
54
53
  }
55
- function renderOnce(text, groups) {
54
+ const cutPlain = (gap, room) => gap.slice(0, safeCutPoint(gap, room));
55
+ function renderOnce(text, groups, until = Number.POSITIVE_INFINITY) {
56
56
  const parts = [];
57
57
  let at = 0;
58
58
  for (const g of groups) {
59
+ if (g.start >= until)
60
+ break;
59
61
  parts.push(text.slice(at, g.start), g.repl);
60
62
  at = g.end;
61
63
  }
62
- parts.push(text.slice(at));
64
+ parts.push(text.slice(at, until));
63
65
  return parts.join("");
64
66
  }
65
67
  function emitAs(form, text) {
@@ -79,12 +81,18 @@ function emitAs(form, text) {
79
81
  }
80
82
  }
81
83
  const layoutOf = (row) => (row.emit === undefined ? "multi-line" : "single-line");
82
- function boundRow(out, row) {
83
- if (row.maxChars === undefined || out.length <= row.maxChars)
84
+ const SCAN_WINDOW_FLOOR = 4096;
85
+ const SCAN_WINDOW_PER_BOUND = 8;
86
+ const scanWindowOf = (maxChars) => Math.max(SCAN_WINDOW_FLOOR, maxChars * SCAN_WINDOW_PER_BOUND);
87
+ function boundRow(out, row, cutUpstream) {
88
+ if (row.maxChars === undefined)
84
89
  return out;
85
90
  if (row.emit === undefined)
86
- return cutPlain(out, row.maxChars);
87
- return cutPlain(out, row.maxChars - CALLER_TEXT_CUT_MARK.length) + CALLER_TEXT_CUT_MARK;
91
+ return out.length <= row.maxChars ? out : cutPlain(out, row.maxChars);
92
+ if (out.length <= row.maxChars && !cutUpstream)
93
+ return out;
94
+ const room = row.maxChars - CALLER_TEXT_CUT_MARK.length;
95
+ return (out.length <= room ? out : cutPlain(out, room)) + CALLER_TEXT_CUT_MARK;
88
96
  }
89
97
  export function seatText(seat, text) {
90
98
  const row = SEAT_ROWS.get(seat);
@@ -92,11 +100,27 @@ export function seatText(seat, text) {
92
100
  throw new Error(`exit seat: ${JSON.stringify(seat)} is not a row of the seat table`);
93
101
  let out;
94
102
  try {
95
- if (row.emit !== undefined && emitAs(row.emit, text) === "")
103
+ const layout = layoutOf(row);
104
+ const scanWindow = row.maxChars === undefined ? undefined : scanWindowOf(row.maxChars);
105
+ let windowEnd;
106
+ let regionEnd;
107
+ if (scanWindow !== undefined && text.length > scanWindow) {
108
+ const half = scanWindow >>> 1;
109
+ const region = safeCutPoint(text, readingHeadEnd(text, layout, half));
110
+ const end = safeCutPoint(text, readingHeadEnd(text, layout, scanWindow - half, region));
111
+ if (end < text.length) {
112
+ windowEnd = end;
113
+ regionEnd = region;
114
+ }
115
+ }
116
+ const head = windowEnd === undefined ? text : text.slice(0, windowEnd);
117
+ if (row.emit !== undefined && emitAs(row.emit, head) === "")
96
118
  out = "";
97
119
  else {
98
- const rendered = renderOnce(text, mergeSpans(proposeRedactionSpans(text, row.scope, layoutOf(row))));
99
- out = boundRow(row.emit === undefined ? rendered : emitAs(row.emit, rendered), row);
120
+ const emitUntil = regionEnd;
121
+ const extent = windowEnd === undefined || regionEnd === undefined ? WHOLE_EXTENT : { kind: "head", emitEnd: regionEnd };
122
+ const rendered = renderOnce(head, mergeSpans(proposeRedactionSpans(head, row.scope, layout, extent)), emitUntil);
123
+ out = boundRow(row.emit === undefined ? rendered : emitAs(row.emit, rendered), row, windowEnd !== undefined);
100
124
  }
101
125
  }
102
126
  catch (err) {
@@ -1,8 +1,7 @@
1
1
  import { type TerminalCause } from "@sema-agent/core";
2
- import { brainStatusEventData } from "./project.js";
2
+ import { brainStatusEventData, type LegWiringSections } from "./project.js";
3
3
  import { NotifiedKeys } from "../orchestration/workflow-completion-inbox.js";
4
4
  import { type LedgerEventType, type ParkLedgerEventType } from "./ledger-events.js";
5
- import type { InstructionsSegment } from "../instruction-selection.js";
6
5
  /**
7
6
  * LedgerSink — the SINGLE "stream event → durable runs-ledger" projection, shared by the background leg
8
7
  * (runs.ts `runInBackground`) and the sync `/v1/tasks/stream` detach lane (server.ts, `x-detach-on-disconnect`).
@@ -152,8 +151,8 @@ export declare function createLedgerSink(opts: {
152
151
  * 各传自己看得见的那个词(位①=流事件 `ev.type`,位②=账本行 `type`);拿不到类型的打点方
153
152
  * (core 的 onActivity 第五席、resume 腿手动打点)省参,`kind` 诚实缺席(见 turn-activity.ts)。 */
154
153
  onActivity?: (kind?: string, statusData?: Record<string, unknown>) => void;
155
- /** [ref]:这条腿的 `wiring_manifest.instructions` 段(腿的 `InstructionSelectionLeg.segment`)。**必填**:账本行与 live 帧是
156
- * 同一条腿的两个载体,段必须来自同一只腿;在投帧那一刻读(core 推帧之前已 await 过 loader)。返回 `undefined` ⇒ 段缺席。 */
157
- instructionsSegment: () => InstructionsSegment | undefined;
154
+ /** 这条腿的 `wiring_manifest` **本仓自铸段**(`LegWiringSections`:[ref] `instructions` 读腿的 `InstructionSelectionLeg.segment`、run 级 `skills` 读 spec 字段
155
+ * `runSkillsOf`)。**必填**:账本行与 live 帧是同一条腿的两个载体,段必须来自同一只腿;在投帧那一刻读(core 推帧之前已 await 过 loader)。 */
156
+ legSections: () => LegWiringSections;
158
157
  }): LedgerSink;
159
158
  //# sourceMappingURL=ledger-sink.d.ts.map
@@ -1,7 +1,7 @@
1
1
  import {} from "@sema-agent/core";
2
2
  import { outwardPlane } from "../terminal.js";
3
3
  import { recordFailOpen } from "../observability/fail-open.js";
4
- import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData } from "./project.js";
4
+ import { modelTextEventData, toolStartEventData, toolEndEventData, taskProgressEventData, taskStartedEventData, taskNotificationEventData, compactedEventData, diagnosticsEventData, brainStatusEventData, steeringInjectedEventData, compactionOutcomeEventData, compactionStartedEventData, workspaceChangedEventData, wiringManifestEventData, toolRosterDeltaEventData, toolDisclosureEventData, humanInputEventData, turnEndEventData, contextUsageEventData, parkEventData } from "./project.js";
5
5
  import { NotifiedKeys, taskNotificationStreamKeyOf } from "../orchestration/workflow-completion-inbox.js";
6
6
  import { isParkLedgerEventType } from "./ledger-events.js";
7
7
  import { isModelSegmentBoundary, reasoningDeltaBytes, reasoningSegmentEventId } from "./model-segment.js";
@@ -115,7 +115,7 @@ export function createLedgerSink(opts) {
115
115
  await append("workspace_changed", workspaceChangedEventData(ev));
116
116
  break;
117
117
  case "wiring_manifest":
118
- await append("wiring_manifest", wiringManifestEventData(ev, opts.instructionsSegment()));
118
+ await append("wiring_manifest", wiringManifestEventData(ev, opts.legSections()));
119
119
  break;
120
120
  case "tool_roster_delta": {
121
121
  const rosterDelta = toolRosterDeltaEventData(ev);
@@ -179,11 +179,7 @@ export function createLedgerSink(opts) {
179
179
  return append("status", statusData);
180
180
  };
181
181
  const appendParked = (kind, result) => {
182
- const t = result?.terminal;
183
- return append(kind, {
184
- gate: t?.kind === "paused" ? t.gate : null,
185
- ...(typeof result?.toolCallId === "string" ? { toolCallId: result.toolCallId } : {}),
186
- });
182
+ return append(kind, parkEventData(result));
187
183
  };
188
184
  const appendDone = (result) => append("done", { result });
189
185
  const onDone = async (result) => {