osborn 0.9.258 → 0.9.259
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 +62 -0
- package/package.json +1 -1
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.
|