tmux-ide 2.9.21 → 2.9.22
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 +5282 -3386
- package/package.json +1 -1
- package/packages/contracts/src/index.ts +1 -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/daemon/dist/command-center/tmux-server-reader.js +41 -0
- package/packages/daemon/dist/command-center/tmux-servers.js +6 -0
- package/packages/daemon/dist/doctor.js +106 -43
- package/packages/daemon/dist/lib/cli-command.js +13 -0
- package/packages/daemon/dist/lib/daemon-embed.js +15 -0
- 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-pane-reader.js +105 -0
- package/packages/daemon/dist/lib/tmux-server-features.js +38 -0
- package/packages/daemon/dist/lib/tmux-server-owner.js +9 -0
- 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/daemon-plugins.js +2 -10
- package/packages/daemon/dist/restore.js +57 -40
- package/packages/daemon/dist/terminal/mirror/session-channel.js +4 -1
- package/packages/daemon/dist/terminal/pane-stream/pane-stream-websocket.js +12 -3
- package/packages/daemon/dist/terminal/protocol/reader-option.js +66 -0
- package/packages/daemon/dist/terminal/protocol/session-descriptor-discovery.js +7 -2
- 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/tmux-server-reader.ts +62 -0
- package/packages/daemon/src/command-center/tmux-servers.ts +6 -0
- package/packages/daemon/src/doctor.ts +118 -45
- package/packages/daemon/src/lib/cli-command.ts +16 -0
- package/packages/daemon/src/lib/daemon-embed.ts +17 -0
- 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-pane-reader.ts +144 -0
- package/packages/daemon/src/lib/tmux-server-features.ts +43 -0
- package/packages/daemon/src/lib/tmux-server-owner.ts +9 -0
- package/packages/daemon/src/open-browser.ts +59 -18
- package/packages/daemon/src/open-reader.ts +148 -0
- package/packages/daemon/src/plugins/daemon-plugins.ts +2 -12
- package/packages/daemon/src/restore.ts +80 -44
- package/packages/daemon/src/terminal/mirror/events.ts +2 -0
- package/packages/daemon/src/terminal/mirror/session-channel.ts +6 -1
- package/packages/daemon/src/terminal/pane-stream/pane-stream-websocket.ts +15 -2
- package/packages/daemon/src/terminal/protocol/reader-option.ts +77 -0
- package/packages/daemon/src/terminal/protocol/session-descriptor-discovery.ts +10 -1
- 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/tmux-bridge/src/runner.ts +3 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { browserIcon } from "./browser-icon.ts";
|
|
2
|
+
import { readerOption, type ReaderOption } from "./reader-option.ts";
|
|
2
3
|
|
|
3
4
|
export interface SessionPaneDescriptor {
|
|
4
5
|
browserIcon?: string | null;
|
|
6
|
+
/** A live `tmux-ide open file.md` reader; the path stays daemon-side. */
|
|
7
|
+
reader?: ReaderOption | null;
|
|
5
8
|
nativePaneBirthId?: string | null;
|
|
6
9
|
sessionName: string;
|
|
7
10
|
runtimePaneId: string;
|
|
@@ -56,6 +59,9 @@ export const SESSION_PANE_DESCRIPTOR_FORMAT = [
|
|
|
56
59
|
"#{pane_birth_id}",
|
|
57
60
|
"#{qa:@tmux_ide_name_source}",
|
|
58
61
|
"#{qa:@tmux_ide_browser_icon}",
|
|
62
|
+
"#{qa:@tmux_ide_reader}",
|
|
63
|
+
// The reader option belongs to the pane only when its own process set it.
|
|
64
|
+
"#{pane_pid}",
|
|
59
65
|
].join("\t");
|
|
60
66
|
|
|
61
67
|
/** Decode the escapes emitted by tmux's `qa` format modifier. */
|
|
@@ -135,7 +141,7 @@ export function parseSessionPaneDescriptorReply(
|
|
|
135
141
|
continue;
|
|
136
142
|
}
|
|
137
143
|
const encoded = utf8Line.split("\t");
|
|
138
|
-
if (encoded.length
|
|
144
|
+
if (encoded.length < 21 || encoded.length > 25) continue;
|
|
139
145
|
const [
|
|
140
146
|
runtimePaneId = "",
|
|
141
147
|
semanticPaneId = "",
|
|
@@ -160,6 +166,8 @@ export function parseSessionPaneDescriptorReply(
|
|
|
160
166
|
nativePaneBirthId = "",
|
|
161
167
|
nameSource = "",
|
|
162
168
|
browserIconRaw = "",
|
|
169
|
+
readerRaw = "",
|
|
170
|
+
panePidRaw = "",
|
|
163
171
|
] = encoded.map(decodeTmuxArgument);
|
|
164
172
|
if (!/^%(?:0|[1-9][0-9]*)$/u.test(runtimePaneId) || runtimePaneId.length > 32) continue;
|
|
165
173
|
if (!/^\$(?:0|[1-9][0-9]*)$/u.test(runtimeSessionId) || runtimeSessionId.length > 32) continue;
|
|
@@ -200,6 +208,7 @@ export function parseSessionPaneDescriptorReply(
|
|
|
200
208
|
}
|
|
201
209
|
descriptors.push({
|
|
202
210
|
browserIcon: browserIcon(browserIconRaw),
|
|
211
|
+
reader: readerOption(readerRaw, panePidRaw),
|
|
203
212
|
sessionName,
|
|
204
213
|
runtimePaneId,
|
|
205
214
|
runtimeSessionId,
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `tmux-ide servers upgrade` (#766): flags, the `--ssh` hand-off, the detached
|
|
3
|
+
* worker's `--continue`, and the exit code. The steps are in ./run.ts.
|
|
4
|
+
*/
|
|
5
|
+
import { spawnSync } from "node:child_process";
|
|
6
|
+
import { readFileSync } from "node:fs";
|
|
7
|
+
import { dirname, join } from "node:path";
|
|
8
|
+
import { SavedMachineSchema } from "@tmux-ide/contracts";
|
|
9
|
+
import { IdeError } from "../lib/errors.ts";
|
|
10
|
+
import { remoteTmuxIdeArgsCommand } from "../lib/remote-tmux-command.ts";
|
|
11
|
+
import { createUpgradeIo, parseWorkerState, writeWorkerResult, type UpgradeTarget } from "./io.ts";
|
|
12
|
+
import {
|
|
13
|
+
finishUpgrade,
|
|
14
|
+
retryCommand,
|
|
15
|
+
upgradeServer,
|
|
16
|
+
type UpgradeOptions,
|
|
17
|
+
type UpgradeResult,
|
|
18
|
+
} from "./run.ts";
|
|
19
|
+
|
|
20
|
+
export interface UpgradeCliOptions extends UpgradeOptions, UpgradeTarget {
|
|
21
|
+
ssh?: string;
|
|
22
|
+
/** The detached worker: finish the upgrade described in this file. */
|
|
23
|
+
continueFrom?: string;
|
|
24
|
+
cliEntry: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** The flags a remote run gets: the same choices, never the local socket defaults. */
|
|
28
|
+
export function forwardedUpgradeArgs(options: UpgradeCliOptions): string[] {
|
|
29
|
+
const args: string[] = [];
|
|
30
|
+
if (options.yes) args.push("--yes");
|
|
31
|
+
if (options.endRunningAgents) args.push("--end-running-agents");
|
|
32
|
+
if (!options.resumeAgents) args.push("--no-resume-agents");
|
|
33
|
+
if (options.dryRun) args.push("--dry-run");
|
|
34
|
+
if (options.json) args.push("--json");
|
|
35
|
+
if (options.socketPath) args.push("--socket-path", options.socketPath);
|
|
36
|
+
if (options.socketName) args.push("--socket-name", options.socketName);
|
|
37
|
+
return args;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const EXIT: Record<UpgradeResult["status"], number> = {
|
|
41
|
+
"already-full": 0,
|
|
42
|
+
preview: 0,
|
|
43
|
+
declined: 0,
|
|
44
|
+
"handed-off": 0,
|
|
45
|
+
upgraded: 0,
|
|
46
|
+
refused: 1,
|
|
47
|
+
failed: 1,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
function report(result: UpgradeResult, json: boolean): void {
|
|
51
|
+
if (json) {
|
|
52
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
// The plan was already printed before the question; print it here only for a preview.
|
|
56
|
+
console.log(
|
|
57
|
+
result.status === "preview"
|
|
58
|
+
? `${result.message}\n\nDry run: nothing was stopped.`
|
|
59
|
+
: result.message,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export async function runUpgradeCli(options: UpgradeCliOptions): Promise<void> {
|
|
64
|
+
if (options.socketPath && options.socketName)
|
|
65
|
+
throw new IdeError("Pass --socket-path or --socket-name, not both.", {
|
|
66
|
+
code: "USAGE",
|
|
67
|
+
exitCode: 2,
|
|
68
|
+
});
|
|
69
|
+
if (options.ssh !== undefined) {
|
|
70
|
+
SavedMachineSchema.shape.sshTarget.parse(options.ssh);
|
|
71
|
+
// The remote runs the same command against its own server, bundle and
|
|
72
|
+
// hostname; its prompt answers here through the terminal.
|
|
73
|
+
const child = spawnSync(
|
|
74
|
+
"ssh",
|
|
75
|
+
[
|
|
76
|
+
...(options.json ? ["-T"] : ["-t"]),
|
|
77
|
+
"--",
|
|
78
|
+
options.ssh,
|
|
79
|
+
remoteTmuxIdeArgsCommand(["servers", "upgrade", ...forwardedUpgradeArgs(options)]),
|
|
80
|
+
],
|
|
81
|
+
{ stdio: "inherit" },
|
|
82
|
+
);
|
|
83
|
+
if (child.error) throw new IdeError("Could not start ssh.", { code: "SSH", exitCode: 1 });
|
|
84
|
+
if (child.status !== 0) process.exitCode = child.status ?? 1;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (options.continueFrom !== undefined) {
|
|
88
|
+
const work = parseWorkerState(readFileSync(options.continueFrom, "utf8"));
|
|
89
|
+
const io = createUpgradeIo({
|
|
90
|
+
target: { socketPath: work.server.socketPath },
|
|
91
|
+
cliEntry: options.cliEntry,
|
|
92
|
+
json: false,
|
|
93
|
+
});
|
|
94
|
+
// Nothing the foreground's terminal does may stop the worker mid-restore.
|
|
95
|
+
for (const signal of ["SIGHUP", "SIGINT", "SIGPIPE"] as const) process.on(signal, () => {});
|
|
96
|
+
let result: UpgradeResult;
|
|
97
|
+
try {
|
|
98
|
+
result = await finishUpgrade(io, work);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
result = {
|
|
101
|
+
status: "failed",
|
|
102
|
+
message: `${(error as Error).message} If the sessions are missing, run: ${retryCommand(work.snapshotPath, work.resumeAgents)}`,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
console.log(`${new Date().toISOString()} ${result.status}: ${result.message}`);
|
|
106
|
+
writeWorkerResult(join(dirname(options.continueFrom), "result.json"), result);
|
|
107
|
+
process.exitCode = EXIT[result.status];
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const io = createUpgradeIo({
|
|
111
|
+
target: { socketPath: options.socketPath, socketName: options.socketName },
|
|
112
|
+
cliEntry: options.cliEntry,
|
|
113
|
+
json: options.json,
|
|
114
|
+
});
|
|
115
|
+
const result = await upgradeServer(io, options);
|
|
116
|
+
report(result, options.json);
|
|
117
|
+
process.exitCode = EXIT[result.status];
|
|
118
|
+
}
|