@ggakila/agentx-framework 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 (228) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/LICENSE +21 -0
  3. package/README.md +335 -0
  4. package/dist/agent/Agent.d.ts +110 -0
  5. package/dist/agent/Agent.d.ts.map +1 -0
  6. package/dist/agent/Agent.js +291 -0
  7. package/dist/agent/Agent.js.map +1 -0
  8. package/dist/agent/index.d.ts +5 -0
  9. package/dist/agent/index.d.ts.map +1 -0
  10. package/dist/agent/index.js +11 -0
  11. package/dist/agent/index.js.map +1 -0
  12. package/dist/cli/CLI.d.ts +74 -0
  13. package/dist/cli/CLI.d.ts.map +1 -0
  14. package/dist/cli/CLI.js +255 -0
  15. package/dist/cli/CLI.js.map +1 -0
  16. package/dist/cli/InteractiveSetup.d.ts +104 -0
  17. package/dist/cli/InteractiveSetup.d.ts.map +1 -0
  18. package/dist/cli/InteractiveSetup.js +2225 -0
  19. package/dist/cli/InteractiveSetup.js.map +1 -0
  20. package/dist/cli/bin.d.ts +7 -0
  21. package/dist/cli/bin.d.ts.map +1 -0
  22. package/dist/cli/bin.js +35 -0
  23. package/dist/cli/bin.js.map +1 -0
  24. package/dist/cli/commands/ProjectCommands.d.ts +23 -0
  25. package/dist/cli/commands/ProjectCommands.d.ts.map +1 -0
  26. package/dist/cli/commands/ProjectCommands.js +504 -0
  27. package/dist/cli/commands/ProjectCommands.js.map +1 -0
  28. package/dist/cli/index.d.ts +7 -0
  29. package/dist/cli/index.d.ts.map +1 -0
  30. package/dist/cli/index.js +21 -0
  31. package/dist/cli/index.js.map +1 -0
  32. package/dist/credential/CredentialManager.d.ts +112 -0
  33. package/dist/credential/CredentialManager.d.ts.map +1 -0
  34. package/dist/credential/CredentialManager.js +343 -0
  35. package/dist/credential/CredentialManager.js.map +1 -0
  36. package/dist/credential/OAuth2Manager.d.ts +206 -0
  37. package/dist/credential/OAuth2Manager.d.ts.map +1 -0
  38. package/dist/credential/OAuth2Manager.js +463 -0
  39. package/dist/credential/OAuth2Manager.js.map +1 -0
  40. package/dist/credential/index.d.ts +6 -0
  41. package/dist/credential/index.d.ts.map +1 -0
  42. package/dist/credential/index.js +16 -0
  43. package/dist/credential/index.js.map +1 -0
  44. package/dist/error/ErrorHandler.d.ts +74 -0
  45. package/dist/error/ErrorHandler.d.ts.map +1 -0
  46. package/dist/error/ErrorHandler.js +279 -0
  47. package/dist/error/ErrorHandler.js.map +1 -0
  48. package/dist/index.d.ts +30 -0
  49. package/dist/index.d.ts.map +1 -0
  50. package/dist/index.js +100 -0
  51. package/dist/index.js.map +1 -0
  52. package/dist/integrations/DatabaseTool.d.ts +149 -0
  53. package/dist/integrations/DatabaseTool.d.ts.map +1 -0
  54. package/dist/integrations/DatabaseTool.js +900 -0
  55. package/dist/integrations/DatabaseTool.js.map +1 -0
  56. package/dist/integrations/EmailTool.d.ts +142 -0
  57. package/dist/integrations/EmailTool.d.ts.map +1 -0
  58. package/dist/integrations/EmailTool.js +259 -0
  59. package/dist/integrations/EmailTool.js.map +1 -0
  60. package/dist/integrations/FileSystemTool.d.ts +153 -0
  61. package/dist/integrations/FileSystemTool.d.ts.map +1 -0
  62. package/dist/integrations/FileSystemTool.js +835 -0
  63. package/dist/integrations/FileSystemTool.js.map +1 -0
  64. package/dist/integrations/GoogleWorkspaceTool.d.ts +125 -0
  65. package/dist/integrations/GoogleWorkspaceTool.d.ts.map +1 -0
  66. package/dist/integrations/GoogleWorkspaceTool.js +765 -0
  67. package/dist/integrations/GoogleWorkspaceTool.js.map +1 -0
  68. package/dist/integrations/HttpTool.d.ts +55 -0
  69. package/dist/integrations/HttpTool.d.ts.map +1 -0
  70. package/dist/integrations/HttpTool.js +209 -0
  71. package/dist/integrations/HttpTool.js.map +1 -0
  72. package/dist/integrations/MessagingTool.d.ts +136 -0
  73. package/dist/integrations/MessagingTool.d.ts.map +1 -0
  74. package/dist/integrations/MessagingTool.js +503 -0
  75. package/dist/integrations/MessagingTool.js.map +1 -0
  76. package/dist/integrations/SchedulerTool.d.ts +147 -0
  77. package/dist/integrations/SchedulerTool.d.ts.map +1 -0
  78. package/dist/integrations/SchedulerTool.js +471 -0
  79. package/dist/integrations/SchedulerTool.js.map +1 -0
  80. package/dist/integrations/WebhookTool.d.ts +97 -0
  81. package/dist/integrations/WebhookTool.d.ts.map +1 -0
  82. package/dist/integrations/WebhookTool.js +351 -0
  83. package/dist/integrations/WebhookTool.js.map +1 -0
  84. package/dist/integrations/index.d.ts +13 -0
  85. package/dist/integrations/index.d.ts.map +1 -0
  86. package/dist/integrations/index.js +60 -0
  87. package/dist/integrations/index.js.map +1 -0
  88. package/dist/llm/LLMProvider.d.ts +83 -0
  89. package/dist/llm/LLMProvider.d.ts.map +1 -0
  90. package/dist/llm/LLMProvider.js +370 -0
  91. package/dist/llm/LLMProvider.js.map +1 -0
  92. package/dist/llm/index.d.ts +5 -0
  93. package/dist/llm/index.d.ts.map +1 -0
  94. package/dist/llm/index.js +14 -0
  95. package/dist/llm/index.js.map +1 -0
  96. package/dist/payment/PaymentProvider.d.ts +157 -0
  97. package/dist/payment/PaymentProvider.d.ts.map +1 -0
  98. package/dist/payment/PaymentProvider.js +525 -0
  99. package/dist/payment/PaymentProvider.js.map +1 -0
  100. package/dist/payment/index.d.ts +5 -0
  101. package/dist/payment/index.d.ts.map +1 -0
  102. package/dist/payment/index.js +16 -0
  103. package/dist/payment/index.js.map +1 -0
  104. package/dist/plugin/PluginManager.d.ts +156 -0
  105. package/dist/plugin/PluginManager.d.ts.map +1 -0
  106. package/dist/plugin/PluginManager.js +288 -0
  107. package/dist/plugin/PluginManager.js.map +1 -0
  108. package/dist/plugin/index.d.ts +5 -0
  109. package/dist/plugin/index.d.ts.map +1 -0
  110. package/dist/plugin/index.js +10 -0
  111. package/dist/plugin/index.js.map +1 -0
  112. package/dist/runtime/AgentXRuntime.d.ts +90 -0
  113. package/dist/runtime/AgentXRuntime.d.ts.map +1 -0
  114. package/dist/runtime/AgentXRuntime.js +469 -0
  115. package/dist/runtime/AgentXRuntime.js.map +1 -0
  116. package/dist/security/SecurityManager.d.ts +245 -0
  117. package/dist/security/SecurityManager.d.ts.map +1 -0
  118. package/dist/security/SecurityManager.js +512 -0
  119. package/dist/security/SecurityManager.js.map +1 -0
  120. package/dist/security/index.d.ts +5 -0
  121. package/dist/security/index.d.ts.map +1 -0
  122. package/dist/security/index.js +14 -0
  123. package/dist/security/index.js.map +1 -0
  124. package/dist/tool/ToolRegistry.d.ts +58 -0
  125. package/dist/tool/ToolRegistry.d.ts.map +1 -0
  126. package/dist/tool/ToolRegistry.js +173 -0
  127. package/dist/tool/ToolRegistry.js.map +1 -0
  128. package/dist/tool/ToolValidator.d.ts +41 -0
  129. package/dist/tool/ToolValidator.d.ts.map +1 -0
  130. package/dist/tool/ToolValidator.js +158 -0
  131. package/dist/tool/ToolValidator.js.map +1 -0
  132. package/dist/tool/index.d.ts +6 -0
  133. package/dist/tool/index.d.ts.map +1 -0
  134. package/dist/tool/index.js +11 -0
  135. package/dist/tool/index.js.map +1 -0
  136. package/dist/transport/BaseTransport.d.ts +66 -0
  137. package/dist/transport/BaseTransport.d.ts.map +1 -0
  138. package/dist/transport/BaseTransport.js +103 -0
  139. package/dist/transport/BaseTransport.js.map +1 -0
  140. package/dist/transport/HttpTransport.d.ts +41 -0
  141. package/dist/transport/HttpTransport.d.ts.map +1 -0
  142. package/dist/transport/HttpTransport.js +160 -0
  143. package/dist/transport/HttpTransport.js.map +1 -0
  144. package/dist/transport/LocalTransport.d.ts +40 -0
  145. package/dist/transport/LocalTransport.d.ts.map +1 -0
  146. package/dist/transport/LocalTransport.js +157 -0
  147. package/dist/transport/LocalTransport.js.map +1 -0
  148. package/dist/transport/QueueTransport.d.ts +63 -0
  149. package/dist/transport/QueueTransport.d.ts.map +1 -0
  150. package/dist/transport/QueueTransport.js +194 -0
  151. package/dist/transport/QueueTransport.js.map +1 -0
  152. package/dist/transport/StdioTransport.d.ts +51 -0
  153. package/dist/transport/StdioTransport.d.ts.map +1 -0
  154. package/dist/transport/StdioTransport.js +216 -0
  155. package/dist/transport/StdioTransport.js.map +1 -0
  156. package/dist/transport/TransportFactory.d.ts +35 -0
  157. package/dist/transport/TransportFactory.d.ts.map +1 -0
  158. package/dist/transport/TransportFactory.js +100 -0
  159. package/dist/transport/TransportFactory.js.map +1 -0
  160. package/dist/transport/index.d.ts +10 -0
  161. package/dist/transport/index.d.ts.map +1 -0
  162. package/dist/transport/index.js +19 -0
  163. package/dist/transport/index.js.map +1 -0
  164. package/dist/types/agent.d.ts +66 -0
  165. package/dist/types/agent.d.ts.map +1 -0
  166. package/dist/types/agent.js +3 -0
  167. package/dist/types/agent.js.map +1 -0
  168. package/dist/types/config.d.ts +60 -0
  169. package/dist/types/config.d.ts.map +1 -0
  170. package/dist/types/config.js +6 -0
  171. package/dist/types/config.js.map +1 -0
  172. package/dist/types/credential.d.ts +38 -0
  173. package/dist/types/credential.d.ts.map +1 -0
  174. package/dist/types/credential.js +3 -0
  175. package/dist/types/credential.js.map +1 -0
  176. package/dist/types/error.d.ts +136 -0
  177. package/dist/types/error.d.ts.map +1 -0
  178. package/dist/types/error.js +223 -0
  179. package/dist/types/error.js.map +1 -0
  180. package/dist/types/index.d.ts +10 -0
  181. package/dist/types/index.d.ts.map +1 -0
  182. package/dist/types/index.js +27 -0
  183. package/dist/types/index.js.map +1 -0
  184. package/dist/types/llm.d.ts +43 -0
  185. package/dist/types/llm.d.ts.map +1 -0
  186. package/dist/types/llm.js +3 -0
  187. package/dist/types/llm.js.map +1 -0
  188. package/dist/types/payment.d.ts +129 -0
  189. package/dist/types/payment.d.ts.map +1 -0
  190. package/dist/types/payment.js +6 -0
  191. package/dist/types/payment.js.map +1 -0
  192. package/dist/types/runtime.d.ts +31 -0
  193. package/dist/types/runtime.d.ts.map +1 -0
  194. package/dist/types/runtime.js +3 -0
  195. package/dist/types/runtime.js.map +1 -0
  196. package/dist/types/tool.d.ts +72 -0
  197. package/dist/types/tool.d.ts.map +1 -0
  198. package/dist/types/tool.js +3 -0
  199. package/dist/types/tool.js.map +1 -0
  200. package/dist/types/transport.d.ts +53 -0
  201. package/dist/types/transport.d.ts.map +1 -0
  202. package/dist/types/transport.js +3 -0
  203. package/dist/types/transport.js.map +1 -0
  204. package/dist/types/workflow.d.ts +72 -0
  205. package/dist/types/workflow.d.ts.map +1 -0
  206. package/dist/types/workflow.js +6 -0
  207. package/dist/types/workflow.js.map +1 -0
  208. package/dist/utils/factory.d.ts +14 -0
  209. package/dist/utils/factory.d.ts.map +1 -0
  210. package/dist/utils/factory.js +146 -0
  211. package/dist/utils/factory.js.map +1 -0
  212. package/dist/workflow/StateManager.d.ts +93 -0
  213. package/dist/workflow/StateManager.d.ts.map +1 -0
  214. package/dist/workflow/StateManager.js +223 -0
  215. package/dist/workflow/StateManager.js.map +1 -0
  216. package/dist/workflow/WorkflowDefinition.d.ts +49 -0
  217. package/dist/workflow/WorkflowDefinition.d.ts.map +1 -0
  218. package/dist/workflow/WorkflowDefinition.js +264 -0
  219. package/dist/workflow/WorkflowDefinition.js.map +1 -0
  220. package/dist/workflow/WorkflowExecutor.d.ts +42 -0
  221. package/dist/workflow/WorkflowExecutor.d.ts.map +1 -0
  222. package/dist/workflow/WorkflowExecutor.js +372 -0
  223. package/dist/workflow/WorkflowExecutor.js.map +1 -0
  224. package/dist/workflow/index.d.ts +7 -0
  225. package/dist/workflow/index.d.ts.map +1 -0
  226. package/dist/workflow/index.js +17 -0
  227. package/dist/workflow/index.js.map +1 -0
  228. package/package.json +122 -0
@@ -0,0 +1,372 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow Executor with DAG-based execution
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.WorkflowExecutor = void 0;
7
+ const uuid_1 = require("uuid");
8
+ const events_1 = require("events");
9
+ const error_1 = require("../types/error");
10
+ const WorkflowDefinition_1 = require("./WorkflowDefinition");
11
+ class WorkflowExecutor extends events_1.EventEmitter {
12
+ logger;
13
+ metrics;
14
+ toolExecutor;
15
+ agentExecutor;
16
+ credentialResolver;
17
+ activeExecutions = new Map();
18
+ constructor(deps) {
19
+ super();
20
+ this.logger = deps.logger;
21
+ this.metrics = deps.metrics;
22
+ this.toolExecutor = deps.toolExecutor;
23
+ this.agentExecutor = deps.agentExecutor;
24
+ this.credentialResolver = deps.credentialResolver;
25
+ }
26
+ async execute(workflow, input, parentContext) {
27
+ const executionId = (0, uuid_1.v4)();
28
+ const traceId = parentContext?.traceId || (0, uuid_1.v4)();
29
+ const execution = {
30
+ id: executionId,
31
+ workflowId: workflow.id,
32
+ status: 'pending',
33
+ input,
34
+ startedAt: new Date(),
35
+ steps: [],
36
+ context: {
37
+ variables: { ...parentContext?.variables },
38
+ metadata: { ...parentContext?.metadata },
39
+ traceId,
40
+ },
41
+ };
42
+ this.activeExecutions.set(executionId, execution);
43
+ this.emit('execution:started', execution);
44
+ this.logger.info(`Starting workflow execution: ${executionId}`, { workflowId: workflow.id, traceId });
45
+ this.metrics.increment('workflow.executions.started');
46
+ try {
47
+ execution.status = 'running';
48
+ execution.context.variables['$input'] = input;
49
+ const parallelGroups = WorkflowDefinition_1.WorkflowValidator.getParallelGroups(workflow.steps);
50
+ const stepMap = new Map(workflow.steps.map(s => [s.id, s]));
51
+ for (const group of parallelGroups) {
52
+ const groupSteps = group.map(id => stepMap.get(id));
53
+ const results = await Promise.allSettled(groupSteps.map(step => this.executeStep(step, workflow, execution)));
54
+ for (let i = 0; i < results.length; i++) {
55
+ const result = results[i];
56
+ if (result.status === 'rejected') {
57
+ const step = groupSteps[i];
58
+ const error = result.reason;
59
+ if (workflow.errorHandling?.continueOnError) {
60
+ this.logger.warn(`Step ${step.id} failed but continuing`, { error: error.message });
61
+ }
62
+ else {
63
+ throw error;
64
+ }
65
+ }
66
+ }
67
+ }
68
+ execution.status = 'completed';
69
+ execution.completedAt = new Date();
70
+ execution.output = execution.context.variables['$output'];
71
+ this.emit('execution:completed', execution);
72
+ this.logger.info(`Workflow execution completed: ${executionId}`);
73
+ this.metrics.increment('workflow.executions.completed');
74
+ }
75
+ catch (error) {
76
+ execution.status = 'failed';
77
+ execution.error = error.message;
78
+ execution.completedAt = new Date();
79
+ this.emit('execution:failed', execution);
80
+ this.logger.error(`Workflow execution failed: ${executionId}`, error);
81
+ this.metrics.increment('workflow.executions.failed');
82
+ throw error;
83
+ }
84
+ finally {
85
+ this.activeExecutions.delete(executionId);
86
+ }
87
+ return execution;
88
+ }
89
+ async executeStep(step, workflow, execution) {
90
+ const stepExecution = {
91
+ id: (0, uuid_1.v4)(),
92
+ stepId: step.id,
93
+ status: 'pending',
94
+ startedAt: new Date(),
95
+ retryCount: 0,
96
+ duration: 0,
97
+ };
98
+ execution.steps.push(stepExecution);
99
+ this.emit('step:started', { execution, step: stepExecution });
100
+ this.logger.debug(`Starting step: ${step.id}`, { executionId: execution.id });
101
+ const retryPolicy = step.retryPolicy || workflow.retryPolicy || {
102
+ maxAttempts: 1,
103
+ backoffStrategy: 'exponential',
104
+ baseDelay: 1000,
105
+ maxDelay: 30000,
106
+ };
107
+ try {
108
+ stepExecution.status = 'running';
109
+ const stepInput = this.resolveStepInput(step, execution.context);
110
+ stepExecution.input = stepInput;
111
+ const result = await this.executeWithRetry(() => this.executeStepByType(step, stepInput, execution), retryPolicy, stepExecution);
112
+ execution.context.variables[`$steps.${step.id}`] = result;
113
+ if (step.outputVariable) {
114
+ execution.context.variables[step.outputVariable] = result;
115
+ }
116
+ stepExecution.output = result;
117
+ stepExecution.status = 'completed';
118
+ stepExecution.completedAt = new Date();
119
+ stepExecution.duration = stepExecution.completedAt.getTime() - stepExecution.startedAt.getTime();
120
+ this.emit('step:completed', { execution, step: stepExecution });
121
+ this.logger.debug(`Step completed: ${step.id}`, { duration: stepExecution.duration });
122
+ this.metrics.increment('workflow.steps.completed');
123
+ }
124
+ catch (error) {
125
+ stepExecution.status = 'failed';
126
+ stepExecution.error = error.message;
127
+ stepExecution.completedAt = new Date();
128
+ stepExecution.duration = stepExecution.completedAt.getTime() - stepExecution.startedAt.getTime();
129
+ this.emit('step:failed', { execution, step: stepExecution });
130
+ this.logger.error(`Step failed: ${step.id}`, error);
131
+ this.metrics.increment('workflow.steps.failed');
132
+ throw error;
133
+ }
134
+ return stepExecution;
135
+ }
136
+ async executeStepByType(step, input, execution) {
137
+ const context = {
138
+ executionId: execution.id,
139
+ workflowId: execution.workflowId,
140
+ stepId: step.id,
141
+ credentials: {},
142
+ logger: this.logger,
143
+ metrics: this.metrics,
144
+ };
145
+ if (this.credentialResolver && step.config.credentialScope) {
146
+ context.credentials = await this.credentialResolver(step.config.credentialScope);
147
+ }
148
+ switch (step.type) {
149
+ case 'tool':
150
+ return this.executeToolStep(step, input, context);
151
+ case 'agent':
152
+ return this.executeAgentStep(step, input, context, execution);
153
+ case 'condition':
154
+ return this.executeConditionStep(step, input, execution);
155
+ case 'loop':
156
+ return this.executeLoopStep(step, input, execution);
157
+ case 'parallel':
158
+ return this.executeParallelStep(step, input, execution);
159
+ default:
160
+ throw new error_1.ValidationError(`Unknown step type: ${step.type}`, error_1.ErrorCodes.INVALID_FORMAT);
161
+ }
162
+ }
163
+ async executeToolStep(step, input, context) {
164
+ const toolName = step.config.toolName;
165
+ if (!toolName) {
166
+ throw new error_1.ValidationError('Tool step requires toolName in config', error_1.ErrorCodes.MISSING_REQUIRED_FIELD);
167
+ }
168
+ const result = await this.toolExecutor(toolName, input, context);
169
+ if (!result.success) {
170
+ throw new error_1.ExecutionError(result.error || 'Tool execution failed', error_1.ErrorCodes.STEP_FAILED, false);
171
+ }
172
+ return result.data;
173
+ }
174
+ async executeAgentStep(step, input, context, execution) {
175
+ if (!this.agentExecutor) {
176
+ throw new error_1.ExecutionError('Agent executor not configured', error_1.ErrorCodes.MISSING_CONFIG, false);
177
+ }
178
+ const goal = step.config.goal || String(input);
179
+ const agentConfig = step.config.agentConfig || {};
180
+ const result = await this.agentExecutor(agentConfig, goal, {
181
+ ...context,
182
+ executionContext: execution.context,
183
+ });
184
+ if (!result.success) {
185
+ throw new error_1.ExecutionError(result.error || 'Agent execution failed', error_1.ErrorCodes.STEP_FAILED, false);
186
+ }
187
+ return result.result;
188
+ }
189
+ async executeConditionStep(step, input, execution) {
190
+ const condition = step.config.condition;
191
+ if (!condition) {
192
+ throw new error_1.ValidationError('Condition step requires condition in config', error_1.ErrorCodes.MISSING_REQUIRED_FIELD);
193
+ }
194
+ const result = this.evaluateCondition(condition, execution.context, input);
195
+ return {
196
+ condition: result,
197
+ branch: result ? 'then' : 'else',
198
+ input,
199
+ };
200
+ }
201
+ async executeLoopStep(step, input, execution) {
202
+ const items = step.config.items || (Array.isArray(input) ? input : [input]);
203
+ const maxIterations = step.config.maxIterations || 1000;
204
+ const results = [];
205
+ for (let i = 0; i < Math.min(items.length, maxIterations); i++) {
206
+ const item = items[i];
207
+ execution.context.variables['$loop.index'] = i;
208
+ execution.context.variables['$loop.item'] = item;
209
+ execution.context.variables['$loop.isFirst'] = i === 0;
210
+ execution.context.variables['$loop.isLast'] = i === items.length - 1;
211
+ if (step.config.body) {
212
+ const bodyResult = await this.executeStepByType(step.config.body, item, execution);
213
+ results.push(bodyResult);
214
+ }
215
+ else {
216
+ results.push(item);
217
+ }
218
+ }
219
+ delete execution.context.variables['$loop.index'];
220
+ delete execution.context.variables['$loop.item'];
221
+ delete execution.context.variables['$loop.isFirst'];
222
+ delete execution.context.variables['$loop.isLast'];
223
+ return results;
224
+ }
225
+ async executeParallelStep(step, input, execution) {
226
+ const branches = step.config.branches || [];
227
+ const results = await Promise.all(branches.map(branch => this.executeStepByType(branch, input, execution)));
228
+ return results;
229
+ }
230
+ async executeWithRetry(fn, policy, stepExecution) {
231
+ let lastError;
232
+ for (let attempt = 0; attempt < policy.maxAttempts; attempt++) {
233
+ try {
234
+ return await fn();
235
+ }
236
+ catch (error) {
237
+ lastError = error;
238
+ stepExecution.retryCount = attempt + 1;
239
+ if (attempt < policy.maxAttempts - 1) {
240
+ const delay = this.calculateDelay(attempt, policy);
241
+ this.logger.debug(`Retrying step after ${delay}ms (attempt ${attempt + 1}/${policy.maxAttempts})`);
242
+ await this.sleep(delay);
243
+ }
244
+ }
245
+ }
246
+ throw lastError;
247
+ }
248
+ calculateDelay(attempt, policy) {
249
+ let delay;
250
+ switch (policy.backoffStrategy) {
251
+ case 'fixed':
252
+ delay = policy.baseDelay;
253
+ break;
254
+ case 'linear':
255
+ delay = policy.baseDelay * (attempt + 1);
256
+ break;
257
+ case 'exponential':
258
+ default:
259
+ delay = policy.baseDelay * Math.pow(2, attempt);
260
+ break;
261
+ }
262
+ return Math.min(delay, policy.maxDelay);
263
+ }
264
+ resolveStepInput(step, context) {
265
+ if (step.config.input !== undefined) {
266
+ return this.resolveValue(step.config.input, context);
267
+ }
268
+ return context.variables['$input'];
269
+ }
270
+ resolveValue(value, context) {
271
+ if (typeof value === 'string') {
272
+ const varMatch = value.match(/^\$\{(.+)\}$/);
273
+ if (varMatch) {
274
+ return this.getNestedValue(context.variables, varMatch[1]);
275
+ }
276
+ return value.replace(/\$\{([^}]+)\}/g, (_, path) => {
277
+ const resolved = this.getNestedValue(context.variables, path);
278
+ return resolved !== undefined ? String(resolved) : '';
279
+ });
280
+ }
281
+ if (Array.isArray(value)) {
282
+ return value.map(v => this.resolveValue(v, context));
283
+ }
284
+ if (value && typeof value === 'object') {
285
+ const resolved = {};
286
+ for (const [k, v] of Object.entries(value)) {
287
+ resolved[k] = this.resolveValue(v, context);
288
+ }
289
+ return resolved;
290
+ }
291
+ return value;
292
+ }
293
+ getNestedValue(obj, path) {
294
+ const parts = path.split('.');
295
+ let current = obj;
296
+ for (const part of parts) {
297
+ if (current === null || current === undefined)
298
+ return undefined;
299
+ current = current[part];
300
+ }
301
+ return current;
302
+ }
303
+ evaluateCondition(condition, context, input) {
304
+ try {
305
+ // Replace $input with the actual input value
306
+ let expr = condition;
307
+ const inputPattern = /\$input\b/g;
308
+ expr = expr.replace(inputPattern, JSON.stringify(input));
309
+ // Replace other context variables
310
+ for (const [key, value] of Object.entries(context.variables)) {
311
+ const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, String.raw `\$&`);
312
+ const pattern = new RegExp(String.raw `\$` + escapedKey + String.raw `\b`, 'g');
313
+ expr = expr.replace(pattern, JSON.stringify(value));
314
+ }
315
+ return this.safeEvaluate(expr);
316
+ }
317
+ catch {
318
+ this.logger.warn(`Failed to evaluate condition: ${condition}`);
319
+ return false;
320
+ }
321
+ }
322
+ safeEvaluate(expr) {
323
+ const comparisons = [
324
+ { op: '===', fn: (a, b) => a === b },
325
+ { op: '!==', fn: (a, b) => a !== b },
326
+ { op: '==', fn: (a, b) => a == b },
327
+ { op: '!=', fn: (a, b) => a != b },
328
+ { op: '>=', fn: (a, b) => a >= b },
329
+ { op: '<=', fn: (a, b) => a <= b },
330
+ { op: '>', fn: (a, b) => a > b },
331
+ { op: '<', fn: (a, b) => a < b },
332
+ ];
333
+ for (const { op, fn } of comparisons) {
334
+ const parts = expr.split(op);
335
+ if (parts.length === 2) {
336
+ const left = this.parseValue(parts[0].trim());
337
+ const right = this.parseValue(parts[1].trim());
338
+ return fn(left, right);
339
+ }
340
+ }
341
+ if (expr.trim() === 'true')
342
+ return true;
343
+ if (expr.trim() === 'false')
344
+ return false;
345
+ return Boolean(this.parseValue(expr.trim()));
346
+ }
347
+ parseValue(str) {
348
+ try {
349
+ return JSON.parse(str);
350
+ }
351
+ catch {
352
+ return str;
353
+ }
354
+ }
355
+ sleep(ms) {
356
+ return new Promise(resolve => setTimeout(resolve, ms));
357
+ }
358
+ async cancel(executionId) {
359
+ const execution = this.activeExecutions.get(executionId);
360
+ if (execution) {
361
+ execution.status = 'cancelled';
362
+ execution.completedAt = new Date();
363
+ this.emit('execution:cancelled', execution);
364
+ this.activeExecutions.delete(executionId);
365
+ }
366
+ }
367
+ getActiveExecutions() {
368
+ return Array.from(this.activeExecutions.values());
369
+ }
370
+ }
371
+ exports.WorkflowExecutor = WorkflowExecutor;
372
+ //# sourceMappingURL=WorkflowExecutor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"WorkflowExecutor.js","sourceRoot":"","sources":["../../src/workflow/WorkflowExecutor.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+BAAoC;AACpC,mCAAsC;AAUtC,0CAA6E;AAC7E,6DAAyD;AAUzD,MAAa,gBAAiB,SAAQ,qBAAY;IACxC,MAAM,CAAS;IACf,OAAO,CAAmB;IAC1B,YAAY,CAAuC;IACnD,aAAa,CAAyC;IACtD,kBAAkB,CAA8C;IAChE,gBAAgB,GAAmC,IAAI,GAAG,EAAE,CAAC;IAErE,YAAY,IAA0B;QACpC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,QAA4B,EAC5B,KAAe,EACf,aAAyC;QAEzC,MAAM,WAAW,GAAG,IAAA,SAAM,GAAE,CAAC;QAC7B,MAAM,OAAO,GAAG,aAAa,EAAE,OAAO,IAAI,IAAA,SAAM,GAAE,CAAC;QAEnD,MAAM,SAAS,GAAsB;YACnC,EAAE,EAAE,WAAW;YACf,UAAU,EAAE,QAAQ,CAAC,EAAE;YACvB,MAAM,EAAE,SAAS;YACjB,KAAK;YACL,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,KAAK,EAAE,EAAE;YACT,OAAO,EAAE;gBACP,SAAS,EAAE,EAAE,GAAG,aAAa,EAAE,SAAS,EAAE;gBAC1C,QAAQ,EAAE,EAAE,GAAG,aAAa,EAAE,QAAQ,EAAE;gBACxC,OAAO;aAC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CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,EAAU;QACtB,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAAmB;QAC9B,MAAM,SAAS,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACzD,IAAI,SAAS,EAAE,CAAC;YACd,SAAS,CAAC,MAAM,GAAG,WAAW,CAAC;YAC/B,SAAS,CAAC,WAAW,GAAG,IAAI,IAAI,EAAE,CAAC;YACnC,IAAI,CAAC,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;YAC5C,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,mBAAmB;QACjB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;IACpD,CAAC;CACF;AA3dD,4CA2dC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Workflow Module Exports
3
+ */
4
+ export { WorkflowDefinitionBuilder, WorkflowValidator, workflow } from './WorkflowDefinition';
5
+ export { WorkflowExecutor, ExecutorDependencies } from './WorkflowExecutor';
6
+ export { StateManager, StateStore, InMemoryStateStore, CheckpointData, IdempotencyManager } from './StateManager';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EACnB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ /**
3
+ * Workflow Module Exports
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.IdempotencyManager = exports.InMemoryStateStore = exports.StateManager = exports.WorkflowExecutor = exports.workflow = exports.WorkflowValidator = exports.WorkflowDefinitionBuilder = void 0;
7
+ var WorkflowDefinition_1 = require("./WorkflowDefinition");
8
+ Object.defineProperty(exports, "WorkflowDefinitionBuilder", { enumerable: true, get: function () { return WorkflowDefinition_1.WorkflowDefinitionBuilder; } });
9
+ Object.defineProperty(exports, "WorkflowValidator", { enumerable: true, get: function () { return WorkflowDefinition_1.WorkflowValidator; } });
10
+ Object.defineProperty(exports, "workflow", { enumerable: true, get: function () { return WorkflowDefinition_1.workflow; } });
11
+ var WorkflowExecutor_1 = require("./WorkflowExecutor");
12
+ Object.defineProperty(exports, "WorkflowExecutor", { enumerable: true, get: function () { return WorkflowExecutor_1.WorkflowExecutor; } });
13
+ var StateManager_1 = require("./StateManager");
14
+ Object.defineProperty(exports, "StateManager", { enumerable: true, get: function () { return StateManager_1.StateManager; } });
15
+ Object.defineProperty(exports, "InMemoryStateStore", { enumerable: true, get: function () { return StateManager_1.InMemoryStateStore; } });
16
+ Object.defineProperty(exports, "IdempotencyManager", { enumerable: true, get: function () { return StateManager_1.IdempotencyManager; } });
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workflow/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,2DAA8F;AAArF,+HAAA,yBAAyB,OAAA;AAAE,uHAAA,iBAAiB,OAAA;AAAE,8GAAA,QAAQ,OAAA;AAC/D,uDAA4E;AAAnE,oHAAA,gBAAgB,OAAA;AACzB,+CAMwB;AALtB,4GAAA,YAAY,OAAA;AAEZ,kHAAA,kBAAkB,OAAA;AAElB,kHAAA,kBAAkB,OAAA"}
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@ggakila/agentx-framework",
3
+ "version": "0.1.0",
4
+ "description": "Production-grade, TypeScript-based AI agent framework with native LLM integration, workflows, and 15+ built-in integrations",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "bin": {
8
+ "agentx": "./dist/cli/bin.js",
9
+ "create-agentx": "./dist/cli/bin.js"
10
+ },
11
+ "files": [
12
+ "dist/**/*",
13
+ "README.md",
14
+ "LICENSE",
15
+ "CHANGELOG.md"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc",
19
+ "dev": "tsc --watch",
20
+ "test": "jest",
21
+ "test:watch": "jest --watch",
22
+ "test:coverage": "jest --coverage",
23
+ "lint": "eslint src/**/*.ts",
24
+ "lint:fix": "eslint src/**/*.ts --fix",
25
+ "clean": "rimraf dist",
26
+ "prepublishOnly": "npm run clean && npm run build && npm test"
27
+ },
28
+ "keywords": [
29
+ "ai",
30
+ "agent",
31
+ "workflow",
32
+ "automation",
33
+ "typescript",
34
+ "llm",
35
+ "openai",
36
+ "anthropic",
37
+ "n8n-alternative",
38
+ "chatbot",
39
+ "mpesa",
40
+ "payments",
41
+ "stripe",
42
+ "paypal",
43
+ "slack",
44
+ "whatsapp",
45
+ "telegram",
46
+ "database",
47
+ "mongodb",
48
+ "postgresql",
49
+ "redis",
50
+ "aws",
51
+ "s3",
52
+ "google-workspace",
53
+ "oauth2",
54
+ "jwt",
55
+ "security",
56
+ "rbac",
57
+ "rate-limiting",
58
+ "docker",
59
+ "kubernetes",
60
+ "serverless",
61
+ "lambda",
62
+ "cli",
63
+ "framework"
64
+ ],
65
+ "author": {
66
+ "name": "AgentX Team",
67
+ "email": "team@agentx.dev",
68
+ "url": "https://agentx.dev"
69
+ },
70
+ "license": "MIT",
71
+ "repository": {
72
+ "type": "git",
73
+ "url": "https://github.com/agentx/agentx.git"
74
+ },
75
+ "homepage": "https://agentx.dev",
76
+ "bugs": {
77
+ "url": "https://github.com/agentx/agentx/issues"
78
+ },
79
+ "funding": {
80
+ "type": "opencollective",
81
+ "url": "https://opencollective.com/agentx"
82
+ },
83
+ "dependencies": {
84
+ "ajv": "^8.12.0",
85
+ "commander": "^11.1.0",
86
+ "fast-check": "^3.15.0",
87
+ "node-cron": "^3.0.3",
88
+ "axios": "^1.6.2",
89
+ "ws": "^8.14.2",
90
+ "crypto-js": "^4.2.0",
91
+ "jsonwebtoken": "^9.0.2",
92
+ "uuid": "^9.0.1"
93
+ },
94
+ "devDependencies": {
95
+ "@types/node": "^20.10.0",
96
+ "@types/jest": "^29.5.8",
97
+ "@types/ws": "^8.5.9",
98
+ "@types/crypto-js": "^4.2.1",
99
+ "@types/jsonwebtoken": "^9.0.5",
100
+ "@types/uuid": "^9.0.7",
101
+ "typescript": "^5.3.2",
102
+ "jest": "^29.7.0",
103
+ "ts-jest": "^29.1.1",
104
+ "eslint": "^8.54.0",
105
+ "@typescript-eslint/eslint-plugin": "^6.12.0",
106
+ "@typescript-eslint/parser": "^6.12.0",
107
+ "rimraf": "^5.0.5"
108
+ },
109
+ "engines": {
110
+ "node": ">=18.0.0",
111
+ "npm": ">=8.0.0"
112
+ },
113
+ "os": [
114
+ "darwin",
115
+ "linux",
116
+ "win32"
117
+ ],
118
+ "publishConfig": {
119
+ "access": "public",
120
+ "registry": "https://registry.npmjs.org/"
121
+ }
122
+ }