@kya-os/checkpoint-wasm-runtime 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/dist/adapters.d.mts +257 -0
  3. package/dist/adapters.d.ts +257 -0
  4. package/dist/adapters.js +603 -0
  5. package/dist/adapters.js.map +1 -0
  6. package/dist/adapters.mjs +586 -0
  7. package/dist/adapters.mjs.map +1 -0
  8. package/dist/dynamic-loader-cS-pUisw.d.ts +65 -0
  9. package/dist/dynamic-loader-qGJacfEC.d.mts +65 -0
  10. package/dist/edge.d.mts +22 -0
  11. package/dist/edge.d.ts +22 -0
  12. package/dist/edge.js +1403 -0
  13. package/dist/edge.js.map +1 -0
  14. package/dist/edge.mjs +1391 -0
  15. package/dist/edge.mjs.map +1 -0
  16. package/dist/engine-edge.d.mts +58 -0
  17. package/dist/engine-edge.d.ts +58 -0
  18. package/dist/engine-edge.js +537 -0
  19. package/dist/engine-edge.js.map +1 -0
  20. package/dist/engine-edge.mjs +533 -0
  21. package/dist/engine-edge.mjs.map +1 -0
  22. package/dist/engine.d.mts +34 -0
  23. package/dist/engine.d.ts +34 -0
  24. package/dist/engine.js +11 -0
  25. package/dist/engine.js.map +1 -0
  26. package/dist/engine.mjs +9 -0
  27. package/dist/engine.mjs.map +1 -0
  28. package/dist/index.d.mts +58 -0
  29. package/dist/index.d.ts +58 -0
  30. package/dist/index.js +1652 -0
  31. package/dist/index.js.map +1 -0
  32. package/dist/index.mjs +1637 -0
  33. package/dist/index.mjs.map +1 -0
  34. package/dist/node.d.mts +26 -0
  35. package/dist/node.d.ts +26 -0
  36. package/dist/node.js +972 -0
  37. package/dist/node.js.map +1 -0
  38. package/dist/node.mjs +960 -0
  39. package/dist/node.mjs.map +1 -0
  40. package/dist/orchestrator-edge.d.mts +243 -0
  41. package/dist/orchestrator-edge.d.ts +243 -0
  42. package/dist/orchestrator-edge.js +1076 -0
  43. package/dist/orchestrator-edge.js.map +1 -0
  44. package/dist/orchestrator-edge.mjs +1065 -0
  45. package/dist/orchestrator-edge.mjs.map +1 -0
  46. package/dist/orchestrator.d.mts +50 -0
  47. package/dist/orchestrator.d.ts +50 -0
  48. package/dist/orchestrator.js +1185 -0
  49. package/dist/orchestrator.js.map +1 -0
  50. package/dist/orchestrator.mjs +1172 -0
  51. package/dist/orchestrator.mjs.map +1 -0
  52. package/dist/rules-detector-DjbTJ1-Q.d.mts +470 -0
  53. package/dist/rules-detector-DjbTJ1-Q.d.ts +470 -0
  54. package/dist/static-loader-C1hUlksK.d.ts +72 -0
  55. package/dist/static-loader-Ds4iNw7c.d.mts +72 -0
  56. package/dist/types-D0j85fF0.d.mts +163 -0
  57. package/dist/types-D0j85fF0.d.ts +163 -0
  58. package/package.json +141 -0
  59. package/wasm/agentshield_wasm.d.ts +485 -0
  60. package/wasm/agentshield_wasm.js +1551 -0
  61. package/wasm/agentshield_wasm_bg.wasm +0 -0
  62. package/wasm/agentshield_wasm_bg.wasm.d.ts +97 -0
  63. package/wasm/kya-os-engine/kya_os_engine.d.ts +24 -0
  64. package/wasm/kya-os-engine/kya_os_engine.js +517 -0
  65. package/wasm/kya-os-engine/kya_os_engine_bg.wasm +0 -0
  66. package/wasm/kya-os-engine/kya_os_engine_bg.wasm.d.ts +8 -0
  67. package/wasm/kya-os-engine-web/kya_os_engine.d.ts +56 -0
  68. package/wasm/kya-os-engine-web/kya_os_engine.js +574 -0
  69. package/wasm/kya-os-engine-web/kya_os_engine_bg.wasm +0 -0
  70. package/wasm/kya-os-engine-web/kya_os_engine_bg.wasm.d.ts +8 -0
  71. package/wasm/package.json +30 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,58 @@
1
+ # @kya-os/checkpoint-wasm-runtime
2
+
3
+ ## 1.0.0 — 2026-05-15
4
+
5
+ E-tracks Phase D — package rename + orchestrator edge variant. **BREAKING.**
6
+
7
+ ### BREAKING CHANGES
8
+
9
+ - **Package renamed** from `@kya-os/agentshield-wasm-runtime` to
10
+ `@kya-os/checkpoint-wasm-runtime` per architect Q1 + Rename-2 (#2483).
11
+ 0-day hard cutover; the legacy `@kya-os/agentshield-wasm-runtime@0.1.6`
12
+ is published with npm's `deprecated` field pointing here. Migrate by
13
+ swapping the import path:
14
+ `from '@kya-os/agentshield-wasm-runtime'` → `from '@kya-os/checkpoint-wasm-runtime'`.
15
+
16
+ ### Added (Edge-WASM-2 folded into Phase D)
17
+
18
+ - `./orchestrator/edge` subpath — async-init equivalent of `./orchestrator`
19
+ for Vercel Edge / Cloudflare Workers / browser embedding. Mirrors the
20
+ Node orchestrator surface (`verifyRequestEdge`, `initEngineEdge`) and
21
+ consumes the Edge-WASM-1 `engineVerifyEdge` engine bridge.
22
+ - `edge-runtime` + `browser` conditions on the `./orchestrator` subpath —
23
+ bundlers targeting edge runtimes automatically route to the async-init
24
+ variant without an explicit subpath.
25
+ - `./adapters` subpath barrel — re-exports the 5 DI adapters
26
+ (DidResolver, StatusListCache, ReputationOracle, PolicyEvaluator, Clock)
27
+ for Phase D / E host wrappers.
28
+
29
+ ### Migration
30
+
31
+ ```diff
32
+ - "@kya-os/agentshield-wasm-runtime": "^0.1.6"
33
+ + "@kya-os/checkpoint-wasm-runtime": "^1.0.0"
34
+ ```
35
+
36
+ ```diff
37
+ - import { verifyRequest } from '@kya-os/agentshield-wasm-runtime/orchestrator';
38
+ + import { verifyRequest } from '@kya-os/checkpoint-wasm-runtime/orchestrator';
39
+ ```
40
+
41
+ For edge runtimes:
42
+
43
+ ```ts
44
+ import {
45
+ verifyRequestEdge,
46
+ initEngineEdge,
47
+ } from '@kya-os/checkpoint-wasm-runtime/orchestrator/edge';
48
+ ```
49
+
50
+ No other API changes. All Phase A/B/C exports — `engineVerify`,
51
+ `engineVerifyEdge`, 5 DI adapters, `verifyRequest`,
52
+ `renderDecisionAsResponse`, types — preserved under the new package name.
53
+
54
+ ## 0.1.6 — 2026-05-15
55
+
56
+ Edge-WASM-1 — `--target web` build of `kya-os-engine` shipped alongside
57
+ the Node target. See `@kya-os/agentshield-wasm-runtime` (legacy name)
58
+ git history for prior phases.
@@ -0,0 +1,257 @@
1
+ import { d as DidDocument, D as Decision } from './types-D0j85fF0.mjs';
2
+ import '@kya-os/checkpoint-shared';
3
+
4
+ /**
5
+ * DidResolver adapter — sub-phase B.1.
6
+ *
7
+ * Resolves `did:key:*` (in-memory multibase decode) and `did:web:*`
8
+ * (HTTPS fetch of `.well-known/did.json`) into the engine's
9
+ * `DidDocument` shape. The async half does any required I/O; the
10
+ * adapter's output is plain data that the host wrapper bundles into
11
+ * `ContextSpec.didDocs` before calling `engineVerify`.
12
+ *
13
+ * Phase 1 supports only Ed25519 verification methods (the engine's
14
+ * `KeyType` is `#[non_exhaustive]` with `Ed25519` as its single
15
+ * variant). Non-Ed25519 methods on a resolved doc are silently
16
+ * filtered out — the engine wouldn't accept them as a valid Stage 2
17
+ * key match anyway.
18
+ *
19
+ * **`kid` for `did:key`**: the verification-method id is
20
+ * `<did>#<multibase>` per mcp-i-core PR #16. **NOT** `<did>#keys-1`.
21
+ * H-1's `stage2_did_key_fragment_resolution` test pins this.
22
+ */
23
+
24
+ declare class MalformedDid extends Error {
25
+ readonly kind = "MalformedDid";
26
+ }
27
+ declare class UnsupportedKeyType extends Error {
28
+ readonly kind = "UnsupportedKeyType";
29
+ }
30
+ declare class DidNotFound extends Error {
31
+ readonly kind = "DidNotFound";
32
+ }
33
+ declare class DidResolverTimeout extends Error {
34
+ readonly kind = "DidResolverTimeout";
35
+ }
36
+ declare class DidResolverError extends Error {
37
+ readonly kind = "DidResolverError";
38
+ }
39
+ declare class UnsupportedDidMethod extends Error {
40
+ readonly kind = "UnsupportedDidMethod";
41
+ }
42
+ interface DidResolverAdapter {
43
+ resolve(did: string): Promise<DidDocument>;
44
+ }
45
+ interface CacheEntry$3<T> {
46
+ value: T;
47
+ fetchedAt: number;
48
+ }
49
+ interface DidResolverOpts {
50
+ /** AbortController timeout for did:web fetches. Default 3000ms. */
51
+ fetchTimeoutMs?: number;
52
+ /** TTL for the in-memory cache. Default 5 minutes. */
53
+ ttlMs?: number;
54
+ /** Injectable fetch — defaults to global `fetch` (Node 18+). */
55
+ fetch?: typeof fetch;
56
+ /**
57
+ * Injectable cache — defaults to a fresh `Map` per adapter instance.
58
+ * Tests pass a shared cache to assert miss/hit behaviour.
59
+ */
60
+ cache?: Map<string, CacheEntry$3<DidDocument>>;
61
+ /** Injectable wall-clock — defaults to `Date.now()`. Tests use a stub. */
62
+ now?: () => number;
63
+ }
64
+ declare function makeDidResolver(opts?: DidResolverOpts): DidResolverAdapter;
65
+ declare function decodeDidKey(did: string): DidDocument;
66
+
67
+ /**
68
+ * StatusListCache adapter — sub-phase B.2.
69
+ *
70
+ * Fetches a W3C StatusList2021 Verifiable Credential, base64url-decodes
71
+ * + gunzips the encoded bitstring, and enumerates set bits as a sorted
72
+ * list of revoked indices. Phase C bundles the output as
73
+ * `ContextSpec.revoked: Record<url, number[]>`; the engine's
74
+ * `MapStatusListCache::is_revoked(url, index)` (in `wasm.rs`) checks
75
+ * `indices.contains(&index)` to make a Stage 3 contribution.
76
+ *
77
+ * Architectural choice (deviation from kickoff § 5 B.2): the kickoff
78
+ * sketched a contract where the WASM side does the bit-level lookup
79
+ * on raw bytes. Phase A's `wasm.rs` already shipped with the simpler
80
+ * `Vec<u64>`-of-indices shape, and § 4.1 of Phase B's mandate is
81
+ * "TS-only." The adapter does the bitstring decode + bit enumeration
82
+ * on the TS side; the engine stays unchanged.
83
+ *
84
+ * Bit convention: W3C VC Status List § "Bitstring expansion algorithm"
85
+ * — index N is bit `7 - (N % 8)` of byte `floor(N / 8)`, MSB-first.
86
+ */
87
+ declare class StatusListUnavailable extends Error {
88
+ readonly kind = "StatusListUnavailable";
89
+ }
90
+ declare class MalformedStatusList extends Error {
91
+ readonly kind = "MalformedStatusList";
92
+ }
93
+ declare class StatusListTimeout extends Error {
94
+ readonly kind = "StatusListTimeout";
95
+ }
96
+ interface StatusListCacheAdapter {
97
+ /**
98
+ * Fetch the status list at `url`, decode it, and return the sorted
99
+ * set of revoked credential indices.
100
+ *
101
+ * @throws {StatusListUnavailable} on transport / non-2xx response.
102
+ * @throws {StatusListTimeout} when the fetch budget is exceeded.
103
+ * @throws {MalformedStatusList} when the VC is unparseable.
104
+ */
105
+ fetch(url: string): Promise<number[]>;
106
+ }
107
+ interface CacheEntry$2 {
108
+ indices: number[];
109
+ fetchedAt: number;
110
+ }
111
+ interface StatusListCacheOpts {
112
+ fetchTimeoutMs?: number;
113
+ ttlMs?: number;
114
+ fetch?: typeof fetch;
115
+ cache?: Map<string, CacheEntry$2>;
116
+ now?: () => number;
117
+ }
118
+ declare function makeStatusListCache(opts?: StatusListCacheOpts): StatusListCacheAdapter;
119
+
120
+ /**
121
+ * ReputationOracle adapter — sub-phase B.3.
122
+ *
123
+ * Resolves a per-DID reputation score in `[0.0, 1.0]`. Phase 1 wires
124
+ * an optional HTTP endpoint (Argus). Unavailable / misconfigured /
125
+ * out-of-range responses degrade to a baseline score so infrastructure
126
+ * blips can't silently DOS Adobe-class traffic. The engine's Stage 6
127
+ * compares the returned score against the tenant-configured threshold
128
+ * (Phase B.4 builds the threshold via `PolicyEvaluator`).
129
+ *
130
+ * **Degrade-to-trust** (Phase B § 4.5). Reputation is best-effort;
131
+ * Argus outages do not block traffic. The adapter returns the
132
+ * configured baseline (default 1.0 = "no signal, treat as trusted")
133
+ * and logs loudly. The engine's `LowReputation` block fires only
134
+ * when score < threshold from tenant policy; baseline-1.0 ensures
135
+ * no traffic is silently rejected just because Argus went down.
136
+ */
137
+ interface ReputationOracleAdapter {
138
+ /**
139
+ * Return the agent's reputation in `[0.0, 1.0]`. Higher is better.
140
+ *
141
+ * **Does not throw.** Network / parse / range failures degrade to
142
+ * the baseline + log; the engine should never see a thrown error
143
+ * from this adapter.
144
+ */
145
+ score(agentDid: string): Promise<number>;
146
+ }
147
+ interface CacheEntry$1 {
148
+ value: number;
149
+ fetchedAt: number;
150
+ }
151
+ interface ReputationOracleOpts {
152
+ /**
153
+ * Base URL for the reputation service (Argus). When unset, the
154
+ * adapter returns the baseline without fetching. Phase 1 only —
155
+ * Argus's HTTP surface is post-Adobe; until it lands, every host
156
+ * runs in degrade-to-trust mode.
157
+ */
158
+ argusUrl?: string;
159
+ /** Fetch budget. Default 1500ms — reputation is best-effort, tighter than DID resolution. */
160
+ fetchTimeoutMs?: number;
161
+ /** Cache TTL. Default 10s — reputation churns faster than DIDs. */
162
+ ttlMs?: number;
163
+ /** Injectable fetch. Defaults to global `fetch`. */
164
+ fetch?: typeof fetch;
165
+ /** Returned when Argus is unset / unreachable / malformed. Default 1.0. */
166
+ baselineWhenUnreachable?: number;
167
+ /** Injectable cache for tests. */
168
+ cache?: Map<string, CacheEntry$1>;
169
+ /** Injectable wall-clock. */
170
+ now?: () => number;
171
+ /** Hook for diagnostics. Phase 1 keeps log volume manageable by sampling. */
172
+ logger?: (msg: string) => void;
173
+ }
174
+ declare function makeReputationOracle(opts?: ReputationOracleOpts): ReputationOracleAdapter;
175
+
176
+ /**
177
+ * PolicyEvaluator adapter — sub-phase B.4.
178
+ *
179
+ * Computes the **tenant verdict** on the JS side and hands the engine
180
+ * a constant `Decision` for the WASM `WasmConstantPolicy` to echo as
181
+ * Stage 7's contribution. The engine's cross-stage priority order
182
+ * (locked in D-design § 6 row 4) handles how Stage 7 interacts with
183
+ * Stages 2 / 3 / 4 / 5.
184
+ *
185
+ * **Sync-engine / async-host invariant.** The JS adapter is async (it
186
+ * fetches tenant policy from the Checkpoint dashboard); the engine
187
+ * sees only the resolved `Decision`. Cedar-1 will replace this
188
+ * adapter's implementation without touching the surrounding orchestrator.
189
+ *
190
+ * **Cedar-1 forward-compat.** [`PolicyEvaluatorAdapter`] is the
191
+ * Cedar-swappable interface: `(input) → Decision`. The Phase 1 stub
192
+ * is a reputation-threshold check; Cedar-1 will replace the
193
+ * implementation, not the surface. Don't bake Cedar internals into
194
+ * this seam.
195
+ *
196
+ * **Degrade-to-permit.** Per Phase B § 4.5: when the dashboard policy
197
+ * endpoint is unreachable, fall back to `defaultPolicy` (caller-supplied)
198
+ * or `permit-by-default`. Loud log; no silent block.
199
+ */
200
+
201
+ /**
202
+ * Pre-fetched inputs the JS host knows before calling the engine.
203
+ * Phase 1's evaluator only consumes `reputation` + `tenantHost`; later
204
+ * implementations (Cedar-1) may extend.
205
+ */
206
+ interface PolicyEvalInput {
207
+ tenantHost: string;
208
+ reputation: number;
209
+ }
210
+ interface PolicyEvaluatorAdapter {
211
+ evaluate(input: PolicyEvalInput): Promise<Decision>;
212
+ }
213
+ /**
214
+ * Phase 1 tenant-policy shape — just a reputation threshold.
215
+ * Cedar-1 replaces this with a full policy bundle; for now the
216
+ * dashboard exposes one field.
217
+ */
218
+ interface TenantPolicy {
219
+ reputationThreshold: number;
220
+ }
221
+ interface PolicyEvaluatorOpts {
222
+ /**
223
+ * Dashboard policy endpoint. When unset, every tenant resolves to
224
+ * `defaultPolicy` (or permit-by-default if that's also unset).
225
+ */
226
+ dashboardUrl?: string;
227
+ fetchTimeoutMs?: number;
228
+ ttlMs?: number;
229
+ fetch?: typeof fetch;
230
+ /** Used when the dashboard endpoint is unreachable or unconfigured. */
231
+ defaultPolicy?: TenantPolicy;
232
+ cache?: Map<string, CacheEntry>;
233
+ now?: () => number;
234
+ logger?: (msg: string) => void;
235
+ }
236
+ interface CacheEntry {
237
+ policy: TenantPolicy;
238
+ fetchedAt: number;
239
+ }
240
+ declare function makePolicyEvaluator(opts?: PolicyEvaluatorOpts): PolicyEvaluatorAdapter;
241
+
242
+ /**
243
+ * Clock adapter — sub-phase B.5.
244
+ *
245
+ * Provides the Unix-seconds timestamp the engine's `Clock` trait needs
246
+ * for Stage 4 expiration checks. Trivial; the trait shape exists so
247
+ * tests can inject a frozen clock (and so the engine's sync-trait
248
+ * surface is satisfied without a JS callback crossing the WASM
249
+ * boundary — `ContextSpec.nowUnix` carries the value).
250
+ */
251
+ interface ClockAdapter {
252
+ nowUnix(): number;
253
+ }
254
+ declare function makeSystemClock(): ClockAdapter;
255
+ declare function makeFixedClock(unixSeconds: number): ClockAdapter;
256
+
257
+ export { type ClockAdapter, DidNotFound, type DidResolverAdapter, DidResolverError, type DidResolverOpts, DidResolverTimeout, MalformedDid, MalformedStatusList, type PolicyEvalInput, type PolicyEvaluatorAdapter, type PolicyEvaluatorOpts, type ReputationOracleAdapter, type ReputationOracleOpts, type StatusListCacheAdapter, type StatusListCacheOpts, StatusListTimeout, StatusListUnavailable, type TenantPolicy, UnsupportedDidMethod, UnsupportedKeyType, decodeDidKey, makeDidResolver, makeFixedClock, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeSystemClock };
@@ -0,0 +1,257 @@
1
+ import { d as DidDocument, D as Decision } from './types-D0j85fF0.js';
2
+ import '@kya-os/checkpoint-shared';
3
+
4
+ /**
5
+ * DidResolver adapter — sub-phase B.1.
6
+ *
7
+ * Resolves `did:key:*` (in-memory multibase decode) and `did:web:*`
8
+ * (HTTPS fetch of `.well-known/did.json`) into the engine's
9
+ * `DidDocument` shape. The async half does any required I/O; the
10
+ * adapter's output is plain data that the host wrapper bundles into
11
+ * `ContextSpec.didDocs` before calling `engineVerify`.
12
+ *
13
+ * Phase 1 supports only Ed25519 verification methods (the engine's
14
+ * `KeyType` is `#[non_exhaustive]` with `Ed25519` as its single
15
+ * variant). Non-Ed25519 methods on a resolved doc are silently
16
+ * filtered out — the engine wouldn't accept them as a valid Stage 2
17
+ * key match anyway.
18
+ *
19
+ * **`kid` for `did:key`**: the verification-method id is
20
+ * `<did>#<multibase>` per mcp-i-core PR #16. **NOT** `<did>#keys-1`.
21
+ * H-1's `stage2_did_key_fragment_resolution` test pins this.
22
+ */
23
+
24
+ declare class MalformedDid extends Error {
25
+ readonly kind = "MalformedDid";
26
+ }
27
+ declare class UnsupportedKeyType extends Error {
28
+ readonly kind = "UnsupportedKeyType";
29
+ }
30
+ declare class DidNotFound extends Error {
31
+ readonly kind = "DidNotFound";
32
+ }
33
+ declare class DidResolverTimeout extends Error {
34
+ readonly kind = "DidResolverTimeout";
35
+ }
36
+ declare class DidResolverError extends Error {
37
+ readonly kind = "DidResolverError";
38
+ }
39
+ declare class UnsupportedDidMethod extends Error {
40
+ readonly kind = "UnsupportedDidMethod";
41
+ }
42
+ interface DidResolverAdapter {
43
+ resolve(did: string): Promise<DidDocument>;
44
+ }
45
+ interface CacheEntry$3<T> {
46
+ value: T;
47
+ fetchedAt: number;
48
+ }
49
+ interface DidResolverOpts {
50
+ /** AbortController timeout for did:web fetches. Default 3000ms. */
51
+ fetchTimeoutMs?: number;
52
+ /** TTL for the in-memory cache. Default 5 minutes. */
53
+ ttlMs?: number;
54
+ /** Injectable fetch — defaults to global `fetch` (Node 18+). */
55
+ fetch?: typeof fetch;
56
+ /**
57
+ * Injectable cache — defaults to a fresh `Map` per adapter instance.
58
+ * Tests pass a shared cache to assert miss/hit behaviour.
59
+ */
60
+ cache?: Map<string, CacheEntry$3<DidDocument>>;
61
+ /** Injectable wall-clock — defaults to `Date.now()`. Tests use a stub. */
62
+ now?: () => number;
63
+ }
64
+ declare function makeDidResolver(opts?: DidResolverOpts): DidResolverAdapter;
65
+ declare function decodeDidKey(did: string): DidDocument;
66
+
67
+ /**
68
+ * StatusListCache adapter — sub-phase B.2.
69
+ *
70
+ * Fetches a W3C StatusList2021 Verifiable Credential, base64url-decodes
71
+ * + gunzips the encoded bitstring, and enumerates set bits as a sorted
72
+ * list of revoked indices. Phase C bundles the output as
73
+ * `ContextSpec.revoked: Record<url, number[]>`; the engine's
74
+ * `MapStatusListCache::is_revoked(url, index)` (in `wasm.rs`) checks
75
+ * `indices.contains(&index)` to make a Stage 3 contribution.
76
+ *
77
+ * Architectural choice (deviation from kickoff § 5 B.2): the kickoff
78
+ * sketched a contract where the WASM side does the bit-level lookup
79
+ * on raw bytes. Phase A's `wasm.rs` already shipped with the simpler
80
+ * `Vec<u64>`-of-indices shape, and § 4.1 of Phase B's mandate is
81
+ * "TS-only." The adapter does the bitstring decode + bit enumeration
82
+ * on the TS side; the engine stays unchanged.
83
+ *
84
+ * Bit convention: W3C VC Status List § "Bitstring expansion algorithm"
85
+ * — index N is bit `7 - (N % 8)` of byte `floor(N / 8)`, MSB-first.
86
+ */
87
+ declare class StatusListUnavailable extends Error {
88
+ readonly kind = "StatusListUnavailable";
89
+ }
90
+ declare class MalformedStatusList extends Error {
91
+ readonly kind = "MalformedStatusList";
92
+ }
93
+ declare class StatusListTimeout extends Error {
94
+ readonly kind = "StatusListTimeout";
95
+ }
96
+ interface StatusListCacheAdapter {
97
+ /**
98
+ * Fetch the status list at `url`, decode it, and return the sorted
99
+ * set of revoked credential indices.
100
+ *
101
+ * @throws {StatusListUnavailable} on transport / non-2xx response.
102
+ * @throws {StatusListTimeout} when the fetch budget is exceeded.
103
+ * @throws {MalformedStatusList} when the VC is unparseable.
104
+ */
105
+ fetch(url: string): Promise<number[]>;
106
+ }
107
+ interface CacheEntry$2 {
108
+ indices: number[];
109
+ fetchedAt: number;
110
+ }
111
+ interface StatusListCacheOpts {
112
+ fetchTimeoutMs?: number;
113
+ ttlMs?: number;
114
+ fetch?: typeof fetch;
115
+ cache?: Map<string, CacheEntry$2>;
116
+ now?: () => number;
117
+ }
118
+ declare function makeStatusListCache(opts?: StatusListCacheOpts): StatusListCacheAdapter;
119
+
120
+ /**
121
+ * ReputationOracle adapter — sub-phase B.3.
122
+ *
123
+ * Resolves a per-DID reputation score in `[0.0, 1.0]`. Phase 1 wires
124
+ * an optional HTTP endpoint (Argus). Unavailable / misconfigured /
125
+ * out-of-range responses degrade to a baseline score so infrastructure
126
+ * blips can't silently DOS Adobe-class traffic. The engine's Stage 6
127
+ * compares the returned score against the tenant-configured threshold
128
+ * (Phase B.4 builds the threshold via `PolicyEvaluator`).
129
+ *
130
+ * **Degrade-to-trust** (Phase B § 4.5). Reputation is best-effort;
131
+ * Argus outages do not block traffic. The adapter returns the
132
+ * configured baseline (default 1.0 = "no signal, treat as trusted")
133
+ * and logs loudly. The engine's `LowReputation` block fires only
134
+ * when score < threshold from tenant policy; baseline-1.0 ensures
135
+ * no traffic is silently rejected just because Argus went down.
136
+ */
137
+ interface ReputationOracleAdapter {
138
+ /**
139
+ * Return the agent's reputation in `[0.0, 1.0]`. Higher is better.
140
+ *
141
+ * **Does not throw.** Network / parse / range failures degrade to
142
+ * the baseline + log; the engine should never see a thrown error
143
+ * from this adapter.
144
+ */
145
+ score(agentDid: string): Promise<number>;
146
+ }
147
+ interface CacheEntry$1 {
148
+ value: number;
149
+ fetchedAt: number;
150
+ }
151
+ interface ReputationOracleOpts {
152
+ /**
153
+ * Base URL for the reputation service (Argus). When unset, the
154
+ * adapter returns the baseline without fetching. Phase 1 only —
155
+ * Argus's HTTP surface is post-Adobe; until it lands, every host
156
+ * runs in degrade-to-trust mode.
157
+ */
158
+ argusUrl?: string;
159
+ /** Fetch budget. Default 1500ms — reputation is best-effort, tighter than DID resolution. */
160
+ fetchTimeoutMs?: number;
161
+ /** Cache TTL. Default 10s — reputation churns faster than DIDs. */
162
+ ttlMs?: number;
163
+ /** Injectable fetch. Defaults to global `fetch`. */
164
+ fetch?: typeof fetch;
165
+ /** Returned when Argus is unset / unreachable / malformed. Default 1.0. */
166
+ baselineWhenUnreachable?: number;
167
+ /** Injectable cache for tests. */
168
+ cache?: Map<string, CacheEntry$1>;
169
+ /** Injectable wall-clock. */
170
+ now?: () => number;
171
+ /** Hook for diagnostics. Phase 1 keeps log volume manageable by sampling. */
172
+ logger?: (msg: string) => void;
173
+ }
174
+ declare function makeReputationOracle(opts?: ReputationOracleOpts): ReputationOracleAdapter;
175
+
176
+ /**
177
+ * PolicyEvaluator adapter — sub-phase B.4.
178
+ *
179
+ * Computes the **tenant verdict** on the JS side and hands the engine
180
+ * a constant `Decision` for the WASM `WasmConstantPolicy` to echo as
181
+ * Stage 7's contribution. The engine's cross-stage priority order
182
+ * (locked in D-design § 6 row 4) handles how Stage 7 interacts with
183
+ * Stages 2 / 3 / 4 / 5.
184
+ *
185
+ * **Sync-engine / async-host invariant.** The JS adapter is async (it
186
+ * fetches tenant policy from the Checkpoint dashboard); the engine
187
+ * sees only the resolved `Decision`. Cedar-1 will replace this
188
+ * adapter's implementation without touching the surrounding orchestrator.
189
+ *
190
+ * **Cedar-1 forward-compat.** [`PolicyEvaluatorAdapter`] is the
191
+ * Cedar-swappable interface: `(input) → Decision`. The Phase 1 stub
192
+ * is a reputation-threshold check; Cedar-1 will replace the
193
+ * implementation, not the surface. Don't bake Cedar internals into
194
+ * this seam.
195
+ *
196
+ * **Degrade-to-permit.** Per Phase B § 4.5: when the dashboard policy
197
+ * endpoint is unreachable, fall back to `defaultPolicy` (caller-supplied)
198
+ * or `permit-by-default`. Loud log; no silent block.
199
+ */
200
+
201
+ /**
202
+ * Pre-fetched inputs the JS host knows before calling the engine.
203
+ * Phase 1's evaluator only consumes `reputation` + `tenantHost`; later
204
+ * implementations (Cedar-1) may extend.
205
+ */
206
+ interface PolicyEvalInput {
207
+ tenantHost: string;
208
+ reputation: number;
209
+ }
210
+ interface PolicyEvaluatorAdapter {
211
+ evaluate(input: PolicyEvalInput): Promise<Decision>;
212
+ }
213
+ /**
214
+ * Phase 1 tenant-policy shape — just a reputation threshold.
215
+ * Cedar-1 replaces this with a full policy bundle; for now the
216
+ * dashboard exposes one field.
217
+ */
218
+ interface TenantPolicy {
219
+ reputationThreshold: number;
220
+ }
221
+ interface PolicyEvaluatorOpts {
222
+ /**
223
+ * Dashboard policy endpoint. When unset, every tenant resolves to
224
+ * `defaultPolicy` (or permit-by-default if that's also unset).
225
+ */
226
+ dashboardUrl?: string;
227
+ fetchTimeoutMs?: number;
228
+ ttlMs?: number;
229
+ fetch?: typeof fetch;
230
+ /** Used when the dashboard endpoint is unreachable or unconfigured. */
231
+ defaultPolicy?: TenantPolicy;
232
+ cache?: Map<string, CacheEntry>;
233
+ now?: () => number;
234
+ logger?: (msg: string) => void;
235
+ }
236
+ interface CacheEntry {
237
+ policy: TenantPolicy;
238
+ fetchedAt: number;
239
+ }
240
+ declare function makePolicyEvaluator(opts?: PolicyEvaluatorOpts): PolicyEvaluatorAdapter;
241
+
242
+ /**
243
+ * Clock adapter — sub-phase B.5.
244
+ *
245
+ * Provides the Unix-seconds timestamp the engine's `Clock` trait needs
246
+ * for Stage 4 expiration checks. Trivial; the trait shape exists so
247
+ * tests can inject a frozen clock (and so the engine's sync-trait
248
+ * surface is satisfied without a JS callback crossing the WASM
249
+ * boundary — `ContextSpec.nowUnix` carries the value).
250
+ */
251
+ interface ClockAdapter {
252
+ nowUnix(): number;
253
+ }
254
+ declare function makeSystemClock(): ClockAdapter;
255
+ declare function makeFixedClock(unixSeconds: number): ClockAdapter;
256
+
257
+ export { type ClockAdapter, DidNotFound, type DidResolverAdapter, DidResolverError, type DidResolverOpts, DidResolverTimeout, MalformedDid, MalformedStatusList, type PolicyEvalInput, type PolicyEvaluatorAdapter, type PolicyEvaluatorOpts, type ReputationOracleAdapter, type ReputationOracleOpts, type StatusListCacheAdapter, type StatusListCacheOpts, StatusListTimeout, StatusListUnavailable, type TenantPolicy, UnsupportedDidMethod, UnsupportedKeyType, decodeDidKey, makeDidResolver, makeFixedClock, makePolicyEvaluator, makeReputationOracle, makeStatusListCache, makeSystemClock };