tmux-ide 2.9.21 → 2.9.23
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/cli.js +6235 -8473
- package/package.json +3 -3
- package/packages/contracts/src/index.ts +2 -0
- package/packages/contracts/src/pane-reader.ts +121 -0
- package/packages/contracts/src/pane-stream.ts +18 -0
- package/packages/contracts/src/visual-theme-presets.ts +58 -2
- package/packages/contracts/src/websocket-heartbeat.ts +41 -0
- package/packages/daemon/dist/command-center/automation.js +1 -1
- package/packages/daemon/dist/command-center/daemon-fleet-facts-observer.js +37 -5
- package/packages/daemon/dist/command-center/discovery.js +28 -2
- package/packages/daemon/dist/command-center/server.js +8 -2
- package/packages/daemon/dist/command-center/tmux-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +7 -1
- package/packages/daemon/dist/doctor.js +147 -43
- package/packages/daemon/dist/lib/bounded-tmux-read.js +34 -12
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +126 -55
- package/packages/daemon/dist/lib/daemon-stop-progress.js +58 -0
- package/packages/daemon/dist/lib/embedded-daemon-lifecycle.js +11 -0
- package/packages/daemon/dist/lib/embedded-tmux-server-owners.js +88 -12
- package/packages/daemon/dist/lib/headless-daemon.js +177 -10
- package/packages/daemon/dist/lib/log.js +18 -1
- package/packages/daemon/dist/lib/pane-reader-files.js +226 -0
- package/packages/daemon/dist/lib/remote-tmux-command.js +8 -5
- package/packages/daemon/dist/lib/tmux-client-execution.js +73 -7
- package/packages/daemon/dist/lib/tmux-external-interaction-observer.js +140 -19
- package/packages/daemon/dist/lib/tmux-native-browser.js +4 -2
- package/packages/daemon/dist/lib/tmux-pane-reader.js +107 -0
- package/packages/daemon/dist/lib/tmux-server-agent-admission.js +6 -1
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner-teardown.js +33 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +38 -37
- package/packages/daemon/dist/lib/tmux-server-owners.js +310 -20
- package/packages/daemon/dist/lib/tmux-server-registration.js +128 -9
- package/packages/daemon/dist/lib/unix-socket-authority.js +58 -3
- package/packages/daemon/dist/lib/workspace-pane-creation.js +10 -1
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Info.plist +2 -2
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/MacOS/tmux-ide-notifier +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/Resources/Assets.car +0 -0
- package/packages/daemon/dist/native/TmuxIdeNotifier.app/Contents/_CodeSignature/CodeResources +2 -2
- package/packages/daemon/dist/open-browser.js +26 -12
- package/packages/daemon/dist/open-reader.js +84 -0
- package/packages/daemon/dist/plugins/cli.js +1 -2
- package/packages/daemon/dist/plugins/daemon-plugins.js +2 -10
- package/packages/daemon/dist/restore.js +57 -40
- package/packages/daemon/dist/server/pane-stream-upgrade.js +5 -1
- package/packages/daemon/dist/server/websocket-heartbeat.js +103 -0
- package/packages/daemon/dist/terminal/attachments/native-runtime.js +32 -14
- package/packages/daemon/dist/terminal/mirror/layout-content-rows.js +11 -0
- package/packages/daemon/dist/terminal/mirror/mirror-service.js +61 -3
- package/packages/daemon/dist/terminal/mirror/session-channel.js +13 -12
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +123 -25
- package/packages/daemon/dist/terminal/pane-stream/runtime.js +3 -2
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +30 -2
- package/packages/daemon/dist/terminal/protocol/stock-split-resize.js +4 -1
- package/packages/daemon/dist/terminal/session-runtime/registry.js +17 -0
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-interpreter.js +81 -3
- package/packages/daemon/dist/terminal/session-runtime/terminal-replica-owner.js +60 -3
- package/packages/daemon/dist/tmux-upgrade/cli.js +106 -0
- package/packages/daemon/dist/tmux-upgrade/io.js +540 -0
- package/packages/daemon/dist/tmux-upgrade/plan.js +238 -0
- package/packages/daemon/dist/tmux-upgrade/run.js +199 -0
- package/packages/daemon/dist/tui/chrome/snapshot.js +3 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agent-navigation.js +64 -4
- package/packages/daemon/dist/tui/mirror/runtime/application-home-agents-owner.js +35 -5
- package/packages/daemon/dist/tui/mirror/runtime/application-machine-agent-navigation.js +12 -8
- package/packages/daemon/dist/tui/mirror/runtime/application-terminal-interaction-controller.js +125 -111
- package/packages/daemon/src/command-center/automation.ts +1 -1
- package/packages/daemon/src/command-center/daemon-fleet-facts-observer.ts +49 -8
- package/packages/daemon/src/command-center/discovery.ts +35 -2
- package/packages/daemon/src/command-center/server.ts +22 -8
- package/packages/daemon/src/command-center/tmux-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +7 -1
- package/packages/daemon/src/doctor.ts +164 -45
- package/packages/daemon/src/lib/bounded-tmux-read.ts +29 -9
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +176 -64
- package/packages/daemon/src/lib/daemon-stop-progress.ts +78 -0
- package/packages/daemon/src/lib/embedded-daemon-lifecycle.ts +12 -0
- package/packages/daemon/src/lib/embedded-tmux-server-owners.ts +115 -11
- package/packages/daemon/src/lib/headless-daemon.ts +205 -12
- package/packages/daemon/src/lib/log.ts +18 -1
- package/packages/daemon/src/lib/pane-reader-files.ts +294 -0
- package/packages/daemon/src/lib/remote-tmux-command.ts +13 -6
- package/packages/daemon/src/lib/tmux-client-execution.ts +79 -7
- package/packages/daemon/src/lib/tmux-external-interaction-observer.ts +163 -25
- package/packages/daemon/src/lib/tmux-native-browser.ts +4 -3
- package/packages/daemon/src/lib/tmux-pane-reader.ts +145 -0
- package/packages/daemon/src/lib/tmux-server-agent-admission.ts +6 -1
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner-teardown.ts +54 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +41 -35
- package/packages/daemon/src/lib/tmux-server-owners.ts +427 -22
- package/packages/daemon/src/lib/tmux-server-registration.ts +155 -7
- package/packages/daemon/src/lib/unix-socket-authority.ts +72 -3
- package/packages/daemon/src/lib/workspace-pane-creation.ts +11 -1
- package/packages/daemon/src/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/cli.ts +1 -2
- package/packages/daemon/src/plugins/daemon-plugins.ts +2 -12
- package/packages/daemon/src/restore.ts +80 -44
- package/packages/daemon/src/server/pane-stream-upgrade.ts +6 -0
- package/packages/daemon/src/server/websocket-heartbeat.ts +135 -0
- package/packages/daemon/src/terminal/attachments/native-runtime.ts +58 -14
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/layout-content-rows.ts +11 -0
- package/packages/daemon/src/terminal/mirror/mirror-service.ts +61 -2
- package/packages/daemon/src/terminal/mirror/session-channel.ts +15 -14
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +140 -23
- package/packages/daemon/src/terminal/pane-stream/runtime.ts +4 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +41 -1
- package/packages/daemon/src/terminal/protocol/stock-split-resize.ts +6 -1
- package/packages/daemon/src/terminal/session-runtime/registry.ts +23 -0
- package/packages/daemon/src/terminal/session-runtime/runtime-observability.ts +2 -0
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-interpreter.ts +100 -3
- package/packages/daemon/src/terminal/session-runtime/terminal-replica-owner.ts +60 -3
- package/packages/daemon/src/tmux-upgrade/cli.ts +118 -0
- package/packages/daemon/src/tmux-upgrade/io.ts +596 -0
- package/packages/daemon/src/tmux-upgrade/plan.ts +353 -0
- package/packages/daemon/src/tmux-upgrade/run.ts +325 -0
- package/packages/daemon/src/tui/chrome/snapshot.ts +3 -4
- package/packages/daemon/src/tui/mirror/runtime/application-home-agent-navigation.ts +110 -10
- package/packages/daemon/src/tui/mirror/runtime/application-home-agents-owner.ts +58 -6
- package/packages/daemon/src/tui/mirror/runtime/application-machine-agent-navigation.ts +20 -9
- package/packages/daemon/src/tui/mirror/runtime/application-root-v2.tsx +2 -2
- package/packages/daemon/src/tui/mirror/runtime/application-terminal-interaction-controller.ts +149 -128
- package/packages/daemon-client/src/direct-application-shell-transport.ts +21 -3
- package/packages/daemon-client/src/workspace-event-supervisor.ts +63 -2
- package/packages/tmux-bridge/src/runner.ts +3 -1
|
@@ -2,10 +2,13 @@ import { requireSupportedTmuxVersion } from "./lib/tmux-version.ts";
|
|
|
2
2
|
import { resolveTmuxExecutable } from "./lib/tmux-client-execution.ts";
|
|
3
3
|
import { TMUX_SOCKET_PATH_ENV } from "./lib/runtime-namespace.ts";
|
|
4
4
|
import { execSync, execFileSync } from "node:child_process";
|
|
5
|
-
import { accessSync, constants, existsSync, mkdtempSync, rmSync } from "node:fs";
|
|
5
|
+
import { accessSync, constants, existsSync, mkdtempSync, realpathSync, rmSync } from "node:fs";
|
|
6
6
|
import { tmpdir } from "node:os";
|
|
7
|
-
import { resolve, dirname, join } from "node:path";
|
|
8
|
-
import {
|
|
7
|
+
import { delimiter, resolve, dirname, join } from "node:path";
|
|
8
|
+
import { resolveBundledTmux } from "./lib/bundled-tmux.ts";
|
|
9
|
+
import { readSnapshot } from "./tui/chrome/snapshot.ts";
|
|
10
|
+
import { isListableSession } from "./tui/team/sessions.ts";
|
|
11
|
+
import { nativeCommands, type NativeAnswer, type TmuxProbe } from "./lib/tmux-server-features.ts";
|
|
9
12
|
import { fileURLToPath } from "node:url";
|
|
10
13
|
import { getCurrentVersion, getUpdateStatus } from "./lib/update-check.ts";
|
|
11
14
|
import { installedSkillVersion } from "./lib/skill-sync.ts";
|
|
@@ -179,54 +182,20 @@ function check(
|
|
|
179
182
|
}
|
|
180
183
|
}
|
|
181
184
|
|
|
182
|
-
type TmuxProbe = (args: readonly string[]) => string;
|
|
183
|
-
const UNKNOWN = (command: string) => new RegExp(`^unknown command: ${command}$`, "mu");
|
|
184
|
-
|
|
185
|
-
type NativeAnswer = "full" | "stock" | "older" | "partial" | "no-server" | "unknown";
|
|
186
|
-
/** The same reading of the server as the mirror's: the stock resize when it refuses
|
|
187
|
-
* the split command by name, and full only with the split capability it requires. */
|
|
188
|
-
function nativeCommands(probe: TmuxProbe): NativeAnswer {
|
|
189
|
-
const ask = (command: string) => {
|
|
190
|
-
try {
|
|
191
|
-
return { output: probe([command, "-V"]) };
|
|
192
|
-
} catch (error) {
|
|
193
|
-
const failure = error as { stderr?: unknown; message?: string };
|
|
194
|
-
return { failure: String(failure.stderr ?? failure.message ?? "") };
|
|
195
|
-
}
|
|
196
|
-
};
|
|
197
|
-
const split = ask("tmux-ide-resize-split");
|
|
198
|
-
const events = ask("tmux-ide-events");
|
|
199
|
-
const failures = [split.failure, events.failure].filter((text) => text !== undefined);
|
|
200
|
-
if (failures.some((text) => /no server running|error connecting/u.test(text!)))
|
|
201
|
-
return "no-server";
|
|
202
|
-
const refused = (answer: { failure?: string }, command: string) =>
|
|
203
|
-
answer.failure !== undefined && UNKNOWN(command).test(answer.failure);
|
|
204
|
-
if (refused(split, "tmux-ide-resize-split")) {
|
|
205
|
-
if (refused(events, "tmux-ide-events")) return "stock";
|
|
206
|
-
// The journal answers: a tmux-ide tmux built before the split command.
|
|
207
|
-
if (events.output !== undefined) return "older";
|
|
208
|
-
return "unknown";
|
|
209
|
-
}
|
|
210
|
-
if (split.output !== undefined && events.output !== undefined) {
|
|
211
|
-
try {
|
|
212
|
-
return nativeSplitCapability(split.output) ? "full" : "partial";
|
|
213
|
-
} catch {
|
|
214
|
-
return "partial";
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
return failures.length === 2 ? "unknown" : "partial";
|
|
218
|
-
}
|
|
219
|
-
|
|
220
185
|
/** Reads the server a session would use. With none running, a throwaway private
|
|
221
186
|
* server shows what the resolved binary would start. */
|
|
222
187
|
export function tmuxFeaturesRow(probeServer: TmuxProbe, probeBinary: TmuxProbe): CheckResult {
|
|
223
188
|
let answer = nativeCommands(probeServer);
|
|
224
|
-
|
|
189
|
+
const running = answer !== "no-server";
|
|
190
|
+
if (!running) answer = nativeCommands(probeBinary);
|
|
191
|
+
// Only a running server can be moved; the command restarts it and restores its sessions.
|
|
192
|
+
const upgrade = running
|
|
193
|
+
? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux"
|
|
194
|
+
: "";
|
|
225
195
|
const details: Record<NativeAnswer, string> = {
|
|
226
196
|
full: "bundled tmux: full features",
|
|
227
|
-
stock:
|
|
228
|
-
older:
|
|
229
|
-
"older tmux-ide tmux: reduced features (restart it with tmux-ide's own tmux for every feature; that ends its sessions)",
|
|
197
|
+
stock: `stock tmux: reduced features${upgrade}`,
|
|
198
|
+
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
230
199
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
231
200
|
"no-server": "could not read the tmux server's features",
|
|
232
201
|
unknown: "could not read the tmux server's features",
|
|
@@ -239,6 +208,108 @@ export function tmuxFeaturesRow(probeServer: TmuxProbe, probeBinary: TmuxProbe):
|
|
|
239
208
|
};
|
|
240
209
|
}
|
|
241
210
|
|
|
211
|
+
/**
|
|
212
|
+
* PURE — what a plain `tmux` typed in a shell runs. Informational: when it is
|
|
213
|
+
* not tmux-ide's own tmux and it starts the server, features drop (#766).
|
|
214
|
+
*/
|
|
215
|
+
export function plainTmuxRow(pathTmux: string | null, bundled: string | null): CheckResult {
|
|
216
|
+
const label = "plain `tmux` in your shell";
|
|
217
|
+
if (!pathTmux)
|
|
218
|
+
return {
|
|
219
|
+
label,
|
|
220
|
+
pass: true,
|
|
221
|
+
detail: "not on PATH (tmux-ide uses its own tmux)",
|
|
222
|
+
optional: true,
|
|
223
|
+
};
|
|
224
|
+
if (bundled && pathTmux === bundled)
|
|
225
|
+
return { label, pass: true, detail: `tmux-ide's own tmux (${pathTmux})`, optional: true };
|
|
226
|
+
return {
|
|
227
|
+
label,
|
|
228
|
+
pass: true,
|
|
229
|
+
detail: `${pathTmux}; if it starts the server, features drop (see docs: tmux upgrade)`,
|
|
230
|
+
optional: true,
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* PURE — is the crash snapshot fresh enough to restore from? It fails when it
|
|
238
|
+
* is missing a live session, or is over a day old while sessions run. Only the
|
|
239
|
+
* chrome updater writes it, and that runs only while a session is adopted.
|
|
240
|
+
*/
|
|
241
|
+
export function snapshotRow(
|
|
242
|
+
snapshot: { savedAt: string; sessions: readonly { name: string }[] } | null,
|
|
243
|
+
liveSessions: readonly string[] | null,
|
|
244
|
+
nowMs: number,
|
|
245
|
+
): CheckResult {
|
|
246
|
+
const label = "crash snapshot (restore)";
|
|
247
|
+
const hint =
|
|
248
|
+
"Only the chrome updater writes it, while a session is adopted: `tmux-ide adopt --all` starts it";
|
|
249
|
+
if (!snapshot) {
|
|
250
|
+
return liveSessions?.length
|
|
251
|
+
? { label, pass: false, detail: `none yet. ${hint}`, optional: true }
|
|
252
|
+
: { label, pass: true, detail: "none yet (no sessions running)", optional: true };
|
|
253
|
+
}
|
|
254
|
+
const ageMs = nowMs - Date.parse(snapshot.savedAt);
|
|
255
|
+
const age =
|
|
256
|
+
ageMs >= DAY_MS
|
|
257
|
+
? `${Math.floor(ageMs / DAY_MS)} days old`
|
|
258
|
+
: `${Math.max(0, Math.round(ageMs / 60_000))} min old`;
|
|
259
|
+
const saved = new Set(snapshot.sessions.map((session) => session.name));
|
|
260
|
+
const missing = (liveSessions ?? []).filter((name) => !saved.has(name));
|
|
261
|
+
if (missing.length)
|
|
262
|
+
return {
|
|
263
|
+
label,
|
|
264
|
+
pass: false,
|
|
265
|
+
detail: `${age}; misses ${missing.length} running session${missing.length === 1 ? "" : "s"} (${missing.slice(0, 5).join(", ")}${missing.length > 5 ? ", …" : ""}). ${hint}`,
|
|
266
|
+
optional: true,
|
|
267
|
+
};
|
|
268
|
+
return { label, pass: true, detail: `${age}, covers every running session`, optional: true };
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
function firstOnPath(name: string): string | null {
|
|
272
|
+
for (const directory of (process.env.PATH ?? "").split(delimiter)) {
|
|
273
|
+
if (!directory) continue;
|
|
274
|
+
const candidate = join(directory, name);
|
|
275
|
+
try {
|
|
276
|
+
accessSync(candidate, constants.X_OK);
|
|
277
|
+
return realpathSync(candidate);
|
|
278
|
+
} catch {
|
|
279
|
+
// Try the next PATH entry.
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function safeBundledTmux(): string | null {
|
|
286
|
+
try {
|
|
287
|
+
const bundled = resolveBundledTmux();
|
|
288
|
+
return bundled ? realpathSync(bundled) : null;
|
|
289
|
+
} catch {
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/** The sessions the snapshot should hold, on the server doctor reads; null when unreadable. */
|
|
295
|
+
function liveListableSessions(): string[] | null {
|
|
296
|
+
try {
|
|
297
|
+
const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
|
|
298
|
+
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
299
|
+
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
300
|
+
return execFileSync(
|
|
301
|
+
resolveTmuxExecutable(),
|
|
302
|
+
[...server, "list-sessions", "-F", "#{session_name}"],
|
|
303
|
+
{ encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3000 },
|
|
304
|
+
)
|
|
305
|
+
.split("\n")
|
|
306
|
+
.filter((name) => name && isListableSession(name));
|
|
307
|
+
} catch (error) {
|
|
308
|
+
const text = String((error as { stderr?: unknown }).stderr ?? "");
|
|
309
|
+
return /no server running|error connecting/u.test(text) ? [] : null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
242
313
|
function runTmuxFeatureProbes(executable: string): CheckResult {
|
|
243
314
|
const run =
|
|
244
315
|
(prefix: readonly string[]): TmuxProbe =>
|
|
@@ -279,6 +350,50 @@ function runTmuxFeatureProbes(executable: string): CheckResult {
|
|
|
279
350
|
}
|
|
280
351
|
}
|
|
281
352
|
|
|
353
|
+
/**
|
|
354
|
+
* PURE — which tmux server the daemon uses, and whether this shell's `tmux`
|
|
355
|
+
* means the same one.
|
|
356
|
+
*
|
|
357
|
+
* A daemon started outside tmux (launchd, systemd, `--headless` from a plain
|
|
358
|
+
* shell) addresses the socket named "default" and gives its tmux clients a
|
|
359
|
+
* scrubbed environment, so it always looks in /tmp/tmux-<uid>/ and ignores
|
|
360
|
+
* TMUX_TMPDIR. A shell that exports TMUX_TMPDIR, or sits in a tmux started
|
|
361
|
+
* with -S or -L, is then on a server that daemon cannot see. The explicit
|
|
362
|
+
* TMUX_IDE_TMUX_SOCKET_PATH / TMUX_IDE_TMUX_SOCKET_NAME settings apply to both.
|
|
363
|
+
*/
|
|
364
|
+
export function tmuxServerSocketRow(environment: NodeJS.ProcessEnv, uid: number): CheckResult {
|
|
365
|
+
const defaultDirectory = join("/tmp", `tmux-${String(uid)}`);
|
|
366
|
+
const explicitPath = environment[TMUX_SOCKET_PATH_ENV];
|
|
367
|
+
const explicitName = environment.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
368
|
+
const daemonSocket = explicitPath
|
|
369
|
+
? explicitPath
|
|
370
|
+
: join(defaultDirectory, explicitName ? explicitName : "default");
|
|
371
|
+
const insideTmux = /^(.*),[0-9]+,[0-9]+$/u.exec(environment.TMUX ?? "")?.[1];
|
|
372
|
+
const shellSocket =
|
|
373
|
+
insideTmux ?? join(environment.TMUX_TMPDIR || "/tmp", `tmux-${String(uid)}`, "default");
|
|
374
|
+
const same = (left: string, right: string): boolean =>
|
|
375
|
+
left.replace(/^\/private\/tmp\//u, "/tmp/") === right.replace(/^\/private\/tmp\//u, "/tmp/");
|
|
376
|
+
if (explicitPath || explicitName || same(shellSocket, daemonSocket))
|
|
377
|
+
return {
|
|
378
|
+
label: "tmux server",
|
|
379
|
+
pass: true,
|
|
380
|
+
detail: `the daemon uses ${daemonSocket}${explicitPath || explicitName ? " (set explicitly)" : ""}`,
|
|
381
|
+
optional: true,
|
|
382
|
+
};
|
|
383
|
+
const why = insideTmux
|
|
384
|
+
? "this shell is inside a tmux on another socket"
|
|
385
|
+
: "TMUX_TMPDIR is set, and the daemon ignores it";
|
|
386
|
+
return {
|
|
387
|
+
label: "tmux server",
|
|
388
|
+
pass: false,
|
|
389
|
+
detail:
|
|
390
|
+
`this shell's tmux uses ${shellSocket}, a background daemon uses ${daemonSocket} (${why}): ` +
|
|
391
|
+
`it will not see this shell's sessions. Set ${TMUX_SOCKET_PATH_ENV}=${shellSocket} in the daemon's environment` +
|
|
392
|
+
(insideTmux ? "" : ", or unset TMUX_TMPDIR"),
|
|
393
|
+
optional: true,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
|
|
282
397
|
export function nodeVersionRow(version: string): CheckResult {
|
|
283
398
|
const major = Number(version.split(".")[0]);
|
|
284
399
|
const pass = Number.isInteger(major) && major >= 20;
|
|
@@ -335,6 +450,8 @@ export async function doctor({
|
|
|
335
450
|
} catch {
|
|
336
451
|
// The tmux version row above already reports a missing executable.
|
|
337
452
|
}
|
|
453
|
+
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
454
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
338
455
|
|
|
339
456
|
checks.push(nodeVersionRow(process.versions.node));
|
|
340
457
|
|
|
@@ -479,6 +596,8 @@ export async function doctor({
|
|
|
479
596
|
),
|
|
480
597
|
);
|
|
481
598
|
|
|
599
|
+
checks.push(tmuxServerSocketRow(process.env, process.getuid?.() ?? 0));
|
|
600
|
+
|
|
482
601
|
// Canonical daemon identity + log provenance (credential-free), so a triage
|
|
483
602
|
// never chases a stale, manually redirected log file.
|
|
484
603
|
checks.push(
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { withBundledTmuxResources } from "./bundled-tmux.ts";
|
|
2
2
|
import { execFile } from "node:child_process";
|
|
3
|
-
|
|
3
|
+
export const BOUNDED_TMUX_KILL_GRACE_MS = 250;
|
|
4
|
+
/**
|
|
5
|
+
* Read-only child ownership: TERM at deadline/abort, KILL after grace; settle
|
|
6
|
+
* after close. "close" needs every holder of the pipes to let go, so once the
|
|
7
|
+
* child has been killed the read settles one more grace later regardless: a
|
|
8
|
+
* wrapper's lingering grandchild must not turn a deadline into a hang (#839).
|
|
9
|
+
*/
|
|
4
10
|
export function boundedTmuxRead(
|
|
5
11
|
executable: string,
|
|
6
12
|
args: readonly string[],
|
|
@@ -30,11 +36,31 @@ export function boundedTmuxRead(
|
|
|
30
36
|
output = stdout;
|
|
31
37
|
},
|
|
32
38
|
);
|
|
39
|
+
let abandon: ReturnType<typeof setTimeout> | null = null;
|
|
40
|
+
let settled = false;
|
|
41
|
+
const settle = () => {
|
|
42
|
+
if (settled) return;
|
|
43
|
+
settled = true;
|
|
44
|
+
clearTimeout(deadline);
|
|
45
|
+
if (escalation) clearTimeout(escalation);
|
|
46
|
+
if (abandon) clearTimeout(abandon);
|
|
47
|
+
options.signal?.removeEventListener("abort", stop);
|
|
48
|
+
if (failure) reject(failure);
|
|
49
|
+
else resolve(output);
|
|
50
|
+
};
|
|
33
51
|
const stop = () => {
|
|
34
52
|
failure ??= new Error("Tmux read cancelled or deadline exceeded");
|
|
35
53
|
if (escalation) return;
|
|
36
54
|
child.kill("SIGTERM");
|
|
37
|
-
escalation = setTimeout(() =>
|
|
55
|
+
escalation = setTimeout(() => {
|
|
56
|
+
child.kill("SIGKILL");
|
|
57
|
+
abandon = setTimeout(() => {
|
|
58
|
+
child.stdout?.destroy();
|
|
59
|
+
child.stderr?.destroy();
|
|
60
|
+
settle();
|
|
61
|
+
}, BOUNDED_TMUX_KILL_GRACE_MS);
|
|
62
|
+
abandon.unref?.();
|
|
63
|
+
}, BOUNDED_TMUX_KILL_GRACE_MS);
|
|
38
64
|
escalation.unref?.();
|
|
39
65
|
};
|
|
40
66
|
const deadline = setTimeout(stop, options.timeoutMs ?? 5000);
|
|
@@ -43,13 +69,7 @@ export function boundedTmuxRead(
|
|
|
43
69
|
child.once("error", (error) => {
|
|
44
70
|
failure ??= error;
|
|
45
71
|
});
|
|
46
|
-
child.once("close",
|
|
47
|
-
clearTimeout(deadline);
|
|
48
|
-
if (escalation) clearTimeout(escalation);
|
|
49
|
-
options.signal?.removeEventListener("abort", stop);
|
|
50
|
-
if (failure) reject(failure);
|
|
51
|
-
else resolve(output);
|
|
52
|
-
});
|
|
72
|
+
child.once("close", settle);
|
|
53
73
|
if (options.signal?.aborted) stop();
|
|
54
74
|
});
|
|
55
75
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The argv prefix that runs this tmux-ide's CLI: the bundled `bin/cli.js`,
|
|
6
|
+
* or `bin/cli.ts` under the runtime's loader flags when run from source.
|
|
7
|
+
* `here` must sit two directories below `packages/daemon/src`'s parent.
|
|
8
|
+
*/
|
|
9
|
+
export function resolveCliCommand(
|
|
10
|
+
here: string = fileURLToPath(import.meta.url),
|
|
11
|
+
runtime: { execPath: string; execArgv: readonly string[] } = process,
|
|
12
|
+
): string[] {
|
|
13
|
+
if (basename(here) === "cli.js") return [runtime.execPath, here];
|
|
14
|
+
const cli = join(dirname(here), "..", "..", "..", "..", "bin", `cli${extname(here)}`);
|
|
15
|
+
return [runtime.execPath, ...runtime.execArgv, cli];
|
|
16
|
+
}
|