@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,160 @@
1
+ "use strict";
2
+ /**
3
+ * HTTP Transport Implementation
4
+ * Executes tools via REST API calls
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.HttpTransport = void 0;
11
+ const axios_1 = __importDefault(require("axios"));
12
+ const BaseTransport_1 = require("./BaseTransport");
13
+ class HttpTransport extends BaseTransport_1.BaseTransport {
14
+ name = 'http';
15
+ client;
16
+ httpConfig;
17
+ /**
18
+ * Initialize the HTTP transport
19
+ */
20
+ async initialize(config) {
21
+ await super.initialize(config);
22
+ this.httpConfig = config;
23
+ // Create axios instance
24
+ this.client = axios_1.default.create({
25
+ baseURL: config.config.baseUrl,
26
+ timeout: config.config.timeout || 30000,
27
+ headers: this.buildHeaders(config.config.authentication),
28
+ });
29
+ // Add retry interceptor
30
+ this.setupRetryInterceptor(config.config.retries || 3);
31
+ }
32
+ /**
33
+ * Build headers based on authentication config
34
+ */
35
+ buildHeaders(auth) {
36
+ const headers = {
37
+ 'Content-Type': 'application/json',
38
+ };
39
+ if (!auth) {
40
+ return headers;
41
+ }
42
+ switch (auth.type) {
43
+ case 'bearer':
44
+ headers['Authorization'] = `Bearer ${auth.credentials.token}`;
45
+ break;
46
+ case 'basic':
47
+ const basicAuth = Buffer.from(`${auth.credentials.username}:${auth.credentials.password}`).toString('base64');
48
+ headers['Authorization'] = `Basic ${basicAuth}`;
49
+ break;
50
+ case 'api_key':
51
+ headers[auth.credentials.headerName || 'X-API-Key'] = auth.credentials.key;
52
+ break;
53
+ }
54
+ return headers;
55
+ }
56
+ /**
57
+ * Setup retry interceptor
58
+ */
59
+ setupRetryInterceptor(maxRetries) {
60
+ this.client.interceptors.response.use(response => response, async (error) => {
61
+ const config = error.config;
62
+ if (!config || !config.retryCount) {
63
+ config.retryCount = 0;
64
+ }
65
+ if (config.retryCount >= maxRetries) {
66
+ return Promise.reject(error);
67
+ }
68
+ // Only retry on network errors or 5xx errors
69
+ if (!error.response || error.response.status >= 500) {
70
+ config.retryCount++;
71
+ // Exponential backoff
72
+ const delay = Math.pow(2, config.retryCount) * 1000;
73
+ await new Promise(resolve => setTimeout(resolve, delay));
74
+ return this.client(config);
75
+ }
76
+ return Promise.reject(error);
77
+ });
78
+ }
79
+ /**
80
+ * Execute a tool via HTTP
81
+ */
82
+ async execute(tool, input, context) {
83
+ this.ensureInitialized();
84
+ const startTime = Date.now();
85
+ try {
86
+ const response = await this.client.post(`/tools/${tool}/execute`, {
87
+ input,
88
+ context: {
89
+ executionId: context.executionId,
90
+ workflowId: context.workflowId,
91
+ stepId: context.stepId,
92
+ },
93
+ });
94
+ const toolResult = {
95
+ success: true,
96
+ data: response.data,
97
+ metadata: {
98
+ duration: Date.now() - startTime,
99
+ transport: 'http',
100
+ statusCode: response.status,
101
+ },
102
+ };
103
+ this.logExecution(tool, context, toolResult);
104
+ return toolResult;
105
+ }
106
+ catch (error) {
107
+ const axiosError = error;
108
+ const toolResult = this.createErrorResult(axiosError.message, {
109
+ duration: Date.now() - startTime,
110
+ transport: 'http',
111
+ statusCode: axiosError.response?.status,
112
+ errorType: axiosError.code,
113
+ });
114
+ this.logExecution(tool, context, toolResult);
115
+ return toolResult;
116
+ }
117
+ }
118
+ /**
119
+ * List tools from the remote server
120
+ */
121
+ async listTools() {
122
+ this.ensureInitialized();
123
+ try {
124
+ const response = await this.client.get('/tools');
125
+ return response.data;
126
+ }
127
+ catch (error) {
128
+ if (this.logger) {
129
+ this.logger.warn('Failed to list tools from HTTP transport', { error });
130
+ }
131
+ return [];
132
+ }
133
+ }
134
+ /**
135
+ * Health check for HTTP transport
136
+ */
137
+ async healthCheck() {
138
+ if (!this.isInitialized) {
139
+ return false;
140
+ }
141
+ try {
142
+ const response = await this.client.get('/health', { timeout: 5000 });
143
+ return response.status === 200;
144
+ }
145
+ catch {
146
+ return false;
147
+ }
148
+ }
149
+ /**
150
+ * Update authentication
151
+ */
152
+ updateAuthentication(auth) {
153
+ const headers = this.buildHeaders(auth);
154
+ for (const [key, value] of Object.entries(headers)) {
155
+ this.client.defaults.headers.common[key] = value;
156
+ }
157
+ }
158
+ }
159
+ exports.HttpTransport = HttpTransport;
160
+ //# sourceMappingURL=HttpTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HttpTransport.js","sourceRoot":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sCAiLC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Local Transport Implementation
3
+ * Executes tools in-process
4
+ */
5
+ import { BaseTransport } from './BaseTransport';
6
+ import { LocalTransportConfig } from '../types/transport';
7
+ import { ToolContext, ToolResult, ToolExecutor } from '../types/tool';
8
+ export declare class LocalTransport extends BaseTransport {
9
+ name: string;
10
+ private executors;
11
+ /**
12
+ * Initialize the local transport
13
+ */
14
+ initialize(config: LocalTransportConfig): Promise<void>;
15
+ /**
16
+ * Load a module containing tool executors
17
+ */
18
+ private loadModule;
19
+ /**
20
+ * Check if an object is a ToolExecutor
21
+ */
22
+ private isToolExecutor;
23
+ /**
24
+ * Register a tool executor
25
+ */
26
+ registerExecutor(name: string, executor: ToolExecutor): void;
27
+ /**
28
+ * Execute a tool locally
29
+ */
30
+ execute(tool: string, input: unknown, context: ToolContext): Promise<ToolResult>;
31
+ /**
32
+ * Health check for local transport
33
+ */
34
+ healthCheck(): Promise<boolean>;
35
+ /**
36
+ * Shutdown the local transport
37
+ */
38
+ shutdown(): Promise<void>;
39
+ }
40
+ //# sourceMappingURL=LocalTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalTransport.d.ts","sourceRoot":"","sources":["../../src/transport/LocalTransport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAY,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAGhF,qBAAa,cAAe,SAAQ,aAAa;IAC/C,IAAI,SAAW;IACf,OAAO,CAAC,SAAS,CAAwC;IAEzD;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAS7D;;OAEG;YACW,UAAU;IAmCxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAOtB;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI;IAI5D;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAwCtF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAIrC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAIhC"}
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ /**
3
+ * Local Transport Implementation
4
+ * Executes tools in-process
5
+ */
6
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
7
+ if (k2 === undefined) k2 = k;
8
+ var desc = Object.getOwnPropertyDescriptor(m, k);
9
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
10
+ desc = { enumerable: true, get: function() { return m[k]; } };
11
+ }
12
+ Object.defineProperty(o, k2, desc);
13
+ }) : (function(o, m, k, k2) {
14
+ if (k2 === undefined) k2 = k;
15
+ o[k2] = m[k];
16
+ }));
17
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
18
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
19
+ }) : function(o, v) {
20
+ o["default"] = v;
21
+ });
22
+ var __importStar = (this && this.__importStar) || (function () {
23
+ var ownKeys = function(o) {
24
+ ownKeys = Object.getOwnPropertyNames || function (o) {
25
+ var ar = [];
26
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
27
+ return ar;
28
+ };
29
+ return ownKeys(o);
30
+ };
31
+ return function (mod) {
32
+ if (mod && mod.__esModule) return mod;
33
+ var result = {};
34
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
35
+ __setModuleDefault(result, mod);
36
+ return result;
37
+ };
38
+ })();
39
+ Object.defineProperty(exports, "__esModule", { value: true });
40
+ exports.LocalTransport = void 0;
41
+ const BaseTransport_1 = require("./BaseTransport");
42
+ class LocalTransport extends BaseTransport_1.BaseTransport {
43
+ name = 'local';
44
+ executors = new Map();
45
+ /**
46
+ * Initialize the local transport
47
+ */
48
+ async initialize(config) {
49
+ await super.initialize(config);
50
+ // Load module if specified
51
+ if (config.config.modulePath) {
52
+ await this.loadModule(config.config.modulePath, config.config.className);
53
+ }
54
+ }
55
+ /**
56
+ * Load a module containing tool executors
57
+ */
58
+ async loadModule(modulePath, className) {
59
+ try {
60
+ const module = await Promise.resolve(`${modulePath}`).then(s => __importStar(require(s)));
61
+ if (className) {
62
+ // Load specific class
63
+ const ExecutorClass = module[className];
64
+ if (ExecutorClass) {
65
+ const executor = new ExecutorClass();
66
+ if (this.isToolExecutor(executor)) {
67
+ this.executors.set(className, executor);
68
+ }
69
+ }
70
+ }
71
+ else {
72
+ // Load all exported executors
73
+ for (const [name, value] of Object.entries(module)) {
74
+ if (typeof value === 'function') {
75
+ try {
76
+ const instance = new value();
77
+ if (this.isToolExecutor(instance)) {
78
+ this.executors.set(name, instance);
79
+ }
80
+ }
81
+ catch {
82
+ // Not a constructor or not a tool executor
83
+ }
84
+ }
85
+ }
86
+ }
87
+ }
88
+ catch (error) {
89
+ if (this.logger) {
90
+ this.logger.warn(`Failed to load module: ${modulePath}`, { error });
91
+ }
92
+ }
93
+ }
94
+ /**
95
+ * Check if an object is a ToolExecutor
96
+ */
97
+ isToolExecutor(obj) {
98
+ return obj !== null &&
99
+ typeof obj === 'object' &&
100
+ 'execute' in obj &&
101
+ typeof obj.execute === 'function';
102
+ }
103
+ /**
104
+ * Register a tool executor
105
+ */
106
+ registerExecutor(name, executor) {
107
+ this.executors.set(name, executor);
108
+ }
109
+ /**
110
+ * Execute a tool locally
111
+ */
112
+ async execute(tool, input, context) {
113
+ this.ensureInitialized();
114
+ const executor = this.executors.get(tool);
115
+ if (!executor) {
116
+ return this.createErrorResult(`Tool executor not found: ${tool}`);
117
+ }
118
+ const startTime = Date.now();
119
+ try {
120
+ const result = await executor.execute(input, context);
121
+ const toolResult = {
122
+ success: true,
123
+ data: result,
124
+ metadata: {
125
+ duration: Date.now() - startTime,
126
+ transport: 'local',
127
+ },
128
+ };
129
+ this.logExecution(tool, context, toolResult);
130
+ return toolResult;
131
+ }
132
+ catch (error) {
133
+ const toolResult = this.createErrorResult(error.message, {
134
+ duration: Date.now() - startTime,
135
+ transport: 'local',
136
+ errorType: error.name,
137
+ });
138
+ this.logExecution(tool, context, toolResult);
139
+ return toolResult;
140
+ }
141
+ }
142
+ /**
143
+ * Health check for local transport
144
+ */
145
+ async healthCheck() {
146
+ return this.isInitialized;
147
+ }
148
+ /**
149
+ * Shutdown the local transport
150
+ */
151
+ async shutdown() {
152
+ this.executors.clear();
153
+ await super.shutdown();
154
+ }
155
+ }
156
+ exports.LocalTransport = LocalTransport;
157
+ //# sourceMappingURL=LocalTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LocalTransport.js","sourceRoot":"","sources":["../../src/transport/LocalTransport.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,mDAAgD;AAKhD,MAAa,cAAe,SAAQ,6BAAa;IAC/C,IAAI,GAAG,OAAO,CAAC;IACP,SAAS,GAA8B,IAAI,GAAG,EAAE,CAAC;IAEzD;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAA4B;QAC3C,MAAM,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAE/B,2BAA2B;QAC3B,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;YAC7B,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAED;;OAEG;IACK,KAAK,CAAC,UAAU,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CAAC,IAAI;aACjC,CACF,CAAC;YAEF,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC;YAC7C,OAAO,UAAU,CAAC;QACpB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;IACzB,CAAC;CACF;AAhID,wCAgIC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Queue Transport Implementation
3
+ * Executes tools via async message queues
4
+ */
5
+ import { BaseTransport } from './BaseTransport';
6
+ import { QueueTransportConfig } from '../types/transport';
7
+ import { ToolContext, ToolResult } from '../types/tool';
8
+ export declare class QueueTransport extends BaseTransport {
9
+ name: string;
10
+ private queueConfig;
11
+ private pendingRequests;
12
+ private isPolling;
13
+ private pollInterval;
14
+ private requestQueue;
15
+ private responseQueue;
16
+ /**
17
+ * Initialize the queue transport
18
+ */
19
+ initialize(config: QueueTransportConfig): Promise<void>;
20
+ /**
21
+ * Start polling for responses
22
+ */
23
+ private startPolling;
24
+ /**
25
+ * Stop polling for responses
26
+ */
27
+ private stopPolling;
28
+ /**
29
+ * Process responses from the response queue
30
+ */
31
+ private processResponses;
32
+ /**
33
+ * Send a message to the request queue
34
+ */
35
+ private sendToQueue;
36
+ /**
37
+ * Simulate worker processing (for demonstration)
38
+ */
39
+ private simulateWorkerProcessing;
40
+ /**
41
+ * Execute a tool via queue
42
+ */
43
+ execute(tool: string, input: unknown, context: ToolContext): Promise<ToolResult>;
44
+ /**
45
+ * Health check for queue transport
46
+ */
47
+ healthCheck(): Promise<boolean>;
48
+ /**
49
+ * Shutdown the queue transport
50
+ */
51
+ shutdown(): Promise<void>;
52
+ /**
53
+ * Get queue statistics
54
+ */
55
+ getStatistics(): QueueStatistics;
56
+ }
57
+ export interface QueueStatistics {
58
+ pendingRequests: number;
59
+ requestQueueSize: number;
60
+ responseQueueSize: number;
61
+ isPolling: boolean;
62
+ }
63
+ //# sourceMappingURL=QueueTransport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueTransport.d.ts","sourceRoot":"","sources":["../../src/transport/QueueTransport.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAY,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAwBlE,qBAAa,cAAe,SAAQ,aAAa;IAC/C,IAAI,SAAW;IACf,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,eAAe,CAIR;IACf,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,YAAY,CAA+B;IAGnD,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,aAAa,CAAuB;IAE5C;;OAEG;IACG,UAAU,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ7D;;OAEG;IACH,OAAO,CAAC,YAAY;IAWpB;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAiCxB;;OAEG;YACW,WAAW;IAWzB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAYhC;;OAEG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC;IAgDtF;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IASrC;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAiB/B;;OAEG;IACH,aAAa,IAAI,eAAe;CAQjC;AAED,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;CACpB"}
@@ -0,0 +1,194 @@
1
+ "use strict";
2
+ /**
3
+ * Queue Transport Implementation
4
+ * Executes tools via async message queues
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.QueueTransport = void 0;
8
+ const BaseTransport_1 = require("./BaseTransport");
9
+ const uuid_1 = require("uuid");
10
+ class QueueTransport extends BaseTransport_1.BaseTransport {
11
+ name = 'queue';
12
+ queueConfig;
13
+ pendingRequests = new Map();
14
+ isPolling = false;
15
+ pollInterval = null;
16
+ // In-memory queue for demonstration (would be replaced with actual queue implementation)
17
+ requestQueue = [];
18
+ responseQueue = [];
19
+ /**
20
+ * Initialize the queue transport
21
+ */
22
+ async initialize(config) {
23
+ await super.initialize(config);
24
+ this.queueConfig = config;
25
+ // Start polling for responses
26
+ this.startPolling();
27
+ }
28
+ /**
29
+ * Start polling for responses
30
+ */
31
+ startPolling() {
32
+ if (this.isPolling) {
33
+ return;
34
+ }
35
+ this.isPolling = true;
36
+ this.pollInterval = setInterval(() => {
37
+ this.processResponses();
38
+ }, 100);
39
+ }
40
+ /**
41
+ * Stop polling for responses
42
+ */
43
+ stopPolling() {
44
+ this.isPolling = false;
45
+ if (this.pollInterval) {
46
+ clearInterval(this.pollInterval);
47
+ this.pollInterval = null;
48
+ }
49
+ }
50
+ /**
51
+ * Process responses from the response queue
52
+ */
53
+ processResponses() {
54
+ while (this.responseQueue.length > 0) {
55
+ const response = this.responseQueue.shift();
56
+ if (!response)
57
+ continue;
58
+ const pending = this.pendingRequests.get(response.id);
59
+ if (!pending)
60
+ continue;
61
+ clearTimeout(pending.timeout);
62
+ this.pendingRequests.delete(response.id);
63
+ if (response.success) {
64
+ pending.resolve({
65
+ success: true,
66
+ data: response.data,
67
+ metadata: {
68
+ transport: 'queue',
69
+ responseTime: Date.now() - response.timestamp,
70
+ },
71
+ });
72
+ }
73
+ else {
74
+ pending.resolve({
75
+ success: false,
76
+ error: response.error,
77
+ metadata: {
78
+ transport: 'queue',
79
+ responseTime: Date.now() - response.timestamp,
80
+ },
81
+ });
82
+ }
83
+ }
84
+ }
85
+ /**
86
+ * Send a message to the request queue
87
+ */
88
+ async sendToQueue(message) {
89
+ // In a real implementation, this would send to an actual message queue
90
+ // (e.g., RabbitMQ, AWS SQS, Redis, etc.)
91
+ this.requestQueue.push(message);
92
+ // Simulate async processing
93
+ setTimeout(() => {
94
+ this.simulateWorkerProcessing(message);
95
+ }, 50);
96
+ }
97
+ /**
98
+ * Simulate worker processing (for demonstration)
99
+ */
100
+ simulateWorkerProcessing(message) {
101
+ // In a real implementation, this would be handled by a separate worker process
102
+ const response = {
103
+ id: message.id,
104
+ success: true,
105
+ data: { processed: true, tool: message.tool },
106
+ timestamp: Date.now(),
107
+ };
108
+ this.responseQueue.push(response);
109
+ }
110
+ /**
111
+ * Execute a tool via queue
112
+ */
113
+ async execute(tool, input, context) {
114
+ this.ensureInitialized();
115
+ const id = (0, uuid_1.v4)();
116
+ const startTime = Date.now();
117
+ const message = {
118
+ id,
119
+ tool,
120
+ input,
121
+ context: {
122
+ executionId: context.executionId,
123
+ workflowId: context.workflowId,
124
+ stepId: context.stepId,
125
+ },
126
+ timestamp: startTime,
127
+ };
128
+ return new Promise((resolve, reject) => {
129
+ const timeout = setTimeout(() => {
130
+ this.pendingRequests.delete(id);
131
+ resolve({
132
+ success: false,
133
+ error: 'Request timeout',
134
+ metadata: {
135
+ transport: 'queue',
136
+ duration: Date.now() - startTime,
137
+ },
138
+ });
139
+ }, 60000); // 60 second timeout for async operations
140
+ this.pendingRequests.set(id, { resolve, reject, timeout });
141
+ this.sendToQueue(message).catch(error => {
142
+ clearTimeout(timeout);
143
+ this.pendingRequests.delete(id);
144
+ resolve({
145
+ success: false,
146
+ error: error.message,
147
+ metadata: {
148
+ transport: 'queue',
149
+ duration: Date.now() - startTime,
150
+ },
151
+ });
152
+ });
153
+ });
154
+ }
155
+ /**
156
+ * Health check for queue transport
157
+ */
158
+ async healthCheck() {
159
+ if (!this.isInitialized) {
160
+ return false;
161
+ }
162
+ // In a real implementation, this would check queue connectivity
163
+ return this.isPolling;
164
+ }
165
+ /**
166
+ * Shutdown the queue transport
167
+ */
168
+ async shutdown() {
169
+ this.stopPolling();
170
+ // Clear pending requests
171
+ for (const [id, pending] of this.pendingRequests) {
172
+ clearTimeout(pending.timeout);
173
+ pending.reject(new Error('Transport shutdown'));
174
+ }
175
+ this.pendingRequests.clear();
176
+ // Clear queues
177
+ this.requestQueue = [];
178
+ this.responseQueue = [];
179
+ await super.shutdown();
180
+ }
181
+ /**
182
+ * Get queue statistics
183
+ */
184
+ getStatistics() {
185
+ return {
186
+ pendingRequests: this.pendingRequests.size,
187
+ requestQueueSize: this.requestQueue.length,
188
+ responseQueueSize: this.responseQueue.length,
189
+ isPolling: this.isPolling,
190
+ };
191
+ }
192
+ }
193
+ exports.QueueTransport = QueueTransport;
194
+ //# sourceMappingURL=QueueTransport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueueTransport.js","sourceRoot":"","sources":["../../src/transport/QueueTransport.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,mDAAgD;AAIhD,+BAAoC;AAsBpC,MAAa,cAAe,SAAQ,6BAAa;IAC/C,IAAI,GAAG,OAAO,CAAC;IACP,WAAW,CAAwB;IACnC,eAAe,GAIlB,IAAI,GAAG,EAAE,CAAC;IACP,SAAS,GAAY,KAAK,CAAC;IAC3B,YAAY,GAA0B,IAAI,CAAC;IAEnD,yFAAyF;IACjF,YAAY,GAAmB,EAAE,CAAC;IAClC,aAAa,GAAoB,EAAE,CAAC;IAE5C;;OAEG;IACH,KAAK,CAAC,UAAU,CAAC,MAA4B;QAC3C,MAAM,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,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