lettactl 0.5.8 → 0.5.9
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/dist/commands/apply-template.d.ts +12 -0
- package/dist/commands/apply-template.d.ts.map +1 -0
- package/dist/commands/apply-template.js +118 -0
- package/dist/commands/apply-template.js.map +1 -0
- package/dist/commands/apply.d.ts.map +1 -1
- package/dist/commands/apply.js +42 -358
- package/dist/commands/apply.js.map +1 -1
- package/dist/lib/agent-manager.d.ts +0 -8
- package/dist/lib/agent-manager.d.ts.map +1 -1
- package/dist/lib/agent-manager.js +10 -58
- package/dist/lib/agent-manager.js.map +1 -1
- package/dist/lib/apply-helpers.d.ts +29 -0
- package/dist/lib/apply-helpers.d.ts.map +1 -0
- package/dist/lib/apply-helpers.js +224 -0
- package/dist/lib/apply-helpers.js.map +1 -0
- package/dist/lib/block-manager.d.ts +6 -29
- package/dist/lib/block-manager.d.ts.map +1 -1
- package/dist/lib/block-manager.js +76 -218
- package/dist/lib/block-manager.js.map +1 -1
- package/dist/lib/diff-analyzers.d.ts +17 -0
- package/dist/lib/diff-analyzers.d.ts.map +1 -0
- package/dist/lib/diff-analyzers.js +172 -0
- package/dist/lib/diff-analyzers.js.map +1 -0
- package/dist/lib/diff-applier.d.ts +27 -0
- package/dist/lib/diff-applier.d.ts.map +1 -0
- package/dist/lib/diff-applier.js +196 -0
- package/dist/lib/diff-applier.js.map +1 -0
- package/dist/lib/diff-engine.d.ts +0 -19
- package/dist/lib/diff-engine.d.ts.map +1 -1
- package/dist/lib/diff-engine.js +8 -359
- package/dist/lib/diff-engine.js.map +1 -1
- package/dist/lib/letta-client.d.ts +5 -0
- package/dist/lib/letta-client.d.ts.map +1 -1
- package/dist/lib/letta-client.js +3 -0
- package/dist/lib/letta-client.js.map +1 -1
- package/dist/utils/hash-utils.d.ts +9 -0
- package/dist/utils/hash-utils.d.ts.map +1 -0
- package/dist/utils/hash-utils.js +54 -0
- package/dist/utils/hash-utils.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,52 +1,13 @@
|
|
|
1
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
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.BlockManager = void 0;
|
|
37
4
|
const response_normalizer_1 = require("./response-normalizer");
|
|
38
|
-
const
|
|
5
|
+
const hash_utils_1 = require("../utils/hash-utils");
|
|
39
6
|
class BlockManager {
|
|
40
7
|
constructor(client) {
|
|
41
8
|
this.blockRegistry = new Map();
|
|
42
9
|
this.client = client;
|
|
43
10
|
}
|
|
44
|
-
/**
|
|
45
|
-
* Generates a content hash for version detection
|
|
46
|
-
*/
|
|
47
|
-
generateContentHash(content) {
|
|
48
|
-
return crypto.createHash('sha256').update(content).digest('hex').substring(0, 16);
|
|
49
|
-
}
|
|
50
11
|
/**
|
|
51
12
|
* Loads existing blocks from the server and builds the registry
|
|
52
13
|
*/
|
|
@@ -55,229 +16,127 @@ class BlockManager {
|
|
|
55
16
|
const blockList = (0, response_normalizer_1.normalizeResponse)(blocks);
|
|
56
17
|
for (const block of blockList) {
|
|
57
18
|
if (block.label && block.value) {
|
|
58
|
-
const contentHash =
|
|
59
|
-
const version = this.parseVersionFromLabel(block.label);
|
|
19
|
+
const contentHash = (0, hash_utils_1.generateContentHash)(block.value);
|
|
60
20
|
const isShared = block.label.startsWith('shared_');
|
|
61
|
-
const
|
|
21
|
+
const blockInfo = {
|
|
62
22
|
id: block.id,
|
|
63
23
|
label: block.label,
|
|
64
24
|
description: block.description || '',
|
|
65
25
|
value: block.value,
|
|
66
26
|
limit: block.limit || 0,
|
|
67
27
|
contentHash,
|
|
68
|
-
|
|
69
|
-
isShared,
|
|
70
|
-
lastUpdated: block.updated_at || new Date().toISOString(),
|
|
71
|
-
userDefined: false // We can't know if existing blocks had user-defined versions
|
|
28
|
+
isShared
|
|
72
29
|
};
|
|
73
|
-
this.blockRegistry.set(this.getBlockKey(block.label, isShared),
|
|
30
|
+
this.blockRegistry.set(this.getBlockKey(block.label, isShared), blockInfo);
|
|
74
31
|
}
|
|
75
32
|
}
|
|
76
33
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Parses version string from block label (e.g., "block_name__v__20241202-a1b2c3d4" -> "20241202-a1b2c3d4")
|
|
79
|
-
*/
|
|
80
|
-
parseVersionFromLabel(label) {
|
|
81
|
-
const versionMatch = label.match(/__v__(.+)$/);
|
|
82
|
-
return versionMatch ? versionMatch[1] : 'initial';
|
|
83
|
-
}
|
|
84
34
|
/**
|
|
85
35
|
* Gets the registry key for a block
|
|
86
36
|
*/
|
|
87
|
-
getBlockKey(
|
|
88
|
-
|
|
89
|
-
return isShared ? `shared:${cleanName}` : cleanName;
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Generates a timestamp-based version string
|
|
93
|
-
*/
|
|
94
|
-
generateTimestampVersion(contentHash) {
|
|
95
|
-
const now = new Date();
|
|
96
|
-
const timestamp = now.toISOString().slice(0, 10).replace(/-/g, ''); // YYYYMMDD
|
|
97
|
-
const shortHash = contentHash.substring(0, 8);
|
|
98
|
-
return `${timestamp}-${shortHash}`;
|
|
37
|
+
getBlockKey(label, isShared) {
|
|
38
|
+
return isShared ? `shared:${label}` : label;
|
|
99
39
|
}
|
|
100
40
|
/**
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
validateUserVersion(version) {
|
|
104
|
-
// Remove spaces, convert to lowercase, replace invalid chars with dashes
|
|
105
|
-
return version.trim().toLowerCase().replace(/[^a-z0-9.-]/g, '-');
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Creates a versioned block label
|
|
109
|
-
*/
|
|
110
|
-
createVersionedLabel(baseName, version, isFirstVersion = false) {
|
|
111
|
-
return isFirstVersion && version === 'initial' ? baseName : `${baseName}__v__${version}`;
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Gets or creates a shared block, with enhanced versioning support
|
|
41
|
+
* Gets or creates a shared block, updating in-place if content changed
|
|
115
42
|
*/
|
|
116
43
|
async getOrCreateSharedBlock(blockConfig) {
|
|
117
44
|
const blockKey = this.getBlockKey(blockConfig.name, true);
|
|
118
|
-
const contentHash =
|
|
119
|
-
// Check both shared and non-shared keys
|
|
45
|
+
const contentHash = (0, hash_utils_1.generateContentHash)(blockConfig.value);
|
|
46
|
+
// Check both shared and non-shared keys
|
|
120
47
|
let existing = this.blockRegistry.get(blockKey);
|
|
121
48
|
if (!existing) {
|
|
122
49
|
existing = this.blockRegistry.get(this.getBlockKey(blockConfig.name, false));
|
|
123
50
|
}
|
|
124
|
-
// Determine version strategy
|
|
125
|
-
let newVersion;
|
|
126
|
-
let userDefined = false;
|
|
127
|
-
if (blockConfig.version) {
|
|
128
|
-
newVersion = this.validateUserVersion(blockConfig.version);
|
|
129
|
-
userDefined = true;
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
newVersion = existing ? this.generateTimestampVersion(contentHash) : 'initial';
|
|
133
|
-
}
|
|
134
51
|
if (existing) {
|
|
135
|
-
|
|
136
|
-
if (existing.contentHash === contentHash && !blockConfig.version) {
|
|
52
|
+
if (existing.contentHash === contentHash) {
|
|
137
53
|
console.log(`Using existing shared block: ${existing.label}`);
|
|
138
54
|
return existing.id;
|
|
139
55
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const reason = blockConfig.version
|
|
144
|
-
? `user tagged as '${newVersion}'`
|
|
145
|
-
: `content changed (${newVersion})`;
|
|
146
|
-
console.log(`Creating shared block ${newLabel} (${reason}, was ${existing.label})`);
|
|
147
|
-
const newBlock = await this.client.createBlock({
|
|
148
|
-
label: newLabel,
|
|
149
|
-
description: blockConfig.description,
|
|
150
|
-
value: blockConfig.value,
|
|
151
|
-
limit: blockConfig.limit
|
|
152
|
-
});
|
|
153
|
-
const blockVersion = {
|
|
154
|
-
id: newBlock.id,
|
|
155
|
-
label: newLabel,
|
|
156
|
-
description: blockConfig.description,
|
|
157
|
-
value: blockConfig.value,
|
|
158
|
-
limit: blockConfig.limit,
|
|
159
|
-
contentHash,
|
|
160
|
-
version: newVersion,
|
|
161
|
-
isShared: true,
|
|
162
|
-
lastUpdated: new Date().toISOString(),
|
|
163
|
-
userDefined
|
|
164
|
-
};
|
|
165
|
-
this.blockRegistry.set(blockKey, blockVersion);
|
|
166
|
-
return newBlock.id;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
else {
|
|
170
|
-
// Create new shared block
|
|
171
|
-
const isFirstVersion = newVersion === 'initial';
|
|
172
|
-
const newLabel = this.createVersionedLabel(blockConfig.name, newVersion, isFirstVersion);
|
|
173
|
-
console.log(`Creating new shared block: ${newLabel}${userDefined ? ` (tagged: ${newVersion})` : ''}`);
|
|
174
|
-
const newBlock = await this.client.createBlock({
|
|
175
|
-
label: newLabel,
|
|
176
|
-
description: blockConfig.description,
|
|
56
|
+
// Content changed - update in-place
|
|
57
|
+
console.log(`Updating shared block: ${existing.label}`);
|
|
58
|
+
await this.client.updateBlock(existing.id, {
|
|
177
59
|
value: blockConfig.value,
|
|
60
|
+
description: blockConfig.description,
|
|
178
61
|
limit: blockConfig.limit
|
|
179
62
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
contentHash,
|
|
187
|
-
version: newVersion,
|
|
188
|
-
isShared: true,
|
|
189
|
-
lastUpdated: new Date().toISOString(),
|
|
190
|
-
userDefined
|
|
191
|
-
};
|
|
192
|
-
this.blockRegistry.set(blockKey, blockVersion);
|
|
193
|
-
return newBlock.id;
|
|
63
|
+
// Update registry
|
|
64
|
+
existing.value = blockConfig.value;
|
|
65
|
+
existing.contentHash = contentHash;
|
|
66
|
+
existing.description = blockConfig.description;
|
|
67
|
+
existing.limit = blockConfig.limit;
|
|
68
|
+
return existing.id;
|
|
194
69
|
}
|
|
70
|
+
// Create new block
|
|
71
|
+
console.log(`Creating new shared block: ${blockConfig.name}`);
|
|
72
|
+
const newBlock = await this.client.createBlock({
|
|
73
|
+
label: blockConfig.name,
|
|
74
|
+
description: blockConfig.description,
|
|
75
|
+
value: blockConfig.value,
|
|
76
|
+
limit: blockConfig.limit
|
|
77
|
+
});
|
|
78
|
+
const blockInfo = {
|
|
79
|
+
id: newBlock.id,
|
|
80
|
+
label: blockConfig.name,
|
|
81
|
+
description: blockConfig.description,
|
|
82
|
+
value: blockConfig.value,
|
|
83
|
+
limit: blockConfig.limit,
|
|
84
|
+
contentHash,
|
|
85
|
+
isShared: true
|
|
86
|
+
};
|
|
87
|
+
this.blockRegistry.set(blockKey, blockInfo);
|
|
88
|
+
return newBlock.id;
|
|
195
89
|
}
|
|
196
90
|
/**
|
|
197
|
-
* Gets or creates an agent-specific block
|
|
91
|
+
* Gets or creates an agent-specific block, updating in-place if content changed
|
|
198
92
|
*/
|
|
199
|
-
async getOrCreateAgentBlock(blockConfig,
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
const contentHash = this.generateContentHash(blockConfig.value);
|
|
93
|
+
async getOrCreateAgentBlock(blockConfig, _agentName) {
|
|
94
|
+
const blockKey = this.getBlockKey(blockConfig.name, false);
|
|
95
|
+
const contentHash = (0, hash_utils_1.generateContentHash)(blockConfig.value);
|
|
203
96
|
const existing = this.blockRegistry.get(blockKey);
|
|
204
|
-
// Determine version strategy
|
|
205
|
-
let newVersion;
|
|
206
|
-
let userDefined = false;
|
|
207
|
-
if (blockConfig.version) {
|
|
208
|
-
newVersion = this.validateUserVersion(blockConfig.version);
|
|
209
|
-
userDefined = true;
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
newVersion = existing ? this.generateTimestampVersion(contentHash) : 'initial';
|
|
213
|
-
}
|
|
214
97
|
if (existing) {
|
|
215
|
-
|
|
216
|
-
if (existing.contentHash === contentHash && !blockConfig.version) {
|
|
98
|
+
if (existing.contentHash === contentHash) {
|
|
217
99
|
console.log(`Using existing block: ${existing.label}`);
|
|
218
100
|
return existing.id;
|
|
219
101
|
}
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const reason = blockConfig.version
|
|
224
|
-
? `user tagged as '${newVersion}'`
|
|
225
|
-
: `content changed (${newVersion})`;
|
|
226
|
-
console.log(`Creating block ${newLabel} (${reason}, was ${existing.label})`);
|
|
227
|
-
const newBlock = await this.client.createBlock({
|
|
228
|
-
label: newLabel,
|
|
229
|
-
description: blockConfig.description,
|
|
230
|
-
value: blockConfig.value,
|
|
231
|
-
limit: blockConfig.limit
|
|
232
|
-
});
|
|
233
|
-
const blockVersion = {
|
|
234
|
-
id: newBlock.id,
|
|
235
|
-
label: newLabel,
|
|
236
|
-
description: blockConfig.description,
|
|
237
|
-
value: blockConfig.value,
|
|
238
|
-
limit: blockConfig.limit,
|
|
239
|
-
contentHash,
|
|
240
|
-
version: newVersion,
|
|
241
|
-
isShared: false,
|
|
242
|
-
lastUpdated: new Date().toISOString(),
|
|
243
|
-
userDefined
|
|
244
|
-
};
|
|
245
|
-
this.blockRegistry.set(blockKey, blockVersion);
|
|
246
|
-
return newBlock.id;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
else {
|
|
250
|
-
// Create new agent block
|
|
251
|
-
const isFirstVersion = newVersion === 'initial';
|
|
252
|
-
const newLabel = this.createVersionedLabel(fullBlockName, newVersion, isFirstVersion);
|
|
253
|
-
console.log(`Creating new block: ${newLabel}${userDefined ? ` (tagged: ${newVersion})` : ''}`);
|
|
254
|
-
const newBlock = await this.client.createBlock({
|
|
255
|
-
label: newLabel,
|
|
256
|
-
description: blockConfig.description,
|
|
102
|
+
// Content changed - update in-place
|
|
103
|
+
console.log(`Updating block: ${existing.label}`);
|
|
104
|
+
await this.client.updateBlock(existing.id, {
|
|
257
105
|
value: blockConfig.value,
|
|
106
|
+
description: blockConfig.description,
|
|
258
107
|
limit: blockConfig.limit
|
|
259
108
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
contentHash,
|
|
267
|
-
version: newVersion,
|
|
268
|
-
isShared: false,
|
|
269
|
-
lastUpdated: new Date().toISOString(),
|
|
270
|
-
userDefined
|
|
271
|
-
};
|
|
272
|
-
this.blockRegistry.set(blockKey, blockVersion);
|
|
273
|
-
return newBlock.id;
|
|
109
|
+
// Update registry
|
|
110
|
+
existing.value = blockConfig.value;
|
|
111
|
+
existing.contentHash = contentHash;
|
|
112
|
+
existing.description = blockConfig.description;
|
|
113
|
+
existing.limit = blockConfig.limit;
|
|
114
|
+
return existing.id;
|
|
274
115
|
}
|
|
116
|
+
// Create new block
|
|
117
|
+
console.log(`Creating new block: ${blockConfig.name}`);
|
|
118
|
+
const newBlock = await this.client.createBlock({
|
|
119
|
+
label: blockConfig.name,
|
|
120
|
+
description: blockConfig.description,
|
|
121
|
+
value: blockConfig.value,
|
|
122
|
+
limit: blockConfig.limit
|
|
123
|
+
});
|
|
124
|
+
const blockInfo = {
|
|
125
|
+
id: newBlock.id,
|
|
126
|
+
label: blockConfig.name,
|
|
127
|
+
description: blockConfig.description,
|
|
128
|
+
value: blockConfig.value,
|
|
129
|
+
limit: blockConfig.limit,
|
|
130
|
+
contentHash,
|
|
131
|
+
isShared: false
|
|
132
|
+
};
|
|
133
|
+
this.blockRegistry.set(blockKey, blockInfo);
|
|
134
|
+
return newBlock.id;
|
|
275
135
|
}
|
|
276
136
|
/**
|
|
277
137
|
* Gets the shared block ID by name
|
|
278
138
|
*/
|
|
279
139
|
getSharedBlockId(blockName) {
|
|
280
|
-
// Check both shared and non-shared keys
|
|
281
140
|
let existing = this.blockRegistry.get(this.getBlockKey(blockName, true));
|
|
282
141
|
if (!existing) {
|
|
283
142
|
existing = this.blockRegistry.get(this.getBlockKey(blockName, false));
|
|
@@ -288,12 +147,11 @@ class BlockManager {
|
|
|
288
147
|
* Gets agent block ID by name if it exists
|
|
289
148
|
*/
|
|
290
149
|
getAgentBlockId(blockName) {
|
|
291
|
-
const
|
|
292
|
-
const existing = this.blockRegistry.get(blockKey);
|
|
150
|
+
const existing = this.blockRegistry.get(this.getBlockKey(blockName, false));
|
|
293
151
|
return existing ? existing.id : null;
|
|
294
152
|
}
|
|
295
153
|
/**
|
|
296
|
-
* Lists all
|
|
154
|
+
* Lists all blocks for debugging/reporting
|
|
297
155
|
*/
|
|
298
156
|
getBlockRegistry() {
|
|
299
157
|
return new Map(this.blockRegistry);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block-manager.js","sourceRoot":"","sources":["../../src/lib/block-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"block-manager.js","sourceRoot":"","sources":["../../src/lib/block-manager.ts"],"names":[],"mappings":";;;AACA,+DAA0D;AAC1D,oDAA0D;AAY1D,MAAa,YAAY;IAIvB,YAAY,MAA0B;QAF9B,kBAAa,GAAG,IAAI,GAAG,EAAqB,CAAC;QAGnD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,kBAAkB;QACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAA,uCAAiB,EAAC,MAAM,CAAC,CAAC;QAE5C,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;YAC9B,IAAI,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAC/B,MAAM,WAAW,GAAG,IAAA,gCAAmB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC;gBACrD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;gBAEnD,MAAM,SAAS,GAAc;oBAC3B,EAAE,EAAE,KAAK,CAAC,EAAE;oBACZ,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,EAAE;oBACpC,KAAK,EAAE,KAAK,CAAC,KAAK;oBAClB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,CAAC;oBACvB,WAAW;oBACX,QAAQ;iBACT,CAAC;gBAEF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,QA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;YACvB,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,KAAK,EAAE,WAAW,CAAC,KAAK;YACxB,WAAW;YACX,QAAQ,EAAE,KAAK;SAChB,CAAC;QAEF,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAC5C,OAAO,QAAQ,CAAC,EAAE,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,SAAiB;QAChC,IAAI,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;QACzE,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QACxE,CAAC;QACD,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,eAAe,CAAC,SAAiB;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5E,OAAO,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACrC,CAAC;CACF;AApLD,oCAoLC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LettaClientWrapper } from './letta-client';
|
|
2
|
+
import { BlockManager } from './block-manager';
|
|
3
|
+
import { ToolDiff, BlockDiff, FolderDiff } from './diff-engine';
|
|
4
|
+
export declare function analyzeToolChanges(currentTools: any[], desiredToolNames: string[], toolRegistry: Map<string, string>, toolSourceHashes?: Record<string, string>): Promise<ToolDiff>;
|
|
5
|
+
export declare function analyzeBlockChanges(currentBlocks: any[], desiredBlocks: Array<{
|
|
6
|
+
name: string;
|
|
7
|
+
isShared?: boolean;
|
|
8
|
+
description?: string;
|
|
9
|
+
limit?: number;
|
|
10
|
+
value?: string;
|
|
11
|
+
}>, blockManager: BlockManager, agentName?: string): Promise<BlockDiff>;
|
|
12
|
+
export declare function analyzeFolderChanges(currentFolders: any[], desiredFolders: Array<{
|
|
13
|
+
name: string;
|
|
14
|
+
files: string[];
|
|
15
|
+
fileContentHashes?: Record<string, string>;
|
|
16
|
+
}>, folderRegistry: Map<string, string>, client: LettaClientWrapper): Promise<FolderDiff>;
|
|
17
|
+
//# sourceMappingURL=diff-analyzers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-analyzers.d.ts","sourceRoot":"","sources":["../../src/lib/diff-analyzers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAMhE,wBAAsB,kBAAkB,CACtC,YAAY,EAAE,GAAG,EAAE,EACnB,gBAAgB,EAAE,MAAM,EAAE,EAC1B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACjC,gBAAgB,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC5C,OAAO,CAAC,QAAQ,CAAC,CAiDnB;AAED,wBAAsB,mBAAmB,CACvC,aAAa,EAAE,GAAG,EAAE,EACpB,aAAa,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAChH,YAAY,EAAE,YAAY,EAC1B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,CAAC,CA8CpB;AAED,wBAAsB,oBAAoB,CACxC,cAAc,EAAE,GAAG,EAAE,EACrB,cAAc,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAAC,EACpG,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EACnC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,UAAU,CAAC,CAsFrB"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.analyzeToolChanges = analyzeToolChanges;
|
|
4
|
+
exports.analyzeBlockChanges = analyzeBlockChanges;
|
|
5
|
+
exports.analyzeFolderChanges = analyzeFolderChanges;
|
|
6
|
+
const response_normalizer_1 = require("./response-normalizer");
|
|
7
|
+
function hasFileBasedContent(itemName, fileHashes) {
|
|
8
|
+
return !!fileHashes[itemName];
|
|
9
|
+
}
|
|
10
|
+
async function analyzeToolChanges(currentTools, desiredToolNames, toolRegistry, toolSourceHashes = {}) {
|
|
11
|
+
const currentToolNames = new Set(currentTools.map(t => t.name));
|
|
12
|
+
const desiredToolSet = new Set(desiredToolNames);
|
|
13
|
+
const toAdd = [];
|
|
14
|
+
const toRemove = [];
|
|
15
|
+
const toUpdate = [];
|
|
16
|
+
const unchanged = [];
|
|
17
|
+
// Find tools to add
|
|
18
|
+
for (const toolName of desiredToolNames) {
|
|
19
|
+
if (!currentToolNames.has(toolName)) {
|
|
20
|
+
const toolId = toolRegistry.get(toolName);
|
|
21
|
+
if (toolId) {
|
|
22
|
+
toAdd.push({ name: toolName, id: toolId });
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// Find tools to remove, update (source code changed), or leave unchanged
|
|
27
|
+
for (const tool of currentTools) {
|
|
28
|
+
if (desiredToolSet.has(tool.name)) {
|
|
29
|
+
const toolName = tool.name;
|
|
30
|
+
if (hasFileBasedContent(toolName, toolSourceHashes) && !['archival_memory_insert', 'archival_memory_search'].includes(toolName)) {
|
|
31
|
+
console.log(`Tool ${toolName} has file-based content, checking for updates...`);
|
|
32
|
+
const currentToolId = tool.id;
|
|
33
|
+
const newToolId = toolRegistry.get(toolName);
|
|
34
|
+
if (newToolId && newToolId !== currentToolId) {
|
|
35
|
+
toUpdate.push({
|
|
36
|
+
name: toolName,
|
|
37
|
+
currentId: currentToolId,
|
|
38
|
+
newId: newToolId,
|
|
39
|
+
reason: 'source_code_changed'
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
unchanged.push({ name: toolName, id: currentToolId });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
unchanged.push({ name: tool.name, id: tool.id });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
toRemove.push({ name: tool.name, id: tool.id });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return { toAdd, toRemove, toUpdate, unchanged };
|
|
55
|
+
}
|
|
56
|
+
async function analyzeBlockChanges(currentBlocks, desiredBlocks, blockManager, agentName) {
|
|
57
|
+
const currentBlockNames = new Set(currentBlocks.map(b => b.label));
|
|
58
|
+
const desiredBlockNames = new Set(desiredBlocks.map(b => b.name));
|
|
59
|
+
const toAdd = [];
|
|
60
|
+
const toRemove = [];
|
|
61
|
+
const toUpdate = [];
|
|
62
|
+
const unchanged = [];
|
|
63
|
+
// Find blocks to add
|
|
64
|
+
for (const blockConfig of desiredBlocks) {
|
|
65
|
+
if (!currentBlockNames.has(blockConfig.name)) {
|
|
66
|
+
let blockId = blockConfig.isShared
|
|
67
|
+
? blockManager.getSharedBlockId(blockConfig.name)
|
|
68
|
+
: blockManager.getAgentBlockId(blockConfig.name);
|
|
69
|
+
// If block doesn't exist yet, create it
|
|
70
|
+
if (!blockId && !blockConfig.isShared && blockConfig.description && agentName) {
|
|
71
|
+
console.log(`Creating new memory block: ${blockConfig.name} for agent ${agentName}`);
|
|
72
|
+
blockId = await blockManager.getOrCreateAgentBlock({
|
|
73
|
+
name: blockConfig.name,
|
|
74
|
+
description: blockConfig.description,
|
|
75
|
+
limit: blockConfig.limit || 2000,
|
|
76
|
+
value: blockConfig.value || ''
|
|
77
|
+
}, agentName);
|
|
78
|
+
}
|
|
79
|
+
if (blockId) {
|
|
80
|
+
toAdd.push({ name: blockConfig.name, id: blockId });
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
// Find blocks to remove or mark as unchanged
|
|
85
|
+
for (const block of currentBlocks) {
|
|
86
|
+
if (desiredBlockNames.has(block.label)) {
|
|
87
|
+
unchanged.push({ name: block.label, id: block.id });
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
toRemove.push({ name: block.label, id: block.id });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { toAdd, toRemove, toUpdate, unchanged };
|
|
94
|
+
}
|
|
95
|
+
async function analyzeFolderChanges(currentFolders, desiredFolders, folderRegistry, client) {
|
|
96
|
+
const currentFolderNames = new Set(currentFolders.map(f => f.name));
|
|
97
|
+
const desiredFolderNames = new Set(desiredFolders.map(f => f.name));
|
|
98
|
+
const toAttach = [];
|
|
99
|
+
const toDetach = [];
|
|
100
|
+
const toUpdate = [];
|
|
101
|
+
const unchanged = [];
|
|
102
|
+
// Find folders to attach (new folders)
|
|
103
|
+
for (const folderConfig of desiredFolders) {
|
|
104
|
+
if (!currentFolderNames.has(folderConfig.name)) {
|
|
105
|
+
const folderId = folderRegistry.get(folderConfig.name);
|
|
106
|
+
if (folderId) {
|
|
107
|
+
toAttach.push({ name: folderConfig.name, id: folderId });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Find folders to detach, update, or leave unchanged
|
|
112
|
+
for (const folder of currentFolders) {
|
|
113
|
+
if (desiredFolderNames.has(folder.name)) {
|
|
114
|
+
const desiredFolder = desiredFolders.find(f => f.name === folder.name);
|
|
115
|
+
if (desiredFolder && desiredFolder.fileContentHashes) {
|
|
116
|
+
try {
|
|
117
|
+
const currentFilesResponse = await client.listFolderFiles(folder.id);
|
|
118
|
+
const currentFiles = (0, response_normalizer_1.normalizeResponse)(currentFilesResponse);
|
|
119
|
+
const currentFileNames = new Set(currentFiles.map((f) => f.name || f.file_name || String(f)).filter(Boolean));
|
|
120
|
+
const desiredFileNames = new Set(desiredFolder.files);
|
|
121
|
+
const filesToAdd = [];
|
|
122
|
+
const filesToRemove = [];
|
|
123
|
+
const filesToUpdate = [];
|
|
124
|
+
// Find files to add or update
|
|
125
|
+
for (const filePath of desiredFolder.files) {
|
|
126
|
+
const fileName = filePath.split('/').pop() || filePath;
|
|
127
|
+
if (!currentFileNames.has(fileName)) {
|
|
128
|
+
filesToAdd.push(filePath);
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
if (hasFileBasedContent(filePath, desiredFolder.fileContentHashes || {})) {
|
|
132
|
+
console.log(`File ${filePath} has file-based content, checking for updates...`);
|
|
133
|
+
filesToUpdate.push(filePath);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Find files to remove
|
|
138
|
+
for (const currentFile of currentFiles) {
|
|
139
|
+
const fileName = currentFile.name || currentFile.file_name || String(currentFile);
|
|
140
|
+
if (fileName && !desiredFileNames.has(fileName)) {
|
|
141
|
+
filesToRemove.push(fileName);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (filesToAdd.length > 0 || filesToRemove.length > 0 || filesToUpdate.length > 0) {
|
|
145
|
+
toUpdate.push({
|
|
146
|
+
name: folder.name,
|
|
147
|
+
id: folder.id,
|
|
148
|
+
filesToAdd,
|
|
149
|
+
filesToRemove,
|
|
150
|
+
filesToUpdate
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
catch (error) {
|
|
158
|
+
console.warn(`Could not analyze files in folder ${folder.name}:`, error);
|
|
159
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
unchanged.push({ name: folder.name, id: folder.id });
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
toDetach.push({ name: folder.name, id: folder.id });
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return { toAttach, toDetach, toUpdate, unchanged };
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=diff-analyzers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-analyzers.js","sourceRoot":"","sources":["../../src/lib/diff-analyzers.ts"],"names":[],"mappings":";;AASA,gDAsDC;AAED,kDAmDC;AAED,oDA2FC;AA/MD,+DAA0D;AAG1D,SAAS,mBAAmB,CAAC,QAAgB,EAAE,UAAkC;IAC/E,OAAO,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAEM,KAAK,UAAU,kBAAkB,CACtC,YAAmB,EACnB,gBAA0B,EAC1B,YAAiC,EACjC,mBAA2C,EAAE;IAE7C,MAAM,gBAAgB,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IAChE,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,gBAAg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,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IAED,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LettaClientWrapper } from './letta-client';
|
|
2
|
+
import { AgentUpdateOperations } from './diff-engine';
|
|
3
|
+
/**
|
|
4
|
+
* DiffApplier applies update operations to agents
|
|
5
|
+
*/
|
|
6
|
+
export declare class DiffApplier {
|
|
7
|
+
private client;
|
|
8
|
+
private basePath;
|
|
9
|
+
constructor(client: LettaClientWrapper, basePath?: string);
|
|
10
|
+
/**
|
|
11
|
+
* Applies the update operations to the agent
|
|
12
|
+
*/
|
|
13
|
+
applyUpdateOperations(agentId: string, operations: AgentUpdateOperations, verbose?: boolean): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Helper method to add a file to an existing folder
|
|
16
|
+
*/
|
|
17
|
+
private addFileToFolder;
|
|
18
|
+
/**
|
|
19
|
+
* Helper method to remove a file from a folder
|
|
20
|
+
*/
|
|
21
|
+
private removeFileFromFolder;
|
|
22
|
+
/**
|
|
23
|
+
* Helper method to update an existing file in a folder
|
|
24
|
+
*/
|
|
25
|
+
private updateFileInFolder;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=diff-applier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-applier.d.ts","sourceRoot":"","sources":["../../src/lib/diff-applier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEtD;;GAEG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,QAAQ,CAAS;gBAEb,MAAM,EAAE,kBAAkB,EAAE,QAAQ,GAAE,MAAW;IAK7D;;OAEG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,UAAU,EAAE,qBAAqB,EACjC,OAAO,GAAE,OAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAwGhB;;OAEG;YACW,eAAe;IAY7B;;OAEG;YACW,oBAAoB;IAYlC;;OAEG;YACW,kBAAkB;CAYjC"}
|