@usefragments/core 1.10.2 → 2.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 (130) hide show
  1. package/dist/{chunk-MZ4SW3TP.js → chunk-3IOWHECM.js} +8 -1
  2. package/dist/{chunk-MZ4SW3TP.js.map → chunk-3IOWHECM.js.map} +1 -1
  3. package/dist/chunk-7ULGH74M.js +66 -0
  4. package/dist/chunk-7ULGH74M.js.map +1 -0
  5. package/dist/{chunk-XN3LSDPY.js → chunk-BMPYIUZE.js} +612 -344
  6. package/dist/chunk-BMPYIUZE.js.map +1 -0
  7. package/dist/{chunk-YF65VYRY.js → chunk-ML5S6QNU.js} +191 -169
  8. package/dist/chunk-ML5S6QNU.js.map +1 -0
  9. package/dist/{chunk-3LLRNCPX.js → chunk-MZ2FS7U4.js} +1 -1
  10. package/dist/chunk-MZ2FS7U4.js.map +1 -0
  11. package/dist/chunk-PWIJMOI4.js +202 -0
  12. package/dist/chunk-PWIJMOI4.js.map +1 -0
  13. package/dist/chunk-RYFULE43.js +578 -0
  14. package/dist/chunk-RYFULE43.js.map +1 -0
  15. package/dist/codes/index.d.ts +2 -2
  16. package/dist/codes/index.js +3 -2
  17. package/dist/compiled-types/index.d.ts +327 -2
  18. package/dist/compiled-types/index.js +1 -1
  19. package/dist/generate/index.d.ts +3 -2
  20. package/dist/{governance-CLk_wkP9.d.ts → governance-hOPXGbbs.d.ts} +474 -515
  21. package/dist/governance-telemetry.d.ts +6 -0
  22. package/dist/governance-telemetry.js +1 -1
  23. package/dist/{index-_sxhUNqx.d.ts → index-C8bcXVav.d.ts} +448 -448
  24. package/dist/index.d.ts +3280 -1305
  25. package/dist/index.js +2414 -350
  26. package/dist/index.js.map +1 -1
  27. package/dist/manifest.d.ts +228 -0
  28. package/dist/manifest.js +24 -0
  29. package/dist/manifest.js.map +1 -0
  30. package/dist/preview/index.js +45 -1
  31. package/dist/preview/index.js.map +1 -1
  32. package/dist/preview-runtime.d.ts +1 -2
  33. package/dist/preview-runtime.js +150 -14
  34. package/dist/preview-runtime.js.map +1 -1
  35. package/dist/react-types.d.ts +1 -2
  36. package/dist/registry.d.ts +1412 -203
  37. package/dist/registry.js +30 -3
  38. package/dist/schemas/index.d.ts +1 -1
  39. package/dist/schemas/index.js +3 -2
  40. package/dist/storyAdapter.d.ts +1 -2
  41. package/dist/storyAdapter.js +11 -49
  42. package/dist/storyAdapter.js.map +1 -1
  43. package/dist/test-utils.d.ts +3 -2
  44. package/dist/topology/index.d.ts +1 -1
  45. package/dist/topology/index.js +1 -1
  46. package/package.json +8 -2
  47. package/src/__tests__/contract-parser.test.ts +318 -277
  48. package/src/__tests__/preview-runtime-hook.test.tsx +315 -0
  49. package/src/__tests__/preview-runtime.test.tsx +30 -8
  50. package/src/__tests__/schema.test.ts +191 -14
  51. package/src/analysis-plan/analysis-plan-v1.test.ts +320 -0
  52. package/src/analysis-plan/coverage.ts +181 -0
  53. package/src/analysis-plan/digest.ts +141 -0
  54. package/src/analysis-plan/index.ts +34 -0
  55. package/src/analysis-plan/types.ts +207 -0
  56. package/src/approved-contract-tokens.test.ts +39 -0
  57. package/src/approved-contract-tokens.ts +18 -0
  58. package/src/codes/__tests__/codes.test.ts +13 -0
  59. package/src/codes/codes.ts +40 -0
  60. package/src/compiled-types/index.ts +640 -39
  61. package/src/compiled-types/parse.test.ts +145 -4
  62. package/src/component-contract.ts +95 -53
  63. package/src/composition.ts +7 -13
  64. package/src/constants.ts +3 -6
  65. package/src/contract/hash.test.ts +20 -0
  66. package/src/contract/hash.ts +66 -9
  67. package/src/contract/index.ts +24 -1
  68. package/src/contract/manifest.test.ts +94 -0
  69. package/src/contract/manifest.ts +68 -0
  70. package/src/contract/preimage.test.ts +219 -1
  71. package/src/contract/preimage.ts +326 -6
  72. package/src/contract/stamp.test.ts +3 -0
  73. package/src/contract/stamp.ts +1 -1
  74. package/src/contract-parser.ts +54 -30
  75. package/src/defineFragment.test.ts +476 -91
  76. package/src/defineFragment.ts +204 -114
  77. package/src/domain-ids.test.ts +35 -0
  78. package/src/domain-ids.ts +61 -0
  79. package/src/evaluation/evaluate.test.ts +522 -0
  80. package/src/evaluation/evaluate.ts +690 -0
  81. package/src/evaluation/evaluation-v2-receipt-v1.test.ts +772 -0
  82. package/src/evaluation/index.ts +58 -0
  83. package/src/evaluation/receipt.ts +753 -0
  84. package/src/evaluation/types.ts +406 -0
  85. package/src/facts/builders.ts +2 -0
  86. package/src/facts/compile.ts +29 -6
  87. package/src/facts/fact-index.ts +13 -3
  88. package/src/facts/fact-integrity-v1.test.ts +172 -0
  89. package/src/facts/facts.test.ts +15 -0
  90. package/src/facts/ids.ts +46 -3
  91. package/src/facts/index.ts +14 -1
  92. package/src/facts/integrity.ts +134 -0
  93. package/src/facts/types.ts +36 -0
  94. package/src/governance-integrity.test.ts +1 -0
  95. package/src/governance-integrity.ts +5 -3
  96. package/src/governance-telemetry.ts +8 -0
  97. package/src/governance.ts +70 -8
  98. package/src/index.ts +230 -37
  99. package/src/preview/validation.test.ts +62 -0
  100. package/src/preview/validation.ts +48 -2
  101. package/src/preview-runtime.tsx +227 -20
  102. package/src/registry-install-plan.ts +200 -109
  103. package/src/registry-shards.test.ts +263 -0
  104. package/src/registry.ts +237 -0
  105. package/src/repository-binding.test.ts +50 -0
  106. package/src/repository-binding.ts +96 -0
  107. package/src/rules/families.test.ts +36 -0
  108. package/src/rules/finding.ts +7 -2
  109. package/src/rules/index.ts +17 -1
  110. package/src/rules/rule-config.test.ts +66 -0
  111. package/src/rules/rule-config.ts +73 -0
  112. package/src/rules/rules.test.ts +26 -0
  113. package/src/rules/tokens-css-vars-must-be-defined.test.ts +51 -2
  114. package/src/rules/tokens-css-vars-must-be-defined.ts +34 -1
  115. package/src/schema.ts +293 -113
  116. package/src/schemas/index.ts +1 -1
  117. package/src/storyAdapter.test.ts +68 -12
  118. package/src/storyAdapter.ts +44 -75
  119. package/src/topology/resolve-area.ts +1 -1
  120. package/src/types.ts +258 -40
  121. package/dist/chunk-3LLRNCPX.js.map +0 -1
  122. package/dist/chunk-RANPUC6C.js +0 -72
  123. package/dist/chunk-RANPUC6C.js.map +0 -1
  124. package/dist/chunk-XN3LSDPY.js.map +0 -1
  125. package/dist/chunk-YF65VYRY.js.map +0 -1
  126. package/src/fragment-types.ts +0 -214
  127. package/src/react-create-element.test.ts +0 -22
  128. package/src/react-create-element.ts +0 -12
  129. package/src/storyFilters.test.ts +0 -350
  130. package/src/storyFilters.ts +0 -253
@@ -0,0 +1,202 @@
1
+ // src/contract/hash.ts
2
+ function normalizeNumber(value) {
3
+ if (Number.isNaN(value)) return '"@num:nan"';
4
+ if (value === Infinity) return '"@num:+inf"';
5
+ if (value === -Infinity) return '"@num:-inf"';
6
+ if (Object.is(value, -0)) return "0";
7
+ return JSON.stringify(value);
8
+ }
9
+ function canonicalPreimage(value) {
10
+ return canonicalPreimageValue(value, /* @__PURE__ */ new Set(), "(root)");
11
+ }
12
+ function compareCanonicalStrings(left, right) {
13
+ return left < right ? -1 : left > right ? 1 : 0;
14
+ }
15
+ function canonicalPreimageValue(value, ancestors, path) {
16
+ if (value === void 0 || value === null) return "null";
17
+ const type = typeof value;
18
+ if (type === "number") return normalizeNumber(value);
19
+ if (type === "string" || type === "boolean") return JSON.stringify(value);
20
+ if (type === "bigint") return JSON.stringify(value.toString());
21
+ if (type === "function" || type === "symbol") {
22
+ throw new TypeError(`Unsupported contract value at ${path}: ${type}`);
23
+ }
24
+ if (Array.isArray(value)) {
25
+ if (ancestors.has(value)) throw new TypeError(`Circular contract value at ${path}`);
26
+ ancestors.add(value);
27
+ try {
28
+ return `[${value.map((entry, index) => canonicalPreimageValue(entry, ancestors, `${path}[${index}]`)).join(",")}]`;
29
+ } finally {
30
+ ancestors.delete(value);
31
+ }
32
+ }
33
+ if (type !== "object") {
34
+ throw new TypeError(`Unsupported contract value at ${path}: ${type}`);
35
+ }
36
+ const object = value;
37
+ const prototype = Object.getPrototypeOf(object);
38
+ if (prototype !== Object.prototype && prototype !== null) {
39
+ const objectType = prototype?.constructor?.name ?? "unknown";
40
+ throw new TypeError(`Unsupported contract object at ${path}: ${objectType}`);
41
+ }
42
+ if (ancestors.has(object)) throw new TypeError(`Circular contract value at ${path}`);
43
+ ancestors.add(object);
44
+ const entries = Object.entries(object).filter(([, v]) => v !== void 0).sort(([a], [b]) => compareCanonicalStrings(a, b));
45
+ try {
46
+ return `{${entries.map(
47
+ ([key, entry]) => `${JSON.stringify(key)}:${canonicalPreimageValue(entry, ancestors, `${path}.${key}`)}`
48
+ ).join(",")}}`;
49
+ } finally {
50
+ ancestors.delete(object);
51
+ }
52
+ }
53
+ var K = new Uint32Array([
54
+ 1116352408,
55
+ 1899447441,
56
+ 3049323471,
57
+ 3921009573,
58
+ 961987163,
59
+ 1508970993,
60
+ 2453635748,
61
+ 2870763221,
62
+ 3624381080,
63
+ 310598401,
64
+ 607225278,
65
+ 1426881987,
66
+ 1925078388,
67
+ 2162078206,
68
+ 2614888103,
69
+ 3248222580,
70
+ 3835390401,
71
+ 4022224774,
72
+ 264347078,
73
+ 604807628,
74
+ 770255983,
75
+ 1249150122,
76
+ 1555081692,
77
+ 1996064986,
78
+ 2554220882,
79
+ 2821834349,
80
+ 2952996808,
81
+ 3210313671,
82
+ 3336571891,
83
+ 3584528711,
84
+ 113926993,
85
+ 338241895,
86
+ 666307205,
87
+ 773529912,
88
+ 1294757372,
89
+ 1396182291,
90
+ 1695183700,
91
+ 1986661051,
92
+ 2177026350,
93
+ 2456956037,
94
+ 2730485921,
95
+ 2820302411,
96
+ 3259730800,
97
+ 3345764771,
98
+ 3516065817,
99
+ 3600352804,
100
+ 4094571909,
101
+ 275423344,
102
+ 430227734,
103
+ 506948616,
104
+ 659060556,
105
+ 883997877,
106
+ 958139571,
107
+ 1322822218,
108
+ 1537002063,
109
+ 1747873779,
110
+ 1955562222,
111
+ 2024104815,
112
+ 2227730452,
113
+ 2361852424,
114
+ 2428436474,
115
+ 2756734187,
116
+ 3204031479,
117
+ 3329325298
118
+ ]);
119
+ function rotr(value, bits) {
120
+ return (value >>> bits | value << 32 - bits) >>> 0;
121
+ }
122
+ function sha256Hex(message) {
123
+ const bytes = new TextEncoder().encode(message);
124
+ const length = bytes.length;
125
+ const bitLength = length * 8;
126
+ const withMarker = length + 1;
127
+ const zeroPad = (56 - withMarker % 64 + 64) % 64;
128
+ const total = withMarker + zeroPad + 8;
129
+ const buffer = new Uint8Array(total);
130
+ buffer.set(bytes, 0);
131
+ buffer[length] = 128;
132
+ const view = new DataView(buffer.buffer);
133
+ view.setUint32(total - 8, Math.floor(bitLength / 4294967296));
134
+ view.setUint32(total - 4, bitLength >>> 0);
135
+ let h0 = 1779033703;
136
+ let h1 = 3144134277;
137
+ let h2 = 1013904242;
138
+ let h3 = 2773480762;
139
+ let h4 = 1359893119;
140
+ let h5 = 2600822924;
141
+ let h6 = 528734635;
142
+ let h7 = 1541459225;
143
+ const w = new Uint32Array(64);
144
+ for (let chunk = 0; chunk < total; chunk += 64) {
145
+ for (let t = 0; t < 16; t++) w[t] = view.getUint32(chunk + t * 4);
146
+ for (let t = 16; t < 64; t++) {
147
+ const w15 = w[t - 15];
148
+ const w2 = w[t - 2];
149
+ const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ w15 >>> 3;
150
+ const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ w2 >>> 10;
151
+ w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
152
+ }
153
+ let a = h0;
154
+ let b = h1;
155
+ let c = h2;
156
+ let d = h3;
157
+ let e = h4;
158
+ let f = h5;
159
+ let g = h6;
160
+ let h = h7;
161
+ for (let t = 0; t < 64; t++) {
162
+ const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
163
+ const ch = e & f ^ ~e & g;
164
+ const temp1 = h + s1 + ch + K[t] + w[t] >>> 0;
165
+ const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
166
+ const maj = a & b ^ a & c ^ b & c;
167
+ const temp2 = s0 + maj >>> 0;
168
+ h = g;
169
+ g = f;
170
+ f = e;
171
+ e = d + temp1 >>> 0;
172
+ d = c;
173
+ c = b;
174
+ b = a;
175
+ a = temp1 + temp2 >>> 0;
176
+ }
177
+ h0 = h0 + a >>> 0;
178
+ h1 = h1 + b >>> 0;
179
+ h2 = h2 + c >>> 0;
180
+ h3 = h3 + d >>> 0;
181
+ h4 = h4 + e >>> 0;
182
+ h5 = h5 + f >>> 0;
183
+ h6 = h6 + g >>> 0;
184
+ h7 = h7 + h >>> 0;
185
+ }
186
+ return [h0, h1, h2, h3, h4, h5, h6, h7].map((value) => value.toString(16).padStart(8, "0")).join("");
187
+ }
188
+ function contractHash(body) {
189
+ return sha256Hex(canonicalPreimage(body));
190
+ }
191
+ function artifactContentHash(body) {
192
+ return sha256Hex(canonicalPreimage(body));
193
+ }
194
+
195
+ export {
196
+ canonicalPreimage,
197
+ compareCanonicalStrings,
198
+ sha256Hex,
199
+ contractHash,
200
+ artifactContentHash
201
+ };
202
+ //# sourceMappingURL=chunk-PWIJMOI4.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/contract/hash.ts"],"sourcesContent":["/**\n * Frontend Contract hashing — the cross-runtime content-address (FCID).\n *\n * The keystone trust property of the Frontend Contract is that \"what the agent\n * was served\" and \"what CI enforced\" are provably the same bytes. That only\n * holds if the contract hash is computed by an *identical* function in every\n * runtime that touches it: the CLI (Node), the Convex isolate, and the browser.\n *\n * The fact-IR `hash64Hex` (FNV-1a, in `../facts/ids.ts`) is deliberately NOT\n * used here: it is a 64-bit non-cryptographic integrity reference for in-process\n * fact dedup, and Convex independently reaches for `crypto.subtle` (async, and a\n * *different* algorithm). Two different hashes over the same preimage cannot back\n * a \"same 64 hex chars or the build is rejected\" guarantee.\n *\n * So this module ships ONE function: a synchronous, dependency-free SHA-256 over\n * a number-normalizing canonical preimage. Synchronous so it composes with the\n * sync fact-compilation path; dependency-free so it is byte-identical across\n * Node, the Convex isolate, and the browser without a native/optional dep\n * (`crypto.subtle` is async; `@noble/hashes` is not a dependency of this MIT,\n * browser-safe package). `TextEncoder` is the only ambient global used, and it is\n * present in all three runtimes.\n */\n\n// ---------------------------------------------------------------------------\n// Canonical preimage\n// ---------------------------------------------------------------------------\n\n/**\n * Normalize a number to a stable string. `JSON.stringify` is stable for finite\n * numbers, but renders `NaN`/`Infinity` as `null` (ambiguous) and does not\n * collapse `-0`. Token values flow into the contract body, so a serializer that\n * silently maps `NaN` to `null` would hash two different inputs to the same\n * preimage. Non-finite numbers get legacy v1 sentinels instead; `-0` collapses\n * to `0`.\n */\nfunction normalizeNumber(value: number): string {\n if (Number.isNaN(value)) return '\"@num:nan\"';\n if (value === Infinity) return '\"@num:+inf\"';\n if (value === -Infinity) return '\"@num:-inf\"';\n if (Object.is(value, -0)) return \"0\";\n return JSON.stringify(value);\n}\n\n/**\n * Deterministic, canonical serialization of a contract body for hashing.\n *\n * - object keys sorted lexicographically; attribute order is irrelevant\n * - `undefined` properties dropped (so optional fields don't perturb the hash)\n * - numbers normalized via {@link normalizeNumber}\n * - `bigint` encoded as its decimal string (JSON cannot represent it natively)\n * - circular, executable, and non-plain runtime values rejected with a stable path\n *\n * This is intentionally a separate serializer from `facts/ids.ts#canonicalJson`:\n * that one targets in-process fact IDs and does not normalize numbers, and we\n * must not change its output (it would silently re-key existing fact IDs).\n */\nexport function canonicalPreimage(value: unknown): string {\n return canonicalPreimageValue(value, new Set<object>(), \"(root)\");\n}\n\n/**\n * Locale-independent lexical order for authority-bearing canonical records.\n *\n * `String#localeCompare` follows the runtime's default locale, so it can order\n * the same Unicode identifiers differently across a developer machine, CI,\n * and a browser. Relational string comparison is defined by ECMAScript over\n * UTF-16 code units and therefore gives every runtime the same ordering.\n */\nexport function compareCanonicalStrings(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction canonicalPreimageValue(value: unknown, ancestors: Set<object>, path: string): string {\n if (value === undefined || value === null) return \"null\";\n const type = typeof value;\n if (type === \"number\") return normalizeNumber(value as number);\n if (type === \"string\" || type === \"boolean\") return JSON.stringify(value);\n if (type === \"bigint\") return JSON.stringify((value as bigint).toString());\n if (type === \"function\" || type === \"symbol\") {\n throw new TypeError(`Unsupported contract value at ${path}: ${type}`);\n }\n if (Array.isArray(value)) {\n if (ancestors.has(value)) throw new TypeError(`Circular contract value at ${path}`);\n ancestors.add(value);\n try {\n return `[${value\n .map((entry, index) => canonicalPreimageValue(entry, ancestors, `${path}[${index}]`))\n .join(\",\")}]`;\n } finally {\n ancestors.delete(value);\n }\n }\n if (type !== \"object\") {\n throw new TypeError(`Unsupported contract value at ${path}: ${type}`);\n }\n const object = value as object;\n const prototype = Object.getPrototypeOf(object);\n if (prototype !== Object.prototype && prototype !== null) {\n const objectType = prototype?.constructor?.name ?? \"unknown\";\n throw new TypeError(`Unsupported contract object at ${path}: ${objectType}`);\n }\n if (ancestors.has(object)) throw new TypeError(`Circular contract value at ${path}`);\n ancestors.add(object);\n const entries = Object.entries(object as Record<string, unknown>)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => compareCanonicalStrings(a, b));\n try {\n return `{${entries\n .map(\n ([key, entry]) =>\n `${JSON.stringify(key)}:${canonicalPreimageValue(entry, ancestors, `${path}.${key}`)}`\n )\n .join(\",\")}}`;\n } finally {\n ancestors.delete(object);\n }\n}\n\n// ---------------------------------------------------------------------------\n// SHA-256 (FIPS 180-4), synchronous, pure JS\n// ---------------------------------------------------------------------------\n\n// First 32 bits of the fractional parts of the cube roots of the first 64 primes.\nconst K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\n 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\n 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\n 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\n 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\n 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\n 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\n 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n]);\n\nfunction rotr(value: number, bits: number): number {\n return ((value >>> bits) | (value << (32 - bits))) >>> 0;\n}\n\n/**\n * SHA-256 of a UTF-8 string, returned as 64 lowercase hex chars.\n *\n * Deterministic and synchronous in every runtime. Verified against the FIPS\n * 180-4 vectors in `hash.test.ts`.\n */\nexport function sha256Hex(message: string): string {\n const bytes = new TextEncoder().encode(message);\n const length = bytes.length;\n const bitLength = length * 8;\n\n // Padding: append 0x80, then zeros, then the 64-bit big-endian bit length,\n // so the total is a multiple of 64 bytes.\n const withMarker = length + 1;\n const zeroPad = (56 - (withMarker % 64) + 64) % 64;\n const total = withMarker + zeroPad + 8;\n const buffer = new Uint8Array(total);\n buffer.set(bytes, 0);\n buffer[length] = 0x80;\n\n const view = new DataView(buffer.buffer);\n // 64-bit length: high word then low word, big-endian. bitLength can exceed\n // 2^32 for very large inputs, so split rather than truncate.\n view.setUint32(total - 8, Math.floor(bitLength / 0x100000000));\n view.setUint32(total - 4, bitLength >>> 0);\n\n let h0 = 0x6a09e667;\n let h1 = 0xbb67ae85;\n let h2 = 0x3c6ef372;\n let h3 = 0xa54ff53a;\n let h4 = 0x510e527f;\n let h5 = 0x9b05688c;\n let h6 = 0x1f83d9ab;\n let h7 = 0x5be0cd19;\n\n const w = new Uint32Array(64);\n for (let chunk = 0; chunk < total; chunk += 64) {\n for (let t = 0; t < 16; t++) w[t] = view.getUint32(chunk + t * 4);\n for (let t = 16; t < 64; t++) {\n const w15 = w[t - 15];\n const w2 = w[t - 2];\n const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ (w15 >>> 3);\n const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ (w2 >>> 10);\n w[t] = (w[t - 16] + s0 + w[t - 7] + s1) >>> 0;\n }\n\n let a = h0;\n let b = h1;\n let c = h2;\n let d = h3;\n let e = h4;\n let f = h5;\n let g = h6;\n let h = h7;\n\n for (let t = 0; t < 64; t++) {\n const s1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);\n const ch = (e & f) ^ (~e & g);\n const temp1 = (h + s1 + ch + K[t] + w[t]) >>> 0;\n const s0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (s0 + maj) >>> 0;\n h = g;\n g = f;\n f = e;\n e = (d + temp1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (temp1 + temp2) >>> 0;\n }\n\n h0 = (h0 + a) >>> 0;\n h1 = (h1 + b) >>> 0;\n h2 = (h2 + c) >>> 0;\n h3 = (h3 + d) >>> 0;\n h4 = (h4 + e) >>> 0;\n h5 = (h5 + f) >>> 0;\n h6 = (h6 + g) >>> 0;\n h7 = (h7 + h) >>> 0;\n }\n\n return [h0, h1, h2, h3, h4, h5, h6, h7]\n .map((value) => value.toString(16).padStart(8, \"0\"))\n .join(\"\");\n}\n\n// ---------------------------------------------------------------------------\n// Contract hash (FCID)\n// ---------------------------------------------------------------------------\n\n/**\n * The Frontend Contract ID: `sha256(canonicalPreimage(body))`, 64 lowercase hex\n * chars. Identical inputs produce an identical FCID in the CLI, the Convex\n * isolate, and the browser — which is what lets the gen-time agent view and the\n * CI enforcement reference the same contract by hash.\n *\n * Never feed preview modules, story states, guidance, or runtime config into\n * this function and call the result an FCID — those belong to\n * {@link artifactContentHash}.\n */\nexport function contractHash(body: unknown): string {\n return sha256Hex(canonicalPreimage(body));\n}\n\n/**\n * Content-address for preview artifacts (`artifactId`): the same deterministic\n * SHA-256 canonicalization as {@link contractHash}, but a separate named seam so\n * callers never assign `artifactId` from an FCID (or vice versa). Hash preview\n * modules, states, guidance/render content, and runtime config here.\n */\nexport function artifactContentHash(body: unknown): string {\n return sha256Hex(canonicalPreimage(body));\n}\n"],"mappings":";AAmCA,SAAS,gBAAgB,OAAuB;AAC9C,MAAI,OAAO,MAAM,KAAK,EAAG,QAAO;AAChC,MAAI,UAAU,SAAU,QAAO;AAC/B,MAAI,UAAU,UAAW,QAAO;AAChC,MAAI,OAAO,GAAG,OAAO,EAAE,EAAG,QAAO;AACjC,SAAO,KAAK,UAAU,KAAK;AAC7B;AAeO,SAAS,kBAAkB,OAAwB;AACxD,SAAO,uBAAuB,OAAO,oBAAI,IAAY,GAAG,QAAQ;AAClE;AAUO,SAAS,wBAAwB,MAAc,OAAuB;AAC3E,SAAO,OAAO,QAAQ,KAAK,OAAO,QAAQ,IAAI;AAChD;AAEA,SAAS,uBAAuB,OAAgB,WAAwB,MAAsB;AAC5F,MAAI,UAAU,UAAa,UAAU,KAAM,QAAO;AAClD,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS,SAAU,QAAO,gBAAgB,KAAe;AAC7D,MAAI,SAAS,YAAY,SAAS,UAAW,QAAO,KAAK,UAAU,KAAK;AACxE,MAAI,SAAS,SAAU,QAAO,KAAK,UAAW,MAAiB,SAAS,CAAC;AACzE,MAAI,SAAS,cAAc,SAAS,UAAU;AAC5C,UAAM,IAAI,UAAU,iCAAiC,IAAI,KAAK,IAAI,EAAE;AAAA,EACtE;AACA,MAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,QAAI,UAAU,IAAI,KAAK,EAAG,OAAM,IAAI,UAAU,8BAA8B,IAAI,EAAE;AA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