fascicle 0.4.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/README.md +16 -8
- package/dist/adapters.d.ts +38 -0
- package/dist/adapters.js +78 -0
- package/dist/adapters.js.map +1 -0
- package/dist/index-CCFSc--s.d.ts +710 -0
- package/dist/index.d.ts +51 -710
- package/dist/index.js +350 -556
- package/dist/index.js.map +1 -1
- package/dist/tee-D_Qh_vfY.js +169 -0
- package/dist/tee-D_Qh_vfY.js.map +1 -0
- package/package.json +7 -8
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { n as http_logger, r as filesystem_logger, t as tee_logger } from "./tee-D_Qh_vfY.js";
|
|
1
2
|
import { createHash, randomUUID } from "node:crypto";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { mkdir, open, readFile, readdir, stat, writeFile } from "node:fs/promises";
|
|
4
5
|
import { dirname, join, resolve } from "node:path";
|
|
5
|
-
import {
|
|
6
|
+
import { createReadStream, existsSync, mkdtempSync, statSync, watch, writeFileSync } from "node:fs";
|
|
6
7
|
import { tmpdir } from "node:os";
|
|
7
8
|
import { spawn } from "node:child_process";
|
|
8
9
|
import { generateText, stepCountIs, streamText, tool } from "ai";
|
|
@@ -408,6 +409,18 @@ var aborted_error = class extends Error {
|
|
|
408
409
|
if (metadata.tool_call_in_flight !== void 0) this.tool_call_in_flight = metadata.tool_call_in_flight;
|
|
409
410
|
}
|
|
410
411
|
};
|
|
412
|
+
/**
|
|
413
|
+
* Control-flow signals are not application failures. `suspended_error` is a
|
|
414
|
+
* human-approval gate pausing the run for later resume; `aborted_error` is
|
|
415
|
+
* cancellation. Resilience composers (`retry`, `fallback`) must rethrow these
|
|
416
|
+
* rather than retry past a suspend or run a backup under an aborted context.
|
|
417
|
+
*
|
|
418
|
+
* Kept internal to @repo/core: not re-exported by index.ts, so it does not
|
|
419
|
+
* widen the public surface.
|
|
420
|
+
*/
|
|
421
|
+
function is_control_flow_error(err) {
|
|
422
|
+
return err instanceof suspended_error || err instanceof aborted_error;
|
|
423
|
+
}
|
|
411
424
|
//#endregion
|
|
412
425
|
//#region packages/core/src/streaming.ts
|
|
413
426
|
const STREAMING_HIGH_WATER_MARK = 1e4;
|
|
@@ -543,6 +556,39 @@ function resolve_span_label(flow, fallback) {
|
|
|
543
556
|
const display = flow.config?.["display_name"];
|
|
544
557
|
return typeof display === "string" && display.length > 0 ? display : fallback;
|
|
545
558
|
}
|
|
559
|
+
/**
|
|
560
|
+
* Register the standard span-wrapping dispatch handler for a composer kind.
|
|
561
|
+
*
|
|
562
|
+
* Every composer wraps `flow.run` in a span identically; this centralizes that
|
|
563
|
+
* boilerplate and threads span parentage: the span opens with the current
|
|
564
|
+
* `ctx.parent_span_id` as its parent, and `flow.run` receives a child context
|
|
565
|
+
* whose `parent_span_id` is this span. Children dispatched from within
|
|
566
|
+
* (including concurrent ones under `parallel`/`map`, which spread the context)
|
|
567
|
+
* therefore nest correctly instead of leaving `parent_span_id` unpopulated.
|
|
568
|
+
*/
|
|
569
|
+
function register_traced_kind(kind) {
|
|
570
|
+
register_kind(kind, async (flow, input, ctx) => {
|
|
571
|
+
const label = resolve_span_label(flow, kind);
|
|
572
|
+
const span_meta = { id: flow.id };
|
|
573
|
+
if (ctx.parent_span_id !== void 0) span_meta["parent_span_id"] = ctx.parent_span_id;
|
|
574
|
+
const span_id = ctx.trajectory.start_span(label, span_meta);
|
|
575
|
+
const child_ctx = {
|
|
576
|
+
...ctx,
|
|
577
|
+
parent_span_id: span_id
|
|
578
|
+
};
|
|
579
|
+
try {
|
|
580
|
+
const out = await flow.run(input, child_ctx);
|
|
581
|
+
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
582
|
+
return out;
|
|
583
|
+
} catch (err) {
|
|
584
|
+
ctx.trajectory.end_span(span_id, {
|
|
585
|
+
id: flow.id,
|
|
586
|
+
error: err instanceof Error ? err.message : String(err)
|
|
587
|
+
});
|
|
588
|
+
throw err;
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
}
|
|
546
592
|
const active_runs = /* @__PURE__ */ new Set();
|
|
547
593
|
let signal_handler_installed = false;
|
|
548
594
|
let sigint_handler = null;
|
|
@@ -573,40 +619,38 @@ const noop_logger = {
|
|
|
573
619
|
end_span: () => {}
|
|
574
620
|
};
|
|
575
621
|
/**
|
|
576
|
-
* Wrap a logger so every emitted event automatically carries `run_id
|
|
622
|
+
* Wrap a logger so every emitted event automatically carries `run_id` and a
|
|
623
|
+
* `ts` (epoch milliseconds) stamped at emission.
|
|
577
624
|
*
|
|
578
|
-
* Studios and other downstream consumers
|
|
579
|
-
*
|
|
580
|
-
*
|
|
625
|
+
* Studios and other downstream consumers multiplex events across runs by
|
|
626
|
+
* `run_id` and reconstruct real timing from `ts` instead of fabricating it at
|
|
627
|
+
* ingest. Either field already present on an event or its meta is preserved;
|
|
628
|
+
* we never overwrite a caller-supplied value.
|
|
581
629
|
*/
|
|
582
|
-
function
|
|
630
|
+
function decorate_logger(inner, run_id) {
|
|
631
|
+
const stamp_meta = (meta) => {
|
|
632
|
+
const out = { ...meta };
|
|
633
|
+
if (!("run_id" in out)) out["run_id"] = run_id;
|
|
634
|
+
if (!("ts" in out)) out["ts"] = Date.now();
|
|
635
|
+
return out;
|
|
636
|
+
};
|
|
583
637
|
return {
|
|
584
638
|
record: (event) => {
|
|
585
|
-
if ("run_id" in event) {
|
|
639
|
+
if ("run_id" in event && "ts" in event) {
|
|
586
640
|
inner.record(event);
|
|
587
641
|
return;
|
|
588
642
|
}
|
|
643
|
+
const extra = {};
|
|
644
|
+
if (!("run_id" in event)) extra["run_id"] = run_id;
|
|
645
|
+
if (!("ts" in event)) extra["ts"] = Date.now();
|
|
589
646
|
inner.record({
|
|
590
647
|
...event,
|
|
591
|
-
|
|
592
|
-
});
|
|
593
|
-
},
|
|
594
|
-
start_span: (name, meta) => {
|
|
595
|
-
if (meta && "run_id" in meta) return inner.start_span(name, meta);
|
|
596
|
-
return inner.start_span(name, {
|
|
597
|
-
...meta,
|
|
598
|
-
run_id
|
|
648
|
+
...extra
|
|
599
649
|
});
|
|
600
650
|
},
|
|
651
|
+
start_span: (name, meta) => inner.start_span(name, stamp_meta(meta)),
|
|
601
652
|
end_span: (id, meta) => {
|
|
602
|
-
|
|
603
|
-
inner.end_span(id, meta);
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
inner.end_span(id, {
|
|
607
|
-
...meta,
|
|
608
|
-
run_id
|
|
609
|
-
});
|
|
653
|
+
inner.end_span(id, stamp_meta(meta));
|
|
610
654
|
}
|
|
611
655
|
};
|
|
612
656
|
}
|
|
@@ -626,21 +670,33 @@ function prepend_path(err, id) {
|
|
|
626
670
|
const next = Array.isArray(existing) ? [id, ...existing.filter((v) => typeof v === "string")] : [id];
|
|
627
671
|
Reflect.set(err, "path", next);
|
|
628
672
|
}
|
|
673
|
+
/**
|
|
674
|
+
* Throw the abort reason if the context has been cancelled. Composers that
|
|
675
|
+
* iterate over children (`sequence`, `scope`, `loop`) call this between steps
|
|
676
|
+
* so a pending abort is honored before the next child starts, not only when a
|
|
677
|
+
* downstream dispatch happens to observe it.
|
|
678
|
+
*/
|
|
679
|
+
function throw_if_aborted$2(ctx) {
|
|
680
|
+
if (!ctx.abort.aborted) return;
|
|
681
|
+
const reason = ctx.abort.reason;
|
|
682
|
+
throw reason instanceof Error ? reason : new aborted_error("aborted", { reason });
|
|
683
|
+
}
|
|
629
684
|
function start_run(flow, input, options, high_water_mark) {
|
|
630
685
|
const install_signal_handlers = options.install_signal_handlers !== false;
|
|
631
686
|
const base_logger = options.trajectory ?? noop_logger;
|
|
632
687
|
const streaming = high_water_mark !== null;
|
|
633
688
|
const controller = new AbortController();
|
|
634
689
|
const run_id = randomUUID();
|
|
635
|
-
let logger = stamp_run_id(base_logger, run_id);
|
|
636
690
|
let stream_events = empty_async_iterable();
|
|
637
691
|
let close_stream = null;
|
|
692
|
+
let inner = base_logger;
|
|
638
693
|
if (streaming) {
|
|
639
|
-
const channel = create_streaming_channel(
|
|
640
|
-
|
|
694
|
+
const channel = create_streaming_channel(base_logger, high_water_mark);
|
|
695
|
+
inner = channel.logger;
|
|
641
696
|
stream_events = channel.events;
|
|
642
697
|
close_stream = channel.close;
|
|
643
698
|
}
|
|
699
|
+
const logger = decorate_logger(inner, run_id);
|
|
644
700
|
const cleanup = create_cleanup_registry(logger);
|
|
645
701
|
const ctx = {
|
|
646
702
|
run_id,
|
|
@@ -746,20 +802,7 @@ function step(id_or_fn, maybe_fn, meta) {
|
|
|
746
802
|
run: maybe_fn
|
|
747
803
|
};
|
|
748
804
|
}
|
|
749
|
-
|
|
750
|
-
const span_id = ctx.trajectory.start_span("step", { id: flow.id });
|
|
751
|
-
try {
|
|
752
|
-
const output = await flow.run(input, ctx);
|
|
753
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
754
|
-
return output;
|
|
755
|
-
} catch (err) {
|
|
756
|
-
ctx.trajectory.end_span(span_id, {
|
|
757
|
-
id: flow.id,
|
|
758
|
-
error: err instanceof Error ? err.message : String(err)
|
|
759
|
-
});
|
|
760
|
-
throw err;
|
|
761
|
-
}
|
|
762
|
-
});
|
|
805
|
+
register_traced_kind("step");
|
|
763
806
|
//#endregion
|
|
764
807
|
//#region packages/core/src/describe.ts
|
|
765
808
|
/**
|
|
@@ -927,7 +970,10 @@ function sequence(children, options) {
|
|
|
927
970
|
const children_ref = children;
|
|
928
971
|
const run_fn = async (input, ctx) => {
|
|
929
972
|
let acc = input;
|
|
930
|
-
for (const child of children_ref)
|
|
973
|
+
for (const child of children_ref) {
|
|
974
|
+
throw_if_aborted$2(ctx);
|
|
975
|
+
acc = await dispatch_step(child, acc, ctx);
|
|
976
|
+
}
|
|
931
977
|
return acc;
|
|
932
978
|
};
|
|
933
979
|
const config_meta = options?.name === void 0 ? void 0 : { display_name: options.name };
|
|
@@ -939,21 +985,7 @@ function sequence(children, options) {
|
|
|
939
985
|
run: run_fn
|
|
940
986
|
};
|
|
941
987
|
}
|
|
942
|
-
|
|
943
|
-
const label = resolve_span_label(flow, "sequence");
|
|
944
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
945
|
-
try {
|
|
946
|
-
const out = await flow.run(input, ctx);
|
|
947
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
948
|
-
return out;
|
|
949
|
-
} catch (err) {
|
|
950
|
-
ctx.trajectory.end_span(span_id, {
|
|
951
|
-
id: flow.id,
|
|
952
|
-
error: err instanceof Error ? err.message : String(err)
|
|
953
|
-
});
|
|
954
|
-
throw err;
|
|
955
|
-
}
|
|
956
|
-
});
|
|
988
|
+
register_traced_kind("sequence");
|
|
957
989
|
//#endregion
|
|
958
990
|
//#region packages/core/src/parallel.ts
|
|
959
991
|
/**
|
|
@@ -968,6 +1000,11 @@ register_kind("sequence", async (flow, input, ctx) => {
|
|
|
968
1000
|
* abort the composer awaits all in-flight children (success, failure, or
|
|
969
1001
|
* aborted) before rethrowing `ctx.abort.reason`. This matches the
|
|
970
1002
|
* "agent-pattern" composer contract in spec.md §6.8.
|
|
1003
|
+
*
|
|
1004
|
+
* When several children fail, a `suspended_error` is preferred over an
|
|
1005
|
+
* application error so a human-approval gate inside a branch stays resumable
|
|
1006
|
+
* rather than being masked by a sibling's failure. Otherwise the first error
|
|
1007
|
+
* in declared order propagates.
|
|
971
1008
|
*/
|
|
972
1009
|
let parallel_counter = 0;
|
|
973
1010
|
function next_id$9() {
|
|
@@ -1013,7 +1050,23 @@ function parallel(members, options) {
|
|
|
1013
1050
|
const reason = ctx.abort.reason;
|
|
1014
1051
|
throw reason instanceof Error ? reason : new aborted_error("aborted", { reason });
|
|
1015
1052
|
}
|
|
1016
|
-
|
|
1053
|
+
let first_err;
|
|
1054
|
+
let has_err = false;
|
|
1055
|
+
let suspended;
|
|
1056
|
+
let has_suspended = false;
|
|
1057
|
+
for (const s of settled) {
|
|
1058
|
+
if (s.status !== "err") continue;
|
|
1059
|
+
if (!has_err) {
|
|
1060
|
+
first_err = s.err;
|
|
1061
|
+
has_err = true;
|
|
1062
|
+
}
|
|
1063
|
+
if (!has_suspended && s.err instanceof suspended_error) {
|
|
1064
|
+
suspended = s.err;
|
|
1065
|
+
has_suspended = true;
|
|
1066
|
+
}
|
|
1067
|
+
}
|
|
1068
|
+
if (has_suspended) throw suspended;
|
|
1069
|
+
if (has_err) throw first_err;
|
|
1017
1070
|
const out = {};
|
|
1018
1071
|
for (const s of settled) if (s.status === "ok") out[s.key] = s.value;
|
|
1019
1072
|
return out;
|
|
@@ -1031,21 +1084,7 @@ function parallel(members, options) {
|
|
|
1031
1084
|
run: run_fn
|
|
1032
1085
|
};
|
|
1033
1086
|
}
|
|
1034
|
-
|
|
1035
|
-
const label = resolve_span_label(flow, "parallel");
|
|
1036
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1037
|
-
try {
|
|
1038
|
-
const out = await flow.run(input, ctx);
|
|
1039
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1040
|
-
return out;
|
|
1041
|
-
} catch (err) {
|
|
1042
|
-
ctx.trajectory.end_span(span_id, {
|
|
1043
|
-
id: flow.id,
|
|
1044
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1045
|
-
});
|
|
1046
|
-
throw err;
|
|
1047
|
-
}
|
|
1048
|
-
});
|
|
1087
|
+
register_traced_kind("parallel");
|
|
1049
1088
|
//#endregion
|
|
1050
1089
|
//#region packages/core/src/branch.ts
|
|
1051
1090
|
/**
|
|
@@ -1082,21 +1121,7 @@ function branch(config) {
|
|
|
1082
1121
|
run: run_fn
|
|
1083
1122
|
};
|
|
1084
1123
|
}
|
|
1085
|
-
|
|
1086
|
-
const label = resolve_span_label(flow, "branch");
|
|
1087
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1088
|
-
try {
|
|
1089
|
-
const out = await flow.run(input, ctx);
|
|
1090
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1091
|
-
return out;
|
|
1092
|
-
} catch (err) {
|
|
1093
|
-
ctx.trajectory.end_span(span_id, {
|
|
1094
|
-
id: flow.id,
|
|
1095
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1096
|
-
});
|
|
1097
|
-
throw err;
|
|
1098
|
-
}
|
|
1099
|
-
});
|
|
1124
|
+
register_traced_kind("branch");
|
|
1100
1125
|
//#endregion
|
|
1101
1126
|
//#region packages/core/src/map.ts
|
|
1102
1127
|
/**
|
|
@@ -1184,21 +1209,7 @@ function map(config) {
|
|
|
1184
1209
|
run: run_fn
|
|
1185
1210
|
};
|
|
1186
1211
|
}
|
|
1187
|
-
|
|
1188
|
-
const label = resolve_span_label(flow, "map");
|
|
1189
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1190
|
-
try {
|
|
1191
|
-
const out = await flow.run(input, ctx);
|
|
1192
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1193
|
-
return out;
|
|
1194
|
-
} catch (err) {
|
|
1195
|
-
ctx.trajectory.end_span(span_id, {
|
|
1196
|
-
id: flow.id,
|
|
1197
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1198
|
-
});
|
|
1199
|
-
throw err;
|
|
1200
|
-
}
|
|
1201
|
-
});
|
|
1212
|
+
register_traced_kind("map");
|
|
1202
1213
|
//#endregion
|
|
1203
1214
|
//#region packages/core/src/pipe.ts
|
|
1204
1215
|
/**
|
|
@@ -1229,30 +1240,21 @@ function pipe(inner, fn, options) {
|
|
|
1229
1240
|
run: run_fn
|
|
1230
1241
|
};
|
|
1231
1242
|
}
|
|
1232
|
-
|
|
1233
|
-
const label = resolve_span_label(flow, "pipe");
|
|
1234
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1235
|
-
try {
|
|
1236
|
-
const out = await flow.run(input, ctx);
|
|
1237
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1238
|
-
return out;
|
|
1239
|
-
} catch (err) {
|
|
1240
|
-
ctx.trajectory.end_span(span_id, {
|
|
1241
|
-
id: flow.id,
|
|
1242
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1243
|
-
});
|
|
1244
|
-
throw err;
|
|
1245
|
-
}
|
|
1246
|
-
});
|
|
1243
|
+
register_traced_kind("pipe");
|
|
1247
1244
|
//#endregion
|
|
1248
1245
|
//#region packages/core/src/retry.ts
|
|
1249
1246
|
/**
|
|
1250
1247
|
* retry: re-run on failure.
|
|
1251
1248
|
*
|
|
1252
1249
|
* `retry(inner, { max_attempts, backoff_ms?, on_error? })` runs `inner`. If it
|
|
1253
|
-
* throws, retries up to `max_attempts - 1` more times with
|
|
1254
|
-
* (`backoff_ms * 2^(attempt-1)`). `on_error` is called on
|
|
1255
|
-
* last error is rethrown if all attempts fail.
|
|
1250
|
+
* throws an application error, retries up to `max_attempts - 1` more times with
|
|
1251
|
+
* exponential backoff (`backoff_ms * 2^(attempt-1)`). `on_error` is called on
|
|
1252
|
+
* every such failure. The last error is rethrown if all attempts fail.
|
|
1253
|
+
*
|
|
1254
|
+
* Control-flow signals (`suspended_error`, `aborted_error`) are not failures:
|
|
1255
|
+
* they propagate immediately without consuming an attempt, firing `on_error`,
|
|
1256
|
+
* or scheduling a backoff. A suspend's `on()` side effect therefore runs once
|
|
1257
|
+
* per run, not once per attempt.
|
|
1256
1258
|
*
|
|
1257
1259
|
* Cancellation / cleanup (constraints.md §5.2, spec.md §6.8): cleanup handlers
|
|
1258
1260
|
* registered by the inner step accumulate across attempts. The parent
|
|
@@ -1300,6 +1302,7 @@ function retry(inner, config) {
|
|
|
1300
1302
|
try {
|
|
1301
1303
|
return await dispatch_step(inner, input, ctx);
|
|
1302
1304
|
} catch (err) {
|
|
1305
|
+
if (is_control_flow_error(err)) throw err;
|
|
1303
1306
|
last_err = err;
|
|
1304
1307
|
if (on_error) on_error(err, attempt);
|
|
1305
1308
|
if (attempt >= max_attempts) break;
|
|
@@ -1322,29 +1325,18 @@ function retry(inner, config) {
|
|
|
1322
1325
|
run: run_fn
|
|
1323
1326
|
};
|
|
1324
1327
|
}
|
|
1325
|
-
|
|
1326
|
-
const label = resolve_span_label(flow, "retry");
|
|
1327
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1328
|
-
try {
|
|
1329
|
-
const out = await flow.run(input, ctx);
|
|
1330
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1331
|
-
return out;
|
|
1332
|
-
} catch (err) {
|
|
1333
|
-
ctx.trajectory.end_span(span_id, {
|
|
1334
|
-
id: flow.id,
|
|
1335
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1336
|
-
});
|
|
1337
|
-
throw err;
|
|
1338
|
-
}
|
|
1339
|
-
});
|
|
1328
|
+
register_traced_kind("retry");
|
|
1340
1329
|
//#endregion
|
|
1341
1330
|
//#region packages/core/src/fallback.ts
|
|
1342
1331
|
/**
|
|
1343
1332
|
* fallback: primary-or-backup.
|
|
1344
1333
|
*
|
|
1345
|
-
* `fallback(primary, backup)` runs `primary`. If it throws
|
|
1346
|
-
* with the same input. If `backup` also throws, the
|
|
1347
|
-
* propagates.
|
|
1334
|
+
* `fallback(primary, backup)` runs `primary`. If it throws an application
|
|
1335
|
+
* error, runs `backup` with the same input. If `backup` also throws, the
|
|
1336
|
+
* `backup` error propagates. Control-flow signals (`suspended_error`,
|
|
1337
|
+
* `aborted_error`) are not failures: they propagate instead of triggering the
|
|
1338
|
+
* backup, so a human-approval gate is never silently bypassed and the backup
|
|
1339
|
+
* never runs under an aborted context. See spec.md §5.8.
|
|
1348
1340
|
*/
|
|
1349
1341
|
let fallback_counter = 0;
|
|
1350
1342
|
function next_id$4() {
|
|
@@ -1356,7 +1348,8 @@ function fallback(primary, backup, options) {
|
|
|
1356
1348
|
const run_fn = async (input, ctx) => {
|
|
1357
1349
|
try {
|
|
1358
1350
|
return await dispatch_step(primary, input, ctx);
|
|
1359
|
-
} catch {
|
|
1351
|
+
} catch (err) {
|
|
1352
|
+
if (is_control_flow_error(err)) throw err;
|
|
1360
1353
|
return dispatch_step(backup, input, ctx);
|
|
1361
1354
|
}
|
|
1362
1355
|
};
|
|
@@ -1369,21 +1362,7 @@ function fallback(primary, backup, options) {
|
|
|
1369
1362
|
run: run_fn
|
|
1370
1363
|
};
|
|
1371
1364
|
}
|
|
1372
|
-
|
|
1373
|
-
const label = resolve_span_label(flow, "fallback");
|
|
1374
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1375
|
-
try {
|
|
1376
|
-
const out = await flow.run(input, ctx);
|
|
1377
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1378
|
-
return out;
|
|
1379
|
-
} catch (err) {
|
|
1380
|
-
ctx.trajectory.end_span(span_id, {
|
|
1381
|
-
id: flow.id,
|
|
1382
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1383
|
-
});
|
|
1384
|
-
throw err;
|
|
1385
|
-
}
|
|
1386
|
-
});
|
|
1365
|
+
register_traced_kind("fallback");
|
|
1387
1366
|
//#endregion
|
|
1388
1367
|
//#region packages/core/src/timeout.ts
|
|
1389
1368
|
/**
|
|
@@ -1450,21 +1429,7 @@ function timeout(inner, ms, options) {
|
|
|
1450
1429
|
run: run_fn
|
|
1451
1430
|
};
|
|
1452
1431
|
}
|
|
1453
|
-
|
|
1454
|
-
const label = resolve_span_label(flow, "timeout");
|
|
1455
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1456
|
-
try {
|
|
1457
|
-
const out = await flow.run(input, ctx);
|
|
1458
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1459
|
-
return out;
|
|
1460
|
-
} catch (err) {
|
|
1461
|
-
ctx.trajectory.end_span(span_id, {
|
|
1462
|
-
id: flow.id,
|
|
1463
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1464
|
-
});
|
|
1465
|
-
throw err;
|
|
1466
|
-
}
|
|
1467
|
-
});
|
|
1432
|
+
register_traced_kind("timeout");
|
|
1468
1433
|
//#endregion
|
|
1469
1434
|
//#region packages/core/src/loop.ts
|
|
1470
1435
|
/**
|
|
@@ -1491,11 +1456,6 @@ function next_id$2(name) {
|
|
|
1491
1456
|
loop_counter += 1;
|
|
1492
1457
|
return `${name ?? "loop"}_${loop_counter}`;
|
|
1493
1458
|
}
|
|
1494
|
-
function throw_if_aborted$2(ctx) {
|
|
1495
|
-
if (!ctx.abort.aborted) return;
|
|
1496
|
-
const reason = ctx.abort.reason;
|
|
1497
|
-
throw reason instanceof Error ? reason : new aborted_error("aborted", { reason });
|
|
1498
|
-
}
|
|
1499
1459
|
function loop(config) {
|
|
1500
1460
|
const { init, body, guard, finish, name } = config;
|
|
1501
1461
|
const rounds_limit = Math.max(1, Math.floor(config.max_rounds));
|
|
@@ -1534,21 +1494,7 @@ function loop(config) {
|
|
|
1534
1494
|
run: run_fn
|
|
1535
1495
|
};
|
|
1536
1496
|
}
|
|
1537
|
-
|
|
1538
|
-
const label = resolve_span_label(flow, "loop");
|
|
1539
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1540
|
-
try {
|
|
1541
|
-
const out = await flow.run(input, ctx);
|
|
1542
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1543
|
-
return out;
|
|
1544
|
-
} catch (err) {
|
|
1545
|
-
ctx.trajectory.end_span(span_id, {
|
|
1546
|
-
id: flow.id,
|
|
1547
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1548
|
-
});
|
|
1549
|
-
throw err;
|
|
1550
|
-
}
|
|
1551
|
-
});
|
|
1497
|
+
register_traced_kind("loop");
|
|
1552
1498
|
//#endregion
|
|
1553
1499
|
//#region packages/core/src/compose.ts
|
|
1554
1500
|
/**
|
|
@@ -1583,21 +1529,7 @@ function compose(name, inner) {
|
|
|
1583
1529
|
run: run_fn
|
|
1584
1530
|
};
|
|
1585
1531
|
}
|
|
1586
|
-
|
|
1587
|
-
const label = resolve_span_label(flow, "compose");
|
|
1588
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1589
|
-
try {
|
|
1590
|
-
const out = await flow.run(input, ctx);
|
|
1591
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1592
|
-
return out;
|
|
1593
|
-
} catch (err) {
|
|
1594
|
-
ctx.trajectory.end_span(span_id, {
|
|
1595
|
-
id: flow.id,
|
|
1596
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1597
|
-
});
|
|
1598
|
-
throw err;
|
|
1599
|
-
}
|
|
1600
|
-
});
|
|
1532
|
+
register_traced_kind("compose");
|
|
1601
1533
|
//#endregion
|
|
1602
1534
|
//#region packages/core/src/checkpoint.ts
|
|
1603
1535
|
/**
|
|
@@ -1651,21 +1583,7 @@ function checkpoint(inner, config) {
|
|
|
1651
1583
|
run: run_fn
|
|
1652
1584
|
};
|
|
1653
1585
|
}
|
|
1654
|
-
|
|
1655
|
-
const label = resolve_span_label(flow, "checkpoint");
|
|
1656
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1657
|
-
try {
|
|
1658
|
-
const out = await flow.run(input, ctx);
|
|
1659
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1660
|
-
return out;
|
|
1661
|
-
} catch (err) {
|
|
1662
|
-
ctx.trajectory.end_span(span_id, {
|
|
1663
|
-
id: flow.id,
|
|
1664
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1665
|
-
});
|
|
1666
|
-
throw err;
|
|
1667
|
-
}
|
|
1668
|
-
});
|
|
1586
|
+
register_traced_kind("checkpoint");
|
|
1669
1587
|
//#endregion
|
|
1670
1588
|
//#region packages/core/src/suspend.ts
|
|
1671
1589
|
/**
|
|
@@ -1717,21 +1635,7 @@ function suspend(config) {
|
|
|
1717
1635
|
run: run_fn
|
|
1718
1636
|
};
|
|
1719
1637
|
}
|
|
1720
|
-
|
|
1721
|
-
const label = resolve_span_label(flow, "suspend");
|
|
1722
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1723
|
-
try {
|
|
1724
|
-
const out = await flow.run(input, ctx);
|
|
1725
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1726
|
-
return out;
|
|
1727
|
-
} catch (err) {
|
|
1728
|
-
ctx.trajectory.end_span(span_id, {
|
|
1729
|
-
id: flow.id,
|
|
1730
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1731
|
-
});
|
|
1732
|
-
throw err;
|
|
1733
|
-
}
|
|
1734
|
-
});
|
|
1638
|
+
register_traced_kind("suspend");
|
|
1735
1639
|
//#endregion
|
|
1736
1640
|
//#region packages/core/src/scope.ts
|
|
1737
1641
|
/**
|
|
@@ -1779,7 +1683,10 @@ function scope(children, options) {
|
|
|
1779
1683
|
state: local
|
|
1780
1684
|
};
|
|
1781
1685
|
let acc = input;
|
|
1782
|
-
for (const child of children_ref)
|
|
1686
|
+
for (const child of children_ref) {
|
|
1687
|
+
throw_if_aborted$2(scope_ctx);
|
|
1688
|
+
acc = await dispatch_step(child, acc, scope_ctx);
|
|
1689
|
+
}
|
|
1783
1690
|
return acc;
|
|
1784
1691
|
};
|
|
1785
1692
|
const config_meta = options?.name === void 0 ? void 0 : { display_name: options.name };
|
|
@@ -1826,51 +1733,9 @@ function use(keys, fn, options) {
|
|
|
1826
1733
|
run: run_fn
|
|
1827
1734
|
};
|
|
1828
1735
|
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
try {
|
|
1833
|
-
const out = await flow.run(input, ctx);
|
|
1834
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1835
|
-
return out;
|
|
1836
|
-
} catch (err) {
|
|
1837
|
-
ctx.trajectory.end_span(span_id, {
|
|
1838
|
-
id: flow.id,
|
|
1839
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1840
|
-
});
|
|
1841
|
-
throw err;
|
|
1842
|
-
}
|
|
1843
|
-
});
|
|
1844
|
-
register_kind("stash", async (flow, input, ctx) => {
|
|
1845
|
-
const label = resolve_span_label(flow, "stash");
|
|
1846
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1847
|
-
try {
|
|
1848
|
-
const out = await flow.run(input, ctx);
|
|
1849
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1850
|
-
return out;
|
|
1851
|
-
} catch (err) {
|
|
1852
|
-
ctx.trajectory.end_span(span_id, {
|
|
1853
|
-
id: flow.id,
|
|
1854
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1855
|
-
});
|
|
1856
|
-
throw err;
|
|
1857
|
-
}
|
|
1858
|
-
});
|
|
1859
|
-
register_kind("use", async (flow, input, ctx) => {
|
|
1860
|
-
const label = resolve_span_label(flow, "use");
|
|
1861
|
-
const span_id = ctx.trajectory.start_span(label, { id: flow.id });
|
|
1862
|
-
try {
|
|
1863
|
-
const out = await flow.run(input, ctx);
|
|
1864
|
-
ctx.trajectory.end_span(span_id, { id: flow.id });
|
|
1865
|
-
return out;
|
|
1866
|
-
} catch (err) {
|
|
1867
|
-
ctx.trajectory.end_span(span_id, {
|
|
1868
|
-
id: flow.id,
|
|
1869
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1870
|
-
});
|
|
1871
|
-
throw err;
|
|
1872
|
-
}
|
|
1873
|
-
});
|
|
1736
|
+
register_traced_kind("scope");
|
|
1737
|
+
register_traced_kind("stash");
|
|
1738
|
+
register_traced_kind("use");
|
|
1874
1739
|
//#endregion
|
|
1875
1740
|
//#region packages/core/src/step_kinds.ts
|
|
1876
1741
|
/**
|
|
@@ -1950,7 +1815,7 @@ const trajectory_event_schema = z.union([
|
|
|
1950
1815
|
]);
|
|
1951
1816
|
//#endregion
|
|
1952
1817
|
//#region packages/core/src/version.ts
|
|
1953
|
-
const version = "0.
|
|
1818
|
+
const version = "0.6.0";
|
|
1954
1819
|
//#endregion
|
|
1955
1820
|
//#region packages/core/src/index.ts
|
|
1956
1821
|
/**
|
|
@@ -2599,171 +2464,6 @@ function tournament(config) {
|
|
|
2599
2464
|
return compose(config.name ?? "tournament", inner);
|
|
2600
2465
|
}
|
|
2601
2466
|
//#endregion
|
|
2602
|
-
//#region packages/observability/src/filesystem.ts
|
|
2603
|
-
/**
|
|
2604
|
-
* Filesystem JSONL trajectory logger.
|
|
2605
|
-
*
|
|
2606
|
-
* Appends one JSON object per line to a configured output file. `start_span`
|
|
2607
|
-
* and `end_span` each emit a line; `record` emits a line with the event as
|
|
2608
|
-
* written. Hierarchical span ids are tracked via an in-memory stack: when
|
|
2609
|
-
* `start_span` fires, the innermost still-open span's id is attached as
|
|
2610
|
-
* `parent_span_id` on the new span's record. This is best-effort for
|
|
2611
|
-
* concurrent children (two siblings spawned from the same parent will see
|
|
2612
|
-
* whichever opened most recently as their parent until proper async-context
|
|
2613
|
-
* propagation is wired). Two concurrent `run(...)` calls that pass distinct
|
|
2614
|
-
* logger instances (constructed with distinct `output_path`s) share nothing.
|
|
2615
|
-
*
|
|
2616
|
-
* Paths are accepted at construction; the logger never reads `process.env`.
|
|
2617
|
-
*/
|
|
2618
|
-
function filesystem_logger(options) {
|
|
2619
|
-
const { output_path } = options;
|
|
2620
|
-
mkdirSync(dirname(output_path), { recursive: true });
|
|
2621
|
-
const stack = [];
|
|
2622
|
-
const write_line = (event) => {
|
|
2623
|
-
appendFileSync(output_path, `${JSON.stringify(event)}\n`);
|
|
2624
|
-
};
|
|
2625
|
-
const start_span = (name, meta) => {
|
|
2626
|
-
const span_id = `${name}:${randomUUID().slice(0, 8)}`;
|
|
2627
|
-
const parent_span_id = stack.length > 0 ? stack[stack.length - 1] : void 0;
|
|
2628
|
-
const event = {
|
|
2629
|
-
kind: "span_start",
|
|
2630
|
-
span_id,
|
|
2631
|
-
name,
|
|
2632
|
-
...meta
|
|
2633
|
-
};
|
|
2634
|
-
if (parent_span_id !== void 0) event["parent_span_id"] = parent_span_id;
|
|
2635
|
-
write_line(event);
|
|
2636
|
-
stack.push(span_id);
|
|
2637
|
-
return span_id;
|
|
2638
|
-
};
|
|
2639
|
-
const end_span = (id, meta) => {
|
|
2640
|
-
write_line({
|
|
2641
|
-
kind: "span_end",
|
|
2642
|
-
span_id: id,
|
|
2643
|
-
...meta
|
|
2644
|
-
});
|
|
2645
|
-
const idx = stack.lastIndexOf(id);
|
|
2646
|
-
if (idx !== -1) stack.splice(idx, 1);
|
|
2647
|
-
};
|
|
2648
|
-
const record = (event) => {
|
|
2649
|
-
write_line({ ...event });
|
|
2650
|
-
};
|
|
2651
|
-
return {
|
|
2652
|
-
record,
|
|
2653
|
-
start_span,
|
|
2654
|
-
end_span
|
|
2655
|
-
};
|
|
2656
|
-
}
|
|
2657
|
-
//#endregion
|
|
2658
|
-
//#region packages/observability/src/http.ts
|
|
2659
|
-
/**
|
|
2660
|
-
* HTTP push trajectory logger.
|
|
2661
|
-
*
|
|
2662
|
-
* Conforms to `TrajectoryLogger`. POSTs each event as a single line of
|
|
2663
|
-
* newline-delimited JSON to a configured URL. Pairs naturally with the
|
|
2664
|
-
* fascicle viewer's `/api/ingest` endpoint, but is a generic adapter — the
|
|
2665
|
-
* receiver can be anything that accepts NDJSON over HTTP.
|
|
2666
|
-
*
|
|
2667
|
-
* Failure policy: drop on transport error and invoke the optional `on_error`
|
|
2668
|
-
* callback. Never throws, never blocks the user's flow on a dev tool being
|
|
2669
|
-
* up. The flow always wins; the viewer is best-effort.
|
|
2670
|
-
*
|
|
2671
|
-
* Hierarchical span ids are tracked in-process, mirroring `filesystem_logger`
|
|
2672
|
-
* so the wire format is identical.
|
|
2673
|
-
*/
|
|
2674
|
-
const default_fetch = async (url, init) => {
|
|
2675
|
-
const res = await fetch(url, init);
|
|
2676
|
-
return {
|
|
2677
|
-
ok: res.ok,
|
|
2678
|
-
status: res.status
|
|
2679
|
-
};
|
|
2680
|
-
};
|
|
2681
|
-
function http_logger(options) {
|
|
2682
|
-
const { url, on_error } = options;
|
|
2683
|
-
const send = options.fetch ?? default_fetch;
|
|
2684
|
-
const stack = [];
|
|
2685
|
-
const post = (event) => {
|
|
2686
|
-
send(url, {
|
|
2687
|
-
method: "POST",
|
|
2688
|
-
headers: { "content-type": "application/x-ndjson" },
|
|
2689
|
-
body: `${JSON.stringify(event)}\n`
|
|
2690
|
-
}).then((res) => {
|
|
2691
|
-
if (!res.ok && on_error) on_error(/* @__PURE__ */ new Error(`http_logger: POST ${url} -> ${res.status}`));
|
|
2692
|
-
}).catch((err) => {
|
|
2693
|
-
if (on_error) on_error(err);
|
|
2694
|
-
});
|
|
2695
|
-
};
|
|
2696
|
-
const start_span = (name, meta) => {
|
|
2697
|
-
const span_id = `${name}:${randomUUID().slice(0, 8)}`;
|
|
2698
|
-
const parent_span_id = stack.length > 0 ? stack[stack.length - 1] : void 0;
|
|
2699
|
-
const event = {
|
|
2700
|
-
kind: "span_start",
|
|
2701
|
-
span_id,
|
|
2702
|
-
name,
|
|
2703
|
-
...meta
|
|
2704
|
-
};
|
|
2705
|
-
if (parent_span_id !== void 0) event["parent_span_id"] = parent_span_id;
|
|
2706
|
-
post(event);
|
|
2707
|
-
stack.push(span_id);
|
|
2708
|
-
return span_id;
|
|
2709
|
-
};
|
|
2710
|
-
const end_span = (id, meta) => {
|
|
2711
|
-
post({
|
|
2712
|
-
kind: "span_end",
|
|
2713
|
-
span_id: id,
|
|
2714
|
-
...meta
|
|
2715
|
-
});
|
|
2716
|
-
const idx = stack.lastIndexOf(id);
|
|
2717
|
-
if (idx !== -1) stack.splice(idx, 1);
|
|
2718
|
-
};
|
|
2719
|
-
const record = (event) => {
|
|
2720
|
-
post({ ...event });
|
|
2721
|
-
};
|
|
2722
|
-
return {
|
|
2723
|
-
record,
|
|
2724
|
-
start_span,
|
|
2725
|
-
end_span
|
|
2726
|
-
};
|
|
2727
|
-
}
|
|
2728
|
-
//#endregion
|
|
2729
|
-
//#region packages/observability/src/tee.ts
|
|
2730
|
-
function tee_logger(...loggers) {
|
|
2731
|
-
if (loggers.length === 0) throw new Error("tee_logger: at least one logger required");
|
|
2732
|
-
const id_map = /* @__PURE__ */ new Map();
|
|
2733
|
-
const safe_each = (fn) => {
|
|
2734
|
-
for (let i = 0; i < loggers.length; i += 1) {
|
|
2735
|
-
const l = loggers[i];
|
|
2736
|
-
if (l === void 0) continue;
|
|
2737
|
-
try {
|
|
2738
|
-
fn(l, i);
|
|
2739
|
-
} catch {}
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
return {
|
|
2743
|
-
record: (event) => {
|
|
2744
|
-
safe_each((l) => l.record(event));
|
|
2745
|
-
},
|
|
2746
|
-
start_span: (name, meta) => {
|
|
2747
|
-
const ids = [];
|
|
2748
|
-
safe_each((l) => {
|
|
2749
|
-
ids.push(l.start_span(name, meta));
|
|
2750
|
-
});
|
|
2751
|
-
const canonical = ids[0] ?? `${name}:tee`;
|
|
2752
|
-
if (loggers.length > 1) id_map.set(canonical, ids);
|
|
2753
|
-
return canonical;
|
|
2754
|
-
},
|
|
2755
|
-
end_span: (id, meta) => {
|
|
2756
|
-
const ids = id_map.get(id);
|
|
2757
|
-
if (ids === void 0) {
|
|
2758
|
-
safe_each((l) => l.end_span(id, meta));
|
|
2759
|
-
return;
|
|
2760
|
-
}
|
|
2761
|
-
id_map.delete(id);
|
|
2762
|
-
safe_each((l, idx) => l.end_span(ids[idx] ?? id, meta));
|
|
2763
|
-
}
|
|
2764
|
-
};
|
|
2765
|
-
}
|
|
2766
|
-
//#endregion
|
|
2767
2467
|
//#region packages/composites/src/bench.ts
|
|
2768
2468
|
/**
|
|
2769
2469
|
* bench: run a flow against a fixture set, score each result, return a report.
|
|
@@ -3205,7 +2905,7 @@ function validate_report(value, path) {
|
|
|
3205
2905
|
}
|
|
3206
2906
|
//#endregion
|
|
3207
2907
|
//#region packages/engine/src/version.ts
|
|
3208
|
-
const version$1 = "0.
|
|
2908
|
+
const version$1 = "0.6.0";
|
|
3209
2909
|
//#endregion
|
|
3210
2910
|
//#region packages/engine/src/errors.ts
|
|
3211
2911
|
var rate_limit_error = class extends Error {
|
|
@@ -3283,6 +2983,20 @@ var model_not_found_error = class extends Error {
|
|
|
3283
2983
|
this.registered = registered;
|
|
3284
2984
|
}
|
|
3285
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;
|
|
2998
|
+
}
|
|
2999
|
+
};
|
|
3286
3000
|
var provider_not_configured_error = class extends Error {
|
|
3287
3001
|
kind = "provider_not_configured_error";
|
|
3288
3002
|
provider;
|
|
@@ -3364,99 +3078,52 @@ const KNOWN_PROVIDERS = new Set([
|
|
|
3364
3078
|
"openrouter",
|
|
3365
3079
|
"claude_cli"
|
|
3366
3080
|
]);
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
},
|
|
3400
|
-
"cli-haiku": {
|
|
3401
|
-
provider: "claude_cli",
|
|
3402
|
-
model_id: "claude-haiku-4-5"
|
|
3403
|
-
},
|
|
3404
|
-
"gpt-4o": {
|
|
3405
|
-
provider: "openai",
|
|
3406
|
-
model_id: "gpt-4o"
|
|
3407
|
-
},
|
|
3408
|
-
"gpt-4o-mini": {
|
|
3409
|
-
provider: "openai",
|
|
3410
|
-
model_id: "gpt-4o-mini"
|
|
3411
|
-
},
|
|
3412
|
-
"gemini-2.5-pro": {
|
|
3413
|
-
provider: "google",
|
|
3414
|
-
model_id: "gemini-2.5-pro"
|
|
3415
|
-
},
|
|
3416
|
-
"gemini-2.5-flash": {
|
|
3417
|
-
provider: "google",
|
|
3418
|
-
model_id: "gemini-2.5-flash"
|
|
3419
|
-
},
|
|
3420
|
-
"gemini-pro": {
|
|
3421
|
-
provider: "google",
|
|
3422
|
-
model_id: "gemini-2.5-pro"
|
|
3423
|
-
},
|
|
3424
|
-
"gemini-flash": {
|
|
3425
|
-
provider: "google",
|
|
3426
|
-
model_id: "gemini-2.5-flash"
|
|
3427
|
-
},
|
|
3428
|
-
"or:sonnet": {
|
|
3429
|
-
provider: "openrouter",
|
|
3430
|
-
model_id: "anthropic/claude-sonnet-4.5"
|
|
3431
|
-
},
|
|
3432
|
-
"or:opus": {
|
|
3433
|
-
provider: "openrouter",
|
|
3434
|
-
model_id: "anthropic/claude-opus-4.1"
|
|
3435
|
-
},
|
|
3436
|
-
"or:gpt-4o": {
|
|
3437
|
-
provider: "openrouter",
|
|
3438
|
-
model_id: "openai/gpt-4o"
|
|
3439
|
-
},
|
|
3440
|
-
"or:gemini-pro": {
|
|
3441
|
-
provider: "openrouter",
|
|
3442
|
-
model_id: "google/gemini-2.5-pro"
|
|
3443
|
-
},
|
|
3444
|
-
"or:llama-3.3-70b": {
|
|
3445
|
-
provider: "openrouter",
|
|
3446
|
-
model_id: "meta-llama/llama-3.3-70b-instruct"
|
|
3447
|
-
}
|
|
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
|
+
})
|
|
3448
3113
|
});
|
|
3449
3114
|
/**
|
|
3450
|
-
* Resolve a model
|
|
3115
|
+
* Resolve a `(model, provider)` pair to a concrete `{ provider, model_id }`.
|
|
3451
3116
|
*
|
|
3452
|
-
* 1.
|
|
3453
|
-
*
|
|
3454
|
-
*
|
|
3455
|
-
*
|
|
3456
|
-
*
|
|
3457
|
-
*
|
|
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.
|
|
3458
3125
|
*/
|
|
3459
|
-
function resolve_model(
|
|
3126
|
+
function resolve_model(model, provider, ctx) {
|
|
3460
3127
|
const colon = model.indexOf(":");
|
|
3461
3128
|
if (colon > 0) {
|
|
3462
3129
|
const prefix = model.slice(0, colon);
|
|
@@ -3465,14 +3132,32 @@ function resolve_model(table, model) {
|
|
|
3465
3132
|
model_id: model.slice(colon + 1)
|
|
3466
3133
|
};
|
|
3467
3134
|
}
|
|
3468
|
-
const
|
|
3469
|
-
if (
|
|
3470
|
-
|
|
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
|
+
};
|
|
3471
3150
|
}
|
|
3472
3151
|
//#endregion
|
|
3473
3152
|
//#region packages/engine/src/pricing.ts
|
|
3474
3153
|
const FREE_PROVIDERS = new Set(["ollama", "lmstudio"]);
|
|
3475
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
|
+
},
|
|
3476
3161
|
"anthropic:claude-opus-4-7": {
|
|
3477
3162
|
input_per_million: 5,
|
|
3478
3163
|
output_per_million: 25,
|
|
@@ -3760,7 +3445,7 @@ function translate_anthropic_effort(effort) {
|
|
|
3760
3445
|
return {
|
|
3761
3446
|
provider_options: { anthropic: { thinking: {
|
|
3762
3447
|
type: "enabled",
|
|
3763
|
-
|
|
3448
|
+
budgetTokens: budget
|
|
3764
3449
|
} } },
|
|
3765
3450
|
effort_ignored: false
|
|
3766
3451
|
};
|
|
@@ -3847,11 +3532,11 @@ const create_openai_adapter = (init) => {
|
|
|
3847
3532
|
//#endregion
|
|
3848
3533
|
//#region packages/engine/src/providers/google.ts
|
|
3849
3534
|
const GOOGLE_THINKING_BUDGET = {
|
|
3850
|
-
low:
|
|
3851
|
-
medium:
|
|
3852
|
-
high:
|
|
3853
|
-
xhigh:
|
|
3854
|
-
max:
|
|
3535
|
+
low: 1024,
|
|
3536
|
+
medium: 8192,
|
|
3537
|
+
high: 24576,
|
|
3538
|
+
xhigh: 32768,
|
|
3539
|
+
max: 32768
|
|
3855
3540
|
};
|
|
3856
3541
|
function translate_google_effort(effort) {
|
|
3857
3542
|
if (effort === "none") return {
|
|
@@ -4219,7 +3904,7 @@ function build_bwrap_args(binary, sandbox) {
|
|
|
4219
3904
|
if (allowlist.length > 0) {
|
|
4220
3905
|
args.push("--share-net");
|
|
4221
3906
|
for (const host of allowlist) args.push("--setenv", "CLAUDE_CLI_NET_ALLOW", host);
|
|
4222
|
-
}
|
|
3907
|
+
} else args.push("--unshare-net");
|
|
4223
3908
|
const write_paths = sandbox.additional_write_paths ?? [];
|
|
4224
3909
|
for (const p of write_paths) args.push("--bind", p, p);
|
|
4225
3910
|
args.push("--");
|
|
@@ -4988,6 +4673,7 @@ function tool_call_record(step_index, call, results, now) {
|
|
|
4988
4673
|
}
|
|
4989
4674
|
function build_generate_result(input) {
|
|
4990
4675
|
const { parsed, resolved } = input;
|
|
4676
|
+
if (parsed.is_error) throw new claude_cli_error("result_error", parsed.final_text.length > 0 ? parsed.final_text : "claude_cli returned an error result");
|
|
4991
4677
|
const turns = normalize_turns(parsed);
|
|
4992
4678
|
const now = Date.now();
|
|
4993
4679
|
const turn_usages = turns.map((t) => ({
|
|
@@ -5181,6 +4867,57 @@ function record_tool_call(trajectory, meta) {
|
|
|
5181
4867
|
...event
|
|
5182
4868
|
});
|
|
5183
4869
|
}
|
|
4870
|
+
/**
|
|
4871
|
+
* Record a resolved tool call's result. `record_tool_call` captures the request
|
|
4872
|
+
* (input); without this event a successful tool's output never reaches the
|
|
4873
|
+
* trajectory, leaving the run record blind to what tools actually returned.
|
|
4874
|
+
*/
|
|
4875
|
+
function record_tool_result(trajectory, meta) {
|
|
4876
|
+
if (trajectory === void 0) return;
|
|
4877
|
+
const event = {
|
|
4878
|
+
kind: "tool_result",
|
|
4879
|
+
step_index: meta.step_index,
|
|
4880
|
+
name: meta.name,
|
|
4881
|
+
tool_call_id: meta.tool_call_id,
|
|
4882
|
+
duration_ms: meta.duration_ms
|
|
4883
|
+
};
|
|
4884
|
+
if (meta.error !== void 0) event["error"] = meta.error;
|
|
4885
|
+
else event["output"] = meta.output;
|
|
4886
|
+
trajectory.record({
|
|
4887
|
+
kind: "tool_result",
|
|
4888
|
+
...event
|
|
4889
|
+
});
|
|
4890
|
+
}
|
|
4891
|
+
/**
|
|
4892
|
+
* Wrap a logger so engine events carry a `ts` (epoch milliseconds) even when
|
|
4893
|
+
* generate is called directly with a caller-supplied logger rather than through
|
|
4894
|
+
* the core runner. When the logger is already runner-decorated, the existing
|
|
4895
|
+
* `ts` is preserved. Private to the engine to avoid widening the public surface.
|
|
4896
|
+
*/
|
|
4897
|
+
function stamp_ts(meta) {
|
|
4898
|
+
const out = { ...meta };
|
|
4899
|
+
if (!("ts" in out)) out["ts"] = Date.now();
|
|
4900
|
+
return out;
|
|
4901
|
+
}
|
|
4902
|
+
function with_timestamps(inner) {
|
|
4903
|
+
if (inner === void 0) return void 0;
|
|
4904
|
+
return {
|
|
4905
|
+
record: (event) => {
|
|
4906
|
+
if ("ts" in event) {
|
|
4907
|
+
inner.record(event);
|
|
4908
|
+
return;
|
|
4909
|
+
}
|
|
4910
|
+
inner.record({
|
|
4911
|
+
...event,
|
|
4912
|
+
ts: Date.now()
|
|
4913
|
+
});
|
|
4914
|
+
},
|
|
4915
|
+
start_span: (name, meta) => inner.start_span(name, stamp_ts(meta)),
|
|
4916
|
+
end_span: (id, meta) => {
|
|
4917
|
+
inner.end_span(id, stamp_ts(meta));
|
|
4918
|
+
}
|
|
4919
|
+
};
|
|
4920
|
+
}
|
|
5184
4921
|
function record_cost(trajectory, step_index, cost, source) {
|
|
5185
4922
|
if (trajectory === void 0) return;
|
|
5186
4923
|
const event = {
|
|
@@ -5393,7 +5130,7 @@ function create_claude_cli_adapter(init) {
|
|
|
5393
5130
|
async generate(opts, resolved) {
|
|
5394
5131
|
if (disposed) throw new engine_disposed_error();
|
|
5395
5132
|
if (opts.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts.abort.reason });
|
|
5396
|
-
const trajectory = opts.trajectory;
|
|
5133
|
+
const trajectory = with_timestamps(opts.trajectory);
|
|
5397
5134
|
const call_opts = extract_call_opts(opts);
|
|
5398
5135
|
const option_ignored = create_option_ignored_dedup(trajectory);
|
|
5399
5136
|
if (opts.max_steps !== void 0) option_ignored.emit("max_steps", PROVIDER_NAME);
|
|
@@ -6098,6 +5835,13 @@ async function run_tool_loop(config) {
|
|
|
6098
5835
|
});
|
|
6099
5836
|
await dispatch_tool_result_chunk(config.dispatch_chunk, step_index, raw_call.id, output);
|
|
6100
5837
|
}
|
|
5838
|
+
for (const r of step_tool_records) record_tool_result(config.trajectory, {
|
|
5839
|
+
step_index,
|
|
5840
|
+
name: r.name,
|
|
5841
|
+
tool_call_id: r.id,
|
|
5842
|
+
duration_ms: r.duration_ms,
|
|
5843
|
+
...r.error !== void 0 ? { error: r.error } : { output: r.output }
|
|
5844
|
+
});
|
|
6101
5845
|
for (const m of tool_results_to_feed) config.messages.push(m);
|
|
6102
5846
|
const turn_finish_reason = would_exceed_after ? "max_steps" : turn.finish_reason;
|
|
6103
5847
|
const step_record = {
|
|
@@ -6431,20 +6175,25 @@ function classify_ai_sdk_error(err) {
|
|
|
6431
6175
|
}
|
|
6432
6176
|
async function generate(opts_in, engine) {
|
|
6433
6177
|
if (opts_in.abort?.aborted === true) throw new aborted_error("aborted", { reason: opts_in.abort.reason });
|
|
6434
|
-
const resolved_model = opts_in.model ?? engine.default_model;
|
|
6435
|
-
|
|
6178
|
+
const resolved_model = opts_in.model ?? engine.default_model ?? "sonnet";
|
|
6179
|
+
const sole_provider = engine.adapters.size === 1 ? [...engine.adapters.keys()][0] : void 0;
|
|
6180
|
+
const resolved_provider = opts_in.provider ?? engine.default_provider ?? sole_provider ?? "anthropic";
|
|
6436
6181
|
const merged_provider_options = merge_provider_options(engine.default_provider_options, opts_in.provider_options);
|
|
6437
6182
|
const opts = {
|
|
6438
6183
|
...opts_in,
|
|
6439
|
-
model: resolved_model
|
|
6184
|
+
model: resolved_model,
|
|
6185
|
+
provider: resolved_provider
|
|
6440
6186
|
};
|
|
6441
6187
|
if (opts_in.system === void 0 && engine.default_system !== void 0) opts.system = engine.default_system;
|
|
6442
6188
|
if (merged_provider_options !== void 0) opts.provider_options = merged_provider_options;
|
|
6443
|
-
const target = resolve_model(
|
|
6189
|
+
const target = resolve_model(resolved_model, resolved_provider, {
|
|
6190
|
+
families: engine.families,
|
|
6191
|
+
aliases: engine.aliases
|
|
6192
|
+
});
|
|
6444
6193
|
const adapter = engine.adapters.get(target.provider);
|
|
6445
6194
|
if (adapter === void 0) throw new provider_not_configured_error(target.provider);
|
|
6446
6195
|
if (adapter.kind === "subprocess") return adapter.generate(opts, target);
|
|
6447
|
-
const trajectory = opts.trajectory;
|
|
6196
|
+
const trajectory = with_timestamps(opts.trajectory);
|
|
6448
6197
|
const on_chunk_provided = opts.on_chunk !== void 0;
|
|
6449
6198
|
const tools_list = opts.tools ?? [];
|
|
6450
6199
|
if (opts.schema !== void 0 && !adapter.supports("schema")) throw new provider_capability_error(target.provider, "schema");
|
|
@@ -6453,7 +6202,8 @@ async function generate(opts_in, engine) {
|
|
|
6453
6202
|
const effort = opts.effort ?? engine.default_effort;
|
|
6454
6203
|
const effort_translation = adapter.translate_effort(effort);
|
|
6455
6204
|
if (effort !== "none" && effort_translation.effort_ignored) record_effort_ignored(trajectory, target.model_id);
|
|
6456
|
-
const
|
|
6205
|
+
const combined_provider_options = merge_provider_options(effort_translation.provider_options, opts.provider_options);
|
|
6206
|
+
const provider_options = combined_provider_options !== void 0 && Object.keys(combined_provider_options).length > 0 ? combined_provider_options : void 0;
|
|
6457
6207
|
const abort = opts.abort ?? new AbortController().signal;
|
|
6458
6208
|
const max_steps = opts.max_steps ?? engine.default_max_steps;
|
|
6459
6209
|
const tool_error_policy = opts.tool_error_policy ?? engine.default_tool_error_policy ?? "feed_back";
|
|
@@ -6694,8 +6444,14 @@ function build_provider_adapters(providers) {
|
|
|
6694
6444
|
function create_engine(config) {
|
|
6695
6445
|
if (config.providers === null || typeof config.providers !== "object") throw new engine_config_error("EngineConfig.providers is required");
|
|
6696
6446
|
const adapters = build_provider_adapters(config.providers);
|
|
6697
|
-
const aliases = {
|
|
6447
|
+
const aliases = {};
|
|
6698
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
|
+
};
|
|
6699
6455
|
const pricing = { ...DEFAULT_PRICING };
|
|
6700
6456
|
if (config.pricing !== void 0) for (const [key, value] of Object.entries(config.pricing)) pricing[key] = value;
|
|
6701
6457
|
const defaults = config.defaults;
|
|
@@ -6704,12 +6460,14 @@ function create_engine(config) {
|
|
|
6704
6460
|
const default_max_steps = defaults?.max_steps ?? config.default_max_steps ?? 10;
|
|
6705
6461
|
const get_internals = () => ({
|
|
6706
6462
|
aliases,
|
|
6463
|
+
families,
|
|
6707
6464
|
pricing,
|
|
6708
6465
|
adapters,
|
|
6709
6466
|
default_retry,
|
|
6710
6467
|
default_effort,
|
|
6711
6468
|
default_max_steps,
|
|
6712
6469
|
...defaults?.model !== void 0 ? { default_model: defaults.model } : {},
|
|
6470
|
+
...defaults?.provider !== void 0 ? { default_provider: defaults.provider } : {},
|
|
6713
6471
|
...defaults?.system !== void 0 ? { default_system: defaults.system } : {},
|
|
6714
6472
|
...defaults?.tool_error_policy !== void 0 ? { default_tool_error_policy: defaults.tool_error_policy } : {},
|
|
6715
6473
|
...defaults?.schema_repair_attempts !== void 0 ? { default_schema_repair_attempts: defaults.schema_repair_attempts } : {},
|
|
@@ -6771,9 +6529,42 @@ function create_engine(config) {
|
|
|
6771
6529
|
* plumbing. Cost events flow out via ctx.trajectory per the engine's own
|
|
6772
6530
|
* emission rules (constraints §5.3).
|
|
6773
6531
|
*/
|
|
6532
|
+
/**
|
|
6533
|
+
* Wrap the run's trajectory so the engine's own spans (engine.generate and its
|
|
6534
|
+
* step spans) nest under the model_call step rather than floating. The wrapper
|
|
6535
|
+
* keeps a private span stack seeded with the model_call step's id, so nesting
|
|
6536
|
+
* is correct and concurrency-safe even when several model_calls run together
|
|
6537
|
+
* under `parallel`/`map` (each invocation builds its own wrapper). A
|
|
6538
|
+
* caller-supplied `parent_span_id` is never overridden.
|
|
6539
|
+
*/
|
|
6540
|
+
function engine_trajectory(inner, root_parent) {
|
|
6541
|
+
const stack = root_parent !== void 0 ? [root_parent] : [];
|
|
6542
|
+
return {
|
|
6543
|
+
record: (event) => {
|
|
6544
|
+
inner.record(event);
|
|
6545
|
+
},
|
|
6546
|
+
start_span: (name, meta) => {
|
|
6547
|
+
const has_parent = meta !== void 0 && "parent_span_id" in meta;
|
|
6548
|
+
const parent = stack.length > 0 ? stack[stack.length - 1] : void 0;
|
|
6549
|
+
const next_meta = has_parent || parent === void 0 ? meta : {
|
|
6550
|
+
...meta,
|
|
6551
|
+
parent_span_id: parent
|
|
6552
|
+
};
|
|
6553
|
+
const id = inner.start_span(name, next_meta);
|
|
6554
|
+
stack.push(id);
|
|
6555
|
+
return id;
|
|
6556
|
+
},
|
|
6557
|
+
end_span: (id, meta) => {
|
|
6558
|
+
inner.end_span(id, meta);
|
|
6559
|
+
const idx = stack.lastIndexOf(id);
|
|
6560
|
+
if (idx !== -1) stack.splice(idx, 1);
|
|
6561
|
+
}
|
|
6562
|
+
};
|
|
6563
|
+
}
|
|
6774
6564
|
function stable_signature(input) {
|
|
6775
6565
|
const payload = JSON.stringify({
|
|
6776
6566
|
model: input.model ?? null,
|
|
6567
|
+
provider: input.provider ?? null,
|
|
6777
6568
|
system: input.system ?? null,
|
|
6778
6569
|
has_tools: input.has_tools,
|
|
6779
6570
|
has_schema: input.has_schema
|
|
@@ -6788,6 +6579,7 @@ function model_call(cfg) {
|
|
|
6788
6579
|
has_schema
|
|
6789
6580
|
};
|
|
6790
6581
|
if (cfg.model !== void 0) signature_input.model = cfg.model;
|
|
6582
|
+
if (cfg.provider !== void 0) signature_input.provider = cfg.provider;
|
|
6791
6583
|
if (cfg.system !== void 0) signature_input.system = cfg.system;
|
|
6792
6584
|
const step_id = cfg.id ?? `model_call:${stable_signature(signature_input)}`;
|
|
6793
6585
|
const describe_config = {
|
|
@@ -6795,6 +6587,7 @@ function model_call(cfg) {
|
|
|
6795
6587
|
has_schema
|
|
6796
6588
|
};
|
|
6797
6589
|
if (cfg.model !== void 0) describe_config.model = cfg.model;
|
|
6590
|
+
if (cfg.provider !== void 0) describe_config.provider = cfg.provider;
|
|
6798
6591
|
if (cfg.system !== void 0) describe_config.system = cfg.system;
|
|
6799
6592
|
if (cfg.effort !== void 0) describe_config.effort = cfg.effort;
|
|
6800
6593
|
const inner = step(step_id, async (input, ctx) => {
|
|
@@ -6811,9 +6604,10 @@ function model_call(cfg) {
|
|
|
6811
6604
|
}]
|
|
6812
6605
|
}] : [...input],
|
|
6813
6606
|
abort: ctx.abort,
|
|
6814
|
-
trajectory: ctx.trajectory
|
|
6607
|
+
trajectory: engine_trajectory(ctx.trajectory, ctx.parent_span_id)
|
|
6815
6608
|
};
|
|
6816
6609
|
if (cfg.model !== void 0) opts.model = cfg.model;
|
|
6610
|
+
if (cfg.provider !== void 0) opts.provider = cfg.provider;
|
|
6817
6611
|
if (cfg.system !== void 0) opts.system = cfg.system;
|
|
6818
6612
|
if (cfg.tools !== void 0) opts.tools = [...cfg.tools];
|
|
6819
6613
|
if (cfg.schema !== void 0) opts.schema = cfg.schema;
|
|
@@ -7412,6 +7206,6 @@ function wrap_handle(server, tail, host, port) {
|
|
|
7412
7206
|
};
|
|
7413
7207
|
}
|
|
7414
7208
|
//#endregion
|
|
7415
|
-
export { STEP_KINDS, aborted_error, adversarial, bench, branch, checkpoint, compose, consensus, version as core_version, create_engine, custom_event_schema, describe, describe_cycle_error, emit_event_schema, engine_config_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_not_found_error, normalize_score, on_chunk_error, parallel, pipe, 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 };
|
|
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, 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 };
|
|
7416
7210
|
|
|
7417
7211
|
//# sourceMappingURL=index.js.map
|