@graph-compose/core 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.
Files changed (155) hide show
  1. package/README.md +323 -0
  2. package/dist/index.d.ts +6 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +24 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/tsconfig.tsbuildinfo +1 -0
  7. package/dist/types/behaviors/conditions.d.ts +54 -0
  8. package/dist/types/behaviors/conditions.d.ts.map +1 -0
  9. package/dist/types/behaviors/conditions.js +103 -0
  10. package/dist/types/behaviors/conditions.js.map +1 -0
  11. package/dist/types/behaviors/index.d.ts +3 -0
  12. package/dist/types/behaviors/index.d.ts.map +1 -0
  13. package/dist/types/behaviors/index.js +19 -0
  14. package/dist/types/behaviors/index.js.map +1 -0
  15. package/dist/types/behaviors/notifications.d.ts +157 -0
  16. package/dist/types/behaviors/notifications.d.ts.map +1 -0
  17. package/dist/types/behaviors/notifications.js +89 -0
  18. package/dist/types/behaviors/notifications.js.map +1 -0
  19. package/dist/types/config/activity.d.ts +58 -0
  20. package/dist/types/config/activity.d.ts.map +1 -0
  21. package/dist/types/config/activity.js +53 -0
  22. package/dist/types/config/activity.js.map +1 -0
  23. package/dist/types/config/http.d.ts +20 -0
  24. package/dist/types/config/http.d.ts.map +1 -0
  25. package/dist/types/config/http.js +66 -0
  26. package/dist/types/config/http.js.map +1 -0
  27. package/dist/types/config/index.d.ts +5 -0
  28. package/dist/types/config/index.d.ts.map +1 -0
  29. package/dist/types/config/index.js +21 -0
  30. package/dist/types/config/index.js.map +1 -0
  31. package/dist/types/config/protocols.d.ts +3 -0
  32. package/dist/types/config/protocols.d.ts.map +1 -0
  33. package/dist/types/config/protocols.js +14 -0
  34. package/dist/types/config/protocols.js.map +1 -0
  35. package/dist/types/config/workflow.d.ts +10 -0
  36. package/dist/types/config/workflow.d.ts.map +1 -0
  37. package/dist/types/config/workflow.js +12 -0
  38. package/dist/types/config/workflow.js.map +1 -0
  39. package/dist/types/context/index.d.ts +4 -0
  40. package/dist/types/context/index.d.ts.map +1 -0
  41. package/dist/types/context/index.js +8 -0
  42. package/dist/types/context/index.js.map +1 -0
  43. package/dist/types/contracts/agents.d.ts +87 -0
  44. package/dist/types/contracts/agents.d.ts.map +1 -0
  45. package/dist/types/contracts/agents.js +94 -0
  46. package/dist/types/contracts/agents.js.map +1 -0
  47. package/dist/types/contracts/index.d.ts +3 -0
  48. package/dist/types/contracts/index.d.ts.map +1 -0
  49. package/dist/types/contracts/index.js +19 -0
  50. package/dist/types/contracts/index.js.map +1 -0
  51. package/dist/types/contracts/tools.d.ts +72 -0
  52. package/dist/types/contracts/tools.d.ts.map +1 -0
  53. package/dist/types/contracts/tools.js +101 -0
  54. package/dist/types/contracts/tools.js.map +1 -0
  55. package/dist/types/index.d.ts +10 -0
  56. package/dist/types/index.d.ts.map +1 -0
  57. package/dist/types/index.js +26 -0
  58. package/dist/types/index.js.map +1 -0
  59. package/dist/types/nodes/agents.d.ts +149 -0
  60. package/dist/types/nodes/agents.d.ts.map +1 -0
  61. package/dist/types/nodes/agents.js +48 -0
  62. package/dist/types/nodes/agents.js.map +1 -0
  63. package/dist/types/nodes/common/base-node-schema.d.ts +109 -0
  64. package/dist/types/nodes/common/base-node-schema.d.ts.map +1 -0
  65. package/dist/types/nodes/common/base-node-schema.js +55 -0
  66. package/dist/types/nodes/common/base-node-schema.js.map +1 -0
  67. package/dist/types/nodes/common/index.d.ts +2 -0
  68. package/dist/types/nodes/common/index.d.ts.map +1 -0
  69. package/dist/types/nodes/common/index.js +18 -0
  70. package/dist/types/nodes/common/index.js.map +1 -0
  71. package/dist/types/nodes/destination.d.ts +148 -0
  72. package/dist/types/nodes/destination.d.ts.map +1 -0
  73. package/dist/types/nodes/destination.js +30 -0
  74. package/dist/types/nodes/destination.js.map +1 -0
  75. package/dist/types/nodes/error-boundary.d.ts +126 -0
  76. package/dist/types/nodes/error-boundary.d.ts.map +1 -0
  77. package/dist/types/nodes/error-boundary.js +24 -0
  78. package/dist/types/nodes/error-boundary.js.map +1 -0
  79. package/dist/types/nodes/http.d.ts +194 -0
  80. package/dist/types/nodes/http.d.ts.map +1 -0
  81. package/dist/types/nodes/http.js +28 -0
  82. package/dist/types/nodes/http.js.map +1 -0
  83. package/dist/types/nodes/index.d.ts +734 -0
  84. package/dist/types/nodes/index.d.ts.map +1 -0
  85. package/dist/types/nodes/index.js +48 -0
  86. package/dist/types/nodes/index.js.map +1 -0
  87. package/dist/types/nodes/iterator.d.ts +126 -0
  88. package/dist/types/nodes/iterator.d.ts.map +1 -0
  89. package/dist/types/nodes/iterator.js +21 -0
  90. package/dist/types/nodes/iterator.js.map +1 -0
  91. package/dist/types/nodes/tools.d.ts +1321 -0
  92. package/dist/types/nodes/tools.d.ts.map +1 -0
  93. package/dist/types/nodes/tools.js +65 -0
  94. package/dist/types/nodes/tools.js.map +1 -0
  95. package/dist/types/primitives/index.d.ts +2 -0
  96. package/dist/types/primitives/index.d.ts.map +1 -0
  97. package/dist/types/primitives/index.js +18 -0
  98. package/dist/types/primitives/index.js.map +1 -0
  99. package/dist/types/primitives/shared.d.ts +21 -0
  100. package/dist/types/primitives/shared.d.ts.map +1 -0
  101. package/dist/types/primitives/shared.js +113 -0
  102. package/dist/types/primitives/shared.js.map +1 -0
  103. package/dist/types/results/agent.d.ts +156 -0
  104. package/dist/types/results/agent.d.ts.map +1 -0
  105. package/dist/types/results/agent.js +54 -0
  106. package/dist/types/results/agent.js.map +1 -0
  107. package/dist/types/results/base.d.ts +4 -0
  108. package/dist/types/results/base.d.ts.map +1 -0
  109. package/dist/types/results/base.js +12 -0
  110. package/dist/types/results/base.js.map +1 -0
  111. package/dist/types/results/index.d.ts +7 -0
  112. package/dist/types/results/index.d.ts.map +1 -0
  113. package/dist/types/results/index.js +23 -0
  114. package/dist/types/results/index.js.map +1 -0
  115. package/dist/types/results/node.d.ts +38 -0
  116. package/dist/types/results/node.d.ts.map +1 -0
  117. package/dist/types/results/node.js +26 -0
  118. package/dist/types/results/node.js.map +1 -0
  119. package/dist/types/results/shared.d.ts +36 -0
  120. package/dist/types/results/shared.d.ts.map +1 -0
  121. package/dist/types/results/shared.js +31 -0
  122. package/dist/types/results/shared.js.map +1 -0
  123. package/dist/types/results/source.d.ts +53 -0
  124. package/dist/types/results/source.d.ts.map +1 -0
  125. package/dist/types/results/source.js +64 -0
  126. package/dist/types/results/source.js.map +1 -0
  127. package/dist/types/results/tool.d.ts +170 -0
  128. package/dist/types/results/tool.d.ts.map +1 -0
  129. package/dist/types/results/tool.js +110 -0
  130. package/dist/types/results/tool.js.map +1 -0
  131. package/dist/types/state/index.d.ts +2 -0
  132. package/dist/types/state/index.d.ts.map +1 -0
  133. package/dist/types/state/index.js +18 -0
  134. package/dist/types/state/index.js.map +1 -0
  135. package/dist/types/state/workflow-state.d.ts +63 -0
  136. package/dist/types/state/workflow-state.d.ts.map +1 -0
  137. package/dist/types/state/workflow-state.js +52 -0
  138. package/dist/types/state/workflow-state.js.map +1 -0
  139. package/dist/types/validation/schema.d.ts +14 -0
  140. package/dist/types/validation/schema.d.ts.map +1 -0
  141. package/dist/types/validation/schema.js +37 -0
  142. package/dist/types/validation/schema.js.map +1 -0
  143. package/dist/types/workflow.d.ts +2179 -0
  144. package/dist/types/workflow.d.ts.map +1 -0
  145. package/dist/types/workflow.js +132 -0
  146. package/dist/types/workflow.js.map +1 -0
  147. package/dist/utils/index.d.ts +2 -0
  148. package/dist/utils/index.d.ts.map +1 -0
  149. package/dist/utils/index.js +18 -0
  150. package/dist/utils/index.js.map +1 -0
  151. package/dist/utils/template/index.d.ts +39 -0
  152. package/dist/utils/template/index.d.ts.map +1 -0
  153. package/dist/utils/template/index.js +151 -0
  154. package/dist/utils/template/index.js.map +1 -0
  155. package/package.json +73 -0
package/README.md ADDED
@@ -0,0 +1,323 @@
1
+ # @graph-compose/core
2
+
3
+ Welcome! 👋 This package provides the foundational building blocks for Graph Compose: the core TypeScript types, Zod schemas, and validation logic needed to create type-safe and robust workflow graphs.
4
+
5
+ > **Note:** This package provides the core definitions (TypeScript types, Zod schemas) for workflows. If you want a fluent builder API to programmatically construct and execute workflows, please use the `@graph-compose/client` package instead. This `@graph-compose/core` package is intended for developers who need to interact directly with the underlying workflow structure definitions or build custom tooling.
6
+
7
+ ## Table of Contents
8
+
9
+ - [Overview](#overview)
10
+ - [Installation](#installation)
11
+ - [Core Concept: The Workflow Graph](#core-concept-the-workflow-graph)
12
+ - [Key Components](#key-components)
13
+ - [Nodes](#nodes)
14
+ - [HTTP Nodes](#http-nodes)
15
+ - [Agent Nodes](#agent-nodes)
16
+ - [Error Boundary Nodes](#error-boundary-nodes)
17
+ - [Iterator Nodes](#iterator-nodes)
18
+ - [Destination Nodes](#destination-nodes)
19
+ - [Tools](#tools)
20
+ - [HTTP Tools](#http-tools)
21
+ - [Graph Tools](#graph-tools)
22
+ - [Validation & Type Safety](#validation--type-safety)
23
+ - [Expressions](#expressions)
24
+ - [API Reference & Documentation](#api-reference--documentation)
25
+ - [Contributing](#contributing)
26
+ - [License](#license)
27
+
28
+ ## Overview
29
+
30
+ The `@graph-compose/core` package helps you:
31
+
32
+ * 🧩 **Define Workflows:** Structure your workflows using Nodes and Edges.
33
+ * 🛡️ **Ensure Type Safety:** Leverage TypeScript types derived directly from validation schemas.
34
+ * ✅ **Validate Runtime Data:** Use powerful Zod schemas to ensure your workflow configurations are correct *before* they run.
35
+ * 🔧 **Configure Nodes:** Define HTTP requests, agent behaviors, error handling, and more within nodes.
36
+ * 🛠️ **Define Tools:** Create reusable tools (like HTTP calls or sub-graphs) for Agent nodes.
37
+ * 🔄 **Use Expressions:** Safely embed dynamic values using `{{ }}` syntax within configurations (e.g., for URLs, headers).
38
+
39
+ ## API Reference & Documentation
40
+
41
+ > **Note:** This document focuses specifically on the `@graph-compose/client` SDK for building workflows programmatically. For broader platform documentation, conceptual guides, API schemas, and examples, please visit the main Graph Compose site: [graphcompose.io](https://graphcompose.io).
42
+
43
+ * **Guides & Overviews:** For conceptual guides, integration examples, and broader platform documentation, visit the main Graph Compose documentation site: [graphcompose.io/docs](https://graphcompose.io/docs).
44
+ * **Workflow API Schemas:** For the definitive source of truth on the backend Workflow API request/response schemas (based on Zod/OpenAPI), see: [graphcompose.io/workflows](https://graphcompose.io/workflows).
45
+
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ npm install @graph-compose/core
51
+ # or
52
+ yarn add @graph-compose/core
53
+ ```
54
+
55
+ ## Core Concept: The Workflow Graph
56
+
57
+ Everything revolves around defining a `WorkflowGraph`. This object describes the structure and components of your workflow. You'll typically import the `WorkflowGraphSchema` to define and validate your graph.
58
+
59
+ A `WorkflowGraph` primarily consists of:
60
+
61
+ * `nodes`: An array defining the steps or operations in your workflow.
62
+ * `tools` (optional): An array of reusable tools, often used by `AgentNode`s.
63
+ * `webhookUrl` (optional): A URL to notify upon workflow completion.
64
+ * `context` (optional): Initial data available to the workflow run.
65
+ * `meta` (optional): Additional metadata about the workflow.
66
+
67
+ ```typescript
68
+ import { WorkflowGraphSchema, NodeSchema, ToolNodeSchema } from '@graph-compose/core';
69
+ import { z } from 'zod';
70
+
71
+ // Define the structure of your workflow
72
+ const myWorkflowData = {
73
+ nodes: [
74
+ // ... your node definitions go here using NodeSchema ...
75
+ {
76
+ id: 'start-node',
77
+ type: 'http', // Example: An HTTP request node
78
+ dependencies: [],
79
+ http: {
80
+ config: {
81
+ method: 'POST',
82
+ url: 'https://api.example.com/data',
83
+ headers: { 'Content-Type': 'application/json' },
84
+ body: { userId: '{{ context.userId }}' } // Example expression
85
+ }
86
+ }
87
+ },
88
+ // ... other nodes
89
+ ],
90
+ tools: [
91
+ // ... your tool definitions go here using ToolNodeSchema ...
92
+ {
93
+ id: 'fetch-user-tool',
94
+ type: 'http',
95
+ description: 'Fetches user data',
96
+ http: {
97
+ config: {
98
+ method: 'GET',
99
+ url: 'https://api.example.com/users/{{ toolInput.userId }}'
100
+ }
101
+ }
102
+ },
103
+ // ... other tools
104
+ ],
105
+ context: {
106
+ initialUserId: 'user-123'
107
+ },
108
+ webhookUrl: 'https://my-service.com/workflow-updates'
109
+ };
110
+
111
+ // Validate your workflow definition
112
+ try {
113
+ const validatedWorkflow = WorkflowGraphSchema.parse(myWorkflowData);
114
+ console.log("Workflow definition is valid!");
115
+ // You can now use validatedWorkflow with confidence
116
+ } catch (error) {
117
+ if (error instanceof z.ZodError) {
118
+ console.error("Workflow validation failed:", error.errors);
119
+ } else {
120
+ console.error("An unexpected error occurred:", error);
121
+ }
122
+ }
123
+
124
+ // Get the inferred TypeScript type
125
+ type MyWorkflow = z.infer<typeof WorkflowGraphSchema>;
126
+ ```
127
+
128
+ ## Key Components
129
+
130
+ ### Nodes
131
+
132
+ Nodes are the individual steps in your workflow. Each node has an `id`, a `type`, and configuration specific to its type. Nodes typically declare their `dependencies` using the IDs of other nodes.
133
+
134
+ #### HTTP Nodes
135
+
136
+ HTTP nodes (`HttpNodeSchema`) make HTTP requests to external APIs or services.
137
+
138
+ ```typescript
139
+ {
140
+ id: 'fetch-data',
141
+ type: 'http',
142
+ dependencies: ['auth-node'],
143
+ http: {
144
+ config: {
145
+ method: 'GET',
146
+ url: 'https://api.example.com/data',
147
+ headers: {
148
+ 'Authorization': 'Bearer {{ auth-node.accessToken }}'
149
+ }
150
+ }
151
+ }
152
+ }
153
+ ```
154
+
155
+ #### Agent Nodes
156
+
157
+ Agent nodes (`AgentNodeSchema`) can use AI agents with access to tools to perform complex tasks.
158
+
159
+ ```typescript
160
+ {
161
+ id: 'data-analysis-agent',
162
+ type: 'agent',
163
+ dependencies: ['fetch-data'],
164
+ tools: ['weather-tool', 'calculate-tool'],
165
+ http: {
166
+ config: {
167
+ max_iterations: 5, // Maximum number of agent thinking cycles
168
+ // Other agent configuration
169
+ }
170
+ }
171
+ }
172
+ ```
173
+
174
+ #### Error Boundary Nodes
175
+
176
+ Error boundary nodes (`ErrorBoundaryNodeSchema`) act like try-catch blocks, handling errors from specified nodes.
177
+
178
+ ```typescript
179
+ {
180
+ id: 'api-error-handler',
181
+ type: 'error_boundary',
182
+ protectedNodes: ['fetch-data', 'process-data'],
183
+ http: {
184
+ // Configuration for handling errors
185
+ }
186
+ }
187
+ ```
188
+
189
+ #### Iterator Nodes
190
+
191
+ Iterator nodes (`IteratorNodeSchema`) process collections of items by creating virtual copies of downstream nodes for each item.
192
+
193
+ ```typescript
194
+ {
195
+ id: 'process-items',
196
+ type: 'source_iterator',
197
+ http: {
198
+ // Configuration for the iterator
199
+ },
200
+ dependencies: [] // Iterator nodes cannot have dependencies
201
+ }
202
+ ```
203
+
204
+ #### Destination Nodes
205
+
206
+ Destination nodes (`DestinationNodeSchema`) allow outputting data to specific destinations such as spreadsheets.
207
+
208
+ ```typescript
209
+ {
210
+ id: 'save-to-sheet',
211
+ type: 'destination',
212
+ dependencies: ['process-data'],
213
+ http: {
214
+ body: {
215
+ sheetId: 'your-sheet-id',
216
+ cellValues: ['{{ process-data.result }}']
217
+ }
218
+ }
219
+ }
220
+ ```
221
+
222
+ ### Tools
223
+
224
+ Tools are reusable operations that can be invoked by `AgentNode`s. There are two types of tools available:
225
+
226
+ #### HTTP Tools
227
+
228
+ HTTP tools (`HttpToolSchema`) make HTTP requests to external services.
229
+
230
+ ```typescript
231
+ {
232
+ id: 'weather-tool',
233
+ type: 'http',
234
+ description: 'Fetches weather data for a location',
235
+ http: {
236
+ config: {
237
+ method: 'GET',
238
+ url: 'https://api.weather.com/forecast/{{ toolInput.location }}'
239
+ }
240
+ }
241
+ }
242
+ ```
243
+
244
+ #### Graph Tools
245
+
246
+ Graph tools (`GraphToolSchema`) are self-contained sub-graphs composed of multiple nodes, allowing for complex operations.
247
+
248
+ ```typescript
249
+ {
250
+ id: 'data-processing-tool',
251
+ type: 'graph',
252
+ description: 'Processes complex datasets',
253
+ graph: {
254
+ nodes: [
255
+ // Array of nodes forming a sub-workflow
256
+ {
257
+ id: 'fetch-step',
258
+ type: 'http',
259
+ dependencies: [],
260
+ http: {
261
+ config: {
262
+ method: 'GET',
263
+ url: 'https://api.example.com/data/{{ toolInput.dataId }}'
264
+ }
265
+ }
266
+ },
267
+ {
268
+ id: 'transform-step',
269
+ type: 'http',
270
+ dependencies: ['fetch-step'],
271
+ http: {
272
+ // Configuration for transforming the data
273
+ }
274
+ }
275
+ ],
276
+ context: {
277
+ // Context data for the sub-graph
278
+ }
279
+ }
280
+ }
281
+ ```
282
+
283
+ ### Validation & Type Safety
284
+
285
+ This package uses [Zod](https://zod.dev/) schemas (`WorkflowGraphSchema`, `NodeSchema`, `ToolNodeSchema`, etc.) as the single source of truth. This gives you:
286
+
287
+ 1. **Runtime Validation:** Calling `.parse()` or `.safeParse()` on a schema ensures your configuration data matches the required structure *before* you attempt to use it.
288
+ 2. **TypeScript Types:** You can easily infer TypeScript types directly from the schemas (e.g., `z.infer<typeof WorkflowGraphSchema>`), ensuring your code interacting with these structures is type-safe.
289
+
290
+ ### Expressions
291
+
292
+ Graph Compose supports dynamic expressions using the `{{ }}` syntax. These expressions can reference:
293
+
294
+ - Node results: `{{ nodeId.property }}`
295
+ - Context values: `{{ context.value }}`
296
+ - Tool inputs (in tools): `{{ toolInput.value }}`
297
+
298
+ Expressions support the [JSONata](https://jsonata.org/) query language for powerful data transformation capabilities.
299
+
300
+ ```typescript
301
+ {
302
+ // Example of expressions in an HTTP config
303
+ http: {
304
+ config: {
305
+ method: 'POST',
306
+ url: 'https://api.example.com/users/{{ user-node.id }}/reports',
307
+ body: {
308
+ // Complex expression with JSONata transformation
309
+ summary: '{{ (reports-node.data).filter(status="complete").count() }}',
310
+ data: '{{ data-node.results }}'
311
+ }
312
+ }
313
+ }
314
+ }
315
+ ```
316
+
317
+ ## Contributing
318
+
319
+ Contributions are welcome! Please refer to the main repository's contribution guidelines.
320
+
321
+ ## License
322
+
323
+ This project is licensed under the MIT License. See the LICENSE file in the main repository for details.
@@ -0,0 +1,6 @@
1
+ import "zod-openapi/extend";
2
+ import { z } from "zod";
3
+ export * from "./types";
4
+ export { z };
5
+ export declare const VERSION = "1.0.0";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,CAAC;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,CAAC;AAEb,eAAO,MAAM,OAAO,UAAU,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.VERSION = exports.z = void 0;
18
+ require("zod-openapi/extend");
19
+ const zod_1 = require("zod");
20
+ Object.defineProperty(exports, "z", { enumerable: true, get: function () { return zod_1.z; } });
21
+ __exportStar(require("./types"), exports);
22
+ // Core package exports will go here
23
+ exports.VERSION = "1.0.0";
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,8BAA4B;AAE5B,6BAAwB;AAGf,kFAHA,OAAC,OAGA;AADV,0CAAwB;AAExB,oCAAoC;AACvB,QAAA,OAAO,GAAG,OAAO,CAAC"}
@@ -0,0 +1 @@
1
+ {"root":["../src/index.ts","../src/types/index.ts","../src/types/workflow.ts","../src/types/behaviors/conditions.ts","../src/types/behaviors/index.ts","../src/types/behaviors/notifications.ts","../src/types/config/activity.ts","../src/types/config/http.ts","../src/types/config/index.ts","../src/types/config/protocols.ts","../src/types/config/workflow.ts","../src/types/context/index.ts","../src/types/contracts/agents.ts","../src/types/contracts/index.ts","../src/types/contracts/tools.ts","../src/types/nodes/agents.ts","../src/types/nodes/destination.ts","../src/types/nodes/error-boundary.ts","../src/types/nodes/http.ts","../src/types/nodes/index.ts","../src/types/nodes/iterator.ts","../src/types/nodes/tools.ts","../src/types/nodes/common/base-node-schema.ts","../src/types/nodes/common/index.ts","../src/types/primitives/index.ts","../src/types/primitives/shared.ts","../src/types/results/agent.ts","../src/types/results/base.ts","../src/types/results/index.ts","../src/types/results/node.ts","../src/types/results/shared.ts","../src/types/results/source.ts","../src/types/results/tool.ts","../src/types/state/index.ts","../src/types/state/workflow-state.ts","../src/types/validation/schema.ts","../src/utils/index.ts","../src/utils/template/index.ts"],"version":"5.8.3"}
@@ -0,0 +1,54 @@
1
+ import { z } from "zod";
2
+ export declare const JSONataExpressionSchema: z.ZodEffects<z.ZodString, string, string>;
3
+ export declare const TemplatedExpressionSchema: z.ZodEffects<z.ZodString, string, string>;
4
+ export declare const FlowControlSchema: z.ZodObject<{
5
+ to: z.ZodString;
6
+ when: z.ZodEffects<z.ZodString, string, string>;
7
+ }, "strip", z.ZodTypeAny, {
8
+ to: string;
9
+ when: string;
10
+ }, {
11
+ to: string;
12
+ when: string;
13
+ }>;
14
+ export declare const NodeConditionsSchema: z.ZodObject<{
15
+ continueTo: z.ZodEffects<z.ZodOptional<z.ZodArray<z.ZodObject<{
16
+ to: z.ZodString;
17
+ when: z.ZodEffects<z.ZodString, string, string>;
18
+ }, "strip", z.ZodTypeAny, {
19
+ to: string;
20
+ when: string;
21
+ }, {
22
+ to: string;
23
+ when: string;
24
+ }>, "many">>, {
25
+ to: string;
26
+ when: string;
27
+ }[] | undefined, {
28
+ to: string;
29
+ when: string;
30
+ }[] | undefined>;
31
+ terminateWhen: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
32
+ pollUntil: z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>;
33
+ }, "strip", z.ZodTypeAny, {
34
+ continueTo?: {
35
+ to: string;
36
+ when: string;
37
+ }[] | undefined;
38
+ terminateWhen?: string[] | undefined;
39
+ pollUntil?: string[] | undefined;
40
+ }, {
41
+ continueTo?: {
42
+ to: string;
43
+ when: string;
44
+ }[] | undefined;
45
+ terminateWhen?: string[] | undefined;
46
+ pollUntil?: string[] | undefined;
47
+ }>;
48
+ export type FlowControl = z.infer<typeof FlowControlSchema>;
49
+ export type NodeConditions = z.infer<typeof NodeConditionsSchema>;
50
+ export type DeepTemplated<T> = {
51
+ [P in keyof T]: T[P] extends string ? string : T[P] extends object ? DeepTemplated<T[P]> : T[P];
52
+ };
53
+ export declare const createTemplatedObjectSchema: <T extends z.ZodType>(schema: T) => z.ZodType<DeepTemplated<z.infer<T>>>;
54
+ //# sourceMappingURL=conditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../../src/types/behaviors/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AASxB,eAAO,MAAM,uBAAuB,2CAI/B,CAAC;AAGN,eAAO,MAAM,yBAAyB,2CAIjC,CAAC;AA2BN,eAAO,MAAM,iBAAiB;;;;;;;;;EAO5B,CAAC;AAGH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAqC7B,CAAC;AAEL,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAGlE,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;KAC5B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GAC/B,MAAM,GACN,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACjB,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACnB,CAAC,CAAC,CAAC,CAAC;CACX,CAAC;AAGF,eAAO,MAAM,2BAA2B,GAAI,CAAC,SAAS,CAAC,CAAC,OAAO,EAC7D,QAAQ,CAAC,KACR,CAAC,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAqBrC,CAAC"}
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createTemplatedObjectSchema = exports.NodeConditionsSchema = exports.FlowControlSchema = exports.TemplatedExpressionSchema = exports.JSONataExpressionSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const template_1 = require("../../utils/template");
6
+ // Base schema for pure JSONata expressions (like conditions)
7
+ exports.JSONataExpressionSchema = zod_1.z
8
+ .string()
9
+ .refine(template_1.validateJsonataExpression, val => ({
10
+ message: `Invalid JSONata expression: ${val}`,
11
+ }));
12
+ // Schema for template strings that may contain JSONata expressions
13
+ exports.TemplatedExpressionSchema = zod_1.z
14
+ .string()
15
+ .refine(template_1.validateTemplateExpression, val => ({
16
+ message: `Invalid JSONata template expression in: ${val}`,
17
+ }));
18
+ // Validates that a string is a single complete boolean template expression
19
+ const validateBooleanTemplateExpression = (value) => {
20
+ const expression = (0, template_1.extractJsonataExpression)(value);
21
+ if (!expression) {
22
+ return false; // Must be wrapped in {{ }}
23
+ }
24
+ if (!(0, template_1.validateJsonataExpression)(expression)) {
25
+ return false; // Must be valid JSONata
26
+ }
27
+ return (0, template_1.validateBooleanExpression)(expression);
28
+ };
29
+ // Base schema for JSONata boolean conditions
30
+ const BooleanTemplateConditionSchema = zod_1.z
31
+ .string()
32
+ .refine(validateBooleanTemplateExpression, val => ({
33
+ message: `Expression must be a JSONata boolean expression wrapped in {{ }}, got: ${val}`,
34
+ }))
35
+ .openapi({
36
+ description: "JSONata boolean expression in `{{ }}` that evaluates to true/false",
37
+ example: "{{ status = 'completed' }}",
38
+ });
39
+ // Defines what happens after a node completes
40
+ exports.FlowControlSchema = zod_1.z.object({
41
+ to: zod_1.z.string().openapi({
42
+ description: "ID of the next node to execute",
43
+ }),
44
+ when: BooleanTemplateConditionSchema.openapi({
45
+ description: "Boolean condition that must be true to take this path",
46
+ }),
47
+ });
48
+ // The main conditions schema that can be attached to any node
49
+ exports.NodeConditionsSchema = zod_1.z
50
+ .object({
51
+ // Control flow
52
+ continueTo: zod_1.z
53
+ .array(exports.FlowControlSchema)
54
+ .optional()
55
+ .refine(branches => {
56
+ if (!branches)
57
+ return true;
58
+ return branches.every(branch => {
59
+ if (!branch.when)
60
+ return true;
61
+ return validateBooleanTemplateExpression(branch.when);
62
+ });
63
+ }, val => ({
64
+ message: `All flow control conditions must be boolean JSONata expressions wrapped in {{ }}`,
65
+ }))
66
+ .openapi({
67
+ description: "Defines conditional branching. An ordered list of potential next nodes. The workflow transitions to the `to` node ID of the *first* entry whose `when` condition evaluates to true based on the current node's results. If no condition matches, the workflow may end or follow default downstream paths.",
68
+ }),
69
+ terminateWhen: zod_1.z.array(BooleanTemplateConditionSchema).optional().openapi({
70
+ description: "Specifies conditions under which the workflow execution should halt immediately after this node completes. \nAn array of boolean [JSONata](https://jsonata.org/) expressions wrapped in `{{ }}` (e.g., `{{ status = 'error' }}`). If *any* condition evaluates to true, the entire workflow terminates.",
71
+ }),
72
+ // Async polling - updated to require boolean expression
73
+ pollUntil: zod_1.z.array(BooleanTemplateConditionSchema).optional().openapi({
74
+ description: "Enables polling behavior. \nAn array of boolean [JSONata](https://jsonata.org/) expressions wrapped in `{{ }}` (e.g., `{{ result.jobStatus = 'COMPLETED' }}`). This node will re-execute according to its retry policy as long as *all* conditions evaluate to false. Once *all* conditions evaluate to true, the workflow proceeds.",
75
+ }),
76
+ })
77
+ .openapi({
78
+ ref: "NodeConditionsSchema",
79
+ description: "Node Conditions represent conditional logic that determines the next step in a workflow. All conditions must be boolean JSONata expressions wrapped in `{{ }}`",
80
+ "x-tags": ["Behaviors"],
81
+ });
82
+ // Helper schema for validating objects that may contain templated expressions
83
+ const createTemplatedObjectSchema = (schema) => {
84
+ const processObject = (obj) => {
85
+ if (obj instanceof zod_1.z.ZodString) {
86
+ return exports.TemplatedExpressionSchema;
87
+ }
88
+ if (obj instanceof zod_1.z.ZodObject) {
89
+ const newShape = Object.fromEntries(Object.entries(obj.shape).map(([key, value]) => [
90
+ key,
91
+ processObject(value),
92
+ ]));
93
+ return zod_1.z.object(newShape);
94
+ }
95
+ if (obj instanceof zod_1.z.ZodArray) {
96
+ return zod_1.z.array(processObject(obj.element));
97
+ }
98
+ return obj;
99
+ };
100
+ return processObject(schema);
101
+ };
102
+ exports.createTemplatedObjectSchema = createTemplatedObjectSchema;
103
+ //# sourceMappingURL=conditions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.js","sourceRoot":"","sources":["../../../src/types/behaviors/conditions.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AACxB,mDAK8B;AAE9B,6DAA6D;AAChD,QAAA,uBAAuB,GAAG,OAAC;KACrC,MAAM,EAAE;KACR,MAAM,CAAC,oCAAyB,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IACzC,OAAO,EAAE,+BAA+B,GAAG,EAAE;CAC9C,CAAC,CAAC,CAAC;AAEN,mEAAmE;AACtD,QAAA,yBAAyB,GAAG,OAAC;KACvC,MAAM,EAAE;KACR,MAAM,CAAC,qCAA0B,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;IAC1C,OAAO,EAAE,2CAA2C,GAAG,EAAE;CAC1D,CAAC,CAAC,CAAC;AAEN,2EAA2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AC5B,CAAC;QACD,IAAI,GAAG,YAAY,OAAC,CAAC,QAAQ,EAAE,CAAC;YAC9B,OAAO,OAAC,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC,CAAC;IAEF,OAAO,aAAa,CAAC,MAAM,CAAC,CAAC;AAC/B,CAAC,CAAC;AAvBW,QAAA,2BAA2B,+BAuBtC"}
@@ -0,0 +1,3 @@
1
+ export * from "./conditions";
2
+ export * from "./notifications";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/behaviors/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./conditions"), exports);
18
+ __exportStar(require("./notifications"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/behaviors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,kDAAgC"}