osborn 0.9.258 → 0.9.260
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/config.js +52 -1
- package/dist/index.js +62 -0
- package/package.json +1 -1
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;
|
package/dist/index.js
CHANGED
|
@@ -2202,6 +2202,39 @@ async function main() {
|
|
|
2202
2202
|
// message. Reuses the SAME subprocess that turn would spawn, so it only moves
|
|
2203
2203
|
// the cost earlier — no extra subprocess, no billing delta.
|
|
2204
2204
|
const CONNECT_OVERLAP = process.env.OSBORN_CONNECT_OVERLAP !== 'off';
|
|
2205
|
+
// ── CONNECT TIMING (0.9.259): physically measure every stage from the
|
|
2206
|
+
// dashboard button click → first REAL agent answer (excluding the hardcoded
|
|
2207
|
+
// "Welcome back" greeting). The frontend stamps the click (clickTs) and
|
|
2208
|
+
// forwards it in participant metadata; the agent stamps each server-side stage
|
|
2209
|
+
// and prints a single breakdown so we can see exactly what eats the seconds.
|
|
2210
|
+
// One live line per mark + a summary table at the first real answer.
|
|
2211
|
+
let connectTiming = null;
|
|
2212
|
+
const ctReset = () => {
|
|
2213
|
+
connectTiming = { clickTs: null, connectRoomTs: Date.now(), marks: [], sawUserMsg: false, answered: false };
|
|
2214
|
+
};
|
|
2215
|
+
const ctMark = (label) => {
|
|
2216
|
+
if (!connectTiming)
|
|
2217
|
+
return;
|
|
2218
|
+
const ts = Date.now();
|
|
2219
|
+
connectTiming.marks.push({ label, ts });
|
|
2220
|
+
const prev = connectTiming.marks.length > 1 ? connectTiming.marks[connectTiming.marks.length - 2].ts : connectTiming.connectRoomTs;
|
|
2221
|
+
const base = connectTiming.clickTs || connectTiming.connectRoomTs;
|
|
2222
|
+
console.log(`⏱️ [CT] ${label} +${ts - base}ms from ${connectTiming.clickTs ? 'CLICK' : 'connect-room'} (Δ${ts - prev}ms prev) [${new Date(ts).toISOString()}]`);
|
|
2223
|
+
};
|
|
2224
|
+
const ctSummary = () => {
|
|
2225
|
+
if (!connectTiming)
|
|
2226
|
+
return;
|
|
2227
|
+
const base = connectTiming.clickTs || connectTiming.connectRoomTs;
|
|
2228
|
+
const lines = connectTiming.marks.map((m, i) => {
|
|
2229
|
+
const prev = i > 0 ? connectTiming.marks[i - 1].ts : base;
|
|
2230
|
+
return ` ${String(m.ts - base).padStart(6)}ms (Δ${m.ts - prev}ms) ${m.label}`;
|
|
2231
|
+
});
|
|
2232
|
+
const total = connectTiming.marks.length ? connectTiming.marks[connectTiming.marks.length - 1].ts - base : 0;
|
|
2233
|
+
console.log(`\n⏱️ ═══ CONNECT TIMING BREAKDOWN ═══\n` +
|
|
2234
|
+
` base = ${connectTiming.clickTs ? 'dashboard CLICK' : 'server connect-room (no clickTs from frontend)'} @ ${new Date(base).toISOString()}\n` +
|
|
2235
|
+
lines.join('\n') +
|
|
2236
|
+
`\n ──────────────────────────────\n TOTAL click→first-real-answer: ${total}ms (${(total / 1000).toFixed(1)}s)\n⏱️ ═══════════════════════════════\n`);
|
|
2237
|
+
};
|
|
2205
2238
|
const REATTACH_GRACE_MS = Number(process.env.OSBORN_REATTACH_GRACE_MS || 150_000); // 2.5 min reconnect window (user: 2–3 min)
|
|
2206
2239
|
const WARM_HARD_CEILING_MS = Number(process.env.OSBORN_WARM_CEILING_MS || 420_000); // 7 min absolute backstop
|
|
2207
2240
|
let warmLLM = null;
|
|
@@ -3806,6 +3839,14 @@ async function main() {
|
|
|
3806
3839
|
appendSuppressedText(data.text);
|
|
3807
3840
|
return;
|
|
3808
3841
|
}
|
|
3842
|
+
// CONNECT TIMING: the FIRST real spoken answer (a tts_say from Claude —
|
|
3843
|
+
// NOT the hardcoded "Welcome back", which is a direct session.say). Gated
|
|
3844
|
+
// on having seen the user's first message so it can only be a response.
|
|
3845
|
+
if (connectTiming && !connectTiming.answered && connectTiming.sawUserMsg) {
|
|
3846
|
+
connectTiming.answered = true;
|
|
3847
|
+
ctMark('FIRST REAL ANSWER spoken');
|
|
3848
|
+
ctSummary();
|
|
3849
|
+
}
|
|
3809
3850
|
const sayId = Date.now(); // simple ID to correlate start/end logs
|
|
3810
3851
|
console.log(`🗣️ [${sayId}] session.say START (${data.text.length} chars): "${data.text}"`);
|
|
3811
3852
|
// Apply agent-requested speed (e.g. [SPEED:0.85] stripped from response text)
|
|
@@ -4370,6 +4411,14 @@ async function main() {
|
|
|
4370
4411
|
preSelectedSessionId = metadata.sessionId;
|
|
4371
4412
|
console.log(`📂 Pre-selected session from frontend: ${preSelectedSessionId}`);
|
|
4372
4413
|
}
|
|
4414
|
+
// CONNECT TIMING: adopt the dashboard button-click timestamp so the agent
|
|
4415
|
+
// can report the TRUE end-to-end (click→first-answer) in one place, with no
|
|
4416
|
+
// cross-log clock-skew. Falls back to the server connect-room time if absent.
|
|
4417
|
+
if (connectTiming && metadata.clickTs) {
|
|
4418
|
+
const c = Number(metadata.clickTs);
|
|
4419
|
+
if (Number.isFinite(c) && c > 0)
|
|
4420
|
+
connectTiming.clickTs = c;
|
|
4421
|
+
}
|
|
4373
4422
|
// Read working directory override from frontend.
|
|
4374
4423
|
//
|
|
4375
4424
|
// If the path doesn't exist yet (new project on first use, or freshly
|
|
@@ -4394,6 +4443,7 @@ async function main() {
|
|
|
4394
4443
|
catch (err) {
|
|
4395
4444
|
console.log('⚠️ Could not parse participant metadata, using config voiceMode:', voiceMode);
|
|
4396
4445
|
}
|
|
4446
|
+
ctMark('participant joined + metadata parsed');
|
|
4397
4447
|
// Sync to outer scope so DataReceived handler can use it
|
|
4398
4448
|
currentVoiceMode = sessionVoiceMode;
|
|
4399
4449
|
// Resume session ID — only set when resuming an existing session
|
|
@@ -4515,11 +4565,15 @@ async function main() {
|
|
|
4515
4565
|
if (CONNECT_OVERLAP && resumeSessionId && !reattached) {
|
|
4516
4566
|
try {
|
|
4517
4567
|
currentLLM?.prewarmResume?.();
|
|
4568
|
+
ctMark('resume replay primed (overlap)');
|
|
4518
4569
|
}
|
|
4519
4570
|
catch (e) {
|
|
4520
4571
|
console.error('⚠️ prewarmResume failed (non-fatal):', e instanceof Error ? e.message : e);
|
|
4521
4572
|
}
|
|
4522
4573
|
}
|
|
4574
|
+
else if (reattached) {
|
|
4575
|
+
ctMark('re-attached warm brain (zero replay)');
|
|
4576
|
+
}
|
|
4523
4577
|
// ============================================================
|
|
4524
4578
|
// Session event wiring — extracted into function for auto-recovery
|
|
4525
4579
|
// ============================================================
|
|
@@ -4544,6 +4598,10 @@ async function main() {
|
|
|
4544
4598
|
console.log(`📝 User (${source}, ${transcript.length} chars): "${transcript}"`);
|
|
4545
4599
|
sendToFrontend({ type: 'user_transcript', text: transcript });
|
|
4546
4600
|
lastSentUserTranscript = normalized;
|
|
4601
|
+
if (connectTiming && !connectTiming.sawUserMsg) {
|
|
4602
|
+
connectTiming.sawUserMsg = true;
|
|
4603
|
+
ctMark('first user message received (STT final)');
|
|
4604
|
+
}
|
|
4547
4605
|
}
|
|
4548
4606
|
function sendAgentTranscript(text, source) {
|
|
4549
4607
|
if (!text || text.length < 3)
|
|
@@ -6527,6 +6585,10 @@ async function main() {
|
|
|
6527
6585
|
connectRoomHook = async () => {
|
|
6528
6586
|
intentionalLeave = false;
|
|
6529
6587
|
cancelIdleExitTimer();
|
|
6588
|
+
// CONNECT TIMING: stamp the server's request-incoming moment (the user asked
|
|
6589
|
+
// to timestamp this explicitly). New attempt → fresh timeline.
|
|
6590
|
+
ctReset();
|
|
6591
|
+
ctMark('connect-room received (server)');
|
|
6530
6592
|
// Idempotency: an active session with a user present is reused (return its
|
|
6531
6593
|
// room name). An active-but-empty session (agent joined, user never showed,
|
|
6532
6594
|
// or a stale race) is torn down and replaced with a fresh one.
|