@volter/supercode-teams 0.3.127 → 0.3.128

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/machine.mjs CHANGED
@@ -1845,10 +1845,24 @@ export class TeamsMachine extends MachineCore {
1845
1845
  /** Whether the machine's stable supercode serves `command` in TypeScript (its front door's own list), asked once: a dev
1846
1846
  * or cargo build's native, run with no front door, serves no hook verb. */
1847
1847
  #frontDoorServes(command) {
1848
+ // asked once, kept while it answered; an ask that found nothing is asked again a minute on, never kept for the
1849
+ // daemon's life (one slow or failed start of the front door refused every relay send until a restart)
1850
+ if (this.frontDoorServed !== undefined && !this.frontDoorServed.size && Date.now() - (this.frontDoorAskedAt ?? 0) > 60_000) this.frontDoorServed = undefined;
1848
1851
  if (this.frontDoorServed === undefined) {
1849
1852
  this.frontDoorServed = new Set();
1853
+ this.frontDoorAskedAt = Date.now();
1850
1854
  try {
1851
- const answer = spawnSync(this.#stableSupercode(), ['front-door', '--json'], { env: this.env, encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'] });
1855
+ const stable = this.#stableSupercode();
1856
+ // On Windows the stable supercode is a `.cmd` shim, which Node starts only through a shell (EINVAL otherwise,
1857
+ // since Node 20.12): asked plainly it answered nothing, so every relay was refused as "no front door here" and
1858
+ // no mail reached a Claude session on the machine. The shim is supercode's own one line (claude_relay.rs:
1859
+ // `@"<node>" "<front door>" %*`), so what it runs is run directly: no shell, nothing of its path read by one
1860
+ // (#1270 review: cmd.exe /s cut a home path with a space at the space). A shim of another form goes through
1861
+ // cmd.exe, the whole line in an outer pair of quotes, so /s takes off only those.
1862
+ const direct = /\.(cmd|bat)$/i.test(stable) ? shimTarget(stable) : [stable];
1863
+ const answer = direct
1864
+ ? spawnSync(direct[0], [...direct.slice(1), 'front-door', '--json'], { env: this.env, encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true })
1865
+ : spawnSync(this.env.ComSpec || process.env.ComSpec || 'cmd.exe', ['/d', '/s', '/c', `""${stable}" front-door --json"`], { env: this.env, encoding: 'utf8', timeout: 5000, stdio: ['ignore', 'pipe', 'ignore'], windowsHide: true, windowsVerbatimArguments: true });
1852
1866
  if (answer.status === 0) for (const row of JSON.parse(answer.stdout).typescript ?? []) this.frontDoorServed.add(row.command);
1853
1867
  } catch { /* none served */ }
1854
1868
  }
@@ -1864,6 +1878,14 @@ export class TeamsMachine extends MachineCore {
1864
1878
  const path = answer.status === 0 ? answer.stdout.trim() : '';
1865
1879
  if (path && isAbsolute(path) && existsSync(path)) this.stableSupercodePath = path;
1866
1880
  } catch { /* this daemon's own supercode */ }
1881
+ // On Windows the daemon runs this release's per-version copy (service\bin\<version>, so an upgrade can replace the
1882
+ // npm one), and `__stable-program` refuses it as not the machine's own supercode: the daemon fell back to that
1883
+ // native, which serves no front door, so every relay was refused and no mail reached a Claude session here. The
1884
+ // shim the machine's own supercode keeps in <SUPERCODE_HOME>\bin is the machine's stable supercode.
1885
+ if (this.stableSupercodePath === null && process.platform === 'win32') {
1886
+ const shim = join(supercodeHome(this.env), 'bin', 'supercode.cmd');
1887
+ if (existsSync(shim)) this.stableSupercodePath = shim;
1888
+ }
1867
1889
  return this.stableSupercodePath ?? this.supercodeBin;
1868
1890
  }
1869
1891
 
@@ -4329,3 +4351,13 @@ function healthEntry(env) {
4329
4351
  const sibling = fileURLToPath(new URL('../health/bin/health.mjs', import.meta.url));
4330
4352
  return existsSync(sibling) ? sibling : null;
4331
4353
  }
4354
+
4355
+ /** What supercode's Windows shim runs, from its one line (`@"<node>" "<front door>" %*`, or `@"<native>" %*`;
4356
+ * claude_relay.rs writes it): `[program, ...args]`, or null for a shim of another form. */
4357
+ function shimTarget(path) {
4358
+ let text;
4359
+ try { text = readFileSync(path, 'utf8'); } catch { return null; }
4360
+ const line = text.split(/\r?\n/).map((row) => row.trim()).find((row) => row.startsWith('@"'));
4361
+ const m = line ? /^@"([^"]+)"(?: "([^"]+)")? %\*$/.exec(line) : null;
4362
+ return m ? [m[1], ...(m[2] ? [m[2]] : [])] : null;
4363
+ }
package/mail/relay.mjs CHANGED
@@ -270,7 +270,7 @@ export class Relays {
270
270
  async #ensure(spec, step = () => {}, { stale = false } = {}) {
271
271
  // a relay's hooks are the front door's verbs (mail step 1b): a stable supercode with no front door (a dev or cargo
272
272
  // build's native) would answer none of them, and every mail the relay is handed would be blocked unfiled
273
- if (!this.hooksServed()) throw new Error('relays run their hooks through the machine\'s stable supercode, which has no front door here (a dev or cargo build); install supercode from npm to send to Claude sessions by relay');
273
+ if (!this.hooksServed()) throw new Error('relays run their hooks through the machine\'s stable supercode, and none here serves them (no stable supercode was found, or it is a dev or cargo build); install supercode from npm to send to Claude sessions by relay');
274
274
  const endpoint = await this.endpoint();
275
275
  step('relay endpoint');
276
276
  if (!endpoint) throw new Error('the relay endpoint is not served by this machine\'s daemon (its log says why); a Claude session can be sent mail once the daemon starts again');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.3.127",
3
+ "version": "0.3.128",
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",