jazz-ai 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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -0
  3. package/dist/cli/commands/auth.d.ts +18 -0
  4. package/dist/cli/commands/auth.d.ts.map +1 -0
  5. package/dist/cli/commands/auth.js +128 -0
  6. package/dist/cli/commands/auth.js.map +1 -0
  7. package/dist/cli/commands/chat-agent.d.ts +18 -0
  8. package/dist/cli/commands/chat-agent.d.ts.map +1 -0
  9. package/dist/cli/commands/chat-agent.js +421 -0
  10. package/dist/cli/commands/chat-agent.js.map +1 -0
  11. package/dist/cli/commands/edit-agent.d.ts +10 -0
  12. package/dist/cli/commands/edit-agent.d.ts.map +1 -0
  13. package/dist/cli/commands/edit-agent.js +310 -0
  14. package/dist/cli/commands/edit-agent.js.map +1 -0
  15. package/dist/cli/commands/task-agent.d.ts +126 -0
  16. package/dist/cli/commands/task-agent.d.ts.map +1 -0
  17. package/dist/cli/commands/task-agent.js +345 -0
  18. package/dist/cli/commands/task-agent.js.map +1 -0
  19. package/dist/core/agent/agent-prompt.d.ts +47 -0
  20. package/dist/core/agent/agent-prompt.d.ts.map +1 -0
  21. package/dist/core/agent/agent-prompt.js +146 -0
  22. package/dist/core/agent/agent-prompt.js.map +1 -0
  23. package/dist/core/agent/agent-runner.d.ts +63 -0
  24. package/dist/core/agent/agent-runner.d.ts.map +1 -0
  25. package/dist/core/agent/agent-runner.js +346 -0
  26. package/dist/core/agent/agent-runner.js.map +1 -0
  27. package/dist/core/agent/agent-service.d.ts +164 -0
  28. package/dist/core/agent/agent-service.d.ts.map +1 -0
  29. package/dist/core/agent/agent-service.js +463 -0
  30. package/dist/core/agent/agent-service.js.map +1 -0
  31. package/dist/core/agent/gmail-agent.d.ts +17 -0
  32. package/dist/core/agent/gmail-agent.d.ts.map +1 -0
  33. package/dist/core/agent/gmail-agent.js +191 -0
  34. package/dist/core/agent/gmail-agent.js.map +1 -0
  35. package/dist/core/agent/prompts/default/v1.d.ts +2 -0
  36. package/dist/core/agent/prompts/default/v1.d.ts.map +1 -0
  37. package/dist/core/agent/prompts/default/v1.js +202 -0
  38. package/dist/core/agent/prompts/default/v1.js.map +1 -0
  39. package/dist/core/agent/prompts/default/v2.d.ts +2 -0
  40. package/dist/core/agent/prompts/default/v2.d.ts.map +1 -0
  41. package/dist/core/agent/prompts/default/v2.js +72 -0
  42. package/dist/core/agent/prompts/default/v2.js.map +1 -0
  43. package/dist/core/agent/prompts/gmail/v1.d.ts +2 -0
  44. package/dist/core/agent/prompts/gmail/v1.d.ts.map +1 -0
  45. package/dist/core/agent/prompts/gmail/v1.js +206 -0
  46. package/dist/core/agent/prompts/gmail/v1.js.map +1 -0
  47. package/dist/core/agent/prompts/gmail/v2.d.ts +2 -0
  48. package/dist/core/agent/prompts/gmail/v2.d.ts.map +1 -0
  49. package/dist/core/agent/prompts/gmail/v2.js +59 -0
  50. package/dist/core/agent/prompts/gmail/v2.js.map +1 -0
  51. package/dist/core/agent/tools/base-tool.d.ts +161 -0
  52. package/dist/core/agent/tools/base-tool.d.ts.map +1 -0
  53. package/dist/core/agent/tools/base-tool.js +153 -0
  54. package/dist/core/agent/tools/base-tool.js.map +1 -0
  55. package/dist/core/agent/tools/fs-tools.d.ts +21 -0
  56. package/dist/core/agent/tools/fs-tools.d.ts.map +1 -0
  57. package/dist/core/agent/tools/fs-tools.js +1210 -0
  58. package/dist/core/agent/tools/fs-tools.js.map +1 -0
  59. package/dist/core/agent/tools/git-tools.d.ts +63 -0
  60. package/dist/core/agent/tools/git-tools.d.ts.map +1 -0
  61. package/dist/core/agent/tools/git-tools.js +600 -0
  62. package/dist/core/agent/tools/git-tools.js.map +1 -0
  63. package/dist/core/agent/tools/gmail-tools.d.ts +22 -0
  64. package/dist/core/agent/tools/gmail-tools.d.ts.map +1 -0
  65. package/dist/core/agent/tools/gmail-tools.js +779 -0
  66. package/dist/core/agent/tools/gmail-tools.js.map +1 -0
  67. package/dist/core/agent/tools/register-tools.d.ts +13 -0
  68. package/dist/core/agent/tools/register-tools.d.ts.map +1 -0
  69. package/dist/core/agent/tools/register-tools.js +169 -0
  70. package/dist/core/agent/tools/register-tools.js.map +1 -0
  71. package/dist/core/agent/tools/shell-tools.d.ts +19 -0
  72. package/dist/core/agent/tools/shell-tools.d.ts.map +1 -0
  73. package/dist/core/agent/tools/shell-tools.js +367 -0
  74. package/dist/core/agent/tools/shell-tools.js.map +1 -0
  75. package/dist/core/agent/tools/tool-registry.d.ts +62 -0
  76. package/dist/core/agent/tools/tool-registry.d.ts.map +1 -0
  77. package/dist/core/agent/tools/tool-registry.js +187 -0
  78. package/dist/core/agent/tools/tool-registry.js.map +1 -0
  79. package/dist/core/agent/tools/web-search-tools.d.ts +39 -0
  80. package/dist/core/agent/tools/web-search-tools.d.ts.map +1 -0
  81. package/dist/core/agent/tools/web-search-tools.js +220 -0
  82. package/dist/core/agent/tools/web-search-tools.js.map +1 -0
  83. package/dist/core/types/errors.d.ts +300 -0
  84. package/dist/core/types/errors.d.ts.map +1 -0
  85. package/dist/core/types/errors.js +115 -0
  86. package/dist/core/types/errors.js.map +1 -0
  87. package/dist/core/types/index.d.ts +208 -0
  88. package/dist/core/types/index.d.ts.map +1 -0
  89. package/dist/core/types/index.js +30 -0
  90. package/dist/core/types/index.js.map +1 -0
  91. package/dist/core/utils/error-handler.d.ts +114 -0
  92. package/dist/core/utils/error-handler.d.ts.map +1 -0
  93. package/dist/core/utils/error-handler.js +551 -0
  94. package/dist/core/utils/error-handler.js.map +1 -0
  95. package/dist/core/utils/markdown-renderer.d.ts +52 -0
  96. package/dist/core/utils/markdown-renderer.d.ts.map +1 -0
  97. package/dist/core/utils/markdown-renderer.js +134 -0
  98. package/dist/core/utils/markdown-renderer.js.map +1 -0
  99. package/dist/main.d.ts +3 -0
  100. package/dist/main.d.ts.map +1 -0
  101. package/dist/main.js +255 -0
  102. package/dist/main.js.map +1 -0
  103. package/dist/services/config.d.ts +29 -0
  104. package/dist/services/config.d.ts.map +1 -0
  105. package/dist/services/config.js +204 -0
  106. package/dist/services/config.js.map +1 -0
  107. package/dist/services/gmail.d.ts +197 -0
  108. package/dist/services/gmail.d.ts.map +1 -0
  109. package/dist/services/gmail.js +592 -0
  110. package/dist/services/gmail.js.map +1 -0
  111. package/dist/services/llm/ai-sdk-service.d.ts +5 -0
  112. package/dist/services/llm/ai-sdk-service.d.ts.map +1 -0
  113. package/dist/services/llm/ai-sdk-service.js +326 -0
  114. package/dist/services/llm/ai-sdk-service.js.map +1 -0
  115. package/dist/services/llm/context-manager.d.ts +51 -0
  116. package/dist/services/llm/context-manager.d.ts.map +1 -0
  117. package/dist/services/llm/context-manager.js +269 -0
  118. package/dist/services/llm/context-manager.js.map +1 -0
  119. package/dist/services/llm/types.d.ts +114 -0
  120. package/dist/services/llm/types.d.ts.map +1 -0
  121. package/dist/services/llm/types.js +51 -0
  122. package/dist/services/llm/types.js.map +1 -0
  123. package/dist/services/logger.d.ts +28 -0
  124. package/dist/services/logger.d.ts.map +1 -0
  125. package/dist/services/logger.js +267 -0
  126. package/dist/services/logger.js.map +1 -0
  127. package/dist/services/shell.d.ts +37 -0
  128. package/dist/services/shell.d.ts.map +1 -0
  129. package/dist/services/shell.js +197 -0
  130. package/dist/services/shell.js.map +1 -0
  131. package/dist/services/storage/file.d.ts +37 -0
  132. package/dist/services/storage/file.d.ts.map +1 -0
  133. package/dist/services/storage/file.js +221 -0
  134. package/dist/services/storage/file.js.map +1 -0
  135. package/dist/services/storage/inMemory.d.ts +25 -0
  136. package/dist/services/storage/inMemory.d.ts.map +1 -0
  137. package/dist/services/storage/inMemory.js +106 -0
  138. package/dist/services/storage/inMemory.js.map +1 -0
  139. package/dist/services/storage/service.d.ts +26 -0
  140. package/dist/services/storage/service.d.ts.map +1 -0
  141. package/dist/services/storage/service.js +48 -0
  142. package/dist/services/storage/service.js.map +1 -0
  143. package/package.json +92 -0
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AgentRunner = void 0;
4
+ exports.executeTool = executeTool;
5
+ const effect_1 = require("effect");
6
+ const config_1 = require("../../services/config");
7
+ const types_1 = require("../../services/llm/types");
8
+ const logger_1 = require("../../services/logger");
9
+ const markdown_renderer_1 = require("../utils/markdown-renderer");
10
+ const agent_prompt_1 = require("./agent-prompt");
11
+ const tool_registry_1 = require("./tools/tool-registry");
12
+ class AgentRunner {
13
+ /**
14
+ * Run an agent conversation
15
+ */
16
+ static run(options) {
17
+ return effect_1.Effect.gen(function* () {
18
+ const { agent, userInput, conversationId, userId, maxIterations = 8 } = options;
19
+ // Get services
20
+ const llmService = yield* types_1.LLMServiceTag;
21
+ const toolRegistry = yield* tool_registry_1.ToolRegistryTag;
22
+ const configService = yield* config_1.AgentConfigService;
23
+ const logger = yield* logger_1.LoggerServiceTag;
24
+ const appConfig = yield* configService.appConfig;
25
+ // Generate a conversation ID if not provided
26
+ const actualConversationId = conversationId || `conv-${Date.now()}`;
27
+ // Use provided history if available to preserve context across turns
28
+ const history = options.conversationHistory || [];
29
+ const agentType = agent.config.agentType;
30
+ // Get available tools for this specific agent
31
+ const allToolNames = yield* toolRegistry.listTools();
32
+ const agentToolNames = agent.config.tools || [];
33
+ // The approval system in base-tool.ts automatically handles execute-* tool mapping
34
+ // No need for manual mapping here as the tool registry handles this internally
35
+ const expandedToolNames = Array.from(agentToolNames);
36
+ // Validate that all agent tools exist in the registry
37
+ const invalidTools = agentToolNames.filter((toolName) => !allToolNames.includes(toolName));
38
+ if (invalidTools.length > 0) {
39
+ return yield* effect_1.Effect.fail(new Error(`Agent ${agent.id} references non-existent tools: ${invalidTools.join(", ")}`));
40
+ }
41
+ // Get tool definitions for only the agent's specified tools
42
+ const allTools = yield* toolRegistry.getToolDefinitions();
43
+ const tools = allTools.filter((tool) => expandedToolNames.includes(tool.function.name));
44
+ // Build a map of available tool descriptions for prompt clarity
45
+ const availableTools = {};
46
+ for (const tool of tools) {
47
+ availableTools[tool.function.name] = tool.function.description;
48
+ }
49
+ // Build messages for the agent with only its specified tools and descriptions
50
+ const messages = yield* agent_prompt_1.agentPromptBuilder.buildAgentMessages(agentType, {
51
+ agentName: agent.name,
52
+ agentDescription: agent.description,
53
+ userInput,
54
+ conversationHistory: history,
55
+ toolNames: agentToolNames,
56
+ availableTools,
57
+ });
58
+ // Create execution context
59
+ const context = {
60
+ agentId: agent.id,
61
+ conversationId: actualConversationId,
62
+ ...(userId ? { userId } : {}),
63
+ };
64
+ // Run the agent loop
65
+ const currentMessages = [...messages];
66
+ let response = {
67
+ content: "",
68
+ conversationId: actualConversationId,
69
+ };
70
+ let finished = false;
71
+ let iterationsUsed = 0;
72
+ // Memory safeguard: prevent unbounded message growth
73
+ const MAX_MESSAGES = 100;
74
+ // Determine the LLM provider and model to use
75
+ const provider = agent.config.llmProvider;
76
+ const model = agent.config.llmModel;
77
+ for (let i = 0; i < maxIterations; i++) {
78
+ // Log user-friendly progress for info level
79
+ if (i === 0) {
80
+ const message = markdown_renderer_1.MarkdownRenderer.formatThinking(agent.name, true);
81
+ yield* logger.info(message, {
82
+ agentId: agent.id,
83
+ conversationId: actualConversationId,
84
+ iteration: i + 1,
85
+ });
86
+ }
87
+ else {
88
+ const message = markdown_renderer_1.MarkdownRenderer.formatThinking(agent.name, false);
89
+ yield* logger.info(message, {
90
+ agentId: agent.id,
91
+ conversationId: actualConversationId,
92
+ iteration: i + 1,
93
+ });
94
+ }
95
+ // Log LLM request in debug mode
96
+ if (appConfig.logging.level === "debug") {
97
+ yield* logger.debug("LLM request", {
98
+ agentId: agent.id,
99
+ conversationId: actualConversationId,
100
+ iteration: i + 1,
101
+ provider,
102
+ model,
103
+ messageCount: currentMessages.length,
104
+ messages: currentMessages,
105
+ tools: tools.map((t) => ({
106
+ name: t.function.name,
107
+ description: t.function.description,
108
+ })),
109
+ });
110
+ }
111
+ // Call the LLM with retry logic for rate limit errors
112
+ let messagesToSend = currentMessages;
113
+ // Secondary safety: ensure messagesToSend is never empty
114
+ if (messagesToSend.length === 0) {
115
+ // Fallback to a single user message if everything else failed
116
+ messagesToSend = [
117
+ {
118
+ role: "user",
119
+ content: userInput && userInput.trim().length > 0 ? userInput : "Continue",
120
+ },
121
+ ];
122
+ yield* logger.warn("messagesToSend was empty; using fallback single user message", {
123
+ agentId: agent.id,
124
+ conversationId: actualConversationId,
125
+ iteration: i + 1,
126
+ });
127
+ }
128
+ const maxRetries = 3;
129
+ const completion = yield* effect_1.Effect.retry(effect_1.Effect.gen(function* () {
130
+ const llmOptions = {
131
+ model,
132
+ messages: messagesToSend,
133
+ tools,
134
+ toolChoice: "auto",
135
+ reasoning_effort: agent.config.reasoningEffort ?? "disable",
136
+ };
137
+ const result = yield* llmService.createChatCompletion(provider, llmOptions);
138
+ return result;
139
+ }), effect_1.Schedule.exponential("1 second").pipe(effect_1.Schedule.intersect(effect_1.Schedule.recurs(maxRetries)), effect_1.Schedule.whileInput((error) => error instanceof types_1.LLMRateLimitError)));
140
+ // Add the assistant's response to the conversation (including tool calls, if any)
141
+ currentMessages.push({
142
+ role: "assistant",
143
+ content: completion.content,
144
+ ...(completion.toolCalls
145
+ ? {
146
+ tool_calls: completion.toolCalls.map((tc) => ({
147
+ id: tc.id,
148
+ type: tc.type,
149
+ function: { name: tc.function.name, arguments: tc.function.arguments },
150
+ })),
151
+ }
152
+ : {}),
153
+ });
154
+ // Memory safeguard: trim messages if they exceed the limit
155
+ if (currentMessages.length > MAX_MESSAGES) {
156
+ // Keep the system message and the most recent messages
157
+ const systemMessage = currentMessages[0];
158
+ if (systemMessage) {
159
+ const recentMessages = currentMessages.slice(-(MAX_MESSAGES - 1));
160
+ currentMessages.length = 0;
161
+ currentMessages.push(systemMessage, ...recentMessages);
162
+ }
163
+ yield* logger.warn("Message history trimmed to prevent memory issues", {
164
+ agentId: agent.id,
165
+ conversationId: actualConversationId,
166
+ maxMessages: MAX_MESSAGES,
167
+ trimmedCount: currentMessages.length,
168
+ });
169
+ }
170
+ // Log assistant response if log level is debug
171
+ if (appConfig.logging.level === "debug") {
172
+ yield* logger.debug("LLM response received", {
173
+ agentId: agent.id,
174
+ conversationId: actualConversationId,
175
+ iteration: i + 1,
176
+ model: completion.model,
177
+ content: completion.content,
178
+ toolCalls: completion.toolCalls?.map((tc) => ({
179
+ id: tc.id,
180
+ name: tc.function.name,
181
+ arguments: tc.function.arguments,
182
+ })),
183
+ usage: completion.usage,
184
+ });
185
+ }
186
+ // Check if the model wants to call a tool
187
+ if (completion.toolCalls && completion.toolCalls.length > 0) {
188
+ const toolResults = {};
189
+ // Log user-friendly tool execution info
190
+ const toolNames = completion.toolCalls.map((tc) => tc.function.name);
191
+ const message = markdown_renderer_1.MarkdownRenderer.formatToolExecution(agent.name, toolNames);
192
+ yield* logger.info(message, {
193
+ agentId: agent.id,
194
+ conversationId: actualConversationId,
195
+ toolCount: completion.toolCalls.length,
196
+ tools: toolNames,
197
+ });
198
+ // Execute each tool call
199
+ for (const toolCall of completion.toolCalls) {
200
+ if (toolCall.type === "function") {
201
+ const { name, arguments: argsString } = toolCall.function;
202
+ try {
203
+ // Parse the arguments safely with proper error handling
204
+ let parsed;
205
+ try {
206
+ parsed = JSON.parse(argsString);
207
+ }
208
+ catch (parseError) {
209
+ throw new Error(`Invalid JSON in tool arguments: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
210
+ }
211
+ const args = parsed && typeof parsed === "object" && !Array.isArray(parsed)
212
+ ? parsed
213
+ : {};
214
+ // Log tool call arguments in debug mode
215
+ yield* logger.debug("Tool call arguments", {
216
+ agentId: agent.id,
217
+ conversationId: actualConversationId,
218
+ toolName: name,
219
+ toolCallId: toolCall.id,
220
+ arguments: args,
221
+ rawArguments: argsString,
222
+ });
223
+ // Execute the tool
224
+ const result = yield* executeTool(name, args, context);
225
+ // Log tool execution result in debug mode
226
+ yield* logger.debug("Tool execution result", {
227
+ agentId: agent.id,
228
+ conversationId: actualConversationId,
229
+ toolName: name,
230
+ toolCallId: toolCall.id,
231
+ arguments: args,
232
+ result: result.result,
233
+ });
234
+ // Add the tool result to the conversation
235
+ currentMessages.push({
236
+ role: "tool",
237
+ name,
238
+ content: JSON.stringify(result.result),
239
+ tool_call_id: toolCall.id,
240
+ });
241
+ // Store the tool result
242
+ toolResults[name] = result.result;
243
+ }
244
+ catch (error) {
245
+ // If the tool does not exist, rethrow to fail fast (never mock missing tools)
246
+ if (error instanceof Error && error.message.startsWith("Tool not found")) {
247
+ throw error;
248
+ }
249
+ // Log the tool execution error for debugging
250
+ const errorMessage = error instanceof Error ? error.message : String(error);
251
+ yield* logger.error("Tool execution failed", {
252
+ agentId: agent.id,
253
+ conversationId: actualConversationId,
254
+ toolName: name,
255
+ toolCallId: toolCall.id,
256
+ error: errorMessage,
257
+ });
258
+ // Include the tool execution error in the conversation
259
+ currentMessages.push({
260
+ role: "tool",
261
+ name,
262
+ content: `Error: ${errorMessage}`,
263
+ tool_call_id: toolCall.id,
264
+ });
265
+ // Store the error
266
+ toolResults[name] = {
267
+ error: errorMessage,
268
+ };
269
+ }
270
+ }
271
+ }
272
+ // Update the response with tool results
273
+ response = { ...response, toolCalls: completion.toolCalls, toolResults };
274
+ // Continue the conversation with the tool results
275
+ continue;
276
+ }
277
+ // No tool calls, we have the final response
278
+ response = { ...response, content: completion.content };
279
+ // Log completion
280
+ const completionMessage = markdown_renderer_1.MarkdownRenderer.formatCompletion(agent.name);
281
+ yield* logger.info(completionMessage, {
282
+ agentId: agent.id,
283
+ conversationId: actualConversationId,
284
+ totalIterations: i + 1,
285
+ hasContent: !!completion.content,
286
+ });
287
+ // Mark loop as finished and break
288
+ iterationsUsed = i + 1;
289
+ finished = true;
290
+ break;
291
+ }
292
+ // Post-loop diagnostics
293
+ if (!finished) {
294
+ const warningMessage = markdown_renderer_1.MarkdownRenderer.formatWarning(agent.name, `reached maximum iterations (${maxIterations})`);
295
+ yield* logger.warn(warningMessage, {
296
+ agentId: agent.id,
297
+ conversationId: actualConversationId,
298
+ maxIterations,
299
+ });
300
+ }
301
+ else if ((!response.content || response.content.trim().length === 0) &&
302
+ !response.toolCalls) {
303
+ const emptyMessage = markdown_renderer_1.MarkdownRenderer.formatWarning(agent.name, "model returned an empty response");
304
+ yield* logger.warn(emptyMessage, {
305
+ agentId: agent.id,
306
+ conversationId: actualConversationId,
307
+ totalIterations: iterationsUsed,
308
+ });
309
+ }
310
+ // Optionally persist conversation history via a storage layer in the future
311
+ // Return the full message history from this turn so callers can persist it
312
+ return { ...response, messages: currentMessages };
313
+ });
314
+ }
315
+ }
316
+ exports.AgentRunner = AgentRunner;
317
+ /**
318
+ * Execute a tool by name with the provided arguments
319
+ *
320
+ * Finds the specified tool in the registry and executes it with the given arguments
321
+ * and context. Provides comprehensive logging of the execution process including
322
+ * start, success, and error states.
323
+ *
324
+ * @param name - The name of the tool to execute
325
+ * @param args - The arguments to pass to the tool
326
+ * @param context - The execution context containing agent and conversation information
327
+ * @returns An Effect that resolves to the tool execution result
328
+ *
329
+ * @throws {Error} When the tool is not found or execution fails
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * const result = yield* executeTool(
334
+ * "gmail_list_emails",
335
+ * { query: "is:unread" },
336
+ * { agentId: "agent-123", conversationId: "conv-456" }
337
+ * );
338
+ * ```
339
+ */
340
+ function executeTool(name, args, context) {
341
+ return effect_1.Effect.gen(function* () {
342
+ const registry = yield* tool_registry_1.ToolRegistryTag;
343
+ return yield* registry.executeTool(name, args, context);
344
+ });
345
+ }
346
+ //# sourceMappingURL=agent-runner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-runner.js","sourceRoot":"","sources":["../../../src/core/agent/agent-runner.ts"],"names":[],"mappings":";;;AA2bA,kCASC;AApcD,mCAA0C;AAE1C,kDAA+E;AAC/E,oDAMkC;AAClC,kDAA6E;AAE7E,kEAA8D;AAC9D,iDAAoD;AACpD,yDAK+B;AA+B/B,MAAa,WAAW;IACtB;;OAEG;IACH,MAAM,CAAC,GAAG,CACR,OAA2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CACnD,KAAK,CAAC,IAAI,EACV,+BAA+B,aAAa,GAAG,CAChD,CAAC;gBACF,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,EAAE;oBACjC,OAAO,EAAE,KAAK,CAAC,EAAE;oBACjB,cAAc,EAAE,oBAAoB;oBACpC,aAAa;iBACd,CAAC,CAAC;YACL,CAAC;iBAAM,IACL,CAAC,CAAC,QAAQ,CAAC,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC;gBAC3D,CAAC,QAAQ,CAAC,SAAS,EACnB,CAAC;gBACD,MAAM,YAAY,GAAG,oCAAgB,CAAC,aAAa,CACjD,KAAK,CAAC,IAAI,EACV,kCAAkC,CACnC,CAAC;gBACF,KAAK,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,EAAE;oBAC/B,OAAO,EAAE,KAAK,CAAC,EAAE;oBACjB,cAAc,EAAE,oBAAoB;oBACpC,eAAe,EAAE,cAAc;iBAChC,CAAC,CAAC;YACL,CAAC;YAED,4EAA4E;YAE5E,2EAA2E;YAC3E,OAAO,EAAE,GAAG,QAAQ,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhXD,kCAgXC;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,SAAgB,WAAW,CACzB,IAAY,EACZ,IAA6B,EAC7B,OAA6B;IAE7B,OAAO,eAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QACzB,MAAM,QAAQ,GAAG,KAAK,CAAC,CAAC,+BAAe,CAAC;QACxC,OAAO,KAAK,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,164 @@
1
+ import { Context, Effect, Layer } from "effect";
2
+ import type { StorageService } from "../../services/storage/service";
3
+ import { AgentAlreadyExistsError, AgentConfigurationError, StorageError, StorageNotFoundError, ValidationError } from "../types/errors";
4
+ import { type Agent, type AgentConfig } from "../types/index";
5
+ /**
6
+ * Agent service for managing agent lifecycle and operations
7
+ */
8
+ export interface AgentService {
9
+ readonly createAgent: (name: string, description: string, config?: Partial<AgentConfig>) => Effect.Effect<Agent, StorageError | AgentAlreadyExistsError | AgentConfigurationError | ValidationError>;
10
+ readonly getAgent: (id: string) => Effect.Effect<Agent, StorageError | StorageNotFoundError>;
11
+ readonly listAgents: () => Effect.Effect<readonly Agent[], StorageError>;
12
+ readonly updateAgent: (id: string, updates: Partial<Agent>) => Effect.Effect<Agent, StorageError | StorageNotFoundError>;
13
+ readonly deleteAgent: (id: string) => Effect.Effect<void, StorageError | StorageNotFoundError>;
14
+ readonly validateAgentConfig: (config: AgentConfig) => Effect.Effect<void, AgentConfigurationError>;
15
+ }
16
+ export declare class DefaultAgentService implements AgentService {
17
+ private readonly storage;
18
+ constructor(storage: StorageService);
19
+ /**
20
+ * Create a new agent with the specified configuration
21
+ *
22
+ * Validates the agent name and description, checks for duplicates, and creates
23
+ * a new agent with the provided configuration. The agent will be assigned a
24
+ * unique ID and timestamps for creation and updates.
25
+ *
26
+ * @param name - The unique name for the agent (must be alphanumeric with underscores/hyphens)
27
+ * @param description - A description of what the agent does (1-500 characters)
28
+ * @param config - Optional configuration including timeout, retry policy, and tasks
29
+ * @returns An Effect that resolves to the created Agent or fails with validation/configuration errors
30
+ *
31
+ * @throws {ValidationError} When name or description validation fails
32
+ * @throws {AgentAlreadyExistsError} When an agent with the same name already exists
33
+ * @throws {AgentConfigurationError} When the configuration is invalid
34
+ * @throws {StorageError} When the agent cannot be saved to storage
35
+ *
36
+ * @example
37
+ * ```typescript
38
+ * const agent = yield* agentService.createAgent(
39
+ * "email-processor",
40
+ * "Processes incoming emails and categorizes them",
41
+ * { timeout: 30000, retryPolicy: { maxRetries: 3, delay: 1000, backoff: "exponential" } }
42
+ * );
43
+ * ```
44
+ */
45
+ createAgent(name: string, description: string, config?: Partial<AgentConfig>): Effect.Effect<Agent, StorageError | AgentAlreadyExistsError | AgentConfigurationError | ValidationError>;
46
+ /**
47
+ * Retrieve an agent by its unique identifier
48
+ *
49
+ * @param id - The unique identifier of the agent to retrieve
50
+ * @returns An Effect that resolves to the Agent or fails if not found
51
+ *
52
+ * @throws {StorageError} When there's an error accessing storage
53
+ * @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const agent = yield* agentService.getAgent("agent-123");
58
+ * console.log(`Found agent: ${agent.name}`);
59
+ * ```
60
+ */
61
+ getAgent(id: string): Effect.Effect<Agent, StorageError | StorageNotFoundError>;
62
+ /**
63
+ * List all available agents
64
+ *
65
+ * @returns An Effect that resolves to an array of all agents in storage
66
+ *
67
+ * @throws {StorageError} When there's an error accessing storage
68
+ *
69
+ * @example
70
+ * ```typescript
71
+ * const agents = yield* agentService.listAgents();
72
+ * console.log(`Found ${agents.length} agents`);
73
+ * agents.forEach(agent => console.log(`- ${agent.name}: ${agent.description}`));
74
+ * ```
75
+ */
76
+ listAgents(): Effect.Effect<readonly Agent[], StorageError>;
77
+ /**
78
+ * Update an existing agent with new data
79
+ *
80
+ * Updates the specified agent with the provided changes. The agent's ID and
81
+ * creation timestamp cannot be changed. The updatedAt timestamp will be
82
+ * automatically set to the current time.
83
+ *
84
+ * @param id - The unique identifier of the agent to update
85
+ * @param updates - Partial agent data containing the fields to update
86
+ * @returns An Effect that resolves to the updated Agent or fails if not found
87
+ *
88
+ * @throws {StorageError} When there's an error accessing storage
89
+ * @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const updatedAgent = yield* agentService.updateAgent("agent-123", {
94
+ * description: "Updated description",
95
+ * config: { timeout: 60000 }
96
+ * });
97
+ * ```
98
+ */
99
+ updateAgent(id: string, updates: Partial<Agent>): Effect.Effect<Agent, StorageError | StorageNotFoundError>;
100
+ /**
101
+ * Delete an agent by its unique identifier
102
+ *
103
+ * @param id - The unique identifier of the agent to delete
104
+ * @returns An Effect that resolves when the agent is successfully deleted
105
+ *
106
+ * @throws {StorageError} When there's an error accessing storage
107
+ * @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
108
+ *
109
+ * @example
110
+ * ```typescript
111
+ * yield* agentService.deleteAgent("agent-123");
112
+ * console.log("Agent deleted successfully");
113
+ * ```
114
+ */
115
+ deleteAgent(id: string): Effect.Effect<void, StorageError | StorageNotFoundError>;
116
+ /**
117
+ * Validate an agent configuration for correctness
118
+ *
119
+ * Performs comprehensive validation of the agent configuration including:
120
+ * - Task validation using schemas
121
+ * - Timeout range validation (1000ms - 3600000ms)
122
+ * - Retry policy validation (max retries 0-10, delay 100ms-60000ms)
123
+ *
124
+ * @param config - The agent configuration to validate
125
+ * @returns An Effect that resolves if validation passes or fails with configuration errors
126
+ *
127
+ * @throws {AgentConfigurationError} When any part of the configuration is invalid
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const config: AgentConfig = {
132
+ * tasks: [],
133
+ * timeout: 30000,
134
+ * retryPolicy: { maxRetries: 3, delay: 1000, backoff: "exponential" }
135
+ * };
136
+ *
137
+ * yield* agentService.validateAgentConfig(config);
138
+ * ```
139
+ */
140
+ validateAgentConfig(config: AgentConfig): Effect.Effect<void, AgentConfigurationError>;
141
+ }
142
+ export declare const AgentServiceTag: Context.Tag<AgentService, AgentService>;
143
+ export declare function createAgentServiceLayer(): Layer.Layer<AgentService, never, StorageService>;
144
+ export declare function createAgent(name: string, description: string, config?: Partial<AgentConfig>): Effect.Effect<Agent, StorageError | AgentAlreadyExistsError | AgentConfigurationError | ValidationError, AgentService>;
145
+ export declare function getAgentById(id: string): Effect.Effect<Agent, StorageError | StorageNotFoundError, AgentService>;
146
+ /**
147
+ * List all available agents using the AgentService
148
+ *
149
+ * This is a convenience function that uses the AgentService from the Effect context
150
+ * to retrieve all agents.
151
+ *
152
+ * @returns An Effect that resolves to an array of all agents
153
+ *
154
+ * @throws {StorageError} When there's an error accessing storage
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const agents = yield* listAllAgents();
159
+ * console.log(`Found ${agents.length} agents`);
160
+ * agents.forEach(agent => console.log(`- ${agent.name}`));
161
+ * ```
162
+ */
163
+ export declare function listAllAgents(): Effect.Effect<readonly Agent[], StorageError, AgentService>;
164
+ //# sourceMappingURL=agent-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-service.d.ts","sourceRoot":"","sources":["../../../src/core/agent/agent-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAU,MAAM,QAAQ,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAErE,OAAO,EACL,uBAAuB,EACvB,uBAAuB,EACvB,YAAY,EACZ,oBAAoB,EACpB,eAAe,EAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,WAAW,EAAyB,MAAM,gBAAgB,CAAC;AAGrF;;GAEG;AAEH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,WAAW,EAAE,CACpB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,MAAM,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,KAC1B,MAAM,CAAC,MAAM,CAChB,KAAK,EACL,YAAY,GAAG,uBAAuB,GAAG,uBAAuB,GAAG,eAAe,CACnF,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,oBAAoB,CAAC,CAAC;IAC7F,QAAQ,CAAC,UAAU,EAAE,MAAM,MAAM,CAAC,MAAM,CAAC,SAAS,KAAK,EAAE,EAAE,YAAY,CAAC,CAAC;IACzE,QAAQ,CAAC,WAAW,EAAE,CACpB,E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