@kya-os/checkpoint-shared 1.10.0 → 1.11.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 (187) hide show
  1. package/CHANGELOG.md +89 -0
  2. package/dist/base64url-BbVG8f-v.js +65 -0
  3. package/dist/base64url-D2MvsR20.mjs +49 -0
  4. package/dist/base64url-D2MvsR20.mjs.map +1 -0
  5. package/dist/beacon-forward-secret/index.d.mts +4 -0
  6. package/dist/beacon-forward-secret/index.d.mts.map +1 -0
  7. package/dist/beacon-forward-secret/index.d.ts +4 -0
  8. package/dist/beacon-forward-secret/index.d.ts.map +1 -0
  9. package/dist/beacon-forward-secret/index.js +15 -0
  10. package/dist/beacon-forward-secret/index.mjs +15 -0
  11. package/dist/beacon-forward-secret/index.mjs.map +1 -0
  12. package/dist/beacon-types/index.d.mts +53 -1
  13. package/dist/beacon-types/index.d.mts.map +1 -1
  14. package/dist/beacon-types/index.d.ts +53 -1
  15. package/dist/beacon-types/index.d.ts.map +1 -1
  16. package/dist/beacon-types/index.js +86 -1
  17. package/dist/beacon-types/index.mjs +77 -2
  18. package/dist/beacon-types/index.mjs.map +1 -1
  19. package/dist/{browser-posture-5fPrsxx7.d.mts → browser-posture-WPk0kl9u.d.mts} +18 -1
  20. package/dist/browser-posture-WPk0kl9u.d.mts.map +1 -0
  21. package/dist/{browser-posture-CCR1kh5e.d.ts → browser-posture-_y6BcdXw.d.ts} +18 -1
  22. package/dist/browser-posture-_y6BcdXw.d.ts.map +1 -0
  23. package/dist/browser-posture-cookie.mjs.map +1 -1
  24. package/dist/browser-posture-proof-verifier.js +136 -5
  25. package/dist/browser-posture-proof-verifier.mjs +134 -2
  26. package/dist/browser-posture-proof-verifier.mjs.map +1 -0
  27. package/dist/browser-posture-proof.d.mts +1 -1
  28. package/dist/browser-posture-proof.d.ts +1 -1
  29. package/dist/browser-posture-proof.js +1 -1
  30. package/dist/browser-posture-proof.mjs +1 -1
  31. package/dist/browser-posture-report.d.mts +17 -0
  32. package/dist/browser-posture-report.d.mts.map +1 -1
  33. package/dist/browser-posture-report.d.ts +17 -0
  34. package/dist/browser-posture-report.d.ts.map +1 -1
  35. package/dist/browser-posture.d.mts +1 -1
  36. package/dist/browser-posture.d.ts +1 -1
  37. package/dist/browser-posture.js +18 -1
  38. package/dist/browser-posture.mjs +18 -1
  39. package/dist/browser-posture.mjs.map +1 -1
  40. package/dist/browser.d.mts +10 -0
  41. package/dist/browser.d.mts.map +1 -1
  42. package/dist/browser.d.ts +10 -0
  43. package/dist/browser.d.ts.map +1 -1
  44. package/dist/browser.js +1 -1
  45. package/dist/browser.mjs +1 -1
  46. package/dist/browser.mjs.map +1 -1
  47. package/dist/canonical-signer/index.d.mts.map +1 -1
  48. package/dist/canonical-signer/index.d.ts.map +1 -1
  49. package/dist/canonical-signer/index.js +0 -4
  50. package/dist/canonical-signer/index.mjs +0 -4
  51. package/dist/canonical-signer/index.mjs.map +1 -1
  52. package/dist/{client-ip-B7w-uHfS.d.ts → client-ip-8KneiMK0.d.mts} +12 -2
  53. package/dist/{client-ip-B7w-uHfS.d.mts.map → client-ip-8KneiMK0.d.mts.map} +1 -1
  54. package/dist/{client-ip-B7w-uHfS.d.mts → client-ip-8KneiMK0.d.ts} +12 -2
  55. package/dist/{client-ip-B7w-uHfS.d.ts.map → client-ip-8KneiMK0.d.ts.map} +1 -1
  56. package/dist/{client-ip-B8wFzJ5f.js → client-ip-BEmLC4I4.js} +71 -0
  57. package/dist/{client-ip-DIJyr6px.mjs → client-ip-DlHx7GGh.mjs} +61 -2
  58. package/dist/client-ip-DlHx7GGh.mjs.map +1 -0
  59. package/dist/client-ip.d.mts +2 -2
  60. package/dist/client-ip.d.ts +2 -2
  61. package/dist/client-ip.js +3 -1
  62. package/dist/client-ip.mjs +2 -2
  63. package/dist/deploy/index.d.mts.map +1 -1
  64. package/dist/deploy/index.d.ts.map +1 -1
  65. package/dist/deploy/index.js +5 -1
  66. package/dist/deploy/index.mjs +5 -1
  67. package/dist/deploy/index.mjs.map +1 -1
  68. package/dist/{detection-reason-mapping-CQexNvR7.d.ts → detection-reason-mapping-BemDaDED.d.mts} +5 -2
  69. package/dist/detection-reason-mapping-BemDaDED.d.mts.map +1 -0
  70. package/dist/{detection-reason-mapping-CQexNvR7.d.mts → detection-reason-mapping-BemDaDED.d.ts} +5 -2
  71. package/dist/detection-reason-mapping-BemDaDED.d.ts.map +1 -0
  72. package/dist/{detection-reason-mapping-B9RSkOs8.js → detection-reason-mapping-BxYaQ8kb.js} +33 -8
  73. package/dist/{detection-reason-mapping-BGymWIPl.mjs → detection-reason-mapping-j-7bXsVb.mjs} +29 -10
  74. package/dist/detection-reason-mapping-j-7bXsVb.mjs.map +1 -0
  75. package/dist/errors/index.d.mts +4 -0
  76. package/dist/errors/index.d.mts.map +1 -1
  77. package/dist/errors/index.d.ts +4 -0
  78. package/dist/errors/index.d.ts.map +1 -1
  79. package/dist/errors/index.js +24 -8
  80. package/dist/errors/index.mjs +24 -8
  81. package/dist/errors/index.mjs.map +1 -1
  82. package/dist/{fetcher-CZfLcbRZ.d.mts → fetcher-CTKz07jg.d.mts} +12 -2
  83. package/dist/fetcher-CTKz07jg.d.mts.map +1 -0
  84. package/dist/{fetcher-CCw4Q95g.d.ts → fetcher-DCr920hx.d.ts} +12 -2
  85. package/dist/fetcher-DCr920hx.d.ts.map +1 -0
  86. package/dist/gateway-client-ip.js +1 -1
  87. package/dist/gateway-client-ip.mjs +1 -1
  88. package/dist/identity-cookie/index.d.mts +14 -0
  89. package/dist/identity-cookie/index.d.mts.map +1 -0
  90. package/dist/identity-cookie/index.d.ts +14 -0
  91. package/dist/identity-cookie/index.d.ts.map +1 -0
  92. package/dist/identity-cookie/index.js +45 -0
  93. package/dist/identity-cookie/index.mjs +43 -0
  94. package/dist/identity-cookie/index.mjs.map +1 -0
  95. package/dist/index.d.mts +598 -142
  96. package/dist/index.d.mts.map +1 -1
  97. package/dist/index.d.ts +598 -142
  98. package/dist/index.d.ts.map +1 -1
  99. package/dist/index.js +793 -198
  100. package/dist/index.mjs +743 -188
  101. package/dist/index.mjs.map +1 -1
  102. package/dist/kya-http.d.mts +2 -2
  103. package/dist/kya-http.d.ts +2 -2
  104. package/dist/kya-http.js +2 -1
  105. package/dist/kya-http.mjs +2 -2
  106. package/dist/mcpi/dashboard-config/index.mjs.map +1 -1
  107. package/dist/patterns-CdTh7LU2.d.mts +35 -0
  108. package/dist/patterns-CdTh7LU2.d.mts.map +1 -0
  109. package/dist/patterns-CdTh7LU2.d.ts +35 -0
  110. package/dist/patterns-CdTh7LU2.d.ts.map +1 -0
  111. package/dist/{patterns-CiMpbdAF.js → patterns-CnNxRnaK.js} +3 -130
  112. package/dist/{patterns-D4OAsNQY.mjs → patterns-CpRk9R3M.mjs} +5 -96
  113. package/dist/patterns-CpRk9R3M.mjs.map +1 -0
  114. package/dist/patterns.d.mts +2 -2
  115. package/dist/patterns.d.ts +2 -2
  116. package/dist/patterns.js +1 -7
  117. package/dist/patterns.mjs +2 -2
  118. package/dist/policy/fetcher.d.mts +2 -2
  119. package/dist/policy/fetcher.d.ts +2 -2
  120. package/dist/policy/fetcher.js +100 -8
  121. package/dist/policy/fetcher.mjs +99 -9
  122. package/dist/policy/fetcher.mjs.map +1 -1
  123. package/dist/proxy-assertion-mapping-BVwXVSMZ.mjs +81 -0
  124. package/dist/proxy-assertion-mapping-BVwXVSMZ.mjs.map +1 -0
  125. package/dist/proxy-assertion-mapping-BxhENrcY.d.mts +70 -0
  126. package/dist/proxy-assertion-mapping-BxhENrcY.d.mts.map +1 -0
  127. package/dist/proxy-assertion-mapping-D64AyZfG.js +85 -0
  128. package/dist/proxy-assertion-mapping-DhAynFqG.d.ts +70 -0
  129. package/dist/proxy-assertion-mapping-DhAynFqG.d.ts.map +1 -0
  130. package/dist/proxy-assertions.d.mts +2 -0
  131. package/dist/proxy-assertions.d.ts +2 -0
  132. package/dist/proxy-assertions.js +4 -0
  133. package/dist/proxy-assertions.mjs +3 -0
  134. package/dist/reason-codes.d.mts +2 -2
  135. package/dist/reason-codes.d.ts +2 -2
  136. package/dist/reason-codes.js +3 -2
  137. package/dist/reason-codes.mjs +2 -2
  138. package/dist/{registered-sid-CnWIU_l1.d.ts → registered-sid-BgDhdj2l.d.mts} +13 -2
  139. package/dist/registered-sid-BgDhdj2l.d.mts.map +1 -0
  140. package/dist/{registered-sid-CnWIU_l1.d.mts → registered-sid-BgDhdj2l.d.ts} +13 -2
  141. package/dist/registered-sid-BgDhdj2l.d.ts.map +1 -0
  142. package/dist/{registered-sid-BZfDOfXy.js → registered-sid-DG1tSSvl.js} +67 -12
  143. package/dist/{registered-sid-CS9V8nPr.mjs → registered-sid-D__xiDPu.mjs} +63 -14
  144. package/dist/registered-sid-D__xiDPu.mjs.map +1 -0
  145. package/dist/timezone-country-B6PkDyNP.d.mts +15 -0
  146. package/dist/timezone-country-B6PkDyNP.d.mts.map +1 -0
  147. package/dist/timezone-country-B6PkDyNP.d.ts +15 -0
  148. package/dist/timezone-country-B6PkDyNP.d.ts.map +1 -0
  149. package/dist/timezone-country-CROxU2Tl.js +505 -0
  150. package/dist/timezone-country-CrrnkOdy.mjs +489 -0
  151. package/dist/timezone-country-CrrnkOdy.mjs.map +1 -0
  152. package/dist/timezone-country.d.mts +2 -0
  153. package/dist/timezone-country.d.ts +2 -0
  154. package/dist/timezone-country.js +6 -0
  155. package/dist/timezone-country.mjs +3 -0
  156. package/dist/tool-protection/index.mjs.map +1 -1
  157. package/fixtures/detection/cloudflare-alias-parity.json +383 -0
  158. package/fixtures/detection/reason-codes.json +3 -1
  159. package/fixtures/detection/signal-exposure-example.json +1 -1
  160. package/fixtures/iana-tzdata/backward +375 -0
  161. package/fixtures/iana-tzdata/renamed-zones.json +21 -0
  162. package/fixtures/iana-tzdata/version +1 -0
  163. package/fixtures/iana-tzdata/zone.tab +448 -0
  164. package/fixtures/workbench/management-session.v1.json +20 -0
  165. package/fixtures/workbench/model-credentials.v1.json +8 -0
  166. package/fixtures/workbench/task-grant.v1.json +37 -0
  167. package/package.json +25 -3
  168. package/src/data/compiled/merged-rules.json +9 -7
  169. package/dist/browser-posture-5fPrsxx7.d.mts.map +0 -1
  170. package/dist/browser-posture-CCR1kh5e.d.ts.map +0 -1
  171. package/dist/browser-posture-proof-verifier-DvsOmFrM.js +0 -202
  172. package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs +0 -180
  173. package/dist/browser-posture-proof-verifier-I0HP2Ics.mjs.map +0 -1
  174. package/dist/client-ip-DIJyr6px.mjs.map +0 -1
  175. package/dist/detection-reason-mapping-BGymWIPl.mjs.map +0 -1
  176. package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +0 -1
  177. package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +0 -1
  178. package/dist/fetcher-CCw4Q95g.d.ts.map +0 -1
  179. package/dist/fetcher-CZfLcbRZ.d.mts.map +0 -1
  180. package/dist/patterns-Bp40cwh2.d.mts +0 -110
  181. package/dist/patterns-Bp40cwh2.d.mts.map +0 -1
  182. package/dist/patterns-Bp40cwh2.d.ts +0 -110
  183. package/dist/patterns-Bp40cwh2.d.ts.map +0 -1
  184. package/dist/patterns-D4OAsNQY.mjs.map +0 -1
  185. package/dist/registered-sid-CS9V8nPr.mjs.map +0 -1
  186. package/dist/registered-sid-CnWIU_l1.d.mts.map +0 -1
  187. package/dist/registered-sid-CnWIU_l1.d.ts.map +0 -1
@@ -233,6 +233,65 @@ function resolveObservedClientAddress(input) {
233
233
  }
234
234
  }
235
235
  }
236
+ /**
237
+ * SHADOW ONLY: the trusted-proxy rule decided on 2026-10-28, measured beside
238
+ * {@link resolveObservedClientAddress} and never used as the client address.
239
+ * It is deleted when the engine's client address resolver lands; that
240
+ * resolver, and the .NET and Java shadows, must pass the same cases in
241
+ * `tests/cross-runtime-parity/client-ip-shadow/vectors.json`.
242
+ *
243
+ * Behind an authenticated socket peer, the client is the entry `trustedHops`
244
+ * places left of the right end of X-Forwarded-For. Unlike the exact rule, a
245
+ * longer chain (entries a client prepended) is read from the right, up to the
246
+ * 32-entry cap. Every entry from the client's to the right end must parse; a
247
+ * chain shorter than `trustedHops + 1` gives no address. Every other profile
248
+ * resolves exactly as {@link resolveObservedClientAddress}.
249
+ */
250
+ function resolveForwardedChainShadow(input) {
251
+ const policy = input.policy;
252
+ if (policy.platform !== "trusted-proxy") return resolveObservedClientAddress(input);
253
+ if (input.explicitAddressTrusted === true) {
254
+ const explicit = singleAddress(input.explicitAddress);
255
+ if (explicit) return observed(explicit, "explicit", "authenticated-explicit");
256
+ }
257
+ if (!authenticatedPeer(input, policy)) return unavailable("untrusted-peer");
258
+ const tokens = boundedTokens(getObservedHeader(input.headers, "x-forwarded-for"));
259
+ const hops = policy.trustedHops;
260
+ if (!tokens || !Number.isInteger(hops) || hops < 0 || tokens.length < hops + 1) return unavailable("invalid-chain");
261
+ const trusted = tokens.slice(tokens.length - hops - 1).map(normalizeToken);
262
+ if (trusted.some((token) => token === null)) return unavailable("invalid-chain");
263
+ return observed(trusted[0], "x-forwarded-for", "authenticated-proxy");
264
+ }
265
+ /**
266
+ * SHADOW ONLY, deleted with {@link resolveForwardedChainShadow}: compares that
267
+ * rule with the host's own resolution of the same input for a trusted-proxy
268
+ * deployment. It reuses the host's peer verdict instead of asking the
269
+ * deployment's `isTrustedPeer` again. Undefined for every other profile,
270
+ * whose rule does not change.
271
+ */
272
+ function compareForwardedChainShadow(input, hostResolution) {
273
+ const policy = input.policy;
274
+ if (policy.platform !== "trusted-proxy") return void 0;
275
+ const peerTrusted = hostResolution.reason !== "untrusted-peer";
276
+ const shadow = resolveForwardedChainShadow({
277
+ ...input,
278
+ policy: {
279
+ ...policy,
280
+ isTrustedPeer: () => peerTrusted
281
+ }
282
+ });
283
+ const host = hostResolution.ip;
284
+ const raw = getObservedHeader(input.headers, "x-forwarded-for");
285
+ const hops = policy.trustedHops;
286
+ return {
287
+ agree: shadow.ip === host,
288
+ host: host === null ? "none" : "ip",
289
+ shadow: shadow.ip === null ? "none" : "ip",
290
+ chainLength: raw ? Math.min(raw.split(",").length, 33) : 0,
291
+ trustedHops: Number.isInteger(hops) && hops >= 0 ? hops : -1,
292
+ reason: shadow.reason
293
+ };
294
+ }
236
295
  function getHeader(headers, name) {
237
296
  if ("get" in headers && typeof headers.get === "function") return headers.get(name) ?? void 0;
238
297
  const wanted = name.toLowerCase();
@@ -315,6 +374,12 @@ function resolveClientIp(input) {
315
374
  }
316
375
 
317
376
  //#endregion
377
+ Object.defineProperty(exports, 'compareForwardedChainShadow', {
378
+ enumerable: true,
379
+ get: function () {
380
+ return compareForwardedChainShadow;
381
+ }
382
+ });
318
383
  Object.defineProperty(exports, 'compressIpv6', {
319
384
  enumerable: true,
320
385
  get: function () {
@@ -339,6 +404,12 @@ Object.defineProperty(exports, 'resolveClientIp', {
339
404
  return resolveClientIp;
340
405
  }
341
406
  });
407
+ Object.defineProperty(exports, 'resolveForwardedChainShadow', {
408
+ enumerable: true,
409
+ get: function () {
410
+ return resolveForwardedChainShadow;
411
+ }
412
+ });
342
413
  Object.defineProperty(exports, 'resolveObservedClientAddress', {
343
414
  enumerable: true,
344
415
  get: function () {
@@ -233,6 +233,65 @@ function resolveObservedClientAddress(input) {
233
233
  }
234
234
  }
235
235
  }
236
+ /**
237
+ * SHADOW ONLY: the trusted-proxy rule decided on 2026-10-28, measured beside
238
+ * {@link resolveObservedClientAddress} and never used as the client address.
239
+ * It is deleted when the engine's client address resolver lands; that
240
+ * resolver, and the .NET and Java shadows, must pass the same cases in
241
+ * `tests/cross-runtime-parity/client-ip-shadow/vectors.json`.
242
+ *
243
+ * Behind an authenticated socket peer, the client is the entry `trustedHops`
244
+ * places left of the right end of X-Forwarded-For. Unlike the exact rule, a
245
+ * longer chain (entries a client prepended) is read from the right, up to the
246
+ * 32-entry cap. Every entry from the client's to the right end must parse; a
247
+ * chain shorter than `trustedHops + 1` gives no address. Every other profile
248
+ * resolves exactly as {@link resolveObservedClientAddress}.
249
+ */
250
+ function resolveForwardedChainShadow(input) {
251
+ const policy = input.policy;
252
+ if (policy.platform !== "trusted-proxy") return resolveObservedClientAddress(input);
253
+ if (input.explicitAddressTrusted === true) {
254
+ const explicit = singleAddress(input.explicitAddress);
255
+ if (explicit) return observed(explicit, "explicit", "authenticated-explicit");
256
+ }
257
+ if (!authenticatedPeer(input, policy)) return unavailable("untrusted-peer");
258
+ const tokens = boundedTokens(getObservedHeader(input.headers, "x-forwarded-for"));
259
+ const hops = policy.trustedHops;
260
+ if (!tokens || !Number.isInteger(hops) || hops < 0 || tokens.length < hops + 1) return unavailable("invalid-chain");
261
+ const trusted = tokens.slice(tokens.length - hops - 1).map(normalizeToken);
262
+ if (trusted.some((token) => token === null)) return unavailable("invalid-chain");
263
+ return observed(trusted[0], "x-forwarded-for", "authenticated-proxy");
264
+ }
265
+ /**
266
+ * SHADOW ONLY, deleted with {@link resolveForwardedChainShadow}: compares that
267
+ * rule with the host's own resolution of the same input for a trusted-proxy
268
+ * deployment. It reuses the host's peer verdict instead of asking the
269
+ * deployment's `isTrustedPeer` again. Undefined for every other profile,
270
+ * whose rule does not change.
271
+ */
272
+ function compareForwardedChainShadow(input, hostResolution) {
273
+ const policy = input.policy;
274
+ if (policy.platform !== "trusted-proxy") return void 0;
275
+ const peerTrusted = hostResolution.reason !== "untrusted-peer";
276
+ const shadow = resolveForwardedChainShadow({
277
+ ...input,
278
+ policy: {
279
+ ...policy,
280
+ isTrustedPeer: () => peerTrusted
281
+ }
282
+ });
283
+ const host = hostResolution.ip;
284
+ const raw = getObservedHeader(input.headers, "x-forwarded-for");
285
+ const hops = policy.trustedHops;
286
+ return {
287
+ agree: shadow.ip === host,
288
+ host: host === null ? "none" : "ip",
289
+ shadow: shadow.ip === null ? "none" : "ip",
290
+ chainLength: raw ? Math.min(raw.split(",").length, 33) : 0,
291
+ trustedHops: Number.isInteger(hops) && hops >= 0 ? hops : -1,
292
+ reason: shadow.reason
293
+ };
294
+ }
236
295
  function getHeader(headers, name) {
237
296
  if ("get" in headers && typeof headers.get === "function") return headers.get(name) ?? void 0;
238
297
  const wanted = name.toLowerCase();
@@ -315,5 +374,5 @@ function resolveClientIp(input) {
315
374
  }
316
375
 
317
376
  //#endregion
318
- export { resolveObservedClientAddress as a, resolveClientIp as i, normalizeClientIp as n, parseIpv6 as r, compressIpv6 as t };
319
- //# sourceMappingURL=client-ip-DIJyr6px.mjs.map
377
+ export { resolveClientIp as a, parseIpv6 as i, compressIpv6 as n, resolveForwardedChainShadow as o, normalizeClientIp as r, resolveObservedClientAddress as s, compareForwardedChainShadow as t };
378
+ //# sourceMappingURL=client-ip-DlHx7GGh.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-ip-DlHx7GGh.mjs","names":[],"sources":["../src/utils/client-ip.ts"],"sourcesContent":["/**\n * Runtime-agnostic client-IP normalization and trust resolution.\n *\n * Header presence is not proof of provenance. Callers must select the\n * deployment profile that describes which infrastructure has already\n * authenticated a value before using the result for security decisions.\n */\n\nexport type ClientIpSource =\n | 'explicit'\n | 'cf-connecting-ip'\n | 'cf-connecting-ipv6'\n | 'x-vercel-forwarded-for'\n | 'x-forwarded-for'\n | 'x-real-ip'\n | 'framework'\n | 'socket'\n | 'none';\n\n/** Legacy platform-assumed result. Use ObservedClientAddressResolution for new ingress integrations. */\nexport interface ClientIpResolution {\n ip: string | null;\n source: ClientIpSource;\n trusted: boolean;\n}\n\nexport type ObservedClientAddressResolution =\n | {\n /** Compatibility alias for observedClientAddress. */\n ip: string;\n observedClientAddress: string;\n source: Exclude<ClientIpSource, 'none'>;\n trusted: true;\n status: 'observed';\n reason: 'direct-peer' | 'authenticated-explicit' | 'vercel-runtime' | 'authenticated-proxy';\n }\n | {\n ip: null;\n observedClientAddress: null;\n source: 'none';\n trusted: false;\n status: 'unavailable';\n reason:\n | 'missing-address'\n | 'untrusted-peer'\n | 'invalid-chain'\n | 'unsupported-synthetic'\n | 'unsupported-worker';\n };\n\ninterface PeerTrust {\n /** Check the transport peer against the deployment's proxy allowlist, never a request header. */\n isTrustedPeer?: (peerAddress: string) => boolean;\n}\n\nexport type ClientIpTrustPolicy =\n | { platform: 'vercel' }\n | ({ platform: 'cloudflare'; pseudoIpv4?: 'off' | 'add-header' | 'overwrite' } & PeerTrust)\n | ({ platform: 'trusted-proxy'; trustedHops: number } & PeerTrust)\n | { platform: 'direct' };\n\nexport type ClientIpHeaderValue = string | readonly string[] | undefined;\nexport type ClientIpHeaders = Headers | Record<string, ClientIpHeaderValue>;\n\nexport interface ResolveClientIpInput {\n headers: ClientIpHeaders;\n directAddress?: string | null;\n frameworkAddress?: string | null;\n explicitAddress?: string | null;\n /** True only after the caller has authenticated the explicit value. */\n explicitAddressTrusted?: boolean;\n vercelRuntime?: boolean;\n policy: ClientIpTrustPolicy;\n}\n\nconst MAX_INPUT_LENGTH = 4096;\nconst MAX_TOKEN_LENGTH = 128;\nconst MAX_FORWARDED_HOPS = 32;\n\nfunction hasControlCharacter(value: string): boolean {\n for (let i = 0; i < value.length; i++) {\n const code = value.charCodeAt(i);\n if (code <= 0x1f || code === 0x7f) return true;\n }\n return false;\n}\n\nfunction parsePort(value: string): boolean {\n return /^(?:0|[1-9]\\d{0,4})$/.test(value) && Number(value) <= 65535;\n}\n\nfunction parseIpv4(value: string): number[] | null {\n const parts = value.split('.');\n if (parts.length !== 4) return null;\n\n const octets: number[] = [];\n for (const part of parts) {\n if (!/^\\d{1,3}$/.test(part)) return null;\n const octet = Number(part);\n if (octet > 255) return null;\n octets.push(octet);\n }\n return octets;\n}\n\nfunction parseHexGroup(value: string): number | null {\n if (!/^[0-9a-fA-F]{1,4}$/.test(value)) return null;\n return Number.parseInt(value, 16);\n}\n\n/** Parses a bare IPv6 address into its 8 groups (`::` expanded). Exported for reuse by anything that needs to mask/truncate an address (see `anonymize-ip.ts`), not just resolve one. */\nexport function parseIpv6(value: string): number[] | null {\n if (!value || value.includes('%') || hasControlCharacter(value)) return null;\n\n let address = value;\n if (address.includes('.')) {\n const lastColon = address.lastIndexOf(':');\n if (lastColon < 0) return null;\n const ipv4 = parseIpv4(address.slice(lastColon + 1));\n if (!ipv4) return null;\n const first = (ipv4[0]! << 8) | ipv4[1]!;\n const second = (ipv4[2]! << 8) | ipv4[3]!;\n address = `${address.slice(0, lastColon + 1)}${first.toString(16)}:${second.toString(16)}`;\n }\n\n const doubleColon = address.indexOf('::');\n if (doubleColon !== address.lastIndexOf('::')) return null;\n\n const parseGroups = (part: string): number[] | null => {\n if (!part) return [];\n const groups = part.split(':');\n const parsed: number[] = [];\n for (const group of groups) {\n const number = parseHexGroup(group);\n if (number === null) return null;\n parsed.push(number);\n }\n return parsed;\n };\n\n if (doubleColon >= 0) {\n const head = parseGroups(address.slice(0, doubleColon));\n const tail = parseGroups(address.slice(doubleColon + 2));\n if (!head || !tail) return null;\n const missing = 8 - head.length - tail.length;\n if (missing < 1) return null;\n return [...head, ...Array<number>(missing).fill(0), ...tail];\n }\n\n const groups = parseGroups(address);\n return groups?.length === 8 ? groups : null;\n}\n\n/** RFC 5952 canonical `::` compression for 8 IPv6 groups. Exported alongside `parseIpv6`. */\nexport function compressIpv6(groups: number[]): string {\n const rendered = groups.map((group) => group.toString(16));\n let bestStart = -1;\n let bestLength = 1;\n let runStart = -1;\n\n for (let index = 0; index <= groups.length; index += 1) {\n if (index < groups.length && groups[index] === 0) {\n if (runStart < 0) runStart = index;\n continue;\n }\n if (runStart >= 0) {\n const runLength = index - runStart;\n if (runLength > bestLength) {\n bestStart = runStart;\n bestLength = runLength;\n }\n runStart = -1;\n }\n }\n\n if (bestStart < 0) return rendered.join(':');\n const before = rendered.slice(0, bestStart).join(':');\n const after = rendered.slice(bestStart + bestLength).join(':');\n if (!before && !after) return '::';\n if (!before) return `::${after}`;\n if (!after) return `${before}::`;\n return `${before}::${after}`;\n}\n\nfunction normalizeToken(rawToken: string): string | null {\n const token = rawToken.trim();\n if (!token || token.length > MAX_TOKEN_LENGTH || hasControlCharacter(token)) return null;\n\n let address = token;\n if (token.startsWith('[')) {\n const closing = token.indexOf(']');\n if (closing <= 1) return null;\n const suffix = token.slice(closing + 1);\n if (suffix && (!suffix.startsWith(':') || !parsePort(suffix.slice(1)))) return null;\n address = token.slice(1, closing);\n } else if ((token.match(/:/g) ?? []).length === 1 && token.includes('.')) {\n const colon = token.indexOf(':');\n if (!parsePort(token.slice(colon + 1))) return null;\n address = token.slice(0, colon);\n }\n\n const ipv4 = parseIpv4(address);\n if (ipv4) return ipv4.join('.');\n\n const ipv6 = parseIpv6(address);\n return ipv6 ? compressIpv6(ipv6) : null;\n}\n\nfunction boundedTokens(raw: string | null | undefined): string[] | null {\n if (raw == null || !raw || raw.length > MAX_INPUT_LENGTH || hasControlCharacter(raw)) return null;\n const tokens = raw.split(',');\n if (tokens.length > MAX_FORWARDED_HOPS) return null;\n return tokens;\n}\n\n/** Normalize the first valid address in a bounded header value. */\nexport function normalizeClientIp(raw: string | null | undefined): string | null {\n const tokens = boundedTokens(raw);\n if (!tokens) return null;\n for (const token of tokens) {\n const normalized = normalizeToken(token);\n if (normalized) return normalized;\n }\n return null;\n}\n\nfunction getObservedHeader(headers: ClientIpHeaders, name: string): string | undefined {\n if ('get' in headers && typeof headers.get === 'function') {\n return headers.get(name) ?? undefined;\n }\n\n const matches = Object.entries(headers).filter(\n ([key, value]) => key.toLowerCase() === name && value !== undefined\n );\n if (matches.length === 0) return undefined;\n if (matches.length !== 1) return '';\n const value = matches[0]![1] as string | readonly string[];\n return typeof value === 'string' ? value : value.length === 1 ? value[0] : '';\n}\n\nfunction singleAddress(raw: string | null | undefined): string | null {\n const tokens = boundedTokens(raw);\n return tokens?.length === 1 ? normalizeToken(tokens[0]!) : null;\n}\n\nfunction unavailable(\n reason: Extract<ObservedClientAddressResolution, { trusted: false }>['reason']\n): ObservedClientAddressResolution {\n return {\n ip: null,\n observedClientAddress: null,\n source: 'none',\n trusted: false,\n status: 'unavailable',\n reason,\n };\n}\n\nfunction observed(\n ip: string,\n source: Exclude<ClientIpSource, 'none'>,\n reason: Extract<ObservedClientAddressResolution, { trusted: true }>['reason']\n): ObservedClientAddressResolution {\n return { ip, observedClientAddress: ip, source, trusted: true, status: 'observed', reason };\n}\n\nfunction authenticatedPeer(input: ResolveClientIpInput, policy: PeerTrust): boolean {\n const peer = singleAddress(input.directAddress);\n if (!peer || !policy.isTrustedPeer) return false;\n try {\n return policy.isTrustedPeer(peer) === true;\n } catch {\n return false;\n }\n}\n\nfunction resolveVercel(input: ResolveClientIpInput): ObservedClientAddressResolution {\n // Vercel overwrites these values before invoking the managed runtime.\n if (input.vercelRuntime !== true) return unavailable('untrusted-peer');\n const platformHeader = getObservedHeader(input.headers, 'x-vercel-forwarded-for');\n const raw = platformHeader ?? getObservedHeader(input.headers, 'x-forwarded-for');\n const ip = singleAddress(raw);\n return ip\n ? observed(\n ip,\n platformHeader === undefined ? 'x-forwarded-for' : 'x-vercel-forwarded-for',\n 'vercel-runtime'\n )\n : unavailable('invalid-chain');\n}\n\nfunction ipv4Octets(ip: string): number[] | null {\n const ipv4 = parseIpv4(ip);\n if (ipv4) return ipv4;\n const groups = parseIpv6(ip)!;\n return groups.slice(0, 5).every((group) => group === 0) && groups[5] === 0xffff\n ? [groups[6]! >> 8, groups[6]! & 255, groups[7]! >> 8, groups[7]! & 255]\n : null;\n}\n\nfunction resolveCloudflare(\n input: ResolveClientIpInput,\n policy: Extract<ClientIpTrustPolicy, { platform: 'cloudflare' }>\n): ObservedClientAddressResolution {\n if (!authenticatedPeer(input, policy)) return unavailable('untrusted-peer');\n const ip = singleAddress(getObservedHeader(input.headers, 'cf-connecting-ip'));\n if (!ip) return unavailable('invalid-chain');\n // Worker subrequests can replace the visitor address. They need their own authenticated binding.\n if (getObservedHeader(input.headers, 'cf-worker') !== undefined || ip === '2a06:98c0:3600::103')\n return unavailable('unsupported-worker');\n const ipv4 = ipv4Octets(ip);\n if (ipv4 && ipv4[0]! >= 240) {\n const native = singleAddress(getObservedHeader(input.headers, 'cf-connecting-ipv6'));\n if (policy.pseudoIpv4 !== 'overwrite' || !native || ipv4Octets(native))\n return unavailable('unsupported-synthetic');\n if (native === '2a06:98c0:3600::103') return unavailable('unsupported-worker');\n return observed(native, 'cf-connecting-ipv6', 'authenticated-proxy');\n }\n return observed(ip, 'cf-connecting-ip', 'authenticated-proxy');\n}\n\nfunction resolveTrustedProxy(\n input: ResolveClientIpInput,\n policy: Extract<ClientIpTrustPolicy, { platform: 'trusted-proxy' }>\n): ObservedClientAddressResolution {\n if (!authenticatedPeer(input, policy)) return unavailable('untrusted-peer');\n const tokens = boundedTokens(getObservedHeader(input.headers, 'x-forwarded-for'));\n const hops = policy.trustedHops;\n // trustedHops counts addresses to the right of the client, excluding the socket peer.\n if (!tokens || !Number.isInteger(hops) || hops < 0 || tokens.length !== hops + 1)\n return unavailable('invalid-chain');\n const parsed = tokens.map(normalizeToken);\n if (parsed.some((token) => token === null)) return unavailable('invalid-chain');\n return observed(parsed[parsed.length - hops - 1]!, 'x-forwarded-for', 'authenticated-proxy');\n}\n\n/** Resolve the observed client address only through an authenticated deployment boundary. */\nexport function resolveObservedClientAddress(\n input: ResolveClientIpInput\n): ObservedClientAddressResolution {\n if (input.explicitAddressTrusted === true) {\n const explicit = singleAddress(input.explicitAddress);\n if (explicit) return observed(explicit, 'explicit', 'authenticated-explicit');\n }\n switch (input.policy.platform) {\n case 'vercel':\n return resolveVercel(input);\n case 'cloudflare':\n return resolveCloudflare(input, input.policy);\n case 'trusted-proxy':\n return resolveTrustedProxy(input, input.policy);\n default:\n return unavailable('untrusted-peer');\n case 'direct': {\n const socket = singleAddress(input.directAddress);\n if (socket) return observed(socket, 'socket', 'direct-peer');\n const framework = singleAddress(input.frameworkAddress);\n return framework\n ? observed(framework, 'framework', 'direct-peer')\n : unavailable('missing-address');\n }\n }\n}\n\n/**\n * SHADOW ONLY: the trusted-proxy rule decided on 2026-10-28, measured beside\n * {@link resolveObservedClientAddress} and never used as the client address.\n * It is deleted when the engine's client address resolver lands; that\n * resolver, and the .NET and Java shadows, must pass the same cases in\n * `tests/cross-runtime-parity/client-ip-shadow/vectors.json`.\n *\n * Behind an authenticated socket peer, the client is the entry `trustedHops`\n * places left of the right end of X-Forwarded-For. Unlike the exact rule, a\n * longer chain (entries a client prepended) is read from the right, up to the\n * 32-entry cap. Every entry from the client's to the right end must parse; a\n * chain shorter than `trustedHops + 1` gives no address. Every other profile\n * resolves exactly as {@link resolveObservedClientAddress}.\n */\nexport function resolveForwardedChainShadow(\n input: ResolveClientIpInput\n): ObservedClientAddressResolution {\n const policy = input.policy;\n if (policy.platform !== 'trusted-proxy') return resolveObservedClientAddress(input);\n if (input.explicitAddressTrusted === true) {\n const explicit = singleAddress(input.explicitAddress);\n if (explicit) return observed(explicit, 'explicit', 'authenticated-explicit');\n }\n if (!authenticatedPeer(input, policy)) return unavailable('untrusted-peer');\n const tokens = boundedTokens(getObservedHeader(input.headers, 'x-forwarded-for'));\n const hops = policy.trustedHops;\n if (!tokens || !Number.isInteger(hops) || hops < 0 || tokens.length < hops + 1)\n return unavailable('invalid-chain');\n const trusted = tokens.slice(tokens.length - hops - 1).map(normalizeToken);\n if (trusted.some((token) => token === null)) return unavailable('invalid-chain');\n return observed(trusted[0]!, 'x-forwarded-for', 'authenticated-proxy');\n}\n\n/** How the shadow rule compared with the host's answer for one request: shapes only, never an address. */\nexport interface ClientAddressShadow {\n /** The shadow rule and the host resolved the same address, or both resolved none. */\n agree: boolean;\n host: 'ip' | 'none';\n shadow: 'ip' | 'none';\n /** X-Forwarded-For entries, 0 when absent, 33 for any chain over the 32-entry cap. */\n chainLength: number;\n /** The host's configured trustedHops, or -1 when it is not a non-negative integer. */\n trustedHops: number;\n reason: 'authenticated-explicit' | 'authenticated-proxy' | 'untrusted-peer' | 'invalid-chain';\n}\n\n/**\n * SHADOW ONLY, deleted with {@link resolveForwardedChainShadow}: compares that\n * rule with the host's own resolution of the same input for a trusted-proxy\n * deployment. It reuses the host's peer verdict instead of asking the\n * deployment's `isTrustedPeer` again. Undefined for every other profile,\n * whose rule does not change.\n */\nexport function compareForwardedChainShadow(\n input: ResolveClientIpInput,\n hostResolution: ObservedClientAddressResolution\n): ClientAddressShadow | undefined {\n const policy = input.policy;\n if (policy.platform !== 'trusted-proxy') return undefined;\n const peerTrusted = hostResolution.reason !== 'untrusted-peer';\n const shadow = resolveForwardedChainShadow({\n ...input,\n policy: { ...policy, isTrustedPeer: () => peerTrusted },\n });\n const host = hostResolution.ip;\n const raw = getObservedHeader(input.headers, 'x-forwarded-for');\n const hops = policy.trustedHops;\n return {\n agree: shadow.ip === host,\n host: host === null ? 'none' : 'ip',\n shadow: shadow.ip === null ? 'none' : 'ip',\n chainLength: raw ? Math.min(raw.split(',').length, MAX_FORWARDED_HOPS + 1) : 0,\n trustedHops: Number.isInteger(hops) && hops >= 0 ? hops : -1,\n reason: shadow.reason as ClientAddressShadow['reason'],\n };\n}\n\nfunction getHeader(headers: ClientIpHeaders, name: string): string | undefined {\n if ('get' in headers && typeof headers.get === 'function') {\n return headers.get(name) ?? undefined;\n }\n\n const wanted = name.toLowerCase();\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() !== wanted || value === undefined) continue;\n return Array.isArray(value) ? value.join(',') : value;\n }\n return undefined;\n}\n\nfunction result(\n ip: string | null,\n source: Exclude<ClientIpSource, 'none'>,\n trusted: boolean\n): ClientIpResolution | null {\n return ip ? { ip, source, trusted } : null;\n}\n\nfunction resolveAddress(\n raw: string | null | undefined,\n source: 'framework' | 'socket'\n): ClientIpResolution | null {\n return result(normalizeClientIp(raw), source, true);\n}\n\nfunction resolveExplicit(input: ResolveClientIpInput): ClientIpResolution | null {\n if (input.explicitAddressTrusted !== true) return null;\n return result(normalizeClientIp(input.explicitAddress), 'explicit', true);\n}\n\nfunction resolveLegacyVercel(input: ResolveClientIpInput): ClientIpResolution {\n const platform = result(\n normalizeClientIp(getHeader(input.headers, 'x-vercel-forwarded-for')),\n 'x-vercel-forwarded-for',\n true\n );\n if (platform) return platform;\n\n const overwrittenXff = result(\n normalizeClientIp(getHeader(input.headers, 'x-forwarded-for')),\n 'x-forwarded-for',\n true\n );\n if (overwrittenXff) return overwrittenXff;\n\n const realIp = result(\n normalizeClientIp(getHeader(input.headers, 'x-real-ip')),\n 'x-real-ip',\n false\n );\n if (realIp) return realIp;\n\n return (\n resolveAddress(input.frameworkAddress, 'framework') ??\n resolveAddress(input.directAddress, 'socket') ?? { ip: null, source: 'none', trusted: false }\n );\n}\n\nfunction resolveLegacyCloudflare(input: ResolveClientIpInput): ClientIpResolution {\n const cloudflare = result(\n normalizeClientIp(getHeader(input.headers, 'cf-connecting-ip')),\n 'cf-connecting-ip',\n true\n );\n if (cloudflare) return cloudflare;\n\n return (\n resolveAddress(input.directAddress, 'socket') ??\n resolveAddress(input.frameworkAddress, 'framework') ??\n result(\n normalizeClientIp(getHeader(input.headers, 'x-forwarded-for')),\n 'x-forwarded-for',\n false\n ) ??\n result(normalizeClientIp(getHeader(input.headers, 'x-real-ip')), 'x-real-ip', false) ?? {\n ip: null,\n source: 'none',\n trusted: false,\n }\n );\n}\n\nfunction resolveLegacyTrustedProxy(\n input: ResolveClientIpInput,\n trustedHops: number\n): ClientIpResolution {\n const raw = getHeader(input.headers, 'x-forwarded-for');\n const tokens = boundedTokens(raw);\n if (tokens && Number.isInteger(trustedHops) && trustedHops >= 0 && tokens.length > trustedHops) {\n const parsed = tokens.map(normalizeToken);\n const selectedIndex = tokens.length - trustedHops - 1;\n const selected = parsed[selectedIndex];\n // Parse every token before selecting one. Otherwise an invalid token could\n // silently move the trusted boundary toward an attacker-controlled value.\n if (selected && parsed.every((token) => token !== null)) {\n return { ip: selected, source: 'x-forwarded-for', trusted: true };\n }\n }\n\n return (\n resolveAddress(input.frameworkAddress, 'framework') ??\n resolveAddress(input.directAddress, 'socket') ??\n result(normalizeClientIp(getHeader(input.headers, 'x-real-ip')), 'x-real-ip', false) ?? {\n ip: null,\n source: 'none',\n trusted: false,\n }\n );\n}\n\n/**\n * Legacy platform-assumed resolver retained for existing gateway and runtime integrations.\n * This API does not authenticate a nearest peer. New ingress integrations must use\n * resolveObservedClientAddress and qualify their actual deployment boundary.\n */\nexport function resolveClientIp(input: ResolveClientIpInput): ClientIpResolution {\n const explicit = resolveExplicit(input);\n if (explicit) return explicit;\n\n switch (input.policy.platform) {\n case 'vercel':\n return resolveLegacyVercel(input);\n case 'cloudflare':\n return resolveLegacyCloudflare(input);\n case 'trusted-proxy':\n return resolveLegacyTrustedProxy(input, input.policy.trustedHops);\n case 'direct':\n return (\n resolveAddress(input.frameworkAddress, 'framework') ??\n resolveAddress(input.directAddress, 'socket') ?? {\n ip: null,\n source: 'none',\n trusted: false,\n }\n );\n }\n}\n"],"mappings":";AA2EA,MAAM,mBAAmB;AACzB,MAAM,mBAAmB;AACzB,MAAM,qBAAqB;AAE3B,SAAS,oBAAoB,OAAwB;CACnD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK;EACrC,MAAM,OAAO,MAAM,WAAW,CAAC;EAC/B,IAAI,QAAQ,MAAQ,SAAS,KAAM,OAAO;CAC5C;CACA,OAAO;AACT;AAEA,SAAS,UAAU,OAAwB;CACzC,OAAO,uBAAuB,KAAK,KAAK,KAAK,OAAO,KAAK,KAAK;AAChE;AAEA,SAAS,UAAU,OAAgC;CACjD,MAAM,QAAQ,MAAM,MAAM,GAAG;CAC7B,IAAI,MAAM,WAAW,GAAG,OAAO;CAE/B,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,QAAQ,OAAO;EACxB,IAAI,CAAC,YAAY,KAAK,IAAI,GAAG,OAAO;EACpC,MAAM,QAAQ,OAAO,IAAI;EACzB,IAAI,QAAQ,KAAK,OAAO;EACxB,OAAO,KAAK,KAAK;CACnB;CACA,OAAO;AACT;AAEA,SAAS,cAAc,OAA8B;CACnD,IAAI,CAAC,qBAAqB,KAAK,KAAK,GAAG,OAAO;CAC9C,OAAO,OAAO,SAAS,OAAO,EAAE;AAClC;;AAGA,SAAgB,UAAU,OAAgC;CACxD,IAAI,CAAC,SAAS,MAA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K;CACtC,IAAI,UAAU,OAAO;CAErB,QAAQ,MAAM,OAAO,UAArB;EACE,KAAK,UACH,OAAO,oBAAoB,KAAK;EAClC,KAAK,cACH,OAAO,wBAAwB,KAAK;EACtC,KAAK,iBACH,OAAO,0BAA0B,OAAO,MAAM,OAAO,WAAW;EAClE,KAAK,UACH,OACE,eAAe,MAAM,kBAAkB,WAAW,KAClD,eAAe,MAAM,eAAe,QAAQ,KAAK;GAC/C,IAAI;GACJ,QAAQ;GACR,SAAS;EACX;CAEN;AACF"}
@@ -1,2 +1,2 @@
1
- import { a as ClientIpTrustPolicy, c as compressIpv6, d as resolveClientIp, f as resolveObservedClientAddress, i as ClientIpSource, l as normalizeClientIp, n as ClientIpHeaders, o as ObservedClientAddressResolution, r as ClientIpResolution, s as ResolveClientIpInput, t as ClientIpHeaderValue, u as parseIpv6 } from "./client-ip-B7w-uHfS.mjs";
2
- export { ClientIpHeaderValue, ClientIpHeaders, ClientIpResolution, ClientIpSource, ClientIpTrustPolicy, ObservedClientAddressResolution, ResolveClientIpInput, compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveObservedClientAddress };
1
+ import { a as ClientIpSource, c as ResolveClientIpInput, d as normalizeClientIp, f as parseIpv6, h as resolveObservedClientAddress, i as ClientIpResolution, l as compareForwardedChainShadow, m as resolveForwardedChainShadow, n as ClientIpHeaderValue, o as ClientIpTrustPolicy, p as resolveClientIp, r as ClientIpHeaders, s as ObservedClientAddressResolution, t as ClientAddressShadow, u as compressIpv6 } from "./client-ip-8KneiMK0.mjs";
2
+ export { ClientAddressShadow, ClientIpHeaderValue, ClientIpHeaders, ClientIpResolution, ClientIpSource, ClientIpTrustPolicy, ObservedClientAddressResolution, ResolveClientIpInput, compareForwardedChainShadow, compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveForwardedChainShadow, resolveObservedClientAddress };
@@ -1,2 +1,2 @@
1
- import { a as ClientIpTrustPolicy, c as compressIpv6, d as resolveClientIp, f as resolveObservedClientAddress, i as ClientIpSource, l as normalizeClientIp, n as ClientIpHeaders, o as ObservedClientAddressResolution, r as ClientIpResolution, s as ResolveClientIpInput, t as ClientIpHeaderValue, u as parseIpv6 } from "./client-ip-B7w-uHfS.js";
2
- export { ClientIpHeaderValue, ClientIpHeaders, ClientIpResolution, ClientIpSource, ClientIpTrustPolicy, ObservedClientAddressResolution, ResolveClientIpInput, compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveObservedClientAddress };
1
+ import { a as ClientIpSource, c as ResolveClientIpInput, d as normalizeClientIp, f as parseIpv6, h as resolveObservedClientAddress, i as ClientIpResolution, l as compareForwardedChainShadow, m as resolveForwardedChainShadow, n as ClientIpHeaderValue, o as ClientIpTrustPolicy, p as resolveClientIp, r as ClientIpHeaders, s as ObservedClientAddressResolution, t as ClientAddressShadow, u as compressIpv6 } from "./client-ip-8KneiMK0.js";
2
+ export { ClientAddressShadow, ClientIpHeaderValue, ClientIpHeaders, ClientIpResolution, ClientIpSource, ClientIpTrustPolicy, ObservedClientAddressResolution, ResolveClientIpInput, compareForwardedChainShadow, compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveForwardedChainShadow, resolveObservedClientAddress };
package/dist/client-ip.js CHANGED
@@ -1,8 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_client_ip = require('./client-ip-B8wFzJ5f.js');
2
+ const require_client_ip = require('./client-ip-BEmLC4I4.js');
3
3
 
4
+ exports.compareForwardedChainShadow = require_client_ip.compareForwardedChainShadow;
4
5
  exports.compressIpv6 = require_client_ip.compressIpv6;
5
6
  exports.normalizeClientIp = require_client_ip.normalizeClientIp;
6
7
  exports.parseIpv6 = require_client_ip.parseIpv6;
7
8
  exports.resolveClientIp = require_client_ip.resolveClientIp;
9
+ exports.resolveForwardedChainShadow = require_client_ip.resolveForwardedChainShadow;
8
10
  exports.resolveObservedClientAddress = require_client_ip.resolveObservedClientAddress;
@@ -1,3 +1,3 @@
1
- import { a as resolveObservedClientAddress, i as resolveClientIp, n as normalizeClientIp, r as parseIpv6, t as compressIpv6 } from "./client-ip-DIJyr6px.mjs";
1
+ import { a as resolveClientIp, i as parseIpv6, n as compressIpv6, o as resolveForwardedChainShadow, r as normalizeClientIp, s as resolveObservedClientAddress, t as compareForwardedChainShadow } from "./client-ip-DlHx7GGh.mjs";
2
2
 
3
- export { compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveObservedClientAddress };
3
+ export { compareForwardedChainShadow, compressIpv6, normalizeClientIp, parseIpv6, resolveClientIp, resolveForwardedChainShadow, resolveObservedClientAddress };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/deploy/index.ts"],"mappings":";;qBAoCa;qBAgBA,iBAAe,EAAA;qBAUf,iBAAe,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAqChB,YAAY,EAAE,aAAa;qBAY1B,mBAAiB,EAAA;;;;;YAElB,cAAc,EAAE,aAAa;qBAM5B,6BAA2B,EAAA;;;;;;;qBAC3B,yBAAuB,EAAA;;;;;qBAOvB,6BAA2B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCpC,EAAA,KAAA;YAEQ,wBAAwB,EAAE,aAAa;YACvC,wBAAwB,EAAE,aAAa;qBAGtC,sCAAsC,SAAS;qBAgB/C,gCAAgC,SAAS;qBAYzC,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAYhC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;qBAEzC,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BvC,EAAA,KAAA;YAEQ,2BAA2B,EAAE,aAAa;wBAEtC,iCAAiC,cAAc;qBAalD,gCAA8B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;GAShC,EAAA,KAAA;YAEC,2BAA2B,EAAE,aAAa;wBAItC,gCACd,QAAQ,mCACR,cAAc,sCACd,SAAS,2BACR;qBAkIU,+BAA6B,EAAA;;;;;;;YAQ9B,0BAA0B,EAAE,aAAa;qBAWxC,wBAAsB,EAAA;;;;;;;;;;;;;;GAuBjC,EAAA,KAAA;YAEU,mBAAmB,EAAE,aAAa;qBASjC,mBAAiB,EAAA;;GAInB,EAAA,KAAA;qBAKE,sBAAoB,EAAA;;GAItB,EAAA,KAAA;qBAKE,2BAAyB,EAAA;;GAI3B,EAAA,KAAA;qBAKE,4BAA0B,EAAA;;;;;GAQ5B,EAAA,KAAA;qBAUE,sBAAoB,EAAA,uBAAA,EAAA;;;;;;;;;;;GAK/B,EAAA,KAAA;YAEU,iBAAiB,EAAE,aAAa;qBAM/B,yBAAuB,EAAA;;;;;;;;;;;;;;;GAWlC,EAAA,KAAA;YAEU,oBAAoB,EAAE,aAAa;qBAgBlC,oBAAkB,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqE7B,EAAA,KAAA;YAEU,eAAe,EAAE,aAAa;qBAU7B,qBAAmB,EAAA;;;;;;;;GAe9B,EAAA,KAAA;YAEU,gBAAgB,EAAE,aAAa"}
@@ -438,7 +438,11 @@ const HeartbeatResponseSchema = zod.z.object({
438
438
  ack: zod.z.literal(true),
439
439
  /** Pending commands for the compute process to execute */
440
440
  commands: zod.z.array(ComputeCommandSchema).default([]),
441
- /** ISO timestamp of last config change (compute compares to detect updates) */
441
+ /**
442
+ * ISO timestamp of the last config change. A change is applied when the heartbeat returns
443
+ * `update_config`, which a tier change withholds while the agent is in use, so this can be
444
+ * newer than the config the gateway runs.
445
+ */
442
446
  configUpdatedAt: zod.z.string().datetime().optional()
443
447
  });
444
448
  /**
@@ -437,7 +437,11 @@ const HeartbeatResponseSchema = z.object({
437
437
  ack: z.literal(true),
438
438
  /** Pending commands for the compute process to execute */
439
439
  commands: z.array(ComputeCommandSchema).default([]),
440
- /** ISO timestamp of last config change (compute compares to detect updates) */
440
+ /**
441
+ * ISO timestamp of the last config change. A change is applied when the heartbeat returns
442
+ * `update_config`, which a tier change withholds while the agent is in use, so this can be
443
+ * newer than the config the gateway runs.
444
+ */
441
445
  configUpdatedAt: z.string().datetime().optional()
442
446
  });
443
447
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["/**\n * Managed Agent Deployment + Compute Process Contracts (checkpoint-owned subset)\n *\n * Schemas for the managed hosting tier (agents on Fly.io) and the\n * `@kya-os/compute` ⇄ Checkpoint heartbeat/config/control protocol.\n *\n * Ported into checkpoint-shared from `@kya-os/contracts/agent-deployment` +\n * `@kya-os/contracts/compute` as part of the E6 / C-series decommission\n * (#2914 / #2917). Only the symbols re-exported by\n * `apps/web/lib/types/molti-deploy-contracts.ts` (plus their transitive deps —\n * `DidStringSchema`, the compute command sub-schemas) are ported.\n *\n * @module @kya-os/checkpoint-shared/deploy\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Cross-repo endpoint contract\n// ============================================================================\n\n/**\n * The KYA-OS activity-events ingest path (SPEC-EVENTS v0.1 batch endpoint).\n *\n * This is a CROSS-REPO CONTRACT. The Tier 2 worker runtime\n * (`@kya-os/mcp-i-cloudflare`) POSTs `tool.invoked` (and the other SPEC-EVENTS\n * types) to `${AGENTSHIELD_API_URL}${KYA_OS_EVENTS_PATH}`, authenticated by the\n * project API key. Checkpoint serves the batch ingest at this exact path\n * (`apps/web/app${KYA_OS_EVENTS_PATH}/route.ts`) and fans events out into the\n * `detections` table behind `/activity`.\n *\n * Managed deploy deliberately injects NO `KYA_OS_EVENTS_*` secret and relies on\n * this derivation instead, so the two sides agree only by matching this literal.\n * Changing it on either side silently drops all managed activity — it is pinned\n * by a contract test. Keep this value and the worker's derivation in sync.\n */\nexport const KYA_OS_EVENTS_PATH = '/api/v1/kya-os/events';\n\n// ============================================================================\n// Shared Schemas\n// ============================================================================\n\n/**\n * Validated DID string schema.\n * Reusable across all contract files that reference agent DIDs.\n *\n * Format: `did:<method>:<method-specific-id>`\n * - method: 1+ lowercase alphanumeric chars\n * - method-specific-id: 1+ non-whitespace chars\n *\n * Examples: `did:key:z6Mk...`, `did:web:example.com`\n */\nexport const DidStringSchema = z\n .string()\n .min(8, 'DID must be at least 8 characters')\n .regex(/^did:[a-z0-9]+:\\S+$/, 'DID must match format did:<method>:<method-specific-id>');\n\n/**\n * Fly.io deployment regions.\n * Enumerated to prevent arbitrary strings from being accepted.\n * @see https://fly.io/docs/reference/regions/\n */\nexport const FlyRegionSchema = z.enum([\n 'ams', // Amsterdam, Netherlands\n 'arn', // Stockholm, Sweden\n 'atl', // Atlanta, Georgia (US)\n 'bog', // Bogotá, Colombia\n 'bos', // Boston, Massachusetts (US)\n 'cdg', // Paris, France\n 'den', // Denver, Colorado (US)\n 'dfw', // Dallas, Texas (US)\n 'ewr', // Secaucus, NJ (US)\n 'eze', // Ezeiza, Argentina\n 'fra', // Frankfurt, Germany\n 'gdl', // Guadalajara, Mexico\n 'gig', // Rio de Janeiro, Brazil\n 'gru', // São Paulo, Brazil\n 'hkg', // Hong Kong\n 'iad', // Ashburn, Virginia (US)\n 'jnb', // Johannesburg, South Africa\n 'lax', // Los Angeles, California (US)\n 'lhr', // London, United Kingdom\n 'mad', // Madrid, Spain\n 'mia', // Miami, Florida (US)\n 'nrt', // Tokyo, Japan\n 'ord', // Chicago, Illinois (US)\n 'otp', // Bucharest, Romania\n 'phx', // Phoenix, Arizona (US)\n 'qro', // Querétaro, Mexico\n 'scl', // Santiago, Chile\n 'sea', // Seattle, Washington (US)\n 'sin', // Singapore\n 'sjc', // San Jose, California (US)\n 'syd', // Sydney, Australia\n 'waw', // Warsaw, Poland\n 'yul', // Montreal, Canada\n 'yyz', // Toronto, Canada\n]);\n\nexport type FlyRegion = z.infer<typeof FlyRegionSchema>;\n\n/**\n * Hosting mode discriminator — differentiates between deploy backends:\n * - `byok`: self-managed deploy in the customer's own Cloudflare account\n * (customer runs the deploy themselves).\n * - `managed`: platform-managed deploy in our Cloudflare account via Workers\n * for Platforms (dispatch namespace).\n * - `managed-byoa`: platform-managed deploy that lands in the customer's own\n * (\"bring your own account\") Cloudflare account via the standard Workers API,\n * after the org connects Cloudflare over OAuth/token (KYA-906-C).\n */\nexport const HostingModeSchema = z.enum(['byok', 'managed', 'managed-byoa']);\n\nexport type HostingMode = z.infer<typeof HostingModeSchema>;\n\n// ============================================================================\n// Protocol audit deployment contract\n// ============================================================================\n\nexport const AuditAssuranceProfileSchema = z.enum(['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4']);\nexport const AuditDeliveryModeSchema = z.enum(['best-effort', 'buffered', 'required']);\n\n/**\n * Serializable request contract shared by the wizard and every deploy lane.\n * `requestedProfile` is intent, never an assurance claim. Only readiness\n * evaluation against observed runtime capabilities yields `effectiveProfile`.\n */\nexport const AuditDeploymentConfigSchema = z\n .object({\n enabled: z.boolean(),\n requestedProfile: AuditAssuranceProfileSchema,\n delivery: AuditDeliveryModeSchema,\n evidenceMode: z.enum(['none', 'encrypted-separate', 'encrypted-inline']),\n retentionClass: z.string().min(1).max(128),\n retentionDays: z.number().int().min(0).max(3650),\n residency: z.enum(['inherit-project', 'us', 'eu', 'global']),\n keyCustody: z.enum(['none', 'checkpoint-managed', 'customer-managed-kms']),\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n })\n .strict()\n .superRefine((value, context) => {\n if (!value.enabled && value.requestedProfile !== 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Disabled audit configuration must request AAP-0',\n });\n }\n if (value.enabled && value.requestedProfile === 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Enabled audit configuration must request AAP-1 or higher',\n });\n }\n if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === 'best-effort') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['delivery'],\n message: 'AAP-2 or higher cannot use best-effort delivery',\n });\n }\n if (!value.enabled && (value.keyCustody !== 'none' || value.recorderTopology !== 'none')) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Disabled audit configuration cannot claim key custody or recorder topology',\n });\n }\n });\n\nexport type AuditDeploymentConfig = z.infer<typeof AuditDeploymentConfigSchema>;\nexport type AuditAssuranceProfile = z.infer<typeof AuditAssuranceProfileSchema>;\n\n/** Applied only when a user starts a new platform-managed deployment. */\nexport const NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: true,\n requestedProfile: 'AAP-2',\n delivery: 'buffered',\n evidenceMode: 'encrypted-separate',\n retentionClass: 'integrity-ledger',\n retentionDays: 365,\n residency: 'inherit-project',\n keyCustody: 'checkpoint-managed',\n recorderTopology: 'managed',\n});\n\n/**\n * Missing audit config in an already persisted manifest is always AAP-0.\n * This prevents a dashboard or redeploy from silently upgrading old workers.\n */\nexport const ABSENT_AUDIT_DEPLOYMENT_CONFIG: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: false,\n requestedProfile: 'AAP-0',\n delivery: 'best-effort',\n evidenceMode: 'none',\n retentionClass: 'none',\n retentionDays: 0,\n residency: 'inherit-project',\n keyCustody: 'none',\n recorderTopology: 'none',\n});\n\nexport const AuditRuntimeCapabilitiesSchema = z\n .object({\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n delivery: AuditDeliveryModeSchema,\n journalDurability: z.enum(['none', 'ephemeral', 'durable']),\n atomicAppend: z.boolean(),\n sourceHighWater: z.boolean(),\n merkleCheckpoints: z.boolean(),\n independentObservation: z.boolean(),\n supportingAnchors: z.array(z.enum(['worm', 'rfc3161', 'scitt'])),\n evidenceRetention: z.enum(['none', 'inline', 'separate']),\n })\n .strict();\n\nexport type AuditRuntimeCapabilities = z.infer<typeof AuditRuntimeCapabilitiesSchema>;\n\nexport const AuditRuntimeCanaryResultSchema = z\n .object({\n passed: z.boolean(),\n observedAt: z.number().int().nonnegative(),\n capabilities: AuditRuntimeCapabilitiesSchema,\n checks: z\n .array(\n z\n .object({\n id: z.string().min(1).max(128),\n passed: z.boolean(),\n })\n .strict()\n )\n .min(1),\n bundleHash: z.string().min(1).max(256).optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.passed !== value.checks.every((check) => check.passed)) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['passed'],\n message: 'Canary result must equal the aggregate of its mechanical checks',\n });\n }\n });\n\nexport type AuditRuntimeCanaryResult = z.infer<typeof AuditRuntimeCanaryResultSchema>;\n\nexport function requiredAuditRuntimeCanaryChecks(capabilities: AuditRuntimeCapabilities): string[] {\n const checks = [\n 'recorder_round_trip',\n 'verified_receipt',\n 'idempotent_retry',\n 'event_identity_conflict',\n 'source_state',\n ];\n if (capabilities.delivery === 'buffered') checks.push('buffered_outbox');\n if (capabilities.evidenceRetention !== 'none') checks.push('evidence_write_verified');\n return checks;\n}\n\nexport const AuditDeploymentReadinessSchema = z\n .object({\n requestedProfile: AuditAssuranceProfileSchema,\n effectiveProfile: AuditAssuranceProfileSchema,\n status: z.enum(['disabled', 'ready', 'degraded']),\n capabilities: AuditRuntimeCapabilitiesSchema.nullable(),\n canary: AuditRuntimeCanaryResultSchema.nullable(),\n reasonCodes: z.array(z.string().min(1).max(128)),\n })\n .strict();\n\nexport type AuditDeploymentReadiness = z.infer<typeof AuditDeploymentReadinessSchema>;\n\nconst PROFILE_BY_LEVEL = ['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4'] as const;\n\nexport function resolveAuditDeploymentReadiness(\n config: AuditDeploymentConfig | undefined,\n capabilities: AuditRuntimeCapabilities | undefined,\n canary?: AuditRuntimeCanaryResult\n): AuditDeploymentReadiness {\n const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);\n const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;\n if (!requested.enabled) {\n return {\n requestedProfile: 'AAP-0',\n effectiveProfile: 'AAP-0',\n status: 'disabled',\n capabilities: capabilities ?? null,\n canary: observedCanary,\n reasonCodes: ['audit_not_configured'],\n };\n }\n const observedCapabilities = capabilities ?? observedCanary?.capabilities;\n if (!observedCapabilities) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: null,\n canary: observedCanary,\n reasonCodes: ['runtime_capabilities_unavailable'],\n };\n }\n const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);\n if (!observedCanary) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: null,\n reasonCodes: ['runtime_canary_required'],\n };\n }\n if (\n !observedCanary.passed ||\n JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)\n ) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: [\n observedCanary.passed ? 'runtime_canary_capability_mismatch' : 'runtime_canary_failed',\n ],\n };\n }\n const passedChecks = new Set(\n observedCanary.checks.filter((check) => check.passed).map((check) => check.id)\n );\n if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: ['runtime_canary_incomplete'],\n };\n }\n let maximum = 0;\n const reasons: string[] = [];\n if (observed.recorderTopology !== requested.recorderTopology) {\n reasons.push('recorder_topology_mismatch');\n }\n const deliveryRank = { 'best-effort': 0, buffered: 1, required: 2 } as const;\n if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) {\n reasons.push('delivery_mode_mismatch');\n }\n const expectedEvidence =\n requested.evidenceMode === 'none'\n ? 'none'\n : requested.evidenceMode === 'encrypted-inline'\n ? 'inline'\n : 'separate';\n if (expectedEvidence !== observed.evidenceRetention) {\n reasons.push('evidence_retention_mismatch');\n }\n // These are explicit deployment-contract mismatches, not merely unavailable\n // higher-assurance services. Never activate a recorder against mechanics\n // weaker than (or topologically different from) the binding it was given.\n if (reasons.length > 0) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n }\n if (observed.recorderTopology !== 'none' && observed.journalDurability !== 'none') maximum = 1;\n else reasons.push('recorder_or_journal_unavailable');\n if (\n maximum >= 1 &&\n observed.journalDurability === 'durable' &&\n observed.atomicAppend &&\n observed.delivery !== 'best-effort'\n ) {\n maximum = 2;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 2) {\n reasons.push('durable_atomic_buffered_append_unavailable');\n }\n if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;\n else if (Number(requested.requestedProfile.slice(-1)) >= 3) {\n reasons.push('checkpoint_or_source_high_water_unavailable');\n }\n if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) {\n maximum = 4;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 4) {\n reasons.push('independent_observation_or_anchor_unavailable');\n }\n const requestedLevel = Number(requested.requestedProfile.slice(-1));\n const effectiveLevel = Math.min(requestedLevel, maximum);\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel]!,\n status: effectiveLevel === requestedLevel && reasons.length === 0 ? 'ready' : 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n}\n\n/**\n * Deploy step status — reuses same status enum as BYOK.\n */\nexport const ManagedDeployStepStatusSchema = z.enum([\n 'pending',\n 'in_progress',\n 'completed',\n 'failed',\n 'skipped',\n]);\n\nexport type ManagedDeployStepStatus = z.infer<typeof ManagedDeployStepStatusSchema>;\n\n// ============================================================================\n// Heartbeat Protocol (@kya-os/compute ⇄ AgentShield)\n// ============================================================================\n\n/**\n * Heartbeat request body.\n * Sent by compute process: POST /api/v1/molti/agents/{did}/heartbeat\n * Auth: X-Heartbeat-Token header\n */\nexport const HeartbeatRequestSchema = z.object({\n /** Agent DID this heartbeat is for */\n agentDid: DidStringSchema,\n /** Current compute process status */\n status: z.enum(['starting', 'running', 'error', 'stopping']),\n /** @kya-os/compute package version (from package.json) */\n computeVersion: z.string().min(1).max(50),\n /** Installed OpenClaw version (from npm ls) */\n openclawVersion: z.string().max(50).optional(),\n /** Fly machine ID (from FLY_MACHINE_ID env var) */\n machineId: z.string().max(255).optional(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative().optional(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative().optional(),\n /**\n * ISO 8601 time (UTC, or with an offset) of the agent's last real user or channel message: the\n * newest `lastInteractionAt` across its OpenClaw session stores. Omitted while no session has\n * one. Checkpoint records it as user activity for the agent's tier. A value that isn't such a\n * time parses as absent instead of failing the heartbeat, which also carries `stop` and\n * `update_config`.\n */\n lastUserActivityAt: z.string().datetime({ offset: true }).optional().catch(undefined),\n});\n\nexport type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;\n\n// ============================================================================\n// Compute Commands (Discriminated Union)\n// ============================================================================\n\n/**\n * Stop command — graceful shutdown, no payload accepted.\n */\nexport const StopCommandSchema = z\n .object({\n type: z.literal('stop'),\n })\n .strict();\n\n/**\n * Restart command — restart the compute process, no payload accepted.\n */\nexport const RestartCommandSchema = z\n .object({\n type: z.literal('restart'),\n })\n .strict();\n\n/**\n * Update config command — triggers config re-fetch, no payload accepted.\n */\nexport const UpdateConfigCommandSchema = z\n .object({\n type: z.literal('update_config'),\n })\n .strict();\n\n/**\n * Update version command — requires target version in payload.\n */\nexport const UpdateVersionCommandSchema = z\n .object({\n type: z.literal('update_version'),\n payload: z.object({\n /** Target OpenClaw version to install */\n version: z.string().min(1).max(50),\n }),\n })\n .strict();\n\n/**\n * Command that Agent Shield can send to the compute process\n * via the heartbeat response.\n *\n * Discriminated union by `type` field:\n * - `stop` / `restart` / `update_config` — no payload\n * - `update_version` — requires `{ version: string }` payload\n */\nexport const ComputeCommandSchema = z.discriminatedUnion('type', [\n StopCommandSchema,\n RestartCommandSchema,\n UpdateConfigCommandSchema,\n UpdateVersionCommandSchema,\n]);\n\nexport type ComputeCommand = z.infer<typeof ComputeCommandSchema>;\n\n/**\n * Heartbeat response from Agent Shield.\n * Returned by: POST /api/v1/molti/agents/{did}/heartbeat\n */\nexport const HeartbeatResponseSchema = z.object({\n /** Always true for successful heartbeats */\n ack: z.literal(true),\n /** Pending commands for the compute process to execute */\n commands: z.array(ComputeCommandSchema).default([]),\n /** ISO timestamp of last config change (compute compares to detect updates) */\n configUpdatedAt: z.string().datetime().optional(),\n});\n\nexport type HeartbeatResponse = z.infer<typeof HeartbeatResponseSchema>;\n\n// ============================================================================\n// Config Bundle\n// ============================================================================\n\n/**\n * Config bundle returned by Agent Shield to the compute process.\n * Fetched on boot: GET /api/v1/molti/deployments/{did}/config-bundle\n * Auth: X-Heartbeat-Token header (for managed) or X-API-Key (for BYOK)\n *\n * **Private Key Delivery**: The agent's private key is NOT included in the config bundle.\n * It is delivered as the `AGENT_PRIVATE_KEY` environment variable at Fly machine creation\n * time and persists in the machine's env. This avoids transmitting the key on every\n * config fetch and keeps it out of the config-bundle response surface.\n */\nexport const ConfigBundleSchema = z.object({\n /** Schema version — 2 for managed bundles */\n version: z.number().int().positive(),\n /** Kill switch — if true, compute must exit immediately */\n killed: z.boolean(),\n /** Target OpenClaw version to install */\n openclawVersion: z.string().min(1).max(50),\n /** Agent personality/system prompt file contents (max 100KB) */\n soulFile: z.string().max(100_000).nullable(),\n /** Gateway auth token for OpenClaw */\n gatewayToken: z.string().min(1).max(500),\n /** Channel configurations */\n channels: z.object({\n telegram: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n discord: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n slack: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n appToken: z.string().optional(),\n })\n .optional(),\n whatsapp: z\n .object({\n enabled: z.boolean(),\n })\n .strict()\n .optional(),\n }),\n /** AI provider configuration — key is decrypted, sent over TLS */\n aiProvider: z.object({\n type: z.enum(['anthropic', 'openai']),\n apiKey: z.string().min(1).max(500),\n /**\n * Optional base URL override. When set, OpenClaw routes all provider\n * traffic through this URL instead of the provider's default endpoint.\n * Used by managed deployments where AgentShield issues a per-deployment\n * gateway token and proxies to the upstream provider with budget tracking.\n */\n baseUrl: z.string().url().optional(),\n }),\n /**\n * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).\n * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —\n * the primary token-cost lever. Examples: \"30m\" (active), \"6h\" (idle),\n * \"off\" (dormant — heartbeat disabled entirely). When absent, the patcher\n * preserves whatever value already lives in openclaw.json (OpenClaw's\n * built-in default of \"30m\").\n */\n heartbeatEvery: z.string().min(1).max(20).optional(),\n /**\n * Optional override for `agents.defaults.model.primary` (e.g.\n * \"anthropic/claude-haiku-4-5\" for idle agents). When absent, the patcher\n * derives the model from `aiProvider.type` as before. Format must be\n * \"<provider>/<model-id>\".\n */\n modelOverride: z.string().min(1).max(100).optional(),\n /** ISO timestamp of last config modification */\n updatedAt: z.string().datetime(),\n});\n\nexport type ConfigBundle = z.infer<typeof ConfigBundleSchema>;\n\n// ============================================================================\n// Control Server (WebSocket :18790)\n// ============================================================================\n\n/**\n * Status frame pushed from compute control server to dashboard.\n * Sent on connect + every 5 seconds.\n */\nexport const ControlStatusSchema = z.object({\n /** Whether the agent runtime is healthy */\n healthy: z.boolean(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative(),\n /** Installed OpenClaw version */\n openclawVersion: z.string().min(1).max(50),\n /** @kya-os/compute version */\n computeVersion: z.string().min(1).max(50),\n /** Number of active WS connections to control server */\n activeConnections: z.number().int().nonnegative(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative(),\n /** CPU usage percentage (0-100) */\n cpuPercent: z.number().nonnegative().max(100),\n});\n\nexport type ControlStatus = z.infer<typeof ControlStatusSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB;;;;;;;;;;;AAgBlC,MAAa,kBAAkB,EAC5B,OAAO,CAAC,CACR,IAAI,GAAG,mCAAmC,CAAC,CAC3C,MAAM,uBAAuB,yDAAyD;;;;;;AAOzF,MAAa,kBAAkB,EAAE,KAAK;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;;;;;;;AAcD,MAAa,oBAAoB,EAAE,KAAK;CAAC;CAAQ;CAAW;AAAc,CAAC;AAQ3E,MAAa,8BAA8B,EAAE,KAAK;CAAC;CAAS;CAAS;CAAS;CAAS;AAAO,CAAC;AAC/F,MAAa,0BAA0B,EAAE,KAAK;CAAC;CAAe;CAAY;AAAU,CAAC;;;;;;AAOrF,MAAa,8BAA8B,EACxC,OAAO;CACN,SAAS,EAAE,QAAQ;CACnB,kBAAkB;CAClB,UAAU;CACV,cAAc,EAAE,KAAK;EAAC;EAAQ;EAAsB;CAAkB,CAAC;CACvE,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;CACzC,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI;CAC/C,WAAW,EAAE,KAAK;EAAC;EAAmB;EAAM;EAAM;CAAQ,CAAC;CAC3D,YAAY,EAAE,KAAK;EAAC;EAAQ;EAAsB;CAAsB,CAAC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AC;;CAED,YAAY,EAAE,OAAO;EACnB,MAAM,EAAE,KAAK,CAAC,aAAa,QAAQ,CAAC;EACpC,QAAQ,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG;;;;;;;EAOjC,SAAS,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS;CACrC,CAAC;;;;;;;;;CASD,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS;;;;;;;CAOnD,eAAe,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,SAAS;;CAEnD,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;AACjC,CAAC;;;;;AAYD,MAAa,sBAAsB,EAAE,OAAO;;CAE1C,SAAS,EAAE,QAAQ;;CAEnB,eAAe,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEtC,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAEzC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAExC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;;CAEhD,UAAU,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEjC,YAAY,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG;AAC9C,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../src/deploy/index.ts"],"sourcesContent":["/**\n * Managed Agent Deployment + Compute Process Contracts (checkpoint-owned subset)\n *\n * Schemas for the managed hosting tier (agents on Fly.io) and the\n * `@kya-os/compute` ⇄ Checkpoint heartbeat/config/control protocol.\n *\n * Ported into checkpoint-shared from `@kya-os/contracts/agent-deployment` +\n * `@kya-os/contracts/compute` as part of the E6 / C-series decommission\n * (#2914 / #2917). Only the symbols re-exported by\n * `apps/web/lib/types/molti-deploy-contracts.ts` (plus their transitive deps —\n * `DidStringSchema`, the compute command sub-schemas) are ported.\n *\n * @module @kya-os/checkpoint-shared/deploy\n */\n\nimport { z } from 'zod';\n\n// ============================================================================\n// Cross-repo endpoint contract\n// ============================================================================\n\n/**\n * The KYA-OS activity-events ingest path (SPEC-EVENTS v0.1 batch endpoint).\n *\n * This is a CROSS-REPO CONTRACT. The Tier 2 worker runtime\n * (`@kya-os/mcp-i-cloudflare`) POSTs `tool.invoked` (and the other SPEC-EVENTS\n * types) to `${AGENTSHIELD_API_URL}${KYA_OS_EVENTS_PATH}`, authenticated by the\n * project API key. Checkpoint serves the batch ingest at this exact path\n * (`apps/web/app${KYA_OS_EVENTS_PATH}/route.ts`) and fans events out into the\n * `detections` table behind `/activity`.\n *\n * Managed deploy deliberately injects NO `KYA_OS_EVENTS_*` secret and relies on\n * this derivation instead, so the two sides agree only by matching this literal.\n * Changing it on either side silently drops all managed activity — it is pinned\n * by a contract test. Keep this value and the worker's derivation in sync.\n */\nexport const KYA_OS_EVENTS_PATH = '/api/v1/kya-os/events';\n\n// ============================================================================\n// Shared Schemas\n// ============================================================================\n\n/**\n * Validated DID string schema.\n * Reusable across all contract files that reference agent DIDs.\n *\n * Format: `did:<method>:<method-specific-id>`\n * - method: 1+ lowercase alphanumeric chars\n * - method-specific-id: 1+ non-whitespace chars\n *\n * Examples: `did:key:z6Mk...`, `did:web:example.com`\n */\nexport const DidStringSchema = z\n .string()\n .min(8, 'DID must be at least 8 characters')\n .regex(/^did:[a-z0-9]+:\\S+$/, 'DID must match format did:<method>:<method-specific-id>');\n\n/**\n * Fly.io deployment regions.\n * Enumerated to prevent arbitrary strings from being accepted.\n * @see https://fly.io/docs/reference/regions/\n */\nexport const FlyRegionSchema = z.enum([\n 'ams', // Amsterdam, Netherlands\n 'arn', // Stockholm, Sweden\n 'atl', // Atlanta, Georgia (US)\n 'bog', // Bogotá, Colombia\n 'bos', // Boston, Massachusetts (US)\n 'cdg', // Paris, France\n 'den', // Denver, Colorado (US)\n 'dfw', // Dallas, Texas (US)\n 'ewr', // Secaucus, NJ (US)\n 'eze', // Ezeiza, Argentina\n 'fra', // Frankfurt, Germany\n 'gdl', // Guadalajara, Mexico\n 'gig', // Rio de Janeiro, Brazil\n 'gru', // São Paulo, Brazil\n 'hkg', // Hong Kong\n 'iad', // Ashburn, Virginia (US)\n 'jnb', // Johannesburg, South Africa\n 'lax', // Los Angeles, California (US)\n 'lhr', // London, United Kingdom\n 'mad', // Madrid, Spain\n 'mia', // Miami, Florida (US)\n 'nrt', // Tokyo, Japan\n 'ord', // Chicago, Illinois (US)\n 'otp', // Bucharest, Romania\n 'phx', // Phoenix, Arizona (US)\n 'qro', // Querétaro, Mexico\n 'scl', // Santiago, Chile\n 'sea', // Seattle, Washington (US)\n 'sin', // Singapore\n 'sjc', // San Jose, California (US)\n 'syd', // Sydney, Australia\n 'waw', // Warsaw, Poland\n 'yul', // Montreal, Canada\n 'yyz', // Toronto, Canada\n]);\n\nexport type FlyRegion = z.infer<typeof FlyRegionSchema>;\n\n/**\n * Hosting mode discriminator — differentiates between deploy backends:\n * - `byok`: self-managed deploy in the customer's own Cloudflare account\n * (customer runs the deploy themselves).\n * - `managed`: platform-managed deploy in our Cloudflare account via Workers\n * for Platforms (dispatch namespace).\n * - `managed-byoa`: platform-managed deploy that lands in the customer's own\n * (\"bring your own account\") Cloudflare account via the standard Workers API,\n * after the org connects Cloudflare over OAuth/token (KYA-906-C).\n */\nexport const HostingModeSchema = z.enum(['byok', 'managed', 'managed-byoa']);\n\nexport type HostingMode = z.infer<typeof HostingModeSchema>;\n\n// ============================================================================\n// Protocol audit deployment contract\n// ============================================================================\n\nexport const AuditAssuranceProfileSchema = z.enum(['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4']);\nexport const AuditDeliveryModeSchema = z.enum(['best-effort', 'buffered', 'required']);\n\n/**\n * Serializable request contract shared by the wizard and every deploy lane.\n * `requestedProfile` is intent, never an assurance claim. Only readiness\n * evaluation against observed runtime capabilities yields `effectiveProfile`.\n */\nexport const AuditDeploymentConfigSchema = z\n .object({\n enabled: z.boolean(),\n requestedProfile: AuditAssuranceProfileSchema,\n delivery: AuditDeliveryModeSchema,\n evidenceMode: z.enum(['none', 'encrypted-separate', 'encrypted-inline']),\n retentionClass: z.string().min(1).max(128),\n retentionDays: z.number().int().min(0).max(3650),\n residency: z.enum(['inherit-project', 'us', 'eu', 'global']),\n keyCustody: z.enum(['none', 'checkpoint-managed', 'customer-managed-kms']),\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n })\n .strict()\n .superRefine((value, context) => {\n if (!value.enabled && value.requestedProfile !== 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Disabled audit configuration must request AAP-0',\n });\n }\n if (value.enabled && value.requestedProfile === 'AAP-0') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['requestedProfile'],\n message: 'Enabled audit configuration must request AAP-1 or higher',\n });\n }\n if (Number(value.requestedProfile.slice(-1)) >= 2 && value.delivery === 'best-effort') {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['delivery'],\n message: 'AAP-2 or higher cannot use best-effort delivery',\n });\n }\n if (!value.enabled && (value.keyCustody !== 'none' || value.recorderTopology !== 'none')) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n message: 'Disabled audit configuration cannot claim key custody or recorder topology',\n });\n }\n });\n\nexport type AuditDeploymentConfig = z.infer<typeof AuditDeploymentConfigSchema>;\nexport type AuditAssuranceProfile = z.infer<typeof AuditAssuranceProfileSchema>;\n\n/** Applied only when a user starts a new platform-managed deployment. */\nexport const NEW_MANAGED_AUDIT_DEPLOYMENT_DEFAULT: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: true,\n requestedProfile: 'AAP-2',\n delivery: 'buffered',\n evidenceMode: 'encrypted-separate',\n retentionClass: 'integrity-ledger',\n retentionDays: 365,\n residency: 'inherit-project',\n keyCustody: 'checkpoint-managed',\n recorderTopology: 'managed',\n});\n\n/**\n * Missing audit config in an already persisted manifest is always AAP-0.\n * This prevents a dashboard or redeploy from silently upgrading old workers.\n */\nexport const ABSENT_AUDIT_DEPLOYMENT_CONFIG: Readonly<AuditDeploymentConfig> = Object.freeze({\n enabled: false,\n requestedProfile: 'AAP-0',\n delivery: 'best-effort',\n evidenceMode: 'none',\n retentionClass: 'none',\n retentionDays: 0,\n residency: 'inherit-project',\n keyCustody: 'none',\n recorderTopology: 'none',\n});\n\nexport const AuditRuntimeCapabilitiesSchema = z\n .object({\n recorderTopology: z.enum(['none', 'self-hosted', 'managed', 'verified-mirror']),\n delivery: AuditDeliveryModeSchema,\n journalDurability: z.enum(['none', 'ephemeral', 'durable']),\n atomicAppend: z.boolean(),\n sourceHighWater: z.boolean(),\n merkleCheckpoints: z.boolean(),\n independentObservation: z.boolean(),\n supportingAnchors: z.array(z.enum(['worm', 'rfc3161', 'scitt'])),\n evidenceRetention: z.enum(['none', 'inline', 'separate']),\n })\n .strict();\n\nexport type AuditRuntimeCapabilities = z.infer<typeof AuditRuntimeCapabilitiesSchema>;\n\nexport const AuditRuntimeCanaryResultSchema = z\n .object({\n passed: z.boolean(),\n observedAt: z.number().int().nonnegative(),\n capabilities: AuditRuntimeCapabilitiesSchema,\n checks: z\n .array(\n z\n .object({\n id: z.string().min(1).max(128),\n passed: z.boolean(),\n })\n .strict()\n )\n .min(1),\n bundleHash: z.string().min(1).max(256).optional(),\n })\n .strict()\n .superRefine((value, context) => {\n if (value.passed !== value.checks.every((check) => check.passed)) {\n context.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['passed'],\n message: 'Canary result must equal the aggregate of its mechanical checks',\n });\n }\n });\n\nexport type AuditRuntimeCanaryResult = z.infer<typeof AuditRuntimeCanaryResultSchema>;\n\nexport function requiredAuditRuntimeCanaryChecks(capabilities: AuditRuntimeCapabilities): string[] {\n const checks = [\n 'recorder_round_trip',\n 'verified_receipt',\n 'idempotent_retry',\n 'event_identity_conflict',\n 'source_state',\n ];\n if (capabilities.delivery === 'buffered') checks.push('buffered_outbox');\n if (capabilities.evidenceRetention !== 'none') checks.push('evidence_write_verified');\n return checks;\n}\n\nexport const AuditDeploymentReadinessSchema = z\n .object({\n requestedProfile: AuditAssuranceProfileSchema,\n effectiveProfile: AuditAssuranceProfileSchema,\n status: z.enum(['disabled', 'ready', 'degraded']),\n capabilities: AuditRuntimeCapabilitiesSchema.nullable(),\n canary: AuditRuntimeCanaryResultSchema.nullable(),\n reasonCodes: z.array(z.string().min(1).max(128)),\n })\n .strict();\n\nexport type AuditDeploymentReadiness = z.infer<typeof AuditDeploymentReadinessSchema>;\n\nconst PROFILE_BY_LEVEL = ['AAP-0', 'AAP-1', 'AAP-2', 'AAP-3', 'AAP-4'] as const;\n\nexport function resolveAuditDeploymentReadiness(\n config: AuditDeploymentConfig | undefined,\n capabilities: AuditRuntimeCapabilities | undefined,\n canary?: AuditRuntimeCanaryResult\n): AuditDeploymentReadiness {\n const requested = AuditDeploymentConfigSchema.parse(config ?? ABSENT_AUDIT_DEPLOYMENT_CONFIG);\n const observedCanary = canary ? AuditRuntimeCanaryResultSchema.parse(canary) : null;\n if (!requested.enabled) {\n return {\n requestedProfile: 'AAP-0',\n effectiveProfile: 'AAP-0',\n status: 'disabled',\n capabilities: capabilities ?? null,\n canary: observedCanary,\n reasonCodes: ['audit_not_configured'],\n };\n }\n const observedCapabilities = capabilities ?? observedCanary?.capabilities;\n if (!observedCapabilities) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: null,\n canary: observedCanary,\n reasonCodes: ['runtime_capabilities_unavailable'],\n };\n }\n const observed = AuditRuntimeCapabilitiesSchema.parse(observedCapabilities);\n if (!observedCanary) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: null,\n reasonCodes: ['runtime_canary_required'],\n };\n }\n if (\n !observedCanary.passed ||\n JSON.stringify(observedCanary.capabilities) !== JSON.stringify(observed)\n ) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: [\n observedCanary.passed ? 'runtime_canary_capability_mismatch' : 'runtime_canary_failed',\n ],\n };\n }\n const passedChecks = new Set(\n observedCanary.checks.filter((check) => check.passed).map((check) => check.id)\n );\n if (requiredAuditRuntimeCanaryChecks(observed).some((check) => !passedChecks.has(check))) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: ['runtime_canary_incomplete'],\n };\n }\n let maximum = 0;\n const reasons: string[] = [];\n if (observed.recorderTopology !== requested.recorderTopology) {\n reasons.push('recorder_topology_mismatch');\n }\n const deliveryRank = { 'best-effort': 0, buffered: 1, required: 2 } as const;\n if (deliveryRank[observed.delivery] < deliveryRank[requested.delivery]) {\n reasons.push('delivery_mode_mismatch');\n }\n const expectedEvidence =\n requested.evidenceMode === 'none'\n ? 'none'\n : requested.evidenceMode === 'encrypted-inline'\n ? 'inline'\n : 'separate';\n if (expectedEvidence !== observed.evidenceRetention) {\n reasons.push('evidence_retention_mismatch');\n }\n // These are explicit deployment-contract mismatches, not merely unavailable\n // higher-assurance services. Never activate a recorder against mechanics\n // weaker than (or topologically different from) the binding it was given.\n if (reasons.length > 0) {\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: 'AAP-0',\n status: 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n }\n if (observed.recorderTopology !== 'none' && observed.journalDurability !== 'none') maximum = 1;\n else reasons.push('recorder_or_journal_unavailable');\n if (\n maximum >= 1 &&\n observed.journalDurability === 'durable' &&\n observed.atomicAppend &&\n observed.delivery !== 'best-effort'\n ) {\n maximum = 2;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 2) {\n reasons.push('durable_atomic_buffered_append_unavailable');\n }\n if (maximum >= 2 && observed.merkleCheckpoints && observed.sourceHighWater) maximum = 3;\n else if (Number(requested.requestedProfile.slice(-1)) >= 3) {\n reasons.push('checkpoint_or_source_high_water_unavailable');\n }\n if (maximum >= 3 && observed.independentObservation && observed.supportingAnchors.length > 0) {\n maximum = 4;\n } else if (Number(requested.requestedProfile.slice(-1)) >= 4) {\n reasons.push('independent_observation_or_anchor_unavailable');\n }\n const requestedLevel = Number(requested.requestedProfile.slice(-1));\n const effectiveLevel = Math.min(requestedLevel, maximum);\n return {\n requestedProfile: requested.requestedProfile,\n effectiveProfile: PROFILE_BY_LEVEL[effectiveLevel]!,\n status: effectiveLevel === requestedLevel && reasons.length === 0 ? 'ready' : 'degraded',\n capabilities: observed,\n canary: observedCanary,\n reasonCodes: reasons,\n };\n}\n\n/**\n * Deploy step status — reuses same status enum as BYOK.\n */\nexport const ManagedDeployStepStatusSchema = z.enum([\n 'pending',\n 'in_progress',\n 'completed',\n 'failed',\n 'skipped',\n]);\n\nexport type ManagedDeployStepStatus = z.infer<typeof ManagedDeployStepStatusSchema>;\n\n// ============================================================================\n// Heartbeat Protocol (@kya-os/compute ⇄ AgentShield)\n// ============================================================================\n\n/**\n * Heartbeat request body.\n * Sent by compute process: POST /api/v1/molti/agents/{did}/heartbeat\n * Auth: X-Heartbeat-Token header\n */\nexport const HeartbeatRequestSchema = z.object({\n /** Agent DID this heartbeat is for */\n agentDid: DidStringSchema,\n /** Current compute process status */\n status: z.enum(['starting', 'running', 'error', 'stopping']),\n /** @kya-os/compute package version (from package.json) */\n computeVersion: z.string().min(1).max(50),\n /** Installed OpenClaw version (from npm ls) */\n openclawVersion: z.string().max(50).optional(),\n /** Fly machine ID (from FLY_MACHINE_ID env var) */\n machineId: z.string().max(255).optional(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative().optional(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative().optional(),\n /**\n * ISO 8601 time (UTC, or with an offset) of the agent's last real user or channel message: the\n * newest `lastInteractionAt` across its OpenClaw session stores. Omitted while no session has\n * one. Checkpoint records it as user activity for the agent's tier. A value that isn't such a\n * time parses as absent instead of failing the heartbeat, which also carries `stop` and\n * `update_config`.\n */\n lastUserActivityAt: z.string().datetime({ offset: true }).optional().catch(undefined),\n});\n\nexport type HeartbeatRequest = z.infer<typeof HeartbeatRequestSchema>;\n\n// ============================================================================\n// Compute Commands (Discriminated Union)\n// ============================================================================\n\n/**\n * Stop command — graceful shutdown, no payload accepted.\n */\nexport const StopCommandSchema = z\n .object({\n type: z.literal('stop'),\n })\n .strict();\n\n/**\n * Restart command — restart the compute process, no payload accepted.\n */\nexport const RestartCommandSchema = z\n .object({\n type: z.literal('restart'),\n })\n .strict();\n\n/**\n * Update config command — triggers config re-fetch, no payload accepted.\n */\nexport const UpdateConfigCommandSchema = z\n .object({\n type: z.literal('update_config'),\n })\n .strict();\n\n/**\n * Update version command — requires target version in payload.\n */\nexport const UpdateVersionCommandSchema = z\n .object({\n type: z.literal('update_version'),\n payload: z.object({\n /** Target OpenClaw version to install */\n version: z.string().min(1).max(50),\n }),\n })\n .strict();\n\n/**\n * Command that Agent Shield can send to the compute process\n * via the heartbeat response.\n *\n * Discriminated union by `type` field:\n * - `stop` / `restart` / `update_config` — no payload\n * - `update_version` — requires `{ version: string }` payload\n */\nexport const ComputeCommandSchema = z.discriminatedUnion('type', [\n StopCommandSchema,\n RestartCommandSchema,\n UpdateConfigCommandSchema,\n UpdateVersionCommandSchema,\n]);\n\nexport type ComputeCommand = z.infer<typeof ComputeCommandSchema>;\n\n/**\n * Heartbeat response from Agent Shield.\n * Returned by: POST /api/v1/molti/agents/{did}/heartbeat\n */\nexport const HeartbeatResponseSchema = z.object({\n /** Always true for successful heartbeats */\n ack: z.literal(true),\n /** Pending commands for the compute process to execute */\n commands: z.array(ComputeCommandSchema).default([]),\n /**\n * ISO timestamp of the last config change. A change is applied when the heartbeat returns\n * `update_config`, which a tier change withholds while the agent is in use, so this can be\n * newer than the config the gateway runs.\n */\n configUpdatedAt: z.string().datetime().optional(),\n});\n\nexport type HeartbeatResponse = z.infer<typeof HeartbeatResponseSchema>;\n\n// ============================================================================\n// Config Bundle\n// ============================================================================\n\n/**\n * Config bundle returned by Agent Shield to the compute process.\n * Fetched on boot: GET /api/v1/molti/deployments/{did}/config-bundle\n * Auth: X-Heartbeat-Token header (for managed) or X-API-Key (for BYOK)\n *\n * **Private Key Delivery**: The agent's private key is NOT included in the config bundle.\n * It is delivered as the `AGENT_PRIVATE_KEY` environment variable at Fly machine creation\n * time and persists in the machine's env. This avoids transmitting the key on every\n * config fetch and keeps it out of the config-bundle response surface.\n */\nexport const ConfigBundleSchema = z.object({\n /** Schema version — 2 for managed bundles */\n version: z.number().int().positive(),\n /** Kill switch — if true, compute must exit immediately */\n killed: z.boolean(),\n /** Target OpenClaw version to install */\n openclawVersion: z.string().min(1).max(50),\n /** Agent personality/system prompt file contents (max 100KB) */\n soulFile: z.string().max(100_000).nullable(),\n /** Gateway auth token for OpenClaw */\n gatewayToken: z.string().min(1).max(500),\n /** Channel configurations */\n channels: z.object({\n telegram: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n discord: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n })\n .optional(),\n slack: z\n .object({\n enabled: z.boolean(),\n token: z.string().optional(),\n appToken: z.string().optional(),\n })\n .optional(),\n whatsapp: z\n .object({\n enabled: z.boolean(),\n })\n .strict()\n .optional(),\n }),\n /** AI provider configuration — key is decrypted, sent over TLS */\n aiProvider: z.object({\n type: z.enum(['anthropic', 'openai']),\n apiKey: z.string().min(1).max(500),\n /**\n * Optional base URL override. When set, OpenClaw routes all provider\n * traffic through this URL instead of the provider's default endpoint.\n * Used by managed deployments where AgentShield issues a per-deployment\n * gateway token and proxies to the upstream provider with budget tracking.\n */\n baseUrl: z.string().url().optional(),\n }),\n /**\n * Optional OpenClaw heartbeat interval (`agents.defaults.heartbeat.every`).\n * Drives how often OpenClaw wakes the agent for HEARTBEAT.md processing —\n * the primary token-cost lever. Examples: \"30m\" (active), \"6h\" (idle),\n * \"off\" (dormant — heartbeat disabled entirely). When absent, the patcher\n * preserves whatever value already lives in openclaw.json (OpenClaw's\n * built-in default of \"30m\").\n */\n heartbeatEvery: z.string().min(1).max(20).optional(),\n /**\n * Optional override for `agents.defaults.model.primary` (e.g.\n * \"anthropic/claude-haiku-4-5\" for idle agents). When absent, the patcher\n * derives the model from `aiProvider.type` as before. Format must be\n * \"<provider>/<model-id>\".\n */\n modelOverride: z.string().min(1).max(100).optional(),\n /** ISO timestamp of last config modification */\n updatedAt: z.string().datetime(),\n});\n\nexport type ConfigBundle = z.infer<typeof ConfigBundleSchema>;\n\n// ============================================================================\n// Control Server (WebSocket :18790)\n// ============================================================================\n\n/**\n * Status frame pushed from compute control server to dashboard.\n * Sent on connect + every 5 seconds.\n */\nexport const ControlStatusSchema = z.object({\n /** Whether the agent runtime is healthy */\n healthy: z.boolean(),\n /** Seconds since compute process started */\n uptimeSeconds: z.number().nonnegative(),\n /** Installed OpenClaw version */\n openclawVersion: z.string().min(1).max(50),\n /** @kya-os/compute version */\n computeVersion: z.string().min(1).max(50),\n /** Number of active WS connections to control server */\n activeConnections: z.number().int().nonnegative(),\n /** Current RSS memory in MB */\n memoryMb: z.number().nonnegative(),\n /** CPU usage percentage (0-100) */\n cpuPercent: z.number().nonnegative().max(100),\n});\n\nexport type ControlStatus = z.infer<typeof ControlStatusSchema>;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAa,qBAAqB;;;;;;;;;;;AAgBlC,MAAa,kBAAkB,EAC5B,OAAO,CAAC,CACR,IAAI,GAAG,mCAAmC,CAAC,CAC3C,MAAM,uBAAuB,yDAAyD;;;;;;AAOzF,MAAa,kBAAkB,EAAE,KAAK;CACpC;CACA;CACA;CACA;CACA;CACA;CACA;CAC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,WAAW,EAAE,OAAO,CAAC,CAAC,SAAS;AACjC,CAAC;;;;;AAYD,MAAa,sBAAsB,EAAE,OAAO;;CAE1C,SAAS,EAAE,QAAQ;;CAEnB,eAAe,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEtC,iBAAiB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAEzC,gBAAgB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE;;CAExC,mBAAmB,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY;;CAEhD,UAAU,EAAE,OAAO,CAAC,CAAC,YAAY;;CAEjC,YAAY,EAAE,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,IAAI,GAAG;AAC9C,CAAC"}
@@ -24,6 +24,8 @@ declare const DETECTION_REASON_CODES: {
24
24
  readonly A2A_CARD_SIGNAL: "detection/a2a-card-signal";
25
25
  readonly SCANNER_MISCLASSIFICATION_HINT_SIGNAL: "detection/scanner-misclassification-hint-signal";
26
26
  readonly CLIENT_HEADLESS_ESCALATION_SIGNAL: "detection/client-headless-escalation-signal";
27
+ readonly AUTOMATION_DEFAULT_VIEWPORT: "detection/automation-default-viewport";
28
+ readonly CLIENT_INTERACTION_HUMAN: "detection/client-interaction-human";
27
29
  readonly CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: "detection/cloudflare-bot-management-signal";
28
30
  readonly SESSION_VELOCITY_SIGNAL: "detection/session-velocity-signal";
29
31
  readonly TIER1_ATTRIBUTION_SIGNAL: "detection/tier1-attribution-signal";
@@ -43,10 +45,11 @@ interface ReasonCodeDetectionFacts {
43
45
  isAiCrawler?: boolean | null;
44
46
  detectionClass?: string | null;
45
47
  }
48
+ declare function reasonCodeForSignalSource(source: string): DetectionReasonCode | undefined;
46
49
  declare function mapDetectionToReasonCodes(detail: ReasonCodeDetectionFacts): DetectionReasonCode[];
47
50
  declare const MAX_REASON_CODES_ON_WIRE = 5;
48
51
  declare const MAX_REASON_CODES_HEADER_BYTES = 256;
49
52
  declare function formatReasonCodesHeader(codes: readonly DetectionReasonCode[]): string;
50
53
  //#endregion
51
- export { mapDetectionToReasonCodes as a, formatReasonCodesHeader as i, MAX_REASON_CODES_ON_WIRE as n, DETECTION_REASON_CODES as o, ReasonCodeDetectionFacts as r, DetectionReasonCode as s, MAX_REASON_CODES_HEADER_BYTES as t };
52
- //# sourceMappingURL=detection-reason-mapping-CQexNvR7.d.ts.map
54
+ export { mapDetectionToReasonCodes as a, DetectionReasonCode as c, formatReasonCodesHeader as i, MAX_REASON_CODES_ON_WIRE as n, reasonCodeForSignalSource as o, ReasonCodeDetectionFacts as r, DETECTION_REASON_CODES as s, MAX_REASON_CODES_HEADER_BYTES as t };
55
+ //# sourceMappingURL=detection-reason-mapping-BemDaDED.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-reason-mapping-BemDaDED.d.mts","names":[],"sources":["../src/core/detection-reason-codes.ts","../src/core/detection-reason-mapping.ts"],"mappings":";cAmCa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+ED,8BACF,qCAAqC;;;UClF9B;EAEf;EAEA,UAAU;IAAgB;;EAE1B;EAEA;;iBAuEc,0BAA0B,iBAAiB;iBAsB3C,0BAA0B,QAAQ,2BAA2B;cAoEhE;cAEA;iBAYG,wBAAwB,gBAAgB"}
@@ -24,6 +24,8 @@ declare const DETECTION_REASON_CODES: {
24
24
  readonly A2A_CARD_SIGNAL: "detection/a2a-card-signal";
25
25
  readonly SCANNER_MISCLASSIFICATION_HINT_SIGNAL: "detection/scanner-misclassification-hint-signal";
26
26
  readonly CLIENT_HEADLESS_ESCALATION_SIGNAL: "detection/client-headless-escalation-signal";
27
+ readonly AUTOMATION_DEFAULT_VIEWPORT: "detection/automation-default-viewport";
28
+ readonly CLIENT_INTERACTION_HUMAN: "detection/client-interaction-human";
27
29
  readonly CLOUDFLARE_BOT_MANAGEMENT_SIGNAL: "detection/cloudflare-bot-management-signal";
28
30
  readonly SESSION_VELOCITY_SIGNAL: "detection/session-velocity-signal";
29
31
  readonly TIER1_ATTRIBUTION_SIGNAL: "detection/tier1-attribution-signal";
@@ -43,10 +45,11 @@ interface ReasonCodeDetectionFacts {
43
45
  isAiCrawler?: boolean | null;
44
46
  detectionClass?: string | null;
45
47
  }
48
+ declare function reasonCodeForSignalSource(source: string): DetectionReasonCode | undefined;
46
49
  declare function mapDetectionToReasonCodes(detail: ReasonCodeDetectionFacts): DetectionReasonCode[];
47
50
  declare const MAX_REASON_CODES_ON_WIRE = 5;
48
51
  declare const MAX_REASON_CODES_HEADER_BYTES = 256;
49
52
  declare function formatReasonCodesHeader(codes: readonly DetectionReasonCode[]): string;
50
53
  //#endregion
51
- export { mapDetectionToReasonCodes as a, formatReasonCodesHeader as i, MAX_REASON_CODES_ON_WIRE as n, DETECTION_REASON_CODES as o, ReasonCodeDetectionFacts as r, DetectionReasonCode as s, MAX_REASON_CODES_HEADER_BYTES as t };
52
- //# sourceMappingURL=detection-reason-mapping-CQexNvR7.d.mts.map
54
+ export { mapDetectionToReasonCodes as a, DetectionReasonCode as c, formatReasonCodesHeader as i, MAX_REASON_CODES_ON_WIRE as n, reasonCodeForSignalSource as o, ReasonCodeDetectionFacts as r, DETECTION_REASON_CODES as s, MAX_REASON_CODES_HEADER_BYTES as t };
55
+ //# sourceMappingURL=detection-reason-mapping-BemDaDED.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"detection-reason-mapping-BemDaDED.d.ts","names":[],"sources":["../src/core/detection-reason-codes.ts","../src/core/detection-reason-mapping.ts"],"mappings":";cAmCa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+ED,8BACF,qCAAqC;;;UClF9B;EAEf;EAEA,UAAU;IAAgB;;EAE1B;EAEA;;iBAuEc,0BAA0B,iBAAiB;iBAsB3C,0BAA0B,QAAQ,2BAA2B;cAoEhE;cAEA;iBAYG,wBAAwB,gBAAgB"}