fascicle 0.12.0 → 0.12.3
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 +148 -32
- package/README.md +25 -15
- package/dist/{adapters-hmnJOOgf.js → adapters-CutexJd3.js} +12 -12
- package/dist/adapters-CutexJd3.js.map +1 -0
- package/dist/adapters.d.ts +10 -10
- package/dist/adapters.js +1 -1
- package/dist/agents.d.ts +22 -3
- package/dist/agents.js +74 -24
- package/dist/agents.js.map +1 -1
- package/dist/bin/fascicle-viewer.js +2 -2
- package/dist/{core-BkB2l1-e.js → core-DdJEhyQc.js} +314 -501
- package/dist/core-DdJEhyQc.js.map +1 -0
- package/dist/engine-J4lIxpw5.js +7000 -0
- package/dist/engine-J4lIxpw5.js.map +1 -0
- package/dist/index.d.ts +237 -178
- package/dist/index.js +617 -7771
- package/dist/index.js.map +1 -1
- package/dist/{invoke-JkzNf7-Y.js → invoke-CH_eJZeS.js} +8 -8
- package/dist/{invoke-JkzNf7-Y.js.map → invoke-CH_eJZeS.js.map} +1 -1
- package/dist/{leading_system-BVtGMweY.js → leading_system-BUCT-PwD.js} +31 -8
- package/dist/leading_system-BUCT-PwD.js.map +1 -0
- package/dist/mcp.d.ts +5 -5
- package/dist/mcp.js +10 -9
- package/dist/mcp.js.map +1 -1
- package/dist/otel.d.ts +1 -1
- package/dist/otel.js +4 -4
- package/dist/otel.js.map +1 -1
- package/dist/static/viewer.html +2 -1
- package/dist/stdio.d.ts +2 -2
- package/dist/stdio.js +2 -2
- package/dist/testing.d.ts +66 -15
- package/dist/testing.js +200 -34
- package/dist/testing.js.map +1 -1
- package/dist/trajectory-ByoOQZ6T.d.ts +114 -0
- package/dist/trajectory-D1eq9eue.js +81 -0
- package/dist/trajectory-D1eq9eue.js.map +1 -0
- package/dist/{types-BCtKsxrX.d.ts → types-BK0UW28o.d.ts} +3 -3
- package/dist/{types-CVdTBXE_.d.ts → types-DBpU27sQ.d.ts} +20 -3
- package/dist/{types-4l54cexm.d.ts → types-DU6cvoA4.d.ts} +9 -5
- package/dist/ui.d.ts +2 -2
- package/dist/ui.js +1 -1
- package/dist/ui.js.map +1 -1
- package/dist/viewer.d.ts +117 -0
- package/dist/viewer.js +659 -0
- package/dist/viewer.js.map +1 -0
- package/package.json +26 -12
- package/dist/adapters-hmnJOOgf.js.map +0 -1
- package/dist/core-BkB2l1-e.js.map +0 -1
- package/dist/leading_system-BVtGMweY.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { n as SchemaIssue, r as ToolSchema, t as AnySchema } from "./types-
|
|
3
|
-
import {
|
|
1
|
+
import { a as Step, c as StepMetadata, d as TrajectoryLogger, i as RunContext, l as StepOutput, n as CheckpointStore, o as StepFn, r as CleanupFn, s as StepInput, t as AnyStep, u as TrajectoryEvent } from "./types-DBpU27sQ.js";
|
|
2
|
+
import { n as SchemaIssue, r as ToolSchema, t as AnySchema } from "./types-BK0UW28o.js";
|
|
3
|
+
import { _ as parse_trajectory_event, a as ParsedTrajectoryEvent, c as SpanEndEvent, d as is_checkpoint_event, f as is_custom_trajectory_event, g as is_span_start_event, h as is_span_end_event, i as EmitEvent, l as SpanStartEvent, m as is_run_end_event, n as CheckpointStatus, o as RunEndEvent, p as is_emit_event, r as CustomTrajectoryEvent, s as RunEndStatus, t as CheckpointEvent, u as TrajectoryParseResult } from "./trajectory-ByoOQZ6T.js";
|
|
4
|
+
import { A as TurnResult, B as ProviderTransport, C as StreamChunk, D as ToolCallRecord, E as ToolApprovalRequest, F as ExternalAgentAdapter, H as default_normalize_usage, I as NativeProviderAdapter, L as ProviderAdapter, M as UserContentPart, N as AiSdkProviderAdapter, O as ToolExecContext, P as EffortTranslation, R as ProviderCapability, S as StepRecord, T as ToolApprovalHandler, V as RawProviderUsage, _ as ProviderConfigMap, a as Engine, b as RetryFailureKind, c as FinishReason, d as Message, f as PrepareStepContext, g as PricingTable, h as Pricing, i as EffortLevel, j as UsageTotals, k as TurnRequest, l as GenerateOptions, m as PrepareStepResult, n as AssistantContentPart, o as EngineConfig, p as PrepareStepHook, r as CostBreakdown, s as EngineDefaults, t as AiSdkTelemetrySettings, u as GenerateResult, v as ProviderInit, w as Tool, x as RetryPolicy, y as ResolvedModel, z as ProviderFactory } from "./types-DU6cvoA4.js";
|
|
4
5
|
|
|
5
6
|
//#region src/core/flow-schema.json.d.ts
|
|
6
7
|
declare let $schema: string;
|
|
@@ -602,13 +603,6 @@ type StreamingRunHandle<o> = {
|
|
|
602
603
|
readonly events: AsyncIterable<TrajectoryEvent>;
|
|
603
604
|
readonly result: Promise<o>;
|
|
604
605
|
};
|
|
605
|
-
/**
|
|
606
|
-
* Route a step to its registered kind handler.
|
|
607
|
-
*
|
|
608
|
-
* This is the single entry point composers use to run children. On failure
|
|
609
|
-
* the step's id is prepended to the error's `path`, so an error surfacing
|
|
610
|
-
* from a deep tree carries the chain of step ids it crossed.
|
|
611
|
-
*/
|
|
612
606
|
/**
|
|
613
607
|
* Execute a flow and resolve with its final output.
|
|
614
608
|
*/
|
|
@@ -623,6 +617,7 @@ type RunOutcome<o> = {
|
|
|
623
617
|
} | {
|
|
624
618
|
readonly kind: 'suspended';
|
|
625
619
|
readonly id: string;
|
|
620
|
+
readonly payload: unknown;
|
|
626
621
|
readonly resume: (data: unknown) => Promise<RunOutcome<o>>;
|
|
627
622
|
};
|
|
628
623
|
/**
|
|
@@ -630,8 +625,9 @@ type RunOutcome<o> = {
|
|
|
630
625
|
* thrown `suspended_error`.
|
|
631
626
|
*
|
|
632
627
|
* Resolves `{ kind: 'done', output }` on completion. When a `suspend` gate
|
|
633
|
-
* fires, resolves `{ kind: 'suspended', id, resume }` where `id` is
|
|
634
|
-
* gate's suspend id
|
|
628
|
+
* fires, resolves `{ kind: 'suspended', id, payload, resume }` where `id` is
|
|
629
|
+
* the gate's suspend id, `payload` is what the gate raised on its
|
|
630
|
+
* `suspended_error`, and `resume(data)` re-runs the flow from the original
|
|
635
631
|
* input with `resume_data[id] = data` merged over the caller's options: the
|
|
636
632
|
* same full re-run semantics as calling `run` again yourself, so pure
|
|
637
633
|
* prefixes replay and `checkpoint`ed steps are served from the store. The
|
|
@@ -658,9 +654,9 @@ declare const run: typeof run_impl & {
|
|
|
658
654
|
/**
|
|
659
655
|
* Wrap a plain function as a `Step`, named or anonymous.
|
|
660
656
|
*
|
|
661
|
-
* The named form takes an explicit id (and optional
|
|
662
|
-
* anonymous form generates
|
|
663
|
-
* rejects it at construction time.
|
|
657
|
+
* The named form takes an explicit id (identity) and optional `meta` (display
|
|
658
|
+
* and description); the anonymous form generates a `step_<n>` id and marks the
|
|
659
|
+
* step so checkpoint rejects it at construction time.
|
|
664
660
|
*/
|
|
665
661
|
declare function step<i, o>(id: string, fn: StepFn<i, o>, meta?: StepMetadata): Step<i, o>;
|
|
666
662
|
declare function step<i, o>(fn: StepFn<i, o>): Step<i, o>;
|
|
@@ -698,14 +694,78 @@ declare const describe: {
|
|
|
698
694
|
json: <i, o>(root: Step<i, o>, options?: DescribeOptions) => FlowNode;
|
|
699
695
|
};
|
|
700
696
|
//#endregion
|
|
697
|
+
//#region src/core/display_name.d.ts
|
|
698
|
+
/**
|
|
699
|
+
* Resolve the human-readable label for `node`, falling back to `fallback`
|
|
700
|
+
* (typically the step's kind) when neither display channel is populated.
|
|
701
|
+
*/
|
|
702
|
+
declare function resolve_display_name(node: AnyStep, fallback: string): string;
|
|
703
|
+
//#endregion
|
|
704
|
+
//#region src/core/step_id.d.ts
|
|
705
|
+
/**
|
|
706
|
+
* Step id validation.
|
|
707
|
+
*
|
|
708
|
+
* Every id in the system is constrained to a valid JavaScript identifier
|
|
709
|
+
* rather than an arbitrary string, because ids are read back as property
|
|
710
|
+
* names: `chain` merges each binding into a typed record under its name, and
|
|
711
|
+
* a name you cannot destructure is a name the record cannot offer. Holding
|
|
712
|
+
* one rule across `step`, `chain`, and the agent surface means a user learns
|
|
713
|
+
* it once instead of discovering per-primitive exceptions.
|
|
714
|
+
*
|
|
715
|
+
* Prose is not constrained, because prose has its own channel: `meta.name`
|
|
716
|
+
* on a step, `name` on a chain binding or composer.
|
|
717
|
+
*
|
|
718
|
+
* Nothing normalizes an id on the caller's behalf. A silent transformation
|
|
719
|
+
* would map several distinct names onto one key ('my-id', 'my.id', and
|
|
720
|
+
* 'my_id' all reduce to 'my_id') and would have to stay bug-for-bug in sync
|
|
721
|
+
* with the equivalent type-level transformation. The suggestion in the
|
|
722
|
+
* failure message is a courtesy for the reader, never a contract.
|
|
723
|
+
*/
|
|
724
|
+
/**
|
|
725
|
+
* Report whether `id` can be read back as a property name.
|
|
726
|
+
*/
|
|
727
|
+
declare function is_valid_step_id(id: string): boolean;
|
|
728
|
+
/**
|
|
729
|
+
* Render the closest identifier-shaped spelling of `raw`, for failure
|
|
730
|
+
* messages only. Prefixes an underscore when the swap alone still leaves an
|
|
731
|
+
* illegal leading character, so the suggestion is always usable as written.
|
|
732
|
+
*/
|
|
733
|
+
declare function suggest_step_id(raw: string): string;
|
|
734
|
+
/**
|
|
735
|
+
* Throw when `id` is not identifier-shaped. `subject` names the failing
|
|
736
|
+
* surface so the message points at the call the reader actually wrote, and
|
|
737
|
+
* `remedy` says where the prose spelling belongs instead.
|
|
738
|
+
*/
|
|
739
|
+
declare function assert_valid_step_id(id: string, subject: string, remedy: string): void;
|
|
740
|
+
//#endregion
|
|
701
741
|
//#region src/core/sequence.d.ts
|
|
702
742
|
type FirstInput<children> = children extends readonly [Step<infer i, unknown>, ...unknown[]] ? i : unknown;
|
|
703
743
|
type LastOutput$1<children> = children extends readonly [...unknown[], Step<never, infer o>] ? o : children extends readonly [Step<never, infer o>] ? o : unknown;
|
|
704
|
-
type OutputOf
|
|
705
|
-
type
|
|
744
|
+
type OutputOf<s> = StepOutput<s>;
|
|
745
|
+
type InputOf<s> = StepInput<s>;
|
|
746
|
+
interface SequenceJointMismatch<at extends string, upstream_output, this_step_accepts> {
|
|
747
|
+
readonly sequence_joint_mismatch: at;
|
|
748
|
+
readonly upstream_output: upstream_output;
|
|
749
|
+
readonly this_step_accepts: this_step_accepts;
|
|
750
|
+
}
|
|
751
|
+
type CheckedJoint<element, upstream, at extends string> = unknown extends element ? unknown : element extends AnyStep ? [upstream] extends [InputOf<element>] ? element : SequenceJointMismatch<at, upstream, InputOf<element>> : AnyStep;
|
|
706
752
|
type CheckedFirst<element> = unknown extends element ? unknown : element extends AnyStep ? element : AnyStep;
|
|
707
|
-
type CheckedTail<children extends readonly unknown[], rest extends readonly unknown[]> = { readonly [k in keyof rest]: CheckedJoint<rest[k], k extends keyof children ? children[k] : never
|
|
708
|
-
type
|
|
753
|
+
type CheckedTail<children extends readonly unknown[], rest extends readonly unknown[]> = { readonly [k in keyof rest]: CheckedJoint<rest[k], OutputOf<k extends keyof children ? children[k] : never>, `after children[${k & string}]`> };
|
|
754
|
+
type IsPlainArray<t extends readonly unknown[]> = t extends readonly [] ? false : t[number][] extends [...t] ? true : false;
|
|
755
|
+
type CheckedSegment<seg extends readonly unknown[], e, upstream> = unknown extends e ? seg : [e] extends [AnyStep] ? [upstream | OutputOf<e>] extends [InputOf<e>] ? seg : readonly SequenceJointMismatch<'spread segment', upstream | OutputOf<e>, InputOf<e>>[] : readonly AnyStep[];
|
|
756
|
+
type SplitSpreadTrail<t extends readonly unknown[], trail extends readonly unknown[] = []> = IsPlainArray<t> extends true ? [t, trail] : t extends readonly [...infer init, infer last_el] ? SplitSpreadTrail<init, [last_el, ...trail]> : [t, trail];
|
|
757
|
+
type SpreadPos = readonly unknown[] | 'spread';
|
|
758
|
+
type JointAt<p extends SpreadPos> = p extends readonly unknown[] ? `after children[${p['length']}]` : 'after spread segment';
|
|
759
|
+
type NextPos<p extends SpreadPos> = p extends readonly unknown[] ? readonly [...p, unknown] : p;
|
|
760
|
+
type CheckedSpreadTail<upstream, t extends readonly unknown[], p extends SpreadPos> = t extends readonly [] ? readonly [] : IsPlainArray<t> extends true ? readonly [...CheckedSegment<t, t[number], upstream>] : t extends readonly [infer h, ...infer r] ? readonly [CheckedJoint<h, upstream, JointAt<p>>, ...CheckedSpreadTail<OutputOf<h>, r, NextPos<p>>] : SplitSpreadTrail<t> extends [infer seg extends readonly unknown[], infer trail extends readonly unknown[]] ? readonly [...CheckedSegment<seg, seg[number], upstream>, ...CheckedSpreadTail<upstream | OutputOf<seg[number]>, trail, 'spread'>] : never;
|
|
761
|
+
interface SequenceRuntimeChildrenMustBeHomogeneous<element> {
|
|
762
|
+
readonly runtime_built_children: 'no tuple positions to check; use ReadonlyArray<Step<T, T>>';
|
|
763
|
+
readonly element: element;
|
|
764
|
+
}
|
|
765
|
+
interface SequenceLeadingSpreadNeedsFixedFirst {
|
|
766
|
+
readonly leading_spread: 'joint checking needs a fixed first element; a homogeneous ReadonlyArray<Step<T, T>> works via the array overload';
|
|
767
|
+
}
|
|
768
|
+
type CheckedChildren<children extends readonly unknown[]> = unknown[] extends children ? children : IsPlainArray<children> extends true ? SequenceRuntimeChildrenMustBeHomogeneous<children[number]> : number extends children['length'] ? children extends readonly [infer first, ...infer rest] ? readonly [CheckedFirst<first>, ...CheckedSpreadTail<OutputOf<first>, rest, readonly []>] : SequenceLeadingSpreadNeedsFixedFirst : children extends readonly [infer first, ...infer rest] ? readonly [CheckedFirst<first>, ...CheckedTail<children, rest>] : children;
|
|
709
769
|
type SequenceOptions = {
|
|
710
770
|
readonly name?: string;
|
|
711
771
|
};
|
|
@@ -715,19 +775,20 @@ type SequenceOptions = {
|
|
|
715
775
|
* The children parameter is checked joint by joint for literal tuples via
|
|
716
776
|
* `CheckedChildren`; the intersection with the bare `children` parameter is
|
|
717
777
|
* what lets inference read the precise tuple while the checked shape
|
|
718
|
-
* constrains it.
|
|
719
|
-
*
|
|
720
|
-
*
|
|
721
|
-
*
|
|
778
|
+
* constrains it. Runtime-built arrays carry no positional types, so the
|
|
779
|
+
* second overload requires them to be homogeneous and self-composing, which
|
|
780
|
+
* keeps `run` sound instead of degrading to the unknown boundary. Validates
|
|
781
|
+
* every element up front so a non-Step (usually a bare function) fails at
|
|
782
|
+
* construction with a pointed message rather than at run time. Checks
|
|
783
|
+
* `ctx.abort` before each child so aborts land on step boundaries.
|
|
722
784
|
*/
|
|
723
785
|
declare function sequence<const children extends readonly unknown[]>(children: children & CheckedChildren<children>, options?: SequenceOptions): Step<FirstInput<children>, LastOutput$1<children>>;
|
|
786
|
+
declare function sequence<t>(children: ReadonlyArray<Step<t, t>>, options?: SequenceOptions): Step<t, t>;
|
|
724
787
|
//#endregion
|
|
725
788
|
//#region src/core/parallel.d.ts
|
|
726
|
-
type OutputOf<s> = s extends Step<never, infer o> ? o : unknown;
|
|
727
|
-
type InputOf<s> = s extends Step<infer i, unknown> ? i : never;
|
|
728
789
|
type UnionToIntersection<u> = (u extends unknown ? (x: u) => void : never) extends ((x: infer i) => void) ? i : never;
|
|
729
|
-
type ParallelInput<children extends Record<string, AnyStep>> = UnionToIntersection<
|
|
730
|
-
type ParallelOutputs<children extends Record<string, AnyStep>> = { [k in keyof children]:
|
|
790
|
+
type ParallelInput<children extends Record<string, AnyStep>> = UnionToIntersection<StepInput<children[keyof children]>>;
|
|
791
|
+
type ParallelOutputs<children extends Record<string, AnyStep>> = { [k in keyof children]: StepOutput<children[k]> };
|
|
731
792
|
type ParallelOptions = {
|
|
732
793
|
readonly name?: string;
|
|
733
794
|
};
|
|
@@ -837,6 +898,7 @@ type LoopGuardResult<state> = {
|
|
|
837
898
|
readonly stop: boolean;
|
|
838
899
|
readonly state: state;
|
|
839
900
|
};
|
|
901
|
+
type LoopGuardPredicate<state> = (state: state) => boolean | Promise<boolean>;
|
|
840
902
|
type LoopOutcome = {
|
|
841
903
|
readonly converged: boolean;
|
|
842
904
|
readonly rounds: number;
|
|
@@ -845,7 +907,7 @@ type LoopConfig<i, state, o> = {
|
|
|
845
907
|
readonly name?: string;
|
|
846
908
|
readonly init: (input: i) => state;
|
|
847
909
|
readonly body: Step<state, state>;
|
|
848
|
-
readonly guard?: Step<state, LoopGuardResult<state
|
|
910
|
+
readonly guard?: Step<state, LoopGuardResult<state>> | LoopGuardPredicate<state>;
|
|
849
911
|
readonly finish: (state: state, outcome: LoopOutcome) => o;
|
|
850
912
|
readonly max_rounds: number;
|
|
851
913
|
};
|
|
@@ -861,14 +923,17 @@ type LoopConfig<i, state, o> = {
|
|
|
861
923
|
declare function loop<i, state, o>(config: LoopConfig<i, state, o>): Step<i, o>;
|
|
862
924
|
//#endregion
|
|
863
925
|
//#region src/core/compose.d.ts
|
|
926
|
+
type ComposeConfig = {
|
|
927
|
+
readonly name: string;
|
|
928
|
+
};
|
|
864
929
|
/**
|
|
865
930
|
* Wrap `inner` in a named composite step.
|
|
866
931
|
*
|
|
867
|
-
* The step's `kind` is always `'compose'`; `name` becomes the
|
|
932
|
+
* The step's `kind` is always `'compose'`; `config.name` becomes the
|
|
868
933
|
* `display_name` used as the span label. Throws a `TypeError` when `name`
|
|
869
934
|
* is not a non-empty string, catching the mistake at construction time.
|
|
870
935
|
*/
|
|
871
|
-
declare function compose<i, o>(
|
|
936
|
+
declare function compose<i, o>(inner: Step<i, o>, config: ComposeConfig): Step<i, o>;
|
|
872
937
|
//#endregion
|
|
873
938
|
//#region src/core/checkpoint.d.ts
|
|
874
939
|
type CheckpointConfig<i> = {
|
|
@@ -942,52 +1007,79 @@ declare function use<const keys extends readonly string[], i, o>(keys: keys, fn:
|
|
|
942
1007
|
type merge<a, b> = { readonly [k in keyof (a & b)]: (a & b)[k] };
|
|
943
1008
|
type ChainStepOptions = {
|
|
944
1009
|
readonly arm?: AnyStep;
|
|
1010
|
+
/**
|
|
1011
|
+
* Display label for the binding's span and `describe` line. The binding
|
|
1012
|
+
* name is a record key and so must be identifier-shaped; this is where the
|
|
1013
|
+
* free prose goes, exactly as `meta.name` does for a plain `step`.
|
|
1014
|
+
*/
|
|
1015
|
+
readonly name?: string;
|
|
945
1016
|
};
|
|
946
1017
|
type Chain<i, acc> = {
|
|
947
|
-
readonly step:
|
|
1018
|
+
readonly step: {
|
|
1019
|
+
<k extends string, o>(name: k, fn: (s: acc, ctx: RunContext) => Promise<o> | o, options?: ChainStepOptions): Chain<i, merge<acc, { readonly [p in k]: o }>>;
|
|
1020
|
+
<k extends string, a, o>(name: k, arm: Step<a, o>, select: (s: acc) => a, options?: ChainStepOptions): Chain<i, merge<acc, { readonly [p in k]: o }>>;
|
|
1021
|
+
};
|
|
948
1022
|
readonly stage: {
|
|
949
1023
|
(name: string): Chain<i, acc>;
|
|
950
1024
|
<next extends Record<string, unknown>>(name: string, project: (s: acc, ctx: RunContext) => Promise<next> | next): Chain<i, merge<next, unknown>>;
|
|
951
1025
|
};
|
|
952
1026
|
readonly output: <o>(fn: (s: acc, ctx: RunContext) => Promise<o> | o) => Step<i, o>;
|
|
953
1027
|
};
|
|
1028
|
+
/**
|
|
1029
|
+
* A freshly opened chain: `Chain` plus `.input<t>()`, which restates the
|
|
1030
|
+
* input type once with the binding name already fixed, so
|
|
1031
|
+
* `chain('q').input<Request>()` equals `chain<Request, 'q'>('q')`. The first
|
|
1032
|
+
* `.step` or `.stage` returns plain `Chain`, so refinement is only possible
|
|
1033
|
+
* before any entry is recorded.
|
|
1034
|
+
*/
|
|
1035
|
+
type ChainOpen<i, k extends string, acc> = Chain<i, acc> & {
|
|
1036
|
+
readonly input: <t>() => Chain<t, { readonly [p in k]: t }>;
|
|
1037
|
+
};
|
|
954
1038
|
/**
|
|
955
1039
|
* Open a chain builder whose record starts as `{ [input_name]: input }`.
|
|
956
1040
|
*
|
|
957
|
-
* `input_name` defaults to `'input'`. The
|
|
958
|
-
*
|
|
1041
|
+
* `input_name` defaults to `'input'`. The input type defaults to `never`, so
|
|
1042
|
+
* a chain that never states it produces a `Step<never, o>` that no real
|
|
1043
|
+
* input satisfies at `run`; state it as the type argument or, when the
|
|
1044
|
+
* binding is renamed, once via `.input<t>()` on the fresh builder. Each
|
|
1045
|
+
* `.step` narrows subsequent callbacks to the record accumulated so far, and
|
|
959
1046
|
* `.stage` with a projection re-types the record to the projection's
|
|
960
1047
|
* return, so binding names and views are checked at compile time with no
|
|
961
1048
|
* declared state shape.
|
|
962
1049
|
*/
|
|
963
|
-
declare function chain<i, k extends string = 'input'>(input_name?: k):
|
|
1050
|
+
declare function chain<i = never, k extends string = 'input'>(input_name?: k): ChainOpen<i, k, { readonly [p in k]: i }>;
|
|
964
1051
|
//#endregion
|
|
965
1052
|
//#region src/core/errors.d.ts
|
|
966
1053
|
declare class timeout_error extends Error {
|
|
967
1054
|
readonly kind: "timeout_error";
|
|
1055
|
+
readonly path?: ReadonlyArray<string>;
|
|
968
1056
|
readonly timeout_ms: number;
|
|
969
1057
|
constructor(message: string, timeout_ms: number);
|
|
970
1058
|
}
|
|
971
1059
|
declare class suspended_error extends Error {
|
|
972
1060
|
readonly kind: "suspended_error";
|
|
1061
|
+
readonly path?: ReadonlyArray<string>;
|
|
973
1062
|
readonly suspend_id: string;
|
|
974
1063
|
readonly payload: unknown;
|
|
975
1064
|
constructor(suspend_id: string, payload: unknown, message?: string);
|
|
976
1065
|
}
|
|
977
1066
|
declare class resume_validation_error extends Error {
|
|
978
1067
|
readonly kind: "resume_validation_error";
|
|
1068
|
+
readonly path?: ReadonlyArray<string>;
|
|
979
1069
|
readonly issues: ReadonlyArray<SchemaIssue>;
|
|
980
1070
|
constructor(message: string, issues: ReadonlyArray<SchemaIssue>);
|
|
981
1071
|
}
|
|
982
1072
|
declare class describe_cycle_error extends Error {
|
|
983
1073
|
readonly kind: "describe_cycle_error";
|
|
1074
|
+
readonly path?: ReadonlyArray<string>;
|
|
984
1075
|
readonly step_id: string;
|
|
985
1076
|
constructor(step_id: string, message?: string);
|
|
986
1077
|
}
|
|
987
1078
|
declare class aborted_error extends Error {
|
|
988
1079
|
readonly kind: "aborted_error";
|
|
1080
|
+
readonly path?: ReadonlyArray<string>;
|
|
989
1081
|
readonly reason?: unknown;
|
|
990
|
-
readonly step_index
|
|
1082
|
+
readonly step_index?: number;
|
|
991
1083
|
readonly tool_call_in_flight?: {
|
|
992
1084
|
id: string;
|
|
993
1085
|
name: string;
|
|
@@ -1001,6 +1093,25 @@ declare class aborted_error extends Error {
|
|
|
1001
1093
|
};
|
|
1002
1094
|
});
|
|
1003
1095
|
}
|
|
1096
|
+
/**
|
|
1097
|
+
* Read the step-id path off any error that crossed the runner's dispatch.
|
|
1098
|
+
*
|
|
1099
|
+
* The runner attaches `path` to whatever escapes a step, including
|
|
1100
|
+
* user-thrown errors the declared class fields cannot type, so a catch block
|
|
1101
|
+
* needs a narrowing read rather than a cast. Returns the ids only when the
|
|
1102
|
+
* property is present and well-formed (an all-string array); anything else,
|
|
1103
|
+
* including non-object inputs, is `undefined`.
|
|
1104
|
+
*/
|
|
1105
|
+
declare function error_path(err: unknown): ReadonlyArray<string> | undefined;
|
|
1106
|
+
//#endregion
|
|
1107
|
+
//#region src/core/is_step.d.ts
|
|
1108
|
+
/**
|
|
1109
|
+
* Check whether a value is structurally a `Step`.
|
|
1110
|
+
*
|
|
1111
|
+
* True when the value has a string `id`, a string `kind`, and a callable
|
|
1112
|
+
* `run`.
|
|
1113
|
+
*/
|
|
1114
|
+
declare function is_step(value: unknown): value is AnyStep;
|
|
1004
1115
|
//#endregion
|
|
1005
1116
|
//#region src/core/step_kinds.d.ts
|
|
1006
1117
|
/**
|
|
@@ -1008,9 +1119,10 @@ declare class aborted_error extends Error {
|
|
|
1008
1119
|
*
|
|
1009
1120
|
* Studio (and any other consumer that needs to enumerate primitives: palette,
|
|
1010
1121
|
* docs, code generation) can rely on this being the exhaustive set. New
|
|
1011
|
-
* primitives must add their kind here.
|
|
1012
|
-
*
|
|
1013
|
-
*
|
|
1122
|
+
* primitives must add their kind here. `step_kinds.test.ts` pins the list
|
|
1123
|
+
* against the kinds core actually constructs, and
|
|
1124
|
+
* `composites/__tests__/coverage.test.ts` covers the four composite kinds
|
|
1125
|
+
* whose factories live outside core.
|
|
1014
1126
|
*/
|
|
1015
1127
|
declare const STEP_KINDS: readonly ["step", "sequence", "parallel", "branch", "map", "pipe", "retry", "fallback", "timeout", "loop", "compose", "adversarial", "ensemble", "tournament", "consensus", "checkpoint", "suspend", "scope", "stash", "use", "chain"];
|
|
1016
1128
|
type StepKind = (typeof STEP_KINDS)[number];
|
|
@@ -1019,87 +1131,6 @@ type StepKind = (typeof STEP_KINDS)[number];
|
|
|
1019
1131
|
*/
|
|
1020
1132
|
declare function is_step_kind(value: unknown): value is StepKind;
|
|
1021
1133
|
//#endregion
|
|
1022
|
-
//#region src/core/trajectory.d.ts
|
|
1023
|
-
/**
|
|
1024
|
-
* Wire-format guards for trajectory events.
|
|
1025
|
-
*
|
|
1026
|
-
* `TrajectoryEvent` (in `types.ts`) is the loose internal type — any code that
|
|
1027
|
-
* calls `trajectory.record(event)` or `start_span(name, meta)` produces values
|
|
1028
|
-
* conforming to it. This file defines the *narrower* shapes that the studio
|
|
1029
|
-
* (and any other downstream consumer) can recognize in the wire stream:
|
|
1030
|
-
*
|
|
1031
|
-
* span_start — composer span open
|
|
1032
|
-
* span_end — composer span close
|
|
1033
|
-
* emit — user-emitted event from inside a step (ctx.emit)
|
|
1034
|
-
* <other> — anything else, recognized by `is_custom_trajectory_event`,
|
|
1035
|
-
* which only requires a string `kind`
|
|
1036
|
-
*
|
|
1037
|
-
* `parse_trajectory_event` is the wire gate, and it is deliberately permissive:
|
|
1038
|
-
* a value is a trajectory event iff it is a non-array object carrying a string
|
|
1039
|
-
* `kind`. The well-known guards layered on top are *recognizers*, not gates — a
|
|
1040
|
-
* `{ kind: 'span_start' }` line missing its `span_id` is still a valid event on
|
|
1041
|
-
* the wire, just not a `SpanStartEvent`. Anything stricter would have a viewer
|
|
1042
|
-
* drop lines a newer producer emits, which is the opposite of what a
|
|
1043
|
-
* forward-compatible wire format is for. `is_custom_trajectory_event` therefore
|
|
1044
|
-
* answers `true` for well-known kinds too: it is the fallback shape, not a
|
|
1045
|
-
* fifth disjoint case.
|
|
1046
|
-
*
|
|
1047
|
-
* Extra fields (`run_id`, `id`, provider-specific metadata) are neither
|
|
1048
|
-
* required nor stripped: a successful parse hands the value straight back, so a
|
|
1049
|
-
* parse / re-serialize round trip is lossless.
|
|
1050
|
-
*/
|
|
1051
|
-
type SpanStartEvent = {
|
|
1052
|
-
readonly kind: 'span_start';
|
|
1053
|
-
readonly span_id: string;
|
|
1054
|
-
readonly name: string;
|
|
1055
|
-
} & {
|
|
1056
|
-
readonly [key: string]: unknown;
|
|
1057
|
-
};
|
|
1058
|
-
type SpanEndEvent = {
|
|
1059
|
-
readonly kind: 'span_end';
|
|
1060
|
-
readonly span_id: string;
|
|
1061
|
-
} & {
|
|
1062
|
-
readonly [key: string]: unknown;
|
|
1063
|
-
};
|
|
1064
|
-
type EmitEvent = {
|
|
1065
|
-
readonly kind: 'emit';
|
|
1066
|
-
} & {
|
|
1067
|
-
readonly [key: string]: unknown;
|
|
1068
|
-
};
|
|
1069
|
-
type CustomTrajectoryEvent = {
|
|
1070
|
-
readonly kind: string;
|
|
1071
|
-
} & {
|
|
1072
|
-
readonly [key: string]: unknown;
|
|
1073
|
-
};
|
|
1074
|
-
type ParsedTrajectoryEvent = SpanStartEvent | SpanEndEvent | EmitEvent | CustomTrajectoryEvent;
|
|
1075
|
-
type TrajectoryParseResult = {
|
|
1076
|
-
readonly success: true;
|
|
1077
|
-
readonly data: ParsedTrajectoryEvent;
|
|
1078
|
-
} | {
|
|
1079
|
-
readonly success: false;
|
|
1080
|
-
readonly error: Error;
|
|
1081
|
-
};
|
|
1082
|
-
/**
|
|
1083
|
-
* The wire gate: a non-array object carrying a string `kind`.
|
|
1084
|
-
*
|
|
1085
|
-
* True for every well-known kind as well, since `custom` is the fallback shape
|
|
1086
|
-
* rather than a disjoint case.
|
|
1087
|
-
*/
|
|
1088
|
-
declare function is_custom_trajectory_event(value: unknown): value is CustomTrajectoryEvent;
|
|
1089
|
-
/** A composer span open: both `span_id` and `name` must be present as strings. */
|
|
1090
|
-
declare function is_span_start_event(value: unknown): value is SpanStartEvent;
|
|
1091
|
-
/** A composer span close: `span_id` must be present as a string, `name` need not be. */
|
|
1092
|
-
declare function is_span_end_event(value: unknown): value is SpanEndEvent;
|
|
1093
|
-
/** A `ctx.emit` event: the kind alone identifies it, the payload is the caller's. */
|
|
1094
|
-
declare function is_emit_event(value: unknown): value is EmitEvent;
|
|
1095
|
-
/**
|
|
1096
|
-
* Parse one wire value into a trajectory event, `safeParse`-shaped.
|
|
1097
|
-
*
|
|
1098
|
-
* On success `data` is the value itself, not a copy, so nothing on the line is
|
|
1099
|
-
* dropped or reordered on the way through.
|
|
1100
|
-
*/
|
|
1101
|
-
declare function parse_trajectory_event(value: unknown): TrajectoryParseResult;
|
|
1102
|
-
//#endregion
|
|
1103
1134
|
//#region src/engine/create_engine.d.ts
|
|
1104
1135
|
/**
|
|
1105
1136
|
* Validate `config` and construct an `Engine`.
|
|
@@ -1113,6 +1144,7 @@ declare function create_engine(config: EngineConfig): Engine;
|
|
|
1113
1144
|
//#region src/engine/errors.d.ts
|
|
1114
1145
|
declare class rate_limit_error extends Error {
|
|
1115
1146
|
readonly kind: "rate_limit_error";
|
|
1147
|
+
readonly path?: ReadonlyArray<string>;
|
|
1116
1148
|
readonly retry_after_ms: number | undefined;
|
|
1117
1149
|
readonly attempts: number;
|
|
1118
1150
|
readonly status: number | undefined;
|
|
@@ -1124,6 +1156,7 @@ declare class rate_limit_error extends Error {
|
|
|
1124
1156
|
}
|
|
1125
1157
|
declare class provider_error extends Error {
|
|
1126
1158
|
readonly kind: "provider_error";
|
|
1159
|
+
readonly path?: ReadonlyArray<string>;
|
|
1127
1160
|
readonly status: number | undefined;
|
|
1128
1161
|
readonly body: string | undefined;
|
|
1129
1162
|
readonly cause_kind: 'provider_5xx' | 'network' | 'unknown' | undefined;
|
|
@@ -1135,12 +1168,14 @@ declare class provider_error extends Error {
|
|
|
1135
1168
|
}
|
|
1136
1169
|
declare class schema_validation_error extends Error {
|
|
1137
1170
|
readonly kind: "schema_validation_error";
|
|
1171
|
+
readonly path?: ReadonlyArray<string>;
|
|
1138
1172
|
readonly schema_issues: ReadonlyArray<SchemaIssue>;
|
|
1139
1173
|
readonly raw_text: string;
|
|
1140
1174
|
constructor(message: string, schema_issues: ReadonlyArray<SchemaIssue>, raw_text: string);
|
|
1141
1175
|
}
|
|
1142
1176
|
declare class tool_error extends Error {
|
|
1143
1177
|
readonly kind: "tool_error";
|
|
1178
|
+
readonly path?: ReadonlyArray<string>;
|
|
1144
1179
|
readonly tool_name: string;
|
|
1145
1180
|
readonly tool_call_id: string;
|
|
1146
1181
|
readonly cause: unknown;
|
|
@@ -1152,6 +1187,7 @@ declare class tool_error extends Error {
|
|
|
1152
1187
|
}
|
|
1153
1188
|
declare class tool_approval_denied_error extends Error {
|
|
1154
1189
|
readonly kind: "tool_approval_denied_error";
|
|
1190
|
+
readonly path?: ReadonlyArray<string>;
|
|
1155
1191
|
readonly tool_name: string;
|
|
1156
1192
|
readonly step_index: number;
|
|
1157
1193
|
readonly tool_call_id: string;
|
|
@@ -1163,36 +1199,61 @@ declare class tool_approval_denied_error extends Error {
|
|
|
1163
1199
|
}
|
|
1164
1200
|
declare class model_required_error extends Error {
|
|
1165
1201
|
readonly kind: "model_required_error";
|
|
1202
|
+
readonly path?: ReadonlyArray<string>;
|
|
1166
1203
|
constructor(message?: string);
|
|
1167
1204
|
}
|
|
1205
|
+
/**
|
|
1206
|
+
* A generate call named a provider the engine has no adapter for. Carries the
|
|
1207
|
+
* configured names, and the message repeats them, so a typo is visible from
|
|
1208
|
+
* the message alone rather than needing the engine config alongside it.
|
|
1209
|
+
*/
|
|
1168
1210
|
declare class provider_not_configured_error extends Error {
|
|
1169
1211
|
readonly kind: "provider_not_configured_error";
|
|
1212
|
+
readonly path?: ReadonlyArray<string>;
|
|
1170
1213
|
readonly provider: string;
|
|
1171
|
-
|
|
1214
|
+
readonly configured: ReadonlyArray<string>;
|
|
1215
|
+
constructor(provider: string, configured?: ReadonlyArray<string>);
|
|
1216
|
+
}
|
|
1217
|
+
/**
|
|
1218
|
+
* No provider could be resolved for a generate call: several providers are
|
|
1219
|
+
* configured, the call named none, and no `defaults.provider` is set. Carries
|
|
1220
|
+
* the configured provider names so the message tells the caller exactly what
|
|
1221
|
+
* the engine can route to.
|
|
1222
|
+
*/
|
|
1223
|
+
declare class provider_required_error extends Error {
|
|
1224
|
+
readonly kind: "provider_required_error";
|
|
1225
|
+
readonly path?: ReadonlyArray<string>;
|
|
1226
|
+
readonly configured: ReadonlyArray<string>;
|
|
1227
|
+
constructor(configured: ReadonlyArray<string>);
|
|
1172
1228
|
}
|
|
1173
1229
|
declare class engine_config_error extends Error {
|
|
1174
1230
|
readonly kind: "engine_config_error";
|
|
1231
|
+
readonly path?: ReadonlyArray<string>;
|
|
1175
1232
|
readonly provider: string | undefined;
|
|
1176
1233
|
constructor(message: string, provider?: string);
|
|
1177
1234
|
}
|
|
1178
1235
|
declare class on_chunk_error extends Error {
|
|
1179
1236
|
readonly kind: "on_chunk_error";
|
|
1237
|
+
readonly path?: ReadonlyArray<string>;
|
|
1180
1238
|
readonly cause: unknown;
|
|
1181
1239
|
constructor(message: string, cause: unknown);
|
|
1182
1240
|
}
|
|
1183
1241
|
declare class provider_capability_error extends Error {
|
|
1184
1242
|
readonly kind: "provider_capability_error";
|
|
1243
|
+
readonly path?: ReadonlyArray<string>;
|
|
1185
1244
|
readonly provider: string;
|
|
1186
1245
|
readonly capability: string;
|
|
1187
1246
|
constructor(provider: string, capability: string, detail?: string);
|
|
1188
1247
|
}
|
|
1189
1248
|
declare class engine_disposed_error extends Error {
|
|
1190
1249
|
readonly kind: "engine_disposed_error";
|
|
1250
|
+
readonly path?: ReadonlyArray<string>;
|
|
1191
1251
|
constructor(message?: string);
|
|
1192
1252
|
}
|
|
1193
1253
|
type ClaudeCliErrorReason = 'binary_not_found' | 'auth_missing' | 'auth_expired' | 'api_key_missing' | 'startup_timeout' | 'stall_timeout' | 'no_result_event' | 'result_error' | 'subprocess_exit' | 'sandbox_unavailable' | 'engine_disposed' | 'parse_error';
|
|
1194
1254
|
declare class claude_cli_error extends Error {
|
|
1195
1255
|
readonly kind: "claude_cli_error";
|
|
1256
|
+
readonly path?: ReadonlyArray<string>;
|
|
1196
1257
|
readonly reason: ClaudeCliErrorReason;
|
|
1197
1258
|
readonly status: number | undefined;
|
|
1198
1259
|
readonly stderr_snippet: string | undefined;
|
|
@@ -1203,6 +1264,7 @@ declare class claude_cli_error extends Error {
|
|
|
1203
1264
|
}
|
|
1204
1265
|
declare class provider_auth_error extends Error {
|
|
1205
1266
|
readonly kind: "provider_auth_error";
|
|
1267
|
+
readonly path?: ReadonlyArray<string>;
|
|
1206
1268
|
readonly provider: string;
|
|
1207
1269
|
readonly refresh_command: string | undefined;
|
|
1208
1270
|
constructor(provider: string, message: string, metadata?: {
|
|
@@ -1220,6 +1282,7 @@ declare class provider_auth_error extends Error {
|
|
|
1220
1282
|
*/
|
|
1221
1283
|
declare class incomplete_generation_error extends Error {
|
|
1222
1284
|
readonly kind: "incomplete_generation_error";
|
|
1285
|
+
readonly path?: ReadonlyArray<string>;
|
|
1223
1286
|
readonly finish_reason: FinishReason;
|
|
1224
1287
|
readonly raw_text: string;
|
|
1225
1288
|
readonly provider_reported: Record<string, unknown> | undefined;
|
|
@@ -1256,7 +1319,7 @@ type AdversarialConfig<input, candidate, projected = AdversarialResult<candidate
|
|
|
1256
1319
|
* notes when available), critiques it, then checks `accept(critique_result)`.
|
|
1257
1320
|
* Returns `{ candidate, converged, rounds }`. Does not throw on
|
|
1258
1321
|
* non-convergence; `converged: false` reports it instead. `project` maps
|
|
1259
|
-
* that envelope into the step's output (
|
|
1322
|
+
* that envelope into the step's output (for example, `(r) => r.candidate`); omitted,
|
|
1260
1323
|
* the envelope itself is the output.
|
|
1261
1324
|
*
|
|
1262
1325
|
* Implemented as a `compose`d `loop` whose body builds a new candidate and
|
|
@@ -1286,7 +1349,7 @@ type ConsensusResult<o> = {
|
|
|
1286
1349
|
* Otherwise re-runs all members up to `max_rounds` times and returns the
|
|
1287
1350
|
* last results with `converged: false` if no agreement is reached.
|
|
1288
1351
|
* `project` maps the `{ result, converged }` envelope into the step's output
|
|
1289
|
-
* (
|
|
1352
|
+
* (for example, `(r) => r.converged`); omitted, the envelope itself is the output.
|
|
1290
1353
|
*
|
|
1291
1354
|
* Implemented as a `compose`d `loop` whose body runs `parallel(members)` and
|
|
1292
1355
|
* whose guard evaluates `agree`. State carries the original input alongside
|
|
@@ -1313,7 +1376,7 @@ type EnsembleResult<o> = {
|
|
|
1313
1376
|
* `select` picks the highest (`'max'`, the default) or lowest (`'min'`)
|
|
1314
1377
|
* score. Tie-breaking is "any tied result is acceptable": the first member
|
|
1315
1378
|
* (in `members` key order) holding the best score wins. `project` maps the
|
|
1316
|
-
* `{ winner, scores }` envelope into the step's output (
|
|
1379
|
+
* `{ winner, scores }` envelope into the step's output (for example, `(r) =>
|
|
1317
1380
|
* r.winner`); omitted, the envelope itself is the output.
|
|
1318
1381
|
*
|
|
1319
1382
|
* Implemented as a `compose`d `sequence` of `parallel(members)` followed by
|
|
@@ -1341,16 +1404,16 @@ type EnsembleStepResult<o, ranked> = {
|
|
|
1341
1404
|
* Builds a Step that runs every member concurrently, scores each result via
|
|
1342
1405
|
* a scoring `Step`, and returns the best-ranking winner.
|
|
1343
1406
|
*
|
|
1344
|
-
* Sibling of `ensemble` for the case where scoring is itself a `Step` (
|
|
1345
|
-
* a separate model call, a sub-flow, anything that wants its own
|
|
1346
|
-
* span and abort routing). The `score` step is dispatched once per
|
|
1347
|
-
* result; `rank_by` projects a number out of the structured scored output;
|
|
1407
|
+
* Sibling of `ensemble` for the case where scoring is itself a `Step` (for
|
|
1408
|
+
* example, a separate model call, a sub-flow, anything that wants its own
|
|
1409
|
+
* trajectory span and abort routing). The `score` step is dispatched once per
|
|
1410
|
+
* member result; `rank_by` projects a number out of the structured scored output;
|
|
1348
1411
|
* `select` picks the highest (`'max'`, default) or lowest (`'min'`) rank.
|
|
1349
1412
|
*
|
|
1350
1413
|
* The result carries `winner_scored`, the structured output from the round's
|
|
1351
1414
|
* scoring run preserved verbatim, so callers never pay to re-score the
|
|
1352
1415
|
* winner. `scored` holds the structured score for every member. `project`
|
|
1353
|
-
* maps that envelope into the step's output (
|
|
1416
|
+
* maps that envelope into the step's output (for example, `(r) => r.winner`);
|
|
1354
1417
|
* omitted, the envelope itself is the output.
|
|
1355
1418
|
*
|
|
1356
1419
|
* Implemented as a `compose`d `scope` over (`stash(parallel(members))` ->
|
|
@@ -1360,6 +1423,30 @@ type EnsembleStepResult<o, ranked> = {
|
|
|
1360
1423
|
*/
|
|
1361
1424
|
declare function ensemble_step<i, o, ranked, projected = EnsembleStepResult<o, ranked>>(config: EnsembleStepConfig<i, o, ranked, projected>): Step<i, projected>;
|
|
1362
1425
|
//#endregion
|
|
1426
|
+
//#region src/composites/gate.d.ts
|
|
1427
|
+
type GateConfig<o> = {
|
|
1428
|
+
readonly id: string;
|
|
1429
|
+
readonly name?: string;
|
|
1430
|
+
readonly store?: CheckpointStore;
|
|
1431
|
+
readonly format?: (result: o) => unknown;
|
|
1432
|
+
};
|
|
1433
|
+
/**
|
|
1434
|
+
* Build a Step that runs `inner`, checkpoints its result at `gate:<id>`, and
|
|
1435
|
+
* suspends with that result as the payload awaiting approval.
|
|
1436
|
+
*
|
|
1437
|
+
* On resume (any defined resume value) the gate resolves to the inner result
|
|
1438
|
+
* unchanged; the decision itself is discarded. On a re-run against the same
|
|
1439
|
+
* store, the checkpoint absorbs the replay so `inner` never re-executes.
|
|
1440
|
+
* Throws at construction time when `inner` is anonymous, because the cached
|
|
1441
|
+
* result must map back to a stable step.
|
|
1442
|
+
*
|
|
1443
|
+
* Implemented as a `compose`d `scope`: the checkpointed result is stashed,
|
|
1444
|
+
* projected into the approver's view, and handed to `suspend`; the suspend's
|
|
1445
|
+
* `combine` returns a `use` step that restores the stashed result, which is
|
|
1446
|
+
* how the decision stays signal-only.
|
|
1447
|
+
*/
|
|
1448
|
+
declare function gate<i, o>(inner: Step<i, o>, config: GateConfig<o>): Step<i, o>;
|
|
1449
|
+
//#endregion
|
|
1363
1450
|
//#region src/composites/improve.d.ts
|
|
1364
1451
|
type Candidate<c> = {
|
|
1365
1452
|
readonly content: c;
|
|
@@ -1426,7 +1513,7 @@ type ImproveResult<c> = {
|
|
|
1426
1513
|
* next round's input. Plateau detection stops the loop early when no
|
|
1427
1514
|
* progress has been made for `patience` rounds; an optional wall-clock
|
|
1428
1515
|
* budget caps total runtime. `project` maps the result envelope into the
|
|
1429
|
-
* step's output (
|
|
1516
|
+
* step's output (for example, `(r) => r.best.content`); omitted, the envelope
|
|
1430
1517
|
* itself is the output.
|
|
1431
1518
|
*
|
|
1432
1519
|
* Implemented as a `compose`d `scope` of (seed) -> (init state) -> (loop) ->
|
|
@@ -1505,7 +1592,7 @@ type TournamentResult<o> = {
|
|
|
1505
1592
|
* All members run concurrently via `parallel`; the bracket step then reduces
|
|
1506
1593
|
* survivors round by round with `compare`, recording every match. Requires at
|
|
1507
1594
|
* least one member so a winner always exists. `project` maps the `{ winner,
|
|
1508
|
-
* bracket }` envelope into the step's output (
|
|
1595
|
+
* bracket }` envelope into the step's output (for example, `(r) => r.winner`);
|
|
1509
1596
|
* omitted, the envelope itself is the output.
|
|
1510
1597
|
*/
|
|
1511
1598
|
declare function tournament<i, o, projected = TournamentResult<o>>(config: TournamentConfig<i, o, projected>): Step<i, projected>;
|
|
@@ -1520,6 +1607,7 @@ declare function tournament<i, o, projected = TournamentResult<o>>(config: Tourn
|
|
|
1520
1607
|
*/
|
|
1521
1608
|
declare class bench_suspend_error extends Error {
|
|
1522
1609
|
readonly kind: "bench_suspend_error";
|
|
1610
|
+
readonly path?: ReadonlyArray<string>;
|
|
1523
1611
|
readonly case_id: string;
|
|
1524
1612
|
readonly suspend_id: string;
|
|
1525
1613
|
constructor(case_id: string, suspend_id: string, message?: string);
|
|
@@ -1693,14 +1781,15 @@ type ModelCallInput = string | ReadonlyArray<Message>;
|
|
|
1693
1781
|
type ModelCallConfig<T = string, projected = GenerateResult<T>> = {
|
|
1694
1782
|
readonly engine: Engine;
|
|
1695
1783
|
/**
|
|
1696
|
-
* Model
|
|
1697
|
-
* `defaults.model` is used. Errors at
|
|
1784
|
+
* Model id, sent to the provider verbatim (there is no alias layer).
|
|
1785
|
+
* Optional: if omitted, the engine's `defaults.model` is used. Errors at
|
|
1786
|
+
* call time if neither is set.
|
|
1698
1787
|
*/
|
|
1699
1788
|
readonly model?: string;
|
|
1700
1789
|
/**
|
|
1701
1790
|
* Transport for the model: `anthropic` | `claude_cli` | `openrouter` | ...
|
|
1702
|
-
* Optional: if omitted, the engine's `defaults.provider` (or sole
|
|
1703
|
-
* provider
|
|
1791
|
+
* Optional: if omitted, the engine's `defaults.provider` (or its sole
|
|
1792
|
+
* configured provider) is used.
|
|
1704
1793
|
*/
|
|
1705
1794
|
readonly provider?: string;
|
|
1706
1795
|
readonly id?: string;
|
|
@@ -1708,7 +1797,20 @@ type ModelCallConfig<T = string, projected = GenerateResult<T>> = {
|
|
|
1708
1797
|
readonly tools?: ReadonlyArray<Tool>;
|
|
1709
1798
|
readonly schema?: ToolSchema<T>;
|
|
1710
1799
|
readonly effort?: EffortLevel;
|
|
1800
|
+
readonly temperature?: number;
|
|
1801
|
+
readonly max_tokens?: number;
|
|
1802
|
+
readonly top_p?: number;
|
|
1711
1803
|
readonly max_steps?: number;
|
|
1804
|
+
/**
|
|
1805
|
+
* Per-turn wall-clock budget in milliseconds, forwarded to the engine.
|
|
1806
|
+
* See `GenerateOptions.turn_timeout_ms`.
|
|
1807
|
+
*/
|
|
1808
|
+
readonly turn_timeout_ms?: number;
|
|
1809
|
+
/**
|
|
1810
|
+
* Per-turn message hook, forwarded to the engine. See
|
|
1811
|
+
* `GenerateOptions.prepare_step`.
|
|
1812
|
+
*/
|
|
1813
|
+
readonly prepare_step?: PrepareStepHook;
|
|
1712
1814
|
readonly provider_options?: Record<string, unknown>;
|
|
1713
1815
|
readonly retry_policy?: RetryPolicy;
|
|
1714
1816
|
readonly tool_error_policy?: 'feed_back' | 'throw';
|
|
@@ -1767,48 +1869,5 @@ declare function model_step<T = string>(cfg: Omit<ModelCallConfig<T>, 'project'>
|
|
|
1767
1869
|
*/
|
|
1768
1870
|
declare function forward_standard_env(): Record<string, string>;
|
|
1769
1871
|
//#endregion
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* `start_viewer` programmatic embed implementation.
|
|
1773
|
-
*
|
|
1774
|
-
* Spin up the server, optionally start tailing a JSONL file, and return a
|
|
1775
|
-
* handle that can stop both. `start_viewer` only depends on core's wire-format
|
|
1776
|
-
* schema; it never reaches into the engine, composites, or any provider.
|
|
1777
|
-
*/
|
|
1778
|
-
type StartViewerOptions = {
|
|
1779
|
-
readonly path?: string;
|
|
1780
|
-
readonly host?: string;
|
|
1781
|
-
readonly port?: number;
|
|
1782
|
-
readonly buffer?: number;
|
|
1783
|
-
readonly on_parse_error?: (err: unknown, line: string) => void;
|
|
1784
|
-
readonly on_io_error?: (err: unknown) => void;
|
|
1785
|
-
readonly on_subscriber_error?: (err: unknown) => void;
|
|
1786
|
-
};
|
|
1787
|
-
type ViewerHandle = {
|
|
1788
|
-
readonly url: string;
|
|
1789
|
-
readonly host: string;
|
|
1790
|
-
readonly port: number;
|
|
1791
|
-
readonly close: () => Promise<void>;
|
|
1792
|
-
};
|
|
1793
|
-
/**
|
|
1794
|
-
* Starts the viewer: brings up the HTTP/SSE server and, if `options.path`
|
|
1795
|
-
* is set, a file tail that feeds the same broadcaster.
|
|
1796
|
-
*
|
|
1797
|
-
* Defaults to `127.0.0.1:4242` with a 1000-event ring buffer. HTTP ingest
|
|
1798
|
-
* and SSE are always available; tailing is opt-in via `path`.
|
|
1799
|
-
*/
|
|
1800
|
-
declare function start_viewer(options?: StartViewerOptions): Promise<ViewerHandle>;
|
|
1801
|
-
//#endregion
|
|
1802
|
-
//#region src/viewer/cli.d.ts
|
|
1803
|
-
/**
|
|
1804
|
-
* CLI entry point: parses argv, starts the viewer, and wires shutdown.
|
|
1805
|
-
*
|
|
1806
|
-
* Warns but proceeds when the tailed path does not exist yet or when the
|
|
1807
|
-
* bind host is 0.0.0.0 (the dashboard has no auth). Optionally opens the
|
|
1808
|
-
* browser, then installs SIGINT/SIGTERM handlers that close the viewer
|
|
1809
|
-
* before exiting.
|
|
1810
|
-
*/
|
|
1811
|
-
declare function run_viewer_cli(argv: readonly string[]): Promise<void>;
|
|
1812
|
-
//#endregion
|
|
1813
|
-
export { type AdversarialBuildInput, type AdversarialConfig, type AdversarialCritiqueResult, type AdversarialResult, type AiSdkProviderAdapter, type AiSdkTelemetrySettings, type AnyStep, type AssistantContentPart, type BenchCase, type BenchOptions, type BenchReport, type BenchSummary, type BracketRecord, type Candidate, type CaseResult, type Chain, type ChainStepOptions, type CheckpointStore, type ConsensusConfig, type ConsensusResult, type CostBreakdown, type CustomTrajectoryEvent, type DescribeOptions, type EffortLevel, type EffortTranslation, type EmitEvent, type Engine, type EngineConfig, type EngineDefaults, type EnsembleConfig, type EnsembleResult, type EnsembleStepConfig, type EnsembleStepResult, type ExternalAgentAdapter, type FinishReason, type FlowNode, type FlowValue, type GenerateOptions, type GenerateResult, type HistoryEntry, type ImproveBudget, type ImproveConfig, type ImproveResult, type ImproveRoundInput, type Improvement, type Judge, type JudgeArgs, type JudgeLlmConfig, type JudgeWithFn, type LearnConfig, type LearnInput, type LearnResult, type Lesson, type LoopConfig, type LoopGuardResult, type LoopOutcome, type Message, type ModelCallConfig, type ModelCallInput, type NativeProviderAdapter, type ParsedTrajectoryEvent, type PerCaseDelta, type PrepareStepContext, type PrepareStepHook, type PrepareStepResult, type Pricing, type PricingTable, type ProviderAdapter, type ProviderCapability, type ProviderConfigMap, type ProviderFactory, type ProviderInit, type ProviderTransport, type RawProviderUsage, type RegressionCompareOptions, type RegressionDelta, type RegressionReport, type ResolvedModel, type RetryFailureKind, type RetryPolicy, type RunContext, type RunOutcome, STEP_KINDS, type Score, type ScoredCandidate, type SpanEndEvent, type SpanStartEvent, type StartViewerOptions, type Step, type StepKind, type StepMetadata, type StepRecord, type StreamChunk, type Tool, type ToolApprovalHandler, type ToolApprovalRequest, type ToolCallRecord, type ToolExecContext, type TournamentConfig, type TournamentResult, type TrajectoryEvent, type TrajectoryLogger, type TrajectoryParseResult, type TrajectorySource, type TurnRequest, type TurnResult, type UsageTotals, type UserContentPart, type ViewerHandle, aborted_error, adversarial, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, compose, consensus, create_engine, default_normalize_usage, describe, describe_cycle_error, engine_config_error, engine_disposed_error, ensemble, ensemble_step, fallback, __json_default_export as flow_schema, forward_standard_env, improve, incomplete_generation_error, is_custom_trajectory_event, is_emit_event, is_span_end_event, is_span_start_event, is_step_kind, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_required_error, model_step, normalize_score, on_chunk_error, parallel, parse_trajectory_event, 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, start_viewer, stash, step, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
|
|
1872
|
+
export { type AdversarialBuildInput, type AdversarialConfig, type AdversarialCritiqueResult, type AdversarialResult, type AiSdkProviderAdapter, type AiSdkTelemetrySettings, type AnySchema, type AnyStep, type AssistantContentPart, type BenchCase, type BenchOptions, type BenchReport, type BenchSummary, type BracketRecord, type BranchConfig, type Candidate, type CaseResult, type Chain, type ChainOpen, type ChainStepOptions, type CheckpointConfig, type CheckpointEvent, type CheckpointStatus, type CheckpointStore, type ClaudeCliErrorReason, type CleanupFn, type ComposeConfig, type ConsensusConfig, type ConsensusResult, type CostBreakdown, type CustomTrajectoryEvent, type DescribeOptions, type EffortLevel, type EffortTranslation, type EmitEvent, type Engine, type EngineConfig, type EngineDefaults, type EnsembleConfig, type EnsembleResult, type EnsembleStepConfig, type EnsembleStepResult, type ExternalAgentAdapter, type FallbackOptions, type FinishReason, type FlowNode, type FlowValue, type GateConfig, type GenerateOptions, type GenerateResult, type HistoryEntry, type ImproveBudget, type ImproveConfig, type ImproveResult, type ImproveRoundInput, type Improvement, type Judge, type JudgeArgs, type JudgeLlmConfig, type JudgeWithFn, type LearnConfig, type LearnInput, type LearnResult, type Lesson, type LoopConfig, type LoopGuardPredicate, type LoopGuardResult, type LoopOutcome, type MapConfig, type Message, type ModelCallConfig, type ModelCallInput, type NativeProviderAdapter, type ParallelOptions, type ParsedTrajectoryEvent, type PerCaseDelta, type PipeOptions, type PrepareStepContext, type PrepareStepHook, type PrepareStepResult, type Pricing, type PricingTable, type ProviderAdapter, type ProviderCapability, type ProviderConfigMap, type ProviderFactory, type ProviderInit, type ProviderTransport, type RawProviderUsage, type RegressionCompareOptions, type RegressionDelta, type RegressionReport, type ResolvedModel, type RetryConfig, type RetryFailureKind, type RetryPolicy, type RunContext, type RunEndEvent, type RunEndStatus, type RunOptions, type RunOutcome, STEP_KINDS, type SchemaIssue, type ScopeOptions, type Score, type ScoredCandidate, type SequenceOptions, type SpanEndEvent, type SpanStartEvent, type StashOptions, type Step, type StepFn, type StepInput, type StepKind, type StepMetadata, type StepOutput, type StepRecord, type StreamChunk, type StreamingRunHandle, type SuspendConfig, type TimeoutOptions, type Tool, type ToolApprovalHandler, type ToolApprovalRequest, type ToolCallRecord, type ToolExecContext, type ToolSchema, type TournamentConfig, type TournamentResult, type TrajectoryEvent, type TrajectoryLogger, type TrajectoryParseResult, type TrajectorySource, type TurnRequest, type TurnResult, type UsageTotals, type UseOptions, type UserContentPart, aborted_error, adversarial, assert_valid_step_id, bench, bench_suspend_error, branch, chain, checkpoint, claude_cli_error, compose, consensus, create_engine, default_normalize_usage, describe, describe_cycle_error, engine_config_error, engine_disposed_error, ensemble, ensemble_step, error_path, fallback, __json_default_export as flow_schema, forward_standard_env, gate, improve, incomplete_generation_error, is_checkpoint_event, is_custom_trajectory_event, is_emit_event, is_run_end_event, is_span_end_event, is_span_start_event, is_step, is_step_kind, is_valid_step_id, judge_equals, judge_llm, judge_with, learn, loop, map, model_call, model_required_error, model_step, normalize_score, on_chunk_error, parallel, parse_trajectory_event, pipe, provider_auth_error, provider_capability_error, provider_error, provider_not_configured_error, provider_required_error, rate_limit_error, read_baseline, regression_compare, resolve_display_name, resume_validation_error, retry, run, schema_validation_error, scope, sequence, stash, step, suggest_step_id, suspend, suspended_error, timeout, timeout_error, tool_approval_denied_error, tool_error, tournament, use, write_baseline };
|
|
1814
1873
|
//# sourceMappingURL=index.d.ts.map
|