fascicle 0.12.0 → 0.12.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/engine_from_generate.ts","../src/testing/make_stub_engine.ts","../src/testing/make_capture_engine.ts"],"sourcesContent":["/**\n * Wrap a canned `generate` function in a complete `Engine`.\n *\n * The remaining members are inert: pricing calls are no-ops that resolve\n * nothing, `dispose` resolves immediately, and `with_providers` throws\n * because a canned engine has no provider registry to derive from. Both\n * testing factories share this shell so a test double differs from a real\n * engine only in how `generate` answers.\n */\n\nimport type { Engine } from '#engine'\n\n/**\n * Build an `Engine` whose only live member is the supplied `generate`.\n */\nexport function engine_from_generate(generate: Engine['generate']): Engine {\n return {\n generate,\n register_price: () => {},\n resolve_price: () => undefined,\n list_prices: () => ({}),\n with_providers: () => {\n throw new Error('testing engines do not support with_providers')\n },\n dispose: async () => {},\n }\n}\n","/**\n * make_stub_engine: a canned, network-free `Engine` for tests and demos.\n *\n * Each generate call is routed by the system prompt's stable first line:\n * the first canned response whose `prefix` the system prompt starts with\n * answers the call, and an unmatched system throws, so a flow that grows a\n * new model boundary fails loudly instead of silently reusing a fixture.\n * A response with the empty-string prefix matches every call, which is the\n * single-model-boundary case.\n *\n * Canned content is validated through the caller's own schema\n * (`opts.schema['~standard'].validate`), so fixtures cannot drift from the\n * contracts they stand in for: a schema change breaks the test that ships\n * stale data.\n */\n\nimport type { Engine, GenerateOptions, GenerateResult, UsageTotals } from '#engine'\nimport { engine_from_generate } from './engine_from_generate.js'\n\nexport type StubResponse = {\n readonly prefix: string\n readonly content: unknown\n}\n\nexport type StubEngineOptions = {\n readonly usage?: UsageTotals\n readonly model_id?: string\n}\n\nconst DEFAULT_USAGE: UsageTotals = { input_tokens: 40, output_tokens: 20 }\n\n/**\n * Build an `Engine` that answers every generate call from `canned`,\n * routed by system-prompt prefix.\n *\n * `options.usage` sets the usage totals reported on every result (default\n * `{ input_tokens: 40, output_tokens: 20 }`, so cost lines render non-zero\n * numbers); `options.model_id` sets `model_resolved.model_id` (default\n * `'stub'`). The provider always reports as `'stub'`.\n */\nexport function make_stub_engine(\n canned: ReadonlyArray<StubResponse>,\n options: StubEngineOptions = {},\n): Engine {\n const usage = options.usage ?? DEFAULT_USAGE\n const model_id = options.model_id ?? 'stub'\n\n return engine_from_generate(\n async <t = string>(opts: GenerateOptions<t>): Promise<GenerateResult<t>> => {\n const system = opts.system ?? ''\n const match = canned.find((c) => system.startsWith(c.prefix))\n if (match === undefined) {\n throw new Error(`make_stub_engine: no canned response for system: ${system || '(none)'}`)\n }\n const checked = await opts.schema?.['~standard'].validate(match.content)\n if (checked?.issues !== undefined) {\n throw new Error(\n `make_stub_engine: canned response for prefix '${match.prefix}' failed the caller's schema`,\n )\n }\n const content = checked === undefined ? match.content : checked.value\n return {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n content: content as t,\n tool_calls: [],\n steps: [],\n usage,\n finish_reason: 'stop',\n model_resolved: { provider: 'stub', model_id },\n }\n },\n )\n}\n","/**\n * make_capture_engine: an `Engine` that records every generate call.\n *\n * Returns the engine together with the live `calls` array, which receives\n * the `GenerateOptions` of each call in order. Every call resolves with the\n * same canned result (`options.result`, or a minimal `'ok'` result), so the\n * double is for asserting what reached the engine, not for scripting\n * multi-role conversations: that is `make_stub_engine`'s job.\n *\n * `options.on_generate` runs after the call is recorded and is awaited\n * before the result resolves, which is the hook for driving streaming\n * chunks, spans, or aborts against the captured options.\n */\n\nimport type { Engine, GenerateOptions, GenerateResult } from '#engine'\nimport { engine_from_generate } from './engine_from_generate.js'\n\nexport type CaptureEngineOptions = {\n readonly result?: GenerateResult<unknown>\n readonly on_generate?: (opts: GenerateOptions) => Promise<void> | void\n}\n\nexport type CaptureEngine = {\n readonly engine: Engine\n readonly calls: GenerateOptions[]\n}\n\nconst DEFAULT_RESULT: GenerateResult<unknown> = {\n content: 'ok',\n tool_calls: [],\n steps: [],\n usage: { input_tokens: 1, output_tokens: 1 },\n finish_reason: 'stop',\n model_resolved: { provider: 'stub', model_id: 'capture' },\n}\n\n/**\n * Build an `Engine` that records each call's `GenerateOptions` into the\n * returned `calls` array and answers with the canned result.\n */\nexport function make_capture_engine(options: CaptureEngineOptions = {}): CaptureEngine {\n const calls: GenerateOptions[] = []\n const result = options.result ?? DEFAULT_RESULT\n\n const engine = engine_from_generate(\n async <t = string>(opts: GenerateOptions<t>): Promise<GenerateResult<t>> => {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const loose = opts as GenerateOptions\n calls.push(loose)\n if (options.on_generate) await options.on_generate(loose)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return result as GenerateResult<t>\n },\n )\n return { engine, calls }\n}\n"],"mappings":";;;;AAeA,SAAgB,qBAAqB,UAAsC;CACzE,OAAO;EACL;EACA,sBAAsB,CAAC;EACvB,qBAAqB,KAAA;EACrB,oBAAoB,CAAC;EACrB,sBAAsB;GACpB,MAAM,IAAI,MAAM,+CAA+C;EACjE;EACA,SAAS,YAAY,CAAC;CACxB;AACF;;;ACGA,MAAM,gBAA6B;CAAE,cAAc;CAAI,eAAe;AAAG;;;;;;;;;;AAWzE,SAAgB,iBACd,QACA,UAA6B,CAAC,GACtB;CACR,MAAM,QAAQ,QAAQ,SAAS;CAC/B,MAAM,WAAW,QAAQ,YAAY;CAErC,OAAO,qBACL,OAAmB,SAAyD;EAC1E,MAAM,SAAS,KAAK,UAAU;EAC9B,MAAM,QAAQ,OAAO,MAAM,MAAM,OAAO,WAAW,EAAE,MAAM,CAAC;EAC5D,IAAI,UAAU,KAAA,GACZ,MAAM,IAAI,MAAM,oDAAoD,UAAU,UAAU;EAE1F,MAAM,UAAU,MAAM,KAAK,SAAS,YAAY,CAAC,SAAS,MAAM,OAAO;EACvE,IAAI,SAAS,WAAW,KAAA,GACtB,MAAM,IAAI,MACR,iDAAiD,MAAM,OAAO,6BAChE;EAGF,OAAO;GAEL,SAHc,YAAY,KAAA,IAAY,MAAM,UAAU,QAAQ;GAI9D,YAAY,CAAC;GACb,OAAO,CAAC;GACR;GACA,eAAe;GACf,gBAAgB;IAAE,UAAU;IAAQ;GAAS;EAC/C;CACF,CACF;AACF;;;AC7CA,MAAM,iBAA0C;CAC9C,SAAS;CACT,YAAY,CAAC;CACb,OAAO,CAAC;CACR,OAAO;EAAE,cAAc;EAAG,eAAe;CAAE;CAC3C,eAAe;CACf,gBAAgB;EAAE,UAAU;EAAQ,UAAU;CAAU;AAC1D;;;;;AAMA,SAAgB,oBAAoB,UAAgC,CAAC,GAAkB;CACrF,MAAM,QAA2B,CAAC;CAClC,MAAM,SAAS,QAAQ,UAAU;CAYjC,OAAO;EAAE,QAVM,qBACb,OAAmB,SAAyD;GAE1E,MAAM,QAAQ;GACd,MAAM,KAAK,KAAK;GAChB,IAAI,QAAQ,aAAa,MAAM,QAAQ,YAAY,KAAK;GAExD,OAAO;EACT,CAEY;EAAG;CAAM;AACzB"}
1
+ {"version":3,"file":"testing.js","names":[],"sources":["../src/testing/engine_from_generate.ts","../src/testing/make_capture_engine.ts","../src/testing/canned.ts","../src/testing/make_script_engine.ts","../src/testing/make_stub_engine.ts","../src/testing/text_of.ts"],"sourcesContent":["/**\n * Wrap a canned `generate` function in a complete `Engine`.\n *\n * The remaining members are inert: pricing calls are no-ops that resolve\n * nothing, `dispose` resolves immediately, and `with_providers` throws\n * because a canned engine has no provider registry to derive from. Both\n * testing factories share this shell so a test double differs from a real\n * engine only in how `generate` answers.\n */\n\nimport type { Engine } from '#engine'\n\n/**\n * Build an `Engine` whose only live member is the supplied `generate`.\n *\n * A custom double MUST implement only `generate`: accept `GenerateOptions`\n * and resolve a complete `GenerateResult` (content, tool_calls, steps,\n * usage, finish_reason, model_resolved). Honoring `opts.abort`,\n * `opts.on_chunk`, and `opts.schema` is optional; honor whichever the code\n * under test exercises. It need NOT implement pricing, `with_providers`, or\n * `dispose`: this shell supplies the inert versions.\n */\nexport function engine_from_generate(generate: Engine['generate']): Engine {\n return {\n generate,\n register_price: () => {},\n resolve_price: () => undefined,\n list_prices: () => ({}),\n with_providers: () => {\n throw new Error('testing engines do not support with_providers')\n },\n dispose: async () => {},\n }\n}\n","/**\n * make_capture_engine: an `Engine` that records every generate call.\n *\n * Returns the engine together with the live `calls` array, which receives\n * the `GenerateOptions` of each call in order. Every call resolves with the\n * same canned result (`options.result`, or a minimal `'ok'` result), so the\n * double is for asserting what reached the engine, not for scripting\n * multi-role conversations: that is `make_stub_engine`'s job.\n *\n * `options.on_generate` runs after the call is recorded and is awaited\n * before the result resolves, which is the hook for driving streaming\n * chunks, spans, or aborts against the captured options.\n */\n\nimport type { Engine, GenerateOptions, GenerateResult } from '#engine'\nimport { engine_from_generate } from './engine_from_generate.js'\n\nexport type CaptureEngineOptions = {\n readonly result?: GenerateResult<unknown>\n readonly on_generate?: (opts: GenerateOptions) => Promise<void> | void\n}\n\nexport type CaptureEngine = {\n readonly engine: Engine\n readonly calls: GenerateOptions[]\n}\n\nconst DEFAULT_RESULT: GenerateResult<unknown> = {\n content: 'ok',\n tool_calls: [],\n steps: [],\n usage: { input_tokens: 1, output_tokens: 1 },\n finish_reason: 'stop',\n model_resolved: { provider: 'stub', model_id: 'capture' },\n}\n\n/**\n * Build an `Engine` that records each call's `GenerateOptions` into the\n * returned `calls` array and answers with the canned result.\n */\nexport function make_capture_engine(options: CaptureEngineOptions = {}): CaptureEngine {\n const calls: GenerateOptions[] = []\n const result = options.result ?? DEFAULT_RESULT\n\n const engine = engine_from_generate(\n async <t = string>(opts: GenerateOptions<t>): Promise<GenerateResult<t>> => {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const loose = opts as GenerateOptions\n calls.push(loose)\n if (options.on_generate) await options.on_generate(loose)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return result as GenerateResult<t>\n },\n )\n return { engine, calls }\n}\n","/**\n * Shared plumbing for the canned engine doubles.\n *\n * make_stub_engine and make_script_engine answer calls from fixtures rather\n * than a provider, but the surrounding contract stays the engine's: a call\n * under an already-aborted signal throws `aborted_error`, a streaming caller\n * sees chunks before the result resolves, and content that fails the\n * caller's schema surfaces as `schema_validation_error` carrying the issues.\n * Keeping that contract here keeps every double interchangeable with a real\n * engine at the seams tests exercise.\n */\n\nimport { aborted_error, schema_validation_error } from '#engine'\nimport type { FinishReason, GenerateOptions, UsageTotals } from '#engine'\n\nexport const DEFAULT_USAGE: UsageTotals = { input_tokens: 40, output_tokens: 20 }\n\n/**\n * Mirror the engine's entry guard: a generate call under an already-aborted\n * signal never reaches a provider, so a double must refuse it the same way\n * for cancellation tests to be trustworthy.\n */\nexport function throw_if_aborted(abort: AbortSignal | undefined): void {\n if (abort?.aborted === true) {\n throw new aborted_error('aborted', { reason: abort.reason })\n }\n}\n\n/**\n * Render canned content as the text a provider would have put on the wire:\n * strings pass through, everything else is serialized as JSON (which is what\n * a schema-bearing call would have streamed).\n */\nfunction render_text(content: unknown): string {\n if (typeof content === 'string') return content\n return JSON.stringify(content) ?? ''\n}\n\n/**\n * Emit the minimal chunk sequence a streaming caller expects: the whole\n * content as one text chunk, then the finish marker. Enough for model_chunk\n * trajectory events and stream-consuming UIs to fire without a network.\n */\nexport async function emit_chunks(\n on_chunk: GenerateOptions['on_chunk'],\n content: unknown,\n finish_reason: FinishReason,\n usage: UsageTotals,\n): Promise<void> {\n if (on_chunk === undefined) return\n await on_chunk({ kind: 'text', text: render_text(content), step_index: 0 })\n await on_chunk({ kind: 'finish', finish_reason, usage })\n}\n\ntype CannedIssue = {\n readonly message: string\n readonly path?: ReadonlyArray<PropertyKey>\n}\n\n/**\n * Render issues as one `path: message` line per issue, dotted the same way\n * the engine's own repair prompts and error messages format them.\n */\nfunction format_issues(issues: ReadonlyArray<CannedIssue>): string {\n return issues\n .map((issue) =>\n issue.path === undefined || issue.path.length === 0\n ? issue.message\n : `${issue.path.map(String).join('.')}: ${issue.message}`,\n )\n .join('; ')\n}\n\n/**\n * Validate canned content through the caller's schema, throwing the engine's\n * own `schema_validation_error` on failure so `instanceof` handling in the\n * code under test sees exactly what a real engine throws when its repair\n * attempts run out. Absent a schema, the content passes through untouched.\n */\nexport async function validate_canned(\n schema: GenerateOptions<unknown>['schema'],\n content: unknown,\n described: string,\n): Promise<unknown> {\n if (schema === undefined) return content\n const checked = await schema['~standard'].validate(content)\n if (checked.issues !== undefined) {\n // The spec allows a path segment to be a bare key or a `{ key }` wrapper;\n // normalize to bare keys so schema_issues reads one shape, as the real\n // engine's validator does.\n const issues: CannedIssue[] = checked.issues.map((issue) =>\n issue.path === undefined\n ? { message: issue.message }\n : {\n message: issue.message,\n path: issue.path.map((segment) =>\n typeof segment === 'object' ? segment.key : segment,\n ),\n },\n )\n throw new schema_validation_error(\n `${described} failed the caller's schema: ${format_issues(issues)}`,\n issues,\n render_text(content),\n )\n }\n return checked.value\n}\n","/**\n * make_script_engine: a queue of canned responses consumed in call order.\n *\n * Where make_stub_engine routes by system-prompt prefix and cannot tell\n * call 3 from call 1, a script cares only about order: the first generate\n * call gets the first entry, the second the next, and a call past the end\n * throws naming how many responses were scripted versus received, so a flow\n * that makes an unexpected extra model call fails loudly. That makes it the\n * double for loops that must converge, retry paths, and flows whose calls a\n * prefix cannot distinguish (a markdown-only define_agent sends no system\n * prompt at all, so every call looks alike to a stub).\n *\n * An entry is plain content, or a `ScriptResponse` object when the call\n * should carry tool calls, report a different finish reason or usage, or\n * throw a scripted error (a rate_limit_error, a provider_error) instead of\n * answering. Only an object whose keys ALL belong to the ScriptResponse\n * shape is treated as scripted; any other value, `{ verdict: 'ship' }`\n * included, becomes content as-is. Wrap literal content that collides with\n * the shape in `{ content }`.\n *\n * Scripted content is validated through the caller's schema, and the abort\n * and on_chunk contracts match make_stub_engine's; see ./canned.ts.\n */\n\nimport type {\n Engine,\n FinishReason,\n GenerateOptions,\n GenerateResult,\n ToolCallRecord,\n UsageTotals,\n} from '#engine'\nimport { DEFAULT_USAGE, emit_chunks, throw_if_aborted, validate_canned } from './canned.js'\nimport { engine_from_generate } from './engine_from_generate.js'\n\nexport type ScriptResponse = {\n readonly content?: unknown\n readonly tool_calls?: ReadonlyArray<ToolCallRecord>\n readonly finish_reason?: FinishReason\n readonly usage?: UsageTotals\n /** An error to throw for this call instead of answering. */\n readonly throw?: Error\n}\n\nexport type ScriptEngineOptions = {\n readonly usage?: UsageTotals\n readonly model_id?: string\n}\n\nconst SCRIPT_KEYS = new Set(['content', 'tool_calls', 'finish_reason', 'usage', 'throw'])\n\n/**\n * Decide whether a queue entry is a ScriptResponse or plain content. Only a\n * non-null, non-array object whose keys all belong to the ScriptResponse\n * shape is scripted, so an arbitrary content fixture with its own keys\n * passes through untouched rather than being half-read as a script entry.\n */\nfunction is_script_response(entry: unknown): entry is ScriptResponse {\n if (typeof entry !== 'object' || entry === null || Array.isArray(entry)) return false\n const keys = Object.keys(entry)\n return keys.length > 0 && keys.every((key) => SCRIPT_KEYS.has(key))\n}\n\n/**\n * Build an `Engine` that answers generate calls strictly in call order from\n * `responses`, throwing once the queue is exhausted.\n *\n * `options` mirrors make_stub_engine's: `usage` is the default usage for\n * entries that do not set their own (default `{ input_tokens: 40,\n * output_tokens: 20 }`) and `model_id` sets `model_resolved.model_id`\n * (default `'script'`). The provider always reports as `'stub'`.\n */\nexport function make_script_engine(\n responses: ReadonlyArray<unknown>,\n options: ScriptEngineOptions = {},\n): Engine {\n const default_usage = options.usage ?? DEFAULT_USAGE\n const model_id = options.model_id ?? 'script'\n let call_count = 0\n\n return engine_from_generate(\n async <t = string>(opts: GenerateOptions<t>): Promise<GenerateResult<t>> => {\n throw_if_aborted(opts.abort)\n call_count += 1\n const index = call_count - 1\n if (index >= responses.length) {\n throw new Error(\n `make_script_engine: script exhausted: ${responses.length} response(s) scripted, call ${call_count} received`,\n )\n }\n const entry = responses[index]\n const scripted: ScriptResponse = is_script_response(entry) ? entry : { content: entry }\n if (scripted.throw !== undefined) throw scripted.throw\n const usage = scripted.usage ?? default_usage\n const finish_reason = scripted.finish_reason ?? 'stop'\n // Chunks carry the raw scripted content, before validation, mirroring a\n // real stream where text flows and only then gets validated.\n await emit_chunks(opts.on_chunk, scripted.content, finish_reason, usage)\n const content = await validate_canned(\n opts.schema,\n scripted.content,\n `make_script_engine: scripted response ${index}`,\n )\n return {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n content: content as t,\n tool_calls: scripted.tool_calls === undefined ? [] : [...scripted.tool_calls],\n steps: [],\n usage,\n finish_reason,\n model_resolved: { provider: 'stub', model_id },\n }\n },\n )\n}\n","/**\n * make_stub_engine: a canned, network-free `Engine` for tests and demos.\n *\n * Each generate call is routed by the system prompt's stable first line:\n * the first canned response whose `prefix` the system prompt starts with\n * answers the call, and an unmatched system throws, so a flow that grows a\n * new model boundary fails loudly instead of silently reusing a fixture.\n * A response with the empty-string prefix matches every call, which is the\n * single-model-boundary case.\n *\n * A response's `content` may be a function of `(opts, call_index)` for\n * routes a flow hits more than once (a converging loop, a judged retry):\n * `call_index` counts how many times that route has matched before,\n * starting at 0, so each pass can answer differently.\n *\n * Canned content is validated through the caller's own schema\n * (`opts.schema['~standard'].validate`), so fixtures cannot drift from the\n * contracts they stand in for. A failure throws the engine's own\n * `schema_validation_error` carrying the issues and the canned content as\n * `raw_text`, exactly what a real engine throws when repair attempts run\n * out, so `instanceof` handling in the code under test stays testable.\n *\n * The engine's streaming and cancellation contract holds too: an\n * already-aborted `opts.abort` throws `aborted_error`, and a provided\n * `opts.on_chunk` receives the canned content as a text chunk plus a finish\n * chunk before the result resolves.\n */\n\nimport type { Engine, GenerateOptions, GenerateResult, UsageTotals } from '#engine'\nimport { DEFAULT_USAGE, emit_chunks, throw_if_aborted, validate_canned } from './canned.js'\nimport { engine_from_generate } from './engine_from_generate.js'\n\n/**\n * The function form of canned content: called with the routed call's options\n * and how many times this prefix route has matched before (starting 0). May\n * be async; the returned value is validated and answered like static content.\n */\nexport type StubContentFn = (opts: GenerateOptions, call_index: number) => unknown\n\nexport type StubResponse = {\n readonly prefix: string\n /** Static content, or a `StubContentFn` invoked per matched call. */\n readonly content: unknown\n}\n\nexport type StubEngineOptions = {\n readonly usage?: UsageTotals\n readonly model_id?: string\n}\n\n/**\n * Build an `Engine` that answers every generate call from `canned`,\n * routed by system-prompt prefix.\n *\n * `options.usage` sets the usage totals reported on every result (default\n * `{ input_tokens: 40, output_tokens: 20 }`, so cost lines render non-zero\n * numbers); `options.model_id` sets `model_resolved.model_id` (default\n * `'stub'`). The provider always reports as `'stub'`.\n */\nexport function make_stub_engine(\n canned: ReadonlyArray<StubResponse>,\n options: StubEngineOptions = {},\n): Engine {\n const usage = options.usage ?? DEFAULT_USAGE\n const model_id = options.model_id ?? 'stub'\n const match_counts = new Map<StubResponse, number>()\n\n return engine_from_generate(\n async <t = string>(opts: GenerateOptions<t>): Promise<GenerateResult<t>> => {\n throw_if_aborted(opts.abort)\n const system = opts.system ?? ''\n const match = canned.find((c) => system.startsWith(c.prefix))\n if (match === undefined) {\n throw new Error(`make_stub_engine: no canned response for system: ${system || '(none)'}`)\n }\n const call_index = match_counts.get(match) ?? 0\n match_counts.set(match, call_index + 1)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const loose = opts as GenerateOptions\n const produced =\n typeof match.content === 'function'\n ? // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n await (match.content as StubContentFn)(loose, call_index)\n : match.content\n // Chunks carry the raw canned content, before validation, mirroring a\n // real stream where text flows and only then gets validated.\n await emit_chunks(opts.on_chunk, produced, 'stop', usage)\n const content = await validate_canned(\n opts.schema,\n produced,\n `make_stub_engine: canned response for prefix '${match.prefix}'`,\n )\n return {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n content: content as t,\n tool_calls: [],\n steps: [],\n usage,\n finish_reason: 'stop',\n model_resolved: { provider: 'stub', model_id },\n }\n },\n )\n}\n","/**\n * text_of: the user-visible prompt text of a captured GenerateOptions.\n *\n * Capture assertions care about what the model was asked, not how the prompt\n * was encoded. A prompt is a bare string or a Message[] whose user turns\n * carry either a string or typed content parts; navigating\n * `calls[0].prompt[0].content[0].text` by hand couples every assertion to\n * one encoding. System and assistant text are excluded on purpose: assert\n * those through `opts.system` and the raw messages.\n */\n\nimport type { GenerateOptions } from '#engine'\n\n/**\n * Flatten the prompt's user-facing text into one string: a string prompt\n * verbatim, otherwise every user turn's text (string content, or the `text`\n * parts of a content-part array) joined with newlines. Total: absent or\n * non-text content yields ''.\n */\nexport function text_of<t = unknown>(opts: GenerateOptions<t>): string {\n if (typeof opts.prompt === 'string') return opts.prompt\n const texts: string[] = []\n for (const message of opts.prompt) {\n if (message.role !== 'user') continue\n if (typeof message.content === 'string') {\n texts.push(message.content)\n continue\n }\n for (const part of message.content) {\n if (part.type === 'text') texts.push(part.text)\n }\n }\n return texts.join('\\n')\n}\n"],"mappings":"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"}
@@ -0,0 +1,114 @@
1
+ //#region src/core/trajectory.d.ts
2
+ /**
3
+ * Wire-format guards for trajectory events.
4
+ *
5
+ * `TrajectoryEvent` (in `types.ts`) is the loose internal type — any code that
6
+ * calls `trajectory.record(event)` or `start_span(name, meta)` produces values
7
+ * conforming to it. This file defines the *narrower* shapes that the studio
8
+ * (and any other downstream consumer) can recognize in the wire stream:
9
+ *
10
+ * span_start — composer span open
11
+ * span_end — composer span close
12
+ * emit — user-emitted event from inside a step (ctx.emit)
13
+ * run_end — terminal run event carrying the run's status, so a consumer
14
+ * distinguishes done / failed / aborted / suspended without
15
+ * inferring from silence
16
+ * checkpoint — checkpoint store lookup outcome (hit / miss / read_error)
17
+ * <other> — anything else, recognized by `is_custom_trajectory_event`,
18
+ * which only requires a string `kind`
19
+ *
20
+ * `parse_trajectory_event` is the wire gate, and it is deliberately permissive:
21
+ * a value is a trajectory event iff it is a non-array object carrying a string
22
+ * `kind`. The well-known guards layered on top are *recognizers*, not gates — a
23
+ * `{ kind: 'span_start' }` line missing its `span_id` is still a valid event on
24
+ * the wire, just not a `SpanStartEvent`. Anything stricter would have a viewer
25
+ * drop lines a newer producer emits, which is the opposite of what a
26
+ * forward-compatible wire format is for. `is_custom_trajectory_event` therefore
27
+ * answers `true` for well-known kinds too: it is the fallback shape, not a
28
+ * fifth disjoint case.
29
+ *
30
+ * Extra fields (`run_id`, `id`, provider-specific metadata) are neither
31
+ * required nor stripped: a successful parse hands the value straight back, so a
32
+ * parse / re-serialize round trip is lossless.
33
+ */
34
+ type SpanStartEvent = {
35
+ readonly kind: 'span_start';
36
+ readonly span_id: string;
37
+ readonly name: string;
38
+ } & {
39
+ readonly [key: string]: unknown;
40
+ };
41
+ type SpanEndEvent = {
42
+ readonly kind: 'span_end';
43
+ readonly span_id: string;
44
+ } & {
45
+ readonly [key: string]: unknown;
46
+ };
47
+ type EmitEvent = {
48
+ readonly kind: 'emit';
49
+ } & {
50
+ readonly [key: string]: unknown;
51
+ };
52
+ type RunEndStatus = 'done' | 'failed' | 'aborted' | 'suspended';
53
+ type RunEndEvent = {
54
+ readonly kind: 'run_end';
55
+ readonly status: RunEndStatus;
56
+ } & {
57
+ readonly [key: string]: unknown;
58
+ };
59
+ type CheckpointStatus = 'hit' | 'miss' | 'read_error';
60
+ type CheckpointEvent = {
61
+ readonly kind: 'checkpoint';
62
+ readonly status: CheckpointStatus;
63
+ readonly key: string;
64
+ } & {
65
+ readonly [key: string]: unknown;
66
+ };
67
+ type CustomTrajectoryEvent = {
68
+ readonly kind: string;
69
+ } & {
70
+ readonly [key: string]: unknown;
71
+ };
72
+ type ParsedTrajectoryEvent = SpanStartEvent | SpanEndEvent | EmitEvent | RunEndEvent | CheckpointEvent | CustomTrajectoryEvent;
73
+ type TrajectoryParseResult = {
74
+ readonly success: true;
75
+ readonly data: ParsedTrajectoryEvent;
76
+ } | {
77
+ readonly success: false;
78
+ readonly error: Error;
79
+ };
80
+ /**
81
+ * The wire gate: a non-array object carrying a string `kind`.
82
+ *
83
+ * True for every well-known kind as well, since `custom` is the fallback shape
84
+ * rather than a disjoint case.
85
+ */
86
+ declare function is_custom_trajectory_event(value: unknown): value is CustomTrajectoryEvent;
87
+ /** A composer span open: both `span_id` and `name` must be present as strings. */
88
+ declare function is_span_start_event(value: unknown): value is SpanStartEvent;
89
+ /** A composer span close: `span_id` must be present as a string, `name` need not be. */
90
+ declare function is_span_end_event(value: unknown): value is SpanEndEvent;
91
+ /** A `ctx.emit` event: the kind alone identifies it, the payload is the caller's. */
92
+ declare function is_emit_event(value: unknown): value is EmitEvent;
93
+ /**
94
+ * A terminal run event: `status` must be one of the known run outcomes, so the
95
+ * narrowed type's `status` union is truthful. An unknown future status still
96
+ * passes the wire gate as a custom event.
97
+ */
98
+ declare function is_run_end_event(value: unknown): value is RunEndEvent;
99
+ /**
100
+ * A checkpoint lookup event: `status` must be a known lookup outcome and `key`
101
+ * the store key that was consulted, for the same truthful-narrowing reason as
102
+ * `is_run_end_event`.
103
+ */
104
+ declare function is_checkpoint_event(value: unknown): value is CheckpointEvent;
105
+ /**
106
+ * Parse one wire value into a trajectory event, `safeParse`-shaped.
107
+ *
108
+ * On success `data` is the value itself, not a copy, so nothing on the line is
109
+ * dropped or reordered on the way through.
110
+ */
111
+ declare function parse_trajectory_event(value: unknown): TrajectoryParseResult;
112
+ //#endregion
113
+ export { parse_trajectory_event as _, ParsedTrajectoryEvent as a, SpanEndEvent as c, is_checkpoint_event as d, is_custom_trajectory_event as f, is_span_start_event as g, is_span_end_event as h, EmitEvent as i, SpanStartEvent as l, is_run_end_event as m, CheckpointStatus as n, RunEndEvent as o, is_emit_event as p, CustomTrajectoryEvent as r, RunEndStatus as s, CheckpointEvent as t, TrajectoryParseResult as u };
114
+ //# sourceMappingURL=trajectory-cSLNlHzh.d.ts.map
@@ -67,6 +67,18 @@ type Step<i, o> = {
67
67
  * it accepts is the runner's job, not the type system's.
68
68
  */
69
69
  type AnyStep = Step<never, unknown>;
70
+ /**
71
+ * Extract a Step's input type. The fallback is `never`, not `unknown`, so a
72
+ * non-step can never satisfy an input-position check by accident; sequence's
73
+ * joint checking depends on that. This is the canonical extractor the
74
+ * composers' internal type machinery builds on.
75
+ */
76
+ type StepInput<s> = s extends Step<infer i, unknown> ? i : never;
77
+ /**
78
+ * Extract a Step's output type. Falls back to `unknown` so type-erased
79
+ * plumbing over `AnyStep` degrades to the safe top type instead of lying.
80
+ */
81
+ type StepOutput<s> = s extends Step<never, infer o> ? o : unknown;
70
82
  //#endregion
71
- export { StepFn as a, TrajectoryLogger as c, Step as i, CheckpointStore as n, StepMetadata as o, RunContext as r, TrajectoryEvent as s, AnyStep as t };
72
- //# sourceMappingURL=types-CVdTBXE_.d.ts.map
83
+ export { Step as a, StepMetadata as c, TrajectoryLogger as d, RunContext as i, StepOutput as l, CheckpointStore as n, StepFn as o, CleanupFn as r, StepInput as s, AnyStep as t, TrajectoryEvent as u };
84
+ //# sourceMappingURL=types-BqUY6nRX.d.ts.map
@@ -1,4 +1,4 @@
1
- import { c as TrajectoryLogger } from "./types-CVdTBXE_.js";
1
+ import { d as TrajectoryLogger } from "./types-BqUY6nRX.js";
2
2
  import { r as ToolSchema } from "./types-BCtKsxrX.js";
3
3
 
4
4
  //#region src/engine/providers/claude_cli/types.d.ts
@@ -531,9 +531,10 @@ type AiSdkTelemetrySettings = {
531
531
  *
532
532
  * | Field | Rule |
533
533
  * | --------------------------------------------------------------------- | ----------------------------------------- |
534
- * | `model` | per-call wins; else default; else `sonnet` |
535
- * | `provider` | per-call wins; else default; else sole configured provider; else `anthropic` |
534
+ * | `model` | per-call wins; else default; else model_required_error is thrown |
535
+ * | `provider` | per-call wins; else default; else sole configured provider; else provider_required_error is thrown |
536
536
  * | `system`, `effort`, `max_steps`, `turn_timeout_ms`, `tool_error_policy`, `schema_repair_attempts`, `tool_call_repair_attempts`, `max_tool_calls_per_step` | per-call wins (nullish coalesce) |
537
+ * | `temperature`, `max_tokens`, `top_p` | per-call wins (nullish coalesce) |
537
538
  * | `retry_policy` | per-call replaces wholesale |
538
539
  * | `provider_options` | two-level: per-provider-key shallow merge |
539
540
  * | `prompt`, `tools`, `schema`, `abort`, `trajectory`, `on_chunk` | not defaultable; always call-supplied |
@@ -543,6 +544,9 @@ type EngineDefaults = {
543
544
  readonly provider?: string;
544
545
  readonly system?: string;
545
546
  readonly effort?: EffortLevel;
547
+ readonly temperature?: number;
548
+ readonly max_tokens?: number;
549
+ readonly top_p?: number;
546
550
  readonly max_steps?: number;
547
551
  readonly turn_timeout_ms?: number;
548
552
  readonly retry_policy?: RetryPolicy;
@@ -598,4 +602,4 @@ type Engine = {
598
602
  };
599
603
  //#endregion
600
604
  export { TurnResult as A, ProviderTransport as B, StreamChunk as C, ToolCallRecord as D, ToolApprovalRequest as E, ExternalAgentAdapter as F, default_normalize_usage as H, NativeProviderAdapter as I, ProviderAdapter as L, UserContentPart as M, AiSdkProviderAdapter as N, ToolExecContext as O, EffortTranslation as P, ProviderCapability as R, StepRecord as S, ToolApprovalHandler as T, RawProviderUsage as V, ProviderConfigMap as _, Engine as a, RetryFailureKind as b, FinishReason as c, Message as d, PrepareStepContext as f, PricingTable as g, Pricing as h, EffortLevel as i, UsageTotals as j, TurnRequest as k, GenerateOptions as l, PrepareStepResult as m, AssistantContentPart as n, EngineConfig as o, PrepareStepHook as p, CostBreakdown as r, EngineDefaults as s, AiSdkTelemetrySettings as t, GenerateResult as u, ProviderInit as v, Tool as w, RetryPolicy as x, ResolvedModel as y, ProviderFactory as z };
601
- //# sourceMappingURL=types-4l54cexm.d.ts.map
605
+ //# sourceMappingURL=types-CXBB4aIM.d.ts.map
package/dist/ui.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { s as TrajectoryEvent } from "./types-CVdTBXE_.js";
2
- import { ServerResponse } from "node:http";
1
+ import { u as TrajectoryEvent } from "./types-BqUY6nRX.js";
3
2
  import { UIMessageChunk } from "ai";
3
+ import { ServerResponse } from "node:http";
4
4
 
5
5
  //#region src/ui/to_ui_message_stream.d.ts
6
6
  /**
@@ -0,0 +1,117 @@
1
+ import { a as ParsedTrajectoryEvent } from "./trajectory-cSLNlHzh.js";
2
+
3
+ //#region src/viewer/start_viewer.d.ts
4
+ /**
5
+ * `start_viewer` programmatic embed implementation.
6
+ *
7
+ * Spin up the server, optionally start tailing a JSONL file, and return a
8
+ * handle that can stop both. `start_viewer` only depends on core's wire-format
9
+ * schema; it never reaches into the engine, composites, or any provider.
10
+ */
11
+ type StartViewerOptions = {
12
+ readonly path?: string;
13
+ readonly host?: string;
14
+ readonly port?: number;
15
+ readonly buffer?: number;
16
+ readonly on_parse_error?: (err: unknown, line: string) => void;
17
+ readonly on_io_error?: (err: unknown) => void;
18
+ readonly on_subscriber_error?: (err: unknown) => void;
19
+ };
20
+ type ViewerHandle = {
21
+ readonly url: string;
22
+ readonly host: string;
23
+ readonly port: number;
24
+ readonly close: () => Promise<void>;
25
+ };
26
+ /**
27
+ * Starts the viewer: brings up the HTTP/SSE server and, if `options.path`
28
+ * is set, a file tail that feeds the same broadcaster.
29
+ *
30
+ * Defaults to `127.0.0.1:4242` with a 1000-event ring buffer. HTTP ingest
31
+ * and SSE are always available; tailing is opt-in via `path`.
32
+ */
33
+ declare function start_viewer(options?: StartViewerOptions): Promise<ViewerHandle>;
34
+ //#endregion
35
+ //#region src/viewer/broadcast.d.ts
36
+ type BroadcastEvent = {
37
+ readonly id: number;
38
+ readonly event: ParsedTrajectoryEvent;
39
+ };
40
+ type Subscriber = (entry: BroadcastEvent) => void;
41
+ type Broadcaster = {
42
+ readonly emit: (event: ParsedTrajectoryEvent) => BroadcastEvent;
43
+ readonly subscribe: (fn: Subscriber) => () => void;
44
+ readonly snapshot: () => readonly BroadcastEvent[];
45
+ readonly snapshot_after: (last_id: number) => readonly BroadcastEvent[];
46
+ readonly size: () => number;
47
+ };
48
+ type BroadcasterOptions = {
49
+ readonly buffer: number;
50
+ readonly on_subscriber_error?: (err: unknown) => void;
51
+ };
52
+ /**
53
+ * Creates a broadcaster: a bounded ring buffer plus subscriber fan-out.
54
+ *
55
+ * Each event gets a monotonic `id` so SSE clients can replay from a known
56
+ * cursor on reconnect (`snapshot_after`). `emit` does not await delivery, so
57
+ * slow-client backpressure is the subscriber's responsibility. A subscriber
58
+ * that throws is unsubscribed, and the `on_subscriber_error` callback fires
59
+ * once with the captured error so the server can log it.
60
+ */
61
+ declare function create_broadcaster(options: BroadcasterOptions): Broadcaster;
62
+ //#endregion
63
+ //#region src/viewer/server.d.ts
64
+ type ServerOptions = {
65
+ readonly broadcaster: Broadcaster;
66
+ readonly host: string;
67
+ readonly port: number;
68
+ readonly on_parse_error?: (err: unknown, line: string) => void;
69
+ };
70
+ type ViewerServer = {
71
+ readonly url: string;
72
+ readonly close: () => Promise<void>;
73
+ };
74
+ /**
75
+ * Starts the HTTP server and resolves once it is listening.
76
+ *
77
+ * Wires the five routes (static HTML, health, snapshot, SSE, ingest) to a
78
+ * single request handler and resolves with the bound URL and a `close`
79
+ * that shuts the socket down.
80
+ */
81
+ declare function start_server(options: ServerOptions): Promise<ViewerServer>;
82
+ //#endregion
83
+ //#region src/viewer/tail.d.ts
84
+ type TailOptions = {
85
+ readonly path: string;
86
+ readonly on_event: (event: ParsedTrajectoryEvent) => void;
87
+ readonly on_parse_error?: (err: unknown, line: string) => void;
88
+ readonly on_io_error?: (err: unknown) => void;
89
+ };
90
+ type Tail = {
91
+ readonly stop: () => void;
92
+ readonly drain: () => Promise<void>;
93
+ };
94
+ /**
95
+ * Starts tailing `path` and returns a handle to stop or drain it.
96
+ *
97
+ * Watches the file with `fs.watch` and re-reads from the last known offset
98
+ * on every change, buffering an incomplete trailing line until the rest
99
+ * arrives. Overlapping change events are coalesced: a read already in
100
+ * flight absorbs any events that fire while it runs instead of starting a
101
+ * second concurrent read.
102
+ */
103
+ declare function start_tail(options: TailOptions): Tail;
104
+ //#endregion
105
+ //#region src/viewer/cli.d.ts
106
+ /**
107
+ * CLI entry point: parses argv, starts the viewer, and wires shutdown.
108
+ *
109
+ * Warns but proceeds when the tailed path does not exist yet or when the
110
+ * bind host is 0.0.0.0 (the dashboard has no auth). Optionally opens the
111
+ * browser, then installs SIGINT/SIGTERM handlers that close the viewer
112
+ * before exiting.
113
+ */
114
+ declare function run_viewer_cli(argv: readonly string[]): Promise<void>;
115
+ //#endregion
116
+ export { type BroadcastEvent, type Broadcaster, type BroadcasterOptions, type ServerOptions, type StartViewerOptions, type Subscriber, type Tail, type TailOptions, type ViewerHandle, type ViewerServer, create_broadcaster, run_viewer_cli, start_server, start_tail, start_viewer };
117
+ //# sourceMappingURL=viewer.d.ts.map