@kya-os/checkpoint-shared 1.7.0 → 1.8.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 (224) hide show
  1. package/CHANGELOG.md +122 -9
  2. package/README.md +24 -7
  3. package/dist/beacon-nonce/index.d.mts +1 -0
  4. package/dist/beacon-nonce/index.d.mts.map +1 -1
  5. package/dist/beacon-nonce/index.d.ts +1 -0
  6. package/dist/beacon-nonce/index.d.ts.map +1 -1
  7. package/dist/beacon-nonce/index.js +9 -3
  8. package/dist/beacon-nonce/index.mjs +9 -4
  9. package/dist/beacon-nonce/index.mjs.map +1 -1
  10. package/dist/beacon-types/index.d.mts +23 -1
  11. package/dist/beacon-types/index.d.mts.map +1 -1
  12. package/dist/beacon-types/index.d.ts +23 -1
  13. package/dist/beacon-types/index.d.ts.map +1 -1
  14. package/dist/beacon-types/index.js +49 -4
  15. package/dist/beacon-types/index.mjs +47 -4
  16. package/dist/beacon-types/index.mjs.map +1 -1
  17. package/dist/{browser-posture-BLhw-MON.d.mts → browser-posture-5fPrsxx7.d.mts} +6 -6
  18. package/dist/{browser-posture-BLhw-MON.d.mts.map → browser-posture-5fPrsxx7.d.mts.map} +1 -1
  19. package/dist/{browser-posture-B8YiPa5c.d.ts → browser-posture-CCR1kh5e.d.ts} +6 -6
  20. package/dist/{browser-posture-B8YiPa5c.d.ts.map → browser-posture-CCR1kh5e.d.ts.map} +1 -1
  21. package/dist/browser-posture-proof.d.mts +16 -2
  22. package/dist/browser-posture-proof.d.mts.map +1 -1
  23. package/dist/browser-posture-proof.d.ts +16 -2
  24. package/dist/browser-posture-proof.d.ts.map +1 -1
  25. package/dist/browser-posture-proof.js +73 -17
  26. package/dist/browser-posture-proof.mjs +71 -17
  27. package/dist/browser-posture-proof.mjs.map +1 -1
  28. package/dist/browser-posture.d.mts +1 -1
  29. package/dist/browser-posture.d.ts +1 -1
  30. package/dist/browser-posture.js +6 -5
  31. package/dist/browser-posture.mjs +4 -3
  32. package/dist/browser-posture.mjs.map +1 -1
  33. package/dist/browser.d.mts +25 -4
  34. package/dist/browser.d.mts.map +1 -1
  35. package/dist/browser.d.ts +25 -4
  36. package/dist/browser.d.ts.map +1 -1
  37. package/dist/browser.js +1 -1
  38. package/dist/browser.mjs +1 -1
  39. package/dist/browser.mjs.map +1 -1
  40. package/dist/canonical-signer/index.js +30 -28
  41. package/dist/canonical-signer/index.mjs +31 -1
  42. package/dist/canonical-signer/index.mjs.map +1 -1
  43. package/dist/clearance.d.mts +1 -1
  44. package/dist/clearance.d.ts +1 -1
  45. package/dist/clearance.js +2 -2
  46. package/dist/clearance.mjs +2 -2
  47. package/dist/client-ip-B7w-uHfS.d.mts +55 -0
  48. package/dist/client-ip-B7w-uHfS.d.mts.map +1 -0
  49. package/dist/client-ip-B7w-uHfS.d.ts +55 -0
  50. package/dist/client-ip-B7w-uHfS.d.ts.map +1 -0
  51. package/dist/{client-ip-CW6pRyLf.js → client-ip-B8wFzJ5f.js} +117 -7
  52. package/dist/{client-ip-B2Xeo-GK.mjs → client-ip-DIJyr6px.mjs} +113 -9
  53. package/dist/client-ip-DIJyr6px.mjs.map +1 -0
  54. package/dist/client-ip.d.mts +2 -2
  55. package/dist/client-ip.d.ts +2 -2
  56. package/dist/client-ip.js +3 -2
  57. package/dist/client-ip.mjs +2 -2
  58. package/dist/detection-reason-mapping-B9RSkOs8.js +277 -0
  59. package/dist/detection-reason-mapping-BGymWIPl.mjs +249 -0
  60. package/dist/detection-reason-mapping-BGymWIPl.mjs.map +1 -0
  61. package/dist/detection-reason-mapping-CQexNvR7.d.mts +52 -0
  62. package/dist/detection-reason-mapping-CQexNvR7.d.mts.map +1 -0
  63. package/dist/detection-reason-mapping-CQexNvR7.d.ts +52 -0
  64. package/dist/detection-reason-mapping-CQexNvR7.d.ts.map +1 -0
  65. package/dist/engine-enforcing-AYEcgNsb.js +39 -0
  66. package/dist/engine-enforcing-B5eNfCpG.mjs +29 -0
  67. package/dist/engine-enforcing-B5eNfCpG.mjs.map +1 -0
  68. package/dist/engine-enforcing-DiOclGqf.d.mts +11 -0
  69. package/dist/engine-enforcing-DiOclGqf.d.mts.map +1 -0
  70. package/dist/engine-enforcing-DiOclGqf.d.ts +11 -0
  71. package/dist/engine-enforcing-DiOclGqf.d.ts.map +1 -0
  72. package/dist/engine-info.d.mts +2 -0
  73. package/dist/engine-info.d.ts +2 -0
  74. package/dist/engine-info.js +4 -0
  75. package/dist/engine-info.mjs +3 -0
  76. package/dist/errors/index.d.mts +5 -0
  77. package/dist/errors/index.d.mts.map +1 -1
  78. package/dist/errors/index.d.ts +5 -0
  79. package/dist/errors/index.d.ts.map +1 -1
  80. package/dist/errors/index.js +23 -4
  81. package/dist/errors/index.mjs +23 -4
  82. package/dist/errors/index.mjs.map +1 -1
  83. package/dist/{external-B7WI9FyQ.d.ts → external-m3Kmafwj.d.mts} +2 -2
  84. package/dist/{external-B7WI9FyQ.d.mts.map → external-m3Kmafwj.d.mts.map} +1 -1
  85. package/dist/{external-B7WI9FyQ.d.mts → external-m3Kmafwj.d.ts} +2 -2
  86. package/dist/{external-B7WI9FyQ.d.ts.map → external-m3Kmafwj.d.ts.map} +1 -1
  87. package/dist/fetcher-CivUCbhL.d.ts +44 -0
  88. package/dist/fetcher-CivUCbhL.d.ts.map +1 -0
  89. package/dist/fetcher-cXQsbm6s.d.mts +44 -0
  90. package/dist/fetcher-cXQsbm6s.d.mts.map +1 -0
  91. package/dist/gateway-client-ip.d.mts +1 -1
  92. package/dist/gateway-client-ip.d.ts +1 -1
  93. package/dist/gateway-client-ip.js +2 -2
  94. package/dist/gateway-client-ip.mjs +2 -2
  95. package/dist/host-adapter/index.d.mts +2 -2
  96. package/dist/host-adapter/index.d.ts +2 -2
  97. package/dist/host-adapter/index.js +2 -1
  98. package/dist/host-adapter/index.mjs +2 -2
  99. package/dist/{host-adapter-CwW9YB0U.js → host-adapter-0F8EpbD6.js} +59 -0
  100. package/dist/{host-adapter-C-4IxmqM.mjs → host-adapter-DHyISsIf.mjs} +55 -2
  101. package/dist/{host-adapter-C-4IxmqM.mjs.map → host-adapter-DHyISsIf.mjs.map} +1 -1
  102. package/dist/index-B3cHxr3O.d.mts +156 -0
  103. package/dist/index-B3cHxr3O.d.mts.map +1 -0
  104. package/dist/index-CXbOY7gB.d.ts +156 -0
  105. package/dist/index-CXbOY7gB.d.ts.map +1 -0
  106. package/dist/index.d.mts +8331 -12630
  107. package/dist/index.d.mts.map +1 -1
  108. package/dist/index.d.ts +8331 -12630
  109. package/dist/index.d.ts.map +1 -1
  110. package/dist/index.js +2515 -6663
  111. package/dist/index.mjs +2438 -6371
  112. package/dist/index.mjs.map +1 -1
  113. package/dist/kya-http.d.mts +2 -2
  114. package/dist/kya-http.d.ts +2 -2
  115. package/dist/kya-http.js +9 -1
  116. package/dist/kya-http.mjs +3 -2
  117. package/dist/mcpi/dashboard-config/index.d.mts.map +1 -1
  118. package/dist/mcpi/dashboard-config/index.d.ts.map +1 -1
  119. package/dist/mcpi/status-list/index.d.mts +72 -0
  120. package/dist/mcpi/status-list/index.d.mts.map +1 -0
  121. package/dist/mcpi/status-list/index.d.ts +72 -0
  122. package/dist/mcpi/status-list/index.d.ts.map +1 -0
  123. package/dist/mcpi/status-list/index.js +703 -0
  124. package/dist/mcpi/status-list/index.mjs +684 -0
  125. package/dist/mcpi/status-list/index.mjs.map +1 -0
  126. package/dist/patterns-B2r7M9wR.js +243 -0
  127. package/dist/patterns-B7dQoeE3.mjs +173 -0
  128. package/dist/patterns-B7dQoeE3.mjs.map +1 -0
  129. package/dist/patterns-Bp40cwh2.d.mts +110 -0
  130. package/dist/patterns-Bp40cwh2.d.mts.map +1 -0
  131. package/dist/patterns-Bp40cwh2.d.ts +110 -0
  132. package/dist/patterns-Bp40cwh2.d.ts.map +1 -0
  133. package/dist/patterns.d.mts +2 -0
  134. package/dist/patterns.d.ts +2 -0
  135. package/dist/patterns.js +15 -0
  136. package/dist/patterns.mjs +3 -0
  137. package/dist/policy/enforcement.d.mts +3 -2
  138. package/dist/policy/enforcement.d.ts +3 -2
  139. package/dist/policy/enforcement.js +8 -2
  140. package/dist/policy/enforcement.mjs +3 -2
  141. package/dist/policy/fetcher.d.mts +2 -0
  142. package/dist/policy/fetcher.d.ts +2 -0
  143. package/dist/policy/fetcher.js +240 -0
  144. package/dist/policy/fetcher.mjs +238 -0
  145. package/dist/policy/fetcher.mjs.map +1 -0
  146. package/dist/policy/schemas.d.mts +3 -0
  147. package/dist/policy/schemas.d.ts +3 -0
  148. package/dist/policy/schemas.js +27 -0
  149. package/dist/policy/schemas.mjs +4 -0
  150. package/dist/{posture-origins-Ba83O0cD.mjs → posture-origins-Ci6k4Zh1.js} +24 -173
  151. package/dist/{posture-origins-CdVOdiMT.js → posture-origins-DGyS4Vuk.mjs} +2 -267
  152. package/dist/posture-origins-DGyS4Vuk.mjs.map +1 -0
  153. package/dist/{project-verification-key-BccT12tQ.js → project-verification-key-B-L3D2nC.js} +1 -1
  154. package/dist/{project-verification-key-66N4edKn.mjs → project-verification-key-CWXdu3-n.mjs} +2 -2
  155. package/dist/{project-verification-key-66N4edKn.mjs.map → project-verification-key-CWXdu3-n.mjs.map} +1 -1
  156. package/dist/provider-registry.d.mts +2 -0
  157. package/dist/provider-registry.d.ts +2 -0
  158. package/dist/provider-registry.js +51 -0
  159. package/dist/provider-registry.mjs +3 -0
  160. package/dist/reason-codes.d.mts +2 -0
  161. package/dist/reason-codes.d.ts +2 -0
  162. package/dist/reason-codes.js +8 -0
  163. package/dist/reason-codes.mjs +3 -0
  164. package/dist/{registered-sid-hUl-bvM5.mjs → registered-sid-26hNxp6t.mjs} +11 -2
  165. package/dist/registered-sid-26hNxp6t.mjs.map +1 -0
  166. package/dist/registered-sid-D6KCaT1E.d.mts +33 -0
  167. package/dist/registered-sid-D6KCaT1E.d.mts.map +1 -0
  168. package/dist/registered-sid-D6KCaT1E.d.ts +33 -0
  169. package/dist/registered-sid-D6KCaT1E.d.ts.map +1 -0
  170. package/dist/{registered-sid-eLCNZvIF.js → registered-sid-DVGTSH0L.js} +15 -0
  171. package/dist/ruleset-hash-Cmv8MSO5.js +34 -0
  172. package/dist/ruleset-hash-IRN5eI9H.d.mts +5 -0
  173. package/dist/ruleset-hash-IRN5eI9H.d.mts.map +1 -0
  174. package/dist/ruleset-hash-IRN5eI9H.d.ts +5 -0
  175. package/dist/ruleset-hash-IRN5eI9H.d.ts.map +1 -0
  176. package/dist/ruleset-hash-QQIaLuPi.mjs +30 -0
  177. package/dist/ruleset-hash-QQIaLuPi.mjs.map +1 -0
  178. package/dist/{index-HaqfPtaL.d.ts → schemas-02CI7jgm.d.mts} +11 -183
  179. package/dist/schemas-02CI7jgm.d.mts.map +1 -0
  180. package/dist/{schemas-YhagYDx_.js → schemas-BlScS1it.js} +0 -20
  181. package/dist/{index-B7rTovHa.d.mts → schemas-C_3C72SR.d.ts} +11 -183
  182. package/dist/schemas-C_3C72SR.d.ts.map +1 -0
  183. package/dist/schemas-Cm4C4Z5G.js +703 -0
  184. package/dist/schemas-DPIT8usF.mjs +525 -0
  185. package/dist/schemas-DPIT8usF.mjs.map +1 -0
  186. package/dist/{schemas-7qodsG-Z.mjs → schemas-IHAhH3gV.mjs} +2 -16
  187. package/dist/schemas-IHAhH3gV.mjs.map +1 -0
  188. package/dist/{step-up-COlmWJN8.mjs → step-up-BK0oBi11.mjs} +91 -41
  189. package/dist/step-up-BK0oBi11.mjs.map +1 -0
  190. package/dist/{step-up-C2d8C20x.js → step-up-Bp8RAQwv.js} +117 -55
  191. package/dist/{step-up-BjP--hG-.d.mts → step-up-Bz12gYKT.d.mts} +28 -12
  192. package/dist/step-up-Bz12gYKT.d.mts.map +1 -0
  193. package/dist/{step-up-BjP--hG-.d.ts → step-up-Bz12gYKT.d.ts} +28 -12
  194. package/dist/step-up-Bz12gYKT.d.ts.map +1 -0
  195. package/dist/test-fixtures/index.d.mts +4 -4
  196. package/dist/test-fixtures/index.d.mts.map +1 -1
  197. package/dist/test-fixtures/index.d.ts +4 -4
  198. package/dist/test-fixtures/index.d.ts.map +1 -1
  199. package/dist/test-fixtures/index.js +4 -4
  200. package/dist/test-fixtures/index.mjs +4 -4
  201. package/dist/test-fixtures/index.mjs.map +1 -1
  202. package/dist/verification-BAw9N8Pt.js +181 -0
  203. package/dist/verification-Cvvv86TT.mjs +123 -0
  204. package/dist/verification-Cvvv86TT.mjs.map +1 -0
  205. package/fixtures/client-ip-resolution.n01.json +101 -0
  206. package/fixtures/reviewer-grant-revocation.v1.json +53 -81
  207. package/package.json +37 -2
  208. package/dist/client-ip-B2Xeo-GK.mjs.map +0 -1
  209. package/dist/client-ip-DFamiNoz.d.mts +0 -34
  210. package/dist/client-ip-DFamiNoz.d.mts.map +0 -1
  211. package/dist/client-ip-DFamiNoz.d.ts +0 -34
  212. package/dist/client-ip-DFamiNoz.d.ts.map +0 -1
  213. package/dist/index-B7rTovHa.d.mts.map +0 -1
  214. package/dist/index-HaqfPtaL.d.ts.map +0 -1
  215. package/dist/posture-origins-Ba83O0cD.mjs.map +0 -1
  216. package/dist/registered-sid-D3g-gZQF.d.mts +0 -11
  217. package/dist/registered-sid-D3g-gZQF.d.mts.map +0 -1
  218. package/dist/registered-sid-D3g-gZQF.d.ts +0 -11
  219. package/dist/registered-sid-D3g-gZQF.d.ts.map +0 -1
  220. package/dist/registered-sid-hUl-bvM5.mjs.map +0 -1
  221. package/dist/schemas-7qodsG-Z.mjs.map +0 -1
  222. package/dist/step-up-BjP--hG-.d.mts.map +0 -1
  223. package/dist/step-up-BjP--hG-.d.ts.map +0 -1
  224. package/dist/step-up-COlmWJN8.mjs.map +0 -1
@@ -0,0 +1,525 @@
1
+ import { C as union, S as string, _ as number, c as array, d as discriminatedUnion, h as literal, i as _enum, l as boolean, v as object } from "./schemas-IHAhH3gV.mjs";
2
+
3
+ //#region src/policy/constants.ts
4
+ /**
5
+ * Policy Constants
6
+ *
7
+ * Default values and constants for policy enforcement.
8
+ * Aligned with Rust types in agentshield-types/src/policy.rs
9
+ */
10
+ /**
11
+ * Available enforcement actions.
12
+ *
13
+ * **Vocab-1 migration (2026-05-13, see [[ADR-001]] amendment + Vocab-1
14
+ * #2501).** The old vocabulary mixed two orthogonal axes — `'allow'` /
15
+ * `'block'` (a Decision) and `'log'` (an EnforcementMode). The new
16
+ * vocabulary separates them:
17
+ *
18
+ * - **Decision** (the engine's verdict): one of
19
+ * `'permit' | 'block' | 'redirect' | 'challenge' | 'instruct'`.
20
+ * - **EnforcementMode** (whether the host wrapper acts on the verdict):
21
+ * one of `'enforce' | 'observe'` — see ENFORCEMENT_MODES below.
22
+ *
23
+ * `ALLOW` is kept as an alias for `PERMIT` during the cutover window
24
+ * (per [[checkpoint-engine-phase-1-cutover]] runbook Cutover-2 — drop
25
+ * after 30 days of zero `'allow'` writes). `LOG` is kept similarly —
26
+ * a stored `'log'` row should be read as Permit + Observe mode.
27
+ *
28
+ * Producers (SDK middleware, gateway worker) emit `'permit'` going
29
+ * forward. Consumers (dashboard, ingest validators) accept both during
30
+ * the alias period and alias `'allow'` → display "Permit".
31
+ */
32
+ const ENFORCEMENT_ACTIONS = {
33
+ /** New canonical name for "the engine permits this request through." */
34
+ PERMIT: "permit",
35
+ /**
36
+ * @deprecated Use PERMIT. Kept as wire alias for the Vocab-1
37
+ * cutover window. Drop after 30 days of zero stored writes.
38
+ */
39
+ ALLOW: "allow",
40
+ BLOCK: "block",
41
+ REDIRECT: "redirect",
42
+ CHALLENGE: "challenge",
43
+ /**
44
+ * @deprecated Pre-Vocab-1: a stored `'log'` action was "permit but
45
+ * record." Post-Vocab-1: the same shape is `action: 'permit'` +
46
+ * `mode: 'observe'` (orthogonal axes). Kept for read-back only;
47
+ * producers should not emit `'log'` after Vocab-1 lands.
48
+ */
49
+ LOG: "log",
50
+ INSTRUCT: "instruct"
51
+ };
52
+ /**
53
+ * EnforcementMode — orthogonal to EnforcementAction.
54
+ *
55
+ * Vocab-1 (2026-05-13) split "what to do" (the action / Decision) from
56
+ * "whether to act on it" (the mode). Customers — especially regulated
57
+ * enterprises — want a low-stakes evaluation ramp: install in Observe,
58
+ * watch the dashboard for two weeks to see what *would have been*
59
+ * blocked, then flip to Enforce. CISO-friendly.
60
+ *
61
+ * The host wrapper (Express middleware, Next.js middleware, .NET
62
+ * filter, Cloudflare Worker) reads the mode and:
63
+ *
64
+ * - **Enforce**: applies the Decision — returns 401/403 for Block,
65
+ * forwards Challenge headers, performs Redirect, etc.
66
+ * - **Observe**: passes the request through to the origin regardless
67
+ * of Decision, but records the would-have-been action in metadata
68
+ * so the dashboard can render "Would have been: Block(OutOfScope)"
69
+ * instead of "Block(OutOfScope)". Dash-1 (#2492) acceptance
70
+ * criterion mandates this rendering distinction.
71
+ */
72
+ const ENFORCEMENT_MODES = {
73
+ ENFORCE: "enforce",
74
+ OBSERVE: "observe"
75
+ };
76
+ /**
77
+ * Condition operators for policy rules
78
+ */
79
+ const CONDITION_OPERATORS = {
80
+ EQUALS: "equals",
81
+ NOT_EQUALS: "notEquals",
82
+ CONTAINS: "contains",
83
+ NOT_CONTAINS: "notContains",
84
+ STARTS_WITH: "startsWith",
85
+ ENDS_WITH: "endsWith",
86
+ GREATER_THAN: "greaterThan",
87
+ LESS_THAN: "lessThan",
88
+ GREATER_THAN_OR_EQUALS: "greaterThanOrEquals",
89
+ LESS_THAN_OR_EQUALS: "lessThanOrEquals",
90
+ MATCHES: "matches",
91
+ IN: "in",
92
+ NOT_IN: "notIn"
93
+ };
94
+ /**
95
+ * Fields that can be matched in policy conditions
96
+ */
97
+ const CONDITION_FIELDS = {
98
+ AGENT_TYPE: "agentType",
99
+ AGENT_NAME: "agentName",
100
+ AGENT_VENDOR: "agentVendor",
101
+ CLIENT_DID: "clientDid",
102
+ AGENT_DID: "agentDid",
103
+ CONFIDENCE: "confidence",
104
+ REPUTATION_SCORE: "reputationScore",
105
+ RISK_LEVEL: "riskLevel",
106
+ PATH: "path",
107
+ METHOD: "method",
108
+ ORIGIN: "origin",
109
+ USER_AGENT: "userAgent",
110
+ SIGNATURE_VERIFIED: "signatureVerified",
111
+ IS_AUTHENTICATED: "isAuthenticated",
112
+ HAS_VALID_DELEGATION: "hasValidDelegation"
113
+ };
114
+ /**
115
+ * Default threshold configuration
116
+ */
117
+ const DEFAULT_THRESHOLDS = {
118
+ confidenceThreshold: 80,
119
+ confidenceAction: ENFORCEMENT_ACTIONS.BLOCK,
120
+ minReputationScore: 0,
121
+ lowReputationAction: ENFORCEMENT_ACTIONS.CHALLENGE,
122
+ trustedReputationThreshold: 90,
123
+ trustSignedRequests: true
124
+ };
125
+ /**
126
+ * Default policy configuration
127
+ */
128
+ const DEFAULT_POLICY = {
129
+ version: "1.0.0",
130
+ enabled: true,
131
+ defaultAction: ENFORCEMENT_ACTIONS.PERMIT,
132
+ thresholds: DEFAULT_THRESHOLDS,
133
+ denyList: [],
134
+ allowList: [],
135
+ rules: [],
136
+ excludedPaths: []
137
+ };
138
+ /**
139
+ * Default rule priority (lower = higher priority)
140
+ */
141
+ const DEFAULT_RULE_PRIORITY = 100;
142
+ /**
143
+ * Cache TTL values (in seconds)
144
+ */
145
+ const CACHE_TTL = {
146
+ POLICY: 300,
147
+ API_KEY: 900
148
+ };
149
+ /**
150
+ * Policy version for schema migrations
151
+ */
152
+ const CURRENT_POLICY_VERSION = "1.0.0";
153
+
154
+ //#endregion
155
+ //#region src/policy/schemas.ts
156
+ /**
157
+ * Policy Zod Schemas
158
+ *
159
+ * Runtime validation schemas for policy configuration.
160
+ * Aligned with Rust types in agentshield-types/src/policy.rs
161
+ */
162
+ const EnforcementActionSchema = _enum([
163
+ ENFORCEMENT_ACTIONS.PERMIT,
164
+ ENFORCEMENT_ACTIONS.BLOCK,
165
+ ENFORCEMENT_ACTIONS.REDIRECT,
166
+ ENFORCEMENT_ACTIONS.CHALLENGE,
167
+ ENFORCEMENT_ACTIONS.INSTRUCT,
168
+ ENFORCEMENT_ACTIONS.ALLOW,
169
+ ENFORCEMENT_ACTIONS.LOG
170
+ ]);
171
+ /**
172
+ * EnforcementMode — orthogonal to EnforcementAction. See
173
+ * `ENFORCEMENT_MODES` in constants.ts for the full rationale.
174
+ */
175
+ const EnforcementModeSchema = _enum([ENFORCEMENT_MODES.ENFORCE, ENFORCEMENT_MODES.OBSERVE]);
176
+ /**
177
+ * Block reasons — priority order (Rust declaration order): Revoked >
178
+ * InvalidSignature > Unauthenticated > Expired > OutOfScope >
179
+ * LowReputation > PolicyDenied > AgentAttribution > ParseError >
180
+ * Tier3UAMatch. The engine returns the most-actionable reason; this
181
+ * schema accepts any of them. See TDD Spec Layer 1 for the priority
182
+ * rules and `rust/crates/kya-os-engine/src/types.rs` for the wire SSOT.
183
+ */
184
+ const BlockReasonSchema = discriminatedUnion("kind", [
185
+ object({ kind: literal("Revoked") }),
186
+ object({ kind: literal("InvalidSignature") }),
187
+ object({ kind: literal("Unauthenticated") }),
188
+ object({ kind: literal("Expired") }),
189
+ object({
190
+ kind: literal("OutOfScope"),
191
+ requested: string(),
192
+ granted: array(string())
193
+ }),
194
+ object({
195
+ kind: literal("LowReputation"),
196
+ score: number(),
197
+ threshold: number()
198
+ }),
199
+ object({
200
+ kind: literal("PolicyDenied"),
201
+ detail: string(),
202
+ policyId: string().optional()
203
+ }),
204
+ object({
205
+ kind: literal("AgentAttribution"),
206
+ vendor: string(),
207
+ tier: number().int(),
208
+ confidence: number().min(0).max(1)
209
+ }),
210
+ object({
211
+ kind: literal("ParseError"),
212
+ detail: string()
213
+ }),
214
+ object({
215
+ kind: literal("Tier3UAMatch"),
216
+ pattern_id: string(),
217
+ pattern_kind: string(),
218
+ confidence: number().int().min(0).max(100)
219
+ })
220
+ ]);
221
+ /**
222
+ * The draft-kya-http-02 §1 assurance ladder, monotone floor → top. These are
223
+ * the exact wire strings the merged kya-http fixtures pin
224
+ * (`packages/checkpoint-shared/fixtures/kya-http`, e.g. `min_assurance`); the
225
+ * Rust engine emits them on the verdict and reads them as `context.assurance`.
226
+ * Canonical SSOT for the assurance tier / `min_assurance` enum.
227
+ */
228
+ const AssuranceTierSchema = _enum([
229
+ "anonymous",
230
+ "attested-bearer",
231
+ "key-bound",
232
+ "registered",
233
+ "delegated"
234
+ ]);
235
+ /**
236
+ * ChallengeParams MUST be the KYA-OS L2+ handshake envelope shape, not
237
+ * a parallel Checkpoint definition. Reusing the spec donated to DIF
238
+ * gives every KYA-OS implementer free interop with Checkpoint's
239
+ * Challenge flow. See [[ADR-001]] amendment.
240
+ */
241
+ const ChallengeParamsSchema = object({
242
+ nonce: string(),
243
+ audience: string(),
244
+ expiresAt: number(),
245
+ algorithmsAccepted: array(string()),
246
+ minAssurance: AssuranceTierSchema.optional(),
247
+ policyId: string().optional(),
248
+ challengeType: string().optional()
249
+ });
250
+ const RedirectTargetSchema = object({
251
+ url: string().url(),
252
+ reason: string(),
253
+ state: string().optional(),
254
+ policyId: string().optional()
255
+ });
256
+ const SuggestedActionSchema = discriminatedUnion("kind", [
257
+ object({
258
+ kind: literal("UseDifferentScope"),
259
+ scope: string()
260
+ }),
261
+ object({
262
+ kind: literal("UpdateRequestField"),
263
+ field: string(),
264
+ acceptedValues: array(string())
265
+ }),
266
+ object({
267
+ kind: literal("UpgradeProtocolVersion"),
268
+ version: string()
269
+ }),
270
+ object({
271
+ kind: literal("Other"),
272
+ code: string(),
273
+ detail: string()
274
+ })
275
+ ]);
276
+ const InstructPayloadSchema = object({
277
+ problem: string(),
278
+ title: string(),
279
+ suggestedActions: array(SuggestedActionSchema),
280
+ policyId: string().optional()
281
+ });
282
+ /**
283
+ * Decision — the Detect → Verify → **Decide** axis. Five variants
284
+ * with per-variant payload via discriminated union. Mirrors the Rust
285
+ * `Decision` enum (D-design #2484); the dashboard renders one badge
286
+ * per variant (see Dash-1 #2492). The wire-side EnforcementAction
287
+ * string above is the legacy flat encoding; this is the canonical
288
+ * structured replacement.
289
+ */
290
+ const DecisionSchema = discriminatedUnion("kind", [
291
+ object({
292
+ kind: literal("Permit"),
293
+ policyId: string().optional()
294
+ }),
295
+ object({
296
+ kind: literal("Block"),
297
+ reason: BlockReasonSchema
298
+ }),
299
+ object({
300
+ kind: literal("Challenge"),
301
+ params: ChallengeParamsSchema
302
+ }),
303
+ object({
304
+ kind: literal("Redirect"),
305
+ target: RedirectTargetSchema
306
+ }),
307
+ object({
308
+ kind: literal("Instruct"),
309
+ payload: InstructPayloadSchema
310
+ })
311
+ ]);
312
+ const ThresholdConfigSchema = object({
313
+ /** Detection confidence threshold (0-100) */
314
+ confidenceThreshold: number().min(0).max(100).default(DEFAULT_THRESHOLDS.confidenceThreshold),
315
+ /** Action to take when confidence threshold is exceeded */
316
+ confidenceAction: EnforcementActionSchema.default(DEFAULT_THRESHOLDS.confidenceAction),
317
+ /** Minimum reputation score (0-100) required to allow access */
318
+ minReputationScore: number().min(0).max(100).default(DEFAULT_THRESHOLDS.minReputationScore),
319
+ /** Action to take when reputation is below threshold */
320
+ lowReputationAction: EnforcementActionSchema.default(DEFAULT_THRESHOLDS.lowReputationAction),
321
+ /** High reputation score threshold (0-100) - trusted agents bypass other checks */
322
+ trustedReputationThreshold: number().min(0).max(100).default(DEFAULT_THRESHOLDS.trustedReputationThreshold),
323
+ /** Whether cryptographically signed requests bypass thresholds */
324
+ trustSignedRequests: boolean().default(DEFAULT_THRESHOLDS.trustSignedRequests)
325
+ });
326
+ const DenyListEntrySchema = object({
327
+ /** KYA-OS client DID */
328
+ clientDid: string().optional(),
329
+ /** Agent DID from KYA-OS identity */
330
+ agentDid: string().optional(),
331
+ /** Human-readable client name (e.g., "ChatGPT") */
332
+ clientName: string().optional(),
333
+ /** Agent type to block (e.g., "ai_agent", "bot") */
334
+ agentType: string().optional(),
335
+ /** Reason for denial */
336
+ reason: string().optional(),
337
+ /** ISO 8601 timestamp when entry was added */
338
+ blockedAt: string().optional(),
339
+ /** Who added this entry */
340
+ addedBy: string().optional(),
341
+ /** Whether this entry is currently active */
342
+ active: boolean().default(true),
343
+ /** Optional expiration date for temporary blocks */
344
+ expiresAt: string().optional()
345
+ });
346
+ const AllowListEntrySchema = object({
347
+ /** KYA-OS client DID */
348
+ clientDid: string().optional(),
349
+ /** Agent DID from KYA-OS identity */
350
+ agentDid: string().optional(),
351
+ /** Human-readable client name */
352
+ clientName: string().optional(),
353
+ /** Agent type to allow */
354
+ agentType: string().optional(),
355
+ /** Reason for allowing */
356
+ reason: string().optional(),
357
+ /** ISO 8601 timestamp when entry was added */
358
+ addedAt: string().optional(),
359
+ /** Who added this entry */
360
+ addedBy: string().optional()
361
+ });
362
+ const ConditionOperatorSchema = _enum([
363
+ CONDITION_OPERATORS.EQUALS,
364
+ CONDITION_OPERATORS.NOT_EQUALS,
365
+ CONDITION_OPERATORS.CONTAINS,
366
+ CONDITION_OPERATORS.NOT_CONTAINS,
367
+ CONDITION_OPERATORS.STARTS_WITH,
368
+ CONDITION_OPERATORS.ENDS_WITH,
369
+ CONDITION_OPERATORS.GREATER_THAN,
370
+ CONDITION_OPERATORS.LESS_THAN,
371
+ CONDITION_OPERATORS.GREATER_THAN_OR_EQUALS,
372
+ CONDITION_OPERATORS.LESS_THAN_OR_EQUALS,
373
+ CONDITION_OPERATORS.MATCHES,
374
+ CONDITION_OPERATORS.IN,
375
+ CONDITION_OPERATORS.NOT_IN
376
+ ]);
377
+ const ConditionFieldSchema = _enum([
378
+ CONDITION_FIELDS.AGENT_TYPE,
379
+ CONDITION_FIELDS.AGENT_NAME,
380
+ CONDITION_FIELDS.AGENT_VENDOR,
381
+ CONDITION_FIELDS.CLIENT_DID,
382
+ CONDITION_FIELDS.AGENT_DID,
383
+ CONDITION_FIELDS.CONFIDENCE,
384
+ CONDITION_FIELDS.REPUTATION_SCORE,
385
+ CONDITION_FIELDS.RISK_LEVEL,
386
+ CONDITION_FIELDS.PATH,
387
+ CONDITION_FIELDS.METHOD,
388
+ CONDITION_FIELDS.ORIGIN,
389
+ CONDITION_FIELDS.USER_AGENT,
390
+ CONDITION_FIELDS.SIGNATURE_VERIFIED,
391
+ CONDITION_FIELDS.IS_AUTHENTICATED,
392
+ CONDITION_FIELDS.HAS_VALID_DELEGATION
393
+ ]);
394
+ const ConditionValueSchema = union([
395
+ string(),
396
+ number(),
397
+ boolean(),
398
+ array(string())
399
+ ]);
400
+ const PolicyConditionSchema = object({
401
+ /** Field to match against */
402
+ field: ConditionFieldSchema,
403
+ /** Comparison operator */
404
+ operator: ConditionOperatorSchema,
405
+ /** Value to compare against */
406
+ value: ConditionValueSchema,
407
+ /** Whether this condition is case-insensitive */
408
+ caseInsensitive: boolean().optional()
409
+ });
410
+ const RuleMetadataSchema = object({
411
+ createdAt: string().optional(),
412
+ updatedAt: string().optional(),
413
+ createdBy: string().optional()
414
+ });
415
+ const PolicyRuleSchema = object({
416
+ /** Unique identifier for this rule */
417
+ id: string(),
418
+ /** Human-readable name */
419
+ name: string(),
420
+ /** Description of what this rule does */
421
+ description: string().optional(),
422
+ /** Priority (lower = higher priority, evaluated first) */
423
+ priority: number().int().default(100),
424
+ /** Conditions that must ALL match for this rule to apply (AND logic) */
425
+ conditions: array(PolicyConditionSchema),
426
+ /** Action to take when conditions match */
427
+ action: EnforcementActionSchema,
428
+ /** Redirect URL (required if action is 'redirect') */
429
+ redirectUrl: string().url().optional(),
430
+ /** Custom message to show/log */
431
+ message: string().optional(),
432
+ /** Whether this rule is currently active */
433
+ enabled: boolean().default(true),
434
+ /** Metadata for auditing */
435
+ metadata: RuleMetadataSchema.optional()
436
+ });
437
+ const PolicyMetadataSchema = object({
438
+ lastUpdated: string().optional(),
439
+ updatedBy: string().optional(),
440
+ policyId: string().optional()
441
+ });
442
+ const PolicyConfigSchema = object({
443
+ /** Schema version for migrations */
444
+ version: string().default(CURRENT_POLICY_VERSION),
445
+ /** Whether policy enforcement is enabled */
446
+ enabled: boolean().default(true),
447
+ /** Default action when no rules match. Updated to PERMIT (was ALLOW)
448
+ * per Vocab-1 (#2501); the wire still accepts both via the alias
449
+ * schema so existing stored policies continue to load. */
450
+ defaultAction: EnforcementActionSchema.default(ENFORCEMENT_ACTIONS.PERMIT),
451
+ /** Default redirect URL for redirect actions */
452
+ redirectUrl: string().url().optional(),
453
+ /** Threshold-based enforcement settings */
454
+ thresholds: ThresholdConfigSchema.prefault({}),
455
+ /** Deny list entries (checked after allow list, before rules) */
456
+ denyList: array(DenyListEntrySchema).default([]),
457
+ /** Allow list entries (exempt from all checks) */
458
+ allowList: array(AllowListEntrySchema).default([]),
459
+ /** Custom policy rules (evaluated by priority after threshold checks) */
460
+ rules: array(PolicyRuleSchema).default([]),
461
+ /** Paths to exclude from policy enforcement (glob patterns supported) */
462
+ excludedPaths: array(string()).default([]),
463
+ /** Paths to include (if set, only these paths are enforced) */
464
+ includedPaths: array(string()).optional(),
465
+ /** Metadata for the policy configuration */
466
+ metadata: PolicyMetadataSchema.optional(),
467
+ /**
468
+ * Composed policy source (Cedar today). `null`/absent → no composed policy
469
+ * (the runtime uses the structured fields). Empty/blank is treated as "no
470
+ * policy" by the engine path (an empty bundle compiles to deny-all), so the
471
+ * runtime MUST normalize blank → absent before handing it to the evaluator.
472
+ */
473
+ policySourceText: string().nullish(),
474
+ /**
475
+ * Language of `policySourceText`. `cedar` today; kept as a free string (not an
476
+ * enum) so a future Rego/OPA bundle flows through the same contract without a
477
+ * schema-version bump. A runtime enforces only languages it actually embeds.
478
+ */
479
+ policyLanguage: string().nullish(),
480
+ /**
481
+ * Hex sha256 of `policySourceText` as served by the SSOT — byte-identical to
482
+ * `policy_revisions.composed_blob_hash` (#3246 PR5). Runtimes ECHO it onto
483
+ * acted decisions (`enforcement.composedBlobHash`) and Delegation challenges
484
+ * (`challenge.composed_blob_hash`) as the point-in-time revision pin; they
485
+ * never hash locally. Absent/null → plane omits the pin (older dashboards).
486
+ */
487
+ policySourceHash: string().nullish(),
488
+ /**
489
+ * Whether the engine should ACT on the composed policy (deployed-to-enforce).
490
+ * False → the composed policy is at most shadow-evaluated; the structured
491
+ * path / bespoke decision governs. Mirrors the gateway worker's act-gate
492
+ * (`engineEnforcementEnabled === true && enabled !== false`).
493
+ */
494
+ engineEnforcementEnabled: boolean().optional().default(false),
495
+ /**
496
+ * Trusted Layer-2 delegation root DIDs for the project's org (P2 / DR-1),
497
+ * server-resolved by the policy API. A consuming middleware forwards these
498
+ * into the engine's `ContextSpec.trustedDelegationRoots` so L2 delegation
499
+ * chains are pinned to the org DID. Absent ⇒ omitted, and the engine rejects
500
+ * delegation. Optional (no default)
501
+ * so a policy without the field round-trips as `undefined`, matching the
502
+ * policy API's `PolicyResponse` shape and the orchestrator's omit-when-unset
503
+ * contract.
504
+ */
505
+ trustedDelegationRoots: array(string()).optional(),
506
+ /**
507
+ * The org's one OAuth authorization server issuer (RFC 8414 `issuer`), as the
508
+ * platform's IssuerContext computes it (`https://<branded host or platform>/oauth/<slug>`).
509
+ * A middleware that serves protected resource metadata advertises exactly
510
+ * this in `authorization_servers` and never builds an issuer URL itself.
511
+ * Absent ⇒ the platform could not resolve the org; serve no metadata.
512
+ */
513
+ authorizationServerIssuer: string().url().optional()
514
+ });
515
+ /**
516
+ * Safely parse a policy configuration (returns null on error)
517
+ */
518
+ function safeParsePolicyConfig(data) {
519
+ const result = PolicyConfigSchema.safeParse(data);
520
+ return result.success ? result.data : null;
521
+ }
522
+
523
+ //#endregion
524
+ export { ENFORCEMENT_MODES as A, CONDITION_FIELDS as C, DEFAULT_RULE_PRIORITY as D, DEFAULT_POLICY as E, DEFAULT_THRESHOLDS as O, CACHE_TTL as S, CURRENT_POLICY_VERSION as T, RedirectTargetSchema as _, ConditionFieldSchema as a, ThresholdConfigSchema as b, DecisionSchema as c, EnforcementModeSchema as d, InstructPayloadSchema as f, PolicyRuleSchema as g, PolicyMetadataSchema as h, ChallengeParamsSchema as i, ENFORCEMENT_ACTIONS as k, DenyListEntrySchema as l, PolicyConfigSchema as m, AssuranceTierSchema as n, ConditionOperatorSchema as o, PolicyConditionSchema as p, BlockReasonSchema as r, ConditionValueSchema as s, AllowListEntrySchema as t, EnforcementActionSchema as u, RuleMetadataSchema as v, CONDITION_OPERATORS as w, safeParsePolicyConfig as x, SuggestedActionSchema as y };
525
+ //# sourceMappingURL=schemas-DPIT8usF.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas-DPIT8usF.mjs","names":["z.enum","z.discriminatedUnion","z.object","z.literal","z.string","z.array","z.number","z\n .number","z.boolean","z.union"],"sources":["../src/policy/constants.ts","../src/policy/schemas.ts"],"sourcesContent":["/**\n * Policy Constants\n *\n * Default values and constants for policy enforcement.\n * Aligned with Rust types in agentshield-types/src/policy.rs\n */\n\n/**\n * Available enforcement actions.\n *\n * **Vocab-1 migration (2026-05-13, see [[ADR-001]] amendment + Vocab-1\n * #2501).** The old vocabulary mixed two orthogonal axes — `'allow'` /\n * `'block'` (a Decision) and `'log'` (an EnforcementMode). The new\n * vocabulary separates them:\n *\n * - **Decision** (the engine's verdict): one of\n * `'permit' | 'block' | 'redirect' | 'challenge' | 'instruct'`.\n * - **EnforcementMode** (whether the host wrapper acts on the verdict):\n * one of `'enforce' | 'observe'` — see ENFORCEMENT_MODES below.\n *\n * `ALLOW` is kept as an alias for `PERMIT` during the cutover window\n * (per [[checkpoint-engine-phase-1-cutover]] runbook Cutover-2 — drop\n * after 30 days of zero `'allow'` writes). `LOG` is kept similarly —\n * a stored `'log'` row should be read as Permit + Observe mode.\n *\n * Producers (SDK middleware, gateway worker) emit `'permit'` going\n * forward. Consumers (dashboard, ingest validators) accept both during\n * the alias period and alias `'allow'` → display \"Permit\".\n */\nexport const ENFORCEMENT_ACTIONS = {\n /** New canonical name for \"the engine permits this request through.\" */\n PERMIT: 'permit',\n /**\n * @deprecated Use PERMIT. Kept as wire alias for the Vocab-1\n * cutover window. Drop after 30 days of zero stored writes.\n */\n ALLOW: 'allow',\n BLOCK: 'block',\n REDIRECT: 'redirect',\n CHALLENGE: 'challenge',\n /**\n * @deprecated Pre-Vocab-1: a stored `'log'` action was \"permit but\n * record.\" Post-Vocab-1: the same shape is `action: 'permit'` +\n * `mode: 'observe'` (orthogonal axes). Kept for read-back only;\n * producers should not emit `'log'` after Vocab-1 lands.\n */\n LOG: 'log',\n INSTRUCT: 'instruct',\n} as const;\n\nexport type EnforcementAction = (typeof ENFORCEMENT_ACTIONS)[keyof typeof ENFORCEMENT_ACTIONS];\n\n/**\n * EnforcementMode — orthogonal to EnforcementAction.\n *\n * Vocab-1 (2026-05-13) split \"what to do\" (the action / Decision) from\n * \"whether to act on it\" (the mode). Customers — especially regulated\n * enterprises — want a low-stakes evaluation ramp: install in Observe,\n * watch the dashboard for two weeks to see what *would have been*\n * blocked, then flip to Enforce. CISO-friendly.\n *\n * The host wrapper (Express middleware, Next.js middleware, .NET\n * filter, Cloudflare Worker) reads the mode and:\n *\n * - **Enforce**: applies the Decision — returns 401/403 for Block,\n * forwards Challenge headers, performs Redirect, etc.\n * - **Observe**: passes the request through to the origin regardless\n * of Decision, but records the would-have-been action in metadata\n * so the dashboard can render \"Would have been: Block(OutOfScope)\"\n * instead of \"Block(OutOfScope)\". Dash-1 (#2492) acceptance\n * criterion mandates this rendering distinction.\n */\nexport const ENFORCEMENT_MODES = {\n ENFORCE: 'enforce',\n OBSERVE: 'observe',\n} as const;\n\nexport type EnforcementMode = (typeof ENFORCEMENT_MODES)[keyof typeof ENFORCEMENT_MODES];\n\n/**\n * Condition operators for policy rules\n */\nexport const CONDITION_OPERATORS = {\n EQUALS: 'equals',\n NOT_EQUALS: 'notEquals',\n CONTAINS: 'contains',\n NOT_CONTAINS: 'notContains',\n STARTS_WITH: 'startsWith',\n ENDS_WITH: 'endsWith',\n GREATER_THAN: 'greaterThan',\n LESS_THAN: 'lessThan',\n GREATER_THAN_OR_EQUALS: 'greaterThanOrEquals',\n LESS_THAN_OR_EQUALS: 'lessThanOrEquals',\n MATCHES: 'matches',\n IN: 'in',\n NOT_IN: 'notIn',\n} as const;\n\nexport type ConditionOperator = (typeof CONDITION_OPERATORS)[keyof typeof CONDITION_OPERATORS];\n\n/**\n * Fields that can be matched in policy conditions\n */\nexport const CONDITION_FIELDS = {\n // Agent identification\n AGENT_TYPE: 'agentType',\n AGENT_NAME: 'agentName',\n AGENT_VENDOR: 'agentVendor',\n CLIENT_DID: 'clientDid',\n AGENT_DID: 'agentDid',\n // Detection metrics\n CONFIDENCE: 'confidence',\n REPUTATION_SCORE: 'reputationScore',\n RISK_LEVEL: 'riskLevel',\n // Request context\n PATH: 'path',\n METHOD: 'method',\n ORIGIN: 'origin',\n USER_AGENT: 'userAgent',\n // Verification status\n SIGNATURE_VERIFIED: 'signatureVerified',\n IS_AUTHENTICATED: 'isAuthenticated',\n HAS_VALID_DELEGATION: 'hasValidDelegation',\n} as const;\n\nexport type ConditionField = (typeof CONDITION_FIELDS)[keyof typeof CONDITION_FIELDS];\n\n/**\n * Default threshold configuration\n */\nexport const DEFAULT_THRESHOLDS = {\n confidenceThreshold: 80,\n confidenceAction: ENFORCEMENT_ACTIONS.BLOCK,\n minReputationScore: 0,\n lowReputationAction: ENFORCEMENT_ACTIONS.CHALLENGE,\n trustedReputationThreshold: 90,\n trustSignedRequests: true,\n} as const;\n\n/**\n * Default policy configuration\n */\nexport const DEFAULT_POLICY = {\n version: '1.0.0',\n enabled: true,\n // Vocab-1 (#2501): canonical default is PERMIT. ALLOW is still accepted on\n // the wire via the alias schema for stored rows, but new defaults emit the\n // canonical form so DEFAULT_POLICY and PolicyConfigSchema's default agree.\n defaultAction: ENFORCEMENT_ACTIONS.PERMIT,\n thresholds: DEFAULT_THRESHOLDS,\n denyList: [],\n allowList: [],\n rules: [],\n excludedPaths: [],\n} as const;\n\n/**\n * Default rule priority (lower = higher priority)\n */\nexport const DEFAULT_RULE_PRIORITY = 100;\n\n/**\n * Cache TTL values (in seconds)\n */\nexport const CACHE_TTL = {\n POLICY: 300, // 5 minutes\n API_KEY: 900, // 15 minutes\n} as const;\n\n/**\n * Policy version for schema migrations\n */\nexport const CURRENT_POLICY_VERSION = '1.0.0';\n","/**\n * Policy Zod Schemas\n *\n * Runtime validation schemas for policy configuration.\n * Aligned with Rust types in agentshield-types/src/policy.rs\n */\n\nimport { z } from 'zod';\nimport {\n ENFORCEMENT_ACTIONS,\n ENFORCEMENT_MODES,\n CONDITION_OPERATORS,\n CONDITION_FIELDS,\n DEFAULT_THRESHOLDS,\n DEFAULT_RULE_PRIORITY,\n CURRENT_POLICY_VERSION,\n} from './constants';\n\n// ============================================================================\n// Enforcement Actions + Mode (Vocab-1, 2026-05-13)\n// ============================================================================\n//\n// EnforcementActionSchema is in the alias-period of the Vocab-1\n// migration (#2501). The wire accepts both `'allow'` (legacy) and\n// `'permit'` (new canonical); the dashboard read-side displays both\n// as \"Permit.\" Producers (SDK, worker) emit `'permit'` going forward.\n// `'log'` is similarly accepted for read-back of legacy rows but\n// producers should emit `'permit'` + `EnforcementMode = 'observe'`\n// instead — those are orthogonal axes now.\n//\n// Drop the alias after 30 consecutive days of zero stored `'allow'`\n// or `'log'` writes (verify SQL in Cutover-2 runbook).\n\nexport const EnforcementActionSchema = z.enum([\n // New canonical:\n ENFORCEMENT_ACTIONS.PERMIT,\n ENFORCEMENT_ACTIONS.BLOCK,\n ENFORCEMENT_ACTIONS.REDIRECT,\n ENFORCEMENT_ACTIONS.CHALLENGE,\n ENFORCEMENT_ACTIONS.INSTRUCT,\n // Alias-period (deprecated; will be removed post-cutover):\n ENFORCEMENT_ACTIONS.ALLOW,\n ENFORCEMENT_ACTIONS.LOG,\n]);\n\n/**\n * EnforcementMode — orthogonal to EnforcementAction. See\n * `ENFORCEMENT_MODES` in constants.ts for the full rationale.\n */\nexport const EnforcementModeSchema = z.enum([ENFORCEMENT_MODES.ENFORCE, ENFORCEMENT_MODES.OBSERVE]);\n\nexport type EnforcementMode = z.infer<typeof EnforcementModeSchema>;\n\n// ============================================================================\n// Decision schemas (Vocab-1) — TS mirror of the Rust `Decision` enum\n// defined by D-design (#2484). The engine doesn't emit these on the\n// TS side yet (it's the Rust engine's output); these schemas exist so\n// the dashboard ingest can validate them once the engine ships, and\n// so dashboard rendering code can derive its types from the canonical\n// shape rather than hand-paste a union. See [[ADR-001]] amendment +\n// TDD Spec Layer 1.\n// ============================================================================\n\n/**\n * Block reasons — priority order (Rust declaration order): Revoked >\n * InvalidSignature > Unauthenticated > Expired > OutOfScope >\n * LowReputation > PolicyDenied > AgentAttribution > ParseError >\n * Tier3UAMatch. The engine returns the most-actionable reason; this\n * schema accepts any of them. See TDD Spec Layer 1 for the priority\n * rules and `rust/crates/kya-os-engine/src/types.rs` for the wire SSOT.\n */\nexport const BlockReasonSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('Revoked') }),\n z.object({ kind: z.literal('InvalidSignature') }),\n z.object({ kind: z.literal('Unauthenticated') }),\n z.object({ kind: z.literal('Expired') }),\n z.object({\n kind: z.literal('OutOfScope'),\n requested: z.string(),\n granted: z.array(z.string()),\n }),\n z.object({\n kind: z.literal('LowReputation'),\n score: z.number(),\n threshold: z.number(),\n }),\n z.object({\n kind: z.literal('PolicyDenied'),\n detail: z.string(),\n // #3272 PR2: the determining policy's authored Cedar @id (the policies\n // index join key). Optional + additive — absent on pre-PR2 payloads.\n policyId: z.string().optional(),\n }),\n z.object({\n // Tier-2 IP+UA cross-match against the vendor SSOT (AIVF-1 Path B).\n // Emitted when the request carries both a vendor-published IP and a\n // matching UA pattern. `confidence` is f32 in [0, 1] — NOT the 0-100\n // scale the rest of the detection detail uses.\n kind: z.literal('AgentAttribution'),\n vendor: z.string(),\n tier: z.number().int(),\n confidence: z.number().min(0).max(1),\n }),\n z.object({ kind: z.literal('ParseError'), detail: z.string() }),\n z.object({\n // Tier-3 UA-only pattern-match short-circuit (engine default policy).\n // Field names are snake_case ON THE WIRE (the Rust enum has no\n // `rename_all`) and mirror the Rust struct fields verbatim.\n // `pattern_kind` is `KnownAiAgent` | `AiCrawler` | `HeadlessBrowser`\n // today; kept a loose string so future engine kinds stay additive.\n // `confidence` is an integer percent (0-100), unlike AgentAttribution.\n kind: z.literal('Tier3UAMatch'),\n pattern_id: z.string(),\n pattern_kind: z.string(),\n confidence: z.number().int().min(0).max(100),\n }),\n]);\n\nexport type BlockReason = z.infer<typeof BlockReasonSchema>;\n\n/**\n * The draft-kya-http-02 §1 assurance ladder, monotone floor → top. These are\n * the exact wire strings the merged kya-http fixtures pin\n * (`packages/checkpoint-shared/fixtures/kya-http`, e.g. `min_assurance`); the\n * Rust engine emits them on the verdict and reads them as `context.assurance`.\n * Canonical SSOT for the assurance tier / `min_assurance` enum.\n */\nexport const AssuranceTierSchema = z.enum([\n 'anonymous',\n 'attested-bearer',\n 'key-bound',\n 'registered',\n 'delegated',\n]);\n\n/** One draft-kya-http-02 §1 assurance tier. See {@link AssuranceTierSchema}. */\nexport type AssuranceTier = z.infer<typeof AssuranceTierSchema>;\n\n/**\n * ChallengeParams MUST be the KYA-OS L2+ handshake envelope shape, not\n * a parallel Checkpoint definition. Reusing the spec donated to DIF\n * gives every KYA-OS implementer free interop with Checkpoint's\n * Challenge flow. See [[ADR-001]] amendment.\n */\nexport const ChallengeParamsSchema = z.object({\n nonce: z.string(),\n audience: z.string(),\n expiresAt: z.number(), // unix seconds\n algorithmsAccepted: z.array(z.string()),\n // draft-kya-http-02 §1/§8 — the minimum assurance tier the policy demands\n // of the retry, set by a Cedar `@min_assurance(...)` annotation and\n // advertised by the PEP as `min_assurance` in the WWW-Authenticate\n // Delegation challenge. Optional + additive: absent for KYA-OS L2+ handshake\n // challenges, so the DIF interop shape is unchanged when unset.\n minAssurance: AssuranceTierSchema.optional(),\n // #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.\n policyId: z.string().optional(),\n // Which handshake this challenge demands, set by a Cedar\n // `@challenge_type(...)` annotation. Kept a loose string (like\n // `Tier3UAMatch.pattern_kind` above) rather than a strict `z.enum` so a\n // FUTURE engine-added kind an older deployed dashboard doesn't know yet\n // stays additive instead of failing validation. Absent means\n // `'delegation'` — the pre-existing MCP-I Level 2+ handshake — and every\n // renderer MUST treat an unrecognized value the same way. See\n // `normalizeChallengeType`.\n challengeType: z.string().optional(),\n});\n\nexport type ChallengeParams = z.infer<typeof ChallengeParamsSchema>;\n\nexport { normalizeChallengeType } from './challenge-type';\n\nexport const RedirectTargetSchema = z.object({\n url: z.string().url(),\n reason: z.string(),\n state: z.string().optional(),\n // #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.\n policyId: z.string().optional(),\n});\n\nexport type RedirectTarget = z.infer<typeof RedirectTargetSchema>;\n\nexport const SuggestedActionSchema = z.discriminatedUnion('kind', [\n z.object({ kind: z.literal('UseDifferentScope'), scope: z.string() }),\n z.object({\n kind: z.literal('UpdateRequestField'),\n field: z.string(),\n acceptedValues: z.array(z.string()),\n }),\n z.object({ kind: z.literal('UpgradeProtocolVersion'), version: z.string() }),\n z.object({ kind: z.literal('Other'), code: z.string(), detail: z.string() }),\n]);\n\nexport type SuggestedAction = z.infer<typeof SuggestedActionSchema>;\n\nexport const InstructPayloadSchema = z.object({\n problem: z.string(),\n title: z.string(),\n suggestedActions: z.array(SuggestedActionSchema),\n // #3272 PR2: the determining policy's authored Cedar @id. Optional + additive.\n policyId: z.string().optional(),\n});\n\nexport type InstructPayload = z.infer<typeof InstructPayloadSchema>;\n\n/**\n * Decision — the Detect → Verify → **Decide** axis. Five variants\n * with per-variant payload via discriminated union. Mirrors the Rust\n * `Decision` enum (D-design #2484); the dashboard renders one badge\n * per variant (see Dash-1 #2492). The wire-side EnforcementAction\n * string above is the legacy flat encoding; this is the canonical\n * structured replacement.\n */\nexport const DecisionSchema = z.discriminatedUnion('kind', [\n // #3272 PR2: optional policyId = the authored Cedar @id of the determining\n // permit policy (\"which rule admitted this\"). Absent on pre-PR2 payloads and\n // non-policy-determined permits.\n z.object({ kind: z.literal('Permit'), policyId: z.string().optional() }),\n z.object({ kind: z.literal('Block'), reason: BlockReasonSchema }),\n z.object({ kind: z.literal('Challenge'), params: ChallengeParamsSchema }),\n z.object({ kind: z.literal('Redirect'), target: RedirectTargetSchema }),\n z.object({ kind: z.literal('Instruct'), payload: InstructPayloadSchema }),\n]);\n\nexport type Decision = z.infer<typeof DecisionSchema>;\n\n// ============================================================================\n// Threshold Configuration\n// ============================================================================\n\nexport const ThresholdConfigSchema = z.object({\n /** Detection confidence threshold (0-100) */\n confidenceThreshold: z.number().min(0).max(100).default(DEFAULT_THRESHOLDS.confidenceThreshold),\n /** Action to take when confidence threshold is exceeded */\n confidenceAction: EnforcementActionSchema.default(DEFAULT_THRESHOLDS.confidenceAction),\n /** Minimum reputation score (0-100) required to allow access */\n minReputationScore: z.number().min(0).max(100).default(DEFAULT_THRESHOLDS.minReputationScore),\n /** Action to take when reputation is below threshold */\n lowReputationAction: EnforcementActionSchema.default(DEFAULT_THRESHOLDS.lowReputationAction),\n /** High reputation score threshold (0-100) - trusted agents bypass other checks */\n trustedReputationThreshold: z\n .number()\n .min(0)\n .max(100)\n .default(DEFAULT_THRESHOLDS.trustedReputationThreshold),\n /** Whether cryptographically signed requests bypass thresholds */\n trustSignedRequests: z.boolean().default(DEFAULT_THRESHOLDS.trustSignedRequests),\n});\n\n// ============================================================================\n// List Entries\n// ============================================================================\n\nexport const DenyListEntrySchema = z.object({\n /** KYA-OS client DID */\n clientDid: z.string().optional(),\n /** Agent DID from KYA-OS identity */\n agentDid: z.string().optional(),\n /** Human-readable client name (e.g., \"ChatGPT\") */\n clientName: z.string().optional(),\n /** Agent type to block (e.g., \"ai_agent\", \"bot\") */\n agentType: z.string().optional(),\n /** Reason for denial */\n reason: z.string().optional(),\n /** ISO 8601 timestamp when entry was added */\n blockedAt: z.string().optional(),\n /** Who added this entry */\n addedBy: z.string().optional(),\n /** Whether this entry is currently active */\n active: z.boolean().default(true),\n /** Optional expiration date for temporary blocks */\n expiresAt: z.string().optional(),\n});\n\nexport const AllowListEntrySchema = z.object({\n /** KYA-OS client DID */\n clientDid: z.string().optional(),\n /** Agent DID from KYA-OS identity */\n agentDid: z.string().optional(),\n /** Human-readable client name */\n clientName: z.string().optional(),\n /** Agent type to allow */\n agentType: z.string().optional(),\n /** Reason for allowing */\n reason: z.string().optional(),\n /** ISO 8601 timestamp when entry was added */\n addedAt: z.string().optional(),\n /** Who added this entry */\n addedBy: z.string().optional(),\n});\n\n// ============================================================================\n// Policy Conditions\n// ============================================================================\n\nexport const ConditionOperatorSchema = z.enum([\n CONDITION_OPERATORS.EQUALS,\n CONDITION_OPERATORS.NOT_EQUALS,\n CONDITION_OPERATORS.CONTAINS,\n CONDITION_OPERATORS.NOT_CONTAINS,\n CONDITION_OPERATORS.STARTS_WITH,\n CONDITION_OPERATORS.ENDS_WITH,\n CONDITION_OPERATORS.GREATER_THAN,\n CONDITION_OPERATORS.LESS_THAN,\n CONDITION_OPERATORS.GREATER_THAN_OR_EQUALS,\n CONDITION_OPERATORS.LESS_THAN_OR_EQUALS,\n CONDITION_OPERATORS.MATCHES,\n CONDITION_OPERATORS.IN,\n CONDITION_OPERATORS.NOT_IN,\n]);\n\nexport const ConditionFieldSchema = z.enum([\n // Agent identification\n CONDITION_FIELDS.AGENT_TYPE,\n CONDITION_FIELDS.AGENT_NAME,\n CONDITION_FIELDS.AGENT_VENDOR,\n CONDITION_FIELDS.CLIENT_DID,\n CONDITION_FIELDS.AGENT_DID,\n // Detection metrics\n CONDITION_FIELDS.CONFIDENCE,\n CONDITION_FIELDS.REPUTATION_SCORE,\n CONDITION_FIELDS.RISK_LEVEL,\n // Request context\n CONDITION_FIELDS.PATH,\n CONDITION_FIELDS.METHOD,\n CONDITION_FIELDS.ORIGIN,\n CONDITION_FIELDS.USER_AGENT,\n // Verification status\n CONDITION_FIELDS.SIGNATURE_VERIFIED,\n CONDITION_FIELDS.IS_AUTHENTICATED,\n CONDITION_FIELDS.HAS_VALID_DELEGATION,\n]);\n\nexport const ConditionValueSchema = z.union([\n z.string(),\n z.number(),\n z.boolean(),\n z.array(z.string()),\n]);\n\nexport const PolicyConditionSchema = z.object({\n /** Field to match against */\n field: ConditionFieldSchema,\n /** Comparison operator */\n operator: ConditionOperatorSchema,\n /** Value to compare against */\n value: ConditionValueSchema,\n /** Whether this condition is case-insensitive */\n caseInsensitive: z.boolean().optional(),\n});\n\n// ============================================================================\n// Policy Rules\n// ============================================================================\n\nexport const RuleMetadataSchema = z.object({\n createdAt: z.string().optional(),\n updatedAt: z.string().optional(),\n createdBy: z.string().optional(),\n});\n\nexport const PolicyRuleSchema = z.object({\n /** Unique identifier for this rule */\n id: z.string(),\n /** Human-readable name */\n name: z.string(),\n /** Description of what this rule does */\n description: z.string().optional(),\n /** Priority (lower = higher priority, evaluated first) */\n priority: z.number().int().default(DEFAULT_RULE_PRIORITY),\n /** Conditions that must ALL match for this rule to apply (AND logic) */\n conditions: z.array(PolicyConditionSchema),\n /** Action to take when conditions match */\n action: EnforcementActionSchema,\n /** Redirect URL (required if action is 'redirect') */\n redirectUrl: z.string().url().optional(),\n /** Custom message to show/log */\n message: z.string().optional(),\n /** Whether this rule is currently active */\n enabled: z.boolean().default(true),\n /** Metadata for auditing */\n metadata: RuleMetadataSchema.optional(),\n});\n\n// ============================================================================\n// Policy Configuration\n// ============================================================================\n\nexport const PolicyMetadataSchema = z.object({\n lastUpdated: z.string().optional(),\n updatedBy: z.string().optional(),\n policyId: z.string().optional(),\n});\n\nexport const PolicyConfigSchema = z.object({\n /** Schema version for migrations */\n version: z.string().default(CURRENT_POLICY_VERSION),\n /** Whether policy enforcement is enabled */\n enabled: z.boolean().default(true),\n /** Default action when no rules match. Updated to PERMIT (was ALLOW)\n * per Vocab-1 (#2501); the wire still accepts both via the alias\n * schema so existing stored policies continue to load. */\n defaultAction: EnforcementActionSchema.default(ENFORCEMENT_ACTIONS.PERMIT),\n /** Default redirect URL for redirect actions */\n redirectUrl: z.string().url().optional(),\n /** Threshold-based enforcement settings */\n // prefault, not default: Zod 4 returns a default value as is, so `{}` would skip the\n // per-field defaults inside ThresholdConfigSchema. prefault parses it, as Zod 3 did.\n thresholds: ThresholdConfigSchema.prefault({}),\n /** Deny list entries (checked after allow list, before rules) */\n denyList: z.array(DenyListEntrySchema).default([]),\n /** Allow list entries (exempt from all checks) */\n allowList: z.array(AllowListEntrySchema).default([]),\n /** Custom policy rules (evaluated by priority after threshold checks) */\n rules: z.array(PolicyRuleSchema).default([]),\n /** Paths to exclude from policy enforcement (glob patterns supported) */\n excludedPaths: z.array(z.string()).default([]),\n /** Paths to include (if set, only these paths are enforced) */\n includedPaths: z.array(z.string()).optional(),\n /** Metadata for the policy configuration */\n metadata: PolicyMetadataSchema.optional(),\n\n // ── Composed-policy (kya-os-engine) fields ──────────────────────────────\n // The policy API (`/api/internal/policies/[projectId]`) serves these so a\n // runtime that embeds the engine's Cedar evaluator can enforce the composed\n // `/policy-compose` output — identically to the DNS gateway worker — instead\n // of (or alongside) the structured fields above. They are carried through the\n // fetch contract here so the middleware (Express / Next.js / .NET) receives\n // them; runtimes that don't run the engine simply ignore them. Optional +\n // safe defaults: a policy without a composed bundle is unaffected.\n\n /**\n * Composed policy source (Cedar today). `null`/absent → no composed policy\n * (the runtime uses the structured fields). Empty/blank is treated as \"no\n * policy\" by the engine path (an empty bundle compiles to deny-all), so the\n * runtime MUST normalize blank → absent before handing it to the evaluator.\n */\n policySourceText: z.string().nullish(),\n /**\n * Language of `policySourceText`. `cedar` today; kept as a free string (not an\n * enum) so a future Rego/OPA bundle flows through the same contract without a\n * schema-version bump. A runtime enforces only languages it actually embeds.\n */\n policyLanguage: z.string().nullish(),\n /**\n * Hex sha256 of `policySourceText` as served by the SSOT — byte-identical to\n * `policy_revisions.composed_blob_hash` (#3246 PR5). Runtimes ECHO it onto\n * acted decisions (`enforcement.composedBlobHash`) and Delegation challenges\n * (`challenge.composed_blob_hash`) as the point-in-time revision pin; they\n * never hash locally. Absent/null → plane omits the pin (older dashboards).\n */\n policySourceHash: z.string().nullish(),\n /**\n * Whether the engine should ACT on the composed policy (deployed-to-enforce).\n * False → the composed policy is at most shadow-evaluated; the structured\n * path / bespoke decision governs. Mirrors the gateway worker's act-gate\n * (`engineEnforcementEnabled === true && enabled !== false`).\n */\n engineEnforcementEnabled: z.boolean().optional().default(false),\n\n /**\n * Trusted Layer-2 delegation root DIDs for the project's org (P2 / DR-1),\n * server-resolved by the policy API. A consuming middleware forwards these\n * into the engine's `ContextSpec.trustedDelegationRoots` so L2 delegation\n * chains are pinned to the org DID. Absent ⇒ omitted, and the engine rejects\n * delegation. Optional (no default)\n * so a policy without the field round-trips as `undefined`, matching the\n * policy API's `PolicyResponse` shape and the orchestrator's omit-when-unset\n * contract.\n */\n trustedDelegationRoots: z.array(z.string()).optional(),\n\n /**\n * The org's one OAuth authorization server issuer (RFC 8414 `issuer`), as the\n * platform's IssuerContext computes it (`https://<branded host or platform>/oauth/<slug>`).\n * A middleware that serves protected resource metadata advertises exactly\n * this in `authorization_servers` and never builds an issuer URL itself.\n * Absent ⇒ the platform could not resolve the org; serve no metadata.\n */\n authorizationServerIssuer: z.string().url().optional(),\n});\n\n// ============================================================================\n// Type Exports\n// ============================================================================\n\nexport type EnforcementAction = z.infer<typeof EnforcementActionSchema>;\nexport type ThresholdConfig = z.infer<typeof ThresholdConfigSchema>;\nexport type DenyListEntry = z.infer<typeof DenyListEntrySchema>;\nexport type AllowListEntry = z.infer<typeof AllowListEntrySchema>;\nexport type ConditionOperator = z.infer<typeof ConditionOperatorSchema>;\nexport type ConditionField = z.infer<typeof ConditionFieldSchema>;\nexport type ConditionValue = z.infer<typeof ConditionValueSchema>;\nexport type PolicyCondition = z.infer<typeof PolicyConditionSchema>;\nexport type RuleMetadata = z.infer<typeof RuleMetadataSchema>;\nexport type PolicyRule = z.infer<typeof PolicyRuleSchema>;\nexport type PolicyMetadata = z.infer<typeof PolicyMetadataSchema>;\nexport type PolicyConfig = z.infer<typeof PolicyConfigSchema>;\n\nexport { isEngineEnforcing } from './engine-enforcing';\n\n// ============================================================================\n// Validation Helpers\n// ============================================================================\n\n/**\n * Safely parse a policy configuration (returns null on error)\n */\nexport function safeParsePolicyConfig(data: unknown): PolicyConfig | null {\n const result = PolicyConfigSchema.safeParse(data);\n return result.success ? result.data : null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,sBAAs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params) {
3643
3643
  });
3644
3644
  }
3645
3645
  // @__NO_SIDE_EFFECTS__
3646
- function _custom(Class, fn, _params) {
3647
- const norm = normalizeParams(_params);
3648
- norm.abort ?? (norm.abort = true);
3649
- return new Class({
3650
- type: "custom",
3651
- check: "custom",
3652
- fn,
3653
- ...norm
3654
- });
3655
- }
3656
- // @__NO_SIDE_EFFECTS__
3657
3646
  function _refine(Class, fn, _params) {
3658
3647
  return new Class({
3659
3648
  type: "custom",
@@ -5523,9 +5512,6 @@ const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
5523
5512
  ZodType.init(inst, def);
5524
5513
  inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
5525
5514
  });
5526
- function custom(fn, _params) {
5527
- return _custom(ZodCustom, fn ?? (() => true), _params);
5528
- }
5529
5515
  function refine(fn, _params = {}) {
5530
5516
  return _refine(ZodCustom, fn, _params);
5531
5517
  }
@@ -5554,5 +5540,5 @@ function _instanceof(cls, params = {}) {
5554
5540
  }
5555
5541
 
5556
5542
  //#endregion
5557
- export { NEVER as A, string as C, _coercedBoolean as D, ZodError as E, _coercedDate as O, strictObject as S, unknown as T, never as _, _instanceof as a, partialRecord as b, array as c, date as d, discriminatedUnion as f, literal as g, ipv6 as h, _enum as i, _coercedNumber as k, boolean as l, ipv4 as m, ZodDate as n, _null as o, guid as p, ZodNumber as r, any as s, ZodBoolean as t, custom as u, number as v, union as w, record as x, object as y };
5558
- //# sourceMappingURL=schemas-7qodsG-Z.mjs.map
5543
+ export { union as C, _coercedDate as D, _coercedBoolean as E, _coercedNumber as O, string as S, ZodError as T, number as _, _instanceof as a, record as b, array as c, discriminatedUnion as d, guid as f, never as g, literal as h, _enum as i, NEVER as k, boolean as l, ipv6 as m, ZodDate as n, _null as o, ipv4 as p, ZodNumber as r, any as s, ZodBoolean as t, date as u, object as v, unknown as w, strictObject as x, partialRecord as y };
5544
+ //# sourceMappingURL=schemas-IHAhH3gV.mjs.map