fascicle 0.10.1 → 0.10.2
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/CHANGELOG.md +12 -0
- package/dist/adapters.d.ts +1 -1
- package/dist/agents.d.ts +2 -2
- package/dist/agents.js +1 -1
- package/dist/{core-DNH8ddMT.js → core-Dit3Rv9J.js} +13 -9
- package/dist/{core-DNH8ddMT.js.map → core-Dit3Rv9J.js.map} +1 -1
- package/dist/{index-SkPG_Rew.d.ts → index-C2ayBpzS.d.ts} +7 -5
- package/dist/{index-BNgtkeUf.d.ts → index-CHtfOfEF.d.ts} +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +1 -1
- package/dist/otel.d.ts +1 -1
- package/dist/stdio.d.ts +1 -1
- package/dist/stdio.js +1 -1
- package/dist/ui.d.ts +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.10.2 — 2026-08-11
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- **`fallback` gains a `handoff` option, so the backup can be told why it is running.** `fallback(primary, backup, { handoff })` calls `handoff(input, err)` when the primary throws an application error and runs the backup on the result, instead of retrying the same input blind; a handoff note like "a previous attempt failed, answer from scratch" is the intended use. Omitting the option keeps the old behaviour exactly: the backup receives the original input. Control-flow signals are untouched by the new path: suspend and abort still propagate without triggering the backup, and the handoff is never called for them, so an approval gate cannot be bypassed through a mapped input. Tests pin the mapped-input path, the handoff argument order, the success path (no handoff call), and the control-flow bypass.
|
|
8
|
+
|
|
9
|
+
### Internal
|
|
10
|
+
|
|
11
|
+
- **The cookbook gains an escalation-tiering recipe: judge the cheap model's actual work, escalate only on real trouble.** Where `fallback` escalates on a throw, the recipe escalates on mediocrity. It covers the single-request shape (a buffered weak draft, a fail-open judge expressed as `fallback` around the judge so a dead judge serves the draft rather than escalating, and an escalate-or-serve `branch` that emits the verdict into the trajectory), a multi-turn latch that holds a confirmation streak in `loop` carry-state (an escalate verdict increments, a decline resets, a fail-open judge holds, two confirmations latch the run onto the strong tier), and a calibration method for deciding when the weak tier is enough (RESCUE/LOSS/SAFE/HARD quadrants over a strong-tier baseline plus a stratified weak-tier probe, harnessed with `bench` and pinned with `regression_compare`). The multi-provider fallback recipe picks up a `handoff` example.
|
|
12
|
+
- **`docs/comparison.md` places NVIDIA's Switchyard.** A wire-level routing proxy is a different layer, not competition: aligned with fascicle on keeping routing policy outside the model surface (its `libsy` library hands every model call back to the caller, the same separation as adapters passed in per run and verbatim model resolution), different on where routing belongs (rewriting traffic for clients you cannot modify versus explicit composition when you own the call site), and usable today as one more OpenAI-compatible gateway behind the compat recipe in `docs/providers.md`.
|
|
13
|
+
- **The check runner (checkride) is upgraded from 0.6.0 to 0.12.1.**
|
|
14
|
+
|
|
3
15
|
## v0.10.1 — 2026-08-07
|
|
4
16
|
|
|
5
17
|
### Fixed
|
package/dist/adapters.d.ts
CHANGED
package/dist/agents.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as Step } from "./index-
|
|
2
|
-
import { b as Engine } from "./index-
|
|
1
|
+
import { G as Step } from "./index-C2ayBpzS.js";
|
|
2
|
+
import { b as Engine } from "./index-CHtfOfEF.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/define_agent.d.ts
|
package/dist/agents.js
CHANGED
|
@@ -1559,11 +1559,13 @@ register_traced_kind("retry");
|
|
|
1559
1559
|
* fallback: primary-or-backup.
|
|
1560
1560
|
*
|
|
1561
1561
|
* `fallback(primary, backup)` runs `primary`. If it throws an application
|
|
1562
|
-
* error, runs `backup` with the same input
|
|
1563
|
-
* `
|
|
1564
|
-
* `
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1562
|
+
* error, runs `backup` with the same input, or with `handoff(input, err)`
|
|
1563
|
+
* when the `handoff` option is set, so the backup can be told why it is
|
|
1564
|
+
* running. If `backup` also throws, the `backup` error propagates.
|
|
1565
|
+
* Control-flow signals (`suspended_error`, `aborted_error`) are not
|
|
1566
|
+
* failures: they propagate instead of triggering the backup, so a
|
|
1567
|
+
* human-approval gate is never silently bypassed and the backup never runs
|
|
1568
|
+
* under an aborted context. `handoff` is never called for them.
|
|
1567
1569
|
*/
|
|
1568
1570
|
let fallback_counter = 0;
|
|
1569
1571
|
/**
|
|
@@ -1576,17 +1578,19 @@ function next_id$4() {
|
|
|
1576
1578
|
/**
|
|
1577
1579
|
* Build a primary-or-backup step.
|
|
1578
1580
|
*
|
|
1579
|
-
* Runs `primary`; on an application error runs `backup` with the same input
|
|
1580
|
-
*
|
|
1581
|
+
* Runs `primary`; on an application error runs `backup` with the same input,
|
|
1582
|
+
* or with `handoff(input, err)` when the option is set. Control-flow signals
|
|
1583
|
+
* propagate without triggering the backup or the handoff.
|
|
1581
1584
|
*/
|
|
1582
1585
|
function fallback(primary, backup, options) {
|
|
1583
1586
|
const id = next_id$4();
|
|
1587
|
+
const handoff = options?.handoff;
|
|
1584
1588
|
const run_fn = async (input, ctx) => {
|
|
1585
1589
|
try {
|
|
1586
1590
|
return await dispatch_step(primary, input, ctx);
|
|
1587
1591
|
} catch (err) {
|
|
1588
1592
|
if (is_control_flow_error(err)) throw err;
|
|
1589
|
-
return dispatch_step(backup, input, ctx);
|
|
1593
|
+
return dispatch_step(backup, handoff === void 0 ? input : handoff(input, err), ctx);
|
|
1590
1594
|
}
|
|
1591
1595
|
};
|
|
1592
1596
|
const config_meta = options?.name === void 0 ? void 0 : { display_name: options.name };
|
|
@@ -2152,4 +2156,4 @@ const trajectory_event_schema = z.union([
|
|
|
2152
2156
|
//#endregion
|
|
2153
2157
|
export { timeout_error as A, describe as C, describe_cycle_error as D, aborted_error as E, resume_validation_error as O, sequence as S, run as T, retry as _, trajectory_event_schema as a, branch as b, scope as c, suspend as d, checkpoint as f, fallback as g, timeout as h, span_start_event_schema as i, flow_schema_default as j, suspended_error as k, stash as l, loop as m, emit_event_schema as n, STEP_KINDS as o, compose as p, span_end_event_schema as r, is_step_kind as s, custom_event_schema as t, use as u, pipe as v, step as w, parallel as x, map as y };
|
|
2154
2158
|
|
|
2155
|
-
//# sourceMappingURL=core-
|
|
2159
|
+
//# sourceMappingURL=core-Dit3Rv9J.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core-DNH8ddMT.js","names":["is_step","is_step","next_id","is_step","next_id","next_id","next_id","next_id","is_step","next_id","next_id","next_id","next_id","next_id"],"sources":["../src/core/flow-schema.json","../src/core/cleanup.ts","../src/core/errors.ts","../src/core/streaming.ts","../src/core/runner.ts","../src/core/step.ts","../src/core/is_step.ts","../src/core/describe.ts","../src/core/sequence.ts","../src/core/parallel.ts","../src/core/branch.ts","../src/core/map.ts","../src/core/pipe.ts","../src/core/retry.ts","../src/core/fallback.ts","../src/core/timeout.ts","../src/core/loop.ts","../src/core/compose.ts","../src/core/checkpoint.ts","../src/core/suspend.ts","../src/core/scope.ts","../src/core/step_kinds.ts","../src/core/trajectory.ts","../src/core/index.ts"],"sourcesContent":["","/**\n * Per-run cleanup registry.\n *\n * Handlers fire in LIFO (reverse registration) order on abort, on uncaught\n * error in the root, and on successful completion. Each handler has a\n * 5-second timeout; timeouts are recorded in the trajectory but do not block\n * other handlers. A handler that throws is recorded as `cleanup_error`;\n * subsequent handlers still execute.\n */\n\nimport type { CleanupFn, TrajectoryLogger } from './types.js'\n\nconst HANDLER_TIMEOUT_MS = 5_000\n\nexport type CleanupRegistry = {\n readonly register: (fn: CleanupFn) => void\n readonly run_all: () => Promise<void>\n}\n\n/**\n * Create the per-run cleanup registry.\n *\n * `register` collects handlers during the run; `run_all` fires them once in\n * LIFO order and is idempotent. A registration arriving after the flush is\n * not executed; it is recorded as `cleanup_registered_after_flush` so the\n * leak is visible in the trajectory instead of silently dropped.\n */\nexport function create_cleanup_registry(trajectory: TrajectoryLogger): CleanupRegistry {\n const handlers: CleanupFn[] = []\n let ran = false\n\n function register(fn: CleanupFn): void {\n if (ran) {\n trajectory.record({\n kind: 'cleanup_registered_after_flush',\n })\n return\n }\n handlers.push(fn)\n }\n\n async function run_all(): Promise<void> {\n if (ran) return\n ran = true\n for (let i = handlers.length - 1; i >= 0; i -= 1) {\n const fn = handlers[i]\n if (!fn) continue\n await run_one(fn, trajectory)\n }\n }\n\n return { register, run_all }\n}\n\n/**\n * Run a single cleanup handler, never letting it fail the run.\n *\n * Races the handler against a 5-second timer. Whichever loses the race only\n * results in a trajectory record (`cleanup_timeout` or `cleanup_error`); the\n * returned promise always resolves so the remaining handlers still execute.\n * A timed-out handler keeps running in the background; it is abandoned, not\n * killed.\n */\nasync function run_one(fn: CleanupFn, trajectory: TrajectoryLogger): Promise<void> {\n let timeout_id: ReturnType<typeof setTimeout> | null = null\n try {\n await new Promise<void>((resolve) => {\n timeout_id = setTimeout(() => {\n trajectory.record({ kind: 'cleanup_timeout', timeout_ms: HANDLER_TIMEOUT_MS })\n resolve()\n }, HANDLER_TIMEOUT_MS)\n \n Promise.resolve()\n .then(() => fn())\n .then(\n () => {\n if (timeout_id) clearTimeout(timeout_id)\n resolve()\n },\n (err: unknown) => {\n if (timeout_id) clearTimeout(timeout_id)\n trajectory.record({\n kind: 'cleanup_error',\n error: err instanceof Error ? err.message : String(err),\n })\n resolve()\n },\n )\n })\n } finally {\n if (timeout_id) clearTimeout(timeout_id)\n }\n}\n","/**\n * Typed errors for the composition layer.\n *\n * This is the only source file in the core layer that uses the `class`\n * keyword. `Error` is a built-in and `instanceof` branching is how composers\n * like `retry` and `fallback` distinguish failure modes.\n */\n\nexport class timeout_error extends Error {\n readonly kind = 'timeout_error' as const;\n readonly timeout_ms: number;\n constructor(message: string, timeout_ms: number) {\n super(message)\n this.name = 'timeout_error'\n this.timeout_ms = timeout_ms\n }\n}\n\nexport class suspended_error extends Error {\n readonly kind = 'suspended_error' as const;\n readonly suspend_id: string;\n readonly payload: unknown;\n constructor(suspend_id: string, payload: unknown, message?: string) {\n super(message ?? `suspended at ${suspend_id}`)\n this.name = 'suspended_error'\n this.suspend_id = suspend_id\n this.payload = payload\n }\n}\n\nexport class resume_validation_error extends Error {\n readonly kind = 'resume_validation_error' as const;\n readonly issues: unknown;\n constructor(message: string, issues: unknown) {\n super(message)\n this.name = 'resume_validation_error'\n this.issues = issues\n }\n}\n\nexport class describe_cycle_error extends Error {\n readonly kind = 'describe_cycle_error' as const;\n readonly step_id: string;\n constructor(step_id: string, message?: string) {\n super(message ?? `describe: cycle detected at step id: ${step_id}`)\n this.name = 'describe_cycle_error'\n this.step_id = step_id\n }\n}\n\nexport class aborted_error extends Error {\n readonly kind = 'aborted_error' as const;\n readonly reason?: unknown;\n readonly step_index: number;\n readonly tool_call_in_flight?: { id: string; name: string };\n constructor(\n message = 'aborted',\n metadata: {\n reason?: unknown\n step_index?: number\n tool_call_in_flight?: { id: string; name: string }\n } = {},\n ) {\n super(message)\n this.name = 'aborted_error'\n if (metadata.reason !== undefined) this.reason = metadata.reason\n this.step_index = metadata.step_index ?? 0\n if (metadata.tool_call_in_flight !== undefined) {\n this.tool_call_in_flight = metadata.tool_call_in_flight\n }\n }\n}\n\n/**\n * Control-flow signals are not application failures. `suspended_error` is a\n * human-approval gate pausing the run for later resume; `aborted_error` is\n * cancellation. Resilience composers (`retry`, `fallback`) must rethrow these\n * rather than retry past a suspend or run a backup under an aborted context.\n *\n * Kept internal to core: not re-exported by index.ts, so it does not\n * widen the public surface.\n */\nexport function is_control_flow_error(\n err: unknown,\n): err is suspended_error | aborted_error {\n return err instanceof suspended_error || err instanceof aborted_error\n}\n","/**\n * Streaming observation channel.\n *\n * `run.stream(flow, input)` is a secondary entry point returning\n * `{ events, result }`. Events are observed via an async iterable; the result\n * promise resolves once the flow completes. Streaming is purely\n * observational: composers do not know it exists, and `run` and `run.stream`\n * produce identical final results.\n *\n * The event buffer has a default high-water mark of 10,000. When the consumer\n * never iterates, emissions past the mark drop the oldest events and record a\n * single `events_dropped` marker. The `result` promise resolves regardless of\n * buffer pressure.\n */\n\nimport type { TrajectoryEvent, TrajectoryLogger } from './types.js'\n\nexport const STREAMING_HIGH_WATER_MARK = 10_000\n\nexport type StreamingChannel = {\n readonly logger: TrajectoryLogger\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly close: () => void\n}\n\n/**\n * Build the logger/iterable pair backing `run.stream`.\n *\n * Wraps a base `TrajectoryLogger` so every recorded event is also enqueued\n * for the async iterable. A single pending `waiter` hands events straight to\n * a blocked consumer; otherwise events buffer up to `high_water_mark`, after\n * which the oldest are dropped and counted for the `events_dropped` marker\n * emitted at close.\n */\nexport function create_streaming_channel(\n base: TrajectoryLogger,\n high_water_mark = STREAMING_HIGH_WATER_MARK,\n): StreamingChannel {\n const buffer: TrajectoryEvent[] = []\n let dropped = 0\n let closed = false\n let marker_emitted = false\n let waiter: ((value: IteratorResult<TrajectoryEvent>) => void) | null = null\n\n function enqueue(event: TrajectoryEvent): void {\n if (closed) return\n if (waiter) {\n const resolve = waiter\n waiter = null\n resolve({ value: event, done: false })\n return\n }\n if (buffer.length >= high_water_mark) {\n buffer.shift()\n dropped += 1\n return\n }\n buffer.push(event)\n }\n\n function close(): void {\n if (closed) return\n closed = true\n if (dropped > 0 && !marker_emitted) {\n marker_emitted = true\n buffer.push({ kind: 'events_dropped', count: dropped })\n }\n if (waiter) {\n const resolve = waiter\n waiter = null\n resolve({ value: undefined, done: true })\n }\n }\n\n const logger: TrajectoryLogger = {\n record: (event) => {\n base.record(event)\n enqueue(event)\n },\n start_span: (name, meta) => {\n const id = base.start_span(name, meta)\n enqueue({ kind: 'span_start', span_id: id, name, ...meta })\n return id\n },\n end_span: (id, meta) => {\n base.end_span(id, meta)\n enqueue({ kind: 'span_end', span_id: id, ...meta })\n },\n }\n\n const events: AsyncIterable<TrajectoryEvent> = {\n [Symbol.asyncIterator]() {\n return {\n next(): Promise<IteratorResult<TrajectoryEvent>> {\n if (buffer.length > 0) {\n const next_event = buffer.shift()\n if (next_event !== undefined) {\n return Promise.resolve({ value: next_event, done: false })\n }\n }\n if (closed) {\n return Promise.resolve({ value: undefined, done: true })\n }\n return new Promise<IteratorResult<TrajectoryEvent>>((resolve) => {\n waiter = resolve\n })\n },\n return(): Promise<IteratorResult<TrajectoryEvent>> {\n close()\n return Promise.resolve({ value: undefined, done: true })\n },\n }\n },\n }\n\n return { logger, events, close }\n}\n","/**\n * Runner.\n *\n * Dispatches a step to its kind-specific handler. `runner.ts` contains no\n * composer-specific logic beyond a Map lookup on `step.kind`; each composer\n * file registers its handler at module load via `register_kind(...)`.\n *\n * `run(flow, input, options?)` constructs a fresh `RunContext` per top-level\n * call, installs process signal handlers (opt-out via options), forwards an\n * optional caller-supplied `AbortSignal` into the run, and guarantees cleanup\n * handlers execute in LIFO order on success, failure, or abort.\n *\n * `run.stream(flow, input, options?)` is a secondary entry point returning\n * `{ events, result }`. Streaming is purely observational; the step graph is\n * identical to `run(...)`.\n */\n\nimport { randomUUID } from 'node:crypto'\nimport { create_cleanup_registry } from './cleanup.js'\nimport { aborted_error } from './errors.js'\nimport { create_streaming_channel, STREAMING_HIGH_WATER_MARK } from './streaming.js'\nimport type {\n CheckpointStore,\n RunContext,\n Step,\n TrajectoryEvent,\n TrajectoryLogger,\n} from './types.js'\n\ntype Dispatcher = (\n flow: Step<unknown, unknown>,\n input: unknown,\n ctx: RunContext,\n) => Promise<unknown>\n\nconst dispatch = new Map<string, Dispatcher>()\n\n/**\n * Register the dispatch handler for a step kind.\n *\n * Composer files call this (directly or via `register_traced_kind`) at module\n * load, which is how the runner stays free of composer-specific logic.\n */\nexport function register_kind(kind: string, fn: Dispatcher): void {\n dispatch.set(kind, fn)\n}\n\n/**\n * Resolve the trajectory span label for a step. Prefers a non-empty\n * `display_name` from `flow.config`; otherwise falls back to the supplied\n * default (typically the step's `kind`).\n *\n * Dispatch handlers use this so that any composer carrying a user-supplied\n * `name` surfaces under that label in the trajectory, while unconfigured\n * composers retain their kind-based label.\n */\nexport function resolve_span_label(\n flow: Step<unknown, unknown>,\n fallback: string,\n): string {\n const display = flow.config?.['display_name']\n return typeof display === 'string' && display.length > 0 ? display : fallback\n}\n\n/**\n * Register the standard span-wrapping dispatch handler for a composer kind.\n *\n * Every composer wraps `flow.run` in a span identically; this centralizes that\n * boilerplate and threads span parentage: the span opens with the current\n * `ctx.parent_span_id` as its parent, and `flow.run` receives a child context\n * whose `parent_span_id` is this span. Children dispatched from within\n * (including concurrent ones under `parallel`/`map`, which spread the context)\n * therefore nest correctly instead of leaving `parent_span_id` unpopulated.\n */\nexport function register_traced_kind(kind: string): void {\n register_kind(kind, async (flow, input, ctx) => {\n const label = resolve_span_label(flow, kind)\n const span_meta: Record<string, unknown> = { id: flow.id }\n if (ctx.parent_span_id !== undefined) {\n span_meta['parent_span_id'] = ctx.parent_span_id\n }\n const span_id = ctx.trajectory.start_span(label, span_meta)\n const child_ctx: RunContext = { ...ctx, parent_span_id: span_id }\n try {\n const out = await flow.run(input, child_ctx)\n ctx.trajectory.end_span(span_id, { id: flow.id })\n return out\n } catch (err) {\n ctx.trajectory.end_span(span_id, {\n id: flow.id,\n error: err instanceof Error ? err.message : String(err),\n })\n throw err\n }\n })\n}\n\nexport type RunOptions = {\n readonly install_signal_handlers?: boolean\n readonly trajectory?: TrajectoryLogger\n readonly checkpoint_store?: CheckpointStore\n readonly resume_data?: Readonly<Record<string, unknown>>\n // A caller-owned cancellation source (HTTP request, queue shutdown, MCP\n // request, AbortSignal.timeout). When it fires the run aborts with its\n // reason, composing with the internal controller and the process signal\n // handlers rather than replacing them.\n readonly abort?: AbortSignal\n}\n\nexport type StreamingRunHandle<o> = {\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly result: Promise<o>\n}\n\nconst active_runs = new Set<AbortController>()\nlet signal_handler_installed = false\nlet sigint_handler: (() => void) | null = null\nlet sigterm_handler: (() => void) | null = null\n\n/**\n * Install process-wide SIGINT/SIGTERM handlers once.\n *\n * The handlers abort every active run with an `aborted_error` naming the\n * signal, so a Ctrl-C tears down all in-flight flows through the normal\n * abort/cleanup path instead of killing the process mid-step.\n */\nfunction ensure_signal_handlers(): void {\n if (signal_handler_installed) return\n signal_handler_installed = true\n const abort_all = (signal_name: string) => () => {\n for (const controller of active_runs) {\n controller.abort(new aborted_error(`received ${signal_name}`, { reason: { signal: signal_name } }))\n }\n }\n sigint_handler = abort_all('SIGINT')\n sigterm_handler = abort_all('SIGTERM')\n process.on('SIGINT', sigint_handler)\n process.on('SIGTERM', sigterm_handler)\n}\n\n/**\n * Remove the process signal handlers once the last active run settles.\n *\n * Keeps a library embed from leaving stray `process.on` listeners behind\n * after all runs complete.\n */\nfunction release_signal_handlers(): void {\n if (!signal_handler_installed) return\n if (active_runs.size > 0) return\n signal_handler_installed = false\n if (sigint_handler) process.off('SIGINT', sigint_handler)\n if (sigterm_handler) process.off('SIGTERM', sigterm_handler)\n sigint_handler = null\n sigterm_handler = null\n}\n\nconst noop_logger: TrajectoryLogger = {\n record: () => {},\n start_span: (name) => `${name}:${randomUUID().slice(0, 8)}`,\n end_span: () => {},\n}\n\n/**\n * Wrap a logger so every emitted event automatically carries `run_id` and a\n * `ts` (epoch milliseconds) stamped at emission.\n *\n * Studios and other downstream consumers multiplex events across runs by\n * `run_id` and reconstruct real timing from `ts` instead of fabricating it at\n * ingest. Either field already present on an event or its meta is preserved;\n * we never overwrite a caller-supplied value.\n */\nfunction decorate_logger(inner: TrajectoryLogger, run_id: string): TrajectoryLogger {\n const stamp_meta = (\n meta: Record<string, unknown> | undefined,\n ): Record<string, unknown> => {\n const out: Record<string, unknown> = { ...meta }\n if (!('run_id' in out)) out['run_id'] = run_id\n if (!('ts' in out)) out['ts'] = Date.now()\n return out\n }\n return {\n record: (event) => {\n if ('run_id' in event && 'ts' in event) {\n inner.record(event)\n return\n }\n const extra: Record<string, unknown> = {}\n if (!('run_id' in event)) extra['run_id'] = run_id\n if (!('ts' in event)) extra['ts'] = Date.now()\n inner.record({ ...event, ...extra })\n },\n start_span: (name, meta) => inner.start_span(name, stamp_meta(meta)),\n end_span: (id, meta) => {\n inner.end_span(id, stamp_meta(meta))\n },\n }\n}\n\n/**\n * Route a step to its registered kind handler.\n *\n * This is the single entry point composers use to run children. On failure\n * the step's id is prepended to the error's `path`, so an error surfacing\n * from a deep tree carries the chain of step ids it crossed.\n */\nexport async function dispatch_step<i, o>(\n flow: Step<i, o>,\n input: i,\n ctx: RunContext,\n): Promise<o> {\n const handler = dispatch.get(flow.kind)\n if (!handler) {\n throw new Error(`unknown step kind: ${flow.kind} (step id: ${flow.id})`)\n }\n try {\n const result = await handler(flow, input, ctx)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return result as o\n } catch (err) {\n prepend_path(err, flow.id)\n throw err\n }\n}\n\n/**\n * Prepend a step id to the `path` array carried on an error object.\n *\n * Mutates the error in place so the path accumulates as the error bubbles up\n * through nested dispatches. Non-object errors are left untouched.\n */\nexport function prepend_path(err: unknown, id: string): void {\n if (err === null || typeof err !== 'object') return\n const existing = Reflect.get(err, 'path')\n const next: string[] = Array.isArray(existing)\n ? [id, ...existing.filter((v): v is string => typeof v === 'string')]\n : [id]\n Reflect.set(err, 'path', next)\n}\n\n/**\n * Throw the abort reason if the context has been cancelled. Composers that\n * iterate over children (`sequence`, `scope`, `loop`) call this between steps\n * so a pending abort is honored before the next child starts, not only when a\n * downstream dispatch happens to observe it.\n */\nexport function throw_if_aborted(ctx: RunContext): void {\n if (!ctx.abort.aborted) return\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n}\n\n/**\n * Forward a caller-owned AbortSignal into the run's internal controller and\n * return an unlink function. The reason is preserved so the original\n * cancellation cause propagates out of `run`. The listener is `once` and the\n * returned unlink is called when the run settles, so a long-lived host (an MCP\n * server, an HTTP worker) firing many short runs against one external signal\n * does not accumulate listeners.\n */\nfunction link_external_abort(\n controller: AbortController,\n external: AbortSignal | undefined,\n): () => void {\n if (external === undefined) return () => {}\n if (external.aborted) {\n controller.abort(external.reason)\n return () => {}\n }\n const on_abort = (): void => {\n controller.abort(external.reason)\n }\n external.addEventListener('abort', on_abort, { once: true })\n return () => {\n external.removeEventListener('abort', on_abort)\n }\n}\n\ntype StartResult<o> = {\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly result: Promise<o>\n}\n\n/**\n * Construct a run context and execute a flow to settlement.\n *\n * Shared engine behind `run` and `run.stream`; `high_water_mark` selects the\n * mode (null means no streaming channel). Owns the full run lifecycle:\n * abort wiring, logger decoration, cleanup registration, signal handlers,\n * and the settle-time teardown ordering (cleanup handlers first, then\n * unlinking and stream close).\n */\nfunction start_run<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions,\n high_water_mark: number | null,\n): StartResult<o> {\n const install_signal_handlers = options.install_signal_handlers !== false\n const base_logger = options.trajectory ?? noop_logger\n const streaming = high_water_mark !== null\n\n const controller = new AbortController()\n const unlink_abort = link_external_abort(controller, options.abort)\n const run_id = randomUUID()\n\n let stream_events: AsyncIterable<TrajectoryEvent> = empty_async_iterable()\n let close_stream: (() => void) | null = null\n let inner: TrajectoryLogger = base_logger\n\n if (streaming) {\n // Decorate must wrap the streaming channel, not the reverse: the channel\n // enqueues a copy of each event for `run.stream` consumers, so it has to\n // see the events after `decorate_logger` has stamped `ts` and `run_id`.\n const channel = create_streaming_channel(base_logger, high_water_mark)\n inner = channel.logger\n stream_events = channel.events\n close_stream = channel.close\n }\n\n const logger: TrajectoryLogger = decorate_logger(inner, run_id)\n\n const cleanup = create_cleanup_registry(logger)\n\n const ctx: RunContext = {\n run_id,\n trajectory: logger,\n state: new Map(),\n abort: controller.signal,\n emit: (event) => {\n logger.record({ ...event, kind: 'emit' })\n },\n on_cleanup: (fn) => {\n cleanup.register(fn)\n },\n checkpoint_store: options.checkpoint_store,\n resume_data: options.resume_data,\n streaming,\n }\n\n active_runs.add(controller)\n if (install_signal_handlers) {\n ensure_signal_handlers()\n }\n\n const result = (async (): Promise<o> => {\n try {\n // Honor an external signal that was already aborted at call time, so the\n // run rejects without dispatching even when the flow is a single leaf\n // step that never reaches a cooperative abort check.\n throw_if_aborted(ctx)\n return await dispatch_step(flow, input, ctx)\n } catch (err) {\n if (controller.signal.aborted && !(err instanceof aborted_error)) {\n const reason = controller.signal.reason\n if (reason instanceof aborted_error) throw reason\n }\n throw err\n } finally {\n try {\n await cleanup.run_all()\n } finally {\n unlink_abort()\n active_runs.delete(controller)\n release_signal_handlers()\n if (close_stream) close_stream()\n }\n }\n })()\n\n return { events: stream_events, result }\n}\n\n/**\n * Build an async iterable that is immediately done.\n *\n * Non-streaming runs hand this to callers so the `events` field always has\n * the same shape regardless of mode.\n */\nfunction empty_async_iterable(): AsyncIterable<TrajectoryEvent> {\n return {\n [Symbol.asyncIterator]() {\n return {\n next: (): Promise<IteratorResult<TrajectoryEvent>> =>\n Promise.resolve({ value: undefined, done: true } as IteratorResult<TrajectoryEvent>),\n }\n },\n }\n}\n\n/**\n * Execute a flow and resolve with its final output.\n */\nasync function run_impl<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions = {},\n): Promise<o> {\n const { result } = start_run(flow, input, options, null)\n return result\n}\n\n/**\n * Execute a flow while exposing its trajectory events as an async iterable.\n */\nfunction run_stream<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions = {},\n): StreamingRunHandle<o> {\n const { events, result } = start_run(flow, input, options, STREAMING_HIGH_WATER_MARK)\n return { events, result }\n}\n\n/**\n * The public entry point for executing a flow.\n *\n * Callable as `run(flow, input, options?)` for a plain result, or\n * `run.stream(flow, input, options?)` for `{ events, result }`. Both share\n * one implementation, so a streamed run and a plain run of the same flow\n * produce identical output.\n */\nexport const run: typeof run_impl & { stream: typeof run_stream } = Object.assign(run_impl, {\n stream: run_stream,\n})\n","/**\n * step() factory.\n *\n * Three forms:\n * step(id, fn): named step. id is rendered in trajectory spans and describe().\n * step(id, fn, meta): named step with optional human-readable metadata for studio,\n * codegen, and similar consumers. `meta` is purely descriptive\n * and never affects runtime semantics.\n * step(fn): anonymous step. id is `anon_<counter>`; cannot be checkpointed.\n *\n * Anonymous steps carry an internal `anonymous: true` flag so checkpoint can\n * reject them synchronously at flow construction time.\n */\n\nimport { register_traced_kind } from './runner.js'\nimport type { Step, StepFn, StepMetadata } from './types.js'\n\nlet anon_counter = 0\n\n/**\n * Generate a unique id of the form `anon_<n>` for anonymous steps.\n */\nfunction next_anon_id(): string {\n anon_counter += 1\n return `anon_${anon_counter}`\n}\n\n/**\n * Wrap a plain function as a `Step`, named or anonymous.\n *\n * The named form takes an explicit id (and optional descriptive `meta`); the\n * anonymous form generates an `anon_<n>` id and marks the step so checkpoint\n * rejects it at construction time.\n */\nexport function step<i, o>(id: string, fn: StepFn<i, o>, meta?: StepMetadata): Step<i, o>\nexport function step<i, o>(fn: StepFn<i, o>): Step<i, o>\nexport function step<i, o>(\n id_or_fn: string | StepFn<i, o>,\n maybe_fn?: StepFn<i, o>,\n meta?: StepMetadata,\n): Step<i, o> {\n if (typeof id_or_fn === 'function') {\n return {\n id: next_anon_id(),\n kind: 'step',\n run: id_or_fn,\n anonymous: true,\n }\n }\n if (typeof maybe_fn !== 'function') {\n throw new TypeError('step(id, fn): fn must be a function')\n }\n if (meta) {\n return {\n id: id_or_fn,\n kind: 'step',\n run: maybe_fn,\n meta,\n }\n }\n return {\n id: id_or_fn,\n kind: 'step',\n run: maybe_fn,\n }\n}\n\nregister_traced_kind('step')\n","/**\n * is_step: structural Step check.\n *\n * Steps are plain objects with no brand symbol, so runtime detection is\n * structural: string `id`, string `kind`, callable `run`. Used by describe()\n * to render Step references and by combinators to validate arguments at\n * construction time.\n */\n\nimport type { Step } from './types.js'\n\n/**\n * Check whether a value is structurally a `Step`.\n *\n * True when the value has a string `id`, a string `kind`, and a callable\n * `run`.\n */\nexport function is_step(value: unknown): value is Step<unknown, unknown> {\n if (typeof value !== 'object' || value === null) return false\n if (!('id' in value) || !('kind' in value) || !('run' in value)) return false\n const { id, kind, run } = value\n return typeof id === 'string' && typeof kind === 'string' && typeof run === 'function'\n}\n","/**\n * describe(step) and describe.json(step): composition introspection.\n *\n * `describe(step)` is the text-tree renderer. Multi-line string with\n * hierarchical indentation. Function values render as `<fn>` (or\n * `<fn:name>` when the function has a non-empty `name`); zod schemas\n * render as `<schema>`.\n *\n * `describe.json(step)` returns a `FlowNode` tree (kind, id, config, children)\n * for tooling (Studio UI, Mermaid renderers, diff tools). Function values\n * serialize as `{ kind: '<fn>', name? }` and schemas as `{ kind: '<schema>' }`.\n *\n * Both forms detect cycles. Under the default (loose) mode, back-references\n * render as `<cycle>(id)` in text and `{ kind: '<cycle>', id }` in JSON. Under\n * `{ strict: true }`, cycles throw `describe_cycle_error`.\n */\n\nimport { describe_cycle_error } from './errors.js'\nimport { is_step } from './is_step.js'\nimport type { Step, StepMetadata } from './types.js'\n\nconst INDENT = ' '\n\nexport type FlowValue =\n | string\n | number\n | boolean\n | null\n | ReadonlyArray<FlowValue>\n | Readonly<{ [key: string]: FlowValue }>\n | { readonly kind: '<fn>'; readonly name?: string }\n | { readonly kind: '<schema>' }\n | { readonly kind: string; readonly id: string }\n\nexport type FlowNode = {\n readonly kind: string\n readonly id: string\n readonly config?: Readonly<{ [key: string]: FlowValue }>\n readonly children?: ReadonlyArray<FlowNode>\n readonly meta?: StepMetadata\n}\n\nexport type DescribeOptions = {\n readonly strict?: boolean\n}\n\ntype Path = Set<Step<unknown, unknown>>\n\n/**\n * Render a step tree as an indented multi-line string.\n */\nfunction describe_text<i, o>(root: Step<i, o>, options?: DescribeOptions): string {\n const lines: string[] = []\n const strict = Boolean(options?.strict)\n render_text(root, 0, lines, new Set(), strict)\n return lines.join('\\n')\n}\n\n/**\n * Render a step tree as a serializable `FlowNode` tree.\n */\nfunction describe_json<i, o>(root: Step<i, o>, options?: DescribeOptions): FlowNode {\n const strict = Boolean(options?.strict)\n return render_json(root, new Set(), strict)\n}\n\n/**\n * Public entry point: `describe(step)` for text, `describe.json(step)` for\n * the `FlowNode` tree.\n */\nexport const describe: {\n <i, o>(root: Step<i, o>, options?: DescribeOptions): string\n json: <i, o>(root: Step<i, o>, options?: DescribeOptions) => FlowNode\n} = Object.assign(describe_text, { json: describe_json })\n\n/**\n * Append one node (label line, config lines, then children) to `lines`.\n *\n * `path` holds the steps on the current root-to-node path for cycle\n * detection; membership is added before recursing and removed in a `finally`\n * so shared (diamond) references are not misreported as cycles.\n */\nfunction render_text(\n node: Step<unknown, unknown>,\n depth: number,\n lines: string[],\n path: Path,\n strict: boolean,\n): void {\n const prefix = INDENT.repeat(depth)\n if (path.has(node)) {\n if (strict) throw new describe_cycle_error(node.id)\n lines.push(`${prefix}<cycle>(${node.id})`)\n return\n }\n path.add(node)\n try {\n const display = node.config?.['display_name']\n const label = typeof display === 'string' && display.length > 0 ? display : node.kind\n lines.push(`${prefix}${label}(${node.id})`)\n if (node.config) {\n for (const [key, value] of Object.entries(node.config)) {\n if (key === 'display_name') continue\n lines.push(`${prefix}${INDENT}${key}: ${render_value_text(value, path, strict)}`)\n }\n }\n if (node.children && node.children.length > 0) {\n for (const child of node.children) {\n render_text(child, depth + 1, lines, path, strict)\n }\n }\n } finally {\n path.delete(node)\n }\n}\n\n/**\n * Render a single config value for the text tree.\n *\n * Functions become `<fn>` or `<fn:name>`, zod schemas `<schema>`, and Step\n * references `kind(id)`; arrays and plain objects recurse. Strings are\n * JSON-quoted so empty and whitespace values stay visible.\n */\nfunction render_value_text(value: unknown, path: Path, strict: boolean): string {\n if (typeof value === 'function') {\n const name = typeof value.name === 'string' && value.name.length > 0 ? value.name : ''\n return name ? `<fn:${name}>` : '<fn>'\n }\n if (value === null) return 'null'\n if (value === undefined) return 'undefined'\n if (is_zod_schema(value)) return '<schema>'\n if (is_step(value)) {\n if (path.has(value)) {\n if (strict) throw new describe_cycle_error(value.id)\n return `<cycle>(${value.id})`\n }\n return `${value.kind}(${value.id})`\n }\n if (Array.isArray(value)) {\n return `[${value.map((item: unknown) => render_value_text(item, path, strict)).join(', ')}]`\n }\n if (typeof value === 'object') {\n const entries = Object.entries({ ...value }).map(\n ([k, v]: [string, unknown]) => `${k}: ${render_value_text(v, path, strict)}`,\n )\n return `{ ${entries.join(', ')} }`\n }\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') return `${value.toString()}n`\n if (typeof value === 'symbol') return value.toString()\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n return JSON.stringify(value)\n}\n\n/**\n * Convert one step node to a `FlowNode`, recursing into config and children.\n *\n * Uses the same path-based cycle detection as `render_text`: back-references\n * become `{ kind: '<cycle>', id }` in loose mode and throw in strict mode.\n */\nfunction render_json(\n node: Step<unknown, unknown>,\n path: Path,\n strict: boolean,\n): FlowNode {\n if (path.has(node)) {\n if (strict) throw new describe_cycle_error(node.id)\n return { kind: '<cycle>', id: node.id }\n }\n path.add(node)\n try {\n const result: {\n kind: string\n id: string\n config?: { [key: string]: FlowValue }\n children?: FlowNode[]\n meta?: StepMetadata\n } = { kind: node.kind, id: node.id }\n if (node.config) {\n const config: { [key: string]: FlowValue } = {}\n for (const [key, value] of Object.entries(node.config)) {\n config[key] = render_value_json(value, path, strict)\n }\n result.config = config\n }\n if (node.children && node.children.length > 0) {\n result.children = node.children.map((child) => render_json(child, path, strict))\n }\n if (node.meta) {\n result.meta = node.meta\n }\n return result\n } finally {\n path.delete(node)\n }\n}\n\n/**\n * Convert a single config value to a JSON-safe `FlowValue`.\n *\n * Functions serialize as `{ kind: '<fn>', name? }`, schemas as\n * `{ kind: '<schema>' }`, Step references as `{ kind, id }`. `undefined`\n * maps to `null` and bigints/symbols to strings so the result survives\n * `JSON.stringify` without loss.\n */\nfunction render_value_json(value: unknown, path: Path, strict: boolean): FlowValue {\n if (typeof value === 'function') {\n const name = typeof value.name === 'string' && value.name.length > 0 ? value.name : ''\n return name ? { kind: '<fn>', name } : { kind: '<fn>' }\n }\n if (value === null) return null\n if (value === undefined) return null\n if (is_zod_schema(value)) return { kind: '<schema>' }\n if (is_step(value)) {\n if (path.has(value)) {\n if (strict) throw new describe_cycle_error(value.id)\n return { kind: '<cycle>', id: value.id }\n }\n return { kind: value.kind, id: value.id }\n }\n if (Array.isArray(value)) {\n return value.map((item: unknown) => render_value_json(item, path, strict))\n }\n if (typeof value === 'object') {\n const out: { [key: string]: FlowValue } = {}\n for (const [k, v] of Object.entries({ ...value })) {\n out[k] = render_value_json(v, path, strict)\n }\n return out\n }\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean') return value\n if (typeof value === 'bigint') return `${value.toString()}n`\n if (typeof value === 'symbol') return value.toString()\n return JSON.stringify(value)\n}\n\n/**\n * Detect a zod schema by its internal marker properties (`_zod` in zod 4,\n * `_def` in zod 3) without importing zod.\n */\nfunction is_zod_schema(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false\n return '_zod' in value || '_def' in value\n}\n","/**\n * sequence: chain child outputs.\n *\n * `sequence([a, b, c])` runs a, b, c in declared order. The input to sequence\n * is passed to the first child; each subsequent child receives the previous\n * child's output. The composer returns the last child's output.\n */\n\nimport { is_step } from './is_step.js'\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype FirstInput<children> = children extends readonly [Step<infer i, unknown>, ...unknown[]]\n ? i\n : unknown\n\ntype LastOutput<children> = children extends readonly [...unknown[], Step<unknown, infer o>]\n ? o\n : children extends readonly [Step<unknown, infer o>]\n ? o\n : unknown\n\nlet sequence_counter = 0\n\n/**\n * Generate a unique step id of the form `sequence_<n>`.\n */\nfunction next_id(): string {\n sequence_counter += 1\n return `sequence_${sequence_counter}`\n}\n\nexport type SequenceOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that chains children, each feeding the next.\n *\n * Validates every element up front so a non-Step (usually a bare function)\n * fails at construction with a pointed message rather than at run time.\n * Checks `ctx.abort` before each child so aborts land on step boundaries.\n */\nexport function sequence<const children extends readonly AnyStep[]>(\n children: children,\n options?: SequenceOptions,\n): Step<FirstInput<children>, LastOutput<children>> {\n if (!Array.isArray(children)) {\n throw new TypeError(\n `sequence(children): children must be an array of Steps, got ${typeof children} — sequence takes a single array, e.g. sequence([a, b, c])`,\n )\n }\n children.forEach((child, index) => {\n if (is_step(child)) return\n const hint =\n typeof child === 'function'\n ? ' — wrap plain functions with step(fn), or use pipe(inner, fn) to transform output'\n : ''\n throw new TypeError(\n `sequence(children): children[${index}] is not a Step, got ${typeof child}${hint}`,\n )\n })\n\n const id = next_id()\n const children_ref = children\n const run_fn = async (input: unknown, ctx: RunContext): Promise<unknown> => {\n let acc: unknown = input\n for (const child of children_ref) {\n throw_if_aborted(ctx)\n acc = await dispatch_step(child, acc, ctx)\n }\n return acc\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return {\n id,\n kind: 'sequence',\n children,\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n } as Step<FirstInput<children>, LastOutput<children>>\n}\n\nregister_traced_kind('sequence')\n","/**\n * parallel: concurrent execution of named children.\n *\n * `parallel({ a, b })` runs a and b concurrently with the same input. Output\n * is an object keyed by the child name; all children must accept the same\n * input type.\n *\n * Cancellation: each child runs with a composed abort signal,\n * `AbortSignal.any([ctx.abort, child_local])`. On abort the composer awaits\n * all in-flight children (success, failure, or aborted) before rethrowing\n * `ctx.abort.reason`.\n *\n * When several children fail, a `suspended_error` is preferred over an\n * application error so a human-approval gate inside a branch stays resumable\n * rather than being masked by a sibling's failure. Otherwise the first error\n * in declared order propagates.\n */\n\nimport { aborted_error, suspended_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype OutputOf<s> = s extends Step<unknown, infer o> ? o : unknown\n\ntype ParallelOutputs<children extends Record<string, AnyStep>> = {\n [k in keyof children]: OutputOf<children[k]>\n}\n\nlet parallel_counter = 0\n\n/**\n * Generate a unique step id of the form `parallel_<n>`.\n */\nfunction next_id(): string {\n parallel_counter += 1\n return `parallel_${parallel_counter}`\n}\n\nexport type ParallelOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that runs named children concurrently on the same input.\n *\n * Returns an object keyed by child name. All children settle before any\n * error propagates; a `suspended_error` wins over application errors so a\n * human-approval gate stays resumable instead of being masked by a sibling's\n * failure.\n */\nexport function parallel<i, children extends Record<string, Step<i, unknown>>>(\n members: children,\n options?: ParallelOptions,\n): Step<i, ParallelOutputs<children>> {\n const id = next_id()\n const entries: ReadonlyArray<readonly [string, AnyStep]> = Object.entries(members)\n const child_list: ReadonlyArray<AnyStep> = entries.map(([, s]) => s)\n const keys: ReadonlyArray<string> = entries.map(([k]) => k)\n\n const run_fn = async (input: i, ctx: RunContext): Promise<ParallelOutputs<children>> => {\n const controllers = entries.map(() => new AbortController())\n const on_parent_abort = (): void => {\n for (const c of controllers) c.abort(ctx.abort.reason)\n }\n if (ctx.abort.aborted) {\n on_parent_abort()\n } else {\n ctx.abort.addEventListener('abort', on_parent_abort, { once: true })\n }\n \n try {\n const settled = await Promise.all(\n entries.map(async ([key, child], idx) => {\n const local = controllers[idx]\n if (!local) throw new Error('parallel: missing controller')\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n try {\n const value = await dispatch_step(child, input, child_ctx)\n return { status: 'ok' as const, key, value }\n } catch (err) {\n return { status: 'err' as const, key, err }\n }\n }),\n )\n \n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n\n let first_err: unknown\n let has_err = false\n let suspended: unknown\n let has_suspended = false\n for (const s of settled) {\n if (s.status !== 'err') continue\n if (!has_err) {\n first_err = s.err\n has_err = true\n }\n if (!has_suspended && s.err instanceof suspended_error) {\n suspended = s.err\n has_suspended = true\n }\n }\n if (has_suspended) throw suspended\n if (has_err) throw first_err\n \n const out: Record<string, unknown> = {}\n for (const s of settled) {\n if (s.status === 'ok') out[s.key] = s.value\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return out as ParallelOutputs<children>\n } finally {\n ctx.abort.removeEventListener('abort', on_parent_abort)\n }\n }\n\n const config_meta: Record<string, unknown> = { keys }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'parallel',\n children: child_list,\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('parallel')\n","/**\n * branch: conditional routing.\n *\n * `branch({ when, then, otherwise })` evaluates `when(input)`; if truthy, runs\n * `then`, else runs `otherwise`. Both branches must return the same output\n * type.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type BranchConfig<i, o> = {\n readonly name?: string\n readonly when: (input: i) => boolean | Promise<boolean>\n readonly then: Step<i, o>\n readonly otherwise: Step<i, o>\n}\n\nlet branch_counter = 0\n\n/**\n * Generate a unique step id of the form `branch_<n>`.\n */\nfunction next_id(): string {\n branch_counter += 1\n return `branch_${branch_counter}`\n}\n\n/**\n * Build a conditional-routing step.\n *\n * Evaluates `when(input)` at run time and dispatches to `then` or `otherwise`.\n * Both branches appear as children so `describe()` renders the full tree even\n * though only one branch runs.\n */\nexport function branch<i, o>(config: BranchConfig<i, o>): Step<i, o> {\n const id = next_id()\n const { when, then: then_step, otherwise: otherwise_step, name } = config\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const cond = await when(input)\n const next_step = cond ? then_step : otherwise_step\n return dispatch_step(next_step, input, ctx)\n }\n\n const config_meta: Record<string, unknown> = { when, then: then_step, otherwise: otherwise_step }\n if (name !== undefined) config_meta['display_name'] = name\n\n return {\n id,\n kind: 'branch',\n children: [then_step, otherwise_step],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('branch')\n","/**\n * map: per-item execution.\n *\n * `map({ items, do, concurrency? })` extracts an array via `items(input)`,\n * runs `do` once per element, returns an array in the same order as inputs.\n * `concurrency` caps simultaneous in-flight items; omitted means full\n * parallelism.\n *\n * Cancellation: each in-flight item runs with a composed abort signal via\n * `AbortSignal.any([ctx.abort, child_local])`.\n * On abort no new items start. The composer awaits all in-flight items before\n * rethrowing `ctx.abort.reason`.\n */\n\nimport { aborted_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type MapConfig<input, item, result> = {\n readonly name?: string\n readonly items: (input: input) => ReadonlyArray<item> | Promise<ReadonlyArray<item>>\n readonly do: Step<item, result>\n readonly concurrency?: number\n}\n\nlet map_counter = 0\n\n/**\n * Generate a unique step id of the form `map_<n>`.\n */\nfunction next_id(): string {\n map_counter += 1\n return `map_${map_counter}`\n}\n\n/**\n * Build a per-item execution step.\n *\n * Extracts an array via `items(input)`, runs `do` once per element through a\n * bounded worker pool, and returns results in input order. The first item\n * failure stops new work and propagates after in-flight items settle.\n */\nexport function map<input, item, result>(\n config: MapConfig<input, item, result>,\n): Step<input, result[]> {\n const id = next_id()\n const { items, do: per_item, concurrency, name } = config\n\n const run_fn = async (input: input, ctx: RunContext): Promise<result[]> => {\n const list = await items(input)\n if (list.length === 0) return []\n const results: result[] = Array.from({ length: list.length })\n \n const limit = concurrency === undefined ? list.length : Math.max(1, concurrency)\n const controllers: AbortController[] = []\n \n const on_parent_abort = (): void => {\n for (const c of controllers) c.abort(ctx.abort.reason)\n }\n if (ctx.abort.aborted) {\n on_parent_abort()\n } else {\n ctx.abort.addEventListener('abort', on_parent_abort, { once: true })\n }\n \n let cursor = 0\n let worker_error: unknown = undefined\n \n const run_one = async (idx: number): Promise<void> => {\n const local = new AbortController()\n controllers.push(local)\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n const item_value = list[idx]\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const value = await dispatch_step(per_item, item_value as item, child_ctx)\n results[idx] = value\n }\n \n const worker = async (): Promise<void> => {\n while (true) {\n if (ctx.abort.aborted || worker_error !== undefined) return\n const idx = cursor\n cursor += 1\n if (idx >= list.length) return\n try {\n await run_one(idx)\n } catch (err) {\n if (worker_error === undefined) worker_error = err\n return\n }\n }\n }\n \n try {\n const worker_count = Math.min(limit, list.length)\n const workers: Promise<void>[] = []\n for (let w = 0; w < worker_count; w += 1) {\n workers.push(worker())\n }\n await Promise.all(workers)\n \n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n if (worker_error !== undefined) throw worker_error\n \n return results\n } finally {\n ctx.abort.removeEventListener('abort', on_parent_abort)\n }\n }\n\n const config_meta: Record<string, unknown> = { items }\n if (concurrency !== undefined) config_meta['concurrency'] = concurrency\n if (name !== undefined) config_meta['display_name'] = name\n\n return {\n id,\n kind: 'map',\n children: [per_item],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('map')\n","/**\n * pipe: transform output.\n *\n * `pipe(inner, fn)` runs `inner`, passes its output to `fn`, returns `fn`'s\n * result. Use for shape adaptation when composing heterogeneous steps.\n */\n\nimport { is_step } from './is_step.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet pipe_counter = 0\n\n/**\n * Generate a unique step id of the form `pipe_<n>`.\n */\nfunction next_id(): string {\n pipe_counter += 1\n return `pipe_${pipe_counter}`\n}\n\nexport type PipeOptions = {\n readonly name?: string\n}\n\n/**\n * Build an output-transforming step around `inner`.\n *\n * The argument checks reject Steps passed where functions belong: `pipe` is\n * not variadic, and the early `TypeError`s point misuse at `step(fn)` or\n * `sequence([...])` instead of failing obscurely at run time.\n */\nexport function pipe<i, a, b>(\n inner: Step<i, a>,\n fn: (value: a) => b | Promise<b>,\n options?: PipeOptions,\n): Step<i, b> {\n if (!is_step(inner)) {\n const hint = typeof inner === 'function' ? ' — wrap plain functions with step(fn)' : ''\n throw new TypeError(`pipe(inner, fn): inner must be a Step, got ${typeof inner}${hint}`)\n }\n if (typeof fn !== 'function') {\n if (is_step(fn)) {\n throw new TypeError(\n 'pipe(inner, fn): fn must be a function, got a Step — pipe is not variadic; to chain Steps use sequence([...])',\n )\n }\n throw new TypeError(`pipe(inner, fn): fn must be a function, got ${typeof fn}`)\n }\n if (is_step(options)) {\n throw new TypeError(\n 'pipe(inner, fn, options): got a Step as the third argument — pipe is not variadic; to chain Steps use sequence([...])',\n )\n }\n\n const id = next_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<b> => {\n const intermediate = await dispatch_step(inner, input, ctx)\n return fn(intermediate)\n }\n\n const config_meta: Record<string, unknown> = { fn }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'pipe',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('pipe')\n","/**\n * retry: re-run on failure.\n *\n * `retry(inner, { max_attempts, backoff_ms?, on_error? })` runs `inner`. If it\n * throws an application error, retries up to `max_attempts - 1` more times with\n * exponential backoff (`backoff_ms * 2^(attempt-1)`). `on_error` is called on\n * every such failure. The last error is rethrown if all attempts fail.\n *\n * Control-flow signals (`suspended_error`, `aborted_error`) are not failures:\n * they propagate immediately without consuming an attempt, firing `on_error`,\n * or scheduling a backoff. A suspend's `on()` side effect therefore runs once\n * per run, not once per attempt.\n *\n * Cancellation / cleanup: cleanup handlers registered by the inner step\n * accumulate across attempts. The parent `ctx.abort` is honored between\n * attempts; a pending abort short-circuits the backoff and propagates.\n */\n\nimport { aborted_error, is_control_flow_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nconst DEFAULT_BACKOFF_MS = 1_000\n\nexport type RetryConfig = {\n readonly name?: string\n readonly max_attempts: number\n readonly backoff_ms?: number\n readonly on_error?: (err: unknown, attempt: number) => void\n}\n\nlet retry_counter = 0\n\n/**\n * Generate a unique step id of the form `retry_<n>`.\n */\nfunction next_id(): string {\n retry_counter += 1\n return `retry_${retry_counter}`\n}\n\n/**\n * Sleep for `ms` unless the run is aborted first.\n *\n * Rejects immediately with the abort reason (or an `aborted_error`) when\n * `ctx.abort` fires, so a pending abort never waits out a backoff delay.\n */\nasync function abortable_wait(ms: number, ctx: RunContext): Promise<void> {\n if (ms <= 0) return\n await new Promise<void>((resolve, reject) => {\n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n return\n }\n const timer = setTimeout(() => {\n ctx.abort.removeEventListener('abort', on_abort)\n resolve()\n }, ms)\n const on_abort = (): void => {\n clearTimeout(timer)\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n }\n ctx.abort.addEventListener('abort', on_abort, { once: true })\n })\n}\n\n/**\n * Build a retrying step around `inner`.\n *\n * Runs `inner` up to `max_attempts` times with exponential backoff between\n * failures. Application errors consume an attempt and fire `on_error`;\n * control-flow signals propagate untouched.\n */\nexport function retry<i, o>(inner: Step<i, o>, config: RetryConfig): Step<i, o> {\n const id = next_id()\n const max_attempts = Math.max(1, Math.floor(config.max_attempts))\n const backoff_ms = config.backoff_ms ?? DEFAULT_BACKOFF_MS\n const on_error = config.on_error\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n let last_err: unknown = undefined\n for (let attempt = 1; attempt <= max_attempts; attempt += 1) {\n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n try {\n return await dispatch_step(inner, input, ctx)\n } catch (err) {\n if (is_control_flow_error(err)) throw err\n last_err = err\n if (on_error) on_error(err, attempt)\n if (attempt >= max_attempts) break\n const delay = backoff_ms * 2 ** (attempt - 1)\n await abortable_wait(delay, ctx)\n }\n }\n throw last_err\n }\n\n const config_meta: Record<string, unknown> = { max_attempts, backoff_ms }\n if (on_error) config_meta['on_error'] = on_error\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id,\n kind: 'retry',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('retry')\n","/**\n * fallback: primary-or-backup.\n *\n * `fallback(primary, backup)` runs `primary`. If it throws an application\n * error, runs `backup` with the same input. If `backup` also throws, the\n * `backup` error propagates. Control-flow signals (`suspended_error`,\n * `aborted_error`) are not failures: they propagate instead of triggering the\n * backup, so a human-approval gate is never silently bypassed and the backup\n * never runs under an aborted context.\n */\n\nimport { is_control_flow_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet fallback_counter = 0\n\n/**\n * Generate a unique step id of the form `fallback_<n>`.\n */\nfunction next_id(): string {\n fallback_counter += 1\n return `fallback_${fallback_counter}`\n}\n\nexport type FallbackOptions = {\n readonly name?: string\n}\n\n/**\n * Build a primary-or-backup step.\n *\n * Runs `primary`; on an application error runs `backup` with the same input.\n * Control-flow signals propagate without triggering the backup.\n */\nexport function fallback<i, o>(\n primary: Step<i, o>,\n backup: Step<i, o>,\n options?: FallbackOptions,\n): Step<i, o> {\n const id = next_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n try {\n return await dispatch_step(primary, input, ctx)\n } catch (err) {\n if (is_control_flow_error(err)) throw err\n return dispatch_step(backup, input, ctx)\n }\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n return {\n id,\n kind: 'fallback',\n children: [primary, backup],\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n }\n}\n\nregister_traced_kind('fallback')\n","/**\n * timeout: bound execution.\n *\n * `timeout(inner, ms)` runs `inner` with a composed `AbortSignal` that fires\n * at `ms` milliseconds. If the inner step does not complete in time, throws\n * `timeout_error`. The inner step is responsible for honoring `ctx.abort`;\n * a step that ignores the signal still triggers `timeout_error` on schedule\n * but continues running in the background.\n *\n * Cancellation: the inner step runs with\n * `AbortSignal.any([ctx.abort, timeout_local])`. On timer expiry, the local\n * controller aborts with a `timeout_error` as its reason; on parent abort\n * the parent reason flows through. The timer is always cleared in a finally\n * block so it does not leak across retries.\n */\n\nimport { aborted_error, timeout_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet timeout_counter = 0\n\n/**\n * Generate a unique step id of the form `timeout_<n>`.\n */\nfunction next_id(): string {\n timeout_counter += 1\n return `timeout_${timeout_counter}`\n}\n\nexport type TimeoutOptions = {\n readonly name?: string\n}\n\n/**\n * Build a deadline-bounded step around `inner`.\n *\n * Races the inner dispatch against a timer that aborts the composed signal\n * with `timeout_error`. The `timed_out` flag distinguishes timer expiry from\n * a parent abort so the right error propagates.\n */\nexport function timeout<i, o>(\n inner: Step<i, o>,\n ms: number,\n options?: TimeoutOptions,\n): Step<i, o> {\n const id = next_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const local = new AbortController()\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n \n let timed_out = false\n const timer = setTimeout(() => {\n timed_out = true\n local.abort(new timeout_error(`timeout after ${ms}ms`, ms))\n }, ms)\n \n const deadline = new Promise<never>((_, reject) => {\n const on_local_abort = (): void => {\n if (timed_out) {\n reject(new timeout_error(`timeout after ${ms}ms`, ms))\n } else {\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n }\n }\n if (composed.aborted) {\n on_local_abort()\n return\n }\n composed.addEventListener('abort', on_local_abort, { once: true })\n })\n \n try {\n return await Promise.race([dispatch_step(inner, input, child_ctx), deadline])\n } finally {\n clearTimeout(timer)\n }\n }\n\n const config_meta: Record<string, unknown> = { ms }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'timeout',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('timeout')\n","/**\n * loop: bounded iteration with carry-state.\n *\n * `loop({ init, body, guard?, finish, max_rounds, name? })` runs `body` up to\n * `max_rounds` times, threading `state` through each iteration. After every\n * `body` call, an optional `guard` step inspects (and may transform) the state\n * and decides whether to stop. When `guard.stop` is true, the loop exits\n * \"converged\"; otherwise it continues until `max_rounds`. `finish` projects\n * the final state to the loop's output value.\n *\n * Non-convergence is data, not error: when `max_rounds` is exhausted without\n * `guard` returning stop, the loop returns `{ value, converged: false, rounds }`,\n * the same convention `adversarial` and `consensus` use.\n *\n * Cancellation: between rounds the parent `ctx.abort` is honored; a pending\n * abort short-circuits and propagates `ctx.abort.reason`. The body and guard\n * receive the parent context unchanged; their own dispatch routes already\n * thread cancellation per the runner contract.\n */\n\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type LoopGuardResult<state> = {\n readonly stop: boolean\n readonly state: state\n}\n\nexport type LoopConfig<i, state, o> = {\n readonly name?: string\n readonly init: (input: i) => state\n readonly body: Step<state, state>\n readonly guard?: Step<state, LoopGuardResult<state>>\n readonly finish: (state: state, round: number) => o\n readonly max_rounds: number\n}\n\nexport type LoopResult<o> = {\n readonly value: o\n readonly converged: boolean\n readonly rounds: number\n}\n\nlet loop_counter = 0\n\n/**\n * Generate a unique step id, prefixed with the display name when one is set.\n */\nfunction next_id(name: string | undefined): string {\n loop_counter += 1\n return `${name ?? 'loop'}_${loop_counter}`\n}\n\n/**\n * Build a bounded iteration step with carry-state.\n *\n * Threads `state` through up to `max_rounds` runs of `body`, lets the\n * optional `guard` stop early, then projects the final state through\n * `finish`. Returns `{ value, converged, rounds }` so callers can tell a\n * converged run from an exhausted one.\n */\nexport function loop<i, state, o>(\n config: LoopConfig<i, state, o>,\n): Step<i, LoopResult<o>> {\n const { init, body, guard, finish, name } = config\n const rounds_limit = Math.max(1, Math.floor(config.max_rounds))\n const id = next_id(name)\n\n const run_fn = async (input: i, ctx: RunContext): Promise<LoopResult<o>> => {\n let state = init(input)\n let round = 0\n let converged = false\n \n while (round < rounds_limit) {\n throw_if_aborted(ctx)\n round += 1\n state = await dispatch_step(body, state, ctx)\n if (guard) {\n throw_if_aborted(ctx)\n const guard_out = await dispatch_step(guard, state, ctx)\n state = guard_out.state\n if (guard_out.stop) {\n converged = true\n break\n }\n }\n }\n \n const value = finish(state, round)\n return { value, converged, rounds: round }\n }\n\n const config_meta: Record<string, unknown> = { max_rounds: rounds_limit }\n if (name !== undefined) config_meta['display_name'] = name\n const children: ReadonlyArray<Step<unknown, unknown>> = guard\n ? [body, guard]\n : [body]\n\n return {\n id,\n kind: 'loop',\n children,\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('loop')\n","/**\n * compose: name a composite step.\n *\n * `compose(name, inner)` wraps any step and labels its trajectory span with\n * `name`. The inner step's own span (e.g. a `sequence`) appears as a child of\n * the compose span: the implementation tree is preserved while the user's\n * intent (\"this whole thing is an ensemble\") is surfaced in observability.\n *\n * Used by the composites package to make built-in patterns appear under\n * their familiar names, and available to library consumers who want their own\n * named composites to show up in logs as first-class components.\n *\n * The primitive's `kind` is always `'compose'`; the user-supplied label lives\n * in `config.display_name` and is the span name the dispatcher opens.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet compose_counter = 0\n\n/**\n * Generate a unique step id of the form `<name>_<n>`, using the user-supplied\n * label so compose ids read naturally in traces.\n */\nfunction next_id(name: string): string {\n compose_counter += 1\n return `${name}_${compose_counter}`\n}\n\n/**\n * Wrap `inner` in a named composite step.\n *\n * The step's `kind` is always `'compose'`; `name` becomes the\n * `display_name` used as the span label. Throws a `TypeError` when `name`\n * is not a non-empty string, catching the mistake at construction time.\n */\nexport function compose<i, o>(name: string, inner: Step<i, o>): Step<i, o> {\n if (typeof name !== 'string' || name.length === 0) {\n throw new TypeError('compose(name, inner): name must be a non-empty string')\n }\n const id = next_id(name)\n\n const run_fn = (input: i, ctx: RunContext): Promise<o> | o => dispatch_step(inner, input, ctx)\n\n return {\n id,\n kind: 'compose',\n children: [inner],\n config: { display_name: name },\n run: run_fn,\n }\n}\n\nregister_traced_kind('compose')\n","/**\n * checkpoint: persist and resume.\n *\n * `checkpoint(inner, { key })` checks a persistent store for a completed\n * result at `key` before running `inner`. On a hit, returns the stored\n * value. On a miss, runs `inner`, persists its result at `key`, and returns\n * it. Corrupted reads (store throws on `get`) are treated as a miss.\n *\n * Wrapping an anonymous inner step throws synchronously at construction time\n * with the message `checkpoint requires a named step; got anonymous`, because\n * a cached result must map back to a stable, identifiable step.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type CheckpointConfig<i> = {\n readonly name?: string\n readonly key: string | ((input: i) => string)\n}\n\nlet checkpoint_counter = 0\n\n/**\n * Generate a unique step id of the form `checkpoint_<n>`.\n */\nfunction next_id(): string {\n checkpoint_counter += 1\n return `checkpoint_${checkpoint_counter}`\n}\n\n/**\n * Wrap `inner` with persist-and-resume behavior keyed by `config.key`.\n *\n * `key` is a fixed string or a function of the input. Without a\n * `checkpoint_store` on the run context, the wrapper runs `inner` directly.\n * A stored `null` or `undefined` counts as a miss, so those values are\n * re-computed rather than replayed. Throws at construction time when `inner`\n * is anonymous.\n */\nexport function checkpoint<i, o>(inner: Step<i, o>, config: CheckpointConfig<i>): Step<i, o> {\n if (inner.anonymous === true) {\n throw new Error('checkpoint requires a named step; got anonymous')\n }\n\n const id = next_id()\n const key_spec = config.key\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const key = typeof key_spec === 'function' ? key_spec(input) : key_spec\n const store = ctx.checkpoint_store\n \n if (store) {\n let cached: unknown = undefined\n let hit = false\n try {\n cached = await store.get(key)\n hit = cached !== null && cached !== undefined\n } catch {\n hit = false\n }\n if (hit) {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return cached as o\n }\n }\n \n const result = await dispatch_step(inner, input, ctx)\n \n if (store) {\n await store.set(key, result)\n }\n \n return result\n }\n\n const config_meta: Record<string, unknown> = { key: key_spec }\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id,\n kind: 'checkpoint',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('checkpoint')\n","/**\n * suspend: human-in-the-loop pause.\n *\n * `suspend({ id, on, resume_schema, combine })` pauses a flow waiting on\n * external input (a notification, an approval, an uploaded file). On first\n * encounter with no resume data, it calls `on(input, ctx)` (side effect) and\n * throws `suspended_error` carrying the run state. On resume (re-invocation\n * with `run_options.resume_data[id]` populated), the provided value is\n * validated against `resume_schema` and passed to `combine(input, resume,\n * ctx)`; the result is returned. Invalid resume data throws\n * `resume_validation_error` built from zod 4's flattened issue format.\n */\n\nimport { z } from 'zod'\nimport { resume_validation_error, suspended_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type SuspendConfig<i, o, resume> = {\n readonly id: string\n readonly name?: string\n readonly on: (input: i, ctx: RunContext) => Promise<void> | void\n readonly resume_schema: z.ZodType<resume>\n readonly combine: (\n input: i,\n resume: resume,\n ctx: RunContext,\n ) => Promise<o> | o | Step<unknown, o>\n}\n\n/**\n * Structurally detect a `Step` returned from `combine`.\n *\n * `combine` may return either a plain value or a Step to dispatch; this local\n * check distinguishes the two without importing the shared helper.\n */\nfunction is_step(value: unknown): value is Step<unknown, unknown> {\n if (typeof value !== 'object' || value === null) return false\n if (!('id' in value) || !('kind' in value) || !('run' in value)) return false\n const { id, kind, run } = value\n return typeof id === 'string' && typeof kind === 'string' && typeof run === 'function'\n}\n\n/**\n * Build a human-in-the-loop pause step.\n *\n * First run fires the `on` side effect and throws `suspended_error`; a resume\n * run validates `resume_data[id]` against `resume_schema` and feeds it to\n * `combine`. The step's id is the user-supplied suspend id so resume data can\n * be addressed to it.\n */\nexport function suspend<i, o, resume>(config: SuspendConfig<i, o, resume>): Step<i, o> {\n const suspend_id = config.id\n const on_fn = config.on\n const resume_schema = config.resume_schema\n const combine_fn = config.combine\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const resume_value = ctx.resume_data?.[suspend_id]\n \n if (resume_value === undefined) {\n await on_fn(input, ctx)\n throw new suspended_error(suspend_id, { input })\n }\n \n const parsed = resume_schema.safeParse(resume_value)\n if (!parsed.success) {\n const issues = z.flattenError(parsed.error)\n throw new resume_validation_error(\n `resume data for ${suspend_id} failed validation`,\n issues,\n )\n }\n \n const result = await combine_fn(input, parsed.data, ctx)\n if (is_step(result)) {\n return dispatch_step(result, input, ctx)\n }\n return result\n }\n\n const config_meta: Record<string, unknown> = { id: suspend_id }\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id: suspend_id,\n kind: 'suspend',\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('suspend')\n","/**\n * scope / stash / use: named state.\n *\n * `scope([...children])` introduces a scope-local `Map<string, unknown>` and\n * runs its children in order, chaining outputs like `sequence`. `stash(key,\n * source)` runs `source`, writes its output to the scope's state at `key`,\n * and passes the value through. `use(keys, fn)` reads the named values from\n * state and runs `fn` with the projection. Inner scopes inherit outer state;\n * writes only affect the inner map.\n *\n * Using `stash` or `use` outside a `scope` is a runtime error with a clear\n * message.\n */\n\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype LastOutput<children> = children extends readonly [...unknown[], Step<unknown, infer o>]\n ? o\n : children extends readonly [Step<unknown, infer o>]\n ? o\n : unknown\n\nconst scope_states = new WeakSet<ReadonlyMap<string, unknown>>()\n\n/**\n * Check whether a state map was created by `scope`.\n *\n * The root `RunContext.state` map is not registered in `scope_states`, which\n * is how `stash`/`use` detect they are running outside any scope.\n */\nfunction is_scope_state(state: ReadonlyMap<string, unknown>): boolean {\n return scope_states.has(state)\n}\n\nlet scope_counter = 0\nlet stash_counter = 0\nlet use_counter = 0\n\n/**\n * Generate a unique step id of the form `scope_<n>`.\n */\nfunction next_scope_id(): string {\n scope_counter += 1\n return `scope_${scope_counter}`\n}\n\n/**\n * Generate a unique step id of the form `stash_<n>`.\n */\nfunction next_stash_id(): string {\n stash_counter += 1\n return `stash_${stash_counter}`\n}\n\n/**\n * Generate a unique step id of the form `use_<n>`.\n */\nfunction next_use_id(): string {\n use_counter += 1\n return `use_${use_counter}`\n}\n\nexport type ScopeOptions = {\n readonly name?: string\n}\n\nexport type StashOptions = {\n readonly name?: string\n}\n\nexport type UseOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that runs children in sequence under a fresh state map.\n *\n * The local map is seeded from the parent state (inner scopes read outer\n * values) and registered so `stash`/`use` inside recognize it; writes stay\n * local to this scope. Outputs chain like `sequence`.\n */\nexport function scope<const children extends readonly AnyStep[]>(\n children: children,\n options?: ScopeOptions,\n): Step<unknown, LastOutput<children>> {\n const id = next_scope_id()\n const children_ref = children\n\n const run_fn = async (input: unknown, ctx: RunContext): Promise<unknown> => {\n const local = new Map<string, unknown>(ctx.state)\n scope_states.add(local)\n const scope_ctx: RunContext = { ...ctx, state: local }\n \n let acc: unknown = input\n for (const child of children_ref) {\n throw_if_aborted(scope_ctx)\n acc = await dispatch_step(child, acc, scope_ctx)\n }\n return acc\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return {\n id,\n kind: 'scope',\n children,\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n } as Step<unknown, LastOutput<children>>\n}\n\n/**\n * Build a step that stores its source's output in scope state at `key`.\n *\n * Passes the value through unchanged so it composes mid-chain. Throws when\n * run outside a `scope`.\n */\nexport function stash<i, v>(\n key: string,\n source: Step<i, v>,\n options?: StashOptions,\n): Step<i, v> {\n const id = next_stash_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<v> => {\n if (!is_scope_state(ctx.state)) {\n throw new Error('stash() may only appear inside scope(); got: top-level')\n }\n const value = await dispatch_step(source, input, ctx)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const state = ctx.state as Map<string, unknown>\n state.set(key, value)\n return value\n }\n\n const config_meta: Record<string, unknown> = { key }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'stash',\n children: [source],\n config: config_meta,\n run: run_fn,\n }\n}\n\n/**\n * Build a step that projects named scope values into a function call.\n *\n * Reads `keys` from scope state (missing keys project as `undefined`) and\n * invokes `fn(projection, input, ctx)`. Throws when run outside a `scope`.\n */\nexport function use<const keys extends readonly string[], i, o>(\n keys: keys,\n fn: (\n state: { [k in keys[number]]: unknown },\n input: i,\n ctx: RunContext,\n ) => Promise<o> | o,\n options?: UseOptions,\n): Step<i, o> {\n const id = next_use_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n if (!is_scope_state(ctx.state)) {\n throw new Error('use() may only appear inside scope(); got: top-level')\n }\n const projection: Record<string, unknown> = {}\n for (const k of keys) {\n projection[k] = ctx.state.get(k)\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return fn(projection as { [k in keys[number]]: unknown }, input, ctx)\n }\n\n const config_meta: Record<string, unknown> = { keys: [...keys] }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'use',\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('scope')\n\nregister_traced_kind('stash')\n\nregister_traced_kind('use')\n","/**\n * Closed registry of every `Step.kind` produced by the composition layer.\n *\n * Studio (and any other consumer that needs to enumerate primitives: palette,\n * docs, code generation) can rely on this being the exhaustive set. New\n * primitives must add their kind here. The `step_kinds_cover_runner` contract\n * test in `step_kinds.test.ts` asserts every dispatch handler corresponds to a\n * kind listed here.\n */\n\nexport const STEP_KINDS = [\n 'step',\n 'sequence',\n 'parallel',\n 'branch',\n 'map',\n 'pipe',\n 'retry',\n 'fallback',\n 'timeout',\n 'loop',\n 'compose',\n 'adversarial',\n 'ensemble',\n 'tournament',\n 'consensus',\n 'checkpoint',\n 'suspend',\n 'scope',\n 'stash',\n 'use',\n] as const\n\nexport type StepKind = (typeof STEP_KINDS)[number]\n\n/**\n * Check whether a value is one of the registered `Step.kind` strings.\n */\nexport function is_step_kind(value: unknown): value is StepKind {\n return typeof value === 'string' && (STEP_KINDS as readonly string[]).includes(value)\n}\n","/**\n * Wire-format schema for trajectory events.\n *\n * `TrajectoryEvent` (in `types.ts`) is the loose internal type — any code that\n * calls `trajectory.record(event)` or `start_span(name, meta)` produces values\n * conforming to it. This file defines the *narrower* shapes that the studio\n * (and any other downstream consumer) can parse out of the wire stream:\n *\n * span_start — composer span open\n * span_end — composer span close\n * emit — user-emitted event from inside a step (ctx.emit)\n * <other> — falls through `custom_event_schema`, which only requires a\n * string `kind` and tolerates any extra fields\n *\n * The discriminated union is **ordered**: well-known shapes are tried before\n * the permissive `custom` schema, so a `{ kind: 'span_start', ... }` event\n * always parses as `SpanStartEvent`, never as `CustomTrajectoryEvent`.\n *\n * Every well-known schema and `custom_event_schema` use `.passthrough()` so\n * additional fields (e.g. `run_id`, `id`, provider-specific metadata) survive\n * a parse / re-serialize round-trip without loss.\n */\n\nimport { z } from 'zod'\n\nexport const span_start_event_schema = z\n .object({\n kind: z.literal('span_start'),\n span_id: z.string(),\n name: z.string(),\n })\n .passthrough()\n\nexport const span_end_event_schema = z\n .object({\n kind: z.literal('span_end'),\n span_id: z.string(),\n })\n .passthrough()\n\nexport const emit_event_schema = z\n .object({\n kind: z.literal('emit'),\n })\n .passthrough()\n\nexport const custom_event_schema = z\n .object({\n kind: z.string(),\n })\n .passthrough()\n\nexport const trajectory_event_schema = z.union([\n span_start_event_schema,\n span_end_event_schema,\n emit_event_schema,\n custom_event_schema,\n])\n\nexport type SpanStartEvent = z.infer<typeof span_start_event_schema>\nexport type SpanEndEvent = z.infer<typeof span_end_event_schema>\nexport type EmitEvent = z.infer<typeof emit_event_schema>\nexport type CustomTrajectoryEvent = z.infer<typeof custom_event_schema>\nexport type ParsedTrajectoryEvent = z.infer<typeof trajectory_event_schema>\n","/**\n * Public surface for core.\n *\n * Side-effect imports ensure every composer registers itself with the runner\n * at module load. Importing anything from `core` populates the\n * dispatch table with the core primitives. Built-in composites\n * (adversarial, ensemble, tournament, consensus) live in composites\n * and surface through the umbrella package.\n */\n\nimport flow_schema_data from './flow-schema.json' with { type: 'json' }\n\nexport { run } from './runner.js'\nexport { step } from './step.js'\nexport { describe } from './describe.js'\nexport type { DescribeOptions, FlowNode, FlowValue } from './describe.js'\nexport { sequence } from './sequence.js'\nexport { parallel } from './parallel.js'\nexport { branch } from './branch.js'\nexport { map } from './map.js'\nexport { pipe } from './pipe.js'\nexport { retry } from './retry.js'\nexport { fallback } from './fallback.js'\nexport { timeout } from './timeout.js'\nexport { loop } from './loop.js'\nexport type { LoopConfig, LoopGuardResult, LoopResult } from './loop.js'\nexport { compose } from './compose.js'\nexport { checkpoint } from './checkpoint.js'\nexport { suspend } from './suspend.js'\nexport { scope, stash, use } from './scope.js'\n\nexport {\n aborted_error,\n describe_cycle_error,\n resume_validation_error,\n suspended_error,\n timeout_error,\n} from './errors.js'\n\nexport type {\n CheckpointStore,\n RunContext,\n Step,\n StepMetadata,\n TrajectoryEvent,\n TrajectoryLogger,\n} from './types.js'\n\nexport { is_step_kind, STEP_KINDS } from './step_kinds.js'\nexport type { StepKind } from './step_kinds.js'\n\nexport {\n custom_event_schema,\n emit_event_schema,\n span_end_event_schema,\n span_start_event_schema,\n trajectory_event_schema,\n} from './trajectory.js'\nexport type {\n CustomTrajectoryEvent,\n EmitEvent,\n ParsedTrajectoryEvent,\n SpanEndEvent,\n SpanStartEvent,\n} from './trajectory.js'\n\nexport { flow_schema_data as flow_schema }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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sD;EAExE,MAAM,aAAsC,CAAC;EAC7C,KAAK,MAAM,KAAK,MACd,WAAW,KAAK,IAAI,MAAM,IAAI,CAAC;EAGjC,OAAO,GAAG,YAAgD,OAAO,GAAG;CACtE;CAEA,MAAM,cAAuC,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE;CAC/D,IAAI,SAAS,SAAS,KAAA,GAAW,YAAY,kBAAkB,QAAQ;CAEvE,OAAO;EACL;EACA,MAAM;EACN,QAAQ;EACR,KAAK;CACP;AACF;AAEA,qBAAqB,OAAO;AAE5B,qBAAqB,OAAO;AAE5B,qBAAqB,KAAK;;;;;;;;;;;;AC3L1B,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAOA,SAAgB,aAAa,OAAmC;CAC9D,OAAO,OAAO,UAAU,YAAa,WAAiC,SAAS,KAAK;AACtF;;;;;;;;;;;;;;;;;;;;;;;;;ACfA,MAAa,0BAA0B,EACpC,OAAO;CACN,MAAM,EAAE,QAAQ,YAAY;CAC5B,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;AACjB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,wBAAwB,EAClC,OAAO;CACN,MAAM,EAAE,QAAQ,UAAU;CAC1B,SAAS,EAAE,OAAO;AACpB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,oBAAoB,EAC9B,OAAO,EACN,MAAM,EAAE,QAAQ,MAAM,EACxB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,sBAAsB,EAChC,OAAO,EACN,MAAM,EAAE,OAAO,EACjB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,0BAA0B,EAAE,MAAM;CAC7C;CACA;CACA;CACA;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"core-Dit3Rv9J.js","names":["is_step","is_step","next_id","is_step","next_id","next_id","next_id","next_id","is_step","next_id","next_id","next_id","next_id","next_id"],"sources":["../src/core/flow-schema.json","../src/core/cleanup.ts","../src/core/errors.ts","../src/core/streaming.ts","../src/core/runner.ts","../src/core/step.ts","../src/core/is_step.ts","../src/core/describe.ts","../src/core/sequence.ts","../src/core/parallel.ts","../src/core/branch.ts","../src/core/map.ts","../src/core/pipe.ts","../src/core/retry.ts","../src/core/fallback.ts","../src/core/timeout.ts","../src/core/loop.ts","../src/core/compose.ts","../src/core/checkpoint.ts","../src/core/suspend.ts","../src/core/scope.ts","../src/core/step_kinds.ts","../src/core/trajectory.ts","../src/core/index.ts"],"sourcesContent":["","/**\n * Per-run cleanup registry.\n *\n * Handlers fire in LIFO (reverse registration) order on abort, on uncaught\n * error in the root, and on successful completion. Each handler has a\n * 5-second timeout; timeouts are recorded in the trajectory but do not block\n * other handlers. A handler that throws is recorded as `cleanup_error`;\n * subsequent handlers still execute.\n */\n\nimport type { CleanupFn, TrajectoryLogger } from './types.js'\n\nconst HANDLER_TIMEOUT_MS = 5_000\n\nexport type CleanupRegistry = {\n readonly register: (fn: CleanupFn) => void\n readonly run_all: () => Promise<void>\n}\n\n/**\n * Create the per-run cleanup registry.\n *\n * `register` collects handlers during the run; `run_all` fires them once in\n * LIFO order and is idempotent. A registration arriving after the flush is\n * not executed; it is recorded as `cleanup_registered_after_flush` so the\n * leak is visible in the trajectory instead of silently dropped.\n */\nexport function create_cleanup_registry(trajectory: TrajectoryLogger): CleanupRegistry {\n const handlers: CleanupFn[] = []\n let ran = false\n\n function register(fn: CleanupFn): void {\n if (ran) {\n trajectory.record({\n kind: 'cleanup_registered_after_flush',\n })\n return\n }\n handlers.push(fn)\n }\n\n async function run_all(): Promise<void> {\n if (ran) return\n ran = true\n for (let i = handlers.length - 1; i >= 0; i -= 1) {\n const fn = handlers[i]\n if (!fn) continue\n await run_one(fn, trajectory)\n }\n }\n\n return { register, run_all }\n}\n\n/**\n * Run a single cleanup handler, never letting it fail the run.\n *\n * Races the handler against a 5-second timer. Whichever loses the race only\n * results in a trajectory record (`cleanup_timeout` or `cleanup_error`); the\n * returned promise always resolves so the remaining handlers still execute.\n * A timed-out handler keeps running in the background; it is abandoned, not\n * killed.\n */\nasync function run_one(fn: CleanupFn, trajectory: TrajectoryLogger): Promise<void> {\n let timeout_id: ReturnType<typeof setTimeout> | null = null\n try {\n await new Promise<void>((resolve) => {\n timeout_id = setTimeout(() => {\n trajectory.record({ kind: 'cleanup_timeout', timeout_ms: HANDLER_TIMEOUT_MS })\n resolve()\n }, HANDLER_TIMEOUT_MS)\n \n Promise.resolve()\n .then(() => fn())\n .then(\n () => {\n if (timeout_id) clearTimeout(timeout_id)\n resolve()\n },\n (err: unknown) => {\n if (timeout_id) clearTimeout(timeout_id)\n trajectory.record({\n kind: 'cleanup_error',\n error: err instanceof Error ? err.message : String(err),\n })\n resolve()\n },\n )\n })\n } finally {\n if (timeout_id) clearTimeout(timeout_id)\n }\n}\n","/**\n * Typed errors for the composition layer.\n *\n * This is the only source file in the core layer that uses the `class`\n * keyword. `Error` is a built-in and `instanceof` branching is how composers\n * like `retry` and `fallback` distinguish failure modes.\n */\n\nexport class timeout_error extends Error {\n readonly kind = 'timeout_error' as const;\n readonly timeout_ms: number;\n constructor(message: string, timeout_ms: number) {\n super(message)\n this.name = 'timeout_error'\n this.timeout_ms = timeout_ms\n }\n}\n\nexport class suspended_error extends Error {\n readonly kind = 'suspended_error' as const;\n readonly suspend_id: string;\n readonly payload: unknown;\n constructor(suspend_id: string, payload: unknown, message?: string) {\n super(message ?? `suspended at ${suspend_id}`)\n this.name = 'suspended_error'\n this.suspend_id = suspend_id\n this.payload = payload\n }\n}\n\nexport class resume_validation_error extends Error {\n readonly kind = 'resume_validation_error' as const;\n readonly issues: unknown;\n constructor(message: string, issues: unknown) {\n super(message)\n this.name = 'resume_validation_error'\n this.issues = issues\n }\n}\n\nexport class describe_cycle_error extends Error {\n readonly kind = 'describe_cycle_error' as const;\n readonly step_id: string;\n constructor(step_id: string, message?: string) {\n super(message ?? `describe: cycle detected at step id: ${step_id}`)\n this.name = 'describe_cycle_error'\n this.step_id = step_id\n }\n}\n\nexport class aborted_error extends Error {\n readonly kind = 'aborted_error' as const;\n readonly reason?: unknown;\n readonly step_index: number;\n readonly tool_call_in_flight?: { id: string; name: string };\n constructor(\n message = 'aborted',\n metadata: {\n reason?: unknown\n step_index?: number\n tool_call_in_flight?: { id: string; name: string }\n } = {},\n ) {\n super(message)\n this.name = 'aborted_error'\n if (metadata.reason !== undefined) this.reason = metadata.reason\n this.step_index = metadata.step_index ?? 0\n if (metadata.tool_call_in_flight !== undefined) {\n this.tool_call_in_flight = metadata.tool_call_in_flight\n }\n }\n}\n\n/**\n * Control-flow signals are not application failures. `suspended_error` is a\n * human-approval gate pausing the run for later resume; `aborted_error` is\n * cancellation. Resilience composers (`retry`, `fallback`) must rethrow these\n * rather than retry past a suspend or run a backup under an aborted context.\n *\n * Kept internal to core: not re-exported by index.ts, so it does not\n * widen the public surface.\n */\nexport function is_control_flow_error(\n err: unknown,\n): err is suspended_error | aborted_error {\n return err instanceof suspended_error || err instanceof aborted_error\n}\n","/**\n * Streaming observation channel.\n *\n * `run.stream(flow, input)` is a secondary entry point returning\n * `{ events, result }`. Events are observed via an async iterable; the result\n * promise resolves once the flow completes. Streaming is purely\n * observational: composers do not know it exists, and `run` and `run.stream`\n * produce identical final results.\n *\n * The event buffer has a default high-water mark of 10,000. When the consumer\n * never iterates, emissions past the mark drop the oldest events and record a\n * single `events_dropped` marker. The `result` promise resolves regardless of\n * buffer pressure.\n */\n\nimport type { TrajectoryEvent, TrajectoryLogger } from './types.js'\n\nexport const STREAMING_HIGH_WATER_MARK = 10_000\n\nexport type StreamingChannel = {\n readonly logger: TrajectoryLogger\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly close: () => void\n}\n\n/**\n * Build the logger/iterable pair backing `run.stream`.\n *\n * Wraps a base `TrajectoryLogger` so every recorded event is also enqueued\n * for the async iterable. A single pending `waiter` hands events straight to\n * a blocked consumer; otherwise events buffer up to `high_water_mark`, after\n * which the oldest are dropped and counted for the `events_dropped` marker\n * emitted at close.\n */\nexport function create_streaming_channel(\n base: TrajectoryLogger,\n high_water_mark = STREAMING_HIGH_WATER_MARK,\n): StreamingChannel {\n const buffer: TrajectoryEvent[] = []\n let dropped = 0\n let closed = false\n let marker_emitted = false\n let waiter: ((value: IteratorResult<TrajectoryEvent>) => void) | null = null\n\n function enqueue(event: TrajectoryEvent): void {\n if (closed) return\n if (waiter) {\n const resolve = waiter\n waiter = null\n resolve({ value: event, done: false })\n return\n }\n if (buffer.length >= high_water_mark) {\n buffer.shift()\n dropped += 1\n return\n }\n buffer.push(event)\n }\n\n function close(): void {\n if (closed) return\n closed = true\n if (dropped > 0 && !marker_emitted) {\n marker_emitted = true\n buffer.push({ kind: 'events_dropped', count: dropped })\n }\n if (waiter) {\n const resolve = waiter\n waiter = null\n resolve({ value: undefined, done: true })\n }\n }\n\n const logger: TrajectoryLogger = {\n record: (event) => {\n base.record(event)\n enqueue(event)\n },\n start_span: (name, meta) => {\n const id = base.start_span(name, meta)\n enqueue({ kind: 'span_start', span_id: id, name, ...meta })\n return id\n },\n end_span: (id, meta) => {\n base.end_span(id, meta)\n enqueue({ kind: 'span_end', span_id: id, ...meta })\n },\n }\n\n const events: AsyncIterable<TrajectoryEvent> = {\n [Symbol.asyncIterator]() {\n return {\n next(): Promise<IteratorResult<TrajectoryEvent>> {\n if (buffer.length > 0) {\n const next_event = buffer.shift()\n if (next_event !== undefined) {\n return Promise.resolve({ value: next_event, done: false })\n }\n }\n if (closed) {\n return Promise.resolve({ value: undefined, done: true })\n }\n return new Promise<IteratorResult<TrajectoryEvent>>((resolve) => {\n waiter = resolve\n })\n },\n return(): Promise<IteratorResult<TrajectoryEvent>> {\n close()\n return Promise.resolve({ value: undefined, done: true })\n },\n }\n },\n }\n\n return { logger, events, close }\n}\n","/**\n * Runner.\n *\n * Dispatches a step to its kind-specific handler. `runner.ts` contains no\n * composer-specific logic beyond a Map lookup on `step.kind`; each composer\n * file registers its handler at module load via `register_kind(...)`.\n *\n * `run(flow, input, options?)` constructs a fresh `RunContext` per top-level\n * call, installs process signal handlers (opt-out via options), forwards an\n * optional caller-supplied `AbortSignal` into the run, and guarantees cleanup\n * handlers execute in LIFO order on success, failure, or abort.\n *\n * `run.stream(flow, input, options?)` is a secondary entry point returning\n * `{ events, result }`. Streaming is purely observational; the step graph is\n * identical to `run(...)`.\n */\n\nimport { randomUUID } from 'node:crypto'\nimport { create_cleanup_registry } from './cleanup.js'\nimport { aborted_error } from './errors.js'\nimport { create_streaming_channel, STREAMING_HIGH_WATER_MARK } from './streaming.js'\nimport type {\n CheckpointStore,\n RunContext,\n Step,\n TrajectoryEvent,\n TrajectoryLogger,\n} from './types.js'\n\ntype Dispatcher = (\n flow: Step<unknown, unknown>,\n input: unknown,\n ctx: RunContext,\n) => Promise<unknown>\n\nconst dispatch = new Map<string, Dispatcher>()\n\n/**\n * Register the dispatch handler for a step kind.\n *\n * Composer files call this (directly or via `register_traced_kind`) at module\n * load, which is how the runner stays free of composer-specific logic.\n */\nexport function register_kind(kind: string, fn: Dispatcher): void {\n dispatch.set(kind, fn)\n}\n\n/**\n * Resolve the trajectory span label for a step. Prefers a non-empty\n * `display_name` from `flow.config`; otherwise falls back to the supplied\n * default (typically the step's `kind`).\n *\n * Dispatch handlers use this so that any composer carrying a user-supplied\n * `name` surfaces under that label in the trajectory, while unconfigured\n * composers retain their kind-based label.\n */\nexport function resolve_span_label(\n flow: Step<unknown, unknown>,\n fallback: string,\n): string {\n const display = flow.config?.['display_name']\n return typeof display === 'string' && display.length > 0 ? display : fallback\n}\n\n/**\n * Register the standard span-wrapping dispatch handler for a composer kind.\n *\n * Every composer wraps `flow.run` in a span identically; this centralizes that\n * boilerplate and threads span parentage: the span opens with the current\n * `ctx.parent_span_id` as its parent, and `flow.run` receives a child context\n * whose `parent_span_id` is this span. Children dispatched from within\n * (including concurrent ones under `parallel`/`map`, which spread the context)\n * therefore nest correctly instead of leaving `parent_span_id` unpopulated.\n */\nexport function register_traced_kind(kind: string): void {\n register_kind(kind, async (flow, input, ctx) => {\n const label = resolve_span_label(flow, kind)\n const span_meta: Record<string, unknown> = { id: flow.id }\n if (ctx.parent_span_id !== undefined) {\n span_meta['parent_span_id'] = ctx.parent_span_id\n }\n const span_id = ctx.trajectory.start_span(label, span_meta)\n const child_ctx: RunContext = { ...ctx, parent_span_id: span_id }\n try {\n const out = await flow.run(input, child_ctx)\n ctx.trajectory.end_span(span_id, { id: flow.id })\n return out\n } catch (err) {\n ctx.trajectory.end_span(span_id, {\n id: flow.id,\n error: err instanceof Error ? err.message : String(err),\n })\n throw err\n }\n })\n}\n\nexport type RunOptions = {\n readonly install_signal_handlers?: boolean\n readonly trajectory?: TrajectoryLogger\n readonly checkpoint_store?: CheckpointStore\n readonly resume_data?: Readonly<Record<string, unknown>>\n // A caller-owned cancellation source (HTTP request, queue shutdown, MCP\n // request, AbortSignal.timeout). When it fires the run aborts with its\n // reason, composing with the internal controller and the process signal\n // handlers rather than replacing them.\n readonly abort?: AbortSignal\n}\n\nexport type StreamingRunHandle<o> = {\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly result: Promise<o>\n}\n\nconst active_runs = new Set<AbortController>()\nlet signal_handler_installed = false\nlet sigint_handler: (() => void) | null = null\nlet sigterm_handler: (() => void) | null = null\n\n/**\n * Install process-wide SIGINT/SIGTERM handlers once.\n *\n * The handlers abort every active run with an `aborted_error` naming the\n * signal, so a Ctrl-C tears down all in-flight flows through the normal\n * abort/cleanup path instead of killing the process mid-step.\n */\nfunction ensure_signal_handlers(): void {\n if (signal_handler_installed) return\n signal_handler_installed = true\n const abort_all = (signal_name: string) => () => {\n for (const controller of active_runs) {\n controller.abort(new aborted_error(`received ${signal_name}`, { reason: { signal: signal_name } }))\n }\n }\n sigint_handler = abort_all('SIGINT')\n sigterm_handler = abort_all('SIGTERM')\n process.on('SIGINT', sigint_handler)\n process.on('SIGTERM', sigterm_handler)\n}\n\n/**\n * Remove the process signal handlers once the last active run settles.\n *\n * Keeps a library embed from leaving stray `process.on` listeners behind\n * after all runs complete.\n */\nfunction release_signal_handlers(): void {\n if (!signal_handler_installed) return\n if (active_runs.size > 0) return\n signal_handler_installed = false\n if (sigint_handler) process.off('SIGINT', sigint_handler)\n if (sigterm_handler) process.off('SIGTERM', sigterm_handler)\n sigint_handler = null\n sigterm_handler = null\n}\n\nconst noop_logger: TrajectoryLogger = {\n record: () => {},\n start_span: (name) => `${name}:${randomUUID().slice(0, 8)}`,\n end_span: () => {},\n}\n\n/**\n * Wrap a logger so every emitted event automatically carries `run_id` and a\n * `ts` (epoch milliseconds) stamped at emission.\n *\n * Studios and other downstream consumers multiplex events across runs by\n * `run_id` and reconstruct real timing from `ts` instead of fabricating it at\n * ingest. Either field already present on an event or its meta is preserved;\n * we never overwrite a caller-supplied value.\n */\nfunction decorate_logger(inner: TrajectoryLogger, run_id: string): TrajectoryLogger {\n const stamp_meta = (\n meta: Record<string, unknown> | undefined,\n ): Record<string, unknown> => {\n const out: Record<string, unknown> = { ...meta }\n if (!('run_id' in out)) out['run_id'] = run_id\n if (!('ts' in out)) out['ts'] = Date.now()\n return out\n }\n return {\n record: (event) => {\n if ('run_id' in event && 'ts' in event) {\n inner.record(event)\n return\n }\n const extra: Record<string, unknown> = {}\n if (!('run_id' in event)) extra['run_id'] = run_id\n if (!('ts' in event)) extra['ts'] = Date.now()\n inner.record({ ...event, ...extra })\n },\n start_span: (name, meta) => inner.start_span(name, stamp_meta(meta)),\n end_span: (id, meta) => {\n inner.end_span(id, stamp_meta(meta))\n },\n }\n}\n\n/**\n * Route a step to its registered kind handler.\n *\n * This is the single entry point composers use to run children. On failure\n * the step's id is prepended to the error's `path`, so an error surfacing\n * from a deep tree carries the chain of step ids it crossed.\n */\nexport async function dispatch_step<i, o>(\n flow: Step<i, o>,\n input: i,\n ctx: RunContext,\n): Promise<o> {\n const handler = dispatch.get(flow.kind)\n if (!handler) {\n throw new Error(`unknown step kind: ${flow.kind} (step id: ${flow.id})`)\n }\n try {\n const result = await handler(flow, input, ctx)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return result as o\n } catch (err) {\n prepend_path(err, flow.id)\n throw err\n }\n}\n\n/**\n * Prepend a step id to the `path` array carried on an error object.\n *\n * Mutates the error in place so the path accumulates as the error bubbles up\n * through nested dispatches. Non-object errors are left untouched.\n */\nexport function prepend_path(err: unknown, id: string): void {\n if (err === null || typeof err !== 'object') return\n const existing = Reflect.get(err, 'path')\n const next: string[] = Array.isArray(existing)\n ? [id, ...existing.filter((v): v is string => typeof v === 'string')]\n : [id]\n Reflect.set(err, 'path', next)\n}\n\n/**\n * Throw the abort reason if the context has been cancelled. Composers that\n * iterate over children (`sequence`, `scope`, `loop`) call this between steps\n * so a pending abort is honored before the next child starts, not only when a\n * downstream dispatch happens to observe it.\n */\nexport function throw_if_aborted(ctx: RunContext): void {\n if (!ctx.abort.aborted) return\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n}\n\n/**\n * Forward a caller-owned AbortSignal into the run's internal controller and\n * return an unlink function. The reason is preserved so the original\n * cancellation cause propagates out of `run`. The listener is `once` and the\n * returned unlink is called when the run settles, so a long-lived host (an MCP\n * server, an HTTP worker) firing many short runs against one external signal\n * does not accumulate listeners.\n */\nfunction link_external_abort(\n controller: AbortController,\n external: AbortSignal | undefined,\n): () => void {\n if (external === undefined) return () => {}\n if (external.aborted) {\n controller.abort(external.reason)\n return () => {}\n }\n const on_abort = (): void => {\n controller.abort(external.reason)\n }\n external.addEventListener('abort', on_abort, { once: true })\n return () => {\n external.removeEventListener('abort', on_abort)\n }\n}\n\ntype StartResult<o> = {\n readonly events: AsyncIterable<TrajectoryEvent>\n readonly result: Promise<o>\n}\n\n/**\n * Construct a run context and execute a flow to settlement.\n *\n * Shared engine behind `run` and `run.stream`; `high_water_mark` selects the\n * mode (null means no streaming channel). Owns the full run lifecycle:\n * abort wiring, logger decoration, cleanup registration, signal handlers,\n * and the settle-time teardown ordering (cleanup handlers first, then\n * unlinking and stream close).\n */\nfunction start_run<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions,\n high_water_mark: number | null,\n): StartResult<o> {\n const install_signal_handlers = options.install_signal_handlers !== false\n const base_logger = options.trajectory ?? noop_logger\n const streaming = high_water_mark !== null\n\n const controller = new AbortController()\n const unlink_abort = link_external_abort(controller, options.abort)\n const run_id = randomUUID()\n\n let stream_events: AsyncIterable<TrajectoryEvent> = empty_async_iterable()\n let close_stream: (() => void) | null = null\n let inner: TrajectoryLogger = base_logger\n\n if (streaming) {\n // Decorate must wrap the streaming channel, not the reverse: the channel\n // enqueues a copy of each event for `run.stream` consumers, so it has to\n // see the events after `decorate_logger` has stamped `ts` and `run_id`.\n const channel = create_streaming_channel(base_logger, high_water_mark)\n inner = channel.logger\n stream_events = channel.events\n close_stream = channel.close\n }\n\n const logger: TrajectoryLogger = decorate_logger(inner, run_id)\n\n const cleanup = create_cleanup_registry(logger)\n\n const ctx: RunContext = {\n run_id,\n trajectory: logger,\n state: new Map(),\n abort: controller.signal,\n emit: (event) => {\n logger.record({ ...event, kind: 'emit' })\n },\n on_cleanup: (fn) => {\n cleanup.register(fn)\n },\n checkpoint_store: options.checkpoint_store,\n resume_data: options.resume_data,\n streaming,\n }\n\n active_runs.add(controller)\n if (install_signal_handlers) {\n ensure_signal_handlers()\n }\n\n const result = (async (): Promise<o> => {\n try {\n // Honor an external signal that was already aborted at call time, so the\n // run rejects without dispatching even when the flow is a single leaf\n // step that never reaches a cooperative abort check.\n throw_if_aborted(ctx)\n return await dispatch_step(flow, input, ctx)\n } catch (err) {\n if (controller.signal.aborted && !(err instanceof aborted_error)) {\n const reason = controller.signal.reason\n if (reason instanceof aborted_error) throw reason\n }\n throw err\n } finally {\n try {\n await cleanup.run_all()\n } finally {\n unlink_abort()\n active_runs.delete(controller)\n release_signal_handlers()\n if (close_stream) close_stream()\n }\n }\n })()\n\n return { events: stream_events, result }\n}\n\n/**\n * Build an async iterable that is immediately done.\n *\n * Non-streaming runs hand this to callers so the `events` field always has\n * the same shape regardless of mode.\n */\nfunction empty_async_iterable(): AsyncIterable<TrajectoryEvent> {\n return {\n [Symbol.asyncIterator]() {\n return {\n next: (): Promise<IteratorResult<TrajectoryEvent>> =>\n Promise.resolve({ value: undefined, done: true } as IteratorResult<TrajectoryEvent>),\n }\n },\n }\n}\n\n/**\n * Execute a flow and resolve with its final output.\n */\nasync function run_impl<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions = {},\n): Promise<o> {\n const { result } = start_run(flow, input, options, null)\n return result\n}\n\n/**\n * Execute a flow while exposing its trajectory events as an async iterable.\n */\nfunction run_stream<i, o>(\n flow: Step<i, o>,\n input: i,\n options: RunOptions = {},\n): StreamingRunHandle<o> {\n const { events, result } = start_run(flow, input, options, STREAMING_HIGH_WATER_MARK)\n return { events, result }\n}\n\n/**\n * The public entry point for executing a flow.\n *\n * Callable as `run(flow, input, options?)` for a plain result, or\n * `run.stream(flow, input, options?)` for `{ events, result }`. Both share\n * one implementation, so a streamed run and a plain run of the same flow\n * produce identical output.\n */\nexport const run: typeof run_impl & { stream: typeof run_stream } = Object.assign(run_impl, {\n stream: run_stream,\n})\n","/**\n * step() factory.\n *\n * Three forms:\n * step(id, fn): named step. id is rendered in trajectory spans and describe().\n * step(id, fn, meta): named step with optional human-readable metadata for studio,\n * codegen, and similar consumers. `meta` is purely descriptive\n * and never affects runtime semantics.\n * step(fn): anonymous step. id is `anon_<counter>`; cannot be checkpointed.\n *\n * Anonymous steps carry an internal `anonymous: true` flag so checkpoint can\n * reject them synchronously at flow construction time.\n */\n\nimport { register_traced_kind } from './runner.js'\nimport type { Step, StepFn, StepMetadata } from './types.js'\n\nlet anon_counter = 0\n\n/**\n * Generate a unique id of the form `anon_<n>` for anonymous steps.\n */\nfunction next_anon_id(): string {\n anon_counter += 1\n return `anon_${anon_counter}`\n}\n\n/**\n * Wrap a plain function as a `Step`, named or anonymous.\n *\n * The named form takes an explicit id (and optional descriptive `meta`); the\n * anonymous form generates an `anon_<n>` id and marks the step so checkpoint\n * rejects it at construction time.\n */\nexport function step<i, o>(id: string, fn: StepFn<i, o>, meta?: StepMetadata): Step<i, o>\nexport function step<i, o>(fn: StepFn<i, o>): Step<i, o>\nexport function step<i, o>(\n id_or_fn: string | StepFn<i, o>,\n maybe_fn?: StepFn<i, o>,\n meta?: StepMetadata,\n): Step<i, o> {\n if (typeof id_or_fn === 'function') {\n return {\n id: next_anon_id(),\n kind: 'step',\n run: id_or_fn,\n anonymous: true,\n }\n }\n if (typeof maybe_fn !== 'function') {\n throw new TypeError('step(id, fn): fn must be a function')\n }\n if (meta) {\n return {\n id: id_or_fn,\n kind: 'step',\n run: maybe_fn,\n meta,\n }\n }\n return {\n id: id_or_fn,\n kind: 'step',\n run: maybe_fn,\n }\n}\n\nregister_traced_kind('step')\n","/**\n * is_step: structural Step check.\n *\n * Steps are plain objects with no brand symbol, so runtime detection is\n * structural: string `id`, string `kind`, callable `run`. Used by describe()\n * to render Step references and by combinators to validate arguments at\n * construction time.\n */\n\nimport type { Step } from './types.js'\n\n/**\n * Check whether a value is structurally a `Step`.\n *\n * True when the value has a string `id`, a string `kind`, and a callable\n * `run`.\n */\nexport function is_step(value: unknown): value is Step<unknown, unknown> {\n if (typeof value !== 'object' || value === null) return false\n if (!('id' in value) || !('kind' in value) || !('run' in value)) return false\n const { id, kind, run } = value\n return typeof id === 'string' && typeof kind === 'string' && typeof run === 'function'\n}\n","/**\n * describe(step) and describe.json(step): composition introspection.\n *\n * `describe(step)` is the text-tree renderer. Multi-line string with\n * hierarchical indentation. Function values render as `<fn>` (or\n * `<fn:name>` when the function has a non-empty `name`); zod schemas\n * render as `<schema>`.\n *\n * `describe.json(step)` returns a `FlowNode` tree (kind, id, config, children)\n * for tooling (Studio UI, Mermaid renderers, diff tools). Function values\n * serialize as `{ kind: '<fn>', name? }` and schemas as `{ kind: '<schema>' }`.\n *\n * Both forms detect cycles. Under the default (loose) mode, back-references\n * render as `<cycle>(id)` in text and `{ kind: '<cycle>', id }` in JSON. Under\n * `{ strict: true }`, cycles throw `describe_cycle_error`.\n */\n\nimport { describe_cycle_error } from './errors.js'\nimport { is_step } from './is_step.js'\nimport type { Step, StepMetadata } from './types.js'\n\nconst INDENT = ' '\n\nexport type FlowValue =\n | string\n | number\n | boolean\n | null\n | ReadonlyArray<FlowValue>\n | Readonly<{ [key: string]: FlowValue }>\n | { readonly kind: '<fn>'; readonly name?: string }\n | { readonly kind: '<schema>' }\n | { readonly kind: string; readonly id: string }\n\nexport type FlowNode = {\n readonly kind: string\n readonly id: string\n readonly config?: Readonly<{ [key: string]: FlowValue }>\n readonly children?: ReadonlyArray<FlowNode>\n readonly meta?: StepMetadata\n}\n\nexport type DescribeOptions = {\n readonly strict?: boolean\n}\n\ntype Path = Set<Step<unknown, unknown>>\n\n/**\n * Render a step tree as an indented multi-line string.\n */\nfunction describe_text<i, o>(root: Step<i, o>, options?: DescribeOptions): string {\n const lines: string[] = []\n const strict = Boolean(options?.strict)\n render_text(root, 0, lines, new Set(), strict)\n return lines.join('\\n')\n}\n\n/**\n * Render a step tree as a serializable `FlowNode` tree.\n */\nfunction describe_json<i, o>(root: Step<i, o>, options?: DescribeOptions): FlowNode {\n const strict = Boolean(options?.strict)\n return render_json(root, new Set(), strict)\n}\n\n/**\n * Public entry point: `describe(step)` for text, `describe.json(step)` for\n * the `FlowNode` tree.\n */\nexport const describe: {\n <i, o>(root: Step<i, o>, options?: DescribeOptions): string\n json: <i, o>(root: Step<i, o>, options?: DescribeOptions) => FlowNode\n} = Object.assign(describe_text, { json: describe_json })\n\n/**\n * Append one node (label line, config lines, then children) to `lines`.\n *\n * `path` holds the steps on the current root-to-node path for cycle\n * detection; membership is added before recursing and removed in a `finally`\n * so shared (diamond) references are not misreported as cycles.\n */\nfunction render_text(\n node: Step<unknown, unknown>,\n depth: number,\n lines: string[],\n path: Path,\n strict: boolean,\n): void {\n const prefix = INDENT.repeat(depth)\n if (path.has(node)) {\n if (strict) throw new describe_cycle_error(node.id)\n lines.push(`${prefix}<cycle>(${node.id})`)\n return\n }\n path.add(node)\n try {\n const display = node.config?.['display_name']\n const label = typeof display === 'string' && display.length > 0 ? display : node.kind\n lines.push(`${prefix}${label}(${node.id})`)\n if (node.config) {\n for (const [key, value] of Object.entries(node.config)) {\n if (key === 'display_name') continue\n lines.push(`${prefix}${INDENT}${key}: ${render_value_text(value, path, strict)}`)\n }\n }\n if (node.children && node.children.length > 0) {\n for (const child of node.children) {\n render_text(child, depth + 1, lines, path, strict)\n }\n }\n } finally {\n path.delete(node)\n }\n}\n\n/**\n * Render a single config value for the text tree.\n *\n * Functions become `<fn>` or `<fn:name>`, zod schemas `<schema>`, and Step\n * references `kind(id)`; arrays and plain objects recurse. Strings are\n * JSON-quoted so empty and whitespace values stay visible.\n */\nfunction render_value_text(value: unknown, path: Path, strict: boolean): string {\n if (typeof value === 'function') {\n const name = typeof value.name === 'string' && value.name.length > 0 ? value.name : ''\n return name ? `<fn:${name}>` : '<fn>'\n }\n if (value === null) return 'null'\n if (value === undefined) return 'undefined'\n if (is_zod_schema(value)) return '<schema>'\n if (is_step(value)) {\n if (path.has(value)) {\n if (strict) throw new describe_cycle_error(value.id)\n return `<cycle>(${value.id})`\n }\n return `${value.kind}(${value.id})`\n }\n if (Array.isArray(value)) {\n return `[${value.map((item: unknown) => render_value_text(item, path, strict)).join(', ')}]`\n }\n if (typeof value === 'object') {\n const entries = Object.entries({ ...value }).map(\n ([k, v]: [string, unknown]) => `${k}: ${render_value_text(v, path, strict)}`,\n )\n return `{ ${entries.join(', ')} }`\n }\n if (typeof value === 'string') return JSON.stringify(value)\n if (typeof value === 'bigint') return `${value.toString()}n`\n if (typeof value === 'symbol') return value.toString()\n if (typeof value === 'number' || typeof value === 'boolean') return String(value)\n return JSON.stringify(value)\n}\n\n/**\n * Convert one step node to a `FlowNode`, recursing into config and children.\n *\n * Uses the same path-based cycle detection as `render_text`: back-references\n * become `{ kind: '<cycle>', id }` in loose mode and throw in strict mode.\n */\nfunction render_json(\n node: Step<unknown, unknown>,\n path: Path,\n strict: boolean,\n): FlowNode {\n if (path.has(node)) {\n if (strict) throw new describe_cycle_error(node.id)\n return { kind: '<cycle>', id: node.id }\n }\n path.add(node)\n try {\n const result: {\n kind: string\n id: string\n config?: { [key: string]: FlowValue }\n children?: FlowNode[]\n meta?: StepMetadata\n } = { kind: node.kind, id: node.id }\n if (node.config) {\n const config: { [key: string]: FlowValue } = {}\n for (const [key, value] of Object.entries(node.config)) {\n config[key] = render_value_json(value, path, strict)\n }\n result.config = config\n }\n if (node.children && node.children.length > 0) {\n result.children = node.children.map((child) => render_json(child, path, strict))\n }\n if (node.meta) {\n result.meta = node.meta\n }\n return result\n } finally {\n path.delete(node)\n }\n}\n\n/**\n * Convert a single config value to a JSON-safe `FlowValue`.\n *\n * Functions serialize as `{ kind: '<fn>', name? }`, schemas as\n * `{ kind: '<schema>' }`, Step references as `{ kind, id }`. `undefined`\n * maps to `null` and bigints/symbols to strings so the result survives\n * `JSON.stringify` without loss.\n */\nfunction render_value_json(value: unknown, path: Path, strict: boolean): FlowValue {\n if (typeof value === 'function') {\n const name = typeof value.name === 'string' && value.name.length > 0 ? value.name : ''\n return name ? { kind: '<fn>', name } : { kind: '<fn>' }\n }\n if (value === null) return null\n if (value === undefined) return null\n if (is_zod_schema(value)) return { kind: '<schema>' }\n if (is_step(value)) {\n if (path.has(value)) {\n if (strict) throw new describe_cycle_error(value.id)\n return { kind: '<cycle>', id: value.id }\n }\n return { kind: value.kind, id: value.id }\n }\n if (Array.isArray(value)) {\n return value.map((item: unknown) => render_value_json(item, path, strict))\n }\n if (typeof value === 'object') {\n const out: { [key: string]: FlowValue } = {}\n for (const [k, v] of Object.entries({ ...value })) {\n out[k] = render_value_json(v, path, strict)\n }\n return out\n }\n if (typeof value === 'string') return value\n if (typeof value === 'number' || typeof value === 'boolean') return value\n if (typeof value === 'bigint') return `${value.toString()}n`\n if (typeof value === 'symbol') return value.toString()\n return JSON.stringify(value)\n}\n\n/**\n * Detect a zod schema by its internal marker properties (`_zod` in zod 4,\n * `_def` in zod 3) without importing zod.\n */\nfunction is_zod_schema(value: unknown): boolean {\n if (typeof value !== 'object' || value === null) return false\n return '_zod' in value || '_def' in value\n}\n","/**\n * sequence: chain child outputs.\n *\n * `sequence([a, b, c])` runs a, b, c in declared order. The input to sequence\n * is passed to the first child; each subsequent child receives the previous\n * child's output. The composer returns the last child's output.\n */\n\nimport { is_step } from './is_step.js'\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype FirstInput<children> = children extends readonly [Step<infer i, unknown>, ...unknown[]]\n ? i\n : unknown\n\ntype LastOutput<children> = children extends readonly [...unknown[], Step<unknown, infer o>]\n ? o\n : children extends readonly [Step<unknown, infer o>]\n ? o\n : unknown\n\nlet sequence_counter = 0\n\n/**\n * Generate a unique step id of the form `sequence_<n>`.\n */\nfunction next_id(): string {\n sequence_counter += 1\n return `sequence_${sequence_counter}`\n}\n\nexport type SequenceOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that chains children, each feeding the next.\n *\n * Validates every element up front so a non-Step (usually a bare function)\n * fails at construction with a pointed message rather than at run time.\n * Checks `ctx.abort` before each child so aborts land on step boundaries.\n */\nexport function sequence<const children extends readonly AnyStep[]>(\n children: children,\n options?: SequenceOptions,\n): Step<FirstInput<children>, LastOutput<children>> {\n if (!Array.isArray(children)) {\n throw new TypeError(\n `sequence(children): children must be an array of Steps, got ${typeof children} — sequence takes a single array, e.g. sequence([a, b, c])`,\n )\n }\n children.forEach((child, index) => {\n if (is_step(child)) return\n const hint =\n typeof child === 'function'\n ? ' — wrap plain functions with step(fn), or use pipe(inner, fn) to transform output'\n : ''\n throw new TypeError(\n `sequence(children): children[${index}] is not a Step, got ${typeof child}${hint}`,\n )\n })\n\n const id = next_id()\n const children_ref = children\n const run_fn = async (input: unknown, ctx: RunContext): Promise<unknown> => {\n let acc: unknown = input\n for (const child of children_ref) {\n throw_if_aborted(ctx)\n acc = await dispatch_step(child, acc, ctx)\n }\n return acc\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return {\n id,\n kind: 'sequence',\n children,\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n } as Step<FirstInput<children>, LastOutput<children>>\n}\n\nregister_traced_kind('sequence')\n","/**\n * parallel: concurrent execution of named children.\n *\n * `parallel({ a, b })` runs a and b concurrently with the same input. Output\n * is an object keyed by the child name; all children must accept the same\n * input type.\n *\n * Cancellation: each child runs with a composed abort signal,\n * `AbortSignal.any([ctx.abort, child_local])`. On abort the composer awaits\n * all in-flight children (success, failure, or aborted) before rethrowing\n * `ctx.abort.reason`.\n *\n * When several children fail, a `suspended_error` is preferred over an\n * application error so a human-approval gate inside a branch stays resumable\n * rather than being masked by a sibling's failure. Otherwise the first error\n * in declared order propagates.\n */\n\nimport { aborted_error, suspended_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype OutputOf<s> = s extends Step<unknown, infer o> ? o : unknown\n\ntype ParallelOutputs<children extends Record<string, AnyStep>> = {\n [k in keyof children]: OutputOf<children[k]>\n}\n\nlet parallel_counter = 0\n\n/**\n * Generate a unique step id of the form `parallel_<n>`.\n */\nfunction next_id(): string {\n parallel_counter += 1\n return `parallel_${parallel_counter}`\n}\n\nexport type ParallelOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that runs named children concurrently on the same input.\n *\n * Returns an object keyed by child name. All children settle before any\n * error propagates; a `suspended_error` wins over application errors so a\n * human-approval gate stays resumable instead of being masked by a sibling's\n * failure.\n */\nexport function parallel<i, children extends Record<string, Step<i, unknown>>>(\n members: children,\n options?: ParallelOptions,\n): Step<i, ParallelOutputs<children>> {\n const id = next_id()\n const entries: ReadonlyArray<readonly [string, AnyStep]> = Object.entries(members)\n const child_list: ReadonlyArray<AnyStep> = entries.map(([, s]) => s)\n const keys: ReadonlyArray<string> = entries.map(([k]) => k)\n\n const run_fn = async (input: i, ctx: RunContext): Promise<ParallelOutputs<children>> => {\n const controllers = entries.map(() => new AbortController())\n const on_parent_abort = (): void => {\n for (const c of controllers) c.abort(ctx.abort.reason)\n }\n if (ctx.abort.aborted) {\n on_parent_abort()\n } else {\n ctx.abort.addEventListener('abort', on_parent_abort, { once: true })\n }\n \n try {\n const settled = await Promise.all(\n entries.map(async ([key, child], idx) => {\n const local = controllers[idx]\n if (!local) throw new Error('parallel: missing controller')\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n try {\n const value = await dispatch_step(child, input, child_ctx)\n return { status: 'ok' as const, key, value }\n } catch (err) {\n return { status: 'err' as const, key, err }\n }\n }),\n )\n \n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n\n let first_err: unknown\n let has_err = false\n let suspended: unknown\n let has_suspended = false\n for (const s of settled) {\n if (s.status !== 'err') continue\n if (!has_err) {\n first_err = s.err\n has_err = true\n }\n if (!has_suspended && s.err instanceof suspended_error) {\n suspended = s.err\n has_suspended = true\n }\n }\n if (has_suspended) throw suspended\n if (has_err) throw first_err\n \n const out: Record<string, unknown> = {}\n for (const s of settled) {\n if (s.status === 'ok') out[s.key] = s.value\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return out as ParallelOutputs<children>\n } finally {\n ctx.abort.removeEventListener('abort', on_parent_abort)\n }\n }\n\n const config_meta: Record<string, unknown> = { keys }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'parallel',\n children: child_list,\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('parallel')\n","/**\n * branch: conditional routing.\n *\n * `branch({ when, then, otherwise })` evaluates `when(input)`; if truthy, runs\n * `then`, else runs `otherwise`. Both branches must return the same output\n * type.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type BranchConfig<i, o> = {\n readonly name?: string\n readonly when: (input: i) => boolean | Promise<boolean>\n readonly then: Step<i, o>\n readonly otherwise: Step<i, o>\n}\n\nlet branch_counter = 0\n\n/**\n * Generate a unique step id of the form `branch_<n>`.\n */\nfunction next_id(): string {\n branch_counter += 1\n return `branch_${branch_counter}`\n}\n\n/**\n * Build a conditional-routing step.\n *\n * Evaluates `when(input)` at run time and dispatches to `then` or `otherwise`.\n * Both branches appear as children so `describe()` renders the full tree even\n * though only one branch runs.\n */\nexport function branch<i, o>(config: BranchConfig<i, o>): Step<i, o> {\n const id = next_id()\n const { when, then: then_step, otherwise: otherwise_step, name } = config\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const cond = await when(input)\n const next_step = cond ? then_step : otherwise_step\n return dispatch_step(next_step, input, ctx)\n }\n\n const config_meta: Record<string, unknown> = { when, then: then_step, otherwise: otherwise_step }\n if (name !== undefined) config_meta['display_name'] = name\n\n return {\n id,\n kind: 'branch',\n children: [then_step, otherwise_step],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('branch')\n","/**\n * map: per-item execution.\n *\n * `map({ items, do, concurrency? })` extracts an array via `items(input)`,\n * runs `do` once per element, returns an array in the same order as inputs.\n * `concurrency` caps simultaneous in-flight items; omitted means full\n * parallelism.\n *\n * Cancellation: each in-flight item runs with a composed abort signal via\n * `AbortSignal.any([ctx.abort, child_local])`.\n * On abort no new items start. The composer awaits all in-flight items before\n * rethrowing `ctx.abort.reason`.\n */\n\nimport { aborted_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type MapConfig<input, item, result> = {\n readonly name?: string\n readonly items: (input: input) => ReadonlyArray<item> | Promise<ReadonlyArray<item>>\n readonly do: Step<item, result>\n readonly concurrency?: number\n}\n\nlet map_counter = 0\n\n/**\n * Generate a unique step id of the form `map_<n>`.\n */\nfunction next_id(): string {\n map_counter += 1\n return `map_${map_counter}`\n}\n\n/**\n * Build a per-item execution step.\n *\n * Extracts an array via `items(input)`, runs `do` once per element through a\n * bounded worker pool, and returns results in input order. The first item\n * failure stops new work and propagates after in-flight items settle.\n */\nexport function map<input, item, result>(\n config: MapConfig<input, item, result>,\n): Step<input, result[]> {\n const id = next_id()\n const { items, do: per_item, concurrency, name } = config\n\n const run_fn = async (input: input, ctx: RunContext): Promise<result[]> => {\n const list = await items(input)\n if (list.length === 0) return []\n const results: result[] = Array.from({ length: list.length })\n \n const limit = concurrency === undefined ? list.length : Math.max(1, concurrency)\n const controllers: AbortController[] = []\n \n const on_parent_abort = (): void => {\n for (const c of controllers) c.abort(ctx.abort.reason)\n }\n if (ctx.abort.aborted) {\n on_parent_abort()\n } else {\n ctx.abort.addEventListener('abort', on_parent_abort, { once: true })\n }\n \n let cursor = 0\n let worker_error: unknown = undefined\n \n const run_one = async (idx: number): Promise<void> => {\n const local = new AbortController()\n controllers.push(local)\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n const item_value = list[idx]\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const value = await dispatch_step(per_item, item_value as item, child_ctx)\n results[idx] = value\n }\n \n const worker = async (): Promise<void> => {\n while (true) {\n if (ctx.abort.aborted || worker_error !== undefined) return\n const idx = cursor\n cursor += 1\n if (idx >= list.length) return\n try {\n await run_one(idx)\n } catch (err) {\n if (worker_error === undefined) worker_error = err\n return\n }\n }\n }\n \n try {\n const worker_count = Math.min(limit, list.length)\n const workers: Promise<void>[] = []\n for (let w = 0; w < worker_count; w += 1) {\n workers.push(worker())\n }\n await Promise.all(workers)\n \n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n if (worker_error !== undefined) throw worker_error\n \n return results\n } finally {\n ctx.abort.removeEventListener('abort', on_parent_abort)\n }\n }\n\n const config_meta: Record<string, unknown> = { items }\n if (concurrency !== undefined) config_meta['concurrency'] = concurrency\n if (name !== undefined) config_meta['display_name'] = name\n\n return {\n id,\n kind: 'map',\n children: [per_item],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('map')\n","/**\n * pipe: transform output.\n *\n * `pipe(inner, fn)` runs `inner`, passes its output to `fn`, returns `fn`'s\n * result. Use for shape adaptation when composing heterogeneous steps.\n */\n\nimport { is_step } from './is_step.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet pipe_counter = 0\n\n/**\n * Generate a unique step id of the form `pipe_<n>`.\n */\nfunction next_id(): string {\n pipe_counter += 1\n return `pipe_${pipe_counter}`\n}\n\nexport type PipeOptions = {\n readonly name?: string\n}\n\n/**\n * Build an output-transforming step around `inner`.\n *\n * The argument checks reject Steps passed where functions belong: `pipe` is\n * not variadic, and the early `TypeError`s point misuse at `step(fn)` or\n * `sequence([...])` instead of failing obscurely at run time.\n */\nexport function pipe<i, a, b>(\n inner: Step<i, a>,\n fn: (value: a) => b | Promise<b>,\n options?: PipeOptions,\n): Step<i, b> {\n if (!is_step(inner)) {\n const hint = typeof inner === 'function' ? ' — wrap plain functions with step(fn)' : ''\n throw new TypeError(`pipe(inner, fn): inner must be a Step, got ${typeof inner}${hint}`)\n }\n if (typeof fn !== 'function') {\n if (is_step(fn)) {\n throw new TypeError(\n 'pipe(inner, fn): fn must be a function, got a Step — pipe is not variadic; to chain Steps use sequence([...])',\n )\n }\n throw new TypeError(`pipe(inner, fn): fn must be a function, got ${typeof fn}`)\n }\n if (is_step(options)) {\n throw new TypeError(\n 'pipe(inner, fn, options): got a Step as the third argument — pipe is not variadic; to chain Steps use sequence([...])',\n )\n }\n\n const id = next_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<b> => {\n const intermediate = await dispatch_step(inner, input, ctx)\n return fn(intermediate)\n }\n\n const config_meta: Record<string, unknown> = { fn }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'pipe',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('pipe')\n","/**\n * retry: re-run on failure.\n *\n * `retry(inner, { max_attempts, backoff_ms?, on_error? })` runs `inner`. If it\n * throws an application error, retries up to `max_attempts - 1` more times with\n * exponential backoff (`backoff_ms * 2^(attempt-1)`). `on_error` is called on\n * every such failure. The last error is rethrown if all attempts fail.\n *\n * Control-flow signals (`suspended_error`, `aborted_error`) are not failures:\n * they propagate immediately without consuming an attempt, firing `on_error`,\n * or scheduling a backoff. A suspend's `on()` side effect therefore runs once\n * per run, not once per attempt.\n *\n * Cancellation / cleanup: cleanup handlers registered by the inner step\n * accumulate across attempts. The parent `ctx.abort` is honored between\n * attempts; a pending abort short-circuits the backoff and propagates.\n */\n\nimport { aborted_error, is_control_flow_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nconst DEFAULT_BACKOFF_MS = 1_000\n\nexport type RetryConfig = {\n readonly name?: string\n readonly max_attempts: number\n readonly backoff_ms?: number\n readonly on_error?: (err: unknown, attempt: number) => void\n}\n\nlet retry_counter = 0\n\n/**\n * Generate a unique step id of the form `retry_<n>`.\n */\nfunction next_id(): string {\n retry_counter += 1\n return `retry_${retry_counter}`\n}\n\n/**\n * Sleep for `ms` unless the run is aborted first.\n *\n * Rejects immediately with the abort reason (or an `aborted_error`) when\n * `ctx.abort` fires, so a pending abort never waits out a backoff delay.\n */\nasync function abortable_wait(ms: number, ctx: RunContext): Promise<void> {\n if (ms <= 0) return\n await new Promise<void>((resolve, reject) => {\n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n return\n }\n const timer = setTimeout(() => {\n ctx.abort.removeEventListener('abort', on_abort)\n resolve()\n }, ms)\n const on_abort = (): void => {\n clearTimeout(timer)\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n }\n ctx.abort.addEventListener('abort', on_abort, { once: true })\n })\n}\n\n/**\n * Build a retrying step around `inner`.\n *\n * Runs `inner` up to `max_attempts` times with exponential backoff between\n * failures. Application errors consume an attempt and fire `on_error`;\n * control-flow signals propagate untouched.\n */\nexport function retry<i, o>(inner: Step<i, o>, config: RetryConfig): Step<i, o> {\n const id = next_id()\n const max_attempts = Math.max(1, Math.floor(config.max_attempts))\n const backoff_ms = config.backoff_ms ?? DEFAULT_BACKOFF_MS\n const on_error = config.on_error\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n let last_err: unknown = undefined\n for (let attempt = 1; attempt <= max_attempts; attempt += 1) {\n if (ctx.abort.aborted) {\n const reason = ctx.abort.reason\n throw reason instanceof Error ? reason : new aborted_error('aborted', { reason })\n }\n try {\n return await dispatch_step(inner, input, ctx)\n } catch (err) {\n if (is_control_flow_error(err)) throw err\n last_err = err\n if (on_error) on_error(err, attempt)\n if (attempt >= max_attempts) break\n const delay = backoff_ms * 2 ** (attempt - 1)\n await abortable_wait(delay, ctx)\n }\n }\n throw last_err\n }\n\n const config_meta: Record<string, unknown> = { max_attempts, backoff_ms }\n if (on_error) config_meta['on_error'] = on_error\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id,\n kind: 'retry',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('retry')\n","/**\n * fallback: primary-or-backup.\n *\n * `fallback(primary, backup)` runs `primary`. If it throws an application\n * error, runs `backup` with the same input, or with `handoff(input, err)`\n * when the `handoff` option is set, so the backup can be told why it is\n * running. If `backup` also throws, the `backup` error propagates.\n * Control-flow signals (`suspended_error`, `aborted_error`) are not\n * failures: they propagate instead of triggering the backup, so a\n * human-approval gate is never silently bypassed and the backup never runs\n * under an aborted context. `handoff` is never called for them.\n */\n\nimport { is_control_flow_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet fallback_counter = 0\n\n/**\n * Generate a unique step id of the form `fallback_<n>`.\n */\nfunction next_id(): string {\n fallback_counter += 1\n return `fallback_${fallback_counter}`\n}\n\nexport type FallbackOptions<i = unknown> = {\n readonly name?: string\n readonly handoff?: (input: i, err: unknown) => i\n}\n\n/**\n * Build a primary-or-backup step.\n *\n * Runs `primary`; on an application error runs `backup` with the same input,\n * or with `handoff(input, err)` when the option is set. Control-flow signals\n * propagate without triggering the backup or the handoff.\n */\nexport function fallback<i, o>(\n primary: Step<i, o>,\n backup: Step<i, o>,\n options?: FallbackOptions<i>,\n): Step<i, o> {\n const id = next_id()\n const handoff = options?.handoff\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n try {\n return await dispatch_step(primary, input, ctx)\n } catch (err) {\n if (is_control_flow_error(err)) throw err\n const backup_input = handoff === undefined ? input : handoff(input, err)\n return dispatch_step(backup, backup_input, ctx)\n }\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n return {\n id,\n kind: 'fallback',\n children: [primary, backup],\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n }\n}\n\nregister_traced_kind('fallback')\n","/**\n * timeout: bound execution.\n *\n * `timeout(inner, ms)` runs `inner` with a composed `AbortSignal` that fires\n * at `ms` milliseconds. If the inner step does not complete in time, throws\n * `timeout_error`. The inner step is responsible for honoring `ctx.abort`;\n * a step that ignores the signal still triggers `timeout_error` on schedule\n * but continues running in the background.\n *\n * Cancellation: the inner step runs with\n * `AbortSignal.any([ctx.abort, timeout_local])`. On timer expiry, the local\n * controller aborts with a `timeout_error` as its reason; on parent abort\n * the parent reason flows through. The timer is always cleared in a finally\n * block so it does not leak across retries.\n */\n\nimport { aborted_error, timeout_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet timeout_counter = 0\n\n/**\n * Generate a unique step id of the form `timeout_<n>`.\n */\nfunction next_id(): string {\n timeout_counter += 1\n return `timeout_${timeout_counter}`\n}\n\nexport type TimeoutOptions = {\n readonly name?: string\n}\n\n/**\n * Build a deadline-bounded step around `inner`.\n *\n * Races the inner dispatch against a timer that aborts the composed signal\n * with `timeout_error`. The `timed_out` flag distinguishes timer expiry from\n * a parent abort so the right error propagates.\n */\nexport function timeout<i, o>(\n inner: Step<i, o>,\n ms: number,\n options?: TimeoutOptions,\n): Step<i, o> {\n const id = next_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const local = new AbortController()\n const composed = AbortSignal.any([ctx.abort, local.signal])\n const child_ctx: RunContext = { ...ctx, abort: composed }\n \n let timed_out = false\n const timer = setTimeout(() => {\n timed_out = true\n local.abort(new timeout_error(`timeout after ${ms}ms`, ms))\n }, ms)\n \n const deadline = new Promise<never>((_, reject) => {\n const on_local_abort = (): void => {\n if (timed_out) {\n reject(new timeout_error(`timeout after ${ms}ms`, ms))\n } else {\n const reason = ctx.abort.reason\n reject(reason instanceof Error ? reason : new aborted_error('aborted', { reason }))\n }\n }\n if (composed.aborted) {\n on_local_abort()\n return\n }\n composed.addEventListener('abort', on_local_abort, { once: true })\n })\n \n try {\n return await Promise.race([dispatch_step(inner, input, child_ctx), deadline])\n } finally {\n clearTimeout(timer)\n }\n }\n\n const config_meta: Record<string, unknown> = { ms }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'timeout',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('timeout')\n","/**\n * loop: bounded iteration with carry-state.\n *\n * `loop({ init, body, guard?, finish, max_rounds, name? })` runs `body` up to\n * `max_rounds` times, threading `state` through each iteration. After every\n * `body` call, an optional `guard` step inspects (and may transform) the state\n * and decides whether to stop. When `guard.stop` is true, the loop exits\n * \"converged\"; otherwise it continues until `max_rounds`. `finish` projects\n * the final state to the loop's output value.\n *\n * Non-convergence is data, not error: when `max_rounds` is exhausted without\n * `guard` returning stop, the loop returns `{ value, converged: false, rounds }`,\n * the same convention `adversarial` and `consensus` use.\n *\n * Cancellation: between rounds the parent `ctx.abort` is honored; a pending\n * abort short-circuits and propagates `ctx.abort.reason`. The body and guard\n * receive the parent context unchanged; their own dispatch routes already\n * thread cancellation per the runner contract.\n */\n\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type LoopGuardResult<state> = {\n readonly stop: boolean\n readonly state: state\n}\n\nexport type LoopConfig<i, state, o> = {\n readonly name?: string\n readonly init: (input: i) => state\n readonly body: Step<state, state>\n readonly guard?: Step<state, LoopGuardResult<state>>\n readonly finish: (state: state, round: number) => o\n readonly max_rounds: number\n}\n\nexport type LoopResult<o> = {\n readonly value: o\n readonly converged: boolean\n readonly rounds: number\n}\n\nlet loop_counter = 0\n\n/**\n * Generate a unique step id, prefixed with the display name when one is set.\n */\nfunction next_id(name: string | undefined): string {\n loop_counter += 1\n return `${name ?? 'loop'}_${loop_counter}`\n}\n\n/**\n * Build a bounded iteration step with carry-state.\n *\n * Threads `state` through up to `max_rounds` runs of `body`, lets the\n * optional `guard` stop early, then projects the final state through\n * `finish`. Returns `{ value, converged, rounds }` so callers can tell a\n * converged run from an exhausted one.\n */\nexport function loop<i, state, o>(\n config: LoopConfig<i, state, o>,\n): Step<i, LoopResult<o>> {\n const { init, body, guard, finish, name } = config\n const rounds_limit = Math.max(1, Math.floor(config.max_rounds))\n const id = next_id(name)\n\n const run_fn = async (input: i, ctx: RunContext): Promise<LoopResult<o>> => {\n let state = init(input)\n let round = 0\n let converged = false\n \n while (round < rounds_limit) {\n throw_if_aborted(ctx)\n round += 1\n state = await dispatch_step(body, state, ctx)\n if (guard) {\n throw_if_aborted(ctx)\n const guard_out = await dispatch_step(guard, state, ctx)\n state = guard_out.state\n if (guard_out.stop) {\n converged = true\n break\n }\n }\n }\n \n const value = finish(state, round)\n return { value, converged, rounds: round }\n }\n\n const config_meta: Record<string, unknown> = { max_rounds: rounds_limit }\n if (name !== undefined) config_meta['display_name'] = name\n const children: ReadonlyArray<Step<unknown, unknown>> = guard\n ? [body, guard]\n : [body]\n\n return {\n id,\n kind: 'loop',\n children,\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('loop')\n","/**\n * compose: name a composite step.\n *\n * `compose(name, inner)` wraps any step and labels its trajectory span with\n * `name`. The inner step's own span (e.g. a `sequence`) appears as a child of\n * the compose span: the implementation tree is preserved while the user's\n * intent (\"this whole thing is an ensemble\") is surfaced in observability.\n *\n * Used by the composites package to make built-in patterns appear under\n * their familiar names, and available to library consumers who want their own\n * named composites to show up in logs as first-class components.\n *\n * The primitive's `kind` is always `'compose'`; the user-supplied label lives\n * in `config.display_name` and is the span name the dispatcher opens.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nlet compose_counter = 0\n\n/**\n * Generate a unique step id of the form `<name>_<n>`, using the user-supplied\n * label so compose ids read naturally in traces.\n */\nfunction next_id(name: string): string {\n compose_counter += 1\n return `${name}_${compose_counter}`\n}\n\n/**\n * Wrap `inner` in a named composite step.\n *\n * The step's `kind` is always `'compose'`; `name` becomes the\n * `display_name` used as the span label. Throws a `TypeError` when `name`\n * is not a non-empty string, catching the mistake at construction time.\n */\nexport function compose<i, o>(name: string, inner: Step<i, o>): Step<i, o> {\n if (typeof name !== 'string' || name.length === 0) {\n throw new TypeError('compose(name, inner): name must be a non-empty string')\n }\n const id = next_id(name)\n\n const run_fn = (input: i, ctx: RunContext): Promise<o> | o => dispatch_step(inner, input, ctx)\n\n return {\n id,\n kind: 'compose',\n children: [inner],\n config: { display_name: name },\n run: run_fn,\n }\n}\n\nregister_traced_kind('compose')\n","/**\n * checkpoint: persist and resume.\n *\n * `checkpoint(inner, { key })` checks a persistent store for a completed\n * result at `key` before running `inner`. On a hit, returns the stored\n * value. On a miss, runs `inner`, persists its result at `key`, and returns\n * it. Corrupted reads (store throws on `get`) are treated as a miss.\n *\n * Wrapping an anonymous inner step throws synchronously at construction time\n * with the message `checkpoint requires a named step; got anonymous`, because\n * a cached result must map back to a stable, identifiable step.\n */\n\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type CheckpointConfig<i> = {\n readonly name?: string\n readonly key: string | ((input: i) => string)\n}\n\nlet checkpoint_counter = 0\n\n/**\n * Generate a unique step id of the form `checkpoint_<n>`.\n */\nfunction next_id(): string {\n checkpoint_counter += 1\n return `checkpoint_${checkpoint_counter}`\n}\n\n/**\n * Wrap `inner` with persist-and-resume behavior keyed by `config.key`.\n *\n * `key` is a fixed string or a function of the input. Without a\n * `checkpoint_store` on the run context, the wrapper runs `inner` directly.\n * A stored `null` or `undefined` counts as a miss, so those values are\n * re-computed rather than replayed. Throws at construction time when `inner`\n * is anonymous.\n */\nexport function checkpoint<i, o>(inner: Step<i, o>, config: CheckpointConfig<i>): Step<i, o> {\n if (inner.anonymous === true) {\n throw new Error('checkpoint requires a named step; got anonymous')\n }\n\n const id = next_id()\n const key_spec = config.key\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const key = typeof key_spec === 'function' ? key_spec(input) : key_spec\n const store = ctx.checkpoint_store\n \n if (store) {\n let cached: unknown = undefined\n let hit = false\n try {\n cached = await store.get(key)\n hit = cached !== null && cached !== undefined\n } catch {\n hit = false\n }\n if (hit) {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return cached as o\n }\n }\n \n const result = await dispatch_step(inner, input, ctx)\n \n if (store) {\n await store.set(key, result)\n }\n \n return result\n }\n\n const config_meta: Record<string, unknown> = { key: key_spec }\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id,\n kind: 'checkpoint',\n children: [inner],\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('checkpoint')\n","/**\n * suspend: human-in-the-loop pause.\n *\n * `suspend({ id, on, resume_schema, combine })` pauses a flow waiting on\n * external input (a notification, an approval, an uploaded file). On first\n * encounter with no resume data, it calls `on(input, ctx)` (side effect) and\n * throws `suspended_error` carrying the run state. On resume (re-invocation\n * with `run_options.resume_data[id]` populated), the provided value is\n * validated against `resume_schema` and passed to `combine(input, resume,\n * ctx)`; the result is returned. Invalid resume data throws\n * `resume_validation_error` built from zod 4's flattened issue format.\n */\n\nimport { z } from 'zod'\nimport { resume_validation_error, suspended_error } from './errors.js'\nimport { dispatch_step, register_traced_kind } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\nexport type SuspendConfig<i, o, resume> = {\n readonly id: string\n readonly name?: string\n readonly on: (input: i, ctx: RunContext) => Promise<void> | void\n readonly resume_schema: z.ZodType<resume>\n readonly combine: (\n input: i,\n resume: resume,\n ctx: RunContext,\n ) => Promise<o> | o | Step<unknown, o>\n}\n\n/**\n * Structurally detect a `Step` returned from `combine`.\n *\n * `combine` may return either a plain value or a Step to dispatch; this local\n * check distinguishes the two without importing the shared helper.\n */\nfunction is_step(value: unknown): value is Step<unknown, unknown> {\n if (typeof value !== 'object' || value === null) return false\n if (!('id' in value) || !('kind' in value) || !('run' in value)) return false\n const { id, kind, run } = value\n return typeof id === 'string' && typeof kind === 'string' && typeof run === 'function'\n}\n\n/**\n * Build a human-in-the-loop pause step.\n *\n * First run fires the `on` side effect and throws `suspended_error`; a resume\n * run validates `resume_data[id]` against `resume_schema` and feeds it to\n * `combine`. The step's id is the user-supplied suspend id so resume data can\n * be addressed to it.\n */\nexport function suspend<i, o, resume>(config: SuspendConfig<i, o, resume>): Step<i, o> {\n const suspend_id = config.id\n const on_fn = config.on\n const resume_schema = config.resume_schema\n const combine_fn = config.combine\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n const resume_value = ctx.resume_data?.[suspend_id]\n \n if (resume_value === undefined) {\n await on_fn(input, ctx)\n throw new suspended_error(suspend_id, { input })\n }\n \n const parsed = resume_schema.safeParse(resume_value)\n if (!parsed.success) {\n const issues = z.flattenError(parsed.error)\n throw new resume_validation_error(\n `resume data for ${suspend_id} failed validation`,\n issues,\n )\n }\n \n const result = await combine_fn(input, parsed.data, ctx)\n if (is_step(result)) {\n return dispatch_step(result, input, ctx)\n }\n return result\n }\n\n const config_meta: Record<string, unknown> = { id: suspend_id }\n if (config.name !== undefined) config_meta['display_name'] = config.name\n\n return {\n id: suspend_id,\n kind: 'suspend',\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('suspend')\n","/**\n * scope / stash / use: named state.\n *\n * `scope([...children])` introduces a scope-local `Map<string, unknown>` and\n * runs its children in order, chaining outputs like `sequence`. `stash(key,\n * source)` runs `source`, writes its output to the scope's state at `key`,\n * and passes the value through. `use(keys, fn)` reads the named values from\n * state and runs `fn` with the projection. Inner scopes inherit outer state;\n * writes only affect the inner map.\n *\n * Using `stash` or `use` outside a `scope` is a runtime error with a clear\n * message.\n */\n\nimport { dispatch_step, register_traced_kind, throw_if_aborted } from './runner.js'\nimport type { RunContext, Step } from './types.js'\n\ntype AnyStep = Step<unknown, unknown>\n\ntype LastOutput<children> = children extends readonly [...unknown[], Step<unknown, infer o>]\n ? o\n : children extends readonly [Step<unknown, infer o>]\n ? o\n : unknown\n\nconst scope_states = new WeakSet<ReadonlyMap<string, unknown>>()\n\n/**\n * Check whether a state map was created by `scope`.\n *\n * The root `RunContext.state` map is not registered in `scope_states`, which\n * is how `stash`/`use` detect they are running outside any scope.\n */\nfunction is_scope_state(state: ReadonlyMap<string, unknown>): boolean {\n return scope_states.has(state)\n}\n\nlet scope_counter = 0\nlet stash_counter = 0\nlet use_counter = 0\n\n/**\n * Generate a unique step id of the form `scope_<n>`.\n */\nfunction next_scope_id(): string {\n scope_counter += 1\n return `scope_${scope_counter}`\n}\n\n/**\n * Generate a unique step id of the form `stash_<n>`.\n */\nfunction next_stash_id(): string {\n stash_counter += 1\n return `stash_${stash_counter}`\n}\n\n/**\n * Generate a unique step id of the form `use_<n>`.\n */\nfunction next_use_id(): string {\n use_counter += 1\n return `use_${use_counter}`\n}\n\nexport type ScopeOptions = {\n readonly name?: string\n}\n\nexport type StashOptions = {\n readonly name?: string\n}\n\nexport type UseOptions = {\n readonly name?: string\n}\n\n/**\n * Build a step that runs children in sequence under a fresh state map.\n *\n * The local map is seeded from the parent state (inner scopes read outer\n * values) and registered so `stash`/`use` inside recognize it; writes stay\n * local to this scope. Outputs chain like `sequence`.\n */\nexport function scope<const children extends readonly AnyStep[]>(\n children: children,\n options?: ScopeOptions,\n): Step<unknown, LastOutput<children>> {\n const id = next_scope_id()\n const children_ref = children\n\n const run_fn = async (input: unknown, ctx: RunContext): Promise<unknown> => {\n const local = new Map<string, unknown>(ctx.state)\n scope_states.add(local)\n const scope_ctx: RunContext = { ...ctx, state: local }\n \n let acc: unknown = input\n for (const child of children_ref) {\n throw_if_aborted(scope_ctx)\n acc = await dispatch_step(child, acc, scope_ctx)\n }\n return acc\n }\n\n const config_meta: Record<string, unknown> | undefined =\n options?.name === undefined ? undefined : { display_name: options.name }\n\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return {\n id,\n kind: 'scope',\n children,\n ...(config_meta ? { config: config_meta } : {}),\n run: run_fn,\n } as Step<unknown, LastOutput<children>>\n}\n\n/**\n * Build a step that stores its source's output in scope state at `key`.\n *\n * Passes the value through unchanged so it composes mid-chain. Throws when\n * run outside a `scope`.\n */\nexport function stash<i, v>(\n key: string,\n source: Step<i, v>,\n options?: StashOptions,\n): Step<i, v> {\n const id = next_stash_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<v> => {\n if (!is_scope_state(ctx.state)) {\n throw new Error('stash() may only appear inside scope(); got: top-level')\n }\n const value = await dispatch_step(source, input, ctx)\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const state = ctx.state as Map<string, unknown>\n state.set(key, value)\n return value\n }\n\n const config_meta: Record<string, unknown> = { key }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'stash',\n children: [source],\n config: config_meta,\n run: run_fn,\n }\n}\n\n/**\n * Build a step that projects named scope values into a function call.\n *\n * Reads `keys` from scope state (missing keys project as `undefined`) and\n * invokes `fn(projection, input, ctx)`. Throws when run outside a `scope`.\n */\nexport function use<const keys extends readonly string[], i, o>(\n keys: keys,\n fn: (\n state: { [k in keys[number]]: unknown },\n input: i,\n ctx: RunContext,\n ) => Promise<o> | o,\n options?: UseOptions,\n): Step<i, o> {\n const id = next_use_id()\n\n const run_fn = async (input: i, ctx: RunContext): Promise<o> => {\n if (!is_scope_state(ctx.state)) {\n throw new Error('use() may only appear inside scope(); got: top-level')\n }\n const projection: Record<string, unknown> = {}\n for (const k of keys) {\n projection[k] = ctx.state.get(k)\n }\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n return fn(projection as { [k in keys[number]]: unknown }, input, ctx)\n }\n\n const config_meta: Record<string, unknown> = { keys: [...keys] }\n if (options?.name !== undefined) config_meta['display_name'] = options.name\n\n return {\n id,\n kind: 'use',\n config: config_meta,\n run: run_fn,\n }\n}\n\nregister_traced_kind('scope')\n\nregister_traced_kind('stash')\n\nregister_traced_kind('use')\n","/**\n * Closed registry of every `Step.kind` produced by the composition layer.\n *\n * Studio (and any other consumer that needs to enumerate primitives: palette,\n * docs, code generation) can rely on this being the exhaustive set. New\n * primitives must add their kind here. The `step_kinds_cover_runner` contract\n * test in `step_kinds.test.ts` asserts every dispatch handler corresponds to a\n * kind listed here.\n */\n\nexport const STEP_KINDS = [\n 'step',\n 'sequence',\n 'parallel',\n 'branch',\n 'map',\n 'pipe',\n 'retry',\n 'fallback',\n 'timeout',\n 'loop',\n 'compose',\n 'adversarial',\n 'ensemble',\n 'tournament',\n 'consensus',\n 'checkpoint',\n 'suspend',\n 'scope',\n 'stash',\n 'use',\n] as const\n\nexport type StepKind = (typeof STEP_KINDS)[number]\n\n/**\n * Check whether a value is one of the registered `Step.kind` strings.\n */\nexport function is_step_kind(value: unknown): value is StepKind {\n return typeof value === 'string' && (STEP_KINDS as readonly string[]).includes(value)\n}\n","/**\n * Wire-format schema for trajectory events.\n *\n * `TrajectoryEvent` (in `types.ts`) is the loose internal type — any code that\n * calls `trajectory.record(event)` or `start_span(name, meta)` produces values\n * conforming to it. This file defines the *narrower* shapes that the studio\n * (and any other downstream consumer) can parse out of the wire stream:\n *\n * span_start — composer span open\n * span_end — composer span close\n * emit — user-emitted event from inside a step (ctx.emit)\n * <other> — falls through `custom_event_schema`, which only requires a\n * string `kind` and tolerates any extra fields\n *\n * The discriminated union is **ordered**: well-known shapes are tried before\n * the permissive `custom` schema, so a `{ kind: 'span_start', ... }` event\n * always parses as `SpanStartEvent`, never as `CustomTrajectoryEvent`.\n *\n * Every well-known schema and `custom_event_schema` use `.passthrough()` so\n * additional fields (e.g. `run_id`, `id`, provider-specific metadata) survive\n * a parse / re-serialize round-trip without loss.\n */\n\nimport { z } from 'zod'\n\nexport const span_start_event_schema = z\n .object({\n kind: z.literal('span_start'),\n span_id: z.string(),\n name: z.string(),\n })\n .passthrough()\n\nexport const span_end_event_schema = z\n .object({\n kind: z.literal('span_end'),\n span_id: z.string(),\n })\n .passthrough()\n\nexport const emit_event_schema = z\n .object({\n kind: z.literal('emit'),\n })\n .passthrough()\n\nexport const custom_event_schema = z\n .object({\n kind: z.string(),\n })\n .passthrough()\n\nexport const trajectory_event_schema = z.union([\n span_start_event_schema,\n span_end_event_schema,\n emit_event_schema,\n custom_event_schema,\n])\n\nexport type SpanStartEvent = z.infer<typeof span_start_event_schema>\nexport type SpanEndEvent = z.infer<typeof span_end_event_schema>\nexport type EmitEvent = z.infer<typeof emit_event_schema>\nexport type CustomTrajectoryEvent = z.infer<typeof custom_event_schema>\nexport type ParsedTrajectoryEvent = z.infer<typeof trajectory_event_schema>\n","/**\n * Public surface for core.\n *\n * Side-effect imports ensure every composer registers itself with the runner\n * at module load. Importing anything from `core` populates the\n * dispatch table with the core primitives. Built-in composites\n * (adversarial, ensemble, tournament, consensus) live in composites\n * and surface through the umbrella package.\n */\n\nimport flow_schema_data from './flow-schema.json' with { type: 'json' }\n\nexport { run } from './runner.js'\nexport { step } from './step.js'\nexport { describe } from './describe.js'\nexport type { DescribeOptions, FlowNode, FlowValue } from './describe.js'\nexport { sequence } from './sequence.js'\nexport { parallel } from './parallel.js'\nexport { branch } from './branch.js'\nexport { map } from './map.js'\nexport { pipe } from './pipe.js'\nexport { retry } from './retry.js'\nexport { fallback } from './fallback.js'\nexport { timeout } from './timeout.js'\nexport { loop } from './loop.js'\nexport type { LoopConfig, LoopGuardResult, LoopResult } from './loop.js'\nexport { compose } from './compose.js'\nexport { checkpoint } from './checkpoint.js'\nexport { suspend } from './suspend.js'\nexport { scope, stash, use } from './scope.js'\n\nexport {\n aborted_error,\n describe_cycle_error,\n resume_validation_error,\n suspended_error,\n timeout_error,\n} from './errors.js'\n\nexport type {\n CheckpointStore,\n RunContext,\n Step,\n StepMetadata,\n TrajectoryEvent,\n TrajectoryLogger,\n} from './types.js'\n\nexport { is_step_kind, STEP_KINDS } from './step_kinds.js'\nexport type { StepKind } from './step_kinds.js'\n\nexport {\n custom_event_schema,\n emit_event_schema,\n span_end_event_schema,\n span_start_event_schema,\n trajectory_event_schema,\n} from './trajectory.js'\nexport type {\n CustomTrajectoryEvent,\n EmitEvent,\n ParsedTrajectoryEvent,\n SpanEndEvent,\n SpanStartEvent,\n} from './trajectory.js'\n\nexport { flow_schema_data as flow_schema }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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O,GAAG;CACtE;CAEA,MAAM,cAAuC,EAAE,MAAM,CAAC,GAAG,IAAI,EAAE;CAC/D,IAAI,SAAS,SAAS,KAAA,GAAW,YAAY,kBAAkB,QAAQ;CAEvE,OAAO;EACL;EACA,MAAM;EACN,QAAQ;EACR,KAAK;CACP;AACF;AAEA,qBAAqB,OAAO;AAE5B,qBAAqB,OAAO;AAE5B,qBAAqB,KAAK;;;;;;;;;;;;AC3L1B,MAAa,aAAa;CACxB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;;AAOA,SAAgB,aAAa,OAAmC;CAC9D,OAAO,OAAO,UAAU,YAAa,WAAiC,SAAS,KAAK;AACtF;;;;;;;;;;;;;;;;;;;;;;;;;ACfA,MAAa,0BAA0B,EACpC,OAAO;CACN,MAAM,EAAE,QAAQ,YAAY;CAC5B,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;AACjB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,wBAAwB,EAClC,OAAO;CACN,MAAM,EAAE,QAAQ,UAAU;CAC1B,SAAS,EAAE,OAAO;AACpB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,oBAAoB,EAC9B,OAAO,EACN,MAAM,EAAE,QAAQ,MAAM,EACxB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,sBAAsB,EAChC,OAAO,EACN,MAAM,EAAE,OAAO,EACjB,CAAC,CAAC,CACD,YAAY;AAEf,MAAa,0BAA0B,EAAE,MAAM;CAC7C;CACA;CACA;CACA;AACF,CAAC"}
|
|
@@ -758,16 +758,18 @@ type RetryConfig = {
|
|
|
758
758
|
declare function retry<i, o>(inner: Step<i, o>, config: RetryConfig): Step<i, o>;
|
|
759
759
|
//#endregion
|
|
760
760
|
//#region src/core/fallback.d.ts
|
|
761
|
-
type FallbackOptions = {
|
|
761
|
+
type FallbackOptions<i = unknown> = {
|
|
762
762
|
readonly name?: string;
|
|
763
|
+
readonly handoff?: (input: i, err: unknown) => i;
|
|
763
764
|
};
|
|
764
765
|
/**
|
|
765
766
|
* Build a primary-or-backup step.
|
|
766
767
|
*
|
|
767
|
-
* Runs `primary`; on an application error runs `backup` with the same input
|
|
768
|
-
*
|
|
768
|
+
* Runs `primary`; on an application error runs `backup` with the same input,
|
|
769
|
+
* or with `handoff(input, err)` when the option is set. Control-flow signals
|
|
770
|
+
* propagate without triggering the backup or the handoff.
|
|
769
771
|
*/
|
|
770
|
-
declare function fallback<i, o>(primary: Step<i, o>, backup: Step<i, o>, options?: FallbackOptions): Step<i, o>;
|
|
772
|
+
declare function fallback<i, o>(primary: Step<i, o>, backup: Step<i, o>, options?: FallbackOptions<i>): Step<i, o>;
|
|
771
773
|
//#endregion
|
|
772
774
|
//#region src/core/timeout.d.ts
|
|
773
775
|
type TimeoutOptions = {
|
|
@@ -988,4 +990,4 @@ type CustomTrajectoryEvent = z.infer<typeof custom_event_schema>;
|
|
|
988
990
|
type ParsedTrajectoryEvent = z.infer<typeof trajectory_event_schema>;
|
|
989
991
|
//#endregion
|
|
990
992
|
export { fallback as A, describe as B, checkpoint as C, LoopResult as D, LoopGuardResult as E, parallel as F, Step as G, run as H, sequence as I, TrajectoryLogger as J, StepMetadata as K, DescribeOptions as L, pipe as M, map as N, loop as O, branch as P, FlowNode as R, suspend as S, LoopConfig as T, CheckpointStore as U, step as V, RunContext as W, __json_default_export as Y, suspended_error as _, SpanStartEvent as a, stash as b, span_end_event_schema as c, STEP_KINDS as d, StepKind as f, resume_validation_error as g, describe_cycle_error as h, SpanEndEvent as i, retry as j, timeout as k, span_start_event_schema as l, aborted_error as m, EmitEvent as n, custom_event_schema as o, is_step_kind as p, TrajectoryEvent as q, ParsedTrajectoryEvent as r, emit_event_schema as s, CustomTrajectoryEvent as t, trajectory_event_schema as u, timeout_error as v, compose as w, use as x, scope as y, FlowValue as z };
|
|
991
|
-
//# sourceMappingURL=index-
|
|
993
|
+
//# sourceMappingURL=index-C2ayBpzS.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { J as TrajectoryLogger } from "./index-
|
|
1
|
+
import { J as TrajectoryLogger } from "./index-C2ayBpzS.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
|
|
4
4
|
//#region src/engine/providers/claude_cli/types.d.ts
|
|
@@ -724,4 +724,4 @@ declare class incomplete_generation_error extends Error {
|
|
|
724
724
|
}
|
|
725
725
|
//#endregion
|
|
726
726
|
export { ProviderCapability as $, Pricing as A, ToolApprovalHandler as B, FinishReason as C, PrepareStepContext as D, Message as E, RetryFailureKind as F, TurnResult as G, ToolCallRecord as H, RetryPolicy as I, AiSdkProviderAdapter as J, UsageTotals as K, StepRecord as L, ProviderConfigMap as M, ProviderInit as N, PrepareStepHook as O, ResolvedModel as P, ProviderAdapter as Q, StreamChunk as R, EngineDefaults as S, GenerateResult as T, ToolExecContext as U, ToolApprovalRequest as V, TurnRequest as W, ExternalAgentAdapter as X, EffortTranslation as Y, NativeProviderAdapter as Z, AssistantContentPart as _, model_required_error as a, Engine as b, provider_capability_error as c, rate_limit_error as d, ProviderFactory as et, schema_validation_error as f, AiSdkTelemetrySettings as g, create_engine as h, incomplete_generation_error as i, PricingTable as j, PrepareStepResult as k, provider_error as l, tool_error as m, engine_config_error as n, RawProviderUsage as nt, on_chunk_error as o, tool_approval_denied_error as p, UserContentPart as q, engine_disposed_error as r, default_normalize_usage as rt, provider_auth_error as s, claude_cli_error as t, ProviderTransport as tt, provider_not_configured_error as u, CostBreakdown as v, GenerateOptions as w, EngineConfig as x, EffortLevel as y, Tool as z };
|
|
727
|
-
//# sourceMappingURL=index-
|
|
727
|
+
//# sourceMappingURL=index-CHtfOfEF.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as fallback, B as describe, C as checkpoint, D as LoopResult, E as LoopGuardResult, F as parallel, G as Step, H as run, I as sequence, J as TrajectoryLogger, K as StepMetadata, L as DescribeOptions, M as pipe, N as map, O as loop, P as branch, R as FlowNode, S as suspend, T as LoopConfig, U as CheckpointStore, V as step, W as RunContext, Y as __json_default_export, _ as suspended_error, a as SpanStartEvent, b as stash, c as span_end_event_schema, d as STEP_KINDS, f as StepKind, g as resume_validation_error, h as describe_cycle_error, i as SpanEndEvent, j as retry, k as timeout, l as span_start_event_schema, m as aborted_error, n as EmitEvent, o as custom_event_schema, p as is_step_kind, q as TrajectoryEvent, r as ParsedTrajectoryEvent, s as emit_event_schema, t as CustomTrajectoryEvent, u as trajectory_event_schema, v as timeout_error, w as compose, x as use, y as scope, z as FlowValue } from "./index-
|
|
2
|
-
import { $ as ProviderCapability, A as Pricing, B as ToolApprovalHandler, C as FinishReason, D as PrepareStepContext, E as Message, F as RetryFailureKind, G as TurnResult, H as ToolCallRecord, I as RetryPolicy, J as AiSdkProviderAdapter, K as UsageTotals, L as StepRecord, M as ProviderConfigMap, N as ProviderInit, O as PrepareStepHook, P as ResolvedModel, Q as ProviderAdapter, R as StreamChunk, S as EngineDefaults, T as GenerateResult, U as ToolExecContext, V as ToolApprovalRequest, W as TurnRequest, X as ExternalAgentAdapter, Y as EffortTranslation, Z as NativeProviderAdapter, _ as AssistantContentPart, a as model_required_error, b as Engine, c as provider_capability_error, d as rate_limit_error, et as ProviderFactory, f as schema_validation_error, g as AiSdkTelemetrySettings, h as create_engine, i as incomplete_generation_error, j as PricingTable, k as PrepareStepResult, l as provider_error, m as tool_error, n as engine_config_error, nt as RawProviderUsage, o as on_chunk_error, p as tool_approval_denied_error, q as UserContentPart, r as engine_disposed_error, rt as default_normalize_usage, s as provider_auth_error, t as claude_cli_error, tt as ProviderTransport, u as provider_not_configured_error, v as CostBreakdown, w as GenerateOptions, x as EngineConfig, y as EffortLevel, z as Tool } from "./index-
|
|
1
|
+
import { A as fallback, B as describe, C as checkpoint, D as LoopResult, E as LoopGuardResult, F as parallel, G as Step, H as run, I as sequence, J as TrajectoryLogger, K as StepMetadata, L as DescribeOptions, M as pipe, N as map, O as loop, P as branch, R as FlowNode, S as suspend, T as LoopConfig, U as CheckpointStore, V as step, W as RunContext, Y as __json_default_export, _ as suspended_error, a as SpanStartEvent, b as stash, c as span_end_event_schema, d as STEP_KINDS, f as StepKind, g as resume_validation_error, h as describe_cycle_error, i as SpanEndEvent, j as retry, k as timeout, l as span_start_event_schema, m as aborted_error, n as EmitEvent, o as custom_event_schema, p as is_step_kind, q as TrajectoryEvent, r as ParsedTrajectoryEvent, s as emit_event_schema, t as CustomTrajectoryEvent, u as trajectory_event_schema, v as timeout_error, w as compose, x as use, y as scope, z as FlowValue } from "./index-C2ayBpzS.js";
|
|
2
|
+
import { $ as ProviderCapability, A as Pricing, B as ToolApprovalHandler, C as FinishReason, D as PrepareStepContext, E as Message, F as RetryFailureKind, G as TurnResult, H as ToolCallRecord, I as RetryPolicy, J as AiSdkProviderAdapter, K as UsageTotals, L as StepRecord, M as ProviderConfigMap, N as ProviderInit, O as PrepareStepHook, P as ResolvedModel, Q as ProviderAdapter, R as StreamChunk, S as EngineDefaults, T as GenerateResult, U as ToolExecContext, V as ToolApprovalRequest, W as TurnRequest, X as ExternalAgentAdapter, Y as EffortTranslation, Z as NativeProviderAdapter, _ as AssistantContentPart, a as model_required_error, b as Engine, c as provider_capability_error, d as rate_limit_error, et as ProviderFactory, f as schema_validation_error, g as AiSdkTelemetrySettings, h as create_engine, i as incomplete_generation_error, j as PricingTable, k as PrepareStepResult, l as provider_error, m as tool_error, n as engine_config_error, nt as RawProviderUsage, o as on_chunk_error, p as tool_approval_denied_error, q as UserContentPart, r as engine_disposed_error, rt as default_normalize_usage, s as provider_auth_error, t as claude_cli_error, tt as ProviderTransport, u as provider_not_configured_error, v as CostBreakdown, w as GenerateOptions, x as EngineConfig, y as EffortLevel, z as Tool } from "./index-CHtfOfEF.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
|
|
5
5
|
//#region src/composites/adversarial.d.ts
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as timeout_error, C as describe, D as describe_cycle_error, E as aborted_error, O as resume_validation_error, S as sequence, T as run, _ as retry, a as trajectory_event_schema, b as branch, c as scope, d as suspend, f as checkpoint, g as fallback, h as timeout, i as span_start_event_schema, j as flow_schema_default, k as suspended_error, l as stash, m as loop, n as emit_event_schema, o as STEP_KINDS, p as compose, r as span_end_event_schema, s as is_step_kind, t as custom_event_schema, u as use, v as pipe, w as step, x as parallel, y as map } from "./core-
|
|
1
|
+
import { A as timeout_error, C as describe, D as describe_cycle_error, E as aborted_error, O as resume_validation_error, S as sequence, T as run, _ as retry, a as trajectory_event_schema, b as branch, c as scope, d as suspend, f as checkpoint, g as fallback, h as timeout, i as span_start_event_schema, j as flow_schema_default, k as suspended_error, l as stash, m as loop, n as emit_event_schema, o as STEP_KINDS, p as compose, r as span_end_event_schema, s as is_step_kind, t as custom_event_schema, u as use, v as pipe, w as step, x as parallel, y as map } from "./core-Dit3Rv9J.js";
|
|
2
2
|
import { a as http_logger, n as tee_logger, o as filesystem_logger } from "./adapters-CJnu1687.js";
|
|
3
3
|
import { createHash } from "node:crypto";
|
|
4
4
|
import { z } from "zod";
|
package/dist/mcp.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as Step, J as TrajectoryLogger } from "./index-
|
|
2
|
-
import { z as Tool } from "./index-
|
|
1
|
+
import { G as Step, J as TrajectoryLogger } from "./index-C2ayBpzS.js";
|
|
2
|
+
import { z as Tool } from "./index-CHtfOfEF.js";
|
|
3
3
|
import { z } from "zod";
|
|
4
4
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
5
5
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
package/dist/mcp.js
CHANGED
package/dist/otel.d.ts
CHANGED
package/dist/stdio.d.ts
CHANGED
package/dist/stdio.js
CHANGED
package/dist/ui.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fascicle",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.2",
|
|
4
4
|
"description": "Compose agents like plain values. A TypeScript toolkit that wires LLM calls, tools, and functions into typed steps over eight providers. No framework, no ambient state.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agents",
|
|
@@ -121,12 +121,12 @@
|
|
|
121
121
|
},
|
|
122
122
|
"peerDependencies": {
|
|
123
123
|
"@ai-sdk/amazon-bedrock": "^5.0.0",
|
|
124
|
-
"@aws-sdk/credential-providers": "^3.0.0",
|
|
125
124
|
"@ai-sdk/anthropic": "^4.0.0",
|
|
126
125
|
"@ai-sdk/google": "^4.0.0",
|
|
127
126
|
"@ai-sdk/openai": "^4.0.0",
|
|
128
127
|
"@ai-sdk/openai-compatible": "^3.0.0",
|
|
129
128
|
"@ai-sdk/otel": "^1.0.0",
|
|
129
|
+
"@aws-sdk/credential-providers": "^3.0.0",
|
|
130
130
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
131
131
|
"@openrouter/ai-sdk-provider": "^3.0.0",
|
|
132
132
|
"@opentelemetry/api": "^1.9.0",
|
|
@@ -178,7 +178,7 @@
|
|
|
178
178
|
"@stryker-mutator/vitest-runner": "9.6.1",
|
|
179
179
|
"@types/node": "26.1.0",
|
|
180
180
|
"@vitest/coverage-v8": "4.1.10",
|
|
181
|
-
"checkride": "0.
|
|
181
|
+
"checkride": "0.12.1",
|
|
182
182
|
"cspell": "10.0.1",
|
|
183
183
|
"fallow": "3.6.0",
|
|
184
184
|
"markdownlint-cli2": "0.23.0",
|