@volter/supercode-teams 0.2.63 → 0.2.65

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/bin/teams.mjs CHANGED
@@ -80,7 +80,8 @@ if (workspaceVerb) {
80
80
  process.stderr.write(JSON.stringify({ version: 1, error: { code: error.code ?? 'invalid_request', message: error.message } }) + '\n');
81
81
  process.exitCode = (error.exitCode ?? ({ invalid_request: 2, ambiguous_reference: 2, authentication_required: 3, not_found: 4, forbidden: 4, unsupported: 5, machine_offline: 5, controller_busy: 6, conflict: 6, resync_required: 6, revision_mismatch: 6, idempotency_conflict: 6, batch_gap: 6, capture_conflict: 6, source_paused: 6 }[error.code] ?? 1));
82
82
  });
83
- if (process.platform !== 'win32') process.exit();
83
+ // Exit only once stdout has drained: a pipe takes 64 KB at a time, and exiting sooner cut a large --json answer off.
84
+ if (process.platform !== 'win32') { await new Promise((resolve) => process.stdout.write('', resolve)); process.exit(); }
84
85
  }
85
86
 
86
87
  const home = flags.home ? String(flags.home) : teamsHome();
package/machine.mjs CHANGED
@@ -1129,7 +1129,9 @@ export class TeamsMachine extends MachineCore {
1129
1129
  contextKey,
1130
1130
  cwd: params.cwd,
1131
1131
  env: this.#paneEnv(contextKey, params.env),
1132
- name: params.name ?? contextKey,
1132
+ // The pane's own tmux session is always its key: the exit hooks record and clean up p_* sessions only, and
1133
+ // a pane named otherwise lingered dead with its exit status lost. A launch's name is its title.
1134
+ name: contextKey,
1133
1135
  });
1134
1136
  } catch (error) {
1135
1137
  this.launches.record({ key, pane: contextKey, kind: params.kind ?? null, status: 'failed', error: error.message });
@@ -1138,6 +1140,12 @@ export class TeamsMachine extends MachineCore {
1138
1140
  }
1139
1141
  this.launches.record({ key, pane: contextKey, kind: params.kind ?? null, status: 'ready' });
1140
1142
  act('launch', `pane:${contextKey}`, 'ok', params.kind ?? params.program);
1143
+ if (typeof params.name === 'string' && params.name.trim()) {
1144
+ const titles = readJson(this.p.titles, { v: 1, titles: {} });
1145
+ titles.titles[`pane:${contextKey}`] = params.name.trim();
1146
+ writeJson(this.p.titles, titles);
1147
+ await this.#renameWindow(contextKey, params.name.trim()).catch(() => null);
1148
+ }
1141
1149
  // The first input is delivered when the pane can TAKE it, not when the
1142
1150
  // pane exists: a program that is still painting its banner has no
1143
1151
  // input box yet, and text sent into one lands half in the scrollback and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/supercode-teams",
3
- "version": "0.2.63",
3
+ "version": "0.2.65",
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",
package/worker/index.mjs CHANGED
@@ -120,7 +120,12 @@ export class TeamsServer extends DurableObject {
120
120
  await this.ready;
121
121
  const done = this.api.serverId ? await maintain(this.api).catch(() => null) : null;
122
122
  // The database's size on every full pass, where `wrangler tail` reads it.
123
- if (!done?.backlog) console.log(`maintain: database ${(this.ctx.storage.sql.databaseSize / 1048576).toFixed(1)} MB`);
123
+ if (!done?.backlog) {
124
+ // What grows: free pages (space deletes left for reuse), and each busy table's newest rowid (its insert rate).
125
+ const sql = this.ctx.storage.sql, one = (query) => { try { return [...sql.exec(query)][0] ?? {}; } catch { return {}; } };
126
+ const tables = ['messages', 'capture_parts', 'captures', 'session_versions', 'idempotency', 'journal'].map((name) => `${name}=${one(`SELECT MAX(rowid) m FROM ${name}`).m ?? '-'}`).join(' ');
127
+ console.log(`maintain: database ${(sql.databaseSize / 1048576).toFixed(1)} MB free_pages=${one('PRAGMA freelist_count').freelist_count ?? '-'} ${tables}`);
128
+ }
124
129
  // A backlog (versions or parts left over) is worked again in seconds, not a minute.
125
130
  await this.ctx.storage.setAlarm(Date.now() + (done?.backlog ? 3_000 : MAINTAIN_MS));
126
131
  }