@remoraflow/core 0.1.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 (77) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +110 -0
  3. package/dist/compiler/index.d.ts +25 -0
  4. package/dist/compiler/index.d.ts.map +1 -0
  5. package/dist/compiler/passes/apply-best-practices.d.ts +19 -0
  6. package/dist/compiler/passes/apply-best-practices.d.ts.map +1 -0
  7. package/dist/compiler/passes/build-graph.d.ts +7 -0
  8. package/dist/compiler/passes/build-graph.d.ts.map +1 -0
  9. package/dist/compiler/passes/generate-constrained-tool-schemas.d.ts +4 -0
  10. package/dist/compiler/passes/generate-constrained-tool-schemas.d.ts.map +1 -0
  11. package/dist/compiler/passes/validate-control-flow.d.ts +4 -0
  12. package/dist/compiler/passes/validate-control-flow.d.ts.map +1 -0
  13. package/dist/compiler/passes/validate-foreach-target.d.ts +4 -0
  14. package/dist/compiler/passes/validate-foreach-target.d.ts.map +1 -0
  15. package/dist/compiler/passes/validate-jmespath.d.ts +4 -0
  16. package/dist/compiler/passes/validate-jmespath.d.ts.map +1 -0
  17. package/dist/compiler/passes/validate-limits.d.ts +9 -0
  18. package/dist/compiler/passes/validate-limits.d.ts.map +1 -0
  19. package/dist/compiler/passes/validate-references.d.ts +4 -0
  20. package/dist/compiler/passes/validate-references.d.ts.map +1 -0
  21. package/dist/compiler/passes/validate-tools.d.ts +4 -0
  22. package/dist/compiler/passes/validate-tools.d.ts.map +1 -0
  23. package/dist/compiler/types.d.ts +100 -0
  24. package/dist/compiler/types.d.ts.map +1 -0
  25. package/dist/compiler/utils/graph.d.ts +35 -0
  26. package/dist/compiler/utils/graph.d.ts.map +1 -0
  27. package/dist/compiler/utils/jmespath-helpers.d.ts +34 -0
  28. package/dist/compiler/utils/jmespath-helpers.d.ts.map +1 -0
  29. package/dist/compiler/utils/schema.d.ts +33 -0
  30. package/dist/compiler/utils/schema.d.ts.map +1 -0
  31. package/dist/example-tasks.d.ts +834 -0
  32. package/dist/example-tasks.d.ts.map +1 -0
  33. package/dist/executor/context.d.ts +42 -0
  34. package/dist/executor/context.d.ts.map +1 -0
  35. package/dist/executor/errors.d.ts +57 -0
  36. package/dist/executor/errors.d.ts.map +1 -0
  37. package/dist/executor/executor-types.d.ts +117 -0
  38. package/dist/executor/executor-types.d.ts.map +1 -0
  39. package/dist/executor/helpers.d.ts +21 -0
  40. package/dist/executor/helpers.d.ts.map +1 -0
  41. package/dist/executor/index.d.ts +16 -0
  42. package/dist/executor/index.d.ts.map +1 -0
  43. package/dist/executor/schema-inference.d.ts +3 -0
  44. package/dist/executor/schema-inference.d.ts.map +1 -0
  45. package/dist/executor/state.d.ts +292 -0
  46. package/dist/executor/state.d.ts.map +1 -0
  47. package/dist/executor/steps/agent-loop.d.ts +15 -0
  48. package/dist/executor/steps/agent-loop.d.ts.map +1 -0
  49. package/dist/executor/steps/end.d.ts +5 -0
  50. package/dist/executor/steps/end.d.ts.map +1 -0
  51. package/dist/executor/steps/extract-data.d.ts +15 -0
  52. package/dist/executor/steps/extract-data.d.ts.map +1 -0
  53. package/dist/executor/steps/for-each.d.ts +11 -0
  54. package/dist/executor/steps/for-each.d.ts.map +1 -0
  55. package/dist/executor/steps/llm-prompt.d.ts +13 -0
  56. package/dist/executor/steps/llm-prompt.d.ts.map +1 -0
  57. package/dist/executor/steps/sleep.d.ts +7 -0
  58. package/dist/executor/steps/sleep.d.ts.map +1 -0
  59. package/dist/executor/steps/start.d.ts +2 -0
  60. package/dist/executor/steps/start.d.ts.map +1 -0
  61. package/dist/executor/steps/switch-case.d.ts +11 -0
  62. package/dist/executor/steps/switch-case.d.ts.map +1 -0
  63. package/dist/executor/steps/tool-call.d.ts +9 -0
  64. package/dist/executor/steps/tool-call.d.ts.map +1 -0
  65. package/dist/executor/steps/wait-for-condition.d.ts +8 -0
  66. package/dist/executor/steps/wait-for-condition.d.ts.map +1 -0
  67. package/dist/generator/index.d.ts +59 -0
  68. package/dist/generator/index.d.ts.map +1 -0
  69. package/dist/generator/prompt.d.ts +6 -0
  70. package/dist/generator/prompt.d.ts.map +1 -0
  71. package/dist/lib.d.ts +15 -0
  72. package/dist/lib.d.ts.map +1 -0
  73. package/dist/lib.js +3566 -0
  74. package/dist/lib.js.map +42 -0
  75. package/dist/types.d.ts +481 -0
  76. package/dist/types.d.ts.map +1 -0
  77. package/package.json +54 -0
@@ -0,0 +1,481 @@
1
+ declare const workflowStepSchema: import("arktype/internal/variants/object.ts").ObjectType<{
2
+ id: string;
3
+ name: string;
4
+ description: string;
5
+ nextStepId?: string | undefined;
6
+ type: "tool-call";
7
+ params: {
8
+ toolName: string;
9
+ toolInput: {
10
+ [x: string]: {
11
+ type: "literal";
12
+ value: unknown;
13
+ } | {
14
+ type: "jmespath";
15
+ expression: string;
16
+ } | {
17
+ type: "template";
18
+ template: string;
19
+ };
20
+ };
21
+ };
22
+ } | {
23
+ id: string;
24
+ name: string;
25
+ description: string;
26
+ nextStepId?: string | undefined;
27
+ type: "switch-case";
28
+ params: {
29
+ switchOn: {
30
+ type: "literal";
31
+ value: unknown;
32
+ } | {
33
+ type: "jmespath";
34
+ expression: string;
35
+ } | {
36
+ type: "template";
37
+ template: string;
38
+ };
39
+ cases: {
40
+ value: {
41
+ type: "literal";
42
+ value: unknown;
43
+ } | {
44
+ type: "jmespath";
45
+ expression: string;
46
+ } | {
47
+ type: "template";
48
+ template: string;
49
+ } | {
50
+ type: "default";
51
+ };
52
+ branchBodyStepId: string;
53
+ }[];
54
+ };
55
+ } | {
56
+ id: string;
57
+ name: string;
58
+ description: string;
59
+ nextStepId?: string | undefined;
60
+ type: "for-each";
61
+ params: {
62
+ target: {
63
+ type: "literal";
64
+ value: unknown;
65
+ } | {
66
+ type: "jmespath";
67
+ expression: string;
68
+ } | {
69
+ type: "template";
70
+ template: string;
71
+ };
72
+ itemName: string;
73
+ loopBodyStepId: string;
74
+ };
75
+ } | {
76
+ id: string;
77
+ name: string;
78
+ description: string;
79
+ nextStepId?: string | undefined;
80
+ type: "llm-prompt";
81
+ params: {
82
+ prompt: string;
83
+ outputFormat: object;
84
+ };
85
+ } | {
86
+ id: string;
87
+ name: string;
88
+ description: string;
89
+ nextStepId?: string | undefined;
90
+ type: "extract-data";
91
+ params: {
92
+ sourceData: {
93
+ type: "literal";
94
+ value: unknown;
95
+ } | {
96
+ type: "jmespath";
97
+ expression: string;
98
+ } | {
99
+ type: "template";
100
+ template: string;
101
+ };
102
+ outputFormat: object;
103
+ };
104
+ } | {
105
+ id: string;
106
+ name: string;
107
+ description: string;
108
+ nextStepId?: string | undefined;
109
+ type: "sleep";
110
+ params: {
111
+ durationMs: {
112
+ type: "literal";
113
+ value: unknown;
114
+ } | {
115
+ type: "jmespath";
116
+ expression: string;
117
+ } | {
118
+ type: "template";
119
+ template: string;
120
+ };
121
+ };
122
+ } | {
123
+ id: string;
124
+ name: string;
125
+ description: string;
126
+ nextStepId?: string | undefined;
127
+ type: "wait-for-condition";
128
+ params: {
129
+ conditionStepId: string;
130
+ condition: {
131
+ type: "literal";
132
+ value: unknown;
133
+ } | {
134
+ type: "jmespath";
135
+ expression: string;
136
+ } | {
137
+ type: "template";
138
+ template: string;
139
+ };
140
+ maxAttempts?: {
141
+ type: "literal";
142
+ value: unknown;
143
+ } | {
144
+ type: "jmespath";
145
+ expression: string;
146
+ } | {
147
+ type: "template";
148
+ template: string;
149
+ } | undefined;
150
+ intervalMs?: {
151
+ type: "literal";
152
+ value: unknown;
153
+ } | {
154
+ type: "jmespath";
155
+ expression: string;
156
+ } | {
157
+ type: "template";
158
+ template: string;
159
+ } | undefined;
160
+ backoffMultiplier?: {
161
+ type: "literal";
162
+ value: unknown;
163
+ } | {
164
+ type: "jmespath";
165
+ expression: string;
166
+ } | {
167
+ type: "template";
168
+ template: string;
169
+ } | undefined;
170
+ timeoutMs?: {
171
+ type: "literal";
172
+ value: unknown;
173
+ } | {
174
+ type: "jmespath";
175
+ expression: string;
176
+ } | {
177
+ type: "template";
178
+ template: string;
179
+ } | undefined;
180
+ };
181
+ } | {
182
+ id: string;
183
+ name: string;
184
+ description: string;
185
+ nextStepId?: string | undefined;
186
+ type: "agent-loop";
187
+ params: {
188
+ instructions: string;
189
+ tools: string[];
190
+ outputFormat: object;
191
+ maxSteps?: {
192
+ type: "literal";
193
+ value: unknown;
194
+ } | {
195
+ type: "jmespath";
196
+ expression: string;
197
+ } | {
198
+ type: "template";
199
+ template: string;
200
+ } | undefined;
201
+ };
202
+ } | {
203
+ id: string;
204
+ name: string;
205
+ description: string;
206
+ nextStepId?: string | undefined;
207
+ type: "start";
208
+ } | {
209
+ id: string;
210
+ name: string;
211
+ description: string;
212
+ nextStepId?: string | undefined;
213
+ type: "end";
214
+ params?: {
215
+ output: {
216
+ type: "literal";
217
+ value: unknown;
218
+ } | {
219
+ type: "jmespath";
220
+ expression: string;
221
+ } | {
222
+ type: "template";
223
+ template: string;
224
+ };
225
+ } | undefined;
226
+ }, {}>;
227
+ /**
228
+ * ArkType schema for validating workflow definitions. Use this to validate
229
+ * workflow JSON before passing it to {@link compileWorkflow}.
230
+ */
231
+ export declare const workflowDefinitionSchema: import("arktype/internal/variants/object.ts").ObjectType<{
232
+ initialStepId: string;
233
+ steps: ({
234
+ id: string;
235
+ name: string;
236
+ description: string;
237
+ nextStepId?: string | undefined;
238
+ type: "tool-call";
239
+ params: {
240
+ toolName: string;
241
+ toolInput: {
242
+ [x: string]: {
243
+ type: "literal";
244
+ value: unknown;
245
+ } | {
246
+ type: "jmespath";
247
+ expression: string;
248
+ } | {
249
+ type: "template";
250
+ template: string;
251
+ };
252
+ };
253
+ };
254
+ } | {
255
+ id: string;
256
+ name: string;
257
+ description: string;
258
+ nextStepId?: string | undefined;
259
+ type: "switch-case";
260
+ params: {
261
+ switchOn: {
262
+ type: "literal";
263
+ value: unknown;
264
+ } | {
265
+ type: "jmespath";
266
+ expression: string;
267
+ } | {
268
+ type: "template";
269
+ template: string;
270
+ };
271
+ cases: {
272
+ value: {
273
+ type: "literal";
274
+ value: unknown;
275
+ } | {
276
+ type: "jmespath";
277
+ expression: string;
278
+ } | {
279
+ type: "template";
280
+ template: string;
281
+ } | {
282
+ type: "default";
283
+ };
284
+ branchBodyStepId: string;
285
+ }[];
286
+ };
287
+ } | {
288
+ id: string;
289
+ name: string;
290
+ description: string;
291
+ nextStepId?: string | undefined;
292
+ type: "for-each";
293
+ params: {
294
+ target: {
295
+ type: "literal";
296
+ value: unknown;
297
+ } | {
298
+ type: "jmespath";
299
+ expression: string;
300
+ } | {
301
+ type: "template";
302
+ template: string;
303
+ };
304
+ itemName: string;
305
+ loopBodyStepId: string;
306
+ };
307
+ } | {
308
+ id: string;
309
+ name: string;
310
+ description: string;
311
+ nextStepId?: string | undefined;
312
+ type: "llm-prompt";
313
+ params: {
314
+ prompt: string;
315
+ outputFormat: object;
316
+ };
317
+ } | {
318
+ id: string;
319
+ name: string;
320
+ description: string;
321
+ nextStepId?: string | undefined;
322
+ type: "extract-data";
323
+ params: {
324
+ sourceData: {
325
+ type: "literal";
326
+ value: unknown;
327
+ } | {
328
+ type: "jmespath";
329
+ expression: string;
330
+ } | {
331
+ type: "template";
332
+ template: string;
333
+ };
334
+ outputFormat: object;
335
+ };
336
+ } | {
337
+ id: string;
338
+ name: string;
339
+ description: string;
340
+ nextStepId?: string | undefined;
341
+ type: "sleep";
342
+ params: {
343
+ durationMs: {
344
+ type: "literal";
345
+ value: unknown;
346
+ } | {
347
+ type: "jmespath";
348
+ expression: string;
349
+ } | {
350
+ type: "template";
351
+ template: string;
352
+ };
353
+ };
354
+ } | {
355
+ id: string;
356
+ name: string;
357
+ description: string;
358
+ nextStepId?: string | undefined;
359
+ type: "wait-for-condition";
360
+ params: {
361
+ conditionStepId: string;
362
+ condition: {
363
+ type: "literal";
364
+ value: unknown;
365
+ } | {
366
+ type: "jmespath";
367
+ expression: string;
368
+ } | {
369
+ type: "template";
370
+ template: string;
371
+ };
372
+ maxAttempts?: {
373
+ type: "literal";
374
+ value: unknown;
375
+ } | {
376
+ type: "jmespath";
377
+ expression: string;
378
+ } | {
379
+ type: "template";
380
+ template: string;
381
+ } | undefined;
382
+ intervalMs?: {
383
+ type: "literal";
384
+ value: unknown;
385
+ } | {
386
+ type: "jmespath";
387
+ expression: string;
388
+ } | {
389
+ type: "template";
390
+ template: string;
391
+ } | undefined;
392
+ backoffMultiplier?: {
393
+ type: "literal";
394
+ value: unknown;
395
+ } | {
396
+ type: "jmespath";
397
+ expression: string;
398
+ } | {
399
+ type: "template";
400
+ template: string;
401
+ } | undefined;
402
+ timeoutMs?: {
403
+ type: "literal";
404
+ value: unknown;
405
+ } | {
406
+ type: "jmespath";
407
+ expression: string;
408
+ } | {
409
+ type: "template";
410
+ template: string;
411
+ } | undefined;
412
+ };
413
+ } | {
414
+ id: string;
415
+ name: string;
416
+ description: string;
417
+ nextStepId?: string | undefined;
418
+ type: "agent-loop";
419
+ params: {
420
+ instructions: string;
421
+ tools: string[];
422
+ outputFormat: object;
423
+ maxSteps?: {
424
+ type: "literal";
425
+ value: unknown;
426
+ } | {
427
+ type: "jmespath";
428
+ expression: string;
429
+ } | {
430
+ type: "template";
431
+ template: string;
432
+ } | undefined;
433
+ };
434
+ } | {
435
+ id: string;
436
+ name: string;
437
+ description: string;
438
+ nextStepId?: string | undefined;
439
+ type: "start";
440
+ } | {
441
+ id: string;
442
+ name: string;
443
+ description: string;
444
+ nextStepId?: string | undefined;
445
+ type: "end";
446
+ params?: {
447
+ output: {
448
+ type: "literal";
449
+ value: unknown;
450
+ } | {
451
+ type: "jmespath";
452
+ expression: string;
453
+ } | {
454
+ type: "template";
455
+ template: string;
456
+ };
457
+ } | undefined;
458
+ })[];
459
+ inputSchema?: object | undefined;
460
+ outputSchema?: object | undefined;
461
+ }, {}>;
462
+ /**
463
+ * A single step in a workflow. Each step has a type that determines its behavior:
464
+ * - `start` — entry point, declares input schema
465
+ * - `tool-call` — calls a tool with literal or expression-based arguments
466
+ * - `llm-prompt` — prompts an LLM with template string interpolation
467
+ * - `extract-data` — uses an LLM to extract structured data from unstructured source
468
+ * - `switch-case` — branches to different step chains based on an expression value
469
+ * - `for-each` — iterates over an array, executing a chain of steps per item
470
+ * - `agent-loop` — delegates work to an autonomous agent with its own tool-calling loop (use sparingly)
471
+ * - `end` — terminates a branch, optionally producing workflow output
472
+ */
473
+ export type WorkflowStep = typeof workflowStepSchema.infer;
474
+ /**
475
+ * A complete workflow definition. Contains an initial step ID and an ordered list of steps.
476
+ * Execution flow is determined by each step's `nextStepId` and branching/looping logic,
477
+ * not by the order of steps in the array.
478
+ */
479
+ export type WorkflowDefinition = typeof workflowDefinitionSchema.infer;
480
+ export {};
481
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAmMA,QAAA,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAgBvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAiBnC,CAAC;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,kBAAkB,CAAC,KAAK,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,OAAO,wBAAwB,CAAC,KAAK,CAAC"}
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@remoraflow/core",
3
+ "version": "0.1.0",
4
+ "description": "A workflow DSL for agents — compile, execute, and visualize agent workflows",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "homepage": "https://isaacwasserman.github.io/remora/",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/isaacwasserman/remora",
12
+ "directory": "packages/core"
13
+ },
14
+ "license": "GPL-3.0",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/lib.js",
19
+ "types": "./dist/lib.d.ts"
20
+ }
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "README.md",
25
+ "LICENSE"
26
+ ],
27
+ "scripts": {
28
+ "build": "bun scripts/build.ts",
29
+ "prepublishOnly": "bun run build",
30
+ "test": "bun test",
31
+ "test:e2e": "bun test src/e2e.ts"
32
+ },
33
+ "dependencies": {
34
+ "arktype": "^2.1.29",
35
+ "@jmespath-community/jmespath": "^1.3.0"
36
+ },
37
+ "peerDependencies": {
38
+ "ai": "^6.0.0",
39
+ "@ai-sdk/provider-utils": "^4.0.0"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "ai": {
43
+ "optional": true
44
+ },
45
+ "@ai-sdk/provider-utils": {
46
+ "optional": true
47
+ }
48
+ },
49
+ "devDependencies": {
50
+ "@ai-sdk/anthropic": "^3.0.50",
51
+ "@ai-sdk/openai": "^3.0.37",
52
+ "ai": "^6.0.105"
53
+ }
54
+ }