@sema-agent/settings-schema 27.1.0 → 28.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 +505 -0
- package/README.md +17 -1
- package/conformance/VERSION +1 -1
- package/dist/api/auth-bridge.js +4 -3
- package/dist/api/auth.js +6 -5
- package/dist/api/credentials.js +9 -8
- package/dist/api/pull-token.js +2 -1
- package/dist/api/scopes.js +5 -4
- package/dist/center-refs.js +3 -2
- package/dist/config-dir-io.d.ts +1 -1
- package/dist/config-dir-io.js +3 -2
- package/dist/config-document-refusal.d.ts +1 -1
- package/dist/config-document-refusal.js +2 -1
- package/dist/config-fns.d.ts +4 -4
- package/dist/config-fns.js +17 -16
- package/dist/config-root-documents.js +4 -3
- package/dist/config-root-node.d.ts +1 -1
- package/dist/config-root-node.js +3 -2
- package/dist/conformance/derive.d.ts +3 -3
- package/dist/conformance/derive.js +6 -5
- package/dist/conformance/types.js +4 -3
- package/dist/cross-domain.js +6 -5
- package/dist/cross-session.js +3 -2
- package/dist/deep-freeze.d.ts +26 -0
- package/dist/deep-freeze.js +69 -0
- package/dist/default-model.js +2 -1
- package/dist/device-relay.d.ts +1 -1
- package/dist/device-relay.js +1 -1
- package/dist/env-model-table.js +2 -1
- package/dist/execution-lane-index.d.ts +1 -1
- package/dist/execution-lane-index.js +5 -4
- package/dist/execution-lanes.d.ts +2 -2
- package/dist/execution-lanes.js +18 -17
- package/dist/file-store.js +2 -1
- package/dist/fleet.d.ts +20 -4
- package/dist/fleet.js +32 -16
- package/dist/hooks-config.d.ts +12 -12
- package/dist/hooks-config.js +16 -15
- package/dist/hooks.d.ts +5 -5
- package/dist/hooks.js +17 -16
- package/dist/http-hook-allowlists.js +2 -1
- package/dist/index.js +1 -1
- package/dist/mcp-request-entry.js +2 -1
- package/dist/mcp-server-policy.js +3 -2
- package/dist/migration-receipt.d.ts +1 -1
- package/dist/migration-receipt.js +3 -2
- package/dist/one-time-migrations.js +3 -2
- package/dist/own-key-read.d.ts +3 -1
- package/dist/plain-json-object.d.ts +6 -3
- package/dist/plain-json-object.js +6 -3
- package/dist/portable-domains.js +4 -3
- package/dist/reserved-member-name.d.ts +1 -1
- package/dist/reserved-member-name.js +3 -2
- package/dist/resolve-roster.js +3 -2
- package/dist/retired-envs.js +3 -6
- package/dist/safety-merge-spec.d.ts +11 -4
- package/dist/safety-merge-spec.js +5 -4
- package/dist/secret-scan.js +1 -1
- package/dist/settings-sources.js +6 -5
- package/dist/settings-units.js +3 -2
- package/dist/types.d.ts +9 -9
- package/dist/types.js +27 -26
- package/dist/ui-language.js +4 -3
- package/dist/url-credential.js +4 -3
- package/dist/url-shape.d.ts +1 -1
- package/dist/url-shape.js +5 -4
- package/dist/web-admin-credential.js +2 -1
- package/dist/web-admin-env.d.ts +1 -1
- package/dist/web-admin-env.js +4 -3
- package/docs/CONSUMER-INTEGRATION.md +48 -3
- package/llms-full.txt +5 -3
- package/llms.txt +4 -2
- package/package.json +1 -1
package/dist/hooks-config.js
CHANGED
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
import { z } from "zod";
|
|
52
52
|
import { isPlainJsonObject } from "./plain-json-object.js";
|
|
53
53
|
import { buildQuotedIssue, fixed } from "./quoted-issue.js";
|
|
54
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
54
55
|
// ── event vocabulary ───────────────────────────────────────────────────────────────────────────────────────
|
|
55
56
|
// The two halves below are where each word came from (CC 2.1.198's own table, then the later additions) — provenance for the
|
|
56
57
|
// reader of this file, not a contract: they are module-private, and the ONE exported closed set is {@link HOOK_EVENTS}.
|
|
@@ -97,7 +98,7 @@ const CC_198_HOOK_EVENTS = [
|
|
|
97
98
|
*/
|
|
98
99
|
const POST_198_HOOK_EVENTS = ["CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"];
|
|
99
100
|
/** The full 33-event contract set = CC 198's 27 + the 6 post-198 events — the one exported closed set of hook event names. */
|
|
100
|
-
export const HOOK_EVENTS = [...CC_198_HOOK_EVENTS, ...POST_198_HOOK_EVENTS];
|
|
101
|
+
export const HOOK_EVENTS = deepFreeze([...CC_198_HOOK_EVENTS, ...POST_198_HOOK_EVENTS]);
|
|
101
102
|
/** The guard events (CC 2.1.296 `SV`): their hooks may guard the permissions declared beside them — see the file header. */
|
|
102
103
|
const HOOK_GUARD_EVENTS = ["PreToolUse", "PermissionRequest"];
|
|
103
104
|
// ── entry vocabulary and the one field table ───────────────────────────────────────────────────────────────
|
|
@@ -107,7 +108,7 @@ const HOOK_GUARD_EVENTS = ["PreToolUse", "PermissionRequest"];
|
|
|
107
108
|
* `mcp_tool` (call a tool on an already-configured MCP server). An entry of another type is a bad piece — and in a guard event that rejects
|
|
108
109
|
* the whole document, which is why `test/upstream-drift.test.ts` ①b holds this set against the CC anchor snapshot.
|
|
109
110
|
*/
|
|
110
|
-
export const HOOK_ENTRY_TYPES = ["command", "prompt", "agent", "http", "mcp_tool"];
|
|
111
|
+
export const HOOK_ENTRY_TYPES = deepFreeze(["command", "prompt", "agent", "http", "mcp_tool"]);
|
|
111
112
|
/**
|
|
112
113
|
* The `onFailure` closed set (CC `cli309.js:252382`, `onFailure:At()`): what a FAILURE of the hook does — it could not start (a missing script), timed out, exited with a code other
|
|
113
114
|
* than 0 or 2, or printed JSON that is invalid or fails validation. `continue` (CC's default when the key is absent; this package does not fill it in — an absent key stays absent): the
|
|
@@ -115,7 +116,7 @@ export const HOOK_ENTRY_TYPES = ["command", "prompt", "agent", "http", "mcp_tool
|
|
|
115
116
|
* CARRIED, not executed here: a consumer that reads `block` executes it or refuses it — ignoring it makes a guard that cannot start let the action through.
|
|
116
117
|
* The classifier reads this set through a closure-private projection that the compiler ties to it in both directions.
|
|
117
118
|
*/
|
|
118
|
-
export const HOOK_ON_FAILURE_WORDS = ["continue", "block"];
|
|
119
|
+
export const HOOK_ON_FAILURE_WORDS = deepFreeze(["continue", "block"]);
|
|
119
120
|
/**
|
|
120
121
|
* 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
122
|
* 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
|
|
@@ -124,7 +125,7 @@ export const HOOK_ON_FAILURE_WORDS = ["continue", "block"];
|
|
|
124
125
|
* 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
126
|
* `http` entries. CARRIED, not executed here.
|
|
126
127
|
*/
|
|
127
|
-
export const HOOK_CLOUD_WORDS = ["device", "skip"];
|
|
128
|
+
export const HOOK_CLOUD_WORDS = deepFreeze(["device", "skip"]);
|
|
128
129
|
/** `shell` values: 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
|
|
129
130
|
const HOOK_SHELLS = ["bash", "powershell"];
|
|
130
131
|
/** 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
|
|
@@ -159,8 +160,8 @@ const HOOK_ENTRY_COMMON_FIELDS = { if: "string?", timeout: "seconds?", statusMes
|
|
|
159
160
|
* 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
161
|
* moves an answer the table already gave.
|
|
161
162
|
*/
|
|
162
|
-
export const HOOK_ENTRY_FIELDS =
|
|
163
|
-
command:
|
|
163
|
+
export const HOOK_ENTRY_FIELDS = deepFreeze({
|
|
164
|
+
command: {
|
|
164
165
|
command: "text",
|
|
165
166
|
args: "argv?",
|
|
166
167
|
shell: "shell?",
|
|
@@ -171,11 +172,11 @@ export const HOOK_ENTRY_FIELDS = Object.freeze({
|
|
|
171
172
|
rewakeMessage: "nonEmpty?",
|
|
172
173
|
rewakeSummary: "nonEmpty?",
|
|
173
174
|
cloud: "any?",
|
|
174
|
-
}
|
|
175
|
-
prompt:
|
|
176
|
-
agent:
|
|
177
|
-
http:
|
|
178
|
-
mcp_tool:
|
|
175
|
+
},
|
|
176
|
+
prompt: { prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS, continueOnBlock: "boolean?" },
|
|
177
|
+
agent: { prompt: "text", model: "string?", ...HOOK_ENTRY_COMMON_FIELDS },
|
|
178
|
+
http: { url: "text", headers: "stringRecord?", allowedEnvVars: "stringList?", onFailure: "onFailure?", ...HOOK_ENTRY_COMMON_FIELDS, cloud: "any?" },
|
|
179
|
+
mcp_tool: { server: "string", tool: "string", input: "record?", ...HOOK_ENTRY_COMMON_FIELDS },
|
|
179
180
|
});
|
|
180
181
|
/** 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
182
|
* 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
|
|
@@ -204,7 +205,7 @@ const HOOK_ENTRY_FIELDS_READ = {
|
|
|
204
205
|
};
|
|
205
206
|
// ── classification vocabulary ──────────────────────────────────────────────────────────────────────────────
|
|
206
207
|
/** What happened to a document's hooks: all loaded / loaded with pieces dropped / the document rejected (nothing in it applies). */
|
|
207
|
-
export const HOOKS_CLASSIFICATION_OUTCOMES = ["loaded", "loaded-partial", "rejected"];
|
|
208
|
+
export const HOOKS_CLASSIFICATION_OUTCOMES = deepFreeze(["loaded", "loaded-partial", "rejected"]);
|
|
208
209
|
/**
|
|
209
210
|
* Why a piece was DROPPED (closed; one word per level of piece, no `other`):
|
|
210
211
|
* · `hooks-not-object` — `hooks` is null / a scalar / an array holding only scalars ⇒ the whole `hooks` key goes;
|
|
@@ -213,7 +214,7 @@ export const HOOKS_CLASSIFICATION_OUTCOMES = ["loaded", "loaded-partial", "rejec
|
|
|
213
214
|
* · `matcher-invalid` — a matcher that is not an object, whose `matcher` is not a string or whose `hooks` is not an array (non-guard event);
|
|
214
215
|
* · `entry-invalid` — an entry that is not an object, has no / an unknown `type`, or a field outside its kind (non-guard event).
|
|
215
216
|
*/
|
|
216
|
-
export const HOOKS_DROPPED_PIECE_CODES = ["hooks-not-object", "unknown-event", "event-not-array", "matcher-invalid", "entry-invalid"];
|
|
217
|
+
export const HOOKS_DROPPED_PIECE_CODES = deepFreeze(["hooks-not-object", "unknown-event", "event-not-array", "matcher-invalid", "entry-invalid"]);
|
|
217
218
|
/**
|
|
218
219
|
* Why the document was REJECTED (closed; each is "a guard may be in this piece"):
|
|
219
220
|
* · `guard-outside-hooks` — a guard sign outside `hooks` (top level, under another key, or the document itself matcher-shaped), or the document could not be read at all (path `[]`);
|
|
@@ -223,14 +224,14 @@ export const HOOKS_DROPPED_PIECE_CODES = ["hooks-not-object", "unknown-event", "
|
|
|
223
224
|
* · `guard-matcher-invalid` — a bad matcher in a guard event, or a matcher holding a sign (in any event);
|
|
224
225
|
* · `guard-entry-invalid` — a bad entry in a guard event, or an entry holding a sign (in any event).
|
|
225
226
|
*/
|
|
226
|
-
export const HOOKS_REJECTION_CODES = [
|
|
227
|
+
export const HOOKS_REJECTION_CODES = deepFreeze([
|
|
227
228
|
"guard-outside-hooks",
|
|
228
229
|
"hooks-is-matcher",
|
|
229
230
|
"guard-under-unknown-event",
|
|
230
231
|
"guard-event-not-array",
|
|
231
232
|
"guard-matcher-invalid",
|
|
232
233
|
"guard-entry-invalid",
|
|
233
|
-
];
|
|
234
|
+
]);
|
|
234
235
|
/** The value's shape — six words: `plain` is a JSON object (not null, not an array, prototype null or a prototype whose own prototype is null: any realm's `Object.prototype`),
|
|
235
236
|
* `uninspectable` is a value whose shape cannot be read at all (a proxy that has been revoked, a throwing `getPrototypeOf` trap). This function IS `./plain-json-object`'s `jsonShapeOf`, character for
|
|
236
237
|
* character: the classifier is copied as source by consumers' generators, so its closure cannot import — the package has this one second copy, and the test is what keeps it from drifting. */
|
package/dist/hooks.d.ts
CHANGED
|
@@ -268,8 +268,8 @@ export type AssistantTurnError = z.infer<typeof AssistantTurnError>;
|
|
|
268
268
|
/** SessionEnd `reason` values (CC EXIT_REASONS). */
|
|
269
269
|
export declare const SESSION_EXIT_REASONS: readonly ["clear", "resume", "logout", "prompt_input_exit", "other", "bypass_permissions_disabled"];
|
|
270
270
|
export declare const SessionExitReason: z.ZodEnum<{
|
|
271
|
-
other: "other";
|
|
272
271
|
clear: "clear";
|
|
272
|
+
other: "other";
|
|
273
273
|
resume: "resume";
|
|
274
274
|
logout: "logout";
|
|
275
275
|
prompt_input_exit: "prompt_input_exit";
|
|
@@ -417,8 +417,8 @@ export declare const SessionEndHookInput: z.ZodObject<{
|
|
|
417
417
|
agent_type: z.ZodOptional<z.ZodString>;
|
|
418
418
|
hook_event_name: z.ZodLiteral<"SessionEnd">;
|
|
419
419
|
reason: z.ZodEnum<{
|
|
420
|
-
other: "other";
|
|
421
420
|
clear: "clear";
|
|
421
|
+
other: "other";
|
|
422
422
|
resume: "resume";
|
|
423
423
|
logout: "logout";
|
|
424
424
|
prompt_input_exit: "prompt_input_exit";
|
|
@@ -800,8 +800,8 @@ export declare const FileChangedHookInput: z.ZodObject<{
|
|
|
800
800
|
hook_event_name: z.ZodLiteral<"FileChanged">;
|
|
801
801
|
file_path: z.ZodString;
|
|
802
802
|
event: z.ZodEnum<{
|
|
803
|
-
change: "change";
|
|
804
803
|
add: "add";
|
|
804
|
+
change: "change";
|
|
805
805
|
unlink: "unlink";
|
|
806
806
|
}>;
|
|
807
807
|
}, z.core.$strip>;
|
|
@@ -1027,8 +1027,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1027
1027
|
agent_type: z.ZodOptional<z.ZodString>;
|
|
1028
1028
|
hook_event_name: z.ZodLiteral<"SessionEnd">;
|
|
1029
1029
|
reason: z.ZodEnum<{
|
|
1030
|
-
other: "other";
|
|
1031
1030
|
clear: "clear";
|
|
1031
|
+
other: "other";
|
|
1032
1032
|
resume: "resume";
|
|
1033
1033
|
logout: "logout";
|
|
1034
1034
|
prompt_input_exit: "prompt_input_exit";
|
|
@@ -1385,8 +1385,8 @@ export declare const HookInput: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1385
1385
|
hook_event_name: z.ZodLiteral<"FileChanged">;
|
|
1386
1386
|
file_path: z.ZodString;
|
|
1387
1387
|
event: z.ZodEnum<{
|
|
1388
|
-
change: "change";
|
|
1389
1388
|
add: "add";
|
|
1389
|
+
change: "change";
|
|
1390
1390
|
unlink: "unlink";
|
|
1391
1391
|
}>;
|
|
1392
1392
|
}, z.core.$strip>, z.ZodObject<{
|
package/dist/hooks.js
CHANGED
|
@@ -42,6 +42,7 @@
|
|
|
42
42
|
import { z } from "zod";
|
|
43
43
|
import { HOOK_EVENTS } from "./hooks-config.js";
|
|
44
44
|
import { INTEGER } from "./integer.js";
|
|
45
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
45
46
|
export * from "./hooks-config.js";
|
|
46
47
|
// ── event set ──────────────────────────────────────────────────────────────────────────────────────────
|
|
47
48
|
// The ONE closed set of hook event names is {@link HOOK_EVENTS} (`./hooks-config`, re-exported above; drift-gated against CC).
|
|
@@ -63,7 +64,7 @@ export const HookOwner = z.enum(["engine", "shell"]);
|
|
|
63
64
|
* contract than a member's row does not know the member is engine-owned. A consumer that routes by this set must not keep its own
|
|
64
65
|
* table of "which member joined at which version".
|
|
65
66
|
*/
|
|
66
|
-
export const ENGINE_OWNED_HOOK_EVENTS = [
|
|
67
|
+
export const ENGINE_OWNED_HOOK_EVENTS = deepFreeze([
|
|
67
68
|
"PreToolUse",
|
|
68
69
|
"PostToolUse",
|
|
69
70
|
"PostToolUseFailure",
|
|
@@ -74,9 +75,9 @@ export const ENGINE_OWNED_HOOK_EVENTS = [
|
|
|
74
75
|
"StopFailure",
|
|
75
76
|
"UserPromptSubmit",
|
|
76
77
|
"PermissionDenied",
|
|
77
|
-
];
|
|
78
|
+
]);
|
|
78
79
|
/** owner per event — single owner; the non-owner side never fires it (dedup rule). */
|
|
79
|
-
export const HOOK_EVENT_OWNER = Object.fromEntries(HOOK_EVENTS.map((e) => [e, ENGINE_OWNED_HOOK_EVENTS.includes(e) ? "engine" : "shell"]));
|
|
80
|
+
export const HOOK_EVENT_OWNER = deepFreeze(Object.fromEntries(HOOK_EVENTS.map((e) => [e, ENGINE_OWNED_HOOK_EVENTS.includes(e) ? "engine" : "shell"])));
|
|
80
81
|
/**
|
|
81
82
|
* The first version of THIS package whose {@link ENGINE_OWNED_HOOK_EVENTS} carried each member — the contract version from which a peer that
|
|
82
83
|
* embeds this package treats the event as engine-owned (the server reports its embedded version as `settingsContract.version` on
|
|
@@ -91,7 +92,7 @@ export const HOOK_EVENT_OWNER = Object.fromEntries(HOOK_EVENTS.map((e) => [e, EN
|
|
|
91
92
|
*
|
|
92
93
|
* Frozen: every reader in a process shares it. Read it through {@link engineOwnsHookEventAt}; do not compare against it by hand.
|
|
93
94
|
*/
|
|
94
|
-
export const ENGINE_OWNED_HOOK_EVENT_SINCE =
|
|
95
|
+
export const ENGINE_OWNED_HOOK_EVENT_SINCE = deepFreeze({
|
|
95
96
|
PreToolUse: "1.0.0",
|
|
96
97
|
PostToolUse: "1.0.0",
|
|
97
98
|
PostToolUseFailure: "1.0.0",
|
|
@@ -138,7 +139,7 @@ export function engineOwnsHookEventAt(event, contractVersion) {
|
|
|
138
139
|
* ignored for the event; every entry matches). Ported from the shell's getMatchingHooks switch. HOW the matcher is read
|
|
139
140
|
* against that field is {@link hookMatcherSelects} (the one reading).
|
|
140
141
|
*/
|
|
141
|
-
export const HOOK_EVENT_MATCHER_FIELD = {
|
|
142
|
+
export const HOOK_EVENT_MATCHER_FIELD = deepFreeze({
|
|
142
143
|
PreToolUse: "tool_name",
|
|
143
144
|
PostToolUse: "tool_name",
|
|
144
145
|
PostToolUseFailure: "tool_name",
|
|
@@ -174,7 +175,7 @@ export const HOOK_EVENT_MATCHER_FIELD = {
|
|
|
174
175
|
// matcher can scope a hook to "only when switching TO this model".
|
|
175
176
|
PreModelSwitch: "to_model",
|
|
176
177
|
PostModelSwitch: "to_model",
|
|
177
|
-
};
|
|
178
|
+
});
|
|
178
179
|
// ── shared enums (CC-verbatim) ─────────────────────────────────────────────────────────────────────────
|
|
179
180
|
export const PermissionBehavior = z.enum(["allow", "deny", "ask"]);
|
|
180
181
|
export const PermissionMode = z.enum(["default", "acceptEdits", "bypassPermissions", "plan", "dontAsk"]);
|
|
@@ -209,14 +210,14 @@ export const AssistantTurnError = z.enum([
|
|
|
209
210
|
"max_output_tokens",
|
|
210
211
|
]);
|
|
211
212
|
/** SessionEnd `reason` values (CC EXIT_REASONS). */
|
|
212
|
-
export const SESSION_EXIT_REASONS = [
|
|
213
|
+
export const SESSION_EXIT_REASONS = deepFreeze([
|
|
213
214
|
"clear",
|
|
214
215
|
"resume",
|
|
215
216
|
"logout",
|
|
216
217
|
"prompt_input_exit",
|
|
217
218
|
"other",
|
|
218
219
|
"bypass_permissions_disabled",
|
|
219
|
-
];
|
|
220
|
+
]);
|
|
220
221
|
export const SessionExitReason = z.enum(SESSION_EXIT_REASONS);
|
|
221
222
|
// ── per-event input payloads (CC-verbatim field names: hook_event_name / session_id / cwd + extras) ────
|
|
222
223
|
/**
|
|
@@ -388,7 +389,7 @@ export const ElicitationResultHookInput = BaseHookInput.extend({
|
|
|
388
389
|
action: z.enum(["accept", "decline", "cancel"]),
|
|
389
390
|
content: z.record(z.string(), z.unknown()).optional(),
|
|
390
391
|
});
|
|
391
|
-
export const CONFIG_CHANGE_SOURCES = ["user_settings", "project_settings", "local_settings", "policy_settings", "skills"];
|
|
392
|
+
export const CONFIG_CHANGE_SOURCES = deepFreeze(["user_settings", "project_settings", "local_settings", "policy_settings", "skills"]);
|
|
392
393
|
export const ConfigChangeHookInput = BaseHookInput.extend({
|
|
393
394
|
hook_event_name: z.literal("ConfigChange"),
|
|
394
395
|
source: z.enum(CONFIG_CHANGE_SOURCES),
|
|
@@ -402,8 +403,8 @@ export const WorktreeRemoveHookInput = BaseHookInput.extend({
|
|
|
402
403
|
hook_event_name: z.literal("WorktreeRemove"),
|
|
403
404
|
worktree_path: z.string(),
|
|
404
405
|
});
|
|
405
|
-
export const INSTRUCTIONS_LOAD_REASONS = ["session_start", "nested_traversal", "path_glob_match", "include", "compact"];
|
|
406
|
-
export const INSTRUCTIONS_MEMORY_TYPES = ["User", "Project", "Local", "Managed"];
|
|
406
|
+
export const INSTRUCTIONS_LOAD_REASONS = deepFreeze(["session_start", "nested_traversal", "path_glob_match", "include", "compact"]);
|
|
407
|
+
export const INSTRUCTIONS_MEMORY_TYPES = deepFreeze(["User", "Project", "Local", "Managed"]);
|
|
407
408
|
export const InstructionsLoadedHookInput = BaseHookInput.extend({
|
|
408
409
|
hook_event_name: z.literal("InstructionsLoaded"),
|
|
409
410
|
file_path: z.string(),
|
|
@@ -438,7 +439,7 @@ export const MessageDisplayHookInput = BaseHookInput.extend({
|
|
|
438
439
|
delta: z.string(),
|
|
439
440
|
});
|
|
440
441
|
/** How a directory joined the session working set: the `/add-dir` slash command or repo-root registration. */
|
|
441
|
-
export const DIRECTORY_ADDED_SOURCES = ["slash_command", "register_repo_root"];
|
|
442
|
+
export const DIRECTORY_ADDED_SOURCES = deepFreeze(["slash_command", "register_repo_root"]);
|
|
442
443
|
/**
|
|
443
444
|
* Fired after a directory joins the session's working set (CC 2.1.219; agent-types hooks.d.ts:582-586 —
|
|
444
445
|
* `directory` is the absolute path). Shell-owned; matcher ignored; no hookSpecificOutput arm upstream.
|
|
@@ -454,10 +455,10 @@ export const DirectoryAddedHookInput = BaseHookInput.extend({
|
|
|
454
455
|
* set_model), while `PostModelSwitch` also reports changes nobody requested (`auto` = automatic fallback,
|
|
455
456
|
* `resume` = model restored while resuming a session) — those have no "before" to gate.
|
|
456
457
|
*/
|
|
457
|
-
export const MODEL_SWITCH_SOURCES = {
|
|
458
|
+
export const MODEL_SWITCH_SOURCES = deepFreeze({
|
|
458
459
|
pre: ["command", "picker", "sdk"],
|
|
459
460
|
post: ["command", "picker", "sdk", "auto", "resume"],
|
|
460
|
-
};
|
|
461
|
+
});
|
|
461
462
|
/** The fields both model-switch events carry (CC-verbatim): the models, what was asked for, and the
|
|
462
463
|
* cache-forfeit estimate a hook needs to decide whether the switch is worth it. */
|
|
463
464
|
const ModelSwitchFields = {
|
|
@@ -648,12 +649,12 @@ export const HookOutput = z.union([AsyncHookOutput, SyncHookOutput]);
|
|
|
648
649
|
// `prompt` / `agent` / `http` / `mcp_tool` hook types are part of the config contract (`HOOK_ENTRY_TYPES`); a runner
|
|
649
650
|
// may phase them in after `command` — config validity is not phased (`classifyHooksConfig` is the one reading of it).
|
|
650
651
|
/** Env names the hook runner injects into a command hook's environment (CC-parity). */
|
|
651
|
-
export const HOOK_INJECTED_ENV = [
|
|
652
|
+
export const HOOK_INJECTED_ENV = deepFreeze([
|
|
652
653
|
/** Absolute path of the project/workspace root. */
|
|
653
654
|
"CLAUDE_PROJECT_DIR",
|
|
654
655
|
/** SessionStart only: file a hook may append `KEY=value` lines to, persisted into the session env. */
|
|
655
656
|
"CLAUDE_ENV_FILE",
|
|
656
|
-
];
|
|
657
|
+
]);
|
|
657
658
|
/** Default per-hook timeout when an entry does not set one (seconds; CC default). */
|
|
658
659
|
export const DEFAULT_HOOK_TIMEOUT_SECONDS = 60;
|
|
659
660
|
/** The characters a matcher may consist of to be read as a NAME LIST rather than a regex. */
|
|
@@ -19,8 +19,9 @@ import { captureDenseArray, inspect, isStringEntry, readKey } from "./own-key-re
|
|
|
19
19
|
import { isJsonArray, isPlainJsonArray, jsonShapeOf } from "./plain-json-object.js";
|
|
20
20
|
import { layerAdmission } from "./settings-sources.js";
|
|
21
21
|
import { urlAllowPatternMatches } from "./url-pattern.js";
|
|
22
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
22
23
|
/** 两键(闭集,声明序)。 */
|
|
23
|
-
export const HTTP_HOOK_ALLOWLIST_KEYS = ["allowedHttpHookUrls", "httpHookAllowedEnvVars"];
|
|
24
|
+
export const HTTP_HOOK_ALLOWLIST_KEYS = deepFreeze(["allowedHttpHookUrls", "httpHookAllowedEnvVars"]);
|
|
24
25
|
/**
|
|
25
26
|
* 整份 `settings.json` 里本片段负责的两键:在场则必须是字符串数组。刻意 `passthrough`(与 `CrossSessionSettings` 同姿势):本片段不是整份
|
|
26
27
|
* 设置的闭集门。它是**写侧**的形门;读侧坏形不拒整份,按 {@link readHttpHookAllowlistLayer} 读成空名单(fail-closed)。
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* web-admin, the worker service, and the TOC desktop/CLI.
|
|
4
4
|
*/
|
|
5
5
|
export * from "./types.js";
|
|
6
|
-
export * from "./execution-lanes.js"; // 7.0.0 M-R2: the ONE lane / store vocabulary (EXECUTION_LANE_WORDS / EXECUTION_LANES / STORE_BACKENDS / SESSION_BACKENDS / MEMORY_ENGINE_BACKENDS) + THE lane-coordinate blank judge isBlankCoordinate (empty or whitespace-only = absent; the write gate and every consumer ask this one function; whether a key is set, and whether an optional key may be empty, stays the caller's call; the same function object as on the `./execution-lanes` subpath) — a zero-import
|
|
6
|
+
export * from "./execution-lanes.js"; // 7.0.0 M-R2: the ONE lane / store vocabulary (EXECUTION_LANE_WORDS / EXECUTION_LANES / STORE_BACKENDS / SESSION_BACKENDS / MEMORY_ENGINE_BACKENDS) + THE lane-coordinate blank judge isBlankCoordinate (empty or whitespace-only = absent; the write gate and every consumer ask this one function; whether a key is set, and whether an optional key may be empty, stays the caller's call; the same function object as on the `./execution-lanes` subpath) — a leaf whose only import is the package-private zero-import freezer, pure/browser-safe
|
|
7
7
|
export * from "./config-document-refusal.js"; // 15.2.0: the typed refusal of one config.d document (CONFIG_DOCUMENT_REFUSAL_REASONS = empty / invalid_json / not_object / io / retired_domain; ConfigDocumentRefusal { document, reason, error } + the tombstone arm's migration) — the reading is `inspectBundle` in ./node; pure/browser-safe
|
|
8
8
|
export * from "./url-shape.js"; // 11.0.0: THE URL shape judge (httpUrlFlaws / httpUrlRule / isHierarchicalUrl; 16.0.0 + wsUrlFlaws), pure/browser-safe
|
|
9
9
|
export * from "./device-relay.js"; // 16.0.0: THE value grammar of the device lane's DEVICE_RELAY_URL (DEVICE_RELAY_NONE / deviceRelayFlaws / DEVICE_RELAY_RULE), pure/browser-safe
|
|
@@ -33,6 +33,7 @@ import { RESERVED_MCP_SERVER_NAME_REASON, isReservedMcpServerName } from "./mcp-
|
|
|
33
33
|
import { startsWithHttpScheme } from "./url-shape.js";
|
|
34
34
|
import { TOOL_WIRE_NAME_MAX_CHARS, hasEdgeWhitespace, isUsableWireName } from "./wire-name.js";
|
|
35
35
|
import { isReservedMemberName } from "./reserved-member-name.js";
|
|
36
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
36
37
|
// ── 值的种类描述(拒句只说「你写的是什么形」,不回显值:值可能带凭据、可能任意长)──────────────────────────────────────
|
|
37
38
|
/** 值的**种类词**(不回显值本身):`null` / `array` / `typeof` 词(`object` / `function` / `string` …);读不出的对象 ⇒ 全包唯一的那一句。形状只问座位(总,不抛):两只坏值描述器共用这一只。 */
|
|
38
39
|
function describeKindWord(v) {
|
|
@@ -321,7 +322,7 @@ const reservedMemberFault = (name) => `no member of a declaration may be named "
|
|
|
321
322
|
* 词的意义逐词写在 {@link McpEntryKeyIssue}。消费方按词分派,不读句子;读器的读数 {@link PlainStringRecordRead} 与传输条目的机读位 {@link McpEntryKeyIssue} 的 `fault` 都由这一张表推出。
|
|
322
323
|
* 多一个词而消费方的穷尽 `switch` 不补 ⇒ 编译红(提货成本,不是静默)。
|
|
323
324
|
*/
|
|
324
|
-
export const PLAIN_STRING_RECORD_FAULTS = ["not_plain_record", "member_not_string", "member_name_reserved"];
|
|
325
|
+
export const PLAIN_STRING_RECORD_FAULTS = deepFreeze(["not_plain_record", "member_not_string", "member_name_reserved"]);
|
|
325
326
|
/** 记录不交时 `detail` 的前半句:它是哪一种不朴素(null / 数组 / 原始值各一句,对象里的非朴素一句)。`shape` 穷举 —— 新词不补 = 编译红。 */
|
|
326
327
|
function notPlainDetail(shape, v) {
|
|
327
328
|
switch (shape) {
|
|
@@ -17,10 +17,11 @@
|
|
|
17
17
|
*/
|
|
18
18
|
import { settingsSourceContract } from "./settings-sources.js";
|
|
19
19
|
import { urlAllowPatternMatches, urlDenyPatternMatches } from "./url-pattern.js";
|
|
20
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
20
21
|
/** 两张名单的键(闭集,声明序)。 */
|
|
21
|
-
export const MCP_SERVER_LIST_KEYS = ["allowedMcpServers", "deniedMcpServers"];
|
|
22
|
+
export const MCP_SERVER_LIST_KEYS = deepFreeze(["allowedMcpServers", "deniedMcpServers"]);
|
|
22
23
|
/** 没过的那一条的种类(闭集)。拒绝名单:命中的条目种类;允许名单:必须命中而没命中的条目种类,`empty` = 允许名单是空数组。 */
|
|
23
|
-
export const MCP_POLICY_RULES = ["name", "command", "url", "empty"];
|
|
24
|
+
export const MCP_POLICY_RULES = deepFreeze(["name", "command", "url", "empty"]);
|
|
24
25
|
const isName = (e) => "serverName" in e && e.serverName !== undefined;
|
|
25
26
|
const isCommand = (e) => "serverCommand" in e && e.serverCommand !== undefined;
|
|
26
27
|
const isUrl = (e) => "serverUrl" in e && e.serverUrl !== undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(
|
|
2
|
+
* 一次性迁移的**收据形**与两张闭集(11.0.0)—— 叶子模块(运行期零依赖;除包内私有的零 import 叶 `./deep-freeze` 外只有型导入),由 `./one-time-migrations` 再导出(不进主桶)。
|
|
3
3
|
* 单拆出来只为一件事:读迁移 id 闭集的叶子(墓碑句 `./retired-form`、车道表 `./execution-lane-index`、配置根文档 `./config-root-documents`)
|
|
4
4
|
* 不该为一个型把整套迁移体与域 schema 拉进来。(26.0.0 起调度店的读口不再带收据 —— 它的读时改写到期删了。)
|
|
5
5
|
*/
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
1
2
|
/** 本版登记的一次性迁移 id(闭集;每个 id 在 `ONE_TIME_MIGRATIONS` 登记表里恰一行)。收据只许这些 id。 */
|
|
2
|
-
export const ONE_TIME_MIGRATION_IDS = ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
|
|
3
|
+
export const ONE_TIME_MIGRATION_IDS = deepFreeze(["SS-M8", "SS-M10", "SS-M11", "SS-M12"]);
|
|
3
4
|
/**
|
|
4
5
|
* 一条收据说迁移**对一个坐标做了什么**(闭集,每词一义):
|
|
5
6
|
* - `moved` — 值搬到新位(`to`),义不变;
|
|
@@ -9,4 +10,4 @@ export const ONE_TIME_MIGRATION_IDS = ["SS-M8", "SS-M10", "SS-M11", "SS-M12"];
|
|
|
9
10
|
* - `minted` — 在**缺席处**写下一份新事实(一份部署决定),不改任何已有的值 —— 只有 SS-M11 铸(配置根的 `config.env-models.json`:
|
|
10
11
|
* 升级前「管模型面的目录整表顶替 env 模型」的读法,写成 `replaced`;不存在才建)。
|
|
11
12
|
*/
|
|
12
|
-
export const MIGRATION_APPLIED_AS = ["moved", "rewritten", "dropped-inert", "refused", "minted"];
|
|
13
|
+
export const MIGRATION_APPLIED_AS = deepFreeze(["moved", "rewritten", "dropped-inert", "refused", "minted"]);
|
|
@@ -40,9 +40,10 @@ import { isJsonArray, isPlainJsonObject, jsonShapeOf } from "./plain-json-object
|
|
|
40
40
|
import { RETIRED_ROLE_WORDS } from "./retired-role-words.js";
|
|
41
41
|
import { isDomainName, isRetiredDomainName } from "./types.js";
|
|
42
42
|
import { workerRowVerdict } from "./worker-row-verdict.js";
|
|
43
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
43
44
|
export { MIGRATION_APPLIED_AS, ONE_TIME_MIGRATION_IDS } from "./migration-receipt.js";
|
|
44
45
|
/** 一次性迁移登记表 —— 本族各条窗的**唯一属主**。别处只写「窗见 `ONE_TIME_MIGRATIONS` 登记表」。 */
|
|
45
|
-
export const ONE_TIME_MIGRATIONS = [
|
|
46
|
+
export const ONE_TIME_MIGRATIONS = deepFreeze([
|
|
46
47
|
{
|
|
47
48
|
id: "SS-M8",
|
|
48
49
|
oldForm: "refused",
|
|
@@ -110,7 +111,7 @@ export const ONE_TIME_MIGRATIONS = [
|
|
|
110
111
|
afterRemoval: "the runtime.execution.lane tombstone field, the memory-backend refusal for \"tidb\" and the reserved-env refusal for DEVICE_RELAY_URL (permanent): a residual " +
|
|
111
112
|
"15.x row is refused on write and held by readWorkersRows on read, never rewritten",
|
|
112
113
|
},
|
|
113
|
-
];
|
|
114
|
+
]);
|
|
114
115
|
/**
|
|
115
116
|
* 迁移一组存储文档(见文件头「入口」)。纯函数;没改的文档原样返回;**不抬任何版本号**(结果里没有版本 —— 那是调用方的)。
|
|
116
117
|
* 重跑恒等:第二次跑零改动,只剩第一次就 `refused` 的那几张收据(那些坐标原样留着,读侧照旧拒)。
|
package/dist/own-key-read.d.ts
CHANGED
|
@@ -25,7 +25,9 @@
|
|
|
25
25
|
* 内核覆盖声明键读与整容器读;**仍自带读法的读者按名登记**(各自写明契约;普查钉按「文件 → 函数 → 读法 API」逐处数,登记外出现即红):
|
|
26
26
|
* 既有、未经内核的数据读者:`tightenVerdict` 的 `none` 规则(`strictJsonCopy`:对象的不可枚举键跳过、访问器 ⇒ 整份 `unreadable`;数组按 `length` 逐位读描述符 —— `length` 走一次 `[[Get]]`、不可枚举的下标照读)·
|
|
27
27
|
* 被丢条目的身份(`readEntryIdentity` 读 `name` / `id`,它调的 `ownEnabledFlag`(`./catalog-manages`,与原文判官共用)读 `enabled` —— 同一读法:访问器 ⇒ 当缺席,从不调)· 传输记录读法(`readPlainStringRecord`:自己枚举成员名 `getOwnPropertyNames`,值经 {@link readKey});
|
|
28
|
-
* 不是数据读的:安全判官 `extraBodyUnsafe` 的审计读(`./types`:问「任何自有键上有没有可疑」,含符号键与会抛的描述符,访问器 ⇒ 判不安全,从不调)
|
|
28
|
+
* 不是数据读的:安全判官 `extraBodyUnsafe` 的审计读(`./types`:问「任何自有键上有没有可疑」,含符号键与会抛的描述符,访问器 ⇒ 判不安全,从不调)·
|
|
29
|
+
* 包内冻结助手 `freezeGraph`(`./deep-freeze`:`getOwnPropertyDescriptor` + `Reflect.ownKeys` 走**包自己的闭集常量**的自有数据属性、决定冻谁,不读嵌入方传来的值;它保持零 import,所以不经本内核 ——
|
|
30
|
+
* 是选择,不是做不到:本内核只 import 座位与 zod 的类型,引它不成环)。
|
|
29
31
|
* 直接用 `[[Get]]` 的几处(不经内核,按名登记):hooks 分类器(`Object.keys` + 成员读;闭包可抄的内建写法,随闭包契约变更收)· `collectDropped` / `collectionSlots`(`./config-fns`:
|
|
30
32
|
* 未知键扫描与条目集合的位置表,自己枚举容器再 `[[Get]]`;既有)· http hook 名单读器与判官的**普通读对拍**(安全轴的名单、判官的 `layers` / `hookVars` 要描述符视图
|
|
31
33
|
* 与普通读两份观测一致才算读到 —— 普通读只作对拍,交出去的值取自描述符那一份;见 `./http-hook-allowlists`)。`stableStringify` 已归零(每个容器经 {@link containerView} 的宽归类列一次成员、
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
|
|
7
7
|
* 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
|
|
8
8
|
* fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
|
|
9
|
-
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格)
|
|
9
|
+
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包里的自由名只有 `HOOK_EVENTS`),闭包里不能 import 本模块 ——
|
|
13
13
|
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里。
|
|
14
|
-
*
|
|
14
|
+
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
|
+
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
|
+
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
|
17
|
+
* 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
|
|
15
18
|
*
|
|
16
19
|
* **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
|
|
17
20
|
* 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
|
|
@@ -6,12 +6,15 @@
|
|
|
6
6
|
* (`./one-time-migrations`)、`config.d` 文档形(`./config-d-file`)、`extraBody` 的形闸与秘密走查(`./types`)、settings 单元读法与严格 JSON 深度判(`./settings-units` / `./safety-merge-spec`)、
|
|
7
7
|
* 请求面传输的记录读法与描述件(`./mcp-request-entry`)、workers 行读口(`./workers-rows`)、有效配置线上载荷读口(`./config-fns` 的 `readEffectiveWire`)、http hook 名单的设置袋(`./http-hook-allowlists`)、
|
|
8
8
|
* fleet 线上载荷的受护判(`./fleet`)、符合性语料的比较器 / 派生 / 语料读口 / 元数据拆分(`./conformance/*`)。零 import。
|
|
9
|
-
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格)
|
|
9
|
+
* **形状分类核 {@link jsonShapeOf} 是座位的本体**,`isPlainJsonObject` 由它派生(`plain` 那一格);本模块里读原型的只有它与安全轴的朴素数组判据 {@link isPlainJsonArray}(全包另有两处读原型,见下)。**总(不抛)**:检视就抛的对象(已撤销的 Proxy、`getPrototypeOf` 陷阱抛)
|
|
10
10
|
* 核答 `uninspectable`、判官答 `false`,不抛出去 —— 全包经座位的读口因此拒而不抛,律在座位上收一处,不在每个读器各包一个 `try`;读者对 `uninspectable` 一律按最严处置(hooks ⇒ 拒整份文档;名单 ⇒ `malformed`;传输 ⇒ 整只不交)。
|
|
11
11
|
*
|
|
12
|
-
*
|
|
12
|
+
* **形状判的第二处是 `./hooks-config` 的 `hookShapeOf` / `hookIsRecord`,与 {@link jsonShapeOf} / 本函数逐字同文(调用名归一后)**:hooks 分类器的闭包要被消费方生成器整函数抄走(闭包里的自由名只有 `HOOK_EVENTS`),闭包里不能 import 本模块 ——
|
|
13
13
|
* 同文由 `test/plain-json-object-single-seat-14.6.0.test.ts` 逐字证明(漂开即红),闭包契约多注入一个名字时(S-2133)把它并回这里。
|
|
14
|
-
*
|
|
14
|
+
* **第三处是包内冻结助手 `./deep-freeze` 的 `freezeGraph`**:它也问「是不是数组」「原型是什么」,但它只接触包自己的闭集常量(不读嵌入方传来的值),判「朴素对象」用的是原型恒等 `Object.prototype`(或 `null`),
|
|
15
|
+
* 与本模块的判法(原型是 `null`,或原型自己的原型是 `null`)不同 —— 它不是本模块的副本,没有「同文」的要求。助手保持零 import 是一个选择(叶性钉与消费方抄本组不必跟着变),不是做不到:本模块自己零 import,引它不成环。
|
|
16
|
+
* 两种「朴素对象」读法收成一种是后续的设计事项,这条注释不改判据。
|
|
17
|
+
* 同一个门也数全包:返回类型是 `x is Record<string, unknown>` 的函数,除本模块与 `./hooks-config` 那一份这两处之外一处不许有;读原型的调用点,除这两处与冻结助手一处之外一处不许有;内联的「typeof 对象 ∧ 非 null ∧ 非数组」合取则**一处都不许有**(座位里它是分开的 `if` 臂,不是合取)。
|
|
15
18
|
*
|
|
16
19
|
* **读者要的答案不只是「是不是朴素对象」时,调本模块的 {@link jsonShapeOf}**(六词形状分类),不在读者里再推一遍形状:例如托管层的 http hook 名单,非朴素的**对象**袋必须 fail-closed(读成空名单并告警),
|
|
17
20
|
* 而 `null` / 原始值 / 数组仍是「整份设置不是对象 ⇒ 两键都缺」—— 两种不同的答案,只能由形状分类给。`isPlainJsonObject` 就是 `jsonShapeOf` 的「朴素」那一格。
|
package/dist/portable-domains.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
1
2
|
/** The domains a single-machine TOC carries: what `FileConfigStore` reads out of `config.d/`, and the
|
|
2
3
|
* **default**域集 of the bundle helpers (`exportBundle`/`readBundle`). 每个被排除的域必须在
|
|
3
4
|
* {@link NON_PORTABLE_DOMAIN_REASONS} 里有一条成文理由(禁裸排除,#282 件5 附带裁定)。
|
|
@@ -12,7 +13,7 @@
|
|
|
12
13
|
* 同形**。当年 `limits` 域就是这样在单机腿静默丢了一整片限额发布(远端腿同批可用,所以更难看出来)。
|
|
13
14
|
* 今日的兜底:漏登记的文件会被 `FileConfigStore`(`./node`)的 `"unread-config-file"` 警告点名(fail-loud,
|
|
14
15
|
* 见 getEffective),但那只在消费方接了 `onWarning` 时才响 —— **登记仍是第一现场的义务**。 */
|
|
15
|
-
export const PORTABLE_DOMAINS = ["models", "rosters", "skills", "mcp", "plugins", "scenarios", "collab", "governance", "execution", "prompts", "limits", "a2a"];
|
|
16
|
+
export const PORTABLE_DOMAINS = deepFreeze(["models", "rosters", "skills", "mcp", "plugins", "scenarios", "collab", "governance", "execution", "prompts", "limits", "a2a"]);
|
|
16
17
|
/**
|
|
17
18
|
* 非便携域的**排除理由表**(#282 件5 附带裁定:禁裸排除)。
|
|
18
19
|
*
|
|
@@ -21,10 +22,10 @@ export const PORTABLE_DOMAINS = ["models", "rosters", "skills", "mcp", "plugins"
|
|
|
21
22
|
* (此前是「理由写在注释里」,机器只能做子串匹配——域名出现在文件任何角落都算数,等于没门;对抗复审
|
|
22
23
|
* 复审 round1 F3。)理由要写**为什么它不该被单机/跨部署搬运**,带出处。
|
|
23
24
|
*/
|
|
24
|
-
export const NON_PORTABLE_DOMAIN_REASONS = {
|
|
25
|
+
export const NON_PORTABLE_DOMAIN_REASONS = deepFreeze({
|
|
25
26
|
workers: "FLEET-only:单机没有 reconciler,`{workers:[]}` 的 schema 默认就是正确语义(缺席不需要 stub)。",
|
|
26
27
|
hosts: "FLEET-only:同 workers —— 单机无机器注册表/自动排布,空注册表即正确语义。",
|
|
27
28
|
systems: "FLEET-only:系统接入/凭据下发的元数据(nonce+路由)属于 web-admin 侧生命周期,单机 lane 无对应执法点。",
|
|
28
29
|
projects: "TENANT IDENTITY DATA,不是可搬运的配置:登记簿随包复制进另一个部署 = 凭空多出的身份登记(design/142 §1.4 威胁模型①「carried-in foreign projectId」换了身 import 的衣服)。要带走走 142 §5 的导出面(service 半场)。",
|
|
29
30
|
entitlement: "per-PRINCIPAL 商务/治理数据(tier·预算上限·kill-switch·allowlist),与 projects 同威胁模型(#282 件5 附带裁定,此前是唯一裸排除项):(a) 搬走 = 把一个租户的商务档复制进另一部署;(b) 反向也不成立 —— 单机 TOC 无 principal 轴(无鉴权语境、无 `/effective?principal=` 解析面),本地 entitlement.json 只会造出一份**永不被执法**的假管控面(真执法点在 service / web-admin 边界)。缺席语义如实:本地 buildEffective 给它 schema 默认值(空表),这**不等于**把远端 kill-switch/预算上限搬到了本地 —— 单机 lane 本就没有那个执法点。",
|
|
30
|
-
};
|
|
31
|
+
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 包内私有叶子模块(
|
|
2
|
+
* 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
|
|
3
3
|
* **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
|
|
4
4
|
* `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
|
|
5
5
|
* 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* 包内私有叶子模块(
|
|
2
|
+
* 包内私有叶子模块(运行期只 import 包内私有的零 import 叶 `./deep-freeze`,浏览器安全;不进 `package.json` 的 exports,主桶经 `./mcp-request-entry` 转出这里的公开名):
|
|
3
3
|
* **一个名字能不能作「名 → 串」记录的成员名**的唯一判据 —— 原型链上的三个名字永远不能:`__proto__`(按赋值拷贝会变成原型;zod 的 record 读键前先跳过它、不判它的值)、
|
|
4
4
|
* `constructor` / `prototype`(读方对普通对象做 `obj[名]` 时撞上原型成员)。
|
|
5
5
|
* 三个读口问它,同一张表、同一个答案:域 schema 的凭据引用集合(`./types` 的 `credentialRefs`:在场 ⇒ 集合坏)· 公开的记录读器(`./mcp-request-entry` 的 `readPlainStringRecord` /
|
|
6
6
|
* `isStringRecord`,请求面传输的 `env` / `headers` 同读:剔出副本并点名)· 中心引用解析口(`./center-refs`,经记录读器:在场 ⇒ `refs_unreadable`)。
|
|
7
7
|
* 住在叶子里,是因为 `./types` 与 `./mcp-request-entry` 都要它,而后者反过来引 `./types`。
|
|
8
8
|
*/
|
|
9
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
9
10
|
/** 保留成员名,闭集。 */
|
|
10
|
-
export const RESERVED_MEMBER_NAMES = ["__proto__", "constructor", "prototype"];
|
|
11
|
+
export const RESERVED_MEMBER_NAMES = deepFreeze(["__proto__", "constructor", "prototype"]);
|
|
11
12
|
/** 这个名字是保留成员名吗(大小写敏感:`Constructor` / `X-Prototype` 不是)。 */
|
|
12
13
|
export function isReservedMemberName(name) {
|
|
13
14
|
return RESERVED_MEMBER_NAMES.includes(name);
|
package/dist/resolve-roster.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { stableHash } from "./hash.js";
|
|
2
2
|
import { danglingRefs } from "./cross-domain.js";
|
|
3
3
|
import { toSkillsManifest } from "./skills-manifest.js";
|
|
4
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
4
5
|
// ── 主/cheap 角色标记语义(0.6.3, E3)────────────────────────────────
|
|
5
6
|
// service 现有 ModelRoles 口径:default→主(12.0.0 起唯一;`team` / `synthesize` 随 core 7.49.0 删)、subagent/summarize→cheap。1.8.0 起 `classifier`/`consolidate`
|
|
6
7
|
// 同 `verifier` 一样**不派生**(归 cheap 会盖掉 models.tiers 档位与 core 兜底链)。`verifier` 刻意
|
|
7
8
|
// 不派生(unset→core 的 default 兜底链,与 service 语义一致)。常量导出=单一语义源,service 收敛小单与
|
|
8
9
|
// web-admin 表单同源引用,别第二份。
|
|
9
10
|
/** primaryModel 标记喂的角色族(§3)。 */
|
|
10
|
-
export const ROSTER_PRIMARY_ROLES = ["default"];
|
|
11
|
+
export const ROSTER_PRIMARY_ROLES = deepFreeze(["default"]);
|
|
11
12
|
/** cheapModel 标记喂的角色族(§3)。 */
|
|
12
|
-
export const ROSTER_CHEAP_ROLES = ["subagent", "summarize"];
|
|
13
|
+
export const ROSTER_CHEAP_ROLES = deepFreeze(["subagent", "summarize"]);
|
|
13
14
|
/** 把 roster 的主/cheap 角色标记派生成 roles 片段(PURE)。显式 roster.roles 逐角色盖过它;它盖过全局
|
|
14
15
|
* models.roles(合并点见 {@link resolveEffectiveForWorker})。wire 形状不变——service 零改仍兼容,
|
|
15
16
|
* 收敛后直接读标记亦可(effective 的 rosters 域不上 wire,标记经此物化进 models.roles)。 */
|
package/dist/retired-envs.js
CHANGED
|
@@ -25,13 +25,14 @@
|
|
|
25
25
|
*
|
|
26
26
|
* 行形 = 字面元组(第三元是族词),一行一个旧名。纯数据 + 纯函数,零 IO,browser-safe。
|
|
27
27
|
*/
|
|
28
|
+
import { deepFreeze } from "./deep-freeze.js";
|
|
28
29
|
import { PREVIOUS_WEB_ADMIN_ENV } from "./previous-web-admin-env.js";
|
|
29
30
|
import { WEB_ADMIN_ENV } from "./web-admin-env.js";
|
|
30
31
|
/** 墓碑拒启码(机读;拒句方括号里)。 */
|
|
31
32
|
export const RETIRED_ENV_REFUSAL_CODE = "config.env_key_retired";
|
|
32
33
|
const OA_REMOVED = "the OA scenario was removed in 5.0.0";
|
|
33
34
|
const negativeAliasWhy = (old, positive) => `negative-name alias retired in server 3.0.0 — unset it; the polarity is inverted: ${old}=true is ${positive}=false (the positive name defaults on)`;
|
|
34
|
-
export const RETIRED_ENVS = [
|
|
35
|
+
export const RETIRED_ENVS = deepFreeze([
|
|
35
36
|
["TIDB_HOST", "MYSQL_HOST", "renamed"],
|
|
36
37
|
["TIDB_PORT", "MYSQL_PORT", "renamed"],
|
|
37
38
|
["TIDB_USER", "MYSQL_USER", "renamed"],
|
|
@@ -85,11 +86,7 @@ export const RETIRED_ENVS = [
|
|
|
85
86
|
// 壳的总开关没有可 rename 的目标(出路是在目录条目上声明链,不是换个 env 名)⇒ removed。近预算降级线的三个旋钮(`MODEL_DEGRADE_TO` / `_AT_COST_FRACTION` / `_TO_VISION`)仍是活旋钮,不在本表。
|
|
86
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"],
|
|
87
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"],
|
|
88
|
-
];
|
|
89
|
-
// 冻结:拿到导出的人改不了拒启判据(读拒句的与投影 wire 的是同一个数组对象)。
|
|
90
|
-
for (const row of RETIRED_ENVS)
|
|
91
|
-
Object.freeze(row);
|
|
92
|
-
Object.freeze(RETIRED_ENVS);
|
|
89
|
+
]);
|
|
93
90
|
/** 墓碑表 → wire 投影(纯数据)。**同一张表、同序**;族是闭集,穷举 switch(加一族不写这里 ⇒ 编译红)。 */
|
|
94
91
|
export function buildRetiredEnvWire() {
|
|
95
92
|
return RETIRED_ENVS.map((row) => {
|