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
package/package.json
CHANGED
|
@@ -119,6 +119,7 @@ export * from "./visual-terminal-palette.ts";
|
|
|
119
119
|
export * from "./window-split-layout.ts";
|
|
120
120
|
export * from "./pane-editor-context.ts";
|
|
121
121
|
export * from "./native-browser.ts";
|
|
122
|
+
export * from "./pane-reader.ts";
|
|
122
123
|
|
|
123
124
|
export * from "./tmux-agent-open.ts";
|
|
124
125
|
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PaneEditorContextTargetSchemaZ } from "./pane-editor-context.ts";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The native Markdown reader (card #756). The daemon serves only the file named
|
|
6
|
+
* by the pane's `@tmux_ide_reader` option; the app never names a path. Bytes go
|
|
7
|
+
* out base64-encoded in pages so every response stays under the client's 1 MiB
|
|
8
|
+
* read limit; the app decodes UTF-8 itself.
|
|
9
|
+
*/
|
|
10
|
+
export const PANE_READER_PAGE_BYTES = 512 * 1024;
|
|
11
|
+
export const PANE_READER_MAX_BYTES = 4 * 1024 * 1024;
|
|
12
|
+
export const PANE_READER_ASSET_MAX_BYTES = 10 * 1024 * 1024;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* C0 controls, DEL and C1 controls (U+0080 to U+009F): Unicode's control
|
|
16
|
+
* characters, the same rule the app applies to a reader's name and folder, so
|
|
17
|
+
* nothing the daemon sends is refused there. Checked by code point so the
|
|
18
|
+
* rule needs no control-character regex.
|
|
19
|
+
*/
|
|
20
|
+
export function hasControlCharacter(value: string): boolean {
|
|
21
|
+
for (const character of value) {
|
|
22
|
+
const code = character.codePointAt(0)!;
|
|
23
|
+
if (code < 32 || (code >= 127 && code <= 159)) return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const PaneReaderRevisionSchemaZ = z.string().regex(/^[0-9a-f]{32}$/u);
|
|
29
|
+
export const PaneReaderPageSchemaZ = z
|
|
30
|
+
.object({
|
|
31
|
+
revision: PaneReaderRevisionSchemaZ,
|
|
32
|
+
offset: z.number().int().nonnegative().max(PANE_READER_ASSET_MAX_BYTES),
|
|
33
|
+
})
|
|
34
|
+
.strict();
|
|
35
|
+
export type PaneReaderPage = z.infer<typeof PaneReaderPageSchemaZ>;
|
|
36
|
+
|
|
37
|
+
export const PaneReaderRequestSchemaZ = z
|
|
38
|
+
.object({
|
|
39
|
+
target: PaneEditorContextTargetSchemaZ,
|
|
40
|
+
have: PaneReaderRevisionSchemaZ.nullable(),
|
|
41
|
+
page: PaneReaderPageSchemaZ.nullable(),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
export type PaneReaderRequest = z.infer<typeof PaneReaderRequestSchemaZ>;
|
|
45
|
+
|
|
46
|
+
export const PaneReaderAssetRequestSchemaZ = z
|
|
47
|
+
.object({
|
|
48
|
+
target: PaneEditorContextTargetSchemaZ,
|
|
49
|
+
src: z.string().min(1).max(2048),
|
|
50
|
+
page: PaneReaderPageSchemaZ.nullable(),
|
|
51
|
+
})
|
|
52
|
+
.strict();
|
|
53
|
+
export type PaneReaderAssetRequest = z.infer<typeof PaneReaderAssetRequestSchemaZ>;
|
|
54
|
+
|
|
55
|
+
const NameSchema = z
|
|
56
|
+
.string()
|
|
57
|
+
.min(1)
|
|
58
|
+
.max(255)
|
|
59
|
+
.refine((value) => !hasControlCharacter(value) && !value.includes("/"), "Expected a file name");
|
|
60
|
+
const FolderSchema = z
|
|
61
|
+
.string()
|
|
62
|
+
.max(255)
|
|
63
|
+
.refine((value) => !hasControlCharacter(value) && !value.includes("/"), "Expected a folder name");
|
|
64
|
+
const Base64Schema = z.string().regex(/^[A-Za-z0-9+/]*={0,2}$/u);
|
|
65
|
+
const SizeSchema = z.number().int().nonnegative();
|
|
66
|
+
const Named = { version: z.literal(1), name: NameSchema, folder: FolderSchema };
|
|
67
|
+
|
|
68
|
+
export const PaneReaderResponseSchemaZ = z.discriminatedUnion("state", [
|
|
69
|
+
z
|
|
70
|
+
.object({ ...Named, state: z.literal("unchanged"), revision: PaneReaderRevisionSchemaZ })
|
|
71
|
+
.strict(),
|
|
72
|
+
z
|
|
73
|
+
.object({
|
|
74
|
+
...Named,
|
|
75
|
+
state: z.literal("ok"),
|
|
76
|
+
revision: PaneReaderRevisionSchemaZ,
|
|
77
|
+
size: SizeSchema.max(PANE_READER_MAX_BYTES),
|
|
78
|
+
offset: SizeSchema,
|
|
79
|
+
chunk: Base64Schema,
|
|
80
|
+
})
|
|
81
|
+
.strict(),
|
|
82
|
+
z.object({ ...Named, state: z.literal("changed") }).strict(),
|
|
83
|
+
z
|
|
84
|
+
.object({
|
|
85
|
+
...Named,
|
|
86
|
+
state: z.literal("too_large"),
|
|
87
|
+
revision: PaneReaderRevisionSchemaZ,
|
|
88
|
+
size: SizeSchema,
|
|
89
|
+
})
|
|
90
|
+
.strict(),
|
|
91
|
+
z.object({ ...Named, state: z.literal("missing") }).strict(),
|
|
92
|
+
]);
|
|
93
|
+
export type PaneReaderResponse = z.infer<typeof PaneReaderResponseSchemaZ>;
|
|
94
|
+
|
|
95
|
+
export const PaneReaderAssetMimeSchemaZ = z.enum([
|
|
96
|
+
"image/png",
|
|
97
|
+
"image/jpeg",
|
|
98
|
+
"image/gif",
|
|
99
|
+
"image/webp",
|
|
100
|
+
"image/svg+xml",
|
|
101
|
+
]);
|
|
102
|
+
export const PaneReaderAssetResponseSchemaZ = z.discriminatedUnion("state", [
|
|
103
|
+
z
|
|
104
|
+
.object({
|
|
105
|
+
version: z.literal(1),
|
|
106
|
+
state: z.literal("ok"),
|
|
107
|
+
mime: PaneReaderAssetMimeSchemaZ,
|
|
108
|
+
revision: PaneReaderRevisionSchemaZ,
|
|
109
|
+
size: SizeSchema.max(PANE_READER_ASSET_MAX_BYTES),
|
|
110
|
+
offset: SizeSchema,
|
|
111
|
+
chunk: Base64Schema,
|
|
112
|
+
})
|
|
113
|
+
.strict(),
|
|
114
|
+
z
|
|
115
|
+
.object({
|
|
116
|
+
version: z.literal(1),
|
|
117
|
+
state: z.enum(["changed", "refused", "missing", "too_large"]),
|
|
118
|
+
})
|
|
119
|
+
.strict(),
|
|
120
|
+
]);
|
|
121
|
+
export type PaneReaderAssetResponse = z.infer<typeof PaneReaderAssetResponseSchemaZ>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { hasControlCharacter } from "./pane-reader.ts";
|
|
1
2
|
import {
|
|
2
3
|
TerminalSurfaceWatchSchemaZ,
|
|
3
4
|
TerminalSurfaceReceiverSchemaZ,
|
|
@@ -251,6 +252,11 @@ export const PANE_STREAM_INPUT_LIFETIME_CAPABILITY_VERSION = 105;
|
|
|
251
252
|
export const PANE_STREAM_INPUT_BYTES_CAPABILITY_VERSION = 106;
|
|
252
253
|
/** Bundles zlib capability 102 and optional browser icon metadata; fixed 16×16 RGBA hex, empty means browser fallback. */
|
|
253
254
|
export const PANE_STREAM_BROWSER_ICON_CAPABILITY_VERSION = 117;
|
|
255
|
+
/**
|
|
256
|
+
* Bundles 117 (browser icons with zlib 102) and adds `reader` pane metadata.
|
|
257
|
+
* Offered in place of 117 because the offer array has nine slots.
|
|
258
|
+
*/
|
|
259
|
+
export const PANE_STREAM_READER_CAPABILITY_VERSION = 118;
|
|
254
260
|
export const PaneStreamInputLifetimeSchemaZ = z
|
|
255
261
|
.object({
|
|
256
262
|
generation: z.string().min(1).max(256),
|
|
@@ -565,6 +571,18 @@ export const PaneStreamLayoutFrameSchemaZ = z
|
|
|
565
571
|
.regex(/^(?:[0-9a-f]{2048})?$/u)
|
|
566
572
|
.nullable()
|
|
567
573
|
.optional(),
|
|
574
|
+
/** Only with capability 118: the Markdown reader's file name, never its path. */
|
|
575
|
+
reader: z
|
|
576
|
+
.object({
|
|
577
|
+
name: z
|
|
578
|
+
.string()
|
|
579
|
+
.min(1)
|
|
580
|
+
.max(255)
|
|
581
|
+
.refine((value) => !hasControlCharacter(value) && !value.includes("/")),
|
|
582
|
+
})
|
|
583
|
+
.strict()
|
|
584
|
+
.nullable()
|
|
585
|
+
.optional(),
|
|
568
586
|
left: CellCoordinateSchemaZ,
|
|
569
587
|
top: CellCoordinateSchemaZ,
|
|
570
588
|
width: GridCellSchemaZ,
|
|
@@ -195,6 +195,51 @@ const palettes = {
|
|
|
195
195
|
selected: "#cdb796",
|
|
196
196
|
selectedText: "#211810",
|
|
197
197
|
},
|
|
198
|
+
// tmux-ide's own pair (#746): warm and low in contrast, with one accent.
|
|
199
|
+
// Warning is the accent, so "needs input" (ANSI yellow) is the only accented
|
|
200
|
+
// state; link and info keep the terminal's blue and cyan distinct.
|
|
201
|
+
linen: {
|
|
202
|
+
name: "Linen",
|
|
203
|
+
bg: "#f7f4ee",
|
|
204
|
+
panel: "#eeeae2",
|
|
205
|
+
border: "#e3ddd2",
|
|
206
|
+
borderFocused: "#984822",
|
|
207
|
+
text: "#2b2722",
|
|
208
|
+
textDim: "#625a4f",
|
|
209
|
+
textBright: "#17140f",
|
|
210
|
+
textMuted: "#8f8679",
|
|
211
|
+
positive: "#4f7034",
|
|
212
|
+
negative: "#a33a30",
|
|
213
|
+
neutral: "#8f8679",
|
|
214
|
+
warning: "#984822",
|
|
215
|
+
link: "#3b6587",
|
|
216
|
+
info: "#36706d",
|
|
217
|
+
cardBorder: "#e1dbcf",
|
|
218
|
+
header: "#e7e1d6",
|
|
219
|
+
selected: "#e3d9c8",
|
|
220
|
+
selectedText: "#2b2722",
|
|
221
|
+
},
|
|
222
|
+
"linen-dark": {
|
|
223
|
+
name: "Linen Dark",
|
|
224
|
+
bg: "#211f1b",
|
|
225
|
+
panel: "#1b1916",
|
|
226
|
+
border: "#36322c",
|
|
227
|
+
borderFocused: "#e0874f",
|
|
228
|
+
text: "#e9e3d8",
|
|
229
|
+
textDim: "#a39a8d",
|
|
230
|
+
textBright: "#fbf7f0",
|
|
231
|
+
textMuted: "#7d7569",
|
|
232
|
+
positive: "#a3b77a",
|
|
233
|
+
negative: "#e0705f",
|
|
234
|
+
neutral: "#7d7569",
|
|
235
|
+
warning: "#e0874f",
|
|
236
|
+
link: "#85a9c8",
|
|
237
|
+
info: "#8cbfb8",
|
|
238
|
+
cardBorder: "#3a362f",
|
|
239
|
+
header: "#2c2925",
|
|
240
|
+
selected: "#45403a",
|
|
241
|
+
selectedText: "#e9e3d8",
|
|
242
|
+
},
|
|
198
243
|
"github-light": {
|
|
199
244
|
name: "GitHub Light",
|
|
200
245
|
bg: "#ffffff",
|
|
@@ -472,7 +517,9 @@ export const VISUAL_THEME_PRESETS: readonly VisualThemeDocumentV1[] = Object.ent
|
|
|
472
517
|
secondary: color(p.textDim),
|
|
473
518
|
muted: color(p.textDim),
|
|
474
519
|
bright: color(p.textBright),
|
|
475
|
-
link
|
|
520
|
+
// A preset may name its own link and info hues (ANSI blue and cyan);
|
|
521
|
+
// otherwise both follow the focused border.
|
|
522
|
+
link: readable("link" in p ? p.link : p.borderFocused, p.panel),
|
|
476
523
|
},
|
|
477
524
|
borders: {
|
|
478
525
|
default: color(p.border),
|
|
@@ -484,7 +531,7 @@ export const VISUAL_THEME_PRESETS: readonly VisualThemeDocumentV1[] = Object.ent
|
|
|
484
531
|
},
|
|
485
532
|
statusTone: {
|
|
486
533
|
neutral: color(p.neutral),
|
|
487
|
-
info: color(p.borderFocused),
|
|
534
|
+
info: color("info" in p ? p.info : p.borderFocused),
|
|
488
535
|
warning: color(p.warning),
|
|
489
536
|
danger: color(p.negative),
|
|
490
537
|
success: color(p.positive),
|
|
@@ -494,6 +541,15 @@ export const VISUAL_THEME_PRESETS: readonly VisualThemeDocumentV1[] = Object.ent
|
|
|
494
541
|
};
|
|
495
542
|
},
|
|
496
543
|
);
|
|
544
|
+
/**
|
|
545
|
+
* The Mac app's pane card border, for the presets that name their own (#746).
|
|
546
|
+
* Every other preset keeps the app's default card border.
|
|
547
|
+
*/
|
|
548
|
+
export const VISUAL_THEME_CARD_BORDERS: Readonly<Record<string, string>> = Object.freeze(
|
|
549
|
+
Object.fromEntries(
|
|
550
|
+
Object.entries(palettes).flatMap(([id, p]) => ("cardBorder" in p ? [[id, p.cardBorder]] : [])),
|
|
551
|
+
),
|
|
552
|
+
);
|
|
497
553
|
export function findVisualThemePreset(id: unknown): VisualThemeDocumentV1 | undefined {
|
|
498
554
|
return typeof id === "string" ? VISUAL_THEME_PRESETS.find((p) => p.id === id) : undefined;
|
|
499
555
|
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PaneReaderAssetRequestSchemaZ, PaneReaderRequestSchemaZ, TmuxServerScopeSchemaZ, } from "@tmux-ide/contracts";
|
|
2
|
+
import { TmuxServerScopeError } from "../lib/tmux-server-owners.js";
|
|
3
|
+
/**
|
|
4
|
+
* The native Markdown reader's routes (card #756). Mount only below the
|
|
5
|
+
* owner-authenticated, no-store scoped router. Responses never carry a path,
|
|
6
|
+
* a file-system error or validation detail.
|
|
7
|
+
*/
|
|
8
|
+
export function mountTmuxServerReaderRoutes(app, options) {
|
|
9
|
+
const handle = (schema, kind) => async (c) => {
|
|
10
|
+
const scope = TmuxServerScopeSchemaZ.safeParse({
|
|
11
|
+
serverId: c.req.param("serverId"),
|
|
12
|
+
generation: c.req.param("generation"),
|
|
13
|
+
});
|
|
14
|
+
if (!scope.success)
|
|
15
|
+
return c.json({ error: { code: "invalid-request" } }, 400);
|
|
16
|
+
let request;
|
|
17
|
+
try {
|
|
18
|
+
request = schema.parse(await options.readBody(c.req.raw));
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return c.json({ error: { code: "invalid-request" } }, 400);
|
|
22
|
+
}
|
|
23
|
+
if (request.target.generation !== scope.data.generation)
|
|
24
|
+
return c.json({ error: { code: "stale-generation" } }, 409);
|
|
25
|
+
try {
|
|
26
|
+
c.req.raw.signal.throwIfAborted();
|
|
27
|
+
const response = await options.owners.withOwner(scope.data, (owner) => kind === "read"
|
|
28
|
+
? owner.paneReader.read(request, c.req.raw.signal)
|
|
29
|
+
: owner.paneReader.asset(request, c.req.raw.signal));
|
|
30
|
+
c.req.raw.signal.throwIfAborted();
|
|
31
|
+
return c.json(response);
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
if (error instanceof TmuxServerScopeError)
|
|
35
|
+
return c.json({ error: { code: "scope-unavailable" } }, error.code === "not-found" ? 404 : 409);
|
|
36
|
+
return c.json({ error: { code: "reader-unavailable" } }, 503);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
app.post(`${options.scopedPath}/reader`, handle(PaneReaderRequestSchemaZ, "read"));
|
|
40
|
+
app.post(`${options.scopedPath}/reader/asset`, handle(PaneReaderAssetRequestSchemaZ, "asset"));
|
|
41
|
+
}
|
|
@@ -5,6 +5,7 @@ import { WindowSplitLayoutUnavailable } from "../terminal/mirror/window-split-au
|
|
|
5
5
|
import { streamTmuxInteractions } from "./tmux-server-interaction-events.js";
|
|
6
6
|
import { mountTmuxServerNativeBackingRoute } from "./tmux-server-native-backing.js";
|
|
7
7
|
import { mountTmuxServerEditorContextRoute } from "./tmux-server-editor-context.js";
|
|
8
|
+
import { mountTmuxServerReaderRoutes } from "./tmux-server-reader.js";
|
|
8
9
|
import { Hono } from "hono";
|
|
9
10
|
import { streamSSE } from "hono/streaming";
|
|
10
11
|
import { projectApplicationShellResource } from "./resources/application-shell.js";
|
|
@@ -111,6 +112,11 @@ export function mountTmuxServerRoutes(app, options) {
|
|
|
111
112
|
owners: options.owners,
|
|
112
113
|
readBody: (request) => boundedJson(request, 8 * 1024),
|
|
113
114
|
});
|
|
115
|
+
mountTmuxServerReaderRoutes(app, {
|
|
116
|
+
scopedPath: scoped,
|
|
117
|
+
owners: options.owners,
|
|
118
|
+
readBody: (request) => boundedJson(request, 8 * 1024),
|
|
119
|
+
});
|
|
114
120
|
app.post(`${scoped}/native-browser`, route(async (c) => {
|
|
115
121
|
const server = scope(c);
|
|
116
122
|
const input = await boundedJson(c.req.raw, 24 * 1024);
|
|
@@ -2,10 +2,13 @@ import { requireSupportedTmuxVersion } from "./lib/tmux-version.js";
|
|
|
2
2
|
import { resolveTmuxExecutable } from "./lib/tmux-client-execution.js";
|
|
3
3
|
import { TMUX_SOCKET_PATH_ENV } from "./lib/runtime-namespace.js";
|
|
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.js";
|
|
9
|
+
import { readSnapshot } from "./tui/chrome/snapshot.js";
|
|
10
|
+
import { isListableSession } from "./tui/team/sessions.js";
|
|
11
|
+
import { nativeCommands } from "./lib/tmux-server-features.js";
|
|
9
12
|
import { fileURLToPath } from "node:url";
|
|
10
13
|
import { getCurrentVersion, getUpdateStatus } from "./lib/update-check.js";
|
|
11
14
|
import { installedSkillVersion } from "./lib/skill-sync.js";
|
|
@@ -152,53 +155,21 @@ function check(label, fn, { optional = false } = {}) {
|
|
|
152
155
|
return { label, pass: false, detail: e.message, optional };
|
|
153
156
|
}
|
|
154
157
|
}
|
|
155
|
-
const UNKNOWN = (command) => new RegExp(`^unknown command: ${command}$`, "mu");
|
|
156
|
-
/** The same reading of the server as the mirror's: the stock resize when it refuses
|
|
157
|
-
* the split command by name, and full only with the split capability it requires. */
|
|
158
|
-
function nativeCommands(probe) {
|
|
159
|
-
const ask = (command) => {
|
|
160
|
-
try {
|
|
161
|
-
return { output: probe([command, "-V"]) };
|
|
162
|
-
}
|
|
163
|
-
catch (error) {
|
|
164
|
-
const failure = error;
|
|
165
|
-
return { failure: String(failure.stderr ?? failure.message ?? "") };
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
const split = ask("tmux-ide-resize-split");
|
|
169
|
-
const events = ask("tmux-ide-events");
|
|
170
|
-
const failures = [split.failure, events.failure].filter((text) => text !== undefined);
|
|
171
|
-
if (failures.some((text) => /no server running|error connecting/u.test(text)))
|
|
172
|
-
return "no-server";
|
|
173
|
-
const refused = (answer, command) => answer.failure !== undefined && UNKNOWN(command).test(answer.failure);
|
|
174
|
-
if (refused(split, "tmux-ide-resize-split")) {
|
|
175
|
-
if (refused(events, "tmux-ide-events"))
|
|
176
|
-
return "stock";
|
|
177
|
-
// The journal answers: a tmux-ide tmux built before the split command.
|
|
178
|
-
if (events.output !== undefined)
|
|
179
|
-
return "older";
|
|
180
|
-
return "unknown";
|
|
181
|
-
}
|
|
182
|
-
if (split.output !== undefined && events.output !== undefined) {
|
|
183
|
-
try {
|
|
184
|
-
return nativeSplitCapability(split.output) ? "full" : "partial";
|
|
185
|
-
}
|
|
186
|
-
catch {
|
|
187
|
-
return "partial";
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
return failures.length === 2 ? "unknown" : "partial";
|
|
191
|
-
}
|
|
192
158
|
/** Reads the server a session would use. With none running, a throwaway private
|
|
193
159
|
* server shows what the resolved binary would start. */
|
|
194
160
|
export function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
195
161
|
let answer = nativeCommands(probeServer);
|
|
196
|
-
|
|
162
|
+
const running = answer !== "no-server";
|
|
163
|
+
if (!running)
|
|
197
164
|
answer = nativeCommands(probeBinary);
|
|
165
|
+
// Only a running server can be moved; the command restarts it and restores its sessions.
|
|
166
|
+
const upgrade = running
|
|
167
|
+
? "; run `tmux-ide servers upgrade` to move it to tmux-ide's own tmux"
|
|
168
|
+
: "";
|
|
198
169
|
const details = {
|
|
199
170
|
full: "bundled tmux: full features",
|
|
200
|
-
stock:
|
|
201
|
-
older:
|
|
171
|
+
stock: `stock tmux: reduced features${upgrade}`,
|
|
172
|
+
older: `older tmux-ide tmux: reduced features${upgrade}`,
|
|
202
173
|
partial: "this tmux has only some tmux-ide commands: no pane dividers",
|
|
203
174
|
"no-server": "could not read the tmux server's features",
|
|
204
175
|
unknown: "could not read the tmux server's features",
|
|
@@ -210,6 +181,96 @@ export function tmuxFeaturesRow(probeServer, probeBinary) {
|
|
|
210
181
|
optional: true,
|
|
211
182
|
};
|
|
212
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* PURE — what a plain `tmux` typed in a shell runs. Informational: when it is
|
|
186
|
+
* not tmux-ide's own tmux and it starts the server, features drop (#766).
|
|
187
|
+
*/
|
|
188
|
+
export function plainTmuxRow(pathTmux, bundled) {
|
|
189
|
+
const label = "plain `tmux` in your shell";
|
|
190
|
+
if (!pathTmux)
|
|
191
|
+
return {
|
|
192
|
+
label,
|
|
193
|
+
pass: true,
|
|
194
|
+
detail: "not on PATH (tmux-ide uses its own tmux)",
|
|
195
|
+
optional: true,
|
|
196
|
+
};
|
|
197
|
+
if (bundled && pathTmux === bundled)
|
|
198
|
+
return { label, pass: true, detail: `tmux-ide's own tmux (${pathTmux})`, optional: true };
|
|
199
|
+
return {
|
|
200
|
+
label,
|
|
201
|
+
pass: true,
|
|
202
|
+
detail: `${pathTmux}; if it starts the server, features drop (see docs: tmux upgrade)`,
|
|
203
|
+
optional: true,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
207
|
+
/**
|
|
208
|
+
* PURE — is the crash snapshot fresh enough to restore from? It fails when it
|
|
209
|
+
* is missing a live session, or is over a day old while sessions run. Only the
|
|
210
|
+
* chrome updater writes it, and that runs only while a session is adopted.
|
|
211
|
+
*/
|
|
212
|
+
export function snapshotRow(snapshot, liveSessions, nowMs) {
|
|
213
|
+
const label = "crash snapshot (restore)";
|
|
214
|
+
const hint = "Only the chrome updater writes it, while a session is adopted: `tmux-ide adopt --all` starts it";
|
|
215
|
+
if (!snapshot) {
|
|
216
|
+
return liveSessions?.length
|
|
217
|
+
? { label, pass: false, detail: `none yet. ${hint}`, optional: true }
|
|
218
|
+
: { label, pass: true, detail: "none yet (no sessions running)", optional: true };
|
|
219
|
+
}
|
|
220
|
+
const ageMs = nowMs - Date.parse(snapshot.savedAt);
|
|
221
|
+
const age = ageMs >= DAY_MS
|
|
222
|
+
? `${Math.floor(ageMs / DAY_MS)} days old`
|
|
223
|
+
: `${Math.max(0, Math.round(ageMs / 60_000))} min old`;
|
|
224
|
+
const saved = new Set(snapshot.sessions.map((session) => session.name));
|
|
225
|
+
const missing = (liveSessions ?? []).filter((name) => !saved.has(name));
|
|
226
|
+
if (missing.length)
|
|
227
|
+
return {
|
|
228
|
+
label,
|
|
229
|
+
pass: false,
|
|
230
|
+
detail: `${age}; misses ${missing.length} running session${missing.length === 1 ? "" : "s"} (${missing.slice(0, 5).join(", ")}${missing.length > 5 ? ", …" : ""}). ${hint}`,
|
|
231
|
+
optional: true,
|
|
232
|
+
};
|
|
233
|
+
return { label, pass: true, detail: `${age}, covers every running session`, optional: true };
|
|
234
|
+
}
|
|
235
|
+
function firstOnPath(name) {
|
|
236
|
+
for (const directory of (process.env.PATH ?? "").split(delimiter)) {
|
|
237
|
+
if (!directory)
|
|
238
|
+
continue;
|
|
239
|
+
const candidate = join(directory, name);
|
|
240
|
+
try {
|
|
241
|
+
accessSync(candidate, constants.X_OK);
|
|
242
|
+
return realpathSync(candidate);
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// Try the next PATH entry.
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
return null;
|
|
249
|
+
}
|
|
250
|
+
function safeBundledTmux() {
|
|
251
|
+
try {
|
|
252
|
+
const bundled = resolveBundledTmux();
|
|
253
|
+
return bundled ? realpathSync(bundled) : null;
|
|
254
|
+
}
|
|
255
|
+
catch {
|
|
256
|
+
return null;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/** The sessions the snapshot should hold, on the server doctor reads; null when unreadable. */
|
|
260
|
+
function liveListableSessions() {
|
|
261
|
+
try {
|
|
262
|
+
const socketPath = process.env[TMUX_SOCKET_PATH_ENV];
|
|
263
|
+
const socketName = process.env.TMUX_IDE_TMUX_SOCKET_NAME;
|
|
264
|
+
const server = socketPath ? ["-S", socketPath] : socketName ? ["-L", socketName] : [];
|
|
265
|
+
return execFileSync(resolveTmuxExecutable(), [...server, "list-sessions", "-F", "#{session_name}"], { encoding: "utf8", stdio: ["ignore", "pipe", "pipe"], timeout: 3000 })
|
|
266
|
+
.split("\n")
|
|
267
|
+
.filter((name) => name && isListableSession(name));
|
|
268
|
+
}
|
|
269
|
+
catch (error) {
|
|
270
|
+
const text = String(error.stderr ?? "");
|
|
271
|
+
return /no server running|error connecting/u.test(text) ? [] : null;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
213
274
|
function runTmuxFeatureProbes(executable) {
|
|
214
275
|
const run = (prefix) => (args) => execFileSync(executable, [...prefix, ...args], {
|
|
215
276
|
encoding: "utf8",
|
|
@@ -296,6 +357,8 @@ export async function doctor({ json, } = {}) {
|
|
|
296
357
|
catch {
|
|
297
358
|
// The tmux version row above already reports a missing executable.
|
|
298
359
|
}
|
|
360
|
+
checks.push(plainTmuxRow(firstOnPath("tmux"), safeBundledTmux()));
|
|
361
|
+
checks.push(snapshotRow(readSnapshot(), liveListableSessions(), Date.now()));
|
|
299
362
|
checks.push(nodeVersionRow(process.versions.node));
|
|
300
363
|
checks.push(check("256-color terminal", () => {
|
|
301
364
|
const term = process.env.TERM ?? "";
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { basename, dirname, extname, join } from "node:path";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
/**
|
|
4
|
+
* The argv prefix that runs this tmux-ide's CLI: the bundled `bin/cli.js`,
|
|
5
|
+
* or `bin/cli.ts` under the runtime's loader flags when run from source.
|
|
6
|
+
* `here` must sit two directories below `packages/daemon/src`'s parent.
|
|
7
|
+
*/
|
|
8
|
+
export function resolveCliCommand(here = fileURLToPath(import.meta.url), runtime = process) {
|
|
9
|
+
if (basename(here) === "cli.js")
|
|
10
|
+
return [runtime.execPath, here];
|
|
11
|
+
const cli = join(dirname(here), "..", "..", "..", "..", "bin", `cli${extname(here)}`);
|
|
12
|
+
return [runtime.execPath, ...runtime.execArgv, cli];
|
|
13
|
+
}
|
|
@@ -6,6 +6,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
6
6
|
}
|
|
7
7
|
return path;
|
|
8
8
|
};
|
|
9
|
+
import { createPaneReaderResolver } from "./tmux-pane-reader.js";
|
|
9
10
|
import { createNativeBrowserResolver } from "./tmux-native-browser.js";
|
|
10
11
|
import { createNativeSurfaceContextResolver } from "./native-surface-context.js";
|
|
11
12
|
import { NativeSurfaceProviderRegistry } from "../terminal/graphics/native-surface-provider.js";
|
|
@@ -1431,6 +1432,20 @@ async function startEmbeddedDaemonGeneration(opts) {
|
|
|
1431
1432
|
throw new Error("Default native browser owner is unavailable");
|
|
1432
1433
|
},
|
|
1433
1434
|
}),
|
|
1435
|
+
paneReader: createPaneReaderResolver({
|
|
1436
|
+
generation: instanceId,
|
|
1437
|
+
run: fleetFactsTmuxRunner,
|
|
1438
|
+
registry: workspaceRegistry,
|
|
1439
|
+
catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
|
|
1440
|
+
inventory: terminalInventoryRuntime,
|
|
1441
|
+
assertOpen: () => {
|
|
1442
|
+
if (defaultEditorContextRetired ||
|
|
1443
|
+
serverOwners?.defaultRetired ||
|
|
1444
|
+
!initialNativeServerIdentity ||
|
|
1445
|
+
terminalInventoryRuntime?.lifecycleState() !== "ready")
|
|
1446
|
+
throw new Error("Default reader owner is unavailable");
|
|
1447
|
+
},
|
|
1448
|
+
}),
|
|
1434
1449
|
catalog: createNativeTmuxServerCatalog(workspaceRegistry, fleetFactsTmuxRunner),
|
|
1435
1450
|
readWindowSplitLayout: async (workspaceName, input) => {
|
|
1436
1451
|
const target = WindowLinkTargetSchemaZ.parse(input);
|