@codebolt/agent 6.1.5 → 6.1.7
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/processor-pieces/messageModifiers/atFileProcessorModifier.d.ts +0 -1
- package/dist/processor-pieces/messageModifiers/atFileProcessorModifier.js +6 -74
- package/dist/unified/agent/agent.js +2 -0
- package/dist/unified/agent/codeboltAgent.js +2 -0
- package/dist/unified/services/compaction/autoCompact.d.ts +1 -0
- package/dist/unified/services/compaction/autoCompact.js +5 -0
- package/dist/unified/services/compaction/compactionOrchestrator.d.ts +1 -0
- package/dist/unified/services/compaction/compactionOrchestrator.js +9 -0
- package/dist/unified/services/compaction/contextCollapse.d.ts +1 -0
- package/dist/unified/services/compaction/contextCollapse.js +5 -0
- package/dist/unified/services/compaction/reactiveCompact.d.ts +1 -0
- package/dist/unified/services/compaction/reactiveCompact.js +5 -0
- package/package.json +1 -1
|
@@ -18,7 +18,6 @@ export declare class AtFileProcessorModifier extends BaseMessageModifier {
|
|
|
18
18
|
private findFiles;
|
|
19
19
|
private readManyFiles;
|
|
20
20
|
private readFileContent;
|
|
21
|
-
private getFilesInFolder;
|
|
22
21
|
private getFolderStructure;
|
|
23
22
|
private findLastUserMessage;
|
|
24
23
|
private getProjectPath;
|
|
@@ -182,40 +182,12 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
182
182
|
const resolvedPath = await this.resolvePath(folderPath, workspaceDirectories);
|
|
183
183
|
const structure = await this.getFolderStructure(resolvedPath);
|
|
184
184
|
filesRead.push(folderPath);
|
|
185
|
-
contextParts.push(`\
|
|
185
|
+
contextParts.push(`\nDirectory listing for @${folderPath}:\n`);
|
|
186
186
|
contextParts.push(structure);
|
|
187
|
-
// Also read files within the folder
|
|
188
|
-
const filesInFolder = await this.getFilesInFolder(resolvedPath);
|
|
189
|
-
// console.log(`Found ${filesInFolder.length} files in ${folderPath}:`, filesInFolder.map(f => path.basename(f)));
|
|
190
|
-
if (filesInFolder.length > 0) {
|
|
191
|
-
contextParts.push(`\n--- Files in ${folderPath} ---`);
|
|
192
|
-
for (const filePath of filesInFolder) {
|
|
193
|
-
try {
|
|
194
|
-
// console.log(`Attempting to read file: ${filePath}`);
|
|
195
|
-
const content = await this.readFileContent(filePath);
|
|
196
|
-
const relativePath = path.relative(resolvedPath, filePath);
|
|
197
|
-
const displayPath = `${folderPath}/${relativePath}`;
|
|
198
|
-
contextParts.push(`\nContent from @${displayPath}:\n`);
|
|
199
|
-
contextParts.push(content);
|
|
200
|
-
// console.log(`Successfully read file: ${displayPath} (${content.length} chars)`);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
204
|
-
const relativePath = path.relative(resolvedPath, filePath);
|
|
205
|
-
const displayPath = `${folderPath}/${relativePath}`;
|
|
206
|
-
console.error(`Error reading file ${displayPath}:`, errorMessage);
|
|
207
|
-
contextParts.push(`\nContent from @${displayPath}:\n`);
|
|
208
|
-
contextParts.push(`[Error reading file: ${errorMessage}]`);
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else {
|
|
213
|
-
console.log(`No files found in ${folderPath} (resolved to ${resolvedPath})`);
|
|
214
|
-
}
|
|
215
187
|
}
|
|
216
188
|
catch (error) {
|
|
217
189
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
218
|
-
contextParts.push(`\
|
|
190
|
+
contextParts.push(`\nDirectory listing for @${folderPath}:\n`);
|
|
219
191
|
contextParts.push(`[Error reading folder ${folderPath}: ${errorMessage}]`);
|
|
220
192
|
}
|
|
221
193
|
}
|
|
@@ -360,26 +332,6 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
360
332
|
const content = await fs.readFile(filePath, 'utf-8');
|
|
361
333
|
return content;
|
|
362
334
|
}
|
|
363
|
-
async getFilesInFolder(folderPath) {
|
|
364
|
-
try {
|
|
365
|
-
const entries = await fs.readdir(folderPath, { withFileTypes: true });
|
|
366
|
-
const files = [];
|
|
367
|
-
for (const entry of entries) {
|
|
368
|
-
if (entry.isFile() && !entry.name.startsWith('.')) {
|
|
369
|
-
const filePath = path.join(folderPath, entry.name);
|
|
370
|
-
if (await this.isReadableTextFile(filePath)) {
|
|
371
|
-
files.push(path.join(folderPath, entry.name));
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
// Limit number of files to avoid overwhelming output
|
|
376
|
-
return files.slice(0, 10);
|
|
377
|
-
}
|
|
378
|
-
catch (error) {
|
|
379
|
-
console.error('Error reading files in folder:', error);
|
|
380
|
-
return [];
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
335
|
async getFolderStructure(folderPath) {
|
|
384
336
|
// Check if folder exists and is readable
|
|
385
337
|
const stats = await fs.stat(folderPath);
|
|
@@ -388,30 +340,10 @@ class AtFileProcessorModifier extends base_1.BaseMessageModifier {
|
|
|
388
340
|
}
|
|
389
341
|
// Read directory structure
|
|
390
342
|
const entries = await fs.readdir(folderPath, { withFileTypes: true });
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
return -1;
|
|
396
|
-
if (!a.isDirectory() && b.isDirectory())
|
|
397
|
-
return 1;
|
|
398
|
-
return a.name.localeCompare(b.name);
|
|
399
|
-
});
|
|
400
|
-
for (const entry of sortedEntries.slice(0, 50)) { // Limit to 50 entries
|
|
401
|
-
if (entry.name.startsWith('.'))
|
|
402
|
-
continue; // Skip hidden files
|
|
403
|
-
if (entry.isDirectory()) {
|
|
404
|
-
lines.push(`${path.basename(folderPath)}/${entry.name}/`);
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
const filePath = path.join(folderPath, entry.name);
|
|
408
|
-
const fileStats = await fs.stat(filePath);
|
|
409
|
-
const size = fileStats.size < 1024 ? `${fileStats.size}B` : `${Math.round(fileStats.size / 1024)}KB`;
|
|
410
|
-
lines.push(`${path.basename(folderPath)}/${entry.name} (${size})`);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
if (entries.length > 50) {
|
|
414
|
-
lines.push(`... and ${entries.length - 50} more items`);
|
|
343
|
+
const maxDirectoryEntries = 1000;
|
|
344
|
+
const lines = entries.slice(0, maxDirectoryEntries).map((entry) => entry.name);
|
|
345
|
+
if (entries.length > maxDirectoryEntries) {
|
|
346
|
+
lines.push(`\u2026 and ${entries.length - maxDirectoryEntries} more entries`);
|
|
415
347
|
}
|
|
416
348
|
return lines.join('\n');
|
|
417
349
|
}
|
|
@@ -26,6 +26,7 @@ class Agent {
|
|
|
26
26
|
this.maxTurns = (_f = runtimeConfig.maxTurns) !== null && _f !== void 0 ? _f : 25;
|
|
27
27
|
}
|
|
28
28
|
async execute(reqMessage) {
|
|
29
|
+
var _a;
|
|
29
30
|
if (!reqMessage) {
|
|
30
31
|
return {
|
|
31
32
|
success: false,
|
|
@@ -58,6 +59,7 @@ class Agent {
|
|
|
58
59
|
while (!stepResult) {
|
|
59
60
|
try {
|
|
60
61
|
const nextStepResult = await agentStep.executeStep(reqMessage, prompt);
|
|
62
|
+
this.compactionOrchestrator.updateModelTokenLimit((_a = nextStepResult.rawLLMResponse) === null || _a === void 0 ? void 0 : _a.tokenLimit);
|
|
61
63
|
const recoverableResponseError = this.getRecoverableResponseError(nextStepResult.rawLLMResponse);
|
|
62
64
|
if (!recoverableResponseError) {
|
|
63
65
|
stepResult = nextStepResult;
|
|
@@ -71,6 +71,7 @@ class CodeboltAgent {
|
|
|
71
71
|
};
|
|
72
72
|
}
|
|
73
73
|
async processMessage(message, context) {
|
|
74
|
+
var _a;
|
|
74
75
|
try {
|
|
75
76
|
const reqMessage = typeof message === 'string'
|
|
76
77
|
? this.createDefaultUserMessage(message)
|
|
@@ -107,6 +108,7 @@ class CodeboltAgent {
|
|
|
107
108
|
while (!stepResult) {
|
|
108
109
|
try {
|
|
109
110
|
const nextStepResult = await agentStep.executeStep(reqMessage, prompt);
|
|
111
|
+
this.compactionOrchestrator.updateModelTokenLimit((_a = nextStepResult.rawLLMResponse) === null || _a === void 0 ? void 0 : _a.tokenLimit);
|
|
110
112
|
const recoverableResponseError = this.getRecoverableResponseError(nextStepResult.rawLLMResponse);
|
|
111
113
|
if (!recoverableResponseError) {
|
|
112
114
|
stepResult = nextStepResult;
|
|
@@ -45,6 +45,7 @@ export declare class AutoCompact implements CompactionLayer {
|
|
|
45
45
|
reset(): void;
|
|
46
46
|
getTracking(): AutoCompactTracking | undefined;
|
|
47
47
|
getConsecutiveFailures(): number;
|
|
48
|
+
updateModelTokenLimit(modelTokenLimit: number): void;
|
|
48
49
|
private compactConversation;
|
|
49
50
|
private findSplitIndex;
|
|
50
51
|
private generateSummary;
|
|
@@ -106,6 +106,11 @@ class AutoCompact {
|
|
|
106
106
|
getConsecutiveFailures() {
|
|
107
107
|
return this.consecutiveFailures;
|
|
108
108
|
}
|
|
109
|
+
updateModelTokenLimit(modelTokenLimit) {
|
|
110
|
+
if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
|
|
111
|
+
this.options.modelTokenLimit = modelTokenLimit;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
109
114
|
// ─── Core Compaction Logic ────────────────────────────────────────
|
|
110
115
|
async compactConversation(messages, ctx) {
|
|
111
116
|
const estimator = new types_1.TokenEstimator();
|
|
@@ -61,6 +61,7 @@ export declare class CompactionOrchestrator {
|
|
|
61
61
|
* Get the number of consecutive auto-compact failures.
|
|
62
62
|
*/
|
|
63
63
|
getConsecutiveFailures(): number;
|
|
64
|
+
updateModelTokenLimit(modelTokenLimit: number | undefined): void;
|
|
64
65
|
/**
|
|
65
66
|
* Reset the reactive compact's per-turn guard.
|
|
66
67
|
* Call at the start of each new turn.
|
|
@@ -200,6 +200,15 @@ class CompactionOrchestrator {
|
|
|
200
200
|
getConsecutiveFailures() {
|
|
201
201
|
return this.auto.getConsecutiveFailures();
|
|
202
202
|
}
|
|
203
|
+
updateModelTokenLimit(modelTokenLimit) {
|
|
204
|
+
if (!Number.isFinite(modelTokenLimit) || !modelTokenLimit || modelTokenLimit <= 0) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this.options.modelTokenLimit = modelTokenLimit;
|
|
208
|
+
this.collapse.updateModelTokenLimit(modelTokenLimit);
|
|
209
|
+
this.auto.updateModelTokenLimit(modelTokenLimit);
|
|
210
|
+
this.reactive.updateModelTokenLimit(modelTokenLimit);
|
|
211
|
+
}
|
|
203
212
|
/**
|
|
204
213
|
* Reset the reactive compact's per-turn guard.
|
|
205
214
|
* Call at the start of each new turn.
|
|
@@ -56,6 +56,7 @@ export declare class ContextCollapse implements CompactionLayer {
|
|
|
56
56
|
*/
|
|
57
57
|
isAtBlockingLimit(messages: MessageObject[]): boolean;
|
|
58
58
|
reset(): void;
|
|
59
|
+
updateModelTokenLimit(modelTokenLimit: number): void;
|
|
59
60
|
private findSplitPoint;
|
|
60
61
|
private buildSummaryMessages;
|
|
61
62
|
private generateGranularSummary;
|
|
@@ -158,6 +158,11 @@ class ContextCollapse {
|
|
|
158
158
|
this.store = [];
|
|
159
159
|
this.staged = [];
|
|
160
160
|
}
|
|
161
|
+
updateModelTokenLimit(modelTokenLimit) {
|
|
162
|
+
if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
|
|
163
|
+
this.options.modelTokenLimit = modelTokenLimit;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
161
166
|
// ─── Private Helpers ──────────────────────────────────────────────
|
|
162
167
|
findSplitPoint(messages, tokensToArchive, estimator) {
|
|
163
168
|
var _a, _b;
|
|
@@ -41,6 +41,7 @@ export declare class ReactiveCompact implements CompactionLayer {
|
|
|
41
41
|
* Reset per-turn guard (call at the start of each turn).
|
|
42
42
|
*/
|
|
43
43
|
resetForTurn(): void;
|
|
44
|
+
updateModelTokenLimit(modelTokenLimit: number): void;
|
|
44
45
|
/**
|
|
45
46
|
* Check if an error message indicates a recoverable context error.
|
|
46
47
|
*/
|
|
@@ -61,6 +61,11 @@ class ReactiveCompact {
|
|
|
61
61
|
resetForTurn() {
|
|
62
62
|
this.hasAttemptedThisTurn = false;
|
|
63
63
|
}
|
|
64
|
+
updateModelTokenLimit(modelTokenLimit) {
|
|
65
|
+
if (Number.isFinite(modelTokenLimit) && modelTokenLimit > 0) {
|
|
66
|
+
this.options.modelTokenLimit = modelTokenLimit;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
64
69
|
/**
|
|
65
70
|
* Check if an error message indicates a recoverable context error.
|
|
66
71
|
*/
|