@sema-agent/settings-schema 19.0.0 → 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 +127 -0
- package/README.md +36 -11
- package/conformance/VERSION +1 -1
- package/conformance/cases/c01-entry-salvage-then-typo/meta.json +1 -1
- package/conformance/cases/c03-literal-dotted-top-key/meta.json +1 -1
- package/conformance/cases/c12-prototype-name-top-keys/meta.json +1 -1
- package/conformance/cases/c34-skills-content-vs-manifest/expected.json +0 -3
- package/conformance/cases/c36-skills-entry-without-content/expected.json +0 -3
- package/conformance/cases/c37-skills-field-null/expected.json +0 -3
- package/conformance/cases/c40-s712-identity-only-what-reads-out/meta.json +1 -1
- package/conformance/cases/c41-s792-encoded-pem-identity/meta.json +1 -1
- package/conformance/cases/c42-s792-unknown-key-secret-redacted/meta.json +1 -1
- package/conformance/cases/c43-s792-form-and-deep-encoded-pem/meta.json +1 -1
- package/conformance/cases/c44-s792-utf8-escape-glued-token/meta.json +1 -1
- package/conformance/cases/c45-s792-identity-bounds-and-decode-depth/meta.json +1 -1
- package/conformance/cases/c46-s811-host-name-url-userinfo-withheld/meta.json +1 -1
- package/conformance/cases/c47-s811-roles-key-url-userinfo-withheld/meta.json +2 -2
- package/conformance/cases/c48-s935-model-headers-transported/meta.json +1 -1
- package/conformance/cases/c49-s935-model-headers-secret-entry-dropped/meta.json +1 -1
- package/conformance/cases/c57-s784-g1-enabled-no-lane/meta.json +1 -1
- package/conformance/cases/c65-s784-pg-without-db/meta.json +1 -1
- package/conformance/cases/c71-one-scanner-write-reads-display-forms/meta.json +2 -2
- package/conformance/cases/c76-projects-entry-salvage-nested/meta.json +1 -1
- package/conformance/cases/c80-prompts-wire-v2-verbatim/expected.json +0 -3
- package/conformance/cases/c84-sandbox-git-block-carried-verbatim/expected.json +0 -3
- package/conformance/cases/c85-sandbox-git-refused-block-still-carried/expected.json +0 -3
- package/conformance/cases/t01-absent-domain-key-not-null/meta.json +1 -1
- package/conformance/cases/t02-entry-salvage-vs-whole-domain-refusal/meta.json +1 -1
- package/conformance/cases/t03-prototype-name-key-not-swallowed/meta.json +1 -1
- package/dist/config-fns.d.ts +5 -0
- package/dist/config-fns.js +16 -5
- package/dist/conformance/derive.d.ts +1 -1
- package/dist/conformance/derive.js +10 -9
- package/dist/hooks-config.d.ts +54 -25
- package/dist/hooks-config.js +82 -21
- package/dist/types.d.ts +75 -7
- package/dist/types.js +39 -2
- package/docs/API-SURFACE.md +22 -4
- package/docs/CC-DIVERGENCE.md +4 -4
- package/docs/CONFORMANCE.md +11 -11
- package/docs/CONSUMER-INTEGRATION.md +55 -8
- package/llms-full.txt +16 -10
- package/llms.txt +12 -8
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"contributor": "test",
|
|
3
|
-
"claim": "同一份坏条目,放进逐条容错的域(`models`,`DOMAIN_READ_FALLBACK=\"default\"`)与放进 fail-loud 的闸门域(`rosters`,`=\"throw\"`),结论必须不同:前者丢那一条并恰报一条 `entry-dropped`、**不得同时**报 `domain-defaulted`(一域一个结论);后者**整份读在 validate 层被拒**(不是回落到 schema 默认 —— 对闸门域回落就是放宽闸门)。server
|
|
3
|
+
"claim": "同一份坏条目,放进逐条容错的域(`models`,`DOMAIN_READ_FALLBACK=\"default\"`)与放进 fail-loud 的闸门域(`rosters`,`=\"throw\"`),结论必须不同:前者丢那一条并恰报一条 `entry-dropped`、**不得同时**报 `domain-defaulted`(一域一个结论);后者**整份读在 validate 层被拒**(不是回落到 schema 默认 —— 对闸门域回落就是放宽闸门)。server 与 web-admin 各自的验收判据是同一件事的两半,跨腿读错会把『逐条容错』顺手放宽到闸门域,把这条设计为拒的输入读成绿(带两条 `entry-dropped`)。",
|
|
4
4
|
"firstRedOn": [],
|
|
5
5
|
"note": "【claim 措辞订正 2026-09-19,test 自纠】初稿写的是「后者整域回落」—— **是本方写错**:「回落」是 `DOMAIN_READ_FALLBACK=\"default\"` 那一族的动作,闸门域是 `\"throw\"` = fail-loud,整份读被拒。出处:契约自述 `config-fns.js` 的 `DOMAIN_READ_FALLBACK` 头注(defaulting would LOOSEN gates)+ 契约自带 `c05-gate-domain-bad-entry-throws` 金样(rejected/validate)+ 本仓 historical 实跑五版一致。claim 已按实测改写,对抗意图不变。两域放**同形**坏条目(`name` 是数字):`models`(DOMAIN_READ_FALLBACK=\"default\")与 `rosters`(=\"throw\",且是唯一一个便携的数组形闸门域)。3.0.0 实测:闸门域坏条目使**整份读**在 `validate` 层拒,三腿同形 —— 因此本条的期望是 `rejected/validate`,`models` 那半场在同一份输入里**结构上观察不到**。这正是本条的判别力所在:一个把逐条容错顺手放宽到闸门域的消费方,会把这条设计为拒的 case 读成绿(带两条 `entry-dropped`)。claim 前半场(`models` 恰一条 `entry-dropped`、零 `domain-defaulted`)由 verify.mjs 的配对正控臂(同一份输入去掉 `rosters` 域)钉住,读数记在 _SUMMARY.json 的 t02.pairedControl。claim 里「闸门域整域回落」的『回落』一词与契约自述的 `\"throw\"` = fail-loud 不符 —— 见 _SUMMARY.json 的 claimVsObserved。firstRedOn 空是**实跑**出来的:1.0.0/1.5.0/1.10.0/2.0.0/2.1.0 五版在本条上都是 expected-rejected(闸门域坏条目整份拒这条律从 1.0.0 起一字未动)⇒ 护栏,不是回归凭证。"
|
|
6
6
|
}
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
"contributor": "test",
|
|
3
3
|
"claim": "`__proto__` / `constructor` / `toString` 作为域内条目的键,**在坏条目上**:告警坐标必须把它当**普通字面键**点名、`effective` 的原型必须不被污染、三腿读法一致。本方在 server 7.87.0 G6 实测过同族(`answer.answers[0].__proto__` ⇒ `400 request.field_invalid` 且 `unknownKeys` 逐字点名);也在本仓自证里把 `__proto__` 的断言方向搞反过一次(`JSON.parse` + spread **保留** own 属性、plain assignment 才污染原型),所以这条同时是护栏。",
|
|
4
4
|
"firstRedOn": [],
|
|
5
|
-
"note": "【claim 收窄 2026-09-19,server
|
|
5
|
+
"note": "【claim 收窄 2026-09-19,server 指出、主会话亲验】初稿把 `__proto__` **作好条目的 record 键**也算进「当普通字面键报进坐标」。**实测不成立**:`parseDomainLoud('limits', {__proto__:1, ok:2}, …)` 的告警 keys 只有 `['ok']`,`parsed` 上无 own `__proto__`(原型仍是 `Object.prototype`)—— 好条目上的原型名键在 zod 3 正常解析路径上本来就被丢,是已知限制,不是本条要钉的东西。claim 已收窄到**坏条目**那半场(真的、可判、有判别力);好条目那半场不入语料。与契约仓 c12 的差别:c12 打的是**顶层键**(`k in built` 一路问到 Object.prototype ⇒ open-world 承诺失效),本条打的是**域内条目的键**(剥键扫描 `collectDropped` 的 `Object.keys` / `hasOwnProperty` 两处判据,以及 salvage/rebase 路径上的对象重建)。构造坑(本方亲踩,记在此处防下一个人重踩):用 JS 对象字面量 `{\"__proto__\": {...}}` 造这条输入会**设置原型而不是加一个键**,于是 `isPlainJsonObject` 判假、整条扫描被跳过、case 测了个寂寞;语料走 `JSON.parse` 才拿到自有键 —— 这也是为什么这条必须以磁盘语料形存在,而不是测试里一个内联对象。firstRedOn 空是**实跑**出来的:五个旧版(1.0.0/1.5.0/1.10.0/2.0.0/2.1.0)在本条上全绿 —— 3.0.0 修的那个 bug 只落在**顶层键**那一层(契约 c12 五版全红),域内条目键这一层从 1.0.0 起就一直对 ⇒ 本条是护栏,不是回归凭证。"
|
|
6
6
|
}
|
package/dist/config-fns.d.ts
CHANGED
|
@@ -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/
|
package/dist/config-fns.js
CHANGED
|
@@ -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
|
-
//
|
|
1202
|
-
//
|
|
1203
|
-
|
|
1204
|
-
|
|
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
|
|
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
|
|
12
|
-
*
|
|
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-
|
|
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
|
|
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
|
|
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
|
|
116
|
+
...Object.entries(base).filter(([k]) => !carried.includes(k) && k !== "skills"),
|
|
116
117
|
["skills", toManifestDoc(base.skills)],
|
|
117
|
-
...(Object.prototype.hasOwnProperty.call(docs,
|
|
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) => {
|
package/dist/hooks-config.d.ts
CHANGED
|
@@ -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
|
|
10
|
-
* the
|
|
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 —
|
|
76
|
-
* types below
|
|
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
|
-
*
|
|
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
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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];
|
package/dist/hooks-config.js
CHANGED
|
@@ -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
|
|
10
|
-
* the
|
|
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
|
|
@@ -113,6 +116,15 @@ export const HOOK_ENTRY_TYPES = ["command", "prompt", "agent", "http", "mcp_tool
|
|
|
113
116
|
* The classifier reads this set through a closure-private projection that the compiler ties to it in both directions.
|
|
114
117
|
*/
|
|
115
118
|
export const HOOK_ON_FAILURE_WORDS = ["continue", "block"];
|
|
119
|
+
/**
|
|
120
|
+
* 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
|
|
121
|
+
* 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
|
|
122
|
+
* 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).
|
|
123
|
+
* 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
|
|
124
|
+
* 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
|
|
125
|
+
* `http` entries. CARRIED, not executed here.
|
|
126
|
+
*/
|
|
127
|
+
export const HOOK_CLOUD_WORDS = ["device", "skip"];
|
|
116
128
|
/** `shell` values: 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
|
|
117
129
|
const HOOK_SHELLS = ["bash", "powershell"];
|
|
118
130
|
/** The classifier's reading of {@link HOOK_ON_FAILURE_WORDS}. The classifier is copied as source by consumers' generators, so its closure cannot read an exported name (its one free name
|
|
@@ -121,29 +133,74 @@ const HOOK_SHELLS = ["bash", "powershell"];
|
|
|
121
133
|
const HOOK_ON_FAILURE_ACCEPTED = { continue: true, block: true };
|
|
122
134
|
/** Fields every entry type takes: `if` = permission-rule syntax (e.g. "Bash(git *)") evaluated against tool_name/tool_input before the hook
|
|
123
135
|
* runs (tool events only; shell superset field, CC-compatible); `timeout` = seconds for this entry (default `DEFAULT_HOOK_TIMEOUT_SECONDS`);
|
|
124
|
-
* `statusMessage` = spinner status message; `once` = run once, then remove.
|
|
136
|
+
* `statusMessage` = spinner status message; `once` = run once, then remove. Read by the exported table below only — the classifier's own
|
|
137
|
+
* projection spells these four out per row (it is a closure, see {@link HOOK_ENTRY_FIELDS_READ}). */
|
|
125
138
|
const HOOK_ENTRY_COMMON_FIELDS = { if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?" };
|
|
126
139
|
/**
|
|
127
|
-
* THE field table of a hook entry, per type —
|
|
128
|
-
* types below
|
|
140
|
+
* 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
|
|
141
|
+
* 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.
|
|
142
|
+
* 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
|
|
143
|
+
* that an export expression reaches — would not be copyable. It reads {@link HOOK_ENTRY_FIELDS_READ}, annotated with this table's type.
|
|
129
144
|
* · command: `args` = exec form (CC `cli309.js:252382`: when present — `[]` included — `command` is an executable spawned directly with these arguments, no shell; the mere
|
|
130
145
|
* presence of `args` is the switch), `shell` (see above), `async` = run in background without blocking, `asyncRewake` = background + wake the model on exit 2,
|
|
131
|
-
* `onFailure` (see {@link HOOK_ON_FAILURE_WORDS})
|
|
132
|
-
*
|
|
146
|
+
* `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
|
|
147
|
+
* 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`
|
|
148
|
+
* and loads the file, so there is nothing to judge — the value is carried as written and the reader folds);
|
|
149
|
+
* · prompt / agent: `prompt` ($ARGUMENTS = the hook input JSON), `model`; prompt only: `continueOnBlock` = the `continue` value of the `decision: "block"` the entry produces when its
|
|
150
|
+
* verdict is not ok (CC default false: the turn ends);
|
|
133
151
|
* · http: `url`, `headers` (values may reference $NAMEs listed in `allowedEnvVars` — env-NAME interpolation only, the config never carries a
|
|
134
|
-
* secret value; `interpolateHookEnvVars` is the one reading), `allowedEnvVars`, `onFailure` (the other schema CC gives it to);
|
|
152
|
+
* secret value; `interpolateHookEnvVars` is the one reading), `allowedEnvVars`, `onFailure` (the other schema CC gives it to), `cloud` (the other schema CC gives it to);
|
|
135
153
|
* · mcp_tool: `server` (an already-configured MCP server's name), `tool`, `input` (the tool's arguments; string values may interpolate
|
|
136
154
|
* `${path}` from the hook input JSON — CC 2.1.296 semantics, the runner's business).
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
155
|
+
* 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
|
|
156
|
+
* (`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
|
|
157
|
+
* 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
|
|
158
|
+
* (a consumer that does not run them carries them as written).
|
|
159
|
+
* 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
|
|
160
|
+
* moves an answer the table already gave.
|
|
140
161
|
*/
|
|
141
|
-
const HOOK_ENTRY_FIELDS = {
|
|
142
|
-
command: {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
162
|
+
export const HOOK_ENTRY_FIELDS = Object.freeze({
|
|
163
|
+
command: Object.freeze({
|
|
164
|
+
command: "text",
|
|
165
|
+
args: "argv?",
|
|
166
|
+
shell: "shell?",
|
|
167
|
+
async: "boolean?",
|
|
168
|
+
asyncRewake: "boolean?",
|
|
169
|
+
onFailure: "onFailure?",
|
|
170
|
+
...HOOK_ENTRY_COMMON_FIELDS,
|
|
171
|
+
rewakeMessage: "nonEmpty?",
|
|
172
|
+
rewakeSummary: "nonEmpty?",
|
|
173
|
+
cloud: "any?",
|
|
174
|
+
}),
|
|
175
|
+
prompt: Object.freeze({ prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS, continueOnBlock: "boolean?" }),
|
|
176
|
+
agent: Object.freeze({ prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS }),
|
|
177
|
+
http: Object.freeze({ url: "text", headers: "stringRecord?", allowedEnvVars: "stringList?", onFailure: "onFailure?", ...HOOK_ENTRY_COMMON_FIELDS, cloud: "any?" }),
|
|
178
|
+
mcp_tool: Object.freeze({ server: "string", tool: "string", input: "record?", ...HOOK_ENTRY_COMMON_FIELDS }),
|
|
179
|
+
});
|
|
180
|
+
/** The classifier's reading of {@link HOOK_ENTRY_FIELDS}. Same reason and same form as {@link HOOK_ON_FAILURE_ACCEPTED}: the classifier closure cannot read the exported table, so this
|
|
181
|
+
* is its closure-private projection, spelled out in full (no shared piece with the exported table) and annotated with the exported table's type — a row, a field or a field kind that
|
|
182
|
+
* the two do not agree on is a compile error in one direction (a missing one) or the other (an extra one). the hook-entry-fields pin under `test/` holds the run-time half: what the
|
|
183
|
+
* classifier accepts, requires and orders per type is what the exported table says. */
|
|
184
|
+
const HOOK_ENTRY_FIELDS_READ = {
|
|
185
|
+
command: {
|
|
186
|
+
command: "text",
|
|
187
|
+
args: "argv?",
|
|
188
|
+
shell: "shell?",
|
|
189
|
+
async: "boolean?",
|
|
190
|
+
asyncRewake: "boolean?",
|
|
191
|
+
onFailure: "onFailure?",
|
|
192
|
+
if: "string?",
|
|
193
|
+
timeout: "seconds?",
|
|
194
|
+
statusMessage: "string?",
|
|
195
|
+
once: "boolean?",
|
|
196
|
+
rewakeMessage: "nonEmpty?",
|
|
197
|
+
rewakeSummary: "nonEmpty?",
|
|
198
|
+
cloud: "any?",
|
|
199
|
+
},
|
|
200
|
+
prompt: { prompt: "text", model: "string?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?", continueOnBlock: "boolean?" },
|
|
201
|
+
agent: { prompt: "text", model: "string?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?" },
|
|
202
|
+
http: { url: "text", headers: "stringRecord?", allowedEnvVars: "stringList?", onFailure: "onFailure?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?", cloud: "any?" },
|
|
203
|
+
mcp_tool: { server: "string", tool: "string", input: "record?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?" },
|
|
147
204
|
};
|
|
148
205
|
// ── classification vocabulary ──────────────────────────────────────────────────────────────────────────────
|
|
149
206
|
/** What happened to a document's hooks: all loaded / loaded with pieces dropped / the document rejected (nothing in it applies). */
|
|
@@ -338,6 +395,8 @@ function hookFieldFits(base, value) {
|
|
|
338
395
|
switch (base) {
|
|
339
396
|
case "text":
|
|
340
397
|
return typeof value === "string" && value.length > 0 && !value.includes("\0");
|
|
398
|
+
case "nonEmpty":
|
|
399
|
+
return typeof value === "string" && value.length > 0;
|
|
341
400
|
case "string":
|
|
342
401
|
return typeof value === "string";
|
|
343
402
|
case "shell":
|
|
@@ -366,6 +425,8 @@ function hookFieldFits(base, value) {
|
|
|
366
425
|
return true;
|
|
367
426
|
case "onFailure":
|
|
368
427
|
return typeof value === "string" && Object.hasOwn(HOOK_ON_FAILURE_ACCEPTED, value);
|
|
428
|
+
case "any":
|
|
429
|
+
return true;
|
|
369
430
|
case "record":
|
|
370
431
|
return hookIsRecord(value);
|
|
371
432
|
default: {
|
|
@@ -379,9 +440,9 @@ function hookEntryRead(entry) {
|
|
|
379
440
|
if (!hookIsRecord(entry))
|
|
380
441
|
return {};
|
|
381
442
|
const type = Object.hasOwn(entry, "type") ? entry.type : undefined;
|
|
382
|
-
if (typeof type !== "string" || !Object.hasOwn(
|
|
443
|
+
if (typeof type !== "string" || !Object.hasOwn(HOOK_ENTRY_FIELDS_READ, type))
|
|
383
444
|
return { field: "type" };
|
|
384
|
-
const fields =
|
|
445
|
+
const fields = HOOK_ENTRY_FIELDS_READ[type];
|
|
385
446
|
const out = { type };
|
|
386
447
|
for (const field of Object.keys(fields)) {
|
|
387
448
|
const kind = fields[field];
|