osborn 0.9.259 → 0.9.261
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 +14 -2
- package/dist/config.js +52 -1
- package/package.json +1 -1
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
|
-
|
|
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,
|
package/dist/config.js
CHANGED
|
@@ -674,6 +674,29 @@ const SESSION_LIST_TTL_MS = 300_000;
|
|
|
674
674
|
export function invalidateSessionListCache() {
|
|
675
675
|
_sessionListCache = null;
|
|
676
676
|
}
|
|
677
|
+
const SESSION_MANIFEST_VERSION = 1;
|
|
678
|
+
function sessionManifestPath() {
|
|
679
|
+
return join(homedir(), '.claude', 'session-manifest.json');
|
|
680
|
+
}
|
|
681
|
+
function loadSessionManifest() {
|
|
682
|
+
try {
|
|
683
|
+
const raw = readFileSync(sessionManifestPath(), 'utf-8');
|
|
684
|
+
const m = JSON.parse(raw);
|
|
685
|
+
if (m && m.v === SESSION_MANIFEST_VERSION && m.entries && typeof m.entries === 'object')
|
|
686
|
+
return m;
|
|
687
|
+
}
|
|
688
|
+
catch { /* missing / corrupt → start fresh */ }
|
|
689
|
+
return { v: SESSION_MANIFEST_VERSION, entries: {} };
|
|
690
|
+
}
|
|
691
|
+
function saveSessionManifest(m) {
|
|
692
|
+
try {
|
|
693
|
+
const p = sessionManifestPath();
|
|
694
|
+
const tmp = `${p}.tmp`;
|
|
695
|
+
writeFileSync(tmp, JSON.stringify(m));
|
|
696
|
+
renameSync(tmp, p); // atomic swap — a reader never sees a half-written file
|
|
697
|
+
}
|
|
698
|
+
catch { /* best-effort — a failed manifest write just means the next cold boot re-reads */ }
|
|
699
|
+
}
|
|
677
700
|
/**
|
|
678
701
|
* Scan ALL Claude Code projects for sessions.
|
|
679
702
|
* Returns lightweight metadata for every main session JSONL across all projects.
|
|
@@ -736,17 +759,45 @@ export async function listAllClaudeSessions(limit = 1000, includeSubagents = fal
|
|
|
736
759
|
// 3. Sort by mtime descending, take top N for detailed reads
|
|
737
760
|
candidates.sort((a, b) => b.mtime.getTime() - a.mtime.getTime());
|
|
738
761
|
const topCandidates = candidates.slice(0, limit);
|
|
739
|
-
// 4. Read metadata in parallel (sequential was ~10ms × N files = seconds at scale)
|
|
762
|
+
// 4. Read metadata in parallel (sequential was ~10ms × N files = seconds at scale).
|
|
763
|
+
// COLD-BOOT FIX: consult the persisted manifest first — a session whose
|
|
764
|
+
// file mtime+size is unchanged since last build is served from the manifest
|
|
765
|
+
// with NO file read. Only changed/new sessions pay the head/tail read. This
|
|
766
|
+
// is what makes the first dashboard build after a machine restart fast.
|
|
740
767
|
const sessions = [];
|
|
768
|
+
const manifest = loadSessionManifest();
|
|
769
|
+
let manifestDirty = false;
|
|
741
770
|
const results = await Promise.all(topCandidates.map(async (c) => {
|
|
771
|
+
const hit = manifest.entries[c.filePath];
|
|
772
|
+
if (hit && hit.mtimeMs === c.mtime.getTime() && hit.size === c.size) {
|
|
773
|
+
// Unchanged since last build — reuse cached preview + cwd, skip the read.
|
|
774
|
+
return { c, preview: { lastMessage: hit.lastMessage, messageCount: hit.messageCount }, cwd: hit.cwd };
|
|
775
|
+
}
|
|
742
776
|
try {
|
|
743
777
|
const [preview, cwd] = await Promise.all([getSessionPreview(c.filePath, c.size), extractCwd(c.filePath)]);
|
|
778
|
+
manifest.entries[c.filePath] = {
|
|
779
|
+
mtimeMs: c.mtime.getTime(), size: c.size,
|
|
780
|
+
lastMessage: preview.lastMessage, messageCount: preview.messageCount, cwd,
|
|
781
|
+
};
|
|
782
|
+
manifestDirty = true;
|
|
744
783
|
return { c, preview, cwd };
|
|
745
784
|
}
|
|
746
785
|
catch {
|
|
747
786
|
return null;
|
|
748
787
|
}
|
|
749
788
|
}));
|
|
789
|
+
// Prune manifest entries for files that no longer exist on disk (deleted
|
|
790
|
+
// sessions), keyed off the full candidate set so the manifest can't grow
|
|
791
|
+
// unbounded or resurrect stale rows.
|
|
792
|
+
const liveKeys = new Set(candidates.map(c => c.filePath));
|
|
793
|
+
for (const key of Object.keys(manifest.entries)) {
|
|
794
|
+
if (!liveKeys.has(key)) {
|
|
795
|
+
delete manifest.entries[key];
|
|
796
|
+
manifestDirty = true;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
if (manifestDirty)
|
|
800
|
+
saveSessionManifest(manifest);
|
|
750
801
|
for (const r of results) {
|
|
751
802
|
if (!r)
|
|
752
803
|
continue;
|