fascicle 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +44 -0
- package/README.md +1 -1
- package/dist/index.d.ts +18 -3
- package/dist/index.js +101 -99
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.5.0 — 2026-06-03
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- Two-axis model resolution. `model` now names either a **family** (`opus`, `sonnet`, `haiku`, `gpt`, `gemini` — "latest of that family") or a specific vendor id (`claude-opus-4-8`), and a new `provider` axis names the transport (`anthropic`, `claude_cli`, `openrouter`, …). `provider` is accepted per-call on `generate` / `model_call` and as an engine default; the same `model: 'opus'` now runs on any transport by swapping `provider`.
|
|
7
|
+
- `MODEL_FAMILIES` catalog mapping each family to the latest id per provider, plus a `families` engine-config field that deep-merges per `(family, provider)` so you can pin newer ids or add new families. Exported `FamilyCatalog` type.
|
|
8
|
+
- `examples/swebench`: `claude_cli` provider option, selectable via `SWEBENCH_PROVIDER`.
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Breaking.** `create_engine` no longer ships default aliases — the alias table starts empty and is reserved for your own named pins. The built-in `cli-*`, `or:*`, `gemini-pro`/`gemini-flash`, and `gpt-4o*` aliases are gone; use `{ model, provider }` pairs (e.g. `{ model: 'sonnet', provider: 'claude_cli' }`) or the colon form (`openrouter:meta-llama/llama-3.3-70b-instruct`).
|
|
12
|
+
- **Breaking.** `resolve_model` signature is now `resolve_model(model, provider, { families, aliases })`. Resolution order: colon-form `provider:id` → user alias → family lookup → pass-through specific id. When `model`/`provider` are omitted, `model` defaults to `sonnet` and `provider` resolves to per-call → `defaults.provider` → the sole configured provider → `anthropic`.
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- A family with no entry for the chosen provider (e.g. `opus` on `openai`) now throws the descriptive `model_family_unavailable_error` instead of the generic not-found path.
|
|
16
|
+
|
|
17
|
+
## v0.4.3 — 2026-05-10
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
- `examples/swebench` — 5-instance smoke harness against SWE-bench Verified. Ships a `Sandbox` seam (`noop` / `local` / `docker` factories), five per-case tools (`read_file`, `write_file`, `run_command` argv-only, `list_files`, `grep_files`), a `solve_instance` flow that captures `git diff` against `base_commit`, and `evaluate_with_sb_cli` for the real eval. Scaling to the 500-instance Verified set is a scale change, not a shape change.
|
|
21
|
+
- `examples/pr-improve` Phase C, PR B: builder dispatches by provider. `make_builder_call` now takes `worktree_root` and `provider` explicit params; under `claude_cli` it keeps the schema-only path that delegates to the CLI's built-in Read/Write/Edit, and under API providers (`anthropic`, `openrouter`) it returns a `model_call` configured with the worktree-scoped tools from `make_builder_tools(worktree_root)`. The `Step<string, GenerateResult<Handoff>>` contract is unchanged; `flow.ts` ripples in one place via a new `FlowEnv = { worktree_root, provider }` arg to `build_flow`. The portability proof — same end-to-end result under `--provider claude_cli` and `--provider anthropic` — is now live.
|
|
22
|
+
|
|
23
|
+
### Internal
|
|
24
|
+
- `examples/pr-improve`: split `CLOUD_SPEC.md` out as the active spec for the remaining AWS/Fargate/Terraform deployment work (Fargate worker, webhook Lambda, single Terraform module). `SPEC.md` keeps a deprecation banner and is preserved as historical context.
|
|
25
|
+
- `examples/pr-improve` `post_improvement_pr`: dropped the "re-run with `--provider claude_cli`" hint from the no-edits follow-up message, now obsolete since API providers also edit files.
|
|
26
|
+
- `vitest.config.ts`: include `examples/pr-improve/src/stages/**/*.{test,spec}.ts` so the new builder-dispatch test runs alongside the tool tests.
|
|
27
|
+
|
|
28
|
+
## v0.4.2 — 2026-05-09
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- `examples/pr-improve` Phase C, PR A: worktree-scoped builder tools and a safety harness. The builder runs in an isolated git worktree (clean cwd, branch named `fascicle/improve-<n>`) and gets bounded `read_file`, `write_file`, `edit_file`, `list_dir`, and `run_shell` tools that refuse paths outside the worktree, follow no symlinks past the root, and cap stdout/stderr per call.
|
|
32
|
+
- `@repo/engine` `claude_cli` provider: typed parsing for `rate_limit_event` stream lines. Trajectories now record a structured `cli_rate_limit_event` (status, rate-limit type, reset times, overage flag) instead of falling through to opaque `cli_unknown_event` blobs. Every field is optional in the schema for forward-compat with future CLI variants.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
- `@repo/engine` `parse_with_schema` now surfaces the first parseable candidate's schema-validation error, not the last. With multi-candidate JSON extraction (text → fenced blocks → outermost-brace slice → outermost-bracket slice), the bracket-slice fallback could grab an inner array and produce an "expected object, received array" error that buried the real shape mismatch and actively misdirected the schema-repair prompt. The first JSON-parseable candidate represents the model's intent and is what repair feedback should describe.
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
- `examples/pr-improve` stage prompts: the pragmatist, builder, and build-reviewer system prompts now describe their JSON output contracts explicitly — exact field names, length caps, and an emphatic "JSON only" footer (especially important for the builder, which uses tools and was previously ending its turn with markdown narration). Without the schema spelled out, models invented field names (`id` for `suggestion_id`, `summary` for `one_liner`) or exceeded the 120-char `one_liner` cap, exhausting the schema-repair budget.
|
|
39
|
+
- `examples/pr-improve` `run_shell` (auto-applied via PR #5): stream-byte caps now use `Buffer.byteLength` instead of UTF-16 string length, so non-ASCII output is truncated at the correct byte count. Promise settlement is deferred to the `close` event so `AbortController`-driven timeouts return `RunShellOutput { timed_out: true }` instead of always rejecting from the abort-triggered `error` event. Spawn environment strips `ANTHROPIC_*`, `GITHUB_*`, and `AWS_*` keys to prevent credential exfiltration via model-controlled commands.
|
|
40
|
+
- `examples/pr-improve` `read_file` / `edit_file` (auto-applied via PR #5): replaced the post-assert `stat()` with `lstat()`, closing a race window where a symlink swapped in after the initial symlink guard could be silently followed.
|
|
41
|
+
- `examples/pr-improve` `claude_cli` stall timeout bumped from the 5-minute default to 15 minutes. The default watchdog tripped on legitimate long thinking phases when the CLI's between-turn heartbeat events (session/rate-limit) fired infrequently.
|
|
42
|
+
- `examples/pr-improve` `run_shell` error narrowing now uses `'code' in err` type guards instead of unsafe casts to `{ code?: unknown }`. The auto-applied improvement landed casts that the project's `no-unsafe-type-assertion` rule rejected, breaking `pnpm check` on main.
|
|
43
|
+
|
|
44
|
+
### Internal
|
|
45
|
+
- `examples/pr-improve` docs: marked Phase B done and detailed the Phase C tool surface.
|
|
46
|
+
|
|
3
47
|
## v0.4.1 — 2026-05-09
|
|
4
48
|
|
|
5
49
|
### Added
|
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ try {
|
|
|
78
78
|
|
|
79
79
|
Plus `run`, `run.stream`, and `describe`.
|
|
80
80
|
|
|
81
|
-
**AI engine.** `create_engine(config)` returns one `generate` surface across seven providers.
|
|
81
|
+
**AI engine.** `create_engine(config)` returns one `generate` surface across seven providers. Two axes: `model` names a family (`sonnet`, `opus`, `gpt` — latest of that family) or a specific id (`claude-opus-4-8`), and `provider` names the transport (`anthropic`, `claude_cli`, `openrouter`, …) — so the same `model: 'opus'` runs anywhere. Reasoning effort (`'low' | 'medium' | 'high'`) is translated per provider. Cost estimation uses a pricing table with per-engine overrides.
|
|
82
82
|
|
|
83
83
|
**Adapters injected per run.** Trajectory loggers and checkpoint stores ship under the `fascicle/adapters` subpath:
|
|
84
84
|
|
package/dist/index.d.ts
CHANGED
|
@@ -325,7 +325,7 @@ type CustomTrajectoryEvent = z.infer<typeof custom_event_schema>;
|
|
|
325
325
|
type ParsedTrajectoryEvent = z.infer<typeof trajectory_event_schema>;
|
|
326
326
|
//#endregion
|
|
327
327
|
//#region packages/core/src/version.d.ts
|
|
328
|
-
declare const version = "0.
|
|
328
|
+
declare const version = "0.5.0";
|
|
329
329
|
//#endregion
|
|
330
330
|
//#region packages/core/src/index.d.ts
|
|
331
331
|
declare const flow_schema: {
|
|
@@ -977,7 +977,7 @@ declare function read_baseline(path: string): Promise<BenchReport>;
|
|
|
977
977
|
declare function write_baseline(path: string, report: BenchReport): Promise<void>;
|
|
978
978
|
//#endregion
|
|
979
979
|
//#region packages/engine/src/version.d.ts
|
|
980
|
-
declare const version$1 = "0.
|
|
980
|
+
declare const version$1 = "0.5.0";
|
|
981
981
|
//#endregion
|
|
982
982
|
//#region packages/engine/src/providers/claude_cli/types.d.ts
|
|
983
983
|
/**
|
|
@@ -1048,6 +1048,11 @@ type AliasTarget = {
|
|
|
1048
1048
|
};
|
|
1049
1049
|
};
|
|
1050
1050
|
type AliasTable = Readonly<Record<string, AliasTarget>>;
|
|
1051
|
+
/**
|
|
1052
|
+
* Family catalog: family name -> provider name -> the latest model id to send
|
|
1053
|
+
* to that provider for the family. See `MODEL_FAMILIES` in aliases.ts.
|
|
1054
|
+
*/
|
|
1055
|
+
type FamilyCatalog = Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
1051
1056
|
type Pricing = {
|
|
1052
1057
|
input_per_million: number;
|
|
1053
1058
|
output_per_million: number;
|
|
@@ -1188,6 +1193,7 @@ type StreamChunk = {
|
|
|
1188
1193
|
};
|
|
1189
1194
|
type GenerateOptions<t = string> = {
|
|
1190
1195
|
model?: string;
|
|
1196
|
+
provider?: string;
|
|
1191
1197
|
prompt: string | Message[];
|
|
1192
1198
|
system?: string;
|
|
1193
1199
|
schema?: z.ZodType<t>;
|
|
@@ -1260,7 +1266,8 @@ type ProviderConfigMap = {
|
|
|
1260
1266
|
*
|
|
1261
1267
|
* | Field | Rule |
|
|
1262
1268
|
* | --------------------------------------------------------------------- | ----------------------------------------- |
|
|
1263
|
-
* | `model` | per-call wins; else default; else
|
|
1269
|
+
* | `model` | per-call wins; else default; else `sonnet` |
|
|
1270
|
+
* | `provider` | per-call wins; else default; else sole configured provider; else `anthropic` |
|
|
1264
1271
|
* | `system`, `effort`, `max_steps`, `tool_error_policy`, `schema_repair_attempts` | per-call wins (nullish coalesce) |
|
|
1265
1272
|
* | `retry_policy` | per-call replaces wholesale |
|
|
1266
1273
|
* | `provider_options` | two-level: per-provider-key shallow merge |
|
|
@@ -1268,6 +1275,7 @@ type ProviderConfigMap = {
|
|
|
1268
1275
|
*/
|
|
1269
1276
|
type EngineDefaults = {
|
|
1270
1277
|
readonly model?: string;
|
|
1278
|
+
readonly provider?: string;
|
|
1271
1279
|
readonly system?: string;
|
|
1272
1280
|
readonly effort?: EffortLevel;
|
|
1273
1281
|
readonly max_steps?: number;
|
|
@@ -1279,6 +1287,7 @@ type EngineDefaults = {
|
|
|
1279
1287
|
type EngineConfig = {
|
|
1280
1288
|
providers: ProviderConfigMap;
|
|
1281
1289
|
aliases?: AliasTable;
|
|
1290
|
+
families?: FamilyCatalog;
|
|
1282
1291
|
pricing?: PricingTable;
|
|
1283
1292
|
default_retry?: RetryPolicy;
|
|
1284
1293
|
default_effort?: EffortLevel;
|
|
@@ -1388,6 +1397,12 @@ type ModelCallConfig<T = unknown> = {
|
|
|
1388
1397
|
* `defaults.model` is used. Errors at call time if neither is set.
|
|
1389
1398
|
*/
|
|
1390
1399
|
readonly model?: string;
|
|
1400
|
+
/**
|
|
1401
|
+
* Transport for the model: `anthropic` | `claude_cli` | `openrouter` | ...
|
|
1402
|
+
* Optional: if omitted, the engine's `defaults.provider` (or sole configured
|
|
1403
|
+
* provider, else `anthropic`) is used.
|
|
1404
|
+
*/
|
|
1405
|
+
readonly provider?: string;
|
|
1391
1406
|
readonly id?: string;
|
|
1392
1407
|
readonly system?: string;
|
|
1393
1408
|
readonly tools?: ReadonlyArray<Tool>;
|
package/dist/index.js
CHANGED
|
@@ -1950,7 +1950,7 @@ const trajectory_event_schema = z.union([
|
|
|
1950
1950
|
]);
|
|
1951
1951
|
//#endregion
|
|
1952
1952
|
//#region packages/core/src/version.ts
|
|
1953
|
-
const version = "0.
|
|
1953
|
+
const version = "0.5.0";
|
|
1954
1954
|
//#endregion
|
|
1955
1955
|
//#region packages/core/src/index.ts
|
|
1956
1956
|
/**
|
|
@@ -3205,7 +3205,7 @@ function validate_report(value, path) {
|
|
|
3205
3205
|
}
|
|
3206
3206
|
//#endregion
|
|
3207
3207
|
//#region packages/engine/src/version.ts
|
|
3208
|
-
const version$1 = "0.
|
|
3208
|
+
const version$1 = "0.5.0";
|
|
3209
3209
|
//#endregion
|
|
3210
3210
|
//#region packages/engine/src/errors.ts
|
|
3211
3211
|
var rate_limit_error = class extends Error {
|
|
@@ -3283,6 +3283,20 @@ var model_not_found_error = class extends Error {
|
|
|
3283
3283
|
this.registered = registered;
|
|
3284
3284
|
}
|
|
3285
3285
|
};
|
|
3286
|
+
var model_family_unavailable_error = class extends Error {
|
|
3287
|
+
kind = "model_family_unavailable_error";
|
|
3288
|
+
family;
|
|
3289
|
+
provider;
|
|
3290
|
+
available_providers;
|
|
3291
|
+
constructor(family, provider, available_providers) {
|
|
3292
|
+
const list = available_providers.length > 0 ? available_providers.join(", ") : "(none)";
|
|
3293
|
+
super(`model family '${family}' is not available on provider '${provider}'. Providers offering this family: ${list}`);
|
|
3294
|
+
this.name = "model_family_unavailable_error";
|
|
3295
|
+
this.family = family;
|
|
3296
|
+
this.provider = provider;
|
|
3297
|
+
this.available_providers = available_providers;
|
|
3298
|
+
}
|
|
3299
|
+
};
|
|
3286
3300
|
var provider_not_configured_error = class extends Error {
|
|
3287
3301
|
kind = "provider_not_configured_error";
|
|
3288
3302
|
provider;
|
|
@@ -3364,99 +3378,52 @@ const KNOWN_PROVIDERS = new Set([
|
|
|
3364
3378
|
"openrouter",
|
|
3365
3379
|
"claude_cli"
|
|
3366
3380
|
]);
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
},
|
|
3400
|
-
"cli-haiku": {
|
|
3401
|
-
provider: "claude_cli",
|
|
3402
|
-
model_id: "claude-haiku-4-5"
|
|
3403
|
-
},
|
|
3404
|
-
"gpt-4o": {
|
|
3405
|
-
provider: "openai",
|
|
3406
|
-
model_id: "gpt-4o"
|
|
3407
|
-
},
|
|
3408
|
-
"gpt-4o-mini": {
|
|
3409
|
-
provider: "openai",
|
|
3410
|
-
model_id: "gpt-4o-mini"
|
|
3411
|
-
},
|
|
3412
|
-
"gemini-2.5-pro": {
|
|
3413
|
-
provider: "google",
|
|
3414
|
-
model_id: "gemini-2.5-pro"
|
|
3415
|
-
},
|
|
3416
|
-
"gemini-2.5-flash": {
|
|
3417
|
-
provider: "google",
|
|
3418
|
-
model_id: "gemini-2.5-flash"
|
|
3419
|
-
},
|
|
3420
|
-
"gemini-pro": {
|
|
3421
|
-
provider: "google",
|
|
3422
|
-
model_id: "gemini-2.5-pro"
|
|
3423
|
-
},
|
|
3424
|
-
"gemini-flash": {
|
|
3425
|
-
provider: "google",
|
|
3426
|
-
model_id: "gemini-2.5-flash"
|
|
3427
|
-
},
|
|
3428
|
-
"or:sonnet": {
|
|
3429
|
-
provider: "openrouter",
|
|
3430
|
-
model_id: "anthropic/claude-sonnet-4.5"
|
|
3431
|
-
},
|
|
3432
|
-
"or:opus": {
|
|
3433
|
-
provider: "openrouter",
|
|
3434
|
-
model_id: "anthropic/claude-opus-4.1"
|
|
3435
|
-
},
|
|
3436
|
-
"or:gpt-4o": {
|
|
3437
|
-
provider: "openrouter",
|
|
3438
|
-
model_id: "openai/gpt-4o"
|
|
3439
|
-
},
|
|
3440
|
-
"or:gemini-pro": {
|
|
3441
|
-
provider: "openrouter",
|
|
3442
|
-
model_id: "google/gemini-2.5-pro"
|
|
3443
|
-
},
|
|
3444
|
-
"or:llama-3.3-70b": {
|
|
3445
|
-
provider: "openrouter",
|
|
3446
|
-
model_id: "meta-llama/llama-3.3-70b-instruct"
|
|
3447
|
-
}
|
|
3381
|
+
const MODEL_FAMILIES = Object.freeze({
|
|
3382
|
+
opus: Object.freeze({
|
|
3383
|
+
anthropic: "claude-opus-4-8",
|
|
3384
|
+
claude_cli: "opus",
|
|
3385
|
+
openrouter: "anthropic/claude-opus-4.8"
|
|
3386
|
+
}),
|
|
3387
|
+
sonnet: Object.freeze({
|
|
3388
|
+
anthropic: "claude-sonnet-4-6",
|
|
3389
|
+
claude_cli: "sonnet",
|
|
3390
|
+
openrouter: "anthropic/claude-sonnet-4.5"
|
|
3391
|
+
}),
|
|
3392
|
+
haiku: Object.freeze({
|
|
3393
|
+
anthropic: "claude-haiku-4-5",
|
|
3394
|
+
claude_cli: "haiku",
|
|
3395
|
+
openrouter: "anthropic/claude-haiku-4.5"
|
|
3396
|
+
}),
|
|
3397
|
+
gpt: Object.freeze({
|
|
3398
|
+
openai: "gpt-4o",
|
|
3399
|
+
openrouter: "openai/gpt-4o"
|
|
3400
|
+
}),
|
|
3401
|
+
"gpt-mini": Object.freeze({
|
|
3402
|
+
openai: "gpt-4o-mini",
|
|
3403
|
+
openrouter: "openai/gpt-4o-mini"
|
|
3404
|
+
}),
|
|
3405
|
+
gemini: Object.freeze({
|
|
3406
|
+
google: "gemini-2.5-pro",
|
|
3407
|
+
openrouter: "google/gemini-2.5-pro"
|
|
3408
|
+
}),
|
|
3409
|
+
"gemini-flash": Object.freeze({
|
|
3410
|
+
google: "gemini-2.5-flash",
|
|
3411
|
+
openrouter: "google/gemini-2.5-flash"
|
|
3412
|
+
})
|
|
3448
3413
|
});
|
|
3449
3414
|
/**
|
|
3450
|
-
* Resolve a model
|
|
3415
|
+
* Resolve a `(model, provider)` pair to a concrete `{ provider, model_id }`.
|
|
3451
3416
|
*
|
|
3452
|
-
* 1.
|
|
3453
|
-
*
|
|
3454
|
-
*
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
3417
|
+
* 1. Colon-form `provider:id` (known provider prefix) splits on the FIRST
|
|
3418
|
+
* colon and sets both axes at once. Preserves OpenRouter `provider/model`
|
|
3419
|
+
* slugs and overrides the `provider` argument.
|
|
3420
|
+
* 2. A user-registered alias (`aliases`) returns its pinned target.
|
|
3421
|
+
* 3. A family name resolves to that family's latest id for `provider`; if the
|
|
3422
|
+
* family has no entry for `provider`, throws `model_family_unavailable_error`.
|
|
3423
|
+
* 4. Anything else is a specific vendor id: passed through verbatim to
|
|
3424
|
+
* `provider`. The vendor rejects a bogus id at call time.
|
|
3458
3425
|
*/
|
|
3459
|
-
function resolve_model(
|
|
3426
|
+
function resolve_model(model, provider, ctx) {
|
|
3460
3427
|
const colon = model.indexOf(":");
|
|
3461
3428
|
if (colon > 0) {
|
|
3462
3429
|
const prefix = model.slice(0, colon);
|
|
@@ -3465,14 +3432,32 @@ function resolve_model(table, model) {
|
|
|
3465
3432
|
model_id: model.slice(colon + 1)
|
|
3466
3433
|
};
|
|
3467
3434
|
}
|
|
3468
|
-
const
|
|
3469
|
-
if (
|
|
3470
|
-
|
|
3435
|
+
const alias = ctx.aliases[model];
|
|
3436
|
+
if (alias !== void 0) return alias;
|
|
3437
|
+
const family = ctx.families[model];
|
|
3438
|
+
if (family !== void 0) {
|
|
3439
|
+
const model_id = family[provider];
|
|
3440
|
+
if (model_id === void 0) throw new model_family_unavailable_error(model, provider, Object.keys(family));
|
|
3441
|
+
return {
|
|
3442
|
+
provider,
|
|
3443
|
+
model_id
|
|
3444
|
+
};
|
|
3445
|
+
}
|
|
3446
|
+
return {
|
|
3447
|
+
provider,
|
|
3448
|
+
model_id: model
|
|
3449
|
+
};
|
|
3471
3450
|
}
|
|
3472
3451
|
//#endregion
|
|
3473
3452
|
//#region packages/engine/src/pricing.ts
|
|
3474
3453
|
const FREE_PROVIDERS = new Set(["ollama", "lmstudio"]);
|
|
3475
3454
|
const DEFAULT_PRICING = Object.freeze({
|
|
3455
|
+
"anthropic:claude-opus-4-8": {
|
|
3456
|
+
input_per_million: 5,
|
|
3457
|
+
output_per_million: 25,
|
|
3458
|
+
cached_input_per_million: .5,
|
|
3459
|
+
cache_write_per_million: 6.25
|
|
3460
|
+
},
|
|
3476
3461
|
"anthropic:claude-opus-4-7": {
|
|
3477
3462
|
input_per_million: 5,
|
|
3478
3463
|
output_per_million: 25,
|
|
@@ -6431,16 +6416,21 @@ function classify_ai_sdk_error(err) {
|
|
|
6431
6416
|
}
|
|
6432
6417
|
async function generate(opts_in, engine) {
|
|
6433
6418
|
if (opts_in.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts_in.abort.reason });
|
|
6434
|
-
const resolved_model = opts_in.model ?? engine.default_model;
|
|
6435
|
-
|
|
6419
|
+
const resolved_model = opts_in.model ?? engine.default_model ?? "sonnet";
|
|
6420
|
+
const sole_provider = engine.adapters.size === 1 ? [...engine.adapters.keys()][0] : void 0;
|
|
6421
|
+
const resolved_provider = opts_in.provider ?? engine.default_provider ?? sole_provider ?? "anthropic";
|
|
6436
6422
|
const merged_provider_options = merge_provider_options(engine.default_provider_options, opts_in.provider_options);
|
|
6437
6423
|
const opts = {
|
|
6438
6424
|
...opts_in,
|
|
6439
|
-
model: resolved_model
|
|
6425
|
+
model: resolved_model,
|
|
6426
|
+
provider: resolved_provider
|
|
6440
6427
|
};
|
|
6441
6428
|
if (opts_in.system === void 0 && engine.default_system !== void 0) opts.system = engine.default_system;
|
|
6442
6429
|
if (merged_provider_options !== void 0) opts.provider_options = merged_provider_options;
|
|
6443
|
-
const target = resolve_model(
|
|
6430
|
+
const target = resolve_model(resolved_model, resolved_provider, {
|
|
6431
|
+
families: engine.families,
|
|
6432
|
+
aliases: engine.aliases
|
|
6433
|
+
});
|
|
6444
6434
|
const adapter = engine.adapters.get(target.provider);
|
|
6445
6435
|
if (adapter === void 0) throw new provider_not_configured_error(target.provider);
|
|
6446
6436
|
if (adapter.kind === "subprocess") return adapter.generate(opts, target);
|
|
@@ -6694,8 +6684,14 @@ function build_provider_adapters(providers) {
|
|
|
6694
6684
|
function create_engine(config) {
|
|
6695
6685
|
if (config.providers === null || typeof config.providers !== "object") throw new engine_config_error("EngineConfig.providers is required");
|
|
6696
6686
|
const adapters = build_provider_adapters(config.providers);
|
|
6697
|
-
const aliases = {
|
|
6687
|
+
const aliases = {};
|
|
6698
6688
|
if (config.aliases !== void 0) for (const [name, target] of Object.entries(config.aliases)) aliases[name] = target;
|
|
6689
|
+
const families = {};
|
|
6690
|
+
for (const [name, entry] of Object.entries(MODEL_FAMILIES)) families[name] = { ...entry };
|
|
6691
|
+
if (config.families !== void 0) for (const [name, entry] of Object.entries(config.families)) families[name] = {
|
|
6692
|
+
...families[name],
|
|
6693
|
+
...entry
|
|
6694
|
+
};
|
|
6699
6695
|
const pricing = { ...DEFAULT_PRICING };
|
|
6700
6696
|
if (config.pricing !== void 0) for (const [key, value] of Object.entries(config.pricing)) pricing[key] = value;
|
|
6701
6697
|
const defaults = config.defaults;
|
|
@@ -6704,12 +6700,14 @@ function create_engine(config) {
|
|
|
6704
6700
|
const default_max_steps = defaults?.max_steps ?? config.default_max_steps ?? 10;
|
|
6705
6701
|
const get_internals = () => ({
|
|
6706
6702
|
aliases,
|
|
6703
|
+
families,
|
|
6707
6704
|
pricing,
|
|
6708
6705
|
adapters,
|
|
6709
6706
|
default_retry,
|
|
6710
6707
|
default_effort,
|
|
6711
6708
|
default_max_steps,
|
|
6712
6709
|
...defaults?.model !== void 0 ? { default_model: defaults.model } : {},
|
|
6710
|
+
...defaults?.provider !== void 0 ? { default_provider: defaults.provider } : {},
|
|
6713
6711
|
...defaults?.system !== void 0 ? { default_system: defaults.system } : {},
|
|
6714
6712
|
...defaults?.tool_error_policy !== void 0 ? { default_tool_error_policy: defaults.tool_error_policy } : {},
|
|
6715
6713
|
...defaults?.schema_repair_attempts !== void 0 ? { default_schema_repair_attempts: defaults.schema_repair_attempts } : {},
|
|
@@ -6774,6 +6772,7 @@ function create_engine(config) {
|
|
|
6774
6772
|
function stable_signature(input) {
|
|
6775
6773
|
const payload = JSON.stringify({
|
|
6776
6774
|
model: input.model ?? null,
|
|
6775
|
+
provider: input.provider ?? null,
|
|
6777
6776
|
system: input.system ?? null,
|
|
6778
6777
|
has_tools: input.has_tools,
|
|
6779
6778
|
has_schema: input.has_schema
|
|
@@ -6788,6 +6787,7 @@ function model_call(cfg) {
|
|
|
6788
6787
|
has_schema
|
|
6789
6788
|
};
|
|
6790
6789
|
if (cfg.model !== void 0) signature_input.model = cfg.model;
|
|
6790
|
+
if (cfg.provider !== void 0) signature_input.provider = cfg.provider;
|
|
6791
6791
|
if (cfg.system !== void 0) signature_input.system = cfg.system;
|
|
6792
6792
|
const step_id = cfg.id ?? `model_call:${stable_signature(signature_input)}`;
|
|
6793
6793
|
const describe_config = {
|
|
@@ -6795,6 +6795,7 @@ function model_call(cfg) {
|
|
|
6795
6795
|
has_schema
|
|
6796
6796
|
};
|
|
6797
6797
|
if (cfg.model !== void 0) describe_config.model = cfg.model;
|
|
6798
|
+
if (cfg.provider !== void 0) describe_config.provider = cfg.provider;
|
|
6798
6799
|
if (cfg.system !== void 0) describe_config.system = cfg.system;
|
|
6799
6800
|
if (cfg.effort !== void 0) describe_config.effort = cfg.effort;
|
|
6800
6801
|
const inner = step(step_id, async (input, ctx) => {
|
|
@@ -6814,6 +6815,7 @@ function model_call(cfg) {
|
|
|
6814
6815
|
trajectory: ctx.trajectory
|
|
6815
6816
|
};
|
|
6816
6817
|
if (cfg.model !== void 0) opts.model = cfg.model;
|
|
6818
|
+
if (cfg.provider !== void 0) opts.provider = cfg.provider;
|
|
6817
6819
|
if (cfg.system !== void 0) opts.system = cfg.system;
|
|
6818
6820
|
if (cfg.tools !== void 0) opts.tools = [...cfg.tools];
|
|
6819
6821
|
if (cfg.schema !== void 0) opts.schema = cfg.schema;
|