tmux-ide 2.9.23 → 2.9.24

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 (39) hide show
  1. package/bin/cli.js +285 -36
  2. package/package.json +1 -1
  3. package/packages/daemon/dist/command-center/tmux-servers.js +11 -0
  4. package/packages/daemon/dist/lib/daemon-embed.js +16 -8
  5. package/packages/daemon/dist/lib/home-agent-observer.js +50 -0
  6. package/packages/daemon/dist/lib/machine-agents.js +18 -1
  7. package/packages/daemon/dist/lib/orphaned-control-clients.js +162 -0
  8. package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +32 -9
  9. package/packages/daemon/dist/lib/tmux-server-owner.js +26 -4
  10. package/packages/daemon/dist/lib/workspace-promotion.js +24 -3
  11. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
  12. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
  13. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
  14. package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
  15. package/packages/daemon/dist/terminal/attachments/native-runtime.js +17 -2
  16. package/packages/daemon/dist/terminal/mirror/session-channel.js +2 -1
  17. package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +8 -0
  18. package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +57 -4
  19. package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +18 -7
  20. package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +17 -0
  21. package/packages/daemon/dist/tui/mirror/runtime/application-machine-navigation.js +4 -2
  22. package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +55 -14
  23. package/packages/daemon/src/command-center/tmux-servers.ts +11 -0
  24. package/packages/daemon/src/lib/daemon-embed.ts +52 -7
  25. package/packages/daemon/src/lib/home-agent-observer.ts +53 -0
  26. package/packages/daemon/src/lib/machine-agents.ts +25 -1
  27. package/packages/daemon/src/lib/orphaned-control-clients.ts +215 -0
  28. package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +32 -8
  29. package/packages/daemon/src/lib/tmux-server-owner.ts +28 -3
  30. package/packages/daemon/src/lib/workspace-promotion.ts +26 -3
  31. package/packages/daemon/src/terminal/attachments/native-runtime.ts +21 -2
  32. package/packages/daemon/src/terminal/mirror/session-channel.ts +2 -1
  33. package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +8 -0
  34. package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +69 -4
  35. package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +30 -13
  36. package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +38 -1
  37. package/packages/daemon/src/tui/mirror/runtime/application-machine-navigation.ts +7 -2
  38. package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +4 -4
  39. package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +71 -17
package/bin/cli.js CHANGED
@@ -15290,7 +15290,7 @@ var require_package = __commonJS({
15290
15290
  "package.json"(exports, module) {
15291
15291
  module.exports = {
15292
15292
  name: "tmux-ide",
15293
- version: "2.9.23",
15293
+ version: "2.9.24",
15294
15294
  description: "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
15295
15295
  type: "module",
15296
15296
  bin: {
@@ -30208,10 +30208,13 @@ function processIsAlive(pid) {
30208
30208
  return error.code !== "ESRCH";
30209
30209
  }
30210
30210
  }
30211
- function nextHookHealthcheckDelay(previousMs, outcome, schedule = DEFAULT_HOOK_HEALTHCHECK_SCHEDULE) {
30211
+ function nextHookHealthcheckDelay(previousMs, outcome, schedule = DEFAULT_HOOK_HEALTHCHECK_SCHEDULE, consecutiveUnhealthy = 1) {
30212
30212
  const base2 = Math.max(1, Math.floor(schedule.baseMs));
30213
30213
  const max = Math.max(base2, Math.floor(schedule.maxMs));
30214
- if (outcome !== "healthy") return base2;
30214
+ if (outcome !== "healthy") {
30215
+ const streak = Math.max(1, Math.min(32, Math.floor(consecutiveUnhealthy) || 1));
30216
+ return Math.min(base2 * 2 ** (streak - 1), max);
30217
+ }
30215
30218
  const previous = Number.isFinite(previousMs) ? Math.max(base2, Math.floor(previousMs)) : base2;
30216
30219
  return Math.min(previous * 2, max);
30217
30220
  }
@@ -30398,6 +30401,8 @@ var init_tmux_external_interaction_observer = __esm({
30398
30401
  #healthcheckSchedule;
30399
30402
  #healthcheckDelayMs;
30400
30403
  #lastHealthcheckOutcome = "failed";
30404
+ /** Scheduled checks in a row that did not find the hooks intact. */
30405
+ #unhealthyChecks = 0;
30401
30406
  #onAvailability;
30402
30407
  #onGap;
30403
30408
  #tmuxWork = Promise.resolve();
@@ -30509,11 +30514,13 @@ var init_tmux_external_interaction_observer = __esm({
30509
30514
  if (!this.#abort.signal.aborted) this.#reportGap("hook-repair-failed");
30510
30515
  outcome = "failed";
30511
30516
  }
30517
+ this.#unhealthyChecks = outcome === "healthy" ? 0 : this.#unhealthyChecks + 1;
30512
30518
  if (this.#healthcheckDelayMs === delayBefore) {
30513
30519
  this.#healthcheckDelayMs = nextHookHealthcheckDelay(
30514
30520
  delayBefore,
30515
30521
  outcome,
30516
- this.#healthcheckSchedule
30522
+ this.#healthcheckSchedule,
30523
+ this.#unhealthyChecks
30517
30524
  );
30518
30525
  }
30519
30526
  if (this.#hookHealthcheck === null) this.#scheduleHealthcheck();
@@ -30607,11 +30614,17 @@ var init_tmux_external_interaction_observer = __esm({
30607
30614
  const work = this.#serializeTmux(async () => {
30608
30615
  const finish = this.#beginDiagnostic("healthcheck");
30609
30616
  try {
30610
- if (await this.#ownedHooksPresent(this.#abort.signal)) {
30617
+ const hooks = await this.#ownedHooksPresent(this.#abort.signal);
30618
+ if (hooks === "present") {
30611
30619
  this.#lastHealthcheckOutcome = "healthy";
30612
30620
  finish(true);
30613
30621
  return;
30614
30622
  }
30623
+ if (hooks === "unknown") {
30624
+ this.#lastHealthcheckOutcome = "failed";
30625
+ finish(false);
30626
+ return;
30627
+ }
30615
30628
  if (this.#installed) this.#reportGap("hooks-replaced");
30616
30629
  this.#setInstalled(false);
30617
30630
  try {
@@ -30843,9 +30856,9 @@ var init_tmux_external_interaction_observer = __esm({
30843
30856
  signal
30844
30857
  );
30845
30858
  } catch {
30846
- return false;
30859
+ return "unknown";
30847
30860
  }
30848
- return ownedHookInstalled(output, "after-send-keys", this.#bufferName) && ownedHookInstalled(output, "after-capture-pane", this.#bufferName);
30861
+ return ownedHookInstalled(output, "after-send-keys", this.#bufferName) && ownedHookInstalled(output, "after-capture-pane", this.#bufferName) ? "present" : "missing";
30849
30862
  }
30850
30863
  get available() {
30851
30864
  return this.#installed;
@@ -36743,7 +36756,9 @@ var init_session_channel = __esm({
36743
36756
  const rightWindow = right.windows.get(runtimeId);
36744
36757
  const leftLayout = left.layouts.get(runtimeId);
36745
36758
  const rightLayout = right.layouts.get(runtimeId);
36746
- if (!rightWindow || !leftLayout || !rightLayout || leftWindow.semanticId !== rightWindow.semanticId || leftWindow.name !== rightWindow.name || leftWindow.paneBorderStatus !== rightWindow.paneBorderStatus || leftWindow.modeKeys !== rightWindow.modeKeys || !layoutIdentitiesEqual(leftLayout, rightLayout)) {
36759
+ if (!rightWindow || !leftLayout || !rightLayout || leftWindow.semanticId !== rightWindow.semanticId || // Not the name: tmux derives it from the running command, and the
36760
+ // pane rows' own check ignores it too (sameSessionPaneInventory, #730).
36761
+ leftWindow.paneBorderStatus !== rightWindow.paneBorderStatus || leftWindow.modeKeys !== rightWindow.modeKeys || !layoutIdentitiesEqual(leftLayout, rightLayout)) {
36747
36762
  return false;
36748
36763
  }
36749
36764
  }
@@ -42170,7 +42185,7 @@ function classifiedAsyncRunner(tmuxAuthority) {
42170
42185
  function digest2(value) {
42171
42186
  return createHash19("sha256").update(value).digest("hex").slice(0, 20);
42172
42187
  }
42173
- var MAX_OPERATIONS, MAX_REPLAYABLE_FAILURES2, MAX_TMUX_OUTPUT_BYTES, ADOPTED_OPTION2, SESSION_PROMOTED_MARKER_OPTION, SESSION_WORKSPACE_OPTION, SESSION_OPERATION_OPTION, SEMANTIC_PANE_OPTION3, SEMANTIC_WINDOW_OPTION2, FIELD, SENTINEL, SESSION_FORMAT, PANE_SCAN_FORMAT, PANE_VERIFY_FORMAT, ERROR_MESSAGES3, WorkspacePromotionError, VALID_SEMANTIC_PANE_ID, RESERVED_DISCOVERED_PREFIX, DEFAULT_IO3, WorkspacePromotionAuthority;
42188
+ var MAX_OPERATIONS, MAX_REPLAYABLE_FAILURES2, MAX_TMUX_OUTPUT_BYTES, ADOPTED_OPTION2, SESSION_PROMOTED_MARKER_OPTION, SESSION_WORKSPACE_OPTION, SESSION_OPERATION_OPTION, SEMANTIC_PANE_OPTION3, SEMANTIC_WINDOW_OPTION2, FIELD, SENTINEL, SESSION_FORMAT, PANE_SCAN_FORMAT, PANE_VERIFY_FORMAT, ERROR_MESSAGES3, PROMOTION_PROOF_ATTEMPTS, WorkspacePromotionError, VALID_SEMANTIC_PANE_ID, RESERVED_DISCOVERED_PREFIX, DEFAULT_IO3, WorkspacePromotionAuthority;
42174
42189
  var init_workspace_promotion2 = __esm({
42175
42190
  "packages/daemon/src/lib/workspace-promotion.ts"() {
42176
42191
  "use strict";
@@ -42243,6 +42258,7 @@ var init_workspace_promotion2 = __esm({
42243
42258
  operation_conflict: "The operation id was already used for another promotion intent.",
42244
42259
  operation_capacity: "The daemon has reached its bounded workspace-promote operation capacity."
42245
42260
  };
42261
+ PROMOTION_PROOF_ATTEMPTS = 3;
42246
42262
  WorkspacePromotionError = class extends Error {
42247
42263
  code;
42248
42264
  context;
@@ -42362,9 +42378,19 @@ var init_workspace_promotion2 = __esm({
42362
42378
  }
42363
42379
  const identity4 = alreadyRegistered ? { workspaceName: alreadyRegistered.name, sessionName: session.sessionName } : derivePromotionIdentity(session.sessionName);
42364
42380
  this.#assertConflictFreeIdentity(identity4);
42365
- const canonicalRoot = await this.#stampSession(request3, session, identity4);
42366
- this.#assertActive(request3.operationId);
42367
- await this.#verifyPromotedInventory(session.sessionId, identity4);
42381
+ let canonicalRoot;
42382
+ for (let attempt = 1; ; attempt += 1) {
42383
+ canonicalRoot = await this.#stampSession(request3, session, identity4);
42384
+ this.#assertActive(request3.operationId);
42385
+ try {
42386
+ await this.#verifyPromotedInventory(session.sessionId, identity4);
42387
+ break;
42388
+ } catch (error) {
42389
+ if (attempt >= PROMOTION_PROOF_ATTEMPTS || !(error instanceof WorkspacePromotionError) || error.context.reason !== "inventory_changed_during_proof")
42390
+ throw error;
42391
+ this.#assertActive(request3.operationId);
42392
+ }
42393
+ }
42368
42394
  await this.#publishFleetEnrollment(request3, session, identity4);
42369
42395
  const discovered = this.#registeredSession(session.sessionName);
42370
42396
  if (discovered) {
@@ -74365,6 +74391,19 @@ var init_native_runtime = __esm({
74365
74391
  if (this.#disposed) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
74366
74392
  const epoch = this.#inventoryEpoch;
74367
74393
  const nativeEpoch = this.#nativeServerEpoch?.() ?? null;
74394
+ const publish = async (value, publicationSignal) => {
74395
+ try {
74396
+ return await this.#publishInventory(value, nativeEpoch, publicationSignal, epoch);
74397
+ } catch (error) {
74398
+ if (this.#disposed || signal?.aborted || this.#inventoryEpoch === epoch) throw error;
74399
+ if (staleRetry < INVENTORY_STALE_RETRIES)
74400
+ return this.#readInventory(signal, staleRetry + 1);
74401
+ throw new NativeTerminalAttachmentRuntimeError(
74402
+ "discovery-failed",
74403
+ "overtaken-by-invalidations"
74404
+ );
74405
+ }
74406
+ };
74368
74407
  if (signal) {
74369
74408
  if (signal.aborted) throw new NativeTerminalAttachmentRuntimeError("runtime-disposed");
74370
74409
  let snapshot3;
@@ -74390,7 +74429,7 @@ var init_native_runtime = __esm({
74390
74429
  "overtaken-by-invalidations"
74391
74430
  );
74392
74431
  }
74393
- return this.#publishInventory(snapshot3, nativeEpoch, signal, epoch);
74432
+ return publish(snapshot3, signal);
74394
74433
  }
74395
74434
  if (this.#inventoryRead?.epoch === epoch) return this.#inventoryRead.promise;
74396
74435
  const abort = new AbortController();
@@ -74417,7 +74456,7 @@ var init_native_runtime = __esm({
74417
74456
  "overtaken-by-invalidations"
74418
74457
  );
74419
74458
  }
74420
- return this.#publishInventory(value, nativeEpoch, abort.signal, epoch);
74459
+ return publish(value, abort.signal);
74421
74460
  })().finally(() => {
74422
74461
  if (this.#inventoryRead?.promise === promise) this.#inventoryRead = null;
74423
74462
  });
@@ -78245,6 +78284,12 @@ var init_pane_stream_websocket = __esm({
78245
78284
  "pane_not_active",
78246
78285
  "mutation_unverified"
78247
78286
  ].includes(rawCode) ? rawCode : "stream-unavailable";
78287
+ logger.info("pane-stream", "intent rejected", {
78288
+ session: this.#descriptor.sessionName,
78289
+ clientId: this.#clientId,
78290
+ verb: intent.verb,
78291
+ code: code2
78292
+ });
78248
78293
  this.#sendFrame(null, {
78249
78294
  type: "semantic-intent-ack",
78250
78295
  operationId,
@@ -78700,6 +78745,136 @@ var init_multiplexer_backend = __esm({
78700
78745
  }
78701
78746
  });
78702
78747
 
78748
+ // packages/daemon/src/lib/orphaned-control-clients.ts
78749
+ import { execFile as execFile11 } from "node:child_process";
78750
+ function parseProcessTable(text2) {
78751
+ const rows = [];
78752
+ for (const line of text2.split("\n")) {
78753
+ const match = /^\s*([0-9]+)\s+([0-9]+)\s+(.+)$/u.exec(line);
78754
+ if (match) rows.push({ pid: Number(match[1]), ppid: Number(match[2]), command: match[3] });
78755
+ }
78756
+ return rows;
78757
+ }
78758
+ function isTmuxIdeControlClientCommand(command3) {
78759
+ return /(?:^|\s)-C(?:\s|$)/u.test(command3) && /ignore-size,pause-after=[0-9]+,active-pane/u.test(command3);
78760
+ }
78761
+ function commandTargetsServer(command3, selector) {
78762
+ const words = command3.split(/\s+/u);
78763
+ for (let index = 0; index < words.length; index += 1) {
78764
+ const word = words[index];
78765
+ if (word === "-C") return false;
78766
+ const flag = selector.kind === "path" ? "-S" : "-L";
78767
+ const value = word === flag ? words[index + 1] : word.startsWith(flag) ? word.slice(2) : null;
78768
+ if (value === null || value === void 0 || value === "") continue;
78769
+ return selector.kind === "path" ? withoutPrivate(value) === withoutPrivate(selector.path) : value === selector.name;
78770
+ }
78771
+ return false;
78772
+ }
78773
+ function adoptsOrphans(pid, command3) {
78774
+ if (pid === 1) return true;
78775
+ return command3 !== null && /^(?:\S*\/)?(?:systemd|launchd|init)(?:\s|$)/u.test(command3);
78776
+ }
78777
+ async function evictOrphanedControlClients(io, ownPid, selector) {
78778
+ let processes;
78779
+ try {
78780
+ processes = await io.listProcesses();
78781
+ } catch {
78782
+ return [];
78783
+ }
78784
+ const byPid = new Map(processes.map((row) => [row.pid, row]));
78785
+ const evicted = [];
78786
+ for (const client of processes) {
78787
+ if (client.pid <= 1 || client.pid === ownPid || client.ppid === ownPid || !isTmuxIdeControlClientCommand(client.command) || !commandTargetsServer(client.command, selector) || !adoptsOrphans(client.ppid, byPid.get(client.ppid)?.command ?? null))
78788
+ continue;
78789
+ try {
78790
+ io.kill(client.pid, "SIGTERM");
78791
+ await io.delay(ORPHAN_KILL_GRACE_MS);
78792
+ if (io.isAlive(client.pid)) io.kill(client.pid, "SIGKILL");
78793
+ evicted.push(client.pid);
78794
+ } catch {
78795
+ }
78796
+ }
78797
+ return evicted;
78798
+ }
78799
+ function orphanedControlClientIo() {
78800
+ return {
78801
+ listProcesses: () => new Promise((resolve47, reject) => {
78802
+ execFile11(
78803
+ "/bin/ps",
78804
+ ["-xww", "-o", "pid=,ppid=,command="],
78805
+ {
78806
+ encoding: "utf8",
78807
+ timeout: 3e3,
78808
+ maxBuffer: 16 * 1024 * 1024,
78809
+ env: { LC_ALL: "C", PATH: "/usr/bin:/bin" }
78810
+ },
78811
+ (error, stdout) => error ? reject(error) : resolve47(parseProcessTable(stdout))
78812
+ );
78813
+ }),
78814
+ kill: (pid, signal) => {
78815
+ process.kill(pid, signal);
78816
+ },
78817
+ isAlive: (pid) => {
78818
+ try {
78819
+ process.kill(pid, 0);
78820
+ return true;
78821
+ } catch (error) {
78822
+ return error.code === "EPERM";
78823
+ }
78824
+ },
78825
+ delay: (ms) => new Promise((resolve47) => setTimeout(resolve47, ms))
78826
+ };
78827
+ }
78828
+ function createOrphanedControlClientWatch(options) {
78829
+ const io = options.io ?? orphanedControlClientIo();
78830
+ const now = options.now ?? Date.now;
78831
+ const fields = options.serverId ? { serverId: options.serverId } : {};
78832
+ let lastPassAt = Number.NEGATIVE_INFINITY;
78833
+ let lastLogAt = Number.NEGATIVE_INFINITY;
78834
+ let running = null;
78835
+ const pass = () => {
78836
+ if (running) return running;
78837
+ lastPassAt = now();
78838
+ const current = evictOrphanedControlClients(io, process.pid, options.selector).catch(() => []).then((pids) => {
78839
+ if (pids.length > 0)
78840
+ logger.warn("tmux-server-owners", "ended control clients a dead daemon left attached", {
78841
+ ...fields,
78842
+ pids
78843
+ });
78844
+ return pids;
78845
+ }).finally(() => {
78846
+ if (running === current) running = null;
78847
+ });
78848
+ running = current;
78849
+ return current;
78850
+ };
78851
+ return {
78852
+ onOwnership: () => pass().then(() => void 0),
78853
+ async onTrouble(kind) {
78854
+ if (now() - lastPassAt < EMPTY_SERVER_PASS_INTERVAL_MS) return;
78855
+ const pids = await pass();
78856
+ if (now() - lastLogAt < EMPTY_SERVER_LOG_INTERVAL_MS) return;
78857
+ lastLogAt = now();
78858
+ logger.warn(
78859
+ "tmux-server-owners",
78860
+ kind === "no-sessions" ? "tmux server answers with no sessions" : "tmux server does not answer its catalog",
78861
+ { ...fields, endedControlClients: pids.length }
78862
+ );
78863
+ }
78864
+ };
78865
+ }
78866
+ var ORPHAN_KILL_GRACE_MS, withoutPrivate, EMPTY_SERVER_PASS_INTERVAL_MS, EMPTY_SERVER_LOG_INTERVAL_MS;
78867
+ var init_orphaned_control_clients = __esm({
78868
+ "packages/daemon/src/lib/orphaned-control-clients.ts"() {
78869
+ "use strict";
78870
+ init_log();
78871
+ ORPHAN_KILL_GRACE_MS = 500;
78872
+ withoutPrivate = (path2) => path2.replace(/^\/private(?=\/)/u, "");
78873
+ EMPTY_SERVER_PASS_INTERVAL_MS = 1e4;
78874
+ EMPTY_SERVER_LOG_INTERVAL_MS = 6e4;
78875
+ }
78876
+ });
78877
+
78703
78878
  // packages/daemon/src/lib/interaction-receipt-journal.ts
78704
78879
  var InteractionReceiptJournal;
78705
78880
  var init_interaction_receipt_journal = __esm({
@@ -79162,9 +79337,15 @@ function discoveredWorkspaceName(registry, sessionName) {
79162
79337
  }
79163
79338
  throw new Error("Unable to allocate discovered workspace identity");
79164
79339
  }
79165
- function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () => void 0) {
79340
+ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () => void 0, onTrouble) {
79166
79341
  return async () => {
79167
79342
  assertOpen();
79343
+ const tell = (kind) => {
79344
+ try {
79345
+ void Promise.resolve(onTrouble?.(kind)).catch(() => void 0);
79346
+ } catch {
79347
+ }
79348
+ };
79168
79349
  const raw = await run(
79169
79350
  [
79170
79351
  "-N",
@@ -79181,10 +79362,15 @@ function createNativeTmuxServerCatalog(workspaceRegistry, run, assertOpen = () =
79181
79362
  ].map(shellEscape).join(" ")
79182
79363
  ],
79183
79364
  AbortSignal.timeout(2e3)
79184
- );
79365
+ ).catch((error) => {
79366
+ tell("unanswered");
79367
+ throw error;
79368
+ });
79185
79369
  assertOpen();
79186
79370
  const rows = /* @__PURE__ */ new Map();
79187
- const lines = raw.trim() === "tmux-ide-empty-catalog-v1" ? [] : raw.trim().split("\n");
79371
+ const empty2 = raw.trim() === "tmux-ide-empty-catalog-v1";
79372
+ if (empty2) tell("no-sessions");
79373
+ const lines = empty2 ? [] : raw.trim().split("\n");
79188
79374
  for (const line of lines) {
79189
79375
  const [pid, id2, created, name, pane, window2, activity, ...pathParts] = line.split(" ");
79190
79376
  const dir = pathParts.join(" ");
@@ -79255,6 +79441,11 @@ async function createNativeTmuxServerOwner(options) {
79255
79441
  authority2,
79256
79442
  nativeServerIdentity
79257
79443
  );
79444
+ const orphanWatch = createOrphanedControlClientWatch({
79445
+ selector: authority2.socketSelector,
79446
+ serverId: options.serverId
79447
+ });
79448
+ void orphanWatch.onOwnership();
79258
79449
  const multiplexer = new WorkspaceMultiplexerAuthority({
79259
79450
  daemonInstanceId: generation,
79260
79451
  registry: workspaceRegistry,
@@ -79530,7 +79721,12 @@ async function createNativeTmuxServerOwner(options) {
79530
79721
  registry: sessionRuntimeRegistry,
79531
79722
  resolveSession: (name) => workspaceRegistry.get(name)?.sessionName ?? null
79532
79723
  });
79533
- const catalog = createNativeTmuxServerCatalog(workspaceRegistry, generationRunAsync, assertOpen);
79724
+ const catalog = createNativeTmuxServerCatalog(
79725
+ workspaceRegistry,
79726
+ generationRunAsync,
79727
+ assertOpen,
79728
+ orphanWatch.onTrouble
79729
+ );
79534
79730
  const sessionCreator = createNativeTmuxSessionCreator({
79535
79731
  generation,
79536
79732
  registry: workspaceRegistry,
@@ -79766,6 +79962,7 @@ var init_tmux_server_owner = __esm({
79766
79962
  init_registry2();
79767
79963
  init_multiplexer_backend();
79768
79964
  init_tmux_external_interaction_observer();
79965
+ init_orphaned_control_clients();
79769
79966
  init_interaction_receipt_journal();
79770
79967
  init_interaction_observation_status();
79771
79968
  init_interaction_evidence_authority();
@@ -80221,7 +80418,7 @@ var init_tmux_server_owners = __esm({
80221
80418
  });
80222
80419
 
80223
80420
  // packages/daemon/src/lib/tmux-server-registration.ts
80224
- import { execFile as execFile11 } from "node:child_process";
80421
+ import { execFile as execFile12 } from "node:child_process";
80225
80422
  import { promisify as promisify2 } from "node:util";
80226
80423
  import { createHash as createHash26, randomUUID as randomUUID39 } from "node:crypto";
80227
80424
  import {
@@ -80380,7 +80577,7 @@ var init_tmux_server_registration = __esm({
80380
80577
  init_tmux_client_execution();
80381
80578
  init_unix_socket_authority();
80382
80579
  init_tmux_server_owners();
80383
- exec = promisify2(execFile11);
80580
+ exec = promisify2(execFile12);
80384
80581
  FileSchema2 = z125.object({
80385
80582
  version: z125.literal(1),
80386
80583
  servers: z125.array(TmuxServerRegistrationSchemaZ).max(MAX_TMUX_SERVER_OWNERS)
@@ -81402,7 +81599,7 @@ var init_runtime_trace_writer = __esm({
81402
81599
  });
81403
81600
 
81404
81601
  // packages/daemon/src/lib/tmux-authority-replacement.ts
81405
- import { execFile as execFile12 } from "node:child_process";
81602
+ import { execFile as execFile13 } from "node:child_process";
81406
81603
  import { lstatSync as lstatSync13 } from "node:fs";
81407
81604
  import { dirname as dirname33 } from "node:path";
81408
81605
  import { promisify as promisify3 } from "node:util";
@@ -81491,7 +81688,7 @@ var init_tmux_authority_replacement = __esm({
81491
81688
  "use strict";
81492
81689
  init_unix_socket_authority();
81493
81690
  init_tmux_named_socket_fence();
81494
- execFileAsync = promisify3(execFile12);
81691
+ execFileAsync = promisify3(execFile13);
81495
81692
  SERVER_FORMAT = "#{socket_path}|#{pid}";
81496
81693
  }
81497
81694
  });
@@ -81590,7 +81787,7 @@ var init_session_monitor = __esm({
81590
81787
  });
81591
81788
 
81592
81789
  // packages/daemon/src/lib/daemon-session-monitor.ts
81593
- import { execFile as execFile13 } from "node:child_process";
81790
+ import { execFile as execFile14 } from "node:child_process";
81594
81791
  function parseDaemonMonitorPanes(raw) {
81595
81792
  if (!raw) return [];
81596
81793
  return raw.split("\n").map((line) => {
@@ -81608,7 +81805,7 @@ function parseDaemonMonitorPanes(raw) {
81608
81805
  }
81609
81806
  function execMonitorCommandAsync(executable, args, signal) {
81610
81807
  return new Promise((resolve47, reject) => {
81611
- execFile13(
81808
+ execFile14(
81612
81809
  executable,
81613
81810
  [...args],
81614
81811
  { encoding: "utf8", maxBuffer: 1024 * 1024, signal },
@@ -91353,6 +91550,14 @@ function failure(c, error) {
91353
91550
  return c.json({ error: { code: error.code } }, 409);
91354
91551
  if (error instanceof z136.ZodError || error instanceof SyntaxError || error instanceof TypeError)
91355
91552
  return c.json({ error: { code: "invalid-request" } }, 400);
91553
+ const code2 = error?.code;
91554
+ logger.warn("tmux-server-routes", "request failed as server-unavailable", {
91555
+ method: c.req.method,
91556
+ route: c.req.routePath,
91557
+ errorName: error instanceof Error ? error.name : typeof error,
91558
+ ...typeof code2 === "string" ? { errorCode: code2.slice(0, 80) } : {},
91559
+ error: (error instanceof Error ? error.message : String(error)).slice(0, 300)
91560
+ });
91356
91561
  return c.json({ error: { code: "server-unavailable" } }, 503);
91357
91562
  }
91358
91563
  function mountTmuxServerRoutes(app, options) {
@@ -91868,6 +92073,7 @@ var init_tmux_servers = __esm({
91868
92073
  init_workspace_multiplexer_verbs();
91869
92074
  init_workspace_pane_creation2();
91870
92075
  init_owner_authority();
92076
+ init_log();
91871
92077
  init_pane_stream_issue();
91872
92078
  init_terminal_runtime_inventory2();
91873
92079
  SESSIONS_RESOURCE_FAVICON_BUDGET_BYTES = 512 * 1024;
@@ -99559,7 +99765,7 @@ __export(server_exports2, {
99559
99765
  getCompatibilityMetrics: () => getCompatibilityMetrics,
99560
99766
  getSseMetrics: () => getSseMetrics
99561
99767
  });
99562
- import { execFile as execFile14 } from "node:child_process";
99768
+ import { execFile as execFile15 } from "node:child_process";
99563
99769
  import { promisify as promisify4 } from "node:util";
99564
99770
  import { existsSync as existsSync38, readdirSync as readdirSync12 } from "node:fs";
99565
99771
  import { join as join59, dirname as dirname46, basename as basename24 } from "node:path";
@@ -100537,7 +100743,7 @@ function createApp(options = {}) {
100537
100743
  return c.json({ error: "Failed to write workspace config", detail: message }, 500);
100538
100744
  }
100539
100745
  });
100540
- const execFileAsync2 = promisify4(execFile14);
100746
+ const execFileAsync2 = promisify4(execFile15);
100541
100747
  app.post("/api/project/:name/restart", async (c) => {
100542
100748
  const name = c.req.param("name");
100543
100749
  const sessions = discoverSessions();
@@ -101723,6 +101929,11 @@ async function startEmbeddedDaemonGeneration(opts) {
101723
101929
  initialNativeServerIdentity ? createServerGenerationFencedTmuxRunner(tmuxAuthority, initialNativeServerIdentity) : catalogTmuxRunner
101724
101930
  );
101725
101931
  const fleetFactsTmuxRunner = initialNativeServerIdentity ? createServerGenerationFencedTmuxAsyncRunner(tmuxAuthority, initialNativeServerIdentity) : createPinnedWorkspaceTmuxAsyncRunner(tmuxAuthority);
101932
+ const defaultServerOrphanWatch = createOrphanedControlClientWatch({
101933
+ selector: tmuxAuthority.socketSelector,
101934
+ serverId: null
101935
+ });
101936
+ void defaultServerOrphanWatch.onOwnership();
101726
101937
  const tmuxAuthorityReplaced = createTmuxAuthorityReplacementProbe(
101727
101938
  tmuxAuthority,
101728
101939
  catalogTmuxRunner
@@ -102381,7 +102592,12 @@ async function startEmbeddedDaemonGeneration(opts) {
102381
102592
  resolveNativeSurfaceContext: createNativeSurfaceContextResolver({
102382
102593
  generation: instanceId,
102383
102594
  registry: workspaceRegistry,
102384
- catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
102595
+ catalog: createNativeTmuxServerCatalog(
102596
+ workspaceRegistry,
102597
+ fleetFactsTmuxRunner,
102598
+ void 0,
102599
+ defaultServerOrphanWatch.onTrouble
102600
+ ),
102385
102601
  inventory: terminalInventoryRuntime,
102386
102602
  run: (args, signal) => fleetFactsTmuxRunner(args, signal),
102387
102603
  assertOpen: () => {
@@ -102392,7 +102608,12 @@ async function startEmbeddedDaemonGeneration(opts) {
102392
102608
  resolvePaneEditorContext: createPaneEditorContextResolver({
102393
102609
  generation: instanceId,
102394
102610
  registry: workspaceRegistry,
102395
- catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
102611
+ catalog: createNativeTmuxServerCatalog(
102612
+ workspaceRegistry,
102613
+ fleetFactsTmuxRunner,
102614
+ void 0,
102615
+ defaultServerOrphanWatch.onTrouble
102616
+ ),
102396
102617
  inventory: terminalInventoryRuntime,
102397
102618
  assertOpen: () => {
102398
102619
  if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
@@ -102403,7 +102624,12 @@ async function startEmbeddedDaemonGeneration(opts) {
102403
102624
  generation: instanceId,
102404
102625
  run: fleetFactsTmuxRunner,
102405
102626
  registry: workspaceRegistry,
102406
- catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
102627
+ catalog: createNativeTmuxServerCatalog(
102628
+ workspaceRegistry,
102629
+ fleetFactsTmuxRunner,
102630
+ void 0,
102631
+ defaultServerOrphanWatch.onTrouble
102632
+ ),
102407
102633
  inventory: terminalInventoryRuntime,
102408
102634
  assertOpen: () => {
102409
102635
  if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
@@ -102414,19 +102640,31 @@ async function startEmbeddedDaemonGeneration(opts) {
102414
102640
  generation: instanceId,
102415
102641
  run: fleetFactsTmuxRunner,
102416
102642
  registry: workspaceRegistry,
102417
- catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
102643
+ catalog: createNativeTmuxServerCatalog(
102644
+ workspaceRegistry,
102645
+ fleetFactsTmuxRunner,
102646
+ void 0,
102647
+ defaultServerOrphanWatch.onTrouble
102648
+ ),
102418
102649
  inventory: terminalInventoryRuntime,
102419
102650
  assertOpen: () => {
102420
102651
  if (defaultEditorContextRetired || serverOwners?.defaultRetired || !initialNativeServerIdentity || terminalInventoryRuntime?.lifecycleState() !== "ready")
102421
102652
  throw new Error("Default reader owner is unavailable");
102422
102653
  }
102423
102654
  }),
102424
- catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
102655
+ catalog: createNativeTmuxServerCatalog(
102656
+ workspaceRegistry,
102657
+ fleetFactsTmuxRunner,
102658
+ void 0,
102659
+ defaultServerOrphanWatch.onTrouble
102660
+ ),
102425
102661
  readWindowSplitLayout: async (workspaceName, input) => {
102426
102662
  const target = WindowLinkTargetSchemaZ.parse(input);
102427
102663
  const sessions = await createNativeTmuxServerCatalog(
102428
102664
  workspaceRegistry,
102429
- fleetFactsTmuxRunner
102665
+ fleetFactsTmuxRunner,
102666
+ void 0,
102667
+ defaultServerOrphanWatch.onTrouble
102430
102668
  )();
102431
102669
  const sessionName2 = workspaceRegistry.get(workspaceName)?.sessionName;
102432
102670
  if (!sessionName2 || !sessions.some(
@@ -102438,7 +102676,12 @@ async function startEmbeddedDaemonGeneration(opts) {
102438
102676
  },
102439
102677
  openAgent: async (liveSessionId, observed) => {
102440
102678
  const target = observedAgentSchema.parse(observed);
102441
- await createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner)();
102679
+ await createNativeTmuxServerCatalog(
102680
+ workspaceRegistry,
102681
+ fleetFactsTmuxRunner,
102682
+ void 0,
102683
+ defaultServerOrphanWatch.onTrouble
102684
+ )();
102442
102685
  try {
102443
102686
  return await defaultSessionOpener.openAgent(liveSessionId, target);
102444
102687
  } finally {
@@ -102446,7 +102689,12 @@ async function startEmbeddedDaemonGeneration(opts) {
102446
102689
  }
102447
102690
  },
102448
102691
  openSession: async (liveSessionId) => {
102449
- await createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner)();
102692
+ await createNativeTmuxServerCatalog(
102693
+ workspaceRegistry,
102694
+ fleetFactsTmuxRunner,
102695
+ void 0,
102696
+ defaultServerOrphanWatch.onTrouble
102697
+ )();
102450
102698
  const result2 = await defaultSessionOpener.openSession(liveSessionId);
102451
102699
  terminalInventoryRuntime.invalidate();
102452
102700
  return result2;
@@ -103079,6 +103327,7 @@ var init_daemon_embed = __esm({
103079
103327
  init_app_window_mutation2();
103080
103328
  init_workspace_multiplexer_verbs();
103081
103329
  init_tmux_external_interaction_observer();
103330
+ init_orphaned_control_clients();
103082
103331
  init_tmux_interaction_observation_handler();
103083
103332
  init_interaction_receipt_journal();
103084
103333
  init_interaction_observation_status();
@@ -104312,7 +104561,7 @@ var init_attach = __esm({
104312
104561
  });
104313
104562
 
104314
104563
  // packages/daemon/src/lib/daemon-service-manager.ts
104315
- import { execFile as execFile15 } from "node:child_process";
104564
+ import { execFile as execFile16 } from "node:child_process";
104316
104565
  function createDaemonServiceManager(plan, run = runCommand) {
104317
104566
  const launchd = plan.manager === "launchd";
104318
104567
  const file = launchd ? "/bin/launchctl" : "systemctl";
@@ -104409,7 +104658,7 @@ var init_daemon_service_manager = __esm({
104409
104658
  "packages/daemon/src/lib/daemon-service-manager.ts"() {
104410
104659
  "use strict";
104411
104660
  runCommand = (file, args) => new Promise((resolve47) => {
104412
- execFile15(
104661
+ execFile16(
104413
104662
  file,
104414
104663
  [...args],
104415
104664
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmux-ide",
3
- "version": "2.9.23",
3
+ "version": "2.9.24",
4
4
  "description": "The open-source workspace for coding agents: run Claude Code, Codex and other agents in tmux with live status",
5
5
  "type": "module",
6
6
  "bin": {
@@ -17,6 +17,7 @@ import { createSessionFaviconResolver } from "../lib/session-favicon.js";
17
17
  import { WorkspaceMultiplexerError } from "../lib/workspace-multiplexer-verbs.js";
18
18
  import { WorkspacePaneCreationError } from "../lib/workspace-pane-creation.js";
19
19
  import { ownerBearerMatches } from "./owner-authority.js";
20
+ import { logger } from "../lib/log.js";
20
21
  import { mountPaneStreamIssueRoute } from "./pane-stream-issue.js";
21
22
  import { projectTerminalRuntimeInventory } from "./resources/terminal-runtime-inventory.js";
22
23
  /** Total raw favicon bytes one version 2 sessions response may carry. */
@@ -68,6 +69,16 @@ function failure(c, error) {
68
69
  return c.json({ error: { code: error.code } }, 409);
69
70
  if (error instanceof z.ZodError || error instanceof SyntaxError || error instanceof TypeError)
70
71
  return c.json({ error: { code: "invalid-request" } }, 400);
72
+ // Everything above tells the client its cause. This answer does not, and a
73
+ // client can only retry it: the cause goes to the daemon's own log.
74
+ const code = error?.code;
75
+ logger.warn("tmux-server-routes", "request failed as server-unavailable", {
76
+ method: c.req.method,
77
+ route: c.req.routePath,
78
+ errorName: error instanceof Error ? error.name : typeof error,
79
+ ...(typeof code === "string" ? { errorCode: code.slice(0, 80) } : {}),
80
+ error: (error instanceof Error ? error.message : String(error)).slice(0, 300),
81
+ });
71
82
  return c.json({ error: { code: "server-unavailable" } }, 503);
72
83
  }
73
84
  /** Owner capability is mandatory even when the ordinary local HTTP surface is open. */