@sema-agent/settings-schema 30.1.0 → 31.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +212 -0
- package/README.md +32 -3
- package/conformance/VERSION +1 -1
- package/dist/file-store.d.ts +1 -1
- package/dist/hooks-config.d.ts +181 -10
- package/dist/hooks-config.js +320 -33
- package/dist/mcp-request-entry.d.ts +3 -2
- package/dist/mcp-request-entry.js +5 -4
- package/dist/plain-json-object.d.ts +3 -2
- package/dist/plain-json-object.js +3 -2
- package/dist/retired-envs.js +7 -0
- package/dist/safety-merge-spec.js +3 -2
- package/dist/types.js +1 -1
- package/dist/web-search-section.js +2 -2
- package/docs/API-SURFACE.md +33 -3
- package/docs/CC-DIVERGENCE.md +14 -3
- package/docs/CONSUMER-INTEGRATION.md +71 -7
- package/llms-full.txt +8 -5
- package/llms.txt +3 -3
- package/package.json +1 -1
package/dist/hooks-config.js
CHANGED
|
@@ -32,23 +32,32 @@
|
|
|
32
32
|
* (it is why the piece is rejected rather than dropped).
|
|
33
33
|
*
|
|
34
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–
|
|
35
|
+
* in `docs/CC-DIVERGENCE.md` (section "hooks classifier", H1–H8) — the whole-subtree guard-sign scan is the first of them. The entry field table
|
|
36
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
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
38
|
* is read as a non-empty string where CC checks URL syntax (not closed yet — see CHANGELOG 20.0.0, "已知限制").
|
|
39
|
+
* One column is this contract's own, not CC's (H8): a `command` entry's `plugin` ({@link HookPluginContext}, 31.0.0) — CC reads a plugin hook's context from where the plugin sits, so its
|
|
40
|
+
* entry schema has no such key and strips one written in a settings file; here the context travels on the entry, and a bad one is a bad piece like any other field's bad value.
|
|
39
41
|
*
|
|
40
42
|
* 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
|
|
41
43
|
* anything, a pasted credential included: pass a coordinate through `outgoingPath` before it leaves the process (log, UI, wire). The classifier
|
|
42
44
|
* echoes no values and writes no sentences — the sentences are the consumers' (same law as `DROPPED_ENTRY_REASON_CODES`).
|
|
43
45
|
*
|
|
44
|
-
* SELF-CONTAINED. {@link classifyHooksConfig} and the module-private declarations it uses reference nothing outside themselves except
|
|
45
|
-
*
|
|
46
|
-
*
|
|
46
|
+
* SELF-CONTAINED. {@link classifyHooksConfig} and the module-private declarations it uses reference nothing outside themselves except their REGISTERED
|
|
47
|
+
* names and JavaScript built-ins (no zod): a consumer that copies the function into its own bundle (client-core's generator does, with the private
|
|
48
|
+
* declarations it uses) copies one closure and gives the copy's scope each registered name, bound to the runtime export it names — never a copy of it.
|
|
49
|
+
* The registered names: {@link HOOK_EVENTS} (the event vocabulary), and the three judgements the `plugin` field needs, each read from its one owner
|
|
50
|
+
* (31.0.0): {@link pluginOptionKeysProblem} (this module; it registers {@link pluginOptionEnvName} in turn), `isAbsoluteHostPath` (`./host-path`) and
|
|
51
|
+
* `readCredentialRef` (the engine primitives package, the one reader of a credential reference). The closure carries no copy of any of them.
|
|
52
|
+
* The hooks-classify test file (group ⑤) holds the registered set exactly; `test/hook-plugin-context-31.0.0.test.ts` S7 holds "no copy".
|
|
47
53
|
*
|
|
48
54
|
* Input is a settings document as parsed from JSON. Values JSON cannot produce (accessors, class instances, cycles) are not part of the
|
|
49
55
|
* contract; cycles are tolerated, a throwing accessor propagates.
|
|
50
56
|
*/
|
|
51
57
|
import { z } from "zod";
|
|
58
|
+
import { readCredentialRef } from "@sema-agent/primitives";
|
|
59
|
+
import { isAbsoluteHostPath } from "./host-path.js";
|
|
60
|
+
import { echoCallerText } from "./caller-text-echo.js";
|
|
52
61
|
import { isPlainJsonObject } from "./plain-json-object.js";
|
|
53
62
|
import { buildQuotedIssue, fixed } from "./quoted-issue.js";
|
|
54
63
|
import { deepFreeze } from "./deep-freeze.js";
|
|
@@ -126,10 +135,223 @@ export const HOOK_ON_FAILURE_WORDS = deepFreeze(["continue", "block"]);
|
|
|
126
135
|
* `http` entries. CARRIED, not executed here.
|
|
127
136
|
*/
|
|
128
137
|
export const HOOK_CLOUD_WORDS = deepFreeze(["device", "skip"]);
|
|
138
|
+
/**
|
|
139
|
+
* The first problem with a list of plugin option keys, in key order, or `undefined` when there is none: a key that is not an identifier (`[A-Za-z_][A-Za-z0-9_]*`) ⇒ `not_identifier`;
|
|
140
|
+
* a key that becomes the same environment variable as an earlier key ({@link pluginOptionEnvName} — for identifiers that is "equal once upper-cased") ⇒ `collision` with the two keys
|
|
141
|
+
* (earlier first) and that name. THE judgement the classifier makes on `plugin.options` (it calls this function; a problem there makes the entry a bad piece): a sender can ask it
|
|
142
|
+
* before it sends. It judges keys as keys — a key named for a guard event is the document's law, not this one (see {@link HookPluginContext}). The keys are user text — pass them
|
|
143
|
+
* through the consumer's echo rules before they are shown. Its one REGISTERED name is {@link pluginOptionEnvName} (no other free name but JavaScript built-ins): a consumer's
|
|
144
|
+
* generator may copy it whole and give the copy that name.
|
|
145
|
+
*/
|
|
146
|
+
export function pluginOptionKeysProblem(keys) {
|
|
147
|
+
const names = new Set();
|
|
148
|
+
for (const key of keys) {
|
|
149
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
|
|
150
|
+
return { kind: "not_identifier", key };
|
|
151
|
+
const envName = pluginOptionEnvName(key);
|
|
152
|
+
if (names.has(envName))
|
|
153
|
+
return { kind: "collision", keys: [keys.find((k) => pluginOptionEnvName(k) === envName), key], envName };
|
|
154
|
+
names.add(envName);
|
|
155
|
+
}
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* The name of the environment variable that carries one plugin option to a hook process: `CLAUDE_PLUGIN_OPTION_` followed by the option key as written with every UTF-16 code unit
|
|
160
|
+
* outside `[A-Za-z0-9_]` replaced by `_`, then upper-cased (the replacement comes first, so only ASCII is ever upper-cased). The reference implementation's fold for that variable. The
|
|
161
|
+
* ONE writing of it in this package (`pluginOptionKeysProblem`'s `envName` reads it): a runner that sets the variables from the keys as written and a sender that still folds before
|
|
162
|
+
* it sends both read this, never their own copy. Two different keys can fold to one name (`api-key` / `api_key`, `a.b` / `A_B`); which value the process then sees is the runner's to
|
|
163
|
+
* decide — this gives the name only. On a plugin entry the classifier already refuses such keys ({@link pluginOptionKeysProblem}). SELF-CONTAINED (no free name but JavaScript
|
|
164
|
+
* built-ins): a consumer's generator may copy it whole.
|
|
165
|
+
*/
|
|
166
|
+
export function pluginOptionEnvName(key) {
|
|
167
|
+
return `CLAUDE_PLUGIN_OPTION_${key.replace(/[^A-Za-z0-9_]/g, "_").toUpperCase()}`;
|
|
168
|
+
}
|
|
169
|
+
// ── the placeholders of a command line, and the copy a process starts from (31.0.0) ────────────────────────
|
|
170
|
+
/** The path names a command line may name as `${NAME}` (closed, frozen): the project directory, the plugin's directory, the plugin's data directory. The order is the order
|
|
171
|
+
* {@link planHookCommandSpawn} reports a missing value in when more than one is missing. */
|
|
172
|
+
export const HOOK_COMMAND_PATH_NAMES = deepFreeze(["CLAUDE_PROJECT_DIR", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PLUGIN_DATA"]);
|
|
173
|
+
/**
|
|
174
|
+
* Why a command hook cannot start (closed, frozen). The ORDER IS THE PRECEDENCE: when more than one holds, {@link planHookCommandSpawn} reports the earliest —
|
|
175
|
+
* · `path_unset` — the command line names a path name ({@link HOOK_COMMAND_PATH_NAMES}) that has no value (either execution form: the shell would expand it to nothing);
|
|
176
|
+
* · `shell_form_user_config` — a plugin entry's shell-form command (no `args`) names `${user_config.K}`: never substituted there (the shell would parse the value again), whatever the
|
|
177
|
+
* option holds — the reference implementation refuses the same hook, whether the option is sensitive, stored or not, PowerShell or not;
|
|
178
|
+
* · `user_config_unset` — a plugin entry's exec-form command line names an option key its option table does not hold;
|
|
179
|
+
* · `user_config_unresolved` — a plugin entry's exec-form command line names an option whose value in the table is still a {@link HookPluginOptionRef} (a reference not resolved by the
|
|
180
|
+
* caller).
|
|
181
|
+
* The words are about the command line against the table the caller holds, not about resolving a reference (that is the caller's, with its own words). The three option words exist only
|
|
182
|
+
* for a plugin entry: on an entry no plugin brought, `${user_config.K}` is not a placeholder (see {@link planHookCommandSpawn}).
|
|
183
|
+
*/
|
|
184
|
+
export const HOOK_COMMAND_SPAWN_REFUSAL_WORDS = deepFreeze(["path_unset", "shell_form_user_config", "user_config_unset", "user_config_unresolved"]);
|
|
185
|
+
/**
|
|
186
|
+
* THE rule for the placeholders of a command hook's command line, and the one reader of their grammar: a sender that substitutes before it sends and a runner that substitutes when it
|
|
187
|
+
* starts the process both call this function, so the two cannot answer differently.
|
|
188
|
+
*
|
|
189
|
+
* GRAMMAR. One pass, left to right, over `command` and then each `args` element. At each `${` the pass recognizes one of the three path names written `${CLAUDE_PROJECT_DIR}` /
|
|
190
|
+
* `${CLAUDE_PLUGIN_ROOT}` / `${CLAUDE_PLUGIN_DATA}`, or — on a plugin entry — an option placeholder `${user_config.K}` (`K` = one or more characters up to the next `}`, the
|
|
191
|
+
* reference implementation's form) — nothing else: any other `${…}` stays as written. A value put in is NOT scanned again: a value that itself reads `${user_config.X}` or
|
|
192
|
+
* `${CLAUDE_PLUGIN_ROOT}` is handed on as those characters (the reference implementation substitutes the path names first and the options in a second pass over the result; this
|
|
193
|
+
* contract does not — a value is a value, not a template).
|
|
194
|
+
*
|
|
195
|
+
* INPUT. `entry` — the command line, and whether a plugin brought it: exec form when `args` is present (`command` is the program, no shell), shell form when it is not (the same
|
|
196
|
+
* switch as the entry's own); a PLUGIN entry is one with a `plugin` member — the same reading the classifier and the `plugin` column make (a {@link CommandHookEntry} the classifier
|
|
197
|
+
* loaded is passed as it is). The `user_config` namespace belongs to plugin entries: on an entry with no `plugin`, `${user_config.…}` is no placeholder at all — it stays as written
|
|
198
|
+
* like any other `${…}`, and a shell-form command is not refused for it (the reference implementation takes an option table only for a plugin's hook, and both its refusal and its
|
|
199
|
+
* substitution hang on that table). `paths` — each path name's value, all three stated: a string (the empty string included) is the value, `undefined` is no value. `resolved` —
|
|
200
|
+
* optional, a plugin entry's option table as the caller holds it after resolving (or, for a sender, the table it holds); left out, the table is the entry's own `plugin.options`, and
|
|
201
|
+
* the empty table when the context has no `options` member. In the table an OWN key holding a string (the empty string included) is that option's value, an own key holding a
|
|
202
|
+
* {@link HookPluginOptionRef} is an option whose value is a reference not resolved, a key not held is an option that is not set. A table given for an entry with no `plugin`, or
|
|
203
|
+
* a `null` table or `plugin` (on any command line), is the caller's error and THROWS — the namespace follows the entry, never whether a table happens to be at hand.
|
|
204
|
+
* Reading the environment, the disk, the secure store or a clock is the caller's; this function does none of it.
|
|
205
|
+
*
|
|
206
|
+
* VERDICT, in the order of {@link HOOK_COMMAND_SPAWN_REFUSAL_WORDS} — a whole word is judged over the whole command line before the next word (any unset key beats any unresolved one,
|
|
207
|
+
* wherever each stands): a named path name without a value ⇒ `path_unset` (the first missing one in {@link HOOK_COMMAND_PATH_NAMES} order); shell form naming an option ⇒
|
|
208
|
+
* `shell_form_user_config`; exec form naming a key the table does not hold ⇒ `user_config_unset`; exec form naming a key whose value is a reference ⇒ `user_config_unresolved` (keys:
|
|
209
|
+
* the first in pass order; the three option words only where options are recognized, i.e. on a plugin entry). Otherwise shell form ⇒ `command` as it is (a shell expands path names from
|
|
210
|
+
* the environment; nothing is substituted in the text), exec form ⇒ `file` / `args` with every recognized placeholder replaced by its value in that same pass.
|
|
211
|
+
*
|
|
212
|
+
* CALL SHAPES. A runner passes the entry it loaded and its paths — `planHookCommandSpawn(entry, paths)` — and nothing else decides the namespace. A runner with steps of its own between
|
|
213
|
+
* the checks (a directory to look at, a reference to resolve) keeps one precedence by answering every refusal but the LAST word at once and `user_config_unresolved` after its own
|
|
214
|
+
* steps: the function reports only the earliest word, so when it reports the last one no earlier word holds; a runner that resolves references calls again with the resolved table
|
|
215
|
+
* (`planHookCommandSpawn(entry, paths, resolved)`). A sender that substitutes for a runner which substitutes the path names itself passes each path name's own placeholder as its
|
|
216
|
+
* value (`{ CLAUDE_PLUGIN_ROOT: "${CLAUDE_PLUGIN_ROOT}", … }`) and, on a plugin entry, the table it holds: a value is not scanned again, so the placeholder reaches the runner as
|
|
217
|
+
* written — and every option word comes out exactly as the runner's own call would give it.
|
|
218
|
+
*
|
|
219
|
+
* THE COPY ONLY. The answer is what a process starts from: an `exec` answer has no `command` member and a `shell` answer's `command` is the input itself; the entry is never written. What
|
|
220
|
+
* is shown, logged or recorded (a hook's display name, its ledger row, a frame, a sentence) is the entry as written, never this copy — the copy may hold option values.
|
|
221
|
+
* SELF-CONTAINED (no free name but JavaScript built-ins): a consumer's generator may copy it whole.
|
|
222
|
+
*/
|
|
223
|
+
export function planHookCommandSpawn(entry, paths, resolved) {
|
|
224
|
+
// Whether a plugin brought the entry is the entry's own fact — its own `plugin` member, read as the classifier reads a field (own key; `undefined` = absent) — never the
|
|
225
|
+
// caller's: no table is read for an entry with no `plugin`.
|
|
226
|
+
const plugin = Object.hasOwn(entry, "plugin") ? entry.plugin : undefined;
|
|
227
|
+
if (resolved === null || plugin === null) {
|
|
228
|
+
throw new Error("planHookCommandSpawn: a null option table or a null plugin context — leave the table out (an entry with no plugin has no `plugin` member)");
|
|
229
|
+
}
|
|
230
|
+
if (resolved !== undefined && plugin === undefined) {
|
|
231
|
+
throw new Error("planHookCommandSpawn: an option table was given for an entry that is not a plugin's (it has no `plugin` member) — the user_config namespace follows the entry");
|
|
232
|
+
}
|
|
233
|
+
const options = plugin === undefined ? undefined : (resolved ?? plugin.options ?? {});
|
|
234
|
+
const names = ["CLAUDE_PROJECT_DIR", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PLUGIN_DATA"];
|
|
235
|
+
const optionOpen = "${user_config.";
|
|
236
|
+
// The one pass: a text → its pieces (literal runs, path placeholders, option placeholders), left to right; a `${` that starts no placeholder stays literal and the scan moves past it.
|
|
237
|
+
const pass = (text) => {
|
|
238
|
+
const pieces = [];
|
|
239
|
+
let literal = "";
|
|
240
|
+
let i = 0;
|
|
241
|
+
while (i < text.length) {
|
|
242
|
+
const at = text.indexOf("${", i);
|
|
243
|
+
if (at === -1) {
|
|
244
|
+
literal += text.slice(i);
|
|
245
|
+
break;
|
|
246
|
+
}
|
|
247
|
+
literal += text.slice(i, at);
|
|
248
|
+
const path = names.find((name) => text.startsWith("${" + name + "}", at));
|
|
249
|
+
// The option namespace exists only on a plugin entry (the entry has a `plugin`, so `options` is a table); elsewhere the `${` of `${user_config.` starts no placeholder and stays literal like any other.
|
|
250
|
+
const opensOption = path === undefined && options !== undefined && text.startsWith(optionOpen, at);
|
|
251
|
+
const close = opensOption ? text.indexOf("}", at + optionOpen.length) : -1;
|
|
252
|
+
if (opensOption && close === -1) {
|
|
253
|
+
// No `}` anywhere after this point: no placeholder of either kind can close, so the rest is literal (and the scan stays linear — no re-search per `${`).
|
|
254
|
+
literal += text.slice(at);
|
|
255
|
+
break;
|
|
256
|
+
}
|
|
257
|
+
if (path === undefined && close <= at + optionOpen.length) {
|
|
258
|
+
literal += "${";
|
|
259
|
+
i = at + 2;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
if (literal !== "")
|
|
263
|
+
pieces.push(literal);
|
|
264
|
+
literal = "";
|
|
265
|
+
if (path !== undefined) {
|
|
266
|
+
pieces.push({ path });
|
|
267
|
+
i = at + path.length + 3;
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
pieces.push({ key: text.slice(at + optionOpen.length, close) });
|
|
271
|
+
i = close + 1;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
if (literal !== "")
|
|
275
|
+
pieces.push(literal);
|
|
276
|
+
return pieces;
|
|
277
|
+
};
|
|
278
|
+
const lines = [entry.command, ...(entry.args ?? [])].map(pass);
|
|
279
|
+
const placeholders = [];
|
|
280
|
+
for (const line of lines)
|
|
281
|
+
for (const piece of line)
|
|
282
|
+
if (typeof piece !== "string")
|
|
283
|
+
placeholders.push(piece);
|
|
284
|
+
const pathValue = (name) => {
|
|
285
|
+
const value = Object.hasOwn(paths, name) ? paths[name] : undefined;
|
|
286
|
+
return typeof value === "string" ? value : undefined;
|
|
287
|
+
};
|
|
288
|
+
for (const name of names) {
|
|
289
|
+
if (pathValue(name) === undefined && placeholders.some((p) => "path" in p && p.path === name))
|
|
290
|
+
return { kind: "refused", refusal: { word: "path_unset", name } };
|
|
291
|
+
}
|
|
292
|
+
const keys = [];
|
|
293
|
+
for (const p of placeholders)
|
|
294
|
+
if ("key" in p)
|
|
295
|
+
keys.push(p.key);
|
|
296
|
+
if (entry.args === undefined) {
|
|
297
|
+
return keys.length > 0 ? { kind: "refused", refusal: { word: "shell_form_user_config", key: keys[0] } } : { kind: "shell", command: entry.command };
|
|
298
|
+
}
|
|
299
|
+
let unresolved;
|
|
300
|
+
for (const key of keys) {
|
|
301
|
+
// A key is recognized only on a plugin entry (the pass above), so `options` is a table wherever a key is read — here and in `render`.
|
|
302
|
+
if (!Object.hasOwn(options, key))
|
|
303
|
+
return { kind: "refused", refusal: { word: "user_config_unset", key } };
|
|
304
|
+
if (unresolved === undefined && typeof options[key] !== "string")
|
|
305
|
+
unresolved = key;
|
|
306
|
+
}
|
|
307
|
+
if (unresolved !== undefined)
|
|
308
|
+
return { kind: "refused", refusal: { word: "user_config_unresolved", key: unresolved } };
|
|
309
|
+
const render = (line) => {
|
|
310
|
+
let out = "";
|
|
311
|
+
for (const piece of line)
|
|
312
|
+
out += typeof piece === "string" ? piece : "path" in piece ? pathValue(piece.path) : options[piece.key];
|
|
313
|
+
return out;
|
|
314
|
+
};
|
|
315
|
+
return { kind: "exec", file: render(lines[0]), args: lines.slice(1).map(render) };
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* The one sentence for a {@link HookCommandSpawnRefusal}: fixed words plus the path name, or the option key passed through this package's echo of caller text (control and
|
|
319
|
+
* bidirectional characters stripped, long keys cut). Never a value — the refusal carries none. A runner and a sender show this sentence instead of writing their own.
|
|
320
|
+
*/
|
|
321
|
+
export function hookCommandSpawnRefusalSentence(refusal) {
|
|
322
|
+
switch (refusal.word) {
|
|
323
|
+
case "path_unset":
|
|
324
|
+
return `hook command names \${${refusal.name}}, which has no value for this hook (it comes from the hook's plugin context or from its environment; settings.env can set it)`;
|
|
325
|
+
case "shell_form_user_config":
|
|
326
|
+
return `hook command names \${user_config.${echoCallerText(refusal.key)}} in shell form, where the shell would parse the substituted value again — use exec form ("command" plus "args"), or read the option from the environment variable CLAUDE_PLUGIN_OPTION_<KEY>`;
|
|
327
|
+
case "user_config_unset":
|
|
328
|
+
return `hook command names plugin option "${echoCallerText(refusal.key)}", which is not set`;
|
|
329
|
+
case "user_config_unresolved":
|
|
330
|
+
return `hook command names plugin option "${echoCallerText(refusal.key)}", whose value is a stored reference that is not resolved here`;
|
|
331
|
+
default: {
|
|
332
|
+
const unknownWord = refusal;
|
|
333
|
+
throw new Error(`hookCommandSpawnRefusalSentence: unknown refusal word '${String(unknownWord.word)}'`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
/** The cap on {@link measureHookPluginContext}'s count for one entry's plugin context, in UTF-16 code units (a literal type: the measure's own copy is tied to it at compile time). */
|
|
338
|
+
export const HOOK_PLUGIN_CONTEXT_CHARS_CAP = 8192;
|
|
339
|
+
/**
|
|
340
|
+
* How big one entry's plugin context is, against {@link HOOK_PLUGIN_CONTEXT_CHARS_CAP}: `chars` = the length of `name` + `root` + `dataDir` + for each option, its key + its value — a
|
|
341
|
+
* string value counts its length, a reference counts its `entry` (the `kind` word and the JSON structure count nothing). Counted per entry. `chars > cap` is over the cap (what a runner
|
|
342
|
+
* answers then is the runner's). The input is a context the classifier accepted. SELF-CONTAINED (no free name but JavaScript built-ins): a consumer's generator may copy it whole.
|
|
343
|
+
*/
|
|
344
|
+
export function measureHookPluginContext(plugin) {
|
|
345
|
+
const cap = 8192;
|
|
346
|
+
let chars = plugin.name.length + plugin.root.length + (plugin.dataDir === undefined ? 0 : plugin.dataDir.length);
|
|
347
|
+
for (const [key, value] of Object.entries(plugin.options ?? {}))
|
|
348
|
+
chars += key.length + (typeof value === "string" ? value.length : value.entry.length);
|
|
349
|
+
return { chars, cap };
|
|
350
|
+
}
|
|
129
351
|
/** `shell` values: 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
|
|
130
352
|
const HOOK_SHELLS = ["bash", "powershell"];
|
|
131
|
-
/** The classifier's reading of {@link HOOK_ON_FAILURE_WORDS}. The classifier is copied as source by consumers' generators, so its closure
|
|
132
|
-
*
|
|
353
|
+
/** The classifier's reading of {@link HOOK_ON_FAILURE_WORDS}. The classifier is copied as source by consumers' generators, so its closure reads no exported name but its registered ones
|
|
354
|
+
* ({@link HOOK_EVENTS} and the three judgements of the `plugin` column — see the file header): this record is the closure-private projection of the exported set, and the compiler ties the two in both directions — a word added to the set without a row
|
|
133
355
|
* here, or a row here that the set does not hold, is a compile error. */
|
|
134
356
|
const HOOK_ON_FAILURE_ACCEPTED = { continue: true, block: true };
|
|
135
357
|
/** Fields every entry type takes: `if` = permission-rule syntax (e.g. "Bash(git *)") evaluated against tool_name/tool_input before the hook
|
|
@@ -146,7 +368,8 @@ const HOOK_ENTRY_COMMON_FIELDS = { if: "string?", timeout: "seconds?", statusMes
|
|
|
146
368
|
* presence of `args` is the switch), `shell` (see above), `async` = run in background without blocking, `asyncRewake` = background + wake the model on exit 2,
|
|
147
369
|
* `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
|
|
148
370
|
* 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`
|
|
149
|
-
* and loads the file, so there is nothing to judge — the value is carried as written and the reader folds)
|
|
371
|
+
* and loads the file, so there is nothing to judge — the value is carried as written and the reader folds), and — this contract's own column, not CC's (31.0.0) — `plugin`
|
|
372
|
+
* (the plugin context: {@link HookPluginContext}; a bad one is a bad piece);
|
|
150
373
|
* · prompt / agent: `prompt` ($ARGUMENTS = the hook input JSON), `model`; prompt only: `continueOnBlock` = the `continue` value of the `decision: "block"` the entry produces when its
|
|
151
374
|
* verdict is not ok (CC default false: the turn ends);
|
|
152
375
|
* · http: `url`, `headers` (values may reference $NAMEs listed in `allowedEnvVars` — env-NAME interpolation only, the config never carries a
|
|
@@ -172,6 +395,7 @@ export const HOOK_ENTRY_FIELDS = deepFreeze({
|
|
|
172
395
|
rewakeMessage: "nonEmpty?",
|
|
173
396
|
rewakeSummary: "nonEmpty?",
|
|
174
397
|
cloud: "any?",
|
|
398
|
+
plugin: "plugin?",
|
|
175
399
|
},
|
|
176
400
|
prompt: { prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS, continueOnBlock: "boolean?" },
|
|
177
401
|
agent: { prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS },
|
|
@@ -197,6 +421,7 @@ const HOOK_ENTRY_FIELDS_READ = {
|
|
|
197
421
|
rewakeMessage: "nonEmpty?",
|
|
198
422
|
rewakeSummary: "nonEmpty?",
|
|
199
423
|
cloud: "any?",
|
|
424
|
+
plugin: "plugin?",
|
|
200
425
|
},
|
|
201
426
|
prompt: { prompt: "text", model: "string?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?", continueOnBlock: "boolean?" },
|
|
202
427
|
agent: { prompt: "text", model: "string?", if: "string?", timeout: "seconds?", statusMessage: "string?", once: "boolean?" },
|
|
@@ -391,52 +616,112 @@ function hookSignKeyOf(at, sign) {
|
|
|
391
616
|
const key = sign[at.length];
|
|
392
617
|
return key === undefined ? "hooks" : String(key);
|
|
393
618
|
}
|
|
394
|
-
/**
|
|
395
|
-
|
|
619
|
+
/** The `plugin` field kind: a {@link HookPluginContext} → a fresh copy (member order `name`, `root`, `dataDir`, `options`; absent members stay absent), or `undefined` when the value is
|
|
620
|
+
* not one — the rules are the ones written on that type, members read once each. The three judgements it needs are their owners', called through the closure's registered names
|
|
621
|
+
* (no copy here): `isAbsoluteHostPath` for `root` / `dataDir`, {@link pluginOptionKeysProblem} for the option keys, the primitives' `readCredentialRef` for a value that is not a
|
|
622
|
+
* string — accepted when it reads a `vault` reference (an accessor, a record with another member, another kind or bad text are refused there); what is carried is a fresh
|
|
623
|
+
* `{ kind: "vault", entry }` built from that reading. */
|
|
624
|
+
function hookPluginRead(value) {
|
|
625
|
+
if (!hookIsRecord(value))
|
|
626
|
+
return undefined;
|
|
627
|
+
let name;
|
|
628
|
+
let root;
|
|
629
|
+
let dataDir;
|
|
630
|
+
let options;
|
|
631
|
+
for (const [member, v] of Object.entries(value)) {
|
|
632
|
+
if (member === "name")
|
|
633
|
+
name = v;
|
|
634
|
+
else if (member === "root")
|
|
635
|
+
root = v;
|
|
636
|
+
else if (member === "dataDir")
|
|
637
|
+
dataDir = v;
|
|
638
|
+
else if (member === "options")
|
|
639
|
+
options = v;
|
|
640
|
+
else
|
|
641
|
+
return undefined;
|
|
642
|
+
}
|
|
643
|
+
if (typeof name !== "string" || name.length === 0 || name.includes("\0") || !isAbsoluteHostPath(root))
|
|
644
|
+
return undefined;
|
|
645
|
+
let context = { name, root };
|
|
646
|
+
if (dataDir !== undefined) {
|
|
647
|
+
if (!isAbsoluteHostPath(dataDir))
|
|
648
|
+
return undefined;
|
|
649
|
+
context = { name, root, dataDir };
|
|
650
|
+
}
|
|
651
|
+
if (options === undefined)
|
|
652
|
+
return context;
|
|
653
|
+
if (!hookIsRecord(options))
|
|
654
|
+
return undefined;
|
|
655
|
+
const entries = Object.entries(options);
|
|
656
|
+
if (pluginOptionKeysProblem(entries.map(([key]) => key)) !== undefined)
|
|
657
|
+
return undefined;
|
|
658
|
+
const carried = [];
|
|
659
|
+
for (const [key, v] of entries) {
|
|
660
|
+
if (typeof v === "string") {
|
|
661
|
+
if (v.includes("\0"))
|
|
662
|
+
return undefined;
|
|
663
|
+
carried.push([key, v]);
|
|
664
|
+
continue;
|
|
665
|
+
}
|
|
666
|
+
const read = readCredentialRef(v);
|
|
667
|
+
if (!read.ok || read.ref.kind !== "vault")
|
|
668
|
+
return undefined;
|
|
669
|
+
carried.push([key, { kind: "vault", entry: read.ref.entry }]);
|
|
670
|
+
}
|
|
671
|
+
return { ...context, options: Object.fromEntries(carried) };
|
|
672
|
+
}
|
|
673
|
+
/** The field kind `base` (the kind without its `?`) read off a present value: `{ carried }` = what the loaded entry holds — lists and records copied one level, a plugin context rebuilt
|
|
674
|
+
* from what was judged (the loaded entry shares no list, record or reference with the document) — or `undefined` when the value does not fit the kind. One read per field: what is
|
|
675
|
+
* judged is what is carried. */
|
|
676
|
+
function hookFieldRead(base, value) {
|
|
396
677
|
switch (base) {
|
|
397
678
|
case "text":
|
|
398
|
-
return typeof value === "string" && value.length > 0 && !value.includes("\0");
|
|
679
|
+
return typeof value === "string" && value.length > 0 && !value.includes("\0") ? { carried: value } : undefined;
|
|
399
680
|
case "nonEmpty":
|
|
400
|
-
return typeof value === "string" && value.length > 0;
|
|
681
|
+
return typeof value === "string" && value.length > 0 ? { carried: value } : undefined;
|
|
401
682
|
case "string":
|
|
402
|
-
return typeof value === "string";
|
|
683
|
+
return typeof value === "string" ? { carried: value } : undefined;
|
|
403
684
|
case "shell":
|
|
404
|
-
return typeof value === "string" && HOOK_SHELLS.includes(value);
|
|
685
|
+
return typeof value === "string" && HOOK_SHELLS.includes(value) ? { carried: value } : undefined;
|
|
405
686
|
case "boolean":
|
|
406
|
-
return typeof value === "boolean";
|
|
687
|
+
return typeof value === "boolean" ? { carried: value } : undefined;
|
|
407
688
|
case "seconds":
|
|
408
|
-
return typeof value === "number" && Number.isFinite(value) && value > 0;
|
|
689
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? { carried: value } : undefined;
|
|
409
690
|
case "stringRecord":
|
|
410
|
-
return hookIsRecord(value) && Object.values(value).every((v) => typeof v === "string");
|
|
691
|
+
return hookIsRecord(value) && Object.values(value).every((v) => typeof v === "string") ? { carried: Object.fromEntries(Object.entries(value)) } : undefined;
|
|
411
692
|
case "stringList":
|
|
412
693
|
if (!hookIsArray(value))
|
|
413
|
-
return
|
|
694
|
+
return undefined;
|
|
414
695
|
for (let i = 0; i < value.length; i++)
|
|
415
696
|
if (typeof value[i] !== "string")
|
|
416
|
-
return
|
|
417
|
-
return
|
|
697
|
+
return undefined;
|
|
698
|
+
return { carried: value.slice() };
|
|
418
699
|
case "argv":
|
|
419
700
|
if (!hookIsArray(value))
|
|
420
|
-
return
|
|
701
|
+
return undefined;
|
|
421
702
|
for (let i = 0; i < value.length; i++) {
|
|
422
703
|
const arg = value[i];
|
|
423
704
|
if (typeof arg !== "string" || arg.includes("\0"))
|
|
424
|
-
return
|
|
705
|
+
return undefined;
|
|
425
706
|
}
|
|
426
|
-
return
|
|
707
|
+
return { carried: value.slice() };
|
|
427
708
|
case "onFailure":
|
|
428
|
-
return typeof value === "string" && Object.hasOwn(HOOK_ON_FAILURE_ACCEPTED, value);
|
|
709
|
+
return typeof value === "string" && Object.hasOwn(HOOK_ON_FAILURE_ACCEPTED, value) ? { carried: value } : undefined;
|
|
429
710
|
case "any":
|
|
430
|
-
return
|
|
711
|
+
return { carried: hookIsArray(value) ? value.slice() : hookIsRecord(value) ? Object.fromEntries(Object.entries(value)) : value };
|
|
431
712
|
case "record":
|
|
432
|
-
return hookIsRecord(value);
|
|
713
|
+
return hookIsRecord(value) ? { carried: Object.fromEntries(Object.entries(value)) } : undefined;
|
|
714
|
+
case "plugin": {
|
|
715
|
+
const plugin = hookPluginRead(value);
|
|
716
|
+
return plugin === undefined ? undefined : { carried: plugin };
|
|
717
|
+
}
|
|
433
718
|
default: {
|
|
434
719
|
const unknownKind = base;
|
|
435
720
|
throw new Error(`hook entry field table: unknown field kind '${String(unknownKind)}'`);
|
|
436
721
|
}
|
|
437
722
|
}
|
|
438
723
|
}
|
|
439
|
-
/** One entry → `{ entry }` (its contract fields, in table order
|
|
724
|
+
/** One entry → `{ entry }` (its contract fields, in table order, each as {@link hookFieldRead} carries it) or `{ field? }` (the first field that is wrong). */
|
|
440
725
|
function hookEntryRead(entry) {
|
|
441
726
|
if (!hookIsRecord(entry))
|
|
442
727
|
return {};
|
|
@@ -454,10 +739,10 @@ function hookEntryRead(entry) {
|
|
|
454
739
|
continue;
|
|
455
740
|
return { field };
|
|
456
741
|
}
|
|
457
|
-
const
|
|
458
|
-
if (
|
|
742
|
+
const read = hookFieldRead((optional ? kind.slice(0, -1) : kind), value);
|
|
743
|
+
if (read === undefined)
|
|
459
744
|
return { field };
|
|
460
|
-
out[field] =
|
|
745
|
+
out[field] = read.carried;
|
|
461
746
|
}
|
|
462
747
|
return { entry: out };
|
|
463
748
|
}
|
|
@@ -561,10 +846,12 @@ function hookBlockRead(hooks, reject, drop) {
|
|
|
561
846
|
* and what loads. Pure: reads `settingsDoc` (the WHOLE document — guard signs outside `hooks` count), never modifies it, no I/O, no sentences.
|
|
562
847
|
* Rejections and drops are listed in document order.
|
|
563
848
|
*
|
|
564
|
-
* COPYING THIS FUNCTION (client-core's generator, or any consumer that emits it as source): its
|
|
565
|
-
* {@link HOOK_EVENTS}
|
|
566
|
-
* the
|
|
567
|
-
*
|
|
849
|
+
* COPYING THIS FUNCTION (client-core's generator, or any consumer that emits it as source): its free names besides JavaScript built-ins are its
|
|
850
|
+
* REGISTERED names — {@link HOOK_EVENTS}, {@link pluginOptionKeysProblem} and `isAbsoluteHostPath` (this package's runtime exports) and `readCredentialRef`
|
|
851
|
+
* (the runtime export of `@sema-agent/primitives`, this package's runtime dependency). The copy's scope must be GIVEN each of them, bound to the export
|
|
852
|
+
* it names (the generator injects each as a registered value, it does not re-declare it; `pluginOptionKeysProblem` in turn registers {@link pluginOptionEnvName}).
|
|
853
|
+
* Never paste a literal event list or a copied judgement into the generated text: a second event table is one the upstream drift gate (it watches
|
|
854
|
+
* `HOOK_EVENTS`) cannot see and goes stale the first time CC adds an event; a copied judgement is a second reading that drifts from its owner unseen.
|
|
568
855
|
* The module-private declarations the closure uses (the `HOOK_*` constants and `hook*` helpers below the classifier line) are copied with it;
|
|
569
856
|
* the hooks-classify test file (group ⑤) pins that the free names are exactly these.
|
|
570
857
|
*/
|
|
@@ -46,8 +46,9 @@ export declare function describeBadContentOrigin(v: unknown): string;
|
|
|
46
46
|
/**
|
|
47
47
|
* 请求面读器**点名拒**的键的**原因词**(闭集,29.0.0)—— 与「表外未知键」分得开的那一类:读器认得这把键,知道它为什么不在请求面上。
|
|
48
48
|
* · `key_retired`:`transport.assertionHeader`(http)—— 29.0.0 退役:托管连接器的断言是部署的声明(配置面的 `transport.credentials`),头名归引擎,请求不说它;
|
|
49
|
-
* · `credentials_not_carried`:`transport.credentials`(两种传输)——
|
|
50
|
-
*
|
|
49
|
+
* · `credentials_not_carried`:`transport.credentials`(两种传输)—— 请求面的 MCP 条目不承载凭据引用:引擎原语包的准入表(`CREDENTIAL_REF_TRUST`)对请求面拒 `env` / `handle` / `assertion`,
|
|
50
|
+
* 其余种类(`vault`)在 MCP 传输上也没有座位;MCP 服务器的凭据是部署一侧的声明。请求面上 vault 引用唯一的座位是 hook command 条目的 `plugin.options` 的值(31.0.0 起,
|
|
51
|
+
* `./hooks-config` 的 `HookPluginOptionRef`),与这里无关。
|
|
51
52
|
* 读到这两把键之一(自有键、值不是 `undefined`)⇒ 硬坏形({@link RequestMcpTransportRead} 的 `ok:false`),`issue.refusal` = 这里的词、`issue.path` 点名那把键、`issue.reason` 是原因句(不回显值)。
|
|
52
53
|
* 只靠继承可见 ⇒ 不读、不拒,进 `lost` 点名 —— 与身份头同一条律({@link axisKeyOf})。
|
|
53
54
|
* 判序 = 读序:`kind` 之后先读这两把键(其余键一个都还没读)—— 一条带着点名拒的键的条目,不论别处坏不坏、读不读得出,都读成这一类;两把都在 ⇒ `assertionHeader` 先。
|
|
@@ -183,8 +183,9 @@ function axisKeyOf(record, key) {
|
|
|
183
183
|
/**
|
|
184
184
|
* 请求面读器**点名拒**的键的**原因词**(闭集,29.0.0)—— 与「表外未知键」分得开的那一类:读器认得这把键,知道它为什么不在请求面上。
|
|
185
185
|
* · `key_retired`:`transport.assertionHeader`(http)—— 29.0.0 退役:托管连接器的断言是部署的声明(配置面的 `transport.credentials`),头名归引擎,请求不说它;
|
|
186
|
-
* · `credentials_not_carried`:`transport.credentials`(两种传输)——
|
|
187
|
-
*
|
|
186
|
+
* · `credentials_not_carried`:`transport.credentials`(两种传输)—— 请求面的 MCP 条目不承载凭据引用:引擎原语包的准入表(`CREDENTIAL_REF_TRUST`)对请求面拒 `env` / `handle` / `assertion`,
|
|
187
|
+
* 其余种类(`vault`)在 MCP 传输上也没有座位;MCP 服务器的凭据是部署一侧的声明。请求面上 vault 引用唯一的座位是 hook command 条目的 `plugin.options` 的值(31.0.0 起,
|
|
188
|
+
* `./hooks-config` 的 `HookPluginOptionRef`),与这里无关。
|
|
188
189
|
* 读到这两把键之一(自有键、值不是 `undefined`)⇒ 硬坏形({@link RequestMcpTransportRead} 的 `ok:false`),`issue.refusal` = 这里的词、`issue.path` 点名那把键、`issue.reason` 是原因句(不回显值)。
|
|
189
190
|
* 只靠继承可见 ⇒ 不读、不拒,进 `lost` 点名 —— 与身份头同一条律({@link axisKeyOf})。
|
|
190
191
|
* 判序 = 读序:`kind` 之后先读这两把键(其余键一个都还没读)—— 一条带着点名拒的键的条目,不论别处坏不坏、读不读得出,都读成这一类;两把都在 ⇒ `assertionHeader` 先。
|
|
@@ -196,13 +197,13 @@ const ASSERTION_HEADER_RETIRED_ON_REQUEST = retiredFormSentence("transport.asser
|
|
|
196
197
|
retiredIn: "29.0.0",
|
|
197
198
|
now: "no request names it: a hosted connector's assertion is declared by the deployment (transport.credentials in its settings) and its header is the engine's — remove the key from the request",
|
|
198
199
|
});
|
|
199
|
-
/** 请求里出现的 `credentials` 为什么不收:原语包读得出且准入表对请求面拒这个种类 ⇒ 点名种类(闭集词);否则 ⇒
|
|
200
|
+
/** 请求里出现的 `credentials` 为什么不收:原语包读得出且准入表对请求面拒这个种类 ⇒ 点名种类(闭集词);否则 ⇒ 请求面的 MCP 传输没有凭据引用的座位。两句都不回显值。 */
|
|
200
201
|
function credentialsNotCarriedReason(raw) {
|
|
201
202
|
const read = readCredentialRef(raw);
|
|
202
203
|
if (read.ok && CREDENTIAL_REF_TRUST[read.ref.kind].request === "refused") {
|
|
203
204
|
return `a credential reference of kind "${read.ref.kind}" is never taken from a request (the deployment declares it for this server) — remove transport.credentials from the request`;
|
|
204
205
|
}
|
|
205
|
-
return "a request carries no credential reference (
|
|
206
|
+
return "an MCP server entry in a request carries no credential reference (its transport has no seat for one; the deployment declares it) — remove transport.credentials from the request";
|
|
206
207
|
}
|
|
207
208
|
/** 点名拒的硬坏形(机读词在 `refusal`)。 */
|
|
208
209
|
const keyRefused = (path, reason, refusal) => ({ ok: false, issue: { path, reason, refusal } });
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(
|
|
13
|
-
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包除内建外只读登记名,本模块的函数不在其中),闭包里不能 import 本模块 ——
|
|
13
|
+
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里
|
|
14
|
+
* (31.0.0 起闭包已多注入三只登记名 —— 插件列的三样判法 —— S-2133 的触发条件已到,收口本身另车)。
|
|
14
15
|
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
16
|
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
17
|
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(
|
|
13
|
-
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包除内建外只读登记名,本模块的函数不在其中),闭包里不能 import 本模块 ——
|
|
13
|
+
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里
|
|
14
|
+
* (31.0.0 起闭包已多注入三只登记名 —— 插件列的三样判法 —— S-2133 的触发条件已到,收口本身另车)。
|
|
14
15
|
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
16
|
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
17
|
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
package/dist/retired-envs.js
CHANGED
|
@@ -86,6 +86,13 @@ export const RETIRED_ENVS = deepFreeze([
|
|
|
86
86
|
// 壳的总开关没有可 rename 的目标(出路是在目录条目上声明链,不是换个 env 名)⇒ removed。近预算降级线的三个旋钮(`MODEL_DEGRADE_TO` / `_AT_COST_FRACTION` / `_TO_VISION`)仍是活旋钮,不在本表。
|
|
87
87
|
["MODEL_DEGRADE_ON", "MODEL_FALLBACK_ON", "replaced", "the gate words moved to the engine's per-model fallback chain: budget is no longer a gate word, network / auth / stream_torn are new, and the gate now applies to every catalog chain instead of one whole-Brain target"],
|
|
88
88
|
["MODEL_DEGRADE_REACTIVE", "the env-driven whole-Brain reactive degrade shell was retired: declare `fallbacks` on the catalog entry (models.models[].fallbacks) — a fallback chain is catalog data now; the gate words that decide when a hop is taken are MODEL_FALLBACK_ON", "removed"],
|
|
89
|
+
// 会话箱耐久帧的部署开关:「排会话箱的每个进程都读得懂引擎帧」自服务端 7.146.0 起是构建的事实(引擎地板),不再是部署的选择 —— 没有可关的东西,也没有可 rename 的目标。
|
|
90
|
+
// 提了本版契约包的那一版服务端(按计划是 7.156.0;本包不验证服务端行为)起才不读这只名:读侧同代要求 —— 7.154.x – 7.155.x 的服务端仍把它当活旋钮读、缺省关
|
|
91
|
+
// (这只名自服务端 7.154.0 起才有,更早的服务端不认识它);服务端精确钉契约包版本,所以这一行只对提了本版契约包的服务端生效。对更老的服务端删掉这只键 = 关掉这项能力;
|
|
92
|
+
// 本包的 worker 规格写闸不分目标服务端的代,而提了本版契约包的服务端见到这只键即拒启 ⇒ 给 worker 渲染 env 的一方逐台做:换到带本版契约包的服务端与从这台 worker 的环境里删掉这只键是同一步;
|
|
93
|
+
// 渲染方在全部 worker 换完之前留在上一版契约包(它还要给没换的 worker 写这只键、对已换的不写),全部换完再提本版;没法按 worker 分别渲染的渲染方先删键再升级。
|
|
94
|
+
// 理由句只说这个能力为什么没了、不带点分版本号(会原样进拒启句;与 LSP_ENABLED / STREAM_APPROVAL_ENABLED / MODEL_DEGRADE_REACTIVE 三行同约定):版本事实写在这里与 CHANGELOG。
|
|
95
|
+
["SESSION_BOX_ENGINE_FRAMES", "the session-box engine-frames switch was retired: every process that drains session boxes reads engine frames, so that is a fact of the build rather than a deployment choice — there is nothing left to switch", "removed"],
|
|
89
96
|
]);
|
|
90
97
|
/** 墓碑表 → wire 投影(纯数据)。**同一张表、同序**;族是闭集,穷举 switch(加一族不写这里 ⇒ 编译红)。 */
|
|
91
98
|
export function buildRetiredEnvWire() {
|
|
@@ -474,10 +474,11 @@ export const SAFETY_MERGE_SPEC = deepFreeze({
|
|
|
474
474
|
// DELIBERATELY not per-key (a harmless key such as the result count admitted from an untrusted layer): an untrusted repository layer's one
|
|
475
475
|
// admission outlet is `direction: "tighten"`, a result count is not a tightening, and a member row has no numeric value class.
|
|
476
476
|
// No `coreAxis` (the value domain is not the engine's). Not in `SETTINGS_UNITS` (see that file's "NOT in this table"); the section's
|
|
477
|
-
// settings-document key is `WEB_SEARCH_SECTION_KEYS` (`./web-search-section`), and
|
|
477
|
+
// settings-document key is `WEB_SEARCH_SECTION_KEYS` (`./web-search-section`), and both this row's key and its seam read it from there
|
|
478
|
+
// (the computed key keeps the literal type, so `SafetyMergeCategory` still has the member "webSearch"). The seam says only what
|
|
478
479
|
// this package holds — where the section comes from and where it lands; what a consumer of the request then does with it is that
|
|
479
480
|
// consumer's contract, documented on its side.
|
|
480
|
-
|
|
481
|
+
[WEB_SEARCH_SECTION_KEYS[0]]: {
|
|
481
482
|
mergeShape: "replace", minTrust: "project", tighten: { rule: "none" }, enforcement: "resolver", fail: "closed",
|
|
482
483
|
seam: `settings.${WEB_SEARCH_SECTION_KEYS[0]} (one section, taken whole from one layer) → request settings.${WEB_SEARCH_SECTION_KEYS[0]}`,
|
|
483
484
|
},
|
package/dist/types.js
CHANGED
|
@@ -2711,7 +2711,7 @@ export const McpConfig = z
|
|
|
2711
2711
|
});
|
|
2712
2712
|
});
|
|
2713
2713
|
// ── Domain: a2a (常驻出站 A2A 对端名册 —— 18.0.0) ─────────────────────────────────────────────────────────────
|
|
2714
|
-
// 一个 A2A 对端 = 一个
|
|
2714
|
+
// 一个 A2A 对端 = 一个 http(s) 端点(`http:` 与 `https:` 两种 scheme 都收 —— 判官判的是 URL 的形,不强制 https;单一传输,没有判别);形是 mcp http 条目的近亲,判官一律复用:URL = NON_SECRET_URL(存量文档座位,与 mcp `transport.url`
|
|
2715
2715
|
// 同座;名形判官 `findUrlCredential` 是新提交门的事,不接进读已落盘字节的 schema),`headerRefs` = mcp 的头名 → env-NAME 引用集合(凭据引用,
|
|
2716
2716
|
// 值集合:坏一项 ⇒ 整个对端丢),`principalHeader` = 头名判官,`name` = 线上名判官(对端名是线上工具名 `a2a__<名>__…` 的身份片)。
|
|
2717
2717
|
// 秘密边界同 mcp:中心只存 env-NAME,值在读方自己的环境里。写权限 publisher(一个对端就是一组新挂进智能体的远端技能,同 mcp)。
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Its merge law and admission floor are one row, `SAFETY_MERGE_SPEC.webSearch` (`./safety-merge-spec`); this module publishes the
|
|
6
6
|
* section's KEY, the way `HTTP_HOOK_ALLOWLIST_KEYS` (`./http-hook-allowlists`) and `MCP_SERVER_LIST_KEYS` (`./mcp-server-policy`) publish
|
|
7
7
|
* the keys of the other contracts that are not `SETTINGS_UNITS` rows. A consumer that labels each settings key with what this package says
|
|
8
|
-
* about it reads the unit table plus these key constants — the section's key is not spelled out anywhere else in this package (the
|
|
9
|
-
* `seam`
|
|
8
|
+
* about it reads the unit table plus these key constants — the section's key is not spelled out anywhere else in this package's code (the
|
|
9
|
+
* row's key in `SAFETY_MERGE_SPEC` and its `seam` both read it from here).
|
|
10
10
|
*
|
|
11
11
|
* Every key here is also the name of the category that governs it, so a reader asks admission with the key itself:
|
|
12
12
|
* `layerAdmission(source, workspace, key)` — the section whole, never one of its members (the category has none).
|