@aion0/forge 0.5.36 → 0.5.37
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/RELEASE_NOTES.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Forge v0.5.
|
|
1
|
+
# Forge v0.5.37
|
|
2
2
|
|
|
3
3
|
Released: 2026-04-11
|
|
4
4
|
|
|
5
|
-
## Changes since v0.5.
|
|
5
|
+
## Changes since v0.5.36
|
|
6
6
|
|
|
7
|
-
###
|
|
8
|
-
-
|
|
7
|
+
### Performance
|
|
8
|
+
- perf: prune bus log to prevent unbounded growth
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
**Full Changelog**: https://github.com/aiwatching/forge/compare/v0.5.
|
|
11
|
+
**Full Changelog**: https://github.com/aiwatching/forge/compare/v0.5.36...v0.5.37
|
|
@@ -63,6 +63,7 @@ export class AgentBus extends EventEmitter {
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
this.log.push(msg);
|
|
66
|
+
this.pruneIfNeeded();
|
|
66
67
|
this.emit('message', msg);
|
|
67
68
|
|
|
68
69
|
// ACK messages don't need delivery tracking
|
|
@@ -350,6 +351,35 @@ export class AgentBus extends EventEmitter {
|
|
|
350
351
|
if (count > 0) console.log(`[bus] Marked ${count} pending messages as failed (restart cleanup)`);
|
|
351
352
|
}
|
|
352
353
|
|
|
354
|
+
// ─── Log maintenance ───────────────────────────────────
|
|
355
|
+
|
|
356
|
+
private static readonly MAX_LOG_SIZE = 500;
|
|
357
|
+
private static readonly PRUNE_KEEP = 200;
|
|
358
|
+
|
|
359
|
+
/** Prune completed messages to prevent unbounded log growth.
|
|
360
|
+
* Keeps: all pending/running messages + last N completed ones.
|
|
361
|
+
* Called automatically after each send(). */
|
|
362
|
+
private pruneIfNeeded(): void {
|
|
363
|
+
if (this.log.length <= AgentBus.MAX_LOG_SIZE) return;
|
|
364
|
+
|
|
365
|
+
// Separate active (must keep) from completed (can prune)
|
|
366
|
+
const active: BusMessage[] = [];
|
|
367
|
+
const completed: BusMessage[] = [];
|
|
368
|
+
for (const m of this.log) {
|
|
369
|
+
if (m.status === 'pending' || m.status === 'pending_approval' || m.status === 'running') {
|
|
370
|
+
active.push(m);
|
|
371
|
+
} else {
|
|
372
|
+
completed.push(m);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// Keep all active + most recent N completed
|
|
377
|
+
const keep = completed.slice(-AgentBus.PRUNE_KEEP);
|
|
378
|
+
this.log = [...active, ...keep].sort((a, b) => a.timestamp - b.timestamp);
|
|
379
|
+
const pruned = completed.length - keep.length;
|
|
380
|
+
if (pruned > 0) console.log(`[bus] Pruned ${pruned} completed messages (${this.log.length} remaining)`);
|
|
381
|
+
}
|
|
382
|
+
|
|
353
383
|
// ─── Query ─────────────────────────────────────────────
|
|
354
384
|
|
|
355
385
|
getMessagesFor(agentId: string): BusMessage[] {
|
|
@@ -374,6 +404,11 @@ export class AgentBus extends EventEmitter {
|
|
|
374
404
|
return this.log;
|
|
375
405
|
}
|
|
376
406
|
|
|
407
|
+
/** Get log for persistence — excludes _system messages (transient notifications) */
|
|
408
|
+
getLogForPersistence(): BusMessage[] {
|
|
409
|
+
return this.log.filter(m => m.to !== '_system');
|
|
410
|
+
}
|
|
411
|
+
|
|
377
412
|
/** Get all outbox queues (for persistence) */
|
|
378
413
|
getAllOutbox(): Record<string, BusMessage[]> {
|
|
379
414
|
const result: Record<string, BusMessage[]> = {};
|
|
@@ -385,6 +420,7 @@ export class AgentBus extends EventEmitter {
|
|
|
385
420
|
|
|
386
421
|
loadLog(messages: BusMessage[]): void {
|
|
387
422
|
this.log = [...messages];
|
|
423
|
+
this.pruneIfNeeded();
|
|
388
424
|
}
|
|
389
425
|
|
|
390
426
|
/** Restore outbox from persisted state */
|
|
@@ -1870,7 +1870,7 @@ export class WorkspaceOrchestrator extends EventEmitter {
|
|
|
1870
1870
|
agents: Array.from(this.agents.values()).map(e => e.config),
|
|
1871
1871
|
agentStates: this.getAllAgentStates(),
|
|
1872
1872
|
nodePositions: this.nodePositions,
|
|
1873
|
-
busLog:
|
|
1873
|
+
busLog: this.bus.getLogForPersistence(),
|
|
1874
1874
|
busOutbox: this.bus.getAllOutbox(),
|
|
1875
1875
|
createdAt: this.createdAt,
|
|
1876
1876
|
updatedAt: Date.now(),
|
package/package.json
CHANGED