@sema-agent/sdk 39.0.0 → 41.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +167 -4
  2. package/dist/client.d.ts +15 -7
  3. package/dist/client.d.ts.map +1 -1
  4. package/dist/client.js +14 -6
  5. package/dist/client.js.map +1 -1
  6. package/dist/device/index.d.ts +53 -12
  7. package/dist/device/index.d.ts.map +1 -1
  8. package/dist/device/index.js +70 -31
  9. package/dist/device/index.js.map +1 -1
  10. package/dist/errors.d.ts +35 -18
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.js +29 -14
  13. package/dist/errors.js.map +1 -1
  14. package/dist/events.d.ts +12 -27
  15. package/dist/events.d.ts.map +1 -1
  16. package/dist/events.js +2 -4
  17. package/dist/events.js.map +1 -1
  18. package/dist/health.d.ts +9 -12
  19. package/dist/health.d.ts.map +1 -1
  20. package/dist/health.js.map +1 -1
  21. package/dist/index.d.ts +15 -12
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +9 -8
  24. package/dist/index.js.map +1 -1
  25. package/dist/resources/approvals.d.ts +12 -8
  26. package/dist/resources/approvals.d.ts.map +1 -1
  27. package/dist/resources/approvals.js +4 -5
  28. package/dist/resources/approvals.js.map +1 -1
  29. package/dist/resources/rules.d.ts +1 -1
  30. package/dist/resources/rules.js +1 -1
  31. package/dist/resources/sessions.d.ts +19 -5
  32. package/dist/resources/sessions.d.ts.map +1 -1
  33. package/dist/resources/sessions.js +19 -5
  34. package/dist/resources/sessions.js.map +1 -1
  35. package/dist/resources/tool-approvals.d.ts +410 -790
  36. package/dist/resources/tool-approvals.d.ts.map +1 -1
  37. package/dist/resources/tool-approvals.js +187 -268
  38. package/dist/resources/tool-approvals.js.map +1 -1
  39. package/dist/settings.d.ts +2 -2
  40. package/dist/types.d.ts +144 -92
  41. package/dist/types.d.ts.map +1 -1
  42. package/dist/types.js +24 -0
  43. package/dist/types.js.map +1 -1
  44. package/openapi.yaml +592 -922
  45. package/package.json +1 -1
@@ -1,79 +1,27 @@
1
- /** tool-approvals — [830]① live-stream TOOL-APPROVAL HITL (server 1.191+ `ToolApprovalCoordinator`, gated on
2
- * `TOOL_APPROVAL_ENABLED`; server `src/tool-approval.ts`, `ToolApprovalCoordinator.respond`). The THIRD sibling of
3
- * {@link import("./questions.js").QuestionsResource} / {@link import("./elicitations.js").ElicitationsResource}:
4
- * elicitation = an inbound-MCP-server ask, question = the agent's own AskUserQuestion, THIS = the ENGINE's
5
- * permission gate ("may I run this tool?") surfaced to a live human — the suspended↔overlay bridge's decide面.
1
+ /** tool-approvals — 审批卡的**一对同根口**(server ≥7.152.0):决 `POST /v1/tasks/:taskId/asks/:askId/decision`({@link ToolApprovalsResource.decideAsk})、
2
+ * 读 `GET /v1/tasks/:taskId/asks/:askId`({@link ToolApprovalsResource.readAsk})。一张卡一只身份 `askId`(取自呈卡帧 {@link ApprovalRequestFrame.askId} 与同帧的 `taskId`);
3
+ * 与 {@link import("./questions.js").QuestionsResource} / {@link import("./elicitations.js").ElicitationsResource} 是同一类 HITL 的三个兄弟:
4
+ * elicitation = 入站 MCP server 的问,question = agent 自己的 AskUserQuestion,**本资源 = 引擎的权限闸**(「这个工具我能不能跑?」)呈给活人。
6
5
  *
7
- * 🔴 SCOPE OF THIS HEADER: everything below describes the LEGACY `respond` leg only. Since 6.7.0 this module
8
- * ALSO carries {@link ToolApprovalsResource.decideAsk} (design/172, POST /v1/tasks/:taskId/asks/:askId/decision),
9
- * which is the opposite shape — a persistent-store CAS keyed on the DURABLE `askId`, accepted by ANY replica.
10
- * Do not read the live-only/same-replica statements as module-wide.
6
+ * 🔴 **只有一个帧族 `approval_request`**(`capabilities.approvalFrameFamilies` = `["approval_request"]` 或 `[]`):`approval_request` → `approval_complete` / `approval_revoke` 三帧是
7
+ * 带外具名帧,与 `question` / `elicitation` 一样交错在活 token 流上。推荐路径 = `tasks.streamRaw` + 按 SSE `event:` 名分派(载荷回声 `type`),用 {@link isApprovalRequestFrameV1}
8
+ * 窄化后经 {@link ToolApprovalsResource.decideAsk} 回决。三帧也都是 {@link import("../events.js").AgentEvent} 的臂:`tasks.stream()` 把每个非心跳帧作为 `AgentEvent` 交给你。
9
+ * 后台 / 耐久腿上三帧被 server 的 durable-append 追加进事件尾,经 `runs.events()` / `GET /v1/runs/:id/events` 回得来 —— `runs.events()` 交出**解析后的载荷**、丢掉 SSE `event:` 行,
10
+ * durable 读边界把帧名重注进载荷(`{ type, ...data }`),所以判别位是 **`ev.type`**。重放的撤卡帧只用于时间线渲染 —— 卡集对账基线仍是重连前导帧,因为帧在任何一条腿上都可能丢。
11
11
  *
12
- * 🔴 LIVE-ONLY + SAME-REPLICA (the `steer()`-class of HITL, NOT the durable approvals/checkpoint class —
13
- * that is {@link import("./approvals.js").ApprovalsResource}): the parked ask is an in-memory promise with a
14
- * 5-min TTL (server DEFAULT_APPROVAL_TTL_MS), so a respond that lands after settle / after the TTL / on
15
- * another replica finds nothing → 404.
12
+ * 🔴 **决断口是持久店上的 CAS,任何副本都收**:按 durable `askId` 落行,不是进程内承诺 —— 别的副本上的属主作答照常 200(决断口写行,不按副本分);窗口到期后转后台候批(停驻)的卡
13
+ * 同一口赎回(200 + `accepted: "parked_redeemed"`)。未答的 ask 怎么收尾:有 checkpoint 店的部署 ⇒ run **durable-PARK**(运维稍后经 {@link import("./approvals.js").ApprovalsResource} 决),
14
+ * 不会按合成拒绝继续;窗口到期由 server 的 `expireAsk` CAS 重判成 `"unavailable"` ⇒ park 路由。任何一条腿 run 都不会挂死。
16
15
  *
17
- * 🔴 WHAT AN UNANSWERED ASK DOES (corrected — the old "fail-closes to DENY, the run proceeds" is now only the
18
- * MINORITY case). Since [879] G1 / core 1.295 the coordinator reports a THIRD value, `"unavailable"` ("no
19
- * reachable human"), instead of translating it to `false`, and CORE picks the landing:
20
- * · deployment WITH a checkpoint store ⇒ the run **durable-PARKS** — an operator can still decide later
21
- * through {@link import("./approvals.js").ApprovalsResource}. It does NOT proceed on a synthetic deny.
22
- * · deployment WITHOUT one ⇒ the historical fail-closed DENY, and the run proceeds.
23
- * With the design/172 protocol on the wire (server ≥7.3.0; default ON from server 7.5.0, see
24
- * {@link ApprovalRequestFrame}) the window expiry itself is re-adjudicated to `"unavailable"` by the server's
25
- * `expireAsk` CAS ⇒ the park route, not a deny. Either way the run never hangs.
26
- *
27
- * 🔴 On the LIVE leg the `tool_approval` / `tool_approval_complete` FRAMES are out-of-band NAMED frames,
28
- * interleaved on the live token stream exactly like `question`/`elicitation`. The RECOMMENDED route there is
29
- * `tasks.streamRaw` + dispatch on the SSE `event:` name (the payload echoes `type`), parse with
30
- * {@link ToolApprovalFrame}, then decide via {@link ToolApprovalsResource.respond}.
31
- * ⚠️ "Named frame" does NOT mean "no arm": since #185a both are {@link import("../events.js").AgentEvent}
32
- * arms, and `tasks.stream()` (which yields every non-heartbeat frame as an `AgentEvent`, without filtering by
33
- * event name) hands them to you typed. Use `streamRaw` when you want name-based dispatch, `stream()` when
34
- * payload-`type` dispatch is enough — both work; only the OLD claim "not an arm on the live leg" was wrong.
35
- * ⚠️ On the BACKGROUND/durable leg this pair — and the new protocol's `approval_request` — IS appended to the
36
- * events tail by the server's durable-append emit, so it DOES come back through `runs.events()` /
37
- * `GET /v1/runs/:id/events`, and as of **#185a** all three ARE arms of the
38
- * {@link import("../events.js").AgentEvent} union. **How to catch it there** (the naive answer does not work,
39
- * so it is spelled out): `runs.events()` yields PARSED PAYLOADS and drops the SSE `event:` line, so you cannot
40
- * dispatch by event name through it. The durable read boundary re-injects the frame name INTO the payload
41
- * (`{ type, ...data }`, same normalized name as the `event:` line), so the discriminator is **`ev.type`** —
42
- * and since the union now declares the arms, `switch (ev.type)` narrows straight to {@link ToolApprovalFrame} /
43
- * {@link ApprovalRequestFrame} with NO widening cast. (Before #185a this was a recorded TYPE-SURFACE GAP and a
44
- * durable consumer switching only on the declared arms silently dropped approval frames until they expired or
45
- * parked; that hole is closed on the type surface — the RUNTIME condition is unchanged, the frames still only
46
- * arrive where the corresponding gate is on.)
47
- * (`approval_revoke` joined the replay in server ≥7.55.0 (S-58): frames are dispatched PER CONTEXT — the sync
48
- * leg stays live-SSE-only (unchanged), while the bg/resume durable legs append the frame to the run's own
49
- * ledger, so `GET /v1/runs/:id/events` tails/replays it too, and it IS an `AgentEvent` arm now. A replayed
50
- * revoke frame is for timeline rendering only — the card-set reconciliation baseline is STILL the reconnect
51
- * preamble, because the frame can be lost on any leg.)
52
- *
53
- * 🔴 UNTRUSTED for display: `message`/`args` are service secret-redacted (+ args size-bounded, >16 KiB →
54
- * `argsOmitted:true`) but remain model/tool-authored — render only, never re-feed to a model. */
16
+ * 🔴 UNTRUSTED for display:`message` / `args` 经 service 秘密脱敏(+ args 大小有界)但仍是模型 / 工具所写 —— 只渲染,绝不回喂模型。 */
55
17
  import type { Transport } from "../transport.js";
56
18
  import type { HitlFrameType } from "../events.js";
57
19
  import type { AskClass, ExtensionRequester } from "../types.js";
58
20
  import type { ApprovalDecidedBy, ApprovalDecidedVia } from "./approvals.js";
59
21
  import type { AskRowEndingCause } from "../errors.js";
60
- /** The human's decision (server `parseToolApprovalResponse` in `src/tool-approval.ts` — closed 3-word set;
61
- * anything else is a 400. [2400] HITL-10: the function name was written `parseToolApprovalDecision`, which does
62
- * not exist in the server — grepping for it finds nothing. `allow_session` = allow AND remember for this session's category (fs-write tools share ONE
63
- * category: approving Write covers Edit/NotebookEdit; other tools are per-tool) — the CC "don't ask again this
64
- * session" semantic. */
65
- export type ToolApprovalDecision = "allow" | "allow_session" | "deny";
66
- /** A live tool-approval frame interleaved on the run's `tasks.streamRaw` connection (server `ToolApprovalFrame`,
67
- * tool-approval.d.ts). `type` IS the SSE `event:` name AND is echoed in the payload. The shell renders the
68
- * `tool_approval` frame as an allow/deny dialog and dismisses it on `tool_approval_complete`.
69
- *
70
- * ⚠️ 与 {@link ApprovalRequestFrame}(design/172 流内审批协议,server ≥7.3.0 已上线)的关系:**一条腿一个帧族**(server ≥7.133.0,`capabilities.approvalFrameFamilies`)——
71
- * 呈卡协议上场的腿(`["approval_request"]`)上一只 ask 只走 `approval_request` 族,**本帧(`tool_approval` / `tool_approval_complete`)一帧都不发**(补偿:该 worker 设 `STREAM_APPROVAL_ENABLED=false` 回到旧族腿);
72
- * 协议没上场的腿(`["tool_approval"]`)只发本族,wire 逐字不变。≤7.132.x 的呈卡腿上两族并发:同一只 ask 先本帧(逐字不变)、后 `approval_request`,两帧同带 `approvalId`
73
- * ⇒ 新壳按 `approvalId` 去重、优先渲染新帧。 */
74
22
  /**
75
23
  * auto 模式分类器「没判出来」的成因闭集 —— 引擎 `AUTO_MODE_FALLBACK_CAUSES`(core 7.43.0)逐字同序:`error` / `timeout`(分类器跑不了)· `parse_error`(答了却没有判词)。
76
- * server ≥7.118.0 上 {@link ToolApprovalFrame.classifierNoRuling} 与收件箱行同名位用它(server 用引擎谓词筛,集外不铸)。**闭集**:加词 = 引擎下一版 + 本常量与 spec enum 同批加。
24
+ * server ≥7.118.0 上 {@link ApprovalRequestLiveFacts.classifierNoRuling} 与收件箱行同名位用它(server 用引擎谓词筛,集外不铸)。**闭集**:加词 = 引擎下一版 + 本常量与 spec enum 同批加。
77
25
  */
78
26
  export declare const AUTO_MODE_FALLBACK_CAUSES: readonly ["error", "timeout", "parse_error"];
79
27
  /** {@link AUTO_MODE_FALLBACK_CAUSES} 的成员型。 */
@@ -91,16 +39,11 @@ export interface BoundSkillGrants {
91
39
  * `question`(问用户的问题 —— 引擎保留的问答工具,不是副作用工具;读 `contentKind === "content_ask"` 的旧消费方改读 `approvalCard === "question"`)· `generic` ·
92
40
  * `computer-access`(把用户屏幕交给模型的工具的同意卡,调用带 `apps` = 要的应用清单)· `computer-control`(同一类工具的另一张同意卡,调用不带卡需要的东西;两张卡各授什么按连接定)。
93
41
  * `skill` / `workflow` 早在 core 7.59.0 就在引擎词表里,sdk 33.x 及以前漏抄(那两张卡在本包读成集外);34.0.0 起本表与引擎包根导出逐字同序(钉 `server-7144-wire` K1)。
94
- * 载体与缺席含义见 {@link ToolApprovalFrame.approvalCard}。**闭集**:新词随 core minor 加入 ⇒ 按它分支的 `switch` 留 default 臂。
42
+ * 载体与缺席含义见 {@link ApprovalRequestLiveFacts.approvalCard}。**闭集**:新词随 core minor 加入 ⇒ 按它分支的 `switch` 留 default 臂。
95
43
  */
96
44
  export declare const TOOL_APPROVAL_CARD_WORDS: readonly ["file-edit", "file-write", "notebook-edit", "shell", "fetch", "skill", "workflow", "plan", "question", "generic", "computer-access", "computer-control"];
97
45
  /** {@link TOOL_APPROVAL_CARD_WORDS} 的成员型。 */
98
46
  export type ToolApprovalCardWord = (typeof TOOL_APPROVAL_CARD_WORDS)[number];
99
- /** 同源锚对账面(2026-07-28,cli 接法核查条 5):`ToolApprovalFrame` 的**字段名清单**,给下游值拷贝
100
- * (client-core 自持同名闭集 copy)做机器对账用——照 settings-schema(原 registry-core)值拷贝+同源锚先例。下游测试断言
101
- * 自己的 copy 键集 ⊇/== 本清单,SDK 每次 additive 增键(如 1.307 的 `toolCallId`)对方当天红,
102
- * 不再靠人肉追平。**新增帧字段必须同步进本清单**(有测试钉)。 */
103
- export declare const TOOL_APPROVAL_FRAME_KEYS: readonly ["type", "approvalId", "toolCallId", "toolName", "sourceSessionId", "agentId", "askReasons", "fromSubagent", "sourceAgentName", "message", "args", "argsOmitted", "governanceForced", "rememberRefused", "requiresRealApproval", "origin", "approvalCard", "inputHasBidi", "expiresAtMs", "expiresInMs", "serverNowMs", "ruleOffers", "ruleOffersAbsence", "mandated", "mandate", "denialLimitFallback", "allowRuleShadowed", "probeCause", "probeReason", "requestedBy", "ruleEvidence", "delegation", "parked", "outcome", "cause", "classifierUnavailable", "ruleStoreUnreadable", "readRootCandidate", "askClass", "classes", "boundGrantDigest", "boundGrants", "classifierNoRuling", "boundGrantAbsence"];
104
47
  /**
105
48
  * 一条规则的**匹配形**闭词表 —— core `PERSISTED_RULE_MATCHES` 逐字十一员同序(词表属主是 core:core 7.54.0 起是包根值,server ≥7.134.0 直接读它、不再自留转录;此前 server 转录并钉全等)。
106
49
  * **一张表、两面同读**:卡上的规则候选 {@link RuleOffer}(server 的卡 schema 用同一只 enum 校验)与持久规则行
@@ -169,7 +112,7 @@ export interface RuleOfferUncoveredDetail {
169
112
  * core #490 修②)—— 规则车道**在场却无可给**时,引擎点名哪扇门关了(前三词是引擎 `ruleClearanceOf` 的三扇门):
170
113
  * · `mandated` —— 这只 ask 是**强制逐次确认**的(治理令 / doctrine `always` / 工具自带 mark / 部署出身的问):没有任何持久规则清得掉它;
171
114
  * 🔴 这一臂**不得**把人指向"去写条规则" —— 写了也不会消音,那是把用户送进一个死循环;
172
- * · `allow_outranked` —— allow 层里已有成员命中了这次调用,而这一问的层级更高(与 {@link ToolApprovalFrame.allowRuleShadowed} 同一件事的机读位):
115
+ * · `allow_outranked` —— allow 层里已有成员命中了这次调用,而这一问的层级更高(与 {@link ApprovalCard.allowRuleShadowed} 同一件事的机读位):
173
116
  * 再写一条 allow 规则也清不掉;
174
117
  * · `ask_rule_matched` —— 一条显式的 `ask` 规则命中了这次调用(同帧 `origin === "ask_rule"`):它会一直问,写 allow 规则也不会消音;
175
118
  * 部署名单门 `APPROVAL_REQUIRE` / supervisor 路由的卡自报命中显式 ask 规则,也落这一词;
@@ -185,7 +128,7 @@ export interface RuleOfferUncoveredDetail {
185
128
  export declare const RULE_OFFERS_ABSENCE_REASONS: readonly ["mandated", "allow_outranked", "ask_rule_matched", "lane_cannot_speak"];
186
129
  export type RuleOffersAbsence = (typeof RULE_OFFERS_ABSENCE_REASONS)[number];
187
130
  /**
188
- * 一张卡**为什么没有**授予绑定摘要 {@link ToolApprovalFrame.boundGrantDigest}(引擎 core 7.51.0 `BOUND_GRANT_ABSENCES`,逐字同序;server ≥7.129.0)——
131
+ * 一张卡**为什么没有**授予绑定摘要 {@link ApprovalRequestLiveFacts.boundGrantDigest}(引擎 core 7.51.0 `BOUND_GRANT_ABSENCES`,逐字同序;server ≥7.129.0)——
189
132
  * 引擎铸的每张工具审批卡**恰带**摘要与本词之一:
190
133
  * · `not_bindable` —— 这一问不是引擎 `Skill` 工具的激活,不绑任何授予 ⇒ 批准它不授予别的东西(「本会话放行」可按工具记);
191
134
  * · `unreadable` —— 卡绑着授予,却读不出绑的是什么(存量行的摘要不是串,或两者都不说 —— 7.51.0 之前停驻的行;集外词);活卡上引擎恒给摘要,
@@ -194,7 +137,7 @@ export type RuleOffersAbsence = (typeof RULE_OFFERS_ABSENCE_REASONS)[number];
194
137
  * 🔴 server ≥7.141.0:读存量行的三面(inbox 行 · 运维队列行 · `pending` 帧)**恰带**摘要与本词之一,同一条读法 —— 摘要是串 ⇒ 摘要;否则摘要键不在且词是闭集成员 ⇒ 那个词;
195
138
  * 否则 ⇒ `unreadable`(摘要在却不是串的行即使另有 `not_bindable` 也读它)。
196
139
  * 🔴 **缺席不是 `not_bindable`**:技能卡带摘要(恰一);老 server(≤7.128.x 三面都不投)、≤7.140.x 队列两面上 7.51.0 之前停驻的行与集外词都读作缺席 ——
197
- * 读不到本词的卡不许当作「批准它不授予别的东西」;要不要渲「本会话放行」读 {@link ToolApprovalFrame.rememberRefused}。display,不是裁决输入。
140
+ * 读不到本词的卡不许当作「批准它不授予别的东西」;要不要渲「本会话放行」读 {@link ApprovalCard.rememberRefused}。display,不是裁决输入。
198
141
  */
199
142
  export declare const BOUND_GRANT_ABSENCES: readonly ["not_bindable", "unreadable"];
200
143
  export type BoundGrantAbsence = (typeof BOUND_GRANT_ABSENCES)[number];
@@ -243,7 +186,7 @@ export interface AllowRuleClearance extends AllowRuleShadow {
243
186
  /**
244
187
  * **auto 模式分类器的限额回落卡**(server `approval-card.ts` 的 `DenialLimitFallbackSchema`;S-114 /
245
188
  * core 7.4.0 #548)—— 分类器连续(缺省 3)或累计(缺省 20)拒到限额的**那一次**调用不再静默 deny,
246
- * 而是落成一张**必须真人批**的卡(同一次铸造同时盖 {@link ToolApprovalFrame.requiresRealApproval},两键是孪生)。
189
+ * 而是落成一张**必须真人批**的卡(同一次铸造同时盖卡的强制位,两键是孪生)。
247
190
  *
248
191
  * 🔴 **四成员全必填**:core 的形上没有一个可选位 ⇒「少一位」不是老 core 而是坏值,server 整键不铸
249
192
  * (绝不半铸一张让人误读计数的卡)。
@@ -264,7 +207,7 @@ export interface DenialLimitFallback {
264
207
  }
265
208
  /**
266
209
  * 一只 ask 上的「**分类器答不了**」标注(server ≥7.69.0;core 7.10.0 #616)—— 答的是审批人最想知道的
267
- * 那句话:**为什么这一问会到我手上**。三面同形同值:live `tool_approval` 帧 / {@link ApprovalCard}
210
+ * 那句话:**为什么这一问会到我手上**。三面同形同值:呈卡帧顶层 / {@link ApprovalCard}
268
211
  * (`card_json` / `approval_request`)/ `GET /v1/assistant/inbox` 行。
269
212
  *
270
213
  * 🔴 **`cause` 在 wire 上是开集 `string`,本 SDK 刻意不枚举**:词表的单一属主在引擎(今天三词
@@ -304,14 +247,14 @@ export interface ClassifierUnavailable {
304
247
  * 🔴 **词表的唯一属主是 core**,本类型只是**型面供给**(具名词给自动补全,`(string & {})` 让新词读得出来)——
305
248
  * 消费端一律按**开集**分支,把未知词当"未知出身"而不是"没有出身"。
306
249
  * ⚠️ **为什么这一条真的要开**(S-170 自查亲读验真,8.3.0 的注写着 `(string & {})` 而类型上没有 = 注与码
307
- * 不符):`tool_approval` 帧上的 `origin` 在 server 侧**只判非空串、不判成员**(`src/tool-approval.ts` 的帧
250
+ * 不符):呈卡帧顶层的 `origin` 在 server 侧**只判非空串、不判成员**(帧
308
251
  * 铸点),所以 core 加一个新词的当天,一个**合法**的帧就会带着词表外的值到达消费端 —— 闭类型会让它变成
309
252
  * 「编译不过、只能 `as` 绕开自己的类型」。这与 {@link import("../types.js").DeniedBy} **刻意相反**,而差别
310
253
  * 🔴 **core 7.14.0 #688 C2 无别名改名**:`unresolvable` → `ancestor_marked`(这次调用被祖先**标记**为不可解:继承的
311
254
  * approver-unavailable 浮起,或祖先的 marked 席);server 7.72.0 起账本存量字节一次性改写、读腿零双读 ⇒ wire 上
312
255
  * 只会出现新词;消费端 switch 若仍写旧词,那一臂永远不会命中(sdk 9.2.0 起本联合同步改名,零别名)。
313
256
  * 有出处:那一条走 `screenGateOutcome` 的成员筛,出集的记录 server **整条不上帧**,所以它在 wire 上是真闭集。
314
- * 🔴 与 {@link ToolApprovalFrame.governanceForced} **不是**一回事:本词答「哪一类权威提的问」,那一位答
257
+ * 🔴 与 {@link ApprovalCard.governanceForced} **不是**一回事:本词答「哪一类权威提的问」,那一位答
315
258
  * 「**本部署运维治理层**是不是这只 ask 的门」;`origin: "policy"` 覆盖任何部署 ToolPolicy 的 ask,
316
259
  * 治理策略产的与普通策略产的在这一个词上同形 ⇒ 顶替不了。
317
260
  */
@@ -337,7 +280,7 @@ export type HookQuestionCause = (typeof HOOK_QUESTION_CAUSES)[number];
337
280
  export declare const ASK_REASON_POLICY_ASKERS: readonly ("policy" | "content_question" | "plan_review" | "ancestor_marked" | "org_unavailable" | "org_rule" | "rule_store_unavailable" | "ask_rule" | "denial_limit_fallback" | "shell_gate_tighten" | "safety_tighten")[];
338
281
  /**
339
282
  * **谁问的、为什么问** —— 一条一位问者 + 它自己的话(server ≥7.143.0,core 7.61.0 `AskReason`;server 投影形 `AskReasonProjection`)。
340
- * 活卡帧({@link ToolApprovalFrame.askReasons})、呈卡帧的卡({@link ApprovalCard.askReasons})、运维队列行(`PendingCheckpoint.askReasons`)三面同一只窄读,逐字同值。
283
+ * 活卡帧({@link ApprovalCard.askReasons})、呈卡帧的卡({@link ApprovalCard.askReasons})、运维队列行(`PendingCheckpoint.askReasons`)三面同一只窄读,逐字同值。
341
284
  * · hook / 扩展的问:`{ by: "hook", cause, registration?, words? }` —— `cause` 见 {@link HOOK_QUESTION_CAUSES},`registration` 是注册名(已截到标识帽),`words` 是它自己写的话;
342
285
  * · 策略链的问:`{ by, words }` —— `by` ∈ {@link ASK_REASON_POLICY_ASKERS}(与 {@link AskOrigin} 同一张词表去 `hook`),`words` 是那一层写的话。
343
286
  * 问者的话是部署策略 / hook / 扩展写的**自由文本**:server 已过凭据脱敏并截长(与卡上 `message` 同一只帽),仍按不可信展示文本渲。两臂都封闭(server 卡 schema `.strict()`)。
@@ -379,7 +322,7 @@ export declare const PERSISTED_RULE_MANDATES: readonly ["operator_always", "tool
379
322
  export type PersistedRuleMandate = (typeof PERSISTED_RULE_MANDATES)[number];
380
323
  /**
381
324
  * 一张审批卡上的**一个**「不再询问」选项(core design/375 §3.1 的判别联合;server ≥7.46.0 在
382
- * `tool_approval` 帧 / `card_json` / durable park 行**三腿同形**发出,**BREAKING 换键**,前名
325
+ * 呈卡帧 / `card_json` / durable park 行**三腿同形**发出,**BREAKING 换键**,前名
383
326
  * `ruleSuggestions`、旧键同批退役无 alias;sdk 26.0.0 随底线 7.52.0 删了旧键的声明)。
384
327
  *
385
328
  * 🔴 **判形读 `kind`,不许按下标假设形**。**序即契约**:whole-string exact 的 `single` 在场时恒 index 0、
@@ -389,7 +332,7 @@ export type PersistedRuleMandate = (typeof PERSISTED_RULE_MANDATES)[number];
389
332
  * 反向**不成立**:缺席只读作「**本卡**无此选项」—— 店在场也可能没有这一格(mandated / `requiresRealApproval` /
390
333
  * allow_outranked / ask_rule_matched / hook 产 / inherited-unresolved / ancestor-resolved / anonymous 七族一律不带)。既不能读成
391
334
  * 「本部署没有规则车道」(那句话看 `capabilities.permissionRules`),也不能读成「你的规则坏了」(那句话看
392
- * {@link ToolApprovalFrame.allowRuleShadowed})。
335
+ * {@link ApprovalCard.allowRuleShadowed})。
393
336
  *
394
337
  * 🔴 **兑付两臂,选择键不同**(见 {@link PersistRuleSelection}):`single` 臂把 `rule` 文本**原样**抄回
395
338
  * (server 按**文本**定位,抄错 = `rule_not_offered`);`batch` 臂没有单条文本可抄(它是对全体成员的**一个**
@@ -398,7 +341,7 @@ export type PersistedRuleMandate = (typeof PERSISTED_RULE_MANDATES)[number];
398
341
  * 🔴 **下标语义随腿不同**(server 两条腿的顶注逐字,消费端必读):活卡帧腿 / `card_json` / 重放帧上
399
342
  * server 是**纯前缀截、零逐条丢弃** ⇒ 下标恒等于 core 的 offer index,**是**合法选择键;而耐久队列行腿
400
343
  * ({@link import("../types.js").PendingCheckpoint.ruleOffers})server 对形不合的 offer 是**逐条丢弃并压紧**的
401
- * ⇒ 下标会前移,且那条腿**没有兑付口** ⇒ 只能当展示/分诊座,**禁**当 `batchOfferIndex` 回兑。
344
+ * ⇒ 下标会前移:server ≤7.151.x 上那条腿**没有兑付口** ⇒ 只能当展示/分诊座,**禁**当 `batchOfferIndex` 回兑;server ≥7.152.0 起耐久回决口 `/decide` 收 `persistRule`,按**本行数组里的下标**兑(读法见 `PendingCheckpoint.ruleOffers`)。
402
345
  * 消费端自己再丢坏形时同理:core 的规范性条款是「保住每个留下来成员的**原始 wire 下标**,做不到就
403
346
  * must suppress its persistence actions entirely(fail toward asking)」。
404
347
  */
@@ -427,7 +370,7 @@ export type RuleOffer =
427
370
  * P-39(server ≥7.48.0,**additive、零能力位**;cli [5254] 请托 / [5263] 定形 = offer 空间)——
428
371
  * batch 臂成功回执上一条规则的**逐条自描述归属锚**。
429
372
  *
430
- * 病:{@link ToolApprovalRespondApplied.persistedRules} 的逐条归属此前**只能靠位置**推,而位置在 wire 上
373
+ * 病:{@link AskDecisionAck.persistedRules} 的逐条归属此前**只能靠位置**推,而位置在 wire 上
431
374
  * 证不出来(回执序取自服务端**重铸批**的成员走序,与文档承诺的展示序只是碰巧一致——防漂等式是**集合**
432
375
  * 等式,序不在里面)。
433
376
  *
@@ -475,7 +418,7 @@ export type PersistRuleSelection =
475
418
  /**
476
419
  * **候选臂 / 编辑臂**(同一个字段两种含义,判别位是 `edited`)。
477
420
  *
478
- * · `edited` 缺席或 `false` = **候选臂**:`rule` 必须是 {@link ToolApprovalFrame.ruleOffers} 里某条
421
+ * · `edited` 缺席或 `false` = **候选臂**:`rule` 必须是 {@link ApprovalCard.ruleOffers} 里某条
479
422
  * `kind:"single"` 的 `rule` **原样文本**。别拼、别改大小写、别自己加 `:*` —— server 按文本定位,
480
423
  * 对不上就拒(`ruleRefusal: "rule_not_offered"`),不猜。
481
424
  * · `edited: true` = **自由文本臂**(server ≥7.44.0 / #340;**先探能力位**
@@ -483,7 +426,7 @@ export type PersistRuleSelection =
483
426
  * `rule` 是人在卡上手改的文本。老 worker 不认识 `edited`(未知键静默丢)会把它当候选判 ⇒ 回一句
484
427
  * `rule_not_offered`(诚实但会被误读成「我写错了」)。落盘走引擎三道门(共享校验器 / 覆盖门:
485
428
  * 编辑后的规则必须仍**容纳本次被裁决的命令** / scope 继承这张卡自己的),成功回执带
486
- * {@link ToolApprovalRespondApplied.persistedRule} = **真正落盘的规范拼写**(`Bash(adb *)` ⇒ `Bash(adb:*)`),
429
+ * {@link AskDecisionAck.persistedRule} = **真正落盘的规范拼写**(`Bash(adb *)` ⇒ `Bash(adb:*)`),
487
430
  * 壳应回显它而不是输入框里的原字节。
488
431
  *
489
432
  * ⚠️ 与 `updatedInput`(ctrl+g 编辑放行)**同时在场 ⇒ server 拒绝这次持久化**
@@ -531,7 +474,7 @@ export type PersistRuleSelection =
531
474
  * · `rule_lane_unavailable` —— **四种成因共用一格**(亲读 `persistRuleAfterDecision` 的合取项):①本部署
532
475
  * 没接规则店;②引擎对这条命令没铸出候选;③命令原字节读不出;④这只 ask 没有已验明的属主。②③是
533
476
  * **这张卡**的局限,不是部署形态 ⇒ 🔴 **禁**据它判断「这台部署不供规则」(帧上 `ruleOffers` 缺席
534
- * 时同理,见 {@link ToolApprovalFrame.ruleOffers});
477
+ * 时同理,见 {@link ApprovalCard.ruleOffers});
535
478
  * · `rule_input_edited` —— 回决同时带了 `updatedInput`(ctrl+g 编辑放行):生效的是编辑后那份,而候选是
536
479
  * 引擎从**原始**命令铸的 ⇒ v1 拒绝这次持久化(否则「把危险命令改安全 + 勾上不再询问」会给原始那条
537
480
  * 危险命令装上常驻放行规则);
@@ -553,7 +496,7 @@ export type RuleRefusalReason = "no-candidates" | "unknown-candidate" | "confirm
553
496
  /** #340(server ≥7.44.0)—— 人写的文本**被引擎的门拒了**:共享校验器不认这个拼写,或它不覆盖本次被裁决
554
497
  * 的命令(「编辑可以更宽,不许换成另一条授权」)。
555
498
  * ⚠️ **射程自 #345(server ≥7.51.0 / core 5.57.0)起收窄**:文本能独立判定的那一半(语法门 + 覆盖门)
556
- * 搬到了**裁决之前** —— 那条路上 respond 在结算前就 400、**卡还在**,所以「改一下再来」今天真能来。
499
+ * 搬到了**裁决之前** —— 那条路上决断口在结算前就 400、**卡还在**,所以「改一下再来」今天真能来。
557
500
  * 剩到这个词的是纵深残余(预检被跳过的路径 / 预检过了但记录级仍拒),此时卡已消费,同一把
558
501
  * `approvalId` 再回决是 404。 */
559
502
  | "edit-rejected"
@@ -571,9 +514,9 @@ export type RuleRefusalReason = "no-candidates" | "unknown-candidate" | "confirm
571
514
  * 没有素材」—— 折成同一个词,一次 park 迟到答就能让壳把一台正常部署的整条车道判死。 */
572
515
  | "rule_material_absent";
573
516
  /**
574
- * 活卡结局帧 `tool_approval_complete` 的 {@link ToolApprovalFrame.cause} 词表 —— 审批席「结局成因」一张闭集(server ≥7.124.0,十七词)里**非人结局**的十四词:
517
+ * 消卡帧 `approval_complete` 的 {@link ApprovalCompleteFrame.cause} 词表(server ≤7.151.x 的旧族 `tool_approval_complete` 同词) —— 审批席「结局成因」一张闭集(server ≥7.124.0,十七词)里**非人结局**的十四词:
575
518
  * 问账行能落的十词({@link AskRowEndingCause}:路由失败 / run 取消 / 承载腿退场 / 批撤 / 兄弟被撤卡连坐 / bind-once 落选 / adhoc 腿无对账域 / 遗孤兜底 / 进程崩溃 / 有序关停截断)
576
- * 再加四个**不落问账行**的等待类词 —— `ttl_expired`(等待窗走完、没有人答)· `broadcast_lost`(两族帧都没送到任何连接,卡从未送达任何人)·
519
+ * 再加四个**不落问账行**的等待类词 —— `ttl_expired`(等待窗走完、没有人答)· `broadcast_lost`(帧没送到任何连接,卡从未送达任何人)·
577
520
  * `stream_disconnected`(承载这张卡的流断了,断连强转 park)· `undeliverable`(持久行不可用 / 身份不定 / 悬挂无行,卡没呈到任何投递面)。
578
521
  * 另三个决断类词(`binding_changed` / `answer_invalid` / `outcome_cell_invalid`)只拒一次决议、不结束一张卡 ⇒ 不在这里(它们在 wire 上是决断口 409 的码,不是词)。
579
522
  * 闭集:冻结的字面元组,成员型 {@link ApprovalSettleCause};{@link isApprovalCompleteFrameV1} 判 `cause` 成员读的就是这张表(型、常量、守卫一处定义)。
@@ -584,15 +527,7 @@ export declare const APPROVAL_SETTLE_CAUSES: readonly ["ttl_expired", "broadcast
584
527
  /** {@link APPROVAL_SETTLE_CAUSES} 的成员型(= 四个等待类词 ∪ {@link AskRowEndingCause} 十词)。 */
585
528
  export type ApprovalSettleCause = (typeof APPROVAL_SETTLE_CAUSES)[number];
586
529
  /**
587
- * 晚答 `POST /v1/tool-approvals/:id/respond` 的 `404 tool_approval.not_pending` 体 `cause`(经 `err.extra.cause` 到达;本包对该码不开具名属性)。
588
- * = 问账行成因十词({@link AskRowEndingCause};读同一列、同一个值)∪ 404 专属词 `unknown_or_other_replica`(本副本不认识这个 id —— 换端点或换副本重试才有意义)。
589
- * 🔴 **server ≥7.124.0:旧词 `voided` / `denied` 退役**(被具体成因词取代,零别名)。按 `cause === "voided"` 分支的壳改读成因词:**任何成因词 ⇒ 这张卡没有人决过它、
590
- * 答案无处兑现,消卡即可**。行上没写成因(存量行)⇒ 键缺席;没有持久 ask 账的部署压根不编这一位(缺席同样合法)。
591
- * 今天只有 park 与取消撤卡两类终局留桥 ⇒ 答得出具体词;批内兄弟连坐与遗孤 TTL 收的行不留桥 ⇒ 那两形的迟到答仍是 `unknown_or_other_replica` —— 别把词表读成可达性承诺。
592
- */
593
- export type ToolApprovalNotPendingCause = AskRowEndingCause | "unknown_or_other_replica";
594
- /**
595
- * 读根候选 {@link ToolApprovalFrame.readRootCandidate} 的 `covers` **词表**(引擎 `ReadRootGrantCandidate.covers`;server 的窄读铸点 `readReadRootCandidate` 对集外词整只丢)。
530
+ * 读根候选 {@link ApprovalRequestLiveFacts.readRootCandidate} 的 `covers` **词表**(引擎 `ReadRootGrantCandidate.covers`;server 的窄读铸点 `readReadRootCandidate` 对集外词整只丢)。
596
531
  * 今天一词:`"exact"` —— `dir` 是命令点名的那一条路径本身,不是包含它的目录。闭集:冻结的字面元组,成员型 {@link ReadRootCover};
597
532
  * 型、随包 spec 枚举、{@link isApprovalRequestFrameV1} 对 `covers` 的成员判读的都是这一张表(一处定义,守卫里没有内联词表)。
598
533
  * 同源锚:测试对着 server 发布字节里铸点上的词(语法树读)与引擎 d.ts 里的字面量联合逐词核 —— 任一边加词 / 换词,这张表不跟就当场红。
@@ -600,336 +535,95 @@ export type ToolApprovalNotPendingCause = AskRowEndingCause | "unknown_or_other_
600
535
  export declare const READ_ROOT_COVERS: readonly ["exact"];
601
536
  /** {@link READ_ROOT_COVERS} 的成员型。 */
602
537
  export type ReadRootCover = (typeof READ_ROOT_COVERS)[number];
603
- export interface ToolApprovalFrame {
604
- type: Extract<HitlFrameType, "tool_approval" | "tool_approval_complete">;
605
- /** The id to echo back to {@link ToolApprovalsResource.respond}. */
606
- approvalId: string;
607
- /** "tool_approval" only: the tool awaiting permission. */
608
- toolName?: string;
609
- /** "tool_approval" only (server ≥1.307, ADDITIVE): the ENGINE's tool-call id — the same `call_…` id that
610
- * rides the assistant message's `tool_use` block. **Anchor the permission card on THIS**, not on
611
- * {@link ToolApprovalFrame.approvalId} (a fresh uuidv7 minted for the approval itself, unrelated to that
612
- * block — nothing else on the stream ever mentions it again, so a card keyed by it never gets reclaimed).
613
- * Anchoring on "the most recent tool_start" does NOT work either: the approval frame arrives BEFORE
614
- * `tool_start` (measured 4020ms vs 4142ms in one turn). Absent on `tool_approval_complete` (that frame
615
- * settles by `approvalId`; a second anchor would only add ambiguity) and on servers < 1.307. */
616
- toolCallId?: string;
617
- /** "tool_approval" only(**server ≥7.143.0 / core 7.61.0,BREAKING 换名**,取代 ≤7.142.x 的 `sourceTaskId`;值不变、零别名,sdk 33.0.0 同删):
618
- * present ⇔ the ask comes from a DELEGATED background/nested child (its permission card floats to the HOST run's live stream).
619
- * Value = the child's core **session** id (same id domain as fleet `bg_notification.sessionId` — join it to the child's session row).
620
- * 它名一只会话,不名任务:发起这一问的那条腿的 agent id 是 {@link agentId}。归属判别读 {@link fromSubagent}(显式判别位),不读本键在场。
621
- * ≤7.142.x 的 server 发的是旧名 `sourceTaskId`,本包不再读它(支持面内的老 server 上本键读作缺席)。 */
622
- sourceSessionId?: string;
623
- /** "tool_approval" only(server ≥7.143.0 / core 7.61.0,additive):发起这一问的**腿的 agent id** —— 后台子代是注册表行 id(`a…`,与它的行、`TaskStop`、`SendMessage`、
624
- * 完成通知同一个串),前台子代是它的会话 id;直接起跑的 workflow 的 agent 带它而**不带** {@link fromSubagent};宿主自己的问缺席。与扩展事件的 `agentId` 同值(引擎同一只判据铸)。 */
625
- agentId?: string;
626
- /** "tool_approval" only(server ≥7.143.0 / core 7.61.0,additive):**谁问的、为什么问** —— 一条一位问者 + 它自己的话({@link AskReason} 两臂:hook / 扩展的问带 `cause`,
627
- * 策略链的问带 `words`)。结构化审批面按它渲理由行,不渲 {@link message}(`message` 照旧逐字给只读文本的消费方)。活卡帧、呈卡帧的卡、运维队列行三面同一只窄读(server `readAskReasons`):
628
- * 问者的话已过凭据脱敏并截长;任一条形不合 ⇒ server **整座不投**(卡上少一行理由,不出现半条)。缺席 = 老引擎 / 老行 / 引擎自己铸的通用问句(不铸条目)。 */
629
- askReasons?: AskReason[];
630
- /** "tool_approval" only (server ≥1.260, engine RB-39②): `true` ⇔ this ask comes from a DELEGATED
631
- * background/nested child — the EXPLICIT discriminator (trusted engine-internals fact, a worker cannot
632
- * forge/suppress it). Read the attribution badge off THIS (not off {@link sourceSessionId} presence). Absent = the
633
- * host's own ask. ADDITIVE. */
634
- fromSubagent?: true;
635
- /** "tool_approval" only (server ≥1.260): the delegated child's display name, secret-redacted.
636
- * UNTRUSTED-for-display (the engine does not guarantee it resolves) — render as the attribution badge
637
- * label ("from @name") when present; fall back to a generic "background agent" label when absent (even
638
- * on a child ask). ADDITIVE. */
639
- sourceAgentName?: string;
640
- /** "tool_approval" only: the engine's ask text, secret-redacted. UNTRUSTED — display only. */
641
- message?: string;
642
- /** "tool_approval" only: the pending call's args, redacted + size-bounded. Absent when `argsOmitted`. */
643
- args?: unknown;
644
- /** "tool_approval" only: args exceeded the 16 KiB bound (or failed to serialize) → omitted, render a stub. */
645
- argsOmitted?: boolean;
538
+ /** (server ≥7.23.0 / core 5.35.0, ADDITIVE): the RULE-PROVENANCE
539
+ * evidence behind this ask — the org policy snapshot `orgRevision`, the matched org rule's verbatim text
540
+ * `orgRule`, and the shadowed personal rule's add dots `personalRuleDots` (the rule's durable identity —
541
+ * an ARRAY by construction; render/reconcile as data, never join into one scalar id). EACH member is a
542
+ * value OR a NAMED absence (`…Absent`, five-word closed set below — read as open set, engine owns the
543
+ * vocabulary): `"not_wired"` no such lane / `"not_adjudicated"` lane exists, call skipped /
544
+ * `"unavailable"` the lane was consulted and its SOURCE could not be read (the one word meaning the
545
+ * audit chain is BROKEN, not empty — the ask in hand is the fail-closed tighten that followed) /
546
+ * `"no_match"` consulted, nothing spoke / `"not_reported"` the seam answered without the identity.
547
+ * Display/reconciliation metadata, NEVER adjudication input; the server transcribes the ENGINE-stamped
548
+ * record and never mints an absence word itself. Absent frame key = older server, or the narrow-read
549
+ * dropped a malformed record — never "ungoverned".
550
+ *
551
+ * ── 消费指引①:**呈现谓词**(别写「在场即渲」)────────────────────────────────────────────────
552
+ * 一只成员**占展示面**的条件是:**有值**,**或者**它的缺席词**不是良性白名单里的**。良性白名单 =
553
+ * 「这条治理车道本来就没接 / 没轮到它说话」那类词(`not_wired` / `not_adjudicated`),它们在
554
+ * **无治理部署上是常态**;而 `unavailable` 必须**恒可见**(它说的是**审计链断了** —— 车道被咨询了、
555
+ * 源读不出来,手上这只 ask 正是随之而来的 fail-closed 收紧,这是用户唯一能看见「为什么突然要我批」
556
+ * 的地方),未知词(引擎将来新铸的)同样**默认可见**(开集读纪律:不认识的词不许被当成良性静默)。
557
+ * 🔴 为什么这条必须写死:**没有治理的部署上,每一只 ask 都会 stamp 三个具名缺席** —— 那是
558
+ * **契约行为,不是缺陷**(引擎如实说「这三条车道我都问过/都没接」)。所以「成员在场就渲一行」的
559
+ * 朴素写法会在最常见的部署上给每张审批卡糊上三行 "not wired",把真正要紧的那一行(`unavailable`)
560
+ * 淹掉。判据是**词**,不是**在场**。
561
+ *
562
+ * ── 消费指引②:**窄读域纪律**(窄读只许 ≥ 铸点域)────────────────────────────────────────────
563
+ * 服务端对这只对象走的是**整只拒读**语义:一条畸形记录被**整只丢掉**(不是逐成员挑好的留下)。
564
+ * 所以消费方若也做窄读/白名单过滤,**读域只许 ≥ 铸点域**(铸点写了几个成员,窄读就得认几个)。
565
+ * 读域更窄 = 一个你不认识的成员就让**整只**记录落进拒读臂,**连坐吞掉兄弟成员的合法证据** ——
566
+ * 同一张卡上本来读得到的 `orgRule` 会随着一个陌生的新成员一起消失。做法:**成员级开集**
567
+ * (不认识的成员原样留着、不渲染即可),别用闭集白名单去校验整只对象。 */
568
+ export interface ApprovalRuleEvidence {
569
+ orgRevision?: number;
570
+ orgRevisionAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
571
+ orgRule?: string;
572
+ orgRuleAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
573
+ personalRuleDots?: Array<{
574
+ actor: string;
575
+ counter: number;
576
+ }>;
577
+ personalRuleDotsAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
578
+ }
579
+ /** {@link ApprovalRequestFrame} 的**活面事实座**:卡外平铺在帧顶层的十一位(`APPROVAL_REQUEST_LIVE_FACT_KEYS`)。本接口是这十一位的**唯一声明处**(成员注即读法的权威说明);
580
+ * {@link ApprovalRequestFrame} `extends` 本型,呈卡帧自己的成员里没有这十一位。座上可选位不收显式 `undefined`。 */
581
+ export interface ApprovalRequestLiveFacts {
582
+ /** server ≥7.93.0(core 7.26.0):这张卡是**强制**出的(读站 / 规则面的 mandated ask:规则永远清不动它,
583
+ * 审批人的 yes 也放不掉拒表读)。只在为真时在场、严格字面 `true`;缺席 = 普通 ask。
584
+ * ⚠️ **订正(sdk 11.4.0)**:旧注写「耐久寄存行上无此孪生位」—— core 7.31.0 起 park 行上**有**孪生座
585
+ * (`PendingAction.tool_approval.mandated`),server 7.101.0 起它投上运维队列行 / `/stream` `pending` 帧 / inbox 行
586
+ * 与 `livePending` 行顶层(T4①)⇒ 四面同一位。`card_json` 卡面**不带**(`ApprovalCardSchema` `.strict()`)。 */
587
+ mandated?: true;
646
588
  /**
647
- * "tool_approval" only, ADDITIVE — 两段式在场性:**≤ server 7.4.0 恒缺席;≥ 7.5.0 起**在治理来源的 ask 上
648
- * 带 `true`([2942]/[2943])。唯一权威 = 实测帧,不是 server 版本号字符串。
649
- *
650
- * 语义:`true` ⇔ 这只 ask 的门来自**运维治理层**(部署侧的 `AUTONOMY` / `commandPolicy` /
651
- * `MANUAL_MODE_SHELL_GATE` / `SENSITIVE_WRITE_PATTERNS`),而不是模型默认门或本次请求的客户端表态。
652
- * 用途:呈「治理强制」徽标,回答「我都开了 `bypassPermissions` 为什么还在问」—— 这类门**客户端表态
653
- * 掀不掉**,壳应把它呈成不可绕过,而不是引导用户去改 `permissionMode`。
654
- *
655
- * 🔴 **缺席 ≠ `false`**(与 `risk` 两轴同族纪律):本键**只在为真时在场**。缺席的含义是「没有治理来源的
656
- * 证据」,它既覆盖真正的非治理 ask(例:部署把某工具写进 `APPROVAL_REQUIRE` 名单),也覆盖 server 侧
657
- * 判据够不着的形(例:治理层的 shell 门停在 `classify` 档时,一次 shell ask 出自分类器还是别的门无从
658
- * 分辨 —— server 选择让键缺席而不是猜)。所以缺席**不得**渲染成「这门可以用表态绕开」。
589
+ * ADDITIVE(server ≥7.102.0 / core 7.32.0)—— 强制位**站在哪一个词上**:
590
+ * {@link PersistedRuleMandate} 闭集之一(server `src/tool-approval.ts:841`,值经 `approval-card.ts` 的
591
+ * `readClosedWordSeat(req, "mandate")` 窄读 = core `isPersistedRuleMandate` 筛,集外词读作缺席 + 计一次 fail-open tag)。
592
+ * 只在 {@link mandated} 为真的**整因**是那一个词时在场 ⇒ 在场蕴含 `mandated:true`;反向不成立。
593
+ * 🔴 **缺席从不命名一个词,也不等于「不强制」**(读 {@link mandated})。echo-only。
594
+ * 四面同一个词:本帧 / `livePending` 行顶层(与本帧同一次读定)/ 运维队列行(`GET /v1/approvals` `pending[]` 与 `/stream`
595
+ * `pending` 帧,park 行孪生座)/ inbox 行(core `CheckpointSummary.mandate`)。🔴 `card_json` 卡面与**断连重放**的
596
+ * `approval_request` 帧**不带**(`ApprovalCardSchema` `.strict()` 无此位;live 的 `approval_request` 帧同样是那张卡)。
659
597
  */
660
- governanceForced?: true;
661
- /** ADDITIVE(server ≥7.116.0;**真才带,永不 `false`**):这张卡上「**本会话放行**」(live `allow_session` / durable `/decide` 的 `remember:"session"`)**不会被记住** ——
662
- * 决定照收、只放行**这一次**,回执 {@link ToolApprovalRespondApplied.rememberApplied} 恒 `false`(既有键,不是新键),同会话之后的同类卡仍出卡。
663
- * 壳读它决定渲不渲「本会话放行」,**别**再从 `requiresRealApproval` / `mandated` / `governanceForced` 自己推断。四个理由共用这一位:运维治理层的门 /
664
- * 必须真人逐次批 / 强制 / **应答还授予这一次调用之外的东西**(本版新增的第四个:引擎 `Skill` 卡上批准 = 激活技能 + 本 run 内它清单上的工具免问,
665
- * 卡上读不出那份授予,所以不记)。
666
- * 🔴 **缺席 = 这张卡上「本会话放行」记得住,**或**老 server(≤7.115.x 所有面结构性不带这个键)** —— 缺席**不**说「一定能记」,只是没有「不记」的声明。
667
- * 同一位出现在:live `tool_approval` 帧、`approval_request` 呈卡帧的 `card`(= `card_json`,含断连重放帧)、`GET /v1/approvals` 的 `livePending` 行与 `pending[]` 行
668
- * 及 `/v1/approvals/stream` 对应帧;**不**在 inbox 行(那一面不带 `toolName`)。
669
- * 🔴 **server ≥7.150.0:这一位读「这一问 + 这条腿」**(此前只问这一问本身记不记得住):没有会话的腿、读不出会话住客令牌的腿(会话店不带执行席,如引擎缺省的内存会话店)上,卡也带它 ——
670
- * 卡面与点 `allow_session` 的回执读同一只判官:**卡带本位 ⇔ 点 `allow_session` 回执 `rememberApplied: false`**(写失败 / 提交歧义是落定之后才知道的,仍只在回执上说)。
671
- * ≤7.149.x 上那两形腿的卡**不带**本位而点 `allow_session` 照样回执 `false` —— 所以那些版本上「缺席 = 记得住」对这两形不成立。 */
672
- rememberRefused?: true;
673
- /** "tool_approval" only, ADDITIVE(server ≥7.30.0 / core 5.37;#283)—— core 的 PreToolUse hook / 策略族铸的
674
- * **安全类 ask 出身位**(`AskRequest.requiresRealApproval` 逐字透传)。
675
- * 🔴 **真才带,缺席绝不编 `false`**(与 {@link governanceForced} 同形)。
676
- * 🔴 与卡上的 `ApprovalCard.risk.requiresRealApproval`(**恒在场布尔**)**两侧契约刻意不同,别混**:
677
- * 卡那一份是 durable 店形(askStore 在场)专属;**本键让 live-only 部署(店缺席、帧无卡)也读得到
678
- * 出身位** —— 安全类标记不得依赖店在场。
679
- * 消费语义:在场 ⇒ **一切自动放行让位**(含记住的规则与 `bypassPermissions` 姿态)。 */
680
- requiresRealApproval?: true;
681
- /** "tool_approval" only, ADDITIVE(server ≥7.57.0 / core 7.5.0;S-125③/#564)—— **谁提的这一问**:
598
+ mandate?: PersistedRuleMandate;
599
+ /** ADDITIVE(server ≥7.57.0 / core 7.5.0)—— **谁提的这一问**:
682
600
  * core 在门上盖章的词(见 {@link AskOrigin} / {@link ASK_ORIGINS} 十一词;server 逐字透传,**不自铸第二张资格表**)。
683
601
  * 按**开集**分支(词表属主是 core;本帧 server 只判非空串);缺席 = 老引擎 / 非 ask 路径。
684
602
  * server ≥7.102.0(S-755)起同一个词也在 `livePending` 行顶层与运维队列行上(inbox 行早就有)—— 五面逐字同值;
685
603
  * `card_json` 卡面 / `approval_request` 帧**不带**(卡 `.strict()`,既有)。
686
604
  * ⚠️ 与 {@link governanceForced} 分工见 {@link AskOrigin} 顶注 —— 两者顶替不了对方。 */
687
605
  origin?: AskOrigin;
688
- /** "tool_approval" only, ADDITIVE(**server ≥7.126.0** / core 7.49.0 #1414;契约 B 表 `approvalCard` 行)—— **这一问渲在哪张卡上**:引擎在闸站铸的那一个词(闭集 {@link ToolApprovalCardWord} 十二词;server 经 `readApprovalCard` 闭集窄读逐字过境,集外词读作缺席),
689
- * **唯一的卡词事实源** —— 取代 ≤7.125.x server 按工具名回推的 `contentKind`(7.126.0 删、零别名;读 `contentKind === "content_ask"` 的消费方改读 `approvalCard === "question"`)。
690
- * 🔴 **缺席 = 引擎没铸**(宿主自建的 ask / 老引擎 / 7.49.0 前停驻的存量行 / 非审批门),**不编 `generic`**;展示 / 分诊用,**永不参与 resume / gate / CAS**。
691
- * 同一个词也在 `livePending` 行顶层(= 帧上这一格)与运维队列行({@link import("../types.js").PendingCheckpoint.approvalCard})及 `/v1/approvals/stream` 的 `pending` / `live_pending` 帧上;**server ≥7.136.0 起 `approval_request` 帧的 `card` 与 `card_json` 卡面也带同一个词**({@link ApprovalCard.approvalCard};活铸帧 / 落库卡信封 / 断连重放帧三面同源 —— 此前重放帧上没有这一位,断线重连后壳退化成通用卡;≤7.135.x 的卡不带,重放帧上缺席读作「这一帧不带」)。
692
- * 到期:`question` 卡的停驻门作废,其余审批门进 SLA 拒扫(判官是引擎的 `facetOf(gate)`)。 */
693
- approvalCard?: ToolApprovalCardWord;
694
- /** "tool_approval" only, ADDITIVE(K-37 扩项;server ≥7.109.0 / S-934 ② / core 7.37.0 #1214)—— 这一问**属于哪一类**:{@link classes} 的首员
695
- * (core `ASK_CLASSES` 序;词表 = 门记录那一张 {@link import("../types.js").AskClass},不另起第二张)。引擎在每一个盖 `origin` 的站盖章,server 经
696
- * `approval-card.ts` 的 `readAskClassPair` **唯一窄读**(成员筛 = core `isAskClass`)逐字透传。
697
- * 🔴 **与 {@link classes} 同在同缺**,且 `classes[0] === askClass`:在场却读不出(半对 / 集外词 / 首员不符)⇒ server **两键都不投**(卡上少一行类
698
- * ≪ 卡上出现生词或半只对)。**缺席 = 老引擎(core < 7.37.0)/ 老行(续跑不补)/ 不盖类的站(共享制品读确认),不是「无类」**,也不是 `ordinary`。
699
- * display / 分诊元数据:壳按类渲卡、durable 审批席按类答;**不是**裁决输入(裁决在 core 的仲裁点)。
700
- * 同一对、同序的面:本帧 / `livePending[].frame` / `approval_request` 呈卡帧的 {@link ApprovalCard}(= `card_json` = 断连重放帧)/ 运维队列行
701
- * (`GET /v1/approvals` `pending[]` 与 `/stream` `pending` 帧,park 行孪生座);**inbox 行不带**(core `CheckpointSummary` 不回显),`livePending`
702
- * 行**顶层**也不带(只在它的 `frame` 里)。 */
703
- askClass?: AskClass;
704
- /** "tool_approval" only, ADDITIVE(K-37 扩项;server ≥7.109.0 / S-934 ②)—— 这一问属于的**全部**类(core `ASK_CLASSES` 序,非空,
705
- * `classes[0] === askClass`)。一问可同属几类 ⇒ **读整只集合**,别只读 {@link askClass}。与 `askClass` 同在同缺、同一只窄读;逐字同序过境
706
- * (server 不排序、不去重)。 */
707
- classes?: AskClass[];
708
- /** "tool_approval" only, ADDITIVE(server ≥7.118.0 / core 7.43.0 #1348 / #1357)—— 对引擎 `Skill` 工具的调用,批准它**还授予**的东西的摘要
606
+ /** ADDITIVE(server ≥7.118.0 / core 7.43.0)—— 对引擎 `Skill` 工具的调用,批准它**还授予**的东西的摘要
709
607
  * (技能名 + 两只清单规范拼写的哈希);别的卡缺席。与停驻行 / 收件箱行的同名位同值(引擎同一只工厂铸,活卡与它的停驻孪生按
710
608
  * `(toolCallId, boundGrantDigest)` 对账);逐字过境,不重算。**「本会话放行」按「工具 + 它」记**:只代答摘要相同的问(同技能同清单),
711
609
  * 换技能或清单变了 ⇒ 再问;没有它的 `Skill` 调用(老引擎 / 部署自己叫 `Skill` 的工具)照旧不记。耐久 `remember:"session"` 不记技能卡。 */
712
610
  boundGrantDigest?: string;
713
- /** "tool_approval" only, ADDITIVE(server ≥7.118.0)—— 上一位哈希的那一份值:`{ skill, allowedTools, disallowedTools }`(`skill: null` = 调用没点名任何已载技能)。
611
+ /** ADDITIVE(server ≥7.118.0)—— 上一位哈希的那一份值:`{ skill, allowedTools, disallowedTools }`(`skill: null` = 调用没点名任何已载技能)。
714
612
  * 与 {@link boundGrantDigest} 同在同缺。🔴 **部署文本**:渲染要按上下文转义。批这张卡 = 放行 `allowedTools`、本 run 拒 `disallowedTools`。 */
715
613
  boundGrants?: BoundSkillGrants;
716
- /** "tool_approval" only, ADDITIVE(server ≥7.129.0 / core 7.51.0 #1688)—— 这张卡**为什么没有** {@link boundGrantDigest}(两者恰一):
717
- * {@link BoundGrantAbsence}(`not_bindable` / `unreadable`;读法与「缺席不是 `not_bindable`」见那只型)。与 inbox 行 / 运维队列行同名同值;逐字过境。 */
718
- boundGrantAbsence?: BoundGrantAbsence;
719
- /** "tool_approval" only, ADDITIVE(server ≥7.118.0 / core 7.43.0 #1353)—— 只在类 `classifier_no_ruling` 的卡上:auto 模式的分类器**为什么没判**
614
+ /** ADDITIVE(server ≥7.118.0 / core 7.43.0)—— 只在类 `classifier_no_ruling` 的卡上:auto 模式的分类器**为什么没判**
720
615
  * ({@link AUTO_MODE_FALLBACK_CAUSES}:`error` / `timeout` = 它跑不了,`parse_error` = 答了却没有判词),所以交给人。server 用引擎的闭集筛,集外 ⇒ 缺席。
721
616
  * display:不是裁决输入。 */
722
617
  classifierNoRuling?: AutoModeFallbackCause;
723
- /** "tool_approval" only, ADDITIVE(server ≥7.45.0;E-14 Trojan Source 族)—— 这只 ask 的**工具输入**
724
- * (`args`)里含 **Unicode bidi 控制符**(LRM/RLM、嵌入/覆写、隔离符)。
725
- * 🔴 **披露位,不是清洗位;字节零改**。审批卡是唯一一处把模型写的命令交给**人眼**判断的面,而 bidi
726
- * 覆写让人眼读到的顺序与真正执行的字节顺序不同 —— 人批准的是 A、跑起来的是 B。清洗会改掉即将被执行的
727
- * 那串字节(卡上显示的与真跑的不是同一个东西),**比不披露更坏**;所以 server 只报「有」,**显形归壳**
728
- * (转义 / 高亮 / 加标记,壳自己定)。
729
- * 🔴 **真才带,缺席绝不编 `false`**:缺席同时覆盖「真的没有」与「args 序列化不了所以扫不了」,
730
- * **禁**读作「已确认干净」。
731
- * ⚠️ 判据素材 = 脱敏后 args 那**一次**序列化的结果,且在**字节帽判定之前**算 —— 所以
732
- * `argsOmitted:true`(卡上根本没有 args)的帧上本键**照样可能在场**,那正是人最看不见输入的一格。
733
- * 判据**不看** {@link message}(那是引擎/策略写的说明文本,不是待执行输入)。 */
734
- inputHasBidi?: true;
735
- /** "tool_approval" only, ADDITIVE(server ≥7.34.0;#288)—— **窗三键**,与 {@link ApprovalRequestFrame}
736
- * 的同名键同名同义,让**旧族帧**也能渲倒计时(此前只有新协议帧带窗,旧壳只能眼看卡停在那儿)。
737
- * · `expiresAtMs` —— 本 ask 的**绝对到期墙钟**(有店 = 行上一次铸定的值,与卡帧/落库同值;
738
- * 无店 = 注册时刻算定的同名初值);
739
- * · `serverNowMs` —— **帧铸造时刻**的服务器钟(倒计时锚 = 帧到手时刻,壳据它校本地时钟偏移);
740
- * · `expiresInMs` —— `max(0, expiresAtMs - serverNowMs)`,现算。
741
- * 🔴 **三键同生同缺**:发得出的帧恒带三个(windowZero 腿根本不发帧)。缺席 = server < 7.34.0。 */
742
- expiresAtMs?: number;
743
- /** 见 {@link expiresAtMs} —— 窗三键之一,`max(0, expiresAtMs - serverNowMs)`。 */
744
- expiresInMs?: number;
745
- /** 见 {@link expiresAtMs} —— 窗三键之一,帧铸造时刻的服务器钟。 */
746
- serverNowMs?: number;
747
- /**
748
- * "tool_approval" only(server ≥7.46.0;core 5.58.0 design/375。**BREAKING 换键** —— 整体取代 ≤7.45 的三元组键 `ruleSuggestions`,
749
- * 无 alias;那只旧键 sdk 26.0.0 随底线 7.52.0 删)—— 引擎为这次 ask 铸的「不再询问」选项,**判别联合** `single | batch`。
750
- *
751
- * 形、序、在场性契约、两臂兑付法与**下标语义随腿不同**的硬条款,逐字见 {@link RuleOffer} 顶注。
752
- *
753
- * 🔴 **在场即承诺**:只在挂了规则店的部署上出现;**缺席**只说「这张卡没有可兑的选项」(三种成因 wire 上不可分:没挂规则店 / 引擎没为这条命令铸出候选 / 命令字节读不出)——
754
- * 别据一次缺席诊断部署,也别自铸候选填空(手拼的规则文本被拒 `ruleRefusal: "rule_not_offered"`)。现成的单点窄读器 = `@sema-agent/client-core` 的 `readRuleOfferSupply`。
755
- *
756
- * ⚠️ **兑付射程**:唯一兑付通道是按本帧 `approvalId` 的 **live respond 腿**
757
- * (单副本进程内映射)。重放到另一副本 / 重启后那把 `approvalId` 是 404,人只能走 durable decide 腿,
758
- * 而**那条腿的体不带规则位**——别把一条重放出来的 offer 读成「它还兑得动」。
759
- */
760
- ruleOffers?: RuleOffer[];
761
- /** "tool_approval" only, ADDITIVE(server ≥7.55.0 / core #490 修②;S-15 第五单)—— {@link ruleOffers}
762
- * 的**缺席因由**:规则车道在场却无可给时,引擎点名哪扇门关了。闭四词集(server ≥7.129.0)与每一臂的壳指路义务逐字见
763
- * {@link RuleOffersAbsence};server 侧与 `card_json` 走**同一只窄读函数** ⇒ 帧与卡同值。
764
- * 🔴 引擎侧与 {@link ruleOffers} **互斥**;**缺席不是断言**;ADVISORY 展示元数据,永不是裁决输入。 */
765
- ruleOffersAbsence?: RuleOffersAbsence | (string & {});
766
- /** server ≥7.93.0(core 7.26.0 #997):这张卡是**强制**出的(读站 / 规则面的 mandated ask:规则永远清不动它,
767
- * 审批人的 yes 也放不掉拒表读)。只在为真时在场、严格字面 `true`;缺席 = 普通 ask。
768
- * ⚠️ **订正(sdk 11.4.0)**:旧注写「耐久寄存行上无此孪生位」—— core 7.31.0 #1079 起 park 行上**有**孪生座
769
- * (`PendingAction.tool_approval.mandated`),server 7.101.0 起它投上运维队列行 / `/stream` `pending` 帧 / inbox 行
770
- * (S-663 二段)与 `livePending` 行顶层(T4①)⇒ 四面同一位。`card_json` 卡面**不带**(`ApprovalCardSchema` `.strict()`)。 */
771
- mandated?: true;
772
- /**
773
- * "tool_approval" only, ADDITIVE(server ≥7.102.0 / S-721 / core 7.32.0 #1092)—— 强制位**站在哪一个词上**:
774
- * {@link PersistedRuleMandate} 闭集之一(server `src/tool-approval.ts:841`,值经 `approval-card.ts` 的
775
- * `readClosedWordSeat(req, "mandate")` 窄读 = core `isPersistedRuleMandate` 筛,集外词读作缺席 + 计一次 fail-open tag)。
776
- * 只在 {@link mandated} 为真的**整因**是那一个词时在场 ⇒ 在场蕴含 `mandated:true`;反向不成立。
777
- * 🔴 **缺席从不命名一个词,也不等于「不强制」**(读 {@link mandated})。echo-only。
778
- * 四面同一个词:本帧 / `livePending` 行顶层(与本帧同一次读定)/ 运维队列行(`GET /v1/approvals` `pending[]` 与 `/stream`
779
- * `pending` 帧,park 行孪生座)/ inbox 行(core `CheckpointSummary.mandate`)。🔴 `card_json` 卡面与**断连重放**的
780
- * `approval_request` 帧**不带**(`ApprovalCardSchema` `.strict()` 无此位;live 的 `approval_request` 帧同样是那张卡)。
781
- */
782
- mandate?: PersistedRuleMandate;
783
- /** "tool_approval" only, ADDITIVE(server ≥7.57.0 / core 7.4.0 #548;S-114)—— 这只 ask 是 auto 模式
784
- * 分类器的**限额回落卡**。形、四成员语义与「不得自铸第二只定时器」的硬条款逐字见
785
- * {@link DenialLimitFallback};与 {@link requiresRealApproval} 是同一次铸造盖的**孪生键**。
786
- * ⚠️ **耐久腿(park 行)今天不携本键**(core 的 `PendingAction` 上没有这一位);卡面那一份走
787
- * `card_json`,与 park 行的 `pendingAction` 是**两条腿**,别混。 */
788
- denialLimitFallback?: DenialLimitFallback;
789
- /**
790
- * "tool_approval" only, ADDITIVE (**server ≥7.117.0 / core 7.42.0 — BREAKING rename**, replacing the retired string `persistedRuleShadowed` of servers [7.13.0, 7.117.0); no alias —
791
- * sdk 26.0.0 deleted that key's declaration):
792
- * the allow-layer members that **matched this call and could NOT clear this ask** — one record `{ member, entries, omitted? }` per matching member (see
793
- * {@link AllowRuleShadow}). `member` ∈ `hook` / `deployment` / `persisted` / `skill` / `request` (see {@link ALLOW_RULE_MEMBERS}); `entries` = the entries that member
794
- * matched, as their source spells them (UNTRUSTED-for-display like {@link message}, secret-redacted, ≤512 chars each, ≤32 listed; a `hook` record's `entries` is
795
- * always the empty list); `omitted` = how many were not listed.
796
- *
797
- * The explaining sentence itself ("… matches this call but does not clear the ask — <reason>") is **in {@link message}** (the engine writes it where it
798
- * builds the card); this key is the structured twin of the same fact. Render a line from it ("your rule matched, but this call must be confirmed each time") —
799
- * WITHOUT it the only conclusion a user can draw is "my rule broke".
800
- *
801
- * 🔴 **ABSENT ≠ "you have no rule"**(缺席 ≠「你没有规则」): present only when a member matched AND could not clear the ask; a match that cleared never becomes an ask at all.
802
- * 🔴 **`member:"hook"` names the answering registration in `entries`** (server ≥7.132.0 / engine 7.52.0 mods): on this server only the request's own `settings.hooks`
803
- * (single-user lane) answers ⇒ `entries: ["settings.hooks"]`; the deployment seat's registrations are observers and never answer. On ≤7.131.x the `hook` record's `entries`
804
- * was always empty and could not say whose hook it was.
805
- * 🔴 **Deliberately SEPARATE from {@link governanceForced}** (that one answers "who imposed the gate", this one "what happened to YOUR rule"; not derivable from each other).
806
- * What the allow layer can NOT clear (hence what makes a matching record show up): any layer's deny / ask rule, operator `APPROVAL_REQUIRE` / `APPROVAL_NEVER_AUTO` /
807
- * `MANUAL_MODE_SHELL_GATE=always`, write protection, sensitive-path writes, governance, a hook's ask, plan-mode asks.
808
- * Same material on the live frame, the stored `card_json`, the replayed frame and the `approval_request` card ({@link ApprovalCard.allowRuleShadowed});
809
- * the durable dual is `gate.riskDescriptor.allowRuleShadowed` on the parked row (read via {@link import("../types.js").PendingCheckpoint.riskDescriptor}).
810
- * Rolling-upgrade caveat: a card written by a ≤7.116.x replica (`card_json` carrying `persistedRuleShadowed`) cannot be read by a ≥7.117.0 replica — the replay skips it.
811
- */
812
- allowRuleShadowed?: AllowRuleShadow[];
813
- /** "tool_approval" only (server ≥7.17.0 / core 5.33.0 #239, ADDITIVE): the STRUCTURED cause of a
814
- * reversibility-probe tightening — `{code, roots:{shown,total}, further?:{shown,total}}`. `code` is
815
- * machine-readable (open set, branch with a default arm); `shown` may be TRUNCATED by the server (≤8
816
- * entries) while `total` stays verbatim, so "N more unnamed" is always computable. Absent ≠ "no reason":
817
- * only maybe-tier tightenings whose probe supplied a cause carry it. Render as data — the server never
818
- * flattens it into a sentence, and neither should a consumer (the prose belongs to the card renderer).
819
- * (Typed here in 7.1.0 — the wire key itself has been live since server 7.17.0; older SDKs passed it
820
- * through the index signature untyped.) */
821
- probeCause?: {
822
- code: string;
823
- roots: {
824
- shown: string[];
825
- total: number;
826
- };
827
- further?: {
828
- shown: string[];
829
- total: number;
830
- };
831
- };
832
- /** "tool_approval" only(**server ≥7.115.0 / S-733**,ADDITIVE):这次 ask 被收紧时探针给的那一句**散文**因由(core `AskRequest.probeReason`,maybe 档收紧点;server 窄读:非串 / 空白 ⇒ 缺席、
833
- * 超 201 码点 ⇒ **整只丢不截**、内容族脱敏〔与耐久面 `gate.riskDescriptor.probeReason` 同一条规则 ⇒ 同一句话两面逐字节同值〕)。**与 {@link probeCause}(结构化因由)并列、不替代**:
834
- * 引擎自己铸的因由走结构位,**部署自写的探针**只会写这一句 —— 渲染读法:**优先渲 `probeCause` 的结构位,没有结构位时回落渲本键**;两者都缺 = 没有因由可渲(缺席 ≠「没有原因」)。
835
- * 🔴 **在场才带**(绝不编空串);🔴 **只在活卡帧上**:呈卡帧(`approval_request`)/ 耐久卡(`card_json`)**不带**它(`ApprovalCardSchema` 是严格信封,加键要另行裁定;
836
- * 耐久面的对偶是 park 行里的 `gate.riskDescriptor.probeReason`,经 `GET /v1/approvals` 的 `riskDescriptor` 透传)—— 所以按「呈卡帧 / 耐久卡」渲的壳读不到它,别据缺席断言「没有散文因由」。
837
- * 展示 / 分诊元数据,**永不是裁决输入**,永不进 `message`。 */
838
- probeReason?: string;
839
- /** "tool_approval" only(**server ≥7.138.0**,ADDITIVE):这一问的调用是**一张扩展注册自己发起**的(`$.tool.call`;core `AskRequest.requestedBy`)—— 卡上「扩展 X 想跑 …」那一行的出处,
840
- * 形见 {@link ExtensionRequester}(与 `tool_start` / `tool_end` 上的同名键同一只读法,注册名逐字节同)。模型消息带来的调用上缺席;部署座装了运维声明的包之后才会出现。
841
- * 展示事实,**不是裁决输入**。呈卡帧(`approval_request`)顶层同名同值(卡外的活面事实之一,见 {@link APPROVAL_REQUEST_LIVE_FACT_KEYS});耐久的卡(`card_json`)不带,断连重放帧上恒缺席。 */
842
- requestedBy?: ExtensionRequester;
843
- /** "tool_approval" only (server ≥7.23.0 / core 5.35.0 design/252 G-2, ADDITIVE): the RULE-PROVENANCE
844
- * evidence behind this ask — the org policy snapshot `orgRevision`, the matched org rule's verbatim text
845
- * `orgRule`, and the shadowed personal rule's add dots `personalRuleDots` (the rule's durable identity —
846
- * an ARRAY by construction; render/reconcile as data, never join into one scalar id). EACH member is a
847
- * value OR a NAMED absence (`…Absent`, five-word closed set below — read as open set, engine owns the
848
- * vocabulary): `"not_wired"` no such lane / `"not_adjudicated"` lane exists, call skipped /
849
- * `"unavailable"` the lane was consulted and its SOURCE could not be read (the one word meaning the
850
- * audit chain is BROKEN, not empty — the ask in hand is the fail-closed tighten that followed) /
851
- * `"no_match"` consulted, nothing spoke / `"not_reported"` the seam answered without the identity.
852
- * Display/reconciliation metadata, NEVER adjudication input; the server transcribes the ENGINE-stamped
853
- * record and never mints an absence word itself. Absent frame key = older server, or the narrow-read
854
- * dropped a malformed record — never "ungoverned".
855
- *
856
- * ── 消费指引①:**呈现谓词**(别写「在场即渲」)────────────────────────────────────────────────
857
- * 一只成员**占展示面**的条件是:**有值**,**或者**它的缺席词**不是良性白名单里的**。良性白名单 =
858
- * 「这条治理车道本来就没接 / 没轮到它说话」那类词(`not_wired` / `not_adjudicated`),它们在
859
- * **无治理部署上是常态**;而 `unavailable` 必须**恒可见**(它说的是**审计链断了** —— 车道被咨询了、
860
- * 源读不出来,手上这只 ask 正是随之而来的 fail-closed 收紧,这是用户唯一能看见「为什么突然要我批」
861
- * 的地方),未知词(引擎将来新铸的)同样**默认可见**(开集读纪律:不认识的词不许被当成良性静默)。
862
- * 🔴 为什么这条必须写死:**没有治理的部署上,每一只 ask 都会 stamp 三个具名缺席** —— 那是
863
- * **契约行为,不是缺陷**(引擎如实说「这三条车道我都问过/都没接」)。所以「成员在场就渲一行」的
864
- * 朴素写法会在最常见的部署上给每张审批卡糊上三行 "not wired",把真正要紧的那一行(`unavailable`)
865
- * 淹掉。判据是**词**,不是**在场**。
866
- *
867
- * ── 消费指引②:**窄读域纪律**(窄读只许 ≥ 铸点域)────────────────────────────────────────────
868
- * 服务端对这只对象走的是**整只拒读**语义:一条畸形记录被**整只丢掉**(不是逐成员挑好的留下)。
869
- * 所以消费方若也做窄读/白名单过滤,**读域只许 ≥ 铸点域**(铸点写了几个成员,窄读就得认几个)。
870
- * 读域更窄 = 一个你不认识的成员就让**整只**记录落进拒读臂,**连坐吞掉兄弟成员的合法证据** ——
871
- * 同一张卡上本来读得到的 `orgRule` 会随着一个陌生的新成员一起消失。做法:**成员级开集**
872
- * (不认识的成员原样留着、不渲染即可),别用闭集白名单去校验整只对象。 */
873
- ruleEvidence?: {
874
- orgRevision?: number;
875
- orgRevisionAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
876
- orgRule?: string;
877
- orgRuleAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
878
- personalRuleDots?: Array<{
879
- actor: string;
880
- counter: number;
881
- }>;
882
- personalRuleDotsAbsent?: "not_wired" | "not_adjudicated" | "unavailable" | "no_match" | "not_reported" | (string & {});
883
- };
884
- /** "tool_approval" only (server ≥ core 5.9.0 W1, [2535]): the ask's DELEGATION provenance chain —
885
- * `{parentToolCallId, depth, agentName?}` (the innermost grandchild frame wins). Present on the same door as
886
- * {@link fromSubagent} (child asks only). Read-only display enrichment (the approval card can show where the
887
- * ask floated up from); `agentName` is UNTRUSTED-for-display like {@link sourceAgentName}. ADDITIVE. */
888
- delegation?: {
889
- parentToolCallId: string;
890
- depth: number;
891
- agentName?: string;
892
- };
893
- /** **"tool_approval_complete" only**, ADDITIVE(server ≥7.42.0;#329)—— `outcome: "expired"` 一词三义
894
- * (park / 当场 deny / 无设施 deny,见 {@link outcome})里 **park 那一义的显式判别位**,**真才带**。
895
- * 在场 ⇔ **这条 ask 本身**按 park 路由收尾 ⇒ 壳把「卡失效」改渲「**已转后台候批**」。
896
- * 🔴 **缺席禁读作「真 deny」**:无店部署 / deny 政策 / 被连坐 VOID 的兄弟都发不出这个键,
897
- * 缺席只是「无 park 证据」。
898
- * ⚠️ 判据是**路由**不是墓碑:常态下同一把 `approvalId` 仍可打 `respond` 走迟到受理;两种容量拒新形下
899
- * live 迟到腿如实 404,壳按既有协议回落 durable decide 腿。 */
900
- parked?: true;
901
- /** "tool_approval_complete" only: how it settled (dialog dismiss reason). `expired` = TTL / abort / emit
902
- * failure. ⚠️ What the ENGINE got for an `expired` ask depends on whether the design/172 ask ledger is on
903
- * this deployment: with it (server ≥7.3.0 under `STREAM_APPROVAL_ENABLED`) the server's `expireAsk` CAS
904
- * re-adjudicates the outcome to `"unavailable"` ⇒ the run **PARKS**; without it the historical
905
- * `settle(false,"expired")` fail-closed DENY stands. The frame itself is cosmetic either way — never derive
906
- * the run's fate from it; read the run row / checkpoint face. */
907
- outcome?: "allowed" | "denied" | "expired";
908
- /** **"tool_approval_complete" only**,ADDITIVE(server ≥7.124.0)—— `outcome: "expired"` 的**成因**:审批席「结局成因」一张闭集里非人结局的十四词
909
- * (`ApprovalSettleCause`,{@link ApprovalSettleCause}),与审计账本 settle 行同一个词。🔴 **在场 ⇔ 非人结局**:人答的结局(`allowed` / `denied`)没有它(决议的出处看别处,不在这只帧上)。
910
- * 壳据它把 `outcome: "expired"` 渲成「已取消」「已到期」「断连」「承载腿退场」……而不再是一个词盖四件事。这是**唯一**能看到等待类四词
911
- * (`ttl_expired` / `broadcast_lost` / `stream_disconnected` / `undeliverable`,它们不落问账行)的 HTTP 面。
912
- * ⚠️ **缺席不是证据**:旧 server 从不发它;本键说的仍是这只帧的收场,run 的去向照旧读 run 行 / checkpoint 面(见 {@link outcome})。
913
- * 带系统成因的 `VOID` / `DENIED` 行被 CAS 输家读到时,同版起帧的 `outcome` 由 `denied` 变 `expired`,按本键分辨。 */
914
- cause?: ApprovalSettleCause;
915
- /** ADDITIVE(server [7.69.0, 7.72.0);core 7.10.0)—— **为什么这一问会到我手上**:分类器被咨询过但答不了。
916
- * 形与三条硬读法(开集 `cause` / 缺席不是断言 / switch 带 default)逐字见 {@link ClassifierUnavailable}。
917
- * ⚰️ **退役(server 7.72.0 / core 7.14.0,BREAKING 无别名)**:server 三腿自 7.72.0 起**恒不再铸它**;继任是 `tool_end.gate` / `permissionDenied.gate` 上的
918
- * `disposition.cause`(闭二词 `unavailable` / `parse_error`,答的是「这次 deny 是什么形」而非「为什么不可用」,旧 switch 搬不过去)。
919
- * 🔴 **为什么 26.0.0 帧上还声明它**:支持面 [7.52.0, ∞) 内 server 7.69–7.71 的帧仍发它,闭形 `InboxRow` 上的同名键具型 ⇒ 帧与行同读(同一个事实不一处具型、一处读 `unknown`)。
920
- * 退役条件:支持底线 ≥ 7.106.0 时随下一个 major 删(与 {@link ruleStoreUnreadable} 一并)。 */
921
- classifierUnavailable?: ClassifierUnavailable;
922
- /** ADDITIVE(server [7.72.0, 7.106.0);core 7.14.0)—— **规则车道读不通的是哪一半**。在场 ⇔ `origin ===
923
- * "rule_store_unavailable"`:`store` = 接上的规则店读不了(去看店与网络);`call` = 店读到了但**这条命令**按人的
924
- * deny/ask 行读不出来(去看命令写法)。一个 `origin` 词对这两件事同形,不投它人只能把两者都读成「我的规则坏了」,
925
- * 而两者的恢复动词一个在运维一个在提示词。帧与 inbox 行同投;`card_json` 卡刻意不带(它跟 `origin` 走,而
926
- * `origin` 本就不在卡上)。缺席 = `origin` 不是该词(不是「规则店没问题」的断言)。
927
- * ⚰️ **退役(server 7.106.0 / core 7.34.0,BREAKING — wire,无别名)**:server 两面自 7.106.0 起**恒不再铸它** —— 信号改走会话流的用户面
928
- * 通告 `engine_notice` **`permission.rule_store_unavailable`**(`detail.at` = `prepare` / `call`;规则读不出期间这条 run 怎么裁决,
929
- * 以该通告原文为准,见 `events.ts` engine_notice 臂)。`origin` 词表里的 `rule_store_unavailable` 仍在(不再带判别位)。
930
- * 🔴 **为什么 26.0.0 帧上还声明它**:支持面内 server 7.72–7.105 的帧仍发它,闭形 `InboxRow` 上的同名键具型 ⇒ 帧与行同读。
931
- * 退役条件:支持底线 ≥ 7.106.0 时随下一个 major 删(与 {@link classifierUnavailable} 一并)。 */
932
- ruleStoreUnreadable?: "store" | "call";
618
+ /** ADDITIVE(server ≥7.129.0 / core 7.51.0)—— 这张卡**为什么没有** {@link boundGrantDigest}(两者恰一):
619
+ * {@link BoundGrantAbsence}(`not_bindable` / `unreadable`;读法与「缺席不是 `not_bindable`」见那只型)。与 inbox 行 / 运维队列行同名同值;逐字过境。 */
620
+ boundGrantAbsence?: BoundGrantAbsence;
621
+ /** ADDITIVE(**server ≥7.126.0** / core 7.49.0;契约 B 表 `approvalCard` 行)—— **这一问渲在哪张卡上**:引擎在闸站铸的那一个词(闭集 {@link ToolApprovalCardWord} 十二词;server 经 `readApprovalCard` 闭集窄读逐字过境,集外词读作缺席),
622
+ * **唯一的卡词事实源** —— 取代 ≤7.125.x server 按工具名回推的 `contentKind`(7.126.0 删、零别名;读 `contentKind === "content_ask"` 的消费方改读 `approvalCard === "question"`)。
623
+ * 🔴 **缺席 = 引擎没铸**(宿主自建的 ask / 老引擎 / 7.49.0 前停驻的存量行 / 非审批门),**不编 `generic`**;展示 / 分诊用,**永不参与 resume / gate / CAS**。
624
+ * 同一个词也在 `livePending` 行顶层(= 帧上这一格)与运维队列行({@link import("../types.js").PendingCheckpoint.approvalCard})及 `/v1/approvals/stream` 的 `pending` / `live_pending` 帧上;**server ≥7.136.0 起 `approval_request` 帧的 `card` 与 `card_json` 卡面也带同一个词**({@link ApprovalCard.approvalCard};活铸帧 / 落库卡信封 / 断连重放帧三面同源 —— 此前重放帧上没有这一位,断线重连后壳退化成通用卡;≤7.135.x 的卡不带,重放帧上缺席读作「这一帧不带」)。
625
+ * 到期:`question` 卡的停驻门作废,其余审批门进 SLA 拒扫(判官是引擎的 `facetOf(gate)`)。 */
626
+ approvalCard?: ToolApprovalCardWord;
933
627
  /** ADDITIVE(server ≥**7.78.1**;core 7.19.0)—— 这只**根外读** ask 的**清障目录**:把 `dir` 加进本会话的
934
628
  * 读目录(壳侧既有的 `/add-dir` 口),同一条调用就不会再问。
935
629
  *
@@ -964,10 +658,20 @@ export interface ToolApprovalFrame {
964
658
  covers?: ReadRootCover;
965
659
  clearsThisAsk: true;
966
660
  };
967
- [k: string]: unknown;
661
+ /** **server ≥7.115.0**,ADDITIVE):这次 ask 被收紧时探针给的那一句**散文**因由(core `AskRequest.probeReason`,maybe 档收紧点;server 窄读:非串 / 空白 ⇒ 缺席、
662
+ * 超 201 码点 ⇒ **整只丢不截**、内容族脱敏〔与耐久面 `gate.riskDescriptor.probeReason` 同一条规则 ⇒ 同一句话两面逐字节同值〕)。**与 {@link probeCause}(结构化因由)并列、不替代**:
663
+ * 引擎自己铸的因由走结构位,**部署自写的探针**只会写这一句 —— 渲染读法:**优先渲 `probeCause` 的结构位,没有结构位时回落渲本键**;两者都缺 = 没有因由可渲(缺席 ≠「没有原因」)。
664
+ * 🔴 **在场才带**(绝不编空串);🔴 **只在活卡帧上**:呈卡帧(`approval_request`)/ 耐久卡(`card_json`)**不带**它(`ApprovalCardSchema` 是严格信封,加键要另行裁定;
665
+ * 耐久面的对偶是 park 行里的 `gate.riskDescriptor.probeReason`,经 `GET /v1/approvals` 的 `riskDescriptor` 透传)—— 所以按「呈卡帧 / 耐久卡」渲的壳读不到它,别据缺席断言「没有散文因由」。
666
+ * 展示 / 分诊元数据,**永不是裁决输入**,永不进 `message`。 */
667
+ probeReason?: string;
668
+ /** **server ≥7.138.0**,ADDITIVE):这一问的调用是**一张扩展注册自己发起**的(`$.tool.call`;core `AskRequest.requestedBy`)—— 卡上「扩展 X 想跑 …」那一行的出处,
669
+ * 形见 {@link ExtensionRequester}(与 `tool_start` / `tool_end` 上的同名键同一只读法,注册名逐字节同)。模型消息带来的调用上缺席;部署座装了运维声明的包之后才会出现。
670
+ * 展示事实,**不是裁决输入**。呈卡帧(`approval_request`)顶层同名同值(卡外的活面事实之一,见 {@link APPROVAL_REQUEST_LIVE_FACT_KEYS});耐久的卡(`card_json`)不带,断连重放帧上恒缺席。 */
671
+ requestedBy?: ExtensionRequester;
968
672
  }
969
- /** 回决二值(design/172 §3.2 / 车4 §3)。⚠️ **不是** {@link ToolApprovalDecision} 的三值集:
970
- * `allow_session`(本 session 记住)是**流内桥**语义,不在本端点(车4 §12-F/F27 记账)。 */
673
+ /** 回决二值。
674
+ * 旧的「本会话放行」手势不是第三个决议词,而是 `approve` 上的独立位 {@link AskDecisionBody.remember}(`"session"`)。 */
971
675
  export type ApprovalAskDecision = "approve" | "deny";
972
676
  /** 卡上的风险两轴(车3 §14.1;design/172 §3.1「irreversibility/egress」)。
973
677
  *
@@ -1018,47 +722,114 @@ export interface ApprovalCard {
1018
722
  toolCallId?: string;
1019
723
  /** 风险两轴 + 安全类标记(见 {@link ApprovalRiskAxes} 的三态说明)。 */
1020
724
  risk: ApprovalRiskAxes;
1021
- /** ADDITIVE,两段式在场性(**≤ server 7.4.0 恒缺席;≥ 7.5.0 起**在治理来源的 ask 上带 `true`):
1022
- * `true` ⇔ 这只 ask 的门来自运维治理层,客户端表态掀不掉。语义、**「缺席 ≠ false」** 的硬条款与
1023
- * 判据边界逐字见 {@link ToolApprovalFrame.governanceForced}。放在卡的顶层而不是 {@link risk} 里:
1024
- * `risk` 讲引擎对这次操作的风险判定,本键讲**门是谁下的**,两件事。 */
725
+ /**
726
+ * ADDITIVE — 两段式在场性:**≤ server 7.4.0 恒缺席;≥ 7.5.0 起**在治理来源的 ask 上
727
+ * 带 `true`。唯一权威 = 实测帧,不是 server 版本号字符串。
728
+ *
729
+ * 语义:`true` ⇔ 这只 ask 的门来自**运维治理层**(部署侧的 `AUTONOMY` / `commandPolicy` /
730
+ * `MANUAL_MODE_SHELL_GATE` / `SENSITIVE_WRITE_PATTERNS`),而不是模型默认门或本次请求的客户端表态。
731
+ * 用途:呈「治理强制」徽标,回答「我都开了 `bypassPermissions` 为什么还在问」—— 这类门**客户端表态
732
+ * 掀不掉**,壳应把它呈成不可绕过,而不是引导用户去改 `permissionMode`。
733
+ *
734
+ * 🔴 **缺席 ≠ `false`**(与 `risk` 两轴同族纪律):本键**只在为真时在场**。缺席的含义是「没有治理来源的
735
+ * 证据」,它既覆盖真正的非治理 ask(例:部署把某工具写进 `APPROVAL_REQUIRE` 名单),也覆盖 server 侧
736
+ * 判据够不着的形(例:治理层的 shell 门停在 `classify` 档时,一次 shell ask 出自分类器还是别的门无从
737
+ * 分辨 —— server 选择让键缺席而不是猜)。所以缺席**不得**渲染成「这门可以用表态绕开」。
738
+ */
1025
739
  governanceForced?: true;
1026
- /** ADDITIVE(server ≥7.116.0;真才带、永不 `false`;缺席 = 这张卡上「本会话放行」记得住 **或** 老 server):与 {@link ToolApprovalFrame.rememberRefused} **同一位同一件事**
1027
- * (帧 / `card_json` / 重放帧三面同一份素材)—— 决定照收、只放行这一次,回执 `rememberApplied` 恒 `false`。 */
740
+ /** ADDITIVE(server ≥7.116.0;**真才带,永不 `false`**):这张卡上「**本会话放行**」(决断口 `decideAsk` / durable `/decide` 的 `remember:"session"`;server ≤7.151.x 上是已删应答口的 `allow_session` 第三词)**不会被记住** ——
741
+ * 决定照收、只放行**这一次**,回执 {@link AskDecisionAck.rememberApplied} 恒 `false`(既有键,不是新键),同会话之后的同类卡仍出卡。
742
+ * 壳读它决定渲不渲「本会话放行」,**别**再从 `requiresRealApproval` / `mandated` / `governanceForced` 自己推断。四个理由共用这一位:运维治理层的门 /
743
+ * 必须真人逐次批 / 强制 / **应答还授予这一次调用之外的东西**(本版新增的第四个:引擎 `Skill` 卡上批准 = 激活技能 + 本 run 内它清单上的工具免问,
744
+ * 卡上读不出那份授予,所以不记)。
745
+ * 🔴 **缺席 = 这张卡上「本会话放行」记得住,**或**老 server(≤7.115.x 所有面结构性不带这个键)** —— 缺席**不**说「一定能记」,只是没有「不记」的声明。
746
+ * 同一位出现在:`approval_request` 呈卡帧的 `card`(= `card_json`,含断连重放帧)、`GET /v1/approvals` 的 `livePending` 行与 `pending[]` 行
747
+ * 及 `/v1/approvals/stream` 对应帧;**不**在 inbox 行(那一面不带 `toolName`)。
748
+ * 🔴 **server ≥7.150.0:这一位读「这一问 + 这条腿」**(此前只问这一问本身记不记得住):没有会话的腿、读不出会话住客令牌的腿(会话店不带执行席,如引擎缺省的内存会话店)上,卡也带它 ——
749
+ * 卡面与带 `remember:"session"` 的回执读同一只判官:**卡带本位 ⇔ 带 `remember:"session"` 的回执 `rememberApplied: false`**(写失败 / 提交歧义是落定之后才知道的,仍只在回执上说)。
750
+ * ≤7.149.x 上那两形腿的卡**不带**本位而点「本会话放行」照样回执 `false` —— 所以那些版本上「缺席 = 记得住」对这两形不成立。 */
1028
751
  rememberRefused?: true;
1029
- /** ADDITIVE(server ≥7.136.0;`ApprovalCardSchema` 新键 `approvalCard: z.enum(TOOL_APPROVAL_CARDS).optional()`)—— 引擎铸的**卡词**(闭集 {@link ToolApprovalCardWord} 十二词),与活卡帧顶层 {@link ToolApprovalFrame.approvalCard} **同一次读定、同一个词**:
752
+ /** ADDITIVE(server ≥7.136.0;`ApprovalCardSchema` 新键 `approvalCard: z.enum(TOOL_APPROVAL_CARDS).optional()`)—— 引擎铸的**卡词**(闭集 {@link ToolApprovalCardWord} 十二词),与活卡帧顶层 {@link ApprovalRequestLiveFacts.approvalCard} **同一次读定、同一个词**:
1030
753
  * 活铸 `approval_request` 帧的 `card`、落库的 `card_json` 卡信封、断连重放帧的 `card` 三面同源(此前卡词不进卡,重放帧只从卡信封回读 ⇒ 断线重连后壳退化成通用卡)。语义、缺席含义(**缺席 = 引擎没铸**〔宿主自建 ask / 老引擎 / 7.136.0 之前落下的行〕,**不编 `generic`**)与
1031
- * 「展示 / 分诊用,永不参与 resume / gate / CAS」逐字见 {@link ToolApprovalFrame.approvalCard}。集外词 / 非串:server 铸卡时再过同一只闭集窄读,**不进卡**(读作缺席)。
754
+ * 「展示 / 分诊用,永不参与 resume / gate / CAS」逐字见 {@link ApprovalRequestLiveFacts.approvalCard}。集外词 / 非串:server 铸卡时再过同一只闭集窄读,**不进卡**(读作缺席)。
1032
755
  * ⚠️ 卡信封是 `.strict()` 的耐久形:7.135.x 副本读不动带本键的新行(重放跳过、幂等重入走耐久停驻)—— 滚动升级窗的已知代价(整队一次滚完),不是本包能补的。 */
1033
756
  approvalCard?: ToolApprovalCardWord;
1034
- /** server ≥7.46.0(core 5.58.0 design/375,**BREAKING 换键**,取代 ≤7.45 的三元组键;那只旧键 sdk 26.0.0 删):引擎为这次 ask 铸的
1035
- * 「不再询问」选项,判别联合 `single | batch`。语义、序即契约、在场性即承诺、两臂兑付法与**下标语义
1036
- * 随腿不同**的硬条款,逐字见 {@link RuleOffer} 与 {@link ToolApprovalFrame.ruleOffers} ——
1037
- * live 帧 / `card_json` / 重放帧三面**同一份素材**(server 侧同一只 `copyRuleOffer` 投影)。 */
757
+ /**
758
+ * (server ≥7.46.0;core 5.58.0。**BREAKING 换键** —— 整体取代 ≤7.45 的三元组键 `ruleSuggestions`,
759
+ * 无 alias;那只旧键 sdk 26.0.0 随底线 7.52.0 删)—— 引擎为这次 ask 铸的「不再询问」选项,**判别联合** `single | batch`。
760
+ *
761
+ * 形、序、在场性契约、两臂兑付法与**下标语义随腿不同**的硬条款,逐字见 {@link RuleOffer} 顶注。
762
+ *
763
+ * 🔴 **在场即承诺**:只在挂了规则店的部署上出现;**缺席**只说「这张卡没有可兑的选项」(三种成因 wire 上不可分:没挂规则店 / 引擎没为这条命令铸出候选 / 命令字节读不出)——
764
+ * 别据一次缺席诊断部署,也别自铸候选填空(手拼的规则文本被拒 `ruleRefusal: "rule_not_offered"`)。现成的单点窄读器 = `@sema-agent/client-core` 的 `readRuleOfferSupply`。
765
+ *
766
+ * ⚠️ **兑付射程**(server ≥7.152.0):兑付通道是决断口 {@link ToolApprovalsResource.decideAsk} 的 `persistRule`(持久店上的 CAS,任何副本都收;窗口到期转停驻后同一口赎回,200 `accepted: "parked_redeemed"`);
767
+ * 耐久回决口 `/decide` 同样收 `persistRule`。**幂等回放不兑规则**:别把一条重放出来的 offer 读成「它还兑得动」。≤7.151.x 上兑付只有按本帧 `approvalId` 的应答口(单副本进程内映射;已随 7.152.0 删除),`/decide` 的体不带规则位。
768
+ */
1038
769
  ruleOffers?: RuleOffer[];
1039
- /** ADDITIVE(**server ≥7.117.0 / core 7.42.0,BREAKING 换名**,取代 [7.13.0, 7.117.0) 的串 `persistedRuleShadowed`;那只旧键 sdk 26.0.0 删):allow 层里命中了这次调用、却清不掉这只 ask 的成员,`{ member, entries, omitted? }[]`。
1040
- * 语义、五个 `member`、`hook` 成员的 `entries` 点名注册(≥7.132.0;此前恒空表)、卡上那句话**在 {@link message} 里**、**「缺席 ≠ 你没有规则」** 与同 {@link governanceForced} 的分列,逐字见 {@link ToolApprovalFrame.allowRuleShadowed} ——
1041
- * live 帧 / `card_json` / 重放帧 / `approval_request` 呈卡帧四面**同一份素材**(server 同一只窄读)。`card_json` 是严格信封:7.116.x 副本写下的、带旧键的卡新副本读不动(重放跳过)。 */
770
+ /**
771
+ * ADDITIVE (**server ≥7.117.0 / core 7.42.0 — BREAKING rename**, replacing the retired string `persistedRuleShadowed` of servers [7.13.0, 7.117.0); no alias —
772
+ * sdk 26.0.0 deleted that key's declaration):
773
+ * the allow-layer members that **matched this call and could NOT clear this ask** — one record `{ member, entries, omitted? }` per matching member (see
774
+ * {@link AllowRuleShadow}). `member` ∈ `hook` / `deployment` / `persisted` / `skill` / `request` (see {@link ALLOW_RULE_MEMBERS}); `entries` = the entries that member
775
+ * matched, as their source spells them (UNTRUSTED-for-display like {@link message}, secret-redacted, ≤512 chars each, ≤32 listed; a `hook` record's `entries` is
776
+ * always the empty list); `omitted` = how many were not listed.
777
+ *
778
+ * The explaining sentence itself ("… matches this call but does not clear the ask — <reason>") is **in {@link message}** (the engine writes it where it
779
+ * builds the card); this key is the structured twin of the same fact. Render a line from it ("your rule matched, but this call must be confirmed each time") —
780
+ * WITHOUT it the only conclusion a user can draw is "my rule broke".
781
+ *
782
+ * 🔴 **ABSENT ≠ "you have no rule"**(缺席 ≠「你没有规则」): present only when a member matched AND could not clear the ask; a match that cleared never becomes an ask at all.
783
+ * 🔴 **`member:"hook"` names the answering registration in `entries`** (server ≥7.132.0 / engine 7.52.0 mods): on this server only the request's own `settings.hooks`
784
+ * (single-user lane) answers ⇒ `entries: ["settings.hooks"]`; the deployment seat's registrations are observers and never answer. On ≤7.131.x the `hook` record's `entries`
785
+ * was always empty and could not say whose hook it was.
786
+ * 🔴 **Deliberately SEPARATE from {@link governanceForced}** (that one answers "who imposed the gate", this one "what happened to YOUR rule"; not derivable from each other).
787
+ * What the allow layer can NOT clear (hence what makes a matching record show up): any layer's deny / ask rule, operator `APPROVAL_REQUIRE` / `APPROVAL_NEVER_AUTO` /
788
+ * `MANUAL_MODE_SHELL_GATE=always`, write protection, sensitive-path writes, governance, a hook's ask, plan-mode asks.
789
+ * Same material on the live frame, the stored `card_json`, the replayed frame and the `approval_request` card ({@link ApprovalCard.allowRuleShadowed});
790
+ * the durable dual is `gate.riskDescriptor.allowRuleShadowed` on the parked row (read via {@link import("../types.js").PendingCheckpoint.riskDescriptor}).
791
+ * Rolling-upgrade caveat: a card written by a ≤7.116.x replica (`card_json` carrying `persistedRuleShadowed`) cannot be read by a ≥7.117.0 replica — the replay skips it.
792
+ */
1042
793
  allowRuleShadowed?: AllowRuleShadow[];
1043
794
  /** 在场 ⇔ 本 ask 来自**委派子代**(显式判别位,worker 不可伪造)。恒 `true` 或缺席。 */
1044
795
  fromSubagent?: true;
1045
- /** 子代的 core session id —— 行 join 值(server ≥7.143.0 换名,取代 `sourceTaskId`;同 {@link ToolApprovalFrame.sourceSessionId})。 */
796
+ /** (**server ≥7.143.0 / core 7.61.0,BREAKING 换名**,取代 ≤7.142.x 的 `sourceTaskId`;值不变、零别名,sdk 33.0.0 同删):
797
+ * present ⇔ the ask comes from a DELEGATED background/nested child (its permission card floats to the HOST run's live stream).
798
+ * Value = the child's core **session** id (same id domain as fleet `bg_notification.sessionId` — join it to the child's session row).
799
+ * 它名一只会话,不名任务:发起这一问的那条腿的 agent id 是 {@link agentId}。归属判别读 {@link fromSubagent}(显式判别位),不读本键在场。
800
+ * ≤7.142.x 的 server 发的是旧名 `sourceTaskId`,本包不再读它(支持面内的老 server 上本键读作缺席)。 */
1046
801
  sourceSessionId?: string;
1047
- /** 发起这一问的腿的 agent id(server ≥7.143.0;同 {@link ToolApprovalFrame.agentId})。 */
802
+ /** (server ≥7.143.0 / core 7.61.0,additive):发起这一问的**腿的 agent id** —— 后台子代是注册表行 id(`a…`,与它的行、`TaskStop`、`SendMessage`、
803
+ * 完成通知同一个串),前台子代是它的会话 id;直接起跑的 workflow 的 agent 带它而**不带** {@link fromSubagent};宿主自己的问缺席。与扩展事件的 `agentId` 同值(引擎同一只判据铸)。 */
1048
804
  agentId?: string;
1049
- /** 谁问的、为什么问(server ≥7.143.0;与帧同一份素材,同 {@link ToolApprovalFrame.askReasons})。 */
805
+ /** (server ≥7.143.0 / core 7.61.0,additive):**谁问的、为什么问** —— 一条一位问者 + 它自己的话({@link AskReason} 两臂:hook / 扩展的问带 `cause`,
806
+ * 策略链的问带 `words`)。结构化审批面按它渲理由行,不渲 {@link message}(`message` 照旧逐字给只读文本的消费方)。活卡帧、呈卡帧的卡、运维队列行三面同一只窄读(server `readAskReasons`):
807
+ * 问者的话已过凭据脱敏并截长;任一条形不合 ⇒ server **整座不投**(卡上少一行理由,不出现半条)。缺席 = 老引擎 / 老行 / 引擎自己铸的通用问句(不铸条目)。 */
1050
808
  askReasons?: AskReason[];
1051
809
  /** 子代 agent 展示名,已脱敏。UNTRUSTED。 */
1052
810
  sourceAgentName?: string;
1053
811
  /** 委派出处(仅子代 ask 在场)。 */
1054
812
  delegation?: ApprovalCardDelegation;
1055
- /** ADDITIVE(server ≥7.45.0 E-14;A-057.④ 补公示——server 早随卡投出,帧卡同窄读函数同值):
1056
- * **待执行输入**(脱敏 args,字节帽判定**之前**算)含 Unicode bidi 覆写字符——人眼读到的顺序可能不是
1057
- * 真正执行的字节顺序。披露位、字节零改;显形(转义/高亮)归渲染面。恒 `true` 或缺席;
1058
- * **缺席 ≠ 已确认干净**(未检出 / 序列化失败 / 老 server)。语义逐字见 {@link ToolApprovalFrame.inputHasBidi}。 */
813
+ /** ADDITIVE(server ≥7.45.0;E-14 Trojan Source 族)—— 这只 ask 的**工具输入**
814
+ * (`args`)里含 **Unicode bidi 控制符**(LRM/RLM、嵌入/覆写、隔离符)。
815
+ * 🔴 **披露位,不是清洗位;字节零改**。审批卡是唯一一处把模型写的命令交给**人眼**判断的面,而 bidi
816
+ * 覆写让人眼读到的顺序与真正执行的字节顺序不同 —— 人批准的是 A、跑起来的是 B。清洗会改掉即将被执行的
817
+ * 那串字节(卡上显示的与真跑的不是同一个东西),**比不披露更坏**;所以 server 只报「有」,**显形归壳**
818
+ * (转义 / 高亮 / 加标记,壳自己定)。
819
+ * 🔴 **真才带,缺席绝不编 `false`**:缺席同时覆盖「真的没有」与「args 序列化不了所以扫不了」,
820
+ * **禁**读作「已确认干净」。
821
+ * ⚠️ 判据素材 = 脱敏后 args 那**一次**序列化的结果,且在**字节帽判定之前**算 —— 所以
822
+ * `argsOmitted:true`(卡上根本没有 args)的帧上本键**照样可能在场**,那正是人最看不见输入的一格。
823
+ * 判据**不看** {@link message}(那是引擎/策略写的说明文本,不是待执行输入)。 */
1059
824
  inputHasBidi?: true;
1060
- /** ADDITIVE(server ≥7.17.0;A-057.④ 补公示):可回滚性探针收紧的**结构化**因由——形状与语义逐字见
1061
- * {@link ToolApprovalFrame.probeCause}(帧与卡同一份素材)。 */
825
+ /** (server ≥7.17.0 / core 5.33.0, ADDITIVE): the STRUCTURED cause of a
826
+ * reversibility-probe tightening — `{code, roots:{shown,total}, further?:{shown,total}}`. `code` is
827
+ * machine-readable (open set, branch with a default arm); `shown` may be TRUNCATED by the server (≤8
828
+ * entries) while `total` stays verbatim, so "N more unnamed" is always computable. Absent ≠ "no reason":
829
+ * only maybe-tier tightenings whose probe supplied a cause carry it. Render as data — the server never
830
+ * flattens it into a sentence, and neither should a consumer (the prose belongs to the card renderer).
831
+ * (Typed here in 7.1.0 — the wire key itself has been live since server 7.17.0; older SDKs passed it
832
+ * through the index signature untyped.) */
1062
833
  probeCause?: {
1063
834
  code: string;
1064
835
  roots: {
@@ -1070,32 +841,71 @@ export interface ApprovalCard {
1070
841
  total: number;
1071
842
  };
1072
843
  };
1073
- /** ADDITIVE(server ≥7.23.0;A-057.④ 补公示):规则出处证据——每员=值或具名缺席词;展示/对账元数据,
1074
- * 永不是裁决输入。形状与语义逐字见 {@link ToolApprovalFrame.ruleEvidence}(帧与卡同一份素材)。 */
1075
- ruleEvidence?: NonNullable<ToolApprovalFrame["ruleEvidence"]>;
1076
- /** ADDITIVE(server ≥7.55.0;S-139 补公示 —— server 早随卡投出,帧与卡走**同一只窄读函数**同值):
1077
- * {@link ApprovalCard.ruleOffers} 的**缺席因由**。语义、闭四词集(server ≥7.129.0)与每一臂的壳指路义务逐字见
1078
- * {@link RuleOffersAbsence} / {@link ToolApprovalFrame.ruleOffersAbsence}。 */
844
+ /** (server ≥7.23.0 / core 5.35.0, ADDITIVE): the RULE-PROVENANCE
845
+ * evidence behind this ask — the org policy snapshot `orgRevision`, the matched org rule's verbatim text
846
+ * `orgRule`, and the shadowed personal rule's add dots `personalRuleDots` (the rule's durable identity —
847
+ * an ARRAY by construction; render/reconcile as data, never join into one scalar id). EACH member is a
848
+ * value OR a NAMED absence (`…Absent`, five-word closed set below — read as open set, engine owns the
849
+ * vocabulary): `"not_wired"` no such lane / `"not_adjudicated"` lane exists, call skipped /
850
+ * `"unavailable"` the lane was consulted and its SOURCE could not be read (the one word meaning the
851
+ * audit chain is BROKEN, not empty — the ask in hand is the fail-closed tighten that followed) /
852
+ * `"no_match"` consulted, nothing spoke / `"not_reported"` the seam answered without the identity.
853
+ * Display/reconciliation metadata, NEVER adjudication input; the server transcribes the ENGINE-stamped
854
+ * record and never mints an absence word itself. Absent frame key = older server, or the narrow-read
855
+ * dropped a malformed record — never "ungoverned".
856
+ *
857
+ * ── 消费指引①:**呈现谓词**(别写「在场即渲」)────────────────────────────────────────────────
858
+ * 一只成员**占展示面**的条件是:**有值**,**或者**它的缺席词**不是良性白名单里的**。良性白名单 =
859
+ * 「这条治理车道本来就没接 / 没轮到它说话」那类词(`not_wired` / `not_adjudicated`),它们在
860
+ * **无治理部署上是常态**;而 `unavailable` 必须**恒可见**(它说的是**审计链断了** —— 车道被咨询了、
861
+ * 源读不出来,手上这只 ask 正是随之而来的 fail-closed 收紧,这是用户唯一能看见「为什么突然要我批」
862
+ * 的地方),未知词(引擎将来新铸的)同样**默认可见**(开集读纪律:不认识的词不许被当成良性静默)。
863
+ * 🔴 为什么这条必须写死:**没有治理的部署上,每一只 ask 都会 stamp 三个具名缺席** —— 那是
864
+ * **契约行为,不是缺陷**(引擎如实说「这三条车道我都问过/都没接」)。所以「成员在场就渲一行」的
865
+ * 朴素写法会在最常见的部署上给每张审批卡糊上三行 "not wired",把真正要紧的那一行(`unavailable`)
866
+ * 淹掉。判据是**词**,不是**在场**。
867
+ *
868
+ * ── 消费指引②:**窄读域纪律**(窄读只许 ≥ 铸点域)────────────────────────────────────────────
869
+ * 服务端对这只对象走的是**整只拒读**语义:一条畸形记录被**整只丢掉**(不是逐成员挑好的留下)。
870
+ * 所以消费方若也做窄读/白名单过滤,**读域只许 ≥ 铸点域**(铸点写了几个成员,窄读就得认几个)。
871
+ * 读域更窄 = 一个你不认识的成员就让**整只**记录落进拒读臂,**连坐吞掉兄弟成员的合法证据** ——
872
+ * 同一张卡上本来读得到的 `orgRule` 会随着一个陌生的新成员一起消失。做法:**成员级开集**
873
+ * (不认识的成员原样留着、不渲染即可),别用闭集白名单去校验整只对象。 */
874
+ ruleEvidence?: ApprovalRuleEvidence;
875
+ /** ADDITIVE(server ≥7.55.0)—— {@link ruleOffers}
876
+ * 的**缺席因由**:规则车道在场却无可给时,引擎点名哪扇门关了。闭四词集(server ≥7.129.0)与每一臂的壳指路义务逐字见
877
+ * {@link RuleOffersAbsence};server 侧与 `card_json` 走**同一只窄读函数** ⇒ 帧与卡同值。
878
+ * 🔴 引擎侧与 {@link ruleOffers} **互斥**;**缺席不是断言**;ADVISORY 展示元数据,永不是裁决输入。 */
1079
879
  ruleOffersAbsence?: RuleOffersAbsence | (string & {});
1080
- /** ADDITIVE(server ≥7.57.0;S-139 补公示,帧卡同窄读函数同值):auto 分类器的**限额回落卡**标记。
1081
- * 形与硬条款逐字见 {@link DenialLimitFallback} / {@link ToolApprovalFrame.denialLimitFallback}。 */
880
+ /** ADDITIVE(server ≥7.57.0 / core 7.4.0)—— 这只 ask 是 auto 模式
881
+ * 分类器的**限额回落卡**。形、四成员语义与「不得自铸第二只定时器」的硬条款逐字见
882
+ * {@link DenialLimitFallback};与 {@link requiresRealApproval} 是同一次铸造盖的**孪生键**。
883
+ * ⚠️ **耐久腿(park 行)今天不携本键**(core 的 `PendingAction` 上没有这一位);卡面那一份走
884
+ * `card_json`,与 park 行的 `pendingAction` 是**两条腿**,别混。 */
1082
885
  denialLimitFallback?: DenialLimitFallback;
1083
- /** ADDITIVE(K-37 扩项;server ≥7.109.0 / S-934 ②,`ApprovalCardSchema` 新两键 + 配对规则):这一问的**类** —— 与活卡帧**同一份素材**(发帧点
1084
- * 经 `readAskClassPair` 窄读定)⇒ live 帧 / `approval_request` / `card_json` / 断连重放帧四面同值。语义、两键同在同缺、`classes[0] === askClass`
1085
- * 与「缺席 ≠ 无类」逐字见 {@link ToolApprovalFrame.askClass}。
1086
- * ⚠️ server 的卡 schema 自 7.109.0 起在落库 / 重放读腿上**拒半对、拒首员不符**;≤7.108.0 副本读不动带这两键的新卡行(`.strict()` ⇒ 重放跳过、
1087
- * 幂等重入走 park —— 滚动升级窗的已知代价,server MIGRATION 7.109.0 登记,不是本包能补的)。 */
886
+ /** ADDITIVE(server ≥7.109.0 / core 7.37.0)—— 这一问**属于哪一类**:{@link classes} 的首员
887
+ * (core `ASK_CLASSES` 序;词表 = 门记录那一张 {@link import("../types.js").AskClass},不另起第二张)。引擎在每一个盖 `origin` 的站盖章,server 经
888
+ * `approval-card.ts` 的 `readAskClassPair` **唯一窄读**(成员筛 = core `isAskClass`)逐字透传。
889
+ * 🔴 **与 {@link classes} 同在同缺**,且 `classes[0] === askClass`:在场却读不出(半对 / 集外词 / 首员不符)⇒ server **两键都不投**(卡上少一行类
890
+ * ≪ 卡上出现生词或半只对)。**缺席 = 老引擎(core < 7.37.0)/ 老行(续跑不补)/ 不盖类的站(共享制品读确认),不是「无类」**,也不是 `ordinary`。
891
+ * display / 分诊元数据:壳按类渲卡、durable 审批席按类答;**不是**裁决输入(裁决在 core 的仲裁点)。
892
+ * 同一对、同序的面:本帧 / `livePending[].frame` / `approval_request` 呈卡帧的 {@link ApprovalCard}(= `card_json` = 断连重放帧)/ 运维队列行
893
+ * (`GET /v1/approvals` `pending[]` 与 `/stream` `pending` 帧,park 行孪生座);**inbox 行不带**(core `CheckpointSummary` 不回显),`livePending`
894
+ * 行**顶层**也不带(只在它的 `frame` 里)。 */
1088
895
  askClass?: AskClass;
1089
- /** ADDITIVE(K-37 扩项;server ≥7.109.0):这一问属于的全部类(非空,首员 = {@link askClass});见 {@link ToolApprovalFrame.classes}。 */
896
+ /** ADDITIVE(server ≥7.109.0)—— 这一问属于的**全部**类(core `ASK_CLASSES` 序,非空,
897
+ * `classes[0] === askClass`)。一问可同属几类 ⇒ **读整只集合**,别只读 {@link askClass}。与 `askClass` 同在同缺、同一只窄读;逐字同序过境
898
+ * (server 不排序、不去重)。 */
1090
899
  classes?: AskClass[];
1091
- /** (server [7.69.0, 7.72.0) 铸;core 7.10.0 #616)分类器答不了的因由 —— 形与三条硬读法见 {@link ClassifierUnavailable}。
900
+ /** ADDITIVE(server [7.69.0, 7.72.0);core 7.10.0)—— **为什么这一问会到我手上**:分类器被咨询过但答不了。
901
+ * 形与三条硬读法(开集 `cause` / 缺席不是断言 / switch 带 default)逐字见 {@link ClassifierUnavailable}。
1092
902
  * ⚰️ **退役(server 7.72.0 / core 7.14.0,BREAKING 无别名)**:server 三腿自 7.72.0 起**恒不再铸它**;继任是 `tool_end.gate` / `permissionDenied.gate` 上的
1093
903
  * `disposition.cause`(闭二词 `unavailable` / `parse_error`,答的是「这次 deny 是什么形」而非「为什么不可用」,旧 switch 搬不过去)。
1094
- * 🔴 **为什么卡上还声明它**(帧上的同名键另有退役窗口,见 {@link ToolApprovalFrame.classifierUnavailable}):钉版 server(7.134.0)的卡 schema(`ApprovalCardSchema`)**仍收这一位** —— 7.69–7.71 写下、仍待决的
1095
- * `card_json` 存行原样回放到 `approval_request.card` / 重放帧上。本包的开形面以钉版 server 的那张面为准:它还声明,本包就声明;它删了,本包同版删。 */
904
+ * 🔴 **为什么 26.0.0 帧上还声明它**:支持面 [7.52.0, ∞) 内 server 7.69–7.71 的帧仍发它,闭形 `InboxRow` 上的同名键具型 ⇒ 帧与行同读(同一个事实不一处具型、一处读 `unknown`)。
905
+ * 退役条件:支持底线 ≥ 7.106.0 时随下一个 major 删(与 {@link ruleStoreUnreadable} 一并)。 */
1096
906
  classifierUnavailable?: ClassifierUnavailable;
1097
907
  }
1098
- /** 同源锚对账面(照 {@link TOOL_APPROVAL_FRAME_KEYS} 先例):`ApprovalRequestFrame` 的**字段名清单**,
908
+ /** 同源锚对账面(照 {@link APPROVAL_REQUEST_LIVE_FACT_KEYS} 先例):`ApprovalRequestFrame` 的**字段名清单**,
1099
909
  * 给下游值拷贝(client-core / web 各自持同名闭集 copy)做机器对账用。
1100
910
  * **新增帧字段必须同步进本清单**(有测试钉)。 */
1101
911
  export declare const APPROVAL_REQUEST_FRAME_KEYS: readonly ["type", "schemaVersion", "askId", "taskId", "kind", "card", "expiresInMs", "expiresAtMs", "serverNowMs", "approvalId", "mandated", "mandate", "origin", "boundGrantDigest", "boundGrants", "classifierNoRuling", "boundGrantAbsence", "approvalCard", "readRootCandidate", "probeReason", "requestedBy", "liveFactsUnknown"];
@@ -1103,7 +913,7 @@ export declare const APPROVAL_REQUEST_FRAME_KEYS: readonly ["type", "schemaVersi
1103
913
  * 呈卡帧顶层**卡外活面事实座**的键名表(server ≥7.133.0;server `APPROVAL_REQUEST_LIVE_FACT_KEYS`,同名同序)。一问一帧族之后,呈卡腿的开卡帧是这只 ask 的**全部**开卡事实:
1104
914
  * 耐久的那张卡在 `card` 里,卡外那十一位(强制位 / 强制词 / 出身 / 技能授予摘要与值 / 分类器未裁 / 授予缺席 / 引擎卡词〔≥7.136.0 另在卡上有同值的一份,见下〕/ 读根候选 / 探测原因 / 扩展发起者〔server ≥7.138.0,
1105
915
  * {@link ExtensionRequester};7.133.0–7.137.x 是前十位〕)在帧顶层 ——
1106
- * 与旧族活卡帧 {@link ToolApprovalFrame} 上同名键**同一份素材**(型就是它的 `Pick`,不手抄第二份)。
916
+ * 型声明在 {@link ApprovalRequestLiveFacts}(这十一位的唯一声明处,成员注即读法的权威说明)。
1107
917
  * 🔴 **断连重放帧与活铸帧同事实(server ≥7.143.0)**:问行的卡信封(SQL `approval_ask.card_json` / local 问账的同一份信封)多一座活面事实,与活铸帧同一次写落下;断连重放帧(`buildReplayFrame`)
1108
918
  * 经与活铸帧同一只构造,顶层带**与活铸帧逐字同**的这一组位。本版之前铸的行(信封里没有那一座)或那一座读不出 ⇒ 重放帧顶层十一位一位不带,另带 {@link ApprovalRequestFrame.liveFactsUnknown}`: true`
1109
919
  * (「不知道」,不是「没有」)。≤7.142.x 的 server 上重放帧顶层十一位恒全缺、也不带 `liveFactsUnknown` —— 那一代把「不带」和「没有」读成同一形。
@@ -1112,23 +922,19 @@ export declare const APPROVAL_REQUEST_FRAME_KEYS: readonly ["type", "schemaVersi
1112
922
  * **读法**:渲染卡词的壳读 **`card.approvalCard`**(活铸帧与重放帧上都有;≤7.135.x 的卡不带,读作缺席)—— 对 ≤7.142.x 的 server,只读帧顶层的壳在断线重连后会落回通用卡。
1113
923
  */
1114
924
  export declare const APPROVAL_REQUEST_LIVE_FACT_KEYS: readonly ["mandated", "mandate", "origin", "boundGrantDigest", "boundGrants", "classifierNoRuling", "boundGrantAbsence", "approvalCard", "readRootCandidate", "probeReason", "requestedBy"];
1115
- /** 呈卡帧活面事实座的类型面 = 旧族活卡帧同名座的 `Pick`。{@link ApprovalRequestFrame} `extends` 本型 —— 十一位只在这里声明一次(测试钉:键清单 ≡ `keyof` 本型,呈卡帧自己的成员里没有这十一位,
1116
- * 十一位各是旧族帧与 spec 的具名成员,座上可选位不收显式 `undefined`)。 */
1117
- export type ApprovalRequestLiveFacts = Pick<ToolApprovalFrame, (typeof APPROVAL_REQUEST_LIVE_FACT_KEYS)[number]>;
1118
925
  /** {@link ApprovalCard} 的字段名清单(同上,卡是嵌套结构,单独一份)。 */
1119
926
  export declare const APPROVAL_CARD_KEYS: readonly ["toolName", "message", "args", "argsOmitted", "toolCallId", "risk", "governanceForced", "rememberRefused", "ruleOffers", "allowRuleShadowed", "fromSubagent", "sourceSessionId", "agentId", "askReasons", "sourceAgentName", "delegation", "inputHasBidi", "probeCause", "ruleEvidence", "ruleOffersAbsence", "denialLimitFallback", "classifierUnavailable", "askClass", "classes", "approvalCard"];
1120
927
  /**
1121
- * 审批开卡帧的**帧族词表**(闭集;server `APPROVAL_FRAME_FAMILIES` 逐词同序,`dist/tool-approval.d.ts`)—— wire 上一只 ask 的开卡帧可能属于的族:
1122
- * · `tool_approval` —— 旧族(活卡帧 `tool_approval` / 消卡帧 `tool_approval_complete`);
928
+ * 审批开卡帧的**帧族词表**(闭集;server `APPROVAL_FRAME_FAMILIES`,`dist/tool-approval.d.ts`)—— 只有一词(server ≥7.152.0):
1123
929
  * · `approval_request` —— 呈卡族(开卡帧 `approval_request` / 消卡帧 `approval_complete` / 批级撤卡帧 `approval_revoke`)。
1124
- * **两处读同一只词表**(一个事实一处声明):能力位 {@link import("../types.js").Capabilities.approvalFrameFamilies}(这台 worker 呈卡用哪一族)与请求键
1125
- * {@link import("../settings.js").SemaSettings.approvalFrameFamilies}(server ≥7.134.0:这条 run 的客户端**渲染得了**哪些族)。加族 = server 下一版 + 本常量同批加(同源锚当场红)。
930
+ * **两处读同一只词表**(一个事实一处声明):能力位 {@link import("../types.js").Capabilities.approvalFrameFamilies}(`["approval_request"]` ⇔ 这台 worker 呈卡;`[]` = 没有审批卡)与请求键
931
+ * {@link import("../settings.js").SemaSettings.approvalFrameFamilies}(这条 run 的客户端**渲染得了**哪些族;请求里写了词表外的词 ⇒ `400 request.field_invalid`,`bad_entry`)。
1126
932
  */
1127
- export declare const APPROVAL_FRAME_FAMILIES: readonly ["tool_approval", "approval_request"];
933
+ export declare const APPROVAL_FRAME_FAMILIES: readonly ["approval_request"];
1128
934
  /** {@link APPROVAL_FRAME_FAMILIES} 的成员型。 */
1129
935
  export type ApprovalFrameFamily = (typeof APPROVAL_FRAME_FAMILIES)[number];
1130
936
  /** 流内审批呈卡帧(SSE,`type` 即事件名;design/172 §3.1 + 车3 §4.1)。**两腿两形**:live 腿上它与
1131
- * `tool_approval`/`question`/`elicitation` 同一条 out-of-band 通道、在 token 流上交织,**不是**
937
+ * `question`/`elicitation` 同一条 out-of-band 通道、在 token 流上交织,**不是**
1132
938
  * `AgentEvent` 臂(按 SSE `event:` 名分派);durable 腿上 server 会 append 它,于是同一帧在
1133
939
  * `runs.events()` 的重放里出现,**并且是**
1134
940
  * {@link import("../events.js").AgentEvent} 的 `approval_request` 臂(#185a,载荷逐字即本类型)。
@@ -1170,8 +976,8 @@ export interface ApprovalRequestFrame extends ApprovalRequestLiveFacts {
1170
976
  expiresAtMs: number;
1171
977
  /** 铸帧时刻的 server 时钟(壳用它与本地时钟校偏)。 */
1172
978
  serverNowMs: number;
1173
- /** `POST /v1/tool-approvals/{id}/respond` 与 `GET /v1/tool-approvals/{id}` 的 id —— **server ≥7.133.0 恒等于 {@link askId}**(行的键就是这只 ask 唯一的 wire 身份,64 位十六进制串;
1174
- * 本族的消卡帧 {@link ApprovalCompleteFrame} 同带它)。当**不透明串**用,别按 uuid 解析。≤7.132.x 上它是与并行 `tool_approval` 帧同值的 uuid(旧帧桥 / 去重键)。 */
979
+ /** **server ≥7.133.0 恒等于 {@link askId}**(行的键就是这只 ask 唯一的 wire 身份,64 位十六进制串;
980
+ * 本族的消卡帧 {@link ApprovalCompleteFrame} 同带它)。当**不透明串**用,别按 uuid 解析。(帧上的 `approvalId` 键仍在 wire 上;它与 `askId` 同值,读 `askId`。) */
1175
981
  approvalId: string;
1176
982
  /** **只在断连重放帧上**(server ≥7.143.0):这一行是本版之前铸的,或卡信封里的活面事实座读不出 ⇒ 顶层十一位活面事实({@link APPROVAL_REQUEST_LIVE_FACT_KEYS})一位不带,带本键说「不知道」。
1177
983
  * 恒 `true` 或缺席;缺席 = 这一帧的活面事实是逐字的(活铸帧,或信封带座的重放帧)。读法:带本键的帧按「事实未知」渲 —— 别把缺席的 `mandated` 读成「不强制」;
@@ -1184,11 +990,10 @@ export declare const APPROVAL_COMPLETE_FRAME_KEYS: readonly ["type", "schemaVers
1184
990
  /**
1185
991
  * 呈卡族的**单卡消卡帧**(`approval_complete`;server ≥7.133.0)—— 一只 ask 落定时发给每一条**收到过它的呈卡帧**的呈卡腿连接(SSE,`type` 即事件名;durable 腿同帧落账本、重放里也出现)。
1186
992
  *
1187
- * 🔴 **一条腿一个帧族**:呈卡协议在一条腿上场(`capabilities.approvalFrameFamilies` = `["approval_request"]`)⇒ 这条腿上一只 ask 的开卡 / 消卡 / 撤卡只走
1188
- * `approval_request` / 本帧 / {@link ApprovalRevokeFrame},旧族 `tool_approval` / `tool_approval_complete` 一帧都不发(BREAKING;补偿 = `STREAM_APPROVAL_ENABLED=false`)。
1189
- * 同一只 ask 在同一条腿上不再有两种开卡帧,消费方不再按 `approvalId` 去重。
993
+ * 🔴 **一条腿一个帧族**:呈卡协议在一条腿上场(`capabilities.approvalFrameFamilies` = `["approval_request"]`)⇒ 这条腿上一只 ask 的开卡 / 消卡 / 撤卡走
994
+ * `approval_request` / 本帧 / {@link ApprovalRevokeFrame}。同一只 ask 在同一条腿上只有一种开卡帧,消费方不需要按 `approvalId` 去重。
1190
995
  *
1191
- * 语义与旧族 `tool_approval_complete` 逐字同一件事(同一次 settle 的同一份判决:`outcome` 三词、非人结局的 `cause`、park 路由的 `parked`),只是它属于本族:键与开卡帧对位
996
+ * 语义 = 同一次 settle 的同一份判决:`outcome` 三词、非人结局的 `cause`、park 路由的 `parked`。键与开卡帧对位
1192
997
  * (`askId` / `taskId` / `approvalId`),消卡**按开卡帧的 `askId`**。与撤卡帧的分工:撤卡帧是**批级**的(兄弟被赢家连坐成 `VOID` 的那一批,不带逐卡终局);本帧是**单卡**终局
1193
998
  * (人答 / 窗到期 / park 路由 / 取消 …)。同一只 ask 两帧都可能收到(被撤的兄弟自己的登记也按 settle 收场)—— 按 `askId` 清卡即可,两帧不冲突。
1194
999
  * 门 = 这条连接的**开卡帧真的送达过**(没见过开卡帧的连接不会收到消卡帧)。**帧只活着通知,行才是真源**:丢帧由开流 preamble 对账补偿(见 {@link ApprovalRequestFrame})。
@@ -1206,11 +1011,11 @@ export interface ApprovalCompleteFrame {
1206
1011
  taskId: string;
1207
1012
  /** 恒等于 {@link askId}(同开卡帧的 `approvalId`)。 */
1208
1013
  approvalId: string;
1209
- /** 这只 ask 怎么落定 —— 与旧族 {@link ToolApprovalFrame.outcome} 同三词:`allowed` / `denied` = 一次决议;`expired` = 非人结局(成因在 {@link cause})。 */
1014
+ /** 这只 ask 怎么落定 ——`allowed` / `denied` = 一次决议;`expired` = 非人结局(成因在 {@link cause})。 */
1210
1015
  outcome: "allowed" | "denied" | "expired";
1211
1016
  /** 非人结局的成因(`outcome: "expired"` 才在;审批席「结局成因」闭集里非人结局的十四词,与审计 settle 行同一个词,见 {@link ApprovalSettleCause});人答缺席。**缺席不是证据**。 */
1212
1017
  cause?: ApprovalSettleCause;
1213
- /** 这只 ask 按 park 路由收尾(行已转 PARKING / PARKED、迟到回决可达);**真才带**。缺席 = 无证据,**禁读作真拒**(同 {@link ToolApprovalFrame.parked})。 */
1018
+ /** 这只 ask 按 park 路由收尾(行已转 PARKING / PARKED、迟到回决可达);**真才带**。缺席 = 无证据,**禁读作真拒**(同 {@link ApprovalCompleteFrame.parked})。 */
1214
1019
  parked?: true;
1215
1020
  /** 铸帧时刻的 server 钟。 */
1216
1021
  serverNowMs: number;
@@ -1268,12 +1073,28 @@ export interface ApprovalFrameEnvelope {
1268
1073
  schemaVersion: number;
1269
1074
  [k: string]: unknown;
1270
1075
  }
1076
+ /** {@link explainApprovalRequestFrameV1} 的结果:合法 ⇒ `{ ok: true }`;不合 ⇒ 第一处不合的键与一句原因。`key` 是从帧根起的键路径(卡内键带 `card.` 前缀;帧本身不是对象 ⇒ `"$"`)。 */
1077
+ export type ApprovalRequestFrameVerdict = {
1078
+ ok: true;
1079
+ } | {
1080
+ ok: false;
1081
+ key: string;
1082
+ reason: string;
1083
+ };
1084
+ /** **单源诊断口**:给定值是否是**本包所描述的** v1 呈卡帧;不是 ⇒ 说**哪个键、为什么**。判否的帧走通用卡(安全元数据 + 人工 approve / deny),**不是拒绝** —— 诊断口不改变这条降级,只让降级的原因读得到
1085
+ * (手铸 / 转发的帧 `requestedBy` 形错之类,此前静默落通用卡、调用方不知道是哪个键)。
1086
+ *
1087
+ * 判据 = 三张逐键表按序读:头部({@link APPROVAL_REQUEST_HEAD_RULES}:判别位 + 必填身份 / 时钟键)→ 卡({@link APPROVAL_CARD_RULES},`card` 须是对象)→ 活面事实({@link APPROVAL_REQUEST_LIVE_FACT_RULES})。
1088
+ * `key` 报**第一处**不合,不是全部;一处修好再读,会读到下一处。布尔守卫 {@link isApprovalRequestFrameV1} 就是 `explain(f).ok`,两个读者读同一张表,不可能分歧。
1089
+ * 入参 `unknown`:消费端手里的 `JSON.parse` 结果就是这个类型,不必先 cast。 */
1090
+ export declare function explainApprovalRequestFrameV1(f: unknown): ApprovalRequestFrameVerdict;
1271
1091
  /** 窄化谓词:给定值是否是**本包所描述的** v1 呈卡帧。
1272
1092
  *
1273
1093
  * 入参是 `unknown` —— 消费端手里的 `JSON.parse` 结果就是这个类型,不必先 cast 一次才敢校验
1274
1094
  * (「为了过校验先撒个谎」正是这条谓词要消灭的形)。判据 = 协议判别位(`type`+`schemaVersion`+`kind`)
1275
1095
  * + **全部必填键的类型** + **在场可选键的类型**(见上方逐键判据的说明)。
1276
- * 判否 ⇒ 走通用卡(安全元数据 + 人工 approve/deny),**不是**拒绝。 */
1096
+ * 判否 ⇒ 走通用卡(安全元数据 + 人工 approve/deny),**不是**拒绝。
1097
+ * 🔴 判据只有一份:{@link explainApprovalRequestFrameV1} 的三张逐键表;本守卫由它派生,想知道**为什么**判否就读诊断口。 */
1277
1098
  export declare function isApprovalRequestFrameV1(f: unknown): f is ApprovalRequestFrame;
1278
1099
  /** 窄化谓词:给定值是否是**本包所描述的** v1 呈卡族消卡帧({@link ApprovalCompleteFrame};server ≥7.133.0)。
1279
1100
  * `outcome` 查闭三词(它决定卡怎么收,不认识的词不能当已知);`cause` / `parked` 按「**在场必须成形**」查(缺席合法 —— 人答没有成因、非 park 路由没有 `parked`;
@@ -1313,19 +1134,15 @@ export interface ActorAssertion {
1313
1134
  * 值拷贝比属主宽 = 拷贝已经漂了;要加第三个值,先动 settings-schema、再随同源锚一起过来。 */
1314
1135
  via?: "owner" | "operator";
1315
1136
  }
1316
- /** `POST /v1/tasks/{taskId}/asks/{askId}/decision` 的 body(car4 §3)。 */
1137
+ /** `POST /v1/tasks/{taskId}/asks/{askId}/decision` 的 body(server `.strict()`:多一个未知键 ⇒ `400 request.body_shape`;词表是 `approve | deny`)。 */
1317
1138
  export interface AskDecisionBody {
1318
1139
  decision: ApprovalAskDecision;
1319
1140
  /** 操作员编辑后批准 —— **整体替换**形(非 patch)。仅 `approve` 臂有效(`deny` 上 server 宽收后忽略)。
1320
1141
  * wire 透传:core 对编辑重跑 PreToolUse + policy 全链裁决,server 不做任何解释。
1321
1142
  * 是否真被透传看 ack 的 {@link AskDecisionAck.updatedInputForwarded}。 */
1322
1143
  updatedInput?: unknown;
1323
- /** 决策备注(审计用,≤2048;超限/非串是响亮 400,不静默截断)。live 回决腿的
1324
- * {@link ToolApprovalsResource.respond} `note` 与本键**同词同源同一列**(`decision_note`)。
1325
- * 🔴 **回显裁定已翻面(#229 / server ≥7.15.0)**:此前这里写「不跨权限回显:409 首决回显里一律不带
1326
- * `note`」——那条最窄形的代价是这一列全仓只写不读。现行:三个回体(首决 200 / 幂等回放 200 /
1327
- * 409 `conflict.ask_decided`)一律回显 {@link AskDecisionAck.decisionNote},**行上有才发**;409 回的恒是
1328
- * **首决**那条,不是本次请求带来的那条。老 server(<7.15.0)恒不带 ⇒ tolerate-absent。 */
1144
+ /** 决策备注(审计用,≤2048;超限/非串是响亮 400,不静默截断)。三个回体(首决 200 / 幂等回放 200 / 409 `conflict.ask_decided`)一律回显 {@link AskDecisionAck.decisionNote},
1145
+ * **行上有才发**;409 回的恒是**首决**那条,不是本次请求带来的那条。`deny` 的 note 作为拒因送达模型(server ≥7.147.0)。 */
1329
1146
  note?: string;
1330
1147
  /** 回决幂等键(≤255)。同 key 重试 ⇒ 回**原**成功响应(真幂等,不打第二次 CAS);
1331
1148
  * 同 key 打到**另一个** askId ⇒ 409 `conflict.ask_idempotency`(fail-loud,不跨 ask 回放)。 */
@@ -1335,13 +1152,29 @@ export interface AskDecisionBody {
1335
1152
  actor?: {
1336
1153
  label: string;
1337
1154
  };
1338
- /** 这次决定是**谁**做的(server ≥7.118.0;与 live `respond`、耐久 `decide` 同一只键、同一只读法,见 {@link ApprovalDecidedBy})。缺席 = `"person"`。
1155
+ /** 这次决定是**谁**做的(server ≥7.118.0;与耐久 `approvals.decide` 同一只键、同一只读法,见 {@link ApprovalDecidedBy})。缺席 = `"person"`。
1339
1156
  * 本口的两句特有答法:要人的卡上 `"policy"` 的放行 ⇒ `400 request.field_conflict`;闭集外 ⇒ `400 request.field_invalid`(都拒在裁决之前,卡不动)。 */
1340
1157
  decidedBy?: ApprovalDecidedBy;
1341
1158
  /** 策略决定从哪只座上答出来的(server ≥7.143.0,能力位 `approvalDecidedVia`;只许在 `decidedBy: "policy"` 旁,否则 / 闭集外 / `null` ⇒ `400 request.field_invalid`)。见 {@link ApprovalDecidedVia}。 */
1342
1159
  decidedVia?: ApprovalDecidedVia;
1160
+ /** server ≥7.152.0 · **「本会话放行」**(CC 的「don't ask again this session」):只有字面 `"session"` 一词,**只配 `decision: "approve"`**;
1161
+ * 别的词 ⇒ `400 request.field_invalid`,配 `deny` ⇒ `400 request.field_conflict`(`reason: "remember_decision"`,`fields: ["remember", "decision"]`),都拒在裁决之前、卡不动。
1162
+ * 回执带 {@link AskDecisionAck.rememberApplied}(落没落)。🔴 带授予的卡(引擎 `Skill` 卡等,卡面位 {@link ApprovalCard.rememberRefused})上**决定照收、只放行这一次、不记**;
1163
+ * 决定打在**不持有那条引擎腿的副本**上时 `rememberApplied: false`(进程内放行只记得在持有它的副本上)。运维可以在别人的**活卡**上带本键(决断口的门对运维开放)。 */
1164
+ remember?: "session";
1165
+ /** 人勾了「不再询问」时这次回决要兑付的东西(server ≥7.152.0 起活卡也经本口说;形、两臂互斥的编译期钉、server 的 400 文案、规则位五键的读法逐字见 {@link PersistRuleSelection})。
1166
+ * 候选臂 `{ rule }` / 编辑臂 `{ rule, edited: true }`(先探 `capabilities.respondFreeFormRules`)/ 批臂 `{ batchOfferIndex }`(先探 `capabilities.respondBatchRuleOffers`);
1167
+ * 首决 200 带规则位五键({@link AskDecisionAck.rulePersisted} 等;**规则没存上从不翻转裁决**);晚答 / 回放不再兑付规则。
1168
+ * ⚠️ 帧上 `ruleOffers` 缺席时**别发这一键**:这张卡没有可兑的东西,拿回的必定是 `rulePersisted:false` + `rule_lane_unavailable`。 */
1169
+ persistRule?: PersistRuleSelection;
1170
+ /** **「Yes, and add directory」**:把帧上 {@link ApprovalRequestLiveFacts.readRootCandidate} 的 `dir` **原串逐字**报回(不规范化、不截、不拼);随 `approve` 放行这一次,
1171
+ * 并让**本 run** 的读目录加上它(只读面;`covers:"exact"` = 只那一条路径)。
1172
+ * 🔴 **只配 `decision:"approve"` 且不带 `remember`**:否则 `400 request.body_shape`(在裁决之前);形门(非空串、≤ 引擎上限)同码 400;**能力位 `approvalReadRootGrant` 为假的部署**(多租 / 非单用户 host 车道)
1173
+ * 收到它 ⇒ 同码 400(先探位);卡已停驻 ⇒ 同码 400(只活卡收)。🔴 server 只判形不判值 —— 它是不是那张卡上的串由**引擎**判;结论只经通告到达(`approval.read_root_granted` /
1174
+ * `approval.read_root_grant_rejected`);**回执不报「加没加上」**,200 只意味着「你的答复送到了」(决定打在不持有引擎腿的副本上时 {@link AskDecisionAck.consumerState} = `"absent"`,授权交不到)。 */
1175
+ readRootGrant?: string;
1343
1176
  }
1344
- /** 回决成功 ack(200;车4 §6 + §12-F)。 */
1177
+ /** 回决成功 ack(200;首决或幂等回放)。已转停驻的问另有 {@link AskDecisionParkedRedeemed} 一臂(`accepted: "parked_redeemed"`)—— 返回联合,先用 {@link isAskDecisionParkedRedeemed} 判别。 */
1345
1178
  export interface AskDecisionAck {
1346
1179
  askId: string;
1347
1180
  taskId: string;
@@ -1350,212 +1183,102 @@ export interface AskDecisionAck {
1350
1183
  /** 决议被持久接受的 server 时刻。 */
1351
1184
  decidedAtMs: number;
1352
1185
  /** server 自铸的决策者身份(见 {@link ActorAssertion})。
1353
- * ⚠️ **可缺席**:车4 §12-D —— 持久行的 `decision_actor` 读出 schema 不成形时,server **省略本字段**
1354
- * 而不是 500。所以 `ack.actor.id` **禁裸取**,必须先判在场(降级/幂等回放腿真会不带它)。 */
1186
+ * ⚠️ **可缺席**:持久行的 `decision_actor` 读出 schema 不成形时(幂等回放腿),server **省略本字段**而不是 500。所以 `ack.actor.id` **禁裸取**,必须先判在场。 */
1355
1187
  actor?: ActorAssertion;
1356
- /** `true` = approve 携带了 `updatedInput` **且**本副本真有活体条目被联动结算(server 已把编辑后的 args
1357
- * 透传给引擎)。
1358
- * 🔴 **`true` 或缺席,从不 `false`**(车4 §12-F 定谳:正文 §6 的 false 臂作废,照 `finishRespond`
1359
- * 省略先例)。所以「无活体条目(纯 durable / 跨副本)」与「没带编辑」在 wire 上同形=缺席;
1360
- * **幂等回放的响应不承诺本字段字节等同**——它是本副本活体状态的函数,不落行。 */
1188
+ /** `true` = approve 携带了 `updatedInput` **且**本副本真有活体条目被联动结算(server 已把编辑后的 args 透传给引擎)。
1189
+ * 🔴 **`true` 或缺席,从不 `false`**。所以「无活体条目(纯 durable / 跨副本)」与「没带编辑」在 wire 上同形=缺席;**幂等回放的响应不承诺本字段字节等同**。 */
1361
1190
  updatedInputForwarded?: true;
1362
- /** #229,ADDITIVE(server ≥7.15.0):**行上**那条回决备注({@link AskDecisionBody.note} 落成的
1363
- * `decision_note`)。**行上有才发**,从不发 `null`/空键 ⇒ 缺席 = 这条决议没留理由(不是「server 藏了」)。
1364
- * 与 `updatedInputForwarded` 不同,本字段**落行**,所以幂等回放承诺字节等同。老 server 恒不带。 */
1191
+ /** **行上**那条回决备注({@link AskDecisionBody.note} 落成的 `decision_note`)。**行上有才发**,从不发 `null`/空键 ⇒ 缺席 = 这条决议没留理由。本字段**落行**,所以幂等回放承诺字节等同。 */
1365
1192
  decisionNote?: string;
1366
- /** server ≥7.133.0:这次请求带的 `note` 有没有**落成行上那段文字**(与 {@link ToolApprovalRespondApplied.noteRecorded} 两口同形同义)——
1367
- * **只在请求带了 `note` 时在场**;`true` ⇔ 行上 `decisionNote` 逐字就是这次提交的(哪怕是别人先写的同一段文字也算),`false` = 没确认(行上是别人的理由 / 店读不出)。
1368
- * 首决与幂等回放两形都带;PARKED 赎回腿不带(按「未知」读)。**缺席 ≠ `false`**:没带 `note` 的请求、老 server 都不带这一键。 */
1193
+ /** 这次请求带的 `note` 有没有**落成行上那段文字**——**只在请求带了 `note` 时在场**;`true` ⇔ 行上 `decisionNote` 逐字就是这次提交的(哪怕是别人先写的同一段文字也算),
1194
+ * `false` = 没确认(行上是别人的理由 / 店读不出)。首决与幂等回放两形都带。**缺席 ≠ `false`**。 */
1369
1195
  noteRecorded?: boolean;
1370
- /** server ≥7.133.0 在耐久决断口 200 上**确认存在的**披露位(同名同值同义见 {@link ToolApprovalRespondApplied.consumerState}):**本副本上没有引擎腿在等这只问**,只记真(`"absent"`)——
1371
- * 行判了(幂等回放读得到、审计面记得住),但本机没有任何东西因此续跑;持有悬挂 promise 的可能是另一个副本,或本副本重启后本地窗已空。续没续跑读 run 面,
1372
- * **绝不把 200 无此键当成「run 已续跑」的证明**(老 server 从不发这个键)。不是 409 / 410:这次决议**确实生效了**。 */
1196
+ /** **本副本上没有引擎腿在等这只问**,只记真(`"absent"`):行判了(幂等回放读得到、审计面记得住),但本机没有任何东西因此续跑;持有悬挂 promise 的可能是另一个副本,或本副本重启后本地窗已空。
1197
+ * 续没续跑读 run 面,**绝不把 200 无此键当成「run 已续跑」的证明**。不是 409 / 410:这次决议**确实生效了**。 */
1373
1198
  consumerState?: "absent";
1374
- }
1375
- /** The respond route's own refusal code (server `src/tool-approval.ts`, `404 tool_approval.not_pending`): a non-owner AND an
1376
- * unknown / settled / expired / wrong-replica id all read the same (no existence oracle).
1377
- * 🔴 **server ≥7.148.0 narrows it to the OWNER**: an ask the caller cannot see (never existed / not yours / row unreadable / this worker keeps no
1378
- * ask ledger) answers `404 not_found.ask` on both the respond door and the read door (the durable decide door's code, no status keys) — treat it
1379
- * exactly like this code: close the card. `tool_approval.not_pending` stays for the owner only (row `VOID` / `DENIED` with its cause word,
1380
- * `unknown_or_other_replica`, a bad row / missing redeem seat with no cause). A consumer that closed cards ONLY on this code must add `not_found.ask`. For a consumer holding a card it
1381
- * re-opened from a replay, this 404 is the ONE positive sign that the card was settled elsewhere and can be closed —
1382
- * a relay's own 404 (`not_found.route`, a worker that is gone) is not. Read it with {@link isToolApprovalNotPending};
1383
- * the additive `cause` past the owner gate stays at `err.extra.cause` ({@link ToolApprovalNotPendingCause}). */
1384
- export declare const TOOL_APPROVAL_NOT_PENDING_CODE: "tool_approval.not_pending";
1385
- /** `err` carries the respond route's refusal code {@link TOOL_APPROVAL_NOT_PENDING_CODE} — judged by `errorCode` ALONE (the
1386
- * code is the dispatch key, never the status: this package dispatches on codes, see the `APIError` head note), structurally,
1387
- * so an `APIError` from this package and any object carrying the same `errorCode` field both read. */
1388
- export declare function isToolApprovalNotPending(err: unknown): err is {
1389
- errorCode: typeof TOOL_APPROVAL_NOT_PENDING_CODE;
1390
- };
1391
- /** The 200 ack of a respond that reached an ask already DECIDED (server `src/tool-approval.ts`, the late-replay assembly):
1392
- * the FIRST decision replayed, not the one this request carried — `decision` is the row's two-word value (`allow_session`
1393
- * was folded to `allow` when it landed), `decidedAtMs` the first decision's clock, `decisionNote` only when the row has one,
1394
- * `rememberApplied: false` only when THIS request asked `allow_session`. No `delivery` key: nothing was delivered. A
1395
- * reversed late answer (you pressed No, the first decision was Yes) is the same 200 replay — not a 409, not an error,
1396
- * nothing re-judged; render the decision in the body, never the one you sent. Discriminant: {@link ToolApprovalRespondAck}. */
1397
- export interface ToolApprovalRespondReplayed {
1398
- approvalId: string;
1399
- askId: string;
1400
- idempotent: true;
1401
- decision: "allow" | "deny";
1402
- decidedAtMs: number;
1403
- decisionNote?: string;
1404
- rememberApplied?: false;
1405
- /** 与 {@link ToolApprovalRespondApplied.noteRecorded} 同形同义(server ≥7.133.0 两口同形):**只在这次请求带了 `note` 时在场**;`true` = 行上那段文字**就是**这次提交的(逐字相等才算),
1406
- * `false` = 没确认(已决行上是别人的理由 / 没有店 / 确认读也读不到)。晚答的 `note` 从不覆盖首决的理由 —— 要看首决的理由读 {@link decisionNote}。 */
1407
- noteRecorded?: boolean;
1408
- /** 这次晚答带了 `persistRule` 而首决已落、**这一次请求不再兑付规则**:恒 `false` + {@link ruleRefusal} `rule_lane_unavailable`(规则只在首决那一拍兑,晚答不补存);没带 `persistRule` ⇒ 键缺席。 */
1409
- rulePersisted?: false;
1410
- /** `rulePersisted: false` 时的机读理由(这一臂上只会是 `rule_lane_unavailable` —— 已发布的晚答路径只铸这一词)。 */
1411
- ruleRefusal?: Extract<RuleRefusalReason, "rule_lane_unavailable">;
1412
- }
1413
- /** The 200 ack of {@link ToolApprovalsResource.respond}: the decision was APPLIED to a live gate
1414
- * ({@link ToolApprovalRespondApplied}, `delivery: "applied"`), or the ask was already decided and the first decision is
1415
- * REPLAYED ({@link ToolApprovalRespondReplayed}, `idempotent: true`), or (server ≥7.133.0) the answer REDEEMED a parked card
1416
- * ({@link ToolApprovalRespondParkedRedeemed}, `accepted: "parked_redeemed"`). The discriminants are `delivery` / `idempotent` / `accepted` — read them with
1417
- * {@link isToolApprovalReplayed} / {@link isToolApprovalParkedRedeemed} before touching the applied-only members (`rememberApplied` and the rule-persistence
1418
- * echoes are applied-arm facts; a replay never carries a `delivery`). */
1419
- export type ToolApprovalRespondAck = ToolApprovalRespondApplied | ToolApprovalRespondReplayed | ToolApprovalRespondParkedRedeemed;
1420
- /** `ack` is the replayed arm of {@link ToolApprovalRespondAck} (the first decision of an already-DECIDED ask replayed; a replayed PARKED redemption is its own arm — {@link isToolApprovalParkedRedeemed}). */
1421
- export declare function isToolApprovalReplayed(ack: ToolApprovalRespondAck): ack is ToolApprovalRespondReplayed;
1422
- /** `ack` is the parked-redemption arm of {@link ToolApprovalRespondAck} (server ≥7.133.0): the late answer redeemed a PARKED card through the durable redemption leg. */
1423
- export declare function isToolApprovalParkedRedeemed(ack: ToolApprovalRespondAck): ack is ToolApprovalRespondParkedRedeemed;
1424
- /** The 200 ack of a respond that settled a LIVE gate (server `src/tool-approval.ts`, the ack assembly inside
1425
- * `ToolApprovalCoordinator.respond` — exact shape, `decision` echoed). */
1426
- export interface ToolApprovalRespondApplied {
1427
- approvalId: string;
1428
- delivery: "applied";
1429
- decision: ToolApprovalDecision;
1430
- /** server 1.239([1392]②):allow_session 时诚实回显 remember 是否**真记了**(true=grant 落桥内店;
1431
- * false=无 sessionId 记不了,壳不得渲染「本 session 全放行」)。非 allow_session 决策=字段省略;
1432
- * 旧 server=恒缺席(tolerate-absent)。
1433
- * 🔴 **server ≥7.116.0:在带授予的卡上恒 `false`**(既有键,不是新键)—— 引擎 `Skill` 卡上批准 = 激活技能 + 本 run 内它清单上的工具免问,卡上读不出这份授予,
1434
- * 所以 `allow_session` 在这类卡上**决定照收、只放行这一次、不记**;同一条件也盖在卡面位 {@link ToolApprovalFrame.rememberRefused}(在场 = 这张卡上记不住,壳不渲「本会话放行」)。 */
1199
+ /** server ≥7.152.0 · 只在这次请求带了 {@link AskDecisionBody.remember} 的**首决**上:落没落。🔴 带授予的卡上恒 `false`(决定照收、只放行这一次);决定打在不持有引擎腿的副本上同样 `false`。回放不带。 */
1435
1200
  rememberApplied?: boolean;
1436
- /** server 1.241([1458] ctrl+g 编辑放行):allow 族带 `updatedInput` 时=server 已把编辑后的 args 透传给
1437
- * 引擎(是否被消费取决于 core OnAsk 对象臂是否到位——诚实措辞:forwarded≠applied)。deny/未带编辑/
1438
- * 旧 server=字段省略(tolerate-absent)。 */
1439
- updatedInputForwarded?: boolean;
1440
- /**
1441
- * #154 车二,ADDITIVE:这次回决携带的 `persistRule` 到底有没有落进规则店。
1442
- *
1443
- * 🔴 **规则没存上从不翻转裁决**:人的「允许这次」已经生效并交给引擎了,把整个回决改判成 4xx 会让一次
1444
- * 真实的放行凭空消失。所以失败的诚实形恒是 **200 + `rulePersisted: false` + {@link ruleRefusal}**,壳据
1445
- * 此告诉人「这次放行了,但『不再询问』没存上」——**不要**把它渲成整次审批失败。
1446
- * 未带 `persistRule` 的回决 / 旧 server ⇒ 字段省略(tolerate-absent);缺席 ≠ `false`。
1447
- */
1201
+ /** server ≥7.152.0 · 只在带了 {@link AskDecisionBody.persistRule} 的**首决**上:这次回决携带的规则到底有没有落进规则店。🔴 **规则没存上从不翻转裁决**:
1202
+ * 失败的诚实形恒是 **200 + `rulePersisted: false` + {@link ruleRefusal}** —— 壳据此告诉人「这次放行了,但『不再询问』没存上」,**不要**渲成整次审批失败。缺席 ≠ `false`。 */
1448
1203
  rulePersisted?: boolean;
1449
- /** #154 车二,ADDITIVE:`rulePersisted: false` 时的**机读**理由(闭词表,见 {@link RuleRefusalReason})。
1450
- * `rulePersisted: true` 时恒缺席。壳按它分「换下一次再存」(`rule_input_edited`)与「这张卡上没有可兑的
1451
- * 东西」(`rule_lane_unavailable`)。🔴 后者**四种成因共用一格、两种是本卡局限** ⇒ 禁据它判断整台部署,
1452
- * 逐条见 {@link RuleRefusalReason}。 */
1204
+ /** `rulePersisted: false` 时的**机读**理由(闭词表,见 {@link RuleRefusalReason});`rulePersisted: true` 时恒缺席。 */
1453
1205
  ruleRefusal?: RuleRefusalReason;
1454
- /**
1455
- * #340,ADDITIVE(server ≥7.44.0)—— **自由文本臂专属**回显:真正落盘的那条规则的**规范拼写**
1456
- * (core 可能把 `Bash(adb *)` 规范成 `Bash(adb:*)`)。壳应当回显它,而不是输入框里的原字节。
1457
- *
1458
- * 🔴 **缺席的三种真实含义,别混**:①这次走的是**候选臂**(`edited` 未带)——server 的
1459
- * `editedArmEcho` 是本键的唯一成形口,候选臂回执因此**逐字节不变**(老壳按固定键集解析,多一个键就是
1460
- * 一次没人要的 wire 变更);②这次没落上(读 {@link rulePersisted} / {@link ruleRefusal});
1461
- * ③整只 `persistRule` 没带。**都不是**「规则丢了」。
1462
- */
1206
+ /** **自由文本臂专属**回显:真正落盘的那条规则的**规范拼写**(引擎可能把 `Bash(adb *)` 规范成 `Bash(adb:*)`)。壳应当回显它,而不是输入框里的原字节。候选臂回执逐字节不变(无本键)。 */
1463
1207
  persistedRule?: string;
1464
- /**
1465
- * design/377,ADDITIVE(server ≥7.46.0)—— **batch 臂专属**成功回执:这次一次性落地的**全部成员**的
1466
- * 规范文本。合取批是**一次 yes 全体落地**;任一成员兑付被拒 ⇒ `rulePersisted:false` +
1467
- * `ruleRefusal:"redeem-refused"`(已落地成员**不回滚** —— dot 记录在案,重触发新卡时 deduped 幂等)。
1468
- *
1469
- * 🔴 **序**:server ≥7.48.0 起按**请求那只 batch offer 的成员序**(帧上 `ruleOffers[batchOfferIndex].rules`
1470
- * 的序)交付,是**承诺**不是碰巧;7.46–7.47 上它继承的是服务端重铸批的走序 —— 所以要逐条归属请读
1471
- * {@link persistedRuleAnchors},别按位置推。
1472
- * 🔴 与 {@link persistedRule} **不是同一件事**:单数键属 single/编辑臂,复数键属 batch 臂,两键不会同场。
1473
- */
1208
+ /** **batch 臂专属**成功回执:这次一次性落地的**全部成员**的规范文本,按请求那只 batch offer 的成员序交付;任一成员被拒 ⇒ `rulePersisted:false` + `ruleRefusal:"redeem-refused"`(已落成员**不回滚**)。与 {@link persistedRule} 不会同场。 */
1474
1209
  persistedRules?: string[];
1475
- /**
1476
- * P-39,ADDITIVE(server ≥7.48.0,**零能力位**)—— {@link persistedRules} 的**逐条自描述归属锚**,
1477
- * 与它 **index 对齐**。形与两级下标的空间见 {@link PersistedRuleAnchor}。
1478
- *
1479
- * 🔴 **只在 batch 臂铸**(single/编辑臂无批成员坐标可言 ⇒ 整键缺席);服务端**证不出归属时同样整键缺席**
1480
- * (诚实缺席,绝不编一个下标)⇒ 读到缺席即知这次只能按旧的位置法读,而 `persistedRules` 本身**一个字节
1481
- * 不变**(老消费方忽略未知键 ⇒ 零感知)。
1482
- */
1210
+ /** {@link persistedRules} 的**逐条自描述归属锚**,与它 index 对齐(形见 {@link PersistedRuleAnchor});只在 batch 臂铸,服务端证不出归属时整键缺席(读到缺席即按位置读)。 */
1483
1211
  persistedRuleAnchors?: PersistedRuleAnchor[];
1484
- /**
1485
- * #229,ADDITIVE(server ≥7.15.0):这次回决携带的 `note` 到底有没有**落进持久 ask 行**。
1486
- *
1487
- * 🔴 报的是**店的真实结果**,不是「这台有没有店」。`false` 的三族真实成因:①本部署没有持久 ask 账
1488
- * (纯活卡形,note 无处可落);②回决落定那一刻店在抖(server 的 D5 fail-open —— **裁决照常生效**,
1489
- * 只是理由没记上);③并发的另一路回决带**同决议、不同 note** 先落了行 —— 决议是终局(所以仍是 200),
1490
- * 但行上那段文本是别人的。⇒ `true` 才可以对人说「理由已入审计」;`false` 时**别把整次回决渲成失败**
1491
- * (同 {@link rulePersisted} 那条纪律:附带记账失败从不翻转裁决)。
1492
- * 未带 `note` 的回决 / 老 server ⇒ 字段省略。🔴 **缺席 ≠ `false`**:老 server 对未知请求键静默忽略
1493
- * 且照回 200,所以「这台不认识 note」与「记上了」只能靠 `capabilities.approvalDecisionNote` 分 ——
1494
- * 位缺席就别发 `note`。
1495
- * server ≥7.133.0:耐久决断口 {@link AskDecisionAck.noteRecorded}、晚答回放臂 {@link ToolApprovalRespondReplayed.noteRecorded} 与本键**同形同义**(三口一只判据:请求带了 `note` 才在,`true` ⇔ 行上那段文本逐字就是这次提交的)。
1496
- */
1497
- noteRecorded?: boolean;
1498
- /**
1499
- * server ≥7.133.0 —— **本副本上没有引擎腿在等这只问**:与耐久决断口 {@link AskDecisionAck.consumerState} 同名同值同义的那一位,**只记真**(`"absent"`;缺席 = 本副本有引擎腿在等它,或老 server)。
1500
- * 在场 ⇔ 本回执结算的是审批机起服时从问账**接管**的登记(前一个进程 / 别的副本铸下、行仍待决):决议照常落行、回执照常 200,但这一决**不会让本副本上任何在跑的东西续跑**
1501
- * —— 续没续跑读 run 面,别把 200 读成「run 已续跑」。同一位也在 {@link import("../types.js").LivePendingRow.consumerState}(列表行)与 {@link ToolApprovalReadBody} 的 `pending` 臂上。
1502
- */
1503
- consumerState?: "absent";
1504
1212
  }
1505
1213
  /** `T` 的**具名成员**(去掉字符串 / 数字索引签名):开集信封里「已知键」那一半 —— 拼封闭的回执臂用,键集只有 `T` 声明的那些,不再是开集。 */
1506
1214
  type KnownMembers<T> = {
1507
1215
  [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K];
1508
1216
  };
1509
1217
  /**
1510
- * 迟到答复**赎回了一张已停驻的卡**的 200 回执(server ≥7.133.0;`accepted: "parked_redeemed"`):卡的窗到期后这只 ask 转了后台候批(停驻),此时在**另一副本 / 重启之后**按 Yes / No ——
1511
- * 此前这是 404 `tool_approval.not_pending`(`cause: "unknown_or_other_replica"`),现在答复**走既有的耐久赎回腿**(与 `POST /v1/approvals/:sessionId/decide` 同一道 CAS)并回这张回执。
1512
- * 体 = 那道赎回腿的回执(见 {@link import("../types.js").ApprovalDecisionResult},`status` / `taskId` / `sessionId` 等原样)+ 本口加的三位:
1513
- * `approvalId` / `askId`(同值,64 位十六进制串)与判别位 `accepted`;`decision` 在**重放形**上是两词方向(`allow` / `deny`,`allow_session` 折成 `allow`),首次赎回形随赎回腿回执原样(开串);`rememberApplied` 只在这次请求要的是 `allow_session`、且是**首次赎回**
1514
- * (server ≥7.147.0:赎回腿的真答,布尔;≤7.146.x 恒 `false`;重放形不带);`rulePersisted` / `ruleRefusal` / `persistedRule*` 是 `persistRule` 在赎回腿上的兑付结果(同 {@link ToolApprovalRespondApplied} 的同名键,**规则没存上从不翻转裁决**)。
1515
- * `idempotent: true` 只在**重放**(同一张已赎回的卡再答一次,回同一份首赎回执)上在场。判别读 {@link isToolApprovalParkedRedeemed};**不要**用 {@link isToolApprovalReplayed} 去读它的重放形。
1516
- * **封闭**(与「已应用 / 已回放」两兄弟臂、随包 spec 的 `additionalProperties: false` 同形):键集只有 `ApprovalDecisionResult` 声明的具名键加上本口加的那些,没有开放索引签名 ——
1517
- * 多写一个未知键编译红。
1218
+ * 决断口对**已转停驻的问**(行 `PARKED`:窗到期后转后台候批)的 200 回执(server ≥7.152.0 起这是活卡晚答的唯一去处,取代已删的应答口的停驻赎回臂;`accepted: "parked_redeemed"`):
1219
+ * 答复**走既有的耐久赎回腿**(与 `POST /v1/approvals/:sessionId/decide` 同一道 CAS),体 = 那道赎回腿的回执(见 {@link import("../types.js").ApprovalDecisionResult},`status` / `taskId` / `sessionId` 等原样)
1220
+ * + 本口加的位:`askId` / `taskId` / `decision`(`approve | deny`)/ `decidedAtMs` / `actor` 与判别位 `accepted`。`rememberApplied` 只在这次请求带了 `remember` 且是**首次赎回**时在场(赎回腿的真答);
1221
+ * `rulePersisted` / `ruleRefusal` / `persistedRule*` 是 `persistRule` 在赎回腿上的兑付结果(规则没存上从不翻转裁决)。`idempotent: true` 只在**重放**(同一张已赎回的卡再答一次)上在场。
1222
+ * **封闭**:键集只有 `ApprovalDecisionResult` 声明的具名键加上本口加的那些,没有开放索引签名 —— 多写一个未知键编译红。
1223
+ * 🔴 `readRootGrant` 打在已停驻的卡上 ⇒ `400 request.body_shape`(只活卡收),不会走到本臂。
1518
1224
  */
1519
- export interface ToolApprovalRespondParkedRedeemed extends KnownMembers<import("../types.js").ApprovalDecisionResult> {
1520
- approvalId: string;
1225
+ export interface AskDecisionParkedRedeemed extends KnownMembers<import("../types.js").ApprovalDecisionResult> {
1521
1226
  askId: string;
1227
+ taskId: string;
1228
+ decision: ApprovalAskDecision;
1229
+ decidedAtMs: number;
1230
+ actor: ActorAssertion;
1522
1231
  accepted: "parked_redeemed";
1523
- /** 只在这次请求要的是 `allow_session` 时在场。🔴 **server ≥7.147.0 起是赎回腿的真答(布尔)**:首次赎回 ⇒ `true` = 赎回腿记住了「本会话放行」/ `false` = 只放行这一次;**重放形不带本键**(重放回的是首赎回执的 `decision` 两词方向,不重答记没记)。
1524
- * ≤7.146.x 的 server 对停驻赎回恒答 `false`(「停驻赎回不记本会话放行」)—— 型从 `false` 放宽为 `boolean`(输出型放宽:把它当字面量 `false` 窄读的代码要改按布尔读)。 */
1232
+ decisionNote?: string;
1233
+ noteRecorded?: boolean;
1525
1234
  rememberApplied?: boolean;
1526
- /** 兑付结果键(`persistRule` 在赎回腿上的结果;语义同 {@link ToolApprovalRespondApplied} 的同名键,缺席同样不是 `false`)。 */
1527
1235
  rulePersisted?: boolean;
1528
1236
  ruleRefusal?: RuleRefusalReason;
1529
1237
  persistedRule?: string;
1530
1238
  persistedRules?: string[];
1531
1239
  persistedRuleAnchors?: PersistedRuleAnchor[];
1532
1240
  }
1241
+ /** `ack` 是决断口的**停驻赎回臂**({@link AskDecisionParkedRedeemed},`accepted: "parked_redeemed"`);否则是首决 / 幂等回放臂({@link AskDecisionAck})。 */
1242
+ export declare function isAskDecisionParkedRedeemed(ack: AskDecisionAck | AskDecisionParkedRedeemed): ack is AskDecisionParkedRedeemed;
1243
+ /** 按问读口的 `404 tool_approval.not_pending` 体 `cause`(经 `err.extra.cause` 到达;本包对该码不开具名属性):**一词** `unknown_or_other_replica` ——
1244
+ * 行仍待决而本副本没有在等它的登记(活在别的副本上 / 本副本不认识它)。其余情形不带 `cause`。(问账行的成因词只经 `void` 体的 `cause` 与决断口 `410 gone.ask` 的 `cause` 到达,见 {@link AskRowEndingCause}。) */
1245
+ export type ToolApprovalNotPendingCause = "unknown_or_other_replica";
1246
+ /** 按问读口自己的拒码(`404 tool_approval.not_pending`):属主**看得见**这只问、但此刻读不出一个可用的态;**看不见**的调用方(查无 / 不是你的 / 行读不出 / 没有问账)读到的是 `404 not_found.ask`
1247
+ * (决断口的码,不带状态位)—— 两码**都读作「消卡」**:只认其中一个码的消费方要补另一个;路由 / 转发自己的 404(`not_found.route`,worker 没了)不是这个正向信号。 */
1248
+ export declare const TOOL_APPROVAL_NOT_PENDING_CODE: "tool_approval.not_pending";
1249
+ /** `err` 带着读口的拒码 {@link TOOL_APPROVAL_NOT_PENDING_CODE} —— **只按 `errorCode` 判**(码是分派键,不是状态;本包按码分派,见 `APIError` 头注),结构性判读:
1250
+ * 本包的 `APIError` 与任何带同名 `errorCode` 字段的对象都读得到。 */
1251
+ export declare function isToolApprovalNotPending(err: unknown): err is {
1252
+ errorCode: typeof TOOL_APPROVAL_NOT_PENDING_CODE;
1253
+ };
1533
1254
  /**
1534
- * `GET /v1/tool-approvals/:id` 应答体 `state` 的**闭集**(server ≥7.133.0;一只 ask 此刻在哪一态,读法与应答口逐条同源,穷举读):
1535
- * · `pending` —— 本副本上有在等它的活登记(应答口此刻收得下;体 = 列表面 {@link import("../types.js").LivePendingRow} 的同一只行投影 + `state`);
1536
- * · `decided` —— 行 `DECIDED`(有人 / 有策略决过;回执三键同晚答回放体:`decision` / `decidedAtMs` / `decisionNote?`);
1537
- * · `parked` —— 行 `PARKING` / `PARKED`(转后台候批;应答口走迟到受理 / 赎回,耐久回决口照收;`decidePath?` 指耐久回决路径);
1538
- * · `void` —— 行 `DENIED` / `VOID`(没有人决过它,答案无处兑现;`cause?` 同晚答 404 的成因词,见 {@link AskRowEndingCause})。
1255
+ * `GET /v1/tasks/:taskId/asks/:askId` 应答体 `state` 的**闭集**(一只 ask 此刻在哪一态,读法与决断口逐条同源,穷举读):
1256
+ * · `pending` —— 本副本上有在等它的活登记(决断口的 live 臂此刻收得下;体 = 列表面 {@link import("../types.js").LivePendingRow} 的同一只行投影 + `state`);
1257
+ * · `decided` —— 行 `DECIDED`(有人 / 有策略决过;三键同决断口的回放体:`decision`〔`approve | deny`〕/ `decidedAtMs` / `decisionNote?`),**或**行 `PARKED` 而它的门已被决;
1258
+ * · `parked` —— 行 `PARKING`,或行 `PARKED` 且门仍是该会话当前待决的审批门(转后台候批;决断口的停驻臂与耐久回决口照收;`decidePath?` 指耐久回决路径);
1259
+ * · `void` —— 行 `DENIED` / `VOID`(没有人决过它,答案无处兑现;`cause?` = 行上记的成因词,与决断口 `410 gone.ask` 同一列,见 {@link AskRowEndingCause}),**或**行 `PARKED` 而它的门已过期 / 被取代(此时 `cause` 缺席)。
1260
+ *
1261
+ * 版本读法:四词自 server ≥7.133.0 就是这四词;停驻行过门判官(下)自 7.134.0 起;`reopened` 自 7.135.0 起;读口的路径自 7.152.0 起是任务名下的 `GET /v1/tasks/:taskId/asks/:askId`(此前是 `GET /v1/tool-approvals/:id`,已随应答口一起删除),
1262
+ * 决议词也自 7.152.0 起是 `approve | deny`(此前读口回 `allow | deny`)。
1539
1263
  *
1540
- * 🔴 **server ≥7.134.0:停驻行(`PARKED`)过门判官**(与应答口判 `409 approval_stale` 同一只)—— 问账行不随赎回 / 取消改写,所以读口去问 checkpoint
1541
- * 「这张卡的门此刻还是不是该会话当前待决的审批门」,词表**不加字**:
1542
- * · 门仍开 ⇒ `parked`(+ `decidePath`,不变)—— **只有这一态才渲「去决定」**;
1543
- * · 门已被人 / 策略结算(checkpoint 上有方向与引擎写的结算时刻)⇒ `decided`(`decision` / `decidedAtMs` / `decisionNote?`,**无 `decidePath`**)—— 渲「已答」;
1264
+ * 🔴 **停驻行(`PARKED`)过门判官**(与决断口判 `409 approval_stale` 同一只)—— 问账行不随赎回 / 取消改写,所以读口去问 checkpoint「这张卡的门此刻还是不是该会话当前待决的审批门」,词表**不加字**:
1265
+ * · 门仍开 ⇒ `parked`(+ `decidePath`)—— **只有这一态才渲「去决定」**;
1266
+ * · 门已被人 / 策略结算(checkpoint 上有方向与引擎写的结算时刻)⇒ `decided`(**无 `decidePath`**)—— 渲「已答」;
1544
1267
  * · 门已过期(取消先把门 expire)/ 被取代 / 结算方是宿主 SLA 扫·窗到期·无人可答 ⇒ `void`(**无 `cause`**:行上没写成因)—— 渲「失效」;
1545
1268
  * · checkpoint 行没了,或已结算却读不出可用的方向 / 时刻 ⇒ `404 tool_approval.not_pending`(**无 `cause`**)—— 渲「消卡」;
1546
- * · 门读不出(店故障)⇒ 退回 `parked`(应答口对同一张卡仍按自己的判官 fail-closed)。
1269
+ * · 门读不出(店故障)⇒ 退回 `parked`(决断口对同一张卡仍按自己的判官 fail-closed)。
1547
1270
  * **已知边界**(以重读为准):停驻行的 `decided` 可回到 `parked` —— 续跑腿在被批准的动作开跑前失败(环境恢复失败 / 工具不在 / 配置被拒 / 决议输入被拒)时引擎**重开**同一张门
1548
1271
  * (一次已送达的拒不重开;工具不在与决议输入被拒要重新决);续跑被取消 ⇒ server 把重开的门收掉,读作 `void`,收掉之前的一瞬(或收不掉、交给收割器时)仍可能读到 `parked`;
1549
- * 重开瞬间两读之间可能读到 `void`。老 server(≤7.133.x)对这几类卡一律答 `parked` + `decidePath`。
1272
+ * 重开瞬间两读之间可能读到 `void`。
1550
1273
  *
1551
- * 🔴 **server ≥7.135.0:重开过的门读 `parked` 时另带 `reopened`**({@link ToolApprovalReopened}:重开因由 + 重开前的那次决议)—— 此前「决过又被重开」的窄窗读口只能说 `parked`,
1552
- * 壳没法告诉用户「你批过了,但续跑失败、这张卡又回来了」。`reopened` **缺席** = 读口说不出它被重开过(不是「没重开过」);词表不加字,`state` 仍是四词。
1274
+ * 🔴 **重开过的门读 `parked` 时另带 `reopened`**({@link ToolApprovalReopened}:重开因由 + 重开前的那次决议)—— 壳据此告诉用户「你批过了,但续跑失败、这张卡又回来了」。
1275
+ * `reopened` **缺席** = 读口说不出它被重开过(不是「没重开过」);词表不加字,`state` 仍是四词。
1553
1276
  */
1554
1277
  export declare const TOOL_APPROVAL_READ_STATES: readonly ["pending", "decided", "parked", "void"];
1555
1278
  /** {@link TOOL_APPROVAL_READ_STATES} 的成员型。 */
1556
1279
  export type ToolApprovalReadState = (typeof TOOL_APPROVAL_READ_STATES)[number];
1557
1280
  /**
1558
- * `GET /v1/tool-approvals/:id` 的 `parked` 臂上 `reopened.reason` 的**闭集**(server ≥7.135.0;引擎 core `REOPEN_REASONS`,逐词同序,server 只回显集内的词 ——
1281
+ * `GET /v1/tasks/:taskId/asks/:askId` 的 `parked` 臂上 `reopened.reason` 的**闭集**(server ≥7.135.0;引擎 core `REOPEN_REASONS`,逐词同序,server 只回显集内的词 ——
1559
1282
  * 门上的因由词不在引擎闭集里〔只有手改行带得出〕⇒ 整个 `reopened` 键缺席,不原样透传):
1560
1283
  * · `env_failed` —— 环境 / 会话这一侧的失败(续跑腿在被批准的动作开跑之前起不来);
1561
1284
  * · `tool_unavailable` —— 批过的工具此刻不在(要重新决);
@@ -1576,11 +1299,11 @@ export type ToolApprovalReopenReason = (typeof TOOL_APPROVAL_REOPEN_REASONS)[num
1576
1299
  */
1577
1300
  export interface ToolApprovalReopened {
1578
1301
  reason: ToolApprovalReopenReason;
1579
- decision?: "allow" | "deny";
1302
+ decision?: ApprovalAskDecision;
1580
1303
  decidedAtMs?: number;
1581
1304
  decisionNote?: string;
1582
1305
  }
1583
- /** `GET /v1/tool-approvals/:id` 非 `pending` 三臂共用的**行投影**(键名是列表面 `livePending[]` 行的同名子集 —— 一个读者一套键):`frame` = 断连重放的那只**呈卡帧**
1306
+ /** `GET /v1/tasks/:taskId/asks/:askId` 非 `pending` 三臂共用的**行投影**(键名是列表面 `livePending[]` 行的同名子集 —— 一个读者一套键):`frame` = 断连重放的那只**呈卡帧**
1584
1307
  * (`approval_request` 形;卡读不出 ⇒ 缺席,不编)。 */
1585
1308
  export interface ToolApprovalReadProjection {
1586
1309
  approvalId: string;
@@ -1593,18 +1316,20 @@ export interface ToolApprovalReadProjection {
1593
1316
  frame?: ApprovalRequestFrame;
1594
1317
  }
1595
1318
  /**
1596
- * `GET /v1/tool-approvals/:id` 的 200 体(server ≥7.133.0):**按 `state` 判别**的四臂联合(读一句 `switch (body.state)`)。纯读:零写、零结算、不碰本地登记。
1597
- * `pending` 臂 = 列表面行 {@link import("../types.js").LivePendingRow} 原样 + `state`(`frame` 是同一格同一个形:呈卡腿上 {@link ApprovalRequestFrame},旧族腿上 {@link ToolApprovalFrame},按 `frame.type` 判 —— 一处声明,见 `LivePendingRow.frame`)。
1598
- * 404 `tool_approval.not_pending`(经 {@link isToolApprovalNotPending};`err.extra.cause` 见 {@link ToolApprovalNotPendingCause})= 属主不过 / 未知 id / 行仍待决而本副本没有在等它的登记(活在别的副本上,
1599
- * `cause: "unknown_or_other_replica"`);没有 ask 账的部署 ⇒ 同句 404、**不带 `cause`**。
1600
- * 🔴 **server ≥7.148.0**:看不见这只问(查无 / 不是你的 / 行读不出 / 本 worker 没有问账)⇒ **404 `not_found.ask`**({@link import("../errors.js").NotFoundError},与耐久决断口同码、不带状态位),
1601
- * 不再答 `tool_approval.not_pending`;后者只对属主出(行 `VOID` / `DENIED` 带成因词、`unknown_or_other_replica`、坏行无 `cause`)。两码都读作「消卡」。`toolApproval` 面没开 ⇒ 501 `feature.tool_approval_disabled`。
1319
+ * `GET /v1/tasks/:taskId/asks/:askId` 的 200 体:**按 `state` 判别**的四臂联合(读一句 `switch (body.state)`)。纯读:零写、零结算、不碰本地登记。
1320
+ * `pending` 臂 = 列表面行 {@link import("../types.js").LivePendingRow} 原样 + `state`(`frame` 是呈卡帧 {@link ApprovalRequestFrame};见 `LivePendingRow.frame`)。
1321
+ * 与决断口 {@link ToolApprovalsResource.decideAsk} **同根同门**(同一只鉴权 / 属主身份):
1322
+ * · **404 `not_found.ask`**({@link import("../errors.js").NotFoundError},与决断口同码同句、不带状态位)= 看不见这只问(查无 / 不属这只 task / 不是你的 / 行读不出 / 本 worker 没有问账)—— 读作「消卡」;
1323
+ * · **404 `tool_approval.not_pending`**(经 {@link isToolApprovalNotPending};`err.extra.cause` 见 {@link ToolApprovalNotPendingCause})= 属主看得见、但卡此刻读不出可用的态(行仍待决而本副本没有在等它的登记〔活在别的副本上,
1324
+ * `cause: "unknown_or_other_replica"`〕;已决行读不出可用的方向 / 时刻〔无 `cause`〕)—— 同样读作「消卡」;
1325
+ * · 没挂 ask 账的部署(`capabilities.approvalsStreamLive` / `streamApproval` 假)⇒ `501 feature.approval_ask_disabled`。
1326
+ * 店读不出行时读口答 `404 not_found.ask`(看不见),决断口答 `500 internal.error`(可重试)—— 同一根上两口的答法不同。
1602
1327
  */
1603
1328
  export type ToolApprovalReadBody = ({
1604
1329
  state: "pending";
1605
1330
  } & import("../types.js").LivePendingRow) | ({
1606
1331
  state: "decided";
1607
- decision: "allow" | "deny";
1332
+ decision: ApprovalAskDecision;
1608
1333
  decidedAtMs: number;
1609
1334
  decisionNote?: string;
1610
1335
  } & ToolApprovalReadProjection) | ({
@@ -1618,143 +1343,38 @@ export type ToolApprovalReadBody = ({
1618
1343
  export declare class ToolApprovalsResource {
1619
1344
  private readonly t;
1620
1345
  constructor(t: Transport);
1621
- /** GET /v1/tool-approvals/:id — **按问读口**(server ≥7.133.0):一只 ask 此刻在哪一态({@link ToolApprovalReadBody} 的 `state` 四词,{@link TOOL_APPROVAL_READ_STATES})。
1622
- * 与 {@link ToolApprovalsResource.respond} 同根同门(同一只鉴权 / 属主身份;属主不过与未知 id **同形** 404,无存在性谕示)。用途:拿着重放来的卡(或 `livePending` 行)的壳,在答之前
1623
- * / 重连之后问一句「这张卡还活着吗、被谁决过没有」,而不是靠 `respond` 的 404 反推。`approvalId` 恒等于 {@link ApprovalRequestFrame.askId}(64 位十六进制串,当不透明串)。
1624
- * 老 server(≤7.132.x)没有这一口 ⇒ 路由级 404 `not_found.route`(与本口的 404 `tool_approval.not_pending` 靠 `errorCode` 分,**别按状态码分**)。 */
1625
- get(approvalId: string, opts?: {
1346
+ /** GET /v1/tasks/:taskId/asks/:askId — **按问读口**(server ≥7.152.0;一对同根口的读半边):一只 ask 此刻在哪一态({@link ToolApprovalReadBody} 的 `state` 四词,{@link TOOL_APPROVAL_READ_STATES})。
1347
+ * 与 {@link ToolApprovalsResource.decideAsk} 同根同门(同一只鉴权 / 属主身份;看不见的问一律 `404 not_found.ask`,无存在性谕示)。用途:拿着重放来的卡(或 `livePending` 行)的壳,在答之前 /
1348
+ * 重连之后问一句「这张卡还活着吗、被谁决过没有」,而不是靠 `decideAsk` 的错答反推。`askId` 取自呈卡帧 {@link ApprovalRequestFrame.askId},`taskId` 取自同帧的 `taskId`
1349
+ * (`livePending[]` 行上在内嵌帧 `frame.askId` / `frame.taskId`)。没挂 ask 账的部署 ⇒ `501 feature.approval_ask_disabled`({@link import("../errors.js").FeatureDisabledError};先探能力位 `streamApproval`)。
1350
+ * 纯读:零写、零结算 → 本包的重试臂照 GET 的常规处置。 */
1351
+ readAsk(taskId: string, askId: string, opts?: {
1626
1352
  signal?: AbortSignal;
1627
1353
  }): Promise<ToolApprovalReadBody>;
1628
- /** POST /v1/tool-approvals/:id/respond — settle a parked LIVE tool-approval gate with the human's decision.
1629
- * The engine's suspended tool call resumes (allow) or is refused (deny) on the still-open task connection.
1630
- *
1631
- * 🔴 **server ≥7.148.0**: an ask the caller cannot see (never existed / not yours / unreadable row / no ask ledger on this worker) answers
1632
- * **`404 not_found.ask`** (the durable decide door's code) instead of `tool_approval.not_pending` — close the card on either code. The text below is
1633
- * the ≤7.147.x reading of the owner gate; on 7.148.0 `tool_approval.not_pending` reaches the owner only.
1634
- *
1635
- * 🔴 OWNER-GATED with a 404 (NO existence oracle, server `src/tool-approval.ts` — errorCode
1636
- * `tool_approval.not_pending`): a non-owner AND an
1637
- * unknown/settled/expired/wrong-replica id both get the same 404 — never branch existence off the status.
1638
- * The 404 body may carry an additive `cause` past the owner gate (read it at `err.extra.cause`, typed `ToolApprovalNotPendingCause` — {@link ToolApprovalNotPendingCause}):
1639
- * a row-ending cause word (the card ended without a human decision — dismiss it) or `unknown_or_other_replica` (retry on another endpoint / replica).
1640
- * 🔴 server ≥7.124.0 retired the old words `voided` / `denied` (replaced by the concrete cause word, no alias); absence is legal (no durable ask ledger / an older row).
1641
- * A malformed body (`decision` outside the 3-word set) is a 400 (existence-independent). A worker without
1642
- * `TOOL_APPROVAL_ENABLED` → 501 (probe `capabilities.toolApproval` instead of trial-by-501); missing
1643
- * principal on a require-principal worker → 401.
1644
- *
1645
- * Not a submit / not idempotent (it settles an in-flight promise exactly once) → NO SDK retry. */
1646
- respond(id: string, body: {
1647
- decision: ToolApprovalDecision;
1648
- /** server 1.241([1458] ctrl+g「edit script in $EDITOR」):allow 族可带编辑后的 tool args(**整体替换**形,
1649
- * 非 patch)。deny 上 server 静默忽略;旧 server 同样忽略未知键(前向兼容)。透传与否看 ack 的
1650
- * `updatedInputForwarded`。 */
1651
- updatedInput?: unknown;
1652
- /**
1653
- * #154 车二起座、7.44.0/7.46.0 长成**两臂**(S-134)—— 人勾了「不再询问」时这次回决要兑付的东西。
1654
- * 形、两臂互斥的编译期钉、server 四条 400 文案原文、以及 `deny` 下整字段不解析的姿势,
1655
- * 逐字见 {@link PersistRuleSelection}。
1656
- *
1657
- * 简表:
1658
- * · **候选臂** `{ rule }` —— 把 {@link ToolApprovalFrame.ruleOffers} 里**选中那条 `kind:"single"`
1659
- * 的 `rule` 文本原样**报回(server 按**文本**定位,别拼、别改大小写、别自己加 `:*`);
1660
- * · **编辑臂** `{ rule, edited: true }`(≥7.44.0,先探 `capabilities.respondFreeFormRules` —— 本包
1661
- * {@link import("../types.js").Capabilities.respondFreeFormRules})——
1662
- * 人手改的自由文本,成功回执带 {@link ToolApprovalRespondApplied.persistedRule} = 落盘的规范拼写;
1663
- * · **批臂** `{ batchOfferIndex }`(≥7.46.0,先探 `capabilities.respondBatchRuleOffers` —— 本包
1664
- * {@link import("../types.js").Capabilities.respondBatchRuleOffers})——
1665
- * 合取批没有单条文本可抄,选择键 = 帧上 `ruleOffers` 的**下标**;成功回执带
1666
- * {@link ToolApprovalRespondApplied.persistedRules} + {@link ToolApprovalRespondApplied.persistedRuleAnchors}。
1667
- *
1668
- * ⚠️ 帧上 `ruleOffers` 缺席时**别发这一键**:**这张卡**没有可兑的
1669
- * 东西,发了拿回的必定是 `rulePersisted:false` + **`rule_lane_unavailable`**(素材缺席在候选比对
1670
- * **之前**就短路了,所以不会是 `rule_not_offered`)。缺席有多个成因 —— 没接规则店 / 引擎对这条命令
1671
- * 铸不出候选 / 命令原字节读不出 / 这只 ask 属七族不铸 offer 之一 —— 所以**别**据一帧、也别据这一个
1672
- * 拒绝理由去判断整台部署的规则车道在不在(那句话看 `capabilities.permissionRules`)。
1673
- */
1674
- persistRule?: PersistRuleSelection;
1675
- /**
1676
- * #229,ADDITIVE(server ≥7.15.0)—— 这次回决的**理由**(自由文本,**≤2048 字符**,超限/非串是响亮
1677
- * `400 request.body_shape`,不静默截断)。落进持久 ask 行的 `decision_note` 列 = 审计面;与 durable
1678
- * 回决腿({@link ToolApprovalsResource.decideAsk} 的 {@link AskDecisionBody.note})**同词同源同一列**。
1679
- *
1680
- * **任何 `decision` 都可带**,`deny` 也算 ——「为什么拒」正是审计面上最值钱的那一条。
1681
- * `allow_session` 在持久行上落成 `approve`(三值映二值),它的 note 记在**那条 approve 行**上、不丢。
1682
- *
1683
- * 🔴 **发之前先探 `capabilities.approvalDecisionNote`**:live 回决口的体校验是**非 strict** 的,
1684
- * 老 server 收到本键会**照回 200 且什么都不记**。位缺席 = 老 server,别渲这一格;位在场时按每次回执的
1685
- * {@link ToolApprovalRespondApplied.noteRecorded} 读结果 —— 它是唯一诚实的 per-call 答案。
1686
- */
1687
- note?: string;
1688
- /** 这次决定是**谁**做的(server ≥7.118.0;与耐久 `decideAsk` / `decide` 同一只键、同一只读法,见 {@link ApprovalDecidedBy})。缺席 = `"person"`。
1689
- * 本口的特有答法:要人的卡上 `"policy"` 的放行与闭集外都是 `400 request.body_shape`(拒在裁决之前,卡不动,改对了用同一把 `approvalId` 再来);
1690
- * 🔴 位缺席的老 server(<7.118.0)对本键**静默丢 + 200** —— 先探 `capabilities().approvalDecidedBy`。 */
1691
- decidedBy?: ApprovalDecidedBy;
1692
- /** 策略决定从哪只座上答出来的(server ≥7.143.0;见 {@link ApprovalDecidedVia})。本口的答法:不在 `decidedBy: "policy"` 旁 / 闭集外 ⇒ `400 request.body_shape`(拒在裁决之前,卡不动)。
1693
- * 🔴 先探 `capabilities().approvalDecidedVia` —— 本口对未知键非 strict,老 server 会静默丢。 */
1694
- decidedVia?: ApprovalDecidedVia;
1695
- /**
1696
- * **S-720(server ≥7.102.0 / core 7.32.0 #1093,ADDITIVE)—— 「Yes, and add directory」**:把帧上
1697
- * {@link ToolApprovalFrame.readRootCandidate} 的 `dir` **原串逐字**报回(不规范化、不截、不拼)。随 `allow` 放行这一次,
1698
- * 并让**本 run** 的读目录加上它(只读面;`covers:"exact"` = 只那一条路径)。
1699
- *
1700
- * 🔴 **只配 `decision:"allow"`**:`allow_session` 不是那一个选项、`deny` 上它没有意义 —— 带在别的 decision 上
1701
- * server **在裁决之前**响亮拒 `400 request.body_shape`(`READ_ROOT_GRANT_ALLOW_ONLY` 那句;修前是静默丢)⇒ 卡还在,
1702
- * 改对了用同一把 `approvalId` 再来。🔴 **形门**:非空串、≤ core `READ_ROOT_CANDIDATE_DIR_MAX`,否则同码 400
1703
- * (`READ_ROOT_GRANT_SHAPE`;超限整只拒不截 —— 截过的目录是另一个目录)。
1704
- * 🔴 **server 只判形不判值**:它是不是那张卡上的串由**引擎**判(判官 = core `resolveAsk`)。结论只经通告到达 ——
1705
- * `approval.read_root_granted`(本 run 的读目录**真的**加上了,`detail: { dir, covers?, root, … }`)/
1706
- * `approval.read_root_grant_rejected`(什么都没加、**裁决照旧**,`detail.reason` 八词见 `engine_notice` 臂顶注)。
1707
- * **本回执不报「加没加上」**:200 只意味着「你的答复送到了」。
1708
- * ⚠️ 射程:**只本 run**(ask 行无此列 ⇒ 重放 / failover / durable 续跑不携带;下一 run 从声明的
1709
- * `additionalReadDirectories` 起算,跨 run 持久化不在 7.102.0);**只本口**(耐久 `/v1/approvals/:sessionId/decide` 与
1710
- * 流内 `decideAsk` 两口不收)。接了持久 ask 店的部署上,本口经 ask 行 CAS 结算 —— 只有**本请求干净赢下那一行**时它才过境
1711
- * (歧义确认臂上行可能是别人的胜利 ⇒ 丢;迟到受理的 PARKED 臂走耐久赎回 ⇒ 不携带):没有 granted 通告 = 什么都没加。
1712
- * ⚠️ 老 server(<7.102.0)对未知请求键静默忽略并照回 200 ⇒ 只得到一次普通放行(没有能力位,S-765 另立);
1713
- * 以通告是否出现为准。
1714
- */
1715
- readRootGrant?: string;
1716
- }, opts?: {
1717
- signal?: AbortSignal;
1718
- }): Promise<ToolApprovalRespondAck>;
1719
- /** POST /v1/tasks/:taskId/asks/:askId/decision — 结算一张**流内审批卡**(design/172 §3.2,车4)。
1720
- * `askId` 取自 {@link ApprovalRequestFrame.askId};`taskId` 取自同帧的 `taskId`(wire run id)。
1721
- *
1722
- * 🔴 **已发布** —— 端点随 server 7.3.0 上线,本 verb 随 SDK 6.7.0 发出。部署默认位**分两段读**:
1723
- * server **≤7.4.0 默认 OFF**(`STREAM_APPROVAL_ENABLED` 默认 false ⇒ 这些版本上绝大多数部署走
1724
- * 501,能用的只有 legacy 活卡腿 {@link ToolApprovalsResource.respond});server **≥7.5.0 默认 ON**
1725
- * (2026-08-07 上 npm;server CHANGELOG 以 BREAKING 披露,`STREAM_APPROVAL_ENABLED=false` 是干净还原键)。
1726
- * 两段都要读——第一段描述今天仍在跑的全部 7.3.x/7.4.x 装机。
1727
- * ⚠️ 别按版本号猜:唯一权威是实测能力位 `capabilities.streamApproval`(它是五合取的结果,
1728
- * 开关只是其中一项)。
1729
- * 未挂 ask 持久层 / 未开开关的 worker ⇒ 501 `feature.approval_ask_disabled`
1730
- * ({@link import("../errors.js").FeatureDisabledError});探能力面而不是 trial-by-501。
1354
+ /** POST /v1/tasks/:taskId/asks/:askId/decision — 结算一张**审批卡**(一对同根口的决半边;server ≥7.152.0 起它是活卡的**唯一**人决口,取代已删的应答口)。
1355
+ * `askId` 取自 {@link ApprovalRequestFrame.askId};`taskId` 取自同帧的 `taskId`(wire run id)。词表是 `approve | deny`(活卡的三个词 `remember:"session"` / `persistRule` / `readRootGrant`
1356
+ * 现在只经本口说,见 {@link AskDecisionBody})。
1357
+ * 未挂 ask 持久层的 worker ⇒ `501 feature.approval_ask_disabled`({@link import("../errors.js").FeatureDisabledError});探能力位 `streamApproval`,不要 trial-by-501。
1731
1358
  *
1732
- * ── 响应四则(design/172 §3.2;错误族见各自 typed 类)──────────────────────────────────────────
1733
- * ① 同 `idempotencyKey` 重试 ⇒ 200 回原成功响应(真幂等,不打第二次 CAS);
1734
- * ② 已 `DECIDED` 后的**异决** ⇒ 409 `conflict.ask_decided`
1735
- * ({@link import("../errors.js").AskDecidedError},带首决回显 `decision`/`decidedAtMs`/`actor`,
1736
- * **server ≥7.15.0 起另带 `decisionNote`**(行上有才发;#229 翻面,见 {@link AskDecisionBody.note}));
1737
- * 同 key 打到另一 askId ⇒ 409 `conflict.ask_idempotency`
1738
- * ({@link import("../errors.js").AskIdempotencyConflictError});
1739
- * ③ `PARKED`/`DENIED`/`VOID` 后到达 ⇒ 410 ({@link import("../errors.js").AskGoneError})。
1740
- * `gone.ask_parked` 带 gate 对账坐标三件 `{sessionId, gateBoundCallId, gateBoundInputHash}` ——
1741
- * 🔴 **不含 checkpoint token**(resume 凭证从不外发);壳按 `sessionId` 走现行 durable gate 流程。
1742
- * ④ `PARKING` 中到达 ⇒ 425 `parking.ask_retry`({@link import("../errors.js").AskParkingError})。
1743
- * 🔴 **不是「重试可成」**:窗已关闭,回决不可能再被接受;重试取的是**终局路由信息**
1744
- * (轮询到 410 拿 gate 坐标),不是重试决议受理。425 体**不含** gate 坐标(PARKING 态坐标尚未写入)。
1359
+ * ── 响应(错误族见各自 typed 类)──────────────────────────────────────────────────────────────
1360
+ * ① 200 首决或幂等回放({@link AskDecisionAck});同 `idempotencyKey` 重试 ⇒ 回**原**成功响应(真幂等,不打第二次 CAS);**不带 / 换 key 的二次答 ⇒ 409**(下);
1361
+ * ② 200 + `accepted: "parked_redeemed"`({@link AskDecisionParkedRedeemed}):卡窗到期后已转后台候批(`PARKED`),本口走既有的耐久赎回腿 —— 用 {@link isAskDecisionParkedRedeemed} 判别;
1362
+ * ③ 已 `DECIDED` 后的**异决**(或不带同 key 的再答)⇒ 409 `conflict.ask_decided`({@link import("../errors.js").AskDecidedError},带首决回显 `decision`/`decidedAtMs`/`actor`/`decisionNote`);
1363
+ * 同 key 打到另一 askId ⇒ 409 `conflict.ask_idempotency`({@link import("../errors.js").AskIdempotencyConflictError});
1364
+ * ④ `DENIED`/`VOID` 的卡(撤卡 / 取消 / 路由失败 …;**没有人决过它**)⇒ 410 `gone.ask` + `state` + `cause?`({@link import("../errors.js").AskGoneError});转停驻但门已不在原处 ⇒ 410 `gone.ask_parked`(带 gate 对账坐标三件,
1365
+ * 🔴 不含 checkpoint token;壳按 `sessionId` 走现行 durable gate 流程);
1366
+ * ⑤ `PARKING` 中(转 park 的一瞬)⇒ **425 `parking.ask_retry`** + `Retry-After` 头({@link import("../errors.js").AskParkingError};**这一次决议没有被受理**,等头里的秒数后**重发**同一份决议:落成 `PARKED` ⇒ 赎回臂 200,终局了 ⇒ 410);
1367
+ * ⑥ 店读不出这只问的行 ⇒ `500 internal.error`(**可重试**)。同一根上读口({@link ToolApprovalsResource.readAsk})在这种情况下答 `404 not_found.ask`。
1745
1368
  *
1746
1369
  * ── 其余码 ──────────────────────────────────────────────────────────────────────────────────
1747
- * 404 `not_found.ask`(未知 askId / taskId 不匹配 / 非属主 —— **无存在性谕示**,三者同形)。
1748
- * ⚠️ **跨 leg 不落这里**(车4 §12-F/F22 改述):park→resume 铸的是**新 askId**,而**旧行留存**在它的
1749
- * 终态上 ⇒ 拿旧 askId 回决拿到的是旧行的终局答复(200 幂等回放 / 409 首决回显 / 410),不是 404。
1750
- * 「决议永不跨 leg 复用」这条保证来自**新 leg 有自己独立的一行**,不是来自旧行消失。
1751
- * 400 `request.invalid_json` / `request.body_shape`;401 缺 principal。
1370
+ * 404 `not_found.ask`(未知 askId / taskId 不匹配 / 非属主 —— **无存在性谕示**,三者同形)。运维席可决别人的卡(决断口的门对运维开放;`actor.via = "operator"`)。
1371
+ * ⚠️ **跨 leg 不落这里**:park→resume 铸的是**新 askId**,而**旧行留存**在它的终态上 ⇒ 拿旧 askId 回决拿到的是旧行的终局答复(200 幂等回放 / 409 首决回显 / 410),不是 404。
1372
+ * 400 `request.invalid_json` / `request.body_shape`(含退役键 `settledBy`,体顶层 `field: "settledBy"`)/ `request.field_invalid` / `request.field_conflict`;401 缺 principal。
1752
1373
  *
1753
- * 🔴 **不是 submit 类、SDK 不自动重试**:回决恰好结算一次持久 CAS。要幂等重试请自带
1754
- * {@link AskDecisionBody.idempotencyKey}(那才是本端点唯一的重试凭据)。 */
1374
+ * 🔴 **不是 submit 类、SDK 不自动重试**:回决恰好结算一次持久 CAS。要幂等重试请自带 {@link AskDecisionBody.idempotencyKey}(那才是本端点唯一的重试凭据)。 */
1755
1375
  decideAsk(taskId: string, askId: string, body: AskDecisionBody, opts?: {
1756
1376
  signal?: AbortSignal;
1757
- }): Promise<AskDecisionAck>;
1377
+ }): Promise<AskDecisionAck | AskDecisionParkedRedeemed>;
1758
1378
  }
1759
1379
  export {};
1760
1380
  //# sourceMappingURL=tool-approvals.d.ts.map