{"version":3,"file":"render-types-CR3-qoxo.mjs","names":[],"sources":["../src/engine/render-types.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"],"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,MAAM;EACN,SAAS;CACX;CACA,MAAM,IAAI,kBAAkB,MAAM,MAAM,MAAM,OAAO;AACvD"}