@graph-compose/client 1.0.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.
@@ -0,0 +1,64 @@
1
+ import { AgentNode, ErrorBoundaryNode, FlowControl, HttpNode, JsonataParam, Node, NodeConditions, RetryPolicy } from "@graph-compose/core";
2
+ import { z } from "zod";
3
+ import { GraphCompose } from "./core/builder";
4
+ export declare class NodeBuilder {
5
+ private readonly graph;
6
+ protected node: HttpNode | ErrorBoundaryNode | AgentNode;
7
+ private isHttpNode;
8
+ private isAgentNode;
9
+ constructor(graph: GraphCompose, id: string, type?: "http" | "error_boundary" | "agent", protectedNodes?: string[]);
10
+ private validateJsonataExpression;
11
+ get(url: string): NodeBuilder;
12
+ post(url: string): NodeBuilder;
13
+ put(url: string): NodeBuilder;
14
+ delete(url: string): NodeBuilder;
15
+ patch(url: string): NodeBuilder;
16
+ withCondition(behavior: NodeConditions): NodeBuilder;
17
+ withFlowControl(flowControls: FlowControl[]): NodeBuilder;
18
+ addFlowControl(flowControl: FlowControl): NodeBuilder;
19
+ withHeaders(headers: Record<string, string | JsonataParam>): NodeBuilder;
20
+ withBody(body: Record<string, any> | string): NodeBuilder;
21
+ withRetries(config: Partial<RetryPolicy>): NodeBuilder;
22
+ withTimeout(duration: string | number): NodeBuilder;
23
+ withDependencies(nodeIds: string[]): NodeBuilder;
24
+ withValidation(config: {
25
+ input?: z.ZodType<any> | Record<string, any>;
26
+ output?: z.ZodType<any> | Record<string, any>;
27
+ }): NodeBuilder;
28
+ private isZodType;
29
+ /**
30
+ * Set the maximum number of iterations for an agent node.
31
+ * An agent runs until it returns a completion schema response.
32
+ * You are responsible for ensuring the agent returns a `complete` response before this limit.
33
+ * If the agent reaches the max iterations without completing, it will fail.
34
+ *
35
+ * @default 5
36
+ * @param maxIterations Must be greater than 0
37
+ * @throws {Error} If called on a non-agent node
38
+ * @throws {ValidationError} If maxIterations is less than 1
39
+ */
40
+ withMaxIterations(maxIterations: number): NodeBuilder;
41
+ /**
42
+ * Set the tools available to the agent.
43
+ * Tools must be defined in the global tools section of the workflow.
44
+ * Each tool name must be unique within the workflow and have no dashes or spaces.
45
+ *
46
+ * @param tools Array of tool names that the agent can use
47
+ * @throws {Error} If called on a non-agent node
48
+ * @throws {ValidationError} If any tool is not found in global tools
49
+ */
50
+ withTools(tools: string[]): NodeBuilder;
51
+ /**
52
+ * Add a single tool to the agent's available tools.
53
+ * The tool must be defined in the global tools section of the workflow.
54
+ * The tool name must be unique within the workflow and have no dashes or spaces.
55
+ *
56
+ * @param tool Name of the tool to add
57
+ * @throws {Error} If called on a non-agent node
58
+ * @throws {ValidationError} If the tool is not found in global tools
59
+ */
60
+ addTool(tool: string): NodeBuilder;
61
+ end(): GraphCompose;
62
+ build(): Node;
63
+ }
64
+ //# sourceMappingURL=node-builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-builder.d.ts","sourceRoot":"","sources":["../src/node-builder.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,IAAI,EACJ,cAAc,EACd,WAAW,EACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,qBAAa,WAAW;IAMpB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,SAAS,CAAC,IAAI,EAAE,QAAQ,GAAG,iBAAiB,GAAG,SAAS,CAAC;IACzD,OAAO,CAAC,UAAU,CAAU;IAC5B,OAAO,CAAC,WAAW,CAAU;gBAGV,KAAK,EAAE,YAAY,EACpC,EAAE,EAAE,MAAM,EACV,IAAI,GAAE,MAAM,GAAG,gBAAgB,GAAG,OAAgB,EAClD,cAAc,CAAC,EAAE,MAAM,EAAE;IA0C3B,OAAO,CAAC,yBAAyB;IAcjC,GAAG,CAAC,GAAG,E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EAAE,MAAM,GAAG,WAAW;IAYlC,GAAG,IAAI,YAAY;IAKnB,KAAK,IAAI,IAAI;CAGd"}
@@ -0,0 +1,261 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.NodeBuilder = void 0;
7
+ const jsonata_1 = __importDefault(require("jsonata"));
8
+ const zod_1 = require("zod");
9
+ const zod_to_json_schema_1 = require("zod-to-json-schema");
10
+ class NodeBuilder {
11
+ constructor(graph, id, type = "http", protectedNodes) {
12
+ this.graph = graph;
13
+ this.isHttpNode = type === "http";
14
+ this.isAgentNode = type === "agent";
15
+ if (type === "error_boundary") {
16
+ this.node = {
17
+ id,
18
+ type: "error_boundary",
19
+ protectedNodes: protectedNodes || [],
20
+ http: {
21
+ method: "POST",
22
+ url: "",
23
+ },
24
+ };
25
+ }
26
+ else if (type === "agent") {
27
+ this.node = {
28
+ id,
29
+ type: "agent",
30
+ dependencies: [],
31
+ tools: [],
32
+ http: {
33
+ method: "POST",
34
+ url: "",
35
+ config: {
36
+ max_iterations: undefined,
37
+ },
38
+ },
39
+ };
40
+ }
41
+ else {
42
+ this.node = {
43
+ id,
44
+ type: "http",
45
+ dependencies: [],
46
+ http: {
47
+ method: "GET",
48
+ url: "",
49
+ },
50
+ };
51
+ }
52
+ }
53
+ validateJsonataExpression(expression, context) {
54
+ try {
55
+ console.log("validating", expression);
56
+ // Try to parse the JSONata expression
57
+ (0, jsonata_1.default)(expression);
58
+ }
59
+ catch (e) {
60
+ console.log("error", e);
61
+ throw new Error(`Invalid JSONata expression in ${context}: ${e instanceof Error ? e.message : "Unknown error"}`);
62
+ }
63
+ }
64
+ // Update HTTP methods to validate URLs
65
+ get(url) {
66
+ this.node.http.method = "GET";
67
+ this.node.http.url = url;
68
+ return this;
69
+ }
70
+ post(url) {
71
+ this.node.http.method = "POST";
72
+ this.node.http.url = url;
73
+ return this;
74
+ }
75
+ put(url) {
76
+ this.node.http.method = "PUT";
77
+ this.node.http.url = url;
78
+ return this;
79
+ }
80
+ delete(url) {
81
+ this.node.http.method = "DELETE";
82
+ this.node.http.url = url;
83
+ return this;
84
+ }
85
+ patch(url) {
86
+ this.node.http.method = "PATCH";
87
+ this.node.http.url = url;
88
+ return this;
89
+ }
90
+ // Conditional branching methods - only available for HTTP nodes
91
+ withCondition(behavior) {
92
+ if (!this.isHttpNode) {
93
+ throw new Error("Conditional branching is only available for HTTP nodes");
94
+ }
95
+ const httpNode = this.node;
96
+ httpNode.conditions = behavior;
97
+ return this;
98
+ }
99
+ withFlowControl(flowControls) {
100
+ if (!this.isHttpNode) {
101
+ throw new Error("Conditional branching is only available for HTTP nodes");
102
+ }
103
+ const httpNode = this.node;
104
+ if (!httpNode.conditions) {
105
+ httpNode.conditions = { flowControl: [] };
106
+ }
107
+ httpNode.conditions.flowControl = flowControls;
108
+ return this;
109
+ }
110
+ addFlowControl(flowControl) {
111
+ if (!this.isHttpNode) {
112
+ throw new Error("Conditional branching is only available for HTTP nodes");
113
+ }
114
+ const httpNode = this.node;
115
+ if (!httpNode.conditions) {
116
+ httpNode.conditions = { flowControl: [] };
117
+ }
118
+ if (!httpNode.conditions.flowControl) {
119
+ httpNode.conditions.flowControl = [];
120
+ }
121
+ httpNode.conditions.flowControl.push(flowControl);
122
+ return this;
123
+ }
124
+ // Configuration methods
125
+ withHeaders(headers) {
126
+ // Validate any JSONata expressions in headers
127
+ Object.entries(headers).forEach(([key, value]) => {
128
+ if (typeof value === "object" && "jsonataExpression" in value) {
129
+ this.validateJsonataExpression(value.jsonataExpression, `header '${key}'`);
130
+ }
131
+ });
132
+ this.node.http.headers = headers;
133
+ return this;
134
+ }
135
+ withBody(body) {
136
+ // Note: Template expression validation happens during final workflow validation
137
+ // This allows us to collect all validation errors at once and maintain a single source of truth
138
+ if (typeof body === "string") {
139
+ this.node.http.body = body;
140
+ }
141
+ else {
142
+ this.node.http.body = body;
143
+ }
144
+ return this;
145
+ }
146
+ withRetries(config) {
147
+ this.node.http.retryPolicy = {
148
+ ...this.node.http.retryPolicy,
149
+ ...config,
150
+ };
151
+ return this;
152
+ }
153
+ withTimeout(duration) {
154
+ this.node.http.startToCloseTimeout = duration;
155
+ return this;
156
+ }
157
+ withDependencies(nodeIds) {
158
+ if (this.isHttpNode) {
159
+ this.node.dependencies = nodeIds;
160
+ }
161
+ else if (this.isAgentNode) {
162
+ this.node.dependencies = nodeIds;
163
+ }
164
+ else {
165
+ throw new Error("Dependencies can only be set on HTTP or agent nodes");
166
+ }
167
+ return this;
168
+ }
169
+ withValidation(config) {
170
+ if (!this.isHttpNode) {
171
+ throw new Error("Validation can only be set on HTTP nodes");
172
+ }
173
+ if (config.input || config.output) {
174
+ this.node.validation = {};
175
+ if (config.input) {
176
+ const inputSchema = this.isZodType(config.input)
177
+ ? (0, zod_to_json_schema_1.zodToJsonSchema)(config.input)
178
+ : config.input;
179
+ this.node.validation.input =
180
+ inputSchema.definitions?.[Object.keys(inputSchema.definitions || {})[0]] || inputSchema;
181
+ }
182
+ if (config.output) {
183
+ const outputSchema = this.isZodType(config.output)
184
+ ? (0, zod_to_json_schema_1.zodToJsonSchema)(config.output)
185
+ : config.output;
186
+ this.node.validation.output =
187
+ outputSchema.definitions?.[Object.keys(outputSchema.definitions || {})[0]] ||
188
+ outputSchema;
189
+ }
190
+ }
191
+ return this;
192
+ }
193
+ isZodType(value) {
194
+ return value instanceof zod_1.z.ZodType;
195
+ }
196
+ /**
197
+ * Set the maximum number of iterations for an agent node.
198
+ * An agent runs until it returns a completion schema response.
199
+ * You are responsible for ensuring the agent returns a `complete` response before this limit.
200
+ * If the agent reaches the max iterations without completing, it will fail.
201
+ *
202
+ * @default 5
203
+ * @param maxIterations Must be greater than 0
204
+ * @throws {Error} If called on a non-agent node
205
+ * @throws {ValidationError} If maxIterations is less than 1
206
+ */
207
+ withMaxIterations(maxIterations) {
208
+ if (!this.isAgentNode) {
209
+ throw new Error("Max iterations can only be set for agent nodes");
210
+ }
211
+ const agentNode = this.node;
212
+ agentNode.http.config.max_iterations = maxIterations;
213
+ return this;
214
+ }
215
+ /**
216
+ * Set the tools available to the agent.
217
+ * Tools must be defined in the global tools section of the workflow.
218
+ * Each tool name must be unique within the workflow and have no dashes or spaces.
219
+ *
220
+ * @param tools Array of tool names that the agent can use
221
+ * @throws {Error} If called on a non-agent node
222
+ * @throws {ValidationError} If any tool is not found in global tools
223
+ */
224
+ withTools(tools) {
225
+ if (!this.isAgentNode) {
226
+ throw new Error("Tools can only be set for agent nodes");
227
+ }
228
+ const agentNode = this.node;
229
+ agentNode.tools = tools;
230
+ return this;
231
+ }
232
+ /**
233
+ * Add a single tool to the agent's available tools.
234
+ * The tool must be defined in the global tools section of the workflow.
235
+ * The tool name must be unique within the workflow and have no dashes or spaces.
236
+ *
237
+ * @param tool Name of the tool to add
238
+ * @throws {Error} If called on a non-agent node
239
+ * @throws {ValidationError} If the tool is not found in global tools
240
+ */
241
+ addTool(tool) {
242
+ if (!this.isAgentNode) {
243
+ throw new Error("Tools can only be added to agent nodes");
244
+ }
245
+ const agentNode = this.node;
246
+ if (!agentNode.tools.includes(tool)) {
247
+ agentNode.tools.push(tool);
248
+ }
249
+ return this;
250
+ }
251
+ // Terminal operation
252
+ end() {
253
+ return this.graph;
254
+ }
255
+ // Internal method to get the built node
256
+ build() {
257
+ return this.node;
258
+ }
259
+ }
260
+ exports.NodeBuilder = NodeBuilder;
261
+ //# sourceMappingURL=node-builder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-builder.js","sourceRoot":"","sources":["../src/node-builder.ts"],"names":[],"mappings":";;;;;;AAUA,sDAA8B;AAC9B,6BAAwB;AACxB,2DAAqD;AAGrD,MAAa,WAAW;IAKtB,YACmB,KAAmB,EACpC,EAAU,EACV,OAA4C,MAAM,EAClD,cAAyB;QAHR,UAAK,GAAL,KAAK,CAAc;QAKpC,IAAI,CAAC,UAAU,GAAG,IA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
+ */
5
+ context?: Record<string, any>;
6
+ /**
7
+ * Webhook URL to receive notifications about workflow progress
8
+ */
9
+ webhookUrl?: string;
10
+ }
11
+ /**
12
+ * Represents the detailed response for getting workflow status or synchronous execution results.
13
+ */
14
+ export interface WorkflowResponse<TState = any, TErr = any> {
15
+ /** Unique identifier for the workflow execution */
16
+ workflowId: string;
17
+ /** Unique identifier for the specific workflow run */
18
+ runId: string;
19
+ /** ISO string timestamp when the workflow started */
20
+ startedAt: string;
21
+ /** User ID associated with the workflow */
22
+ userId: string;
23
+ /** Organization ID associated with the workflow */
24
+ organizationId: string;
25
+ /** Current status of the workflow execution */
26
+ status: "RUNNING" | "COMPLETED" | "FAILED" | "CANCELLED" | "TERMINATED" | "CONTINUED_AS_NEW" | "TIMED_OUT";
27
+ /**
28
+ * The current state of the workflow (e.g., node results).
29
+ * Structure depends on the workflow implementation.
30
+ * Often null if status is RUNNING, FAILED, or TERMINATED.
31
+ */
32
+ executionState?: TState | null;
33
+ /**
34
+ * Error information if workflow status is FAILED or TERMINATED.
35
+ * Structure varies based on failure type.
36
+ */
37
+ error?: TErr | null;
38
+ }
39
+ export interface ApiResponse<T> {
40
+ success: boolean;
41
+ message: string;
42
+ data: T | null;
43
+ }
44
+ export interface ValidationResult {
45
+ isValid: boolean;
46
+ errors: {
47
+ name: string;
48
+ message: string;
49
+ }[];
50
+ }
51
+ export interface GetWorkflowResponse {
52
+ workflow_id: string;
53
+ run_id: string;
54
+ started_at: string;
55
+ user_id: string;
56
+ organization_id: string;
57
+ status: string;
58
+ execution_state: any;
59
+ error?: any;
60
+ }
61
+ export interface TerminateWorkflowResponse {
62
+ workflowId: string;
63
+ status: string;
64
+ }
65
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM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AAyB;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB"}
package/dist/types.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // --- Added Types --- END
4
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAkFA,0BAA0B"}
@@ -0,0 +1,34 @@
1
+ import { WorkflowGraph } from "@graph-compose/core";
2
+ import { z } from "zod";
3
+ export declare const ValidationResponseSchema: z.ZodObject<{
4
+ isValid: z.ZodBoolean;
5
+ errors: z.ZodArray<z.ZodType<Error, z.ZodTypeDef, Error>, "many">;
6
+ }, "strip", z.ZodTypeAny, {
7
+ isValid: boolean;
8
+ errors: Error[];
9
+ }, {
10
+ isValid: boolean;
11
+ errors: Error[];
12
+ }>;
13
+ export interface ValidationResult extends z.infer<typeof ValidationResponseSchema> {
14
+ }
15
+ /**
16
+ * Validates a workflow definition
17
+ */
18
+ export declare function validateWorkflow(workflow: WorkflowGraph): ValidationResult;
19
+ /**
20
+ * Validates a JSONata expression within a node's configuration
21
+ * @param expr - The JSONata expression to validate
22
+ * @param nodeId - The ID of the node containing the expression
23
+ * @returns A validation result indicating success or failure
24
+ */
25
+ declare function validateExpression(expr: string, nodeId: string): ValidationResult;
26
+ /**
27
+ * Validates a template string containing JSONata expressions
28
+ * @param template - The template string to validate
29
+ * @param nodeId - The ID of the node containing the template
30
+ * @returns A validation result indicating success or failure
31
+ */
32
+ declare function validateTemplate(template: string, nodeId: string): ValidationResult;
33
+ export { validateExpression, validateTemplate };
34
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validation/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,aAAa,EAAuB,MAAM,qBAAqB,CAAC;AAE9F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,eAAO,MAAM,wBAAwB;;;;;;;;;EAGnC,CAAC;AAEH,MAAM,WAAW,gBAAiB,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC;CAAG;AA+FrF;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,aAAa,GAAG,gBAAgB,CA4J1E;AAED;;;;;GAKG;AACH,iBAAS,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CAyB1E;AAED;;;;;GAKG;AACH,iBAAS,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,gBAAgB,CA8C5E;AAGD,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC"}