{"version":3,"file":"edge-B3UxWniO.mjs","names":[],"sources":["../src/engine/render-types.ts","../src/wasm-module-error.ts","../src/engine/edge-wasm.ts","../src/engine/warm-up.ts","../src/engine/edge.ts"],"sourcesContent":["/**\n * Types and the envelope unwrap for the engine's kya-os/http renderer\n * (`render` / `engine_render_json` in `rust/crates/kya-os-engine/src/render`).\n *\n * The engine renders a `VerifyResult` into status, ordered headers and body.\n * Every binding (wasm, WASI, uniffi) returns the same `{ success, result |\n * error }` envelope; the bridges in `./index.ts`, `./node.ts` and `./edge.ts`\n * unwrap it and throw {@link EngineRenderError} on failure.\n *\n * The Node and bundler orchestrator builds export `renderDecisionAsResponse`\n * bound to these bridges (`./orchestrator/render-engine.ts`).\n */\n\nimport type { ChallengeWireErrorCode, ChallengeWireInput } from '@kya-os/checkpoint-shared';\n\nimport type { EngineInfo } from './types';\n\n/** Per-request host settings for the engine renderer. */\nexport interface EngineRenderOptions {\n  /** Serve the body-readable HTTP 200 for Challenge / Instruct (negotiated mode). */\n  bodyReadable200?: boolean;\n  /** Registered context for a canonical Delegation challenge. */\n  delegationChallenge?: ChallengeWireInput;\n  /** The host tried to resolve registered context and got none. */\n  challengeContextRequested?: boolean;\n}\n\n/** The rendered answer. `status: null` passes the request through. */\nexport interface EngineRenderedResponse {\n  status: number | null;\n  /** Ordered `[name, value]` pairs, applied in order. Names may repeat. */\n  headers: [name: string, value: string][];\n  body?: unknown;\n}\n\n/** The TS challenge-wire codes plus `invalid-input` for an unparseable input. */\nexport type EngineRenderErrorCode = ChallengeWireErrorCode | 'invalid-input';\n\n/** What every binding returns. */\nexport interface EngineRenderEnvelope {\n  success: boolean;\n  result?: EngineRenderedResponse;\n  error?: { code: EngineRenderErrorCode; message: string };\n}\n\n/** One control the engine enforces, and the engine version it arrived in. */\nexport interface EngineCapability {\n  id: string;\n  since: string;\n}\n\n/** The engine's self-description: attribution stamp plus capabilities. */\nexport interface EngineManifest {\n  manifestVersion: number;\n  engine: EngineInfo;\n  capabilities: EngineCapability[];\n}\n\n/** A typed render failure, with the same codes as `ChallengeWireError`. */\nexport class EngineRenderError extends TypeError {\n  readonly code: EngineRenderErrorCode;\n\n  constructor(code: EngineRenderErrorCode, message: string) {\n    super(message);\n    this.name = 'EngineRenderError';\n    this.code = code;\n  }\n}\n\n/** Unwrap a binding's envelope, throwing {@link EngineRenderError} on failure. */\nexport function unwrapRenderEnvelope(envelope: EngineRenderEnvelope): EngineRenderedResponse {\n  if (envelope.success && envelope.result) return envelope.result;\n  const error = envelope.error ?? {\n    code: 'invalid-input' as const,\n    message: 'engine returned no render result',\n  };\n  throw new EngineRenderError(error.code, error.message);\n}\n","/** The compiled WebAssembly module an edge entry was missing. */\nexport type EdgeWasmArtifact = 'engine' | 'cedar';\n\n/**\n * Thrown when an edge entry has to instantiate its WebAssembly before the host\n * registered the compiled `WebAssembly.Module`. The edge glue has no URL\n * fallback (`rust/scripts/lib/remove-wasm-url-fallback.mjs` removes it at\n * build time): bundlers copy the wasm into every bundle for that fallback, and\n * it fails on Cloudflare Workers anyway. A host catches this like any other\n * evaluator failure and fails closed.\n */\nexport class WasmModuleNotRegisteredError extends Error {\n  readonly code = 'wasm_module_not_registered' as const;\n  readonly artifact: EdgeWasmArtifact;\n\n  /** `register` names where the module goes, e.g. `initEngine()`. */\n  constructor(artifact: EdgeWasmArtifact, register: string) {\n    super(\n      `No ${artifact} WebAssembly.Module is registered: import the module and pass it to ${register} before use.`\n    );\n    this.name = 'WasmModuleNotRegisteredError';\n    this.artifact = artifact;\n  }\n}\n","/**\n * The compiled engines an edge host registers, shared by the edge engine\n * (`./edge.ts`) and the edge Cedar evaluator (`../policy-evaluator-edge.ts`).\n *\n * The cedar-web build is the engine-web build plus the Cedar evaluator: the\n * `cedar` feature only adds `src/policy`, so its detection exports are the same\n * code. A host that enforces Cedar on the edge therefore passes one module,\n * the cedar-web one, and one instance of it serves both roles; passing both\n * modules still works, but bundles the engine twice.\n *\n * This file imports no glue, so the module check and the registry cost a\n * bundle nothing. The Cedar evaluator does import `./edge.ts` to share its\n * instance, so a bundle that uses only `./policy-edge` also carries the\n * engine-web glue JS, never its wasm: neither web glue can load a wasm the\n * host did not pass.\n */\n\nimport type { EngineWasmSource } from './types';\n\n/**\n * Whether a module is the cedar-web build, judged by what it exports (its\n * Cedar evaluator constructor). Only a compiled `WebAssembly.Module` can be\n * inspected; any other source (bytes, a URL) counts as the engine-web build.\n *\n * `WebAssembly.Module.exports` is the module check, not `instanceof`: the\n * Next.js Edge sandbox hands middleware `.wasm?module` imports compiled in\n * another realm, which fail `instanceof WebAssembly.Module` here, and\n * `exports` accepts a module from any realm and throws for anything else.\n */\nexport function isCedarModule(source: EngineWasmSource | undefined): source is WebAssembly.Module {\n  if (typeof WebAssembly === 'undefined' || typeof source !== 'object' || source === null) {\n    return false;\n  }\n  try {\n    return WebAssembly.Module.exports(source as WebAssembly.Module).some(\n      (entry) => entry.name === 'policyevaluator_new'\n    );\n  } catch {\n    return false;\n  }\n}\n\n/** The cedar-web module registered through `initPolicyEvaluatorEdge`. */\nlet cedarModule: WebAssembly.Module | undefined;\n/**\n * The last attempt to instantiate `cedarModule`, by either side: the Cedar\n * evaluator's own, or the engine's when it runs on the registered module.\n */\nlet lastAttempt: Promise<unknown> | undefined;\nlet lastAttemptFailed = false;\n\n/**\n * Register the cedar-web module (`initPolicyEvaluatorEdge`), with the same\n * module rule as `initEngineEdge`: the first one registered is used, and a\n * different one replaces it only after an attempt on it failed, never while\n * one is pending or after one succeeded.\n */\nexport function registerCedarModule(module: WebAssembly.Module): void {\n  if (module === cedarModule) return;\n  if (cedarModule !== undefined && !lastAttemptFailed) return;\n  cedarModule = module;\n  lastAttempt = undefined;\n  lastAttemptFailed = false;\n}\n\n/** The registered cedar-web module, if any. */\nexport function registeredCedarModule(): WebAssembly.Module | undefined {\n  return cedarModule;\n}\n\n/**\n * Record an attempt to instantiate `module`. Only an attempt on the registered\n * module counts, and only the latest one: its outcome decides whether\n * {@link registerCedarModule} may replace the module.\n */\nexport function noteCedarAttempt(\n  module: EngineWasmSource | undefined,\n  attempt: Promise<unknown>\n): void {\n  if (module === undefined || module !== cedarModule) return;\n  lastAttempt = attempt;\n  lastAttemptFailed = false;\n  attempt.then(\n    () => undefined,\n    () => {\n      if (lastAttempt === attempt) lastAttemptFailed = true;\n    }\n  );\n}\n","/**\n * Engine warm-up (epic #6089, stage 3).\n *\n * The engine's first verify pays for work no later verify repeats: it builds\n * its user-agent pattern tables, and V8 compiles each WASM function on its\n * first call. Running one verify ahead of traffic moves that cost off the\n * first real request. A Chrome page load is the request used, because it\n * matches no AI-agent pattern and so reaches every pattern table.\n *\n * The warm-up calls the engine binding directly, never `verifyRequest`, so it\n * resolves no DID, fetches no status list, asks no policy or reputation\n * service, starts no vendor-key feed round and reports nothing. The engine\n * records state on a verify only for a signed request (a vendor-key miss), and\n * this request carries no signature, so the feed's cold-start demand is left\n * for the first real request exactly as it was.\n *\n * Each engine loader calls `warmEngine` once, after a successful load and\n * before it reports the engine ready, so no real request reaches a cold engine\n * through it. This module imports no scheduling helper: the edge build loads\n * it too, and a build that warms later passes its own deferral to\n * `scheduleWarmUp`.\n */\n\nimport type { AgentRequest, ContextSpec, VerifyResult } from './types';\n\nexport type EngineVerify = (input: AgentRequest, ctx: ContextSpec) => VerifyResult;\n\nconst CHROME_USER_AGENT =\n  'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36';\n\nconst WARM_UP_REQUEST: AgentRequest = {\n  protocol: 'PlainHttp',\n  request: {\n    raw: [],\n    method: 'GET',\n    path: '/',\n    headers: [\n      ['user-agent', CHROME_USER_AGENT],\n      ['accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'],\n      ['accept-language', 'en-US,en;q=0.9'],\n      ['accept-encoding', 'gzip, deflate, br'],\n    ],\n    userAgent: CHROME_USER_AGENT,\n    // TEST-NET-3 (RFC 5737): never a real client.\n    remoteIp: '203.0.113.7',\n    signals: null,\n    sessionVelocity: null,\n  },\n};\n\nfunction warmUpContext(): ContextSpec {\n  return {\n    didDocs: {},\n    revoked: {},\n    reputation: {},\n    tenantDecision: { kind: 'Permit' },\n    nowUnix: Math.floor(Date.now() / 1000),\n    enforcementMode: 'observe',\n  };\n}\n\n/**\n * Run one verify of a Chrome page load on `verify`. Never throws: an engine\n * that cannot verify reports that on the first real request, through the\n * caller's usual error path.\n */\nexport function warmEngine(verify: EngineVerify): void {\n  try {\n    verify(WARM_UP_REQUEST, warmUpContext());\n  } catch {\n    // Left for the first real verify to report.\n  }\n}\n\n/**\n * For an engine that loads when its module is imported (the bundler build):\n * queue the warm-up behind `defer`, so the import stays as fast as before and a\n * server that imports at startup is warm before its first request arrives.\n * When `defer` rejects (no `setImmediate`, say), the warm-up runs then.\n * Returns a function that runs the warm-up now unless it has run, for\n * `initEngine()`, so a host that awaits it at startup gets a warm engine\n * whatever the scheduling.\n */\nexport function scheduleWarmUp(verify: EngineVerify, defer: () => Promise<void>): () => void {\n  let warmed = false;\n  const warmNow = (): void => {\n    if (warmed) return;\n    warmed = true;\n    warmEngine(verify);\n  };\n  let deferred: Promise<void>;\n  try {\n    deferred = defer();\n  } catch {\n    deferred = Promise.resolve();\n  }\n  void deferred.then(warmNow, warmNow);\n  return warmNow;\n}\n","/**\n * `kya-os-engine` WASM bridge for edge runtimes — Edge-WASM-1.\n *\n * The Node target (`./index.ts`) uses `fs.readFileSync` at module\n * load and exposes a sync `engineVerify`. That's incompatible with\n * Vercel Edge / Cloudflare Workers / browser embedding (no `fs`,\n * no sync wasm load).\n *\n * This module loads the `wasm-pack --target web` artifact via the\n * async `__wbg_init` default export. The web target's `init()`\n * accepts a pre-instantiated `WebAssembly.Module` argument — the\n * canonical Cloudflare-Workers + wasm-bindgen pattern.\n *\n * # Why the caller MUST pass `wasmModule` on Cloudflare Workers\n *\n * Both `--target web` (URL fetch) and `--target bundler` (auto-\n * instantiated `__wbg_set_wasm(wasm)`) have failure modes on wrangler:\n *\n *   - `--target web` falls back to `new URL('<wasm>', import.meta.url)`\n *     when `init()` is called with no arg. Cloudflare Workers don't\n *     materialise `import.meta.url` the way browsers do → throws\n *     `TypeError: Invalid URL string`. (Broke production 2026-05-23,\n *     captured via dev tail in run 26352287112.)\n *\n *   - `--target bundler` expects the host bundler to AUTO-INSTANTIATE\n *     `import * as wasm from './foo.wasm'` so `wasm` is the\n *     `Instance.exports` object. Webpack does this. **Wrangler does\n *     NOT** — wrangler gives you a raw `WebAssembly.Module`, and the\n *     bundler-target shim's `__wbg_set_wasm(rawModule)` happily\n *     accepts it, then every export lookup (`wasm.__wbindgen_add_\n *     to_stack_pointer`, etc.) returns undefined → throws\n *     `TypeError: wasm.__wbindgen_add_to_stack_pointer is not a function`.\n *     (Broke production 2026-05-24 after switching to bundler target\n *     in PR #2785; captured via prod tail.)\n *\n * The fix is the standard Cloudflare-Workers + wasm-bindgen pattern:\n * the consumer statically imports the `.wasm` file (wrangler then\n * bundles it + hands the worker a `WebAssembly.Module`), then passes\n * it to `init(wasmModule)`. The web target's init detects the Module\n * input + calls `WebAssembly.instantiate(Module, imports)` internally\n * to produce a real `Instance` whose exports populate the JS shim's\n * `wasm` binding correctly.\n *\n * Every host passes it, on every runtime. The web glue no longer has the\n * URL fallback (`rust/scripts/lib/remove-wasm-url-fallback.mjs` removes\n * it at build time, because bundlers copied the wasm into the bundle a\n * second time for it), so an engine that was never given a module\n * rejects with `WasmModuleNotRegisteredError` and fetches nothing.\n *\n * **Why this matters for the consolidation narrative.** Phase A\n * shipped Node-only. Without an edge build, the first Vercel-edge\n * or Cloudflare-Workers deployment after Phase D would hit the\n * same wasm-bindgen-on-edge wall the Sites-1 F3 workaround was\n * created to dodge — and someone would re-introduce the\n * inline-TS detector that Q10 ratified deleting. Shipping the\n * edge target alongside the Node target keeps Phase D's\n * deletion narrative durable.\n */\n\nimport type {\n  AdoptedVendorKeys,\n  AgentRequest,\n  ContextSpec,\n  DelegationVerifyInput,\n  EngineWasmSource,\n  FeedAttemptOutcome,\n  FeedDemandReason,\n  RootNeedsResult,\n  RuleBundleReport,\n  VendorKeyFeedStatus,\n  VendorKeyMissReason,\n  VerifyResult,\n} from './types';\nimport {\n  unwrapRenderEnvelope,\n  type EngineManifest,\n  type EngineRenderEnvelope,\n  type EngineRenderOptions,\n  type EngineRenderedResponse,\n} from './render-types';\nimport { WasmModuleNotRegisteredError } from '../wasm-module-error';\nimport { isCedarModule, noteCedarAttempt, registeredCedarModule } from './edge-wasm';\nimport { warmEngine } from './warm-up';\nimport type { StatusListVerification } from './adapters/status-list-cache';\n\nexport { WasmModuleNotRegisteredError } from '../wasm-module-error';\n\ntype VerifyFn = (input: unknown, ctx: unknown) => unknown;\n/** The engine exports the edge bridge needs once the wasm module is ready. */\ninterface EngineExports {\n  verify: VerifyFn;\n  verifyDelegation: VerifyFn;\n  applyRuleBundle: (bundleJson: string, nowUnix: number) => unknown;\n  feedDemand: (nowUnix: number) => unknown;\n  feedAttemptFinished: (outcome: string) => unknown;\n  feedStatus: (nowUnix: number) => unknown;\n  feedNoteMiss: (keyid: string, reason: string) => unknown;\n  vendorKeys: () => unknown;\n  render: (input: unknown) => EngineRenderEnvelope;\n  engineInfo: () => EngineManifest;\n  verifyStatusList: (requestJson: string) => StatusListVerification;\n  rootNeeds: (contextJson: string) => RootNeedsResult;\n  /** The initialised cedar-web glue, when the engine runs on it (see {@link edgeEngineCedarGlue}). */\n  cedarGlue?: unknown;\n}\ntype InitFn = (\n  moduleOrPath?: WebAssembly.Module | URL | string | Request | BufferSource\n) => Promise<unknown>;\n\nlet initialised: Promise<EngineExports> | null = null;\nlet providedModule: EngineWasmSource | undefined;\n/** The module the current attempt (`initialised`) instantiates. */\nlet initialisedWith: EngineWasmSource | undefined;\n\n/**\n * The module the engine runs on: the one given to `initEngineEdge`, else the\n * cedar-web module registered for policy (`initPolicyEvaluatorEdge`), which\n * carries the same engine.\n */\nfunction engineModule(): EngineWasmSource | undefined {\n  return providedModule ?? registeredCedarModule();\n}\n\n/**\n * Initialise the edge wasm module. Idempotent — subsequent calls\n * return the same in-flight or resolved promise. Host wrappers\n * should call this once at startup with the `wasmModule` they\n * statically imported from the package's `./wasm/kya-os-engine-web/`\n * subpath (see CLAUDE.md for the wrangler/webpack import pattern).\n *\n * @param wasmModule  The engine module the host imported\n *                    (`./wasm/kya-os-engine-web/kya_os_engine_bg.wasm`).\n *                    Required on the first call, on every runtime. Which\n *                    module an attempt uses:\n *                    - the first one given;\n *                    - a different one only after an attempt failed, so a\n *                      host can replace a bad module; never while an\n *                      attempt is pending or after one succeeded;\n *                    - after a failure, the module that failed, when the\n *                      retry passes none (`verifyRequestEdge` calls\n *                      `initEngineEdge()` itself), so one transient\n *                      failure is not permanent.\n *                    With no module ever given it rejects with\n *                    `WasmModuleNotRegisteredError`.\n */\nexport function initEngineEdge(wasmModule?: EngineWasmSource): Promise<void> {\n  // `initialised` is null only before the first attempt and after a\n  // failed one, which are exactly the times a given module may be taken.\n  if (wasmModule !== undefined && initialised === null) {\n    providedModule = wasmModule;\n  }\n  return ensureReady().then(() => undefined);\n}\n\nfunction ensureReady(): Promise<EngineExports> {\n  if (initialised) return initialised;\n\n  // Dynamic import keeps this module's top level free of side\n  // effects — important for edge runtimes that statically analyse\n  // imports at deploy time. The generated wasm-bindgen module\n  // has no static `.d.ts` types we can rely on; cast at the\n  // boundary.\n  const wasmModule = engineModule();\n  initialisedWith = wasmModule;\n  const pending = (async () => {\n    if (wasmModule === undefined) {\n      throw new WasmModuleNotRegisteredError('engine', 'initEngine()');\n    }\n    // A wasm runs only with the glue generated for it. The cedar-web build is\n    // this engine plus the Cedar evaluator, so its glue serves both, and the\n    // edge Cedar evaluator shares the instance (`edgeEngineCedarGlue`).\n    const cedar = isCedarModule(wasmModule);\n    // Package self-import — keeps the import string stable across\n    // the source-vs-dist location boundary; tsup leaves the literal\n    // in place (external regex in tsup.config.ts), the consumer's\n    // bundler resolves via the package's `./wasm/*` exports pattern.\n    const mod = (await (cedar\n      ? import('@kya-os/checkpoint-wasm-runtime/wasm/kya-os-engine-cedar-web/kya_os_engine.js')\n      : import(\n          '@kya-os/checkpoint-wasm-runtime/wasm/kya-os-engine-web/kya_os_engine.js'\n        ))) as unknown as {\n      default: InitFn;\n      verify: VerifyFn;\n      verifyDelegation: VerifyFn;\n      applyRuleBundle: (bundleJson: string, nowUnix: number) => unknown;\n      feedDemand: (nowUnix: number) => unknown;\n      feedAttemptFinished: (outcome: string) => unknown;\n      feedStatus: (nowUnix: number) => unknown;\n      feedNoteMiss: (keyid: string, reason: string) => unknown;\n      vendorKeys: () => unknown;\n      render: (input: unknown) => EngineRenderEnvelope;\n      engineInfo: () => EngineManifest;\n      verifyStatusList: (requestJson: string) => StatusListVerification;\n      rootNeeds: (contextJson: string) => RootNeedsResult;\n    };\n    // wasm-bindgen's web-target init instantiates a `WebAssembly.Module`\n    // (or compiles bytes) passed as `{ module_or_path }`; the object form\n    // suppresses the deprecation warning the bare-argument form emits.\n    await mod.default({ module_or_path: wasmModule });\n    // Once per successful instantiation, before any caller sees the engine\n    // ready: the first real verify then finds it warm (./warm-up.ts).\n    warmEngine((input, ctx) => mod.verify(input, ctx) as VerifyResult);\n    return {\n      verify: mod.verify,\n      verifyDelegation: mod.verifyDelegation,\n      applyRuleBundle: mod.applyRuleBundle,\n      feedDemand: mod.feedDemand,\n      feedAttemptFinished: mod.feedAttemptFinished,\n      feedStatus: mod.feedStatus,\n      feedNoteMiss: mod.feedNoteMiss,\n      vendorKeys: mod.vendorKeys,\n      render: mod.render,\n      engineInfo: mod.engineInfo,\n      verifyStatusList: mod.verifyStatusList,\n      rootNeeds: mod.rootNeeds,\n      cedarGlue: cedar ? mod : undefined,\n    };\n  })();\n\n  // Cache the in-flight promise so concurrent callers join the\n  // same init. On rejection, clear the init cache but keep the\n  // module: a retry without an argument tries it again, and a retry\n  // that passes a module replaces it (`initEngineEdge`), so neither a\n  // transient failure nor a bad module is permanent.\n  initialised = pending;\n  // An attempt on the module registered for policy decides, for both sides,\n  // whether a newly registered module may replace it.\n  noteCedarAttempt(wasmModule, pending);\n  pending.catch(() => {\n    if (initialised === pending) {\n      initialised = null;\n    }\n  });\n  return initialised;\n}\n\n/**\n * The engine's cedar-web glue, initialised, when the engine runs on the\n * cedar-web module (or would, once it starts): the edge Cedar evaluator then\n * uses this one instance instead of instantiating its own. `null` when the\n * engine runs on the engine-web module.\n */\nexport function edgeEngineCedarGlue(): Promise<unknown> | null {\n  const module = initialised ? initialisedWith : engineModule();\n  if (!isCedarModule(module)) return null;\n  return ensureReady().then((exports) => exports.cedarGlue);\n}\n\n/**\n * Edge-runtime async equivalent of `engineVerify`.\n *\n * Identical contract (typed `AgentRequest` + `ContextSpec` in,\n * typed `VerifyResult` out) — only the return type changes from\n * `VerifyResult` to `Promise<VerifyResult>` because the underlying\n * wasm artifact is loaded async on this target.\n *\n * @throws If `engineVerify` rejects the input (deserialisation\n *   failure) or the engine returns a `VerifyError`. Verdicts\n *   surface inside the returned `VerifyResult`, not as throws.\n */\nexport async function engineVerifyEdge(\n  input: AgentRequest,\n  ctx: ContextSpec\n): Promise<VerifyResult> {\n  const { verify } = await ensureReady();\n  return verify(input, ctx) as VerifyResult;\n}\n\n/**\n * Edge-runtime async equivalent of `engineVerifyDelegation` — the standalone\n * Layer-2-only (`Authorization: Bearer <DelegationCredential>`) path,\n * `draft-kya-http-02` §4.3. Same contract as the bundler/node entries, only\n * the return type is `Promise<VerifyResult>` (the wasm artifact loads async on\n * this target). The resource server's own org DID rides on `ctx.resourceOrgDid`.\n */\nexport async function engineVerifyDelegationEdge(\n  input: DelegationVerifyInput,\n  ctx: ContextSpec\n): Promise<VerifyResult> {\n  const { verifyDelegation } = await ensureReady();\n  return verifyDelegation(input, ctx) as VerifyResult;\n}\n\n/**\n * Edge-runtime async equivalent of `engineRender`: the kya-os/http answer,\n * rendered in the engine. Same output as the bundler and Node entries.\n *\n * @throws {EngineRenderError} when the registered challenge context fails\n *   validation.\n */\nexport async function engineRenderEdge(\n  result: VerifyResult,\n  options: EngineRenderOptions = {}\n): Promise<EngineRenderedResponse> {\n  const { render } = await ensureReady();\n  return unwrapRenderEnvelope(render({ result, options }));\n}\n\n/**\n * Edge-runtime async equivalent of `engineVerifyStatusList`: verify a fetched\n * status list against its issuer's DID document. Never rejects for a bad\n * list; a rejection is `{ ok: false, code, message }`.\n */\n/** The trusted roots' DID-document needs (`rootNeeds`), on the edge engine. Never throws. */\nexport async function engineRootNeedsEdge(contextJson: string): Promise<RootNeedsResult> {\n  const { rootNeeds } = await ensureReady();\n  return rootNeeds(contextJson);\n}\n\nexport async function engineVerifyStatusListEdge(\n  requestJson: string\n): Promise<StatusListVerification> {\n  const { verifyStatusList } = await ensureReady();\n  return verifyStatusList(requestJson);\n}\n\n/** Edge-runtime async equivalent of `engineInfo`: the capability manifest. */\nexport async function engineInfoEdge(): Promise<EngineManifest> {\n  const { engineInfo } = await ensureReady();\n  return engineInfo();\n}\n\nexport {\n  EngineRenderError,\n  type EngineCapability,\n  type EngineManifest,\n  type EngineRenderEnvelope,\n  type EngineRenderErrorCode,\n  type EngineRenderOptions,\n  type EngineRenderedResponse,\n} from './render-types';\n\n// Re-export every typed shape so edge consumers don't need a second\n// import line for the ABI types.\nexport type {\n  AdoptedVendorKey,\n  AdoptedVendorKeys,\n  AgentRequest,\n  A2ARequest,\n  A2PRequest,\n  BehaviouralSignals,\n  BlockReason,\n  ChallengeParams,\n  ClientSignalAttribute,\n  ClientIntegrityInput,\n  ClientSignals,\n  ContextSpec,\n  Decision,\n  DelegationVerifyInput,\n  DetectionDetail,\n  DidDocument,\n  EngineConfig,\n  EngineInfo,\n  EnforcementMode,\n  FeedAttemptOutcome,\n  FeedDemandReason,\n  HttpSignedRequest,\n  InstructPayload,\n  IpReputation,\n  KeySetOutcome,\n  KeyType,\n  McpIPayload,\n  McpIRequest,\n  NetworkContext,\n  PlainHttpRequest,\n  ProxyInfo,\n  ProxyType,\n  RedirectTarget,\n  RuleBundleApplied,\n  RuleBundleRejected,\n  RuleBundleRejectionCode,\n  RuleBundleReport,\n  RoutingType,\n  SignalsEnvelope,\n  StabilityTier,\n  SuggestedAction,\n  Tier1PolicyMode,\n  Tier3Action,\n  TransportSignals,\n  VendorKeyFeedKeyStatus,\n  VendorKeyFeedStatus,\n  VendorKeyMissReason,\n  VerificationMethod,\n  VerifyResult,\n} from './types';\n\nexport async function engineApplyRuleBundleEdge(\n  bundleJson: string,\n  nowUnix: number\n): Promise<RuleBundleReport> {\n  const { applyRuleBundle } = await ensureReady();\n  return applyRuleBundle(bundleJson, nowUnix) as RuleBundleReport;\n}\n\nexport async function engineFeedDemandEdge(nowUnix: number): Promise<FeedDemandReason | undefined> {\n  const { feedDemand } = await ensureReady();\n  return feedDemand(nowUnix) as FeedDemandReason | undefined;\n}\n\nexport async function engineFeedAttemptFinishedEdge(outcome: FeedAttemptOutcome): Promise<boolean> {\n  const { feedAttemptFinished } = await ensureReady();\n  return feedAttemptFinished(outcome) as boolean;\n}\n\nexport async function engineFeedStatusEdge(nowUnix: number): Promise<VendorKeyFeedStatus | null> {\n  const { feedStatus } = await ensureReady();\n  return feedStatus(nowUnix) as VendorKeyFeedStatus | null;\n}\n\nexport async function engineFeedNoteMissEdge(\n  keyid: string,\n  reason: VendorKeyMissReason\n): Promise<boolean> {\n  const { feedNoteMiss } = await ensureReady();\n  return feedNoteMiss(keyid, reason) as boolean;\n}\n\nexport async function engineVendorKeysEdge(): Promise<AdoptedVendorKeys> {\n  const { vendorKeys } = await ensureReady();\n  return vendorKeys() as AdoptedVendorKeys;\n}\n"],"mappings":";;AA2DA,IAAa,oBAAb,cAAuC,UAAU;CAC/C;CAEA,YAAY,MAA6B,SAAiB;EACxD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,OAAO;CACd;AACF;;AAGA,SAAgB,qBAAqB,UAAwD;CAC3F,IAAI,SAAS,WAAW,SAAS,QAAQ,OAAO,SAAS;CACzD,MAAM,QAAQ,SAAS,SAAS;EAC9B,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