@intentproof/sdk 0.1.1 → 0.1.3
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.
- package/README.md +121 -79
- package/dist/index.cjs +417 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +305 -24
- package/dist/index.d.ts +305 -24
- package/dist/index.js +402 -28
- package/dist/index.js.map +1 -1
- package/package.json +25 -14
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/exporters/memory.ts","../src/runtime.ts","../src/snapshot.ts","../src/exporters/http.ts","../src/exporters/queue.ts","../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\nimport { randomUUID } from \"crypto\";\nimport { MemoryExporter } from \"./exporters/memory.js\";\nimport { describeValueType, isPromiseLike } from \"./runtime.js\";\nimport { snapshot } from \"./snapshot.js\";\nimport type {\n ExecutionErrorSnapshot,\n ExecutionEvent,\n ExecutionStatus,\n Exporter,\n SerializeOptions,\n IntentProofConfig,\n WrapOptions,\n} from \"./types.js\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\n/**\n * Validates a correlation id: non-empty string after trim (same as `WrapOptions.correlationId` /\n * {@link assertWrapOptionsShape}). Used by {@link runWithCorrelationId}.\n */\nexport function assertCorrelationId(id: unknown): asserts id is string {\n if (typeof id !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a string, got ${describeValueType(id)}`,\n );\n }\n if (id.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n}\n\n/** Active correlation id from async context, if any. */\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\n/**\n * Run `fn` with an explicit `correlationId` in async context. The id must be a non-empty string\n * after trim ({@link assertCorrelationId}) — the parameter name implies a caller-supplied id.\n */\nexport function runWithCorrelationId<T>(correlationId: string, fn: () => T): T {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n \"IntentProofClient: expected runWithCorrelationId(correlationId, fn)\",\n );\n }\n assertCorrelationId(correlationId);\n return correlationStore.run(correlationId, fn);\n}\n\nfunction defaultOnExporterError(error: unknown, _event: ExecutionEvent): void {\n console.error(\"[intentproof] exporter error\", error);\n}\n\nfunction toErrorSnapshot(e: unknown, includeStack: boolean): ExecutionErrorSnapshot {\n if (e instanceof Error) {\n return includeStack\n ? { name: e.name, message: e.message, stack: e.stack }\n : { name: e.name, message: e.message };\n }\n return { name: \"Error\", message: String(e) };\n}\n\nfunction assertExporterAtIndex(ex: unknown, index: number): void {\n if (\n ex == null ||\n typeof ex !== \"object\" ||\n typeof (ex as Exporter).export !== \"function\"\n ) {\n throw new TypeError(\n `IntentProofClient: exporters[${index}] must be an object with an export() method`,\n );\n }\n}\n\nfunction assertAttributesRecord(label: string, value: unknown): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\n `IntentProofClient: ${label} must be a plain object, got ${describeValueType(value)}`,\n );\n }\n const o = value as Record<string, unknown>;\n for (const key of Object.keys(o)) {\n const v = o[key];\n const t = typeof v;\n if (t !== \"string\" && t !== \"number\" && t !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: ${label}[${JSON.stringify(key)}] must be a string, number, or boolean, got ${describeValueType(v)}`,\n );\n }\n }\n}\n\n/** Runtime validation for {@link IntentProofClient.wrap} options. */\nexport function assertWrapOptionsShape(options: WrapOptions): void {\n if (typeof options.intent !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"intent\" must be a string, got ${describeValueType(options.intent)}`,\n );\n }\n if (options.intent.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"intent\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n if (typeof options.action !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"action\" must be a string, got ${describeValueType(options.action)}`,\n );\n }\n if (options.action.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"action\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n if (\n options.correlationId !== undefined &&\n typeof options.correlationId !== \"string\"\n ) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a string when provided, got ${describeValueType(options.correlationId)}`,\n );\n }\n if (\n options.correlationId !== undefined &&\n options.correlationId.trim().length === 0\n ) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a non-empty string when provided (trimmed length is 0)`,\n );\n }\n if (options.attributes !== undefined) {\n assertAttributesRecord(\"WrapOptions.attributes\", options.attributes);\n }\n if (options.includeErrorStack !== undefined) {\n if (typeof options.includeErrorStack !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: \"includeErrorStack\" must be a boolean when provided, got ${describeValueType(options.includeErrorStack)}`,\n );\n }\n }\n}\n\nexport class IntentProofClient {\n private exporters: Exporter[] = [new MemoryExporter()];\n private onExporterError: (error: unknown, event: ExecutionEvent) => void =\n defaultOnExporterError;\n private defaultAttributes: Readonly<Record<string, string | number | boolean>> = {};\n private includeErrorStack = true;\n\n constructor(config: IntentProofConfig = {}) {\n this.configure(config);\n }\n\n configure(config: IntentProofConfig): void {\n if (config.exporters !== undefined) {\n for (let i = 0; i < config.exporters.length; i++) {\n assertExporterAtIndex(config.exporters[i], i);\n }\n this.exporters = [...config.exporters];\n }\n if (config.onExporterError !== undefined) {\n if (typeof config.onExporterError !== \"function\") {\n throw new TypeError(\n `IntentProofClient: onExporterError must be a function, got ${describeValueType(config.onExporterError)}`,\n );\n }\n this.onExporterError = config.onExporterError;\n }\n if (config.defaultAttributes !== undefined) {\n assertAttributesRecord(\"defaultAttributes\", config.defaultAttributes);\n this.defaultAttributes = config.defaultAttributes;\n }\n if (config.includeErrorStack !== undefined) {\n if (typeof config.includeErrorStack !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: includeErrorStack must be a boolean when provided, got ${describeValueType(config.includeErrorStack)}`,\n );\n }\n this.includeErrorStack = config.includeErrorStack;\n }\n }\n\n /**\n * Await optional {@link Exporter.flush} on each exporter (parallel).\n * Used for graceful shutdown or tests.\n */\n flush(): Promise<void> {\n return Promise.all(\n this.exporters.map((ex) =>\n typeof ex.flush === \"function\"\n ? Promise.resolve(ex.flush())\n : Promise.resolve(),\n ),\n ).then(() => {});\n }\n\n /**\n * {@link Exporter.shutdown} when present, otherwise {@link Exporter.flush}.\n */\n shutdown(): Promise<void> {\n return Promise.all(\n this.exporters.map((ex) => {\n if (typeof ex.shutdown === \"function\") {\n return Promise.resolve(ex.shutdown());\n }\n if (typeof ex.flush === \"function\") {\n return Promise.resolve(ex.flush());\n }\n return Promise.resolve();\n }),\n ).then(() => {});\n }\n\n /** Read active correlation id (AsyncLocalStorage). */\n getCorrelationId(): string | undefined {\n return getCorrelationId();\n }\n\n /**\n * Run `fn` with a generated correlation id for nested `wrap` calls (callers do not supply an id).\n */\n withCorrelation<T>(fn: () => T): T;\n /**\n * Run `fn` under an optional inbound `correlationId`. Non-empty after trim uses that id;\n * empty or whitespace-only values generate a UUID instead (e.g. missing request header).\n * To require a validated, non-blank id, use {@link runWithCorrelationId}.\n */\n withCorrelation<T>(correlationId: string, fn: () => T): T;\n withCorrelation<T>(correlationIdOrFn: string | (() => T), maybeFn?: () => T): T {\n if (typeof correlationIdOrFn === \"function\") {\n return runWithCorrelationId(randomUUID(), correlationIdOrFn);\n }\n if (typeof correlationIdOrFn !== \"string\") {\n throw new TypeError(\n \"IntentProofClient: withCorrelation: correlation id must be a string\",\n );\n }\n if (typeof maybeFn !== \"function\") {\n throw new TypeError(\n \"IntentProofClient: expected withCorrelation(fn) or withCorrelation(correlationId, fn)\",\n );\n }\n const fn = maybeFn;\n const id = correlationIdOrFn;\n if (id.trim().length === 0) {\n return runWithCorrelationId(randomUUID(), fn);\n }\n return runWithCorrelationId(id, fn);\n }\n\n /**\n * Wrap a function to emit one `ExecutionEvent` per invocation (sync or async).\n */\n wrap<A extends unknown[], R>(\n options: WrapOptions,\n fn: (...args: A) => R,\n ): (...args: A) => R {\n assertWrapOptionsShape(options);\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `IntentProofClient: wrap() second argument must be a function, got ${describeValueType(fn)}`,\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias -- `function` wrapper uses `fn.apply(this, …)`\n const self = this;\n const wrapped = function (this: unknown, ...args: A): R {\n const correlationId = options.correlationId ?? getCorrelationId() ?? undefined;\n const startedAt = new Date();\n const serOpts: SerializeOptions = {\n maxDepth: options.maxDepth,\n maxKeys: options.maxKeys,\n redactKeys: options.redactKeys,\n maxStringLength: options.maxStringLength,\n };\n let inputs: unknown;\n if (options.captureInput) {\n try {\n inputs = options.captureInput(args as unknown[]);\n } catch {\n inputs = snapshot(args as unknown[], serOpts);\n }\n } else {\n inputs = snapshot(args as unknown[], serOpts);\n }\n\n const base = {\n id: randomUUID(),\n correlationId,\n intent: options.intent,\n action: options.action,\n inputs,\n startedAt: startedAt.toISOString(),\n attributes: mergeAttrs(self.defaultAttributes, options.attributes),\n };\n\n try {\n const out = fn.apply(this, args as unknown as A);\n if (isPromiseLike(out)) {\n return self.handleAsync(out, base, options, serOpts, startedAt) as R;\n }\n self.emitComplete(\n base,\n \"ok\",\n out,\n undefined,\n options,\n serOpts,\n startedAt,\n self.includeErrorStack,\n );\n return out;\n } catch (e) {\n self.emitComplete(\n base,\n \"error\",\n undefined,\n e,\n options,\n serOpts,\n startedAt,\n self.includeErrorStack,\n );\n throw e;\n }\n };\n Object.defineProperty(wrapped, \"name\", {\n value: `intentproof(${fn.name || \"anonymous\"})`,\n configurable: true,\n });\n return wrapped as (...args: A) => R;\n }\n\n private handleAsync(\n p: PromiseLike<unknown>,\n base: Omit<\n ExecutionEvent,\n \"status\" | \"completedAt\" | \"durationMs\" | \"output\" | \"error\"\n >,\n options: WrapOptions,\n serOpts: SerializeOptions,\n startedAt: Date,\n ): Promise<unknown> {\n const includeStack = this.includeErrorStack;\n return Promise.resolve(p).then(\n (value) => {\n this.emitComplete(\n base,\n \"ok\",\n value,\n undefined,\n options,\n serOpts,\n startedAt,\n includeStack,\n );\n return value;\n },\n (err) => {\n this.emitComplete(\n base,\n \"error\",\n undefined,\n err,\n options,\n serOpts,\n startedAt,\n includeStack,\n );\n throw err;\n },\n );\n }\n\n private emitComplete(\n base: Omit<\n ExecutionEvent,\n \"status\" | \"completedAt\" | \"durationMs\" | \"output\" | \"error\"\n >,\n status: ExecutionStatus,\n result: unknown,\n error: unknown | undefined,\n options: WrapOptions,\n serOpts: SerializeOptions,\n startedAt: Date,\n defaultIncludeErrorStack: boolean,\n ): void {\n const completedAt = new Date();\n const durationMs = completedAt.getTime() - startedAt.getTime();\n let output: unknown | undefined;\n let errSnap: ExecutionErrorSnapshot | undefined;\n const includeStack = options.includeErrorStack ?? defaultIncludeErrorStack;\n\n if (status === \"ok\") {\n try {\n output = options.captureOutput\n ? options.captureOutput(result)\n : snapshot(result, serOpts);\n } catch {\n output = snapshot(result, serOpts);\n }\n } else {\n errSnap = toErrorSnapshot(error, includeStack);\n if (options.captureError) {\n try {\n output = options.captureError(error);\n } catch {\n output = undefined;\n }\n }\n }\n\n const event: ExecutionEvent =\n status === \"ok\"\n ? {\n ...base,\n status,\n completedAt: completedAt.toISOString(),\n durationMs,\n output,\n }\n : {\n ...base,\n status,\n completedAt: completedAt.toISOString(),\n durationMs,\n error: errSnap,\n ...(output !== undefined ? { output } : {}),\n };\n\n this.dispatch(event);\n }\n\n private dispatch(event: ExecutionEvent): void {\n for (const ex of this.exporters) {\n try {\n const r = ex.export(event);\n if (isPromiseLike(r)) {\n void r.catch((e) => this.onExporterError(e, event));\n }\n } catch (e) {\n this.onExporterError(e, event);\n }\n }\n }\n}\n\nfunction mergeAttrs(\n a: Readonly<Record<string, string | number | boolean>>,\n b: Readonly<Record<string, string | number | boolean>> | undefined,\n): Readonly<Record<string, string | number | boolean>> | undefined {\n if (!b || Object.keys(b).length === 0) {\n return Object.keys(a).length ? { ...a } : undefined;\n }\n return { ...a, ...b };\n}\n\nlet defaultClient: IntentProofClient | null = null;\n\nexport function getIntentProofClient(): IntentProofClient {\n if (!defaultClient) defaultClient = new IntentProofClient();\n return defaultClient;\n}\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\n\nexport interface MemoryExporterOptions {\n /** Keep at most this many recent events (default 1000). Must be a finite number >= 1. */\n maxEvents?: number;\n}\n\n/**\n * Default exporter: ring buffer in memory for debugging and tests.\n */\nexport class MemoryExporter implements Exporter {\n private readonly maxEvents: number;\n private readonly events: ExecutionEvent[] = [];\n\n constructor(options: MemoryExporterOptions = {}) {\n const cap = options.maxEvents ?? 1000;\n if (!Number.isFinite(cap) || cap < 1) {\n throw new TypeError('MemoryExporter: \"maxEvents\" must be a finite number >= 1');\n }\n this.maxEvents = Math.trunc(cap);\n }\n\n export(event: ExecutionEvent): void {\n this.events.push(event);\n const overflow = this.events.length - this.maxEvents;\n if (overflow > 0) this.events.splice(0, overflow);\n }\n\n /** Mutable snapshot for inspection — newest last. */\n getEvents(): readonly ExecutionEvent[] {\n return this.events;\n }\n\n clear(): void {\n this.events.length = 0;\n }\n\n flush(): Promise<void> {\n return Promise.resolve();\n }\n}\n","export function describeValueType(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\nexport function isPromiseLike(x: unknown): x is PromiseLike<unknown> {\n return (\n x !== null &&\n typeof x === \"object\" &&\n typeof (x as PromiseLike<unknown>).then === \"function\"\n );\n}\n","import type { SerializeOptions } from \"./types.js\";\n\nconst DEFAULT_MAX_DEPTH = 6;\nconst DEFAULT_MAX_KEYS = 50;\n\nfunction snapshotLimit(n: number | undefined, fallback: number): number {\n if (n === undefined) return fallback;\n if (!Number.isFinite(n)) return fallback;\n const i = Math.trunc(n);\n return i < 0 ? fallback : i;\n}\n\nfunction snapshotStringLimit(n: number | undefined): number | undefined {\n if (n === undefined) return undefined;\n if (!Number.isFinite(n)) return undefined;\n const i = Math.trunc(n);\n return i < 0 ? undefined : i;\n}\n\nfunction normalizeRedactSet(redactKeys: string[] | undefined): Set<string> | undefined {\n if (!redactKeys?.length) return undefined;\n const set = new Set(\n redactKeys\n .filter((k): k is string => typeof k === \"string\" && k.length > 0)\n .map((k) => k.toLowerCase()),\n );\n return set.size > 0 ? set : undefined;\n}\n\nfunction shouldRedactKey(key: string, redact: Set<string> | undefined): boolean {\n if (!redact) return false;\n return redact.has(key.toLowerCase());\n}\n\nfunction truncateString(s: string, maxLen: number | undefined): string {\n if (maxLen === undefined || s.length <= maxLen) return s;\n return `${s.slice(0, maxLen)}…[truncated ${s.length - maxLen} chars]`;\n}\n\n/** JSON-safe value for `ExecutionEvent` inputs/output (depth/key limits, optional redaction). */\nexport function snapshot(value: unknown, options: SerializeOptions = {}): unknown {\n const maxDepth = snapshotLimit(options.maxDepth, DEFAULT_MAX_DEPTH);\n const maxKeys = snapshotLimit(options.maxKeys, DEFAULT_MAX_KEYS);\n const maxStringLength = snapshotStringLimit(options.maxStringLength);\n const redact = normalizeRedactSet(options.redactKeys);\n const seen = new WeakSet<object>();\n\n function walk(v: unknown, depth: number): unknown {\n if (v === null || v === undefined) return v;\n const t = typeof v;\n if (t === \"string\" || t === \"number\" || t === \"boolean\") {\n if (t === \"string\") return truncateString(v as string, maxStringLength);\n return v;\n }\n if (t === \"bigint\") return (v as bigint).toString();\n if (t === \"symbol\") return (v as symbol).toString();\n if (t === \"function\") {\n const fn = v as { name?: string };\n return `[Function ${fn.name || \"anonymous\"}]`;\n }\n if (v instanceof Date) return v.toISOString();\n if (Array.isArray(v)) {\n if (depth >= maxDepth) return \"[Array]\";\n return v.slice(0, maxKeys).map((item) => walk(item, depth + 1));\n }\n if (t === \"object\") {\n const o = v as object;\n if (seen.has(o)) return \"[Circular]\";\n seen.add(o);\n if (depth >= maxDepth) return \"[Object]\";\n const out: Record<string, unknown> = {};\n const keys = Object.keys(o);\n let n = 0;\n for (const k of keys) {\n if (n >= maxKeys) {\n out[\"…\"] = `${keys.length - maxKeys} more keys`;\n break;\n }\n try {\n if (shouldRedactKey(k, redact)) {\n out[k] = \"[REDACTED]\";\n } else {\n out[k] = walk((o as Record<string, unknown>)[k], depth + 1);\n }\n } catch {\n out[k] = \"[Unserializable]\";\n }\n n += 1;\n }\n return out;\n }\n }\n\n try {\n return walk(value, 0);\n } catch {\n return \"[SnapshotError]\";\n }\n}\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\nimport { describeValueType } from \"../runtime.js\";\n\n/** Last-resort wire body when custom `body` and `safeJsonEnvelope` both fail. */\nconst HTTP_EXPORTER_FALLBACK_BODY =\n '{\"intentproof\":\"1\",\"eventSerializeFailed\":true}' as const;\n\n/** JSON body for the default wire shape; never throws (last resort is a static envelope). */\nfunction safeJsonEnvelope(event: ExecutionEvent): string {\n try {\n return JSON.stringify({ intentproof: \"1\", event });\n } catch {\n try {\n return JSON.stringify({\n intentproof: \"1\",\n eventPartial: {\n id: event.id,\n action: event.action,\n intent: event.intent,\n status: event.status,\n correlationId: event.correlationId,\n startedAt: event.startedAt,\n completedAt: event.completedAt,\n durationMs: event.durationMs,\n },\n note: \"full event not JSON-serializable\",\n });\n } catch {\n return HTTP_EXPORTER_FALLBACK_BODY;\n }\n }\n}\n\nexport interface HttpExporterOptions {\n url: string;\n method?: string;\n headers?: Record<string, string>;\n /** Serialize event for wire format (default JSON body). */\n body?: (event: ExecutionEvent) => string;\n /**\n * When true, await each request (blocks until HTTP completes). Default false.\n */\n awaitEach?: boolean;\n /** Abort the request after this many milliseconds (global `AbortSignal.timeout`). */\n timeoutMs?: number;\n onError?: (error: unknown, event: ExecutionEvent) => void;\n}\n\n/**\n * POST execution events as JSON. Uses global `fetch` (Node 18+).\n * Fire-and-forget by default to avoid slowing callers.\n */\nexport class HttpExporter implements Exporter {\n private readonly url: string;\n private readonly method: string;\n private readonly headers: Record<string, string>;\n private readonly body: (event: ExecutionEvent) => string;\n private readonly awaitEach: boolean;\n private readonly timeoutMs?: number;\n private readonly onError?: (error: unknown, event: ExecutionEvent) => void;\n private readonly inFlight = new Set<Promise<void>>();\n private closed = false;\n\n constructor(options: HttpExporterOptions) {\n if (typeof options.url !== \"string\") {\n throw new TypeError(\n `HttpExporter: \"url\" must be a non-empty string, got ${describeValueType(options.url)}`,\n );\n }\n if (options.url.trim().length === 0) {\n throw new TypeError(\n 'HttpExporter: \"url\" must be a non-empty string (trimmed length is 0)',\n );\n }\n this.url = options.url;\n this.method = (options.method ?? \"POST\").trim() || \"POST\";\n const rawHeaders = options.headers;\n const extraHeaders =\n rawHeaders !== undefined &&\n rawHeaders !== null &&\n typeof rawHeaders === \"object\" &&\n !Array.isArray(rawHeaders)\n ? (rawHeaders as Record<string, string>)\n : {};\n this.headers = {\n \"content-type\": \"application/json\",\n ...extraHeaders,\n };\n this.body = options.body ?? ((event: ExecutionEvent) => safeJsonEnvelope(event));\n this.awaitEach = options.awaitEach ?? false;\n if (options.timeoutMs !== undefined) {\n const t = options.timeoutMs;\n if (!Number.isFinite(t) || t <= 0) {\n throw new TypeError(\n 'HttpExporter: \"timeoutMs\" must be a finite number > 0 when set',\n );\n }\n this.timeoutMs = Math.trunc(t);\n } else {\n this.timeoutMs = undefined;\n }\n this.onError = options.onError;\n }\n\n private track(p: Promise<void>): void {\n this.inFlight.add(p);\n void p.finally(() => this.inFlight.delete(p));\n }\n\n export(event: ExecutionEvent): void | Promise<void> {\n if (this.closed) {\n this.onError?.(new Error(\"HttpExporter has been shut down\"), event);\n return;\n }\n\n let payload: string;\n try {\n payload = this.body(event);\n } catch (e) {\n this.onError?.(e, event);\n payload = safeJsonEnvelope(event);\n }\n\n const run = async (): Promise<void> => {\n try {\n const res = await fetch(this.url, {\n method: this.method,\n headers: this.headers,\n body: payload,\n credentials: \"omit\",\n signal:\n this.timeoutMs !== undefined\n ? AbortSignal.timeout(this.timeoutMs)\n : undefined,\n });\n if (!res.ok) {\n const err = new Error(`HTTP ${res.status}: ${res.statusText}`);\n this.onError?.(err, event);\n }\n } catch (e) {\n this.onError?.(e, event);\n }\n };\n\n const p = run();\n this.track(p);\n if (this.awaitEach) return p;\n void p;\n }\n\n /** Waits until every started request has settled (success or failure). */\n flush(): Promise<void> {\n if (this.inFlight.size === 0) return Promise.resolve();\n return Promise.all([...this.inFlight]).then(() => {});\n }\n\n /** Stops accepting new events and waits for in-flight requests to finish. */\n async shutdown(): Promise<void> {\n this.closed = true;\n await this.flush();\n }\n}\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\nimport { isPromiseLike } from \"../runtime.js\";\n\nexport type QueueOverflowStrategy = \"drop-newest\" | \"drop-oldest\";\n\nexport interface BoundedQueueExporterOptions {\n /** Downstream exporter (often {@link import(\"./http.js\").HttpExporter}). */\n exporter: Exporter;\n /** Maximum concurrent async exports to the inner exporter (default `4`). */\n maxConcurrent?: number;\n /**\n * Maximum **queued** events waiting for a worker slot (default `1000`).\n * Use `0` for unlimited backlog (not recommended under sustained overload).\n */\n maxQueue?: number;\n /** How to handle overflow when the queue is full (default `drop-newest`). */\n strategy?: QueueOverflowStrategy;\n onDrop?: (event: ExecutionEvent, reason: string) => void;\n onInnerError?: (error: unknown, event: ExecutionEvent) => void;\n}\n\n/**\n * Bounded concurrency + backlog for async-heavy exporters.\n * Sync inner exporters run on the microtask queue and still respect {@link maxConcurrent}.\n */\nexport class BoundedQueueExporter implements Exporter {\n private readonly inner: Exporter;\n private readonly maxConcurrent: number;\n private readonly maxQueue: number;\n private readonly strategy: QueueOverflowStrategy;\n private readonly onDrop?: (event: ExecutionEvent, reason: string) => void;\n private readonly onInnerError?: (error: unknown, event: ExecutionEvent) => void;\n\n private readonly queue: ExecutionEvent[] = [];\n private active = 0;\n /** When false, {@link export} drops events with reason `shutdown`; queued work still drains. */\n private accepting = true;\n private idleResolvers: Array<() => void> = [];\n\n constructor(options: BoundedQueueExporterOptions) {\n const inner = options.exporter;\n if (\n inner == null ||\n typeof inner !== \"object\" ||\n typeof inner.export !== \"function\"\n ) {\n throw new TypeError(\n 'BoundedQueueExporter: \"exporter\" must be an object with an export() method',\n );\n }\n this.inner = inner;\n const rawMc = options.maxConcurrent ?? 4;\n this.maxConcurrent = !Number.isFinite(rawMc) ? 4 : Math.max(1, Math.trunc(rawMc));\n const rawQ = options.maxQueue ?? 1000;\n if (!Number.isFinite(rawQ)) {\n this.maxQueue = 1000;\n } else {\n const q = Math.trunc(rawQ);\n if (q === 0) {\n this.maxQueue = 0;\n } else if (q < 0) {\n this.maxQueue = 1000;\n } else {\n this.maxQueue = q;\n }\n }\n const strategy = options.strategy ?? \"drop-newest\";\n if (strategy !== \"drop-newest\" && strategy !== \"drop-oldest\") {\n throw new TypeError(\n 'BoundedQueueExporter: \"strategy\" must be \"drop-newest\" or \"drop-oldest\"',\n );\n }\n this.strategy = strategy;\n this.onDrop = options.onDrop;\n this.onInnerError = options.onInnerError;\n }\n\n export(event: ExecutionEvent): void {\n if (!this.accepting) {\n this.onDrop?.(event, \"shutdown\");\n return;\n }\n\n const cap = this.maxQueue <= 0 ? Number.POSITIVE_INFINITY : this.maxQueue;\n\n if (this.queue.length >= cap) {\n if (this.strategy === \"drop-oldest\") {\n const dropped = this.queue.shift();\n if (dropped) this.onDrop?.(dropped, \"queue-overflow-drop-oldest\");\n this.queue.push(event);\n } else {\n this.onDrop?.(event, \"queue-overflow-drop-newest\");\n }\n this.pump();\n return;\n }\n\n this.queue.push(event);\n this.pump();\n }\n\n private pump(): void {\n while (this.active < this.maxConcurrent && this.queue.length > 0) {\n const next = this.queue.shift()!;\n this.active++;\n void this.runInner(next).finally(() => {\n this.active--;\n this.pump();\n this.resolveIdleWaitersIfNeeded();\n });\n }\n }\n\n private async runInner(event: ExecutionEvent): Promise<void> {\n try {\n const r = this.inner.export(event);\n if (isPromiseLike(r)) await r;\n } catch (e) {\n this.onInnerError?.(e, event);\n }\n }\n\n private resolveIdleWaitersIfNeeded(): void {\n if (this.queue.length === 0 && this.active === 0) {\n const waiters = this.idleResolvers;\n this.idleResolvers = [];\n for (const r of waiters) r();\n }\n }\n\n /** Resolves when the queue is empty and no inner export is in flight. */\n flush(): Promise<void> {\n if (this.queue.length === 0 && this.active === 0) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n this.idleResolvers.push(resolve);\n });\n }\n\n /**\n * Stops accepting new events; does **not** drop items already in the queue—\n * {@link flush} waits until queued and in-flight work finishes.\n */\n async shutdown(): Promise<void> {\n this.accepting = false;\n await this.flush();\n }\n}\n","/**\n * @packageDocumentation\n * Structured `ExecutionEvent` emission for verification / ingest pipelines.\n */\n\nimport { IntentProofClient, getIntentProofClient } from \"./client.js\";\nimport type { IntentProofConfig } from \"./types.js\";\n\n/** Injected at build (`tsup`) and test (`vitest`) time from `package.json` — single source of truth. */\ndeclare const __INTENTPROOF_SDK_VERSION__: string;\n\nexport const VERSION = __INTENTPROOF_SDK_VERSION__;\n\nexport type {\n ExecutionErrorSnapshot,\n ExecutionEvent,\n ExecutionStatus,\n Exporter,\n SerializeOptions,\n IntentProofConfig,\n WrapOptions,\n} from \"./types.js\";\n\nexport { snapshot } from \"./snapshot.js\";\n\nexport { MemoryExporter } from \"./exporters/memory.js\";\nexport type { MemoryExporterOptions } from \"./exporters/memory.js\";\n\nexport { HttpExporter } from \"./exporters/http.js\";\nexport type { HttpExporterOptions } from \"./exporters/http.js\";\n\nexport { BoundedQueueExporter } from \"./exporters/queue.js\";\nexport type {\n BoundedQueueExporterOptions,\n QueueOverflowStrategy,\n} from \"./exporters/queue.js\";\n\nexport {\n IntentProofClient,\n assertCorrelationId,\n assertWrapOptionsShape,\n getCorrelationId,\n getIntentProofClient,\n runWithCorrelationId,\n} from \"./client.js\";\n\n/** Default singleton — same instance as `getIntentProofClient()`. */\nexport const client = getIntentProofClient();\n\n/** Isolated client instance (tests, workers, per-tenant configuration). */\nexport function createIntentProofClient(config?: IntentProofConfig): IntentProofClient {\n return new IntentProofClient(config);\n}\n"],"mappings":";AAAA,SAAS,yBAAyB;AAClC,SAAS,kBAAkB;;;ACSpB,IAAM,iBAAN,MAAyC;AAAA,EAC7B;AAAA,EACA,SAA2B,CAAC;AAAA,EAE7C,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,KAAK,MAAM,WAAW,KAAK,KAAK,WAAW,GAAG;AAChD,YAAM,UAAU,KAAK;AACrB,WAAK,gBAAgB,CAAC;AACtB,iBAAW,KAAK,QAAS,GAAE;AAAA,IAC7B;AAAA,EACF;AAAA;AAAA,EAGA,QAAuB;AACrB,QAAI,KAAK,MAAM,WAAW,KAAK,KAAK,WAAW,GAAG;AAChD,aAAO,QAAQ,QAAQ;AAAA,IACzB;AACA,WAAO,IAAI,QAAQ,CAAC,YAAY;AAC9B,WAAK,cAAc,KAAK,OAAO;AAAA,IACjC,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,WAA0B;AAC9B,SAAK,YAAY;AACjB,UAAM,KAAK,MAAM;AAAA,EACnB;AACF;;;ACzIO,IAAM,UAAU;AAoChB,IAAM,SAAS,qBAAqB;AAGpC,SAAS,wBAAwB,QAA+C;AACrF,SAAO,IAAI,kBAAkB,MAAM;AACrC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/exporters/memory.ts","../src/runtime.ts","../src/snapshot.ts","../src/validators.ts","../src/generated/embed/execution-event.v1.ts","../src/generated/embed/intentproof-config.v1.ts","../src/generated/embed/wrap-options.v1.ts","../src/exporters/http.ts","../src/exporters/queue.ts","../src/index.ts"],"sourcesContent":["import { AsyncLocalStorage } from \"async_hooks\";\nimport { randomUUID } from \"crypto\";\nimport { MemoryExporter } from \"./exporters/memory.js\";\nimport { describeValueType, isPromiseLike } from \"./runtime.js\";\nimport { snapshot } from \"./snapshot.js\";\nimport { assertValidExecutionEventWire } from \"./validators.js\";\nimport type {\n ExecutionErrorSnapshot,\n ExecutionEvent,\n ExecutionEventBase,\n ExecutionStatus,\n Exporter,\n IntentProofConfig,\n SerializeOptions,\n WrapOptions,\n} from \"./types.js\";\nimport type {\n IntentProofExecutionEventV1,\n JsonValue,\n} from \"./generated/execution-event.js\";\n\nconst correlationStore = new AsyncLocalStorage<string>();\n\n/**\n * JSON Schema requires `inputs` to be an object; positional snapshots may be arrays — wrap them.\n */\nfunction normalizeInputsForExecutionEvent(\n inputs: unknown,\n): IntentProofExecutionEventV1[\"inputs\"] {\n if (inputs !== null && typeof inputs === \"object\" && !Array.isArray(inputs)) {\n return inputs as IntentProofExecutionEventV1[\"inputs\"];\n }\n return { args: inputs } as IntentProofExecutionEventV1[\"inputs\"];\n}\n\n/**\n * Validates a correlation id: non-empty string after trim (same as `WrapOptions.correlationId` /\n * {@link assertWrapOptionsShape}). Used by {@link runWithCorrelationId}.\n */\nexport function assertCorrelationId(id: unknown): asserts id is string {\n if (typeof id !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a string, got ${describeValueType(id)}`,\n );\n }\n if (id.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n}\n\n/** Active correlation id from async context, if any. */\nexport function getCorrelationId(): string | undefined {\n return correlationStore.getStore();\n}\n\n/**\n * Run `fn` with an explicit `correlationId` in async context. The id must be a non-empty string\n * after trim ({@link assertCorrelationId}) — the parameter name implies a caller-supplied id.\n */\nexport function runWithCorrelationId<T>(correlationId: string, fn: () => T): T {\n if (typeof fn !== \"function\") {\n throw new TypeError(\n \"IntentProofClient: expected runWithCorrelationId(correlationId, fn)\",\n );\n }\n assertCorrelationId(correlationId);\n return correlationStore.run(correlationId, fn);\n}\n\nfunction defaultOnExporterError(error: unknown, _event: ExecutionEvent): void {\n console.error(\"[intentproof] exporter error\", error);\n}\n\nfunction toErrorSnapshot(e: unknown, includeStack: boolean): ExecutionErrorSnapshot {\n if (e instanceof Error) {\n return includeStack\n ? { name: e.name, message: e.message, stack: e.stack }\n : { name: e.name, message: e.message };\n }\n return { name: \"Error\", message: String(e) };\n}\n\nfunction assertExporterAtIndex(ex: unknown, index: number): void {\n if (\n ex == null ||\n typeof ex !== \"object\" ||\n typeof (ex as Exporter).export !== \"function\"\n ) {\n throw new TypeError(\n `IntentProofClient: exporters[${index}] must be an object with an export() method`,\n );\n }\n}\n\nfunction assertAttributesRecord(label: string, value: unknown): void {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(\n `IntentProofClient: ${label} must be a plain object, got ${describeValueType(value)}`,\n );\n }\n const o = value as Record<string, unknown>;\n for (const key of Object.keys(o)) {\n const v = o[key];\n const t = typeof v;\n if (t !== \"string\" && t !== \"number\" && t !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: ${label}[${JSON.stringify(key)}] must be a string, number, or boolean, got ${describeValueType(v)}`,\n );\n }\n }\n}\n\n/** Runtime validation for {@link IntentProofClient.wrap} options. */\nexport function assertWrapOptionsShape(options: WrapOptions): void {\n if (typeof options.intent !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"intent\" must be a string, got ${describeValueType(options.intent)}`,\n );\n }\n if (options.intent.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"intent\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n if (typeof options.action !== \"string\") {\n throw new TypeError(\n `IntentProofClient: \"action\" must be a string, got ${describeValueType(options.action)}`,\n );\n }\n if (options.action.trim().length === 0) {\n throw new TypeError(\n `IntentProofClient: \"action\" must be a non-empty string (trimmed length is 0)`,\n );\n }\n if (\n options.correlationId !== undefined &&\n typeof options.correlationId !== \"string\"\n ) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a string when provided, got ${describeValueType(options.correlationId)}`,\n );\n }\n if (\n options.correlationId !== undefined &&\n options.correlationId.trim().length === 0\n ) {\n throw new TypeError(\n `IntentProofClient: \"correlationId\" must be a non-empty string when provided (trimmed length is 0)`,\n );\n }\n if (options.attributes !== undefined) {\n assertAttributesRecord(\"WrapOptions.attributes\", options.attributes);\n }\n if (options.includeErrorStack !== undefined) {\n if (typeof options.includeErrorStack !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: \"includeErrorStack\" must be a boolean when provided, got ${describeValueType(options.includeErrorStack)}`,\n );\n }\n }\n}\n\nexport class IntentProofClient {\n private exporters: Exporter[] = [new MemoryExporter()];\n private onExporterError: (error: unknown, event: ExecutionEvent) => void =\n defaultOnExporterError;\n private defaultAttributes: Readonly<Record<string, string | number | boolean>> = {};\n private includeErrorStack = true;\n\n constructor(config: IntentProofConfig = {}) {\n this.configure(config);\n }\n\n configure(config: IntentProofConfig): void {\n if (config.exporters !== undefined) {\n for (let i = 0; i < config.exporters.length; i++) {\n assertExporterAtIndex(config.exporters[i], i);\n }\n this.exporters = [...config.exporters];\n }\n if (config.onExporterError !== undefined) {\n if (typeof config.onExporterError !== \"function\") {\n throw new TypeError(\n `IntentProofClient: onExporterError must be a function, got ${describeValueType(config.onExporterError)}`,\n );\n }\n this.onExporterError = config.onExporterError;\n }\n if (config.defaultAttributes !== undefined) {\n assertAttributesRecord(\"defaultAttributes\", config.defaultAttributes);\n this.defaultAttributes = config.defaultAttributes;\n }\n if (config.includeErrorStack !== undefined) {\n if (typeof config.includeErrorStack !== \"boolean\") {\n throw new TypeError(\n `IntentProofClient: includeErrorStack must be a boolean when provided, got ${describeValueType(config.includeErrorStack)}`,\n );\n }\n this.includeErrorStack = config.includeErrorStack;\n }\n }\n\n /**\n * Await optional {@link Exporter.flush} on each exporter (parallel).\n * Used for graceful shutdown or tests.\n */\n flush(): Promise<void> {\n return Promise.all(\n this.exporters.map((ex) =>\n typeof ex.flush === \"function\"\n ? Promise.resolve(ex.flush())\n : Promise.resolve(),\n ),\n ).then(() => {});\n }\n\n /**\n * {@link Exporter.shutdown} when present, otherwise {@link Exporter.flush}.\n */\n shutdown(): Promise<void> {\n return Promise.all(\n this.exporters.map((ex) => {\n if (typeof ex.shutdown === \"function\") {\n return Promise.resolve(ex.shutdown());\n }\n if (typeof ex.flush === \"function\") {\n return Promise.resolve(ex.flush());\n }\n return Promise.resolve();\n }),\n ).then(() => {});\n }\n\n /** Read active correlation id (AsyncLocalStorage). */\n getCorrelationId(): string | undefined {\n return getCorrelationId();\n }\n\n /**\n * Run `fn` with a generated correlation id for nested `wrap` calls (callers do not supply an id).\n */\n withCorrelation<T>(fn: () => T): T;\n /**\n * Run `fn` under an optional inbound `correlationId`. Non-empty after trim uses that id;\n * empty or whitespace-only values generate a UUID instead (e.g. missing request header).\n * To require a validated, non-blank id, use {@link runWithCorrelationId}.\n */\n withCorrelation<T>(correlationId: string, fn: () => T): T;\n withCorrelation<T>(correlationIdOrFn: string | (() => T), maybeFn?: () => T): T {\n if (typeof correlationIdOrFn === \"function\") {\n return runWithCorrelationId(randomUUID(), correlationIdOrFn);\n }\n if (typeof correlationIdOrFn !== \"string\") {\n throw new TypeError(\n \"IntentProofClient: withCorrelation: correlation id must be a string\",\n );\n }\n if (typeof maybeFn !== \"function\") {\n throw new TypeError(\n \"IntentProofClient: expected withCorrelation(fn) or withCorrelation(correlationId, fn)\",\n );\n }\n const fn = maybeFn;\n const id = correlationIdOrFn;\n if (id.trim().length === 0) {\n return runWithCorrelationId(randomUUID(), fn);\n }\n return runWithCorrelationId(id, fn);\n }\n\n /**\n * Wrap a function to emit one `ExecutionEvent` per invocation (sync or async).\n */\n wrap<A extends unknown[], R>(\n options: WrapOptions,\n fn: (...args: A) => R,\n ): (...args: A) => R {\n assertWrapOptionsShape(options);\n if (typeof fn !== \"function\") {\n throw new TypeError(\n `IntentProofClient: wrap() second argument must be a function, got ${describeValueType(fn)}`,\n );\n }\n // eslint-disable-next-line @typescript-eslint/no-this-alias -- `function` wrapper uses `fn.apply(this, …)`\n const self = this;\n const wrapped = function (this: unknown, ...args: A): R {\n const correlationId = options.correlationId ?? getCorrelationId() ?? undefined;\n const startedAt = new Date();\n const serOpts: SerializeOptions = {\n maxDepth: options.maxDepth,\n maxKeys: options.maxKeys,\n redactKeys: options.redactKeys,\n maxStringLength: options.maxStringLength,\n };\n let inputs: unknown;\n if (options.captureInput) {\n try {\n inputs = options.captureInput(args as unknown[]);\n } catch {\n inputs = snapshot(args as unknown[], serOpts);\n }\n } else {\n inputs = snapshot(args as unknown[], serOpts);\n }\n\n const base: ExecutionEventBase = {\n id: randomUUID(),\n correlationId,\n intent: options.intent,\n action: options.action,\n inputs: normalizeInputsForExecutionEvent(inputs),\n startedAt: startedAt.toISOString(),\n attributes: mergeAttrs(\n self.defaultAttributes,\n options.attributes,\n ) as IntentProofExecutionEventV1[\"attributes\"],\n };\n\n try {\n const out = fn.apply(this, args as unknown as A);\n if (isPromiseLike(out)) {\n return self.handleAsync(out, base, options, serOpts, startedAt) as R;\n }\n self.emitComplete(\n base,\n \"ok\",\n out,\n undefined,\n options,\n serOpts,\n startedAt,\n self.includeErrorStack,\n );\n return out;\n } catch (e) {\n self.emitComplete(\n base,\n \"error\",\n undefined,\n e,\n options,\n serOpts,\n startedAt,\n self.includeErrorStack,\n );\n throw e;\n }\n };\n Object.defineProperty(wrapped, \"name\", {\n value: `intentproof(${fn.name || \"anonymous\"})`,\n configurable: true,\n });\n return wrapped as (...args: A) => R;\n }\n\n private handleAsync(\n p: PromiseLike<unknown>,\n base: ExecutionEventBase,\n options: WrapOptions,\n serOpts: SerializeOptions,\n startedAt: Date,\n ): Promise<unknown> {\n const includeStack = this.includeErrorStack;\n return Promise.resolve(p).then(\n (value) => {\n this.emitComplete(\n base,\n \"ok\",\n value,\n undefined,\n options,\n serOpts,\n startedAt,\n includeStack,\n );\n return value;\n },\n (err) => {\n this.emitComplete(\n base,\n \"error\",\n undefined,\n err,\n options,\n serOpts,\n startedAt,\n includeStack,\n );\n throw err;\n },\n );\n }\n\n private emitComplete(\n base: ExecutionEventBase,\n status: ExecutionStatus,\n result: unknown,\n error: unknown | undefined,\n options: WrapOptions,\n serOpts: SerializeOptions,\n startedAt: Date,\n defaultIncludeErrorStack: boolean,\n ): void {\n const completedAt = new Date();\n const durationMs = completedAt.getTime() - startedAt.getTime();\n let output: unknown | undefined;\n let errSnap: ExecutionErrorSnapshot | undefined;\n const includeStack = options.includeErrorStack ?? defaultIncludeErrorStack;\n\n if (status === \"ok\") {\n try {\n output = options.captureOutput\n ? options.captureOutput(result)\n : snapshot(result, serOpts);\n } catch {\n output = snapshot(result, serOpts);\n }\n } else {\n errSnap = toErrorSnapshot(error, includeStack);\n if (options.captureError) {\n try {\n output = options.captureError(error);\n } catch {\n output = undefined;\n }\n }\n }\n\n const event: ExecutionEvent =\n status === \"ok\"\n ? {\n ...base,\n status,\n completedAt: completedAt.toISOString(),\n durationMs,\n output: output as JsonValue | undefined,\n }\n : {\n ...base,\n status,\n completedAt: completedAt.toISOString(),\n durationMs,\n error: errSnap,\n ...(output !== undefined ? { output: output as JsonValue } : {}),\n };\n\n this.dispatch(event);\n }\n\n private dispatch(event: ExecutionEvent): void {\n assertValidExecutionEventWire(JSON.parse(JSON.stringify(event)) as unknown);\n for (const ex of this.exporters) {\n try {\n const r = ex.export(event);\n if (isPromiseLike(r)) {\n void r.catch((e) => this.onExporterError(e, event));\n }\n } catch (e) {\n this.onExporterError(e, event);\n }\n }\n }\n}\n\nfunction mergeAttrs(\n a: Readonly<Record<string, string | number | boolean>>,\n b: Readonly<Record<string, string | number | boolean>> | undefined,\n): Readonly<Record<string, string | number | boolean>> | undefined {\n if (!b || Object.keys(b).length === 0) {\n return Object.keys(a).length ? { ...a } : undefined;\n }\n return { ...a, ...b };\n}\n\nlet defaultClient: IntentProofClient | null = null;\n\nexport function getIntentProofClient(): IntentProofClient {\n if (!defaultClient) defaultClient = new IntentProofClient();\n return defaultClient;\n}\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\n\nexport interface MemoryExporterOptions {\n /** Keep at most this many recent events (default 1000). Must be a finite number >= 1. */\n maxEvents?: number;\n}\n\n/**\n * Default exporter: ring buffer in memory for debugging and tests.\n */\nexport class MemoryExporter implements Exporter {\n private readonly maxEvents: number;\n private readonly events: ExecutionEvent[] = [];\n\n constructor(options: MemoryExporterOptions = {}) {\n const cap = options.maxEvents ?? 1000;\n if (!Number.isFinite(cap) || cap < 1) {\n throw new TypeError('MemoryExporter: \"maxEvents\" must be a finite number >= 1');\n }\n this.maxEvents = Math.trunc(cap);\n }\n\n export(event: ExecutionEvent): void {\n this.events.push(event);\n const overflow = this.events.length - this.maxEvents;\n if (overflow > 0) this.events.splice(0, overflow);\n }\n\n /** Mutable snapshot for inspection — newest last. */\n getEvents(): readonly ExecutionEvent[] {\n return this.events;\n }\n\n clear(): void {\n this.events.length = 0;\n }\n\n flush(): Promise<void> {\n return Promise.resolve();\n }\n}\n","export function describeValueType(value: unknown): string {\n if (value === null) return \"null\";\n if (Array.isArray(value)) return \"array\";\n return typeof value;\n}\n\nexport function isPromiseLike(x: unknown): x is PromiseLike<unknown> {\n return (\n x !== null &&\n typeof x === \"object\" &&\n typeof (x as PromiseLike<unknown>).then === \"function\"\n );\n}\n","import type { SerializeOptions } from \"./types.js\";\n\nconst DEFAULT_MAX_DEPTH = 6;\nconst DEFAULT_MAX_KEYS = 50;\n\nfunction snapshotLimit(n: number | undefined, fallback: number): number {\n if (n === undefined) return fallback;\n if (!Number.isFinite(n)) return fallback;\n const i = Math.trunc(n);\n return i < 0 ? fallback : i;\n}\n\nfunction snapshotStringLimit(n: number | undefined): number | undefined {\n if (n === undefined) return undefined;\n if (!Number.isFinite(n)) return undefined;\n const i = Math.trunc(n);\n return i < 0 ? undefined : i;\n}\n\nfunction normalizeRedactSet(redactKeys: string[] | undefined): Set<string> | undefined {\n if (!redactKeys?.length) return undefined;\n const set = new Set(\n redactKeys\n .filter((k): k is string => typeof k === \"string\" && k.length > 0)\n .map((k) => k.toLowerCase()),\n );\n return set.size > 0 ? set : undefined;\n}\n\nfunction shouldRedactKey(key: string, redact: Set<string> | undefined): boolean {\n if (!redact) return false;\n return redact.has(key.toLowerCase());\n}\n\nfunction truncateString(s: string, maxLen: number | undefined): string {\n if (maxLen === undefined || s.length <= maxLen) return s;\n return `${s.slice(0, maxLen)}…[truncated ${s.length - maxLen} chars]`;\n}\n\n/** JSON-safe value for `ExecutionEvent` inputs/output (depth/key limits, optional redaction). */\nexport function snapshot(value: unknown, options: SerializeOptions = {}): unknown {\n const maxDepth = snapshotLimit(options.maxDepth, DEFAULT_MAX_DEPTH);\n const maxKeys = snapshotLimit(options.maxKeys, DEFAULT_MAX_KEYS);\n const maxStringLength = snapshotStringLimit(options.maxStringLength);\n const redact = normalizeRedactSet(options.redactKeys);\n const seen = new WeakSet<object>();\n\n function walk(v: unknown, depth: number): unknown {\n if (v === null || v === undefined) return v;\n const t = typeof v;\n if (t === \"string\" || t === \"number\" || t === \"boolean\") {\n if (t === \"string\") return truncateString(v as string, maxStringLength);\n return v;\n }\n if (t === \"bigint\") return (v as bigint).toString();\n if (t === \"symbol\") return (v as symbol).toString();\n if (t === \"function\") {\n const fn = v as { name?: string };\n return `[Function ${fn.name || \"anonymous\"}]`;\n }\n if (v instanceof Date) return v.toISOString();\n if (Array.isArray(v)) {\n if (depth >= maxDepth) return \"[Array]\";\n return v.slice(0, maxKeys).map((item) => walk(item, depth + 1));\n }\n // Remaining `typeof v === \"object\"` values (plain objects, Map-like POJOs, etc.).\n const o = v as object;\n if (seen.has(o)) return \"[Circular]\";\n seen.add(o);\n if (depth >= maxDepth) return \"[Object]\";\n const out: Record<string, unknown> = {};\n const keys = Object.keys(o);\n let n = 0;\n for (const k of keys) {\n if (n >= maxKeys) {\n out[\"…\"] = `${keys.length - maxKeys} more keys`;\n break;\n }\n try {\n if (shouldRedactKey(k, redact)) {\n out[k] = \"[REDACTED]\";\n } else {\n out[k] = walk((o as Record<string, unknown>)[k], depth + 1);\n }\n } catch {\n out[k] = \"[Unserializable]\";\n }\n n += 1;\n }\n return out;\n }\n\n try {\n return walk(value, 0);\n } catch {\n return \"[SnapshotError]\";\n }\n}\n","/**\n * Runtime JSON Schema validation using Ajv (compiled from normative spec schemas in `generated/embed/`).\n */\nimport { Ajv2020 } from \"ajv/dist/2020.js\";\nimport type { ValidateFunction } from \"ajv\";\nimport type { Plugin } from \"ajv\";\nimport * as AjvFormats from \"ajv-formats\";\nimport executionEventSchema from \"./generated/embed/execution-event.v1.js\";\nimport intentproofConfigSchema from \"./generated/embed/intentproof-config.v1.js\";\nimport wrapOptionsSchema from \"./generated/embed/wrap-options.v1.js\";\n\nconst ajv = new Ajv2020({\n allErrors: true,\n strict: false,\n});\nconst addFormats = AjvFormats.default as unknown as Plugin<unknown>;\naddFormats(ajv);\n\n/** Compiled validator for `execution_event` v1 (wire / export shape, camelCase keys). */\nexport const validateExecutionEvent: ValidateFunction = ajv.compile(\n executionEventSchema as object,\n);\n\n/** Compiled validator for `wrap_options` v1. */\nexport const validateWrapOptions: ValidateFunction = ajv.compile(\n wrapOptionsSchema as object,\n);\n\n/** Compiled validator for `intentproof_config` v1 (runtime JSON document subset). */\nexport const validateIntentProofConfig: ValidateFunction = ajv.compile(\n intentproofConfigSchema as object,\n);\n\nfunction errorsText(v: ValidateFunction): string {\n return ajv.errorsText(v.errors, { separator: \"; \" });\n}\n\n/**\n * Ensures an execution record matches the pinned `execution_event` schema (throws on failure).\n */\nexport function assertValidExecutionEventWire(data: unknown): void {\n if (!validateExecutionEvent(data)) {\n throw new TypeError(\n `ExecutionEvent wire JSON failed schema validation: ${errorsText(validateExecutionEvent)}`,\n );\n }\n}\n","/* eslint-disable */\n/**\n * Normative JSON Schema from intentproof-spec (bundled for Ajv).\n * Generated by scripts/embed-spec-schemas.mjs — do not edit.\n */\nexport default {\n $comment:\n \"Normative IntentProof source tree: https://github.com/IntentProof/intentproof-spec/tree/main/schema — $id is a logical URI; see README.\",\n $defs: {\n ExecutionError: {\n additionalProperties: false,\n properties: {\n cause: {\n $ref: \"#/$defs/ExecutionError\",\n description:\n \"Optional chained cause; MUST conform to ExecutionError when present.\",\n },\n code: { description: \"Optional stable machine-readable code.\", type: \"string\" },\n message: {\n description:\n \"Human-readable error message (may be empty string if the runtime provides none).\",\n type: \"string\",\n },\n name: {\n description: \"Exception or error type name (e.g. Error, TypeError).\",\n minLength: 1,\n type: \"string\",\n },\n stack: {\n description:\n \"Optional stringified stack trace; null when stacks are suppressed.\",\n type: [\"string\", \"null\"],\n },\n },\n required: [\"name\", \"message\"],\n type: \"object\",\n },\n JsonValue: {\n anyOf: [\n { type: \"null\" },\n { type: \"boolean\" },\n { type: \"number\" },\n { type: \"string\" },\n { items: { $ref: \"#/$defs/JsonValue\" }, type: \"array\" },\n { additionalProperties: { $ref: \"#/$defs/JsonValue\" }, type: \"object\" },\n ],\n description: \"Any JSON-serializable value per semantics/serialization_rules.md.\",\n },\n },\n $id: \"https://intentproof.dev/schema/execution_event.v1.schema.json\",\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n additionalProperties: false,\n allOf: [\n {\n if: { properties: { status: { const: \"ok\" } }, required: [\"status\"] },\n then: { not: { required: [\"error\"] }, required: [\"output\"] },\n },\n {\n if: { properties: { status: { const: \"error\" } }, required: [\"status\"] },\n then: { required: [\"error\"] },\n },\n ],\n properties: {\n action: {\n description:\n \"Stable identifier for the concrete operation. Many systems use hierarchical dotted names (e.g. vendor.resource.operation); REST paths, RPC names, or other conventions are allowed. The schema does not constrain the format.\",\n minLength: 1,\n type: \"string\",\n },\n attributes: {\n additionalProperties: { type: [\"string\", \"number\", \"boolean\", \"null\"] },\n description: \"Flat primitive key/value metadata attached to the event.\",\n propertyNames: { pattern: \"^[A-Za-z0-9_.:-]{1,256}$\" },\n type: \"object\",\n },\n completedAt: {\n description: \"RFC 3339 / ISO 8601 instant when execution completed.\",\n format: \"date-time\",\n type: \"string\",\n },\n correlationId: {\n description:\n \"Optional cross-cutting identifier for distributed tracing. MUST be trimmed and non-empty when present.\",\n minLength: 1,\n type: \"string\",\n },\n durationMs: {\n description:\n \"Wall-clock duration in milliseconds between startedAt and completedAt.\",\n minimum: 0,\n type: \"number\",\n },\n error: {\n $ref: \"#/$defs/ExecutionError\",\n description: \"Structured error when status is error.\",\n },\n id: {\n description: \"Stable unique identifier for this execution record.\",\n minLength: 1,\n type: \"string\",\n },\n inputs: {\n additionalProperties: true,\n description:\n \"Captured call inputs. Values MUST be JSON-serializable (see semantics/serialization_rules.md).\",\n type: \"object\",\n },\n intent: {\n description:\n \"Natural-language description of what the user or caller was trying to achieve (often a full sentence or question). No fixed grammar; SHOULD stay human-readable in logs and UIs.\",\n minLength: 1,\n type: \"string\",\n },\n output: {\n $ref: \"#/$defs/JsonValue\",\n description:\n \"Captured return value when status is ok, or optional captured value when captureError allows output on failure.\",\n },\n startedAt: {\n description: \"RFC 3339 / ISO 8601 instant when execution started.\",\n format: \"date-time\",\n type: \"string\",\n },\n status: {\n description: \"Terminal execution status.\",\n enum: [\"ok\", \"error\"],\n type: \"string\",\n },\n },\n required: [\n \"id\",\n \"intent\",\n \"action\",\n \"status\",\n \"inputs\",\n \"startedAt\",\n \"completedAt\",\n \"durationMs\",\n ],\n title: \"IntentProof ExecutionEvent v1\",\n type: \"object\",\n} as const;\n","/* eslint-disable */\n/**\n * Normative JSON Schema from intentproof-spec (bundled for Ajv).\n * Generated by scripts/embed-spec-schemas.mjs — do not edit.\n */\nexport default {\n $comment:\n \"Normative IntentProof source tree: https://github.com/IntentProof/intentproof-spec/tree/main/schema — $id is a logical URI; see README.\",\n $defs: {\n WrapOptionsV1: {\n $comment:\n \"Normative IntentProof source tree: https://github.com/IntentProof/intentproof-spec/tree/main/schema — $id is a logical URI; see README.\",\n $id: \"https://intentproof.dev/schema/wrap_options.v1.schema.json\",\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n additionalProperties: false,\n properties: {\n action: {\n description:\n \"Default operation identifier (often dotted like vendor.service.method); SDKs MAY derive from the callable when omitted.\",\n minLength: 1,\n type: \"string\",\n },\n attributes: {\n additionalProperties: { type: [\"string\", \"number\", \"boolean\", \"null\"] },\n description:\n \"Static attributes merged into each emitted ExecutionEvent.attributes.\",\n type: \"object\",\n },\n captureError: {\n default: true,\n description:\n \"When true, failures MUST populate error; when false with captureOutput semantics, see semantics/wrap_behavior.md.\",\n type: \"boolean\",\n },\n captureInputs: {\n default: true,\n description: \"When false, inputs MUST be serialized as an empty object {}.\",\n type: \"boolean\",\n },\n captureOutput: {\n default: true,\n description: \"When false and status is ok, output MUST be null.\",\n type: \"boolean\",\n },\n captureStack: {\n default: true,\n description: \"When false, error.stack MUST be null on emitted events.\",\n type: \"boolean\",\n },\n exporterTimeoutMs: {\n description:\n \"Maximum time an exporter hook may block the wrap boundary; 0 means SDK default.\",\n minimum: 0,\n type: \"number\",\n },\n intent: {\n description:\n \"Default natural-language intent for wrapped executions when the call site does not override it.\",\n minLength: 1,\n type: \"string\",\n },\n propagateCorrelation: {\n default: true,\n description: \"When true, nested wraps inherit the active correlationId.\",\n type: \"boolean\",\n },\n },\n title: \"IntentProof WrapOptions v1\",\n type: \"object\",\n },\n },\n $id: \"https://intentproof.dev/schema/intentproof_config.v1.schema.json\",\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n additionalProperties: false,\n properties: {\n correlation: {\n additionalProperties: false,\n properties: {\n generateOnMissing: {\n default: true,\n description: \"When true, SDK generates a UUID when no correlation is active.\",\n type: \"boolean\",\n },\n headerName: {\n default: \"x-intentproof-correlation-id\",\n description:\n \"HTTP header used for inbound correlation extraction when applicable.\",\n type: \"string\",\n },\n },\n type: \"object\",\n },\n defaultWrapOptions: { $ref: \"#/$defs/WrapOptionsV1\" },\n exporters: {\n description:\n \"Ordered list of exporter identifiers or inline hooks (SDK-defined encoding).\",\n items: {\n additionalProperties: true,\n properties: {\n endpoint: {\n description: \"Required for http exporters when used.\",\n format: \"uri\",\n type: \"string\",\n },\n failOpen: {\n default: true,\n description:\n \"When true, exporter failures MUST NOT change user-visible outcomes.\",\n type: \"boolean\",\n },\n headers: {\n additionalProperties: { type: \"string\" },\n description: \"Optional HTTP headers for http exporters.\",\n type: \"object\",\n },\n type: {\n description:\n \"Exporter kind; custom MUST include implementation-specific fields.\",\n enum: [\"console\", \"http\", \"otel\", \"custom\"],\n type: \"string\",\n },\n },\n required: [\"type\"],\n type: \"object\",\n },\n type: \"array\",\n },\n serialization: {\n additionalProperties: false,\n properties: {\n maxDepth: {\n default: 32,\n description: \"Maximum object graph depth for input/output capture.\",\n minimum: 1,\n type: \"integer\",\n },\n maxStringLength: {\n default: 65536,\n description: \"Maximum serialized string length for any single field.\",\n minimum: 1,\n type: \"integer\",\n },\n redactKeys: {\n description:\n \"Case-insensitive key names to replace with [REDACTED] in captured objects.\",\n items: { type: \"string\" },\n type: \"array\",\n },\n },\n type: \"object\",\n },\n version: {\n const: 1,\n description: \"Config document version; MUST be 1 for this schema.\",\n type: \"integer\",\n },\n },\n title: \"IntentProof Runtime Config v1\",\n type: \"object\",\n} as const;\n","/* eslint-disable */\n/**\n * Normative JSON Schema from intentproof-spec (bundled for Ajv).\n * Generated by scripts/embed-spec-schemas.mjs — do not edit.\n */\nexport default {\n $comment:\n \"Normative IntentProof source tree: https://github.com/IntentProof/intentproof-spec/tree/main/schema — $id is a logical URI; see README.\",\n $id: \"https://intentproof.dev/schema/wrap_options.v1.schema.json\",\n $schema: \"https://json-schema.org/draft/2020-12/schema\",\n additionalProperties: false,\n properties: {\n action: {\n description:\n \"Default operation identifier (often dotted like vendor.service.method); SDKs MAY derive from the callable when omitted.\",\n minLength: 1,\n type: \"string\",\n },\n attributes: {\n additionalProperties: { type: [\"string\", \"number\", \"boolean\", \"null\"] },\n description:\n \"Static attributes merged into each emitted ExecutionEvent.attributes.\",\n type: \"object\",\n },\n captureError: {\n default: true,\n description:\n \"When true, failures MUST populate error; when false with captureOutput semantics, see semantics/wrap_behavior.md.\",\n type: \"boolean\",\n },\n captureInputs: {\n default: true,\n description: \"When false, inputs MUST be serialized as an empty object {}.\",\n type: \"boolean\",\n },\n captureOutput: {\n default: true,\n description: \"When false and status is ok, output MUST be null.\",\n type: \"boolean\",\n },\n captureStack: {\n default: true,\n description: \"When false, error.stack MUST be null on emitted events.\",\n type: \"boolean\",\n },\n exporterTimeoutMs: {\n description:\n \"Maximum time an exporter hook may block the wrap boundary; 0 means SDK default.\",\n minimum: 0,\n type: \"number\",\n },\n intent: {\n description:\n \"Default natural-language intent for wrapped executions when the call site does not override it.\",\n minLength: 1,\n type: \"string\",\n },\n propagateCorrelation: {\n default: true,\n description: \"When true, nested wraps inherit the active correlationId.\",\n type: \"boolean\",\n },\n },\n title: \"IntentProof WrapOptions v1\",\n type: \"object\",\n} as const;\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\nimport { describeValueType } from \"../runtime.js\";\n\n/** Last-resort wire body when custom `body` and `safeJsonEnvelope` both fail. */\nconst HTTP_EXPORTER_FALLBACK_BODY =\n '{\"intentproof\":\"1\",\"eventSerializeFailed\":true}' as const;\n\n/** JSON body for the default wire shape; never throws (last resort is a static envelope). */\nfunction safeJsonEnvelope(event: ExecutionEvent): string {\n try {\n return JSON.stringify({ intentproof: \"1\", event });\n } catch {\n try {\n return JSON.stringify({\n intentproof: \"1\",\n eventPartial: {\n id: event.id,\n action: event.action,\n intent: event.intent,\n status: event.status,\n correlationId: event.correlationId,\n startedAt: event.startedAt,\n completedAt: event.completedAt,\n durationMs: event.durationMs,\n },\n note: \"full event not JSON-serializable\",\n });\n } catch {\n return HTTP_EXPORTER_FALLBACK_BODY;\n }\n }\n}\n\nexport interface HttpExporterOptions {\n url: string;\n method?: string;\n headers?: Record<string, string>;\n /** Serialize event for wire format (default JSON body). */\n body?: (event: ExecutionEvent) => string;\n /**\n * When true, await each request (blocks until HTTP completes). Default false.\n */\n awaitEach?: boolean;\n /** Abort the request after this many milliseconds (global `AbortSignal.timeout`). */\n timeoutMs?: number;\n onError?: (error: unknown, event: ExecutionEvent) => void;\n}\n\n/**\n * POST execution events as JSON. Uses global `fetch` (Node 18+).\n * Fire-and-forget by default to avoid slowing callers.\n */\nexport class HttpExporter implements Exporter {\n private readonly url: string;\n private readonly method: string;\n private readonly headers: Record<string, string>;\n private readonly body: (event: ExecutionEvent) => string;\n private readonly awaitEach: boolean;\n private readonly timeoutMs?: number;\n private readonly onError?: (error: unknown, event: ExecutionEvent) => void;\n private readonly inFlight = new Set<Promise<void>>();\n private closed = false;\n\n constructor(options: HttpExporterOptions) {\n if (typeof options.url !== \"string\") {\n throw new TypeError(\n `HttpExporter: \"url\" must be a non-empty string, got ${describeValueType(options.url)}`,\n );\n }\n if (options.url.trim().length === 0) {\n throw new TypeError(\n 'HttpExporter: \"url\" must be a non-empty string (trimmed length is 0)',\n );\n }\n this.url = options.url;\n this.method = (options.method ?? \"POST\").trim() || \"POST\";\n const rawHeaders = options.headers;\n const extraHeaders =\n rawHeaders !== undefined &&\n rawHeaders !== null &&\n typeof rawHeaders === \"object\" &&\n !Array.isArray(rawHeaders)\n ? (rawHeaders as Record<string, string>)\n : {};\n this.headers = {\n \"content-type\": \"application/json\",\n ...extraHeaders,\n };\n this.body = options.body ?? ((event: ExecutionEvent) => safeJsonEnvelope(event));\n this.awaitEach = options.awaitEach ?? false;\n if (options.timeoutMs !== undefined) {\n const t = options.timeoutMs;\n if (!Number.isFinite(t) || t <= 0) {\n throw new TypeError(\n 'HttpExporter: \"timeoutMs\" must be a finite number > 0 when set',\n );\n }\n this.timeoutMs = Math.trunc(t);\n } else {\n this.timeoutMs = undefined;\n }\n this.onError = options.onError;\n }\n\n private track(p: Promise<void>): void {\n this.inFlight.add(p);\n void p.finally(() => this.inFlight.delete(p));\n }\n\n export(event: ExecutionEvent): void | Promise<void> {\n if (this.closed) {\n this.onError?.(new Error(\"HttpExporter has been shut down\"), event);\n return;\n }\n\n let payload: string;\n try {\n payload = this.body(event);\n } catch (e) {\n this.onError?.(e, event);\n payload = safeJsonEnvelope(event);\n }\n\n const run = async (): Promise<void> => {\n try {\n const res = await fetch(this.url, {\n method: this.method,\n headers: this.headers,\n body: payload,\n credentials: \"omit\",\n signal:\n this.timeoutMs !== undefined\n ? AbortSignal.timeout(this.timeoutMs)\n : undefined,\n });\n if (!res.ok) {\n const err = new Error(`HTTP ${res.status}: ${res.statusText}`);\n this.onError?.(err, event);\n }\n } catch (e) {\n this.onError?.(e, event);\n }\n };\n\n const p = run();\n this.track(p);\n if (this.awaitEach) return p;\n void p;\n }\n\n /** Waits until every started request has settled (success or failure). */\n flush(): Promise<void> {\n if (this.inFlight.size === 0) return Promise.resolve();\n return Promise.all([...this.inFlight]).then(() => {});\n }\n\n /** Stops accepting new events and waits for in-flight requests to finish. */\n async shutdown(): Promise<void> {\n this.closed = true;\n await this.flush();\n }\n}\n","import type { ExecutionEvent, Exporter } from \"../types.js\";\nimport { isPromiseLike } from \"../runtime.js\";\n\nexport type QueueOverflowStrategy = \"drop-newest\" | \"drop-oldest\";\n\nexport interface BoundedQueueExporterOptions {\n /** Downstream exporter (often {@link import(\"./http.js\").HttpExporter}). */\n exporter: Exporter;\n /** Maximum concurrent async exports to the inner exporter (default `4`). */\n maxConcurrent?: number;\n /**\n * Maximum **queued** events waiting for a worker slot (default `1000`).\n * Use `0` for unlimited backlog (not recommended under sustained overload).\n */\n maxQueue?: number;\n /** How to handle overflow when the queue is full (default `drop-newest`). */\n strategy?: QueueOverflowStrategy;\n onDrop?: (event: ExecutionEvent, reason: string) => void;\n onInnerError?: (error: unknown, event: ExecutionEvent) => void;\n}\n\n/**\n * Bounded concurrency + backlog for async-heavy exporters.\n * Sync inner exporters run on the microtask queue and still respect {@link maxConcurrent}.\n */\nexport class BoundedQueueExporter implements Exporter {\n private readonly inner: Exporter;\n private readonly maxConcurrent: number;\n private readonly maxQueue: number;\n private readonly strategy: QueueOverflowStrategy;\n private readonly onDrop?: (event: ExecutionEvent, reason: string) => void;\n private readonly onInnerError?: (error: unknown, event: ExecutionEvent) => void;\n\n private readonly queue: ExecutionEvent[] = [];\n private active = 0;\n /** When false, {@link export} drops events with reason `shutdown`; queued work still drains. */\n private accepting = true;\n private idleResolvers: Array<() => void> = [];\n\n constructor(options: BoundedQueueExporterOptions) {\n const inner = options.exporter;\n if (\n inner == null ||\n typeof inner !== \"object\" ||\n typeof inner.export !== \"function\"\n ) {\n throw new TypeError(\n 'BoundedQueueExporter: \"exporter\" must be an object with an export() method',\n );\n }\n this.inner = inner;\n const rawMc = options.maxConcurrent ?? 4;\n this.maxConcurrent = !Number.isFinite(rawMc) ? 4 : Math.max(1, Math.trunc(rawMc));\n const rawQ = options.maxQueue ?? 1000;\n if (!Number.isFinite(rawQ)) {\n this.maxQueue = 1000;\n } else {\n const q = Math.trunc(rawQ);\n if (q === 0) {\n this.maxQueue = 0;\n } else if (q < 0) {\n this.maxQueue = 1000;\n } else {\n this.maxQueue = q;\n }\n }\n const strategy = options.strategy ?? \"drop-newest\";\n if (strategy !== \"drop-newest\" && strategy !== \"drop-oldest\") {\n throw new TypeError(\n 'BoundedQueueExporter: \"strategy\" must be \"drop-newest\" or \"drop-oldest\"',\n );\n }\n this.strategy = strategy;\n this.onDrop = options.onDrop;\n this.onInnerError = options.onInnerError;\n }\n\n export(event: ExecutionEvent): void {\n if (!this.accepting) {\n this.onDrop?.(event, \"shutdown\");\n return;\n }\n\n const cap = this.maxQueue <= 0 ? Number.POSITIVE_INFINITY : this.maxQueue;\n\n if (this.queue.length >= cap) {\n if (this.strategy === \"drop-oldest\") {\n // `length >= cap` and finite cap imply a non-empty queue before push.\n const dropped = this.queue.shift()!;\n this.onDrop?.(dropped, \"queue-overflow-drop-oldest\");\n this.queue.push(event);\n } else {\n this.onDrop?.(event, \"queue-overflow-drop-newest\");\n }\n this.pump();\n return;\n }\n\n this.queue.push(event);\n this.pump();\n }\n\n private pump(): void {\n while (this.active < this.maxConcurrent && this.queue.length > 0) {\n const next = this.queue.shift()!;\n this.active++;\n void this.runInner(next).finally(() => {\n this.active--;\n this.pump();\n this.resolveIdleWaitersIfNeeded();\n });\n }\n }\n\n private async runInner(event: ExecutionEvent): Promise<void> {\n try {\n const r = this.inner.export(event);\n if (isPromiseLike(r)) await r;\n } catch (e) {\n this.onInnerError?.(e, event);\n }\n }\n\n private resolveIdleWaitersIfNeeded(): void {\n if (this.queue.length === 0 && this.active === 0) {\n const waiters = this.idleResolvers;\n this.idleResolvers = [];\n for (const r of waiters) r();\n }\n }\n\n /** Resolves when the queue is empty and no inner export is in flight. */\n flush(): Promise<void> {\n if (this.queue.length === 0 && this.active === 0) {\n return Promise.resolve();\n }\n return new Promise((resolve) => {\n this.idleResolvers.push(resolve);\n });\n }\n\n /**\n * Stops accepting new events; does **not** drop items already in the queue—\n * {@link flush} waits until queued and in-flight work finishes.\n */\n async shutdown(): Promise<void> {\n this.accepting = false;\n await this.flush();\n }\n}\n","/**\n * @packageDocumentation\n * Structured `ExecutionEvent` emission for verification / ingest pipelines.\n */\n\nimport { IntentProofClient, getIntentProofClient } from \"./client.js\";\nimport type { IntentProofConfig } from \"./types.js\";\n\n/** Injected at build (`tsup`) and test (`vitest`) time from `package.json` — single source of truth. */\ndeclare const __INTENTPROOF_SDK_VERSION__: string;\n\nexport const VERSION = __INTENTPROOF_SDK_VERSION__;\n\nexport type {\n ExecutionError,\n ExecutionErrorSnapshot,\n ExecutionEvent,\n ExecutionEventBase,\n ExecutionStatus,\n Exporter,\n IntentProofConfig,\n IntentProofExecutionEventV1,\n IntentProofRuntimeConfigV1,\n IntentProofWrapOptionsV1,\n JsonValue,\n SerializeOptions,\n WrapOptions,\n} from \"./types.js\";\n\nexport { snapshot } from \"./snapshot.js\";\n\nexport { MemoryExporter } from \"./exporters/memory.js\";\nexport type { MemoryExporterOptions } from \"./exporters/memory.js\";\n\nexport { HttpExporter } from \"./exporters/http.js\";\nexport type { HttpExporterOptions } from \"./exporters/http.js\";\n\nexport { BoundedQueueExporter } from \"./exporters/queue.js\";\nexport type {\n BoundedQueueExporterOptions,\n QueueOverflowStrategy,\n} from \"./exporters/queue.js\";\n\nexport {\n IntentProofClient,\n assertCorrelationId,\n assertWrapOptionsShape,\n getCorrelationId,\n getIntentProofClient,\n runWithCorrelationId,\n} from \"./client.js\";\n\nexport {\n assertValidExecutionEventWire,\n validateExecutionEvent,\n validateIntentProofConfig,\n validateWrapOptions,\n} from \"./validators.js\";\n\n/** Default singleton — same instance as `getIntentProofClient()`. */\nexport const client = getIntentProofClient();\n\n/** Isolated client instance (tests, workers, per-tenant configuration). */\nexport function createIntentProofClient(config?: IntentProofConfig): IntentProofClient {\n return new IntentProofClient(config);\n}\n"],"mapp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"name": "@intentproof/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"intentproofSpecVersion": "spec-v1.0.1",
|
|
5
|
+
"intentproofSpecCommit": "74ea3a23ea80dbe6549338d0612b543a26ebbaf1",
|
|
4
6
|
"description": "TypeScript SDK for IntentProof",
|
|
5
7
|
"license": "Apache-2.0",
|
|
6
8
|
"repository": {
|
|
7
9
|
"type": "git",
|
|
8
|
-
"url": "
|
|
10
|
+
"url": "https://github.com/IntentProof/intentproof-sdk-node",
|
|
9
11
|
"directory": "packages/sdk"
|
|
10
12
|
},
|
|
11
13
|
"keywords": [
|
|
14
|
+
"IntentProof",
|
|
12
15
|
"intentproof",
|
|
13
16
|
"execution-events",
|
|
14
17
|
"telemetry",
|
|
@@ -38,6 +41,10 @@
|
|
|
38
41
|
"README.md"
|
|
39
42
|
],
|
|
40
43
|
"sideEffects": false,
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"ajv": "^8.17.1",
|
|
46
|
+
"ajv-formats": "^3.0.1"
|
|
47
|
+
},
|
|
41
48
|
"scripts": {
|
|
42
49
|
"build": "tsup",
|
|
43
50
|
"dev": "tsup --watch",
|
|
@@ -51,21 +58,25 @@
|
|
|
51
58
|
"publint": "publint",
|
|
52
59
|
"sync-readme": "cp ../../README.md README.md",
|
|
53
60
|
"prepack": "npm run sync-readme",
|
|
54
|
-
"
|
|
61
|
+
"generate:types": "bash ../../scripts/generate-schema-types.sh",
|
|
62
|
+
"verify:types": "bash ../../scripts/verify-generated-types.sh",
|
|
63
|
+
"ci": "npm run sync-readme && bash ../../scripts/check-sdk-spec-pin.sh \"${INTENTPROOF_SPEC_ROOT:?}\" && bash ../../scripts/check-no-bundled-schema.sh && bash ../../scripts/check-no-handwritten-model-types.sh && npm run verify:types && npm run typecheck && npm run lint && npm run format:check && npm run test:coverage && npm run build && npm run publint"
|
|
55
64
|
},
|
|
56
65
|
"devDependencies": {
|
|
57
|
-
"@eslint/js": "^
|
|
58
|
-
"@types/node": "^
|
|
59
|
-
"@vitest/coverage-v8": "^
|
|
60
|
-
"
|
|
61
|
-
"eslint
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
66
|
+
"@eslint/js": "^10.0.1",
|
|
67
|
+
"@types/node": "^25.6.0",
|
|
68
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
69
|
+
"json-stable-stringify": "^1.0.1",
|
|
70
|
+
"eslint": "^10.3.0",
|
|
71
|
+
"eslint-config-prettier": "^10.1.8",
|
|
72
|
+
"globals": "^17.6.0",
|
|
73
|
+
"json-schema-to-typescript": "15.0.4",
|
|
74
|
+
"prettier": "^3.8.3",
|
|
75
|
+
"publint": "^0.3.18",
|
|
76
|
+
"tsup": "^8.5.1",
|
|
77
|
+
"typescript": "^6.0.3",
|
|
67
78
|
"typescript-eslint": "^8.59.1",
|
|
68
|
-
"vitest": "^
|
|
79
|
+
"vitest": "^4.1.5"
|
|
69
80
|
},
|
|
70
81
|
"engines": {
|
|
71
82
|
"node": ">=22"
|