lettactl 0.1.1
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 +606 -0
- package/dist/commands/apply.d.ts +6 -0
- package/dist/commands/apply.d.ts.map +1 -0
- package/dist/commands/apply.js +337 -0
- package/dist/commands/apply.js.map +1 -0
- package/dist/commands/create.d.ts +13 -0
- package/dist/commands/create.d.ts.map +1 -0
- package/dist/commands/create.js +72 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/delete.d.ts +9 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +179 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/describe.d.ts +5 -0
- package/dist/commands/describe.d.ts.map +1 -0
- package/dist/commands/describe.js +121 -0
- package/dist/commands/describe.js.map +1 -0
- package/dist/commands/export.d.ts +6 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +79 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/get.d.ts +5 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +32 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/import.d.ts +10 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +94 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/messages.d.ts +21 -0
- package/dist/commands/messages.d.ts.map +1 -0
- package/dist/commands/messages.js +254 -0
- package/dist/commands/messages.js.map +1 -0
- package/dist/commands/update.d.ts +11 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +63 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +230 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/agent-manager.d.ts +125 -0
- package/dist/lib/agent-manager.d.ts.map +1 -0
- package/dist/lib/agent-manager.js +254 -0
- package/dist/lib/agent-manager.js.map +1 -0
- package/dist/lib/agent-resolver.d.ts +12 -0
- package/dist/lib/agent-resolver.d.ts.map +1 -0
- package/dist/lib/agent-resolver.js +27 -0
- package/dist/lib/agent-resolver.js.map +1 -0
- package/dist/lib/block-manager.d.ts +63 -0
- package/dist/lib/block-manager.d.ts.map +1 -0
- package/dist/lib/block-manager.js +288 -0
- package/dist/lib/block-manager.js.map +1 -0
- package/dist/lib/diff-engine.d.ts +129 -0
- package/dist/lib/diff-engine.d.ts.map +1 -0
- package/dist/lib/diff-engine.js +391 -0
- package/dist/lib/diff-engine.js.map +1 -0
- package/dist/lib/error-handler.d.ts +9 -0
- package/dist/lib/error-handler.d.ts.map +1 -0
- package/dist/lib/error-handler.js +25 -0
- package/dist/lib/error-handler.js.map +1 -0
- package/dist/lib/file-content-tracker.d.ts +42 -0
- package/dist/lib/file-content-tracker.d.ts.map +1 -0
- package/dist/lib/file-content-tracker.js +128 -0
- package/dist/lib/file-content-tracker.js.map +1 -0
- package/dist/lib/fleet-parser.d.ts +14 -0
- package/dist/lib/fleet-parser.d.ts.map +1 -0
- package/dist/lib/fleet-parser.js +282 -0
- package/dist/lib/fleet-parser.js.map +1 -0
- package/dist/lib/letta-client.d.ts +61 -0
- package/dist/lib/letta-client.d.ts.map +1 -0
- package/dist/lib/letta-client.js +208 -0
- package/dist/lib/letta-client.js.map +1 -0
- package/dist/lib/output-formatter.d.ts +15 -0
- package/dist/lib/output-formatter.d.ts.map +1 -0
- package/dist/lib/output-formatter.js +51 -0
- package/dist/lib/output-formatter.js.map +1 -0
- package/dist/lib/resource-classifier.d.ts +27 -0
- package/dist/lib/resource-classifier.d.ts.map +1 -0
- package/dist/lib/resource-classifier.js +84 -0
- package/dist/lib/resource-classifier.js.map +1 -0
- package/dist/lib/response-normalizer.d.ts +6 -0
- package/dist/lib/response-normalizer.d.ts.map +1 -0
- package/dist/lib/response-normalizer.js +27 -0
- package/dist/lib/response-normalizer.js.map +1 -0
- package/dist/lib/validators.d.ts +9 -0
- package/dist/lib/validators.d.ts.map +1 -0
- package/dist/lib/validators.js +26 -0
- package/dist/lib/validators.js.map +1 -0
- package/dist/types/fleet-config.d.ts +44 -0
- package/dist/types/fleet-config.d.ts.map +1 -0
- package/dist/types/fleet-config.js +3 -0
- package/dist/types/fleet-config.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.applyCommand = applyCommand;
|
|
37
|
+
const fleet_parser_1 = require("../lib/fleet-parser");
|
|
38
|
+
const letta_client_1 = require("../lib/letta-client");
|
|
39
|
+
const block_manager_1 = require("../lib/block-manager");
|
|
40
|
+
const agent_manager_1 = require("../lib/agent-manager");
|
|
41
|
+
const diff_engine_1 = require("../lib/diff-engine");
|
|
42
|
+
const file_content_tracker_1 = require("../lib/file-content-tracker");
|
|
43
|
+
const fs = __importStar(require("fs"));
|
|
44
|
+
const path = __importStar(require("path"));
|
|
45
|
+
async function applyCommand(options, command) {
|
|
46
|
+
const verbose = command.parent?.opts().verbose || false;
|
|
47
|
+
try {
|
|
48
|
+
console.log(`Applying configuration from ${options.file}`);
|
|
49
|
+
if (options.dryRun) {
|
|
50
|
+
console.log('Dry-run mode enabled');
|
|
51
|
+
}
|
|
52
|
+
if (options.agent) {
|
|
53
|
+
if (verbose)
|
|
54
|
+
console.log(`Filtering agents by pattern: ${options.agent}`);
|
|
55
|
+
}
|
|
56
|
+
const parser = new fleet_parser_1.FleetParser(options.file);
|
|
57
|
+
const config = await parser.parseFleetConfig(options.file);
|
|
58
|
+
if (verbose)
|
|
59
|
+
console.log(`Found ${config.agents.length} agents in configuration`);
|
|
60
|
+
if (options.dryRun) {
|
|
61
|
+
for (const agent of config.agents) {
|
|
62
|
+
console.log(`Would create/update agent: ${agent.name}`);
|
|
63
|
+
if (agent.folders) {
|
|
64
|
+
for (const folder of agent.folders) {
|
|
65
|
+
console.log(` Would create folder: ${folder.name} with ${folder.files.length} files`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const client = new letta_client_1.LettaClientWrapper();
|
|
72
|
+
const blockManager = new block_manager_1.BlockManager(client);
|
|
73
|
+
const agentManager = new agent_manager_1.AgentManager(client);
|
|
74
|
+
const diffEngine = new diff_engine_1.DiffEngine(client, blockManager, parser.basePath);
|
|
75
|
+
const fileTracker = new file_content_tracker_1.FileContentTracker(parser.basePath);
|
|
76
|
+
const createdFolders = new Map(); // folder name -> folder id
|
|
77
|
+
// Load existing resources for versioning
|
|
78
|
+
if (verbose)
|
|
79
|
+
console.log('Loading existing blocks...');
|
|
80
|
+
await blockManager.loadExistingBlocks();
|
|
81
|
+
if (verbose)
|
|
82
|
+
console.log('Loading existing agents...');
|
|
83
|
+
await agentManager.loadExistingAgents();
|
|
84
|
+
// Process shared blocks first
|
|
85
|
+
const sharedBlockIds = new Map();
|
|
86
|
+
if (config.shared_blocks) {
|
|
87
|
+
if (verbose)
|
|
88
|
+
console.log('Processing shared blocks...');
|
|
89
|
+
for (const sharedBlock of config.shared_blocks) {
|
|
90
|
+
const blockId = await blockManager.getOrCreateSharedBlock(sharedBlock);
|
|
91
|
+
sharedBlockIds.set(sharedBlock.name, blockId);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Generate tool source hashes for all tools in config
|
|
95
|
+
const allToolNames = new Set();
|
|
96
|
+
for (const agent of config.agents) {
|
|
97
|
+
for (const toolName of agent.tools || []) {
|
|
98
|
+
allToolNames.add(toolName);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const globalToolSourceHashes = fileTracker.generateToolSourceHashes(Array.from(allToolNames));
|
|
102
|
+
// Register required tools
|
|
103
|
+
if (verbose)
|
|
104
|
+
console.log('Registering tools...');
|
|
105
|
+
const toolNameToId = await parser.registerRequiredTools(config, client, verbose, globalToolSourceHashes);
|
|
106
|
+
// Create/get all folders with duplicate prevention
|
|
107
|
+
if (verbose)
|
|
108
|
+
console.log('Processing folders...');
|
|
109
|
+
const foldersResponse = await client.listFolders();
|
|
110
|
+
const existingFolders = Array.isArray(foldersResponse) ? foldersResponse : foldersResponse.items || [];
|
|
111
|
+
for (const agent of config.agents) {
|
|
112
|
+
if (options.agent && !agent.name.includes(options.agent))
|
|
113
|
+
continue;
|
|
114
|
+
if (agent.folders) {
|
|
115
|
+
for (const folderConfig of agent.folders) {
|
|
116
|
+
if (createdFolders.has(folderConfig.name)) {
|
|
117
|
+
if (verbose)
|
|
118
|
+
console.log(`Using existing folder: ${folderConfig.name}`);
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
// Check if folder already exists
|
|
122
|
+
let folder = existingFolders.find((f) => f.name === folderConfig.name);
|
|
123
|
+
if (!folder) {
|
|
124
|
+
if (verbose)
|
|
125
|
+
console.log(`Creating folder: ${folderConfig.name}`);
|
|
126
|
+
folder = await client.createFolder({
|
|
127
|
+
name: folderConfig.name,
|
|
128
|
+
embedding: agent.embedding || "letta/letta-free"
|
|
129
|
+
});
|
|
130
|
+
console.log(`Created folder: ${folderConfig.name}`);
|
|
131
|
+
createdFolders.set(folderConfig.name, folder.id);
|
|
132
|
+
// Upload files only to newly created folders
|
|
133
|
+
if (verbose)
|
|
134
|
+
console.log(`Uploading ${folderConfig.files.length} files...`);
|
|
135
|
+
for (const filePath of folderConfig.files) {
|
|
136
|
+
try {
|
|
137
|
+
const resolvedPath = path.resolve(parser.basePath, filePath);
|
|
138
|
+
if (!fs.existsSync(resolvedPath)) {
|
|
139
|
+
console.warn(`File not found, skipping: ${filePath}`);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (verbose)
|
|
143
|
+
console.log(` Uploading ${filePath}...`);
|
|
144
|
+
const fileStream = fs.createReadStream(resolvedPath);
|
|
145
|
+
await client.uploadFileToFolder(fileStream, folder.id, path.basename(filePath));
|
|
146
|
+
if (verbose)
|
|
147
|
+
console.log(` Uploaded: ${filePath}`);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
console.error(` Failed to upload ${filePath}:`, error.message);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
if (verbose)
|
|
156
|
+
console.log(`Using existing folder: ${folderConfig.name}`);
|
|
157
|
+
if (verbose)
|
|
158
|
+
console.log(' (Skipping file upload - files already exist)');
|
|
159
|
+
createdFolders.set(folderConfig.name, folder.id);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
// Create agents with memory blocks
|
|
165
|
+
if (verbose)
|
|
166
|
+
console.log('Processing agents...');
|
|
167
|
+
for (const agent of config.agents) {
|
|
168
|
+
if (options.agent && !agent.name.includes(options.agent))
|
|
169
|
+
continue;
|
|
170
|
+
console.log(`Processing agent: ${agent.name}`);
|
|
171
|
+
if (verbose) {
|
|
172
|
+
console.log(` Description: ${agent.description}`);
|
|
173
|
+
console.log(` Tools: ${agent.tools.join(', ')}`);
|
|
174
|
+
console.log(` Memory blocks: ${agent.memory_blocks?.length || 0}`);
|
|
175
|
+
console.log(` Folders: ${agent.folders?.length || 0}`);
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
// Generate file content hashes for change detection
|
|
179
|
+
const folderContentHashes = fileTracker.generateFolderFileHashes(agent.folders || []);
|
|
180
|
+
// Generate tool source code hashes for change detection
|
|
181
|
+
const toolSourceHashes = fileTracker.generateToolSourceHashes(agent.tools || []);
|
|
182
|
+
// Generate memory block file content hashes for change detection
|
|
183
|
+
const memoryBlockFileHashes = fileTracker.generateMemoryBlockFileHashes(agent.memory_blocks || []);
|
|
184
|
+
// Check if agent needs to be created based on complete configuration
|
|
185
|
+
const { agentName, shouldCreate, existingAgent } = await agentManager.getOrCreateAgentName(agent.name, {
|
|
186
|
+
systemPrompt: agent.system_prompt.value || '',
|
|
187
|
+
tools: agent.tools || [],
|
|
188
|
+
toolSourceHashes,
|
|
189
|
+
model: agent.llm_config?.model,
|
|
190
|
+
embedding: agent.embedding,
|
|
191
|
+
contextWindow: agent.llm_config?.context_window,
|
|
192
|
+
memoryBlocks: (agent.memory_blocks || []).map(block => ({
|
|
193
|
+
name: block.name,
|
|
194
|
+
description: block.description,
|
|
195
|
+
limit: block.limit,
|
|
196
|
+
value: block.value || ''
|
|
197
|
+
})),
|
|
198
|
+
memoryBlockFileHashes,
|
|
199
|
+
folders: (agent.folders || []).map(folder => ({
|
|
200
|
+
name: folder.name,
|
|
201
|
+
files: folder.files,
|
|
202
|
+
fileContentHashes: folderContentHashes.get(folder.name) || {}
|
|
203
|
+
})),
|
|
204
|
+
sharedBlocks: agent.shared_blocks || []
|
|
205
|
+
}, verbose);
|
|
206
|
+
if (!shouldCreate && existingAgent) {
|
|
207
|
+
// Agent exists but may need partial updates
|
|
208
|
+
const agentConfig = {
|
|
209
|
+
systemPrompt: agent.system_prompt.value || '',
|
|
210
|
+
tools: agent.tools || [],
|
|
211
|
+
toolSourceHashes,
|
|
212
|
+
model: agent.llm_config?.model,
|
|
213
|
+
embedding: agent.embedding,
|
|
214
|
+
contextWindow: agent.llm_config?.context_window,
|
|
215
|
+
memoryBlocks: (agent.memory_blocks || []).map(block => ({
|
|
216
|
+
name: block.name,
|
|
217
|
+
description: block.description,
|
|
218
|
+
limit: block.limit,
|
|
219
|
+
value: block.value || ''
|
|
220
|
+
})),
|
|
221
|
+
memoryBlockFileHashes,
|
|
222
|
+
folders: (agent.folders || []).map(folder => ({
|
|
223
|
+
name: folder.name,
|
|
224
|
+
files: folder.files,
|
|
225
|
+
fileContentHashes: folderContentHashes.get(folder.name) || {}
|
|
226
|
+
})),
|
|
227
|
+
sharedBlocks: agent.shared_blocks || []
|
|
228
|
+
};
|
|
229
|
+
// Check if any granular changes are needed
|
|
230
|
+
const changes = agentManager.getConfigChanges(existingAgent, agentConfig);
|
|
231
|
+
if (!changes.hasChanges) {
|
|
232
|
+
console.log(`Agent ${agent.name} already exists and is up to date`);
|
|
233
|
+
continue;
|
|
234
|
+
}
|
|
235
|
+
// Apply partial updates to preserve conversation history
|
|
236
|
+
console.log(`Updating agent ${agent.name} (changed: ${changes.changedComponents.join(', ')})`);
|
|
237
|
+
const updateOperations = await diffEngine.generateUpdateOperations(existingAgent, agentConfig, toolNameToId, createdFolders, verbose);
|
|
238
|
+
await diffEngine.applyUpdateOperations(existingAgent.id, updateOperations, verbose);
|
|
239
|
+
// Update registry with new hashes
|
|
240
|
+
agentManager.updateRegistry(existingAgent.name, agentConfig, existingAgent.id);
|
|
241
|
+
console.log(`Agent ${agent.name} updated successfully (conversation history preserved)`);
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
// Collect all block IDs (shared + agent-specific)
|
|
245
|
+
const blockIds = [];
|
|
246
|
+
// Add shared blocks for this agent
|
|
247
|
+
if (agent.shared_blocks) {
|
|
248
|
+
for (const sharedBlockName of agent.shared_blocks) {
|
|
249
|
+
const sharedBlockId = sharedBlockIds.get(sharedBlockName);
|
|
250
|
+
if (sharedBlockId) {
|
|
251
|
+
blockIds.push(sharedBlockId);
|
|
252
|
+
if (verbose)
|
|
253
|
+
console.log(` Using shared block: ${sharedBlockName}`);
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
console.warn(` Shared block not found: ${sharedBlockName}`);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Create agent-specific memory blocks
|
|
261
|
+
if (agent.memory_blocks) {
|
|
262
|
+
for (const block of agent.memory_blocks) {
|
|
263
|
+
if (verbose)
|
|
264
|
+
console.log(` Processing memory block: ${block.name}`);
|
|
265
|
+
const blockId = await blockManager.getOrCreateAgentBlock(block, agent.name);
|
|
266
|
+
blockIds.push(blockId);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// Create agent
|
|
270
|
+
if (verbose)
|
|
271
|
+
console.log(` Creating agent...`);
|
|
272
|
+
// Resolve tool names to IDs
|
|
273
|
+
const toolIds = [];
|
|
274
|
+
if (agent.tools) {
|
|
275
|
+
for (const toolName of agent.tools) {
|
|
276
|
+
const toolId = toolNameToId.get(toolName);
|
|
277
|
+
if (toolId) {
|
|
278
|
+
toolIds.push(toolId);
|
|
279
|
+
}
|
|
280
|
+
else {
|
|
281
|
+
console.warn(` Tool not found: ${toolName}`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
const createdAgent = await client.createAgent({
|
|
286
|
+
name: agentName,
|
|
287
|
+
model: agent.llm_config?.model || "google_ai/gemini-2.5-pro",
|
|
288
|
+
embedding: agent.embedding || "letta/letta-free",
|
|
289
|
+
system: agent.system_prompt.value || '',
|
|
290
|
+
blockIds: blockIds,
|
|
291
|
+
toolIds: toolIds,
|
|
292
|
+
contextWindowLimit: agent.llm_config?.context_window || 64000
|
|
293
|
+
});
|
|
294
|
+
// Update agent registry with new agent
|
|
295
|
+
agentManager.updateRegistry(agentName, {
|
|
296
|
+
systemPrompt: agent.system_prompt.value || '',
|
|
297
|
+
tools: agent.tools || [],
|
|
298
|
+
model: agent.llm_config?.model,
|
|
299
|
+
embedding: agent.embedding,
|
|
300
|
+
contextWindow: agent.llm_config?.context_window,
|
|
301
|
+
memoryBlocks: (agent.memory_blocks || []).map(block => ({
|
|
302
|
+
name: block.name,
|
|
303
|
+
description: block.description,
|
|
304
|
+
limit: block.limit,
|
|
305
|
+
value: block.value || ''
|
|
306
|
+
})),
|
|
307
|
+
folders: agent.folders || [],
|
|
308
|
+
sharedBlocks: agent.shared_blocks || []
|
|
309
|
+
}, createdAgent.id);
|
|
310
|
+
// Attach folders to agent
|
|
311
|
+
if (agent.folders) {
|
|
312
|
+
for (const folderConfig of agent.folders) {
|
|
313
|
+
const folderId = createdFolders.get(folderConfig.name);
|
|
314
|
+
if (folderId) {
|
|
315
|
+
if (verbose)
|
|
316
|
+
console.log(` Attaching folder ${folderConfig.name}`);
|
|
317
|
+
await client.attachFolderToAgent(createdAgent.id, folderId);
|
|
318
|
+
if (verbose)
|
|
319
|
+
console.log(` Folder attached`);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
console.log(`Agent ${agentName} created successfully`);
|
|
324
|
+
}
|
|
325
|
+
catch (error) {
|
|
326
|
+
console.error(`Failed to create agent ${agent.name}:`, error.message);
|
|
327
|
+
throw error;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
console.log('Apply completed successfully');
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
console.error('Apply failed:', error);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
//# sourceMappingURL=apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply.js","sourceRoot":"","sources":["../../src/commands/apply.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,oCAwUC;AAlVD,sDAAkD;AAClD,sDAAyD;AACzD,wDAAoD;AACpD,wDAAoD;AACpD,oDAAgD;AAChD,sEAAiE;AACjE,uCAAyB;AACzB,2CAA6B;AAGtB,KAAK,UAAU,YAAY,CAAC,OAA2D,EAAE,OAAY;IAC1G,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,OAAO,IAAI,KAAK,CAAC;IACxD,IAAI,CAAC;QACH,OAAO,CAAC,GAAG,CAAC,+BAA+B,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;QAE3D,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC;QACtC,CAAC;QAED,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;YAClB,IAAI,OAAO;gBAAE,OAAO,CAAC,GAAG,CAAC,gCAAgC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5E,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,0BAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7C,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAE3D,IAAI,OAAO;YAAE,OAAO,CAAC,GAAG,C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AAe,EAAE,KAAK,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default function createCommand(resource: string, name: string, options: {
|
|
2
|
+
description?: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
system?: string;
|
|
5
|
+
contextWindow?: number;
|
|
6
|
+
embedding?: string;
|
|
7
|
+
timezone?: string;
|
|
8
|
+
tags?: string;
|
|
9
|
+
agentType?: string;
|
|
10
|
+
tools?: string;
|
|
11
|
+
memoryBlocks?: string;
|
|
12
|
+
}, command: any): Promise<void>;
|
|
13
|
+
//# sourceMappingURL=create.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":"AAEA,wBAA8B,aAAa,CACzC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,EACD,OAAO,EAAE,GAAG,iBAoEb"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = createCommand;
|
|
4
|
+
const letta_client_1 = require("../lib/letta-client");
|
|
5
|
+
async function createCommand(resource, name, options, command) {
|
|
6
|
+
const verbose = command.parent?.opts().verbose || false;
|
|
7
|
+
try {
|
|
8
|
+
if (resource !== 'agent') {
|
|
9
|
+
throw new Error('Only "agent" resource is currently supported for creation');
|
|
10
|
+
}
|
|
11
|
+
const client = new letta_client_1.LettaClientWrapper();
|
|
12
|
+
if (verbose) {
|
|
13
|
+
console.log(`Creating agent: ${name}`);
|
|
14
|
+
}
|
|
15
|
+
// Build create payload
|
|
16
|
+
const createPayload = {
|
|
17
|
+
name: name
|
|
18
|
+
};
|
|
19
|
+
if (options.description)
|
|
20
|
+
createPayload.description = options.description;
|
|
21
|
+
if (options.model)
|
|
22
|
+
createPayload.model = options.model;
|
|
23
|
+
if (options.system)
|
|
24
|
+
createPayload.system = options.system;
|
|
25
|
+
if (options.contextWindow)
|
|
26
|
+
createPayload.context_window_limit = options.contextWindow;
|
|
27
|
+
if (options.embedding)
|
|
28
|
+
createPayload.embedding = options.embedding;
|
|
29
|
+
if (options.timezone)
|
|
30
|
+
createPayload.timezone = options.timezone;
|
|
31
|
+
if (options.agentType)
|
|
32
|
+
createPayload.agent_type = options.agentType;
|
|
33
|
+
if (options.tags) {
|
|
34
|
+
createPayload.tags = options.tags.split(',').map(tag => tag.trim());
|
|
35
|
+
}
|
|
36
|
+
if (options.tools) {
|
|
37
|
+
// Assume tools are provided as comma-separated tool IDs
|
|
38
|
+
createPayload.tool_ids = options.tools.split(',').map(tool => tool.trim());
|
|
39
|
+
}
|
|
40
|
+
if (options.memoryBlocks) {
|
|
41
|
+
// Assume memory blocks are provided as comma-separated block IDs
|
|
42
|
+
createPayload.block_ids = options.memoryBlocks.split(',').map(block => block.trim());
|
|
43
|
+
}
|
|
44
|
+
// Set defaults if not provided
|
|
45
|
+
if (!createPayload.model)
|
|
46
|
+
createPayload.model = "google_ai/gemini-2.5-pro";
|
|
47
|
+
if (!createPayload.embedding)
|
|
48
|
+
createPayload.embedding = "letta/letta-free";
|
|
49
|
+
if (!createPayload.system)
|
|
50
|
+
createPayload.system = "You are a helpful AI assistant.";
|
|
51
|
+
if (verbose) {
|
|
52
|
+
console.log('Create payload:', JSON.stringify(createPayload, null, 2));
|
|
53
|
+
}
|
|
54
|
+
// Create the agent
|
|
55
|
+
const createdAgent = await client.createAgent(createPayload);
|
|
56
|
+
console.log(`Agent ${name} created successfully`);
|
|
57
|
+
console.log(`Agent ID: ${createdAgent.id}`);
|
|
58
|
+
if (verbose) {
|
|
59
|
+
console.log(`Model: ${createdAgent.model || createPayload.model}`);
|
|
60
|
+
console.log(`Embedding: ${createdAgent.embedding || createPayload.embedding}`);
|
|
61
|
+
if (createPayload.description)
|
|
62
|
+
console.log(`Description: ${createPayload.description}`);
|
|
63
|
+
if (createPayload.tags)
|
|
64
|
+
console.log(`Tags: ${createPayload.tags.join(', ')}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
console.error(`Failed to create agent ${name}:`, error.message);
|
|
69
|
+
throw error;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create.js","sourceRoot":"","sources":["../../src/commands/create.ts"],"names":[],"mappings":";;AAEA,gCAmFC;AArFD,sDAAyD;AAE1C,KAAK,UAAU,aAAa,CACzC,QAAgB,EAChB,IAAY,EACZ,OAWC,EACD,OAAY;IAEZ,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,OAAO,IAAI,KAAK,CAAC;IAExD,IAAI,CAAC;QACH,IAAI,QAAQ,KAAK,OAAO,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;QAC/E,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,iCAAkB,EAAE,CAAC;QAExC,IAAI,OAAO,EAAE,CAAC;YACZ,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QAED,uBAAuB;QACvB,MAAM,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;QACpB,OAAO,CAAC,KAAK,CAAC,0BAA0B,IAAI,GAAG,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;QAChE,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const _default: (resource: string, name: string, options?: {
|
|
2
|
+
force?: boolean;
|
|
3
|
+
} | undefined) => Promise<void>;
|
|
4
|
+
export default _default;
|
|
5
|
+
export declare const deleteAllCommand: (resource: string, options?: {
|
|
6
|
+
force?: boolean;
|
|
7
|
+
pattern?: string;
|
|
8
|
+
} | undefined) => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=delete.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";YAOqF,OAAO;;AA0L5F,wBAAsE;AACtE,eAAO,MAAM,gBAAgB;YA7JnB,OAAO;cACL,MAAM;+BA4J2E,CAAC"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteAllCommand = void 0;
|
|
4
|
+
const letta_client_1 = require("../lib/letta-client");
|
|
5
|
+
const agent_resolver_1 = require("../lib/agent-resolver");
|
|
6
|
+
const resource_classifier_1 = require("../lib/resource-classifier");
|
|
7
|
+
const validators_1 = require("../lib/validators");
|
|
8
|
+
const error_handler_1 = require("../lib/error-handler");
|
|
9
|
+
const response_normalizer_1 = require("../lib/response-normalizer");
|
|
10
|
+
async function deleteCommandImpl(resource, name, options) {
|
|
11
|
+
(0, validators_1.validateResourceType)(resource, ['agent', 'agents']);
|
|
12
|
+
(0, validators_1.validateRequired)(name, 'Agent name', 'lettactl delete agent <name>');
|
|
13
|
+
const client = new letta_client_1.LettaClientWrapper();
|
|
14
|
+
const resolver = new agent_resolver_1.AgentResolver(client);
|
|
15
|
+
// Find agent by name
|
|
16
|
+
const { agent, allAgents } = await resolver.findAgentByName(name);
|
|
17
|
+
if (!options?.force) {
|
|
18
|
+
console.log(`This will permanently delete agent: ${name} (${agent.id})`);
|
|
19
|
+
console.log('This will also delete:');
|
|
20
|
+
console.log(' - Agent-specific memory blocks');
|
|
21
|
+
console.log(' - Agent-specific folders (if not shared)');
|
|
22
|
+
console.log(' - Associated conversation history');
|
|
23
|
+
console.log('Shared blocks and folders will be preserved.');
|
|
24
|
+
console.log('Use --force to confirm deletion');
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
console.log(`Deleting agent: ${name}...`);
|
|
28
|
+
// Use the shared delete logic
|
|
29
|
+
await deleteAgentWithCleanup(client, resolver, agent, allAgents, true);
|
|
30
|
+
console.log(`Agent ${name} and associated resources deleted successfully`);
|
|
31
|
+
}
|
|
32
|
+
async function deleteAllCommandImpl(resource, options) {
|
|
33
|
+
(0, validators_1.validateResourceType)(resource, ['agent', 'agents']);
|
|
34
|
+
const client = new letta_client_1.LettaClientWrapper();
|
|
35
|
+
const resolver = new agent_resolver_1.AgentResolver(client);
|
|
36
|
+
// Get all agents
|
|
37
|
+
const allAgents = await resolver.getAllAgents();
|
|
38
|
+
// Filter agents by pattern if provided
|
|
39
|
+
let agentsToDelete = allAgents;
|
|
40
|
+
if (options?.pattern) {
|
|
41
|
+
const pattern = new RegExp(options.pattern, 'i');
|
|
42
|
+
agentsToDelete = allAgents.filter(agent => pattern.test(agent.name) || pattern.test(agent.id));
|
|
43
|
+
}
|
|
44
|
+
if (agentsToDelete.length === 0) {
|
|
45
|
+
console.log(options?.pattern
|
|
46
|
+
? `No agents found matching pattern: ${options.pattern}`
|
|
47
|
+
: 'No agents found to delete');
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
console.log(`Found ${agentsToDelete.length} agent(s) to delete:`);
|
|
51
|
+
agentsToDelete.forEach((agent, i) => {
|
|
52
|
+
console.log(` ${i + 1}. ${agent.name} (${agent.id})`);
|
|
53
|
+
});
|
|
54
|
+
if (!options?.force) {
|
|
55
|
+
console.log('');
|
|
56
|
+
console.log('This will permanently delete all listed agents and their associated resources:');
|
|
57
|
+
console.log(' - Agent-specific memory blocks');
|
|
58
|
+
console.log(' - Agent-specific folders (if not shared)');
|
|
59
|
+
console.log(' - Associated conversation history');
|
|
60
|
+
console.log('Shared blocks and folders will be preserved.');
|
|
61
|
+
console.log('Use --force to confirm deletion.');
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
console.log('');
|
|
65
|
+
console.log('Starting bulk deletion...');
|
|
66
|
+
// Delete each agent
|
|
67
|
+
for (const agent of agentsToDelete) {
|
|
68
|
+
try {
|
|
69
|
+
console.log(`\nDeleting agent: ${agent.name}...`);
|
|
70
|
+
await deleteAgentWithCleanup(client, resolver, agent, allAgents, false);
|
|
71
|
+
console.log(`✓ Agent ${agent.name} deleted successfully`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
console.error(`✗ Failed to delete agent ${agent.name}: ${error.message}`);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
console.log(`\nBulk deletion completed. Deleted ${agentsToDelete.length} agent(s).`);
|
|
78
|
+
}
|
|
79
|
+
async function deleteAgentWithCleanup(client, resolver, agent, allAgents, verbose = false) {
|
|
80
|
+
const classifier = new resource_classifier_1.ResourceClassifier(client);
|
|
81
|
+
// Get agent details to find attached folders and blocks
|
|
82
|
+
const agentDetails = await resolver.getAgentWithDetails(agent.id);
|
|
83
|
+
// Delete agent-attached memory blocks first (custom blocks attached to this specific agent)
|
|
84
|
+
const agentAttachedBlocks = agentDetails.blocks || [];
|
|
85
|
+
if (agentAttachedBlocks.length > 0) {
|
|
86
|
+
if (verbose)
|
|
87
|
+
console.log(`Checking attached memory blocks...`);
|
|
88
|
+
for (const block of agentAttachedBlocks) {
|
|
89
|
+
// Check if this is a shared block
|
|
90
|
+
const isShared = classifier.isSharedBlock(block);
|
|
91
|
+
if (isShared) {
|
|
92
|
+
if (verbose)
|
|
93
|
+
console.log(` Keeping shared block: ${block.label || block.id}`);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// Check if this block is used by other agents
|
|
97
|
+
const blockInUse = await classifier.isBlockUsedByOtherAgents(block.id, agent.id, allAgents);
|
|
98
|
+
if (!blockInUse) {
|
|
99
|
+
if (verbose)
|
|
100
|
+
console.log(` Deleting agent-specific block: ${block.label || block.id}`);
|
|
101
|
+
try {
|
|
102
|
+
await client.deleteBlock(block.id);
|
|
103
|
+
if (verbose)
|
|
104
|
+
console.log(` Block deleted`);
|
|
105
|
+
}
|
|
106
|
+
catch (error) {
|
|
107
|
+
console.warn(` Could not delete block: ${error.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if (verbose)
|
|
112
|
+
console.log(` Keeping block used by other agents: ${block.label || block.id}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// Delete attached folders if they're not shared
|
|
117
|
+
const folders = agentDetails.folders;
|
|
118
|
+
if (folders) {
|
|
119
|
+
if (verbose)
|
|
120
|
+
console.log(`Checking attached folders...`);
|
|
121
|
+
for (const folder of folders) {
|
|
122
|
+
// Check if folder is shared or used by other agents
|
|
123
|
+
const isShared = classifier.isSharedFolder(folder);
|
|
124
|
+
const usedByOthers = await classifier.isFolderUsedByOtherAgents(folder.id, agent.id, allAgents);
|
|
125
|
+
if (isShared) {
|
|
126
|
+
if (verbose)
|
|
127
|
+
console.log(` Keeping shared folder: ${folder.name || folder.id}`);
|
|
128
|
+
}
|
|
129
|
+
else if (!usedByOthers) {
|
|
130
|
+
if (verbose)
|
|
131
|
+
console.log(` Deleting agent-specific folder: ${folder.name || folder.id}`);
|
|
132
|
+
try {
|
|
133
|
+
await client.deleteFolder(folder.id);
|
|
134
|
+
if (verbose)
|
|
135
|
+
console.log(` Folder deleted`);
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
console.warn(` Could not delete folder: ${error.message}`);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
if (verbose)
|
|
143
|
+
console.log(` Keeping folder used by other agents: ${folder.name || folder.id}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
// Delete the agent
|
|
148
|
+
await client.deleteAgent(agent.id);
|
|
149
|
+
// Clean up any remaining orphaned memory blocks by name pattern (fallback)
|
|
150
|
+
if (verbose)
|
|
151
|
+
console.log(`Cleaning up orphaned memory blocks...`);
|
|
152
|
+
try {
|
|
153
|
+
const blocks = await client.listBlocks();
|
|
154
|
+
const blockList = (0, response_normalizer_1.normalizeResponse)(blocks);
|
|
155
|
+
const agentSpecificBlocks = classifier.getAgentSpecificBlocks(blockList, agent.name);
|
|
156
|
+
for (const block of agentSpecificBlocks) {
|
|
157
|
+
// Check if this block is still attached to any remaining agents
|
|
158
|
+
const blockInUse = await classifier.isBlockUsedByOtherAgents(block.id, agent.id, allAgents);
|
|
159
|
+
if (!blockInUse) {
|
|
160
|
+
if (verbose)
|
|
161
|
+
console.log(` Deleting orphaned block: ${block.label}`);
|
|
162
|
+
try {
|
|
163
|
+
await client.deleteBlock(block.id);
|
|
164
|
+
if (verbose)
|
|
165
|
+
console.log(` Block deleted`);
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
console.warn(` Could not delete block: ${error.message}`);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
console.warn(` Could not clean up blocks: ${error.message}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.default = (0, error_handler_1.withErrorHandling)('Delete command', deleteCommandImpl);
|
|
178
|
+
exports.deleteAllCommand = (0, error_handler_1.withErrorHandling)('Delete all command', deleteAllCommandImpl);
|
|
179
|
+
//# sourceMappingURL=delete.js.map
|