osborn 0.9.117 → 0.9.119

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.
Files changed (2) hide show
  1. package/dist/index.js +68 -45
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2651,44 +2651,46 @@ async function main() {
2651
2651
  // Wire up TTS say — bypass LiveKit's BufferedTokenStream, speak directly via session.say()
2652
2652
  // Each text block from Claude gets spoken immediately as it arrives, no internal buffering
2653
2653
  directLLM.events.on('tts_say', (data) => {
2654
- // Guard: session must be alive — TTS errors can kill the session while background query runs
2655
- if (!currentSession) {
2656
- console.warn(`⚠️ tts_say fired but currentSession is null — text dropped (${data.text?.length || 0} chars): "${data.text || ''}"`);
2657
- return;
2658
- }
2659
2654
  if (!data.text?.trim()) {
2660
2655
  console.log(`🔇 tts_say fired but text is empty — skipping`);
2661
2656
  return;
2662
2657
  }
2663
- // Suppress browser TTS for meeting-chunk responses — the agent speaks INTO
2664
- // the meeting via /canvas, not the laptop speakers (which the Meet mic
2665
- // re-captures in the same room → feedback). Set by PipelineDirectLLM.chat()
2666
- // when the turn is a [MEETING —] chunk. Normal user turns are unaffected.
2658
+ // MEETING PATH (fix 2026-08-01) — runs BEFORE the currentSession guard.
2659
+ // A meeting reply routes to the meeting via speakIntoMeeting → Recall
2660
+ // output_audio, which needs NO LiveKit voice session. Keeping this ahead
2661
+ // of the guard is what lets the bot keep replying AFTER the browser voice
2662
+ // session dropped (currentLLM is deliberately kept alive for exactly this;
2663
+ // see handleParticipantDisconnected). Before the fix a participant blip
2664
+ // nulled currentSession and EVERY meeting reply was "text dropped" — the
2665
+ // deaf-bot bug proven live 2026-08-01 via synthetic transcript inject.
2666
+ // Set by PipelineDirectLLM.chat() when the turn is a [MEETING —] chunk.
2667
2667
  if (directLLM.suppressMeetingTTS) {
2668
- // MEETING MODE CONDITION (user directive 2026-08-01): says route to
2669
- // the NATIVE Recall sink by default — no room/Chrome relay (that path
2670
- // was moderately-to-extremely choppy). The LiveKit parity relay stays
2671
- // available behind OSBORN_MEETING_AUDIO=parity for future testing.
2672
- if (process.env.OSBORN_MEETING_AUDIO === 'parity' && meetingCanvasInRoom && activeMeetingBotId && Date.now() < meetingAddressedUntil) {
2668
+ // Parity relay (behind OSBORN_MEETING_AUDIO=parity) speaks via
2669
+ // session.say, so it still needs a live session — it falls through to
2670
+ // the normal browser-TTS path below only when currentSession exists.
2671
+ const parity = process.env.OSBORN_MEETING_AUDIO === 'parity' && meetingCanvasInRoom && activeMeetingBotId && Date.now() < meetingAddressedUntil && !!currentSession;
2672
+ if (parity) {
2673
2673
  console.log(`🔊🎼 meeting reply via NATIVE session.say (canvas relays): "${data.text.slice(0, 50)}"`);
2674
2674
  markMeetingSpeaking(data.text);
2675
- // no return — normal say proceeds below
2676
- }
2677
- else
2678
- // ADDRESSED turn → REDIRECT the normal streaming reply into the meeting
2679
- // (reuse of the regular speak path; no Bash roundtrip). Silent-observer
2680
- // turns stay suppressed as before.
2681
- if (activeMeetingBotId && Date.now() < meetingAddressedUntil) {
2682
- // ONE say per reply (2026-08-01 quality directive): chunking created
2683
- // seams no scheduler fully hid. A single utterance = a single clean
2684
- // audio file = zero seams — quality over ~1s of latency. (Structural
2685
- // fix queued: canvas as LiveKit subscriber playing the agent's real
2686
- // TTS track — the true "same browser experience" reuse.)
2675
+ // fall through to normal browser TTS (currentSession present)
2676
+ }
2677
+ else if (activeMeetingBotId && Date.now() < meetingAddressedUntil) {
2678
+ // NATIVE sink: one clean output_audio push into the meeting, NO
2679
+ // LiveKit session required — this is the path that survives a
2680
+ // voice-session drop.
2687
2681
  console.log(`🔊➡️📢 tts_say → meeting (native audio) t=${new Date().toISOString()}: "${data.text.slice(0, 60)}"`);
2688
2682
  void speakIntoMeeting(data.text);
2689
2683
  return;
2690
2684
  }
2691
- console.log(`🔇 tts_say suppressed (meeting turn — response goes to /canvas, not browser): "${data.text.slice(0, 60)}"`);
2685
+ else {
2686
+ console.log(`🔇 tts_say suppressed (meeting turn — response goes to /canvas, not browser): "${data.text.slice(0, 60)}"`);
2687
+ return;
2688
+ }
2689
+ }
2690
+ // NORMAL BROWSER TTS (and the parity fall-through): needs a live session.
2691
+ // TTS errors can kill the session while a background query still runs.
2692
+ if (!currentSession) {
2693
+ console.warn(`⚠️ tts_say fired but currentSession is null — text dropped (${data.text?.length || 0} chars): "${data.text || ''}"`);
2692
2694
  return;
2693
2695
  }
2694
2696
  // Suppress while the user is mid-utterance. Without this, agent text generated
@@ -4149,6 +4151,17 @@ async function main() {
4149
4151
  // Close handler with auto-recovery for crashes (both realtime and direct modes)
4150
4152
  sess.on('close', async (ev) => {
4151
4153
  console.log('🚪 Session closed:', ev.reason);
4154
+ // ORPHAN-BOT GUARD (fix 2026-08-01): an abrupt AgentSession close
4155
+ // (e.g. a driver tab killed → reason 'user_initiated', with NO clean
4156
+ // ParticipantDisconnected) must not leave the Recall bot stuck in-call
4157
+ // draining credits. Arm the meeting leave-grace so endMeeting() fires
4158
+ // (bot leaves + LLM released) once the room is genuinely empty. A rejoin
4159
+ // cancels it; error/disconnected closes still auto-recover below and the
4160
+ // grace is harmless there (recovery + rejoin cancels it).
4161
+ if (activeMeetingBotId) {
4162
+ console.log('📽️ Meeting active on session close — arming leave-grace (bot leaves if no user returns)');
4163
+ armMeetingLeaveGrace();
4164
+ }
4152
4165
  // TTS abort from user interruption — SDK already killed the session internally,
4153
4166
  // so we MUST recover (can't just reset state — STT pipeline is dead).
4154
4167
  // Log it distinctly so we know it's an interrupt recovery, not a real crash.
@@ -4533,24 +4546,34 @@ async function main() {
4533
4546
  })();
4534
4547
  }
4535
4548
  currentAgent = null;
4536
- // Kill the Claude SDK subprocess BEFORE dropping the reference, otherwise the
4537
- // persistent session keeps running tools and pushing TTS into a dead session.
4538
- killCurrentLLM('participant_disconnected');
4539
- currentLLM = null;
4540
- clearFastBrainSession();
4541
- clearPipelineFastBrainSession();
4542
- // Auto-leave any active meeting bot when user disconnects from the room.
4543
- // DELIBERATE COUPLING: the bot's lifecycle follows the voice session — a
4544
- // decoupled always-on meeting bot means untracked background agents (no
4545
- // status surface for them yet). Revisit only WITH a tracking UI.
4546
- // endMeeting() centralizes the teardown (flush, poller, max-timer, Recall
4547
- // leave, frontend notify).
4548
- armMeetingLeaveGrace();
4549
- // 0.9.83: a real session just ended → use the FAST leave (~20s), not the
4550
- // 3-min alone grace. Runs on the agent, so it fires even on an abrupt tab
4551
- // close. Cancelled if a user rejoins within the grace (handled where the
4552
- // participant-join cancels timers).
4553
- armFastLeaveTimer();
4549
+ if (activeMeetingBotId) {
4550
+ // MEETING SURVIVES A VOICE-SESSION DROP (fix 2026-08-01). The bot's brain
4551
+ // is the persistent Claude LLM; killing it on every participant blip left
4552
+ // the Recall bot permanently DEAF mid-call ("Addressed" fired but never
4553
+ // "Flushed" — currentLLM was null; proven via synthetic transcript inject).
4554
+ // Keep currentLLM alive so meeting transcripts still flush + reply
4555
+ // (speakIntoMeeting is Recall-direct, needs no LiveKit session). The
4556
+ // leave-grace below owns teardown: if the user is truly gone at 75s,
4557
+ // endMeeting() releases the LLM (its !userPresent branch). A rejoin cancels
4558
+ // the grace. DO NOT arm the 20s fast-leave here — it would destroy the room
4559
+ // before the meeting grace and orphan the bot; the meeting grace is the
4560
+ // single teardown while a meeting is live.
4561
+ console.log('📽️ Meeting active — keeping currentLLM alive across the voice-session drop (leave-grace owns teardown)');
4562
+ armMeetingLeaveGrace();
4563
+ }
4564
+ else {
4565
+ // Kill the Claude SDK subprocess BEFORE dropping the reference, otherwise the
4566
+ // persistent session keeps running tools and pushing TTS into a dead session.
4567
+ killCurrentLLM('participant_disconnected');
4568
+ currentLLM = null;
4569
+ clearFastBrainSession();
4570
+ clearPipelineFastBrainSession();
4571
+ // Auto-leave path for a NON-meeting session. 0.9.83: a real session just
4572
+ // ended → use the FAST leave (~20s), not the 3-min alone grace. Fires even
4573
+ // on an abrupt tab close; cancelled if a user rejoins within the grace.
4574
+ armMeetingLeaveGrace(); // no-op when no meeting, kept for symmetry
4575
+ armFastLeaveTimer();
4576
+ }
4554
4577
  console.log('⏳ Waiting for new user...\n');
4555
4578
  };
4556
4579
  const handleDataReceived = async (payload, participant, kind, topic) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.117",
3
+ "version": "0.9.119",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {