osborn 0.9.80 → 0.9.81

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 +15 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1237,6 +1237,8 @@ async function main() {
1237
1237
  // Track state
1238
1238
  let pendingSessionClose = null; // Tracks async session close for reconnect safety
1239
1239
  let currentSession = null;
1240
+ // 0.9.81: callable handler reference — see registration site for why.
1241
+ let participantConnectedHandler = null;
1240
1242
  let currentAgent = null; // For updateChatCtx() context injection
1241
1243
  let currentLLM = null;
1242
1244
  // Agent-side "alone in room" leave timer (see Room-presence lifecycle note up
@@ -1384,8 +1386,8 @@ async function main() {
1384
1386
  if (Date.now() - last < 60_000)
1385
1387
  return;
1386
1388
  adoptAttempts.set(p.identity, Date.now());
1387
- console.log(`šŸ“„ [ADOPT-POLL] ${p.identity} present with no session — re-emitting ParticipantConnected`);
1388
- room.emit(RoomEvent.ParticipantConnected, p);
1389
+ console.log(`šŸ“„ [ADOPT-POLL] ${p.identity} present with no session — invoking ParticipantConnected handler directly`);
1390
+ participantConnectedHandler?.(p).catch((e) => console.error('šŸ“„ [ADOPT-POLL] handler error:', e instanceof Error ? e.message : e));
1389
1391
  }
1390
1392
  catch (err) {
1391
1393
  console.error('šŸ“„ [ADOPT-POLL] error:', err instanceof Error ? err.message : err);
@@ -3067,7 +3069,13 @@ async function main() {
3067
3069
  console.error('āŒ Reconnect attempt threw (should not happen — connectWithRetry loops):', err);
3068
3070
  });
3069
3071
  });
3070
- room.on(RoomEvent.ParticipantConnected, async (participant) => {
3072
+ // 0.9.81: handler extracted to a named reference so the adopt-poll and
3073
+ // /connect-room adopt can CALL it directly. Synthetic `room.emit(...)` does
3074
+ // NOT reach listeners on rtc-node's Room (observed 2026-07-28: ADOPT-POLL
3075
+ // re-emitted for three successive participants, zero sessions created) —
3076
+ // the event dispatch is internal, so direct invocation is the only
3077
+ // reliable path for state-driven adoption.
3078
+ participantConnectedHandler = async (participant) => {
3071
3079
  console.log(`\nšŸ‘¤ User joined: ${participant.identity}`);
3072
3080
  // A user is present — cancel any pending agent-side "alone" leave.
3073
3081
  if (aloneTimer) {
@@ -3929,7 +3937,8 @@ async function main() {
3929
3937
  catch (err) {
3930
3938
  console.error('āŒ Failed to start session:', err);
3931
3939
  }
3932
- });
3940
+ };
3941
+ room.on(RoomEvent.ParticipantConnected, (p) => { participantConnectedHandler?.(p); });
3933
3942
  room.on(RoomEvent.ParticipantDisconnected, (participant) => {
3934
3943
  console.log(`šŸ‘‹ User left: ${participant.identity}`);
3935
3944
  // Full cleanup — stop all background work to avoid accumulating API usage
@@ -4810,8 +4819,8 @@ async function main() {
4810
4819
  // Re-emit the event for every pre-existing participant so the session is
4811
4820
  // created exactly as if they had joined after us.
4812
4821
  for (const p of room.remoteParticipants.values()) {
4813
- console.log(`šŸ‘„ Participant already in room at join: ${p.identity} — adopting (re-emitting ParticipantConnected)`);
4814
- room.emit(RoomEvent.ParticipantConnected, p);
4822
+ console.log(`šŸ‘„ Participant already in room at join: ${p.identity} — adopting (invoking handler directly)`);
4823
+ participantConnectedHandler?.(p).catch((e) => console.error('šŸ‘„ adopt handler error:', e instanceof Error ? e.message : e));
4815
4824
  }
4816
4825
  };
4817
4826
  // 0.9.73: explicit frontend leave should also start the idle-exit countdown —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "osborn",
3
- "version": "0.9.80",
3
+ "version": "0.9.81",
4
4
  "description": "Voice AI coding assistant - local agent that connects to Osborn frontend",
5
5
  "type": "module",
6
6
  "bin": {