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.
- package/LICENSE +21 -0
- package/README.md +182 -0
- package/dist/cli/commands/auth.d.ts +18 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +128 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/chat-agent.d.ts +18 -0
- package/dist/cli/commands/chat-agent.d.ts.map +1 -0
- package/dist/cli/commands/chat-agent.js +421 -0
- package/dist/cli/commands/chat-agent.js.map +1 -0
- package/dist/cli/commands/edit-agent.d.ts +10 -0
- package/dist/cli/commands/edit-agent.d.ts.map +1 -0
- package/dist/cli/commands/edit-agent.js +310 -0
- package/dist/cli/commands/edit-agent.js.map +1 -0
- package/dist/cli/commands/task-agent.d.ts +126 -0
- package/dist/cli/commands/task-agent.d.ts.map +1 -0
- package/dist/cli/commands/task-agent.js +345 -0
- package/dist/cli/commands/task-agent.js.map +1 -0
- package/dist/core/agent/agent-prompt.d.ts +47 -0
- package/dist/core/agent/agent-prompt.d.ts.map +1 -0
- package/dist/core/agent/agent-prompt.js +146 -0
- package/dist/core/agent/agent-prompt.js.map +1 -0
- package/dist/core/agent/agent-runner.d.ts +63 -0
- package/dist/core/agent/agent-runner.d.ts.map +1 -0
- package/dist/core/agent/agent-runner.js +346 -0
- package/dist/core/agent/agent-runner.js.map +1 -0
- package/dist/core/agent/agent-service.d.ts +164 -0
- package/dist/core/agent/agent-service.d.ts.map +1 -0
- package/dist/core/agent/agent-service.js +463 -0
- package/dist/core/agent/agent-service.js.map +1 -0
- package/dist/core/agent/gmail-agent.d.ts +17 -0
- package/dist/core/agent/gmail-agent.d.ts.map +1 -0
- package/dist/core/agent/gmail-agent.js +191 -0
- package/dist/core/agent/gmail-agent.js.map +1 -0
- package/dist/core/agent/prompts/default/v1.d.ts +2 -0
- package/dist/core/agent/prompts/default/v1.d.ts.map +1 -0
- package/dist/core/agent/prompts/default/v1.js +202 -0
- package/dist/core/agent/prompts/default/v1.js.map +1 -0
- package/dist/core/agent/prompts/default/v2.d.ts +2 -0
- package/dist/core/agent/prompts/default/v2.d.ts.map +1 -0
- package/dist/core/agent/prompts/default/v2.js +72 -0
- package/dist/core/agent/prompts/default/v2.js.map +1 -0
- package/dist/core/agent/prompts/gmail/v1.d.ts +2 -0
- package/dist/core/agent/prompts/gmail/v1.d.ts.map +1 -0
- package/dist/core/agent/prompts/gmail/v1.js +206 -0
- package/dist/core/agent/prompts/gmail/v1.js.map +1 -0
- package/dist/core/agent/prompts/gmail/v2.d.ts +2 -0
- package/dist/core/agent/prompts/gmail/v2.d.ts.map +1 -0
- package/dist/core/agent/prompts/gmail/v2.js +59 -0
- package/dist/core/agent/prompts/gmail/v2.js.map +1 -0
- package/dist/core/agent/tools/base-tool.d.ts +161 -0
- package/dist/core/agent/tools/base-tool.d.ts.map +1 -0
- package/dist/core/agent/tools/base-tool.js +153 -0
- package/dist/core/agent/tools/base-tool.js.map +1 -0
- package/dist/core/agent/tools/fs-tools.d.ts +21 -0
- package/dist/core/agent/tools/fs-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/fs-tools.js +1210 -0
- package/dist/core/agent/tools/fs-tools.js.map +1 -0
- package/dist/core/agent/tools/git-tools.d.ts +63 -0
- package/dist/core/agent/tools/git-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/git-tools.js +600 -0
- package/dist/core/agent/tools/git-tools.js.map +1 -0
- package/dist/core/agent/tools/gmail-tools.d.ts +22 -0
- package/dist/core/agent/tools/gmail-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/gmail-tools.js +779 -0
- package/dist/core/agent/tools/gmail-tools.js.map +1 -0
- package/dist/core/agent/tools/register-tools.d.ts +13 -0
- package/dist/core/agent/tools/register-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/register-tools.js +169 -0
- package/dist/core/agent/tools/register-tools.js.map +1 -0
- package/dist/core/agent/tools/shell-tools.d.ts +19 -0
- package/dist/core/agent/tools/shell-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/shell-tools.js +367 -0
- package/dist/core/agent/tools/shell-tools.js.map +1 -0
- package/dist/core/agent/tools/tool-registry.d.ts +62 -0
- package/dist/core/agent/tools/tool-registry.d.ts.map +1 -0
- package/dist/core/agent/tools/tool-registry.js +187 -0
- package/dist/core/agent/tools/tool-registry.js.map +1 -0
- package/dist/core/agent/tools/web-search-tools.d.ts +39 -0
- package/dist/core/agent/tools/web-search-tools.d.ts.map +1 -0
- package/dist/core/agent/tools/web-search-tools.js +220 -0
- package/dist/core/agent/tools/web-search-tools.js.map +1 -0
- package/dist/core/types/errors.d.ts +300 -0
- package/dist/core/types/errors.d.ts.map +1 -0
- package/dist/core/types/errors.js +115 -0
- package/dist/core/types/errors.js.map +1 -0
- package/dist/core/types/index.d.ts +208 -0
- package/dist/core/types/index.d.ts.map +1 -0
- package/dist/core/types/index.js +30 -0
- package/dist/core/types/index.js.map +1 -0
- package/dist/core/utils/error-handler.d.ts +114 -0
- package/dist/core/utils/error-handler.d.ts.map +1 -0
- package/dist/core/utils/error-handler.js +551 -0
- package/dist/core/utils/error-handler.js.map +1 -0
- package/dist/core/utils/markdown-renderer.d.ts +52 -0
- package/dist/core/utils/markdown-renderer.d.ts.map +1 -0
- package/dist/core/utils/markdown-renderer.js +134 -0
- package/dist/core/utils/markdown-renderer.js.map +1 -0
- package/dist/main.d.ts +3 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/main.js +255 -0
- package/dist/main.js.map +1 -0
- package/dist/services/config.d.ts +29 -0
- package/dist/services/config.d.ts.map +1 -0
- package/dist/services/config.js +204 -0
- package/dist/services/config.js.map +1 -0
- package/dist/services/gmail.d.ts +197 -0
- package/dist/services/gmail.d.ts.map +1 -0
- package/dist/services/gmail.js +592 -0
- package/dist/services/gmail.js.map +1 -0
- package/dist/services/llm/ai-sdk-service.d.ts +5 -0
- package/dist/services/llm/ai-sdk-service.d.ts.map +1 -0
- package/dist/services/llm/ai-sdk-service.js +326 -0
- package/dist/services/llm/ai-sdk-service.js.map +1 -0
- package/dist/services/llm/context-manager.d.ts +51 -0
- package/dist/services/llm/context-manager.d.ts.map +1 -0
- package/dist/services/llm/context-manager.js +269 -0
- package/dist/services/llm/context-manager.js.map +1 -0
- package/dist/services/llm/types.d.ts +114 -0
- package/dist/services/llm/types.d.ts.map +1 -0
- package/dist/services/llm/types.js +51 -0
- package/dist/services/llm/types.js.map +1 -0
- package/dist/services/logger.d.ts +28 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +267 -0
- package/dist/services/logger.js.map +1 -0
- package/dist/services/shell.d.ts +37 -0
- package/dist/services/shell.d.ts.map +1 -0
- package/dist/services/shell.js +197 -0
- package/dist/services/shell.js.map +1 -0
- package/dist/services/storage/file.d.ts +37 -0
- package/dist/services/storage/file.d.ts.map +1 -0
- package/dist/services/storage/file.js +221 -0
- package/dist/services/storage/file.js.map +1 -0
- package/dist/services/storage/inMemory.d.ts +25 -0
- package/dist/services/storage/inMemory.d.ts.map +1 -0
- package/dist/services/storage/inMemory.js +106 -0
- package/dist/services/storage/inMemory.js.map +1 -0
- package/dist/services/storage/service.d.ts +26 -0
- package/dist/services/storage/service.d.ts.map +1 -0
- package/dist/services/storage/service.js +48 -0
- package/dist/services/storage/service.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createAgentCommand = createAgentCommand;
|
|
4
|
+
exports.listAgentsCommand = listAgentsCommand;
|
|
5
|
+
exports.runAgentCommand = runAgentCommand;
|
|
6
|
+
exports.deleteAgentCommand = deleteAgentCommand;
|
|
7
|
+
exports.getAgentCommand = getAgentCommand;
|
|
8
|
+
const effect_1 = require("effect");
|
|
9
|
+
const agent_service_1 = require("../../core/agent/agent-service");
|
|
10
|
+
const gmail_agent_1 = require("../../core/agent/gmail-agent");
|
|
11
|
+
/**
|
|
12
|
+
* CLI commands for task-based agent management
|
|
13
|
+
*
|
|
14
|
+
* These commands handle traditional automation agents that execute predefined tasks
|
|
15
|
+
* like Gmail operations, shell commands, API calls, etc. They focus on workflow
|
|
16
|
+
* automation rather than conversational AI interactions.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Create a new agent via CLI command
|
|
20
|
+
*
|
|
21
|
+
* Creates a new agent with the specified name, description, and configuration options.
|
|
22
|
+
* The command validates input parameters and displays success information including
|
|
23
|
+
* the agent ID, configuration details, and timestamps.
|
|
24
|
+
*
|
|
25
|
+
* @param name - The unique name for the agent
|
|
26
|
+
* @param description - A description of what the agent does
|
|
27
|
+
* @param options - Configuration options including timeout, retry policy settings
|
|
28
|
+
* @returns An Effect that resolves when the agent is created successfully
|
|
29
|
+
*
|
|
30
|
+
* @throws {StorageError} When there's an error saving the agent
|
|
31
|
+
* @throws {AgentAlreadyExistsError} When an agent with the same name already exists
|
|
32
|
+
* @throws {AgentConfigurationError} When the configuration is invalid
|
|
33
|
+
* @throws {ValidationError} When input validation fails
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* yield* createAgentCommand(
|
|
38
|
+
* "email-processor",
|
|
39
|
+
* "Processes incoming emails",
|
|
40
|
+
* { timeout: 30000, maxRetries: 3, retryDelay: 1000 }
|
|
41
|
+
* );
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
function createAgentCommand(name, description, options) {
|
|
45
|
+
return effect_1.Effect.gen(function* () {
|
|
46
|
+
const agentService = yield* agent_service_1.AgentServiceTag;
|
|
47
|
+
// Use provided description or default
|
|
48
|
+
const agentDescription = description || options.description || `Agent for ${name}`;
|
|
49
|
+
// Build agent configuration from options
|
|
50
|
+
const config = {};
|
|
51
|
+
if (options.timeout) {
|
|
52
|
+
config.timeout = options.timeout;
|
|
53
|
+
}
|
|
54
|
+
if (options.maxRetries !== undefined ||
|
|
55
|
+
options.retryDelay !== undefined ||
|
|
56
|
+
options.retryBackoff) {
|
|
57
|
+
config.retryPolicy = {
|
|
58
|
+
maxRetries: options.maxRetries || 3,
|
|
59
|
+
delay: options.retryDelay || 1000,
|
|
60
|
+
backoff: options.retryBackoff || "exponential",
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// Create the agent
|
|
64
|
+
const agent = yield* agentService.createAgent(name, agentDescription, config);
|
|
65
|
+
// Display success message
|
|
66
|
+
console.log(`✅ Agent created successfully!`);
|
|
67
|
+
console.log(` ID: ${agent.id}`);
|
|
68
|
+
console.log(` Name: ${agent.name}`);
|
|
69
|
+
console.log(` Description: ${agent.description}`);
|
|
70
|
+
console.log(` Status: ${agent.status}`);
|
|
71
|
+
console.log(` Created: ${agent.createdAt.toISOString()}`);
|
|
72
|
+
if (config.timeout) {
|
|
73
|
+
console.log(` Timeout: ${config.timeout}ms`);
|
|
74
|
+
}
|
|
75
|
+
if (config.retryPolicy) {
|
|
76
|
+
console.log(` Retry Policy: ${config.retryPolicy.maxRetries} retries, ${config.retryPolicy.delay}ms delay, ${config.retryPolicy.backoff} backoff`);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* List all agents via CLI command
|
|
82
|
+
*
|
|
83
|
+
* Retrieves and displays all available agents in a formatted table showing
|
|
84
|
+
* their ID, name, description, status, and creation date.
|
|
85
|
+
*
|
|
86
|
+
* @returns An Effect that resolves when the agents are listed successfully
|
|
87
|
+
*
|
|
88
|
+
* @throws {StorageError} When there's an error accessing storage
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* yield* listAgentsCommand();
|
|
93
|
+
* // Output: Table showing all agents with their details
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
function listAgentsCommand() {
|
|
97
|
+
return effect_1.Effect.gen(function* () {
|
|
98
|
+
const agents = yield* (0, agent_service_1.listAllAgents)();
|
|
99
|
+
if (agents.length === 0) {
|
|
100
|
+
console.log("No agents found. Create your first agent with: jazz agent create");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
console.log(`Found ${agents.length} agent(s):`);
|
|
104
|
+
console.log();
|
|
105
|
+
agents.forEach((agent, index) => {
|
|
106
|
+
console.log(`${index + 1}. ${agent.name} (${agent.id})`);
|
|
107
|
+
console.log(` Description: ${agent.description}`);
|
|
108
|
+
console.log(` Status: ${agent.status}`);
|
|
109
|
+
console.log(` Tasks: ${agent.config.tasks.length}`);
|
|
110
|
+
console.log(` Created: ${agent.createdAt.toISOString()}`);
|
|
111
|
+
console.log(` Updated: ${agent.updatedAt.toISOString()}`);
|
|
112
|
+
console.log();
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Run an agent via CLI command
|
|
118
|
+
*
|
|
119
|
+
* Executes the specified agent, including all its configured tasks. Supports
|
|
120
|
+
* dry-run mode for testing and watch mode for continuous execution. For Gmail
|
|
121
|
+
* tasks, it displays formatted email results including subject, sender, date,
|
|
122
|
+
* and snippet information.
|
|
123
|
+
*
|
|
124
|
+
* @param agentId - The unique identifier of the agent to run
|
|
125
|
+
* @param options - Execution options including watch and dry-run modes
|
|
126
|
+
* @returns An Effect that resolves when the agent execution completes
|
|
127
|
+
*
|
|
128
|
+
* @throws {StorageError} When there's an error accessing storage
|
|
129
|
+
* @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* yield* runAgentCommand("agent-123", { dryRun: true });
|
|
134
|
+
* // Output: Shows what would be executed without actually running
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function runAgentCommand(agentId, options) {
|
|
138
|
+
return effect_1.Effect.gen(function* () {
|
|
139
|
+
const agent = yield* (0, agent_service_1.getAgentById)(agentId);
|
|
140
|
+
console.log(`🚀 Running agent: ${agent.name} (${agent.id})`);
|
|
141
|
+
console.log(` Description: ${agent.description}`);
|
|
142
|
+
console.log(` Status: ${agent.status}`);
|
|
143
|
+
console.log(` Tasks: ${agent.config.tasks.length}`);
|
|
144
|
+
if (options.dryRun) {
|
|
145
|
+
console.log(` Mode: DRY RUN (no actual execution)`);
|
|
146
|
+
console.log();
|
|
147
|
+
console.log("Tasks that would be executed:");
|
|
148
|
+
agent.config.tasks.forEach((task, index) => {
|
|
149
|
+
console.log(` ${index + 1}. ${task.name} (${task.type})`);
|
|
150
|
+
console.log(` Description: ${task.description}`);
|
|
151
|
+
if (task.dependencies && task.dependencies.length > 0) {
|
|
152
|
+
console.log(` Dependencies: ${task.dependencies.join(", ")}`);
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
if (options.watch) {
|
|
158
|
+
console.log(` Mode: WATCH (continuous execution)`);
|
|
159
|
+
}
|
|
160
|
+
console.log();
|
|
161
|
+
// Check if this agent has Gmail tasks
|
|
162
|
+
const gmailTasks = agent.config.tasks.filter((task) => task.type === "gmail");
|
|
163
|
+
if (gmailTasks.length > 0) {
|
|
164
|
+
console.log(`🔍 Found ${gmailTasks.length} Gmail task(s) to execute`);
|
|
165
|
+
// Import the Gmail task executor dynamically
|
|
166
|
+
// Execute each Gmail task
|
|
167
|
+
for (const task of gmailTasks) {
|
|
168
|
+
console.log(`\n📨 Executing Gmail task: ${task.name}`);
|
|
169
|
+
console.log(` Operation: ${task.config.gmailOperation}`);
|
|
170
|
+
const result = yield* (0, gmail_agent_1.executeGmailTask)(task).pipe(effect_1.Effect.catchAll((error) => effect_1.Effect.succeed({
|
|
171
|
+
taskId: task.id,
|
|
172
|
+
status: "failure",
|
|
173
|
+
error: error instanceof Error ? error.message : String(error),
|
|
174
|
+
duration: 0,
|
|
175
|
+
timestamp: new Date(),
|
|
176
|
+
output: "[]",
|
|
177
|
+
})));
|
|
178
|
+
if (result.status === "success") {
|
|
179
|
+
console.log(`✅ Task completed successfully in ${result.duration}ms`);
|
|
180
|
+
// Display the output based on the operation
|
|
181
|
+
if (task.config.gmailOperation === "listEmails" ||
|
|
182
|
+
task.config.gmailOperation === "searchEmails") {
|
|
183
|
+
try {
|
|
184
|
+
const emails = JSON.parse(result.output || "[]");
|
|
185
|
+
console.log(`\n📬 Found ${emails.length} email(s):`);
|
|
186
|
+
emails.forEach((email, index) => {
|
|
187
|
+
console.log(`\n${index + 1}. ${email.subject}`);
|
|
188
|
+
console.log(` From: ${email.from}`);
|
|
189
|
+
console.log(` Date: ${new Date(email.date).toLocaleString()}`);
|
|
190
|
+
console.log(` ${email.snippet}`);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
catch {
|
|
194
|
+
console.log(`\n${result.output}`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
console.log(`\n${result.output}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
console.log(`❌ Task failed: ${result.error}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
console.log("⚠️ No Gmail tasks found in this agent.");
|
|
208
|
+
console.log(" Other task types are not yet implemented.");
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Delete an agent via CLI command
|
|
214
|
+
*
|
|
215
|
+
* Removes the specified agent from storage after confirming the deletion.
|
|
216
|
+
* This operation is irreversible and will permanently delete the agent
|
|
217
|
+
* and all its associated data.
|
|
218
|
+
*
|
|
219
|
+
* @param agentId - The unique identifier of the agent to delete
|
|
220
|
+
* @returns An Effect that resolves when the agent is deleted successfully
|
|
221
|
+
*
|
|
222
|
+
* @throws {StorageError} When there's an error accessing storage
|
|
223
|
+
* @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* yield* deleteAgentCommand("agent-123");
|
|
228
|
+
* // Output: Confirmation message and deletion success
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
function deleteAgentCommand(agentId) {
|
|
232
|
+
return effect_1.Effect.gen(function* () {
|
|
233
|
+
const agentService = yield* agent_service_1.AgentServiceTag;
|
|
234
|
+
// First check if agent exists
|
|
235
|
+
const agent = yield* agentService.getAgent(agentId);
|
|
236
|
+
// Delete the agent
|
|
237
|
+
yield* agentService.deleteAgent(agentId);
|
|
238
|
+
console.log(`🗑️ Agent deleted successfully!`);
|
|
239
|
+
console.log(` Name: ${agent.name}`);
|
|
240
|
+
console.log(` ID: ${agent.id}`);
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Get agent details via CLI command
|
|
245
|
+
*
|
|
246
|
+
* Retrieves and displays detailed information about a specific agent including
|
|
247
|
+
* its configuration, tasks, and metadata in a formatted output.
|
|
248
|
+
*
|
|
249
|
+
* @param agentId - The unique identifier of the agent to retrieve
|
|
250
|
+
* @returns An Effect that resolves when the agent details are displayed
|
|
251
|
+
*
|
|
252
|
+
* @throws {StorageError} When there's an error accessing storage
|
|
253
|
+
* @throws {StorageNotFoundError} When the agent with the given ID doesn't exist
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* yield* getAgentCommand("agent-123");
|
|
258
|
+
* // Output: Detailed agent information including config and tasks
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
function getAgentCommand(agentId) {
|
|
262
|
+
return effect_1.Effect.gen(function* () {
|
|
263
|
+
const agent = yield* (0, agent_service_1.getAgentById)(agentId);
|
|
264
|
+
console.log(`📋 Agent Details:`);
|
|
265
|
+
console.log(` ID: ${agent.id}`);
|
|
266
|
+
console.log(` Name: ${agent.name}`);
|
|
267
|
+
console.log(` Description: ${agent.description}`);
|
|
268
|
+
console.log(` Status: ${agent.status}`);
|
|
269
|
+
console.log(` Created: ${agent.createdAt.toISOString()}`);
|
|
270
|
+
console.log(` Updated: ${agent.updatedAt.toISOString()}`);
|
|
271
|
+
console.log();
|
|
272
|
+
console.log(`⚙️ Configuration:`);
|
|
273
|
+
console.log(` Timeout: ${agent.config.timeout || "default"}ms`);
|
|
274
|
+
console.log(` Tasks: ${agent.config.tasks.length}`);
|
|
275
|
+
if (agent.config.retryPolicy) {
|
|
276
|
+
console.log(` Retry Policy:`);
|
|
277
|
+
console.log(` Max Retries: ${agent.config.retryPolicy.maxRetries}`);
|
|
278
|
+
console.log(` Delay: ${agent.config.retryPolicy.delay}ms`);
|
|
279
|
+
console.log(` Backoff: ${agent.config.retryPolicy.backoff}`);
|
|
280
|
+
}
|
|
281
|
+
if (agent.config.environment && Object.keys(agent.config.environment).length > 0) {
|
|
282
|
+
console.log(` Environment Variables: ${Object.keys(agent.config.environment).length}`);
|
|
283
|
+
}
|
|
284
|
+
if (agent.config.schedule) {
|
|
285
|
+
console.log(` Schedule: ${agent.config.schedule.type} - ${agent.config.schedule.value}`);
|
|
286
|
+
}
|
|
287
|
+
console.log();
|
|
288
|
+
if (agent.config.tasks.length > 0) {
|
|
289
|
+
console.log(`📝 Tasks:`);
|
|
290
|
+
agent.config.tasks.forEach((task, index) => {
|
|
291
|
+
console.log(` ${index + 1}. ${task.name} (${task.type})`);
|
|
292
|
+
console.log(` Description: ${task.description}`);
|
|
293
|
+
console.log(` ID: ${task.id}`);
|
|
294
|
+
if (task.dependencies && task.dependencies.length > 0) {
|
|
295
|
+
console.log(` Dependencies: ${task.dependencies.join(", ")}`);
|
|
296
|
+
}
|
|
297
|
+
if (task.maxRetries !== undefined) {
|
|
298
|
+
console.log(` Max Retries: ${task.maxRetries}`);
|
|
299
|
+
}
|
|
300
|
+
// Show task-specific config
|
|
301
|
+
switch (task.type) {
|
|
302
|
+
case "command":
|
|
303
|
+
if (task.config.command) {
|
|
304
|
+
console.log(` Command: ${task.config.command}`);
|
|
305
|
+
}
|
|
306
|
+
break;
|
|
307
|
+
case "script":
|
|
308
|
+
if (task.config.script) {
|
|
309
|
+
console.log(` Script: ${task.config.script.substring(0, 100)}${task.config.script.length > 100 ? "..." : ""}`);
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
case "api":
|
|
313
|
+
if (task.config.url) {
|
|
314
|
+
console.log(` URL: ${task.config.url}`);
|
|
315
|
+
if (task.config.method) {
|
|
316
|
+
console.log(` Method: ${task.config.method}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
break;
|
|
320
|
+
case "file":
|
|
321
|
+
if (task.config.filePath) {
|
|
322
|
+
console.log(` File Path: ${task.config.filePath}`);
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
case "gmail":
|
|
326
|
+
if (task.config.gmailOperation) {
|
|
327
|
+
console.log(` Gmail Operation: ${task.config.gmailOperation}`);
|
|
328
|
+
if (task.config.gmailQuery) {
|
|
329
|
+
console.log(` Query: ${task.config.gmailQuery}`);
|
|
330
|
+
}
|
|
331
|
+
if (task.config.gmailMaxResults) {
|
|
332
|
+
console.log(` Max Results: ${task.config.gmailMaxResults}`);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
console.log();
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
console.log(`📝 No tasks configured for this agent.`);
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
//# sourceMappingURL=task-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"task-agent.js","sourceRoot":"","sources":["../../../src/cli/commands/task-agent.ts"],"names":[],"mappings":";;AAoDA,gDA6DC;AAkBD,8CAsBC;AAuBD,0CA8FC;AAqBD,gDAgBC;AAoBD,0CAgGC;AAvaD,mCAAgC;AAChC,kEAKwC;AACxC,8DAAgE;AAWhE;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,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,CAAC;wBAC1D,CAAC;wBACD,MAAM;oBACR,KAAK,OAAO;wBACV,IAAI,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;4BAC/B,OAAO,CAAC,GAAG,CAAC,0BAA0B,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;4BACpE,IAAI,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gCAC3B,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;4BACxD,CAAC;4BACD,IAAI,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC;gCAChC,OAAO,CAAC,GAAG,CAAC,sBAAsB,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;4BACnE,CAAC;wBACH,CAAC;wBACD,MAAM;gBACV,CAAC;gBACD,OAAO,CAAC,GAAG,EAAE,CAAC;YAChB,CAAC,CAAC,CAAC;QACL,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QACxD,CAAC;IACH,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type ChatMessage } from "../../services/llm/types";
|
|
3
|
+
export interface AgentPromptTemplate {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description: string;
|
|
6
|
+
readonly systemPrompt: string;
|
|
7
|
+
readonly userPromptTemplate: string;
|
|
8
|
+
readonly toolDescriptions?: Record<string, string>;
|
|
9
|
+
}
|
|
10
|
+
export interface AgentPromptOptions {
|
|
11
|
+
readonly agentName: string;
|
|
12
|
+
readonly agentDescription: string;
|
|
13
|
+
readonly userInput: string;
|
|
14
|
+
readonly conversationHistory?: ChatMessage[];
|
|
15
|
+
readonly toolNames?: readonly string[];
|
|
16
|
+
readonly availableTools?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export declare class AgentPromptBuilder {
|
|
19
|
+
private templates;
|
|
20
|
+
constructor();
|
|
21
|
+
/**
|
|
22
|
+
* Get current system information including date and OS details
|
|
23
|
+
*/
|
|
24
|
+
private getSystemInfo;
|
|
25
|
+
/**
|
|
26
|
+
* Get a prompt template by name
|
|
27
|
+
*/
|
|
28
|
+
getTemplate(name: string): Effect.Effect<AgentPromptTemplate, Error>;
|
|
29
|
+
/**
|
|
30
|
+
* List available prompt templates
|
|
31
|
+
*/
|
|
32
|
+
listTemplates(): Effect.Effect<readonly string[], never>;
|
|
33
|
+
/**
|
|
34
|
+
* Build a system prompt from a template and options
|
|
35
|
+
*/
|
|
36
|
+
buildSystemPrompt(templateName: string, options: AgentPromptOptions): Effect.Effect<string, Error>;
|
|
37
|
+
/**
|
|
38
|
+
* Build a user prompt from a template and options
|
|
39
|
+
*/
|
|
40
|
+
buildUserPrompt(templateName: string, options: AgentPromptOptions): Effect.Effect<string, Error>;
|
|
41
|
+
/**
|
|
42
|
+
* Build complete messages for an agent, including system prompt and conversation history
|
|
43
|
+
*/
|
|
44
|
+
buildAgentMessages(templateName: string, options: AgentPromptOptions): Effect.Effect<ChatMessage[], Error>;
|
|
45
|
+
}
|
|
46
|
+
export declare const agentPromptBuilder: AgentPromptBuilder;
|
|
47
|
+
//# sourceMappingURL=agent-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-prompt.d.ts","sourceRoot":"","sources":["../../../src/core/agent/agent-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,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-0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentPromptBuilder = exports.AgentPromptBuilder = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const effect_1 = require("effect");
|
|
6
|
+
const os = tslib_1.__importStar(require("os"));
|
|
7
|
+
const v2_1 = require("./prompts/default/v2");
|
|
8
|
+
const v2_2 = require("./prompts/gmail/v2");
|
|
9
|
+
class AgentPromptBuilder {
|
|
10
|
+
templates;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.templates = {
|
|
13
|
+
default: {
|
|
14
|
+
name: "Default Agent",
|
|
15
|
+
description: "A general-purpose agent that can assist with various tasks.",
|
|
16
|
+
systemPrompt: v2_1.DEFAULT_PROMPT_V2,
|
|
17
|
+
userPromptTemplate: "{userInput}",
|
|
18
|
+
},
|
|
19
|
+
gmail: {
|
|
20
|
+
name: "Gmail Agent",
|
|
21
|
+
description: "An agent specialized in handling email-related tasks.",
|
|
22
|
+
systemPrompt: v2_2.GMAIL_PROMPT_V2,
|
|
23
|
+
userPromptTemplate: "{userInput}",
|
|
24
|
+
toolDescriptions: {
|
|
25
|
+
listEmails: "List the user's emails with optional filtering.",
|
|
26
|
+
getEmail: "Get the full content of a specific email by ID.",
|
|
27
|
+
searchEmails: "Search for emails matching specific criteria.",
|
|
28
|
+
sendEmail: "Draft an email on behalf of the user (does not send).",
|
|
29
|
+
trashEmail: "Trash an email by ID.",
|
|
30
|
+
batchModifyEmails: "Batch modify emails by ID.",
|
|
31
|
+
deleteEmail: "Delete an email by ID.",
|
|
32
|
+
deleteLabel: "Delete a label by ID.",
|
|
33
|
+
addLabelsToEmail: "Add labels to an email by ID.",
|
|
34
|
+
removeLabelsFromEmail: "Remove labels from an email by ID.",
|
|
35
|
+
listLabels: "List the user's labels.",
|
|
36
|
+
createLabel: "Create a new label.",
|
|
37
|
+
updateLabel: "Update a label by ID.",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get current system information including date and OS details
|
|
44
|
+
*/
|
|
45
|
+
getSystemInfo() {
|
|
46
|
+
return effect_1.Effect.sync(() => {
|
|
47
|
+
const currentDate = new Date().toISOString();
|
|
48
|
+
const platform = os.platform();
|
|
49
|
+
const arch = os.arch();
|
|
50
|
+
const release = os.release();
|
|
51
|
+
const hostname = os.hostname();
|
|
52
|
+
const username = os.userInfo().username;
|
|
53
|
+
const shell = process.env["SHELL"] || "unknown";
|
|
54
|
+
const workingDirectory = process.cwd();
|
|
55
|
+
const systemInfo = `${platform} ${release} (${arch}) on ${hostname}`;
|
|
56
|
+
const userInfo = `${username} using ${shell.split("/").pop() || "shell"}`;
|
|
57
|
+
return { currentDate, systemInfo, userInfo, workingDirectory };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Get a prompt template by name
|
|
62
|
+
*/
|
|
63
|
+
getTemplate(name) {
|
|
64
|
+
return effect_1.Effect.try({
|
|
65
|
+
try: () => {
|
|
66
|
+
const template = this.templates[name];
|
|
67
|
+
if (!template) {
|
|
68
|
+
throw new Error(`Prompt template not found: ${name}`);
|
|
69
|
+
}
|
|
70
|
+
return template;
|
|
71
|
+
},
|
|
72
|
+
catch: (error) => (error instanceof Error ? error : new Error(String(error))),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* List available prompt templates
|
|
77
|
+
*/
|
|
78
|
+
listTemplates() {
|
|
79
|
+
return effect_1.Effect.succeed(Object.keys(this.templates));
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Build a system prompt from a template and options
|
|
83
|
+
*/
|
|
84
|
+
buildSystemPrompt(templateName, options) {
|
|
85
|
+
return effect_1.Effect.gen(function* () {
|
|
86
|
+
const template = yield* this.getTemplate(templateName);
|
|
87
|
+
const { currentDate, systemInfo, userInfo, workingDirectory } = yield* this.getSystemInfo();
|
|
88
|
+
// Replace placeholders in system prompt
|
|
89
|
+
const systemPrompt = template.systemPrompt
|
|
90
|
+
.replace("{agentName}", options.agentName)
|
|
91
|
+
.replace("{agentDescription}", options.agentDescription)
|
|
92
|
+
.replace("{currentDate}", currentDate)
|
|
93
|
+
.replace("{systemInfo}", systemInfo)
|
|
94
|
+
.replace("{userInfo}", userInfo)
|
|
95
|
+
.replace("{workingDirectory}", workingDirectory);
|
|
96
|
+
return systemPrompt;
|
|
97
|
+
}.bind(this));
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Build a user prompt from a template and options
|
|
101
|
+
*/
|
|
102
|
+
buildUserPrompt(templateName, options) {
|
|
103
|
+
return effect_1.Effect.gen(function* () {
|
|
104
|
+
const template = yield* this.getTemplate(templateName);
|
|
105
|
+
return template.userPromptTemplate.replace("{userInput}", options.userInput);
|
|
106
|
+
}.bind(this));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build complete messages for an agent, including system prompt and conversation history
|
|
110
|
+
*/
|
|
111
|
+
buildAgentMessages(templateName, options) {
|
|
112
|
+
return effect_1.Effect.gen(function* () {
|
|
113
|
+
const systemPrompt = yield* this.buildSystemPrompt(templateName, options);
|
|
114
|
+
const userPrompt = yield* this.buildUserPrompt(templateName, options);
|
|
115
|
+
const messages = [{ role: "system", content: systemPrompt }];
|
|
116
|
+
// Add conversation history if available
|
|
117
|
+
if (options.conversationHistory && options.conversationHistory.length > 0) {
|
|
118
|
+
// Filter out system messages from history
|
|
119
|
+
const filteredHistory = options.conversationHistory.filter((msg) => msg.role !== "system");
|
|
120
|
+
messages.push(...filteredHistory);
|
|
121
|
+
}
|
|
122
|
+
// Add the current user input if not already in history
|
|
123
|
+
if (!options.conversationHistory ||
|
|
124
|
+
options.conversationHistory[options.conversationHistory.length - 1]?.role !== "user") {
|
|
125
|
+
// Safety check: ensure userPrompt is not empty
|
|
126
|
+
if (userPrompt && userPrompt.trim().length > 0) {
|
|
127
|
+
messages.push({ role: "user", content: userPrompt });
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// If userPrompt is empty, use the original userInput
|
|
131
|
+
if (options.userInput && options.userInput.trim().length > 0) {
|
|
132
|
+
messages.push({ role: "user", content: options.userInput });
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Final safety check: ensure we never return an empty messages array
|
|
137
|
+
if (messages.length === 0) {
|
|
138
|
+
throw new Error(`Cannot create empty messages array - at least system message should be present. Template: ${templateName}, userInput: "${options.userInput}", userPrompt: "${userPrompt}"`);
|
|
139
|
+
}
|
|
140
|
+
return messages;
|
|
141
|
+
}.bind(this));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
exports.AgentPromptBuilder = AgentPromptBuilder;
|
|
145
|
+
exports.agentPromptBuilder = new AgentPromptBuilder();
|
|
146
|
+
//# sourceMappingURL=agent-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-prompt.js","sourceRoot":"","sources":["../../../src/core/agent/agent-prompt.ts"],"names":[],"mappings":";;;;AAAA,mCAAgC;AAChC,+CAAyB;AAEzB,6CAAyD;AACzD,2CAAqD;AAmBrD,MAAa,kBAAkB;IACrB,SAAS,CAAsC;IAEvD;QACE,IAAI,CAAC,SAAS,GAAG;YACf,OAAO,EAAE;gBACP,IAAI,EAAE,eAAe;gBACrB,WAAW,EAAE,6DAA6D;gBAC1E,YAAY,EAAE,sBAAiB;gBAC/B,kBAAkB,EAAE,aAAa;aAClC;YACD,KAAK,EAAE;gBACL,IAAI,EAAE,aAAa;gBACnB,WAAW,EAAE,uDAAuD;gBACpE,YAAY,EAAE,oBAAe;gBAC7B,kBAAkB,EAAE,aAAa;gBACjC,gBAAgB,EAAE;oBAChB,UAAU,EAAE,iDAAiD;oBAC7D,QAAQ,EAAE,iDAAiD;oBAC3D,YAAY,EAAE,+CAA+C;oBAC7D,SAAS,EAAE,uDAAuD;oBACl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O,CAAC,mBAAmB;gBAC5B,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,mBAAmB,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM,EACpF,CAAC;gBACD,+CAA+C;gBAC/C,IAAI,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;gBACvD,CAAC;qBAAM,CAAC;oBACN,qDAAqD;oBACrD,IAAI,OAAO,CAAC,SAAS,IAAI,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;oBAC9D,CAAC;gBACH,CAAC;YACH,CAAC;YAED,qEAAqE;YACrE,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CACb,6FAA6F,YAAY,iBAAiB,OAAO,CAAC,SAAS,mBAAmB,UAAU,GAAG,CAC5K,CAAC;YACJ,CAAC;YAED,OAAO,QAAQ,CAAC;QAClB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAC;IACJ,CAAC;CACF;AA5KD,gDA4KC;AAEY,QAAA,kBAAkB,GAAG,IAAI,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Effect } from "effect";
|
|
2
|
+
import { type ConfigService } from "../../services/config";
|
|
3
|
+
import { LLMRateLimitError, type ChatMessage, type LLMService, type ToolCall } from "../../services/llm/types";
|
|
4
|
+
import { type LoggerService } from "../../services/logger";
|
|
5
|
+
import { type Agent } from "../types";
|
|
6
|
+
import { type ToolExecutionContext, type ToolExecutionResult, type ToolRegistry } from "./tools/tool-registry";
|
|
7
|
+
/**
|
|
8
|
+
* Agent runner for executing agent conversations
|
|
9
|
+
*/
|
|
10
|
+
export interface AgentRunnerOptions {
|
|
11
|
+
readonly agent: Agent;
|
|
12
|
+
readonly userInput: string;
|
|
13
|
+
readonly conversationId?: string;
|
|
14
|
+
readonly userId?: string;
|
|
15
|
+
readonly maxIterations?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Full conversation history to date, including prior assistant, user, and tool messages.
|
|
18
|
+
* Use this to preserve context across turns (e.g., approval flows).
|
|
19
|
+
*/
|
|
20
|
+
readonly conversationHistory?: ChatMessage[];
|
|
21
|
+
}
|
|
22
|
+
export interface AgentResponse {
|
|
23
|
+
readonly content: string;
|
|
24
|
+
readonly conversationId: string;
|
|
25
|
+
readonly toolCalls?: ToolCall[];
|
|
26
|
+
readonly toolResults?: Record<string, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* The full message list used for this turn, including system, user, assistant, and tool messages.
|
|
29
|
+
* Pass this back on the next turn to retain context across approvals and multi-step tasks.
|
|
30
|
+
*/
|
|
31
|
+
readonly messages?: ChatMessage[] | undefined;
|
|
32
|
+
}
|
|
33
|
+
export declare class AgentRunner {
|
|
34
|
+
/**
|
|
35
|
+
* Run an agent conversation
|
|
36
|
+
*/
|
|
37
|
+
static run(options: AgentRunnerOptions): Effect.Effect<AgentResponse, LLMRateLimitError | Error, LLMService | ToolRegistry | LoggerService | ConfigService>;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Execute a tool by name with the provided arguments
|
|
41
|
+
*
|
|
42
|
+
* Finds the specified tool in the registry and executes it with the given arguments
|
|
43
|
+
* and context. Provides comprehensive logging of the execution process including
|
|
44
|
+
* start, success, and error states.
|
|
45
|
+
*
|
|
46
|
+
* @param name - The name of the tool to execute
|
|
47
|
+
* @param args - The arguments to pass to the tool
|
|
48
|
+
* @param context - The execution context containing agent and conversation information
|
|
49
|
+
* @returns An Effect that resolves to the tool execution result
|
|
50
|
+
*
|
|
51
|
+
* @throws {Error} When the tool is not found or execution fails
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const result = yield* executeTool(
|
|
56
|
+
* "gmail_list_emails",
|
|
57
|
+
* { query: "is:unread" },
|
|
58
|
+
* { agentId: "agent-123", conversationId: "conv-456" }
|
|
59
|
+
* );
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare function executeTool(name: string, args: Record<string, unknown>, context: ToolExecutionContext): Effect.Effect<ToolExecutionResult, Error, ToolRegistry | LoggerService | ConfigService>;
|
|
63
|
+
//# sourceMappingURL=agent-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-runner.d.ts","sourceRoot":"","sources":["../../../src/core/agent/agent-runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAY,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAsB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EACL,iBAAiB,EAEjB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAoB,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC7E,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,UAAU,CAAC;AAGtC,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AAEH,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,aAAa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