osborn 0.9.67 → 0.9.68
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 +36 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2703,7 +2703,16 @@ async function main() {
|
|
|
2703
2703
|
// Room Event Handlers
|
|
2704
2704
|
// ============================================================
|
|
2705
2705
|
room.on(RoomEvent.Connected, () => {
|
|
2706
|
-
|
|
2706
|
+
// 0.9.68: log Room SID + name PROMINENTLY so we can cross-reference
|
|
2707
|
+
// this specific session in LiveKit Cloud dashboard → Sessions tab.
|
|
2708
|
+
// @livekit/rtc-node Room exposes SID via async getSid() (it's resolved
|
|
2709
|
+
// after WebRTC handshake), so we fetch it asynchronously and log when ready.
|
|
2710
|
+
console.log(`✅ Connected to room: ${roomName} | t=${new Date().toISOString()}`);
|
|
2711
|
+
room.getSid().then((sid) => {
|
|
2712
|
+
console.log(`🔗 [LIVEKIT-DASHBOARD] room sid=${sid} name=${roomName} — search at https://cloud.livekit.io/projects → Sessions → "${sid}"`);
|
|
2713
|
+
}).catch((err) => {
|
|
2714
|
+
console.log(`⚠️ [LIVEKIT-DASHBOARD] failed to fetch room SID: ${err instanceof Error ? err.message : String(err)}`);
|
|
2715
|
+
});
|
|
2707
2716
|
localParticipant = room.localParticipant;
|
|
2708
2717
|
// Arm the alone timer: if we connected but no user joins within the grace
|
|
2709
2718
|
// window (e.g. machine woken then abandoned mid-handshake), leave the room
|
|
@@ -3183,9 +3192,26 @@ async function main() {
|
|
|
3183
3192
|
sendAgentTranscript(message, 'playout');
|
|
3184
3193
|
}
|
|
3185
3194
|
});
|
|
3195
|
+
// 0.9.68: mirror SDK's internal unrecoverable-error counters so we can
|
|
3196
|
+
// see EXACTLY how close we are to closeImpl() firing (default threshold 3).
|
|
3197
|
+
// Counter resets on each successful "speaking" transition (agent_session.js:740).
|
|
3198
|
+
let __ttsErrorCounter = 0;
|
|
3199
|
+
let __llmErrorCounter = 0;
|
|
3200
|
+
const __maxUnrecov = 3; // SDK default DEFAULT_SESSION_CONNECT_OPTIONS.maxUnrecoverableErrors
|
|
3186
3201
|
// Error handler
|
|
3187
3202
|
sess.on('error', (ev) => {
|
|
3188
3203
|
const msg = ev.error?.message || String(ev.error);
|
|
3204
|
+
const errType = ev.type || 'unknown';
|
|
3205
|
+
const recoverable = ev.recoverable;
|
|
3206
|
+
// 0.9.68: counter mirror — increment for recoverable:false same as SDK does
|
|
3207
|
+
if (recoverable === false) {
|
|
3208
|
+
if (errType === 'tts_error')
|
|
3209
|
+
__ttsErrorCounter++;
|
|
3210
|
+
else if (errType === 'llm_error')
|
|
3211
|
+
__llmErrorCounter++;
|
|
3212
|
+
}
|
|
3213
|
+
const willCloseNext = (__ttsErrorCounter > __maxUnrecov || __llmErrorCounter > __maxUnrecov);
|
|
3214
|
+
console.log(`📊 [ERROR-COUNTER] type=${errType} recoverable=${recoverable} ttsErrorCount=${__ttsErrorCounter}/${__maxUnrecov} llmErrorCount=${__llmErrorCounter}/${__maxUnrecov} willCloseNext=${willCloseNext} t=${new Date().toISOString()}`);
|
|
3189
3215
|
// OpenAI race: voice queue collided with server-side VAD auto-response
|
|
3190
3216
|
if (msg.includes('conversation_already_has_active_response') || msg.includes('active_response')) {
|
|
3191
3217
|
console.log('⚠️ OpenAI active response collision — queue will retry on next listening state');
|
|
@@ -3198,6 +3224,15 @@ async function main() {
|
|
|
3198
3224
|
}
|
|
3199
3225
|
console.error('❌ Session error:', ev.error);
|
|
3200
3226
|
});
|
|
3227
|
+
// 0.9.68: reset error counter mirror when SDK does (on speaking transition).
|
|
3228
|
+
// Reuses the existing agent_state_changed handler logic — fires AFTER.
|
|
3229
|
+
sess.on('agent_state_changed', (ev) => {
|
|
3230
|
+
if (ev.newState === 'speaking' && (__ttsErrorCounter > 0 || __llmErrorCounter > 0)) {
|
|
3231
|
+
console.log(`📊 [COUNTER-RESET] speaking transition cleared ttsErrorCount=${__ttsErrorCounter}→0 llmErrorCount=${__llmErrorCounter}→0`);
|
|
3232
|
+
__ttsErrorCounter = 0;
|
|
3233
|
+
__llmErrorCounter = 0;
|
|
3234
|
+
}
|
|
3235
|
+
});
|
|
3201
3236
|
// Capture voice mode at session creation — prevents state confusion
|
|
3202
3237
|
// if currentVoiceMode changes between session start and crash recovery
|
|
3203
3238
|
const sessionVoiceMode = currentVoiceMode;
|