fascicle 0.4.0 → 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/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.4.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.4.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 DEFAULT_ALIASES = Object.freeze({
3368
- "claude-opus": {
3369
- provider: "anthropic",
3370
- model_id: "claude-opus-4-7"
3371
- },
3372
- opus: {
3373
- provider: "anthropic",
3374
- model_id: "claude-opus-4-7"
3375
- },
3376
- "claude-sonnet": {
3377
- provider: "anthropic",
3378
- model_id: "claude-sonnet-4-6"
3379
- },
3380
- sonnet: {
3381
- provider: "anthropic",
3382
- model_id: "claude-sonnet-4-6"
3383
- },
3384
- "claude-haiku": {
3385
- provider: "anthropic",
3386
- model_id: "claude-haiku-4-5"
3387
- },
3388
- haiku: {
3389
- provider: "anthropic",
3390
- model_id: "claude-haiku-4-5"
3391
- },
3392
- "cli-opus": {
3393
- provider: "claude_cli",
3394
- model_id: "claude-opus-4-7"
3395
- },
3396
- "cli-sonnet": {
3397
- provider: "claude_cli",
3398
- model_id: "claude-sonnet-4-6"
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 identifier to a concrete `{ provider, model_id }`.
3415
+ * Resolve a `(model, provider)` pair to a concrete `{ provider, model_id }`.
3451
3416
  *
3452
- * 1. If `model` contains a colon and the prefix matches a known provider name,
3453
- * split on the FIRST colon only and return `{ provider, model_id }`. This
3454
- * lets OpenRouter ids like `openrouter:anthropic/claude-sonnet-4.5`
3455
- * round-trip without losing the upstream `provider/model` separator.
3456
- * 2. Otherwise look up `model` in the alias table.
3457
- * 3. Otherwise throw `model_not_found_error`.
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(table, 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 hit = table[model];
3469
- if (hit !== void 0) return hit;
3470
- throw new model_not_found_error(model, Object.keys(table));
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,
@@ -4503,10 +4488,15 @@ async function* build_stdout_lines(child, on_data) {
4503
4488
  * and skip (spec §7.1, §7.4). Neither ever throws.
4504
4489
  *
4505
4490
  * Event shapes are Zod-validated via `cli_event_schema` (a
4506
- * `z.discriminatedUnion` over the four CLI event types). Per-entry content
4507
- * arrays use `.transform` to silently drop invalid entries rather than
4508
- * rejecting the whole event — this preserves forward compatibility with
4509
- * new CLI content types.
4491
+ * `z.discriminatedUnion` over the recognized CLI event types: system,
4492
+ * assistant, user, result, rate_limit_event). Per-entry content arrays use
4493
+ * `.transform` to silently drop invalid entries rather than rejecting the
4494
+ * whole event — this preserves forward compatibility with new CLI content
4495
+ * types.
4496
+ *
4497
+ * `rate_limit_event` is informational: the CLI emits it between turns to
4498
+ * report current rate-limit budget. The parser records a structured
4499
+ * `cli_rate_limit_event` to trajectory and does not affect turn state.
4510
4500
  */
4511
4501
  const cli_usage_schema = z.object({
4512
4502
  input_tokens: z.number().optional(),
@@ -4571,11 +4561,25 @@ const result_event_schema = z.object({
4571
4561
  usage: cli_usage_schema.optional(),
4572
4562
  result: z.string().optional()
4573
4563
  });
4564
+ const rate_limit_info_schema = z.object({
4565
+ status: z.string().optional(),
4566
+ resetsAt: z.number().optional(),
4567
+ rateLimitType: z.string().optional(),
4568
+ overageStatus: z.string().optional(),
4569
+ overageResetsAt: z.number().optional(),
4570
+ isUsingOverage: z.boolean().optional()
4571
+ });
4572
+ const rate_limit_event_schema = z.object({
4573
+ type: z.literal("rate_limit_event"),
4574
+ rate_limit_info: rate_limit_info_schema.optional(),
4575
+ session_id: z.string().optional()
4576
+ });
4574
4577
  const cli_event_schema = z.discriminatedUnion("type", [
4575
4578
  system_event_schema,
4576
4579
  assistant_event_schema,
4577
4580
  user_event_schema,
4578
- result_event_schema
4581
+ result_event_schema,
4582
+ rate_limit_event_schema
4579
4583
  ]);
4580
4584
  function create_parser_state() {
4581
4585
  return {
@@ -4631,6 +4635,19 @@ function record_session_started(trajectory, session_id, model) {
4631
4635
  model
4632
4636
  });
4633
4637
  }
4638
+ function record_rate_limit(trajectory, event) {
4639
+ const info = event.rate_limit_info;
4640
+ trajectory?.record({
4641
+ kind: "cli_rate_limit_event",
4642
+ session_id: event.session_id,
4643
+ status: info?.status,
4644
+ rate_limit_type: info?.rateLimitType,
4645
+ resets_at: info?.resetsAt,
4646
+ overage_status: info?.overageStatus,
4647
+ overage_resets_at: info?.overageResetsAt,
4648
+ is_using_overage: info?.isUsingOverage
4649
+ });
4650
+ }
4634
4651
  function flush_turn(state) {
4635
4652
  state.turns.push({
4636
4653
  step_index: state.current_step_index,
@@ -4761,6 +4778,9 @@ async function handle_event(state, event, chunks, dispatch, trajectory) {
4761
4778
  case "result":
4762
4779
  await handle_result(state, event, chunks, dispatch);
4763
4780
  return;
4781
+ case "rate_limit_event":
4782
+ record_rate_limit(trajectory, event);
4783
+ return;
4764
4784
  }
4765
4785
  }
4766
4786
  async function consume_line(state, line, chunks, dispatch, trajectory) {
@@ -5009,27 +5029,69 @@ function build_generate_result(input) {
5009
5029
  * Attempt to parse `text` as JSON and validate it with `schema`. Returns a
5010
5030
  * tagged union; the caller decides whether to escalate to repair, throw, or
5011
5031
  * surface the failure.
5032
+ *
5033
+ * Even with --json-schema enforcement, models occasionally wrap structured
5034
+ * output in markdown fences and surrounding prose. We try a sequence of
5035
+ * candidates in increasing leniency: the trimmed text as-is, every fenced
5036
+ * block in the text, and the outermost {…} / […] slice. The first candidate
5037
+ * that both parses as JSON and matches the schema wins.
5038
+ *
5039
+ * When every candidate fails, we prefer the schema-validation error from the
5040
+ * FIRST candidate that parsed as JSON — that error reflects the model's
5041
+ * primary output and is what a repair prompt should feed back. Later
5042
+ * candidates (e.g. the bracket-slice fallback) often produce noisy errors
5043
+ * like "expected object, received array" that misdirect the model. Only when
5044
+ * NO candidate parses as JSON do we surface the JSON parse error.
5012
5045
  */
5013
5046
  function parse_with_schema(schema, text) {
5014
- let parsed_json;
5015
- try {
5016
- parsed_json = JSON.parse(text);
5017
- } catch (err) {
5018
- return {
5019
- ok: false,
5020
- error: err
5047
+ const candidates = json_candidates(text);
5048
+ let json_parse_error = /* @__PURE__ */ new Error("No JSON-parseable content found in model output");
5049
+ let first_schema_error;
5050
+ for (const candidate of candidates) {
5051
+ let parsed;
5052
+ try {
5053
+ parsed = JSON.parse(candidate);
5054
+ } catch (err) {
5055
+ json_parse_error = err;
5056
+ continue;
5057
+ }
5058
+ const result = schema.safeParse(parsed);
5059
+ if (result.success) return {
5060
+ ok: true,
5061
+ value: result.data
5021
5062
  };
5063
+ if (first_schema_error === void 0) first_schema_error = result.error;
5022
5064
  }
5023
- const result = schema.safeParse(parsed_json);
5024
- if (result.success) return {
5025
- ok: true,
5026
- value: result.data
5027
- };
5028
5065
  return {
5029
5066
  ok: false,
5030
- error: result.error
5067
+ error: first_schema_error ?? json_parse_error
5031
5068
  };
5032
5069
  }
5070
+ const FENCE_BLOCK = /```(?:[\w-]*)\s*\n?([\s\S]*?)\n?```/g;
5071
+ function json_candidates(text) {
5072
+ const candidates = [];
5073
+ const seen = /* @__PURE__ */ new Set();
5074
+ const push = (s) => {
5075
+ const trimmed = s.trim();
5076
+ if (trimmed.length === 0 || seen.has(trimmed)) return;
5077
+ seen.add(trimmed);
5078
+ candidates.push(trimmed);
5079
+ };
5080
+ push(text);
5081
+ for (const match of text.matchAll(FENCE_BLOCK)) {
5082
+ const body = match[1];
5083
+ if (body !== void 0) push(body);
5084
+ }
5085
+ push(slice_outermost(text, "{", "}"));
5086
+ push(slice_outermost(text, "[", "]"));
5087
+ return candidates;
5088
+ }
5089
+ function slice_outermost(text, open, close) {
5090
+ const first = text.indexOf(open);
5091
+ const last = text.lastIndexOf(close);
5092
+ if (first === -1 || last <= first) return "";
5093
+ return text.slice(first, last + 1);
5094
+ }
5033
5095
  /**
5034
5096
  * Build the canonical repair message appended after a schema parse failure.
5035
5097
  * Content mirrors spec §6.5 exactly so the repair prompt is predictable and
@@ -5038,10 +5100,18 @@ function parse_with_schema(schema, text) {
5038
5100
  function build_repair_message(zod_error) {
5039
5101
  return {
5040
5102
  role: "user",
5041
- content: `Your previous response did not match the expected schema. Error: ${format_zod_error(zod_error)}. Please provide a corrected response that strictly conforms to the schema.`
5103
+ content: build_repair_prompt_text(zod_error)
5042
5104
  };
5043
5105
  }
5044
5106
  /**
5107
+ * String form of the repair prompt for transports (subprocess CLIs) that take
5108
+ * a single stdin string rather than a Message. Same wording as
5109
+ * build_repair_message so the on-wire instruction is identical across providers.
5110
+ */
5111
+ function build_repair_prompt_text(zod_error) {
5112
+ return `Your previous response did not match the expected schema. Error: ${format_zod_error(zod_error)}. Please provide a corrected response that strictly conforms to the schema. Return ONLY the JSON value: no markdown code fences, no surrounding prose, no commentary.`;
5113
+ }
5114
+ /**
5045
5115
  * Throw schema_validation_error carrying the zod error and the raw model text.
5046
5116
  * Called by the orchestrator when all repair attempts are exhausted.
5047
5117
  */
@@ -5135,6 +5205,21 @@ function record_effort_ignored(trajectory, model_id) {
5135
5205
  model_id
5136
5206
  });
5137
5207
  }
5208
+ /**
5209
+ * Emit a structured event when a schema-driven generate call returns text
5210
+ * that fails parse + zod validation. Persists the raw model output and a
5211
+ * formatted zod issues summary to the trajectory so the failure is debuggable
5212
+ * without needing stdout. Spec §6.5.
5213
+ */
5214
+ function record_schema_validation_failed(trajectory, meta) {
5215
+ if (trajectory === void 0) return;
5216
+ trajectory.record({
5217
+ kind: "schema_validation_failed",
5218
+ attempt: meta.attempt,
5219
+ zod_issues: meta.zod_issues,
5220
+ raw_text: meta.raw_text
5221
+ });
5222
+ }
5138
5223
  function record_tool_approval(trajectory, kind, meta) {
5139
5224
  if (trajectory === void 0) return;
5140
5225
  trajectory.record({
@@ -5366,24 +5451,32 @@ function create_claude_cli_adapter(init) {
5366
5451
  let parsed = (await run_cli(spawn_runtime, base_args)).parsed;
5367
5452
  let parsed_content;
5368
5453
  if (opts.schema !== void 0) {
5369
- const attempt = parse_with_schema(opts.schema, parsed.final_text);
5370
- if (attempt.ok) parsed_content = attempt.value;
5371
- else {
5454
+ const max_repairs = opts.schema_repair_attempts ?? 1;
5455
+ let repairs_done = 0;
5456
+ for (;;) {
5457
+ const attempt = parse_with_schema(opts.schema, parsed.final_text);
5458
+ if (attempt.ok) {
5459
+ parsed_content = attempt.value;
5460
+ break;
5461
+ }
5462
+ record_schema_validation_failed(trajectory, {
5463
+ attempt: repairs_done === 0 ? "initial" : "repair",
5464
+ zod_issues: format_zod_error(attempt.error),
5465
+ raw_text: parsed.final_text
5466
+ });
5467
+ if (repairs_done >= max_repairs) throw new schema_validation_error(max_repairs === 0 ? "schema validation failed and repair is disabled (schema_repair_attempts: 0)" : `schema validation failed after ${String(max_repairs)} repair attempt${max_repairs === 1 ? "" : "s"}`, attempt.error, parsed.final_text);
5372
5468
  const repair_session_id = parsed.session_id;
5373
5469
  if (repair_session_id === void 0) throw new schema_validation_error("schema validation failed and no session_id available for repair", attempt.error, parsed.final_text);
5374
- const repair_prompt = "Your previous response did not match the expected schema. Return ONLY a JSON value that conforms to the provided --json-schema.";
5375
5470
  const repair_call_opts = {
5376
5471
  ...call_opts,
5377
5472
  session_id: repair_session_id
5378
5473
  };
5379
5474
  parsed = (await run_cli(spawn_runtime, {
5380
5475
  ...base_args,
5381
- stdin_text: repair_prompt,
5476
+ stdin_text: build_repair_prompt_text(attempt.error),
5382
5477
  call_opts: repair_call_opts
5383
5478
  })).parsed;
5384
- const retry = parse_with_schema(opts.schema, parsed.final_text);
5385
- if (!retry.ok) throw new schema_validation_error("schema validation failed after one repair attempt", retry.error, parsed.final_text);
5386
- parsed_content = retry.value;
5479
+ repairs_done += 1;
5387
5480
  }
5388
5481
  }
5389
5482
  const result_input = {
@@ -6323,16 +6416,21 @@ function classify_ai_sdk_error(err) {
6323
6416
  }
6324
6417
  async function generate(opts_in, engine) {
6325
6418
  if (opts_in.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts_in.abort.reason });
6326
- const resolved_model = opts_in.model ?? engine.default_model;
6327
- if (resolved_model === void 0) throw new engine_config_error("model is required: pass `model` on generate()/model_call() or set `defaults.model` on create_engine");
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";
6328
6422
  const merged_provider_options = merge_provider_options(engine.default_provider_options, opts_in.provider_options);
6329
6423
  const opts = {
6330
6424
  ...opts_in,
6331
- model: resolved_model
6425
+ model: resolved_model,
6426
+ provider: resolved_provider
6332
6427
  };
6333
6428
  if (opts_in.system === void 0 && engine.default_system !== void 0) opts.system = engine.default_system;
6334
6429
  if (merged_provider_options !== void 0) opts.provider_options = merged_provider_options;
6335
- const target = resolve_model(engine.aliases, resolved_model);
6430
+ const target = resolve_model(resolved_model, resolved_provider, {
6431
+ families: engine.families,
6432
+ aliases: engine.aliases
6433
+ });
6336
6434
  const adapter = engine.adapters.get(target.provider);
6337
6435
  if (adapter === void 0) throw new provider_not_configured_error(target.provider);
6338
6436
  if (adapter.kind === "subprocess") return adapter.generate(opts, target);
@@ -6474,6 +6572,11 @@ async function generate(opts_in, engine) {
6474
6572
  schema_satisfied = true;
6475
6573
  break;
6476
6574
  }
6575
+ record_schema_validation_failed(trajectory, {
6576
+ attempt: repair_remaining === schema_repair_attempts ? "initial" : "repair",
6577
+ zod_issues: format_zod_error(parse.error),
6578
+ raw_text: text
6579
+ });
6477
6580
  if (repair_remaining <= 0 || total_steps >= max_steps) throw_schema_validation(parse.error, text);
6478
6581
  repair_remaining -= 1;
6479
6582
  messages_mutable.push(build_repair_message(parse.error));
@@ -6581,8 +6684,14 @@ function build_provider_adapters(providers) {
6581
6684
  function create_engine(config) {
6582
6685
  if (config.providers === null || typeof config.providers !== "object") throw new engine_config_error("EngineConfig.providers is required");
6583
6686
  const adapters = build_provider_adapters(config.providers);
6584
- const aliases = { ...DEFAULT_ALIASES };
6687
+ const aliases = {};
6585
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
+ };
6586
6695
  const pricing = { ...DEFAULT_PRICING };
6587
6696
  if (config.pricing !== void 0) for (const [key, value] of Object.entries(config.pricing)) pricing[key] = value;
6588
6697
  const defaults = config.defaults;
@@ -6591,12 +6700,14 @@ function create_engine(config) {
6591
6700
  const default_max_steps = defaults?.max_steps ?? config.default_max_steps ?? 10;
6592
6701
  const get_internals = () => ({
6593
6702
  aliases,
6703
+ families,
6594
6704
  pricing,
6595
6705
  adapters,
6596
6706
  default_retry,
6597
6707
  default_effort,
6598
6708
  default_max_steps,
6599
6709
  ...defaults?.model !== void 0 ? { default_model: defaults.model } : {},
6710
+ ...defaults?.provider !== void 0 ? { default_provider: defaults.provider } : {},
6600
6711
  ...defaults?.system !== void 0 ? { default_system: defaults.system } : {},
6601
6712
  ...defaults?.tool_error_policy !== void 0 ? { default_tool_error_policy: defaults.tool_error_policy } : {},
6602
6713
  ...defaults?.schema_repair_attempts !== void 0 ? { default_schema_repair_attempts: defaults.schema_repair_attempts } : {},
@@ -6661,6 +6772,7 @@ function create_engine(config) {
6661
6772
  function stable_signature(input) {
6662
6773
  const payload = JSON.stringify({
6663
6774
  model: input.model ?? null,
6775
+ provider: input.provider ?? null,
6664
6776
  system: input.system ?? null,
6665
6777
  has_tools: input.has_tools,
6666
6778
  has_schema: input.has_schema
@@ -6675,6 +6787,7 @@ function model_call(cfg) {
6675
6787
  has_schema
6676
6788
  };
6677
6789
  if (cfg.model !== void 0) signature_input.model = cfg.model;
6790
+ if (cfg.provider !== void 0) signature_input.provider = cfg.provider;
6678
6791
  if (cfg.system !== void 0) signature_input.system = cfg.system;
6679
6792
  const step_id = cfg.id ?? `model_call:${stable_signature(signature_input)}`;
6680
6793
  const describe_config = {
@@ -6682,6 +6795,7 @@ function model_call(cfg) {
6682
6795
  has_schema
6683
6796
  };
6684
6797
  if (cfg.model !== void 0) describe_config.model = cfg.model;
6798
+ if (cfg.provider !== void 0) describe_config.provider = cfg.provider;
6685
6799
  if (cfg.system !== void 0) describe_config.system = cfg.system;
6686
6800
  if (cfg.effort !== void 0) describe_config.effort = cfg.effort;
6687
6801
  const inner = step(step_id, async (input, ctx) => {
@@ -6701,6 +6815,7 @@ function model_call(cfg) {
6701
6815
  trajectory: ctx.trajectory
6702
6816
  };
6703
6817
  if (cfg.model !== void 0) opts.model = cfg.model;
6818
+ if (cfg.provider !== void 0) opts.provider = cfg.provider;
6704
6819
  if (cfg.system !== void 0) opts.system = cfg.system;
6705
6820
  if (cfg.tools !== void 0) opts.tools = [...cfg.tools];
6706
6821
  if (cfg.schema !== void 0) opts.schema = cfg.schema;