@volter/supercode-teams 0.2.82 → 0.2.83

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.82",
3
+ "version": "0.2.83",
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",
@@ -4,10 +4,10 @@
4
4
  // daemon's ConPTY host on Windows, holds it); the pane ending ends the client, and the terminal closes the window as
5
5
  // its command exits. Adapters are tried in rank order; SUPERCODE_POPUP_TERMINAL names one (or `none`).
6
6
  import { spawn, spawnSync } from 'node:child_process';
7
- import { chmodSync, existsSync, readdirSync, writeFileSync } from 'node:fs';
7
+ import { chmodSync, existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
8
8
  import { homedir, tmpdir } from 'node:os';
9
9
  import { join } from 'node:path';
10
- import { randomBytes } from 'node:crypto';
10
+ import { createHash, randomBytes } from 'node:crypto';
11
11
  import { weztermConfigFile } from './terminal-look.mjs';
12
12
 
13
13
  const onPath = (name) => {
@@ -31,11 +31,12 @@ function selfDeletingScript(argv, extension) {
31
31
  // running process is on screen in about 0.3 s, where a process started per window took 0.7 to 2 s (measured on macOS
32
32
  // 26 with WezTerm 20240203). The process is known by its class; it listens on ~/.local/share/wezterm/gui-sock-<pid>.
33
33
  // A window goes into it with `wezterm cli spawn --new-window`, and when there is none, or the spawn fails, the window
34
- // starts it. The fallback runs in the launched shell, so the daemon never waits on WezTerm.
34
+ // starts it. The fallback runs in the launched shell, so the daemon never waits on WezTerm. The class carries the
35
+ // config's content: WezTerm does not reload it (terminal-look.mjs), so a process holding an older look is never reused.
35
36
  const WEZTERM_CLASS = 'dev.volter.supercode';
36
37
 
37
- /** The socket of a running supercode WezTerm process, or null. */
38
- function weztermSocket() {
38
+ /** The socket of a running supercode WezTerm process of class `cls`, or null. */
39
+ function weztermSocket(cls) {
39
40
  const dir = join(homedir(), '.local', 'share', 'wezterm');
40
41
  let names;
41
42
  try { names = readdirSync(dir); } catch { return null; }
@@ -44,15 +45,17 @@ function weztermSocket() {
44
45
  if (!pid) continue;
45
46
  try { process.kill(pid, 0); } catch { continue; }
46
47
  const command = spawnSync('ps', ['-p', String(pid), '-o', 'command='], { encoding: 'utf8', timeout: 2_000 }).stdout ?? '';
47
- if (command.includes(`--class ${WEZTERM_CLASS}`)) return join(dir, name);
48
+ if (command.includes(`--class ${cls} `)) return join(dir, name);
48
49
  }
49
50
  return null;
50
51
  }
51
52
 
52
53
  /** WezTerm's launch: a window in supercode's running WezTerm, else a new one with supercode's look (terminal-look.mjs). */
53
54
  function weztermLaunch(program, argv) {
54
- const start = [program, '--config-file', weztermConfigFile(), 'start', '--always-new-process', '--class', WEZTERM_CLASS, '--', ...argv];
55
- const socket = process.platform === 'win32' ? null : weztermSocket();
55
+ const config = weztermConfigFile();
56
+ const cls = `${WEZTERM_CLASS}.${createHash('sha256').update(readFileSync(config)).digest('hex').slice(0, 12)}`;
57
+ const start = [program, '--config-file', config, 'start', '--always-new-process', '--class', cls, '--', ...argv];
58
+ const socket = process.platform === 'win32' ? null : weztermSocket(cls);
56
59
  if (!socket) return [start[0], start.slice(1)];
57
60
  const quote = (arg) => `'${String(arg).replaceAll("'", `'"'"'`)}'`;
58
61
  const spawnWindow = [program, 'cli', '--no-auto-start', 'spawn', '--new-window', '--', ...argv].map(quote).join(' ');