@volter/supercode-teams 0.3.196 → 0.3.197

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/mail/send.mjs +16 -14
  2. package/package.json +1 -1
package/mail/send.mjs CHANGED
@@ -427,7 +427,8 @@ export class MailSend {
427
427
  const [code, what] = {
428
428
  steered: [0, 'steered into its running turn'],
429
429
  started: [0, 'it was idle, so the message started a turn'],
430
- native_waits: [EXIT_STORED, 'Stored: its native session is not known to be idle, so the message waits unread until it is idle. Do not resend'],
430
+ native_busy: [0, 'it will read it at its next tool call'],
431
+ native_waits: [EXIT_STORED, 'Stored: its relay could not deliver it and its session is busy, so its pane fallback waits unread until it is idle. Do not resend'],
431
432
  native_idle: [0, 'it was idle, so the message starts its next turn'],
432
433
  hooked: [0, 'queued in its mailbox; terminal delivery waits for native transcript confirmation'],
433
434
  hook_woken: [0, 'it was idle, so its pane was told to read its mailbox; its hook shows it the message in that turn'],
@@ -497,15 +498,8 @@ export class MailSend {
497
498
  if (held?.queued) return 'pane_held';
498
499
  const busy = door.session.status !== 'idle' || door.session.panes_current === false;
499
500
  if (!wake && !busy) throw new Refused('queue');
500
- if (busy) {
501
- attempt?.begin('native-mailbox');
502
- this.store.deliver(to, sent);
503
- this.store.requestWake(to, sent.id, { keep: true });
504
- const state = this.store.wakeState(to, sent.id);
505
- this.store.setWakeState(to, sent.id, { ...state, waiting_for_idle: true, next_at_ms: Date.now() + 300_000 });
506
- if (notifyWhenIdle && !cameThroughLink(sent)) this.store.subscribeIdle(to, { message_id: sent.id, subscriber: sent.from, notice: true, final_reply: false });
507
- return 'native_waits';
508
- }
501
+ // a busy session is handed it at once, as an idle one is: Claude Code's own cross-session message surfaces at the
502
+ // receiver's next tool call (D391). Only the pane fallback below waits for idle, since a busy pane is never typed into
509
503
  // its reply line names the door this session really has: its tools when it runs supercode's MCP server
510
504
  const handed = sent.reply_via?.mode === 'command' && door.session.tools ? { ...sent, reply_via: { mode: 'tool' } } : sent;
511
505
  const text = render(handed);
@@ -555,7 +549,15 @@ export class MailSend {
555
549
  const received = this.store.claimOf(to, handed.id)?.recipient === true;
556
550
  // the relay produced no receipt and cannot send it late (known not made, or not in the receiver's transcript after
557
551
  // its bound, its queue gone): a session with a daemon pane has the same copy typed there instead
558
- if (!relayed.delivered && !received && wake && door.pane && (!relayed.unknown || relayed.landed === false)) {
552
+ if (!relayed.delivered && !received && wake && door.pane && (!relayed.unknown || relayed.landed === false) && busy) {
553
+ // its pane is typed into only once its turn is idle: the copy waits unread, its wake resumed when it goes idle
554
+ // (carrier.mjs), which hands it to the relay again first
555
+ this.log(`relay could not deliver ${shortId(handed.id)} to busy ${to} (${relayed.detail}); its pane fallback waits for idle`);
556
+ try { this.store.requestWake(to, handed.id, { keep: true }); } catch { /* the wake filed above stands */ }
557
+ const state = this.store.wakeState(to, handed.id);
558
+ this.store.setWakeState(to, handed.id, { ...state, waiting_for_idle: true, next_at_ms: Date.now() + 300_000 });
559
+ delivered = 'native_waits';
560
+ } else if (!relayed.delivered && !received && wake && door.pane && (!relayed.unknown || relayed.landed === false)) {
559
561
  this.log(`relay could not deliver ${shortId(handed.id)} to ${to} (${relayed.detail}); typing it into its pane ${door.pane}`);
560
562
  this.relaying.add(key);
561
563
  try { delivered = await this.#typeIntoPane(handed, to, door.pane, wake, attempt); }
@@ -573,7 +575,7 @@ export class MailSend {
573
575
  const now = this.store.findIn(to, handed.id);
574
576
  if (now?.state === 'unread') { try { this.store.markRead(to, now.path); } catch { /* moved meanwhile */ } }
575
577
  }
576
- delivered = 'native_idle';
578
+ delivered = busy ? 'native_busy' : 'native_idle';
577
579
  }
578
580
  } else if (door.kind === 'hook') {
579
581
  attempt?.begin('hook-mailbox');
@@ -745,7 +747,7 @@ export class MailSend {
745
747
  if (error instanceof Refused) throw new Error(`${error.bytes} bytes; the limit is ${MAX_RELAYED_BYTES}`);
746
748
  throw error;
747
749
  }
748
- return { how, text: { steered: 'steered into its running turn', started: 'started a turn', native_waits: 'waits unread until its native turn is idle', native_idle: 'starts its next turn', hooked: 'in its mailbox, its hook shows it', queued: 'waits in its mailbox', operator: 'filed', already: 'it already had it', stored: 'stored; it has no delivery door', typed: 'typed into its pane', pane_held: 'held for its pane until its composer is free', pane_waits: 'waits in its mailbox (its composer was not empty)' }[how] };
750
+ return { how, text: { steered: 'steered into its running turn', started: 'started a turn', native_busy: 'read at its next tool call', native_waits: 'waits unread until its native turn is idle', native_idle: 'starts its next turn', hooked: 'in its mailbox, its hook shows it', queued: 'waits in its mailbox', operator: 'filed', already: 'it already had it', stored: 'stored; it has no delivery door', typed: 'typed into its pane', pane_held: 'held for its pane until its composer is free', pane_waits: 'waits in its mailbox (its composer was not empty)' }[how] };
749
751
  }
750
752
 
751
753
  // ---- a filing --------------------------------------------------------------------------------------------------
@@ -848,7 +850,7 @@ export class MailSend {
848
850
  return {
849
851
  delivered_to_bus: door.kind !== 'stored' && !['pane_waits', 'pane_held', 'native_waits'].includes(how), message_id: sent.id, reply_to: sender,
850
852
  target: { harness, session_id: sessionId, name: door.kind === 'native' ? door.session.name.split('@')[0] : null },
851
- delivery: { door: door.kind, how: { steered: 'steered', started: 'started', native_waits: 'waiting_for_idle', native_idle: 'started', hooked: 'hook', queued: 'queued', stored: 'stored', operator: 'filed', already: 'already', typed: 'typed', pane_held: 'held', pane_waits: 'stored' }[how] },
853
+ delivery: { door: door.kind, how: { steered: 'steered', started: 'started', native_busy: 'next_tool_call', native_waits: 'waiting_for_idle', native_idle: 'started', hooked: 'hook', queued: 'queued', stored: 'stored', operator: 'filed', already: 'already', typed: 'typed', pane_held: 'held', pane_waits: 'stored' }[how] },
852
854
  };
853
855
  }
854
856
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.196",
3
+ "version": "0.3.197",
4
4
  "type": "module",
5
5
  "description": "A machine daemon serving this machine's doors, and a local or remote Teams server for shared session discovery, OpenTelemetry ingestion and access to enrolled machines.",
6
6
  "license": "MIT",