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
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import "./core-DkuJqLwd.js";
|
|
2
|
+
//#region src/engine/errors.ts
|
|
3
|
+
var rate_limit_error = class extends Error {
|
|
4
|
+
kind = "rate_limit_error";
|
|
5
|
+
retry_after_ms;
|
|
6
|
+
attempts;
|
|
7
|
+
status;
|
|
8
|
+
constructor(message, metadata = {}) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "rate_limit_error";
|
|
11
|
+
this.retry_after_ms = metadata.retry_after_ms;
|
|
12
|
+
this.attempts = metadata.attempts ?? 0;
|
|
13
|
+
this.status = metadata.status;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var provider_error = class extends Error {
|
|
17
|
+
kind = "provider_error";
|
|
18
|
+
status;
|
|
19
|
+
body;
|
|
20
|
+
cause_kind;
|
|
21
|
+
constructor(message, metadata = {}) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.name = "provider_error";
|
|
24
|
+
this.status = metadata.status;
|
|
25
|
+
this.body = metadata.body;
|
|
26
|
+
this.cause_kind = metadata.cause_kind;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Turn-timeout expiry. Thrown by the engine-owned retry_turn wrapper when a
|
|
31
|
+
* single invoke_turn exceeds `turn_timeout_ms` before any chunk streamed.
|
|
32
|
+
* Its `kind` is the RetryFailureKind wire value `'timeout'` (not the class
|
|
33
|
+
* name) on purpose: that is the discriminant classify_retryable /
|
|
34
|
+
* classify_provider_error already key on, so the shared classifier treats an
|
|
35
|
+
* expiry as retryable without any timeout-specific branch. A mid-stream
|
|
36
|
+
* expiry never reaches here; retry_turn converts it to a non-retryable
|
|
37
|
+
* stream interruption first.
|
|
38
|
+
*/
|
|
39
|
+
var turn_timeout_error = class extends Error {
|
|
40
|
+
kind = "timeout";
|
|
41
|
+
timeout_ms;
|
|
42
|
+
step_index;
|
|
43
|
+
constructor(timeout_ms, step_index) {
|
|
44
|
+
super(`turn exceeded turn_timeout_ms budget of ${timeout_ms}ms`);
|
|
45
|
+
this.name = "turn_timeout_error";
|
|
46
|
+
this.timeout_ms = timeout_ms;
|
|
47
|
+
this.step_index = step_index;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var schema_validation_error = class extends Error {
|
|
51
|
+
kind = "schema_validation_error";
|
|
52
|
+
schema_issues;
|
|
53
|
+
raw_text;
|
|
54
|
+
constructor(message, schema_issues, raw_text) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = "schema_validation_error";
|
|
57
|
+
this.schema_issues = schema_issues;
|
|
58
|
+
this.raw_text = raw_text;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var tool_error = class extends Error {
|
|
62
|
+
kind = "tool_error";
|
|
63
|
+
tool_name;
|
|
64
|
+
tool_call_id;
|
|
65
|
+
cause;
|
|
66
|
+
constructor(message, metadata) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "tool_error";
|
|
69
|
+
this.tool_name = metadata.tool_name;
|
|
70
|
+
this.tool_call_id = metadata.tool_call_id;
|
|
71
|
+
this.cause = metadata.cause;
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
var tool_approval_denied_error = class extends Error {
|
|
75
|
+
kind = "tool_approval_denied_error";
|
|
76
|
+
tool_name;
|
|
77
|
+
step_index;
|
|
78
|
+
tool_call_id;
|
|
79
|
+
constructor(message, metadata) {
|
|
80
|
+
super(message);
|
|
81
|
+
this.name = "tool_approval_denied_error";
|
|
82
|
+
this.tool_name = metadata.tool_name;
|
|
83
|
+
this.step_index = metadata.step_index;
|
|
84
|
+
this.tool_call_id = metadata.tool_call_id;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
var model_required_error = class extends Error {
|
|
88
|
+
kind = "model_required_error";
|
|
89
|
+
constructor(message = "no model specified: pass `model` to generate() or set `defaults.model` on the engine") {
|
|
90
|
+
super(message);
|
|
91
|
+
this.name = "model_required_error";
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
var provider_not_configured_error = class extends Error {
|
|
95
|
+
kind = "provider_not_configured_error";
|
|
96
|
+
provider;
|
|
97
|
+
constructor(provider) {
|
|
98
|
+
super(`provider '${provider}' is not configured on this engine`);
|
|
99
|
+
this.name = "provider_not_configured_error";
|
|
100
|
+
this.provider = provider;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
var engine_config_error = class extends Error {
|
|
104
|
+
kind = "engine_config_error";
|
|
105
|
+
provider;
|
|
106
|
+
constructor(message, provider) {
|
|
107
|
+
super(message);
|
|
108
|
+
this.name = "engine_config_error";
|
|
109
|
+
this.provider = provider;
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var on_chunk_error = class extends Error {
|
|
113
|
+
kind = "on_chunk_error";
|
|
114
|
+
cause;
|
|
115
|
+
constructor(message, cause) {
|
|
116
|
+
super(message);
|
|
117
|
+
this.name = "on_chunk_error";
|
|
118
|
+
this.cause = cause;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
var provider_capability_error = class extends Error {
|
|
122
|
+
kind = "provider_capability_error";
|
|
123
|
+
provider;
|
|
124
|
+
capability;
|
|
125
|
+
constructor(provider, capability, detail) {
|
|
126
|
+
const suffix = detail !== void 0 ? `: ${detail}` : "";
|
|
127
|
+
super(`provider '${provider}' does not support '${capability}'${suffix}`);
|
|
128
|
+
this.name = "provider_capability_error";
|
|
129
|
+
this.provider = provider;
|
|
130
|
+
this.capability = capability;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var engine_disposed_error = class extends Error {
|
|
134
|
+
kind = "engine_disposed_error";
|
|
135
|
+
constructor(message = "engine has been disposed; further calls are not permitted") {
|
|
136
|
+
super(message);
|
|
137
|
+
this.name = "engine_disposed_error";
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
var claude_cli_error = class extends Error {
|
|
141
|
+
kind = "claude_cli_error";
|
|
142
|
+
reason;
|
|
143
|
+
status;
|
|
144
|
+
stderr_snippet;
|
|
145
|
+
constructor(reason, message, metadata = {}) {
|
|
146
|
+
super(message);
|
|
147
|
+
this.name = "claude_cli_error";
|
|
148
|
+
this.reason = reason;
|
|
149
|
+
this.status = metadata.status;
|
|
150
|
+
this.stderr_snippet = metadata.stderr_snippet;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
var provider_auth_error = class extends Error {
|
|
154
|
+
kind = "provider_auth_error";
|
|
155
|
+
provider;
|
|
156
|
+
refresh_command;
|
|
157
|
+
constructor(provider, message, metadata = {}) {
|
|
158
|
+
super(message);
|
|
159
|
+
this.name = "provider_auth_error";
|
|
160
|
+
this.provider = provider;
|
|
161
|
+
this.refresh_command = metadata.refresh_command;
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
/**
|
|
165
|
+
* A generate call that set a schema finished for a reason other than 'stop'
|
|
166
|
+
* (content_filter, length, max_steps, tool_calls), so no schema-validated
|
|
167
|
+
* value exists and validation was never attempted. Carries the raw model text
|
|
168
|
+
* and the last provider-reported payload, so a guardrail trace or other
|
|
169
|
+
* block detail stays reachable from the catch. Distinct from
|
|
170
|
+
* schema_validation_error, which covers a response that completed normally
|
|
171
|
+
* and then failed validation after its repair attempts ran out.
|
|
172
|
+
*/
|
|
173
|
+
var incomplete_generation_error = class extends Error {
|
|
174
|
+
kind = "incomplete_generation_error";
|
|
175
|
+
finish_reason;
|
|
176
|
+
raw_text;
|
|
177
|
+
provider_reported;
|
|
178
|
+
constructor(finish_reason, raw_text, provider_reported) {
|
|
179
|
+
super(`generation finished with '${finish_reason}' before a schema-validated response was produced`);
|
|
180
|
+
this.name = "incomplete_generation_error";
|
|
181
|
+
this.finish_reason = finish_reason;
|
|
182
|
+
this.raw_text = raw_text;
|
|
183
|
+
this.provider_reported = provider_reported;
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/engine/providers/types.ts
|
|
188
|
+
/**
|
|
189
|
+
* Read the `transport` selector off a provider init. Defaults to 'ai_sdk';
|
|
190
|
+
* anything but the two known backends throws at construction so a typo
|
|
191
|
+
* fails loud instead of silently running the default.
|
|
192
|
+
*/
|
|
193
|
+
function resolve_transport(init, provider) {
|
|
194
|
+
const raw = init["transport"];
|
|
195
|
+
if (raw === void 0 || raw === "ai_sdk") return "ai_sdk";
|
|
196
|
+
if (raw === "native") return "native";
|
|
197
|
+
throw new engine_config_error(`${provider} provider: transport must be 'ai_sdk' or 'native', got ${JSON.stringify(raw)}`, provider);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Map raw provider usage to UsageTotals, the mapper most adapters share.
|
|
201
|
+
*
|
|
202
|
+
* Missing usage zeroes the totals. Optional fields (reasoning and cache
|
|
203
|
+
* tokens) are set only when the raw payload carries them, reading the
|
|
204
|
+
* flattened field first and the AI SDK's *_details container second.
|
|
205
|
+
*/
|
|
206
|
+
function default_normalize_usage(raw) {
|
|
207
|
+
if (raw === void 0) return {
|
|
208
|
+
input_tokens: 0,
|
|
209
|
+
output_tokens: 0
|
|
210
|
+
};
|
|
211
|
+
const totals = {
|
|
212
|
+
input_tokens: typeof raw.input_tokens === "number" ? raw.input_tokens : 0,
|
|
213
|
+
output_tokens: typeof raw.output_tokens === "number" ? raw.output_tokens : 0
|
|
214
|
+
};
|
|
215
|
+
if (typeof raw.reasoning_tokens === "number") totals.reasoning_tokens = raw.reasoning_tokens;
|
|
216
|
+
else if (typeof raw.output_token_details?.reasoning_tokens === "number") totals.reasoning_tokens = raw.output_token_details.reasoning_tokens;
|
|
217
|
+
if (typeof raw.cached_input_tokens === "number") totals.cached_input_tokens = raw.cached_input_tokens;
|
|
218
|
+
else if (typeof raw.input_token_details?.cached_tokens === "number") totals.cached_input_tokens = raw.input_token_details.cached_tokens;
|
|
219
|
+
if (typeof raw.cache_write_tokens === "number") totals.cache_write_tokens = raw.cache_write_tokens;
|
|
220
|
+
else if (typeof raw.input_token_details?.cache_creation_input_tokens === "number") totals.cache_write_tokens = raw.input_token_details.cache_creation_input_tokens;
|
|
221
|
+
return totals;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Build the standard missing-peer error: names the package and the install
|
|
225
|
+
* command so a missing peer is diagnosable from the message alone. Shared so
|
|
226
|
+
* every optional-peer failure reads identically, whether the failing
|
|
227
|
+
* `import()` names the peer directly (load_optional_peer below) or a local
|
|
228
|
+
* module that reaches the peer through its own static import (the ai_sdk
|
|
229
|
+
* turn seam in generate.ts, whose dynamic import must stay written in
|
|
230
|
+
* generate.ts for its relative specifier to resolve correctly).
|
|
231
|
+
*/
|
|
232
|
+
function missing_peer_error(peer_name, cause) {
|
|
233
|
+
const message = `missing peer dependency '${peer_name}'. Install it with: pnpm add ${peer_name}. Cause: ${cause instanceof Error ? cause.message : JSON.stringify(cause)}`;
|
|
234
|
+
return new Error(message, { cause });
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Dynamically import an optional peer dependency, rethrowing an import
|
|
238
|
+
* failure via missing_peer_error so a missing peer is diagnosable from the
|
|
239
|
+
* message alone.
|
|
240
|
+
*/
|
|
241
|
+
async function load_optional_peer(specifier) {
|
|
242
|
+
let mod;
|
|
243
|
+
try {
|
|
244
|
+
mod = await import(specifier);
|
|
245
|
+
} catch (err) {
|
|
246
|
+
throw missing_peer_error(specifier, err);
|
|
247
|
+
}
|
|
248
|
+
return mod;
|
|
249
|
+
}
|
|
250
|
+
//#endregion
|
|
251
|
+
export { tool_approval_denied_error as _, claude_cli_error as a, incomplete_generation_error as c, provider_auth_error as d, provider_capability_error as f, schema_validation_error as g, rate_limit_error as h, resolve_transport as i, model_required_error as l, provider_not_configured_error as m, load_optional_peer as n, engine_config_error as o, provider_error as p, missing_peer_error as r, engine_disposed_error as s, default_normalize_usage as t, on_chunk_error as u, tool_error as v, turn_timeout_error as y };
|
|
252
|
+
|
|
253
|
+
//# sourceMappingURL=types-kO1JoGNZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-kO1JoGNZ.js","names":[],"sources":["../src/engine/errors.ts","../src/engine/providers/types.ts"],"sourcesContent":["/**\n * Typed errors for the AI engine layer.\n *\n * This is the only source file in the engine module permitted to use the\n * `class` keyword. `Error` is a built-in and `instanceof` branching is how\n * the retry helper and composition-layer composers distinguish failure modes.\n * Every other engine file stays class-free.\n *\n * `aborted_error` is defined in the core module and re-exported here so that\n * `instanceof aborted_error` is true regardless of which layer surfaced it.\n * This is the one value-level import from core permitted in engine source;\n * see the ignores in `rules/no-core-value-import-in-engine.yml`.\n */\n\nimport type { SchemaIssue } from '#schema'\nimport type { FinishReason } from './types.js'\n\nexport { aborted_error } from '#core'\n\nexport class rate_limit_error extends Error {\n readonly kind = 'rate_limit_error' as const;\n readonly retry_after_ms: number | undefined;\n readonly attempts: number;\n readonly status: number | undefined;\n constructor(\n message: string,\n metadata: { retry_after_ms?: number; attempts?: number; status?: number } = {},\n ) {\n super(message)\n this.name = 'rate_limit_error'\n this.retry_after_ms = metadata.retry_after_ms\n this.attempts = metadata.attempts ?? 0\n this.status = metadata.status\n }\n}\n\nexport class provider_error extends Error {\n readonly kind = 'provider_error' as const;\n readonly status: number | undefined;\n readonly body: string | undefined;\n readonly cause_kind: 'provider_5xx' | 'network' | 'unknown' | undefined;\n constructor(\n message: string,\n metadata: {\n status?: number\n body?: string\n cause_kind?: 'provider_5xx' | 'network' | 'unknown'\n } = {},\n ) {\n super(message)\n this.name = 'provider_error'\n this.status = metadata.status\n this.body = metadata.body\n this.cause_kind = metadata.cause_kind\n }\n}\n\n/**\n * Turn-timeout expiry. Thrown by the engine-owned retry_turn wrapper when a\n * single invoke_turn exceeds `turn_timeout_ms` before any chunk streamed.\n * Its `kind` is the RetryFailureKind wire value `'timeout'` (not the class\n * name) on purpose: that is the discriminant classify_retryable /\n * classify_provider_error already key on, so the shared classifier treats an\n * expiry as retryable without any timeout-specific branch. A mid-stream\n * expiry never reaches here; retry_turn converts it to a non-retryable\n * stream interruption first.\n */\nexport class turn_timeout_error extends Error {\n // classify_retryable reads this off an `unknown` via read_string(err, 'kind'),\n // a dynamic access no static analysis can resolve back to this field.\n // fallow-ignore-next-line unused-class-member\n readonly kind = 'timeout' as const;\n readonly timeout_ms: number;\n readonly step_index: number | undefined;\n constructor(timeout_ms: number, step_index?: number) {\n super(`turn exceeded turn_timeout_ms budget of ${timeout_ms}ms`)\n this.name = 'turn_timeout_error'\n this.timeout_ms = timeout_ms\n this.step_index = step_index\n }\n}\n\nexport class schema_validation_error extends Error {\n // Part of the published discriminant surface: consumers switch on `kind`\n // outside this repo, so the field has no in-repo production reader.\n // fallow-ignore-next-line unused-class-member\n readonly kind = 'schema_validation_error' as const;\n readonly schema_issues: ReadonlyArray<SchemaIssue>;\n readonly raw_text: string;\n constructor(message: string, schema_issues: ReadonlyArray<SchemaIssue>, raw_text: string) {\n super(message)\n this.name = 'schema_validation_error'\n this.schema_issues = schema_issues\n this.raw_text = raw_text\n }\n}\n\nexport class tool_error extends Error {\n readonly kind = 'tool_error' as const;\n readonly tool_name: string;\n readonly tool_call_id: string;\n override readonly cause: unknown;\n constructor(\n message: string,\n metadata: { tool_name: string; tool_call_id: string; cause: unknown },\n ) {\n super(message)\n this.name = 'tool_error'\n this.tool_name = metadata.tool_name\n this.tool_call_id = metadata.tool_call_id\n this.cause = metadata.cause\n }\n}\n\nexport class tool_approval_denied_error extends Error {\n readonly kind = 'tool_approval_denied_error' as const;\n readonly tool_name: string;\n readonly step_index: number;\n readonly tool_call_id: string;\n constructor(\n message: string,\n metadata: { tool_name: string; step_index: number; tool_call_id: string },\n ) {\n super(message)\n this.name = 'tool_approval_denied_error'\n this.tool_name = metadata.tool_name\n this.step_index = metadata.step_index\n this.tool_call_id = metadata.tool_call_id\n }\n}\n\nexport class model_required_error extends Error {\n readonly kind = 'model_required_error' as const;\n constructor(\n message = 'no model specified: pass `model` to generate() or set `defaults.model` on the engine',\n ) {\n super(message)\n this.name = 'model_required_error'\n }\n}\n\nexport class provider_not_configured_error extends Error {\n readonly kind = 'provider_not_configured_error' as const;\n readonly provider: string;\n constructor(provider: string) {\n super(`provider '${provider}' is not configured on this engine`)\n this.name = 'provider_not_configured_error'\n this.provider = provider\n }\n}\n\nexport class engine_config_error extends Error {\n readonly kind = 'engine_config_error' as const;\n readonly provider: string | undefined;\n constructor(message: string, provider?: string) {\n super(message)\n this.name = 'engine_config_error'\n this.provider = provider\n }\n}\n\nexport class on_chunk_error extends Error {\n readonly kind = 'on_chunk_error' as const;\n override readonly cause: unknown;\n constructor(message: string, cause: unknown) {\n super(message)\n this.name = 'on_chunk_error'\n this.cause = cause\n }\n}\n\nexport class provider_capability_error extends Error {\n readonly kind = 'provider_capability_error' as const;\n readonly provider: string;\n readonly capability: string;\n constructor(provider: string, capability: string, detail?: string) {\n const suffix = detail !== undefined ? `: ${detail}` : ''\n super(`provider '${provider}' does not support '${capability}'${suffix}`)\n this.name = 'provider_capability_error'\n this.provider = provider\n this.capability = capability\n }\n}\n\nexport class engine_disposed_error extends Error {\n readonly kind = 'engine_disposed_error' as const;\n constructor(message = 'engine has been disposed; further calls are not permitted') {\n super(message)\n this.name = 'engine_disposed_error'\n }\n}\n\nexport type ClaudeCliErrorReason =\n | 'binary_not_found'\n | 'auth_missing'\n | 'auth_expired'\n | 'api_key_missing'\n | 'startup_timeout'\n | 'stall_timeout'\n | 'no_result_event'\n | 'result_error'\n | 'subprocess_exit'\n | 'sandbox_unavailable'\n | 'engine_disposed'\n | 'parse_error'\n\nexport class claude_cli_error extends Error {\n readonly kind = 'claude_cli_error' as const;\n readonly reason: ClaudeCliErrorReason;\n readonly status: number | undefined;\n readonly stderr_snippet: string | undefined;\n constructor(\n reason: ClaudeCliErrorReason,\n message: string,\n metadata: { status?: number; stderr_snippet?: string } = {},\n ) {\n super(message)\n this.name = 'claude_cli_error'\n this.reason = reason\n this.status = metadata.status\n this.stderr_snippet = metadata.stderr_snippet\n }\n}\n\nexport class provider_auth_error extends Error {\n readonly kind = 'provider_auth_error' as const;\n readonly provider: string;\n readonly refresh_command: string | undefined;\n constructor(\n provider: string,\n message: string,\n metadata: { refresh_command?: string } = {},\n ) {\n super(message)\n this.name = 'provider_auth_error'\n this.provider = provider\n this.refresh_command = metadata.refresh_command\n }\n}\n\n/**\n * A generate call that set a schema finished for a reason other than 'stop'\n * (content_filter, length, max_steps, tool_calls), so no schema-validated\n * value exists and validation was never attempted. Carries the raw model text\n * and the last provider-reported payload, so a guardrail trace or other\n * block detail stays reachable from the catch. Distinct from\n * schema_validation_error, which covers a response that completed normally\n * and then failed validation after its repair attempts ran out.\n */\nexport class incomplete_generation_error extends Error {\n readonly kind = 'incomplete_generation_error' as const;\n readonly finish_reason: FinishReason;\n readonly raw_text: string;\n readonly provider_reported: Record<string, unknown> | undefined;\n constructor(\n finish_reason: FinishReason,\n raw_text: string,\n provider_reported?: Record<string, unknown>,\n ) {\n super(\n `generation finished with '${finish_reason}' before a schema-validated response was produced`,\n )\n this.name = 'incomplete_generation_error'\n this.finish_reason = finish_reason\n this.raw_text = raw_text\n this.provider_reported = provider_reported\n }\n}\n","/**\n * Shared provider-adapter shape.\n *\n * Each file under src/engine/providers/ exports a factory that accepts a\n * ProviderInit shape and returns a ProviderAdapter. Factories are\n * synchronous; build_model is async so SDK loading is deferred until a model\n * is actually needed. Missing peer dependencies surface as engine_config_error\n * on first build_model call with a clear message naming the missing peer.\n *\n * Only the ai_sdk transport module (providers/ai_sdk/invoke.ts) may import\n * from `ai` or invoke generateText/streamText. ai_sdk adapters build the\n * provider model and translate parameters; they do not orchestrate the call.\n */\n\nimport type {\n ResolvedModel,\n EffortLevel,\n GenerateOptions,\n GenerateResult,\n ProviderInit,\n TurnRequest,\n TurnResult,\n UsageTotals,\n} from '../types.js'\nimport { engine_config_error } from '../errors.js'\n\n/**\n * Which backend a provider factory returns: 'ai_sdk' wraps the Vercel AI SDK\n * provider package, 'native' talks to the provider's HTTP API directly. The\n * provider name stays the same across transports so pricing keys and usage\n * fields carry over; only the wire implementation changes.\n */\nexport type ProviderTransport = 'ai_sdk' | 'native'\n\n/**\n * Read the `transport` selector off a provider init. Defaults to 'ai_sdk';\n * anything but the two known backends throws at construction so a typo\n * fails loud instead of silently running the default.\n */\nexport function resolve_transport(\n init: ProviderInit,\n provider: string,\n): ProviderTransport {\n const raw = init['transport']\n if (raw === undefined || raw === 'ai_sdk') return 'ai_sdk'\n if (raw === 'native') return 'native'\n throw new engine_config_error(\n `${provider} provider: transport must be 'ai_sdk' or 'native', got ${JSON.stringify(raw)}`,\n provider,\n )\n}\n\nexport type EffortTranslation = {\n // Outer keys are provider names, inner records hold per-provider settings,\n // matching the two-level shape merge_provider_options expects.\n provider_options: Record<string, Record<string, unknown>>\n effort_ignored: boolean\n}\n\nexport type ProviderCapability =\n | 'text'\n | 'tools'\n | 'schema'\n | 'streaming'\n | 'image_input'\n | 'reasoning'\n // Provider performs native constrained decoding (the AI SDK responseFormat /\n // Output.object path), as opposed to the prompt-for-JSON-then-extract path.\n // Distinct from 'schema': every provider can satisfy a schema via repair, but\n // only some constrain the decode to it.\n | 'structured_output'\n\nexport type RawProviderUsage = {\n input_tokens?: number\n output_tokens?: number\n reasoning_tokens?: number\n cached_input_tokens?: number\n cache_write_tokens?: number\n // Vercel AI SDK v6 also surfaces details via *Details containers; adapters\n // accept the flattened shape above for testability.\n input_token_details?: {\n cached_tokens?: number\n cache_creation_input_tokens?: number\n }\n output_token_details?: {\n reasoning_tokens?: number\n }\n [k: string]: unknown\n}\n\nexport type AiSdkProviderAdapter = {\n readonly kind: 'ai_sdk'\n readonly name: string\n readonly build_model: (model_id: string) => Promise<unknown>\n readonly translate_effort: (effort: EffortLevel) => EffortTranslation\n readonly normalize_usage: (raw: RawProviderUsage | undefined) => UsageTotals\n readonly supports: (capability: ProviderCapability) => boolean\n}\n\n/**\n * Raw-HTTP transport: implements a single turn against a provider's own\n * API with zero `ai` / `@ai-sdk/*` in its module graph. generate.ts wraps\n * invoke_turn in retry + classification + abort, so a native adapter owns only\n * request/response mapping (and streaming via TurnRequest.dispatch_chunk); it\n * MUST NOT implement its own retry. classify_error optionally overrides the\n * shared classifier; dispose is optional (keep-alive agents, connection pools).\n */\nexport type NativeProviderAdapter = {\n readonly kind: 'native'\n readonly name: string\n readonly invoke_turn: (req: TurnRequest) => Promise<TurnResult>\n readonly supports: (capability: ProviderCapability) => boolean\n readonly dispose?: () => Promise<void>\n readonly classify_error?: (err: unknown) => unknown\n}\n\nexport type ExternalAgentAdapter = {\n readonly kind: 'external'\n readonly name: string\n readonly generate: <t>(\n opts: GenerateOptions<t>,\n resolved: ResolvedModel,\n ) => Promise<GenerateResult<t>>\n readonly dispose: () => Promise<void>\n readonly supports: (capability: ProviderCapability) => boolean\n}\n\nexport type ProviderAdapter =\n | AiSdkProviderAdapter\n | NativeProviderAdapter\n | ExternalAgentAdapter\n\nexport type ProviderFactory = (init: ProviderInit) => ProviderAdapter\n\n/**\n * Map raw provider usage to UsageTotals, the mapper most adapters share.\n *\n * Missing usage zeroes the totals. Optional fields (reasoning and cache\n * tokens) are set only when the raw payload carries them, reading the\n * flattened field first and the AI SDK's *_details container second.\n */\nexport function default_normalize_usage(\n raw: RawProviderUsage | undefined,\n): UsageTotals {\n if (raw === undefined) return { input_tokens: 0, output_tokens: 0 }\n const input_tokens = typeof raw.input_tokens === 'number' ? raw.input_tokens : 0\n const output_tokens = typeof raw.output_tokens === 'number' ? raw.output_tokens : 0\n const totals: UsageTotals = { input_tokens, output_tokens }\n if (typeof raw.reasoning_tokens === 'number') totals.reasoning_tokens = raw.reasoning_tokens\n else if (typeof raw.output_token_details?.reasoning_tokens === 'number') {\n totals.reasoning_tokens = raw.output_token_details.reasoning_tokens\n }\n if (typeof raw.cached_input_tokens === 'number') totals.cached_input_tokens = raw.cached_input_tokens\n else if (typeof raw.input_token_details?.cached_tokens === 'number') {\n totals.cached_input_tokens = raw.input_token_details.cached_tokens\n }\n if (typeof raw.cache_write_tokens === 'number') totals.cache_write_tokens = raw.cache_write_tokens\n else if (typeof raw.input_token_details?.cache_creation_input_tokens === 'number') {\n totals.cache_write_tokens = raw.input_token_details.cache_creation_input_tokens\n }\n return totals\n}\n\n/**\n * Build the standard missing-peer error: names the package and the install\n * command so a missing peer is diagnosable from the message alone. Shared so\n * every optional-peer failure reads identically, whether the failing\n * `import()` names the peer directly (load_optional_peer below) or a local\n * module that reaches the peer through its own static import (the ai_sdk\n * turn seam in generate.ts, whose dynamic import must stay written in\n * generate.ts for its relative specifier to resolve correctly).\n */\nexport function missing_peer_error(peer_name: string, cause: unknown): Error {\n const detail = cause instanceof Error ? cause.message : JSON.stringify(cause)\n const message =\n `missing peer dependency '${peer_name}'. Install it with: pnpm add ${peer_name}. Cause: ${detail}`\n return new Error(message, { cause })\n}\n\n/**\n * Dynamically import an optional peer dependency, rethrowing an import\n * failure via missing_peer_error so a missing peer is diagnosable from the\n * message alone.\n */\nexport async function load_optional_peer<t>(\n specifier: string,\n): Promise<t> {\n let mod: unknown\n try {\n mod = await import(specifier)\n } catch (err: unknown) {\n throw missing_peer_error(specifier, err)\n }\n // eslint-disable-next-line typescript-eslint/no-unsafe-type-assertion\n return mod as t\n}\n"],"mappings":";;AAmBA,IAAa,mBAAb,cAAsC,MAAM;CAC1C,OAAgB;CAChB;CACA;CACA;CACA,YACE,SACA,WAA4E,CAAC,GAC7E;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,iBAAiB,SAAS;EAC/B,KAAK,WAAW,SAAS,YAAY;EACrC,KAAK,SAAS,SAAS;CACzB;AACF;AAEA,IAAa,iBAAb,cAAoC,MAAM;CACxC,OAAgB;CAChB;CACA;CACA;CACA,YACE,SACA,WAII,CAAC,GACL;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,SAAS,SAAS;EACvB,KAAK,OAAO,SAAS;EACrB,KAAK,aAAa,SAAS;CAC7B;AACF;;;;;;;;;;;AAYA,IAAa,qBAAb,cAAwC,MAAM;CAI5C,OAAgB;CAChB;CACA;CACA,YAAY,YAAoB,YAAqB;EACnD,MAAM,2CAA2C,WAAW,GAAG;EAC/D,KAAK,OAAO;EACZ,KAAK,aAAa;EAClB,KAAK,aAAa;CACpB;AACF;AAEA,IAAa,0BAAb,cAA6C,MAAM;CAIjD,OAAgB;CAChB;CACA;CACA,YAAY,SAAiB,eAA2C,UAAkB;EACxF,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,gBAAgB;EACrB,KAAK,WAAW;CAClB;AACF;AAEA,IAAa,aAAb,cAAgC,MAAM;CACpC,OAAgB;CAChB;CACA;CACA;CACA,YACE,SACA,UACA;EACA,MAAM,OAAO;EACb,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B,UAAU,OAAO,sBAAsB,IAAI;MAC7E,IAAI,OAAO,IAAI,qBAAqB,kBAAkB,UACzD,OAAO,sBAAsB,IAAI,oBAAoB;CAEvD,IAAI,OAAO,IAAI,uBAAuB,UAAU,OAAO,qBAAqB,IAAI;MAC3E,IAAI,OAAO,IAAI,qBAAqB,gCAAgC,UACvE,OAAO,qBAAqB,IAAI,oBAAoB;CAEtD,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,mBAAmB,WAAmB,OAAuB;CAE3E,MAAM,UACJ,4BAA4B,UAAU,+BAA+B,UAAU,WAFlE,iBAAiB,QAAQ,MAAM,UAAU,KAAK,UAAU,KAAK;CAG5E,OAAO,IAAI,MAAM,SAAS,EAAE,MAAM,CAAC;AACrC;;;;;;AAOA,eAAsB,mBACpB,WACY;CACZ,IAAI;CACJ,IAAI;EACF,MAAM,MAAM,OAAO;CACrB,SAAS,KAAc;EACrB,MAAM,mBAAmB,WAAW,GAAG;CACzC;CAEA,OAAO;AACT"}
|
package/dist/ui.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UIMessageChunk } from "ai";
|
|
1
|
+
import { o as TrajectoryEvent } from "./types-BDSbSUAO.js";
|
|
3
2
|
import { ServerResponse } from "node:http";
|
|
3
|
+
import { UIMessageChunk } from "ai";
|
|
4
4
|
|
|
5
5
|
//#region src/ui/to_ui_message_stream.d.ts
|
|
6
6
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fascicle",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.3",
|
|
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",
|
|
@@ -80,7 +80,9 @@
|
|
|
80
80
|
"#viewer": "./src/viewer/index.ts",
|
|
81
81
|
"#agents": "./src/agents/index.ts",
|
|
82
82
|
"#stdio": "./src/stdio/index.ts",
|
|
83
|
-
"#ui": "./src/ui/index.ts"
|
|
83
|
+
"#ui": "./src/ui/index.ts",
|
|
84
|
+
"#policy": "./src/policy/index.ts",
|
|
85
|
+
"#schema": "./src/schema/index.ts"
|
|
84
86
|
},
|
|
85
87
|
"bin": {
|
|
86
88
|
"fascicle-viewer": "./dist/bin/fascicle-viewer.js"
|
|
@@ -121,18 +123,18 @@
|
|
|
121
123
|
},
|
|
122
124
|
"peerDependencies": {
|
|
123
125
|
"@ai-sdk/amazon-bedrock": "^5.0.0",
|
|
124
|
-
"@aws-sdk/credential-providers": "^3.0.0",
|
|
125
126
|
"@ai-sdk/anthropic": "^4.0.0",
|
|
126
127
|
"@ai-sdk/google": "^4.0.0",
|
|
127
128
|
"@ai-sdk/openai": "^4.0.0",
|
|
128
129
|
"@ai-sdk/openai-compatible": "^3.0.0",
|
|
129
130
|
"@ai-sdk/otel": "^1.0.0",
|
|
131
|
+
"@aws-sdk/credential-providers": "^3.0.0",
|
|
130
132
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
131
133
|
"@openrouter/ai-sdk-provider": "^3.0.0",
|
|
132
134
|
"@opentelemetry/api": "^1.9.0",
|
|
133
135
|
"ai": "^7.0.0",
|
|
134
136
|
"ai-sdk-ollama": "^4.0.0",
|
|
135
|
-
"zod": "
|
|
137
|
+
"zod": "4.4.3"
|
|
136
138
|
},
|
|
137
139
|
"peerDependenciesMeta": {
|
|
138
140
|
"@ai-sdk/amazon-bedrock": {
|
|
@@ -144,6 +146,9 @@
|
|
|
144
146
|
"@ai-sdk/anthropic": {
|
|
145
147
|
"optional": true
|
|
146
148
|
},
|
|
149
|
+
"ai": {
|
|
150
|
+
"optional": true
|
|
151
|
+
},
|
|
147
152
|
"@ai-sdk/google": {
|
|
148
153
|
"optional": true
|
|
149
154
|
},
|
|
@@ -167,6 +172,9 @@
|
|
|
167
172
|
},
|
|
168
173
|
"ai-sdk-ollama": {
|
|
169
174
|
"optional": true
|
|
175
|
+
},
|
|
176
|
+
"zod": {
|
|
177
|
+
"optional": true
|
|
170
178
|
}
|
|
171
179
|
},
|
|
172
180
|
"devDependencies": {
|
|
@@ -174,11 +182,14 @@
|
|
|
174
182
|
"@ast-grep/cli": "0.44.1",
|
|
175
183
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
176
184
|
"@opentelemetry/sdk-trace-base": "2.9.0",
|
|
185
|
+
"@standard-schema/spec": "1.1.0",
|
|
177
186
|
"@stryker-mutator/core": "9.6.1",
|
|
178
187
|
"@stryker-mutator/vitest-runner": "9.6.1",
|
|
179
188
|
"@types/node": "26.1.0",
|
|
180
189
|
"@vitest/coverage-v8": "4.1.10",
|
|
181
|
-
"
|
|
190
|
+
"ai": "7.0.17",
|
|
191
|
+
"arktype": "2.2.3",
|
|
192
|
+
"checkride": "0.12.1",
|
|
182
193
|
"cspell": "10.0.1",
|
|
183
194
|
"fallow": "3.6.0",
|
|
184
195
|
"markdownlint-cli2": "0.23.0",
|