@darqlabs/curator-sdk 0.1.6 → 0.3.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/errors.d.ts +96 -5
- package/dist/cjs/errors.d.ts.map +1 -1
- package/dist/cjs/errors.js +181 -15
- 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/http.d.ts.map +1 -1
- package/dist/cjs/http.js +65 -13
- package/dist/cjs/http.js.map +1 -1
- package/dist/cjs/index.d.ts +2 -1
- 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/streamEventParse.d.ts.map +1 -1
- package/dist/cjs/streamEventParse.js +12 -0
- package/dist/cjs/streamEventParse.js.map +1 -1
- package/dist/cjs/streamEvents.d.ts +30 -2
- package/dist/cjs/streamEvents.d.ts.map +1 -1
- package/dist/cjs/streamEvents.js +2 -1
- package/dist/cjs/streamEvents.js.map +1 -1
- package/dist/esm/errors.d.ts +96 -5
- package/dist/esm/errors.d.ts.map +1 -1
- package/dist/esm/errors.js +176 -14
- 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/http.d.ts.map +1 -1
- package/dist/esm/http.js +66 -14
- package/dist/esm/http.js.map +1 -1
- package/dist/esm/index.d.ts +2 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/streamEventParse.d.ts.map +1 -1
- package/dist/esm/streamEventParse.js +12 -0
- package/dist/esm/streamEventParse.js.map +1 -1
- package/dist/esm/streamEvents.d.ts +30 -2
- package/dist/esm/streamEvents.d.ts.map +1 -1
- package/dist/esm/streamEvents.js +2 -1
- package/dist/esm/streamEvents.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/errors.js
CHANGED
|
@@ -9,9 +9,45 @@
|
|
|
9
9
|
* backstop.
|
|
10
10
|
*/
|
|
11
11
|
export class CuratorError extends Error {
|
|
12
|
+
/**
|
|
13
|
+
* What an END USER may be shown.
|
|
14
|
+
*
|
|
15
|
+
* `message` is for developers — it can name the request, the status, and the
|
|
16
|
+
* server's own wording. That is the wrong text to put in a chat bubble, and
|
|
17
|
+
* shipping it there is not a hypothetical: a 500 rendered as
|
|
18
|
+
* `HTTP 500 from https://api.../agents/<slug>/conversations: …`, exposing the
|
|
19
|
+
* deployment's URL to whoever was chatting, and an end-user token failure
|
|
20
|
+
* rendered as "End-user JWT could not be verified", which tells the person
|
|
21
|
+
* nothing they can act on and leaks the auth mechanism.
|
|
22
|
+
*
|
|
23
|
+
* Every subclass sets this to something safe and actionable. `renderError` in
|
|
24
|
+
* the React bindings prefers it and never falls back to `message`, so a new
|
|
25
|
+
* error type is safe-by-default rather than leaky-by-default.
|
|
26
|
+
*/
|
|
27
|
+
userMessage;
|
|
28
|
+
/** HTTP status, when this came from a response. */
|
|
29
|
+
status;
|
|
30
|
+
/** Server error code (`error.code`), when present. */
|
|
31
|
+
code;
|
|
32
|
+
/**
|
|
33
|
+
* Correlation id from `x-request-id` / `correlationId`. The one detail worth
|
|
34
|
+
* showing a user on an unexpected failure — it is what support can trace,
|
|
35
|
+
* and it says nothing about the system's shape.
|
|
36
|
+
*/
|
|
37
|
+
requestId;
|
|
38
|
+
/**
|
|
39
|
+
* Request URL, as a PROPERTY rather than part of `message`. Available for
|
|
40
|
+
* logs and bug reports without riding along into anything user-visible.
|
|
41
|
+
*/
|
|
42
|
+
url;
|
|
12
43
|
constructor(message, options) {
|
|
13
44
|
super(message);
|
|
14
45
|
this.name = "CuratorError";
|
|
46
|
+
this.userMessage = options?.userMessage ?? DEFAULT_USER_MESSAGE;
|
|
47
|
+
this.status = options?.status ?? null;
|
|
48
|
+
this.code = options?.code ?? null;
|
|
49
|
+
this.requestId = options?.requestId ?? null;
|
|
50
|
+
this.url = options?.url ?? null;
|
|
15
51
|
// Preserve the underlying error if the runtime supports it.
|
|
16
52
|
if (options?.cause !== undefined) {
|
|
17
53
|
;
|
|
@@ -19,32 +55,65 @@ export class CuratorError extends Error {
|
|
|
19
55
|
}
|
|
20
56
|
}
|
|
21
57
|
}
|
|
58
|
+
/** Last-resort user-facing text. Deliberately says nothing about the system. */
|
|
59
|
+
export const DEFAULT_USER_MESSAGE = "Something went wrong. Please try again.";
|
|
60
|
+
/** Appends a correlation id when there is one, so support has a handle. */
|
|
61
|
+
export function withRequestId(text, requestId) {
|
|
62
|
+
return requestId ? `${text} (reference: ${requestId})` : text;
|
|
63
|
+
}
|
|
22
64
|
/** HTTP 401 from the API — your API key is missing, invalid, or revoked. */
|
|
23
65
|
export class CuratorAuthError extends CuratorError {
|
|
24
|
-
constructor(message = "Invalid or revoked API key") {
|
|
25
|
-
|
|
66
|
+
constructor(message = "Invalid or revoked API key", ctx = {}) {
|
|
67
|
+
// The API key is the INTEGRATOR's credential. An end user can do nothing
|
|
68
|
+
// about it and should not be told which credential failed.
|
|
69
|
+
super(message, { ...ctx, userMessage: "This chat isn't available right now. Please try again later." });
|
|
26
70
|
this.name = "CuratorAuthError";
|
|
27
71
|
}
|
|
28
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* HTTP 401 specifically because the END-USER token was missing, expired, or
|
|
75
|
+
* unverifiable — distinct from `CuratorAuthError`, which is about the
|
|
76
|
+
* integrator's API key.
|
|
77
|
+
*
|
|
78
|
+
* Separate because the remediation is completely different: an API-key failure
|
|
79
|
+
* needs a developer, whereas this one is usually a stale session the user fixes
|
|
80
|
+
* by signing in again. Collapsing them produced "Authentication failed. Check
|
|
81
|
+
* your API key." in response to an expired user token, which sends the reader
|
|
82
|
+
* after the wrong thing entirely.
|
|
83
|
+
*/
|
|
84
|
+
export class CuratorEndUserAuthError extends CuratorError {
|
|
85
|
+
constructor(message = "End-user token could not be verified", ctx = {}) {
|
|
86
|
+
super(message, {
|
|
87
|
+
...ctx,
|
|
88
|
+
userMessage: "Your session has expired. Please sign in again to continue.",
|
|
89
|
+
});
|
|
90
|
+
this.name = "CuratorEndUserAuthError";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
29
93
|
/** HTTP 403 from the API — your API key doesn't have permission for this action. */
|
|
30
94
|
export class CuratorForbiddenError extends CuratorError {
|
|
31
|
-
constructor(message = "Permission denied") {
|
|
32
|
-
super(message);
|
|
95
|
+
constructor(message = "Permission denied", ctx = {}) {
|
|
96
|
+
super(message, { ...ctx, userMessage: "You don't have access to this." });
|
|
33
97
|
this.name = "CuratorForbiddenError";
|
|
34
98
|
}
|
|
35
99
|
}
|
|
36
100
|
/** HTTP 404 from the API — the deployment slug or conversation id wasn't found. */
|
|
37
101
|
export class CuratorNotFoundError extends CuratorError {
|
|
38
|
-
constructor(message = "Resource not found") {
|
|
39
|
-
|
|
102
|
+
constructor(message = "Resource not found", ctx = {}) {
|
|
103
|
+
// Says nothing about WHICH resource: on a 404 the slug is often the thing
|
|
104
|
+
// that is wrong, and echoing it back tells a prober they guessed close.
|
|
105
|
+
super(message, { ...ctx, userMessage: "This chat isn't available." });
|
|
40
106
|
this.name = "CuratorNotFoundError";
|
|
41
107
|
}
|
|
42
108
|
}
|
|
43
109
|
/** HTTP 410 from the API — the deployment was retired. */
|
|
44
110
|
export class CuratorDeploymentRetiredError extends CuratorError {
|
|
45
111
|
retiredAt;
|
|
46
|
-
constructor(message, retiredAt) {
|
|
47
|
-
super(message
|
|
112
|
+
constructor(message, retiredAt, ctx = {}) {
|
|
113
|
+
super(message, {
|
|
114
|
+
...ctx,
|
|
115
|
+
userMessage: "This assistant is no longer available.",
|
|
116
|
+
});
|
|
48
117
|
this.name = "CuratorDeploymentRetiredError";
|
|
49
118
|
this.retiredAt = retiredAt;
|
|
50
119
|
}
|
|
@@ -52,12 +121,31 @@ export class CuratorDeploymentRetiredError extends CuratorError {
|
|
|
52
121
|
/** HTTP 429 from the API — back off. */
|
|
53
122
|
export class CuratorRateLimitError extends CuratorError {
|
|
54
123
|
retryAfterSeconds;
|
|
55
|
-
constructor(message = "Rate limit exceeded", retryAfterSeconds = null) {
|
|
56
|
-
super(message
|
|
124
|
+
constructor(message = "Rate limit exceeded", retryAfterSeconds = null, ctx = {}) {
|
|
125
|
+
super(message, {
|
|
126
|
+
...ctx,
|
|
127
|
+
userMessage: retryAfterSeconds
|
|
128
|
+
? `Too many messages. Please wait ${retryAfterSeconds} seconds and try again.`
|
|
129
|
+
: "Too many messages. Please wait a moment and try again.",
|
|
130
|
+
});
|
|
57
131
|
this.name = "CuratorRateLimitError";
|
|
58
132
|
this.retryAfterSeconds = retryAfterSeconds;
|
|
59
133
|
}
|
|
60
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* HTTP 5xx. The server already returns a generic body plus a `correlationId`
|
|
137
|
+
* for unexpected failures, so the useful thing to surface is that id — not the
|
|
138
|
+
* status line and URL the SDK used to build into `message`.
|
|
139
|
+
*/
|
|
140
|
+
export class CuratorServerError extends CuratorError {
|
|
141
|
+
constructor(message, ctx = {}) {
|
|
142
|
+
super(message, {
|
|
143
|
+
...ctx,
|
|
144
|
+
userMessage: withRequestId("Something went wrong on our end. Please try again.", ctx.requestId ?? null),
|
|
145
|
+
});
|
|
146
|
+
this.name = "CuratorServerError";
|
|
147
|
+
}
|
|
148
|
+
}
|
|
61
149
|
/**
|
|
62
150
|
* Run paused waiting for human approval. Approval resolution is not
|
|
63
151
|
* exposed to API consumers — pauses are routed through the dashboard
|
|
@@ -71,7 +159,10 @@ export class CuratorApprovalRequiredError extends CuratorError {
|
|
|
71
159
|
runId;
|
|
72
160
|
constructor(args) {
|
|
73
161
|
super(`Run paused for approval — the '${args.approval.tool_name}' tool needs an administrator to review it. ` +
|
|
74
|
-
"Contact your administrator to resolve this in the Curator dashboard."
|
|
162
|
+
"Contact your administrator to resolve this in the Curator dashboard.", {
|
|
163
|
+
userMessage: `That action needs administrator approval. Someone has been asked to review the ` +
|
|
164
|
+
`"${args.approval.tool_name}" request.`,
|
|
165
|
+
});
|
|
75
166
|
this.name = "CuratorApprovalRequiredError";
|
|
76
167
|
this.approval = args.approval;
|
|
77
168
|
this.conversationId = args.conversationId;
|
|
@@ -92,13 +183,62 @@ export class CuratorAuthorizationRequiredError extends CuratorError {
|
|
|
92
183
|
super(`Run paused for authorization — connect ${args.authorization.provider} to continue. ` +
|
|
93
184
|
(args.authorization.connect_url
|
|
94
185
|
? `Connect at ${args.authorization.connect_url}, then resume the conversation.`
|
|
95
|
-
: "Connect the provider, then resume the conversation.")
|
|
186
|
+
: "Connect the provider, then resume the conversation."), {
|
|
187
|
+
// `reason` is authored for the end user by the integration; prefer it.
|
|
188
|
+
userMessage: args.authorization.reason ||
|
|
189
|
+
`Connect your ${args.authorization.provider} account to continue.`,
|
|
190
|
+
});
|
|
96
191
|
this.name = "CuratorAuthorizationRequiredError";
|
|
97
192
|
this.authorization = args.authorization;
|
|
98
193
|
this.conversationId = args.conversationId;
|
|
99
194
|
this.runId = args.runId;
|
|
100
195
|
}
|
|
101
196
|
}
|
|
197
|
+
const DELEGATION_CODES = [
|
|
198
|
+
"DELEGATED_IDENTITY_EXPIRED",
|
|
199
|
+
"DELEGATED_IDENTITY_REVOKED",
|
|
200
|
+
"DELEGATED_TOKEN_EXCHANGE_FAILED",
|
|
201
|
+
"DOWNSTREAM_AUTH_REJECTED",
|
|
202
|
+
"DELEGATED_AUTH_NOT_CONFIGURED",
|
|
203
|
+
];
|
|
204
|
+
/** Recover the delegated-failure code from a server message prefix. */
|
|
205
|
+
export function parseDelegationFailureCode(message) {
|
|
206
|
+
if (!message)
|
|
207
|
+
return null;
|
|
208
|
+
for (const code of DELEGATION_CODES) {
|
|
209
|
+
if (message.startsWith(`${code}:`))
|
|
210
|
+
return code;
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* End-user text per delegated-failure code. The split that matters is WHO can
|
|
216
|
+
* fix it: expiry is the user's to resolve by re-authenticating, revocation and
|
|
217
|
+
* scope gaps need an administrator, and the exchange/config failures are ours
|
|
218
|
+
* and must not be phrased as the user's fault.
|
|
219
|
+
*/
|
|
220
|
+
function delegationUserMessage(code) {
|
|
221
|
+
switch (code) {
|
|
222
|
+
case "DELEGATED_IDENTITY_EXPIRED":
|
|
223
|
+
// The common one: a run paused past the assertion's lifetime. Retrying
|
|
224
|
+
// the same request is futile, so the text must ask for a NEW session
|
|
225
|
+
// rather than inviting another attempt.
|
|
226
|
+
return "Your session expired before that could finish. Please sign in again and retry.";
|
|
227
|
+
case "DELEGATED_IDENTITY_REVOKED":
|
|
228
|
+
// Server-side this pages someone — it means a context was crossed or
|
|
229
|
+
// probed. Never hint at the mechanism; the user just lacks authority.
|
|
230
|
+
return "You don't have permission to complete that action. Please contact your administrator.";
|
|
231
|
+
case "DOWNSTREAM_AUTH_REJECTED":
|
|
232
|
+
// Exchange worked; the resource server said no. A scope/permission gap on
|
|
233
|
+
// the customer's side, so an administrator is the right destination.
|
|
234
|
+
return "Your account doesn't have access to what that action needed. Please contact your administrator.";
|
|
235
|
+
case "DELEGATED_TOKEN_EXCHANGE_FAILED":
|
|
236
|
+
case "DELEGATED_AUTH_NOT_CONFIGURED":
|
|
237
|
+
// Ours to fix. Do not tell the user to sign in — it will not help, and it
|
|
238
|
+
// sends them chasing a problem they cannot see.
|
|
239
|
+
return "That action isn't available right now. Please try again later.";
|
|
240
|
+
}
|
|
241
|
+
}
|
|
102
242
|
/**
|
|
103
243
|
* The agent run reached a terminal error state (LLM quota, auth, 5xx
|
|
104
244
|
* exhausted retries, etc.). `failureClass` and `isPermanent` mirror the
|
|
@@ -110,9 +250,29 @@ export class CuratorAgentError extends CuratorError {
|
|
|
110
250
|
conversationId;
|
|
111
251
|
runId;
|
|
112
252
|
stepId;
|
|
253
|
+
/**
|
|
254
|
+
* Set when the run failed on delegated identity. Distinct from
|
|
255
|
+
* `failureClass`, which has no delegated variant — see
|
|
256
|
+
* {@link DelegationFailureCode}.
|
|
257
|
+
*/
|
|
258
|
+
delegationCode;
|
|
113
259
|
constructor(args) {
|
|
114
|
-
|
|
260
|
+
const delegationCode = parseDelegationFailureCode(args.message);
|
|
261
|
+
super(args.message, {
|
|
262
|
+
// NOT `args.message`: the run's failure text is written for an operator
|
|
263
|
+
// and can name providers, quotas, or step ids. A delegated failure gets
|
|
264
|
+
// its own text because the server already told us who can fix it —
|
|
265
|
+
// throwing that away and falling back to `isPermanent` is how an expired
|
|
266
|
+
// session became "couldn't complete that request", which is true and
|
|
267
|
+
// useless when "sign in again" was the answer.
|
|
268
|
+
userMessage: delegationCode
|
|
269
|
+
? delegationUserMessage(delegationCode)
|
|
270
|
+
: args.isPermanent
|
|
271
|
+
? "The assistant couldn't complete that request. Please try rephrasing, or contact support."
|
|
272
|
+
: "The assistant hit a temporary problem. Please try again.",
|
|
273
|
+
});
|
|
115
274
|
this.name = "CuratorAgentError";
|
|
275
|
+
this.delegationCode = delegationCode;
|
|
116
276
|
this.failureClass = args.failureClass;
|
|
117
277
|
this.isPermanent = args.isPermanent;
|
|
118
278
|
this.conversationId = args.conversationId;
|
|
@@ -130,7 +290,9 @@ export class CuratorTimeoutError extends CuratorError {
|
|
|
130
290
|
runId;
|
|
131
291
|
continueWaiting;
|
|
132
292
|
constructor(args) {
|
|
133
|
-
super("Timed out waiting for the agent to reply — the run is still in progress."
|
|
293
|
+
super("Timed out waiting for the agent to reply — the run is still in progress.", {
|
|
294
|
+
userMessage: "This is taking longer than usual. It may still finish — check back in a moment.",
|
|
295
|
+
});
|
|
134
296
|
this.name = "CuratorTimeoutError";
|
|
135
297
|
this.conversationId = args.conversationId;
|
|
136
298
|
this.runId = args.runId;
|
package/dist/esm/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AASH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC;;;;;;;;;;;;;;OAcG;IACM,WAAW,CAAQ;IAC5B,mDAAmD;IAC1C,MAAM,CAAe;IAC9B,sDAAsD;IAC7C,IAAI,CAAe;IAC5B;;;;OAIG;IACM,SAAS,CAAe;IACjC;;;OAGG;IACM,GAAG,CAAe;IAE3B,YACE,OAAe,EACf,OAOC;QAED,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;QAC1B,IAAI,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,oBAAoB,CAAA;QAC/D,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,IAAI,CAAA;QACrC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,IAAI,CAAA;QACjC,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAA;QAC3C,IAAI,CAAC,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,IAAI,CAAA;QAC/B,4DAA4D;QAC5D,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,EAAE,CAAC;YACjC,CAAC;YAAC,IAA4B,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAA;QACtD,CAAC;IACH,CAAC;CACF;AAED,gFAAgF;AAChF,MAAM,CAAC,MAAM,oBAAoB,GAC/B,yCAAyC,CAAA;AAE3C,2EAA2E;AAC3E,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,SAAwB;IAClE,OAAO,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,gBAA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,cAAc,GAAG,cAAc,CAAA;QACpC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAA;QACrC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAA;QACnC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACvB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAA;IACnC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IAC1C,cAAc,CAAQ;IACtB,KAAK,CAAQ;IACb,eAAe,CAAmD;IAE3E,YAAY,IAIX;QACC,KAAK,CAAC,0EAA0E,EAAE;YAChF,WAAW,EACT,iFAAiF;SACpF,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,CAAA;QACzC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAA;QACvB,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,eAAe,CAAA;IAC7C,CAAC;CACF"}
|
|
@@ -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,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