taugraph 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +233 -2
- package/README.zh-CN.md +234 -0
- package/dist/core/engine.d.ts +51 -0
- package/dist/core/engine.d.ts.map +1 -0
- package/dist/core/engine.js +412 -0
- package/dist/core/engine.js.map +1 -0
- package/dist/core/errors.d.ts +48 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/errors.js +30 -0
- package/dist/core/errors.js.map +1 -0
- package/dist/core/graph.d.ts +11 -0
- package/dist/core/graph.d.ts.map +1 -0
- package/dist/core/graph.js +134 -0
- package/dist/core/graph.js.map +1 -0
- package/dist/core/node.d.ts +7 -0
- package/dist/core/node.d.ts.map +1 -0
- package/dist/core/node.js +22 -0
- package/dist/core/node.js.map +1 -0
- package/dist/core/standard-schema.d.ts +39 -0
- package/dist/core/standard-schema.d.ts.map +1 -0
- package/dist/core/standard-schema.js +2 -0
- package/dist/core/standard-schema.js.map +1 -0
- package/dist/core/trace.d.ts +90 -0
- package/dist/core/trace.d.ts.map +1 -0
- package/dist/core/trace.js +290 -0
- package/dist/core/trace.js.map +1 -0
- package/dist/core/types.d.ts +175 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/core/types.js +2 -0
- package/dist/core/types.js.map +1 -0
- package/dist/core/util.d.ts +19 -0
- package/dist/core/util.d.ts.map +1 -0
- package/dist/core/util.js +85 -0
- package/dist/core/util.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/code.d.ts +12 -0
- package/dist/nodes/code.d.ts.map +1 -0
- package/dist/nodes/code.js +9 -0
- package/dist/nodes/code.js.map +1 -0
- package/dist/nodes/human.d.ts +17 -0
- package/dist/nodes/human.d.ts.map +1 -0
- package/dist/nodes/human.js +18 -0
- package/dist/nodes/human.js.map +1 -0
- package/dist/nodes/index.d.ts +4 -0
- package/dist/nodes/index.d.ts.map +1 -0
- package/dist/nodes/index.js +6 -0
- package/dist/nodes/index.js.map +1 -0
- package/dist/nodes/llm.d.ts +63 -0
- package/dist/nodes/llm.d.ts.map +1 -0
- package/dist/nodes/llm.js +54 -0
- package/dist/nodes/llm.js.map +1 -0
- package/dist/nodes/util.d.ts +5 -0
- package/dist/nodes/util.d.ts.map +1 -0
- package/dist/nodes/util.js +11 -0
- package/dist/nodes/util.js.map +1 -0
- package/package.json +74 -4
- package/src/core/engine.ts +552 -0
- package/src/core/errors.ts +70 -0
- package/src/core/graph.ts +166 -0
- package/src/core/node.ts +24 -0
- package/src/core/standard-schema.ts +47 -0
- package/src/core/trace.ts +346 -0
- package/src/core/types.ts +206 -0
- package/src/core/util.ts +81 -0
- package/src/index.ts +46 -0
- package/src/nodes/code.ts +18 -0
- package/src/nodes/human.ts +33 -0
- package/src/nodes/index.ts +15 -0
- package/src/nodes/llm.ts +123 -0
- package/src/nodes/util.ts +13 -0
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export type MaybePromise<T> = T | PromiseLike<T>;
|
|
2
|
+
/** Event types written by the kernel. Nodes cannot append these. */
|
|
3
|
+
export type KernelEventType = "run_start" | "enter" | "exit" | "error" | "pause" | "resume" | "run_end";
|
|
4
|
+
/** Event types reserved by convention for plugin nodes. */
|
|
5
|
+
export type PluginEventType = "llm_call" | "tool_call";
|
|
6
|
+
export type TraceEventType = KernelEventType | PluginEventType | (string & {});
|
|
7
|
+
/** One immutable, JSON-serializable record in the append-only transcript. */
|
|
8
|
+
export interface TraceEvent {
|
|
9
|
+
/** Position in the run, starting at 0. Strictly increasing. */
|
|
10
|
+
readonly seq: number;
|
|
11
|
+
readonly runId: string;
|
|
12
|
+
readonly type: TraceEventType;
|
|
13
|
+
/** Milliseconds since epoch. */
|
|
14
|
+
readonly timestamp: number;
|
|
15
|
+
readonly nodeId?: string;
|
|
16
|
+
/** Index of the node execution this event belongs to, starting at 0. */
|
|
17
|
+
readonly step?: number;
|
|
18
|
+
readonly input?: unknown;
|
|
19
|
+
readonly output?: unknown;
|
|
20
|
+
readonly meta?: Readonly<Record<string, unknown>>;
|
|
21
|
+
}
|
|
22
|
+
/** A full run transcript. Serialize it with `toJSONL`, replay it with `graph.replay`. */
|
|
23
|
+
export type Trace = readonly TraceEvent[];
|
|
24
|
+
/** What a node may append through `ctx.trace.append`. The kernel fills in the rest. */
|
|
25
|
+
export interface PluginEvent {
|
|
26
|
+
readonly type: TraceEventType;
|
|
27
|
+
readonly input?: unknown;
|
|
28
|
+
readonly output?: unknown;
|
|
29
|
+
readonly meta?: Record<string, unknown>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* What running a node does to the outside world.
|
|
33
|
+
* - `read`: safe to run again (queries, LLM calls, pure code).
|
|
34
|
+
* - `write`: changes something outside the run (placing an order, sending a message).
|
|
35
|
+
* Replay never re-executes a write node unless you pass `allowWrites: true`.
|
|
36
|
+
* Undeclared nodes are treated like `read`.
|
|
37
|
+
*/
|
|
38
|
+
export type Effect = "read" | "write";
|
|
39
|
+
export interface RunContext {
|
|
40
|
+
readonly meta: {
|
|
41
|
+
readonly runId: string;
|
|
42
|
+
readonly nodeId: string;
|
|
43
|
+
readonly step: number;
|
|
44
|
+
/** 1-based attempt number when the node has a retry policy. */
|
|
45
|
+
readonly attempt: number;
|
|
46
|
+
/**
|
|
47
|
+
* True when this step was already running when the trace ended (e.g. the process crashed)
|
|
48
|
+
* and `resume` started it again. A write node should check whether its effect already happened.
|
|
49
|
+
*/
|
|
50
|
+
readonly recovered: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** Aborted when the caller cancels the run. Pass it to fetch / model clients. */
|
|
53
|
+
readonly signal: AbortSignal;
|
|
54
|
+
readonly trace: {
|
|
55
|
+
/** Append a side-effect record (llm_call, tool_call, ...) to the transcript. */
|
|
56
|
+
append(event: PluginEvent): void;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Asks the outside world for a value and pauses the run until `graph.resume(trace, value)`.
|
|
60
|
+
* On resume the node runs again from the top and this call returns the value.
|
|
61
|
+
* The n-th call in a node returns the n-th value delivered to this step.
|
|
62
|
+
* Code before the call runs again on resume, so keep it free of side effects.
|
|
63
|
+
* `request` (plain JSON) is recorded in the `pause` event and returned as `pending.request`.
|
|
64
|
+
*/
|
|
65
|
+
interrupt<T = unknown>(request?: unknown): T;
|
|
66
|
+
}
|
|
67
|
+
export interface RetryPolicy {
|
|
68
|
+
/** Total attempts including the first one. Must be an integer >= 1. */
|
|
69
|
+
readonly maxAttempts: number;
|
|
70
|
+
}
|
|
71
|
+
/** Receives the current (deeply frozen) state and returns a brand-new state. */
|
|
72
|
+
export type NodeFn<S> = (state: S, ctx: RunContext) => MaybePromise<S>;
|
|
73
|
+
export interface NodeMeta {
|
|
74
|
+
/** Free-form label recorded in `enter` events, e.g. "code" or "llm". */
|
|
75
|
+
readonly kind?: string;
|
|
76
|
+
readonly retry?: RetryPolicy;
|
|
77
|
+
readonly effect?: Effect;
|
|
78
|
+
}
|
|
79
|
+
/** Any function with the `NodeFn` signature is a node. Plugins attach metadata with `defineNode`. */
|
|
80
|
+
export type Node<S> = NodeFn<S> & NodeMeta;
|
|
81
|
+
export interface Edge<K extends string> {
|
|
82
|
+
readonly from: K;
|
|
83
|
+
readonly to: K;
|
|
84
|
+
}
|
|
85
|
+
export interface ConditionalEdge<S, K extends string> {
|
|
86
|
+
readonly from: K;
|
|
87
|
+
/** Pure, synchronous routing function. Put side effects in a node instead. */
|
|
88
|
+
readonly route: (state: NoInfer<S>) => K;
|
|
89
|
+
/** Optional allow-list of targets, checked at build time and at run time. */
|
|
90
|
+
readonly targets?: readonly K[];
|
|
91
|
+
}
|
|
92
|
+
/** Graph shape. The state schema is passed separately: `createGraph(schema, definition)`. */
|
|
93
|
+
export interface GraphDefinition<S, K extends string> {
|
|
94
|
+
readonly start: NoInfer<K>;
|
|
95
|
+
readonly nodes: {
|
|
96
|
+
readonly [P in K]: Node<NoInfer<S>>;
|
|
97
|
+
};
|
|
98
|
+
readonly edges?: readonly Edge<NoInfer<K>>[];
|
|
99
|
+
readonly conditionalEdges?: readonly ConditionalEdge<S, NoInfer<K>>[];
|
|
100
|
+
readonly endNodes: readonly NoInfer<K>[];
|
|
101
|
+
}
|
|
102
|
+
export interface RunOptions {
|
|
103
|
+
/** Defaults to a random UUID. */
|
|
104
|
+
readonly runId?: string;
|
|
105
|
+
readonly signal?: AbortSignal;
|
|
106
|
+
/** Upper bound on node executions, guards against unbounded loops. Defaults to 100. */
|
|
107
|
+
readonly maxSteps?: number;
|
|
108
|
+
/**
|
|
109
|
+
* Called synchronously for every appended event, before the run continues. Use it to write
|
|
110
|
+
* the trace to durable storage. If it throws, the run stops with SINK_FAILED.
|
|
111
|
+
*/
|
|
112
|
+
readonly onEvent?: (event: TraceEvent) => void;
|
|
113
|
+
}
|
|
114
|
+
export type ReplayMode = "recorded" | "live";
|
|
115
|
+
export interface ReplayOptions<S, K extends string> extends RunOptions {
|
|
116
|
+
/** Replace node implementations for this replay only, e.g. swap a model or mock a tool. */
|
|
117
|
+
readonly overrides?: {
|
|
118
|
+
readonly [P in K]?: Node<S>;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* - `recorded` (default): a non-overridden node reuses its recorded output when it sees
|
|
122
|
+
* exactly the recorded input state; otherwise it runs live.
|
|
123
|
+
* - `live`: every node runs again.
|
|
124
|
+
* In both modes, values delivered by `resume` are fed to `ctx.interrupt` again when the
|
|
125
|
+
* step sees the recorded input state.
|
|
126
|
+
*/
|
|
127
|
+
readonly mode?: ReplayMode;
|
|
128
|
+
/** Let `write` nodes run live. Off by default so a replay never repeats a real side effect. */
|
|
129
|
+
readonly allowWrites?: boolean;
|
|
130
|
+
}
|
|
131
|
+
export interface ResumeOptions extends Omit<RunOptions, "runId"> {
|
|
132
|
+
/** Required to restart a `write` node that was running when the trace ended. */
|
|
133
|
+
readonly allowWrites?: boolean;
|
|
134
|
+
}
|
|
135
|
+
/** Where a paused run is waiting. Compare `step` with your latest trace to reject stale answers. */
|
|
136
|
+
export interface Pending<K extends string = string> {
|
|
137
|
+
readonly nodeId: K;
|
|
138
|
+
readonly step: number;
|
|
139
|
+
readonly request: unknown;
|
|
140
|
+
}
|
|
141
|
+
interface RunResultBase<S, K extends string> {
|
|
142
|
+
readonly runId: string;
|
|
143
|
+
/** Final state, or for a paused run the state the waiting node received. */
|
|
144
|
+
readonly state: S;
|
|
145
|
+
readonly trace: Trace;
|
|
146
|
+
/** Node ids in execution order, across pauses. */
|
|
147
|
+
readonly path: readonly K[];
|
|
148
|
+
}
|
|
149
|
+
export interface CompletedRun<S, K extends string = string> extends RunResultBase<S, K> {
|
|
150
|
+
readonly status: "completed";
|
|
151
|
+
}
|
|
152
|
+
export interface PausedRun<S, K extends string = string> extends RunResultBase<S, K> {
|
|
153
|
+
readonly status: "paused";
|
|
154
|
+
readonly pending: Pending<K>;
|
|
155
|
+
}
|
|
156
|
+
export type RunResult<S, K extends string = string> = CompletedRun<S, K> | PausedRun<S, K>;
|
|
157
|
+
export interface Graph<S, I, K extends string> {
|
|
158
|
+
readonly start: K;
|
|
159
|
+
readonly nodeIds: readonly K[];
|
|
160
|
+
readonly endNodes: readonly K[];
|
|
161
|
+
run(input: I, options?: RunOptions): Promise<RunResult<S, K>>;
|
|
162
|
+
/** Runs without Promises. Throws ASYNC_IN_SYNC_RUN if a node or the schema returns a Promise. */
|
|
163
|
+
runSync(input: I, options?: RunOptions): RunResult<S, K>;
|
|
164
|
+
/**
|
|
165
|
+
* Continues a trace under the same runId, appending to it.
|
|
166
|
+
* - Paused trace: `value` is returned by the waiting node's `ctx.interrupt`.
|
|
167
|
+
* - Trace that ended without `run_end` (crash): restarts from the last unfinished step; omit `value`.
|
|
168
|
+
*/
|
|
169
|
+
resume(trace: Trace, value?: unknown, options?: ResumeOptions): Promise<RunResult<S, K>>;
|
|
170
|
+
resumeSync(trace: Trace, value?: unknown, options?: ResumeOptions): RunResult<S, K>;
|
|
171
|
+
/** Re-runs a recorded trace from its original input under a new runId. */
|
|
172
|
+
replay(trace: Trace, options?: ReplayOptions<S, K>): Promise<RunResult<S, K>>;
|
|
173
|
+
}
|
|
174
|
+
export {};
|
|
175
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAMjD,oEAAoE;AACpE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,CAAC;AAExG,2DAA2D;AAC3D,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,WAAW,CAAC;AAEvD,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,eAAe,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;AAE/E,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,gCAAgC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC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C;IACzD;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACzF,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACpF,0EAA0E;IAC1E,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC/E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare function isThenable(value: unknown): value is PromiseLike<unknown>;
|
|
2
|
+
export declare class NotJsonError extends Error {
|
|
3
|
+
readonly path: string;
|
|
4
|
+
readonly reason: string;
|
|
5
|
+
constructor(path: string, reason: string);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Returns a deeply frozen copy of a plain-JSON value.
|
|
9
|
+
*
|
|
10
|
+
* Throws `NotJsonError` for anything that would not survive a JSON round trip
|
|
11
|
+
* (Date, Map, class instances, functions, bigint, NaN, cycles). This is what makes
|
|
12
|
+
* an in-memory trace and a trace loaded from JSONL replay identically.
|
|
13
|
+
* `undefined` object properties are kept (JSON drops them; `jsonEqual` ignores them).
|
|
14
|
+
*/
|
|
15
|
+
export declare function freezeJson<T>(value: T): T;
|
|
16
|
+
/** Structural equality for JSON values. Object properties set to `undefined` count as absent. */
|
|
17
|
+
export declare function jsonEqual(a: unknown, b: unknown): boolean;
|
|
18
|
+
export declare function randomId(): string;
|
|
19
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/core/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAAC,OAAO,CAAC,CAMxE;AAED,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM;IAFzB,YACW,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAGxB;CACF;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,CAEzC;AAkCD,iGAAiG;AACjG,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAYzD;AAED,wBAAgB,QAAQ,IAAI,MAAM,CAIjC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
export function isThenable(value) {
|
|
2
|
+
return (value !== null &&
|
|
3
|
+
(typeof value === "object" || typeof value === "function") &&
|
|
4
|
+
typeof value.then === "function");
|
|
5
|
+
}
|
|
6
|
+
export class NotJsonError extends Error {
|
|
7
|
+
path;
|
|
8
|
+
reason;
|
|
9
|
+
constructor(path, reason) {
|
|
10
|
+
super(`${path === "" ? "(root)" : path}: ${reason}`);
|
|
11
|
+
this.path = path;
|
|
12
|
+
this.reason = reason;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns a deeply frozen copy of a plain-JSON value.
|
|
17
|
+
*
|
|
18
|
+
* Throws `NotJsonError` for anything that would not survive a JSON round trip
|
|
19
|
+
* (Date, Map, class instances, functions, bigint, NaN, cycles). This is what makes
|
|
20
|
+
* an in-memory trace and a trace loaded from JSONL replay identically.
|
|
21
|
+
* `undefined` object properties are kept (JSON drops them; `jsonEqual` ignores them).
|
|
22
|
+
*/
|
|
23
|
+
export function freezeJson(value) {
|
|
24
|
+
return copy(value, "", new Set());
|
|
25
|
+
}
|
|
26
|
+
function copy(value, path, ancestors) {
|
|
27
|
+
if (value === null || typeof value === "string" || typeof value === "boolean")
|
|
28
|
+
return value;
|
|
29
|
+
if (typeof value === "number") {
|
|
30
|
+
if (!Number.isFinite(value))
|
|
31
|
+
throw new NotJsonError(path, `non-finite number ${value}`);
|
|
32
|
+
return value;
|
|
33
|
+
}
|
|
34
|
+
if (typeof value !== "object")
|
|
35
|
+
throw new NotJsonError(path, `${typeof value} is not JSON`);
|
|
36
|
+
if (ancestors.has(value))
|
|
37
|
+
throw new NotJsonError(path, "circular reference");
|
|
38
|
+
ancestors.add(value);
|
|
39
|
+
let result;
|
|
40
|
+
if (Array.isArray(value)) {
|
|
41
|
+
result = value.map((item, i) => {
|
|
42
|
+
if (item === undefined)
|
|
43
|
+
throw new NotJsonError(`${path}[${i}]`, "undefined in array");
|
|
44
|
+
return copy(item, `${path}[${i}]`, ancestors);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
const proto = Object.getPrototypeOf(value);
|
|
49
|
+
if (proto !== Object.prototype && proto !== null) {
|
|
50
|
+
const name = value.constructor?.name ?? "object";
|
|
51
|
+
throw new NotJsonError(path, `${name} is not a plain object (use strings / numbers / arrays / objects)`);
|
|
52
|
+
}
|
|
53
|
+
const out = {};
|
|
54
|
+
for (const [key, item] of Object.entries(value)) {
|
|
55
|
+
out[key] = item === undefined ? undefined : copy(item, path === "" ? key : `${path}.${key}`, ancestors);
|
|
56
|
+
}
|
|
57
|
+
result = out;
|
|
58
|
+
}
|
|
59
|
+
ancestors.delete(value);
|
|
60
|
+
return Object.freeze(result);
|
|
61
|
+
}
|
|
62
|
+
/** Structural equality for JSON values. Object properties set to `undefined` count as absent. */
|
|
63
|
+
export function jsonEqual(a, b) {
|
|
64
|
+
if (a === b)
|
|
65
|
+
return true;
|
|
66
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null)
|
|
67
|
+
return false;
|
|
68
|
+
if (Array.isArray(a) !== Array.isArray(b))
|
|
69
|
+
return false;
|
|
70
|
+
if (Array.isArray(a) && Array.isArray(b)) {
|
|
71
|
+
return a.length === b.length && a.every((item, i) => jsonEqual(item, b[i]));
|
|
72
|
+
}
|
|
73
|
+
const ra = a;
|
|
74
|
+
const rb = b;
|
|
75
|
+
const ka = Object.keys(ra).filter((k) => ra[k] !== undefined);
|
|
76
|
+
const kb = Object.keys(rb).filter((k) => rb[k] !== undefined);
|
|
77
|
+
return ka.length === kb.length && ka.every((k) => Object.hasOwn(rb, k) && jsonEqual(ra[k], rb[k]));
|
|
78
|
+
}
|
|
79
|
+
export function randomId() {
|
|
80
|
+
const cryptoApi = globalThis.crypto;
|
|
81
|
+
if (typeof cryptoApi?.randomUUID === "function")
|
|
82
|
+
return cryptoApi.randomUUID();
|
|
83
|
+
return `run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 10)}`;
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/core/util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,UAAU,CAAC,KAAc;IACvC,OAAO,CACL,KAAK,KAAK,IAAI;QACd,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;QAC1D,OAAQ,KAA4B,CAAC,IAAI,KAAK,UAAU,CACzD,CAAC;AACJ,CAAC;AAED,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B,IAAI;IACJ,MAAM;IAFjB,YACW,IAAY,EACZ,MAAc;QAEvB,KAAK,CAAC,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,EAAE,CAA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AC,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;AACrF,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type { TaugraphErrorCode, TaugraphErrorDetails } from "./core/errors.js";
|
|
2
|
+
export { isTaugraphError, TaugraphError } from "./core/errors.js";
|
|
3
|
+
export { createGraph } from "./core/graph.js";
|
|
4
|
+
export { defineNode } from "./core/node.js";
|
|
5
|
+
export type { StandardSchemaV1 } from "./core/standard-schema.js";
|
|
6
|
+
export type { RecordedStep, TraceDiff } from "./core/trace.js";
|
|
7
|
+
export { assertTrace, diffTraces, fromJSONL, recordedSteps, TRACE_FORMAT, TRACE_VERSION, toJSONL, tracePath, } from "./core/trace.js";
|
|
8
|
+
export type { CompletedRun, ConditionalEdge, Edge, Effect, Graph, GraphDefinition, KernelEventType, MaybePromise, Node, NodeFn, NodeMeta, PausedRun, Pending, PluginEvent, PluginEventType, ReplayMode, ReplayOptions, ResumeOptions, RetryPolicy, RunContext, RunOptions, RunResult, Trace, TraceEvent, TraceEventType, } from "./core/types.js";
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,aAAa,EACb,OAAO,EACP,SAAS,GACV,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,YAAY,EACZ,eAAe,EACf,IAAI,EACJ,MAAM,EACN,KAAK,EACL,eAAe,EACf,eAAe,EACf,YAAY,EACZ,IAAI,EACJ,MAAM,EACN,QAAQ,EACR,SAAS,EACT,OAAO,EACP,WAAW,EACX,eAAe,EACf,UAAU,EACV,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,UAAU,EACV,SAAS,EACT,KAAK,EACL,UAAU,EACV,cAAc,GACf,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// taugraph kernel: graph definition, runtime, typed state, append-only trace.
|
|
2
|
+
// Plugin nodes (CodeNode, LLMNode, ...) live in "taugraph/nodes" and only use this public API.
|
|
3
|
+
export { isTaugraphError, TaugraphError } from "./core/errors.js";
|
|
4
|
+
export { createGraph } from "./core/graph.js";
|
|
5
|
+
export { defineNode } from "./core/node.js";
|
|
6
|
+
export { assertTrace, diffTraces, fromJSONL, recordedSteps, TRACE_FORMAT, TRACE_VERSION, toJSONL, tracePath, } from "./core/trace.js";
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,+FAA+F;AAG/F,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,aAAa,EACb,YAAY,EACZ,aAAa,EACb,OAAO,EACP,SAAS,GACV,MAAM,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Effect, type MaybePromise, type Node, type RetryPolicy, type RunContext } from "../index.js";
|
|
2
|
+
export interface CodeNodeOptions {
|
|
3
|
+
readonly retry?: RetryPolicy;
|
|
4
|
+
/** Declare `"write"` for code that changes the outside world, so replay will not repeat it. */
|
|
5
|
+
readonly effect?: Effect;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Deterministic transformation from state to state. Labelled `kind: "code"` in the trace.
|
|
9
|
+
* `S` is inferred from the graph schema; outside a graph, annotate it: `CodeNode<State>(...)`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function CodeNode<S>(fn: (state: S, ctx: RunContext) => MaybePromise<NoInfer<S>>, options?: CodeNodeOptions): Node<S>;
|
|
12
|
+
//# sourceMappingURL=code.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.d.ts","sourceRoot":"","sources":["../../src/nodes/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAEvH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC;IAC7B,+FAA+F;IAC/F,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,UAAU,KAAK,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAC3D,OAAO,GAAE,eAAoB,GAC5B,IAAI,CAAC,CAAC,CAAC,CAET"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineNode } from "../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic transformation from state to state. Labelled `kind: "code"` in the trace.
|
|
4
|
+
* `S` is inferred from the graph schema; outside a graph, annotate it: `CodeNode<State>(...)`.
|
|
5
|
+
*/
|
|
6
|
+
export function CodeNode(fn, options = {}) {
|
|
7
|
+
return defineNode(fn, { kind: "code", ...options });
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=code.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code.js","sourceRoot":"","sources":["../../src/nodes/code.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAgF,MAAM,aAAa,CAAC;AAQvH;;;GAGG;AACH,MAAM,UAAU,QAAQ,CACtB,EAA2D,EAC3D,OAAO,GAAoB,EAAE;IAE7B,OAAO,UAAU,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Node, type StandardSchemaV1 } from "../index.js";
|
|
2
|
+
export interface HumanNodeConfig<S, T> {
|
|
3
|
+
/**
|
|
4
|
+
* Builds what the human sees. Returned as `pending.request` by the paused run.
|
|
5
|
+
* `error` is set when the previous answer failed the `answer` schema, so you can ask again.
|
|
6
|
+
*/
|
|
7
|
+
readonly ask: (state: S, error?: string) => unknown;
|
|
8
|
+
/** Validates the value passed to `graph.resume`. An invalid value pauses again with `error` set. */
|
|
9
|
+
readonly answer?: StandardSchemaV1<unknown, T>;
|
|
10
|
+
readonly update: (state: S, answer: T) => NoInfer<S>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Pauses the run until a human (or any outside system) answers through `graph.resume(trace, value)`.
|
|
14
|
+
* Built only on `ctx.interrupt`; the kernel knows nothing about humans.
|
|
15
|
+
*/
|
|
16
|
+
export declare function HumanNode<S, T = unknown>(config: HumanNodeConfig<S, T>): Node<S>;
|
|
17
|
+
//# sourceMappingURL=human.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human.d.ts","sourceRoot":"","sources":["../../src/nodes/human.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiC,KAAK,IAAI,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG9F,MAAM,WAAW,eAAe,CAAC,CAAC,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC;IACpD,oGAAoG;IACpG,QAAQ,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC/C,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CACtD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,eAAe,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAchF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineNode } from "../index.js";
|
|
2
|
+
import { andThen, issuesMessage } from "./util.js";
|
|
3
|
+
/**
|
|
4
|
+
* Pauses the run until a human (or any outside system) answers through `graph.resume(trace, value)`.
|
|
5
|
+
* Built only on `ctx.interrupt`; the kernel knows nothing about humans.
|
|
6
|
+
*/
|
|
7
|
+
export function HumanNode(config) {
|
|
8
|
+
return defineNode((state, ctx) => {
|
|
9
|
+
const ask = (error) => {
|
|
10
|
+
const value = ctx.interrupt(config.ask(state, error));
|
|
11
|
+
if (!config.answer)
|
|
12
|
+
return config.update(state, value);
|
|
13
|
+
return andThen(config.answer["~standard"].validate(value), (result) => result.issues ? ask(issuesMessage(result.issues)) : config.update(state, result.value));
|
|
14
|
+
};
|
|
15
|
+
return ask();
|
|
16
|
+
}, { kind: "human" });
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=human.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"human.js","sourceRoot":"","sources":["../../src/nodes/human.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAuD,MAAM,aAAa,CAAC;AAC9F,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAanD;;;GAGG;AACH,MAAM,UAAU,SAAS,CAAiB,MAA6B;IACrE,OAAO,UAAU,CACf,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QACb,MAAM,GAAG,GAAG,CAAC,KAAc,EAAmB,EAAE;YAC9C,MAAM,KAAK,GAAG,GAAG,CAAC,SAAS,CAAU,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;YAC/D,IAAI,CAAC,MAAM,CAAC,MAAM;gBAAE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAU,CAAC,CAAC;YAC5D,OAAO,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CACpE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CACvF,CAAC;QACJ,CAAC,CAAC;QACF,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,EACD,EAAE,IAAI,EAAE,OAAO,EAAE,CAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CodeNode, type CodeNodeOptions } from "./code.js";
|
|
2
|
+
export { HumanNode, type HumanNodeConfig } from "./human.js";
|
|
3
|
+
export { type ChatMessage, type LLMModel, LLMNode, LLMOutputError, type LLMRequest, type LLMResponse, type LLMStructuredNodeConfig, type LLMTextNodeConfig, } from "./llm.js";
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,QAAQ,EACb,OAAO,EACP,cAAc,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,GACvB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Plugin nodes. Not part of the kernel: everything here is built on the public
|
|
2
|
+
// `defineNode` + `ctx.trace.append` API, the same way third-party nodes are.
|
|
3
|
+
export { CodeNode } from "./code.js";
|
|
4
|
+
export { HumanNode } from "./human.js";
|
|
5
|
+
export { LLMNode, LLMOutputError, } from "./llm.js";
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/nodes/index.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6EAA6E;AAE7E,OAAO,EAAE,QAAQ,EAAwB,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAwB,MAAM,YAAY,CAAC;AAC7D,OAAO,EAGL,OAAO,EACP,cAAc,GAKf,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type MaybePromise, type Node, type RetryPolicy, type StandardSchemaV1 } from "../index.js";
|
|
2
|
+
export interface ChatMessage {
|
|
3
|
+
readonly role: "system" | "user" | "assistant";
|
|
4
|
+
readonly content: string;
|
|
5
|
+
}
|
|
6
|
+
/** Everything in a request is recorded in the trace, so keep it plain JSON. */
|
|
7
|
+
export interface LLMRequest {
|
|
8
|
+
readonly messages: readonly ChatMessage[];
|
|
9
|
+
readonly temperature?: number;
|
|
10
|
+
readonly maxTokens?: number;
|
|
11
|
+
/** Hint for adapters that support JSON mode. */
|
|
12
|
+
readonly responseFormat?: "text" | "json";
|
|
13
|
+
/** Provider-specific options, passed through by the adapter. */
|
|
14
|
+
readonly extra?: Readonly<Record<string, unknown>>;
|
|
15
|
+
}
|
|
16
|
+
export interface LLMResponse {
|
|
17
|
+
readonly content: string;
|
|
18
|
+
readonly model?: string;
|
|
19
|
+
readonly finishReason?: string;
|
|
20
|
+
readonly usage?: {
|
|
21
|
+
readonly inputTokens?: number;
|
|
22
|
+
readonly outputTokens?: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface LLMModel {
|
|
26
|
+
/** Recorded in every `llm_call` event, e.g. "openai:gpt-4o-mini" or "ollama:qwen3". */
|
|
27
|
+
readonly id: string;
|
|
28
|
+
complete(request: LLMRequest, options: {
|
|
29
|
+
readonly signal: AbortSignal;
|
|
30
|
+
}): MaybePromise<LLMResponse>;
|
|
31
|
+
}
|
|
32
|
+
interface LLMNodeBase<S> {
|
|
33
|
+
readonly model: LLMModel;
|
|
34
|
+
/** Builds the request from state. A string becomes a single user message. */
|
|
35
|
+
readonly prompt: (state: S) => LLMRequest | string;
|
|
36
|
+
/** Retries the whole call, including output parsing. */
|
|
37
|
+
readonly retry?: RetryPolicy;
|
|
38
|
+
}
|
|
39
|
+
export interface LLMTextNodeConfig<S> extends LLMNodeBase<S> {
|
|
40
|
+
/** Folds the reply into state. The return type does not drive inference; the graph does. */
|
|
41
|
+
readonly update: (state: S, text: string, response: LLMResponse) => NoInfer<S>;
|
|
42
|
+
}
|
|
43
|
+
export interface LLMStructuredNodeConfig<S, T> extends LLMNodeBase<S> {
|
|
44
|
+
/** Parses the response content as JSON (code fences allowed) and validates it. */
|
|
45
|
+
readonly output: StandardSchemaV1<unknown, T>;
|
|
46
|
+
readonly update: (state: S, data: T, response: LLMResponse) => NoInfer<S>;
|
|
47
|
+
}
|
|
48
|
+
/** Thrown when structured output is not JSON or fails its schema. Retryable. */
|
|
49
|
+
export declare class LLMOutputError extends Error {
|
|
50
|
+
readonly content: string;
|
|
51
|
+
readonly issues?: readonly StandardSchemaV1.Issue[] | undefined;
|
|
52
|
+
readonly name = "LLMOutputError";
|
|
53
|
+
constructor(message: string, content: string, issues?: readonly StandardSchemaV1.Issue[] | undefined);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Calls a model and folds the result into state. Every call is appended to the trace
|
|
57
|
+
* as an `llm_call` event (request in `input`, response in `output`).
|
|
58
|
+
* Stays synchronous when the model does, so mock models work with `runSync`.
|
|
59
|
+
*/
|
|
60
|
+
export declare function LLMNode<S, T>(config: LLMStructuredNodeConfig<S, T>): Node<S>;
|
|
61
|
+
export declare function LLMNode<S>(config: LLMTextNodeConfig<S>): Node<S>;
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/nodes/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,YAAY,EAAE,KAAK,IAAI,EAAE,KAAK,WAAW,EAAE,KAAK,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAOhH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,+EAA+E;AAC/E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,WAAW,EAAE,CAAC;IAC1C,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,QA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AAK,OAAO,CAAC,CAAC,CAAC,CAAC;CAChF;AAED,MAAM,WAAW,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAC,CAAC;IACnE,kFAAkF;IAClF,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC9C,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;CAC3E;AAED,gFAAgF;AAChF,qBAAa,cAAe,SAAQ,KAAK;IAIrC,QAAQ,CAAC,OAAO,EAAE,MAAM;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,SAAS,gBAAgB,CAAC,KAAK,EAAE;IAJrD,SAAkB,IAAI,oBAAoB;IAC1C,YACE,OAAO,EAAE,MAAM,EACN,OAAO,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,SAAS,gBAAgB,CAAC,KAAK,EAAE,YAAA,EAGpD;CACF;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,uBAAuB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAC9E,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { defineNode } from "../index.js";
|
|
2
|
+
import { andThen, issuesMessage } from "./util.js";
|
|
3
|
+
/** Thrown when structured output is not JSON or fails its schema. Retryable. */
|
|
4
|
+
export class LLMOutputError extends Error {
|
|
5
|
+
content;
|
|
6
|
+
issues;
|
|
7
|
+
name = "LLMOutputError";
|
|
8
|
+
constructor(message, content, issues) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.content = content;
|
|
11
|
+
this.issues = issues;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export function LLMNode(config) {
|
|
15
|
+
const { model, prompt } = config;
|
|
16
|
+
return defineNode((state, ctx) => {
|
|
17
|
+
const built = prompt(state);
|
|
18
|
+
const request = typeof built === "string" ? { messages: [{ role: "user", content: built }] } : built;
|
|
19
|
+
const startedAt = Date.now();
|
|
20
|
+
return andThen(model.complete(request, { signal: ctx.signal }), (response) => {
|
|
21
|
+
if (typeof response?.content !== "string") {
|
|
22
|
+
throw new TypeError(`Model "${model.id}" returned a response without a string \`content\``);
|
|
23
|
+
}
|
|
24
|
+
ctx.trace.append({
|
|
25
|
+
type: "llm_call",
|
|
26
|
+
input: request,
|
|
27
|
+
output: response,
|
|
28
|
+
meta: { model: model.id, durationMs: Date.now() - startedAt },
|
|
29
|
+
});
|
|
30
|
+
if (!("output" in config))
|
|
31
|
+
return config.update(state, response.content, response);
|
|
32
|
+
return andThen(parseStructured(config.output, response.content), (data) => config.update(state, data, response));
|
|
33
|
+
});
|
|
34
|
+
}, { kind: "llm", ...(config.retry && { retry: config.retry }) });
|
|
35
|
+
}
|
|
36
|
+
function parseStructured(schema, content) {
|
|
37
|
+
const fenced = /```(?:json)?\s*([\s\S]*?)```/i.exec(content);
|
|
38
|
+
const text = (fenced?.[1] ?? content).trim();
|
|
39
|
+
let json;
|
|
40
|
+
try {
|
|
41
|
+
json = JSON.parse(text);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
throw new LLMOutputError("Model output is not valid JSON", content);
|
|
45
|
+
}
|
|
46
|
+
return andThen(schema["~standard"].validate(json), (result) => {
|
|
47
|
+
if (result.issues) {
|
|
48
|
+
const detail = issuesMessage(result.issues);
|
|
49
|
+
throw new LLMOutputError(`Model output does not match the schema: ${detail}`, content, result.issues);
|
|
50
|
+
}
|
|
51
|
+
return result.value;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=llm.js.map
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EAAE,CAAC,MAAM,EAAE,EAAE;QAC5D,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,IAAI,cAAc,CAAC,2CAA2C,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;QACxG,CAAC;QACD,OAAO,MAAM,CAAC,KAAK,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { MaybePromise, StandardSchemaV1 } from "../index.js";
|
|
2
|
+
/** Chains without introducing a Promise when the value is synchronous, so nodes stay `runSync`-friendly. */
|
|
3
|
+
export declare function andThen<A, B>(value: MaybePromise<A>, fn: (value: A) => MaybePromise<B>): MaybePromise<B>;
|
|
4
|
+
export declare function issuesMessage(issues: readonly StandardSchemaV1.Issue[]): string;
|
|
5
|
+
//# sourceMappingURL=util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/nodes/util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAElE,4GAA4G;AAC5G,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAKxG;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,SAAS,gBAAgB,CAAC,KAAK,EAAE,GAAG,MAAM,CAE/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Chains without introducing a Promise when the value is synchronous, so nodes stay `runSync`-friendly. */
|
|
2
|
+
export function andThen(value, fn) {
|
|
3
|
+
if (value !== null && typeof value === "object" && typeof value.then === "function") {
|
|
4
|
+
return Promise.resolve(value).then(fn);
|
|
5
|
+
}
|
|
6
|
+
return fn(value);
|
|
7
|
+
}
|
|
8
|
+
export function issuesMessage(issues) {
|
|
9
|
+
return issues.map((issue) => issue.message).join("; ");
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/nodes/util.ts"],"names":[],"mappings":"AAEA,4GAA4G;AAC5G,MAAM,UAAU,OAAO,CAAO,KAAsB,EAAE,EAAiC;IACrF,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAQ,KAAwB,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACxG,OAAO,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,EAAE,CAAC,KAAU,CAAC,CAAC;AACxB,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,MAAyC;IACrE,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzD,CAAC"}
|