@botpress/evals 2.0.0-alpha.0 → 2.0.1-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client.js +39 -1
- package/dist/client.js.map +3 -3
- package/dist/loader.js +39 -1
- package/dist/loader.js.map +3 -3
- package/dist/runner.js +44 -2
- package/dist/runner.js.map +3 -3
- package/dist/spans/index.js +39 -1
- package/dist/spans/index.js.map +3 -3
- package/dist/spans/local-span-source.js +39 -1
- package/dist/spans/local-span-source.js.map +3 -3
- package/dist/spans/sse-collector.js +39 -1
- package/dist/spans/sse-collector.js.map +3 -3
- package/dist/stores/eval-definition-loader.js +39 -1
- package/dist/stores/eval-definition-loader.js.map +3 -3
- package/dist/stores/index.js +39 -1
- package/dist/stores/index.js.map +3 -3
- package/dist/stores/local-eval-store.js +39 -1
- package/dist/stores/local-eval-store.js.map +3 -3
- package/dist/stores/vortex-eval-store-entry.js +39 -1
- package/dist/stores/vortex-eval-store-entry.js.map +3 -3
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/errors.ts", "../../src/spans/sse-collector.ts"],
|
|
4
|
-
"sourcesContent": ["import { AdkError } from '@botpress/analytics'\n\n/**\n * Stable error codes for the eval engine. Typed as a literal union so a typo'd\n * code is a compile error and PostHog issue-slicing stays consistent.\n * Conventions per docs/ERROR-HANDLING.md.\n */\nexport const EVAL_ERROR_CODES = [\n 'EVAL_LOAD_FAILED',\n 'EVAL_FILE_EMPTY',\n 'EVAL_DUPLICATE_NAME',\n 'EVAL_SEED_NO_CONVERSATION',\n 'EVAL_NO_CONVERSATION_ID',\n 'EVAL_TURN_CONFIG_INVALID',\n 'SSE_CONNECT_FAILED',\n 'SSE_NO_BODY',\n 'CHAT_CLIENT_MISSING',\n 'CHAT_NOT_CONNECTED',\n 'CHAT_INTEGRATION_MISSING',\n 'CHAT_CHANNEL_UNBOUND',\n] as const\n\nexport type EvalErrorCode = (typeof EVAL_ERROR_CODES)[number]\n\n/**\n * Typed error for the eval engine. Named EvalRunnerError (not EvalError) to\n * avoid shadowing the JS built-in `EvalError`.\n */\nexport class EvalRunnerError extends AdkError<EvalErrorCode> {}\n", "/**\n * SSECollector \u2014 connects to the ADK dev server's SSE trace stream,\n * accumulates spans, and provides promise-based wait methods for\n * turn completion and workflow signals.\n *\n * Uses fetch() + async iteration with manual SSE line parsing\n * (Bun does not have native EventSource).\n */\n\nimport type { Span } from './trace'\nimport { EvalRunnerError } from '../errors'\n\ntype SSEFilter = { conversationId: string } | { workflowId: string }\n\ninterface WaitOptions {\n timeout: number\n /**\n * Optional abort signal \u2014 when fired, the wait rejects immediately rather\n * than burning the full timeout. Used by the runner so Stop unblocks\n * pending workflow assertions (otherwise a single negative-result wait\n * can hold the suite hostage for `idleTimeout` per assertion).\n */\n abortSignal?: AbortSignal\n}\n\ninterface WorkflowWaitOptions extends WaitOptions {\n signal: 'entered' | 'completed'\n}\n\ninterface TurnWaitOptions extends WaitOptions {\n /**\n * Which handler span names may complete this turn. A user-message turn\n * completes via `handler.conversation` only \u2014 async noise such as a\n * workflow callback closes a silent `handler.event` span, and counting it\n * releases the runner early, whose next message then interrupts the\n * still-running handler. An event-driven turn completes via\n * `handler.event`. Omitted = any turn-handler span (legacy behavior).\n */\n acceptSpanNames?: ReadonlySet<string>\n /**\n * Quiet window after the handler closes before the turn is considered\n * settled (default 100 ms). The runner raises it so async follow-through\n * the handler scheduled \u2014 a tool-started workflow run and its callback,\n * which only execute AFTER the handler closes \u2014 finishes before the next\n * message is sent. A message sent into that window can be absorbed by the\n * follow-through's transcript save and silently skipped as already\n * processed.\n */\n settleQuietMs?: number\n /** Hard cap on the settle phase (default 2 s; the runner raises it with settleQuietMs). */\n settleMaxMs?: number\n}\n\n/**\n * Unique key for span deduplication.\n */\nfunction spanKey(span: Span): string {\n return `${span.id.trace}:${span.id.span}`\n}\n\n/**\n * Type-safe accessor for span.data fields.\n */\nfunction spanData(span: Span): Record<string, unknown> {\n return span.data && typeof span.data === 'object' ? (span.data as Record<string, unknown>) : {}\n}\n\n/**\n * Span names that mark a Conversation handler reaching the end of a turn.\n *\n * A turn driven by a user message emits `handler.conversation`; a turn driven\n * by an event (a Conversation's `events:` subscription \u2014 e.g. greeting on a\n * conversation-start signal) emits `handler.event`. Both close exactly once\n * per handler invocation, so either is a valid \"turn complete\" signal.\n */\nconst TURN_HANDLER_SPAN_NAMES = new Set(['handler.conversation', 'handler.event'])\n\nfunction isTurnHandlerSpan(span: Span): boolean {\n return TURN_HANDLER_SPAN_NAMES.has(span.name)\n}\n\nexport class SSECollector {\n private devServerUrl: string\n private headers: Record<string, string>\n\n /** All spans accumulated since connect(), keyed by spanKey for dedup. */\n private spanMap = new Map<string, Span>()\n\n /** Index into spanMap insertion order marking where the current turn started. */\n private turnStartKeys = new Set<string>()\n\n /** Handler span IDs seen before the current turn (for startTurn filtering). */\n private seenHandlerKeys = new Set<string>()\n\n /** Callbacks waiting for span updates. */\n private waiters: Array<(span: Span) => void> = []\n\n /** AbortController for the active SSE connection. */\n private abortController: AbortController | null = null\n\n /** Whether the background loop is running. */\n private connected = false\n\n /** Error from the SSE stream if it died unexpectedly. */\n private streamError: Error | null = null\n\n /** Passive counters used only to explain timeout failures. */\n private updateEventCount = 0\n private keepaliveEventCount = 0\n private lastEvent: { name: string; at: number } | null = null\n\n /** Set while a settle phase is in flight; called by disconnect() to short-circuit. */\n private _cancelSettle: (() => void) | null = null\n\n constructor(devServerUrl: string, headers: Record<string, string> = {}) {\n this.devServerUrl = devServerUrl\n this.headers = headers\n }\n\n /**\n * Open a streaming SSE connection filtered by conversationId or workflowId.\n * Starts a background loop that parses SSE events and accumulates spans.\n */\n async connect(filter: SSEFilter): Promise<void> {\n const attributeName = 'conversationId' in filter ? 'conversationId' : 'workflowId'\n const attributeValue = 'conversationId' in filter ? filter.conversationId : filter.workflowId\n\n const url = `${this.devServerUrl}/api/traces/stream?attributeName=${encodeURIComponent(attributeName)}&attributeValue=${encodeURIComponent(attributeValue)}`\n\n this.abortController = new AbortController()\n const myController = this.abortController\n\n const response = await fetch(url, {\n headers: { ...this.headers, Accept: 'text/event-stream' },\n signal: myController.signal,\n })\n\n if (!response.ok) {\n throw new EvalRunnerError({\n code: 'SSE_CONNECT_FAILED',\n message: `SSE connection failed: ${response.status} ${response.statusText}`,\n expected: true,\n suggestion: 'Make sure the dev server is running (`adk dev`) and reachable.',\n })\n }\n\n if (!response.body) {\n throw new EvalRunnerError({ code: 'SSE_NO_BODY', message: 'SSE response has no body' })\n }\n\n this.connected = true\n\n // Start background parsing loop\n this._consumeStream(response.body).catch((err) => {\n // Ignore the deliberate abort from repoint(): only the current stream's failure counts.\n if (this.connected && this.abortController === myController) {\n this.streamError = err instanceof Error ? err : new Error(String(err))\n }\n })\n\n // Wait for the initial snapshot to arrive before returning.\n // This ensures that connect() resolves only after the snapshot\n // has been processed so callers can immediately check spans.\n await this._waitForSnapshot()\n }\n\n /**\n * Re-point at a new conversation, keeping `spanMap` and `seenHandlerKeys` (so\n * the earlier conversation stays visible and its completed handler can't\n * satisfy the next turn). Resets the snapshot latch so connect() awaits the\n * new conversation's snapshot.\n */\n async repoint(filter: SSEFilter): Promise<void> {\n this.connected = false\n this.abortController?.abort()\n this.abortController = null\n this._cancelSettle?.()\n this._cancelSettle = null\n this.waiters = []\n this.snapshotReceived = false\n this.snapshotResolvers = []\n // Clear any prior stream's error so a later timeout reports the new\n // conversation's state, not a dead connection we intentionally closed.\n this.streamError = null\n await this.connect(filter)\n }\n\n /**\n * Mark the beginning of a new turn.\n * Records which turn-handler span IDs (handler.conversation / handler.event)\n * have been seen so far, so waitForTurnComplete() only resolves on NEW\n * handler completions.\n */\n startTurn(): void {\n // Snapshot the current set of span keys as the turn boundary\n this.turnStartKeys = new Set(this.spanMap.keys())\n\n // Record all turn-handler spans seen so far\n for (const [key, span] of this.spanMap) {\n if (isTurnHandlerSpan(span)) {\n this.seenHandlerKeys.add(key)\n }\n }\n }\n\n private static readonly SETTLE_MS = 100\n\n /**\n * Wait for a turn-handler span (handler.conversation or handler.event) to\n * reach terminal status (ok or error).\n * Only considers spans NOT seen before the last startTurn() call.\n *\n * After the handler closes, waits for a quiet period (no new spans for SETTLE_MS)\n * to ensure all child spans (tool calls, messages, state saves) have arrived.\n * The runtime's HttpSpanExporter fires POSTs without awaiting them, so child\n * spans may arrive slightly after the handler close event.\n */\n async waitForTurnComplete(opts: TurnWaitOptions): Promise<void> {\n const accept = opts.acceptSpanNames\n const settle = { quietMs: opts.settleQuietMs, maxMs: opts.settleMaxMs }\n // Check if a completed handler already exists (e.g. from snapshot)\n if (this._hasNewCompletedHandler(accept)) {\n return this._settleAfterHandler(settle)\n }\n if (opts.abortSignal?.aborted) {\n throw new Error('waitForTurnComplete aborted')\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n const expected = accept ? [...accept].join(' or ') : 'handler.conversation or handler.event'\n const reason = this.streamError\n ? `SSE stream died: ${this.streamError.message}`\n : `no ${expected} span completed`\n reject(\n new Error(\n `waitForTurnComplete timed out after ${opts.timeout}ms \u2014 ${reason}; diagnostics: ${this._formatTurnDiagnostics()}`\n )\n )\n }, opts.timeout)\n\n const onAbort = () => {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n reject(new Error('waitForTurnComplete aborted'))\n }\n opts.abortSignal?.addEventListener('abort', onAbort, { once: true })\n\n const waiter = (_span: Span) => {\n if (this._hasNewCompletedHandler(accept)) {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n this._settleAfterHandler(settle).then(resolve, reject)\n }\n }\n\n this.waiters.push(waiter)\n })\n }\n\n private static readonly MAX_SETTLE_MS = 2_000\n\n /**\n * After the handler span closes, wait for spans to stop arriving.\n * Resolves when no new spans arrive for SETTLE_MS, or after MAX_SETTLE_MS hard cap.\n *\n * Exposes a cancellation hook via _cancelSettle so disconnect() can short-\n * circuit an in-flight settle phase and avoid leaking timers for up to 2s.\n */\n private _settleAfterHandler(settle?: { quietMs?: number; maxMs?: number }): Promise<void> {\n const quietMs = settle?.quietMs ?? SSECollector.SETTLE_MS\n const maxMs = settle?.maxMs ?? SSECollector.MAX_SETTLE_MS\n return new Promise<void>((resolve) => {\n let resolved = false\n const done = () => {\n if (resolved) return\n resolved = true\n clearTimeout(hardCap)\n clearTimeout(settleTimer)\n this._removeWaiter(settleWaiter)\n this._cancelSettle = null\n resolve()\n }\n\n const hardCap = setTimeout(done, maxMs)\n\n let settleTimer = setTimeout(done, quietMs)\n\n const settleWaiter = () => {\n if (resolved) return\n clearTimeout(settleTimer)\n settleTimer = setTimeout(done, quietMs)\n }\n\n this.waiters.push(settleWaiter)\n this._cancelSettle = done\n })\n }\n\n /**\n * Wait for a handler.workflow span with matching workflow name.\n * - signal 'entered': resolves when the span appears (any status)\n * - signal 'completed': resolves when the span has status !== 'running'\n */\n async waitForWorkflow(name: string, opts: WorkflowWaitOptions): Promise<void> {\n // Check if condition is already met\n if (this._matchesWorkflowCondition(name, opts.signal)) {\n return\n }\n if (opts.abortSignal?.aborted) {\n throw new Error(`waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) aborted`)\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n const reason = this.streamError ? `SSE stream died: ${this.streamError.message}` : 'span not found'\n reject(\n new Error(\n `waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) timed out after ${opts.timeout}ms \u2014 ${reason}`\n )\n )\n }, opts.timeout)\n\n const onAbort = () => {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n reject(new Error(`waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) aborted`))\n }\n opts.abortSignal?.addEventListener('abort', onAbort, { once: true })\n\n const waiter = (_span: Span) => {\n if (this._matchesWorkflowCondition(name, opts.signal)) {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n resolve()\n }\n }\n\n this.waiters.push(waiter)\n })\n }\n\n /**\n * Return spans accumulated since the last startTurn() call.\n */\n getTurnSpans(): Span[] {\n const result: Span[] = []\n for (const [key, span] of this.spanMap) {\n if (!this.turnStartKeys.has(key)) {\n result.push(span)\n }\n }\n return result\n }\n\n /**\n * Return all spans accumulated since connect().\n */\n getAllSpans(): Span[] {\n return Array.from(this.spanMap.values())\n }\n\n /**\n * Close the SSE connection and clean up.\n */\n disconnect(): void {\n this.connected = false\n this.abortController?.abort()\n this.abortController = null\n // Short-circuit an in-flight settle phase so its hardCap / settleTimer\n // don't fire after disconnect.\n this._cancelSettle?.()\n this._cancelSettle = null\n // Waiters hold setTimeout references that will reject on their own;\n // clearing the array just prevents further notifications.\n this.waiters = []\n this.snapshotResolvers = []\n }\n\n // \u2500\u2500 Private \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /** Whether we have received the initial snapshot. */\n private snapshotReceived = false\n private snapshotResolvers: Array<() => void> = []\n\n private static readonly SNAPSHOT_TIMEOUT_MS = 10_000\n\n /**\n * Returns a promise that resolves once the snapshot event has been processed,\n * or rejects after a timeout to prevent connect() from hanging indefinitely.\n */\n private _waitForSnapshot(): Promise<void> {\n if (this.snapshotReceived) {\n return Promise.resolve()\n }\n return new Promise<void>((resolve, reject) => {\n let settled = false\n const resolver = () => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n resolve()\n }\n const timer = setTimeout(() => {\n if (settled) return\n settled = true\n const idx = this.snapshotResolvers.indexOf(resolver)\n if (idx !== -1) this.snapshotResolvers.splice(idx, 1)\n reject(\n new Error(\n `SSE snapshot not received within ${SSECollector.SNAPSHOT_TIMEOUT_MS}ms \u2014 is the dev server healthy?`\n )\n )\n }, SSECollector.SNAPSHOT_TIMEOUT_MS)\n this.snapshotResolvers.push(resolver)\n })\n }\n\n /**\n * Consume the ReadableStream body, parse SSE lines, and dispatch events.\n */\n private async _consumeStream(body: ReadableStream<Uint8Array>): Promise<void> {\n const decoder = new TextDecoder()\n let buffer = ''\n\n const reader = body.getReader()\n\n try {\n while (this.connected) {\n const { done, value } = await reader.read()\n if (done) break\n\n buffer += decoder.decode(value, { stream: true })\n\n // Split on double-newline boundaries to get complete SSE events\n const parts = buffer.split('\\n\\n')\n // The last part may be incomplete \u2014 keep it in the buffer\n buffer = parts.pop() ?? ''\n\n for (const part of parts) {\n this._parseSSEBlock(part)\n }\n }\n } finally {\n reader.releaseLock()\n }\n }\n\n /**\n * Parse a single SSE event block (text between \\n\\n boundaries).\n * Extracts event name and data payload.\n */\n private _parseSSEBlock(block: string): void {\n const lines = block.split('\\n')\n let eventName = ''\n let dataLine = ''\n\n for (const line of lines) {\n if (line.startsWith('event:')) {\n eventName = line.slice('event:'.length).trim()\n } else if (line.startsWith('data:')) {\n const value = line.slice('data:'.length).trim()\n dataLine = dataLine ? `${dataLine}\\n${value}` : value\n }\n // id: and retry: lines are ignored\n }\n\n if (!eventName || !dataLine) {\n // Could be a retry: line or empty block \u2014 skip\n if (!this.snapshotReceived && block.includes('retry:')) {\n // The retry line comes before the snapshot; don't resolve yet\n }\n return\n }\n\n try {\n const payload = JSON.parse(dataLine)\n this._handleEvent(eventName, payload)\n } catch {\n // Malformed JSON \u2014 skip\n }\n }\n\n /**\n * Dispatch a parsed SSE event to the appropriate handler.\n */\n private _handleEvent(eventName: string, payload: unknown): void {\n this._recordEvent(eventName)\n\n if (eventName === 'snapshot') {\n const data = payload as { spans: Span[] }\n const spans = Array.isArray(data.spans) ? data.spans : []\n for (const span of spans) {\n this._upsertSpan(span)\n }\n this.snapshotReceived = true\n for (const resolve of this.snapshotResolvers) {\n resolve()\n }\n this.snapshotResolvers = []\n } else if (eventName === 'update') {\n const data = payload as { span: Span }\n if (data.span) {\n this._upsertSpan(data.span)\n this._notifyWaiters(data.span)\n }\n }\n // keepalive events are intentionally ignored\n }\n\n private _recordEvent(eventName: string): void {\n this.lastEvent = { name: eventName, at: Date.now() }\n\n if (eventName === 'update') {\n this.updateEventCount++\n } else if (eventName === 'keepalive') {\n this.keepaliveEventCount++\n }\n }\n\n private _formatTurnDiagnostics(): string {\n const turnSpans = this.getTurnSpans()\n const spanNames = new Set<string>()\n const handlerStatuses = new Set<string>()\n\n for (const span of turnSpans) {\n spanNames.add(span.name)\n // Tracks both handler.conversation and handler.event so an event-driven\n // turn that times out still surfaces its handler status.\n if (isTurnHandlerSpan(span)) {\n handlerStatuses.add(span.status)\n }\n }\n\n const lastEvent = this.lastEvent ? `${this.lastEvent.name} ${Date.now() - this.lastEvent.at}ms ago` : 'none'\n\n return [\n `snapshotReceived=${this.snapshotReceived}`,\n `totalUpdates=${this.updateEventCount}`,\n `totalKeepalives=${this.keepaliveEventCount}`,\n `lastEvent=${lastEvent}`,\n `totalSpans=${this.spanMap.size}`,\n `turnSpans=${turnSpans.length}`,\n `turnSpanNames=${this._formatSet(spanNames)}`,\n `turnHandlerStatuses=${this._formatSet(handlerStatuses)}`,\n ].join(', ')\n }\n\n private _formatSet(values: Set<string>, limit = 12): string {\n if (values.size === 0) {\n return 'none'\n }\n\n const items = Array.from(values)\n const suffix = items.length > limit ? `|+${items.length - limit} more` : ''\n return `${items.slice(0, limit).join('|')}${suffix}`\n }\n\n /**\n * Insert or replace a span in the map (dedup by trace+span ID).\n */\n private _upsertSpan(span: Span): void {\n this.spanMap.set(spanKey(span), span)\n }\n\n /**\n * Notify all waiters that a new span was received.\n */\n private _notifyWaiters(span: Span): void {\n // Copy the array since waiters may remove themselves during iteration\n const current = [...this.waiters]\n for (const waiter of current) {\n waiter(span)\n }\n }\n\n /**\n * Remove a waiter callback from the list.\n */\n private _removeWaiter(fn: (span: Span) => void): void {\n const idx = this.waiters.indexOf(fn)\n if (idx !== -1) {\n this.waiters.splice(idx, 1)\n }\n }\n\n /**\n * Check if there is a turn-handler span (handler.conversation / handler.event) that:\n * 1. Was NOT seen before startTurn()\n * 2. Has terminal status (ok or error)\n *\n * Marks the matched key as consumed so the same handler span cannot\n * satisfy both the current turn's settle phase AND the next turn's\n * waitForTurnComplete check (which would otherwise resolve instantly\n * against stale data instead of waiting for the new turn's handler).\n */\n private _hasNewCompletedHandler(acceptSpanNames?: ReadonlySet<string>): boolean {\n for (const [key, span] of this.spanMap) {\n if (\n isTurnHandlerSpan(span) &&\n (!acceptSpanNames || acceptSpanNames.has(span.name)) &&\n !this.seenHandlerKeys.has(key) &&\n (span.status === 'ok' || span.status === 'error')\n ) {\n this.seenHandlerKeys.add(key)\n return true\n }\n }\n return false\n }\n\n /**\n * Check if a handler.workflow span matches the given condition.\n */\n private _matchesWorkflowCondition(name: string, signal: 'entered' | 'completed'): boolean {\n for (const span of this.spanMap.values()) {\n if (span.name !== 'handler.workflow') continue\n\n const d = spanData(span)\n const wfName = d['workflow.name'] || d['workflowName']\n if (wfName !== name) continue\n\n if (signal === 'entered') {\n // Any status means the workflow was entered\n return true\n }\n\n if (signal === 'completed') {\n return span.status === 'ok' || span.status === 'error'\n }\n }\n return false\n }\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,
|
|
3
|
+
"sources": ["../../../analytics/src/errors.ts", "../../src/errors.ts", "../../src/spans/sse-collector.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Shared base error for ADK packages. Lives in `@botpress/analytics` because\n * it's the dependency-light package every surface already shares (cli, adk,\n * ui) \u2014 so all typed errors can genuinely inherit one base instead of\n * mirroring its shape.\n *\n * The policy lives in docs/ERROR-HANDLING.md. The short version: every error\n * we *intend* to throw should carry a stable `code` (so PostHog error\n * tracking can slice issues by code) and an `expected` flag separating\n * user/environment conditions (bad input, not logged in, network down \u2014 render\n * a friendly message, low alert priority) from internal bugs (invariant\n * violations \u2014 full stack, page someone).\n *\n * The runtime package is out of scope and keeps its own `Errors.AbstractError`\n * hierarchy. The adk typed families (`DependencyError`, `Agent0*Error`) extend\n * this base; new code should start here.\n */\nexport class AdkError<Code extends string = string> extends Error {\n /**\n * Marker for cross-module-instance checks \u2014 `instanceof` breaks when a\n * package is duplicated in the dependency graph.\n * @internal\n */\n public static readonly __IS_ADK_BASE_ERROR = true\n\n /**\n * Stable SCREAMING_SNAKE_CASE identifier, e.g. 'BOT_NOT_FOUND'. Subclasses\n * pin `Code` to a literal union (`class EvalRunnerError extends\n * AdkError<EvalErrorCode>`) so typos are compile errors and `code` narrows\n * in switches.\n */\n readonly code: Code\n /**\n * True for user/environment conditions the developer can fix themselves\n * (validation, auth, connectivity). False for internal bugs. Defaults to\n * false so unclassified errors surface as bugs until someone triages them.\n */\n readonly expected: boolean\n /** Structured context. Sanitized before any telemetry leaves the machine. */\n readonly details?: Record<string, unknown>\n /** Actionable next step shown to the user, e.g. \"Run 'adk login' first.\" */\n readonly suggestion?: string\n\n constructor(opts: {\n code: Code\n message: string\n expected?: boolean\n details?: Record<string, unknown>\n suggestion?: string\n cause?: unknown\n }) {\n super(opts.message, opts.cause !== undefined ? { cause: opts.cause } : undefined)\n this.name = this.constructor.name\n this.code = opts.code\n this.expected = opts.expected ?? false\n // Conditional assignment keeps the optional fields absent-not-undefined,\n // which downstream tsconfigs with exactOptionalPropertyTypes require.\n if (opts.details !== undefined) {\n this.details = opts.details\n }\n if (opts.suggestion !== undefined) {\n this.suggestion = opts.suggestion\n }\n }\n}\n\n/**\n * Duck-typed guard that survives duplicated module instances in the\n * dependency graph, where `instanceof AdkError` returns false for an error\n * constructed from another copy of this module. No manual prototype walking\n * needed: static properties are inherited through the constructor chain, so\n * a subclass's constructor resolves the marker in one lookup.\n */\nexport function isAdkError(error: unknown): error is AdkError {\n if (error instanceof AdkError) return true\n if (!(error instanceof Error)) return false\n return (error.constructor as unknown as Record<string, unknown> | undefined)?.__IS_ADK_BASE_ERROR === true\n}\n", "import { AdkError } from '@botpress/analytics'\n\n/**\n * Stable error codes for the eval engine. Typed as a literal union so a typo'd\n * code is a compile error and PostHog issue-slicing stays consistent.\n * Conventions per docs/ERROR-HANDLING.md.\n */\nexport const EVAL_ERROR_CODES = [\n 'EVAL_LOAD_FAILED',\n 'EVAL_FILE_EMPTY',\n 'EVAL_DUPLICATE_NAME',\n 'EVAL_SEED_NO_CONVERSATION',\n 'EVAL_NO_CONVERSATION_ID',\n 'EVAL_TURN_CONFIG_INVALID',\n 'SSE_CONNECT_FAILED',\n 'SSE_NO_BODY',\n 'CHAT_CLIENT_MISSING',\n 'CHAT_NOT_CONNECTED',\n 'CHAT_INTEGRATION_MISSING',\n 'CHAT_CHANNEL_UNBOUND',\n] as const\n\nexport type EvalErrorCode = (typeof EVAL_ERROR_CODES)[number]\n\n/**\n * Typed error for the eval engine. Named EvalRunnerError (not EvalError) to\n * avoid shadowing the JS built-in `EvalError`.\n */\nexport class EvalRunnerError extends AdkError<EvalErrorCode> {}\n", "/**\n * SSECollector \u2014 connects to the ADK dev server's SSE trace stream,\n * accumulates spans, and provides promise-based wait methods for\n * turn completion and workflow signals.\n *\n * Uses fetch() + async iteration with manual SSE line parsing\n * (Bun does not have native EventSource).\n */\n\nimport type { Span } from './trace'\nimport { EvalRunnerError } from '../errors'\n\ntype SSEFilter = { conversationId: string } | { workflowId: string }\n\ninterface WaitOptions {\n timeout: number\n /**\n * Optional abort signal \u2014 when fired, the wait rejects immediately rather\n * than burning the full timeout. Used by the runner so Stop unblocks\n * pending workflow assertions (otherwise a single negative-result wait\n * can hold the suite hostage for `idleTimeout` per assertion).\n */\n abortSignal?: AbortSignal\n}\n\ninterface WorkflowWaitOptions extends WaitOptions {\n signal: 'entered' | 'completed'\n}\n\ninterface TurnWaitOptions extends WaitOptions {\n /**\n * Which handler span names may complete this turn. A user-message turn\n * completes via `handler.conversation` only \u2014 async noise such as a\n * workflow callback closes a silent `handler.event` span, and counting it\n * releases the runner early, whose next message then interrupts the\n * still-running handler. An event-driven turn completes via\n * `handler.event`. Omitted = any turn-handler span (legacy behavior).\n */\n acceptSpanNames?: ReadonlySet<string>\n /**\n * Quiet window after the handler closes before the turn is considered\n * settled (default 100 ms). The runner raises it so async follow-through\n * the handler scheduled \u2014 a tool-started workflow run and its callback,\n * which only execute AFTER the handler closes \u2014 finishes before the next\n * message is sent. A message sent into that window can be absorbed by the\n * follow-through's transcript save and silently skipped as already\n * processed.\n */\n settleQuietMs?: number\n /** Hard cap on the settle phase (default 2 s; the runner raises it with settleQuietMs). */\n settleMaxMs?: number\n}\n\n/**\n * Unique key for span deduplication.\n */\nfunction spanKey(span: Span): string {\n return `${span.id.trace}:${span.id.span}`\n}\n\n/**\n * Type-safe accessor for span.data fields.\n */\nfunction spanData(span: Span): Record<string, unknown> {\n return span.data && typeof span.data === 'object' ? (span.data as Record<string, unknown>) : {}\n}\n\n/**\n * Span names that mark a Conversation handler reaching the end of a turn.\n *\n * A turn driven by a user message emits `handler.conversation`; a turn driven\n * by an event (a Conversation's `events:` subscription \u2014 e.g. greeting on a\n * conversation-start signal) emits `handler.event`. Both close exactly once\n * per handler invocation, so either is a valid \"turn complete\" signal.\n */\nconst TURN_HANDLER_SPAN_NAMES = new Set(['handler.conversation', 'handler.event'])\n\nfunction isTurnHandlerSpan(span: Span): boolean {\n return TURN_HANDLER_SPAN_NAMES.has(span.name)\n}\n\nexport class SSECollector {\n private devServerUrl: string\n private headers: Record<string, string>\n\n /** All spans accumulated since connect(), keyed by spanKey for dedup. */\n private spanMap = new Map<string, Span>()\n\n /** Index into spanMap insertion order marking where the current turn started. */\n private turnStartKeys = new Set<string>()\n\n /** Handler span IDs seen before the current turn (for startTurn filtering). */\n private seenHandlerKeys = new Set<string>()\n\n /** Callbacks waiting for span updates. */\n private waiters: Array<(span: Span) => void> = []\n\n /** AbortController for the active SSE connection. */\n private abortController: AbortController | null = null\n\n /** Whether the background loop is running. */\n private connected = false\n\n /** Error from the SSE stream if it died unexpectedly. */\n private streamError: Error | null = null\n\n /** Passive counters used only to explain timeout failures. */\n private updateEventCount = 0\n private keepaliveEventCount = 0\n private lastEvent: { name: string; at: number } | null = null\n\n /** Set while a settle phase is in flight; called by disconnect() to short-circuit. */\n private _cancelSettle: (() => void) | null = null\n\n constructor(devServerUrl: string, headers: Record<string, string> = {}) {\n this.devServerUrl = devServerUrl\n this.headers = headers\n }\n\n /**\n * Open a streaming SSE connection filtered by conversationId or workflowId.\n * Starts a background loop that parses SSE events and accumulates spans.\n */\n async connect(filter: SSEFilter): Promise<void> {\n const attributeName = 'conversationId' in filter ? 'conversationId' : 'workflowId'\n const attributeValue = 'conversationId' in filter ? filter.conversationId : filter.workflowId\n\n const url = `${this.devServerUrl}/api/traces/stream?attributeName=${encodeURIComponent(attributeName)}&attributeValue=${encodeURIComponent(attributeValue)}`\n\n this.abortController = new AbortController()\n const myController = this.abortController\n\n const response = await fetch(url, {\n headers: { ...this.headers, Accept: 'text/event-stream' },\n signal: myController.signal,\n })\n\n if (!response.ok) {\n throw new EvalRunnerError({\n code: 'SSE_CONNECT_FAILED',\n message: `SSE connection failed: ${response.status} ${response.statusText}`,\n expected: true,\n suggestion: 'Make sure the dev server is running (`adk dev`) and reachable.',\n })\n }\n\n if (!response.body) {\n throw new EvalRunnerError({ code: 'SSE_NO_BODY', message: 'SSE response has no body' })\n }\n\n this.connected = true\n\n // Start background parsing loop\n this._consumeStream(response.body).catch((err) => {\n // Ignore the deliberate abort from repoint(): only the current stream's failure counts.\n if (this.connected && this.abortController === myController) {\n this.streamError = err instanceof Error ? err : new Error(String(err))\n }\n })\n\n // Wait for the initial snapshot to arrive before returning.\n // This ensures that connect() resolves only after the snapshot\n // has been processed so callers can immediately check spans.\n await this._waitForSnapshot()\n }\n\n /**\n * Re-point at a new conversation, keeping `spanMap` and `seenHandlerKeys` (so\n * the earlier conversation stays visible and its completed handler can't\n * satisfy the next turn). Resets the snapshot latch so connect() awaits the\n * new conversation's snapshot.\n */\n async repoint(filter: SSEFilter): Promise<void> {\n this.connected = false\n this.abortController?.abort()\n this.abortController = null\n this._cancelSettle?.()\n this._cancelSettle = null\n this.waiters = []\n this.snapshotReceived = false\n this.snapshotResolvers = []\n // Clear any prior stream's error so a later timeout reports the new\n // conversation's state, not a dead connection we intentionally closed.\n this.streamError = null\n await this.connect(filter)\n }\n\n /**\n * Mark the beginning of a new turn.\n * Records which turn-handler span IDs (handler.conversation / handler.event)\n * have been seen so far, so waitForTurnComplete() only resolves on NEW\n * handler completions.\n */\n startTurn(): void {\n // Snapshot the current set of span keys as the turn boundary\n this.turnStartKeys = new Set(this.spanMap.keys())\n\n // Record all turn-handler spans seen so far\n for (const [key, span] of this.spanMap) {\n if (isTurnHandlerSpan(span)) {\n this.seenHandlerKeys.add(key)\n }\n }\n }\n\n private static readonly SETTLE_MS = 100\n\n /**\n * Wait for a turn-handler span (handler.conversation or handler.event) to\n * reach terminal status (ok or error).\n * Only considers spans NOT seen before the last startTurn() call.\n *\n * After the handler closes, waits for a quiet period (no new spans for SETTLE_MS)\n * to ensure all child spans (tool calls, messages, state saves) have arrived.\n * The runtime's HttpSpanExporter fires POSTs without awaiting them, so child\n * spans may arrive slightly after the handler close event.\n */\n async waitForTurnComplete(opts: TurnWaitOptions): Promise<void> {\n const accept = opts.acceptSpanNames\n const settle = { quietMs: opts.settleQuietMs, maxMs: opts.settleMaxMs }\n // Check if a completed handler already exists (e.g. from snapshot)\n if (this._hasNewCompletedHandler(accept)) {\n return this._settleAfterHandler(settle)\n }\n if (opts.abortSignal?.aborted) {\n throw new Error('waitForTurnComplete aborted')\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n const expected = accept ? [...accept].join(' or ') : 'handler.conversation or handler.event'\n const reason = this.streamError\n ? `SSE stream died: ${this.streamError.message}`\n : `no ${expected} span completed`\n reject(\n new Error(\n `waitForTurnComplete timed out after ${opts.timeout}ms \u2014 ${reason}; diagnostics: ${this._formatTurnDiagnostics()}`\n )\n )\n }, opts.timeout)\n\n const onAbort = () => {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n reject(new Error('waitForTurnComplete aborted'))\n }\n opts.abortSignal?.addEventListener('abort', onAbort, { once: true })\n\n const waiter = (_span: Span) => {\n if (this._hasNewCompletedHandler(accept)) {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n this._settleAfterHandler(settle).then(resolve, reject)\n }\n }\n\n this.waiters.push(waiter)\n })\n }\n\n private static readonly MAX_SETTLE_MS = 2_000\n\n /**\n * After the handler span closes, wait for spans to stop arriving.\n * Resolves when no new spans arrive for SETTLE_MS, or after MAX_SETTLE_MS hard cap.\n *\n * Exposes a cancellation hook via _cancelSettle so disconnect() can short-\n * circuit an in-flight settle phase and avoid leaking timers for up to 2s.\n */\n private _settleAfterHandler(settle?: { quietMs?: number; maxMs?: number }): Promise<void> {\n const quietMs = settle?.quietMs ?? SSECollector.SETTLE_MS\n const maxMs = settle?.maxMs ?? SSECollector.MAX_SETTLE_MS\n return new Promise<void>((resolve) => {\n let resolved = false\n const done = () => {\n if (resolved) return\n resolved = true\n clearTimeout(hardCap)\n clearTimeout(settleTimer)\n this._removeWaiter(settleWaiter)\n this._cancelSettle = null\n resolve()\n }\n\n const hardCap = setTimeout(done, maxMs)\n\n let settleTimer = setTimeout(done, quietMs)\n\n const settleWaiter = () => {\n if (resolved) return\n clearTimeout(settleTimer)\n settleTimer = setTimeout(done, quietMs)\n }\n\n this.waiters.push(settleWaiter)\n this._cancelSettle = done\n })\n }\n\n /**\n * Wait for a handler.workflow span with matching workflow name.\n * - signal 'entered': resolves when the span appears (any status)\n * - signal 'completed': resolves when the span has status !== 'running'\n */\n async waitForWorkflow(name: string, opts: WorkflowWaitOptions): Promise<void> {\n // Check if condition is already met\n if (this._matchesWorkflowCondition(name, opts.signal)) {\n return\n }\n if (opts.abortSignal?.aborted) {\n throw new Error(`waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) aborted`)\n }\n\n return new Promise<void>((resolve, reject) => {\n const timer = setTimeout(() => {\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n const reason = this.streamError ? `SSE stream died: ${this.streamError.message}` : 'span not found'\n reject(\n new Error(\n `waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) timed out after ${opts.timeout}ms \u2014 ${reason}`\n )\n )\n }, opts.timeout)\n\n const onAbort = () => {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n reject(new Error(`waitForWorkflow(\"${name}\", { signal: \"${opts.signal}\" }) aborted`))\n }\n opts.abortSignal?.addEventListener('abort', onAbort, { once: true })\n\n const waiter = (_span: Span) => {\n if (this._matchesWorkflowCondition(name, opts.signal)) {\n clearTimeout(timer)\n this._removeWaiter(waiter)\n opts.abortSignal?.removeEventListener('abort', onAbort)\n resolve()\n }\n }\n\n this.waiters.push(waiter)\n })\n }\n\n /**\n * Return spans accumulated since the last startTurn() call.\n */\n getTurnSpans(): Span[] {\n const result: Span[] = []\n for (const [key, span] of this.spanMap) {\n if (!this.turnStartKeys.has(key)) {\n result.push(span)\n }\n }\n return result\n }\n\n /**\n * Return all spans accumulated since connect().\n */\n getAllSpans(): Span[] {\n return Array.from(this.spanMap.values())\n }\n\n /**\n * Close the SSE connection and clean up.\n */\n disconnect(): void {\n this.connected = false\n this.abortController?.abort()\n this.abortController = null\n // Short-circuit an in-flight settle phase so its hardCap / settleTimer\n // don't fire after disconnect.\n this._cancelSettle?.()\n this._cancelSettle = null\n // Waiters hold setTimeout references that will reject on their own;\n // clearing the array just prevents further notifications.\n this.waiters = []\n this.snapshotResolvers = []\n }\n\n // \u2500\u2500 Private \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\n /** Whether we have received the initial snapshot. */\n private snapshotReceived = false\n private snapshotResolvers: Array<() => void> = []\n\n private static readonly SNAPSHOT_TIMEOUT_MS = 10_000\n\n /**\n * Returns a promise that resolves once the snapshot event has been processed,\n * or rejects after a timeout to prevent connect() from hanging indefinitely.\n */\n private _waitForSnapshot(): Promise<void> {\n if (this.snapshotReceived) {\n return Promise.resolve()\n }\n return new Promise<void>((resolve, reject) => {\n let settled = false\n const resolver = () => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n resolve()\n }\n const timer = setTimeout(() => {\n if (settled) return\n settled = true\n const idx = this.snapshotResolvers.indexOf(resolver)\n if (idx !== -1) this.snapshotResolvers.splice(idx, 1)\n reject(\n new Error(\n `SSE snapshot not received within ${SSECollector.SNAPSHOT_TIMEOUT_MS}ms \u2014 is the dev server healthy?`\n )\n )\n }, SSECollector.SNAPSHOT_TIMEOUT_MS)\n this.snapshotResolvers.push(resolver)\n })\n }\n\n /**\n * Consume the ReadableStream body, parse SSE lines, and dispatch events.\n */\n private async _consumeStream(body: ReadableStream<Uint8Array>): Promise<void> {\n const decoder = new TextDecoder()\n let buffer = ''\n\n const reader = body.getReader()\n\n try {\n while (this.connected) {\n const { done, value } = await reader.read()\n if (done) break\n\n buffer += decoder.decode(value, { stream: true })\n\n // Split on double-newline boundaries to get complete SSE events\n const parts = buffer.split('\\n\\n')\n // The last part may be incomplete \u2014 keep it in the buffer\n buffer = parts.pop() ?? ''\n\n for (const part of parts) {\n this._parseSSEBlock(part)\n }\n }\n } finally {\n reader.releaseLock()\n }\n }\n\n /**\n * Parse a single SSE event block (text between \\n\\n boundaries).\n * Extracts event name and data payload.\n */\n private _parseSSEBlock(block: string): void {\n const lines = block.split('\\n')\n let eventName = ''\n let dataLine = ''\n\n for (const line of lines) {\n if (line.startsWith('event:')) {\n eventName = line.slice('event:'.length).trim()\n } else if (line.startsWith('data:')) {\n const value = line.slice('data:'.length).trim()\n dataLine = dataLine ? `${dataLine}\\n${value}` : value\n }\n // id: and retry: lines are ignored\n }\n\n if (!eventName || !dataLine) {\n // Could be a retry: line or empty block \u2014 skip\n if (!this.snapshotReceived && block.includes('retry:')) {\n // The retry line comes before the snapshot; don't resolve yet\n }\n return\n }\n\n try {\n const payload = JSON.parse(dataLine)\n this._handleEvent(eventName, payload)\n } catch {\n // Malformed JSON \u2014 skip\n }\n }\n\n /**\n * Dispatch a parsed SSE event to the appropriate handler.\n */\n private _handleEvent(eventName: string, payload: unknown): void {\n this._recordEvent(eventName)\n\n if (eventName === 'snapshot') {\n const data = payload as { spans: Span[] }\n const spans = Array.isArray(data.spans) ? data.spans : []\n for (const span of spans) {\n this._upsertSpan(span)\n }\n this.snapshotReceived = true\n for (const resolve of this.snapshotResolvers) {\n resolve()\n }\n this.snapshotResolvers = []\n } else if (eventName === 'update') {\n const data = payload as { span: Span }\n if (data.span) {\n this._upsertSpan(data.span)\n this._notifyWaiters(data.span)\n }\n }\n // keepalive events are intentionally ignored\n }\n\n private _recordEvent(eventName: string): void {\n this.lastEvent = { name: eventName, at: Date.now() }\n\n if (eventName === 'update') {\n this.updateEventCount++\n } else if (eventName === 'keepalive') {\n this.keepaliveEventCount++\n }\n }\n\n private _formatTurnDiagnostics(): string {\n const turnSpans = this.getTurnSpans()\n const spanNames = new Set<string>()\n const handlerStatuses = new Set<string>()\n\n for (const span of turnSpans) {\n spanNames.add(span.name)\n // Tracks both handler.conversation and handler.event so an event-driven\n // turn that times out still surfaces its handler status.\n if (isTurnHandlerSpan(span)) {\n handlerStatuses.add(span.status)\n }\n }\n\n const lastEvent = this.lastEvent ? `${this.lastEvent.name} ${Date.now() - this.lastEvent.at}ms ago` : 'none'\n\n return [\n `snapshotReceived=${this.snapshotReceived}`,\n `totalUpdates=${this.updateEventCount}`,\n `totalKeepalives=${this.keepaliveEventCount}`,\n `lastEvent=${lastEvent}`,\n `totalSpans=${this.spanMap.size}`,\n `turnSpans=${turnSpans.length}`,\n `turnSpanNames=${this._formatSet(spanNames)}`,\n `turnHandlerStatuses=${this._formatSet(handlerStatuses)}`,\n ].join(', ')\n }\n\n private _formatSet(values: Set<string>, limit = 12): string {\n if (values.size === 0) {\n return 'none'\n }\n\n const items = Array.from(values)\n const suffix = items.length > limit ? `|+${items.length - limit} more` : ''\n return `${items.slice(0, limit).join('|')}${suffix}`\n }\n\n /**\n * Insert or replace a span in the map (dedup by trace+span ID).\n */\n private _upsertSpan(span: Span): void {\n this.spanMap.set(spanKey(span), span)\n }\n\n /**\n * Notify all waiters that a new span was received.\n */\n private _notifyWaiters(span: Span): void {\n // Copy the array since waiters may remove themselves during iteration\n const current = [...this.waiters]\n for (const waiter of current) {\n waiter(span)\n }\n }\n\n /**\n * Remove a waiter callback from the list.\n */\n private _removeWaiter(fn: (span: Span) => void): void {\n const idx = this.waiters.indexOf(fn)\n if (idx !== -1) {\n this.waiters.splice(idx, 1)\n }\n }\n\n /**\n * Check if there is a turn-handler span (handler.conversation / handler.event) that:\n * 1. Was NOT seen before startTurn()\n * 2. Has terminal status (ok or error)\n *\n * Marks the matched key as consumed so the same handler span cannot\n * satisfy both the current turn's settle phase AND the next turn's\n * waitForTurnComplete check (which would otherwise resolve instantly\n * against stale data instead of waiting for the new turn's handler).\n */\n private _hasNewCompletedHandler(acceptSpanNames?: ReadonlySet<string>): boolean {\n for (const [key, span] of this.spanMap) {\n if (\n isTurnHandlerSpan(span) &&\n (!acceptSpanNames || acceptSpanNames.has(span.name)) &&\n !this.seenHandlerKeys.has(key) &&\n (span.status === 'ok' || span.status === 'error')\n ) {\n this.seenHandlerKeys.add(key)\n return true\n }\n }\n return false\n }\n\n /**\n * Check if a handler.workflow span matches the given condition.\n */\n private _matchesWorkflowCondition(name: string, signal: 'entered' | 'completed'): boolean {\n for (const span of this.spanMap.values()) {\n if (span.name !== 'handler.workflow') continue\n\n const d = spanData(span)\n const wfName = d['workflow.name'] || d['workflowName']\n if (wfName !== name) continue\n\n if (signal === 'entered') {\n // Any status means the workflow was entered\n return true\n }\n\n if (signal === 'completed') {\n return span.status === 'ok' || span.status === 'error'\n }\n }\n return false\n }\n}\n"],
|
|
5
|
+
"mappings": ";AAiBO,IAAM,WAAN,cAAqD,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMhE,OAAuB,sBAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQpC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA;AAAA;AAAA,EAEA;AAAA;AAAA,EAEA;AAAA,EAET,YAAY,MAOT;AACD,UAAM,KAAK,SAAS,KAAK,UAAU,SAAY,EAAE,OAAO,KAAK,MAAM,IAAI,MAAS;AAChF,SAAK,OAAO,KAAK,YAAY;AAC7B,SAAK,OAAO,KAAK;AACjB,SAAK,WAAW,KAAK,YAAY;AAGjC,QAAI,KAAK,YAAY,QAAW;AAC9B,WAAK,UAAU,KAAK;AAAA,IACtB;AACA,QAAI,KAAK,eAAe,QAAW;AACjC,WAAK,aAAa,KAAK;AAAA,IACzB;AAAA,EACF;AACF;;;ACpCO,IAAM,kBAAN,cAA8B,SAAwB;AAAC;;;AC4B9D,SAAS,QAAQ,MAAoB;AACnC,SAAO,GAAG,KAAK,GAAG,KAAK,IAAI,KAAK,GAAG,IAAI;AACzC;AAKA,SAAS,SAAS,MAAqC;AACrD,SAAO,KAAK,QAAQ,OAAO,KAAK,SAAS,WAAY,KAAK,OAAmC,CAAC;AAChG;AAUA,IAAM,0BAA0B,oBAAI,IAAI,CAAC,wBAAwB,eAAe,CAAC;AAEjF,SAAS,kBAAkB,MAAqB;AAC9C,SAAO,wBAAwB,IAAI,KAAK,IAAI;AAC9C;AAEO,IAAM,eAAN,MAAM,cAAa;AAAA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,gBAAgB,IAAI,GAAG;AAC5B,eAAO;AAAA,MACT;AAAA,IACF;AACA,WAAO;AAAA,EACT;AAAA;AAAA;AAAA;AAAA,EAKQ,0BAA0B,MAAc,QAA0C;AACxF,eAAW,QAAQ,KAAK,QAAQ,OAAO,GAAG;AACxC,UAAI,KAAK,SAAS,mBAAoB;AAEtC,YAAM,IAAI,SAAS,IAAI;AACvB,YAAM,SAAS,EAAE,eAAe,KAAK,EAAE,cAAc;AACrD,UAAI,WAAW,KAAM;AAErB,UAAI,WAAW,WAAW;AAExB,eAAO;AAAA,MACT;AAEA,UAAI,WAAW,aAAa;AAC1B,eAAO,KAAK,WAAW,QAAQ,KAAK,WAAW;AAAA,MACjD;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -24,8 +24,46 @@ var Eval = class {
|
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
+
// ../analytics/src/errors.ts
|
|
28
|
+
var AdkError = class extends Error {
|
|
29
|
+
/**
|
|
30
|
+
* Marker for cross-module-instance checks — `instanceof` breaks when a
|
|
31
|
+
* package is duplicated in the dependency graph.
|
|
32
|
+
* @internal
|
|
33
|
+
*/
|
|
34
|
+
static __IS_ADK_BASE_ERROR = true;
|
|
35
|
+
/**
|
|
36
|
+
* Stable SCREAMING_SNAKE_CASE identifier, e.g. 'BOT_NOT_FOUND'. Subclasses
|
|
37
|
+
* pin `Code` to a literal union (`class EvalRunnerError extends
|
|
38
|
+
* AdkError<EvalErrorCode>`) so typos are compile errors and `code` narrows
|
|
39
|
+
* in switches.
|
|
40
|
+
*/
|
|
41
|
+
code;
|
|
42
|
+
/**
|
|
43
|
+
* True for user/environment conditions the developer can fix themselves
|
|
44
|
+
* (validation, auth, connectivity). False for internal bugs. Defaults to
|
|
45
|
+
* false so unclassified errors surface as bugs until someone triages them.
|
|
46
|
+
*/
|
|
47
|
+
expected;
|
|
48
|
+
/** Structured context. Sanitized before any telemetry leaves the machine. */
|
|
49
|
+
details;
|
|
50
|
+
/** Actionable next step shown to the user, e.g. "Run 'adk login' first." */
|
|
51
|
+
suggestion;
|
|
52
|
+
constructor(opts) {
|
|
53
|
+
super(opts.message, opts.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
54
|
+
this.name = this.constructor.name;
|
|
55
|
+
this.code = opts.code;
|
|
56
|
+
this.expected = opts.expected ?? false;
|
|
57
|
+
if (opts.details !== void 0) {
|
|
58
|
+
this.details = opts.details;
|
|
59
|
+
}
|
|
60
|
+
if (opts.suggestion !== void 0) {
|
|
61
|
+
this.suggestion = opts.suggestion;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
|
|
27
66
|
// src/errors.ts
|
|
28
|
-
import { AdkError } from "@botpress/analytics";
|
|
29
67
|
var EvalRunnerError = class extends AdkError {
|
|
30
68
|
};
|
|
31
69
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../../src/loader.ts", "../../src/definition.ts", "../../src/errors.ts", "../../src/stores/eval-definition-loader.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Eval file loader.\n * Loads *.eval.ts files from a directory using dynamic imports.\n * Supports both default and named exports, and multiple evals per file.\n */\n\nimport { readdirSync, existsSync } from 'fs'\nimport { resolve } from 'path'\nimport type { EvalDefinition, EvalFilter } from './types'\nimport { Eval } from './types'\nimport { EvalRunnerError } from './errors'\n\nfunction isEvalDefinition(value: unknown): value is EvalDefinition {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as Record<string, unknown>).name === 'string' &&\n (value as Record<string, unknown>).name !== '' &&\n Array.isArray((value as Record<string, unknown>).conversation)\n )\n}\n\nexport async function loadEvalFile(filePath: string): Promise<EvalDefinition[]> {\n const absPath = resolve(filePath)\n\n let mod: Record<string, unknown>\n try {\n mod = await import(absPath)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n // Guidance stays in the message until the CLI renders `suggestion`\n // (cli-package remediation) \u2014 report.error/logger.fatal only show message.\n throw new EvalRunnerError({\n code: 'EVAL_LOAD_FAILED',\n message:\n `Failed to load eval file ${filePath}: ${msg}\\n\\n` +\n 'Make sure your eval file:\\n' +\n ' - Has no syntax or type errors\\n' +\n ' - Exports one or more `new Eval({...})` instances\\n' +\n ' - Has all dependencies installed (`bun install`)',\n expected: true,\n cause: err,\n })\n }\n\n const results: EvalDefinition[] = []\n\n for (const [key, value] of Object.entries(mod)) {\n if (key === '__esModule') continue\n if (value instanceof Eval || isEvalDefinition(value)) {\n results.push(value)\n }\n }\n\n if (results.length === 0) {\n throw new EvalRunnerError({\n code: 'EVAL_FILE_EMPTY',\n message: `Invalid eval file ${filePath}: no valid evals found. Export one or more \\`new Eval({...})\\` instances (as default or named exports).`,\n expected: true,\n })\n }\n\n return results\n}\n\nexport async function loadEvalsFromDir(dirPath: string): Promise<EvalDefinition[]> {\n const absDir = resolve(dirPath)\n if (!existsSync(absDir)) {\n return []\n }\n\n const files = readdirSync(absDir).filter((f) => f.endsWith('.eval.ts'))\n const evals: EvalDefinition[] = []\n\n for (const f of files) {\n const defs = await loadEvalFile(`${absDir}/${f}`)\n evals.push(...defs)\n }\n\n const seen = new Set<string>()\n for (const e of evals) {\n if (seen.has(e.name)) {\n throw new EvalRunnerError({\n code: 'EVAL_DUPLICATE_NAME',\n message: `Duplicate eval name \"${e.name}\" found in ${dirPath} \u2014 names must be unique across the evals directory.`,\n expected: true,\n details: { name: e.name },\n })\n }\n seen.add(e.name)\n }\n\n return evals\n}\n\nexport async function loadEvalByName(dirPath: string, name: string): Promise<EvalDefinition | null> {\n const absDir = resolve(dirPath)\n if (!existsSync(absDir)) return null\n\n const files = readdirSync(absDir).filter((f) => f.endsWith('.eval.ts'))\n\n for (const f of files) {\n const defs = await loadEvalFile(`${absDir}/${f}`)\n const found = defs.find((d) => d.name === name)\n if (found) return found\n }\n\n return null\n}\n\nexport function filterEvals(evals: EvalDefinition[], filter?: EvalFilter): EvalDefinition[] {\n if (!filter) return evals\n\n return evals.filter((e) => {\n if (filter.names && filter.names.length > 0) {\n if (!filter.names.includes(e.name)) return false\n }\n if (filter.tags && filter.tags.length > 0) {\n if (!e.tags || !filter.tags.some((t) => e.tags!.includes(t))) return false\n }\n if (filter.type) {\n if (e.type !== filter.type) return false\n }\n return true\n })\n}\n", "export type MatchOperator =\n | string\n | { equals: unknown }\n | { contains: string }\n | { not_contains: string }\n | { matches: string }\n | { in: unknown[] }\n | { exists: boolean }\n | { gte: number }\n | { lte: number }\n\nexport type ResponseAssertion =\n | { contains: string }\n | { not_contains: string }\n | { matches: string }\n | { llm_judge: string }\n// | { similar_to: string } TODO: uncomment this when it gets implemented\n\nexport type ToolAssertion =\n | { called: string; params?: Record<string, MatchOperator> }\n | { not_called: string }\n | { call_order: string[] }\n\nexport interface StateAssertion {\n path: string\n equals?: unknown\n changed?: boolean\n}\n\nexport interface WorkflowAssertion {\n name: string\n entered?: boolean\n completed?: boolean\n}\n\nexport type NumericOperator = { equals: number } | { gte: number } | { lte: number }\n\nexport interface TimingAssertion {\n response_time: NumericOperator\n}\n\nexport interface TurnAssertions {\n response?: ResponseAssertion[]\n tools?: ToolAssertion[]\n state?: StateAssertion[]\n workflow?: WorkflowAssertion[]\n timing?: TimingAssertion[]\n}\n\nexport interface ConversationTurn {\n user?: string\n event?: { payload: Record<string, unknown> }\n expectSilence?: boolean\n assert?: TurnAssertions\n /**\n * Run this turn in a NEW conversation under the same user. The prior\n * transcript is absent, so recall here can only come from user-scoped\n * persistence, not context. Ignored on the first turn.\n */\n newConversation?: boolean\n}\n\nexport interface OutcomeAssertions {\n state?: StateAssertion[]\n workflow?: WorkflowAssertion[]\n}\n\nexport interface EvalSetup {\n state?: {\n bot?: Record<string, unknown>\n user?: Record<string, unknown>\n conversation?: Record<string, unknown>\n }\n workflow?: {\n trigger: string\n input?: Record<string, unknown>\n }\n}\n\nexport interface EvalDefinition {\n name: string\n description?: string\n tags?: string[]\n type?: 'capability' | 'regression'\n setup?: EvalSetup\n conversation: ConversationTurn[]\n outcome?: OutcomeAssertions\n options?: {\n idleTimeout?: number\n /** @deprecated No-op: the LLM judge is boolean (zai.check); there is no score threshold. */\n judgePassThreshold?: number\n }\n}\n\nexport class Eval implements EvalDefinition {\n readonly name: string\n readonly description?: string\n readonly tags?: string[]\n readonly type?: 'capability' | 'regression'\n readonly setup?: EvalSetup\n readonly conversation: ConversationTurn[]\n readonly outcome?: OutcomeAssertions\n readonly options?: {\n idleTimeout?: number\n /** @deprecated No-op: the LLM judge is boolean (zai.check); there is no score threshold. */\n judgePassThreshold?: number\n }\n\n constructor(def: EvalDefinition) {\n this.name = def.name\n this.conversation = def.conversation\n if (def.description !== undefined) this.description = def.description\n if (def.tags !== undefined) this.tags = def.tags\n if (def.type !== undefined) this.type = def.type\n if (def.setup !== undefined) this.setup = def.setup\n if (def.outcome !== undefined) this.outcome = def.outcome\n if (def.options !== undefined) this.options = def.options\n }\n}\n", "import { AdkError } from '@botpress/analytics'\n\n/**\n * Stable error codes for the eval engine. Typed as a literal union so a typo'd\n * code is a compile error and PostHog issue-slicing stays consistent.\n * Conventions per docs/ERROR-HANDLING.md.\n */\nexport const EVAL_ERROR_CODES = [\n 'EVAL_LOAD_FAILED',\n 'EVAL_FILE_EMPTY',\n 'EVAL_DUPLICATE_NAME',\n 'EVAL_SEED_NO_CONVERSATION',\n 'EVAL_NO_CONVERSATION_ID',\n 'EVAL_TURN_CONFIG_INVALID',\n 'SSE_CONNECT_FAILED',\n 'SSE_NO_BODY',\n 'CHAT_CLIENT_MISSING',\n 'CHAT_NOT_CONNECTED',\n 'CHAT_INTEGRATION_MISSING',\n 'CHAT_CHANNEL_UNBOUND',\n] as const\n\nexport type EvalErrorCode = (typeof EVAL_ERROR_CODES)[number]\n\n/**\n * Typed error for the eval engine. Named EvalRunnerError (not EvalError) to\n * avoid shadowing the JS built-in `EvalError`.\n */\nexport class EvalRunnerError extends AdkError<EvalErrorCode> {}\n", "import type { EvalDefinition } from '../definition'\nimport { loadEvalsFromDir } from '../loader'\n\nexport type EvalDefinitionLoader = () => Promise<EvalDefinition[]>\n\nexport function createDiskEvalLoader(evalsDir: string): EvalDefinitionLoader {\n return () => loadEvalsFromDir(evalsDir)\n}\n"],
|
|
5
|
-
"mappings": ";AAMA,SAAS,aAAa,kBAAkB;AACxC,SAAS,eAAe;;;ACuFjB,IAAM,OAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMT,YAAY,KAAqB;AAC/B,SAAK,OAAO,IAAI;AAChB,SAAK,eAAe,IAAI;AACxB,QAAI,IAAI,gBAAgB,OAAW,MAAK,cAAc,IAAI;AAC1D,QAAI,IAAI,SAAS,OAAW,MAAK,OAAO,IAAI;AAC5C,QAAI,IAAI,SAAS,OAAW,MAAK,OAAO,IAAI;AAC5C,QAAI,IAAI,UAAU,OAAW,MAAK,QAAQ,IAAI;AAC9C,QAAI,IAAI,YAAY,OAAW,MAAK,UAAU,IAAI;AAClD,QAAI,IAAI,YAAY,OAAW,MAAK,UAAU,IAAI;AAAA,EACpD;AACF;;;
|
|
3
|
+
"sources": ["../../src/loader.ts", "../../src/definition.ts", "../../../analytics/src/errors.ts", "../../src/errors.ts", "../../src/stores/eval-definition-loader.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Eval file loader.\n * Loads *.eval.ts files from a directory using dynamic imports.\n * Supports both default and named exports, and multiple evals per file.\n */\n\nimport { readdirSync, existsSync } from 'fs'\nimport { resolve } from 'path'\nimport type { EvalDefinition, EvalFilter } from './types'\nimport { Eval } from './types'\nimport { EvalRunnerError } from './errors'\n\nfunction isEvalDefinition(value: unknown): value is EvalDefinition {\n return (\n value !== null &&\n typeof value === 'object' &&\n typeof (value as Record<string, unknown>).name === 'string' &&\n (value as Record<string, unknown>).name !== '' &&\n Array.isArray((value as Record<string, unknown>).conversation)\n )\n}\n\nexport async function loadEvalFile(filePath: string): Promise<EvalDefinition[]> {\n const absPath = resolve(filePath)\n\n let mod: Record<string, unknown>\n try {\n mod = await import(absPath)\n } catch (err) {\n const msg = err instanceof Error ? err.message : String(err)\n // Guidance stays in the message until the CLI renders `suggestion`\n // (cli-package remediation) \u2014 report.error/logger.fatal only show message.\n throw new EvalRunnerError({\n code: 'EVAL_LOAD_FAILED',\n message:\n `Failed to load eval file ${filePath}: ${msg}\\n\\n` +\n 'Make sure your eval file:\\n' +\n ' - Has no syntax or type errors\\n' +\n ' - Exports one or more `new Eval({...})` instances\\n' +\n ' - Has all dependencies installed (`bun install`)',\n expected: true,\n cause: err,\n })\n }\n\n const results: EvalDefinition[] = []\n\n for (const [key, value] of Object.entries(mod)) {\n if (key === '__esModule') continue\n if (value instanceof Eval || isEvalDefinition(value)) {\n results.push(value)\n }\n }\n\n if (results.length === 0) {\n throw new EvalRunnerError({\n code: 'EVAL_FILE_EMPTY',\n message: `Invalid eval file ${filePath}: no valid evals found. Export one or more \\`new Eval({...})\\` instances (as default or named exports).`,\n expected: true,\n })\n }\n\n return results\n}\n\nexport async function loadEvalsFromDir(dirPath: string): Promise<EvalDefinition[]> {\n const absDir = resolve(dirPath)\n if (!existsSync(absDir)) {\n return []\n }\n\n const files = readdirSync(absDir).filter((f) => f.endsWith('.eval.ts'))\n const evals: EvalDefinition[] = []\n\n for (const f of files) {\n const defs = await loadEvalFile(`${absDir}/${f}`)\n evals.push(...defs)\n }\n\n const seen = new Set<string>()\n for (const e of evals) {\n if (seen.has(e.name)) {\n throw new EvalRunnerError({\n code: 'EVAL_DUPLICATE_NAME',\n message: `Duplicate eval name \"${e.name}\" found in ${dirPath} \u2014 names must be unique across the evals directory.`,\n expected: true,\n details: { name: e.name },\n })\n }\n seen.add(e.name)\n }\n\n return evals\n}\n\nexport async function loadEvalByName(dirPath: string, name: string): Promise<EvalDefinition | null> {\n const absDir = resolve(dirPath)\n if (!existsSync(absDir)) return null\n\n const files = readdirSync(absDir).filter((f) => f.endsWith('.eval.ts'))\n\n for (const f of files) {\n const defs = await loadEvalFile(`${absDir}/${f}`)\n const found = defs.find((d) => d.name === name)\n if (found) return found\n }\n\n return null\n}\n\nexport function filterEvals(evals: EvalDefinition[], filter?: EvalFilter): EvalDefinition[] {\n if (!filter) return evals\n\n return evals.filter((e) => {\n if (filter.names && filter.names.length > 0) {\n if (!filter.names.includes(e.name)) return false\n }\n if (filter.tags && filter.tags.length > 0) {\n if (!e.tags || !filter.tags.some((t) => e.tags!.includes(t))) return false\n }\n if (filter.type) {\n if (e.type !== filter.type) return false\n }\n return true\n })\n}\n", "export type MatchOperator =\n | string\n | { equals: unknown }\n | { contains: string }\n | { not_contains: string }\n | { matches: string }\n | { in: unknown[] }\n | { exists: boolean }\n | { gte: number }\n | { lte: number }\n\nexport type ResponseAssertion =\n | { contains: string }\n | { not_contains: string }\n | { matches: string }\n | { llm_judge: string }\n// | { similar_to: string } TODO: uncomment this when it gets implemented\n\nexport type ToolAssertion =\n | { called: string; params?: Record<string, MatchOperator> }\n | { not_called: string }\n | { call_order: string[] }\n\nexport interface StateAssertion {\n path: string\n equals?: unknown\n changed?: boolean\n}\n\nexport interface WorkflowAssertion {\n name: string\n entered?: boolean\n completed?: boolean\n}\n\nexport type NumericOperator = { equals: number } | { gte: number } | { lte: number }\n\nexport interface TimingAssertion {\n response_time: NumericOperator\n}\n\nexport interface TurnAssertions {\n response?: ResponseAssertion[]\n tools?: ToolAssertion[]\n state?: StateAssertion[]\n workflow?: WorkflowAssertion[]\n timing?: TimingAssertion[]\n}\n\nexport interface ConversationTurn {\n user?: string\n event?: { payload: Record<string, unknown> }\n expectSilence?: boolean\n assert?: TurnAssertions\n /**\n * Run this turn in a NEW conversation under the same user. The prior\n * transcript is absent, so recall here can only come from user-scoped\n * persistence, not context. Ignored on the first turn.\n */\n newConversation?: boolean\n}\n\nexport interface OutcomeAssertions {\n state?: StateAssertion[]\n workflow?: WorkflowAssertion[]\n}\n\nexport interface EvalSetup {\n state?: {\n bot?: Record<string, unknown>\n user?: Record<string, unknown>\n conversation?: Record<string, unknown>\n }\n workflow?: {\n trigger: string\n input?: Record<string, unknown>\n }\n}\n\nexport interface EvalDefinition {\n name: string\n description?: string\n tags?: string[]\n type?: 'capability' | 'regression'\n setup?: EvalSetup\n conversation: ConversationTurn[]\n outcome?: OutcomeAssertions\n options?: {\n idleTimeout?: number\n /** @deprecated No-op: the LLM judge is boolean (zai.check); there is no score threshold. */\n judgePassThreshold?: number\n }\n}\n\nexport class Eval implements EvalDefinition {\n readonly name: string\n readonly description?: string\n readonly tags?: string[]\n readonly type?: 'capability' | 'regression'\n readonly setup?: EvalSetup\n readonly conversation: ConversationTurn[]\n readonly outcome?: OutcomeAssertions\n readonly options?: {\n idleTimeout?: number\n /** @deprecated No-op: the LLM judge is boolean (zai.check); there is no score threshold. */\n judgePassThreshold?: number\n }\n\n constructor(def: EvalDefinition) {\n this.name = def.name\n this.conversation = def.conversation\n if (def.description !== undefined) this.description = def.description\n if (def.tags !== undefined) this.tags = def.tags\n if (def.type !== undefined) this.type = def.type\n if (def.setup !== undefined) this.setup = def.setup\n if (def.outcome !== undefined) this.outcome = def.outcome\n if (def.options !== undefined) this.options = def.options\n }\n}\n", "/**\n * Shared base error for ADK packages. Lives in `@botpress/analytics` because\n * it's the dependency-light package every surface already shares (cli, adk,\n * ui) \u2014 so all typed errors can genuinely inherit one base instead of\n * mirroring its shape.\n *\n * The policy lives in docs/ERROR-HANDLING.md. The short version: every error\n * we *intend* to throw should carry a stable `code` (so PostHog error\n * tracking can slice issues by code) and an `expected` flag separating\n * user/environment conditions (bad input, not logged in, network down \u2014 render\n * a friendly message, low alert priority) from internal bugs (invariant\n * violations \u2014 full stack, page someone).\n *\n * The runtime package is out of scope and keeps its own `Errors.AbstractError`\n * hierarchy. The adk typed families (`DependencyError`, `Agent0*Error`) extend\n * this base; new code should start here.\n */\nexport class AdkError<Code extends string = string> extends Error {\n /**\n * Marker for cross-module-instance checks \u2014 `instanceof` breaks when a\n * package is duplicated in the dependency graph.\n * @internal\n */\n public static readonly __IS_ADK_BASE_ERROR = true\n\n /**\n * Stable SCREAMING_SNAKE_CASE identifier, e.g. 'BOT_NOT_FOUND'. Subclasses\n * pin `Code` to a literal union (`class EvalRunnerError extends\n * AdkError<EvalErrorCode>`) so typos are compile errors and `code` narrows\n * in switches.\n */\n readonly code: Code\n /**\n * True for user/environment conditions the developer can fix themselves\n * (validation, auth, connectivity). False for internal bugs. Defaults to\n * false so unclassified errors surface as bugs until someone triages them.\n */\n readonly expected: boolean\n /** Structured context. Sanitized before any telemetry leaves the machine. */\n readonly details?: Record<string, unknown>\n /** Actionable next step shown to the user, e.g. \"Run 'adk login' first.\" */\n readonly suggestion?: string\n\n constructor(opts: {\n code: Code\n message: string\n expected?: boolean\n details?: Record<string, unknown>\n suggestion?: string\n cause?: unknown\n }) {\n super(opts.message, opts.cause !== undefined ? { cause: opts.cause } : undefined)\n this.name = this.constructor.name\n this.code = opts.code\n this.expected = opts.expected ?? false\n // Conditional assignment keeps the optional fields absent-not-undefined,\n // which downstream tsconfigs with exactOptionalPropertyTypes require.\n if (opts.details !== undefined) {\n this.details = opts.details\n }\n if (opts.suggestion !== undefined) {\n this.suggestion = opts.suggestion\n }\n }\n}\n\n/**\n * Duck-typed guard that survives duplicated module instances in the\n * dependency graph, where `instanceof AdkError` returns false for an error\n * constructed from another copy of this module. No manual prototype walking\n * needed: static properties are inherited through the constructor chain, so\n * a subclass's constructor resolves the marker in one lookup.\n */\nexport function isAdkError(error: unknown): error is AdkError {\n if (error instanceof AdkError) return true\n if (!(error instanceof Error)) return false\n return (error.constructor as unknown as Record<string, unknown> | undefined)?.__IS_ADK_BASE_ERROR === true\n}\n", "import { AdkError } from '@botpress/analytics'\n\n/**\n * Stable error codes for the eval engine. Typed as a literal union so a typo'd\n * code is a compile error and PostHog issue-slicing stays consistent.\n * Conventions per docs/ERROR-HANDLING.md.\n */\nexport const EVAL_ERROR_CODES = [\n 'EVAL_LOAD_FAILED',\n 'EVAL_FILE_EMPTY',\n 'EVAL_DUPLICATE_NAME',\n 'EVAL_SEED_NO_CONVERSATION',\n 'EVAL_NO_CONVERSATION_ID',\n 'EVAL_TURN_CONFIG_INVALID',\n 'SSE_CONNECT_FAILED',\n 'SSE_NO_BODY',\n 'CHAT_CLIENT_MISSING',\n 'CHAT_NOT_CONNECTED',\n 'CHAT_INTEGRATION_MISSING',\n 'CHAT_CHANNEL_UNBOUND',\n] as const\n\nexport type EvalErrorCode = (typeof EVAL_ERROR_CODES)[number]\n\n/**\n * Typed error for the eval engine. Named EvalRunnerError (not EvalError) to\n * avoid shadowing the JS built-in `EvalError`.\n */\nexport class EvalRunnerError extends AdkError<EvalErrorCode> {}\n", "import type { EvalDefinition } from '../definition'\nimport { loadEvalsFromDir } from '../loader'\n\nexport type EvalDefinitionLoader = () => Promise<EvalDefinition[]>\n\nexport function createDiskEvalLoader(evalsDir: string): EvalDefinitionLoader {\n return () => loadEvalsFromDir(evalsDir)\n}\n"],
|
|
5
|
+
"mappings": ";AAMA,SAAS,aAAa,kBAAkB;AACxC,SAAS,eAAe;;;ACuFjB,IAAM,OAAN,MAAqC;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAMT,YAAY,KAAqB;AAC/B,SAAK,OAAO,IAAI;AAChB,SAAK,eAAe,IAAI;AACxB,QAAI,IAAI,gBAAgB,OAAW,MAAK,cAAc,IAAI;AAC1D,QAAI,IAAI,SAAS,OAAW,MAAK,OAAO,IAAI;AAC5C,QAAI,IAAI,SAAS,OAAW,MAAK,OAAO,IAAI;AAC5C,QAAI,IAAI,UAAU,OAAW,MAAK,QAAQ,IAAI;AAC9C,QAAI,IAAI,YAAY,OAAW,MAAK,UAAU,IAAI;AAClD,QAAI,IAAI,YAAY,OAAW,MAAK,UAAU,IAAI;AAAA,EACpD;AACF;;;ACr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C1B,QAAI,iBAAiB,QAAQ,iBAAiB,KAAK,GAAG;AACpD,cAAQ,KAAK,KAAK;AAAA,IACpB;AAAA,EACF;AAEA,MAAI,QAAQ,WAAW,GAAG;AACxB,UAAM,IAAI,gBAAgB;AAAA,MACxB,MAAM;AAAA,MACN,SAAS,qBAAqB,QAAQ;AAAA,MACtC,UAAU;AAAA,IACZ,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAEA,eAAsB,iBAAiB,SAA4C;AACjF,QAAM,SAAS,QAAQ,OAAO;AAC9B,MAAI,CAAC,WAAW,MAAM,GAAG;AACvB,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,QAAQ,YAAY,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,SAAS,UAAU,CAAC;AACtE,QAAM,QAA0B,CAAC;AAEjC,aAAW,KAAK,OAAO;AACrB,UAAM,OAAO,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,EAAE;AAChD,UAAM,KAAK,GAAG,IAAI;AAAA,EACpB;AAEA,QAAM,OAAO,oBAAI,IAAY;AAC7B,aAAW,KAAK,OAAO;AACrB,QAAI,KAAK,IAAI,EAAE,IAAI,GAAG;AACpB,YAAM,IAAI,gBAAgB;AAAA,QACxB,MAAM;AAAA,QACN,SAAS,wBAAwB,EAAE,IAAI,cAAc,OAAO;AAAA,QAC5D,UAAU;AAAA,QACV,SAAS,EAAE,MAAM,EAAE,KAAK;AAAA,MAC1B,CAAC;AAAA,IACH;AACA,SAAK,IAAI,EAAE,IAAI;AAAA,EACjB;AAEA,SAAO;AACT;;;AIxFO,SAAS,qBAAqB,UAAwC;AAC3E,SAAO,MAAM,iBAAiB,QAAQ;AACxC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/stores/index.js
CHANGED
|
@@ -29,8 +29,46 @@ var Eval = class {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
+
// ../analytics/src/errors.ts
|
|
33
|
+
var AdkError = class extends Error {
|
|
34
|
+
/**
|
|
35
|
+
* Marker for cross-module-instance checks — `instanceof` breaks when a
|
|
36
|
+
* package is duplicated in the dependency graph.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
static __IS_ADK_BASE_ERROR = true;
|
|
40
|
+
/**
|
|
41
|
+
* Stable SCREAMING_SNAKE_CASE identifier, e.g. 'BOT_NOT_FOUND'. Subclasses
|
|
42
|
+
* pin `Code` to a literal union (`class EvalRunnerError extends
|
|
43
|
+
* AdkError<EvalErrorCode>`) so typos are compile errors and `code` narrows
|
|
44
|
+
* in switches.
|
|
45
|
+
*/
|
|
46
|
+
code;
|
|
47
|
+
/**
|
|
48
|
+
* True for user/environment conditions the developer can fix themselves
|
|
49
|
+
* (validation, auth, connectivity). False for internal bugs. Defaults to
|
|
50
|
+
* false so unclassified errors surface as bugs until someone triages them.
|
|
51
|
+
*/
|
|
52
|
+
expected;
|
|
53
|
+
/** Structured context. Sanitized before any telemetry leaves the machine. */
|
|
54
|
+
details;
|
|
55
|
+
/** Actionable next step shown to the user, e.g. "Run 'adk login' first." */
|
|
56
|
+
suggestion;
|
|
57
|
+
constructor(opts) {
|
|
58
|
+
super(opts.message, opts.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
59
|
+
this.name = this.constructor.name;
|
|
60
|
+
this.code = opts.code;
|
|
61
|
+
this.expected = opts.expected ?? false;
|
|
62
|
+
if (opts.details !== void 0) {
|
|
63
|
+
this.details = opts.details;
|
|
64
|
+
}
|
|
65
|
+
if (opts.suggestion !== void 0) {
|
|
66
|
+
this.suggestion = opts.suggestion;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
32
71
|
// src/errors.ts
|
|
33
|
-
import { AdkError } from "@botpress/analytics";
|
|
34
72
|
var EvalRunnerError = class extends AdkError {
|
|
35
73
|
};
|
|
36
74
|
|