@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.
- package/README.md +646 -0
- package/dist/core/builder.d.ts +313 -0
- package/dist/core/builder.d.ts.map +1 -0
- package/dist/core/builder.js +538 -0
- package/dist/core/builder.js.map +1 -0
- package/dist/core/node-builder.d.ts +180 -0
- package/dist/core/node-builder.d.ts.map +1 -0
- package/dist/core/node-builder.js +387 -0
- package/dist/core/node-builder.js.map +1 -0
- package/dist/core/tool-builder.d.ts +130 -0
- package/dist/core/tool-builder.d.ts.map +1 -0
- package/dist/core/tool-builder.js +343 -0
- package/dist/core/tool-builder.js.map +1 -0
- package/dist/errors.d.ts +16 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +39 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/node-builder.d.ts +64 -0
- package/dist/node-builder.d.ts.map +1 -0
- package/dist/node-builder.js +261 -0
- package/dist/node-builder.js.map +1 -0
- package/dist/types.d.ts +65 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/validation/index.d.ts +34 -0
- package/dist/validation/index.d.ts.map +1 -0
- package/dist/validation/index.js +304 -0
- package/dist/validation/index.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,538 @@
|
|
|
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.GraphCompose = void 0;
|
|
7
|
+
const console_1 = __importDefault(require("console"));
|
|
8
|
+
const validation_1 = require("../validation");
|
|
9
|
+
const node_builder_1 = require("./node-builder");
|
|
10
|
+
const tool_builder_1 = require("./tool-builder");
|
|
11
|
+
/**
|
|
12
|
+
* GraphCompose is the main builder class for creating workflow graphs.
|
|
13
|
+
* It provides a fluent API for building and executing workflows composed of HTTP nodes, agents, and error boundaries.
|
|
14
|
+
* You configure each node or tool using chained methods and **must** call `.end()` to finalize its definition.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const graph = new GraphCompose({ token: "your-token" });
|
|
19
|
+
*
|
|
20
|
+
* // Create and finalize a simple HTTP node
|
|
21
|
+
* graph.node("fetch_data")
|
|
22
|
+
* .get("https://api.example.com/data")
|
|
23
|
+
* .withHeaders({ "Authorization": "Bearer token" })
|
|
24
|
+
* .end(); // Required!
|
|
25
|
+
*
|
|
26
|
+
* // Define and end a tool (example)
|
|
27
|
+
* graph.tool("analyze")
|
|
28
|
+
* .post("https://api.example.com/analyze")
|
|
29
|
+
* .end();
|
|
30
|
+
*
|
|
31
|
+
* // Create and finalize an agent node that uses the tool
|
|
32
|
+
* graph.agent("process_data")
|
|
33
|
+
* .withMaxIterations(5)
|
|
34
|
+
* .withTools(["analyze"])
|
|
35
|
+
* .post("https://api.example.com/agent")
|
|
36
|
+
* .withDependencies(["fetch_data"])
|
|
37
|
+
* .end(); // Required!
|
|
38
|
+
*
|
|
39
|
+
* // Validate the complete workflow (requires all nodes/tools ended)
|
|
40
|
+
* const validationResult = graph.validate();
|
|
41
|
+
* if (!validationResult.isValid) { console.error("Validation failed:", validationResult.errors); }
|
|
42
|
+
*
|
|
43
|
+
* // Execute the workflow (requires all nodes/tools ended)
|
|
44
|
+
* try {
|
|
45
|
+
* const result = await graph.execute({});
|
|
46
|
+
* console.log("Execution started:", result);
|
|
47
|
+
* } catch (error) { console.error("Execution failed:", error); }
|
|
48
|
+
*
|
|
49
|
+
* // Get the raw workflow definition (requires all nodes/tools ended)
|
|
50
|
+
* const definition = graph.toJSON();
|
|
51
|
+
* console.log("Workflow JSON:", JSON.stringify(definition, null, 2));
|
|
52
|
+
*
|
|
53
|
+
* // Interact with existing workflows via API
|
|
54
|
+
* // const statusResult = await graph.getWorkflowStatus('some-workflow-id');
|
|
55
|
+
* // const terminateResult = await graph.terminateWorkflow('some-workflow-id');
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
class GraphCompose {
|
|
59
|
+
/**
|
|
60
|
+
* Creates a new GraphCompose instance.
|
|
61
|
+
*
|
|
62
|
+
* @param options Configuration options for the graph builder
|
|
63
|
+
* @throws {Error} If no API token is provided via options or environment variable
|
|
64
|
+
*/
|
|
65
|
+
constructor(options = {}) {
|
|
66
|
+
this.nodes = [];
|
|
67
|
+
this._tools = [];
|
|
68
|
+
this.token = options.token || process.env.GRAPH_COMPOSE_TOKEN || "";
|
|
69
|
+
if (!this.token) {
|
|
70
|
+
throw new Error("API token is required. Set GRAPH_COMPOSE_TOKEN environment variable or pass token in constructor options.");
|
|
71
|
+
}
|
|
72
|
+
// Default to production API URL
|
|
73
|
+
this.baseUrl = "https://api.graphcompose.io/api/v1";
|
|
74
|
+
}
|
|
75
|
+
/** Internal method for ToolBuilder to add its definition */
|
|
76
|
+
_addToolDefinition(tool) {
|
|
77
|
+
if (this._tools.some((t) => t.id === tool.id)) {
|
|
78
|
+
console_1.default.warn(`GraphCompose: Tool with ID '${tool.id}' already exists. Overwriting.`);
|
|
79
|
+
this._tools = this._tools.filter((t) => t.id !== tool.id);
|
|
80
|
+
}
|
|
81
|
+
this._tools.push(tool);
|
|
82
|
+
this.currentToolBuilder = undefined;
|
|
83
|
+
}
|
|
84
|
+
/** Internal method for NodeBuilder to add its definition */
|
|
85
|
+
_addNodeDefinition(node) {
|
|
86
|
+
this.nodes.push(node);
|
|
87
|
+
this.currentNodeBuilder = undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Checks if there's an unfinalized builder and throws an error.
|
|
91
|
+
* Call this before operations that require a complete workflow definition.
|
|
92
|
+
*/
|
|
93
|
+
ensureBuildersFinalized(operation) {
|
|
94
|
+
if (this.currentNodeBuilder) {
|
|
95
|
+
throw new Error(`Cannot ${operation} while node '${this.currentNodeBuilder.getId()}' is being built. Call .end() first.`);
|
|
96
|
+
}
|
|
97
|
+
if (this.currentToolBuilder) {
|
|
98
|
+
throw new Error(`Cannot ${operation} while tool '${this.currentToolBuilder.getId()}' is being built. Call .end() first.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Start building a new HTTP node.
|
|
103
|
+
* HTTP nodes are the basic building blocks of workflows, used to make HTTP requests.
|
|
104
|
+
* **Note:** You must call `.end()` on the returned `NodeBuilder` before starting another node or finishing the graph.
|
|
105
|
+
*
|
|
106
|
+
* @param id Unique identifier for the node (must be alphanumeric with underscores)
|
|
107
|
+
* @returns NodeBuilder instance for method chaining
|
|
108
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* graph.node("fetch_data")
|
|
112
|
+
* .get("https://api.example.com/data")
|
|
113
|
+
* .withHeaders({ "Authorization": "Bearer token" })
|
|
114
|
+
* .end(); // Required!
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
node(id) {
|
|
118
|
+
this.ensureBuildersFinalized(`start node '${id}'`);
|
|
119
|
+
this.currentNodeBuilder = new node_builder_1.NodeBuilder(this, id);
|
|
120
|
+
return this.currentNodeBuilder;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Start building a new error boundary node.
|
|
124
|
+
* Error boundaries catch and handle errors from their protected nodes.
|
|
125
|
+
* **Note:** You must call `.end()` on the returned `NodeBuilder` before starting another node or finishing the graph.
|
|
126
|
+
*
|
|
127
|
+
* @param id Unique identifier for the node (must be alphanumeric with underscores)
|
|
128
|
+
* @param protectedNodes Array of node IDs that this error boundary protects
|
|
129
|
+
* @returns NodeBuilder instance for method chaining
|
|
130
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* graph.errorBoundary("data_error_handler", ["fetch_data"])
|
|
134
|
+
* .post("https://api.example.com/error-handler")
|
|
135
|
+
* .withBody(({ context, results }) => ({
|
|
136
|
+
* error: results.error,
|
|
137
|
+
* nodeId: results.nodeId
|
|
138
|
+
* }))
|
|
139
|
+
* .end(); // Required!
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
errorBoundary(id, protectedNodes) {
|
|
143
|
+
this.ensureBuildersFinalized(`start error boundary '${id}'`);
|
|
144
|
+
this.currentNodeBuilder = new node_builder_1.NodeBuilder(this, id, "error_boundary", protectedNodes);
|
|
145
|
+
return this.currentNodeBuilder;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Start building a new agent node.
|
|
149
|
+
* Agent nodes are special nodes that can execute multiple iterations and use tools.
|
|
150
|
+
* **Note:** You must call `.end()` on the returned `NodeBuilder` before starting another node or finishing the graph.
|
|
151
|
+
*
|
|
152
|
+
* @param id Unique identifier for the node (must be alphanumeric with underscores)
|
|
153
|
+
* @returns NodeBuilder instance for method chaining
|
|
154
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
155
|
+
* @example
|
|
156
|
+
* ```typescript
|
|
157
|
+
* graph.agent("research_agent")
|
|
158
|
+
* .withMaxIterations(10)
|
|
159
|
+
* .withTools(["search", "analyze"])
|
|
160
|
+
* .post("https://api.example.com/agent")
|
|
161
|
+
* .end(); // Required!
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
agent(id) {
|
|
165
|
+
this.ensureBuildersFinalized(`start agent '${id}'`);
|
|
166
|
+
this.currentNodeBuilder = new node_builder_1.NodeBuilder(this, id, "agent");
|
|
167
|
+
return this.currentNodeBuilder;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Start building a new tool definition.
|
|
171
|
+
* Tools are reusable components (HTTP calls or sub-graphs) usable by agent nodes.
|
|
172
|
+
* **Note:** You must call `.end()` on the returned `ToolBuilder` before starting another tool/node or finishing the graph.
|
|
173
|
+
*
|
|
174
|
+
* @param id Unique identifier for the tool (must be alphanumeric with underscores)
|
|
175
|
+
* @returns ToolBuilder instance for method chaining
|
|
176
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* graph.tool("search")
|
|
180
|
+
* .get("https://api.search.com")
|
|
181
|
+
* .withHeaders({ "Authorization": "Bearer token" })
|
|
182
|
+
* .end(); // Required!
|
|
183
|
+
* ```
|
|
184
|
+
*/
|
|
185
|
+
tool(id) {
|
|
186
|
+
this.ensureBuildersFinalized(`start tool '${id}'`);
|
|
187
|
+
this.currentToolBuilder = new tool_builder_1.ToolBuilder(this, id);
|
|
188
|
+
return this.currentToolBuilder;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Add a pre-configured node to the workflow.
|
|
192
|
+
* Ensures no other builder is active before adding.
|
|
193
|
+
*
|
|
194
|
+
* @param node The node configuration to add
|
|
195
|
+
* @returns this GraphCompose instance for method chaining
|
|
196
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
197
|
+
*/
|
|
198
|
+
addNode(node) {
|
|
199
|
+
this.ensureBuildersFinalized("add pre-configured node");
|
|
200
|
+
this.nodes.push(node);
|
|
201
|
+
return this;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Add a pre-configured tool definition to the workflow.
|
|
205
|
+
* Ensures no other builder is active before adding.
|
|
206
|
+
*
|
|
207
|
+
* @param tool The tool configuration to add
|
|
208
|
+
* @returns this GraphCompose instance for method chaining
|
|
209
|
+
* @throws {Error} If another node or tool is currently being built.
|
|
210
|
+
*/
|
|
211
|
+
addTool(tool) {
|
|
212
|
+
this.ensureBuildersFinalized("add pre-configured tool");
|
|
213
|
+
if (this._tools.some((t) => t.id === tool.id)) {
|
|
214
|
+
console_1.default.warn(`GraphCompose: Tool with ID '${tool.id}' already exists. Overwriting.`);
|
|
215
|
+
this._tools = this._tools.filter((t) => t.id !== tool.id);
|
|
216
|
+
}
|
|
217
|
+
this._tools.push(tool);
|
|
218
|
+
return this;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get the complete workflow definition object.
|
|
222
|
+
* This includes all nodes, tools, webhook URL, context, and workflow configuration.
|
|
223
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
224
|
+
*
|
|
225
|
+
* @returns The complete workflow graph definition object.
|
|
226
|
+
* @throws {Error} If a node or tool is currently being built (missing `.end()`).
|
|
227
|
+
*/
|
|
228
|
+
getWorkflow() {
|
|
229
|
+
this.ensureBuildersFinalized("get workflow definition");
|
|
230
|
+
return {
|
|
231
|
+
nodes: this.nodes,
|
|
232
|
+
tools: this._tools,
|
|
233
|
+
webhookUrl: this.webhookUrl,
|
|
234
|
+
context: this.context,
|
|
235
|
+
workflowConfig: this.workflowConfig,
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Returns the complete workflow definition as a plain JavaScript object.
|
|
240
|
+
* This is the raw representation suitable for serialization (e.g., to JSON).
|
|
241
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
242
|
+
*
|
|
243
|
+
* @returns The complete workflow graph definition object.
|
|
244
|
+
* @throws {Error} If a node or tool is currently being built (missing `.end()`).
|
|
245
|
+
* @alias getWorkflow
|
|
246
|
+
*/
|
|
247
|
+
toJSON() {
|
|
248
|
+
return this.getWorkflow();
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validate the current workflow locally.
|
|
252
|
+
* Checks for:
|
|
253
|
+
* - Valid node IDs
|
|
254
|
+
* - Valid URLs
|
|
255
|
+
* - Valid dependencies
|
|
256
|
+
* - Valid tool configurations
|
|
257
|
+
* - No circular dependencies
|
|
258
|
+
* - Agent-specific requirements (e.g., `max_iterations` presence and value)
|
|
259
|
+
*
|
|
260
|
+
* Note: This performs client-side validation only. Use `validateApi()` for server-side checks including tier limits.
|
|
261
|
+
*
|
|
262
|
+
* @returns Validation result indicating if the workflow is valid and any errors.
|
|
263
|
+
* @throws {Error} If a node or tool is currently being built (missing `.end()`).
|
|
264
|
+
*/
|
|
265
|
+
validate() {
|
|
266
|
+
this.ensureBuildersFinalized("validate workflow");
|
|
267
|
+
const workflow = this.getWorkflow();
|
|
268
|
+
return (0, validation_1.validateWorkflow)(workflow);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Validates the current workflow definition against the API endpoint.
|
|
272
|
+
* Performs server-side checks including tier limits.
|
|
273
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
274
|
+
*
|
|
275
|
+
* @returns {Promise<ApiResponse<ApiValidationResult | null>>} The validation result from the API, wrapped in an ApiResponse.
|
|
276
|
+
* @throws {Error} If the API call fails or returns an unexpected format.
|
|
277
|
+
*/
|
|
278
|
+
async validateApi() {
|
|
279
|
+
this.ensureBuildersFinalized("validate workflow via API");
|
|
280
|
+
const workflow = this.getWorkflow();
|
|
281
|
+
const requestBody = { workflow };
|
|
282
|
+
console_1.default.log(`Validating workflow via API: ${this.baseUrl}/workflows/validate`);
|
|
283
|
+
try {
|
|
284
|
+
const response = await fetch(`${this.baseUrl}/workflows/validate`, {
|
|
285
|
+
method: "POST",
|
|
286
|
+
headers: {
|
|
287
|
+
"Content-Type": "application/json",
|
|
288
|
+
Authorization: `Bearer ${this.token}`,
|
|
289
|
+
},
|
|
290
|
+
body: JSON.stringify(requestBody),
|
|
291
|
+
});
|
|
292
|
+
const responseJson = await response.json();
|
|
293
|
+
if (!response.ok) {
|
|
294
|
+
console_1.default.error(`API Validation Error ${response.status}:`, responseJson?.message || response.statusText);
|
|
295
|
+
}
|
|
296
|
+
// Assert the response structure matches ApiResponse<ApiValidationResult | null>
|
|
297
|
+
return responseJson;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
console_1.default.error("Error calling validation API:", error);
|
|
301
|
+
if (error instanceof Error) {
|
|
302
|
+
throw new Error(`Failed to call validation API: ${error.message}`);
|
|
303
|
+
}
|
|
304
|
+
throw new Error("An unknown error occurred during API validation.");
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* Retrieves the details and status of a specific workflow instance by its ID.
|
|
309
|
+
*
|
|
310
|
+
* @param workflowId The unique identifier of the workflow instance.
|
|
311
|
+
* @returns Promise resolving to the full API response containing the workflow details.
|
|
312
|
+
* @throws {Error} If the API request fails (e.g., 404 Not Found).
|
|
313
|
+
*/
|
|
314
|
+
async getWorkflowStatus(workflowId) {
|
|
315
|
+
if (!workflowId) {
|
|
316
|
+
throw new Error("Workflow ID is required to get status.");
|
|
317
|
+
}
|
|
318
|
+
console_1.default.log(`Getting workflow status via API: ${this.baseUrl}/workflows/${workflowId}`);
|
|
319
|
+
try {
|
|
320
|
+
const response = await fetch(`${this.baseUrl}/workflows/${workflowId}`, {
|
|
321
|
+
method: "GET",
|
|
322
|
+
headers: {
|
|
323
|
+
Authorization: `Bearer ${this.token}`,
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
const responseJson = await response.json();
|
|
327
|
+
if (!response.ok) {
|
|
328
|
+
console_1.default.error(`API Get Status Error ${response.status}:`, responseJson?.message || response.statusText);
|
|
329
|
+
}
|
|
330
|
+
return responseJson;
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
console_1.default.error("Error calling get workflow status API:", error);
|
|
334
|
+
if (error instanceof Error) {
|
|
335
|
+
throw new Error(`Failed to get workflow status: ${error.message}`);
|
|
336
|
+
}
|
|
337
|
+
throw new Error("An unknown error occurred while getting workflow status.");
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Requests the termination of a running workflow instance.
|
|
342
|
+
*
|
|
343
|
+
* @param workflowId The unique identifier of the workflow instance to terminate.
|
|
344
|
+
* @param options Optional parameters including the specific run ID and a reason for termination.
|
|
345
|
+
* @returns Promise resolving to the full API response confirming the termination request.
|
|
346
|
+
* @throws {Error} If the API request fails.
|
|
347
|
+
*/
|
|
348
|
+
async terminateWorkflow(workflowId, options) {
|
|
349
|
+
if (!workflowId) {
|
|
350
|
+
throw new Error("Workflow ID is required to terminate.");
|
|
351
|
+
}
|
|
352
|
+
console_1.default.log(`Terminating workflow via API: ${this.baseUrl}/workflows/${workflowId}/terminate`);
|
|
353
|
+
const requestBody = {
|
|
354
|
+
run_id: options?.runId,
|
|
355
|
+
reason: options?.reason,
|
|
356
|
+
};
|
|
357
|
+
try {
|
|
358
|
+
const response = await fetch(`${this.baseUrl}/workflows/${workflowId}/terminate`, {
|
|
359
|
+
method: "POST",
|
|
360
|
+
headers: {
|
|
361
|
+
"Content-Type": "application/json",
|
|
362
|
+
Authorization: `Bearer ${this.token}`,
|
|
363
|
+
},
|
|
364
|
+
body: options?.runId || options?.reason ? JSON.stringify(requestBody) : undefined,
|
|
365
|
+
});
|
|
366
|
+
const responseJson = await response.json();
|
|
367
|
+
if (!response.ok) {
|
|
368
|
+
console_1.default.error(`API Terminate Error ${response.status}:`, responseJson?.message || response.statusText);
|
|
369
|
+
}
|
|
370
|
+
return responseJson;
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
console_1.default.error("Error calling terminate workflow API:", error);
|
|
374
|
+
if (error instanceof Error) {
|
|
375
|
+
throw new Error(`Failed to terminate workflow: ${error.message}`);
|
|
376
|
+
}
|
|
377
|
+
throw new Error("An unknown error occurred during workflow termination.");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Set the execution context for the workflow.
|
|
382
|
+
* The context is available to all nodes via JSONata expressions.
|
|
383
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
384
|
+
*
|
|
385
|
+
* @param context Key-value pairs that will be available to nodes
|
|
386
|
+
* @returns this GraphCompose instance for method chaining
|
|
387
|
+
* @throws {Error} If a node or tool is currently being built.
|
|
388
|
+
* @example
|
|
389
|
+
* ```typescript
|
|
390
|
+
* graph.withContext({
|
|
391
|
+
* api_key: process.env.API_KEY,
|
|
392
|
+
* user_id: "123",
|
|
393
|
+
* });
|
|
394
|
+
* ```
|
|
395
|
+
*/
|
|
396
|
+
withContext(context) {
|
|
397
|
+
this.ensureBuildersFinalized("set context");
|
|
398
|
+
this.context = context;
|
|
399
|
+
return this;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Execute the workflow asynchronously without waiting for completion.
|
|
403
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
404
|
+
*
|
|
405
|
+
* @param options Execution options including webhook URL and context
|
|
406
|
+
* @returns Promise resolving to the full API response containing the initial workflow details (like workflow ID and run ID). The status will likely be RUNNING.
|
|
407
|
+
* @throws {Error} If a node or tool is currently being built.
|
|
408
|
+
* @throws {Error} If validation fails or if the execution fails
|
|
409
|
+
* @example
|
|
410
|
+
* ```typescript
|
|
411
|
+
* const apiResponse = await graph.execute({ ... });
|
|
412
|
+
* if (apiResponse.success && apiResponse.data) {
|
|
413
|
+
* console.log("Workflow started:", apiResponse.data.workflowId);
|
|
414
|
+
* // apiResponse.data will contain workflowId, runId, etc.
|
|
415
|
+
* }
|
|
416
|
+
* ```
|
|
417
|
+
*/
|
|
418
|
+
async execute(options = {}) {
|
|
419
|
+
this.ensureBuildersFinalized("execute workflow (async)");
|
|
420
|
+
const validationResult = this.validate();
|
|
421
|
+
if (!validationResult.isValid) {
|
|
422
|
+
console_1.default.error("Workflow validation failed:", validationResult.errors);
|
|
423
|
+
throw new Error(`Workflow validation failed: ${validationResult.errors.map((e) => e.message).join(", ")}`);
|
|
424
|
+
}
|
|
425
|
+
const workflow = this.getWorkflow();
|
|
426
|
+
const executionContext = { ...this.context, ...options.context };
|
|
427
|
+
const requestBody = {
|
|
428
|
+
...workflow,
|
|
429
|
+
context: executionContext,
|
|
430
|
+
webhookUrl: options.webhookUrl || this.webhookUrl,
|
|
431
|
+
};
|
|
432
|
+
try {
|
|
433
|
+
const response = await fetch(`${this.baseUrl}/workflows`, {
|
|
434
|
+
method: "POST",
|
|
435
|
+
headers: {
|
|
436
|
+
"Content-Type": "application/json",
|
|
437
|
+
Authorization: `Bearer ${this.token}`,
|
|
438
|
+
},
|
|
439
|
+
body: JSON.stringify(requestBody),
|
|
440
|
+
});
|
|
441
|
+
if (!response.ok) {
|
|
442
|
+
let errorBody;
|
|
443
|
+
try {
|
|
444
|
+
errorBody = await response.json();
|
|
445
|
+
}
|
|
446
|
+
catch (e) {
|
|
447
|
+
errorBody = await response.text();
|
|
448
|
+
}
|
|
449
|
+
throw new Error(`HTTP Error: ${response.status} ${response.statusText}. Body: ${JSON.stringify(errorBody)}`);
|
|
450
|
+
}
|
|
451
|
+
return (await response.json());
|
|
452
|
+
}
|
|
453
|
+
catch (error) {
|
|
454
|
+
console_1.default.error("Error initiating async workflow execution:", error);
|
|
455
|
+
throw error;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
/**
|
|
459
|
+
* Execute the workflow synchronously and wait for completion.
|
|
460
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
461
|
+
*
|
|
462
|
+
* @param options Execution options including webhook URL and context
|
|
463
|
+
* @returns Promise resolving to the full API response containing the final workflow details (status, results, error) upon completion or failure.
|
|
464
|
+
* @throws {Error} If a node or tool is currently being built (missing `.end()`).
|
|
465
|
+
*/
|
|
466
|
+
async executeSync(options = {}) {
|
|
467
|
+
this.ensureBuildersFinalized("execute workflow (sync)");
|
|
468
|
+
const validationResult = this.validate();
|
|
469
|
+
if (!validationResult.isValid) {
|
|
470
|
+
console_1.default.error("Workflow validation failed:", validationResult.errors);
|
|
471
|
+
throw new Error(`Workflow validation failed: ${validationResult.errors.map((e) => e.message).join(", ")}`);
|
|
472
|
+
}
|
|
473
|
+
const workflow = this.getWorkflow();
|
|
474
|
+
const executionContext = { ...this.context, ...options.context };
|
|
475
|
+
const requestBody = {
|
|
476
|
+
...workflow,
|
|
477
|
+
context: executionContext,
|
|
478
|
+
webhookUrl: options.webhookUrl || this.webhookUrl,
|
|
479
|
+
};
|
|
480
|
+
try {
|
|
481
|
+
const response = await fetch(`${this.baseUrl}/workflows/execute-sync`, {
|
|
482
|
+
method: "POST",
|
|
483
|
+
headers: {
|
|
484
|
+
"Content-Type": "application/json",
|
|
485
|
+
Authorization: `Bearer ${this.token}`,
|
|
486
|
+
},
|
|
487
|
+
body: JSON.stringify(requestBody),
|
|
488
|
+
});
|
|
489
|
+
if (!response.ok) {
|
|
490
|
+
let errorBody;
|
|
491
|
+
try {
|
|
492
|
+
errorBody = await response.json();
|
|
493
|
+
}
|
|
494
|
+
catch (e) {
|
|
495
|
+
errorBody = await response.text();
|
|
496
|
+
}
|
|
497
|
+
throw new Error(`HTTP Error: ${response.status} ${response.statusText}. Body: ${JSON.stringify(errorBody)}`);
|
|
498
|
+
}
|
|
499
|
+
return (await response.json());
|
|
500
|
+
}
|
|
501
|
+
catch (error) {
|
|
502
|
+
console_1.default.error("Error executing sync workflow:", error);
|
|
503
|
+
throw error;
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Set the webhook URL for workflow notifications.
|
|
508
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
509
|
+
*
|
|
510
|
+
* @param url The URL that will receive webhook notifications
|
|
511
|
+
* @returns this GraphCompose instance for method chaining
|
|
512
|
+
* @throws {Error} If a node or tool is currently being built.
|
|
513
|
+
*/
|
|
514
|
+
withWebhookUrl(url) {
|
|
515
|
+
this.ensureBuildersFinalized("set webhook URL");
|
|
516
|
+
this.webhookUrl = url;
|
|
517
|
+
return this;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Sets the workflow-level configuration.
|
|
521
|
+
* **Note:** Requires all active builders to be finalized using `.end()`.
|
|
522
|
+
*
|
|
523
|
+
* @param config The workflow configuration object
|
|
524
|
+
* @returns this GraphCompose instance for method chaining
|
|
525
|
+
* @throws {Error} If a node or tool is currently being built.
|
|
526
|
+
* @example
|
|
527
|
+
* ```typescript
|
|
528
|
+
* graph.withWorkflowConfig({ workflowExecutionTimeout: '5 minutes' });
|
|
529
|
+
* ```
|
|
530
|
+
*/
|
|
531
|
+
withWorkflowConfig(config) {
|
|
532
|
+
this.ensureBuildersFinalized("set workflow config");
|
|
533
|
+
this.workflowConfig = { ...this.workflowConfig, ...config };
|
|
534
|
+
return this;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
exports.GraphCompose = GraphCompose;
|
|
538
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/core/builder.ts"],"names":[],"mappings":";;;;;;AACA,sDAA8B;AAS9B,8CAAiD;AACjD,iDAA6C;AAC7C,iDAA6C;AAoB7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAa,YAAY;IAWvB;;;;;OAKG;IACH,YAAY,UAA+B,EAAE;QAhBrC,UAAK,GAAW,EAAE,CAAC;QACnB,WAAM,GAAe,EAAE,CAAC;QAgB9B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;QACpE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;QACJ,CAAC;QACD,gCAAgC;QAChC,IAAI,CAAC,OAAO,GAAG,oCAAoC,CAAC;IACtD,CAAC;IAED,4DAA4D;IAC5D,kBAAkB,CAAC,IAAc;QAC/B,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YAC9C,iBAAO,CAAC,IAAI,CAAC,+BAA+B,IAAI,CAAC,EAAE,gCAAgC,CAAC,CAAC;YACrF,IAAI,CAAC,MAAM,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