@sema-agent/settings-schema 27.2.0 → 29.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/CHANGELOG.md +753 -0
  2. package/README.md +88 -12
  3. package/conformance/VERSION +1 -1
  4. package/conformance/cases/c01-entry-salvage-then-typo/expected.json +1 -1
  5. package/conformance/cases/c02-hosts-clamp-stacked/expected.json +1 -1
  6. package/conformance/cases/c03-literal-dotted-top-key/expected.json +1 -1
  7. package/conformance/cases/c04-all-bad-collection-not-salvaged/expected.json +1 -1
  8. package/conformance/cases/c07-hooks-is-not-a-config-domain/expected.json +1 -1
  9. package/conformance/cases/c08-limits-unknown-carried-64/expected.json +1 -1
  10. package/conformance/cases/c09-limits-unknown-carried-65/expected.json +1 -1
  11. package/conformance/cases/c10-record-key-secret-redacted-twice/expected.json +1 -1
  12. package/conformance/cases/c11-unicode-unknown-keys/expected.json +1 -1
  13. package/conformance/cases/c12-prototype-name-top-keys/expected.json +1 -1
  14. package/conformance/cases/c13-models-field-null/expected.json +1 -1
  15. package/conformance/cases/c14-models-field-empty-array/expected.json +1 -1
  16. package/conformance/cases/c15-models-field-number/expected.json +1 -1
  17. package/conformance/cases/c18-wire-envelope-not-an-object/expected.json +1 -1
  18. package/conformance/cases/c19-wire-envelope-no-version/expected.json +1 -1
  19. package/conformance/cases/c21-governance-empty-object-wins/expected.json +1 -1
  20. package/conformance/cases/c23-mixed-validity-models/expected.json +1 -1
  21. package/conformance/cases/c24-valid-entries-with-unknown-keys/expected.json +1 -1
  22. package/conformance/cases/c25-published-roundtrip-zero-warnings/expected.json +1 -1
  23. package/conformance/cases/c26-hosts-array-1024/expected.json +1 -1
  24. package/conformance/cases/c27-hosts-array-1025/expected.json +1 -1
  25. package/conformance/cases/c28-large-document-over-1mb/expected.json +1 -1
  26. package/conformance/cases/c29-salvage-then-domain-refine-fails/expected.json +1 -1
  27. package/conformance/cases/c30-version-triple-a-first/expected.json +1 -1
  28. package/conformance/cases/c31-version-triple-b-changed/expected.json +1 -1
  29. package/conformance/cases/c32-version-triple-a-restored/expected.json +1 -1
  30. package/conformance/cases/c33-limits-nested-carried-key/expected.json +1 -1
  31. package/conformance/cases/c34-skills-content-vs-manifest/expected.json +1 -1
  32. package/conformance/cases/c36-skills-entry-without-content/expected.json +1 -1
  33. package/conformance/cases/c38-remote-exec-is-a-non-domain-file/expected.json +1 -1
  34. package/conformance/cases/c39-hidden-file-in-config-d/expected.json +1 -1
  35. package/conformance/cases/c40-s712-identity-only-what-reads-out/expected.json +1 -1
  36. package/conformance/cases/c41-s792-encoded-pem-identity/expected.json +1 -1
  37. package/conformance/cases/c42-s792-unknown-key-secret-redacted/expected.json +1 -1
  38. package/conformance/cases/c43-s792-form-and-deep-encoded-pem/expected.json +1 -1
  39. package/conformance/cases/c44-s792-utf8-escape-glued-token/expected.json +1 -1
  40. package/conformance/cases/c45-s792-identity-bounds-and-decode-depth/expected.json +1 -1
  41. package/conformance/cases/c46-s811-host-name-url-userinfo-withheld/expected.json +1 -1
  42. package/conformance/cases/c47-s811-roles-key-url-userinfo-withheld/expected.json +1 -1
  43. package/conformance/cases/c48-s935-model-headers-transported/expected.json +1 -1
  44. package/conformance/cases/c49-s935-model-headers-secret-entry-dropped/expected.json +1 -1
  45. package/conformance/cases/c50-s784-lane-host-legal/expected.json +1 -1
  46. package/conformance/cases/c51-s784-lane-e2b-legal/expected.json +1 -1
  47. package/conformance/cases/c52-s784-lane-k8s-legal/expected.json +1 -1
  48. package/conformance/cases/c53-s784-lane-ssh-legal/expected.json +1 -1
  49. package/conformance/cases/c54-s784-lane-adb-legal/expected.json +1 -1
  50. package/conformance/cases/c55-s784-lane-local-docker-legal/expected.json +1 -1
  51. package/conformance/cases/c56-s784-lane-device-legal/expected.json +1 -1
  52. package/conformance/cases/c57-s784-g1-enabled-no-lane/expected.json +1 -1
  53. package/conformance/cases/c58-s784-g2-multitenant-host/expected.json +1 -1
  54. package/conformance/cases/c59-s784-g3-k8s-missing-image/expected.json +1 -1
  55. package/conformance/cases/c60-s784-g3-e2b-missing-key/expected.json +1 -1
  56. package/conformance/cases/c61-s784-g3-other-lane-key/expected.json +1 -1
  57. package/conformance/cases/c62-s784-g7a-session-tidb/expected.json +1 -1
  58. package/conformance/cases/c63-s784-host-two-replicas/expected.json +1 -1
  59. package/conformance/cases/c64-s784-multitenant-local-store/expected.json +1 -1
  60. package/conformance/cases/c65-s784-pg-without-db/expected.json +1 -1
  61. package/conformance/cases/c66-s784-memory-backend-mismatch/expected.json +1 -1
  62. package/conformance/cases/c67-s784-retired-field-loud/expected.json +1 -1
  63. package/conformance/cases/c68-s784-device-local-store/expected.json +1 -1
  64. package/conformance/cases/c69-deep-encoded-token-past-every-reading/expected.json +1 -1
  65. package/conformance/cases/c70-rewritten-token-in-front-of-encoded-pem-header/expected.json +1 -1
  66. package/conformance/cases/c71-one-scanner-write-reads-display-forms/expected.json +1 -1
  67. package/conformance/cases/c72-dangling-reference-write-seat-refuses/expected.json +1 -1
  68. package/conformance/cases/c73-projects-extended-registration-reads/expected.json +1 -1
  69. package/conformance/cases/c74-projects-over-bound-refused/expected.json +3 -72
  70. package/conformance/cases/c75-projects-patch-remote-uniqueness/expected.json +3 -72
  71. package/conformance/cases/c76-projects-entry-salvage-nested/expected.json +1 -1
  72. package/conformance/cases/c77-prompts-center-artifact-carried/expected.json +1 -1
  73. package/conformance/cases/c78-prompts-empty-bindings-refused/expected.json +1 -1
  74. package/conformance/cases/c79-prompts-bad-worker-artifact-not-salvaged/expected.json +1 -1
  75. package/conformance/cases/c80-prompts-wire-v2-verbatim/expected.json +1 -1
  76. package/conformance/cases/c81-prompts-declaration-bindings-refused/expected.json +1 -1
  77. package/conformance/cases/c82-prompts-v1-catalog-refused/expected.json +1 -1
  78. package/conformance/cases/c83-prompts-bad-overlay-not-salvaged/expected.json +1 -1
  79. package/conformance/cases/c84-sandbox-git-block-carried-verbatim/expected.json +1 -1
  80. package/conformance/cases/c85-sandbox-git-refused-block-still-carried/expected.json +1 -1
  81. package/conformance/cases/c86-a2a-peers-legal/expected.json +1 -1
  82. package/conformance/cases/c87-a2a-credential-refs-not-partially-salvaged/expected.json +1 -1
  83. package/conformance/cases/c88-projects-content-attestation-carried/expected.json +1 -1
  84. package/conformance/cases/c89-projects-content-attestation-malformed/expected.json +1 -1
  85. package/conformance/cases/c90-mcp-assertion-credential-carried/expected.json +143 -0
  86. package/conformance/cases/c90-mcp-assertion-credential-carried/input.json +30 -0
  87. package/conformance/cases/c90-mcp-assertion-credential-carried/meta.json +6 -0
  88. package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/expected.json +105 -0
  89. package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/input.json +27 -0
  90. package/conformance/cases/c91-mcp-assertion-header-retired-entry-dropped/meta.json +6 -0
  91. package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/expected.json +105 -0
  92. package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/input.json +31 -0
  93. package/conformance/cases/c92-mcp-principal-header-with-assertion-dropped/meta.json +6 -0
  94. package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/expected.json +105 -0
  95. package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/input.json +33 -0
  96. package/conformance/cases/c93-mcp-header-refs-with-credentials-dropped/meta.json +6 -0
  97. package/conformance/cases/c94-mcp-credentials-env-kind-dropped/expected.json +105 -0
  98. package/conformance/cases/c94-mcp-credentials-env-kind-dropped/input.json +32 -0
  99. package/conformance/cases/c94-mcp-credentials-env-kind-dropped/meta.json +6 -0
  100. package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/expected.json +105 -0
  101. package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/input.json +30 -0
  102. package/conformance/cases/c95-mcp-credentials-audience-not-connector-id-dropped/meta.json +6 -0
  103. package/conformance/cases/c96-mcp-credentials-extra-member-dropped/expected.json +105 -0
  104. package/conformance/cases/c96-mcp-credentials-extra-member-dropped/input.json +31 -0
  105. package/conformance/cases/c96-mcp-credentials-extra-member-dropped/meta.json +6 -0
  106. package/conformance/cases/cc01-mcp-toolfaces-non-object/expected.json +1 -1
  107. package/conformance/cases/cc02-mcp-source-key-is-transported/expected.json +1 -1
  108. package/conformance/cases/cc03-model-compat-unknown-subkey/expected.json +1 -1
  109. package/conformance/cases/cli01-model-name-nfc-vs-nfd/expected.json +1 -1
  110. package/conformance/cases/cli02-control-and-zero-width-chars/expected.json +1 -1
  111. package/conformance/cases/cli03-credential-pasted-into-unknown-key/expected.json +1 -1
  112. package/conformance/cases/cli04-env-value-with-newline/expected.json +1 -1
  113. package/conformance/cases/cli05-long-and-prefix-colliding-names/expected.json +1 -1
  114. package/conformance/cases/t01-absent-domain-key-not-null/expected.json +1 -1
  115. package/conformance/cases/t03-prototype-name-key-not-swallowed/expected.json +1 -1
  116. package/conformance/cases/t04-secret-literal-never-in-warning-value/expected.json +1 -1
  117. package/conformance/cases/z01-every-domain-empty-object/expected.json +1 -1
  118. package/conformance/cases/z02-every-domain-unknown-key/expected.json +1 -1
  119. package/dist/api/auth-bridge.js +4 -3
  120. package/dist/api/auth.js +6 -5
  121. package/dist/api/credentials.js +14 -15
  122. package/dist/api/lifecycle-events.d.ts +266 -0
  123. package/dist/api/lifecycle-events.js +169 -0
  124. package/dist/api/pull-token.js +2 -1
  125. package/dist/api/scopes.js +5 -4
  126. package/dist/api/wire-scalars.d.ts +13 -0
  127. package/dist/api/wire-scalars.js +15 -0
  128. package/dist/atomic-write.d.ts +4 -0
  129. package/dist/atomic-write.js +26 -3
  130. package/dist/center-refs.js +3 -2
  131. package/dist/config-d-file.d.ts +1 -1
  132. package/dist/config-dir-io.d.ts +1 -1
  133. package/dist/config-dir-io.js +3 -2
  134. package/dist/config-document-refusal.d.ts +5 -5
  135. package/dist/config-document-refusal.js +2 -1
  136. package/dist/config-fns.d.ts +5 -5
  137. package/dist/config-fns.js +17 -16
  138. package/dist/config-root-documents.d.ts +1 -1
  139. package/dist/config-root-documents.js +4 -3
  140. package/dist/config-root-node.d.ts +1 -1
  141. package/dist/config-root-node.js +5 -3
  142. package/dist/conformance/corpus.d.ts +1 -1
  143. package/dist/conformance/derive.d.ts +16 -8
  144. package/dist/conformance/derive.js +41 -24
  145. package/dist/conformance/index.d.ts +1 -1
  146. package/dist/conformance/index.js +1 -1
  147. package/dist/conformance/run.js +8 -9
  148. package/dist/conformance/types.js +4 -3
  149. package/dist/connector-authorize-url.d.ts +23 -0
  150. package/dist/connector-authorize-url.js +129 -0
  151. package/dist/connector-id.d.ts +23 -0
  152. package/dist/connector-id.js +27 -0
  153. package/dist/cross-domain.js +6 -5
  154. package/dist/cross-session.js +3 -2
  155. package/dist/deep-freeze.d.ts +26 -0
  156. package/dist/deep-freeze.js +69 -0
  157. package/dist/default-model.js +2 -1
  158. package/dist/device-relay.d.ts +1 -1
  159. package/dist/device-relay.js +1 -1
  160. package/dist/env-model-table.js +2 -1
  161. package/dist/execution-lane-index.d.ts +1 -1
  162. package/dist/execution-lane-index.js +5 -4
  163. package/dist/execution-lanes.d.ts +2 -2
  164. package/dist/execution-lanes.js +18 -17
  165. package/dist/file-edit.d.ts +44 -0
  166. package/dist/file-edit.js +70 -1
  167. package/dist/file-store.d.ts +12 -7
  168. package/dist/file-store.js +72 -59
  169. package/dist/fleet.js +14 -13
  170. package/dist/hooks-config.d.ts +12 -12
  171. package/dist/hooks-config.js +16 -15
  172. package/dist/hooks.d.ts +20 -10
  173. package/dist/hooks.js +30 -19
  174. package/dist/http-hook-allowlists.js +2 -1
  175. package/dist/index.d.ts +4 -0
  176. package/dist/index.js +6 -2
  177. package/dist/mcp-entry-credential.d.ts +47 -0
  178. package/dist/mcp-entry-credential.js +73 -0
  179. package/dist/mcp-request-entry.d.ts +32 -13
  180. package/dist/mcp-request-entry.js +106 -59
  181. package/dist/mcp-server-policy.js +3 -2
  182. package/dist/migration-receipt.d.ts +3 -3
  183. package/dist/migration-receipt.js +4 -3
  184. package/dist/one-time-migrations.d.ts +2 -2
  185. package/dist/one-time-migrations.js +75 -57
  186. package/dist/own-key-read.d.ts +3 -1
  187. package/dist/plain-json-object.d.ts +6 -3
  188. package/dist/plain-json-object.js +6 -3
  189. package/dist/portable-domains.d.ts +18 -12
  190. package/dist/portable-domains.js +21 -15
  191. package/dist/reserved-member-name.d.ts +1 -1
  192. package/dist/reserved-member-name.js +3 -2
  193. package/dist/resolve-roster.js +3 -2
  194. package/dist/retired-envs.js +3 -6
  195. package/dist/retired-role-words.d.ts +1 -1
  196. package/dist/retired-role-words.js +4 -6
  197. package/dist/safety-merge-spec.d.ts +11 -4
  198. package/dist/safety-merge-spec.js +5 -4
  199. package/dist/scheduler-store-node.d.ts +5 -2
  200. package/dist/scheduler-store-node.js +8 -5
  201. package/dist/secret-scan.js +1 -1
  202. package/dist/settings-sources.js +6 -5
  203. package/dist/settings-units.js +3 -2
  204. package/dist/sha256.d.ts +5 -0
  205. package/dist/sha256.js +7 -0
  206. package/dist/skills-manifest.js +2 -2
  207. package/dist/types.d.ts +89 -19
  208. package/dist/types.js +57 -65
  209. package/dist/ui-language.js +4 -3
  210. package/dist/url-credential.js +4 -3
  211. package/dist/url-shape.d.ts +1 -1
  212. package/dist/url-shape.js +5 -4
  213. package/dist/web-admin-credential.js +2 -1
  214. package/dist/web-admin-env.d.ts +1 -1
  215. package/dist/web-admin-env.js +4 -3
  216. package/docs/API-SURFACE.md +47 -7
  217. package/docs/CONFORMANCE.md +6 -4
  218. package/docs/CONSUMER-INTEGRATION.md +131 -6
  219. package/llms-full.txt +46 -24
  220. package/llms.txt +27 -13
  221. package/package.json +3 -2
@@ -6,9 +6,9 @@
6
6
  *
7
7
  * Store path = caller-supplied; both sides agree on `SEMA_CONFIG_DIR` → `~/.sema/scheduled_tasks.json`.
8
8
  */
9
- import { mkdirSync, readFileSync } from 'node:fs';
9
+ import { readFileSync } from 'node:fs';
10
10
  import { dirname } from 'node:path';
11
- import { writeFileAtomic } from './atomic-write.js';
11
+ import { ensureOwnerOnlyDirectory, writeFileAtomic } from './atomic-write.js';
12
12
  import { parseSchedulerStore, serializeSchedulerStore } from './scheduler-store.js';
13
13
  /**
14
14
  * Load the durable store. A MISSING file (ENOENT) ⇒ no records, no warnings (first-run/never-written case); any OTHER
@@ -31,13 +31,16 @@ export function loadSchedulerStore(path, opts) {
31
31
  return parseSchedulerStore(text, opts);
32
32
  }
33
33
  /**
34
- * Persist ATOMICALLY: `mkdir -p` the parent, then the package's one atomic writer (`./atomic-write`: a uniquely-named `.tmp`
34
+ * Persist ATOMICALLY: create the parent if it is missing, then the package's one atomic writer (`./atomic-write`: a uniquely-named `.tmp`
35
35
  * sibling, then `rename` over the target — atomic on POSIX, so a concurrent reader never sees a partial file). The file mode
36
36
  * is the `scheduler-store` class's (0o600 — owner-only, the records may carry principal/session identifiers; every save
37
- * restores it). Throws on IO failure (caller maps to a domain error).
37
+ * restores it). A missing parent is created by the package's one owner-only directory maker (`ensureOwnerOnlyDirectory`, the same
38
+ * one that creates a config root): every missing level is exactly 0o700 whatever the process umask (29.0.0; before, `mkdir -p`
39
+ * under the umask — 002 gave a group-writable directory, which a directory-trust check on the store's path refuses);
40
+ * a directory that already exists keeps its mode. Throws on IO failure (caller maps to a domain error).
38
41
  */
39
42
  export function saveSchedulerStore(path, records) {
40
- mkdirSync(dirname(path), { recursive: true });
43
+ ensureOwnerOnlyDirectory(dirname(path));
41
44
  writeFileAtomic(path, serializeSchedulerStore(records), 'scheduler-store');
42
45
  }
43
46
  /** A filesystem-backed {@link SchedulerStore} bound to a path (convenience for the daemon/backend constructors).
@@ -10,7 +10,7 @@
10
10
  * 不靠异常:单个转义的判据写成字符集(只有 ASCII 的 `%00`–`%7F` 单独解得开),转义串的判据写成 UTF-8 良构判定 ——
11
11
  * 结果与原来的 try/catch 逐字相同(`test/disclosable-identity-6.3.0.test.ts` 的两只冻结 oracle 钉着)。
12
12
  *
13
- * 本模块只引 `./url-shape`(零 import 的叶子;`./types` 引本模块,本模块不回引,不成环)。
13
+ * 本模块只引 `./url-shape`(叶子:自己只引包内私有的零 import 叶 `./deep-freeze`;`./types` 引本模块,本模块不回引,不成环)。
14
14
  */
15
15
  import { httpUrlFlaws } from "./url-shape.js"; // the URL shape judge — whether a parsed URL carries userinfo is its call
16
16
  /** How many percent-decoded layers a secret scan reads beyond the raw string (a multi-encoded `%2573%256B…` →
@@ -35,18 +35,19 @@
35
35
  import { echoCallerText } from "./caller-text-echo.js";
36
36
  import { stripControlAndBidi } from "./control-and-bidi.js";
37
37
  import { SAFETY_MERGE_SPEC, isAtLeast, memberAdmission } from "./safety-merge-spec.js";
38
+ import { deepFreeze } from "./deep-freeze.js";
38
39
  /** The settings sources, in MERGE order (a later source overrides an earlier one where a category's merge shape lets it):
39
40
  * user < project < local < flag < policy. `flagSettings` = settings handed in at launch (`--settings <file|json>`, an SDK embedder's inline
40
41
  * settings); `policySettings` = managed. `foreignProjectSettings` (appended) = the repository's settings files written for another tool; it
41
42
  * contributes tightening writes only, and every tighten rule merges by "the stricter wins" (order-independent), so its place in the order
42
43
  * changes no merged value. */
43
- export const SETTINGS_SOURCES = ["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"];
44
+ export const SETTINGS_SOURCES = deepFreeze(["userSettings", "projectSettings", "localSettings", "flagSettings", "policySettings", "foreignProjectSettings"]);
44
45
  /**
45
46
  * The source table. `flagSettings` is in the operator tier (`global`, not repository-controllable) like CC's: settings handed in at launch are
46
47
  * the launcher's own act — an SDK embedder or a wrapper script — not something a repository brings (a wrapper that turns repository content
47
48
  * into `--settings` makes that choice itself).
48
49
  */
49
- export const SETTINGS_SOURCE_CONTRACT = {
50
+ export const SETTINGS_SOURCE_CONTRACT = deepFreeze({
50
51
  userSettings: { trust: "global", repoControllable: false },
51
52
  projectSettings: { trust: "project", repoControllable: true },
52
53
  localSettings: { trust: "project", repoControllable: true },
@@ -56,7 +57,7 @@ export const SETTINGS_SOURCE_CONTRACT = {
56
57
  // project tier and repository-controlled like this product's own project files, and tighten-only — its deny / ask rules, kill-switches ON and
57
58
  // sandbox restrictions are read, its allow rules, hooks, env, MCP servers and the rest never are (see the file header).
58
59
  foreignProjectSettings: { trust: "project", repoControllable: true, tightenOnly: true },
59
- };
60
+ });
60
61
  /**
61
62
  * The ONE lookup of {@link SETTINGS_SOURCE_CONTRACT}: a source's tier and whether a repository controls it. Every function in this package
62
63
  * that needs a layer's tier reads it here ({@link layerAdmission}, the http hook allowlist judge, the MCP server list verdict) — none takes a
@@ -73,11 +74,11 @@ export function settingsSourceContract(source) {
73
74
  * host must assume so), `no_trust_step` (the host has no trust step at all). A host whose reading throws or yields a word outside this set
74
75
  * passes `declined`; this package's functions refuse an unknown word loudly rather than reading it as any tier.
75
76
  */
76
- export const WORKSPACE_TRUST_STATES = ["accepted", "declined", "no_trust_step"];
77
+ export const WORKSPACE_TRUST_STATES = deepFreeze(["accepted", "declined", "no_trust_step"]);
77
78
  /** What {@link layerAdmission} answers (closed): `admitted`; `trust_withheld` = would be admitted once the workspace is `accepted`;
78
79
  * `below_trust_floor` = this source can never set it (its tier is below the floor); `tighten_only` = this source is read in the tighten direction
79
80
  * only, so nothing — no workspace decision — admits this write from it. */
80
- export const LAYER_ADMISSION_VERDICTS = ["admitted", "trust_withheld", "below_trust_floor", "tighten_only"];
81
+ export const LAYER_ADMISSION_VERDICTS = deepFreeze(["admitted", "trust_withheld", "below_trust_floor", "tighten_only"]);
81
82
  /**
82
83
  * Does a value from `source` for `category` (or one of its declared `member`s; `value` = the candidate value, for a value-directional member)
83
84
  * enter the effective settings, given the workspace trust reading? The rule is in the file header; the data is {@link SETTINGS_SOURCE_CONTRACT}
@@ -60,8 +60,9 @@ import { classifyHooksConfig } from "./hooks-config.js";
60
60
  import { captureJson, captureStringArray, ownEntriesOf } from "./own-key-read.js";
61
61
  import { isPlainJsonObject } from "./plain-json-object.js";
62
62
  import { SAFETY_MERGE_SPEC, resolveMemberTighten, tightenVerdict } from "./safety-merge-spec.js";
63
+ import { deepFreeze } from "./deep-freeze.js";
63
64
  /** The settings-document units (see the file header). `path` is the unit's place in a settings document. */
64
- export const SETTINGS_UNITS = {
65
+ export const SETTINGS_UNITS = deepFreeze({
65
66
  permissions: { path: ["permissions"], category: "permissions", reads: "members" },
66
67
  permissionMode: { path: ["permissions", "defaultMode"], category: "permissionMode", reads: "whole", reading: "permissionMode" },
67
68
  additionalDirectories: { path: ["permissions", "additionalDirectories"], category: "sandboxNetwork", reads: "whole", reading: "stringList" },
@@ -72,7 +73,7 @@ export const SETTINGS_UNITS = {
72
73
  env: { path: ["env"], category: "env", reads: "whole", reading: "envMap" },
73
74
  model: { path: ["model"], category: "model", reads: "whole", reading: "nonEmptyString" },
74
75
  outputStyle: { path: ["outputStyle"], category: "ui", reads: "whole", reading: "nonEmptyString" },
75
- };
76
+ });
76
77
  /** The one place a unit + optional member resolves to what is being asked about — the row and its comparator. Fail-closed
77
78
  * and loud on every misaddressing: an unknown unit (own-property lookup — `"__proto__"` is unknown, not Object.prototype),
78
79
  * a `members` unit without a member, a `whole` unit with one, a `member` unit given another one, an undeclared member
package/dist/sha256.d.ts CHANGED
@@ -17,5 +17,10 @@ import { z } from "zod";
17
17
  export declare function sha256Hex(input: string): string;
18
18
  /** The one spelling of a content digest on the wire: `sha256:` + 64 lowercase hex characters. */
19
19
  export declare const SHA256_DIGEST_RE: RegExp;
20
+ /** The one MINT of that spelling: `sha256:` + the SHA-256 hex of the content. A string is digested as its UTF-8 encoding (the same answer as {@link sha256Hex}); a `Uint8Array` / `Buffer` is
21
+ * digested as the bytes it holds. For a valid UTF-8 byte sequence the two are the same digest of the same octets — but a string decoded from bytes that are not valid UTF-8 has lost them
22
+ * (each bad sequence became U+FFFD), so digest the bytes when the bytes are what you read. Every digest-bearing seat — a skill body (`skillContentHash`), the bytes of a `config.d` document
23
+ * (the expected digest of `writeDomainFileIf`) — calls this, so a reader and a writer of the same content can never spell it two ways. */
24
+ export declare function contentDigest(content: string | Uint8Array): string;
20
25
  /** {@link SHA256_DIGEST_RE} as a schema —— 本包每个装 `sha256:<hex>` 摘要的座位都引它(此前五处各写一遍同一条正则)。 */
21
26
  export declare const Sha256Digest: z.ZodString;
package/dist/sha256.js CHANGED
@@ -20,5 +20,12 @@ export function sha256Hex(input) {
20
20
  }
21
21
  /** The one spelling of a content digest on the wire: `sha256:` + 64 lowercase hex characters. */
22
22
  export const SHA256_DIGEST_RE = /^sha256:[0-9a-f]{64}$/;
23
+ /** The one MINT of that spelling: `sha256:` + the SHA-256 hex of the content. A string is digested as its UTF-8 encoding (the same answer as {@link sha256Hex}); a `Uint8Array` / `Buffer` is
24
+ * digested as the bytes it holds. For a valid UTF-8 byte sequence the two are the same digest of the same octets — but a string decoded from bytes that are not valid UTF-8 has lost them
25
+ * (each bad sequence became U+FFFD), so digest the bytes when the bytes are what you read. Every digest-bearing seat — a skill body (`skillContentHash`), the bytes of a `config.d` document
26
+ * (the expected digest of `writeDomainFileIf`) — calls this, so a reader and a writer of the same content can never spell it two ways. */
27
+ export function contentDigest(content) {
28
+ return `sha256:${typeof content === "string" ? sha256Hex(content) : toHex(sha256Digest(content))}`;
29
+ }
23
30
  /** {@link SHA256_DIGEST_RE} as a schema —— 本包每个装 `sha256:<hex>` 摘要的座位都引它(此前五处各写一遍同一条正则)。 */
24
31
  export const Sha256Digest = z.string().regex(SHA256_DIGEST_RE);
@@ -13,7 +13,7 @@
13
13
  * import here would leak `node:*` into the browser bundle (the review-flagged blocker). Output is byte-identical to
14
14
  * `createHash("sha256")`, so the `sha256:<hex>` content-address the service verifies still matches.
15
15
  */
16
- import { sha256Hex } from "./sha256.js";
16
+ import { contentDigest } from "./sha256.js";
17
17
  // Memoize content→hash: the /effective poll path (toSkillsManifest) and the content-endpoint lookup
18
18
  // (findSkillContent) re-hash the same small, stable skill bodies repeatedly (× N workers × 60s). Skill
19
19
  // bodies are few + rarely change, so this stays tiny; a cap guards against unbounded growth.
@@ -25,7 +25,7 @@ export function skillContentHash(content) {
25
25
  const hit = _hashMemo.get(content);
26
26
  if (hit !== undefined)
27
27
  return hit;
28
- const h = `sha256:${sha256Hex(content)}`;
28
+ const h = contentDigest(content);
29
29
  if (_hashMemo.size >= _HASH_MEMO_CAP)
30
30
  _hashMemo.clear(); // bound — skills are few; simple evict-all is fine
31
31
  _hashMemo.set(content, h);
package/dist/types.d.ts CHANGED
@@ -118,14 +118,14 @@ export type SealedApiKey = z.infer<typeof SealedApiKey>;
118
118
  export type ParseTransparentValidator = "engine-ingest" | "consumer";
119
119
  /** {@link PARSE_TRANSPARENT_KEYS} 的一行。 */
120
120
  export interface ParseTransparentKey {
121
- domain: DomainName;
121
+ readonly domain: DomainName;
122
122
  /** 从域根算起的路径,`[]` = 数组条目,`{}` = Record 值(与门里的派生形逐字一致)。 */
123
- path: string;
123
+ readonly path: string;
124
124
  /** 这个键从哪一版起是解析透明的。 */
125
- since: string;
126
- validatedBy: ParseTransparentValidator;
125
+ readonly since: string;
126
+ readonly validatedBy: ParseTransparentValidator;
127
127
  /** 为什么它在这里不设形判据 —— 一句,带真实后果。 */
128
- why: string;
128
+ readonly why: string;
129
129
  }
130
130
  /**
131
131
  * **解析透明键登记表** —— 本包收下但**不校验其形**的键,一处列全,连同「谁校验」。
@@ -509,7 +509,7 @@ export declare const ScenarioConfig: z.ZodObject<{
509
509
  export type ScenarioConfig = z.infer<typeof ScenarioConfig>;
510
510
  /** Platform credential surfaces a system may NEVER deliver into (红线1 — would let a publish overwrite the
511
511
  * platform's own secrets). Runtime delivery (S3) re-checks; this is the save-time half. */
512
- export declare const DELIVER_DENYLIST: Set<string>;
512
+ export declare const DELIVER_DENYLIST: ReadonlySet<string>;
513
513
  export declare const SystemEntry: z.ZodObject<{
514
514
  name: z.ZodString;
515
515
  callsWorkers: z.ZodPrefault<z.ZodArray<z.ZodString>>;
@@ -737,7 +737,7 @@ export type EntitlementRuntimeCaps = z.infer<typeof EntitlementRuntimeCaps>;
737
737
  * `allow*` ceilings tighten toward `false` (disabled wins); `forceDurableGate` tightens toward `true` (forced
738
738
  * wins). Single source for the merge polarity so resolvers don't hardcode it. `Record<keyof …>` = a new cap
739
739
  * without an entry is a COMPILE error (no silent wrong-direction merge). */
740
- export declare const RUNTIME_CAP_STRICT: Record<keyof EntitlementRuntimeCaps, boolean>;
740
+ export declare const RUNTIME_CAP_STRICT: Readonly<Record<keyof EntitlementRuntimeCaps, boolean>>;
741
741
  /** A named entitlement bundle (a `tier`, or a composable `role`). Bind a `roster` to inherit its model/skill/mcp
742
742
  * visibility for free; explicit allowlists intersect on top. Edit a tier once → re-prices everyone on it. */
743
743
  export declare const EntitlementTier: z.ZodObject<{
@@ -1422,7 +1422,7 @@ export declare const WorkerLifecycle: z.ZodObject<{
1422
1422
  export type WorkerLifecycle = z.infer<typeof WorkerLifecycle>;
1423
1423
  /** 结构化 WorkerSpec 字段已经产出的 env 名 —— 通用 `env` / `secretEnv` 逃生口**不许**设它们(用专属字段)。由
1424
1424
  * `RESERVED_ENV_FIELD`(名 → 唯一写位)的键派生;增删理由见那张表的头注。 */
1425
- export declare const RESERVED_WORKER_ENV: Set<string>;
1425
+ export declare const RESERVED_WORKER_ENV: ReadonlySet<string>;
1426
1426
  /** 一台 worker 的名字(唯一 → 容器名 / compose project / 缺省路由键)—— **唯一**的名字判据。web-admin 在租约 / 用量 /
1427
1427
  * discovery `?worker=` 等面上校验外部传来的 worker 名时读它(不抄窄正则)。 */
1428
1428
  export declare const WORKER_NAME: z.ZodString;
@@ -1877,7 +1877,26 @@ export declare const McpTransport: z.ZodDiscriminatedUnion<[z.ZodObject<{
1877
1877
  url: z.ZodString;
1878
1878
  headerRefs: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodString>, unknown>>;
1879
1879
  principalHeader: z.ZodOptional<z.ZodString>;
1880
- assertionHeader: z.ZodOptional<z.ZodString>;
1880
+ credentials: z.ZodOptional<z.ZodPipe<z.ZodType<{
1881
+ readonly kind: "assertion";
1882
+ readonly audience: string;
1883
+ }, {
1884
+ readonly kind: "assertion";
1885
+ readonly audience: string;
1886
+ }, z.core.$ZodTypeInternals<{
1887
+ readonly kind: "assertion";
1888
+ readonly audience: string;
1889
+ }, {
1890
+ readonly kind: "assertion";
1891
+ readonly audience: string;
1892
+ }>>, z.ZodTransform<{
1893
+ readonly kind: "assertion";
1894
+ readonly audience: string;
1895
+ }, {
1896
+ readonly kind: "assertion";
1897
+ readonly audience: string;
1898
+ }>>>;
1899
+ assertionHeader: z.ZodOptional<z.ZodNever>;
1881
1900
  }, z.core.$strip>], "kind">;
1882
1901
  export type McpTransport = z.infer<typeof McpTransport>;
1883
1902
  /** The closed word table for {@link McpServerSpec}.contentOrigin — a MIRROR literal of the engine's
@@ -1899,7 +1918,26 @@ export declare const McpServerSpec: z.ZodObject<{
1899
1918
  url: z.ZodString;
1900
1919
  headerRefs: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodString>, unknown>>;
1901
1920
  principalHeader: z.ZodOptional<z.ZodString>;
1902
- assertionHeader: z.ZodOptional<z.ZodString>;
1921
+ credentials: z.ZodOptional<z.ZodPipe<z.ZodType<{
1922
+ readonly kind: "assertion";
1923
+ readonly audience: string;
1924
+ }, {
1925
+ readonly kind: "assertion";
1926
+ readonly audience: string;
1927
+ }, z.core.$ZodTypeInternals<{
1928
+ readonly kind: "assertion";
1929
+ readonly audience: string;
1930
+ }, {
1931
+ readonly kind: "assertion";
1932
+ readonly audience: string;
1933
+ }>>, z.ZodTransform<{
1934
+ readonly kind: "assertion";
1935
+ readonly audience: string;
1936
+ }, {
1937
+ readonly kind: "assertion";
1938
+ readonly audience: string;
1939
+ }>>>;
1940
+ assertionHeader: z.ZodOptional<z.ZodNever>;
1903
1941
  }, z.core.$strip>], "kind">;
1904
1942
  allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1905
1943
  scenarios: z.ZodPrefault<z.ZodArray<z.ZodString>>;
@@ -1916,8 +1954,6 @@ export declare const McpServerSpec: z.ZodObject<{
1916
1954
  source: z.ZodOptional<z.ZodUnknown>;
1917
1955
  toolFaces: z.ZodOptional<z.ZodUnknown>;
1918
1956
  toolAxes: z.ZodOptional<z.ZodUnknown>;
1919
- authForm: z.ZodOptional<z.ZodUnknown>;
1920
- entryKind: z.ZodOptional<z.ZodUnknown>;
1921
1957
  notes: z.ZodOptional<z.ZodString>;
1922
1958
  }, z.core.$strip>;
1923
1959
  export type McpServerSpec = z.infer<typeof McpServerSpec>;
@@ -1934,7 +1970,26 @@ export declare const McpConfig: z.ZodObject<{
1934
1970
  url: z.ZodString;
1935
1971
  headerRefs: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodString>, unknown>>;
1936
1972
  principalHeader: z.ZodOptional<z.ZodString>;
1937
- assertionHeader: z.ZodOptional<z.ZodString>;
1973
+ credentials: z.ZodOptional<z.ZodPipe<z.ZodType<{
1974
+ readonly kind: "assertion";
1975
+ readonly audience: string;
1976
+ }, {
1977
+ readonly kind: "assertion";
1978
+ readonly audience: string;
1979
+ }, z.core.$ZodTypeInternals<{
1980
+ readonly kind: "assertion";
1981
+ readonly audience: string;
1982
+ }, {
1983
+ readonly kind: "assertion";
1984
+ readonly audience: string;
1985
+ }>>, z.ZodTransform<{
1986
+ readonly kind: "assertion";
1987
+ readonly audience: string;
1988
+ }, {
1989
+ readonly kind: "assertion";
1990
+ readonly audience: string;
1991
+ }>>>;
1992
+ assertionHeader: z.ZodOptional<z.ZodNever>;
1938
1993
  }, z.core.$strip>], "kind">;
1939
1994
  allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1940
1995
  scenarios: z.ZodPrefault<z.ZodArray<z.ZodString>>;
@@ -1951,8 +2006,6 @@ export declare const McpConfig: z.ZodObject<{
1951
2006
  source: z.ZodOptional<z.ZodUnknown>;
1952
2007
  toolFaces: z.ZodOptional<z.ZodUnknown>;
1953
2008
  toolAxes: z.ZodOptional<z.ZodUnknown>;
1954
- authForm: z.ZodOptional<z.ZodUnknown>;
1955
- entryKind: z.ZodOptional<z.ZodUnknown>;
1956
2009
  notes: z.ZodOptional<z.ZodString>;
1957
2010
  }, z.core.$strip>>>;
1958
2011
  }, z.core.$strip>;
@@ -2575,7 +2628,26 @@ export declare const DOMAIN_SCHEMAS: {
2575
2628
  url: z.ZodString;
2576
2629
  headerRefs: z.ZodOptional<z.ZodPreprocess<z.ZodRecord<z.ZodString, z.ZodString>, unknown>>;
2577
2630
  principalHeader: z.ZodOptional<z.ZodString>;
2578
- assertionHeader: z.ZodOptional<z.ZodString>;
2631
+ credentials: z.ZodOptional<z.ZodPipe<z.ZodType<{
2632
+ readonly kind: "assertion";
2633
+ readonly audience: string;
2634
+ }, {
2635
+ readonly kind: "assertion";
2636
+ readonly audience: string;
2637
+ }, z.core.$ZodTypeInternals<{
2638
+ readonly kind: "assertion";
2639
+ readonly audience: string;
2640
+ }, {
2641
+ readonly kind: "assertion";
2642
+ readonly audience: string;
2643
+ }>>, z.ZodTransform<{
2644
+ readonly kind: "assertion";
2645
+ readonly audience: string;
2646
+ }, {
2647
+ readonly kind: "assertion";
2648
+ readonly audience: string;
2649
+ }>>>;
2650
+ assertionHeader: z.ZodOptional<z.ZodNever>;
2579
2651
  }, z.core.$strip>], "kind">;
2580
2652
  allowTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
2581
2653
  scenarios: z.ZodPrefault<z.ZodArray<z.ZodString>>;
@@ -2592,8 +2664,6 @@ export declare const DOMAIN_SCHEMAS: {
2592
2664
  source: z.ZodOptional<z.ZodUnknown>;
2593
2665
  toolFaces: z.ZodOptional<z.ZodUnknown>;
2594
2666
  toolAxes: z.ZodOptional<z.ZodUnknown>;
2595
- authForm: z.ZodOptional<z.ZodUnknown>;
2596
- entryKind: z.ZodOptional<z.ZodUnknown>;
2597
2667
  notes: z.ZodOptional<z.ZodString>;
2598
2668
  }, z.core.$strip>>>;
2599
2669
  }, z.core.$strip>;
@@ -3339,7 +3409,7 @@ export interface ConfigChange {
3339
3409
  at: string;
3340
3410
  summary?: string;
3341
3411
  }
3342
- export declare const DOMAINS: DomainName[];
3412
+ export declare const DOMAINS: readonly DomainName[];
3343
3413
  /** The canonical "is this a config domain?" predicate. Use it instead of hard-coding a domain list when
3344
3414
  * filtering arbitrary keys (e.g. a `config.d/` directory scan that also turns up the non-domain
3345
3415
  * `remote-exec.json`) — `remote-exec` is NOT a domain (it's the exec backend; see writeRemoteExec). */