@llm4ts/runner 2.19.0 → 2.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentTree.d.ts +150 -0
- package/dist/AgentTree.d.ts.map +1 -0
- package/dist/AgentTree.js +638 -0
- package/dist/AgentTree.js.map +1 -0
- package/dist/AgentTreeSurface.d.ts +34 -0
- package/dist/AgentTreeSurface.d.ts.map +1 -0
- package/dist/AgentTreeSurface.js +118 -0
- package/dist/AgentTreeSurface.js.map +1 -0
- package/dist/FlowArgs.d.ts +1 -1
- package/dist/FlowArgs.d.ts.map +1 -1
- package/dist/FlowArgs.js +1 -0
- package/dist/FlowArgs.js.map +1 -1
- package/dist/FlowRunner.d.ts.map +1 -1
- package/dist/FlowRunner.js +33 -4
- package/dist/FlowRunner.js.map +1 -1
- package/dist/Terminal.d.ts.map +1 -1
- package/dist/Terminal.js +15 -3
- package/dist/Terminal.js.map +1 -1
- package/dist/Watch.d.ts +46 -0
- package/dist/Watch.d.ts.map +1 -0
- package/dist/Watch.js +177 -0
- package/dist/Watch.js.map +1 -0
- package/package.json +6 -3
- package/src/AgentTree.ts +954 -0
- package/src/AgentTreeSurface.ts +202 -0
- package/src/FlowArgs.ts +1 -0
- package/src/FlowRunner.ts +51 -4
- package/src/Terminal.ts +15 -2
- package/src/Watch.ts +291 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { FlowEvent } from "@llm4ts/flow/FlowEvents";
|
|
2
|
+
import type { TraceLine } from "@llm4ts/flow/FlowRecorder";
|
|
3
|
+
/**
|
|
4
|
+
* The agent tree (ADR 0022): a full-screen view of a running or finished
|
|
5
|
+
* flow — the orchestrator, the judgment layer, the story lanes on the
|
|
6
|
+
* executor roster, the judge seat and a session log.
|
|
7
|
+
*
|
|
8
|
+
* Pure: `reduceTree` folds what a run published into a `TreeState`, and
|
|
9
|
+
* `renderTree` draws that state at a width. Where the inputs come from (the
|
|
10
|
+
* event hub of a live run, or a trace file) is the host's business, so a live
|
|
11
|
+
* view, a finished run and a replay are the same fold.
|
|
12
|
+
*/
|
|
13
|
+
export type TreeInput = {
|
|
14
|
+
readonly _tag: "Event";
|
|
15
|
+
readonly at: number;
|
|
16
|
+
readonly event: FlowEvent;
|
|
17
|
+
} | {
|
|
18
|
+
readonly _tag: "RunEnded";
|
|
19
|
+
readonly at: number;
|
|
20
|
+
readonly outcome: string;
|
|
21
|
+
};
|
|
22
|
+
export type LaneStatus = "running" | "done" | "failed";
|
|
23
|
+
export interface TreeLane {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
/** The lane's open stages below `story <id>`, innermost last. */
|
|
26
|
+
readonly stages: ReadonlyArray<string>;
|
|
27
|
+
readonly executor: string | undefined;
|
|
28
|
+
readonly startedAt: number;
|
|
29
|
+
readonly status: LaneStatus;
|
|
30
|
+
readonly lastTool: string | undefined;
|
|
31
|
+
/** The lane's most recent tool calls, oldest first, for the expanded view. */
|
|
32
|
+
readonly tools: ReadonlyArray<string>;
|
|
33
|
+
readonly tokens: number;
|
|
34
|
+
readonly costUsd: number;
|
|
35
|
+
}
|
|
36
|
+
export type LogSource = "lane" | "run" | "roster" | "judge";
|
|
37
|
+
export interface TreeLogEntry {
|
|
38
|
+
readonly at: number;
|
|
39
|
+
readonly source: LogSource;
|
|
40
|
+
/** The lane, executor or `flow` the entry is about. */
|
|
41
|
+
readonly who: string;
|
|
42
|
+
readonly what: string;
|
|
43
|
+
}
|
|
44
|
+
/** A story as the epic's board lists it, before or without a lane of its own. */
|
|
45
|
+
export interface TreeStory {
|
|
46
|
+
readonly id: string;
|
|
47
|
+
readonly status: "planned" | "active" | "waiting" | "done" | "failed" | "skipped";
|
|
48
|
+
}
|
|
49
|
+
/** A lease an executor holds now: its role and who it is for (a story id). */
|
|
50
|
+
export interface TreeLease {
|
|
51
|
+
readonly executor: string;
|
|
52
|
+
readonly role: string;
|
|
53
|
+
readonly label: string | undefined;
|
|
54
|
+
}
|
|
55
|
+
/** The judge seat: who sits in it, and how often it was asked. */
|
|
56
|
+
export interface TreeJudge {
|
|
57
|
+
readonly executor: string | undefined;
|
|
58
|
+
readonly reviews: number;
|
|
59
|
+
readonly verdicts: number;
|
|
60
|
+
}
|
|
61
|
+
/** The latest story verdict (`StoryJudged`). */
|
|
62
|
+
export interface TreeVerdict {
|
|
63
|
+
readonly lane: string;
|
|
64
|
+
readonly round: number;
|
|
65
|
+
readonly cleared: boolean;
|
|
66
|
+
readonly issues: number;
|
|
67
|
+
readonly dimensions: ReadonlyArray<{
|
|
68
|
+
readonly id: string;
|
|
69
|
+
readonly score: number;
|
|
70
|
+
readonly max: number;
|
|
71
|
+
}>;
|
|
72
|
+
}
|
|
73
|
+
/** The latest typed judgment per key (`JudgmentObserved`). */
|
|
74
|
+
export interface TreeJudgment {
|
|
75
|
+
readonly key: string;
|
|
76
|
+
readonly certainty: number;
|
|
77
|
+
readonly decision: string;
|
|
78
|
+
}
|
|
79
|
+
export interface TreeState {
|
|
80
|
+
readonly title: string;
|
|
81
|
+
readonly action: string | undefined;
|
|
82
|
+
/** The board's stories, in plan order; lanes not on it are added after. */
|
|
83
|
+
readonly stories: ReadonlyArray<TreeStory>;
|
|
84
|
+
readonly startedAt: number | undefined;
|
|
85
|
+
readonly now: number | undefined;
|
|
86
|
+
/** Run-wide open stages, innermost last. */
|
|
87
|
+
readonly stages: ReadonlyArray<string>;
|
|
88
|
+
/** Lanes in the order they started. */
|
|
89
|
+
readonly lanes: ReadonlyArray<TreeLane>;
|
|
90
|
+
/** Executors in the order the run first named them. */
|
|
91
|
+
readonly executors: ReadonlyArray<string>;
|
|
92
|
+
readonly leases: ReadonlyArray<TreeLease>;
|
|
93
|
+
/** Executors out of the round, with the roster's reason. */
|
|
94
|
+
readonly exclusions: ReadonlyArray<{
|
|
95
|
+
readonly executor: string;
|
|
96
|
+
readonly reason: string;
|
|
97
|
+
}>;
|
|
98
|
+
readonly judge: TreeJudge;
|
|
99
|
+
readonly verdict: TreeVerdict | undefined;
|
|
100
|
+
readonly judgments: ReadonlyArray<TreeJudgment>;
|
|
101
|
+
readonly log: ReadonlyArray<TreeLogEntry>;
|
|
102
|
+
readonly tokens: number;
|
|
103
|
+
/** Estimated: the backend's own figure when it reports one, else the price list. */
|
|
104
|
+
readonly costUsd: number;
|
|
105
|
+
/** The run's outcome once its trace says it ended; a live run has none. */
|
|
106
|
+
readonly ended: string | undefined;
|
|
107
|
+
}
|
|
108
|
+
export interface TreeOptions {
|
|
109
|
+
readonly title?: string;
|
|
110
|
+
/** What the run set out to do ("run plan", "round 2"), when the caller knows. */
|
|
111
|
+
readonly action?: string;
|
|
112
|
+
readonly stories?: ReadonlyArray<TreeStory>;
|
|
113
|
+
}
|
|
114
|
+
export declare const emptyTree: (options?: TreeOptions) => TreeState;
|
|
115
|
+
export declare const reduceTree: (state: TreeState, input: TreeInput) => TreeState;
|
|
116
|
+
/**
|
|
117
|
+
* A trace's lines as tree inputs. Kinds this version does not know — raw
|
|
118
|
+
* stream lines, events from a newer llm4ts — are skipped, so any trace renders.
|
|
119
|
+
*/
|
|
120
|
+
export declare const treeInputsOfTrace: (lines: ReadonlyArray<TraceLine>) => ReadonlyArray<TreeInput>;
|
|
121
|
+
export type TreeMode = "lanes" | "executors";
|
|
122
|
+
/** What the reader chose to look at; the run's state is separate. */
|
|
123
|
+
export interface TreeView {
|
|
124
|
+
readonly mode: TreeMode;
|
|
125
|
+
/** The selected lane's story id. */
|
|
126
|
+
readonly selected: string | undefined;
|
|
127
|
+
readonly expanded: boolean;
|
|
128
|
+
readonly fullLog: boolean;
|
|
129
|
+
}
|
|
130
|
+
export declare const initialView: TreeView;
|
|
131
|
+
/**
|
|
132
|
+
* The view after a key: arrows or 1–9 select a running lane, enter expands
|
|
133
|
+
* it, escape collapses, `e` switches lanes and executors, `l` the full log,
|
|
134
|
+
* `q` quits. Keys it does not know return the same view.
|
|
135
|
+
*/
|
|
136
|
+
export declare const onTreeKey: (view: TreeView, key: string, state: TreeState) => TreeView | "quit";
|
|
137
|
+
export interface TreeRenderOptions {
|
|
138
|
+
readonly width: number;
|
|
139
|
+
readonly colour: boolean;
|
|
140
|
+
readonly view: TreeView;
|
|
141
|
+
/** The terminal's rows; the frame fits them (see `renderTree`). */
|
|
142
|
+
readonly height?: number;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The tree at a width and, when `height` is given, no taller: the session
|
|
146
|
+
* log gives way first — fewer lines, down to one, then none — and only then
|
|
147
|
+
* is the frame cut, keeping its status lines, so a redraw never scrolls.
|
|
148
|
+
*/
|
|
149
|
+
export declare const renderTree: (state: TreeState, options: TreeRenderOptions) => ReadonlyArray<string>;
|
|
150
|
+
//# sourceMappingURL=AgentTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AgentTree.d.ts","sourceRoot":"","sources":["../src/AgentTree.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAI1D;;;;;;;;;GASG;AAEH,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAA;CAAE,GAC1E;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEtD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAA;IACtC,QAAQ,CAAC,QA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