@darqlabs/curator-sdk 0.1.5 → 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/README.md +18 -0
- package/dist/cjs/client.d.ts +13 -0
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +30 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/errors.d.ts +17 -1
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +23 -1
- package/dist/cjs/errors.js.map +1 -1
- package/dist/cjs/graph.d.ts +307 -0
- package/dist/cjs/graph.d.ts.map +1 -0
- package/dist/cjs/graph.js +336 -0
- package/dist/cjs/graph.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -3
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/integrations.d.ts +57 -0
- package/dist/cjs/integrations.d.ts.map +1 -0
- package/dist/cjs/integrations.js +85 -0
- package/dist/cjs/integrations.js.map +1 -0
- package/dist/cjs/streamEventParse.d.ts.map +1 -1
- package/dist/cjs/streamEventParse.js +19 -0
- package/dist/cjs/streamEventParse.js.map +1 -1
- package/dist/cjs/streamEvents.d.ts +38 -3
- package/dist/cjs/streamEvents.d.ts.map +1 -1
- package/dist/cjs/streamEvents.js +3 -1
- package/dist/cjs/streamEvents.js.map +1 -1
- package/dist/cjs/types.d.ts +29 -0
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/esm/client.d.ts +13 -0
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +31 -1
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/errors.d.ts +17 -1
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +21 -0
- package/dist/esm/errors.js.map +1 -1
- package/dist/esm/graph.d.ts +307 -0
- package/dist/esm/graph.d.ts.map +1 -0
- package/dist/esm/graph.js +321 -0
- package/dist/esm/graph.js.map +1 -0
- package/dist/esm/index.d.ts +4 -3
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +2 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/integrations.d.ts +57 -0
- package/dist/esm/integrations.d.ts.map +1 -0
- package/dist/esm/integrations.js +80 -0
- package/dist/esm/integrations.js.map +1 -0
- package/dist/esm/streamEventParse.d.ts.map +1 -1
- package/dist/esm/streamEventParse.js +19 -0
- package/dist/esm/streamEventParse.js.map +1 -1
- package/dist/esm/streamEvents.d.ts +38 -3
- package/dist/esm/streamEvents.d.ts.map +1 -1
- package/dist/esm/streamEvents.js +3 -1
- package/dist/esm/streamEvents.js.map +1 -1
- package/dist/esm/types.d.ts +29 -0
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow-graph authoring + run surface for the Curator SDK.
|
|
3
|
+
*
|
|
4
|
+
* import { Curator, reducers, agentNode, toolNode, transformNode, edge, branch, when } from "@darqlabs/curator-sdk"
|
|
5
|
+
*
|
|
6
|
+
* const draft = curator.defineGraph({
|
|
7
|
+
* name: "copy-loop",
|
|
8
|
+
* state: { messages: reducers.append(), draft: reducers.lastValue(), revisions: reducers.counter() },
|
|
9
|
+
* nodes: {
|
|
10
|
+
* write: agentNode("copywriter"),
|
|
11
|
+
* review: toolNode("api.grammar.check"),
|
|
12
|
+
* score: transformNode({ transformId: "tf_quality", version: 1 }),
|
|
13
|
+
* },
|
|
14
|
+
* entry: "write",
|
|
15
|
+
* edges: [
|
|
16
|
+
* edge("write", "review"),
|
|
17
|
+
* edge("review", "score"),
|
|
18
|
+
* branch("score", when("draft_ok", "==", true).then("END").else("write")),
|
|
19
|
+
* ],
|
|
20
|
+
* recursionLimit: 12,
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* const graph = await curator.graphs.create(draft) // POST /api/graphs
|
|
24
|
+
* await graph.deploy({ expectedDraftRevision: 1 }) // versioned snapshot
|
|
25
|
+
*
|
|
26
|
+
* // run + stream node/state events
|
|
27
|
+
* for await (const ev of graph.stream({ messages: [] })) {
|
|
28
|
+
* if (ev.type === "node.completed") console.log("done:", ev.node)
|
|
29
|
+
* if (ev.type === "done") console.log("final:", ev.state)
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* These graph types are SDK-owned (the SDK is published and cannot depend on the
|
|
33
|
+
* private @darq/shared-types); they mirror the backend spec shape exactly so the
|
|
34
|
+
* assembled JSON validates + compiles server-side.
|
|
35
|
+
*/
|
|
36
|
+
import type { HttpClient } from "./http.js";
|
|
37
|
+
import type { Environment } from "./types.js";
|
|
38
|
+
export interface TransformRef {
|
|
39
|
+
transformId: string;
|
|
40
|
+
version: number;
|
|
41
|
+
autoUpdate?: boolean;
|
|
42
|
+
}
|
|
43
|
+
export type ReducerKind = "append" | "lastValue" | "merge" | "counter" | "custom";
|
|
44
|
+
export interface ChannelDescriptor {
|
|
45
|
+
reducer: ReducerKind;
|
|
46
|
+
reducerRef?: TransformRef;
|
|
47
|
+
initialValue?: unknown;
|
|
48
|
+
description?: string;
|
|
49
|
+
}
|
|
50
|
+
export type JoinPolicy = "all" | "any";
|
|
51
|
+
export interface NodeCommon {
|
|
52
|
+
inputChannels?: string[];
|
|
53
|
+
inputTransform?: TransformRef;
|
|
54
|
+
outputTransform?: TransformRef;
|
|
55
|
+
join?: JoinPolicy;
|
|
56
|
+
timeout?: number;
|
|
57
|
+
maxVisits?: number;
|
|
58
|
+
label?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface AgentGraphNode extends NodeCommon {
|
|
61
|
+
type: "agent";
|
|
62
|
+
agentId: string;
|
|
63
|
+
instructions?: string;
|
|
64
|
+
}
|
|
65
|
+
export interface ToolGraphNode extends NodeCommon {
|
|
66
|
+
type: "tool";
|
|
67
|
+
action: string;
|
|
68
|
+
parameters?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
export interface TransformGraphNode extends NodeCommon {
|
|
71
|
+
type: "transform";
|
|
72
|
+
transform: TransformRef;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Fans its inline `body` out over the elements of the `over` channel (an array),
|
|
76
|
+
* appending each body output into `collect`. Body params/instructions can reference
|
|
77
|
+
* the current element via `{{item}}` / `{{item.field}}` / `{{index}}`. Body may be
|
|
78
|
+
* an agent/tool/transform node — not another forEach (no nesting).
|
|
79
|
+
*/
|
|
80
|
+
export interface ForEachGraphNode extends NodeCommon {
|
|
81
|
+
type: "forEach";
|
|
82
|
+
over: string;
|
|
83
|
+
body: GraphNode;
|
|
84
|
+
collect?: string;
|
|
85
|
+
itemAs?: string;
|
|
86
|
+
}
|
|
87
|
+
export type GraphNode = AgentGraphNode | ToolGraphNode | TransformGraphNode | ForEachGraphNode;
|
|
88
|
+
export type BranchOp = "==" | "!=" | ">" | ">=" | "<" | "<=" | "in" | "not_in" | "exists" | "truthy" | "falsy";
|
|
89
|
+
export interface BranchPredicate {
|
|
90
|
+
channel: string;
|
|
91
|
+
op: BranchOp;
|
|
92
|
+
value?: unknown;
|
|
93
|
+
}
|
|
94
|
+
export type Branch = {
|
|
95
|
+
kind: "predicate";
|
|
96
|
+
predicate: BranchPredicate;
|
|
97
|
+
then: string;
|
|
98
|
+
else: string;
|
|
99
|
+
} | {
|
|
100
|
+
kind: "router";
|
|
101
|
+
transform: TransformRef;
|
|
102
|
+
targets: string[];
|
|
103
|
+
};
|
|
104
|
+
export interface StaticEdge {
|
|
105
|
+
kind: "static";
|
|
106
|
+
from: string;
|
|
107
|
+
to: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ConditionalEdge {
|
|
110
|
+
kind: "conditional";
|
|
111
|
+
from: string;
|
|
112
|
+
branch: Branch;
|
|
113
|
+
}
|
|
114
|
+
export type GraphEdge = StaticEdge | ConditionalEdge;
|
|
115
|
+
export interface GraphSpec {
|
|
116
|
+
state: Record<string, ChannelDescriptor>;
|
|
117
|
+
nodes: Record<string, GraphNode>;
|
|
118
|
+
entry: string;
|
|
119
|
+
edges: GraphEdge[];
|
|
120
|
+
recursionLimit?: number;
|
|
121
|
+
toolFailureMode?: "strict" | "best_effort";
|
|
122
|
+
}
|
|
123
|
+
/** The `END` sentinel target. */
|
|
124
|
+
export declare const GRAPH_END: "END";
|
|
125
|
+
export type GraphRunStatus = "running" | "paused" | "succeeded" | "failed" | "cancelled";
|
|
126
|
+
export type GraphNodeRunStatus = "pending" | "ready" | "running" | "succeeded" | "failed" | "skipped";
|
|
127
|
+
export interface GraphNodeRunView {
|
|
128
|
+
key: string;
|
|
129
|
+
type: GraphNode["type"];
|
|
130
|
+
status: GraphNodeRunStatus;
|
|
131
|
+
visits: number;
|
|
132
|
+
childRunId?: string;
|
|
133
|
+
}
|
|
134
|
+
export interface GraphRunView {
|
|
135
|
+
runId: string;
|
|
136
|
+
graphId: string;
|
|
137
|
+
versionId: string;
|
|
138
|
+
status: GraphRunStatus;
|
|
139
|
+
spec: GraphSpec;
|
|
140
|
+
nodes: GraphNodeRunView[];
|
|
141
|
+
hops: number;
|
|
142
|
+
recursionLimit: number;
|
|
143
|
+
state: Record<string, unknown>;
|
|
144
|
+
errorCode?: string;
|
|
145
|
+
errorMessage?: string;
|
|
146
|
+
}
|
|
147
|
+
/** Streamed node/state lifecycle, derived from run-view snapshots. */
|
|
148
|
+
export type GraphRunEvent = {
|
|
149
|
+
type: "run.started";
|
|
150
|
+
runId: string;
|
|
151
|
+
} | {
|
|
152
|
+
type: "node.started";
|
|
153
|
+
node: string;
|
|
154
|
+
visit: number;
|
|
155
|
+
} | {
|
|
156
|
+
type: "node.completed";
|
|
157
|
+
node: string;
|
|
158
|
+
} | {
|
|
159
|
+
type: "node.failed";
|
|
160
|
+
node: string;
|
|
161
|
+
} | {
|
|
162
|
+
type: "state.delta";
|
|
163
|
+
channels: Record<string, unknown>;
|
|
164
|
+
} | {
|
|
165
|
+
type: "done";
|
|
166
|
+
status: GraphRunStatus;
|
|
167
|
+
state: Record<string, unknown>;
|
|
168
|
+
} | {
|
|
169
|
+
type: "error";
|
|
170
|
+
message: string;
|
|
171
|
+
};
|
|
172
|
+
export declare const reducers: {
|
|
173
|
+
append: () => ChannelDescriptor;
|
|
174
|
+
lastValue: () => ChannelDescriptor;
|
|
175
|
+
merge: () => ChannelDescriptor;
|
|
176
|
+
counter: () => ChannelDescriptor;
|
|
177
|
+
/** A custom fold `(prev, update) => next`, run as a sandboxed transform. */
|
|
178
|
+
custom: (transform: TransformRef) => ChannelDescriptor;
|
|
179
|
+
};
|
|
180
|
+
export declare function agentNode(agentId: string, opts?: Omit<AgentGraphNode, "type" | "agentId">): AgentGraphNode;
|
|
181
|
+
export declare function toolNode(action: string, opts?: Omit<ToolGraphNode, "type" | "action">): ToolGraphNode;
|
|
182
|
+
export declare function transformNode(transform: TransformRef, opts?: Omit<TransformGraphNode, "type" | "transform">): TransformGraphNode;
|
|
183
|
+
/**
|
|
184
|
+
* A `forEach` (map) node: run `body` per element of the `over` channel, appending
|
|
185
|
+
* each output into `collect`. Body params can reference the element via
|
|
186
|
+
* `{{item}}` / `{{item.field}}` / `{{index}}`.
|
|
187
|
+
*/
|
|
188
|
+
export declare function forEachNode(over: string, body: GraphNode, opts?: Omit<ForEachGraphNode, "type" | "over" | "body">): ForEachGraphNode;
|
|
189
|
+
export declare function edge(from: string, to: string): StaticEdge;
|
|
190
|
+
/** Attach a conditional edge to `from`. Pass a predicate builder or a router. */
|
|
191
|
+
export declare function branch(from: string, spec: Branch | PredicateBuilder): ConditionalEdge;
|
|
192
|
+
/** A sandboxed router transform that returns a next-node key (or END). */
|
|
193
|
+
export declare function router(transform: TransformRef, targets: string[]): Branch;
|
|
194
|
+
/**
|
|
195
|
+
* Fluent declarative predicate: `when("draft_ok", "==", true).then("END").else("write")`.
|
|
196
|
+
* Unary ops (`exists`/`truthy`/`falsy`) omit the value.
|
|
197
|
+
*/
|
|
198
|
+
export declare function when(channel: string, op: BranchOp, value?: unknown): PredicateBuilder;
|
|
199
|
+
export declare class PredicateBuilder {
|
|
200
|
+
private readonly predicate;
|
|
201
|
+
private thenKey?;
|
|
202
|
+
private elseKey?;
|
|
203
|
+
constructor(predicate: BranchPredicate);
|
|
204
|
+
then(nodeKey: string): this;
|
|
205
|
+
else(nodeKey: string): this;
|
|
206
|
+
/** @internal */
|
|
207
|
+
build(): Branch;
|
|
208
|
+
}
|
|
209
|
+
export interface DefineGraphConfig {
|
|
210
|
+
name: string;
|
|
211
|
+
description?: string;
|
|
212
|
+
state: Record<string, ChannelDescriptor>;
|
|
213
|
+
nodes: Record<string, GraphNode>;
|
|
214
|
+
entry: string;
|
|
215
|
+
edges: GraphEdge[];
|
|
216
|
+
recursionLimit?: number;
|
|
217
|
+
toolFailureMode?: "strict" | "best_effort";
|
|
218
|
+
tags?: string[];
|
|
219
|
+
}
|
|
220
|
+
/** A locally-assembled graph, ready to `curator.graphs.create(...)`. */
|
|
221
|
+
export interface GraphDraft {
|
|
222
|
+
name: string;
|
|
223
|
+
description?: string;
|
|
224
|
+
tags?: string[];
|
|
225
|
+
spec: GraphSpec;
|
|
226
|
+
}
|
|
227
|
+
/** Assemble a serializable graph spec locally. Pure — no network. */
|
|
228
|
+
export declare function defineGraph(config: DefineGraphConfig): GraphDraft;
|
|
229
|
+
export interface GraphRunOptions {
|
|
230
|
+
/** Target environment for the deployed spec (default: the client default). */
|
|
231
|
+
environment?: Environment;
|
|
232
|
+
/** Run the draft spec instead of the live deployed version. */
|
|
233
|
+
useDraft?: boolean;
|
|
234
|
+
/** Sync-wait timeout, in ms (server-capped). Only used by `run` (non-stream). */
|
|
235
|
+
timeoutMs?: number;
|
|
236
|
+
}
|
|
237
|
+
export interface GraphRunResult {
|
|
238
|
+
runId: string;
|
|
239
|
+
status: GraphRunStatus | "timeout";
|
|
240
|
+
state?: Record<string, unknown>;
|
|
241
|
+
errorCode?: string;
|
|
242
|
+
errorMessage?: string;
|
|
243
|
+
}
|
|
244
|
+
export interface DeployGraphOptions {
|
|
245
|
+
environment?: Environment;
|
|
246
|
+
slug?: string;
|
|
247
|
+
changeSummary?: string;
|
|
248
|
+
/** Optimistic-concurrency token — the draft revision you reviewed. */
|
|
249
|
+
expectedDraftRevision: number;
|
|
250
|
+
}
|
|
251
|
+
/** A handle to one graph resource, addressed by its `graph_id`. */
|
|
252
|
+
export declare class Graph {
|
|
253
|
+
private readonly http;
|
|
254
|
+
private readonly baseUrl;
|
|
255
|
+
private readonly defaultTimeoutMs;
|
|
256
|
+
readonly graphId: string;
|
|
257
|
+
private readonly defaultEnvironment;
|
|
258
|
+
/** @internal */
|
|
259
|
+
constructor(http: HttpClient, baseUrl: string, defaultTimeoutMs: number, graphId: string, defaultEnvironment: Environment);
|
|
260
|
+
private get base();
|
|
261
|
+
/** Deploy the current draft as an immutable versioned snapshot. */
|
|
262
|
+
deploy(opts: DeployGraphOptions): Promise<{
|
|
263
|
+
versionId: string;
|
|
264
|
+
versionNumber: number;
|
|
265
|
+
slug: string;
|
|
266
|
+
}>;
|
|
267
|
+
/**
|
|
268
|
+
* Start a run and, unless `{ wait: false }`, block until it settles.
|
|
269
|
+
* Returns the terminal channel state (or `status: "timeout"` if the wait
|
|
270
|
+
* expires — the run keeps going server-side).
|
|
271
|
+
*/
|
|
272
|
+
run(input: Record<string, unknown>, opts?: GraphRunOptions & {
|
|
273
|
+
wait?: boolean;
|
|
274
|
+
}): Promise<GraphRunResult>;
|
|
275
|
+
/**
|
|
276
|
+
* Start a run and stream node/state lifecycle events until it settles.
|
|
277
|
+
* Events (`run.started` / `node.started` / `node.completed` / `node.failed`
|
|
278
|
+
* / `state.delta` / `done` / `error`) are derived from the server's run-view
|
|
279
|
+
* snapshot stream. Breaking out of the loop closes the connection; the run
|
|
280
|
+
* continues server-side.
|
|
281
|
+
*/
|
|
282
|
+
stream(input: Record<string, unknown>, opts?: GraphRunOptions): AsyncGenerator<GraphRunEvent, void, void>;
|
|
283
|
+
/** Fetch the read-only run projection (spec + per-node status + state). */
|
|
284
|
+
runStatus(runId: string): Promise<GraphRunView>;
|
|
285
|
+
/** List this graph's version snapshots (newest first). */
|
|
286
|
+
versions(): Promise<Array<{
|
|
287
|
+
versionId: string;
|
|
288
|
+
versionNumber: number;
|
|
289
|
+
createdAt: string;
|
|
290
|
+
}>>;
|
|
291
|
+
}
|
|
292
|
+
/** Collection surface for creating + addressing graphs. */
|
|
293
|
+
export declare class Graphs {
|
|
294
|
+
private readonly http;
|
|
295
|
+
private readonly baseUrl;
|
|
296
|
+
private readonly defaultTimeoutMs;
|
|
297
|
+
private readonly defaultEnvironment;
|
|
298
|
+
/** @internal */
|
|
299
|
+
constructor(http: HttpClient, baseUrl: string, defaultTimeoutMs: number, defaultEnvironment: Environment);
|
|
300
|
+
/** Create a new graph resource from a draft (or inline config). Returns a
|
|
301
|
+
* handle bound to the new `graph_id`. */
|
|
302
|
+
create(draft: GraphDraft | DefineGraphConfig): Promise<Graph>;
|
|
303
|
+
/** Reattach to an existing graph by id. */
|
|
304
|
+
get(graphId: string): Graph;
|
|
305
|
+
private handle;
|
|
306
|
+
}
|
|
307
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAI7C,MAAM,WAAW,YAAY;IAC3B,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;IACf,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,WAAW,GAAG,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAA;AAEjF,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,WAAW,CAAA;IAC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IACI,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,GAAE,eAAoB,GAAG,cAAc,CAAC,aAAa,EAAE,IAAI,EAAE,IAAI,CAAC;IAsCpH,2EAA2E;IACrE,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAOrD,0DAA0D;IACpD,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,aAAa,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAUlG;AAED,2DAA2D;AAC3D,qBAAa,MAAM;IAGf,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,gBAAgB;IACjC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IALrC,gBAAgB;gBAEG,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,kBAAkB,EAAE,WAAW;IAGlD;8CAC0C;IACpC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,iBAAiB,GAAG,OAAO,CAAC,KAAK,CAAC;IAcnE,2CAA2C;IAC3C,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK;IAI3B,OAAO,CAAC,MAAM;CAGf"}
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flow-graph authoring + run surface for the Curator SDK.
|
|
3
|
+
*
|
|
4
|
+
* import { Curator, reducers, agentNode, toolNode, transformNode, edge, branch, when } from "@darqlabs/curator-sdk"
|
|
5
|
+
*
|
|
6
|
+
* const draft = curator.defineGraph({
|
|
7
|
+
* name: "copy-loop",
|
|
8
|
+
* state: { messages: reducers.append(), draft: reducers.lastValue(), revisions: reducers.counter() },
|
|
9
|
+
* nodes: {
|
|
10
|
+
* write: agentNode("copywriter"),
|
|
11
|
+
* review: toolNode("api.grammar.check"),
|
|
12
|
+
* score: transformNode({ transformId: "tf_quality", version: 1 }),
|
|
13
|
+
* },
|
|
14
|
+
* entry: "write",
|
|
15
|
+
* edges: [
|
|
16
|
+
* edge("write", "review"),
|
|
17
|
+
* edge("review", "score"),
|
|
18
|
+
* branch("score", when("draft_ok", "==", true).then("END").else("write")),
|
|
19
|
+
* ],
|
|
20
|
+
* recursionLimit: 12,
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* const graph = await curator.graphs.create(draft) // POST /api/graphs
|
|
24
|
+
* await graph.deploy({ expectedDraftRevision: 1 }) // versioned snapshot
|
|
25
|
+
*
|
|
26
|
+
* // run + stream node/state events
|
|
27
|
+
* for await (const ev of graph.stream({ messages: [] })) {
|
|
28
|
+
* if (ev.type === "node.completed") console.log("done:", ev.node)
|
|
29
|
+
* if (ev.type === "done") console.log("final:", ev.state)
|
|
30
|
+
* }
|
|
31
|
+
*
|
|
32
|
+
* These graph types are SDK-owned (the SDK is published and cannot depend on the
|
|
33
|
+
* private @darq/shared-types); they mirror the backend spec shape exactly so the
|
|
34
|
+
* assembled JSON validates + compiles server-side.
|
|
35
|
+
*/
|
|
36
|
+
import { CuratorError } from "./errors.js";
|
|
37
|
+
import { parseSseStream } from "./sse.js";
|
|
38
|
+
/** The `END` sentinel target. */
|
|
39
|
+
export const GRAPH_END = "END";
|
|
40
|
+
// ── Builders (pure) ───────────────────────────────────────────────
|
|
41
|
+
export const reducers = {
|
|
42
|
+
append: () => ({ reducer: "append" }),
|
|
43
|
+
lastValue: () => ({ reducer: "lastValue" }),
|
|
44
|
+
merge: () => ({ reducer: "merge" }),
|
|
45
|
+
counter: () => ({ reducer: "counter" }),
|
|
46
|
+
/** A custom fold `(prev, update) => next`, run as a sandboxed transform. */
|
|
47
|
+
custom: (transform) => ({ reducer: "custom", reducerRef: transform }),
|
|
48
|
+
};
|
|
49
|
+
export function agentNode(agentId, opts = {}) {
|
|
50
|
+
return { type: "agent", agentId, ...opts };
|
|
51
|
+
}
|
|
52
|
+
export function toolNode(action, opts = {}) {
|
|
53
|
+
return { type: "tool", action, ...opts };
|
|
54
|
+
}
|
|
55
|
+
export function transformNode(transform, opts = {}) {
|
|
56
|
+
return { type: "transform", transform, ...opts };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A `forEach` (map) node: run `body` per element of the `over` channel, appending
|
|
60
|
+
* each output into `collect`. Body params can reference the element via
|
|
61
|
+
* `{{item}}` / `{{item.field}}` / `{{index}}`.
|
|
62
|
+
*/
|
|
63
|
+
export function forEachNode(over, body, opts = {}) {
|
|
64
|
+
return { type: "forEach", over, body, ...opts };
|
|
65
|
+
}
|
|
66
|
+
export function edge(from, to) {
|
|
67
|
+
return { kind: "static", from, to };
|
|
68
|
+
}
|
|
69
|
+
/** Attach a conditional edge to `from`. Pass a predicate builder or a router. */
|
|
70
|
+
export function branch(from, spec) {
|
|
71
|
+
const b = spec instanceof PredicateBuilder ? spec.build() : spec;
|
|
72
|
+
return { kind: "conditional", from, branch: b };
|
|
73
|
+
}
|
|
74
|
+
/** A sandboxed router transform that returns a next-node key (or END). */
|
|
75
|
+
export function router(transform, targets) {
|
|
76
|
+
return { kind: "router", transform, targets };
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Fluent declarative predicate: `when("draft_ok", "==", true).then("END").else("write")`.
|
|
80
|
+
* Unary ops (`exists`/`truthy`/`falsy`) omit the value.
|
|
81
|
+
*/
|
|
82
|
+
export function when(channel, op, value) {
|
|
83
|
+
return new PredicateBuilder({ channel, op, value });
|
|
84
|
+
}
|
|
85
|
+
export class PredicateBuilder {
|
|
86
|
+
predicate;
|
|
87
|
+
thenKey;
|
|
88
|
+
elseKey;
|
|
89
|
+
constructor(predicate) {
|
|
90
|
+
this.predicate = predicate;
|
|
91
|
+
}
|
|
92
|
+
then(nodeKey) {
|
|
93
|
+
this.thenKey = nodeKey;
|
|
94
|
+
return this;
|
|
95
|
+
}
|
|
96
|
+
else(nodeKey) {
|
|
97
|
+
this.elseKey = nodeKey;
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
/** @internal */
|
|
101
|
+
build() {
|
|
102
|
+
if (this.thenKey === undefined || this.elseKey === undefined) {
|
|
103
|
+
throw new CuratorError("A `when(...)` branch requires both `.then(...)` and `.else(...)`.");
|
|
104
|
+
}
|
|
105
|
+
return { kind: "predicate", predicate: this.predicate, then: this.thenKey, else: this.elseKey };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
/** Assemble a serializable graph spec locally. Pure — no network. */
|
|
109
|
+
export function defineGraph(config) {
|
|
110
|
+
const { name, description, tags, state, nodes, entry, edges, recursionLimit, toolFailureMode } = config;
|
|
111
|
+
return {
|
|
112
|
+
name,
|
|
113
|
+
description,
|
|
114
|
+
tags,
|
|
115
|
+
spec: { state, nodes, entry, edges, recursionLimit, toolFailureMode },
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// ── Client handles ────────────────────────────────────────────────
|
|
119
|
+
/** A handle to one graph resource, addressed by its `graph_id`. */
|
|
120
|
+
export class Graph {
|
|
121
|
+
http;
|
|
122
|
+
baseUrl;
|
|
123
|
+
defaultTimeoutMs;
|
|
124
|
+
graphId;
|
|
125
|
+
defaultEnvironment;
|
|
126
|
+
/** @internal */
|
|
127
|
+
constructor(http, baseUrl, defaultTimeoutMs, graphId, defaultEnvironment) {
|
|
128
|
+
this.http = http;
|
|
129
|
+
this.baseUrl = baseUrl;
|
|
130
|
+
this.defaultTimeoutMs = defaultTimeoutMs;
|
|
131
|
+
this.graphId = graphId;
|
|
132
|
+
this.defaultEnvironment = defaultEnvironment;
|
|
133
|
+
}
|
|
134
|
+
get base() {
|
|
135
|
+
return `${this.baseUrl}/api/graphs/${encodeURIComponent(this.graphId)}`;
|
|
136
|
+
}
|
|
137
|
+
/** Deploy the current draft as an immutable versioned snapshot. */
|
|
138
|
+
async deploy(opts) {
|
|
139
|
+
const env = opts.environment ?? this.defaultEnvironment;
|
|
140
|
+
const res = await this.http.request(`${this.base}/deploy`, {
|
|
141
|
+
method: "POST",
|
|
142
|
+
body: {
|
|
143
|
+
environment: env,
|
|
144
|
+
slug: opts.slug,
|
|
145
|
+
change_summary: opts.changeSummary,
|
|
146
|
+
expected_draft_revision: opts.expectedDraftRevision,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
versionId: res.data.version.version_id,
|
|
151
|
+
versionNumber: res.data.version.version_number,
|
|
152
|
+
slug: res.data.deployment.slug,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Start a run and, unless `{ wait: false }`, block until it settles.
|
|
157
|
+
* Returns the terminal channel state (or `status: "timeout"` if the wait
|
|
158
|
+
* expires — the run keeps going server-side).
|
|
159
|
+
*/
|
|
160
|
+
async run(input, opts = {}) {
|
|
161
|
+
const wait = opts.wait !== false;
|
|
162
|
+
const timeoutMs = opts.timeoutMs ?? this.defaultTimeoutMs;
|
|
163
|
+
const res = await this.http.request(`${this.base}/run`, {
|
|
164
|
+
method: "POST",
|
|
165
|
+
body: {
|
|
166
|
+
input,
|
|
167
|
+
environment: opts.environment ?? this.defaultEnvironment,
|
|
168
|
+
use_draft: opts.useDraft,
|
|
169
|
+
wait,
|
|
170
|
+
timeout_ms: wait ? timeoutMs : undefined,
|
|
171
|
+
},
|
|
172
|
+
signalTimeoutMs: wait ? timeoutMs + 10_000 : undefined,
|
|
173
|
+
});
|
|
174
|
+
return {
|
|
175
|
+
runId: res.data.run_id,
|
|
176
|
+
status: res.data.status ?? "running",
|
|
177
|
+
state: res.data.state,
|
|
178
|
+
errorCode: res.data.errorCode,
|
|
179
|
+
errorMessage: res.data.errorMessage,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Start a run and stream node/state lifecycle events until it settles.
|
|
184
|
+
* Events (`run.started` / `node.started` / `node.completed` / `node.failed`
|
|
185
|
+
* / `state.delta` / `done` / `error`) are derived from the server's run-view
|
|
186
|
+
* snapshot stream. Breaking out of the loop closes the connection; the run
|
|
187
|
+
* continues server-side.
|
|
188
|
+
*/
|
|
189
|
+
async *stream(input, opts = {}) {
|
|
190
|
+
// Start async (no wait) to get a run id, then attach to the snapshot stream.
|
|
191
|
+
const started = await this.run(input, { ...opts, wait: false });
|
|
192
|
+
const runId = started.runId;
|
|
193
|
+
yield { type: "run.started", runId };
|
|
194
|
+
const controller = new AbortController();
|
|
195
|
+
const response = await this.http.streamPost(`${this.base}/runs/${encodeURIComponent(runId)}/stream`, { query: { stream: "true" }, signal: controller.signal });
|
|
196
|
+
const differ = new SnapshotDiffer();
|
|
197
|
+
try {
|
|
198
|
+
for await (const frame of parseSseStream(response.body)) {
|
|
199
|
+
if (frame.event === "snapshot") {
|
|
200
|
+
const view = safeParse(frame.data);
|
|
201
|
+
if (!view)
|
|
202
|
+
continue;
|
|
203
|
+
for (const ev of differ.diff(view))
|
|
204
|
+
yield ev;
|
|
205
|
+
}
|
|
206
|
+
else if (frame.event === "done") {
|
|
207
|
+
const done = safeParse(frame.data);
|
|
208
|
+
const last = differ.lastView;
|
|
209
|
+
yield {
|
|
210
|
+
type: "done",
|
|
211
|
+
status: done?.status ?? last?.status ?? "succeeded",
|
|
212
|
+
state: last?.state ?? {},
|
|
213
|
+
};
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
finally {
|
|
219
|
+
try {
|
|
220
|
+
controller.abort();
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
/* ignore */
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/** Fetch the read-only run projection (spec + per-node status + state). */
|
|
228
|
+
async runStatus(runId) {
|
|
229
|
+
const res = await this.http.request(`${this.base}/runs/${encodeURIComponent(runId)}`);
|
|
230
|
+
return res.data;
|
|
231
|
+
}
|
|
232
|
+
/** List this graph's version snapshots (newest first). */
|
|
233
|
+
async versions() {
|
|
234
|
+
const res = await this.http.request(`${this.base}/versions`);
|
|
235
|
+
return res.data.map((v) => ({
|
|
236
|
+
versionId: v.version_id,
|
|
237
|
+
versionNumber: v.version_number,
|
|
238
|
+
createdAt: v.created_at,
|
|
239
|
+
}));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
/** Collection surface for creating + addressing graphs. */
|
|
243
|
+
export class Graphs {
|
|
244
|
+
http;
|
|
245
|
+
baseUrl;
|
|
246
|
+
defaultTimeoutMs;
|
|
247
|
+
defaultEnvironment;
|
|
248
|
+
/** @internal */
|
|
249
|
+
constructor(http, baseUrl, defaultTimeoutMs, defaultEnvironment) {
|
|
250
|
+
this.http = http;
|
|
251
|
+
this.baseUrl = baseUrl;
|
|
252
|
+
this.defaultTimeoutMs = defaultTimeoutMs;
|
|
253
|
+
this.defaultEnvironment = defaultEnvironment;
|
|
254
|
+
}
|
|
255
|
+
/** Create a new graph resource from a draft (or inline config). Returns a
|
|
256
|
+
* handle bound to the new `graph_id`. */
|
|
257
|
+
async create(draft) {
|
|
258
|
+
const normalized = "spec" in draft ? draft : defineGraph(draft);
|
|
259
|
+
const res = await this.http.request(`${this.baseUrl}/api/graphs`, {
|
|
260
|
+
method: "POST",
|
|
261
|
+
body: {
|
|
262
|
+
name: normalized.name,
|
|
263
|
+
description: normalized.description,
|
|
264
|
+
tags: normalized.tags,
|
|
265
|
+
spec: normalized.spec,
|
|
266
|
+
},
|
|
267
|
+
});
|
|
268
|
+
return this.handle(res.data.graph_id);
|
|
269
|
+
}
|
|
270
|
+
/** Reattach to an existing graph by id. */
|
|
271
|
+
get(graphId) {
|
|
272
|
+
return this.handle(graphId);
|
|
273
|
+
}
|
|
274
|
+
handle(graphId) {
|
|
275
|
+
return new Graph(this.http, this.baseUrl, this.defaultTimeoutMs, graphId, this.defaultEnvironment);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
// ── Snapshot → event diffing ──────────────────────────────────────
|
|
279
|
+
class SnapshotDiffer {
|
|
280
|
+
lastView = null;
|
|
281
|
+
prevStatuses = new Map();
|
|
282
|
+
prevState = {};
|
|
283
|
+
diff(view) {
|
|
284
|
+
const events = [];
|
|
285
|
+
for (const node of view.nodes) {
|
|
286
|
+
const prev = this.prevStatuses.get(node.key);
|
|
287
|
+
if (prev !== node.status) {
|
|
288
|
+
if (node.status === "running") {
|
|
289
|
+
events.push({ type: "node.started", node: node.key, visit: node.visits });
|
|
290
|
+
}
|
|
291
|
+
else if (node.status === "succeeded") {
|
|
292
|
+
events.push({ type: "node.completed", node: node.key });
|
|
293
|
+
}
|
|
294
|
+
else if (node.status === "failed") {
|
|
295
|
+
events.push({ type: "node.failed", node: node.key });
|
|
296
|
+
}
|
|
297
|
+
this.prevStatuses.set(node.key, node.status);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const changed = {};
|
|
301
|
+
for (const [k, v] of Object.entries(view.state)) {
|
|
302
|
+
if (JSON.stringify(this.prevState[k]) !== JSON.stringify(v))
|
|
303
|
+
changed[k] = v;
|
|
304
|
+
}
|
|
305
|
+
if (Object.keys(changed).length > 0) {
|
|
306
|
+
events.push({ type: "state.delta", channels: changed });
|
|
307
|
+
}
|
|
308
|
+
this.prevState = view.state;
|
|
309
|
+
this.lastView = view;
|
|
310
|
+
return events;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
function safeParse(text) {
|
|
314
|
+
try {
|
|
315
|
+
return JSON.parse(text);
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
//# sourceMappingURL=graph.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/graph.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,EAAE,YAAY,EAAE,MAA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gBAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;QAC7E,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACpC,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAA;QACzD,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,CAAA;QAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QACpB,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAED,SAAS,SAAS,CAAI,IAAY;IAChC,IAAI,CAAC;QACH,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAA;IAC9B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAA;IACb,CAAC;AACH,CAAC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,8 +3,9 @@ export type { CuratorOptions, AgentLocator } from "./client.js";
|
|
|
3
3
|
export type { EndUserJwtProvider } from "./http.js";
|
|
4
4
|
export { Files } from "./files.js";
|
|
5
5
|
export type { PresignUploadInput, PresignUploadResult, OneShotUploadInput, UploadData, } from "./files.js";
|
|
6
|
-
export { CuratorError, CuratorAuthError, CuratorForbiddenError, CuratorNotFoundError, CuratorDeploymentRetiredError, CuratorRateLimitError, CuratorApprovalRequiredError, CuratorAgentError, CuratorTimeoutError, } from "./errors.js";
|
|
7
|
-
export type { AssistantMessage, UserMessage, ToolMessage, ConversationMessage, Environment, FileAttachment, ApprovalDetails, AgentFailureClass, SendOptions, HistoryOptions, HistoryPage, DeploymentConfig, } from "./types.js";
|
|
8
|
-
export
|
|
6
|
+
export { CuratorError, CuratorAuthError, CuratorForbiddenError, CuratorNotFoundError, CuratorDeploymentRetiredError, CuratorRateLimitError, CuratorApprovalRequiredError, CuratorAuthorizationRequiredError, CuratorAgentError, CuratorTimeoutError, } from "./errors.js";
|
|
7
|
+
export type { AssistantMessage, UserMessage, ToolMessage, ConversationMessage, Environment, FileAttachment, ApprovalDetails, AuthorizationDetails, AgentFailureClass, SendOptions, HistoryOptions, HistoryPage, DeploymentConfig, EndUserConnection, } from "./types.js";
|
|
8
|
+
export { Integrations, GmailIntegration } from "./integrations.js";
|
|
9
|
+
export type { StreamEvent, StreamDelta, StreamToolCallStarted, StreamToolCallCompleted, StreamState, StreamPlanProgress, StreamDone, StreamError, StreamPausedForApproval, StreamPausedForAuthorization, } from "./streamEvents.js";
|
|
9
10
|
export { isTerminalStreamEvent } from "./streamEvents.js";
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|