@volter/supercode-teams 0.3.129 → 0.3.130

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/mail/relay.mjs CHANGED
@@ -373,8 +373,8 @@ export class Relays {
373
373
  */
374
374
  /** Whether `sender`'s relay still holds a send queued (its queue file, written within SEND_TIMEOUT_MS twice over): a
375
375
  * relay runtime outlives a daemon that ended mid-send and may still make it. */
376
- sending(sender) {
377
- try { return Date.now() - statSync(this.spec(sender).queue).mtimeMs < 2 * SEND_TIMEOUT_MS; } catch { return false; }
376
+ sending(sender, senderName) {
377
+ try { return Date.now() - statSync(this.spec(sender, senderName).queue).mtimeMs < 2 * SEND_TIMEOUT_MS; } catch { return false; }
378
378
  }
379
379
 
380
380
  /** Whether message `messageId` from `sender` landed in Claude session `sessionId`'s transcript, as a relay send reads
package/mail/send.mjs CHANGED
@@ -330,13 +330,29 @@ export class MailSend {
330
330
  // at its first tool call finds it, and a daemon that ends before the relay answers (an upgrade's restart, a crash)
331
331
  // leaves it for the carrier, which hands it over again (t_b0f9a2a0: filed read before, such a send was lost). It is
332
332
  // read once the relay has made it; a relay that fails takes back the copy this delivery filed
333
+ // never beside another hand-over of the same message: one running here, one a relay that outlived its daemon may
334
+ // still be making, or one an earlier daemon made that landed (every path: a wake's handOver, an agent's re-plan)
335
+ const key = `${to}\n${handed.id}`;
336
+ const unanswered = (detail) => Object.assign(new Error(detail), { unanswered: true });
337
+ if (this.relaying.has(key)) throw unanswered('its relay send is still running here');
338
+ const earlier = this.store.hasWake(to, handed.id) ? this.store.wakeState(to, handed.id).handover_at_ms : null;
339
+ if (earlier != null) {
340
+ if (this.relays.sending?.(handed.from, handed.from_name)) throw unanswered('its relay may still be making it');
341
+ let landed = false;
342
+ try { landed = await this.relays.landed(door.session.address.split(':').slice(3).join(':'), handed.id, handed.from); } catch { /* unread: hand it over */ }
343
+ if (landed) {
344
+ try { this.store.claimFor(to, handed.id, { pid: process.pid, via: 'door', caller: null, recipient: true, at_ms: Date.now() }); } catch { /* best kept */ }
345
+ const now = this.store.findIn(to, handed.id);
346
+ if (now?.state === 'unread') { try { this.store.markRead(to, now.path); } catch { /* moved meanwhile */ } }
347
+ return 'already';
348
+ }
349
+ }
333
350
  const filedHere = this.store.findIn(to, handed.id) == null;
334
351
  const filed = this.store.deliver(to, handed);
335
352
  if (wake && !this.store.hasWake(to, handed.id)) {
336
353
  // its hand-over begins now: a daemon that restarts reads the receiver's transcript before sending it again
337
354
  try { this.store.requestWake(to, handed.id); this.store.setWakeState(to, handed.id, { attempts: 0, next_at_ms: Date.now() + RELAY_GRACE_MS, handover_at_ms: Date.now() }); } catch { /* the relay's own outcome stands */ }
338
355
  }
339
- const key = `${to}\n${handed.id}`;
340
356
  this.relaying.add(key);
341
357
  let relayed;
342
358
  try { relayed = await this.relays.send(handed.from, handed.from_name, { sessionId: door.session.address.split(':').slice(3).join(':'), name: door.session.name.split('@')[0], socket: door.session.socket }, text, handed.id); }
@@ -783,19 +799,6 @@ export class MailSend {
783
799
  // tried again after its backoff, settled by that hand-over's own outcome
784
800
  const key = `${address}\n${id}`;
785
801
  if (this.handing.has(key) || this.relaying.has(key)) return { outcome: 'later', detail: 'its hand-over is still in progress' };
786
- // an earlier hand-over never settled (the daemon ended mid-way): one its receiver's transcript holds landed, and is
787
- // read; any other is handed over again, never given up (t_b0f9a2a0)
788
- if (state.handover_at_ms != null && door.kind === 'native') {
789
- // a relay that outlived its daemon may still be making that send (its queue still there, fresh): waited for, never
790
- // sent beside it (#1264 review P2a)
791
- if (this.relays.sending?.(sent.from, id)) return { outcome: 'later', detail: 'its relay may still be making it' };
792
- let landed = false;
793
- try { landed = await this.relays.landed(door.session.address.split(':').slice(3).join(':'), id, sent.from); } catch { /* unread: hand it over */ }
794
- if (landed) {
795
- try { this.store.claimFor(address, id, { pid: process.pid, via: 'door', caller: null, recipient: true, at_ms: Date.now() }); this.store.markRead(address, found.path); } catch { /* moved meanwhile */ }
796
- return { outcome: 'filed', detail: 'an earlier hand-over landed' };
797
- }
798
- }
799
802
  this.store.setWakeState(address, id, { ...state, handover_at_ms: Date.now() });
800
803
  this.handing.add(key);
801
804
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.129",
3
+ "version": "0.3.130",
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",