@elizaos/plugin-agent-orchestrator 0.4.1 → 0.4.2
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/index.js +17 -3
- package/dist/index.js.map +3 -3
- package/dist/services/swarm-history.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3241,6 +3241,7 @@ import * as os from "os";
|
|
|
3241
3241
|
import * as path2 from "path";
|
|
3242
3242
|
var MAX_ENTRIES = 150;
|
|
3243
3243
|
var TRUNCATE_TO = 100;
|
|
3244
|
+
var MAX_FILE_SIZE_BYTES = 1048576;
|
|
3244
3245
|
|
|
3245
3246
|
class WriteMutex {
|
|
3246
3247
|
queue = [];
|
|
@@ -3280,6 +3281,13 @@ class SwarmHistory {
|
|
|
3280
3281
|
await fs.appendFile(this.filePath, `${JSON.stringify(entry)}
|
|
3281
3282
|
`, "utf-8");
|
|
3282
3283
|
this.appendCount++;
|
|
3284
|
+
try {
|
|
3285
|
+
const stat2 = await fs.stat(this.filePath);
|
|
3286
|
+
if (stat2.size > MAX_FILE_SIZE_BYTES) {
|
|
3287
|
+
await this.truncateInner(TRUNCATE_TO);
|
|
3288
|
+
return;
|
|
3289
|
+
}
|
|
3290
|
+
} catch {}
|
|
3283
3291
|
if (this.appendCount >= MAX_ENTRIES - TRUNCATE_TO) {
|
|
3284
3292
|
const content = await fs.readFile(this.filePath, "utf-8");
|
|
3285
3293
|
const lineCount = content.split(`
|
|
@@ -3339,10 +3347,16 @@ class SwarmHistory {
|
|
|
3339
3347
|
return;
|
|
3340
3348
|
}
|
|
3341
3349
|
}
|
|
3342
|
-
|
|
3343
|
-
|
|
3350
|
+
let kept = entries.slice(-maxEntries);
|
|
3351
|
+
let content = kept.map((e) => JSON.stringify(e)).join(`
|
|
3352
|
+
`) + `
|
|
3353
|
+
`;
|
|
3354
|
+
while (Buffer.byteLength(content, "utf-8") > MAX_FILE_SIZE_BYTES && kept.length > 1) {
|
|
3355
|
+
kept = kept.slice(Math.max(1, Math.floor(kept.length * 0.2)));
|
|
3356
|
+
content = kept.map((e) => JSON.stringify(e)).join(`
|
|
3344
3357
|
`) + `
|
|
3345
3358
|
`;
|
|
3359
|
+
}
|
|
3346
3360
|
await fs.writeFile(this.filePath, content, "utf-8");
|
|
3347
3361
|
this.appendCount = 0;
|
|
3348
3362
|
}
|
|
@@ -8029,5 +8043,5 @@ export {
|
|
|
8029
8043
|
CodingWorkspaceService
|
|
8030
8044
|
};
|
|
8031
8045
|
|
|
8032
|
-
//# debugId=
|
|
8046
|
+
//# debugId=322E3591797FD51B64756E2164756E21
|
|
8033
8047
|
//# sourceMappingURL=index.js.map
|