fascicle 0.6.0 → 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/CHANGELOG.md +52 -0
- package/README.md +5 -5
- package/dist/adapters.d.ts +6 -6
- package/dist/adapters.js +5 -5
- package/dist/adapters.js.map +1 -1
- package/dist/{index-CCFSc--s.d.ts → index-BjOnbuc9.d.ts} +26 -26
- package/dist/index.d.ts +40 -54
- package/dist/index.js +321 -347
- package/dist/index.js.map +1 -1
- package/dist/{tee-D_Qh_vfY.js → tee-B-MeNi7d.js} +4 -4
- package/dist/tee-B-MeNi7d.js.map +1 -0
- package/package.json +15 -7
- package/dist/tee-D_Qh_vfY.js.map +0 -1
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-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
1818
|
-
const version = "0.
|
|
1817
|
+
//#region src/core/version.ts
|
|
1818
|
+
const version = "0.8.1";
|
|
1819
1819
|
//#endregion
|
|
1820
|
-
//#region
|
|
1820
|
+
//#region src/core/index.ts
|
|
1821
1821
|
/**
|
|
1822
|
-
* Public surface for
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
2908
|
-
const version$1 = "0.
|
|
2907
|
+
//#region src/engine/version.ts
|
|
2908
|
+
const version$1 = "0.8.1";
|
|
2909
2909
|
//#endregion
|
|
2910
|
-
//#region
|
|
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
|
|
2975
|
-
kind = "
|
|
2976
|
-
model
|
|
2977
|
-
|
|
2978
|
-
|
|
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
|
|
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
|
|
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
|
|
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$
|
|
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$
|
|
3379
|
+
supports: (capability) => SUPPORTED$7.has(capability)
|
|
3480
3380
|
};
|
|
3481
3381
|
};
|
|
3482
3382
|
//#endregion
|
|
3483
|
-
//#region
|
|
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$
|
|
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$
|
|
3429
|
+
supports: (capability) => SUPPORTED$6.has(capability)
|
|
3530
3430
|
};
|
|
3531
3431
|
};
|
|
3532
3432
|
//#endregion
|
|
3533
|
-
//#region
|
|
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$
|
|
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$
|
|
3483
|
+
supports: (capability) => SUPPORTED$5.has(capability)
|
|
3584
3484
|
};
|
|
3585
3485
|
};
|
|
3586
3486
|
//#endregion
|
|
3587
|
-
//#region
|
|
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$
|
|
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$
|
|
3522
|
+
supports: (capability) => SUPPORTED$4.has(capability)
|
|
3623
3523
|
};
|
|
3624
3524
|
};
|
|
3625
3525
|
//#endregion
|
|
3626
|
-
//#region
|
|
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$
|
|
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$
|
|
3564
|
+
supports: (capability) => SUPPORTED$3.has(capability)
|
|
3665
3565
|
};
|
|
3666
3566
|
};
|
|
3667
3567
|
//#endregion
|
|
3668
|
-
//#region
|
|
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$
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
5841
|
+
//#region src/engine/generate.ts
|
|
5880
5842
|
/**
|
|
5881
5843
|
* generate(opts) — single public entry point for model calls.
|
|
5882
5844
|
*
|
|
@@ -6021,6 +5983,39 @@ function to_sdk_messages(messages) {
|
|
|
6021
5983
|
}
|
|
6022
5984
|
return out;
|
|
6023
5985
|
}
|
|
5986
|
+
/**
|
|
5987
|
+
* Hoist a leading run of system messages out of the SDK message list into the
|
|
5988
|
+
* AI SDK's top-level `system` option.
|
|
5989
|
+
*
|
|
5990
|
+
* Passing a `role: 'system'` entry inside `messages` makes the AI SDK treat it
|
|
5991
|
+
* as potentially attacker-controlled: it warns on every call (and newer `ai`
|
|
5992
|
+
* versions throw unless `allowSystemInMessages` is set). fascicle's system
|
|
5993
|
+
* content is the developer's own prompt, and the SDK's own recommendation is to
|
|
5994
|
+
* deliver it through the top-level `system` option, which removes the warning
|
|
5995
|
+
* at its source rather than suppressing it.
|
|
5996
|
+
*
|
|
5997
|
+
* Only the *leading* run is hoisted (fascicle's only shape: one or more system
|
|
5998
|
+
* messages, then the conversation). A system message that appears after a
|
|
5999
|
+
* non-system message keeps its position rather than being silently reordered to
|
|
6000
|
+
* the top, and the original list is returned untouched when hoisting would leave
|
|
6001
|
+
* `messages` empty, since the SDK rejects an empty messages array.
|
|
6002
|
+
*/
|
|
6003
|
+
function split_leading_system(messages) {
|
|
6004
|
+
let run_end = 0;
|
|
6005
|
+
const system_parts = [];
|
|
6006
|
+
while (run_end < messages.length) {
|
|
6007
|
+
const m = messages[run_end];
|
|
6008
|
+
if (m?.role !== "system") break;
|
|
6009
|
+
system_parts.push(m.content);
|
|
6010
|
+
run_end += 1;
|
|
6011
|
+
}
|
|
6012
|
+
const rest = messages.slice(run_end);
|
|
6013
|
+
if (system_parts.length === 0 || rest.length === 0) return { messages: [...messages] };
|
|
6014
|
+
return {
|
|
6015
|
+
system: system_parts.join("\n\n"),
|
|
6016
|
+
messages: rest
|
|
6017
|
+
};
|
|
6018
|
+
}
|
|
6024
6019
|
function to_sdk_tools(tools) {
|
|
6025
6020
|
if (tools.length === 0) return void 0;
|
|
6026
6021
|
const entries = {};
|
|
@@ -6175,7 +6170,8 @@ function classify_ai_sdk_error(err) {
|
|
|
6175
6170
|
}
|
|
6176
6171
|
async function generate(opts_in, engine) {
|
|
6177
6172
|
if (opts_in.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts_in.abort.reason });
|
|
6178
|
-
const resolved_model = opts_in.model ?? engine.default_model
|
|
6173
|
+
const resolved_model = opts_in.model ?? engine.default_model;
|
|
6174
|
+
if (resolved_model === void 0) throw new model_required_error();
|
|
6179
6175
|
const sole_provider = engine.adapters.size === 1 ? [...engine.adapters.keys()][0] : void 0;
|
|
6180
6176
|
const resolved_provider = opts_in.provider ?? engine.default_provider ?? sole_provider ?? "anthropic";
|
|
6181
6177
|
const merged_provider_options = merge_provider_options(engine.default_provider_options, opts_in.provider_options);
|
|
@@ -6186,10 +6182,10 @@ async function generate(opts_in, engine) {
|
|
|
6186
6182
|
};
|
|
6187
6183
|
if (opts_in.system === void 0 && engine.default_system !== void 0) opts.system = engine.default_system;
|
|
6188
6184
|
if (merged_provider_options !== void 0) opts.provider_options = merged_provider_options;
|
|
6189
|
-
const target =
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
}
|
|
6185
|
+
const target = {
|
|
6186
|
+
provider: resolved_provider,
|
|
6187
|
+
model_id: resolved_model
|
|
6188
|
+
};
|
|
6193
6189
|
const adapter = engine.adapters.get(target.provider);
|
|
6194
6190
|
if (adapter === void 0) throw new provider_not_configured_error(target.provider);
|
|
6195
6191
|
if (adapter.kind === "subprocess") return adapter.generate(opts, target);
|
|
@@ -6253,12 +6249,14 @@ async function generate(opts_in, engine) {
|
|
|
6253
6249
|
};
|
|
6254
6250
|
if (args.abort.aborted) internal_controller.abort(args.abort.reason);
|
|
6255
6251
|
else args.abort.addEventListener("abort", cancel_on_user_abort, { once: true });
|
|
6252
|
+
const { system: hoisted_system, messages: sdk_messages } = split_leading_system(to_sdk_messages(args.messages));
|
|
6256
6253
|
const base_params = {
|
|
6257
6254
|
model,
|
|
6258
|
-
messages:
|
|
6255
|
+
messages: sdk_messages,
|
|
6259
6256
|
abortSignal: internal_controller.signal,
|
|
6260
6257
|
stopWhen: stepCountIs(1)
|
|
6261
6258
|
};
|
|
6259
|
+
if (hoisted_system !== void 0) base_params.system = hoisted_system;
|
|
6262
6260
|
if (sdk_tools !== void 0) base_params.tools = sdk_tools;
|
|
6263
6261
|
if (provider_options !== void 0) base_params.providerOptions = provider_options;
|
|
6264
6262
|
if (opts.temperature !== void 0) base_params.temperature = opts.temperature;
|
|
@@ -6431,7 +6429,7 @@ function aggregate_cost(steps, provider) {
|
|
|
6431
6429
|
return out;
|
|
6432
6430
|
}
|
|
6433
6431
|
//#endregion
|
|
6434
|
-
//#region
|
|
6432
|
+
//#region src/engine/create_engine.ts
|
|
6435
6433
|
function build_provider_adapters(providers) {
|
|
6436
6434
|
const adapters = /* @__PURE__ */ new Map();
|
|
6437
6435
|
for (const [name, init] of Object.entries(providers)) {
|
|
@@ -6444,14 +6442,6 @@ function build_provider_adapters(providers) {
|
|
|
6444
6442
|
function create_engine(config) {
|
|
6445
6443
|
if (config.providers === null || typeof config.providers !== "object") throw new engine_config_error("EngineConfig.providers is required");
|
|
6446
6444
|
const adapters = build_provider_adapters(config.providers);
|
|
6447
|
-
const aliases = {};
|
|
6448
|
-
if (config.aliases !== void 0) for (const [name, target] of Object.entries(config.aliases)) aliases[name] = target;
|
|
6449
|
-
const families = {};
|
|
6450
|
-
for (const [name, entry] of Object.entries(MODEL_FAMILIES)) families[name] = { ...entry };
|
|
6451
|
-
if (config.families !== void 0) for (const [name, entry] of Object.entries(config.families)) families[name] = {
|
|
6452
|
-
...families[name],
|
|
6453
|
-
...entry
|
|
6454
|
-
};
|
|
6455
6445
|
const pricing = { ...DEFAULT_PRICING };
|
|
6456
6446
|
if (config.pricing !== void 0) for (const [key, value] of Object.entries(config.pricing)) pricing[key] = value;
|
|
6457
6447
|
const defaults = config.defaults;
|
|
@@ -6459,8 +6449,6 @@ function create_engine(config) {
|
|
|
6459
6449
|
const default_effort = defaults?.effort ?? config.default_effort ?? "none";
|
|
6460
6450
|
const default_max_steps = defaults?.max_steps ?? config.default_max_steps ?? 10;
|
|
6461
6451
|
const get_internals = () => ({
|
|
6462
|
-
aliases,
|
|
6463
|
-
families,
|
|
6464
6452
|
pricing,
|
|
6465
6453
|
adapters,
|
|
6466
6454
|
default_retry,
|
|
@@ -6480,20 +6468,6 @@ function create_engine(config) {
|
|
|
6480
6468
|
if (disposed) throw new engine_disposed_error();
|
|
6481
6469
|
return generate(opts, get_internals());
|
|
6482
6470
|
},
|
|
6483
|
-
register_alias(alias, target) {
|
|
6484
|
-
aliases[alias] = target;
|
|
6485
|
-
},
|
|
6486
|
-
unregister_alias(alias) {
|
|
6487
|
-
delete aliases[alias];
|
|
6488
|
-
},
|
|
6489
|
-
resolve_alias(alias) {
|
|
6490
|
-
const hit = aliases[alias];
|
|
6491
|
-
if (hit === void 0) throw new model_not_found_error(alias, Object.keys(aliases));
|
|
6492
|
-
return hit;
|
|
6493
|
-
},
|
|
6494
|
-
list_aliases() {
|
|
6495
|
-
return { ...aliases };
|
|
6496
|
-
},
|
|
6497
6471
|
register_price(provider, model_id, value) {
|
|
6498
6472
|
pricing[pricing_key(provider, model_id)] = value;
|
|
6499
6473
|
},
|
|
@@ -6514,13 +6488,13 @@ function create_engine(config) {
|
|
|
6514
6488
|
};
|
|
6515
6489
|
}
|
|
6516
6490
|
//#endregion
|
|
6517
|
-
//#region
|
|
6491
|
+
//#region src/model_call.ts
|
|
6518
6492
|
/**
|
|
6519
6493
|
* model_call — the single sanctioned bridge between the composition and
|
|
6520
6494
|
* engine layers.
|
|
6521
6495
|
*
|
|
6522
6496
|
* This is the only file under packages/fascicle/src/ permitted to import
|
|
6523
|
-
* value symbols from both
|
|
6497
|
+
* value symbols from both core and engine (enforced by the
|
|
6524
6498
|
* model-call-is-sole-bridge ast-grep rule in rules/).
|
|
6525
6499
|
*
|
|
6526
6500
|
* The returned Step auto-threads ctx.abort, ctx.trajectory, and — only when
|
|
@@ -6635,7 +6609,7 @@ function model_call(cfg) {
|
|
|
6635
6609
|
};
|
|
6636
6610
|
}
|
|
6637
6611
|
//#endregion
|
|
6638
|
-
//#region
|
|
6612
|
+
//#region src/forward_standard_env.ts
|
|
6639
6613
|
/**
|
|
6640
6614
|
* Returns the standard set of env vars a typical CLI subprocess needs
|
|
6641
6615
|
* to reach a user's logged-in session: PATH, HOME, SHELL, USER,
|
|
@@ -6668,7 +6642,7 @@ function forward_standard_env() {
|
|
|
6668
6642
|
return out;
|
|
6669
6643
|
}
|
|
6670
6644
|
//#endregion
|
|
6671
|
-
//#region
|
|
6645
|
+
//#region src/viewer/broadcast.ts
|
|
6672
6646
|
function create_broadcaster(options) {
|
|
6673
6647
|
const max = Math.max(1, options.buffer | 0);
|
|
6674
6648
|
const ring = [];
|
|
@@ -6707,7 +6681,7 @@ function create_broadcaster(options) {
|
|
|
6707
6681
|
};
|
|
6708
6682
|
}
|
|
6709
6683
|
//#endregion
|
|
6710
|
-
//#region
|
|
6684
|
+
//#region src/viewer/server.ts
|
|
6711
6685
|
/**
|
|
6712
6686
|
* Tiny HTTP server: 5 routes, SSE fan-out, NDJSON ingest.
|
|
6713
6687
|
*
|
|
@@ -6878,7 +6852,7 @@ function handle_ingest(req, res, broadcaster, on_parse_error) {
|
|
|
6878
6852
|
});
|
|
6879
6853
|
}
|
|
6880
6854
|
//#endregion
|
|
6881
|
-
//#region
|
|
6855
|
+
//#region src/viewer/tail.ts
|
|
6882
6856
|
/**
|
|
6883
6857
|
* JSONL file tailer.
|
|
6884
6858
|
*
|
|
@@ -7001,7 +6975,7 @@ function start_tail(options) {
|
|
|
7001
6975
|
};
|
|
7002
6976
|
}
|
|
7003
6977
|
//#endregion
|
|
7004
|
-
//#region
|
|
6978
|
+
//#region src/viewer/cli.ts
|
|
7005
6979
|
/**
|
|
7006
6980
|
* fascicle-viewer CLI.
|
|
7007
6981
|
*
|
|
@@ -7161,13 +7135,13 @@ if (process.argv[1] !== void 0 && process.argv[1] === fileURLToPath(import.meta.
|
|
|
7161
7135
|
process.exit(1);
|
|
7162
7136
|
});
|
|
7163
7137
|
//#endregion
|
|
7164
|
-
//#region
|
|
7138
|
+
//#region src/viewer/index.ts
|
|
7165
7139
|
/**
|
|
7166
|
-
* Public surface for
|
|
7140
|
+
* Public surface for viewer.
|
|
7167
7141
|
*
|
|
7168
7142
|
* `start_viewer({ ... })` is the programmatic embed: spin up the server,
|
|
7169
7143
|
* optionally start tailing a JSONL file, and return a handle that can stop
|
|
7170
|
-
* both. `start_viewer` only depends on
|
|
7144
|
+
* both. `start_viewer` only depends on core's wire-format schema; it
|
|
7171
7145
|
* never reaches into the engine, composites, or any provider.
|
|
7172
7146
|
*/
|
|
7173
7147
|
async function start_viewer(options = {}) {
|
|
@@ -7206,6 +7180,6 @@ function wrap_handle(server, tail, host, port) {
|
|
|
7206
7180
|
};
|
|
7207
7181
|
}
|
|
7208
7182
|
//#endregion
|
|
7209
|
-
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,
|
|
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 };
|
|
7210
7184
|
|
|
7211
7185
|
//# sourceMappingURL=index.js.map
|