@sema-agent/settings-schema 19.0.1 → 20.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.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,113 @@
8
8
 
9
9
  ## Unreleased
10
10
 
11
+ ## 20.0.0 — 2026-11-03 — major:目录条目 `ModelEntry.thinkingLevelMap`(引擎 `Model.thinkingLevelMap` 的声明位)· 词闭集 `MODEL_THINKING_LEVEL_WORDS` / 型 `ModelThinkingLevel` / 席位 schema `ModelThinkingLevelMap` · 运行期导出 `HOOK_ENTRY_FIELDS` / 型 `HookEntryFields` · hook 条目承运余下四个 CC 键 `rewakeMessage` / `rewakeSummary`(command)· `cloud`(command / http)· `continueOnBlock`(prompt),按 CC 的值形判 · 词闭集 `HOOK_CLOUD_WORDS` / 型 `HookCloud`(读者折 `cloud` 的参考)· `rewakeMessage` / `rewakeSummary` / `continueOnBlock` 的坏值自此是坏块(校验收紧) · 线上读口不编造生产方没发的域 —— `readEffectiveWire` 对载荷上缺席的 `a2a` 不再补 `{ peers: [] }`(`EffectiveWire.a2a` 改可选)· 承运表 `WIRE_CARRIED_DOMAINS`(`prompts` / `a2a`)/ 型 `WireCarriedDomain`
12
+
13
+ > 档位(按发版纪律):**major** —— 校验收紧、类型面不加性、同一份配置 / 载荷解析出不同结果(发版纪律「破坏性变更必 bump major」点名的几类)。本版三件各有「同一输入解析结果会变」的读数,下面逐条列全(件序:目录条目 `thinkingLevelMap` · hook 条目余下四个 CC 键 · 线上读口):
14
+ > **目录条目的 `thinkingLevelMap`** —— **一处读数会变**:目录条目上的 `thinkingLevelMap` 键,此前被当作未知键剥掉(读口报 `unknown-keys-dropped`),条目照装;自此合形的装上,**坏形(未知键 · 非对象 · 空串值 · 非串非 `null` 值)的条目整条被拒** —— 读口逐条丢并报 `entry-dropped`(同域**未被引用**的其余条目照常生效;**被 `roles` / `atMention.only` / `tierGroups` 引用的条目坏形 ⇒ 引用悬空,既有级联律把整个 `models` 域退成缺省:只发 `domain-defaulted`、目录退成空、兄弟条目一并丢,不发 `entry-dropped`**〔任何被引用的坏条目都是这个答案;19.0.x 里这类条目全装、只剥键;默认模型 `roles.default` 最常见〕;目录里一条好条目都不剩时,含它是唯一一条,走既有的零幸存者律:不发 `entry-dropped`,只发 `domain-defaulted`、`models` 退成空目录),文档面(`getDomain` / 导出)整域抛,写口拒;例:`{ name, id, thinkingLevelMap: 123 }` 在 19.0.x 装上(键被剥),本版整条被拒。没写这个键的条目,读数与内容哈希逐字不变。
15
+ > **hook 条目余下四个 CC 键** —— 校验收紧,**同一输入解析结果会变的两处**:① 带这四个键的条目,装上的那一份自此带着它们(此前被当作契约外的键剥掉;`cloud` 写什么装什么);② `rewakeMessage` / `rewakeSummary` / `continueOnBlock` 带**坏值**的条目 —— 空串或非串的 `rewakeMessage` / `rewakeSummary`、非布尔的 `continueOnBlock` —— 自此是坏块:非守卫事件里剔那一条,**守卫事件(`PreToolUse` / `PermissionRequest`)里整份设置不装,同文件的 `permissions.deny` 一起不生效**;此前这些键不论值是什么都被剥掉、整份照装(值里藏守卫迹象的除外:那一直是整份拒,见 `classifyHooksConfig` 头注)。上面是分类器的读法;zod 面(`HooksConfig` / `HookEntry` / 逐型五只)对该值**整个拒**,`readSettingsUnit("hooks", …)` 对该设置单元**整个答 `unreadable`**(此前都受理)——不止「剔那一条」。`cloud` 不在第 ② 处:它没有坏值。
16
+ > hook 条目这一件没有第三处:新列排在每行**行尾**(公共字段之后),所以已是坏块的条目 `field` 点名的字段、装上的既有键序都不变(19.0.0 的 `args` / `onFailure` 列在行中间,那一版因此有「`field` 改点名」的一处;本版没有,有钉)。对不带这四个键的文档,读数逐字不变。
17
+ > **线上读口(`readEffectiveWire` 的 `a2a`)** —— 类型面不加性(`EffectiveWire.a2a` 由必填变可选:直读 `readEffectiveWire(…).a2a.peers` 的消费方编译红),**同一输入解析结果会变的两处**:① 不带 `a2a` 的线上载荷(18.0.0 之前的设置契约铸出的中心载荷不带它):读出形里**没有** `a2a` 成员(此前补成 `{ peers: [] }`,与「中心说了空名册」同读);
18
+ > ② 嵌入方传自有键而值为 `undefined` 的 `prompts` / `a2a`(JSON 载荷里没有 `undefined`,只有进程内调用方会碰到):读作缺席(此前 `prompts` 读出一个值为 `undefined` 的自有成员、`a2a` 读出 `{ peers: [] }`)。
19
+ > 线上读口这一件不变的:载荷带 `a2a` 的读数(含 `{}` 与 `{ peers: [] }`:在场的空名册原样保真);整域读不进 ⇒ `{ peers: [] }` + `domain-defaulted`;读店 / 读 `config.d` 的一侧(`buildEffective` / `FileConfigStore` / `loadLocalConfig` / `emptyEffective`)照旧物化 `a2a`,`EffectiveConfig.a2a` 仍必填;其余 15 个域的线上读法。
20
+ > 加性的部分:新导出九个(`MODEL_THINKING_LEVEL_WORDS` 值、`ModelThinkingLevel` 型、`ModelThinkingLevelMap` 值与型、`HOOK_ENTRY_FIELDS` 值、`HookEntryFields` 型、`HOOK_CLOUD_WORDS` 值、`HookCloud` 型、`WIRE_CARRIED_DOMAINS` 值、`WireCarriedDomain` 型);`ModelEntry` 多一个可选键;hook 条目字段表多四个可选列(`CommandHookEntry` 多可选键 `rewakeMessage` · `rewakeSummary` · `cloud`,`HttpHookEntry` 多可选键 `cloud`,`PromptHookEntry` 多可选键 `continueOnBlock`;对 `keyof` 写穷举表的消费方在提货时编译红,是提货成本)。
21
+ > **迁移**:不配一次性迁移。(a)目录条目 `thinkingLevelMap` 与 hook 三键(`rewakeMessage` / `rewakeSummary` / `continueOnBlock`)的坏形 / 坏值没有可猜的正确值,要人改。升级前检查目录条目里已有的 `thinkingLevelMap`(含存下来要续跑的 models 文档、中心名册草稿),先查被 `roles` / `atMention.only` / `tierGroups` 引用的条目(坏形会让整个目录退空,不是只丢那一条):未知键 / 非对象 / 空串值 / 非串非 `null` 值改成合形(键取词表七词,值取非空串或 `null`),或把这个键整个删掉(删掉后读数逐字同 19.0.x)。另检查设置文件、请求体里的 `hooks`(含存下来要续跑的):把空串的 `rewakeMessage` / `rewakeSummary` 改成非空串、把非布尔的 `continueOnBlock` 改成布尔,或把这三个键整个删掉(删掉后读数逐字同 19.0.0)。不确定就先跑一遍 `classifyHooksConfig`:结局不是 `loaded`,或 `field` 是这三个键之一,就是要改的那一条。(b)线上读口:没有存量数据要迁(变的是线上读法,不是存储形)。消费方把 `.a2a` 的直读改成先判在场;要旧读法(缺席与空名册同读)的一侧补 `?? { peers: [] }` 一行。
22
+ > 律 · hook 条目:hook 条目的字段集只有一张表(`HOOK_ENTRY_FIELDS`),分类器、zod 面、条目类型同读它;「承运」与「执行」是两件事 —— 本包只判形,不执行。
23
+ > 律 · 线上读口:线上读口不编造生产方没发的域 —— 按在场性承运的域只有一张表 `WIRE_CARRIED_DOMAINS`,在场判据只有一个(载荷的自有键,且值不是 `undefined`)。
24
+
25
+ ### 目录条目的 `thinkingLevelMap`
26
+
27
+ - **席位**:`ModelEntry.thinkingLevelMap?`,引擎 `Model.thinkingLevelMap` 的声明位。键闭集 = 词表 `MODEL_THINKING_LEVEL_WORDS`(`off` `minimal` `low` `medium` `high` `xhigh` `max`,包根与 `./types`;型 `ModelThinkingLevel`),全可选;值 = **非空串**(供应商在这一档上自己的取值)或 **`null`**(这一档在这个模型上不支持);缺键 = 供应商缺省。
28
+ 席位的 schema `ModelThinkingLevelMap`(值与型)从词表铸键并 `.strict()`,条目里的席位就是这只实例。
29
+ - **三态,同 `reasoning` / `vision`**:缺席 = 未声明(本包不补 `{}`);`{}` = 声明了、没有覆盖,与缺席是两种声明(内容哈希区分)。
30
+ - **坏形整条拒,不剥键、不折默认**:未知键(含大小写变体、邻词、原型名)、非对象(含整张表写 `null`、数组)、空串值、非串非 `null` 的值 ⇒ 这一条目不过:读口逐条丢并报 `entry-dropped`(同域**未被引用**的其余条目照常;**被 `roles` / `atMention.only` / `tierGroups` 引用的条目坏形 ⇒ 引用悬空,既有级联律(悬空引用的 refine)把整个 `models` 域退成缺省**:目录退成空、只发 `domain-defaulted`、不发 `entry-dropped`,兄弟条目一并丢 —— 任何被引用的坏条目(例:缺 `id`)都是这个答案,本席位不是特例;但 19.0.x 里这类条目全装、只剥键,所以这也是档位段「一处读数会变」的一部分;目录里一条好条目都不剩时,含它是唯一一条,走既有的零幸存者律 —— 与任何别的坏目录条目同答:不发 `entry-dropped`,只发 `domain-defaulted`、`models` 退成空目录),文档面(`getDomain` / 导出)整域抛,写口拒。剥掉一个拼错的档名,就是把「这一档关不掉」悄悄读成「这一档照常」,所以这里不走 `compat` 的解析透明(那条的形归读它的消费方);词表是本包的闭集,坏形就是坏条目。拒句点名席位与坏字段。
31
+ - **本包只承载与判形,不判语义**:串的内容是供应商取值,怎么用(哪条线缆读哪一档、`null` 怎么落到线缆上)归读它的消费方。
32
+ - **与引擎的锚**:引擎的 `ModelThinkingLevel` 只在类型层,漂移门 ⑫(`test/upstream-drift.test.ts`)把本包的词表联合、席位的整个型、席位的键集与引擎根导出的 `Model` 的 `thinkingLevelMap` 双向对拍 —— 引擎加词 / 删词 / 放宽值型 / 改字段名,`npm run typecheck` 红;运行期只能单向(本包每个词被引擎的 `isThinkingLevel` 认)。**引擎加词只在 typecheck 咬,vitest 单跑不红。**
33
+ 引擎的值型是任意 `string`,本包的值是**非空**串(空串放行会让一个空 effort 上线缆)—— 运行期的收紧,类型层同为 `string | null`。
34
+ - **三问** —— **谁需要**:线缆上某档关不掉、或要换个拼法的部署(例:`anthropic-messages` 条目要把某档落到另一档)—— 此前目录条目与 env 腿都没有这一席,声明不了;
35
+ **谁受伤**:此前在目录条目上写了 `thinkingLevelMap` 的部署 —— 该键被剥掉、条目照装;自此写坏的(上面四类)条目被拒、条目从目录里消失(同域未被引用的其余条目照常;**被 `roles` / `atMention.only` / `tierGroups` 引用的条目写坏 ⇒ 整个目录退空并发 `domain-defaulted`,最常见的就是默认模型那一条**;若它是唯一一条,目录读成空),合形的则第一次真的到达消费方;没写这个键的部署零变化。
36
+ **补偿**:拒句点名席位与坏字段,改成合形(键取词表七词、值取非空串或 `null`)或删掉这个键即可,被引用的条目先改;缺席即旧行为。
37
+
38
+ ### 运行期导出 `HOOK_ENTRY_FIELDS`
39
+
40
+ - hook 条目的字段表(每型 → 字段名 → 取值类,`?` 结尾 = 选填)此前是模块私有的 —— 19.0.0 的包里有定义,包根与 `./hooks` 都取不到,要把「条目承运哪些字段」投影出去的消费方只能自己抄一份。现导出 `HOOK_ENTRY_FIELDS`(包根与 `./hooks` 同一只对象,逐行深冻结)与型 `HookEntryFields`(= `typeof HOOK_ENTRY_FIELDS`)。字段序即装上的条目的键序(`args` 在 `shell` / `async` / `asyncRewake` / `onFailure` 与公共字段之前,`onFailure` 在公共字段之前 —— 与 19.0.0 节第 ③ 处所述一致)。条目类型照旧从它派生。
41
+ - **分类器读的是闭包私有的投影,不是这一只导出**:分类器被消费方的生成器整函数抄走,闭包里除登记的注入名 `HOOK_EVENTS` 外不能读任何导出声明,私有件也不能经导出表达式逃逸 —— 否则拒抄。所以它读 `HOOK_ENTRY_FIELDS_READ`(闭包私有,与 `HOOK_ON_FAILURE_ACCEPTED` 同形):逐行逐字段全写、以 `HookEntryFields` 作型标注 —— 少一行、多一行、换一个取值类,编译红;钉再核运行期:导出表的每个字段在分类器里的必填 / 选填 / 取值类判法与表所写一致,装出来的键序 = `type` + 表序。
42
+ 导出与投影本身对分类器的判法逐位不变(判法随字段表;四键承运见下面「hook 条目余下四个 CC 键」);闭包文本的变化 = 私有件 `HOOK_ENTRY_FIELDS` + `HOOK_ENTRY_COMMON_FIELDS` 换成 `HOOK_ENTRY_FIELDS_READ`(公共四字段在投影里写开)。**这不是「同一引用」**:导出表与分类器的投影是两只对象,由型标注与差分钉咬住不漂。
43
+ - **三问** —— **谁需要**:要把 hook 条目承运的字段投影给别人的消费方(服务端的能力位);**谁受伤**:无(两个新导出,导出本身不改解析读数);**补偿**:不适用。
44
+
45
+ ### 消费方提货
46
+
47
+ - **server 7.147.0**:能力位 `settingsContract.hookEntryFields` 从 `HOOK_ENTRY_FIELDS` 投影,退役本地镜像;目录条目的 `thinkingLevelMap` 随条目到达(中心名册透传 · env 腿 · `GET /v1/models` 投影 · anthropic `compat` 分读由 server 自己的版本接),读 `MODEL_THINKING_LEVEL_WORDS` / `ModelThinkingLevel` 的穷举处补词表。
48
+ - **web-admin**:模型目录编辑面可选地承运 `thinkingLevelMap`(键取词表七词,值取非空串或 `null`);不读也不受影响 —— 但写坏的条目自此会在读口被丢,表单应只产合形。
49
+ - **client-core**:由 `classifyHooksConfig` 生成的读器副本要重生成 —— 闭包读的私有件由 19.0.x 的私有 `HOOK_ENTRY_FIELDS` + `HOOK_ENTRY_COMMON_FIELDS` 换成 `HOOK_ENTRY_FIELDS_READ`(公共四字段在投影里写开),字段表多四列、取值判多 `nonEmpty` · `any` 两个分支,行为随表(`rewakeMessage` / `rewakeSummary` / `cloud` / `continueOnBlock` 承运,`rewakeMessage` / `rewakeSummary` / `continueOnBlock` 的坏值是坏块 —— 见 hook 条目余下四个 CC 键一节);自由名仍只有 `HOOK_EVENTS`;生成器照旧整函数抄。
50
+ - **cli**:无读点(壳零直读这两处)。
51
+ - 文书:README 升级指引(19.0.x → 20.0.0)· `llms.txt` / `llms-full.txt` · `docs/CONSUMER-INTEGRATION.md` §19 · `docs/API-SURFACE.md` 重生。
52
+
53
+ ### 钉
54
+
55
+ `test/thinking-level-map-20.0.0.test.ts`(词表七词与导出〔包根 = `./types` 同一份〕· 席位 schema 的键从词表铸 · 七个键各一的串值 / `null` 正控 · `{}` 与缺席是两种声明 · 坏形整条拒〔未知键含大小写变体 / 原型名 / 自有键 `__proto__`、好键 + 未知键同在、七个空串值、非对象、非串非 `null` 值〕· 缺席不补 `{}` · 五条读口 + 写腿同班车〔带席位逐字交出且零告警;坏形逐条丢 `entry-dropped`、文档面抛、写口拒且不落盘;唯一一条就是坏条目 ⇒ 与缺 `id` 的唯一条目同答〔零幸存者律〕〕· 内容哈希按值参与)·
56
+ `test/upstream-drift.test.ts` 门 ⑫(词表联合 / 席位的整个型 / 席位的键集与引擎 `Model.thinkingLevelMap` 双向同,另一道 `any` 判别守值型位,七颗 `@ts-expect-error` 牙;运行期单向)·
57
+ `test/hook-entry-fields-20.0.0.test.ts`(两处导出同一只 · 行 = 条目 type 闭集 · 深冻结 · 型面 · 每型字段序与 19.0.0 节第 ③ 处所述一致 · 闭包私有的投影从源码求值后与导出表逐行逐字段深等〔含键序〕· 与分类器的差分)·
58
+ `test/docs-20.0.0-fields.test.ts`(文书对账)。
59
+
60
+ ### hook 条目余下四个 CC 键
61
+
62
+ - **CC 真形**(逐键,坐标 `cli309.js:252382` —— 条目 schema 工厂 `_s()` 里五个 `u({…})`,一行压缩码;值形照 CC,CC 不判的本包不判):
63
+ - `rewakeMessage`(只 command):`o().min(1).optional()` —— 串,**不允许空串**(`min(1)`),别的不判:空白串、多行、含 NUL 都是值。CC 标 `@internal`:`asyncRewake` 的 hook 以退出码 2 退出时,系统提醒给模型的前缀。
64
+ - `rewakeSummary`(只 command):同形(`o().min(1).optional()`)。CC 标 `@internal`:同一时刻给用户的一行终端摘要,CC 缺省 `Stop hook feedback`。
65
+ - `cloud`(command 与 http):`B(["device","skip"]).optional().catch("skip")` —— 词表 `device` | `skip`,CC 标 `@internal`:云会话由这台机器驱动时,这个 hook 能不能被带进云会话。**`.catch("skip")` 接住内层的任何解析失败**(`$ZodCatch`:内层有 issue 就换成 catch 值,`cli309.js:252268`),所以词表外的任何值(含非串、`null`、数组、对象)在 CC 里都合法:读作 `skip`,文件照装。**本包同:任意值照带** —— 不判;也不折成 `skip`(那是改写作者写下的值),也不剥键(剥掉会把「不上云」读成缺省:command 缺省下,脚本读得到、钉得住且在云会话可写范围之外的会被带上云)。折法**由读者折**:`HOOK_CLOUD_WORDS` 是它的参考,不是检查。
66
+ - `continueOnBlock`(只 prompt):`O().optional()` —— 布尔,`false` 是值。prompt 条目判「不通过」产出 `decision: "block"` 时的 `continue` 取值(CC 缺省 false:这一轮结束)。
67
+ agent 与 mcp_tool 两型的 schema 没有这四个键;别的型上写它们仍是契约外的键(剥掉,不算坏块,连坏值也不算;键下装着守卫迹象的除外 —— 那一直是整份拒,不因本版改变)。
68
+ - **坏值 = 坏块**(`rewakeMessage` / `rewakeSummary` / `continueOnBlock`,与 19.0.0 的 `args` / `onFailure` 同律):非守卫事件剔那一条、守卫事件整份拒,`field` 点名那个键;不剥键、不折默认,缺席就是缺席(本包不补缺省)。
69
+ - **自述订正**:此前两处自述「不比 CC 松」——`src/hooks-config.ts` 头注「a document CC would load may be rejected here, never the reverse」与 `docs/CC-DIVERGENCE.md`「本包不登比 CC 更松的偏离」—— 与行为不符:这四个键被剥掉、不看值,守卫事件里 `rewakeMessage: ""` / 非布尔 `continueOnBlock` 照装,比 CC 松(19.0.0 节「仍不承运」条已披露为已知限制)。本版承运它们之后,CC 五型条目 schema 上的每个**键**都在字段表里,H7 改写成逐键同归属型,那一条已知限制关闭;头注收窄成「列出来的偏离都更严 + 键覆盖」。已发布的 19.0.0 节照原样保留。
70
+ **仍未收的一处更松的面**(**已知限制**,本版不动):`http` 条目的 `url` —— CC 的 schema 判 URL 语法(`url:o().url()`),本包只判非空串且不含 NUL,所以守卫事件里 `url: "x"` 照装,比 CC 松。收它要在分类器闭包里用内建 `URL` 并让读器生成器跨仓登记,是另一类设计,不并进本版;翻面条件 = URL 语法判落地。
71
+ - **词闭集**:`HOOK_CLOUD_WORDS = ["device", "skip"] as const`(包根与 `./hooks`)· 型 `HookCloud`:**读者折法的参考**,分类器不读它(`cloud` 的值不判,条目类型里 `cloud` 的型是 `unknown`)。登记表 `docs/API-SURFACE.md` 已重生。
72
+ - **一事一源**:字段表仍是唯一声明 —— 两个新取值类(`nonEmpty` = CC 的 `min(1)`、`any` = 不判、原值照带,列与列表拷贝一层同 `record`)是表里的两个词,分类器的取值判、zod 面、条目类型都从表读;没有按字段名写的分支。分类器闭包没有新的私有声明(没有词表镜像),也没有新增内建词,自由名仍只有 `HOOK_EVENTS`。
73
+ - **承运 ≠ 执行**:`@internal` 不是不承运的理由。`rewakeMessage` / `rewakeSummary` / `cloud` 是 CC 标 `@internal` 的键,`continueOnBlock` 属 prompt 型:本包只判形,不执行,读到它们的消费方如实带着;server 侧的执行面另票处理,本版不规定。
74
+ - **三问** —— **谁需要**:在 CC 与本栈之间搬运 `hooks` 的部署与壳:按 CC 写的、带这四个键的 hooks 文档,此前装上的那一份不带它们(静默剥掉),经本栈再带出去时键丢了;坏值也不被拦(守卫事件里 `rewakeMessage: ""` 照装,CC 自己会拒)。
75
+ **谁受伤**:hook 条目这一件的第 ② 处 —— 在 `rewakeMessage` / `rewakeSummary` / `continueOnBlock` 上写过坏值的设置文档;守卫事件里是整份不装。按 CC 写的文档不受这一处伤:这三个键 CC 自己也拒同样的值(空串的 `rewakeMessage` / `rewakeSummary`、非布尔的 `continueOnBlock`);`cloud` 与 CC 同读,CC 里能装的文件这里一样装。
76
+ **补偿**:坏块的 `field` 点名那个键;改成合法值即可,不想要这些键的文档删掉它们,读数逐字同 19.0.0。
77
+
78
+ ### hook 条目四键 · 消费方提货
79
+
80
+ - **server**:`CommandHookEntry` / `HttpHookEntry` / `PromptHookEntry` 多可选键(随条目到达)· `HOOK_CLOUD_WORDS` / `HookCloud`(折 `cloud` 时的参考)。server 侧对 `rewakeMessage` / `rewakeSummary` / `cloud` 的执行面另票处理,本版不规定;`continueOnBlock` 与 prompt 条目的其余字段同路。
81
+ - **cli**:`CommandHookEntry` / `HttpHookEntry` / `PromptHookEntry` 的四个键 —— 壳若自己执行 hook(引擎属主事件 `ENGINE_OWNED_HOOK_EVENTS` 以外)执行它们、如实带着或明拒;`cloud` 要折就按 CC 折(词表外的任何值读作 `skip`);「能不能装」仍只问 `classifyHooksConfig`。
82
+ - **client-core**:由 `classifyHooksConfig` 生成的读器副本要重生成 —— 闭包读的私有件由 19.0.x 的私有 `HOOK_ENTRY_FIELDS` + `HOOK_ENTRY_COMMON_FIELDS` 换成 `HOOK_ENTRY_FIELDS_READ`(公共四字段在投影里写开),字段表多四列、取值判多 `nonEmpty` · `any` 两个分支,行为随表(`rewakeMessage` / `rewakeSummary` / `cloud` / `continueOnBlock` 承运,`rewakeMessage` / `rewakeSummary` / `continueOnBlock` 的坏值是坏块 —— 见 hook 条目余下四个 CC 键一节);自由名仍只有 `HOOK_EVENTS`;生成器照旧整函数抄。
83
+ - **web-admin**:`HookEntry` 一族的编辑面可选地承运四列(`cloud` 的编辑面可以拿 `HOOK_CLOUD_WORDS` 做选项);不读也不受影响(加性的类型面)。
84
+ - **sdk**:类型面 —— 多四个可选键(`cloud` 的型是 `unknown`);对 `CommandHookEntry` / `HttpHookEntry` / `PromptHookEntry` 的 `keyof` 写穷举表的地方编译红,补列。
85
+ - 文书:README hooks 条 + 升级指引(19.0.x → 20.0.0)· `llms.txt` / `llms-full.txt` · `docs/CONSUMER-INTEGRATION.md` §18 · `docs/CC-DIVERGENCE.md` H7 改写 · `docs/API-SURFACE.md` 重生。
86
+
87
+ ### hook 条目四键 · 钉
88
+
89
+ `test/hooks-cc-keys-20.0.0.test.ts`(承运集:CC 五型全键装上与键序〔新列在行尾〕、归属型 × 别型仍剥 · `rewakeMessage` / `rewakeSummary` 非空串〔空白 / 多行 / NUL 是值〕与坏值 · `cloud` 两词与任意值照带〔词表外 · 非串 · `null` · 数组 · 对象 · 原型名,三个事件〕· `continueOnBlock` 布尔与非布尔 ·
90
+ 守卫轴整份拒 / 非守卫剔一条 / 键下装迹象仍整份拒 / 迹象先于更靠前的坏字段 · 已是坏块的条目 `field` 不挪 · zod 面投影 · 词表导出 · 类型面 `keyof` 精确 · 🚧 已知限制(url 语法)· 自述句与文书对账)· `test/hooks-command-fields-19.0.0.test.ts`(4 格「仍不承运」读法与已知限制钉翻成承运 / 坏块 / 照带)· `test/hooks-classify-13.0.0.test.ts`(两处「契约外键」例子由 `rewakeSummary` / `cloud` 换成 CC 条目 schema 上没有的键;差分门语料的 `extra` 样本同换)· `test/docs-19.0.0.test.ts`(H7 钉标题改准)。
91
+
92
+ ### 线上读形与承运表
93
+
94
+ - **`WIRE_CARRIED_DOMAINS = ["prompts", "a2a"] as const`**(包根与 `./types`)· 型 **`WireCarriedDomain`**:表里的域在 `GET /effective` 载荷上缺席 ⇒ `readEffectiveWire` 的读出形里同样缺席;在场 ⇒ 照该域既有读法(`prompts` 原样,由消费方判;`a2a` 解析、逐条抢救、整域读不进 ⇒ 缺省 + 告警)。
95
+ `EffectiveWire` 由这张表派生:表里除 `prompts` 外的域在线上读形上是可选成员(今天就是 `a2a`)。`prompts` 自 0.13.0 起就是缺席进缺席出,本版只是把它的专用臂并进这张表、用同一个在场判据。
96
+ - **为什么只有这两个域**:不在表里的 15 个域在 1.0.0 起就在域表上,`buildEffective` 恒物化它们,支持面内的每个生产方都恒发 —— 线上缺席对它们不可达,读作契约缺省(与读店同一份缺省;`governance` / `limits` 的缺省本身就是「每键不说」,空 `models` 目录读作「不管模型面」,集合域空表 = 没有条目)。
97
+ `a2a` 是 18.0.0 才进域表的:比它旧的生产方不懂它、不发它,线上缺席是常态形,补空名册就是替生产方说了一句它没说的「空」。**之后加进域表的域一律进这张表**(钉:域表 = 恒发名单 ⊎ 承运表,新域不表态即红)。
98
+ - **消费方读 `a2a` 的三态**:缺席(读出形里没有 `a2a` = 生产方不懂此域)· 在场(值即解析结果,`{ peers: [] }` = 说了空名册)· 读不进(在场、值为 `{ peers: [] }`,同时有一条 `domain-defaulted`,域 `a2a`)。
99
+ 18.0.0 起 `buildEffective` 恒物化 `a2a`,所以 ≥ 18.0.0 的中心恒发它(没存文档也发 `{ peers: [] }`):线上缺席 ⇔ 生产方早于本域。
100
+ - **读店 / 读 `config.d` 不在本律内**:那两腿的读者就是本包,恒懂每个域,没有「生产方不懂」这一态 —— `config.d/a2a.json` 不存在与存在空名册同读 `{ peers: [] }`。要问「文件在不在」的一侧读既有的三态读口 `readConfigDFileReadingSync(root, "a2a")`(`absent` / `present` / `refused`)。
101
+ - **三问** —— **谁需要**:要把「旧中心没说」与「中心说了空名册」分开的消费方(例:在原始回体上判 a2a 三态的壳 —— 缺席是「这台中心不懂 a2a」,在场的空名册才是「中心撤了对端」);此前解析后两态同读,只能绕开契约读口去看原始载荷。
102
+ **谁受伤**:直读 `readEffectiveWire(…).a2a.peers` 的线上消费方 —— 型上 `a2a` 变可选,编译红即通知;运行期读老中心载荷时那一处拿到 `undefined`。
103
+ **补偿**:`readEffectiveWire(…).a2a ?? { peers: [] }` 一行恢复旧读法;线上型本来就把各域写成可选成员的消费方零改动。
104
+
105
+ ### 消费方提货
106
+
107
+ - **server 7.147.0**:中心腿把读出形换装成本仓自己的型,那里的 `a2a` 已是可选成员 —— 零编译改动;老中心上 `a2a` 由 `{ peers: [] }` 变缺席,两者都不拨任何对端(按场景筛对端时空表与缺席同答)、重启指纹同为空;只需把它那一句「两腿都经契约读口、缺省已物化」的注释改准(中心没发 ⇒ 缺席)。本地腿(`FileConfigStore`)不变。
108
+ - **client-core**:原始回体上的 a2a 三态可以改读契约:`readEffectiveWire(body)` 的 `a2a` 不在 ⇒ 缺席;在 ⇒ 在场;在 + `domain-defaulted`(域 `a2a`)⇒ 读不进。旧的自证「`readEffectiveWire` 把缺席补成空名册」那一格翻面;`buildEffective` / `emptyEffective` 恒物化那两格不翻。
109
+ - **web-admin**:没有 a2a 读点;提货到 ≥ 18.0.0 之后 `buildEffective` 恒物化 `a2a`,中心载荷恒带它。
110
+ - **sdk / cli**:不读 `EffectiveWire` / `readEffectiveWire`;无动作。
111
+ - 一致性语料:wire 腿的派生只登记一条表示差异 —— `T1` 由「prompts 物化」泛化为承运表(id 改为 `T1-wire-carried-domains`,`DERIVATION_TRANSFORMS` 里读这个 id 的一侧随改);域腿金样零改;六条写显式 wire 金样的 case 去掉补出来的 `"a2a": { "peers": [] }`。
112
+ - 文书:README 升级指引(19.0.x → 20.0.0)· `llms.txt` / `llms-full.txt` · `docs/CONSUMER-INTEGRATION.md` §17.4 改准 + §20 · `docs/CONFORMANCE.md` T1 行 · `docs/API-SURFACE.md` 重生。
113
+
114
+ ### 钉
115
+
116
+ `test/wire-carried-domains-20.0.0.test.ts`(律:承运表 = `prompts` + `a2a`、域表 = 恒发名单 ⊎ 承运表 · 类型面 `EffectiveWire.a2a` 可选 / `EffectiveConfig.a2a` 必填 · a2a 线上三态:缺席、`a2a: undefined` 同读缺席、空名册保真、`{}` 物化、对端解析、四种整域坏形 ⇒ 在场 + `domain-defaulted` · 往返:≥ 18.0.0 中心无文档照发空名册、存了对端读回逐键同、老中心载荷过两道读口仍缺席 · 律外:恒发的域照旧物化、prompts 同一判据、读店 / 本地腿照旧物化)· `test/a2a-domain-18.0.0.test.ts`(「中心腿不带 a2a 也物化空名册」那一格翻面)· `test/conformance-coverage.test.ts`(T1 逐域记:承运表里每个域都要有语料让两腿真的分开)· `test/docs-20.0.0-wire-carried.test.ts`(文书对账)。
117
+
11
118
  ## 19.0.1 — 2026-11-03 — patch:随包文件去内部编号 + docs-hygiene K 组门 · 零幸存者律澄清与钉
12
119
 
13
120
  > 已知限制(复审两腿;另票收):已发 CHANGELOG 节里的内部编号(约 159 处)本版未改 —— 本仓此前没有成文的「已发节字节冻结」纪律,且有六个已发节与其 tag 不同;下一版先成文该纪律并配门(照 server 的已发节字节核),再决定是否做一次性清洗。同用途的编号 / 版本词表在 test/ 下仍有多份,随该票并成一张;门 K 认不出的复审项标号(如 WA-NN / L5 / M1 类)与语料数据文件里的编号同票。
package/README.md CHANGED
@@ -47,6 +47,30 @@ therefore shows only `zod`. Node built-ins only (`node:crypto`, `node:fs`).
47
47
  > zod 3, nested inside every zod-4 host). The move to zod 4 did not change what any schema accepts or produces —
48
48
  > the conformance corpus reads byte-identically on both — only the wording of validation errors (see CHANGELOG 11.0.0).
49
49
 
50
+ ## 升级指引:19.0.x → 20.0.0(BREAKING:目录条目 `thinkingLevelMap` 的坏形自此整条目被拒 · hook 条目承运余下四个 CC 键 `rewakeMessage` / `rewakeSummary` / `cloud` / `continueOnBlock`,其中 `rewakeMessage` / `rewakeSummary` / `continueOnBlock` 的坏值自此是坏块 · 线上读口不再替生产方补出缺席的 `a2a` —— `EffectiveWire.a2a` 改可选)
51
+
52
+ 三处**不加性**的边(目录条目的 `thinkingLevelMap` 坏形 · hook 三键的坏值 · 线上读口缺席的 `a2a`),外加一个加性的面(`HOOK_ENTRY_FIELDS` 运行期导出;三问与逐条细节见 CHANGELOG 20.0.0):
53
+
54
+ 1. **目录条目多一个可选席 `thinkingLevelMap`**(引擎 `Model.thinkingLevelMap` 的声明位):键取词表 `MODEL_THINKING_LEVEL_WORDS`(`off` `minimal` `low` `medium` `high` `xhigh` `max`,型 `ModelThinkingLevel`),值取非空串(供应商在这一档上的取值)或 `null`(这一档不支持);缺席 = 未声明,本包不补 `{}`。
55
+ - **读数变化(不加性)**:此前目录条目上写的 `thinkingLevelMap` 被当作未知键剥掉、条目照装(例:`thinkingLevelMap: 123` 装上、键被剥);自此合形的装上,**坏形(未知键 · 非对象 · 空串值 · 非串非 `null` 值)的条目整条被拒** —— 读口逐条丢并报 `entry-dropped`(同域未被引用的其余条目照常;**被 `roles` / `atMention.only` / `tierGroups` 引用的条目坏形 ⇒ 引用悬空,既有级联律把整个 `models` 域退成缺省**:只发 `domain-defaulted`、目录退空、兄弟条目一并丢,不发 `entry-dropped`;目录里一条好条目都不剩时,含它是唯一一条,走既有的零幸存者律:只发 `domain-defaulted`、`models` 退成空目录),文档面整域抛,写口拒。没写这个键的条目零变化。
56
+ - 动作:升级前检查目录条目(含存下来要续跑的 models 文档、中心名册草稿)里是否已有这个键,先查被 `roles` / `atMention.only` / `tierGroups` 引用的条目(例:默认模型);有就把坏形改成合形(键取词表七词、值取非空串或 `null`),或整个删掉这个键(删掉后读数逐字同 19.0.x)。
57
+ 2. **hook 条目的字段表运行期导出**(加性):包根与 `./hooks` 多 `HOOK_ENTRY_FIELDS`(每型 → 字段名 → 取值类,深冻结)与型 `HookEntryFields`。导出本身不改分类器的判法(判法随字段表);它读的是闭包私有的投影,与导出表以型标注咬合。
58
+ 3. 对 `ModelEntry` 的 `keyof` 写穷举表的地方编译红(多一个可选键):补一列。
59
+ 4. **`hooks` 条目的四个键此前被当作契约外的键剥掉,自此是契约字段**:command 条目的 `rewakeMessage` / `rewakeSummary`(非空串;CC 的 `min(1)`,空白 / 多行 / NUL 都是值)、command / http 条目的 `cloud`(**任意值照带** —— CC 的 `.catch("skip")` 把词表外的任何值读作 `skip` 且文件照装,本包不判、不折、不剥,由读者折;`HOOK_CLOUD_WORDS` = `device` | `skip` 与型 `HookCloud` 是折法的参考;缺席不补缺省)、prompt 条目的 `continueOnBlock`(布尔)。别的条目型上写这些键仍是契约外的键。
60
+ - 合形的值:装上的那一份自此带着它们(此前没有)。`rewakeMessage` / `rewakeSummary` / `cloud` 是 CC 标 `@internal` 的键:本包只判形、不执行,读到它们的一侧如实带着(server 侧的执行面另票处理,本版不规定)。
61
+ - **坏值**(空串或非串的 `rewakeMessage` / `rewakeSummary`、非布尔的 `continueOnBlock`;`cloud` 没有坏值):**非守卫事件里那一条 hook 被剔;守卫事件(`PreToolUse` / `PermissionRequest`)里整份设置不装,同文件的 `permissions.deny` 一起不生效**。此前这些键不论值是什么都被剥掉、整份照装。按 CC 写的文档不受这一处伤(这三个键 CC 自己也拒同样的值;`cloud` 与 CC 同读)。**例外 —— 值里装着守卫事件名记号**(例:`Stop` 事件的条目 `cloud: { "PreToolUse": "guard" }`):19.0.0 与 20.0.0 **都**整份拒(`guard-entry-invalid`,`field` 点名 `cloud`),本版没改这一条。zod 面与 `readSettingsUnit("hooks", …)` 对坏值则整个拒 / 整个答 `unreadable`(此前都受理)。
62
+ - 动作:升级前把设置文件与请求体里(含存下来要续跑的)空串的 `rewakeMessage` / `rewakeSummary` 改成非空串、非布尔的 `continueOnBlock` 改成布尔,或整个删掉这三个键(删掉后读数逐字同 19.0.0)。不确定就跑一遍 `classifyHooksConfig(settingsDoc)`:结局不是 `loaded`,或拒 / 剔项的 `field` 是这三个键之一,就是要改的那一条。
63
+ 5. 对 `CommandHookEntry` / `HttpHookEntry` / `PromptHookEntry` 的 `keyof` 写穷举表的地方编译红(多可选键):补列。已是坏块的条目 `field` 点名的字段不变(新列排在每行行尾)。
64
+ 6. **`readEffectiveWire` 对载荷上缺席的 `a2a` 不再补 `{ peers: [] }`**:读出形里没有 `a2a` 成员 = 生产方没发这个域(18.0.0 之前的设置契约铸出的中心载荷不带它);在场的空名册 `{ peers: [] }` 原样保真、与缺席分得开。
65
+ 按在场性承运的域只有一张表 `WIRE_CARRIED_DOMAINS`(`prompts` / `a2a`,型 `WireCarriedDomain`),在场判据只有一个:载荷的自有键且值不是 `undefined`(嵌入方传的 `prompts: undefined` / `a2a: undefined` 自此读作缺席)。
66
+ - 读不进不变:整域坏形 ⇒ `{ peers: [] }` + `domain-defaulted`(域 `a2a`)—— 消费方的三态 = 缺席 / 在场 / 在场且有该告警。
67
+ - 不变的一侧:`buildEffective` / `FileConfigStore` / `loadLocalConfig` / `emptyEffective` 照旧物化 `a2a`,`EffectiveConfig.a2a` 仍必填(`config.d/a2a.json` 不存在与空名册同读);文件在不在读 `readConfigDFileReadingSync(root, "a2a")`。其余 15 个域的线上读法不变。
68
+ - 动作:直读 `readEffectiveWire(…).a2a.peers` 的地方编译红 —— 先判在场;要旧读法补 `?? { peers: [] }` 一行。线上型本来就把各域写成可选成员的消费方零改动。
69
+
70
+ **迁移**:不配一次性迁移 —— 第 1、4 条的坏形 / 坏值没有可猜的正确值,要人改(各条「动作」);第 6 条没有存量数据要迁(变的是线上读法,不是存储形)。
71
+
72
+ 各消费方读哪些键、做什么见 `docs/CONSUMER-INTEGRATION.md`:§18(hook 条目四键)· §19(目录条目 `thinkingLevelMap` 与字段表导出)· §20(线上读口)。
73
+
50
74
  ## 升级指引:18.0.x → 19.0.0(BREAKING:hook 条目承运 `args` / `onFailure`,这两个键的坏值自此是坏块)
51
75
 
52
76
  一处**不加性**的边(三问与逐条细节见 CHANGELOG 19.0.0):
@@ -402,7 +426,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
402
426
  `promptArtifactFor`); 0.19.0 adds `limits`, the cost/rate-limit publication slot; 11.0.0 retires
403
427
  `runtime` — its tombstone is `RETIRED_DOMAINS`, see "One-time migrations" below; 18.0.0 adds `a2a`, the standing outbound
404
428
  A2A peer roster (`A2aConfig` / `A2aPeerSpec`, portable)),
405
- `EffectiveConfig`, `EffectiveWire`,
429
+ `EffectiveConfig`, `EffectiveWire` (20.0.0: the wire reader never fabricates a domain the producer did not send — `WIRE_CARRIED_DOMAINS`
430
+ (`prompts`, `a2a`) are carried by presence, so `EffectiveWire.a2a` is optional: absent = the producer predates the domain),
406
431
  `ENV_NAME`/`K8S_QUANTITY` boundaries, every domain's entry/config type.
407
432
  - **Pure config fns** (`config-fns.ts`): `buildEffective` (deterministic — `updatedAt` is a required param),
408
433
  `parseDomain`, `emptyEffective` (epoch-seeded), `statusRowsToPrune`, role helpers (`roleAtLeast`,
@@ -698,7 +723,8 @@ settings 单元读不进的成员**不是缺席**(`loosen` 可丢且要响,`tigh
698
723
  the output/decision shapes (`SyncHookOutput` / `HookSpecificOutput` / `HookPermissionRequestDecision`),
699
724
  the config surface (defined in `hooks-config.ts`, re-exported by `./hooks`): `HOOK_ENTRY_TYPES` (CC 2.1.296's five: command / prompt / agent / http /
700
725
  `mcp_tool`; the field table carries `args` — the exec-form argument list — on `command` entries and `onFailure` — `HOOK_ON_FAILURE_WORDS` = `continue` | `block`, type `HookOnFailure` —
701
- on `command` and `http` entries; carried, not executed: a consumer that reads `block` executes it or refuses it) and the ONE classifier `classifyHooksConfig(settingsDoc)` — which pieces of a settings document's `hooks` drop
726
+ on `command` and `http` entries; carried, not executed: a consumer that reads `block` executes it or refuses it; from 20.0.0 the table carries every other key CC's entry schemas carry too — `rewakeMessage` / `rewakeSummary` on `command`,
727
+ `cloud` on `command` and `http` — any value is carried as written, CC reads every value outside `HOOK_CLOUD_WORDS` = `device` | `skip` (type `HookCloud`) as `skip`, and folding is the reader's — `continueOnBlock` on `prompt`; a bad value of the others is a bad piece) and the ONE classifier `classifyHooksConfig(settingsDoc)` — which pieces of a settings document's `hooks` drop
702
728
  (`HOOKS_DROPPED_PIECE_CODES`), whether the whole document is rejected because a guard (`PreToolUse` / `PermissionRequest`) may be
703
729
  in a bad piece (`HOOKS_REJECTION_CODES`), and what loads; codes + `ConfigPath` coordinates + the wrong key's name (`field`: for a matcher / entry, the contract
704
730
  field whose value is wrong, or the member that holds a guard sign; absent only when the piece is not an object), no sentences, self-contained (no zod;
@@ -1 +1 @@
1
- 19.0.1
1
+ 20.0.0
@@ -124,9 +124,6 @@
124
124
  "wire": {
125
125
  "outcome": "effective",
126
126
  "effective": {
127
- "a2a": {
128
- "peers": []
129
- },
130
127
  "collab": {
131
128
  "templates": []
132
129
  },
@@ -100,9 +100,6 @@
100
100
  "wire": {
101
101
  "outcome": "effective",
102
102
  "effective": {
103
- "a2a": {
104
- "peers": []
105
- },
106
103
  "collab": {
107
104
  "templates": []
108
105
  },
@@ -78,9 +78,6 @@
78
78
  "wire": {
79
79
  "outcome": "effective",
80
80
  "effective": {
81
- "a2a": {
82
- "peers": []
83
- },
84
81
  "collab": {
85
82
  "templates": []
86
83
  },
@@ -78,9 +78,6 @@
78
78
  "wire": {
79
79
  "outcome": "effective",
80
80
  "effective": {
81
- "a2a": {
82
- "peers": []
83
- },
84
81
  "collab": {
85
82
  "templates": []
86
83
  },
@@ -78,9 +78,6 @@
78
78
  "wire": {
79
79
  "outcome": "effective",
80
80
  "effective": {
81
- "a2a": {
82
- "peers": []
83
- },
84
81
  "collab": {
85
82
  "templates": []
86
83
  },
@@ -78,9 +78,6 @@
78
78
  "wire": {
79
79
  "outcome": "effective",
80
80
  "effective": {
81
- "a2a": {
82
- "peers": []
83
- },
84
81
  "collab": {
85
82
  "templates": []
86
83
  },
@@ -656,6 +656,11 @@ export declare function buildEffective(version: number, getRaw: StoredDocumentRe
656
656
  * default the domain(蒸发整张 skill 清单)— it validates against {@link SkillsManifestSchema} instead,
657
657
  * same "default" fallback tier as the skills domain itself.
658
658
  *
659
+ * NEVER FABRICATES a domain the producer did not send (20.0.0): the domains of {@link WIRE_CARRIED_DOMAINS} (`prompts`, `a2a`) are carried by presence —
660
+ * absent on the wire ⇒ absent in the result (an older producer does not know `a2a`; `prompts` is absent whenever nothing is published), present ⇒ the
661
+ * domain's own reading (`prompts` verbatim, `a2a` through buildEffective). "Present" has one judgment: an own key of the payload whose value is not
662
+ * `undefined`. Every other domain is sent by every supported producer and reads as the contract default when absent.
663
+ *
659
664
  * OPEN-WORLD on unknown top-level keys: they ride through VERBATIM(never validated, never dropped)— a
660
665
  * newer web-admin's new domain reaches an older engine untouched(§M2 能力面语义:读不到即走老路,不该炸),
661
666
  * and so does any key no domain names(the 0.6-era `teams` key included — not a domain since 0.7, and no engine reads it). Throws ONLY on garbage no caller can partially trust: a non-object payload, or a missing/
@@ -23,7 +23,7 @@ import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object
23
23
  import { carriesUserinfo, secretScanForms } from "./secret-scan.js"; // package-private normalization (both scanners read it) + the userinfo judgement (not in the barrel)
24
24
  import { sha256Hex } from "./sha256.js";
25
25
  import { unwrapSchema } from "./zod-unwrap.js"; // package-private: the ONE reading of zod's wrapper layers (salvage + the one-time migrations share it)
26
- import { ATOMIC_SALVAGE, DOMAIN_SCHEMAS, InfraCostRates, LimitsConfig, PRIVATE_KEY_PEM_HEADER, RETIRED_DOMAINS, SkillsManifestSchema, containsSecretToken, isDomainName, isRetiredDomainName, renderQuotedSentence, retiredDomainSentence } from "./types.js";
26
+ import { ATOMIC_SALVAGE, DOMAIN_SCHEMAS, InfraCostRates, LimitsConfig, PRIVATE_KEY_PEM_HEADER, RETIRED_DOMAINS, SkillsManifestSchema, WIRE_CARRIED_DOMAINS, containsSecretToken, isDomainName, isRetiredDomainName, renderQuotedSentence, retiredDomainSentence } from "./types.js";
27
27
  /** Redact secret-shaped tokens from a validation MESSAGE — a zod error echoes the offending value (e.g.
28
28
  * `received 'sk-live-…'`), so a secret pasted into the WRONG field would leak via the error string. Redacts
29
29
  * space-spanning auth credentials (`Bearer <token>`) FIRST (the token pass can't see across the space), then
@@ -1143,6 +1143,11 @@ export function buildEffective(version, getRaw, updatedAt, onWarning) {
1143
1143
  * default the domain(蒸发整张 skill 清单)— it validates against {@link SkillsManifestSchema} instead,
1144
1144
  * same "default" fallback tier as the skills domain itself.
1145
1145
  *
1146
+ * NEVER FABRICATES a domain the producer did not send (20.0.0): the domains of {@link WIRE_CARRIED_DOMAINS} (`prompts`, `a2a`) are carried by presence —
1147
+ * absent on the wire ⇒ absent in the result (an older producer does not know `a2a`; `prompts` is absent whenever nothing is published), present ⇒ the
1148
+ * domain's own reading (`prompts` verbatim, `a2a` through buildEffective). "Present" has one judgment: an own key of the payload whose value is not
1149
+ * `undefined`. Every other domain is sent by every supported producer and reads as the contract default when absent.
1150
+ *
1146
1151
  * OPEN-WORLD on unknown top-level keys: they ride through VERBATIM(never validated, never dropped)— a
1147
1152
  * newer web-admin's new domain reaches an older engine untouched(§M2 能力面语义:读不到即走老路,不该炸),
1148
1153
  * and so does any key no domain names(the 0.6-era `teams` key included — not a domain since 0.7, and no engine reads it). Throws ONLY on garbage no caller can partially trust: a non-object payload, or a missing/
@@ -1198,11 +1203,17 @@ export function readEffectiveWire(raw, onWarning) {
1198
1203
  // `Object.fromEntries`,**不是**逐键 `passthrough[k] = v`:后者对 `"__proto__"` 走的是原型 setter
1199
1204
  // (改掉对象的原型,而不是加一个键),fromEntries 走 CreateDataProperty —— 同一条「键就是键」的律。
1200
1205
  const passthrough = Object.fromEntries(Object.entries(r).filter(([k]) => !Object.prototype.hasOwnProperty.call(built, k) && k !== "skills" && !isRetiredDomainName(k)));
1201
- // prompts:剥掉 buildEffective 恒物化的 `{}` 底座,按 wire 在场性 verbatim 挂回(#100:
1202
- // 缺席进缺席出——发布闸关是常态形,物化会让消费端「缺席」分支永不可达)。
1203
- const { prompts: _promptsMaterialized, ...builtSansPrompts } = built;
1204
- return { ...passthrough, ...builtSansPrompts, skills, ...(Object.hasOwn(r, "prompts") ? { prompts: r.prompts } : {}) };
1206
+ // 线上读口不编造生产方没发的域(20.0.0;承运表 WIRE_CARRIED_DOMAINS 是唯一一张):剥掉 buildEffective 对表里各域恒物化的底座,
1207
+ // 按载荷在场性挂回 —— 缺席进缺席出(prompts:发布闸关是常态形;a2a:比本域旧的生产方不发它,补空名册 = 替它说了「空」)。
1208
+ // 在场判据只有一个:载荷快照的自有键且值不是 undefined(`r` 只装自有数据位;与 parseDomain「只有 undefined 是缺席」同律)。
1209
+ // 在场的值:prompts 是原样(上面已把它从 buildEffective 引开,线上形由消费方判),挂在尾部;其余是 buildEffective 的读数(解析 / 抢救 / 整域缺省 + 告警),
1210
+ // 留在域序位上 —— 在场时读出形的键序与 19.0.0 逐位同(序列化读数不变)。
1211
+ const carriedOnWire = (d) => Object.hasOwn(r, d) && r[d] !== undefined;
1212
+ const read = Object.fromEntries(Object.entries(built).filter(([k]) => !isWireCarriedDomain(k) || (k !== "prompts" && carriedOnWire(k))));
1213
+ return { ...passthrough, ...read, skills, ...(carriedOnWire("prompts") ? { prompts: r.prompts } : {}) };
1205
1214
  }
1215
+ /** 一个顶层键是不是承运表里的域(读名字,不读值)。 */
1216
+ const isWireCarriedDomain = (k) => WIRE_CARRIED_DOMAINS.includes(k);
1206
1217
  /**
1207
1218
  * wire 上 skills 清单的读法 —— **与非门控域同一臂**,只是判的是清单 schema({@link SkillsManifestSchema}):整份严判({@link strictParse})→ 读不进
1208
1219
  * (校验不过,或校验器自己抛 —— 合法 JSON 里的怪形值、嵌入方对象的 getter / 陷阱 —— 同一条臂)⇒ 逐条抢救({@link salvageThenParse}:坏条目丢它自己 + `entry-dropped`,
@@ -42,7 +42,7 @@ export declare const foreignKeysOf: (docs: Readonly<Record<string, unknown>>) =>
42
42
  /** T2 的**入参**半场:域形的 skills 文档 → wire 形的 manifest 文档。结构变换,不解析 —— 坏形原样传下去,
43
43
  * 让 wire 腿自己的判据去裁(否则语料就没法喂一份坏 manifest 了)。 */
44
44
  export declare function toManifestDoc(doc: unknown): unknown;
45
- /** `domains` 真源 → `wire` 腿入参(T1 缺席进缺席出 + T2 表示换 + T4 未知键照原样带上)。 */
45
+ /** `domains` 真源 → `wire` 腿入参(T1 承运域缺席即不放进载荷 + T2 表示换 + T4 未知键照原样带上)。 */
46
46
  export declare function deriveWireInput(docs: Readonly<Record<string, unknown>>, version: number, updatedAt: string): LegInput;
47
47
  /** `domains` 真源 → `local-root` 腿入参(每个顶层键一个 `config.d/<键>.json`,含非域名的那些 —— T3/T4
48
48
  * 的告警正是靠它们在目录里在场才会响)。 */
@@ -8,9 +8,8 @@
8
8
  * 显示成 diff。于是「有没有第四条变换没登记」这件事不再靠人回忆 —— 没登记的那条会自己红出来。
9
9
  *
10
10
  * 变换表(每条写明:动了什么、影响哪几条腿、出处):
11
- * · **T1 prompts 物化**(wire):`buildEffective` 恒物化 `prompts`(域缺席 ⇒ `{}`;14.0.0 前是 `{bindings:[]}`);wire 腿按**在场性**
12
- * verbatim 挂回(`readEffectiveWire` 的 `"prompts" in r` 判据)—— 缺席进缺席出,且在场时是**未解析的
13
- * 原文档**。
11
+ * · **T1 承运域在场性**(wire):`buildEffective` 恒物化每个域;wire 腿对承运表 `WIRE_CARRIED_DOMAINS` 里的域(`prompts`、`a2a`)按**在场性**
12
+ * 挂回(线上读口不编造生产方没发的域)—— 缺席进缺席出;在场时 `prompts` 是**未解析的原文档**,`a2a` 是域腿的读数。表由常量派生,不手抄域名。
14
13
  * · **T2 skills 表示**(wire):域形带 `content`,wire 形带 `contentHash`(manifest)。判据 schema 随表示走。
15
14
  * · **T3 非便携域**(local-root):`config.d/` 只读 {@link PORTABLE_DOMAINS};其余域的文件在场则报
16
15
  * `unread-config-file{why:"non-portable-domain"}`,域本身取 schema 默认。**由 `PORTABLE_DOMAINS` 派生,
@@ -38,10 +37,10 @@ import { NON_DOMAIN_CONFIG_FILES } from "../file-store.js";
38
37
  import { PORTABLE_DOMAINS } from "../portable-domains.js";
39
38
  import { isJsonArray, isPlainJsonObject } from "../plain-json-object.js";
40
39
  import { skillContentHash } from "../skills-manifest.js";
41
- import { DOMAINS, isDomainName } from "../types.js";
40
+ import { DOMAINS, WIRE_CARRIED_DOMAINS, isDomainName } from "../types.js";
42
41
  /** 变换表(本文件头注的机器形;`docs/CONFORMANCE.md` 与 `test/conformance-coverage.test.ts` 都读它)。 */
43
42
  export const DERIVATION_TRANSFORMS = [
44
- { id: "T1-prompts-materialisation", legs: ["wire"], what: "buildEffective 恒物化 prompts(缺席 ⇒ {});wire 按在场性 verbatim 挂回(缺席进缺席出)" },
43
+ { id: "T1-wire-carried-domains", legs: ["wire"], what: "buildEffective 恒物化每个域;wire 对 WIRE_CARRIED_DOMAINS(prompts / a2a)按在场性挂回(缺席进缺席出;在场时 prompts 是原文档、a2a 是域腿读数)" },
45
44
  { id: "T2-skills-representation", legs: ["wire"], what: "域形 content ↔ wire 形 contentHash(manifest),判据 schema 随表示走" },
46
45
  { id: "T3-non-portable-domains", legs: ["localRoot"], what: "config.d/ 只读 PORTABLE_DOMAINS;其余域取默认 + unread-config-file{non-portable-domain}" },
47
46
  { id: "T4-unknown-top-level-key", legs: ["wire", "localRoot"], what: "wire open-world 逐字承运;domains 腿按域名取文档故无声;local 报 unread-config-file{not-a-domain}" },
@@ -84,7 +83,7 @@ export function toManifestDoc(doc) {
84
83
  }),
85
84
  };
86
85
  }
87
- /** `domains` 真源 → `wire` 腿入参(T1 缺席进缺席出 + T2 表示换 + T4 未知键照原样带上)。 */
86
+ /** `domains` 真源 → `wire` 腿入参(T1 承运域缺席即不放进载荷 + T2 表示换 + T4 未知键照原样带上)。 */
88
87
  export function deriveWireInput(docs, version, updatedAt) {
89
88
  // fromEntries(不是逐键赋值):语料里的顶层键可以叫 `__proto__`(S-332 的那一类),逐键赋值会把它
90
89
  // 变成一次原型改写,载荷里就再也没有这个键 —— 整条 case 于是测了个寂寞。
@@ -107,14 +106,16 @@ const clone = (v) => structuredClone(v);
107
106
  /** T1 + T2 + T4:`domains` 期望 → `wire` 期望。 */
108
107
  export function deriveWireExpectation(source, docs) {
109
108
  const base = clone(source.effective);
110
- // T1:缺席进缺席出;在场则是**未解析的原文档**(wire 腿从不 parse prompts)。
109
+ // T1:承运表里的域缺席进缺席出;在场 = 自有键且值不是 undefined(与读口同一条律,这里独立写一遍 —— 派生不调被测读口;嵌入方调导出的派生时
110
+ // 文档集里可以有 undefined,JSON 语料没有);在场时 prompts 是**未解析的原文档**(wire 腿从不 parse prompts),其余是域腿读数。
111
111
  // T2:域形条目的 content → contentHash(manifest 的条目 schema = 域条目 omit content + contentHash)。
112
112
  // T4:open-world 顶层键逐字承运 —— 用 fromEntries 而不是逐键赋值,否则一个叫 `__proto__` 的顶层键
113
113
  // 会变成一次原型改写(期望侧与实际侧被同样吃掉 = 比对器对这一类全盲,S-332 同族)。
114
+ const carried = WIRE_CARRIED_DOMAINS;
114
115
  const effective = Object.fromEntries([
115
- ...Object.entries(base).filter(([k]) => k !== "prompts" && k !== "skills"),
116
+ ...Object.entries(base).filter(([k]) => !carried.includes(k) && k !== "skills"),
116
117
  ["skills", toManifestDoc(base.skills)],
117
- ...(Object.prototype.hasOwnProperty.call(docs, "prompts") ? [["prompts", clone(docs.prompts)]] : []),
118
+ ...WIRE_CARRIED_DOMAINS.filter((d) => Object.prototype.hasOwnProperty.call(docs, d) && docs[d] !== undefined).map((d) => [d, d === "prompts" ? clone(docs.prompts) : base[d]]),
118
119
  ...foreignKeysOf(docs).map((k) => [k, clone(docs[k])]),
119
120
  ]);
120
121
  const warnings = source.warnings.filter((w) => {
@@ -6,8 +6,8 @@
6
6
  * ONE READER. "Can this document's hooks be loaded, and which pieces must go?" has one answer: {@link classifyHooksConfig}. The zod faces
7
7
  * below ({@link HooksConfig}, {@link HookMatcherEntry}, {@link HookEntry} and the per-type five) are its PROJECTIONS — accepted ⇔ the
8
8
  * classifier says `"loaded"`, the parsed value is what it loaded, each issue is one of its pieces (code + coordinate). There is no second
9
- * statement of what a valid hook entry is: the per-type field table {@link HOOK_ENTRY_FIELDS} is read by the classifier at run time and by
10
- * the entry TYPES at compile time (they are derived from it).
9
+ * statement of what a valid hook entry is: the per-type field table {@link HOOK_ENTRY_FIELDS} (exported) is what the entry TYPES are derived from at
10
+ * compile time, and the classifier reads its closure-private projection of it ({@link HOOK_ENTRY_FIELDS_READ}, tied to the table's type — see there).
11
11
  *
12
12
  * GRANULARITY = CC 2.1.296 (`cli296.js:237470`, `Yy` → `on`): four levels of piece — the `hooks` key, an event, a matcher, an entry.
13
13
  * · Outside the guard events, a bad piece is DROPPED alone (the rest of the document — its `permissions.deny`, its `env` — still applies).
@@ -31,8 +31,11 @@
31
31
  * with a sign>] }` reports the matcher's wrong `matcher` field. A sign of the piece decides before a wrong contract field of the same piece does
32
32
  * (it is why the piece is rejected rather than dropped).
33
33
  *
34
- * CC 2.1.296 DIVERGENCES (each in the stricter direction — a document CC would load may be rejected here, never the reverse): listed once,
35
- * in `docs/CC-DIVERGENCE.md` (section "hooks classifier", H1–H7) — the whole-subtree guard-sign scan is the first of them.
34
+ * CC 2.1.296 DIVERGENCES (the ones LISTED there are each in the stricter direction — a document CC would load may be rejected here, never the reverse): listed once,
35
+ * in `docs/CC-DIVERGENCE.md` (section "hooks classifier", H1–H7) — the whole-subtree guard-sign scan is the first of them. The entry field table
36
+ * ({@link HOOK_ENTRY_FIELDS}) carries EVERY key CC's five hook-entry schemas carry (`cli309.js:252382`), so no key CC judges is stripped here unjudged. That is a statement about
37
+ * which KEYS are read; the VALUE forms are the field kinds' (H7 lists where they judge more than CC does), with one known place where a kind judges LESS than CC: an `http` entry's `url`
38
+ * is read as a non-empty string where CC checks URL syntax (not closed yet — see CHANGELOG 20.0.0, "已知限制").
36
39
  *
37
40
  * COORDINATES are raw {@link ConfigPath} segments (the keys as written). An unknown event name or a key outside `hooks` is user text and may be
38
41
  * anything, a pasted credential included: pass a coordinate through `outgoingPath` before it leaves the process (log, UI, wire). The classifier
@@ -69,25 +72,47 @@ export type HookEntryType = (typeof HOOK_ENTRY_TYPES)[number];
69
72
  export declare const HOOK_ON_FAILURE_WORDS: readonly ["continue", "block"];
70
73
  /** One word of {@link HOOK_ON_FAILURE_WORDS}. */
71
74
  export type HookOnFailure = (typeof HOOK_ON_FAILURE_WORDS)[number];
75
+ /**
76
+ * The words CC gives `cloud` (CC `cli309.js:252382`, `cloud:B(["device","skip"]).optional().catch("skip")`, marked `@internal` there): where this hook may run when a cloud session is driven from the
77
+ * machine that holds the settings. `device`: offer it to the cloud session and run it on the device even when its script sits where the cloud session can write; `skip`: never offer it to cloud
78
+ * sessions. The key absent is a third reading (CC's default: a command hook whose script can be pinned and lies outside everything the cloud session can write is offered, an http hook is offered).
79
+ * REFERENCE FOR READERS, not a check: CC's `.catch("skip")` takes ANY value that is not one of these words (a non-string, `null`, an object included) as `skip` and still loads the file, so `cloud` has no bad
80
+ * value — {@link classifyHooksConfig} carries whatever is written, as written (it neither judges it, nor folds it to `skip`, nor strips it), and folding to `skip` is the reader's. Carried by `command` and
81
+ * `http` entries. CARRIED, not executed here.
82
+ */
83
+ export declare const HOOK_CLOUD_WORDS: readonly ["device", "skip"];
84
+ /** One word of {@link HOOK_CLOUD_WORDS}. */
85
+ export type HookCloud = (typeof HOOK_CLOUD_WORDS)[number];
72
86
  /** `shell` values: 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
73
87
  declare const HOOK_SHELLS: readonly ["bash", "powershell"];
74
88
  /**
75
- * THE field table of a hook entry, per type — read by {@link classifyHooksConfig} (which field is bad, what is carried) and by the entry
76
- * types below (derived from it). Field order = the order a loaded entry's keys come out in.
89
+ * THE field table of a hook entry, per type — exported, deeply frozen (a consumer that projects "which fields does an entry carry" reads this one object and
90
+ * cannot change what the others read), and what the entry types below are derived from. Field order = the order a loaded entry's keys come out in.
91
+ * The classifier does not read THIS object: it is copied as source by consumers' generators, and a closure that read an exported declaration — or a private one
92
+ * that an export expression reaches — would not be copyable. It reads {@link HOOK_ENTRY_FIELDS_READ}, annotated with this table's type.
77
93
  * · command: `args` = exec form (CC `cli309.js:252382`: when present — `[]` included — `command` is an executable spawned directly with these arguments, no shell; the mere
78
94
  * presence of `args` is the switch), `shell` (see above), `async` = run in background without blocking, `asyncRewake` = background + wake the model on exit 2,
79
- * `onFailure` (see {@link HOOK_ON_FAILURE_WORDS});
80
- * · prompt / agent: `prompt` ($ARGUMENTS = the hook input JSON), `model`;
95
+ * `onFailure` (see {@link HOOK_ON_FAILURE_WORDS}), and — CC marks them `@internal` — `rewakeMessage` (the prefix of the system-reminder the model gets when an `asyncRewake` hook exits
96
+ * 2) and `rewakeSummary` (the one-line summary the user sees then): both a string of at least one character (`nonEmpty`), `cloud` (`any`: CC reads every value outside {@link HOOK_CLOUD_WORDS} as `skip`
97
+ * and loads the file, so there is nothing to judge — the value is carried as written and the reader folds);
98
+ * · prompt / agent: `prompt` ($ARGUMENTS = the hook input JSON), `model`; prompt only: `continueOnBlock` = the `continue` value of the `decision: "block"` the entry produces when its
99
+ * verdict is not ok (CC default false: the turn ends);
81
100
  * · http: `url`, `headers` (values may reference $NAMEs listed in `allowedEnvVars` — env-NAME interpolation only, the config never carries a
82
- * secret value; `interpolateHookEnvVars` is the one reading), `allowedEnvVars`, `onFailure` (the other schema CC gives it to);
101
+ * secret value; `interpolateHookEnvVars` is the one reading), `allowedEnvVars`, `onFailure` (the other schema CC gives it to), `cloud` (the other schema CC gives it to);
83
102
  * · mcp_tool: `server` (an already-configured MCP server's name), `tool`, `input` (the tool's arguments; string values may interpolate
84
103
  * `${path}` from the hook input JSON — CC 2.1.296 semantics, the runner's business).
85
- * NOT in the table, on purpose: CC's `@internal` command / http keys `rewakeMessage` / `rewakeSummary` / `cloud` (not public settings keys; `cloud` even reads a bad value
86
- * as 'skip' and loads the file) and the prompt entry's `continueOnBlock`. A key outside a type's row is not carried and not a bad piece (`docs/CC-DIVERGENCE.md` H7) —
87
- * which is also why `args` on a non-command entry and `onFailure` on a prompt / agent / mcp_tool entry are such keys.
104
+ * Every key of CC's five entry schemas (`cli309.js:252382`) is in its row — nothing CC judges is stripped here. A key outside a type's row is not carried and not a bad piece
105
+ * (`docs/CC-DIVERGENCE.md` H7): `args` on a non-command entry, `onFailure` on a prompt / agent / mcp_tool entry, `cloud` and `rewakeMessage` / `rewakeSummary` and `continueOnBlock` on a type CC's
106
+ * schema does not give them to, and any key CC does not know. CARRIED, not executed: `rewakeMessage` / `rewakeSummary` / `cloud` / `continueOnBlock` are read by the consumer that runs the hook
107
+ * (a consumer that does not run them carries them as written).
108
+ * The row order also decides which field an already-bad entry names (the first wrong one), so a column added later goes at the TAIL of its row (after the shared fields): adding one never
109
+ * moves an answer the table already gave.
88
110
  */
89
- declare const HOOK_ENTRY_FIELDS: {
90
- readonly command: {
111
+ export declare const HOOK_ENTRY_FIELDS: Readonly<{
112
+ command: Readonly<{
113
+ readonly rewakeMessage: "nonEmpty?";
114
+ readonly rewakeSummary: "nonEmpty?";
115
+ readonly cloud: "any?";
91
116
  readonly if: "string?";
92
117
  readonly timeout: "seconds?";
93
118
  readonly statusMessage: "string?";
@@ -98,24 +123,26 @@ declare const HOOK_ENTRY_FIELDS: {
98
123
  readonly async: "boolean?";
99
124
  readonly asyncRewake: "boolean?";
100
125
  readonly onFailure: "onFailure?";
101
- };
102
- readonly prompt: {
126
+ }>;
127
+ prompt: Readonly<{
128
+ readonly continueOnBlock: "boolean?";
103
129
  readonly if: "string?";
104
130
  readonly timeout: "seconds?";
105
131
  readonly statusMessage: "string?";
106
132
  readonly once: "boolean?";
107
133
  readonly prompt: "text";
108
134
  readonly model: "string?";
109
- };
110
- readonly agent: {
135
+ }>;
136
+ agent: Readonly<{
111
137
  readonly if: "string?";
112
138
  readonly timeout: "seconds?";
113
139
  readonly statusMessage: "string?";
114
140
  readonly once: "boolean?";
115
141
  readonly prompt: "text";
116
142
  readonly model: "string?";
117
- };
118
- readonly http: {
143
+ }>;
144
+ http: Readonly<{
145
+ readonly cloud: "any?";
119
146
  readonly if: "string?";
120
147
  readonly timeout: "seconds?";
121
148
  readonly statusMessage: "string?";
@@ -124,8 +151,8 @@ declare const HOOK_ENTRY_FIELDS: {
124
151
  readonly headers: "stringRecord?";
125
152
  readonly allowedEnvVars: "stringList?";
126
153
  readonly onFailure: "onFailure?";
127
- };
128
- readonly mcp_tool: {
154
+ }>;
155
+ mcp_tool: Readonly<{
129
156
  readonly if: "string?";
130
157
  readonly timeout: "seconds?";
131
158
  readonly statusMessage: "string?";
@@ -133,9 +160,11 @@ declare const HOOK_ENTRY_FIELDS: {
133
160
  readonly server: "string";
134
161
  readonly tool: "string";
135
162
  readonly input: "record?";
136
- };
137
- };
138
- type HookFieldBaseValue<B> = B extends "text" | "string" ? string : B extends "shell" ? (typeof HOOK_SHELLS)[number] : B extends "onFailure" ? HookOnFailure : B extends "boolean" ? boolean : B extends "seconds" ? number : B extends "stringRecord" ? Record<string, string> : B extends "stringList" | "argv" ? string[] : B extends "record" ? Record<string, unknown> : never;
163
+ }>;
164
+ }>;
165
+ /** The type of {@link HOOK_ENTRY_FIELDS}: per entry type, field name → field kind (literal types). */
166
+ export type HookEntryFields = typeof HOOK_ENTRY_FIELDS;
167
+ type HookFieldBaseValue<B> = B extends "text" | "nonEmpty" | "string" ? string : B extends "shell" ? (typeof HOOK_SHELLS)[number] : B extends "onFailure" ? HookOnFailure : B extends "any" ? unknown : B extends "boolean" ? boolean : B extends "seconds" ? number : B extends "stringRecord" ? Record<string, string> : B extends "stringList" | "argv" ? string[] : B extends "record" ? Record<string, unknown> : never;
139
168
  type HookFieldValue<K> = K extends `${infer B}?` ? HookFieldBaseValue<B> : HookFieldBaseValue<K>;
140
169
  type Flat<O> = {
141
170
  [K in keyof O]: O[K];