@lupaflow/workflow 0.1.1 → 0.1.2

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/dist/index.cjs ADDED
@@ -0,0 +1,231 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ Pipeline: () => Pipeline,
24
+ WorkflowEngine: () => WorkflowEngine,
25
+ WorkflowStep: () => WorkflowStep
26
+ });
27
+ module.exports = __toCommonJS(src_exports);
28
+
29
+ // src/step.ts
30
+ var import_agent = require("@lupaflow/agent");
31
+ var import_core = require("@lupaflow/core");
32
+ var WorkflowStep = class {
33
+ config;
34
+ result;
35
+ constructor(config) {
36
+ this.config = { ...config, id: config.id || (0, import_core.generateId)() };
37
+ }
38
+ async execute(input) {
39
+ const start = Date.now();
40
+ try {
41
+ let output;
42
+ switch (this.config.type) {
43
+ case "agent": {
44
+ if (!this.config.agent) throw new Error("Agent config required for agent step");
45
+ const agent = new import_agent.Agent(this.config.agent);
46
+ const agentInput = this.config.input || input;
47
+ const result = await agent.run(typeof agentInput === "string" ? agentInput : JSON.stringify(agentInput));
48
+ output = result.output;
49
+ break;
50
+ }
51
+ case "tool": {
52
+ if (!this.config.tool) throw new Error("Tool required for tool step");
53
+ const toolInput = this.config.input || input;
54
+ output = await this.config.tool.execute(toolInput);
55
+ break;
56
+ }
57
+ case "transform": {
58
+ if (!this.config.transform) throw new Error("Transform function required for transform step");
59
+ output = this.config.transform(input);
60
+ break;
61
+ }
62
+ case "condition": {
63
+ if (!this.config.condition) throw new Error("Condition function required for condition step");
64
+ output = this.config.condition(input);
65
+ break;
66
+ }
67
+ default: {
68
+ output = input;
69
+ }
70
+ }
71
+ const durationMs = Date.now() - start;
72
+ this.result = {
73
+ id: this.config.id,
74
+ name: this.config.name,
75
+ type: this.config.type,
76
+ status: "success",
77
+ input,
78
+ output,
79
+ durationMs
80
+ };
81
+ this.config.onComplete?.(output);
82
+ return this.result;
83
+ } catch (err) {
84
+ const durationMs = Date.now() - start;
85
+ this.result = {
86
+ id: this.config.id,
87
+ name: this.config.name,
88
+ type: this.config.type,
89
+ status: "failed",
90
+ input,
91
+ durationMs,
92
+ error: err.message
93
+ };
94
+ this.config.onError?.(err);
95
+ return this.result;
96
+ }
97
+ }
98
+ };
99
+
100
+ // src/engine.ts
101
+ var import_core2 = require("@lupaflow/core");
102
+ var import_core3 = require("@lupaflow/core");
103
+ var import_core4 = require("@lupaflow/core");
104
+ var WorkflowEngine = class _WorkflowEngine {
105
+ config;
106
+ results = [];
107
+ constructor(config) {
108
+ this.config = { ...config, id: config.id || (0, import_core2.generateId)() };
109
+ }
110
+ static fromPipeline(name, pipeline, description) {
111
+ return new _WorkflowEngine({
112
+ name,
113
+ description,
114
+ steps: pipeline.getSteps()
115
+ });
116
+ }
117
+ async run(initialInput) {
118
+ const start = Date.now();
119
+ const stepResults = [];
120
+ await import_core3.globalEventBus.emit("workflow:start", {
121
+ steps: this.config.steps.length
122
+ });
123
+ let currentInput = initialInput;
124
+ for (let i = 0; i < this.config.steps.length; i++) {
125
+ const stepConfig = this.config.steps[i];
126
+ const step = new WorkflowStep(stepConfig);
127
+ await import_core3.globalEventBus.emit("workflow:step", {
128
+ step: i + 1,
129
+ stepName: stepConfig.name,
130
+ status: "running"
131
+ });
132
+ const stepResult = await step.execute(currentInput);
133
+ stepResults.push(stepResult);
134
+ await import_core3.globalEventBus.emit("workflow:step", {
135
+ step: i + 1,
136
+ stepName: stepConfig.name,
137
+ status: stepResult.status === "success" ? "completed" : "failed"
138
+ });
139
+ if (stepResult.status === "failed") {
140
+ if (this.config.maxRetries && i < this.config.steps.length - 1) {
141
+ stepResult.status = "success";
142
+ } else {
143
+ const result2 = {
144
+ id: this.config.id,
145
+ name: this.config.name,
146
+ success: false,
147
+ steps: stepResults,
148
+ durationMs: Date.now() - start,
149
+ error: stepResult.error
150
+ };
151
+ await import_core3.globalEventBus.emit("workflow:complete", {
152
+ totalSteps: this.config.steps.length,
153
+ failedSteps: stepResults.filter((s) => s.status === "failed").length,
154
+ durationMs: result2.durationMs
155
+ });
156
+ this.config.onError?.(new import_core4.WorkflowError(stepResult.error, stepConfig.id));
157
+ this.results.push(result2);
158
+ return result2;
159
+ }
160
+ }
161
+ currentInput = stepResult.output;
162
+ }
163
+ const durationMs = Date.now() - start;
164
+ const result = {
165
+ id: this.config.id,
166
+ name: this.config.name,
167
+ success: true,
168
+ steps: stepResults,
169
+ durationMs
170
+ };
171
+ await import_core3.globalEventBus.emit("workflow:complete", {
172
+ totalSteps: this.config.steps.length,
173
+ failedSteps: 0,
174
+ durationMs
175
+ });
176
+ this.config.onComplete?.(stepResults.map((s) => s.output));
177
+ this.results.push(result);
178
+ return result;
179
+ }
180
+ };
181
+
182
+ // src/pipeline.ts
183
+ var Pipeline = class {
184
+ steps = [];
185
+ addAgent(name, config) {
186
+ this.steps.push({
187
+ id: `step-${this.steps.length + 1}`,
188
+ name,
189
+ type: "agent",
190
+ ...config
191
+ });
192
+ return this;
193
+ }
194
+ addTool(name, config) {
195
+ this.steps.push({
196
+ id: `step-${this.steps.length + 1}`,
197
+ name,
198
+ type: "tool",
199
+ ...config
200
+ });
201
+ return this;
202
+ }
203
+ addTransform(name, transform) {
204
+ this.steps.push({
205
+ id: `step-${this.steps.length + 1}`,
206
+ name,
207
+ type: "transform",
208
+ transform
209
+ });
210
+ return this;
211
+ }
212
+ addCondition(name, condition) {
213
+ this.steps.push({
214
+ id: `step-${this.steps.length + 1}`,
215
+ name,
216
+ type: "condition",
217
+ condition
218
+ });
219
+ return this;
220
+ }
221
+ getSteps() {
222
+ return [...this.steps];
223
+ }
224
+ };
225
+ // Annotate the CommonJS export names for ESM import in node:
226
+ 0 && (module.exports = {
227
+ Pipeline,
228
+ WorkflowEngine,
229
+ WorkflowStep
230
+ });
231
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/step.ts","../src/engine.ts","../src/pipeline.ts"],"sourcesContent":["export { WorkflowEngine } from \"./engine\"\nexport { WorkflowStep } from \"./step\"\nexport { Pipeline } from \"./pipeline\"\n","import type { WorkflowStepConfig, WorkflowStepResult } from \"@lupaflow/types\"\nimport { Agent } from \"@lupaflow/agent\"\nimport { generateId } from \"@lupaflow/core\"\n\nexport class WorkflowStep {\n public config: WorkflowStepConfig\n public result?: WorkflowStepResult\n\n constructor(config: WorkflowStepConfig) {\n this.config = { ...config, id: config.id || generateId() }\n }\n\n async execute(input?: unknown): Promise<WorkflowStepResult> {\n const start = Date.now()\n\n try {\n let output: unknown\n\n switch (this.config.type) {\n case \"agent\": {\n if (!this.config.agent) throw new Error(\"Agent config required for agent step\")\n const agent = new Agent(this.config.agent)\n const agentInput = this.config.input || input\n const result = await agent.run(typeof agentInput === \"string\" ? agentInput : JSON.stringify(agentInput))\n output = result.output\n break\n }\n case \"tool\": {\n if (!this.config.tool) throw new Error(\"Tool required for tool step\")\n const toolInput = this.config.input || input\n output = await this.config.tool.execute(toolInput as Record<string, unknown>)\n break\n }\n case \"transform\": {\n if (!this.config.transform) throw new Error(\"Transform function required for transform step\")\n output = this.config.transform(input)\n break\n }\n case \"condition\": {\n if (!this.config.condition) throw new Error(\"Condition function required for condition step\")\n output = this.config.condition(input)\n break\n }\n default: {\n output = input\n }\n }\n\n const durationMs = Date.now() - start\n this.result = {\n id: this.config.id,\n name: this.config.name,\n type: this.config.type,\n status: \"success\",\n input,\n output,\n durationMs,\n }\n\n this.config.onComplete?.(output)\n return this.result!\n } catch (err: any) {\n const durationMs = Date.now() - start\n this.result = {\n id: this.config.id,\n name: this.config.name,\n type: this.config.type,\n status: \"failed\",\n input,\n durationMs,\n error: err.message,\n }\n this.config.onError?.(err)\n return this.result!\n }\n }\n}\n","import type { WorkflowConfig, WorkflowResult } from \"@lupaflow/types\"\nimport { WorkflowStep } from \"./step\"\nimport { Pipeline } from \"./pipeline\"\nimport { generateId } from \"@lupaflow/core\"\nimport { globalEventBus } from \"@lupaflow/core\"\nimport { WorkflowError } from \"@lupaflow/core\"\n\nexport class WorkflowEngine {\n public config: WorkflowConfig\n public results: WorkflowResult[] = []\n\n constructor(config: WorkflowConfig) {\n this.config = { ...config, id: config.id || generateId() }\n }\n\n static fromPipeline(name: string, pipeline: Pipeline, description?: string): WorkflowEngine {\n return new WorkflowEngine({\n name,\n description,\n steps: pipeline.getSteps(),\n })\n }\n\n async run(initialInput?: unknown): Promise<WorkflowResult> {\n const start = Date.now()\n const stepResults = []\n\n await globalEventBus.emit(\"workflow:start\", {\n steps: this.config.steps.length,\n } as any)\n\n let currentInput = initialInput\n\n for (let i = 0; i < this.config.steps.length; i++) {\n const stepConfig = this.config.steps[i]\n const step = new WorkflowStep(stepConfig)\n\n await globalEventBus.emit(\"workflow:step\", {\n step: i + 1,\n stepName: stepConfig.name,\n status: \"running\",\n } as any)\n\n const stepResult = await step.execute(currentInput)\n stepResults.push(stepResult)\n\n await globalEventBus.emit(\"workflow:step\", {\n step: i + 1,\n stepName: stepConfig.name,\n status: stepResult.status === \"success\" ? \"completed\" : \"failed\",\n } as any)\n\n if (stepResult.status === \"failed\") {\n if (this.config.maxRetries && i < this.config.steps.length - 1) {\n stepResult.status = \"success\"\n } else {\n const result: WorkflowResult = {\n id: this.config.id!,\n name: this.config.name,\n success: false,\n steps: stepResults,\n durationMs: Date.now() - start,\n error: stepResult.error,\n }\n\n await globalEventBus.emit(\"workflow:complete\", {\n totalSteps: this.config.steps.length,\n failedSteps: stepResults.filter((s) => s.status === \"failed\").length,\n durationMs: result.durationMs,\n } as any)\n\n this.config.onError?.(new WorkflowError(stepResult.error!, stepConfig.id))\n this.results.push(result)\n return result\n }\n }\n\n currentInput = stepResult.output\n }\n\n const durationMs = Date.now() - start\n const result: WorkflowResult = {\n id: this.config.id!,\n name: this.config.name,\n success: true,\n steps: stepResults,\n durationMs,\n }\n\n await globalEventBus.emit(\"workflow:complete\", {\n totalSteps: this.config.steps.length,\n failedSteps: 0,\n durationMs,\n } as any)\n\n this.config.onComplete?.(stepResults.map((s) => s.output))\n this.results.push(result)\n return result\n }\n}\n","import type { WorkflowStepConfig } from \"@lupaflow/types\"\n\nexport class Pipeline {\n public steps: WorkflowStepConfig[] = []\n\n addAgent(name: string, config: Partial<WorkflowStepConfig>): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"agent\",\n ...config,\n })\n return this\n }\n\n addTool(name: string, config: Partial<WorkflowStepConfig>): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"tool\",\n ...config,\n })\n return this\n }\n\n addTransform(name: string, transform: (input: unknown) => unknown): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"transform\",\n transform,\n })\n return this\n }\n\n addCondition(name: string, condition: (input: unknown) => boolean): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"condition\",\n condition,\n })\n return this\n }\n\n getSteps(): WorkflowStepConfig[] {\n return [...this.steps]\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,mBAAsB;AACtB,kBAA2B;AAEpB,IAAM,eAAN,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,OAAO,aAAa,YAAY,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;AACzD,SAAK,QAAQ,KAAK,MAAM;AACxB,WAAO;AAAA,EACT;AACF;;;ACjGO,IAAM,WAAN,MAAe;AAAA,EACb,QAA8B,CAAC;AAAA,EAEtC,SAAS,MAAc,QAA2C;AAChE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAc,QAA2C;AAC/D,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,MAAc,WAA8C;AACvE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,MAAc,WAA8C;AACvE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,WAAiC;AAC/B,WAAO,CAAC,GAAG,KAAK,KAAK;AAAA,EACvB;AACF;","names":["import_core","result"]}
@@ -0,0 +1,27 @@
1
+ import { WorkflowStepConfig, WorkflowConfig, WorkflowResult, WorkflowStepResult } from '@lupaflow/types';
2
+
3
+ declare class Pipeline {
4
+ steps: WorkflowStepConfig[];
5
+ addAgent(name: string, config: Partial<WorkflowStepConfig>): this;
6
+ addTool(name: string, config: Partial<WorkflowStepConfig>): this;
7
+ addTransform(name: string, transform: (input: unknown) => unknown): this;
8
+ addCondition(name: string, condition: (input: unknown) => boolean): this;
9
+ getSteps(): WorkflowStepConfig[];
10
+ }
11
+
12
+ declare class WorkflowEngine {
13
+ config: WorkflowConfig;
14
+ results: WorkflowResult[];
15
+ constructor(config: WorkflowConfig);
16
+ static fromPipeline(name: string, pipeline: Pipeline, description?: string): WorkflowEngine;
17
+ run(initialInput?: unknown): Promise<WorkflowResult>;
18
+ }
19
+
20
+ declare class WorkflowStep {
21
+ config: WorkflowStepConfig;
22
+ result?: WorkflowStepResult;
23
+ constructor(config: WorkflowStepConfig);
24
+ execute(input?: unknown): Promise<WorkflowStepResult>;
25
+ }
26
+
27
+ export { Pipeline, WorkflowEngine, WorkflowStep };
@@ -0,0 +1,27 @@
1
+ import { WorkflowStepConfig, WorkflowConfig, WorkflowResult, WorkflowStepResult } from '@lupaflow/types';
2
+
3
+ declare class Pipeline {
4
+ steps: WorkflowStepConfig[];
5
+ addAgent(name: string, config: Partial<WorkflowStepConfig>): this;
6
+ addTool(name: string, config: Partial<WorkflowStepConfig>): this;
7
+ addTransform(name: string, transform: (input: unknown) => unknown): this;
8
+ addCondition(name: string, condition: (input: unknown) => boolean): this;
9
+ getSteps(): WorkflowStepConfig[];
10
+ }
11
+
12
+ declare class WorkflowEngine {
13
+ config: WorkflowConfig;
14
+ results: WorkflowResult[];
15
+ constructor(config: WorkflowConfig);
16
+ static fromPipeline(name: string, pipeline: Pipeline, description?: string): WorkflowEngine;
17
+ run(initialInput?: unknown): Promise<WorkflowResult>;
18
+ }
19
+
20
+ declare class WorkflowStep {
21
+ config: WorkflowStepConfig;
22
+ result?: WorkflowStepResult;
23
+ constructor(config: WorkflowStepConfig);
24
+ execute(input?: unknown): Promise<WorkflowStepResult>;
25
+ }
26
+
27
+ export { Pipeline, WorkflowEngine, WorkflowStep };
package/dist/index.js ADDED
@@ -0,0 +1,202 @@
1
+ // src/step.ts
2
+ import { Agent } from "@lupaflow/agent";
3
+ import { generateId } from "@lupaflow/core";
4
+ var WorkflowStep = class {
5
+ config;
6
+ result;
7
+ constructor(config) {
8
+ this.config = { ...config, id: config.id || generateId() };
9
+ }
10
+ async execute(input) {
11
+ const start = Date.now();
12
+ try {
13
+ let output;
14
+ switch (this.config.type) {
15
+ case "agent": {
16
+ if (!this.config.agent) throw new Error("Agent config required for agent step");
17
+ const agent = new Agent(this.config.agent);
18
+ const agentInput = this.config.input || input;
19
+ const result = await agent.run(typeof agentInput === "string" ? agentInput : JSON.stringify(agentInput));
20
+ output = result.output;
21
+ break;
22
+ }
23
+ case "tool": {
24
+ if (!this.config.tool) throw new Error("Tool required for tool step");
25
+ const toolInput = this.config.input || input;
26
+ output = await this.config.tool.execute(toolInput);
27
+ break;
28
+ }
29
+ case "transform": {
30
+ if (!this.config.transform) throw new Error("Transform function required for transform step");
31
+ output = this.config.transform(input);
32
+ break;
33
+ }
34
+ case "condition": {
35
+ if (!this.config.condition) throw new Error("Condition function required for condition step");
36
+ output = this.config.condition(input);
37
+ break;
38
+ }
39
+ default: {
40
+ output = input;
41
+ }
42
+ }
43
+ const durationMs = Date.now() - start;
44
+ this.result = {
45
+ id: this.config.id,
46
+ name: this.config.name,
47
+ type: this.config.type,
48
+ status: "success",
49
+ input,
50
+ output,
51
+ durationMs
52
+ };
53
+ this.config.onComplete?.(output);
54
+ return this.result;
55
+ } catch (err) {
56
+ const durationMs = Date.now() - start;
57
+ this.result = {
58
+ id: this.config.id,
59
+ name: this.config.name,
60
+ type: this.config.type,
61
+ status: "failed",
62
+ input,
63
+ durationMs,
64
+ error: err.message
65
+ };
66
+ this.config.onError?.(err);
67
+ return this.result;
68
+ }
69
+ }
70
+ };
71
+
72
+ // src/engine.ts
73
+ import { generateId as generateId2 } from "@lupaflow/core";
74
+ import { globalEventBus } from "@lupaflow/core";
75
+ import { WorkflowError } from "@lupaflow/core";
76
+ var WorkflowEngine = class _WorkflowEngine {
77
+ config;
78
+ results = [];
79
+ constructor(config) {
80
+ this.config = { ...config, id: config.id || generateId2() };
81
+ }
82
+ static fromPipeline(name, pipeline, description) {
83
+ return new _WorkflowEngine({
84
+ name,
85
+ description,
86
+ steps: pipeline.getSteps()
87
+ });
88
+ }
89
+ async run(initialInput) {
90
+ const start = Date.now();
91
+ const stepResults = [];
92
+ await globalEventBus.emit("workflow:start", {
93
+ steps: this.config.steps.length
94
+ });
95
+ let currentInput = initialInput;
96
+ for (let i = 0; i < this.config.steps.length; i++) {
97
+ const stepConfig = this.config.steps[i];
98
+ const step = new WorkflowStep(stepConfig);
99
+ await globalEventBus.emit("workflow:step", {
100
+ step: i + 1,
101
+ stepName: stepConfig.name,
102
+ status: "running"
103
+ });
104
+ const stepResult = await step.execute(currentInput);
105
+ stepResults.push(stepResult);
106
+ await globalEventBus.emit("workflow:step", {
107
+ step: i + 1,
108
+ stepName: stepConfig.name,
109
+ status: stepResult.status === "success" ? "completed" : "failed"
110
+ });
111
+ if (stepResult.status === "failed") {
112
+ if (this.config.maxRetries && i < this.config.steps.length - 1) {
113
+ stepResult.status = "success";
114
+ } else {
115
+ const result2 = {
116
+ id: this.config.id,
117
+ name: this.config.name,
118
+ success: false,
119
+ steps: stepResults,
120
+ durationMs: Date.now() - start,
121
+ error: stepResult.error
122
+ };
123
+ await globalEventBus.emit("workflow:complete", {
124
+ totalSteps: this.config.steps.length,
125
+ failedSteps: stepResults.filter((s) => s.status === "failed").length,
126
+ durationMs: result2.durationMs
127
+ });
128
+ this.config.onError?.(new WorkflowError(stepResult.error, stepConfig.id));
129
+ this.results.push(result2);
130
+ return result2;
131
+ }
132
+ }
133
+ currentInput = stepResult.output;
134
+ }
135
+ const durationMs = Date.now() - start;
136
+ const result = {
137
+ id: this.config.id,
138
+ name: this.config.name,
139
+ success: true,
140
+ steps: stepResults,
141
+ durationMs
142
+ };
143
+ await globalEventBus.emit("workflow:complete", {
144
+ totalSteps: this.config.steps.length,
145
+ failedSteps: 0,
146
+ durationMs
147
+ });
148
+ this.config.onComplete?.(stepResults.map((s) => s.output));
149
+ this.results.push(result);
150
+ return result;
151
+ }
152
+ };
153
+
154
+ // src/pipeline.ts
155
+ var Pipeline = class {
156
+ steps = [];
157
+ addAgent(name, config) {
158
+ this.steps.push({
159
+ id: `step-${this.steps.length + 1}`,
160
+ name,
161
+ type: "agent",
162
+ ...config
163
+ });
164
+ return this;
165
+ }
166
+ addTool(name, config) {
167
+ this.steps.push({
168
+ id: `step-${this.steps.length + 1}`,
169
+ name,
170
+ type: "tool",
171
+ ...config
172
+ });
173
+ return this;
174
+ }
175
+ addTransform(name, transform) {
176
+ this.steps.push({
177
+ id: `step-${this.steps.length + 1}`,
178
+ name,
179
+ type: "transform",
180
+ transform
181
+ });
182
+ return this;
183
+ }
184
+ addCondition(name, condition) {
185
+ this.steps.push({
186
+ id: `step-${this.steps.length + 1}`,
187
+ name,
188
+ type: "condition",
189
+ condition
190
+ });
191
+ return this;
192
+ }
193
+ getSteps() {
194
+ return [...this.steps];
195
+ }
196
+ };
197
+ export {
198
+ Pipeline,
199
+ WorkflowEngine,
200
+ WorkflowStep
201
+ };
202
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/step.ts","../src/engine.ts","../src/pipeline.ts"],"sourcesContent":["import type { WorkflowStepConfig, WorkflowStepResult } from \"@lupaflow/types\"\nimport { Agent } from \"@lupaflow/agent\"\nimport { generateId } from \"@lupaflow/core\"\n\nexport class WorkflowStep {\n public config: WorkflowStepConfig\n public result?: WorkflowStepResult\n\n constructor(config: WorkflowStepConfig) {\n this.config = { ...config, id: config.id || generateId() }\n }\n\n async execute(input?: unknown): Promise<WorkflowStepResult> {\n const start = Date.now()\n\n try {\n let output: unknown\n\n switch (this.config.type) {\n case \"agent\": {\n if (!this.config.agent) throw new Error(\"Agent config required for agent step\")\n const agent = new Agent(this.config.agent)\n const agentInput = this.config.input || input\n const result = await agent.run(typeof agentInput === \"string\" ? agentInput : JSON.stringify(agentInput))\n output = result.output\n break\n }\n case \"tool\": {\n if (!this.config.tool) throw new Error(\"Tool required for tool step\")\n const toolInput = this.config.input || input\n output = await this.config.tool.execute(toolInput as Record<string, unknown>)\n break\n }\n case \"transform\": {\n if (!this.config.transform) throw new Error(\"Transform function required for transform step\")\n output = this.config.transform(input)\n break\n }\n case \"condition\": {\n if (!this.config.condition) throw new Error(\"Condition function required for condition step\")\n output = this.config.condition(input)\n break\n }\n default: {\n output = input\n }\n }\n\n const durationMs = Date.now() - start\n this.result = {\n id: this.config.id,\n name: this.config.name,\n type: this.config.type,\n status: \"success\",\n input,\n output,\n durationMs,\n }\n\n this.config.onComplete?.(output)\n return this.result!\n } catch (err: any) {\n const durationMs = Date.now() - start\n this.result = {\n id: this.config.id,\n name: this.config.name,\n type: this.config.type,\n status: \"failed\",\n input,\n durationMs,\n error: err.message,\n }\n this.config.onError?.(err)\n return this.result!\n }\n }\n}\n","import type { WorkflowConfig, WorkflowResult } from \"@lupaflow/types\"\nimport { WorkflowStep } from \"./step\"\nimport { Pipeline } from \"./pipeline\"\nimport { generateId } from \"@lupaflow/core\"\nimport { globalEventBus } from \"@lupaflow/core\"\nimport { WorkflowError } from \"@lupaflow/core\"\n\nexport class WorkflowEngine {\n public config: WorkflowConfig\n public results: WorkflowResult[] = []\n\n constructor(config: WorkflowConfig) {\n this.config = { ...config, id: config.id || generateId() }\n }\n\n static fromPipeline(name: string, pipeline: Pipeline, description?: string): WorkflowEngine {\n return new WorkflowEngine({\n name,\n description,\n steps: pipeline.getSteps(),\n })\n }\n\n async run(initialInput?: unknown): Promise<WorkflowResult> {\n const start = Date.now()\n const stepResults = []\n\n await globalEventBus.emit(\"workflow:start\", {\n steps: this.config.steps.length,\n } as any)\n\n let currentInput = initialInput\n\n for (let i = 0; i < this.config.steps.length; i++) {\n const stepConfig = this.config.steps[i]\n const step = new WorkflowStep(stepConfig)\n\n await globalEventBus.emit(\"workflow:step\", {\n step: i + 1,\n stepName: stepConfig.name,\n status: \"running\",\n } as any)\n\n const stepResult = await step.execute(currentInput)\n stepResults.push(stepResult)\n\n await globalEventBus.emit(\"workflow:step\", {\n step: i + 1,\n stepName: stepConfig.name,\n status: stepResult.status === \"success\" ? \"completed\" : \"failed\",\n } as any)\n\n if (stepResult.status === \"failed\") {\n if (this.config.maxRetries && i < this.config.steps.length - 1) {\n stepResult.status = \"success\"\n } else {\n const result: WorkflowResult = {\n id: this.config.id!,\n name: this.config.name,\n success: false,\n steps: stepResults,\n durationMs: Date.now() - start,\n error: stepResult.error,\n }\n\n await globalEventBus.emit(\"workflow:complete\", {\n totalSteps: this.config.steps.length,\n failedSteps: stepResults.filter((s) => s.status === \"failed\").length,\n durationMs: result.durationMs,\n } as any)\n\n this.config.onError?.(new WorkflowError(stepResult.error!, stepConfig.id))\n this.results.push(result)\n return result\n }\n }\n\n currentInput = stepResult.output\n }\n\n const durationMs = Date.now() - start\n const result: WorkflowResult = {\n id: this.config.id!,\n name: this.config.name,\n success: true,\n steps: stepResults,\n durationMs,\n }\n\n await globalEventBus.emit(\"workflow:complete\", {\n totalSteps: this.config.steps.length,\n failedSteps: 0,\n durationMs,\n } as any)\n\n this.config.onComplete?.(stepResults.map((s) => s.output))\n this.results.push(result)\n return result\n }\n}\n","import type { WorkflowStepConfig } from \"@lupaflow/types\"\n\nexport class Pipeline {\n public steps: WorkflowStepConfig[] = []\n\n addAgent(name: string, config: Partial<WorkflowStepConfig>): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"agent\",\n ...config,\n })\n return this\n }\n\n addTool(name: string, config: Partial<WorkflowStepConfig>): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"tool\",\n ...config,\n })\n return this\n }\n\n addTransform(name: string, transform: (input: unknown) => unknown): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"transform\",\n transform,\n })\n return this\n }\n\n addCondition(name: string, condition: (input: unknown) => boolean): this {\n this.steps.push({\n id: `step-${this.steps.length + 1}`,\n name,\n type: \"condition\",\n condition,\n })\n return this\n }\n\n getSte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,qBAAqB;AAAA,MAC7C,YAAY,KAAK,OAAO,MAAM;AAAA,MAC9B,aAAa;AAAA,MACb;AAAA,IACF,CAAQ;AAER,SAAK,OAAO,aAAa,YAAY,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC;AACzD,SAAK,QAAQ,KAAK,MAAM;AACxB,WAAO;AAAA,EACT;AACF;;;ACjGO,IAAM,WAAN,MAAe;AAAA,EACb,QAA8B,CAAC;AAAA,EAEtC,SAAS,MAAc,QAA2C;AAChE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,QAAQ,MAAc,QAA2C;AAC/D,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN,GAAG;AAAA,IACL,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,MAAc,WAA8C;AACvE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,aAAa,MAAc,WAA8C;AACvE,SAAK,MAAM,KAAK;AAAA,MACd,IAAI,QAAQ,KAAK,MAAM,SAAS,CAAC;AAAA,MACjC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT;AAAA,EAEA,WAAiC;AAC/B,WAAO,CAAC,GAAG,KAAK,KAAK;AAAA,EACvB;AACF;","names":["generateId","result"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lupaflow/workflow",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -16,7 +16,8 @@
16
16
  "import": "./dist/index.js"
17
17
  }
18
18
  },
19
- "scripts": {
19
+ "files": ["dist", "src", "package.json"],
20
+ "scripts": {
20
21
  "build": "tsup",
21
22
  "dev": "tsup --watch"
22
23
  },
package/tsconfig.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "./dist",
5
- "rootDir": "./src"
6
- },
7
- "include": ["src"]
8
- }
package/tsup.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from "tsup"
2
- export default defineConfig({
3
- entry: { index: "src/index.ts" },
4
- format: ["cjs", "esm"],
5
- dts: true,
6
- sourcemap: true,
7
- clean: true,
8
- external: [/node_modules/],
9
- })