@volter/supercode-teams 0.3.111 → 0.3.112

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/relay.mjs +26 -8
  2. package/package.json +1 -1
package/mail/relay.mjs CHANGED
@@ -31,6 +31,9 @@ const TURN_END_MS = 15_000;
31
31
  * runtime's process group itself, so a relay stuck in a turn is closed through serve, never left running. */
32
32
  const CLOSE_MS = 35_000;
33
33
 
34
+ /** How long a started relay's receipt is waited for, in the map (its watch) or through serve (terminal instructions). */
35
+ const RECEIPT_WAIT_MS = 15_000;
36
+
34
37
  /**
35
38
  * Whether harness serve's error for a relay's input leaves its outcome unknown: no answer (its bound passed, serve ended
36
39
  * mid-call) or serve's own deadline on the runtime ("gave up after", harness_service.rs `within_control_deadline`).
@@ -280,10 +283,18 @@ export class Relays {
280
283
  }
281
284
  // why it is not reused, said in the timing line: a relay that should have been warm and was not shows here
282
285
  step(`runtime not reused (${stale ? 'it held a stale turn' : !runtime ? 'no live receipt' : !alive(this.#pid(spec, runtime)) ? 'its process ended' : !record.connection ? 'no connection' : 'endpoint moved'})`);
283
- // closed through the owner's door even after its receipt went
284
- try { await this.serve('harness.v1.runtimes.close', { connection: record.connection, runtime_id: record.runtime_id }, CLOSE_MS); }
285
- catch (error) { if (this.runtimeOf('claude-code', record.runtime_id)) throw new Error(`could not retire the old relay: ${error.message}`); }
286
- step('old runtime closed (runtimes.close)');
286
+ // closed through the owner's door even after its receipt went. One whose receipt is gone (it ended) is only
287
+ // serve's record of it: let go without holding this send (yuerans, 2026-10-06: 2.3-18 s of every send under
288
+ // load); one still held is closed before its successor starts, as before
289
+ const close = this.serve('harness.v1.runtimes.close', { connection: record.connection, runtime_id: record.runtime_id }, CLOSE_MS);
290
+ if (runtime) {
291
+ try { await close; }
292
+ catch (error) { if (this.runtimeOf('claude-code', record.runtime_id)) throw new Error(`could not retire the old relay: ${error.message}`); }
293
+ step('old runtime closed (runtimes.close)');
294
+ } else {
295
+ close.catch(() => {});
296
+ step('old runtime let go (runtimes.close, not waited on)');
297
+ }
287
298
  }
288
299
  const key = spec.directory.split(/[\\/]/).pop();
289
300
  const started = await this.#start(spec, {
@@ -308,12 +319,19 @@ export class Relays {
308
319
  // one it does not hold yet is read by its own name (the receipt the runtime's terminal launch opens), never waited on
309
320
  const known = this.runtimeOf('claude-code', runtimeId);
310
321
  if (known) { step('its receipt held'); return { runtime: known, connection }; }
322
+ // its receipt, from whichever answers first: the map's watch (it learns the receipt file serve wrote before it
323
+ // answered the start, about a second later), or serve naming it (terminal instructions), each for at most
324
+ // RECEIPT_WAIT_MS. Serve alone, bounded at 5 s, refused every start on a loaded machine (yuerans, 2026-10-06:
325
+ // "the relay started but registered no live runtime").
311
326
  let receiptId = null;
312
- try {
313
- const launch = (await this.serve('harness.v1.runtimes.terminal_instructions', { connection }, 5000))?.launch;
327
+ this.serve('harness.v1.runtimes.terminal_instructions', { connection }, RECEIPT_WAIT_MS).then((answer) => {
328
+ const launch = answer?.launch;
314
329
  receiptId = (Array.isArray(launch?.arguments) ? launch.arguments : []).find((arg) => typeof arg === 'string' && arg.startsWith('supercode-live://'))?.slice('supercode-live://'.length) ?? null;
315
- } catch { /* said below */ }
316
- const runtime = receiptId ? this.runtimeNamed(receiptId) : null;
330
+ }, () => { /* the map's watch still may */ });
331
+ let runtime = null;
332
+ for (const until = Date.now() + RECEIPT_WAIT_MS; !runtime && Date.now() < until; await new Promise((resolve) => setTimeout(resolve, 100))) {
333
+ runtime = this.runtimeOf('claude-code', runtimeId) ?? (receiptId ? this.runtimeNamed(receiptId) : null);
334
+ }
317
335
  step('its receipt read');
318
336
  if (!runtime) {
319
337
  // a runtime no send can use is closed, never left running untracked
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.111",
3
+ "version": "0.3.112",
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",