fascicle 0.6.3 → 0.8.1

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
@@ -1,4 +1,4 @@
1
- import { n as http_logger, r as filesystem_logger, t as tee_logger } from "./tee-D_Qh_vfY.js";
1
+ import { n as http_logger, r as filesystem_logger, t as tee_logger } from "./tee-B-MeNi7d.js";
2
2
  import { createHash, randomUUID } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { mkdir, open, readFile, readdir, stat, writeFile } from "node:fs/promises";
@@ -10,7 +10,7 @@ import { generateText, stepCountIs, streamText, tool } from "ai";
10
10
  import { createServer } from "node:http";
11
11
  import { fileURLToPath } from "node:url";
12
12
  import { parseArgs } from "node:util";
13
- //#region packages/core/src/flow-schema.json
13
+ //#region src/core/flow-schema.json
14
14
  var flow_schema_default = {
15
15
  $schema: "https://json-schema.org/draft/2020-12/schema",
16
16
  $id: "https://robmclarty.dev/schemas/flow-schema.json",
@@ -296,7 +296,7 @@ var flow_schema_default = {
296
296
  }
297
297
  };
298
298
  //#endregion
299
- //#region packages/core/src/cleanup.ts
299
+ //#region src/core/cleanup.ts
300
300
  const HANDLER_TIMEOUT_MS = 5e3;
301
301
  function create_cleanup_registry(trajectory) {
302
302
  const handlers = [];
@@ -350,7 +350,7 @@ async function run_one(fn, trajectory) {
350
350
  }
351
351
  }
352
352
  //#endregion
353
- //#region packages/core/src/errors.ts
353
+ //#region src/core/errors.ts
354
354
  /**
355
355
  * Typed errors for the composition layer.
356
356
  *
@@ -415,14 +415,14 @@ var aborted_error = class extends Error {
415
415
  * cancellation. Resilience composers (`retry`, `fallback`) must rethrow these
416
416
  * rather than retry past a suspend or run a backup under an aborted context.
417
417
  *
418
- * Kept internal to @repo/core: not re-exported by index.ts, so it does not
418
+ * Kept internal to core: not re-exported by index.ts, so it does not
419
419
  * widen the public surface.
420
420
  */
421
421
  function is_control_flow_error(err) {
422
422
  return err instanceof suspended_error || err instanceof aborted_error;
423
423
  }
424
424
  //#endregion
425
- //#region packages/core/src/streaming.ts
425
+ //#region src/core/streaming.ts
426
426
  const STREAMING_HIGH_WATER_MARK = 1e4;
427
427
  function create_streaming_channel(base, high_water_mark = STREAMING_HIGH_WATER_MARK) {
428
428
  const buffer = [];
@@ -523,7 +523,7 @@ function create_streaming_channel(base, high_water_mark = STREAMING_HIGH_WATER_M
523
523
  };
524
524
  }
525
525
  //#endregion
526
- //#region packages/core/src/runner.ts
526
+ //#region src/core/runner.ts
527
527
  /**
528
528
  * Runner.
529
529
  *
@@ -763,7 +763,7 @@ function run_stream(flow, input, options = {}) {
763
763
  }
764
764
  const run = Object.assign(run_impl, { stream: run_stream });
765
765
  //#endregion
766
- //#region packages/core/src/step.ts
766
+ //#region src/core/step.ts
767
767
  /**
768
768
  * step() factory.
769
769
  *
@@ -804,7 +804,7 @@ function step(id_or_fn, maybe_fn, meta) {
804
804
  }
805
805
  register_traced_kind("step");
806
806
  //#endregion
807
- //#region packages/core/src/describe.ts
807
+ //#region src/core/describe.ts
808
808
  /**
809
809
  * describe(step) and describe.json(step) — composition introspection.
810
810
  *
@@ -950,7 +950,7 @@ function is_zod_schema(value) {
950
950
  return "_zod" in value || "_def" in value;
951
951
  }
952
952
  //#endregion
953
- //#region packages/core/src/sequence.ts
953
+ //#region src/core/sequence.ts
954
954
  /**
955
955
  * sequence: chain child outputs.
956
956
  *
@@ -987,7 +987,7 @@ function sequence(children, options) {
987
987
  }
988
988
  register_traced_kind("sequence");
989
989
  //#endregion
990
- //#region packages/core/src/parallel.ts
990
+ //#region src/core/parallel.ts
991
991
  /**
992
992
  * parallel: concurrent execution of named children.
993
993
  *
@@ -1086,7 +1086,7 @@ function parallel(members, options) {
1086
1086
  }
1087
1087
  register_traced_kind("parallel");
1088
1088
  //#endregion
1089
- //#region packages/core/src/branch.ts
1089
+ //#region src/core/branch.ts
1090
1090
  /**
1091
1091
  * branch: conditional routing.
1092
1092
  *
@@ -1123,7 +1123,7 @@ function branch(config) {
1123
1123
  }
1124
1124
  register_traced_kind("branch");
1125
1125
  //#endregion
1126
- //#region packages/core/src/map.ts
1126
+ //#region src/core/map.ts
1127
1127
  /**
1128
1128
  * map: per-item execution.
1129
1129
  *
@@ -1211,7 +1211,7 @@ function map(config) {
1211
1211
  }
1212
1212
  register_traced_kind("map");
1213
1213
  //#endregion
1214
- //#region packages/core/src/pipe.ts
1214
+ //#region src/core/pipe.ts
1215
1215
  /**
1216
1216
  * pipe: transform output.
1217
1217
  *
@@ -1242,7 +1242,7 @@ function pipe(inner, fn, options) {
1242
1242
  }
1243
1243
  register_traced_kind("pipe");
1244
1244
  //#endregion
1245
- //#region packages/core/src/retry.ts
1245
+ //#region src/core/retry.ts
1246
1246
  /**
1247
1247
  * retry: re-run on failure.
1248
1248
  *
@@ -1327,7 +1327,7 @@ function retry(inner, config) {
1327
1327
  }
1328
1328
  register_traced_kind("retry");
1329
1329
  //#endregion
1330
- //#region packages/core/src/fallback.ts
1330
+ //#region src/core/fallback.ts
1331
1331
  /**
1332
1332
  * fallback: primary-or-backup.
1333
1333
  *
@@ -1364,7 +1364,7 @@ function fallback(primary, backup, options) {
1364
1364
  }
1365
1365
  register_traced_kind("fallback");
1366
1366
  //#endregion
1367
- //#region packages/core/src/timeout.ts
1367
+ //#region src/core/timeout.ts
1368
1368
  /**
1369
1369
  * timeout: bound execution.
1370
1370
  *
@@ -1431,7 +1431,7 @@ function timeout(inner, ms, options) {
1431
1431
  }
1432
1432
  register_traced_kind("timeout");
1433
1433
  //#endregion
1434
- //#region packages/core/src/loop.ts
1434
+ //#region src/core/loop.ts
1435
1435
  /**
1436
1436
  * loop: bounded iteration with carry-state.
1437
1437
  *
@@ -1496,7 +1496,7 @@ function loop(config) {
1496
1496
  }
1497
1497
  register_traced_kind("loop");
1498
1498
  //#endregion
1499
- //#region packages/core/src/compose.ts
1499
+ //#region src/core/compose.ts
1500
1500
  /**
1501
1501
  * compose: name a composite step.
1502
1502
  *
@@ -1505,7 +1505,7 @@ register_traced_kind("loop");
1505
1505
  * the compose span — the implementation tree is preserved while the user's
1506
1506
  * intent ("this whole thing is an ensemble") is surfaced in observability.
1507
1507
  *
1508
- * Used by the @repo/composites package to make built-in patterns appear under
1508
+ * Used by the composites package to make built-in patterns appear under
1509
1509
  * their familiar names, and available to library consumers who want their own
1510
1510
  * named composites to show up in logs as first-class components.
1511
1511
  *
@@ -1531,7 +1531,7 @@ function compose(name, inner) {
1531
1531
  }
1532
1532
  register_traced_kind("compose");
1533
1533
  //#endregion
1534
- //#region packages/core/src/checkpoint.ts
1534
+ //#region src/core/checkpoint.ts
1535
1535
  /**
1536
1536
  * checkpoint: persist and resume.
1537
1537
  *
@@ -1585,7 +1585,7 @@ function checkpoint(inner, config) {
1585
1585
  }
1586
1586
  register_traced_kind("checkpoint");
1587
1587
  //#endregion
1588
- //#region packages/core/src/suspend.ts
1588
+ //#region src/core/suspend.ts
1589
1589
  /**
1590
1590
  * suspend: human-in-the-loop pause.
1591
1591
  *
@@ -1637,7 +1637,7 @@ function suspend(config) {
1637
1637
  }
1638
1638
  register_traced_kind("suspend");
1639
1639
  //#endregion
1640
- //#region packages/core/src/scope.ts
1640
+ //#region src/core/scope.ts
1641
1641
  /**
1642
1642
  * scope / stash / use: named state.
1643
1643
  *
@@ -1737,7 +1737,7 @@ register_traced_kind("scope");
1737
1737
  register_traced_kind("stash");
1738
1738
  register_traced_kind("use");
1739
1739
  //#endregion
1740
- //#region packages/core/src/step_kinds.ts
1740
+ //#region src/core/step_kinds.ts
1741
1741
  /**
1742
1742
  * Closed registry of every `Step.kind` produced by the composition layer.
1743
1743
  *
@@ -1773,7 +1773,7 @@ function is_step_kind(value) {
1773
1773
  return typeof value === "string" && STEP_KINDS.includes(value);
1774
1774
  }
1775
1775
  //#endregion
1776
- //#region packages/core/src/trajectory.ts
1776
+ //#region src/core/trajectory.ts
1777
1777
  /**
1778
1778
  * Wire-format schema for trajectory events.
1779
1779
  *
@@ -1814,22 +1814,22 @@ const trajectory_event_schema = z.union([
1814
1814
  custom_event_schema
1815
1815
  ]);
1816
1816
  //#endregion
1817
- //#region packages/core/src/version.ts
1818
- const version = "0.6.3";
1817
+ //#region src/core/version.ts
1818
+ const version = "0.8.1";
1819
1819
  //#endregion
1820
- //#region packages/core/src/index.ts
1820
+ //#region src/core/index.ts
1821
1821
  /**
1822
- * Public surface for @repo/core.
1822
+ * Public surface for core.
1823
1823
  *
1824
1824
  * Side-effect imports ensure every composer registers itself with the runner
1825
- * at module load. Importing anything from `@repo/core` populates the
1825
+ * at module load. Importing anything from `core` populates the
1826
1826
  * dispatch table with the core primitives. Built-in composites
1827
- * (adversarial, ensemble, tournament, consensus) live in @repo/composites
1827
+ * (adversarial, ensemble, tournament, consensus) live in composites
1828
1828
  * and surface through the umbrella package.
1829
1829
  */
1830
1830
  const flow_schema = flow_schema_default;
1831
1831
  //#endregion
1832
- //#region packages/composites/src/adversarial.ts
1832
+ //#region src/composites/adversarial.ts
1833
1833
  /**
1834
1834
  * adversarial: build-and-critique loop.
1835
1835
  *
@@ -1845,7 +1845,7 @@ const flow_schema = flow_schema_default;
1845
1845
  * remain unmodified user-supplied `Step` values.
1846
1846
  *
1847
1847
  * This file is the canonical example of how a user-built composite is
1848
- * structured — the entire implementation is a composition of @repo/core
1848
+ * structured — the entire implementation is a composition of core
1849
1849
  * primitives. Read it as documentation.
1850
1850
  */
1851
1851
  function build_input_from_state(s) {
@@ -1907,7 +1907,7 @@ function adversarial(config) {
1907
1907
  return compose(config.name ?? "adversarial", inner);
1908
1908
  }
1909
1909
  //#endregion
1910
- //#region packages/composites/src/consensus.ts
1910
+ //#region src/composites/consensus.ts
1911
1911
  /**
1912
1912
  * consensus: run-until-agreement.
1913
1913
  *
@@ -1953,7 +1953,7 @@ function consensus(config) {
1953
1953
  return compose(config.name ?? "consensus", inner);
1954
1954
  }
1955
1955
  //#endregion
1956
- //#region packages/composites/src/ensemble.ts
1956
+ //#region src/composites/ensemble.ts
1957
1957
  /**
1958
1958
  * ensemble: N-of-M pick-best.
1959
1959
  *
@@ -2003,7 +2003,7 @@ function ensemble(config) {
2003
2003
  return compose(config.name ?? "ensemble", inner);
2004
2004
  }
2005
2005
  //#endregion
2006
- //#region packages/composites/src/ensemble_step.ts
2006
+ //#region src/composites/ensemble_step.ts
2007
2007
  /**
2008
2008
  * ensemble_step: N-of-M pick-best with a Step-based scorer.
2009
2009
  *
@@ -2089,7 +2089,7 @@ function ensemble_step(config) {
2089
2089
  return compose(config.name ?? "ensemble_step", inner);
2090
2090
  }
2091
2091
  //#endregion
2092
- //#region packages/composites/src/improve.ts
2092
+ //#region src/composites/improve.ts
2093
2093
  /**
2094
2094
  * improve: bounded online self-improvement loop.
2095
2095
  *
@@ -2264,7 +2264,7 @@ function improve(config) {
2264
2264
  return compose(config.name ?? "improve", inner);
2265
2265
  }
2266
2266
  //#endregion
2267
- //#region packages/composites/src/learn.ts
2267
+ //#region src/composites/learn.ts
2268
2268
  /**
2269
2269
  * learn: offline self-improvement composer.
2270
2270
  *
@@ -2405,7 +2405,7 @@ function learn(config) {
2405
2405
  return compose(config.name ?? "learn", inner);
2406
2406
  }
2407
2407
  //#endregion
2408
- //#region packages/composites/src/tournament.ts
2408
+ //#region src/composites/tournament.ts
2409
2409
  /**
2410
2410
  * tournament: pairwise bracket.
2411
2411
  *
@@ -2464,7 +2464,7 @@ function tournament(config) {
2464
2464
  return compose(config.name ?? "tournament", inner);
2465
2465
  }
2466
2466
  //#endregion
2467
- //#region packages/composites/src/bench.ts
2467
+ //#region src/composites/bench.ts
2468
2468
  /**
2469
2469
  * bench: run a flow against a fixture set, score each result, return a report.
2470
2470
  *
@@ -2658,7 +2658,7 @@ function random_suffix() {
2658
2658
  return Math.random().toString(36).slice(2, 8);
2659
2659
  }
2660
2660
  //#endregion
2661
- //#region packages/composites/src/judges.ts
2661
+ //#region src/composites/judges.ts
2662
2662
  /**
2663
2663
  * Stock judges for `bench`.
2664
2664
  *
@@ -2674,7 +2674,7 @@ function random_suffix() {
2674
2674
  *
2675
2675
  * `judge_llm` is engine-agnostic: callers pass their already-configured
2676
2676
  * model_call step (Step<string, string>), which keeps composites decoupled
2677
- * from @repo/engine. The user-facing wiring lives in their own code.
2677
+ * from engine. The user-facing wiring lives in their own code.
2678
2678
  */
2679
2679
  function is_record(v) {
2680
2680
  return v !== null && typeof v === "object" && !Array.isArray(v);
@@ -2777,7 +2777,7 @@ function extract_json_object(text) {
2777
2777
  return text.slice(start, end + 1);
2778
2778
  }
2779
2779
  //#endregion
2780
- //#region packages/composites/src/regression.ts
2780
+ //#region src/composites/regression.ts
2781
2781
  /**
2782
2782
  * regression_compare: diff two BenchReports for regressions.
2783
2783
  *
@@ -2904,10 +2904,128 @@ function validate_report(value, path) {
2904
2904
  if (!Array.isArray(v.cases) || typeof v.summary !== "object" || v.summary === null) throw new Error(`baseline at ${path} missing cases/summary`);
2905
2905
  }
2906
2906
  //#endregion
2907
- //#region packages/engine/src/version.ts
2908
- const version$1 = "0.6.3";
2907
+ //#region src/engine/version.ts
2908
+ const version$1 = "0.8.1";
2909
2909
  //#endregion
2910
- //#region packages/engine/src/errors.ts
2910
+ //#region src/engine/pricing.ts
2911
+ const FREE_PROVIDERS = new Set(["ollama", "lmstudio"]);
2912
+ const DEFAULT_PRICING = Object.freeze({
2913
+ "anthropic:claude-opus-4-8": {
2914
+ input_per_million: 5,
2915
+ output_per_million: 25,
2916
+ cached_input_per_million: .5,
2917
+ cache_write_per_million: 6.25
2918
+ },
2919
+ "anthropic:claude-opus-4-7": {
2920
+ input_per_million: 5,
2921
+ output_per_million: 25,
2922
+ cached_input_per_million: .5,
2923
+ cache_write_per_million: 6.25
2924
+ },
2925
+ "anthropic:claude-opus-4-6": {
2926
+ input_per_million: 5,
2927
+ output_per_million: 25,
2928
+ cached_input_per_million: .5,
2929
+ cache_write_per_million: 6.25
2930
+ },
2931
+ "anthropic:claude-sonnet-4-6": {
2932
+ input_per_million: 3,
2933
+ output_per_million: 15,
2934
+ cached_input_per_million: .3,
2935
+ cache_write_per_million: 3.75
2936
+ },
2937
+ "anthropic:claude-haiku-4-5": {
2938
+ input_per_million: 1,
2939
+ output_per_million: 5,
2940
+ cached_input_per_million: .1,
2941
+ cache_write_per_million: 1.25
2942
+ },
2943
+ "openai:gpt-4o": {
2944
+ input_per_million: 2.5,
2945
+ output_per_million: 10,
2946
+ cached_input_per_million: 1.25
2947
+ },
2948
+ "openai:gpt-4o-mini": {
2949
+ input_per_million: .15,
2950
+ output_per_million: .6,
2951
+ cached_input_per_million: .075
2952
+ },
2953
+ "google:gemini-2.5-pro": {
2954
+ input_per_million: 1.25,
2955
+ output_per_million: 5
2956
+ },
2957
+ "google:gemini-2.5-flash": {
2958
+ input_per_million: .075,
2959
+ output_per_million: .3
2960
+ }
2961
+ });
2962
+ function pricing_key(provider, model_id) {
2963
+ return `${provider}:${model_id}`;
2964
+ }
2965
+ function round6$1(value) {
2966
+ return Math.round(value * 1e6) / 1e6;
2967
+ }
2968
+ /**
2969
+ * Compute a CostBreakdown for a single turn's usage.
2970
+ *
2971
+ * Returns undefined when pricing is absent AND the provider is not free. Free
2972
+ * providers (ollama, lmstudio) return an all-zero breakdown even with no
2973
+ * pricing entry. Callers are responsible for deduplicating pricing_missing
2974
+ * trajectory events across turns within a single generate call.
2975
+ *
2976
+ * Fields are omitted (not zeroed) when the corresponding usage is 0 for the
2977
+ * input call.
2978
+ */
2979
+ function compute_cost(usage, pricing, provider) {
2980
+ if (pricing === void 0) {
2981
+ if (!FREE_PROVIDERS.has(provider)) return void 0;
2982
+ return {
2983
+ total_usd: 0,
2984
+ input_usd: 0,
2985
+ output_usd: 0,
2986
+ currency: "USD",
2987
+ is_estimate: true
2988
+ };
2989
+ }
2990
+ const input_tokens = usage.input_tokens;
2991
+ const output_tokens = usage.output_tokens;
2992
+ const cached = usage.cached_input_tokens ?? 0;
2993
+ const cache_write = usage.cache_write_tokens ?? 0;
2994
+ const reasoning = usage.reasoning_tokens ?? 0;
2995
+ const fresh_input = Math.max(0, input_tokens - cached - cache_write);
2996
+ const cached_rate = pricing.cached_input_per_million ?? pricing.input_per_million;
2997
+ const cache_write_rate = pricing.cache_write_per_million ?? pricing.input_per_million;
2998
+ const has_reasoning_rate = pricing.reasoning_per_million !== void 0;
2999
+ const reasoning_rate = pricing.reasoning_per_million ?? pricing.output_per_million;
3000
+ const input_usd_raw = fresh_input * pricing.input_per_million / 1e6;
3001
+ const cached_usd_raw = cached * cached_rate / 1e6;
3002
+ const cache_write_usd_raw = cache_write * cache_write_rate / 1e6;
3003
+ const reasoning_usd_raw = reasoning * reasoning_rate / 1e6;
3004
+ const plain_output_usd_raw = Math.max(0, output_tokens - reasoning) * pricing.output_per_million / 1e6;
3005
+ const input_usd = round6$1(input_usd_raw);
3006
+ let output_usd_raw = plain_output_usd_raw;
3007
+ let surface_reasoning_usd;
3008
+ if (reasoning > 0) if (has_reasoning_rate) surface_reasoning_usd = round6$1(reasoning_usd_raw);
3009
+ else output_usd_raw = plain_output_usd_raw + reasoning_usd_raw;
3010
+ const output_usd = round6$1(output_usd_raw);
3011
+ let cached_input_usd;
3012
+ let cache_write_usd;
3013
+ if (cached > 0) cached_input_usd = round6$1(cached_usd_raw);
3014
+ if (cache_write > 0) cache_write_usd = round6$1(cache_write_usd_raw);
3015
+ const breakdown = {
3016
+ total_usd: round6$1(input_usd_raw + cached_usd_raw + cache_write_usd_raw + (surface_reasoning_usd !== void 0 ? reasoning_usd_raw : 0) + output_usd_raw),
3017
+ input_usd,
3018
+ output_usd,
3019
+ currency: "USD",
3020
+ is_estimate: true
3021
+ };
3022
+ if (cached_input_usd !== void 0) breakdown.cached_input_usd = cached_input_usd;
3023
+ if (cache_write_usd !== void 0) breakdown.cache_write_usd = cache_write_usd;
3024
+ if (surface_reasoning_usd !== void 0) breakdown.reasoning_usd = surface_reasoning_usd;
3025
+ return breakdown;
3026
+ }
3027
+ //#endregion
3028
+ //#region src/engine/errors.ts
2911
3029
  var rate_limit_error = class extends Error {
2912
3030
  kind = "rate_limit_error";
2913
3031
  retry_after_ms;
@@ -2971,30 +3089,11 @@ var tool_approval_denied_error = class extends Error {
2971
3089
  this.tool_call_id = metadata.tool_call_id;
2972
3090
  }
2973
3091
  };
2974
- var model_not_found_error = class extends Error {
2975
- kind = "model_not_found_error";
2976
- model;
2977
- registered;
2978
- constructor(model, registered) {
2979
- const list = registered.length > 0 ? registered.join(", ") : "(none)";
2980
- super(`model '${model}' is not registered. Available aliases: ${list}`);
2981
- this.name = "model_not_found_error";
2982
- this.model = model;
2983
- this.registered = registered;
2984
- }
2985
- };
2986
- var model_family_unavailable_error = class extends Error {
2987
- kind = "model_family_unavailable_error";
2988
- family;
2989
- provider;
2990
- available_providers;
2991
- constructor(family, provider, available_providers) {
2992
- const list = available_providers.length > 0 ? available_providers.join(", ") : "(none)";
2993
- super(`model family '${family}' is not available on provider '${provider}'. Providers offering this family: ${list}`);
2994
- this.name = "model_family_unavailable_error";
2995
- this.family = family;
2996
- this.provider = provider;
2997
- this.available_providers = available_providers;
3092
+ var model_required_error = class extends Error {
3093
+ kind = "model_required_error";
3094
+ constructor(message = "no model specified: pass `model` to generate() or set `defaults.model` on the engine") {
3095
+ super(message);
3096
+ this.name = "model_required_error";
2998
3097
  }
2999
3098
  };
3000
3099
  var provider_not_configured_error = class extends Error {
@@ -3068,206 +3167,7 @@ var provider_auth_error = class extends Error {
3068
3167
  }
3069
3168
  };
3070
3169
  //#endregion
3071
- //#region packages/engine/src/aliases.ts
3072
- const KNOWN_PROVIDERS = new Set([
3073
- "anthropic",
3074
- "openai",
3075
- "google",
3076
- "ollama",
3077
- "lmstudio",
3078
- "openrouter",
3079
- "claude_cli"
3080
- ]);
3081
- const MODEL_FAMILIES = Object.freeze({
3082
- opus: Object.freeze({
3083
- anthropic: "claude-opus-4-8",
3084
- claude_cli: "opus",
3085
- openrouter: "anthropic/claude-opus-4.8"
3086
- }),
3087
- sonnet: Object.freeze({
3088
- anthropic: "claude-sonnet-4-6",
3089
- claude_cli: "sonnet",
3090
- openrouter: "anthropic/claude-sonnet-4.5"
3091
- }),
3092
- haiku: Object.freeze({
3093
- anthropic: "claude-haiku-4-5",
3094
- claude_cli: "haiku",
3095
- openrouter: "anthropic/claude-haiku-4.5"
3096
- }),
3097
- gpt: Object.freeze({
3098
- openai: "gpt-4o",
3099
- openrouter: "openai/gpt-4o"
3100
- }),
3101
- "gpt-mini": Object.freeze({
3102
- openai: "gpt-4o-mini",
3103
- openrouter: "openai/gpt-4o-mini"
3104
- }),
3105
- gemini: Object.freeze({
3106
- google: "gemini-2.5-pro",
3107
- openrouter: "google/gemini-2.5-pro"
3108
- }),
3109
- "gemini-flash": Object.freeze({
3110
- google: "gemini-2.5-flash",
3111
- openrouter: "google/gemini-2.5-flash"
3112
- })
3113
- });
3114
- /**
3115
- * Resolve a `(model, provider)` pair to a concrete `{ provider, model_id }`.
3116
- *
3117
- * 1. Colon-form `provider:id` (known provider prefix) splits on the FIRST
3118
- * colon and sets both axes at once. Preserves OpenRouter `provider/model`
3119
- * slugs and overrides the `provider` argument.
3120
- * 2. A user-registered alias (`aliases`) returns its pinned target.
3121
- * 3. A family name resolves to that family's latest id for `provider`; if the
3122
- * family has no entry for `provider`, throws `model_family_unavailable_error`.
3123
- * 4. Anything else is a specific vendor id: passed through verbatim to
3124
- * `provider`. The vendor rejects a bogus id at call time.
3125
- */
3126
- function resolve_model(model, provider, ctx) {
3127
- const colon = model.indexOf(":");
3128
- if (colon > 0) {
3129
- const prefix = model.slice(0, colon);
3130
- if (KNOWN_PROVIDERS.has(prefix)) return {
3131
- provider: prefix,
3132
- model_id: model.slice(colon + 1)
3133
- };
3134
- }
3135
- const alias = ctx.aliases[model];
3136
- if (alias !== void 0) return alias;
3137
- const family = ctx.families[model];
3138
- if (family !== void 0) {
3139
- const model_id = family[provider];
3140
- if (model_id === void 0) throw new model_family_unavailable_error(model, provider, Object.keys(family));
3141
- return {
3142
- provider,
3143
- model_id
3144
- };
3145
- }
3146
- return {
3147
- provider,
3148
- model_id: model
3149
- };
3150
- }
3151
- //#endregion
3152
- //#region packages/engine/src/pricing.ts
3153
- const FREE_PROVIDERS = new Set(["ollama", "lmstudio"]);
3154
- const DEFAULT_PRICING = Object.freeze({
3155
- "anthropic:claude-opus-4-8": {
3156
- input_per_million: 5,
3157
- output_per_million: 25,
3158
- cached_input_per_million: .5,
3159
- cache_write_per_million: 6.25
3160
- },
3161
- "anthropic:claude-opus-4-7": {
3162
- input_per_million: 5,
3163
- output_per_million: 25,
3164
- cached_input_per_million: .5,
3165
- cache_write_per_million: 6.25
3166
- },
3167
- "anthropic:claude-opus-4-6": {
3168
- input_per_million: 5,
3169
- output_per_million: 25,
3170
- cached_input_per_million: .5,
3171
- cache_write_per_million: 6.25
3172
- },
3173
- "anthropic:claude-sonnet-4-6": {
3174
- input_per_million: 3,
3175
- output_per_million: 15,
3176
- cached_input_per_million: .3,
3177
- cache_write_per_million: 3.75
3178
- },
3179
- "anthropic:claude-haiku-4-5": {
3180
- input_per_million: 1,
3181
- output_per_million: 5,
3182
- cached_input_per_million: .1,
3183
- cache_write_per_million: 1.25
3184
- },
3185
- "openai:gpt-4o": {
3186
- input_per_million: 2.5,
3187
- output_per_million: 10,
3188
- cached_input_per_million: 1.25
3189
- },
3190
- "openai:gpt-4o-mini": {
3191
- input_per_million: .15,
3192
- output_per_million: .6,
3193
- cached_input_per_million: .075
3194
- },
3195
- "google:gemini-2.5-pro": {
3196
- input_per_million: 1.25,
3197
- output_per_million: 5
3198
- },
3199
- "google:gemini-2.5-flash": {
3200
- input_per_million: .075,
3201
- output_per_million: .3
3202
- }
3203
- });
3204
- function pricing_key(provider, model_id) {
3205
- return `${provider}:${model_id}`;
3206
- }
3207
- function round6$1(value) {
3208
- return Math.round(value * 1e6) / 1e6;
3209
- }
3210
- /**
3211
- * Compute a CostBreakdown for a single turn's usage.
3212
- *
3213
- * Returns undefined when pricing is absent AND the provider is not free. Free
3214
- * providers (ollama, lmstudio) return an all-zero breakdown even with no
3215
- * pricing entry. Callers are responsible for deduplicating pricing_missing
3216
- * trajectory events across turns within a single generate call.
3217
- *
3218
- * Fields are omitted (not zeroed) when the corresponding usage is 0 for the
3219
- * input call.
3220
- */
3221
- function compute_cost(usage, pricing, provider) {
3222
- if (pricing === void 0) {
3223
- if (!FREE_PROVIDERS.has(provider)) return void 0;
3224
- return {
3225
- total_usd: 0,
3226
- input_usd: 0,
3227
- output_usd: 0,
3228
- currency: "USD",
3229
- is_estimate: true
3230
- };
3231
- }
3232
- const input_tokens = usage.input_tokens;
3233
- const output_tokens = usage.output_tokens;
3234
- const cached = usage.cached_input_tokens ?? 0;
3235
- const cache_write = usage.cache_write_tokens ?? 0;
3236
- const reasoning = usage.reasoning_tokens ?? 0;
3237
- const fresh_input = Math.max(0, input_tokens - cached - cache_write);
3238
- const cached_rate = pricing.cached_input_per_million ?? pricing.input_per_million;
3239
- const cache_write_rate = pricing.cache_write_per_million ?? pricing.input_per_million;
3240
- const has_reasoning_rate = pricing.reasoning_per_million !== void 0;
3241
- const reasoning_rate = pricing.reasoning_per_million ?? pricing.output_per_million;
3242
- const input_usd_raw = fresh_input * pricing.input_per_million / 1e6;
3243
- const cached_usd_raw = cached * cached_rate / 1e6;
3244
- const cache_write_usd_raw = cache_write * cache_write_rate / 1e6;
3245
- const reasoning_usd_raw = reasoning * reasoning_rate / 1e6;
3246
- const plain_output_usd_raw = Math.max(0, output_tokens - reasoning) * pricing.output_per_million / 1e6;
3247
- const input_usd = round6$1(input_usd_raw);
3248
- let output_usd_raw = plain_output_usd_raw;
3249
- let surface_reasoning_usd;
3250
- if (reasoning > 0) if (has_reasoning_rate) surface_reasoning_usd = round6$1(reasoning_usd_raw);
3251
- else output_usd_raw = plain_output_usd_raw + reasoning_usd_raw;
3252
- const output_usd = round6$1(output_usd_raw);
3253
- let cached_input_usd;
3254
- let cache_write_usd;
3255
- if (cached > 0) cached_input_usd = round6$1(cached_usd_raw);
3256
- if (cache_write > 0) cache_write_usd = round6$1(cache_write_usd_raw);
3257
- const breakdown = {
3258
- total_usd: round6$1(input_usd_raw + cached_usd_raw + cache_write_usd_raw + (surface_reasoning_usd !== void 0 ? reasoning_usd_raw : 0) + output_usd_raw),
3259
- input_usd,
3260
- output_usd,
3261
- currency: "USD",
3262
- is_estimate: true
3263
- };
3264
- if (cached_input_usd !== void 0) breakdown.cached_input_usd = cached_input_usd;
3265
- if (cache_write_usd !== void 0) breakdown.cache_write_usd = cache_write_usd;
3266
- if (surface_reasoning_usd !== void 0) breakdown.reasoning_usd = surface_reasoning_usd;
3267
- return breakdown;
3268
- }
3269
- //#endregion
3270
- //#region packages/engine/src/retry.ts
3170
+ //#region src/engine/retry.ts
3271
3171
  const DEFAULT_RETRY = {
3272
3172
  max_attempts: 3,
3273
3173
  initial_delay_ms: 500,
@@ -3398,7 +3298,7 @@ function classify_retryable(err) {
3398
3298
  }
3399
3299
  }
3400
3300
  //#endregion
3401
- //#region packages/engine/src/providers/types.ts
3301
+ //#region src/engine/providers/types.ts
3402
3302
  function default_normalize_usage(raw) {
3403
3303
  if (raw === void 0) return {
3404
3304
  input_tokens: 0,
@@ -3427,7 +3327,7 @@ async function load_optional_peer(specifier) {
3427
3327
  return mod;
3428
3328
  }
3429
3329
  //#endregion
3430
- //#region packages/engine/src/providers/anthropic.ts
3330
+ //#region src/engine/providers/anthropic.ts
3431
3331
  const ANTHROPIC_THINKING_BUDGETS = {
3432
3332
  none: 0,
3433
3333
  low: 1024,
@@ -3453,7 +3353,7 @@ function translate_anthropic_effort(effort) {
3453
3353
  function normalize_anthropic_usage(raw) {
3454
3354
  return default_normalize_usage(raw);
3455
3355
  }
3456
- const SUPPORTED$6 = new Set([
3356
+ const SUPPORTED$7 = new Set([
3457
3357
  "text",
3458
3358
  "tools",
3459
3359
  "schema",
@@ -3476,11 +3376,11 @@ const create_anthropic_adapter = (init) => {
3476
3376
  },
3477
3377
  translate_effort: translate_anthropic_effort,
3478
3378
  normalize_usage: normalize_anthropic_usage,
3479
- supports: (capability) => SUPPORTED$6.has(capability)
3379
+ supports: (capability) => SUPPORTED$7.has(capability)
3480
3380
  };
3481
3381
  };
3482
3382
  //#endregion
3483
- //#region packages/engine/src/providers/openai.ts
3383
+ //#region src/engine/providers/openai.ts
3484
3384
  const OPENAI_REASONING_EFFORT = {
3485
3385
  low: "low",
3486
3386
  medium: "medium",
@@ -3501,7 +3401,7 @@ function translate_openai_effort(effort) {
3501
3401
  function normalize_openai_usage(raw) {
3502
3402
  return default_normalize_usage(raw);
3503
3403
  }
3504
- const SUPPORTED$5 = new Set([
3404
+ const SUPPORTED$6 = new Set([
3505
3405
  "text",
3506
3406
  "tools",
3507
3407
  "schema",
@@ -3526,11 +3426,11 @@ const create_openai_adapter = (init) => {
3526
3426
  },
3527
3427
  translate_effort: translate_openai_effort,
3528
3428
  normalize_usage: normalize_openai_usage,
3529
- supports: (capability) => SUPPORTED$5.has(capability)
3429
+ supports: (capability) => SUPPORTED$6.has(capability)
3530
3430
  };
3531
3431
  };
3532
3432
  //#endregion
3533
- //#region packages/engine/src/providers/google.ts
3433
+ //#region src/engine/providers/google.ts
3534
3434
  const GOOGLE_THINKING_BUDGET = {
3535
3435
  low: 1024,
3536
3436
  medium: 8192,
@@ -3557,7 +3457,7 @@ function normalize_google_usage(raw) {
3557
3457
  if (base.cache_write_tokens === void 0) delete base.cache_write_tokens;
3558
3458
  return base;
3559
3459
  }
3560
- const SUPPORTED$4 = new Set([
3460
+ const SUPPORTED$5 = new Set([
3561
3461
  "text",
3562
3462
  "tools",
3563
3463
  "schema",
@@ -3580,11 +3480,11 @@ const create_google_adapter = (init) => {
3580
3480
  },
3581
3481
  translate_effort: translate_google_effort,
3582
3482
  normalize_usage: normalize_google_usage,
3583
- supports: (capability) => SUPPORTED$4.has(capability)
3483
+ supports: (capability) => SUPPORTED$5.has(capability)
3584
3484
  };
3585
3485
  };
3586
3486
  //#endregion
3587
- //#region packages/engine/src/providers/ollama.ts
3487
+ //#region src/engine/providers/ollama.ts
3588
3488
  function translate_ollama_effort(effort) {
3589
3489
  return {
3590
3490
  provider_options: {},
@@ -3602,7 +3502,7 @@ function normalize_ollama_usage(raw) {
3602
3502
  delete base.reasoning_tokens;
3603
3503
  return base;
3604
3504
  }
3605
- const SUPPORTED$3 = new Set([
3505
+ const SUPPORTED$4 = new Set([
3606
3506
  "text",
3607
3507
  "tools",
3608
3508
  "schema",
@@ -3619,11 +3519,11 @@ const create_ollama_adapter = (init) => {
3619
3519
  },
3620
3520
  translate_effort: translate_ollama_effort,
3621
3521
  normalize_usage: normalize_ollama_usage,
3622
- supports: (capability) => SUPPORTED$3.has(capability)
3522
+ supports: (capability) => SUPPORTED$4.has(capability)
3623
3523
  };
3624
3524
  };
3625
3525
  //#endregion
3626
- //#region packages/engine/src/providers/lmstudio.ts
3526
+ //#region src/engine/providers/lmstudio.ts
3627
3527
  function translate_lmstudio_effort(effort) {
3628
3528
  return {
3629
3529
  provider_options: {},
@@ -3641,7 +3541,7 @@ function normalize_lmstudio_usage(raw) {
3641
3541
  delete base.reasoning_tokens;
3642
3542
  return base;
3643
3543
  }
3644
- const SUPPORTED$2 = new Set([
3544
+ const SUPPORTED$3 = new Set([
3645
3545
  "text",
3646
3546
  "tools",
3647
3547
  "schema",
@@ -3661,11 +3561,11 @@ const create_lmstudio_adapter = (init) => {
3661
3561
  },
3662
3562
  translate_effort: translate_lmstudio_effort,
3663
3563
  normalize_usage: normalize_lmstudio_usage,
3664
- supports: (capability) => SUPPORTED$2.has(capability)
3564
+ supports: (capability) => SUPPORTED$3.has(capability)
3665
3565
  };
3666
3566
  };
3667
3567
  //#endregion
3668
- //#region packages/engine/src/providers/openrouter.ts
3568
+ //#region src/engine/providers/openrouter.ts
3669
3569
  function translate_openrouter_effort(effort) {
3670
3570
  if (effort === "none") return {
3671
3571
  provider_options: {},
@@ -3679,7 +3579,7 @@ function translate_openrouter_effort(effort) {
3679
3579
  function normalize_openrouter_usage(raw) {
3680
3580
  return default_normalize_usage(raw);
3681
3581
  }
3682
- const SUPPORTED$1 = new Set([
3582
+ const SUPPORTED$2 = new Set([
3683
3583
  "text",
3684
3584
  "tools",
3685
3585
  "schema",
@@ -3708,11 +3608,72 @@ const create_openrouter_adapter = (init) => {
3708
3608
  },
3709
3609
  translate_effort: translate_openrouter_effort,
3710
3610
  normalize_usage: normalize_openrouter_usage,
3611
+ supports: (capability) => SUPPORTED$2.has(capability)
3612
+ };
3613
+ };
3614
+ //#endregion
3615
+ //#region src/engine/providers/bedrock.ts
3616
+ const BEDROCK_THINKING_BUDGETS = {
3617
+ none: 0,
3618
+ low: 1024,
3619
+ medium: 5e3,
3620
+ high: 2e4,
3621
+ xhigh: 32e3,
3622
+ max: 64e3
3623
+ };
3624
+ function translate_bedrock_effort(effort) {
3625
+ const budget = BEDROCK_THINKING_BUDGETS[effort];
3626
+ if (effort === "none" || budget === 0) return {
3627
+ provider_options: {},
3628
+ effort_ignored: false
3629
+ };
3630
+ return {
3631
+ provider_options: { bedrock: { reasoningConfig: {
3632
+ type: "enabled",
3633
+ budgetTokens: budget
3634
+ } } },
3635
+ effort_ignored: false
3636
+ };
3637
+ }
3638
+ function normalize_bedrock_usage(raw) {
3639
+ return default_normalize_usage(raw);
3640
+ }
3641
+ const SUPPORTED$1 = new Set([
3642
+ "text",
3643
+ "tools",
3644
+ "schema",
3645
+ "streaming",
3646
+ "image_input",
3647
+ "reasoning"
3648
+ ]);
3649
+ const create_bedrock_adapter = (init) => {
3650
+ const region = typeof init["region"] === "string" ? init["region"] : "";
3651
+ if (region.length === 0) throw new engine_config_error("bedrock provider requires a non-empty region", "bedrock");
3652
+ const api_key = typeof init.api_key === "string" ? init.api_key : void 0;
3653
+ const access_key_id = typeof init["access_key_id"] === "string" ? init["access_key_id"] : void 0;
3654
+ const secret_access_key = typeof init["secret_access_key"] === "string" ? init["secret_access_key"] : void 0;
3655
+ const session_token = typeof init["session_token"] === "string" ? init["session_token"] : void 0;
3656
+ const base_url = typeof init.base_url === "string" ? init.base_url : void 0;
3657
+ return {
3658
+ kind: "ai_sdk",
3659
+ name: "bedrock",
3660
+ async build_model(model_id) {
3661
+ const sdk = await load_optional_peer("@ai-sdk/amazon-bedrock");
3662
+ const config = { region };
3663
+ if (api_key !== void 0) config.apiKey = api_key;
3664
+ if (access_key_id !== void 0) config.accessKeyId = access_key_id;
3665
+ if (secret_access_key !== void 0) config.secretAccessKey = secret_access_key;
3666
+ if (session_token !== void 0) config.sessionToken = session_token;
3667
+ if (base_url !== void 0) config.baseURL = base_url;
3668
+ return sdk.createAmazonBedrock(config)(model_id);
3669
+ },
3670
+ translate_effort: translate_bedrock_effort,
3671
+ normalize_usage: normalize_bedrock_usage,
3711
3672
  supports: (capability) => SUPPORTED$1.has(capability)
3712
3673
  };
3713
3674
  };
3714
3675
  //#endregion
3715
- //#region packages/engine/src/providers/claude_cli/constants.ts
3676
+ //#region src/engine/providers/claude_cli/constants.ts
3716
3677
  /**
3717
3678
  * Frozen constants for the claude_cli provider (spec §5.1 defaults, §6.3
3718
3679
  * escalation window, §10.2 cost decomposition multipliers, §11 F19 auth
@@ -3734,7 +3695,7 @@ const CLI_AUTH_ERROR_PATTERNS = Object.freeze([
3734
3695
  ]);
3735
3696
  const DEFAULT_SETTING_SOURCES = Object.freeze(["project", "local"]);
3736
3697
  //#endregion
3737
- //#region packages/engine/src/providers/claude_cli/auth.ts
3698
+ //#region src/engine/providers/claude_cli/auth.ts
3738
3699
  /**
3739
3700
  * Authentication enforcement for the claude_cli adapter (spec §4, §6.1).
3740
3701
  *
@@ -3805,7 +3766,7 @@ function stderr_is_auth_failure(stderr) {
3805
3766
  return false;
3806
3767
  }
3807
3768
  //#endregion
3808
- //#region packages/engine/src/providers/claude_cli/argv.ts
3769
+ //#region src/engine/providers/claude_cli/argv.ts
3809
3770
  function build_cli_argv(input) {
3810
3771
  const args = [];
3811
3772
  args.push("-p");
@@ -3844,7 +3805,7 @@ function merge_allowed_tools(call_allowlist, tool_names) {
3844
3805
  return merged;
3845
3806
  }
3846
3807
  //#endregion
3847
- //#region packages/engine/src/providers/claude_cli/sandbox.ts
3808
+ //#region src/engine/providers/claude_cli/sandbox.ts
3848
3809
  /**
3849
3810
  * Sandbox wrapper for the claude_cli adapter (spec §5.1, F30).
3850
3811
  *
@@ -3929,7 +3890,7 @@ function write_greywall_settings(sandbox) {
3929
3890
  return path;
3930
3891
  }
3931
3892
  //#endregion
3932
- //#region packages/engine/src/providers/claude_cli/spawn.ts
3893
+ //#region src/engine/providers/claude_cli/spawn.ts
3933
3894
  /**
3934
3895
  * Subprocess lifecycle for the claude_cli adapter (spec §6, constraints §5.10).
3935
3896
  *
@@ -4172,7 +4133,7 @@ async function* build_stdout_lines(child, on_data) {
4172
4133
  }
4173
4134
  }
4174
4135
  //#endregion
4175
- //#region packages/engine/src/providers/claude_cli/stream_parse.ts
4136
+ //#region src/engine/providers/claude_cli/stream_parse.ts
4176
4137
  /**
4177
4138
  * JSON-lines stream parser for the claude CLI stdout (spec §7).
4178
4139
  *
@@ -4530,7 +4491,7 @@ function snapshot(state) {
4530
4491
  return base;
4531
4492
  }
4532
4493
  //#endregion
4533
- //#region packages/engine/src/providers/claude_cli/cost.ts
4494
+ //#region src/engine/providers/claude_cli/cost.ts
4534
4495
  function decompose_total_cost(total_cost_usd, usage) {
4535
4496
  const input = Math.max(0, usage.input_tokens);
4536
4497
  const output = Math.max(0, usage.output_tokens);
@@ -4590,7 +4551,7 @@ function allocate_cost_across_turns(total_cost_usd, turns) {
4590
4551
  return out;
4591
4552
  }
4592
4553
  //#endregion
4593
- //#region packages/engine/src/providers/claude_cli/stream_result.ts
4554
+ //#region src/engine/providers/claude_cli/stream_result.ts
4594
4555
  function sum_usage$1(totals) {
4595
4556
  let input = 0;
4596
4557
  let output = 0;
@@ -4725,7 +4686,7 @@ function build_generate_result(input) {
4725
4686
  return result;
4726
4687
  }
4727
4688
  //#endregion
4728
- //#region packages/engine/src/schema.ts
4689
+ //#region src/engine/schema.ts
4729
4690
  /**
4730
4691
  * Attempt to parse `text` as JSON and validate it with `schema`. Returns a
4731
4692
  * tagged union; the caller decides whether to escalate to repair, throw, or
@@ -4834,7 +4795,7 @@ function format_zod_error(err) {
4834
4795
  }
4835
4796
  }
4836
4797
  //#endregion
4837
- //#region packages/engine/src/trajectory.ts
4798
+ //#region src/engine/trajectory.ts
4838
4799
  function start_generate_span(trajectory, meta) {
4839
4800
  if (trajectory === void 0) return void 0;
4840
4801
  return trajectory.start_span("engine.generate", { ...meta });
@@ -4995,7 +4956,7 @@ function create_option_ignored_dedup(trajectory) {
4995
4956
  } };
4996
4957
  }
4997
4958
  //#endregion
4998
- //#region packages/engine/src/providers/claude_cli/index.ts
4959
+ //#region src/engine/providers/claude_cli/index.ts
4999
4960
  /**
5000
4961
  * claude_cli adapter factory (spec §5.5, §6, §8, §13).
5001
4962
  *
@@ -5291,7 +5252,7 @@ function create_claude_cli_adapter(init) {
5291
5252
  };
5292
5253
  }
5293
5254
  //#endregion
5294
- //#region packages/engine/src/providers/registry.ts
5255
+ //#region src/engine/providers/registry.ts
5295
5256
  /**
5296
5257
  * Provider name → adapter factory lookup.
5297
5258
  *
@@ -5306,6 +5267,7 @@ const BUILTIN_PROVIDERS = new Map([
5306
5267
  ["ollama", create_ollama_adapter],
5307
5268
  ["lmstudio", create_lmstudio_adapter],
5308
5269
  ["openrouter", create_openrouter_adapter],
5270
+ ["bedrock", create_bedrock_adapter],
5309
5271
  ["claude_cli", create_claude_cli_adapter]
5310
5272
  ]);
5311
5273
  function get_provider_factory(name) {
@@ -5314,7 +5276,7 @@ function get_provider_factory(name) {
5314
5276
  return factory;
5315
5277
  }
5316
5278
  //#endregion
5317
- //#region packages/engine/src/merge_defaults.ts
5279
+ //#region src/engine/merge_defaults.ts
5318
5280
  /**
5319
5281
  * Default-merging helpers for engine-level `EngineDefaults`.
5320
5282
  *
@@ -5349,7 +5311,7 @@ function is_plain_object(value) {
5349
5311
  return value !== null && typeof value === "object" && !Array.isArray(value);
5350
5312
  }
5351
5313
  //#endregion
5352
- //#region packages/engine/src/streaming.ts
5314
+ //#region src/engine/streaming.ts
5353
5315
  /**
5354
5316
  * Build a dispatcher around a user-supplied on_chunk. Catches sync throws and
5355
5317
  * rejected promises; once an error is recorded subsequent dispatch calls are
@@ -5374,7 +5336,7 @@ function create_chunk_dispatcher(on_chunk) {
5374
5336
  };
5375
5337
  }
5376
5338
  //#endregion
5377
- //#region packages/engine/src/usage.ts
5339
+ //#region src/engine/usage.ts
5378
5340
  const OPTIONAL_FIELDS = [
5379
5341
  "reasoning_tokens",
5380
5342
  "cached_input_tokens",
@@ -5412,7 +5374,7 @@ function sum_usage(steps) {
5412
5374
  return total;
5413
5375
  }
5414
5376
  //#endregion
5415
- //#region packages/engine/src/tool_loop.ts
5377
+ //#region src/engine/tool_loop.ts
5416
5378
  function throw_if_aborted(abort, step_index) {
5417
5379
  if (!abort.aborted) return;
5418
5380
  throw new aborted_error("aborted", {
@@ -5876,7 +5838,7 @@ async function run_tool_loop(config) {
5876
5838
  };
5877
5839
  }
5878
5840
  //#endregion
5879
- //#region packages/engine/src/generate.ts
5841
+ //#region src/engine/generate.ts
5880
5842
  /**
5881
5843
  * generate(opts) — single public entry point for model calls.
5882
5844
  *
@@ -6208,7 +6170,8 @@ function classify_ai_sdk_error(err) {
6208
6170
  }
6209
6171
  async function generate(opts_in, engine) {
6210
6172
  if (opts_in.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts_in.abort.reason });
6211
- const resolved_model = opts_in.model ?? engine.default_model ?? "sonnet";
6173
+ const resolved_model = opts_in.model ?? engine.default_model;
6174
+ if (resolved_model === void 0) throw new model_required_error();
6212
6175
  const sole_provider = engine.adapters.size === 1 ? [...engine.adapters.keys()][0] : void 0;
6213
6176
  const resolved_provider = opts_in.provider ?? engine.default_provider ?? sole_provider ?? "anthropic";
6214
6177
  const merged_provider_options = merge_provider_options(engine.default_provider_options, opts_in.provider_options);
@@ -6219,10 +6182,10 @@ async function generate(opts_in, engine) {
6219
6182
  };
6220
6183
  if (opts_in.system === void 0 && engine.default_system !== void 0) opts.system = engine.default_system;
6221
6184
  if (merged_provider_options !== void 0) opts.provider_options = merged_provider_options;
6222
- const target = resolve_model(resolved_model, resolved_provider, {
6223
- families: engine.families,
6224
- aliases: engine.aliases
6225
- });
6185
+ const target = {
6186
+ provider: resolved_provider,
6187
+ model_id: resolved_model
6188
+ };
6226
6189
  const adapter = engine.adapters.get(target.provider);
6227
6190
  if (adapter === void 0) throw new provider_not_configured_error(target.provider);
6228
6191
  if (adapter.kind === "subprocess") return adapter.generate(opts, target);
@@ -6466,7 +6429,7 @@ function aggregate_cost(steps, provider) {
6466
6429
  return out;
6467
6430
  }
6468
6431
  //#endregion
6469
- //#region packages/engine/src/create_engine.ts
6432
+ //#region src/engine/create_engine.ts
6470
6433
  function build_provider_adapters(providers) {
6471
6434
  const adapters = /* @__PURE__ */ new Map();
6472
6435
  for (const [name, init] of Object.entries(providers)) {
@@ -6479,14 +6442,6 @@ function build_provider_adapters(providers) {
6479
6442
  function create_engine(config) {
6480
6443
  if (config.providers === null || typeof config.providers !== "object") throw new engine_config_error("EngineConfig.providers is required");
6481
6444
  const adapters = build_provider_adapters(config.providers);
6482
- const aliases = {};
6483
- if (config.aliases !== void 0) for (const [name, target] of Object.entries(config.aliases)) aliases[name] = target;
6484
- const families = {};
6485
- for (const [name, entry] of Object.entries(MODEL_FAMILIES)) families[name] = { ...entry };
6486
- if (config.families !== void 0) for (const [name, entry] of Object.entries(config.families)) families[name] = {
6487
- ...families[name],
6488
- ...entry
6489
- };
6490
6445
  const pricing = { ...DEFAULT_PRICING };
6491
6446
  if (config.pricing !== void 0) for (const [key, value] of Object.entries(config.pricing)) pricing[key] = value;
6492
6447
  const defaults = config.defaults;
@@ -6494,8 +6449,6 @@ function create_engine(config) {
6494
6449
  const default_effort = defaults?.effort ?? config.default_effort ?? "none";
6495
6450
  const default_max_steps = defaults?.max_steps ?? config.default_max_steps ?? 10;
6496
6451
  const get_internals = () => ({
6497
- aliases,
6498
- families,
6499
6452
  pricing,
6500
6453
  adapters,
6501
6454
  default_retry,
@@ -6515,20 +6468,6 @@ function create_engine(config) {
6515
6468
  if (disposed) throw new engine_disposed_error();
6516
6469
  return generate(opts, get_internals());
6517
6470
  },
6518
- register_alias(alias, target) {
6519
- aliases[alias] = target;
6520
- },
6521
- unregister_alias(alias) {
6522
- delete aliases[alias];
6523
- },
6524
- resolve_alias(alias) {
6525
- const hit = aliases[alias];
6526
- if (hit === void 0) throw new model_not_found_error(alias, Object.keys(aliases));
6527
- return hit;
6528
- },
6529
- list_aliases() {
6530
- return { ...aliases };
6531
- },
6532
6471
  register_price(provider, model_id, value) {
6533
6472
  pricing[pricing_key(provider, model_id)] = value;
6534
6473
  },
@@ -6549,13 +6488,13 @@ function create_engine(config) {
6549
6488
  };
6550
6489
  }
6551
6490
  //#endregion
6552
- //#region packages/fascicle/src/model_call.ts
6491
+ //#region src/model_call.ts
6553
6492
  /**
6554
6493
  * model_call — the single sanctioned bridge between the composition and
6555
6494
  * engine layers.
6556
6495
  *
6557
6496
  * This is the only file under packages/fascicle/src/ permitted to import
6558
- * value symbols from both @repo/core and @repo/engine (enforced by the
6497
+ * value symbols from both core and engine (enforced by the
6559
6498
  * model-call-is-sole-bridge ast-grep rule in rules/).
6560
6499
  *
6561
6500
  * The returned Step auto-threads ctx.abort, ctx.trajectory, and — only when
@@ -6670,7 +6609,7 @@ function model_call(cfg) {
6670
6609
  };
6671
6610
  }
6672
6611
  //#endregion
6673
- //#region packages/fascicle/src/forward_standard_env.ts
6612
+ //#region src/forward_standard_env.ts
6674
6613
  /**
6675
6614
  * Returns the standard set of env vars a typical CLI subprocess needs
6676
6615
  * to reach a user's logged-in session: PATH, HOME, SHELL, USER,
@@ -6703,7 +6642,7 @@ function forward_standard_env() {
6703
6642
  return out;
6704
6643
  }
6705
6644
  //#endregion
6706
- //#region packages/viewer/src/broadcast.ts
6645
+ //#region src/viewer/broadcast.ts
6707
6646
  function create_broadcaster(options) {
6708
6647
  const max = Math.max(1, options.buffer | 0);
6709
6648
  const ring = [];
@@ -6742,7 +6681,7 @@ function create_broadcaster(options) {
6742
6681
  };
6743
6682
  }
6744
6683
  //#endregion
6745
- //#region packages/viewer/src/server.ts
6684
+ //#region src/viewer/server.ts
6746
6685
  /**
6747
6686
  * Tiny HTTP server: 5 routes, SSE fan-out, NDJSON ingest.
6748
6687
  *
@@ -6913,7 +6852,7 @@ function handle_ingest(req, res, broadcaster, on_parse_error) {
6913
6852
  });
6914
6853
  }
6915
6854
  //#endregion
6916
- //#region packages/viewer/src/tail.ts
6855
+ //#region src/viewer/tail.ts
6917
6856
  /**
6918
6857
  * JSONL file tailer.
6919
6858
  *
@@ -7036,7 +6975,7 @@ function start_tail(options) {
7036
6975
  };
7037
6976
  }
7038
6977
  //#endregion
7039
- //#region packages/viewer/src/cli.ts
6978
+ //#region src/viewer/cli.ts
7040
6979
  /**
7041
6980
  * fascicle-viewer CLI.
7042
6981
  *
@@ -7196,13 +7135,13 @@ if (process.argv[1] !== void 0 && process.argv[1] === fileURLToPath(import.meta.
7196
7135
  process.exit(1);
7197
7136
  });
7198
7137
  //#endregion
7199
- //#region packages/viewer/src/index.ts
7138
+ //#region src/viewer/index.ts
7200
7139
  /**
7201
- * Public surface for @repo/viewer.
7140
+ * Public surface for viewer.
7202
7141
  *
7203
7142
  * `start_viewer({ ... })` is the programmatic embed: spin up the server,
7204
7143
  * optionally start tailing a JSONL file, and return a handle that can stop
7205
- * both. `start_viewer` only depends on @repo/core's wire-format schema; it
7144
+ * both. `start_viewer` only depends on core's wire-format schema; it
7206
7145
  * never reaches into the engine, composites, or any provider.
7207
7146
  */
7208
7147
  async function start_viewer(options = {}) {
@@ -7241,6 +7180,6 @@ function wrap_handle(server, tail, host, port) {
7241
7180
  };
7242
7181
  }
7243
7182
  //#endregion
7244
- export { STEP_KINDS, aborted_error, adversarial, bench, branch, checkpoint, claude_cli_error, compose, consensus, version as core_version, create_engine, custom_event_schema, describe, describe_cycle_error, emit_event_schema, engine_config_error, engine_disposed_error, version$1 as engine_version, ensemble, ensemble_step, fallback, flow_schema, forward_standard_env, improve, is_step_kind, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_family_unavailable_error, model_not_found_error, normalize_score, on_chunk_error, parallel, pipe, provider_auth_error, provider_capability_error, provider_error, provider_not_configured_error, rate_limit_error, read_baseline, regression_compare, resume_validation_error, retry, run, run_viewer_cli, schema_validation_error, scope, sequence, span_end_event_schema, span_start_event_schema, start_viewer, stash, step, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, trajectory_event_schema, use, write_baseline };
7183
+ export { STEP_KINDS, aborted_error, adversarial, bench, branch, checkpoint, claude_cli_error, compose, consensus, version as core_version, create_engine, custom_event_schema, describe, describe_cycle_error, emit_event_schema, engine_config_error, engine_disposed_error, version$1 as engine_version, ensemble, ensemble_step, fallback, flow_schema, forward_standard_env, improve, is_step_kind, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_required_error, normalize_score, on_chunk_error, parallel, pipe, provider_auth_error, provider_capability_error, provider_error, provider_not_configured_error, rate_limit_error, read_baseline, regression_compare, resume_validation_error, retry, run, run_viewer_cli, schema_validation_error, scope, sequence, span_end_event_schema, span_start_event_schema, start_viewer, stash, step, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, trajectory_event_schema, use, write_baseline };
7245
7184
 
7246
7185
  //# sourceMappingURL=index.js.map