fascicle 0.10.1 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/README.md +9 -9
- package/dist/adapters.d.ts +1 -1
- package/dist/agents.d.ts +4 -4
- package/dist/agents.js +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/{core-DNH8ddMT.js → core-DkuJqLwd.js} +182 -96
- package/dist/core-DkuJqLwd.js.map +1 -0
- package/dist/index.d.ts +1124 -5
- package/dist/index.js +467 -939
- package/dist/index.js.map +1 -1
- package/dist/invoke-D9pxbZcu.js +451 -0
- package/dist/invoke-D9pxbZcu.js.map +1 -0
- package/dist/mcp.d.ts +25 -13
- package/dist/mcp.js +203 -121
- package/dist/mcp.js.map +1 -1
- package/dist/otel.d.ts +1 -1
- package/dist/stdio.d.ts +4 -4
- package/dist/stdio.js +30 -12
- package/dist/stdio.js.map +1 -1
- package/dist/{index-BNgtkeUf.d.ts → types-B3HIsBBD.d.ts} +7 -133
- package/dist/types-BCtKsxrX.d.ts +149 -0
- package/dist/types-BDSbSUAO.d.ts +63 -0
- package/dist/types-kO1JoGNZ.js +253 -0
- package/dist/types-kO1JoGNZ.js.map +1 -0
- package/dist/ui.d.ts +2 -2
- package/package.json +16 -5
- package/dist/core-DNH8ddMT.js.map +0 -1
- package/dist/index-SkPG_Rew.d.ts +0 -991
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.10.3 — 2026-08-12
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- **`bench` no longer scores a suspended or cancelled run as a set of failed cases.** A `suspended_error` from a human-approval gate inside a benched flow was caught by the same handler as an application failure and recorded as `{ ok: false, error: 'suspended at ...' }`, so a paused case scored a zero and moved `pass_rate` without anything reporting that the flow never finished. `bench` has no resume path, so a suspend inside a benched flow is a usage error: it now rejects with `bench_suspend_error` (exported from `fascicle`), carrying `case_id` and `suspend_id` so the offending case is named rather than searched for. The judge loop's `catch { continue }` abstain path had the same hole and gets the same guard. **Breaking** for anyone benching a flow that suspends: those runs rejected nothing before and reject now, which is the point, since the old report was wrong.
|
|
8
|
+
|
|
9
|
+
- **The documented install for every `ai_sdk` provider was missing `ai`, and openrouter's named the wrong package.** `docs/configuration.md`'s seven per-provider snippets said `pnpm add @ai-sdk/anthropic` alone. The official `@ai-sdk/*` packages peer-depend on `zod` rather than on `ai`, so once `ai` became optional nothing pulled it in transitively and each of those lines produced an install that could not run a turn. Correcting them surfaced a second, older defect in the same block: openrouter was documented as `@ai-sdk/openai-compatible`, but the adapter loads `@openrouter/ai-sdk-provider`, so the documented install could never satisfy it. `docs/providers.md`'s peer table is the authority for both.
|
|
10
|
+
|
|
11
|
+
- **`fascicle/ui` never named the peer it requires.** The subpath imports `ai` statically (it speaks the AI SDK's UI message-stream protocol), but none of the places documenting it said so. With `ai` optional and `pnpm add fascicle` now the whole install line, following those docs produced a raw `ERR_MODULE_NOT_FOUND`. `docs/api-reference.md` now separates the two peer-bearing subpaths by failure mode: `fascicle/mcp` loads its SDK dynamically and reports `mcp_sdk_missing_error`, while `fascicle/ui` fails at module resolution.
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- **`ai` is now an optional peer dependency.** It was the last mandatory peer on a package whose own `dependencies` block is empty, so `pnpm add fascicle` forced an install of the AI SDK core even for a `transport: 'native'`-only or `claude_cli`-only setup that never imports it. `ai` is loaded lazily from the one `ai_sdk` turn seam (`src/engine/generate.ts`), same as every `@ai-sdk/*` provider package, so it drops to `peerDependenciesMeta: { ai: { optional: true } }` alongside them; a missing `ai` reports through the same `load_optional_peer` message step 7 named it in. `docs/providers.md` and `README.md` now show `ai` alongside each `ai_sdk`-kind provider's install snippet, since the official `@ai-sdk/*` packages only peer-depend on `zod`, not `ai` — installing just `@ai-sdk/anthropic` no longer pulls `ai` in transitively now that fascicle's own peer is optional.
|
|
16
|
+
|
|
17
|
+
- **`BenchOptions` gains `abort`, and a cancelled bench rejects instead of returning a report.** `bench` accepted no signal at all and defaulted `install_signal_handlers` to `false`, so there was no cancellation path through a bench run. The signal now forwards to every per-case `run` and is re-checked before each case is claimed, so an abort halts scheduling at the queue rather than only cancelling work already in flight, and it is checked once more before the report is built, so neither a full fan-out (no queue to halt) nor a flow that ignores `ctx.abort` can yield a report for a run the caller cancelled. An `aborted_error` raised inside a case or a judge propagates rather than being flattened into `ok: false`. Abort reasons follow core's shape: an `Error` reason propagates verbatim, anything else is wrapped in `aborted_error`.
|
|
18
|
+
|
|
19
|
+
### Changed
|
|
20
|
+
|
|
21
|
+
- **`zod` is now an optional peer dependency, and fascicle has zero mandatory peers.** It was the last one: `ai` went optional earlier in this release, and the Standard Schema migration removed every internal zod import from `src/` except the type-only one in `src/mcp/serve.ts` (`McpServer.registerTool` accepts nothing else). `zod` drops to `peerDependenciesMeta: { zod: { optional: true } }` alongside every other peer, so `pnpm add fascicle` alone builds and runs a flow against `transport: 'native'` or `claude_cli` — no AI SDK, no schema library. Schemas accept any Standard Schema implementation (zod, ArkType, Valibot, …); installing zod remains necessary only if that is the vendor you choose. The `no-core-npm-dep-except-zod` and `no-engine-npm-dep-except-ai-zod` ast-grep rules, which permitted an npm dependency neither zone still uses, are replaced by `no-core-npm-dep` and `no-engine-npm-dep`: core and engine (outside `providers/`) now depend on no npm package at all, matching the `#schema`/`#policy` bottom-of-DAG zones that already carry the vendor-specific code. `README.md`, `docs/getting-started.md`, `VALUES.md`, and `SECURITY.md` state the zero-mandatory-peers posture directly.
|
|
22
|
+
|
|
23
|
+
- **The trajectory wire format is now read through hand-written guards instead of zod schemas.** The five exported schemas — `trajectory_event_schema`, `span_start_event_schema`, `span_end_event_schema`, `emit_event_schema`, and `custom_event_schema` — put a zod object on the published surface of a package that is dropping zod to an optional peer, so a consumer who never writes a zod schema still resolved zod to read a trajectory file. They are replaced by `parse_trajectory_event(value)`, which returns the same `safeParse` shape (`{ success: true, data }` / `{ success: false, error }`), and four type guards: `is_span_start_event`, `is_span_end_event`, `is_emit_event`, `is_custom_trajectory_event`. What parses is unchanged, deliberately down to the permissiveness: an event is any non-array object carrying a string `kind`, so a `span_start` line missing its `span_id` is still accepted as an event (the old ordered union fell through to `custom_event_schema` for exactly that case) and the well-known guards are recognizers layered on top rather than gates. `is_custom_trajectory_event` therefore answers `true` for well-known kinds too, matching `custom_event_schema` before it. Two visible differences: a successful parse now hands the wire value straight back rather than a shallow zod clone, so nothing is dropped on the way through — including a literal `__proto__` key, which zod's clone silently swallowed and which now rides along as the inert own property `JSON.parse` produced (no prototype is mutated either way) — and the failure `error` is a plain `Error` rather than a `ZodError`, so code reading `.issues` off it needs the line itself instead (the viewer's `on_parse_error` already receives that as its second argument). The exported types keep their names (`SpanStartEvent`, `SpanEndEvent`, `EmitEvent`, `CustomTrajectoryEvent`, `ParsedTrajectoryEvent`) and shapes, joined by `TrajectoryParseResult`. **Breaking:** any of the five schema exports, or `ZodError`-shaped handling of a rejected line.
|
|
24
|
+
|
|
25
|
+
- **Every schema fascicle validates now runs through Standard Schema, so validation failures read the same whichever library produced them.** Tool inputs, structured-output parsing, `suspend` resume data, and both `run_stdio` IO checks called zod's `safeParse` directly and reported whatever zod handed back. They now go through the vendor-neutral `~standard.validate` interface, so an ArkType or Valibot schema validates on the same path a zod one does. Two things consumers can see change shape. The message fed back to a model on a rejected tool call (and the schema repair prompt, and `schema_validation_error.message`) was zod's own multi-line JSON dump of its issue objects; it is now one line of `path: message` clauses with dotted paths — `city: Invalid input: expected string, received number; opts.deep: Invalid input: expected boolean, received string`. And the `cause` on a `run_stdio` `validate_input` / `validate_output` failure now carries `{ message, path }` issues instead of zod's issue objects, so the `code` and `expected` fields are gone from that JSON. Nothing that was validated before validates differently: only the report changed.
|
|
26
|
+
|
|
27
|
+
- **Schema failures are now reported vendor-neutrally end to end, closing out the zod-shaped naming and reporting left over from the Standard Schema migration.** `schema_validation_error` (thrown by `generate` and the `claude_cli` adapter after repair attempts are exhausted) carried a field named `.zod_error`; it is renamed `.schema_issues` and now holds the vendor-neutral `{ message, path? }` issue list directly rather than an `Error` wrapping a pre-formatted string. The engine's `schema_validation_failed` trajectory event's `zod_issues` field is renamed `schema_issues` (same one-line formatted string as before). `suspend`'s `resume_validation_error.issues` — called out above as unchanged — now also carries the vendor-neutral issue list instead of a hand-rolled reproduction of zod's `{ formErrors, fieldErrors }` shape. The internal `format_zod_error` helper is gone; formatting goes through `format_schema_issues` everywhere. **Breaking:** code reading `schema_validation_error.zod_error`, `resume_validation_error.issues.formErrors` / `.fieldErrors`, or a trajectory consumer reading `schema_validation_failed.zod_issues` needs to move to the renamed fields and shapes.
|
|
28
|
+
|
|
29
|
+
- **An inbound MCP tool now reaches the model with the schema its server actually advertised.** The bridge converted a server's JSON Schema into a Zod schema so the tool loop could validate it, and the provider path then converted that Zod back into JSON Schema — a round trip the old file's own header conceded was lossy. It dropped every value constraint on the way through: `minLength`, `maxItems`, `format`, `pattern`, and `enum` descriptions were modeled as plain types, so a model calling an MCP tool was told less about its arguments than the server had published. The bridge now builds a Standard Schema directly over the advertised JSON Schema, and emission hands that schema back verbatim in both directions, so what the server declared is what the provider receives. Validation is unchanged in reach — structure, types, enums, const, unions, and required keys are checked, value constraints are not, extra keys still pass through to the server, and anything unrecognized still accepts — because the server re-validates its own arguments and is the authority on them. Two visible consequences of verbatim emission: a server that declares `additionalProperties: false` now has that reach the provider instead of being loosened away, and `$schema` / `$id` keys the server published now ride along on the transports that accept them. The MCP path no longer imports zod at all. **Breaking:** the `fascicle/mcp` export `json_schema_to_zod` is renamed `json_schema_to_standard` and returns a `ToolSchema` rather than a `z.ZodType`, so a caller using it directly validates through `~standard.validate` (async) instead of `safeParse`.
|
|
30
|
+
|
|
31
|
+
- **The `zod` peer dependency is pinned to exactly `4.4.3`, up from `^4.0.0`.** fascicle is moving to emit provider JSON Schema through Standard JSON Schema (`~standard.jsonSchema`) rather than `z.toJSONSchema`, and that interface does not exist before zod 4.2.0: on 4.1.12 `~standard.jsonSchema` is `undefined`, so the old `^4.0.0` range named a floor that cannot work. The pin is exact rather than a range so that the one version fascicle is tested against is the one version it promises; 4.2.0 and 4.4.3 emit byte-identical draft-2020-12 schemas, so this is a choice about which version is guaranteed, not about behaviour. **Breaking:** an install that resolves zod to any other version, including a later patch such as 4.4.4, now reports a peer dependency conflict, and a project whose other packages peer-depend on a zod range excluding 4.4.3 cannot satisfy both at once. zod is an optional peer as of this release, which lifts the requirement for anyone who never installs it, but a consumer using zod schemas with fascicle still has to be on 4.4.3.
|
|
32
|
+
|
|
33
|
+
- **`retry` (composition layer) now jitters its backoff by default and caps it at 30s.** `RetryConfig` gains `max_delay_ms` (defaults to 30_000, matching the engine retry layer's cap) and `jitter` (defaults to `true`), both now expressed through the `#policy` backoff algebra the engine retry layer already used. Un-jittered retries from concurrent callers stampede back onto a recovering dependency in lockstep, and jittering is cheapest to add now, before `retry` has callers depending on its old exact-doubling delays. **Breaking:** a `retry(...)` call with a large `backoff_ms` or high `max_attempts` now serves a longer, randomized delay per attempt and is capped at 30s where it was previously uncapped; pass `jitter: false` and an explicit `max_delay_ms` to keep the old behavior exactly. `retry.test.ts` pins the default-on jitter clamped to an explicit cap, and the old exact-doubling assertion now runs with `jitter: false`.
|
|
34
|
+
|
|
35
|
+
### Internal
|
|
36
|
+
|
|
37
|
+
- **Two new bottom-of-DAG zones carry what core and engine used to reach for directly.** `#policy` holds the shared backoff algebra both retry layers now compute delays through; `#schema` holds the Standard Schema helpers (`validate_schema`, `to_json_schema`) that replaced zod at the public surface. Each ships its own ast-grep npm-dependency rule, so the "no npm dependency below this line" invariant is enforced rather than intended, and `snake-case-exports.yml` now covers both.
|
|
38
|
+
- **`docs/concepts.md` documents what cooperative cancellation cannot do** — `timeout` and abort signal intent but cannot kill work that ignores `ctx.abort`, and abandoned work keeps spending tokens — and `docs/composition.md`'s `retry` summary picks up the new `max_delay_ms` / `jitter` options.
|
|
39
|
+
- **The `claude_cli` SIGTERM-to-SIGKILL escalation test no longer races the wall clock.** It sampled child liveness partway through the escalation window, which under parallel load overran past `SIGKILL_ESCALATION_MS` and reported a dead child on untouched code. The sample is removed rather than given a wider margin, which would have pushed it past SIGKILL instead of clear of it: `signalCode` already proves SIGTERM was survived and the elapsed floor proves the escalator waited, both robust under load.
|
|
40
|
+
|
|
41
|
+
## v0.10.2 — 2026-08-11
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- **`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.
|
|
46
|
+
|
|
47
|
+
### Internal
|
|
48
|
+
|
|
49
|
+
- **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.
|
|
50
|
+
- **`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`.
|
|
51
|
+
- **The check runner (checkride) is upgraded from 0.6.0 to 0.12.1.**
|
|
52
|
+
|
|
3
53
|
## v0.10.1 — 2026-08-07
|
|
4
54
|
|
|
5
55
|
### Fixed
|
package/README.md
CHANGED
|
@@ -9,10 +9,10 @@ No framework lifecycle. No ambient state. No decorators. Adapters are passed in
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
pnpm add fascicle
|
|
12
|
+
pnpm add fascicle
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
fascicle is ESM-only and requires Node >= 24.
|
|
15
|
+
fascicle is ESM-only and requires Node >= 24. `ai`, `zod`, and every provider SDK are optional peers — install only the ones you use. `pnpm add fascicle` alone builds and runs a flow against `transport: 'native'` or `claude_cli`, with no AI SDK package and no schema library installed at all; schemas accept any [Standard Schema](https://standardschema.dev) — zod, ArkType, Valibot, whichever you already use. See [docs/providers.md](./docs/providers.md).
|
|
16
16
|
|
|
17
17
|
## A 60-second tour
|
|
18
18
|
|
|
@@ -152,13 +152,13 @@ serve_flow({
|
|
|
152
152
|
|
|
153
153
|
| Provider | Peer dep | Auth |
|
|
154
154
|
| ------------ | ----------------------------- | ------------------- |
|
|
155
|
-
| `anthropic` | `@ai-sdk/anthropic`, or none with `transport: 'native'` | API key |
|
|
156
|
-
| `openai` | `@ai-sdk/openai`, or none with `transport: 'native'` | API key
|
|
157
|
-
| `google` | `@ai-sdk/google`
|
|
158
|
-
| `openrouter` | `@openrouter/ai-sdk-provider`, or none with `transport: 'native'` | API key |
|
|
159
|
-
| `bedrock` | `@ai-sdk/amazon-bedrock`
|
|
160
|
-
| `ollama` | `ai-sdk-ollama`, or none with `transport: 'native'` | local `base_url` |
|
|
161
|
-
| `lmstudio` | `@ai-sdk/openai-compatible`, or none with `transport: 'native'` | local `base_url` |
|
|
155
|
+
| `anthropic` | `ai` + `@ai-sdk/anthropic`, or none with `transport: 'native'` | API key |
|
|
156
|
+
| `openai` | `ai` + `@ai-sdk/openai`, or none with `transport: 'native'` | API key |
|
|
157
|
+
| `google` | `ai` + `@ai-sdk/google` | API key |
|
|
158
|
+
| `openrouter` | `ai` + `@openrouter/ai-sdk-provider`, or none with `transport: 'native'` | API key |
|
|
159
|
+
| `bedrock` | `ai` + `@ai-sdk/amazon-bedrock` | `region` + AWS credentials |
|
|
160
|
+
| `ollama` | `ai` + `ai-sdk-ollama`, or none with `transport: 'native'` | local `base_url` |
|
|
161
|
+
| `lmstudio` | `ai` + `@ai-sdk/openai-compatible`, or none with `transport: 'native'` | local `base_url` |
|
|
162
162
|
| `claude_cli` | none (spawns `claude`) | OAuth or API key |
|
|
163
163
|
|
|
164
164
|
Full details: [docs/providers.md](./docs/providers.md). The `claude_cli` adapter has its own guide: [docs/cli.md](./docs/cli.md).
|
package/dist/adapters.d.ts
CHANGED
package/dist/agents.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { r as Step } from "./types-BDSbSUAO.js";
|
|
2
|
+
import { r as ToolSchema } from "./types-BCtKsxrX.js";
|
|
3
|
+
import { a as Engine } from "./types-B3HIsBBD.js";
|
|
4
4
|
|
|
5
5
|
//#region src/agents/define_agent.d.ts
|
|
6
6
|
type AgentBuiltPrompt = string | {
|
|
@@ -9,7 +9,7 @@ type AgentBuiltPrompt = string | {
|
|
|
9
9
|
};
|
|
10
10
|
type DefineAgentConfig<i, o> = {
|
|
11
11
|
readonly md_path: string | URL;
|
|
12
|
-
readonly schema:
|
|
12
|
+
readonly schema: ToolSchema<o>;
|
|
13
13
|
readonly engine: Engine;
|
|
14
14
|
readonly name?: string;
|
|
15
15
|
readonly build_prompt?: (input: i) => AgentBuiltPrompt;
|
package/dist/agents.js
CHANGED
package/dist/agents.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.js","names":[],"sources":["../src/agents/define_agent.ts"],"sourcesContent":["/**\n * define_agent: markdown-driven loader for simple agents.\n *\n * Most \"agents\" in practice are a system prompt and an output schema with a\n * thin wrapper. `define_agent({ md_path, schema, engine, build_prompt? })`\n * folds those into a `Step<i, o>`:\n *\n * - The markdown file is read once at factory time. Its YAML-style frontmatter\n * (`name`, `description`, `model`, `temperature`) is parsed into the agent's\n * step name and engine call defaults; the body is the system prompt.\n * - Without `build_prompt`, the body (after `{{key}}` substitution against\n * top-level string fields of the input) is the user prompt and no system is\n * sent; the markdown carries the full instruction.\n * - With `build_prompt`, the body is the system prompt and `build_prompt(input)`\n * produces the user message (string, or `{ user, system? }` to override).\n * - `config.model` and `config.schema_repair_attempts` shape the call from\n * code. An explicit `model` wins over frontmatter `model` (frontmatter stays\n * the role default when the app threads nothing; the engine default is the\n * last resort), so a resolved role-to-model table and env overrides actually\n * reach the call.\n *\n * The factory keeps no engine state. Each call delegates to `engine.generate`\n * with the resolved prompts, the schema, and `ctx.abort` / `ctx.trajectory`\n * threaded through. An `agent.call` trajectory event carries the agent name,\n * resolved model id, and engine-reported usage. No retry or fallback is baked\n * in; wrap with `retry()` from core if you need it.\n *\n * Frontmatter parser is intentionally tiny (no gray-matter): bare `key: value`\n * lines, optional `'`/`\"` quotes, `temperature` coerced to number. Anything\n * richer should go through `build_prompt`.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { aborted_error, step } from '#core'\nimport type { RunContext, Step } from '#core'\nimport type { Engine, GenerateOptions } from '#engine'\nimport type { z } from 'zod'\n\nexport type AgentBuiltPrompt =\n | string\n | { readonly user: string; readonly system?: string }\n\nexport type DefineAgentConfig<i, o> = {\n readonly md_path: string | URL\n readonly schema: z.ZodType<o>\n readonly engine: Engine\n readonly name?: string\n readonly build_prompt?: (input: i) => AgentBuiltPrompt\n /**\n * Model for this agent's calls, typically threaded from the app's resolved\n * role-to-model table. Wins over frontmatter `model`; when both are absent\n * the engine default applies.\n */\n readonly model?: string\n /**\n * Forwarded to `engine.generate`: how many times the engine may re-prompt\n * the model to repair schema-invalid output before failing the call.\n */\n readonly schema_repair_attempts?: number\n}\n\ntype Frontmatter = {\n readonly name?: string\n readonly description?: string\n readonly model?: string\n readonly temperature?: number\n}\n\ntype ParsedPrompt = {\n readonly frontmatter: Frontmatter\n readonly body: string\n}\n\nconst FRONTMATTER_OPEN = /^---\\s*\\r?\\n/\nconst FRONTMATTER_CLOSE = /^---\\s*$/m\nconst PLACEHOLDER_RE = /\\{\\{(\\w+)\\}\\}/g\n\n/**\n * Strip one matching pair of surrounding single or double quotes.\n */\nfunction unquote(raw: string): string {\n if (raw.length >= 2) {\n const first = raw[0]\n const last = raw[raw.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return raw.slice(1, -1)\n }\n }\n return raw\n}\n\n/**\n * Split a markdown file into frontmatter fields and prompt body.\n *\n * Parses only the flat `key: value` subset of YAML that agent files need:\n * recognized keys are `name`, `description`, `model`, and `temperature`\n * (coerced to a number); unrecognized keys are ignored. A file without an\n * opening `---` is all body. Malformed frontmatter throws rather than\n * silently producing a wrong prompt.\n */\nfunction parse_frontmatter(content: string): ParsedPrompt {\n const open_match = content.match(FRONTMATTER_OPEN)\n if (!open_match) return { frontmatter: {}, body: content }\n const after_open = content.slice(open_match[0].length)\n const close_match = FRONTMATTER_CLOSE.exec(after_open)\n if (close_match?.index === undefined) {\n throw new Error('define_agent: malformed frontmatter (missing closing `---`)')\n }\n const yaml_block = after_open.slice(0, close_match.index)\n const body = after_open.slice(close_match.index + close_match[0].length).replace(/^\\r?\\n/, '')\n\n const out: { -readonly [K in keyof Frontmatter]: Frontmatter[K] } = {}\n const lines = yaml_block.split(/\\r?\\n/)\n for (const raw of lines) {\n const line = raw.trim()\n if (line === '' || line.startsWith('#')) continue\n const colon_idx = line.indexOf(':')\n if (colon_idx === -1) {\n throw new Error(`define_agent: malformed frontmatter line: ${raw}`)\n }\n const key = line.slice(0, colon_idx).trim()\n const value_raw = line.slice(colon_idx + 1).trim()\n const value = unquote(value_raw)\n if (key === 'name' || key === 'description' || key === 'model') {\n out[key] = value\n continue\n }\n if (key === 'temperature') {\n const n = Number(value)\n if (!Number.isFinite(n)) {\n throw new Error(`define_agent: temperature must be a number, got: ${value_raw}`)\n }\n out.temperature = n\n continue\n }\n }\n return { frontmatter: out, body }\n}\n\n/**\n * Read the markdown file from a filesystem path, `URL`, or `file://` string.\n *\n * Accepting all three lets callers pass `new URL('./x.md', import.meta.url)`\n * or its string form without caring about the difference.\n */\nfunction read_md_sync(path: string | URL): string {\n if (path instanceof URL) {\n return readFileSync(fileURLToPath(path), 'utf8')\n }\n if (path.startsWith('file://')) {\n return readFileSync(fileURLToPath(path), 'utf8')\n }\n return readFileSync(path, 'utf8')\n}\n\n/**\n * Replace `{{key}}` placeholders with top-level string fields of the input.\n *\n * Non-string values and unknown keys leave the placeholder untouched, so a\n * typo'd placeholder is visible in the sent prompt instead of vanishing.\n */\nfunction substitute(template: string, input: unknown): string {\n if (input === null || typeof input !== 'object') return template\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const obj = input as Record<string, unknown>\n return template.replace(PLACEHOLDER_RE, (match, key: string) => {\n const v = obj[key]\n return typeof v === 'string' ? v : match\n })\n}\n\n/**\n * Load a markdown-defined agent as a `Step<i, o>`.\n *\n * Reads and parses the file once at factory time; each run resolves the\n * user/system prompts (via `build_prompt` or `{{key}}` substitution), calls\n * `engine.generate` with the schema and threaded abort/trajectory, and\n * records an `agent.call` event with the resolved model and usage.\n */\nexport function define_agent<i, o>(config: DefineAgentConfig<i, o>): Step<i, o> {\n const text = read_md_sync(config.md_path)\n const { frontmatter, body } = parse_frontmatter(text)\n\n const display_name = config.name ?? frontmatter.name ?? 'agent'\n\n return step<i, o>(display_name, async (input, ctx: RunContext): Promise<o> => {\n if (ctx.abort.aborted) {\n throw new aborted_error('aborted before agent call')\n }\n \n let user_prompt: string\n let system_prompt: string | undefined\n if (config.build_prompt) {\n const built = config.build_prompt(input)\n if (typeof built === 'string') {\n user_prompt = built\n system_prompt = body\n } else {\n user_prompt = built.user\n system_prompt = built.system ?? body\n }\n } else {\n user_prompt = substitute(body, input)\n system_prompt = undefined\n }\n \n const opts: GenerateOptions<o> = {\n prompt: user_prompt,\n schema: config.schema,\n abort: ctx.abort,\n trajectory: ctx.trajectory,\n }\n if (system_prompt !== undefined && system_prompt !== '') {\n opts.system = system_prompt\n }\n const model = config.model ?? frontmatter.model\n if (model !== undefined) opts.model = model\n if (frontmatter.temperature !== undefined) opts.temperature = frontmatter.temperature\n if (config.schema_repair_attempts !== undefined) {\n opts.schema_repair_attempts = config.schema_repair_attempts\n }\n \n const result = await config.engine.generate<o>(opts)\n \n const resolved_model = `${result.model_resolved.provider}:${result.model_resolved.model_id}`\n ctx.trajectory.record({\n kind: 'agent.call',\n name: display_name,\n model: resolved_model,\n usage: result.usage,\n })\n \n return result.content\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;;;;AAKvB,SAAS,QAAQ,KAAqB;CACpC,IAAI,IAAI,UAAU,GAAG;EACnB,MAAM,QAAQ,IAAI;EAClB,MAAM,OAAO,IAAI,IAAI,SAAS;EAC9B,IAAK,UAAU,QAAO,SAAS,QAAS,UAAU,OAAO,SAAS,KAChE,OAAO,IAAI,MAAM,GAAG,EAAE;CAE1B;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,kBAAkB,SAA+B;CACxD,MAAM,aAAa,QAAQ,MAAM,gBAAgB;CACjD,IAAI,CAAC,YAAY,OAAO;EAAE,aAAa,CAAC;EAAG,MAAM;CAAQ;CACzD,MAAM,aAAa,QAAQ,MAAM,WAAW,EAAE,CAAC,MAAM;CACrD,MAAM,cAAc,kBAAkB,KAAK,UAAU;CACrD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|
+
{"version":3,"file":"agents.js","names":[],"sources":["../src/agents/define_agent.ts"],"sourcesContent":["/**\n * define_agent: markdown-driven loader for simple agents.\n *\n * Most \"agents\" in practice are a system prompt and an output schema with a\n * thin wrapper. `define_agent({ md_path, schema, engine, build_prompt? })`\n * folds those into a `Step<i, o>`:\n *\n * - The markdown file is read once at factory time. Its YAML-style frontmatter\n * (`name`, `description`, `model`, `temperature`) is parsed into the agent's\n * step name and engine call defaults; the body is the system prompt.\n * - Without `build_prompt`, the body (after `{{key}}` substitution against\n * top-level string fields of the input) is the user prompt and no system is\n * sent; the markdown carries the full instruction.\n * - With `build_prompt`, the body is the system prompt and `build_prompt(input)`\n * produces the user message (string, or `{ user, system? }` to override).\n * - `config.model` and `config.schema_repair_attempts` shape the call from\n * code. An explicit `model` wins over frontmatter `model` (frontmatter stays\n * the role default when the app threads nothing; the engine default is the\n * last resort), so a resolved role-to-model table and env overrides actually\n * reach the call.\n *\n * The factory keeps no engine state. Each call delegates to `engine.generate`\n * with the resolved prompts, the schema, and `ctx.abort` / `ctx.trajectory`\n * threaded through. An `agent.call` trajectory event carries the agent name,\n * resolved model id, and engine-reported usage. No retry or fallback is baked\n * in; wrap with `retry()` from core if you need it.\n *\n * Frontmatter parser is intentionally tiny (no gray-matter): bare `key: value`\n * lines, optional `'`/`\"` quotes, `temperature` coerced to number. Anything\n * richer should go through `build_prompt`.\n */\n\nimport { readFileSync } from 'node:fs'\nimport { fileURLToPath } from 'node:url'\nimport { aborted_error, step } from '#core'\nimport type { RunContext, Step } from '#core'\nimport type { Engine, GenerateOptions } from '#engine'\nimport type { ToolSchema } from '#schema'\n\nexport type AgentBuiltPrompt =\n | string\n | { readonly user: string; readonly system?: string }\n\nexport type DefineAgentConfig<i, o> = {\n readonly md_path: string | URL\n readonly schema: ToolSchema<o>\n readonly engine: Engine\n readonly name?: string\n readonly build_prompt?: (input: i) => AgentBuiltPrompt\n /**\n * Model for this agent's calls, typically threaded from the app's resolved\n * role-to-model table. Wins over frontmatter `model`; when both are absent\n * the engine default applies.\n */\n readonly model?: string\n /**\n * Forwarded to `engine.generate`: how many times the engine may re-prompt\n * the model to repair schema-invalid output before failing the call.\n */\n readonly schema_repair_attempts?: number\n}\n\ntype Frontmatter = {\n readonly name?: string\n readonly description?: string\n readonly model?: string\n readonly temperature?: number\n}\n\ntype ParsedPrompt = {\n readonly frontmatter: Frontmatter\n readonly body: string\n}\n\nconst FRONTMATTER_OPEN = /^---\\s*\\r?\\n/\nconst FRONTMATTER_CLOSE = /^---\\s*$/m\nconst PLACEHOLDER_RE = /\\{\\{(\\w+)\\}\\}/g\n\n/**\n * Strip one matching pair of surrounding single or double quotes.\n */\nfunction unquote(raw: string): string {\n if (raw.length >= 2) {\n const first = raw[0]\n const last = raw[raw.length - 1]\n if ((first === '\"' && last === '\"') || (first === \"'\" && last === \"'\")) {\n return raw.slice(1, -1)\n }\n }\n return raw\n}\n\n/**\n * Split a markdown file into frontmatter fields and prompt body.\n *\n * Parses only the flat `key: value` subset of YAML that agent files need:\n * recognized keys are `name`, `description`, `model`, and `temperature`\n * (coerced to a number); unrecognized keys are ignored. A file without an\n * opening `---` is all body. Malformed frontmatter throws rather than\n * silently producing a wrong prompt.\n */\nfunction parse_frontmatter(content: string): ParsedPrompt {\n const open_match = content.match(FRONTMATTER_OPEN)\n if (!open_match) return { frontmatter: {}, body: content }\n const after_open = content.slice(open_match[0].length)\n const close_match = FRONTMATTER_CLOSE.exec(after_open)\n if (close_match?.index === undefined) {\n throw new Error('define_agent: malformed frontmatter (missing closing `---`)')\n }\n const yaml_block = after_open.slice(0, close_match.index)\n const body = after_open.slice(close_match.index + close_match[0].length).replace(/^\\r?\\n/, '')\n\n const out: { -readonly [K in keyof Frontmatter]: Frontmatter[K] } = {}\n const lines = yaml_block.split(/\\r?\\n/)\n for (const raw of lines) {\n const line = raw.trim()\n if (line === '' || line.startsWith('#')) continue\n const colon_idx = line.indexOf(':')\n if (colon_idx === -1) {\n throw new Error(`define_agent: malformed frontmatter line: ${raw}`)\n }\n const key = line.slice(0, colon_idx).trim()\n const value_raw = line.slice(colon_idx + 1).trim()\n const value = unquote(value_raw)\n if (key === 'name' || key === 'description' || key === 'model') {\n out[key] = value\n continue\n }\n if (key === 'temperature') {\n const n = Number(value)\n if (!Number.isFinite(n)) {\n throw new Error(`define_agent: temperature must be a number, got: ${value_raw}`)\n }\n out.temperature = n\n continue\n }\n }\n return { frontmatter: out, body }\n}\n\n/**\n * Read the markdown file from a filesystem path, `URL`, or `file://` string.\n *\n * Accepting all three lets callers pass `new URL('./x.md', import.meta.url)`\n * or its string form without caring about the difference.\n */\nfunction read_md_sync(path: string | URL): string {\n if (path instanceof URL) {\n return readFileSync(fileURLToPath(path), 'utf8')\n }\n if (path.startsWith('file://')) {\n return readFileSync(fileURLToPath(path), 'utf8')\n }\n return readFileSync(path, 'utf8')\n}\n\n/**\n * Replace `{{key}}` placeholders with top-level string fields of the input.\n *\n * Non-string values and unknown keys leave the placeholder untouched, so a\n * typo'd placeholder is visible in the sent prompt instead of vanishing.\n */\nfunction substitute(template: string, input: unknown): string {\n if (input === null || typeof input !== 'object') return template\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion\n const obj = input as Record<string, unknown>\n return template.replace(PLACEHOLDER_RE, (match, key: string) => {\n const v = obj[key]\n return typeof v === 'string' ? v : match\n })\n}\n\n/**\n * Load a markdown-defined agent as a `Step<i, o>`.\n *\n * Reads and parses the file once at factory time; each run resolves the\n * user/system prompts (via `build_prompt` or `{{key}}` substitution), calls\n * `engine.generate` with the schema and threaded abort/trajectory, and\n * records an `agent.call` event with the resolved model and usage.\n */\nexport function define_agent<i, o>(config: DefineAgentConfig<i, o>): Step<i, o> {\n const text = read_md_sync(config.md_path)\n const { frontmatter, body } = parse_frontmatter(text)\n\n const display_name = config.name ?? frontmatter.name ?? 'agent'\n\n return step<i, o>(display_name, async (input, ctx: RunContext): Promise<o> => {\n if (ctx.abort.aborted) {\n throw new aborted_error('aborted before agent call')\n }\n \n let user_prompt: string\n let system_prompt: string | undefined\n if (config.build_prompt) {\n const built = config.build_prompt(input)\n if (typeof built === 'string') {\n user_prompt = built\n system_prompt = body\n } else {\n user_prompt = built.user\n system_prompt = built.system ?? body\n }\n } else {\n user_prompt = substitute(body, input)\n system_prompt = undefined\n }\n \n const opts: GenerateOptions<o> = {\n prompt: user_prompt,\n schema: config.schema,\n abort: ctx.abort,\n trajectory: ctx.trajectory,\n }\n if (system_prompt !== undefined && system_prompt !== '') {\n opts.system = system_prompt\n }\n const model = config.model ?? frontmatter.model\n if (model !== undefined) opts.model = model\n if (frontmatter.temperature !== undefined) opts.temperature = frontmatter.temperature\n if (config.schema_repair_attempts !== undefined) {\n opts.schema_repair_attempts = config.schema_repair_attempts\n }\n \n const result = await config.engine.generate<o>(opts)\n \n const resolved_model = `${result.model_resolved.provider}:${result.model_resolved.model_id}`\n ctx.trajectory.record({\n kind: 'agent.call',\n name: display_name,\n model: resolved_model,\n usage: result.usage,\n })\n \n return result.content\n })\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EA,MAAM,mBAAmB;AACzB,MAAM,oBAAoB;AAC1B,MAAM,iBAAiB;;;;AAKvB,SAAS,QAAQ,KAAqB;CACpC,IAAI,IAAI,UAAU,GAAG;EACnB,MAAM,QAAQ,IAAI;EAClB,MAAM,OAAO,IAAI,IAAI,SAAS;EAC9B,IAAK,UAAU,QAAO,SAAS,QAAS,UAAU,OAAO,SAAS,KAChE,OAAO,IAAI,MAAM,GAAG,EAAE;CAE1B;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAS,kBAAkB,SAA+B;CACxD,MAAM,aAAa,QAAQ,MAAM,gBAAgB;CACjD,IAAI,CAAC,YAAY,OAAO;EAAE,aAAa,CAAC;EAAG,MAAM;CAAQ;CACzD,MAAM,aAAa,QAAQ,MAAM,WAAW,EAAE,CAAC,MAAM;CACrD,MAAM,cAAc,kBAAkB,KAAK,UAAU;CACrD,IAAI,aAAa,U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@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
|
-
import { z } from "zod";
|
|
3
2
|
//#region src/core/flow-schema.json
|
|
4
3
|
var flow_schema_default = {
|
|
5
4
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -358,13 +357,6 @@ async function run_one(fn, trajectory) {
|
|
|
358
357
|
}
|
|
359
358
|
//#endregion
|
|
360
359
|
//#region src/core/errors.ts
|
|
361
|
-
/**
|
|
362
|
-
* Typed errors for the composition layer.
|
|
363
|
-
*
|
|
364
|
-
* This is the only source file in the core layer that uses the `class`
|
|
365
|
-
* keyword. `Error` is a built-in and `instanceof` branching is how composers
|
|
366
|
-
* like `retry` and `fallback` distinguish failure modes.
|
|
367
|
-
*/
|
|
368
360
|
var timeout_error = class extends Error {
|
|
369
361
|
kind = "timeout_error";
|
|
370
362
|
timeout_ms;
|
|
@@ -1454,14 +1446,59 @@ function pipe(inner, fn, options) {
|
|
|
1454
1446
|
}
|
|
1455
1447
|
register_traced_kind("pipe");
|
|
1456
1448
|
//#endregion
|
|
1449
|
+
//#region src/policy/backoff.ts
|
|
1450
|
+
/**
|
|
1451
|
+
* Compute the delay before retry attempt `attempt`, counted from zero.
|
|
1452
|
+
*
|
|
1453
|
+
* Exponential (`initial_delay_ms * 2^attempt`) plus up to one
|
|
1454
|
+
* `initial_delay_ms` of random jitter when `policy.jitter` is set, clamped to
|
|
1455
|
+
* `max_delay_ms`. The jitter spreads retries from concurrent callers apart so
|
|
1456
|
+
* they don't stampede in lockstep; a `max_delay_ms` of `Infinity` is uncapped.
|
|
1457
|
+
*/
|
|
1458
|
+
function compute_backoff(policy, attempt) {
|
|
1459
|
+
const base = policy.initial_delay_ms * 2 ** attempt;
|
|
1460
|
+
const jitter = policy.jitter ? Math.random() * policy.initial_delay_ms : 0;
|
|
1461
|
+
return Math.min(base + jitter, policy.max_delay_ms);
|
|
1462
|
+
}
|
|
1463
|
+
/**
|
|
1464
|
+
* Sleep `ms`, rejecting the moment `signal` fires instead of serving out the
|
|
1465
|
+
* delay, so a pending abort never waits out a backoff.
|
|
1466
|
+
*
|
|
1467
|
+
* A non-positive `ms` resolves without arming a timer or consulting `signal`,
|
|
1468
|
+
* matching what both retry layers did before. The rejection value is
|
|
1469
|
+
* `to_error` applied to `signal.reason`.
|
|
1470
|
+
*/
|
|
1471
|
+
function wait_with_abort(ms, signal, to_error) {
|
|
1472
|
+
if (ms <= 0) return Promise.resolve();
|
|
1473
|
+
return new Promise((resolve, reject) => {
|
|
1474
|
+
if (signal.aborted) {
|
|
1475
|
+
reject(to_error(signal.reason));
|
|
1476
|
+
return;
|
|
1477
|
+
}
|
|
1478
|
+
const timer = setTimeout(() => {
|
|
1479
|
+
signal.removeEventListener("abort", on_abort);
|
|
1480
|
+
resolve();
|
|
1481
|
+
}, ms);
|
|
1482
|
+
const on_abort = () => {
|
|
1483
|
+
clearTimeout(timer);
|
|
1484
|
+
reject(to_error(signal.reason));
|
|
1485
|
+
};
|
|
1486
|
+
signal.addEventListener("abort", on_abort, { once: true });
|
|
1487
|
+
});
|
|
1488
|
+
}
|
|
1489
|
+
//#endregion
|
|
1457
1490
|
//#region src/core/retry.ts
|
|
1458
1491
|
/**
|
|
1459
1492
|
* retry: re-run on failure.
|
|
1460
1493
|
*
|
|
1461
|
-
* `retry(inner, { max_attempts, backoff_ms?, on_error? })`
|
|
1462
|
-
* throws an application error, retries up to
|
|
1463
|
-
*
|
|
1464
|
-
*
|
|
1494
|
+
* `retry(inner, { max_attempts, backoff_ms?, max_delay_ms?, jitter?, on_error? })`
|
|
1495
|
+
* runs `inner`. If it throws an application error, retries up to
|
|
1496
|
+
* `max_attempts - 1` more times with exponential backoff
|
|
1497
|
+
* (`backoff_ms * 2^(attempt-1)`), jittered by up to one `backoff_ms` and
|
|
1498
|
+
* clamped to `max_delay_ms` (default 30s) through the shared `#policy`
|
|
1499
|
+
* algebra. `jitter` defaults on: un-jittered concurrent retries stampede in
|
|
1500
|
+
* lockstep. `on_error` is called on every such failure. The last error is
|
|
1501
|
+
* rethrown if all attempts fail.
|
|
1465
1502
|
*
|
|
1466
1503
|
* Control-flow signals (`suspended_error`, `aborted_error`) are not failures:
|
|
1467
1504
|
* they propagate immediately without consuming an attempt, firing `on_error`,
|
|
@@ -1473,6 +1510,7 @@ register_traced_kind("pipe");
|
|
|
1473
1510
|
* attempts; a pending abort short-circuits the backoff and propagates.
|
|
1474
1511
|
*/
|
|
1475
1512
|
const DEFAULT_BACKOFF_MS = 1e3;
|
|
1513
|
+
const DEFAULT_MAX_DELAY_MS = 3e4;
|
|
1476
1514
|
let retry_counter = 0;
|
|
1477
1515
|
/**
|
|
1478
1516
|
* Generate a unique step id of the form `retry_<n>`.
|
|
@@ -1482,30 +1520,11 @@ function next_id$5() {
|
|
|
1482
1520
|
return `retry_${retry_counter}`;
|
|
1483
1521
|
}
|
|
1484
1522
|
/**
|
|
1485
|
-
*
|
|
1486
|
-
*
|
|
1487
|
-
* Rejects immediately with the abort reason (or an `aborted_error`) when
|
|
1488
|
-
* `ctx.abort` fires, so a pending abort never waits out a backoff delay.
|
|
1523
|
+
* Map an abort reason onto the error a retry rejects with, preserving an
|
|
1524
|
+
* `Error` reason verbatim rather than wrapping it in `aborted_error`.
|
|
1489
1525
|
*/
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
await new Promise((resolve, reject) => {
|
|
1493
|
-
if (ctx.abort.aborted) {
|
|
1494
|
-
const reason = ctx.abort.reason;
|
|
1495
|
-
reject(reason instanceof Error ? reason : new aborted_error("aborted", { reason }));
|
|
1496
|
-
return;
|
|
1497
|
-
}
|
|
1498
|
-
const timer = setTimeout(() => {
|
|
1499
|
-
ctx.abort.removeEventListener("abort", on_abort);
|
|
1500
|
-
resolve();
|
|
1501
|
-
}, ms);
|
|
1502
|
-
const on_abort = () => {
|
|
1503
|
-
clearTimeout(timer);
|
|
1504
|
-
const reason = ctx.abort.reason;
|
|
1505
|
-
reject(reason instanceof Error ? reason : new aborted_error("aborted", { reason }));
|
|
1506
|
-
};
|
|
1507
|
-
ctx.abort.addEventListener("abort", on_abort, { once: true });
|
|
1508
|
-
});
|
|
1526
|
+
function to_abort_error(reason) {
|
|
1527
|
+
return reason instanceof Error ? reason : new aborted_error("aborted", { reason });
|
|
1509
1528
|
}
|
|
1510
1529
|
/**
|
|
1511
1530
|
* Build a retrying step around `inner`.
|
|
@@ -1518,14 +1537,18 @@ function retry(inner, config) {
|
|
|
1518
1537
|
const id = next_id$5();
|
|
1519
1538
|
const max_attempts = Math.max(1, Math.floor(config.max_attempts));
|
|
1520
1539
|
const backoff_ms = config.backoff_ms ?? DEFAULT_BACKOFF_MS;
|
|
1540
|
+
const max_delay_ms = config.max_delay_ms ?? DEFAULT_MAX_DELAY_MS;
|
|
1541
|
+
const jitter = config.jitter ?? true;
|
|
1521
1542
|
const on_error = config.on_error;
|
|
1543
|
+
const backoff_policy = {
|
|
1544
|
+
initial_delay_ms: backoff_ms,
|
|
1545
|
+
max_delay_ms,
|
|
1546
|
+
jitter
|
|
1547
|
+
};
|
|
1522
1548
|
const run_fn = async (input, ctx) => {
|
|
1523
1549
|
let last_err = void 0;
|
|
1524
1550
|
for (let attempt = 1; attempt <= max_attempts; attempt += 1) {
|
|
1525
|
-
if (ctx.abort.aborted)
|
|
1526
|
-
const reason = ctx.abort.reason;
|
|
1527
|
-
throw reason instanceof Error ? reason : new aborted_error("aborted", { reason });
|
|
1528
|
-
}
|
|
1551
|
+
if (ctx.abort.aborted) throw to_abort_error(ctx.abort.reason);
|
|
1529
1552
|
try {
|
|
1530
1553
|
return await dispatch_step(inner, input, ctx);
|
|
1531
1554
|
} catch (err) {
|
|
@@ -1533,14 +1556,16 @@ function retry(inner, config) {
|
|
|
1533
1556
|
last_err = err;
|
|
1534
1557
|
if (on_error) on_error(err, attempt);
|
|
1535
1558
|
if (attempt >= max_attempts) break;
|
|
1536
|
-
await
|
|
1559
|
+
await wait_with_abort(compute_backoff(backoff_policy, attempt - 1), ctx.abort, to_abort_error);
|
|
1537
1560
|
}
|
|
1538
1561
|
}
|
|
1539
1562
|
throw last_err;
|
|
1540
1563
|
};
|
|
1541
1564
|
const config_meta = {
|
|
1542
1565
|
max_attempts,
|
|
1543
|
-
backoff_ms
|
|
1566
|
+
backoff_ms,
|
|
1567
|
+
max_delay_ms,
|
|
1568
|
+
jitter
|
|
1544
1569
|
};
|
|
1545
1570
|
if (on_error) config_meta["on_error"] = on_error;
|
|
1546
1571
|
if (config.name !== void 0) config_meta["display_name"] = config.name;
|
|
@@ -1559,11 +1584,13 @@ register_traced_kind("retry");
|
|
|
1559
1584
|
* fallback: primary-or-backup.
|
|
1560
1585
|
*
|
|
1561
1586
|
* `fallback(primary, backup)` runs `primary`. If it throws an application
|
|
1562
|
-
* error, runs `backup` with the same input
|
|
1563
|
-
* `
|
|
1564
|
-
* `
|
|
1565
|
-
*
|
|
1566
|
-
*
|
|
1587
|
+
* error, runs `backup` with the same input, or with `handoff(input, err)`
|
|
1588
|
+
* when the `handoff` option is set, so the backup can be told why it is
|
|
1589
|
+
* running. If `backup` also throws, the `backup` error propagates.
|
|
1590
|
+
* Control-flow signals (`suspended_error`, `aborted_error`) are not
|
|
1591
|
+
* failures: they propagate instead of triggering the backup, so a
|
|
1592
|
+
* human-approval gate is never silently bypassed and the backup never runs
|
|
1593
|
+
* under an aborted context. `handoff` is never called for them.
|
|
1567
1594
|
*/
|
|
1568
1595
|
let fallback_counter = 0;
|
|
1569
1596
|
/**
|
|
@@ -1576,17 +1603,19 @@ function next_id$4() {
|
|
|
1576
1603
|
/**
|
|
1577
1604
|
* Build a primary-or-backup step.
|
|
1578
1605
|
*
|
|
1579
|
-
* Runs `primary`; on an application error runs `backup` with the same input
|
|
1580
|
-
*
|
|
1606
|
+
* Runs `primary`; on an application error runs `backup` with the same input,
|
|
1607
|
+
* or with `handoff(input, err)` when the option is set. Control-flow signals
|
|
1608
|
+
* propagate without triggering the backup or the handoff.
|
|
1581
1609
|
*/
|
|
1582
1610
|
function fallback(primary, backup, options) {
|
|
1583
1611
|
const id = next_id$4();
|
|
1612
|
+
const handoff = options?.handoff;
|
|
1584
1613
|
const run_fn = async (input, ctx) => {
|
|
1585
1614
|
try {
|
|
1586
1615
|
return await dispatch_step(primary, input, ctx);
|
|
1587
1616
|
} catch (err) {
|
|
1588
1617
|
if (is_control_flow_error(err)) throw err;
|
|
1589
|
-
return dispatch_step(backup, input, ctx);
|
|
1618
|
+
return dispatch_step(backup, handoff === void 0 ? input : handoff(input, err), ctx);
|
|
1590
1619
|
}
|
|
1591
1620
|
};
|
|
1592
1621
|
const config_meta = options?.name === void 0 ? void 0 : { display_name: options.name };
|
|
@@ -1863,6 +1892,63 @@ function checkpoint(inner, config) {
|
|
|
1863
1892
|
}
|
|
1864
1893
|
register_traced_kind("checkpoint");
|
|
1865
1894
|
//#endregion
|
|
1895
|
+
//#region src/schema/validate.ts
|
|
1896
|
+
/**
|
|
1897
|
+
* Validate `value` against `schema`, returning the typed value or the issues.
|
|
1898
|
+
*
|
|
1899
|
+
* Always async, even for a validator that answers synchronously: the spec
|
|
1900
|
+
* permits `validate` to return either a result or a promise of one, and
|
|
1901
|
+
* fascicle cannot know which a given vendor does. Awaiting a non-promise is
|
|
1902
|
+
* cheap; guessing wrong is a silent bug.
|
|
1903
|
+
*/
|
|
1904
|
+
async function validate_schema(schema, value) {
|
|
1905
|
+
const result = await schema["~standard"].validate(value);
|
|
1906
|
+
if (result.issues) return {
|
|
1907
|
+
ok: false,
|
|
1908
|
+
issues: result.issues.map(normalize_issue)
|
|
1909
|
+
};
|
|
1910
|
+
return {
|
|
1911
|
+
ok: true,
|
|
1912
|
+
value: result.value
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
/**
|
|
1916
|
+
* Flatten one vendor issue into fascicle's shape.
|
|
1917
|
+
*
|
|
1918
|
+
* The spec allows a path segment to be a bare key or a `{ key }` wrapper, and
|
|
1919
|
+
* allows the path to be absent entirely. Normalizing here means no consumer has
|
|
1920
|
+
* to know which vendor produced the issue.
|
|
1921
|
+
*/
|
|
1922
|
+
function normalize_issue(issue) {
|
|
1923
|
+
if (issue.path === void 0) return { message: issue.message };
|
|
1924
|
+
const path = issue.path.map((segment) => typeof segment === "object" ? segment.key : segment);
|
|
1925
|
+
return {
|
|
1926
|
+
message: issue.message,
|
|
1927
|
+
path
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Render issues as the single line that goes into an error message or a repair
|
|
1932
|
+
* prompt fed back to the model.
|
|
1933
|
+
*
|
|
1934
|
+
* Paths are dotted (`address.city`, `items.0.name`) rather than bracketed for
|
|
1935
|
+
* indices: the model reads it as a hint about which field to fix, and one
|
|
1936
|
+
* consistent separator is easier to follow than two.
|
|
1937
|
+
*/
|
|
1938
|
+
function format_schema_issues(issues) {
|
|
1939
|
+
if (issues.length === 0) return "unknown schema issue";
|
|
1940
|
+
return issues.map(format_issue).join("; ");
|
|
1941
|
+
}
|
|
1942
|
+
/**
|
|
1943
|
+
* Render one issue as `path: message`, or just the message when the vendor
|
|
1944
|
+
* reported no path (a failure about the value as a whole).
|
|
1945
|
+
*/
|
|
1946
|
+
function format_issue(issue) {
|
|
1947
|
+
const path = issue.path;
|
|
1948
|
+
if (path === void 0 || path.length === 0) return issue.message;
|
|
1949
|
+
return `${path.map((segment) => String(segment)).join(".")}: ${issue.message}`;
|
|
1950
|
+
}
|
|
1951
|
+
//#endregion
|
|
1866
1952
|
//#region src/core/suspend.ts
|
|
1867
1953
|
/**
|
|
1868
1954
|
* suspend: human-in-the-loop pause.
|
|
@@ -1874,7 +1960,7 @@ register_traced_kind("checkpoint");
|
|
|
1874
1960
|
* with `run_options.resume_data[id]` populated), the provided value is
|
|
1875
1961
|
* validated against `resume_schema` and passed to `combine(input, resume,
|
|
1876
1962
|
* ctx)`; the result is returned. Invalid resume data throws
|
|
1877
|
-
* `resume_validation_error`
|
|
1963
|
+
* `resume_validation_error` carrying the vendor-neutral issue list.
|
|
1878
1964
|
*/
|
|
1879
1965
|
/**
|
|
1880
1966
|
* Structurally detect a `Step` returned from `combine`.
|
|
@@ -1907,12 +1993,9 @@ function suspend(config) {
|
|
|
1907
1993
|
await on_fn(input, ctx);
|
|
1908
1994
|
throw new suspended_error(suspend_id, { input });
|
|
1909
1995
|
}
|
|
1910
|
-
const parsed = resume_schema
|
|
1911
|
-
if (!parsed.
|
|
1912
|
-
|
|
1913
|
-
throw new resume_validation_error(`resume data for ${suspend_id} failed validation`, issues);
|
|
1914
|
-
}
|
|
1915
|
-
const result = await combine_fn(input, parsed.data, ctx);
|
|
1996
|
+
const parsed = await validate_schema(resume_schema, resume_value);
|
|
1997
|
+
if (!parsed.ok) throw new resume_validation_error(`resume data for ${suspend_id} failed validation`, parsed.issues);
|
|
1998
|
+
const result = await combine_fn(input, parsed.value, ctx);
|
|
1916
1999
|
if (is_step(result)) return dispatch_step(result, input, ctx);
|
|
1917
2000
|
return result;
|
|
1918
2001
|
};
|
|
@@ -2100,44 +2183,47 @@ function is_step_kind(value) {
|
|
|
2100
2183
|
//#endregion
|
|
2101
2184
|
//#region src/core/trajectory.ts
|
|
2102
2185
|
/**
|
|
2103
|
-
*
|
|
2104
|
-
*
|
|
2105
|
-
*
|
|
2106
|
-
*
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2186
|
+
* The wire gate: a non-array object carrying a string `kind`.
|
|
2187
|
+
*
|
|
2188
|
+
* True for every well-known kind as well, since `custom` is the fallback shape
|
|
2189
|
+
* rather than a disjoint case.
|
|
2190
|
+
*/
|
|
2191
|
+
function is_custom_trajectory_event(value) {
|
|
2192
|
+
if (typeof value !== "object" || value === null) return false;
|
|
2193
|
+
if (Array.isArray(value)) return false;
|
|
2194
|
+
return typeof value.kind === "string";
|
|
2195
|
+
}
|
|
2196
|
+
/** A composer span open: both `span_id` and `name` must be present as strings. */
|
|
2197
|
+
function is_span_start_event(value) {
|
|
2198
|
+
if (!is_custom_trajectory_event(value)) return false;
|
|
2199
|
+
if (value.kind !== "span_start") return false;
|
|
2200
|
+
return typeof value["span_id"] === "string" && typeof value["name"] === "string";
|
|
2201
|
+
}
|
|
2202
|
+
/** A composer span close: `span_id` must be present as a string, `name` need not be. */
|
|
2203
|
+
function is_span_end_event(value) {
|
|
2204
|
+
if (!is_custom_trajectory_event(value)) return false;
|
|
2205
|
+
return value.kind === "span_end" && typeof value["span_id"] === "string";
|
|
2206
|
+
}
|
|
2207
|
+
/** A `ctx.emit` event: the kind alone identifies it, the payload is the caller's. */
|
|
2208
|
+
function is_emit_event(value) {
|
|
2209
|
+
return is_custom_trajectory_event(value) && value.kind === "emit";
|
|
2210
|
+
}
|
|
2211
|
+
/**
|
|
2212
|
+
* Parse one wire value into a trajectory event, `safeParse`-shaped.
|
|
2213
|
+
*
|
|
2214
|
+
* On success `data` is the value itself, not a copy, so nothing on the line is
|
|
2215
|
+
* dropped or reordered on the way through.
|
|
2216
|
+
*/
|
|
2217
|
+
function parse_trajectory_event(value) {
|
|
2218
|
+
if (!is_custom_trajectory_event(value)) return {
|
|
2219
|
+
success: false,
|
|
2220
|
+
error: /* @__PURE__ */ new Error("not a trajectory event: expected an object with a string 'kind'")
|
|
2221
|
+
};
|
|
2222
|
+
return {
|
|
2223
|
+
success: true,
|
|
2224
|
+
data: value
|
|
2225
|
+
};
|
|
2226
|
+
}
|
|
2141
2227
|
//#endregion
|
|
2142
2228
|
//#region src/core/index.ts
|
|
2143
2229
|
/**
|
|
@@ -2150,6 +2236,6 @@ const trajectory_event_schema = z.union([
|
|
|
2150
2236
|
* and surface through the umbrella package.
|
|
2151
2237
|
*/
|
|
2152
2238
|
//#endregion
|
|
2153
|
-
export {
|
|
2239
|
+
export { aborted_error as A, map as C, describe as D, sequence as E, flow_schema_default as F, resume_validation_error as M, suspended_error as N, step as O, timeout_error as P, pipe as S, parallel as T, timeout as _, parse_trajectory_event as a, compute_backoff as b, scope as c, suspend as d, format_schema_issues as f, loop as g, compose as h, is_span_start_event as i, describe_cycle_error as j, run as k, stash as l, checkpoint as m, is_emit_event as n, STEP_KINDS as o, validate_schema as p, is_span_end_event as r, is_step_kind as s, is_custom_trajectory_event as t, use as u, fallback as v, branch as w, wait_with_abort as x, retry as y };
|
|
2154
2240
|
|
|
2155
|
-
//# sourceMappingURL=core-
|
|
2241
|
+
//# sourceMappingURL=core-DkuJqLwd.js.map
|