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,391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DiffEngine = void 0;
|
|
4
|
+
const response_normalizer_1 = require("./response-normalizer");
|
|
5
|
+
/**
|
|
6
|
+
* DiffEngine determines what specific operations are needed to update an agent
|
|
7
|
+
* while preserving conversation history whenever possible
|
|
8
|
+
*/
|
|
9
|
+
class DiffEngine {
|
|
10
|
+
constructor(client, blockManager, basePath = '') {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.blockManager = blockManager;
|
|
13
|
+
this.basePath = basePath;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Analyzes differences between existing and desired agent configuration
|
|
17
|
+
* and generates specific update operations that preserve conversation history
|
|
18
|
+
*/
|
|
19
|
+
async generateUpdateOperations(existingAgent, desiredConfig, toolRegistry, folderRegistry, verbose = false) {
|
|
20
|
+
const operations = {
|
|
21
|
+
preservesConversation: true,
|
|
22
|
+
operationCount: 0
|
|
23
|
+
};
|
|
24
|
+
if (verbose)
|
|
25
|
+
console.log(` Analyzing configuration changes for agent: ${existingAgent.name}`);
|
|
26
|
+
// Get current agent state from server
|
|
27
|
+
const currentAgent = await this.client.getAgent(existingAgent.id);
|
|
28
|
+
const currentToolsResponse = await this.client.listAgentTools(existingAgent.id);
|
|
29
|
+
const currentBlocksResponse = await this.client.listAgentBlocks(existingAgent.id);
|
|
30
|
+
const currentFoldersResponse = await this.client.listAgentFolders(existingAgent.id);
|
|
31
|
+
// Normalize responses to arrays
|
|
32
|
+
const currentTools = (0, response_normalizer_1.normalizeResponse)(currentToolsResponse);
|
|
33
|
+
const currentBlocks = (0, response_normalizer_1.normalizeResponse)(currentBlocksResponse);
|
|
34
|
+
const currentFolders = (0, response_normalizer_1.normalizeResponse)(currentFoldersResponse);
|
|
35
|
+
// Analyze basic field changes
|
|
36
|
+
const fieldUpdates = {};
|
|
37
|
+
if (currentAgent.system !== desiredConfig.systemPrompt) {
|
|
38
|
+
fieldUpdates.systemPrompt = desiredConfig.systemPrompt;
|
|
39
|
+
operations.operationCount++;
|
|
40
|
+
}
|
|
41
|
+
const desiredModel = desiredConfig.model || "google_ai/gemini-2.5-pro";
|
|
42
|
+
if (currentAgent.model !== desiredModel) {
|
|
43
|
+
fieldUpdates.model = desiredModel;
|
|
44
|
+
operations.operationCount++;
|
|
45
|
+
}
|
|
46
|
+
const desiredEmbedding = desiredConfig.embedding || "letta/letta-free";
|
|
47
|
+
if (currentAgent.embedding !== desiredEmbedding) {
|
|
48
|
+
fieldUpdates.embedding = desiredEmbedding;
|
|
49
|
+
operations.operationCount++;
|
|
50
|
+
}
|
|
51
|
+
const desiredContextWindow = desiredConfig.contextWindow || 64000;
|
|
52
|
+
const currentContextWindow = currentAgent.llm_config?.context_window || 64000;
|
|
53
|
+
if (currentContextWindow !== desiredContextWindow) {
|
|
54
|
+
fieldUpdates.context_window_limit = desiredContextWindow;
|
|
55
|
+
operations.operationCount++;
|
|
56
|
+
}
|
|
57
|
+
if (Object.keys(fieldUpdates).length > 0) {
|
|
58
|
+
operations.updateFields = fieldUpdates;
|
|
59
|
+
}
|
|
60
|
+
// Analyze tool changes
|
|
61
|
+
operations.tools = await this.analyzeToolChanges(currentTools, desiredConfig.tools || [], toolRegistry, desiredConfig.toolSourceHashes || {});
|
|
62
|
+
operations.operationCount += operations.tools.toAdd.length + operations.tools.toRemove.length + operations.tools.toUpdate.length;
|
|
63
|
+
// Analyze memory block changes
|
|
64
|
+
operations.blocks = await this.analyzeBlockChanges(currentBlocks, [
|
|
65
|
+
...(desiredConfig.memoryBlocks || []),
|
|
66
|
+
...(desiredConfig.sharedBlocks || []).map(name => ({ name, isShared: true }))
|
|
67
|
+
]);
|
|
68
|
+
operations.operationCount += operations.blocks.toAdd.length + operations.blocks.toRemove.length + operations.blocks.toUpdate.length;
|
|
69
|
+
// Analyze folder changes
|
|
70
|
+
operations.folders = await this.analyzeFolderChanges(currentFolders, desiredConfig.folders || [], folderRegistry);
|
|
71
|
+
operations.operationCount += operations.folders.toAttach.length + operations.folders.toDetach.length +
|
|
72
|
+
operations.folders.toUpdate.reduce((sum, folder) => sum + folder.filesToAdd.length + folder.filesToRemove.length + folder.filesToUpdate.length, 0);
|
|
73
|
+
return operations;
|
|
74
|
+
}
|
|
75
|
+
async analyzeToolChanges(currentTools, desiredToolNames, toolRegistry, toolSourceHashes = {}) {
|
|
76
|
+
const currentToolNames = new Set(currentTools.map(t => t.name));
|
|
77
|
+
const desiredToolSet = new Set(desiredToolNames);
|
|
78
|
+
const toAdd = [];
|
|
79
|
+
const toRemove = [];
|
|
80
|
+
const toUpdate = [];
|
|
81
|
+
const unchanged = [];
|
|
82
|
+
// Find tools to add
|
|
83
|
+
for (const toolName of desiredToolNames) {
|
|
84
|
+
if (!currentToolNames.has(toolName)) {
|
|
85
|
+
const toolId = toolRegistry.get(toolName);
|
|
86
|
+
if (toolId) {
|
|
87
|
+
toAdd.push({ name: toolName, id: toolId });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Find tools to remove, update (source code changed), or leave unchanged
|
|
92
|
+
for (const tool of currentTools) {
|
|
93
|
+
if (desiredToolSet.has(tool.name)) {
|
|
94
|
+
// Tool exists in both current and desired
|
|
95
|
+
const toolName = tool.name;
|
|
96
|
+
// Check if source code has changed for custom tools
|
|
97
|
+
if (toolSourceHashes[toolName] && !['archival_memory_insert', 'archival_memory_search'].includes(toolName)) {
|
|
98
|
+
// For tools with source code, we need to check if the source has changed
|
|
99
|
+
// This would require getting the current tool's source hash and comparing
|
|
100
|
+
// For now, we'll re-register tools when their source files exist and have hashes
|
|
101
|
+
const currentToolId = tool.id;
|
|
102
|
+
const newToolId = toolRegistry.get(toolName);
|
|
103
|
+
if (newToolId && newToolId !== currentToolId) {
|
|
104
|
+
// Tool was re-registered (likely due to source code change)
|
|
105
|
+
toUpdate.push({
|
|
106
|
+
name: toolName,
|
|
107
|
+
currentId: currentToolId,
|
|
108
|
+
newId: newToolId,
|
|
109
|
+
reason: 'source_code_changed'
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
unchanged.push({ name: tool.name, id: tool.id });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
unchanged.push({ name: tool.name, id: tool.id });
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
// Tool exists in current but not desired - remove it
|
|
122
|
+
toRemove.push({ name: tool.name, id: tool.id });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return { toAdd, toRemove, toUpdate, unchanged };
|
|
126
|
+
}
|
|
127
|
+
async analyzeBlockChanges(currentBlocks, desiredBlocks) {
|
|
128
|
+
const currentBlockNames = new Set(currentBlocks.map(b => b.label));
|
|
129
|
+
const desiredBlockNames = new Set(desiredBlocks.map(b => b.name));
|
|
130
|
+
const toAdd = [];
|
|
131
|
+
const toRemove = [];
|
|
132
|
+
const toUpdate = [];
|
|
133
|
+
const unchanged = [];
|
|
134
|
+
// Find blocks to add
|
|
135
|
+
for (const blockConfig of desiredBlocks) {
|
|
136
|
+
if (!currentBlockNames.has(blockConfig.name)) {
|
|
137
|
+
const blockId = blockConfig.isShared
|
|
138
|
+
? this.blockManager.getSharedBlockId(blockConfig.name)
|
|
139
|
+
: this.blockManager.getSharedBlockId(blockConfig.name); // TODO: Add agent block lookup
|
|
140
|
+
if (blockId) {
|
|
141
|
+
toAdd.push({ name: blockConfig.name, id: blockId });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
// Find blocks to remove and unchanged
|
|
146
|
+
for (const block of currentBlocks) {
|
|
147
|
+
if (desiredBlockNames.has(block.label)) {
|
|
148
|
+
unchanged.push({ name: block.label, id: block.id });
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
toRemove.push({ name: block.label, id: block.id });
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { toAdd, toRemove, toUpdate, unchanged };
|
|
155
|
+
}
|
|
156
|
+
async analyzeFolderChanges(currentFolders, desiredFolders, folderRegistry) {
|
|
157
|
+
const currentFolderNames = new Set(currentFolders.map(f => f.name));
|
|
158
|
+
const desiredFolderNames = new Set(desiredFolders.map(f => f.name));
|
|
159
|
+
const toAttach = [];
|
|
160
|
+
const toDetach = [];
|
|
161
|
+
const toUpdate = [];
|
|
162
|
+
const unchanged = [];
|
|
163
|
+
// Find folders to attach (new folders)
|
|
164
|
+
for (const folderConfig of desiredFolders) {
|
|
165
|
+
if (!currentFolderNames.has(folderConfig.name)) {
|
|
166
|
+
const folderId = folderRegistry.get(folderConfig.name);
|
|
167
|
+
if (folderId) {
|
|
168
|
+
toAttach.push({ name: folderConfig.name, id: folderId });
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// Find folders to detach, update, or leave unchanged
|
|
173
|
+
for (const folder of currentFolders) {
|
|
174
|
+
if (desiredFolderNames.has(folder.name)) {
|
|
175
|
+
// Folder exists in both current and desired - check for file changes
|
|
176
|
+
const desiredFolder = desiredFolders.find(f => f.name === folder.name);
|
|
177
|
+
if (desiredFolder && desiredFolder.fileContentHashes) {
|
|
178
|
+
// Get current files in this folder from server
|
|
179
|
+
try {
|
|
180
|
+
const currentFilesResponse = await this.client.listFolderFiles(folder.id);
|
|
181
|
+
const currentFiles = (0, response_normalizer_1.normalizeResponse)(currentFilesResponse);
|
|
182
|
+
const currentFileNames = new Set(currentFiles.map((f) => f.name || f.file_name || String(f)).filter(Boolean));
|
|
183
|
+
const desiredFileNames = new Set(desiredFolder.files);
|
|
184
|
+
const filesToAdd = [];
|
|
185
|
+
const filesToRemove = [];
|
|
186
|
+
const filesToUpdate = [];
|
|
187
|
+
// Find files to add or update
|
|
188
|
+
for (const filePath of desiredFolder.files) {
|
|
189
|
+
const fileName = filePath.split('/').pop() || filePath; // Get just filename
|
|
190
|
+
if (!currentFileNames.has(fileName)) {
|
|
191
|
+
filesToAdd.push(filePath);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// File exists, check if content changed
|
|
195
|
+
// For now, assume content may have changed if folder hash changed
|
|
196
|
+
if (desiredFolder.fileContentHashes && desiredFolder.fileContentHashes[filePath]) {
|
|
197
|
+
filesToUpdate.push(filePath);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// Find files to remove
|
|
202
|
+
for (const currentFile of currentFiles) {
|
|
203
|
+
const fileName = currentFile.name || currentFile.file_name || String(currentFile);
|
|
204
|
+
if (fileName && !desiredFileNames.has(fileName)) {
|
|
205
|
+
filesToRemove.push(fileName);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
if (filesToAdd.length > 0 || filesToRemove.length > 0 || filesToUpdate.length > 0) {
|
|
209
|
+
toUpdate.push({
|
|
210
|
+
name: folder.name,
|
|
211
|
+
id: folder.id,
|
|
212
|
+
filesToAdd,
|
|
213
|
+
filesToRemove,
|
|
214
|
+
filesToUpdate
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
else {
|
|
218
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.warn(`Could not analyze files in folder ${folder.name}:`, error);
|
|
223
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
// Folder exists in current but not desired - detach it
|
|
232
|
+
toDetach.push({ name: folder.name, id: folder.id });
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
return { toAttach, toDetach, toUpdate, unchanged };
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Applies the update operations to the agent
|
|
239
|
+
*/
|
|
240
|
+
async applyUpdateOperations(agentId, operations, verbose = false) {
|
|
241
|
+
if (operations.operationCount === 0) {
|
|
242
|
+
if (verbose)
|
|
243
|
+
console.log(' No changes needed');
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (verbose)
|
|
247
|
+
console.log(` Applying ${operations.operationCount} updates (preserves conversation: ${operations.preservesConversation})`);
|
|
248
|
+
// Apply field updates
|
|
249
|
+
if (operations.updateFields) {
|
|
250
|
+
if (verbose)
|
|
251
|
+
console.log(' Updating agent fields...');
|
|
252
|
+
await this.client.updateAgent(agentId, operations.updateFields);
|
|
253
|
+
}
|
|
254
|
+
// Apply tool changes
|
|
255
|
+
if (operations.tools) {
|
|
256
|
+
for (const tool of operations.tools.toAdd) {
|
|
257
|
+
if (verbose)
|
|
258
|
+
console.log(` Attaching tool: ${tool.name}`);
|
|
259
|
+
await this.client.attachToolToAgent(agentId, tool.id);
|
|
260
|
+
}
|
|
261
|
+
for (const tool of operations.tools.toUpdate) {
|
|
262
|
+
if (verbose)
|
|
263
|
+
console.log(` Updating tool: ${tool.name} (${tool.reason})`);
|
|
264
|
+
// Detach old version and attach new version
|
|
265
|
+
await this.client.detachToolFromAgent(agentId, tool.currentId);
|
|
266
|
+
await this.client.attachToolToAgent(agentId, tool.newId);
|
|
267
|
+
}
|
|
268
|
+
for (const tool of operations.tools.toRemove) {
|
|
269
|
+
if (verbose)
|
|
270
|
+
console.log(` Detaching tool: ${tool.name}`);
|
|
271
|
+
await this.client.detachToolFromAgent(agentId, tool.id);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
// Apply block changes
|
|
275
|
+
if (operations.blocks) {
|
|
276
|
+
for (const block of operations.blocks.toAdd) {
|
|
277
|
+
if (verbose)
|
|
278
|
+
console.log(` Attaching block: ${block.name}`);
|
|
279
|
+
await this.client.attachBlockToAgent(agentId, block.id);
|
|
280
|
+
}
|
|
281
|
+
for (const block of operations.blocks.toRemove) {
|
|
282
|
+
if (verbose)
|
|
283
|
+
console.log(` Detaching block: ${block.name}`);
|
|
284
|
+
await this.client.detachBlockFromAgent(agentId, block.id);
|
|
285
|
+
}
|
|
286
|
+
for (const block of operations.blocks.toUpdate) {
|
|
287
|
+
if (verbose)
|
|
288
|
+
console.log(` Updating block: ${block.name}`);
|
|
289
|
+
// First detach old, then attach new
|
|
290
|
+
await this.client.detachBlockFromAgent(agentId, block.currentId);
|
|
291
|
+
await this.client.attachBlockToAgent(agentId, block.newId);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
// Apply folder changes
|
|
295
|
+
if (operations.folders) {
|
|
296
|
+
for (const folder of operations.folders.toAttach) {
|
|
297
|
+
if (verbose)
|
|
298
|
+
console.log(` Attaching folder: ${folder.name}`);
|
|
299
|
+
await this.client.attachFolderToAgent(agentId, folder.id);
|
|
300
|
+
}
|
|
301
|
+
for (const folder of operations.folders.toDetach) {
|
|
302
|
+
if (verbose)
|
|
303
|
+
console.log(` Detaching folder: ${folder.name}`);
|
|
304
|
+
await this.client.detachFolderFromAgent(agentId, folder.id);
|
|
305
|
+
}
|
|
306
|
+
for (const folder of operations.folders.toUpdate) {
|
|
307
|
+
if (verbose)
|
|
308
|
+
console.log(` Updating folder: ${folder.name}`);
|
|
309
|
+
// Add new files to the folder
|
|
310
|
+
for (const filePath of folder.filesToAdd) {
|
|
311
|
+
try {
|
|
312
|
+
if (verbose)
|
|
313
|
+
console.log(` Adding file: ${filePath}`);
|
|
314
|
+
await this.addFileToFolder(folder.id, filePath);
|
|
315
|
+
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
console.error(` Failed to add file ${filePath}:`, error.message);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
// Remove files from the folder
|
|
321
|
+
for (const fileName of folder.filesToRemove) {
|
|
322
|
+
try {
|
|
323
|
+
if (verbose)
|
|
324
|
+
console.log(` Removing file: ${fileName}`);
|
|
325
|
+
await this.removeFileFromFolder(folder.id, fileName);
|
|
326
|
+
}
|
|
327
|
+
catch (error) {
|
|
328
|
+
console.error(` Failed to remove file ${fileName}:`, error.message);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
// Update existing files in the folder
|
|
332
|
+
for (const filePath of folder.filesToUpdate) {
|
|
333
|
+
try {
|
|
334
|
+
if (verbose)
|
|
335
|
+
console.log(` Updating file: ${filePath}`);
|
|
336
|
+
await this.updateFileInFolder(folder.id, filePath);
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
console.error(` Failed to update file ${filePath}:`, error.message);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (verbose)
|
|
345
|
+
console.log(' Updates completed successfully');
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Helper method to add a file to an existing folder
|
|
349
|
+
*/
|
|
350
|
+
async addFileToFolder(folderId, filePath) {
|
|
351
|
+
const fs = require('fs');
|
|
352
|
+
const path = require('path');
|
|
353
|
+
const fullPath = path.resolve(this.basePath, filePath);
|
|
354
|
+
const fileName = path.basename(filePath);
|
|
355
|
+
if (!fs.existsSync(fullPath)) {
|
|
356
|
+
throw new Error(`File not found: ${fullPath}`);
|
|
357
|
+
}
|
|
358
|
+
const fileStream = fs.createReadStream(fullPath);
|
|
359
|
+
await this.client.uploadFileToFolder(fileStream, folderId, fileName);
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Helper method to remove a file from a folder
|
|
363
|
+
*/
|
|
364
|
+
async removeFileFromFolder(folderId, fileName) {
|
|
365
|
+
// Get the file ID by name
|
|
366
|
+
const fileId = await this.client.getFileIdByName(folderId, fileName);
|
|
367
|
+
if (!fileId) {
|
|
368
|
+
throw new Error(`File not found in folder: ${fileName}`);
|
|
369
|
+
}
|
|
370
|
+
// Delete the file using the SDK
|
|
371
|
+
await this.client.deleteFileFromFolder(folderId, fileId);
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Helper method to update an existing file in a folder
|
|
375
|
+
*/
|
|
376
|
+
async updateFileInFolder(folderId, filePath) {
|
|
377
|
+
const fs = require('fs');
|
|
378
|
+
const path = require('path');
|
|
379
|
+
const fullPath = path.resolve(this.basePath, filePath);
|
|
380
|
+
const fileName = path.basename(filePath);
|
|
381
|
+
if (!fs.existsSync(fullPath)) {
|
|
382
|
+
throw new Error(`File not found: ${fullPath}`);
|
|
383
|
+
}
|
|
384
|
+
// For file updates, we re-upload the file
|
|
385
|
+
// This may overwrite the existing file or create a duplicate
|
|
386
|
+
const fileStream = fs.createReadStream(fullPath);
|
|
387
|
+
await this.client.uploadFileToFolder(fileStream, folderId, fileName);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
exports.DiffEngine = DiffEngine;
|
|
391
|
+
//# sourceMappingURL=diff-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-engine.js","sourceRoot":"","sources":["../../src/lib/diff-engine.ts"],"names":[],"mappings":";;;AAGA,+DAA0D;AAgD1D;;;GAGG;AACH,MAAa,UAAU;IAKrB,YAAY,MAA0B,EAAE,YAA0B,EAAE,WAAmB,EAAE;QACvF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,wBAAwB,CAC5B,aAA2B,EAC3B,aAUC,EACD,YAAiC,EACjC,cAAmC,EACnC,UAAmB,KAAK;QAGxB,MAAM,UAAU,GAA0B;YACxC,qBAAqB,EAAE,IAAI;YAC3B,cAAc,EAAE,CAAC;SAClB,CAAC;QAEF,IA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
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps command functions with consistent error handling
|
|
3
|
+
*/
|
|
4
|
+
export declare function withErrorHandling<T extends any[], R>(commandName: string, fn: (...args: T) => Promise<R>): (...args: T) => Promise<R>;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a consistent error for resource not found
|
|
7
|
+
*/
|
|
8
|
+
export declare function createNotFoundError(resourceType: string, name: string): Error;
|
|
9
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/lib/error-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,EAClD,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,IAEhB,GAAG,MAAM,CAAC,KAAG,OAAO,CAAC,CAAC,CAAC,CAQtC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,KAAK,CAE7E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.withErrorHandling = withErrorHandling;
|
|
4
|
+
exports.createNotFoundError = createNotFoundError;
|
|
5
|
+
/**
|
|
6
|
+
* Wraps command functions with consistent error handling
|
|
7
|
+
*/
|
|
8
|
+
function withErrorHandling(commandName, fn) {
|
|
9
|
+
return async (...args) => {
|
|
10
|
+
try {
|
|
11
|
+
return await fn(...args);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error(`${commandName} failed:`, error.message || error);
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a consistent error for resource not found
|
|
21
|
+
*/
|
|
22
|
+
function createNotFoundError(resourceType, name) {
|
|
23
|
+
return new Error(`${resourceType} "${name}" not found`);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/lib/error-handler.ts"],"names":[],"mappings":";;AAGA,8CAYC;AAKD,kDAEC;AAtBD;;GAEG;AACH,SAAgB,iBAAiB,CAC/B,WAAmB,EACnB,EAA8B;IAE9B,OAAO,KAAK,EAAE,GAAG,IAAO,EAAc,EAAE;QACtC,IAAI,CAAC;YACH,OAAO,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;QAC3B,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,UAAU,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC;YAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,mBAAmB,CAAC,YAAoB,EAAE,IAAY;IACpE,OAAO,IAAI,KAAK,CAAC,GAAG,YAAY,KAAK,IAAI,aAAa,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export interface FileContentMap {
|
|
2
|
+
[filePath: string]: string;
|
|
3
|
+
}
|
|
4
|
+
/**
|
|
5
|
+
* Centralized file content tracking for change detection across tools, folders, and memory blocks
|
|
6
|
+
*/
|
|
7
|
+
export declare class FileContentTracker {
|
|
8
|
+
private basePath;
|
|
9
|
+
constructor(basePath: string);
|
|
10
|
+
/**
|
|
11
|
+
* Generates a content hash for a single file
|
|
12
|
+
*/
|
|
13
|
+
generateFileContentHash(filePath: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generates content hashes for multiple files
|
|
16
|
+
*/
|
|
17
|
+
generateFileContentHashes(filePaths: string[]): FileContentMap;
|
|
18
|
+
/**
|
|
19
|
+
* Generates content hashes for tool source files
|
|
20
|
+
*/
|
|
21
|
+
generateToolSourceHashes(toolNames: string[]): FileContentMap;
|
|
22
|
+
/**
|
|
23
|
+
* Generates content hashes for memory block files
|
|
24
|
+
*/
|
|
25
|
+
generateMemoryBlockFileHashes(memoryBlocks: Array<{
|
|
26
|
+
name: string;
|
|
27
|
+
from_file?: string;
|
|
28
|
+
value?: string;
|
|
29
|
+
}>): FileContentMap;
|
|
30
|
+
/**
|
|
31
|
+
* Generates content hashes for folder files (grouped by folder)
|
|
32
|
+
*/
|
|
33
|
+
generateFolderFileHashes(folderConfigs: Array<{
|
|
34
|
+
name: string;
|
|
35
|
+
files: string[];
|
|
36
|
+
}>): Map<string, FileContentMap>;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if a file exists
|
|
39
|
+
*/
|
|
40
|
+
fileExists(filePath: string): boolean;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=file-content-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-content-tracker.d.ts","sourceRoot":"","sources":["../../src/lib/file-content-tracker.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,EAAE,MAAM;IAI5B;;OAEG;IACH,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAWjD;;OAEG;IACH,yBAAyB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,cAAc;IAU9D;;OAEG;IACH,wBAAwB,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,cAAc;IAgB7D;;OAEG;IACH,6BAA6B,CAAC,YAAY,EAAE,KAAK,CAAC;QAChD,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,CAAC,GAAG,cAAc;IAgBnB;;OAEG;IACH,wBAAwB,CAAC,aAAa,EAAE,KAAK,CAAC;QAC5C,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC;IAWhC;;OAEG;IACH,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAQtC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
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.FileContentTracker = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const crypto = __importStar(require("crypto"));
|
|
40
|
+
/**
|
|
41
|
+
* Centralized file content tracking for change detection across tools, folders, and memory blocks
|
|
42
|
+
*/
|
|
43
|
+
class FileContentTracker {
|
|
44
|
+
constructor(basePath) {
|
|
45
|
+
this.basePath = basePath;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Generates a content hash for a single file
|
|
49
|
+
*/
|
|
50
|
+
generateFileContentHash(filePath) {
|
|
51
|
+
try {
|
|
52
|
+
const fullPath = path.resolve(this.basePath, filePath);
|
|
53
|
+
const content = fs.readFileSync(fullPath, 'utf8');
|
|
54
|
+
return crypto.createHash('sha256').update(content).digest('hex').substring(0, 16);
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.warn(`Warning: Could not read file ${filePath} for hashing:`, error.message);
|
|
58
|
+
return crypto.createHash('sha256').update(`file-not-found:${filePath}`).digest('hex').substring(0, 16);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Generates content hashes for multiple files
|
|
63
|
+
*/
|
|
64
|
+
generateFileContentHashes(filePaths) {
|
|
65
|
+
const contentHashes = {};
|
|
66
|
+
for (const filePath of filePaths) {
|
|
67
|
+
contentHashes[filePath] = this.generateFileContentHash(filePath);
|
|
68
|
+
}
|
|
69
|
+
return contentHashes;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Generates content hashes for tool source files
|
|
73
|
+
*/
|
|
74
|
+
generateToolSourceHashes(toolNames) {
|
|
75
|
+
const toolHashes = {};
|
|
76
|
+
for (const toolName of toolNames) {
|
|
77
|
+
// Skip built-in tools that don't have source files
|
|
78
|
+
if (['archival_memory_insert', 'archival_memory_search'].includes(toolName)) {
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
const toolPath = path.join('tools', `${toolName}.py`);
|
|
82
|
+
toolHashes[toolName] = this.generateFileContentHash(toolPath);
|
|
83
|
+
}
|
|
84
|
+
return toolHashes;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Generates content hashes for memory block files
|
|
88
|
+
*/
|
|
89
|
+
generateMemoryBlockFileHashes(memoryBlocks) {
|
|
90
|
+
const blockHashes = {};
|
|
91
|
+
for (const block of memoryBlocks) {
|
|
92
|
+
if (block.from_file) {
|
|
93
|
+
// Memory block loads content from file
|
|
94
|
+
blockHashes[block.name] = this.generateFileContentHash(block.from_file);
|
|
95
|
+
}
|
|
96
|
+
else if (block.value) {
|
|
97
|
+
// Memory block has inline value - hash it directly
|
|
98
|
+
blockHashes[block.name] = crypto.createHash('sha256').update(block.value).digest('hex').substring(0, 16);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return blockHashes;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Generates content hashes for folder files (grouped by folder)
|
|
105
|
+
*/
|
|
106
|
+
generateFolderFileHashes(folderConfigs) {
|
|
107
|
+
const folderHashes = new Map();
|
|
108
|
+
for (const folder of folderConfigs) {
|
|
109
|
+
const fileHashes = this.generateFileContentHashes(folder.files);
|
|
110
|
+
folderHashes.set(folder.name, fileHashes);
|
|
111
|
+
}
|
|
112
|
+
return folderHashes;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Checks if a file exists
|
|
116
|
+
*/
|
|
117
|
+
fileExists(filePath) {
|
|
118
|
+
try {
|
|
119
|
+
const fullPath = path.resolve(this.basePath, filePath);
|
|
120
|
+
return fs.existsSync(fullPath);
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
return false;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
exports.FileContentTracker = FileContentTracker;
|
|
128
|
+
//# sourceMappingURL=file-content-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-content-tracker.js","sourceRoot":"","sources":["../../src/lib/file-content-tracker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAC7B,+CAAiC;AAMjC;;GAEG;AACH,MAAa,kBAAkB;IAG7B,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED;;OAEG;IACH,uBAAuB,CAAC,QAAgB;QACtC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACvD,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YAClD,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACpF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,IAAI,CAAC,gCAAgC,QAAQ,eAAe,EAAG,KAAe,CAAC,OAAO,CAAC,CAAC;YAChG,OAAO,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,kBAAkB,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAA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,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;YAC3G,CAAC;QACH,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,wBAAwB,CAAC,aAGvB;QACA,MAAM,YAAY,GAAG,IAAI,GAAG,EAA0B,CAAC;QAEvD,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;YACnC,MAAM,UAAU,GAAG,IAAI,CAAC,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAChE,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;QAED,OAAO,YAAY,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,UAAU,CAAC,QAAgB;QACzB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACvD,OAAO,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF;AAxGD,gDAwGC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FleetConfig } from '../types/fleet-config';
|
|
2
|
+
export declare class FleetParser {
|
|
3
|
+
basePath: string;
|
|
4
|
+
constructor(configPath: string);
|
|
5
|
+
parseFleetConfig(configPath: string): Promise<FleetConfig>;
|
|
6
|
+
private resolveBlockContent;
|
|
7
|
+
private resolvePromptContent;
|
|
8
|
+
private expandFileFolders;
|
|
9
|
+
private expandFolderFiles;
|
|
10
|
+
private getAllFilesRecursive;
|
|
11
|
+
private expandToolReferences;
|
|
12
|
+
registerRequiredTools(config: FleetConfig, client: any, verbose?: boolean, toolSourceHashes?: Record<string, string>): Promise<Map<string, string>>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=fleet-parser.d.ts.map
|