osborn 0.9.260 → 0.9.262

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/bin/cli.js CHANGED
@@ -99,8 +99,20 @@ if (existsSync(srcPath)) {
99
99
  env: process.env,
100
100
  })
101
101
  } else if (existsSync(distPath)) {
102
- // Production: run compiled JS directly
103
- child = spawn('node', [distPath, mode, ...args], {
102
+ // Production: run compiled JS directly.
103
+ // HEAP-OOM CRASH FIX (0.9.261): long heavy sessions (big context + many
104
+ // sub-agents) grew the MAIN process past its default V8 old-space limit
105
+ // (~2GB), and a barge-in interrupt tipped it over → "FATAL ERROR: Reached
106
+ // heap limit" → process crash → Fly restart → session lost. Observed 3x in
107
+ // one day, always `🔇 Speech interrupted` → heap OOM. Give the main process a
108
+ // heap limit scaled to the machine's RAM (~half), so it has real headroom and
109
+ // AUTO-SCALES if the machine's memory is bumped. Passed as a node ARGV flag —
110
+ // NOT NODE_OPTIONS — so it applies ONLY to the main process and is NOT
111
+ // inherited by the Claude SDK sub-agent subprocesses (which would multiply
112
+ // memory use and cause a system OOM instead).
113
+ const heapMB = Math.max(3072, Math.floor((os.totalmem() / (1024 * 1024)) * 0.5))
114
+ console.log(`[cli] main agent --max-old-space-size=${heapMB}MB (machine RAM ${Math.round(os.totalmem() / (1024 * 1024))}MB)`)
115
+ child = spawn('node', [`--max-old-space-size=${heapMB}`, distPath, mode, ...args], {
104
116
  stdio: 'inherit',
105
117
  cwd: join(__dirname, '..'),
106
118
  env: process.env,
@@ -241,6 +241,13 @@ export declare class ClaudeLLM extends llm.LLM {
241
241
  * Call this when starting a new session
242
242
  */
243
243
  clearCheckpoints(): void;
244
+ /**
245
+ * MEMORY-LEAK HUNT (0.9.262): sizes of every long-lived internal structure,
246
+ * logged by the periodic [MEM] probe in index.ts. Over a long heavy session,
247
+ * whichever counter climbs in lockstep with heapUsed is the retainer behind
248
+ * the heap-OOM crashes (11x since 2026-10-02). Read-only — no behavior change.
249
+ */
250
+ getMemDebug(): Record<string, number>;
244
251
  /**
245
252
  * Check if checkpoints are available
246
253
  */
@@ -1437,6 +1437,24 @@ export class ClaudeLLM extends llm.LLM {
1437
1437
  this.#latestCheckpoint = null;
1438
1438
  console.log('🧹 Checkpoints cleared');
1439
1439
  }
1440
+ /**
1441
+ * MEMORY-LEAK HUNT (0.9.262): sizes of every long-lived internal structure,
1442
+ * logged by the periodic [MEM] probe in index.ts. Over a long heavy session,
1443
+ * whichever counter climbs in lockstep with heapUsed is the retainer behind
1444
+ * the heap-OOM crashes (11x since 2026-10-02). Read-only — no behavior change.
1445
+ */
1446
+ getMemDebug() {
1447
+ return {
1448
+ checkpoints: this.#checkpoints.length,
1449
+ tasksById: this.#tasksById.size,
1450
+ taskIdByToolUse: this.#taskIdByToolUse.size,
1451
+ toolUseByAgentId: this.#toolUseByAgentId.size,
1452
+ typeByAgentId: this.#typeByAgentId.size,
1453
+ dispatchedFor: this.#dispatchedFor.size,
1454
+ busListeners: this.#eventEmitter.eventNames()
1455
+ .reduce((n, e) => n + this.#eventEmitter.listenerCount(e), 0),
1456
+ };
1457
+ }
1440
1458
  /**
1441
1459
  * Check if checkpoints are available
1442
1460
  */
package/dist/index.js CHANGED
@@ -2351,6 +2351,26 @@ async function main() {
2351
2351
  warmStats.reattachHits++;
2352
2352
  return llm;
2353
2353
  };
2354
+ // ── MEM PROBE (leak hunt, 0.9.262) ──
2355
+ // The heap-OOM crashes (11x since 2026-10-02) exceed what the known small
2356
+ // leaks can retain — something holds LARGE message content in the main heap.
2357
+ // Every 2 min, log heapUsed alongside the size of every suspect structure;
2358
+ // over one heavy session, whichever counter climbs in lockstep with heapUsed
2359
+ // is the retainer. heapUsed is the series that matters for the V8 limit
2360
+ // (external/arrayBuffers — LiveKit audio — do NOT count toward it).
2361
+ setInterval(() => {
2362
+ try {
2363
+ const m = process.memoryUsage();
2364
+ const mb = (b) => Math.round((b || 0) / 1048576);
2365
+ const s = currentLLM?.getMemDebug?.() ?? {};
2366
+ const chatCtxItems = currentAgent?.chatCtx?.items?.length ?? -1;
2367
+ const structs = Object.entries(s).map(([k, v]) => `${k}=${v}`).join(' ');
2368
+ console.log(`🧠 [MEM] heapUsed=${mb(m.heapUsed)}MB heapTotal=${mb(m.heapTotal)}MB rss=${mb(m.rss)}MB ` +
2369
+ `external=${mb(m.external)}MB arrayBuffers=${mb(m.arrayBuffers)}MB ` +
2370
+ `chatCtxItems=${chatCtxItems} slots=${slots.size} warm=${warmLLM ? 1 : 0} ${structs}`);
2371
+ }
2372
+ catch { /* probe must never break the agent */ }
2373
+ }, 120_000).unref();
2354
2374
  // ── 0.9.83: Zombie-presence watchdog + event-loss adopter DELETED ──
2355
2375
  // Both poll-based layers existed solely to compensate for Room-reuse damage:
2356
2376
  // • zombie-watchdog: RoomEvent callbacks stopped firing after a leave/rejoin
@@ -65,6 +65,7 @@ export declare class PipelineDirectLLM extends llm.LLM {
65
65
  setAgents(a: any): void;
66
66
  setTurbo(on: boolean): void;
67
67
  prewarmResume(): void;
68
+ getMemDebug(): Record<string, number>;
68
69
  interruptAgent(): Promise<boolean>;
69
70
  abortAgent(): void;
70
71
  rewindAgent(checkpointId?: string): Promise<boolean>;
@@ -115,6 +115,8 @@ export class PipelineDirectLLM extends llm.LLM {
115
115
  // CLICK-TIME OVERLAP (0.9.258): start the resume replay early so it overlaps
116
116
  // the connect handshake. Proxied to the inner ClaudeLLM.
117
117
  prewarmResume() { this.#claudeLLM.prewarmResume(); }
118
+ // MEM probe (leak hunt, 0.9.262) — proxied to the inner ClaudeLLM.
119
+ getMemDebug() { return this.#claudeLLM.getMemDebug(); }
118
120
  // Agent control — proxied to ClaudeLLM for fast brain access
119
121
  async interruptAgent() { return this.#claudeLLM.interruptQuery(); }
120
122
  abortAgent() { this.#claudeLLM.abortQuery(); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.260",
3
+ "version": "0.9.262",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {