@antondanv/brainyard 0.1.0 → 0.2.0
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/CHANGELOG.md +108 -0
- package/README.md +322 -104
- package/dist/ask.d.ts.map +1 -1
- package/dist/ask.js +23 -0
- package/dist/ask.js.map +1 -1
- package/dist/brains/adapter.d.ts +16 -2
- package/dist/brains/adapter.d.ts.map +1 -1
- package/dist/brains/adapter.js.map +1 -1
- package/dist/brains/index.d.ts.map +1 -1
- package/dist/brains/index.js +2 -1
- package/dist/brains/index.js.map +1 -1
- package/dist/brains/info.d.ts.map +1 -1
- package/dist/brains/info.js +22 -0
- package/dist/brains/info.js.map +1 -1
- package/dist/brains/opencode-bridge.d.ts +2 -0
- package/dist/brains/opencode-bridge.d.ts.map +1 -0
- package/dist/brains/opencode-bridge.js +332 -0
- package/dist/brains/opencode-bridge.js.map +1 -0
- package/dist/brains/opencode.d.ts +14 -0
- package/dist/brains/opencode.d.ts.map +1 -0
- package/dist/brains/opencode.js +474 -0
- package/dist/brains/opencode.js.map +1 -0
- package/dist/catalog.d.ts +8 -1
- package/dist/catalog.d.ts.map +1 -1
- package/dist/catalog.js +100 -1
- package/dist/catalog.js.map +1 -1
- package/dist/codex-live.d.ts +12 -0
- package/dist/codex-live.d.ts.map +1 -0
- package/dist/codex-live.js +188 -0
- package/dist/codex-live.js.map +1 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/flags.d.ts.map +1 -1
- package/dist/flags.js +7 -5
- package/dist/flags.js.map +1 -1
- package/dist/humanize.d.ts.map +1 -1
- package/dist/humanize.js +19 -2
- package/dist/humanize.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/open.d.ts +87 -0
- package/dist/open.d.ts.map +1 -0
- package/dist/open.js +324 -0
- package/dist/open.js.map +1 -0
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +4 -2
- package/dist/options.js.map +1 -1
- package/dist/panes.d.ts +118 -0
- package/dist/panes.d.ts.map +1 -0
- package/dist/panes.js +478 -0
- package/dist/panes.js.map +1 -0
- package/dist/process.d.ts +26 -0
- package/dist/process.d.ts.map +1 -1
- package/dist/process.js +92 -2
- package/dist/process.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/run.js +11 -3
- package/dist/run.js.map +1 -1
- package/dist/sessions.d.ts +137 -0
- package/dist/sessions.d.ts.map +1 -0
- package/dist/sessions.js +1023 -0
- package/dist/sessions.js.map +1 -0
- package/dist/status.d.ts +1 -1
- package/dist/status.d.ts.map +1 -1
- package/dist/status.js +28 -7
- package/dist/status.js.map +1 -1
- package/dist/subscription-limits.d.ts +12 -0
- package/dist/subscription-limits.d.ts.map +1 -0
- package/dist/subscription-limits.js +281 -0
- package/dist/subscription-limits.js.map +1 -0
- package/dist/types.d.ts +14 -8
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -2
- package/dist/types.js.map +1 -1
- package/dist/usage-readers.d.ts +16 -0
- package/dist/usage-readers.d.ts.map +1 -0
- package/dist/usage-readers.js +194 -0
- package/dist/usage-readers.js.map +1 -0
- package/dist/usage.d.ts +71 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +403 -0
- package/dist/usage.js.map +1 -0
- package/package.json +7 -23
- package/README.ru.md +0 -334
- package/dist/cli/main.d.ts +0 -3
- package/dist/cli/main.d.ts.map +0 -1
- package/dist/cli/main.js +0 -520
- package/dist/cli/main.js.map +0 -1
- package/dist/cli/term.d.ts +0 -20
- package/dist/cli/term.d.ts.map +0 -1
- package/dist/cli/term.js +0 -87
- package/dist/cli/term.js.map +0 -1
- package/dist/ui/dashboard.html +0 -693
- package/dist/ui/page.d.ts +0 -9
- package/dist/ui/page.d.ts.map +0 -1
- package/dist/ui/page.js +0 -12
- package/dist/ui/page.js.map +0 -1
- package/dist/ui/server.d.ts +0 -20
- package/dist/ui/server.d.ts.map +0 -1
- package/dist/ui/server.js +0 -409
- package/dist/ui/server.js.map +0 -1
package/dist/panes.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type OpenOptions } from './open.js';
|
|
2
|
+
import type { SessionInfo } from './sessions.js';
|
|
3
|
+
import type { BrainId } from './types.js';
|
|
4
|
+
export interface PaneOptions extends OpenOptions {
|
|
5
|
+
/** Columns and rows of the pane's screen; a watcher resizes it to its view later. */
|
|
6
|
+
width?: number;
|
|
7
|
+
height?: number;
|
|
8
|
+
/** Shown by watchers; defaults to the session name. */
|
|
9
|
+
label?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface PaneStart {
|
|
12
|
+
pane: string;
|
|
13
|
+
brain: BrainId;
|
|
14
|
+
/** Known at once for Claude Code and for a resumed session; the others: `findPaneSession()`. */
|
|
15
|
+
sessionId?: string;
|
|
16
|
+
/** ISO. */
|
|
17
|
+
startedAt: string;
|
|
18
|
+
warnings: string[];
|
|
19
|
+
/** The CLI command line, for logs. */
|
|
20
|
+
display: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PaneInfo {
|
|
23
|
+
/** The tmux session name. */
|
|
24
|
+
pane: string;
|
|
25
|
+
brain?: BrainId;
|
|
26
|
+
sessionId?: string;
|
|
27
|
+
label?: string;
|
|
28
|
+
cwd?: string;
|
|
29
|
+
/** The CLI's process (the pane's first process). */
|
|
30
|
+
pid?: number;
|
|
31
|
+
/** What runs in the pane now, as tmux sees it (`node`, `agy`…). */
|
|
32
|
+
command?: string;
|
|
33
|
+
/** ISO. */
|
|
34
|
+
startedAt?: string;
|
|
35
|
+
/** ISO: the last time the CLI printed anything. */
|
|
36
|
+
activityAt?: string;
|
|
37
|
+
/** A terminal shows it full screen right now. */
|
|
38
|
+
attached: boolean;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
}
|
|
42
|
+
export interface PaneScreen {
|
|
43
|
+
/** One string per row, with colours as ANSI SGR; each row sets and resets its own. */
|
|
44
|
+
lines: string[];
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
cursor: {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
visible: boolean;
|
|
51
|
+
};
|
|
52
|
+
/** Available scrollback rows and the captured viewport's distance above the live screen. */
|
|
53
|
+
historySize: number;
|
|
54
|
+
scrollOffset: number;
|
|
55
|
+
/** The CLI handles mouse events itself (coordinates are relative to its screen). */
|
|
56
|
+
mouseTracking: boolean;
|
|
57
|
+
mouseSgr: boolean;
|
|
58
|
+
alternate: boolean;
|
|
59
|
+
/** ISO: the last time the CLI printed anything. */
|
|
60
|
+
activityAt?: string;
|
|
61
|
+
}
|
|
62
|
+
export interface PaneSettings {
|
|
63
|
+
/** tmux executable; `BRAINYARD_TMUX_BIN`, then `tmux` on PATH. */
|
|
64
|
+
command?: string | string[];
|
|
65
|
+
/** Server socket name; `BRAINYARD_TMUX_SOCKET`, then `brainyard`. */
|
|
66
|
+
socket?: string;
|
|
67
|
+
env?: NodeJS.ProcessEnv;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* The fields of one line of a `-F` listing. tmux 3.4 writes a control
|
|
71
|
+
* character in its format output as an octal escape, the separator as `\037`;
|
|
72
|
+
* later versions write it as it is.
|
|
73
|
+
*/
|
|
74
|
+
export declare function formatFields(line: string): string[];
|
|
75
|
+
/**
|
|
76
|
+
* What tmux gives a mouse selection to: the system clipboard. Without it, text
|
|
77
|
+
* selected in a full-screen pane stays in tmux's own buffer, which nothing
|
|
78
|
+
* outside can paste. `BRAINYARD_COPY_COMMAND` names another command (empty:
|
|
79
|
+
* none, tmux keeps the text to itself).
|
|
80
|
+
*/
|
|
81
|
+
export declare function clipboardCommand(env?: NodeJS.ProcessEnv, platform?: NodeJS.Platform): string | undefined;
|
|
82
|
+
/** Whether tmux is there to run panes. */
|
|
83
|
+
export declare function panesAvailable(settings?: PaneSettings): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* Starts a CLI session in a new pane and returns at once; the session runs
|
|
86
|
+
* until the CLI exits or `closePane()`.
|
|
87
|
+
*/
|
|
88
|
+
export declare function startPane(options: PaneOptions, settings?: PaneSettings): Promise<PaneStart>;
|
|
89
|
+
/** Every live pane of this server. Empty when tmux is missing or nothing runs. */
|
|
90
|
+
export declare function listPanes(settings?: PaneSettings): Promise<PaneInfo[]>;
|
|
91
|
+
/** A screen-sized viewport, optionally scrolled into history; undefined when it is gone. */
|
|
92
|
+
export declare function capturePane(pane: string, settings?: PaneSettings & {
|
|
93
|
+
scroll?: number;
|
|
94
|
+
}): Promise<PaneScreen | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Types into the pane: the bytes go to the CLI as if typed in its terminal
|
|
97
|
+
* (keys, escape sequences, pasted text in any language).
|
|
98
|
+
*/
|
|
99
|
+
export declare function sendToPane(pane: string, data: string | Uint8Array, settings?: PaneSettings): Promise<void>;
|
|
100
|
+
/** Makes the pane's screen this size, so it fits the view that shows it. */
|
|
101
|
+
export declare function resizePane(pane: string, width: number, height: number, settings?: PaneSettings): Promise<boolean>;
|
|
102
|
+
/** Remembers which CLI session runs in the pane (all but Claude Code name it only after starting). */
|
|
103
|
+
export declare function setPaneSession(pane: string, sessionId: string, settings?: PaneSettings): Promise<boolean>;
|
|
104
|
+
/** The session a Codex, Antigravity or OpenCode pane started, found in the CLI's store. */
|
|
105
|
+
export declare function findPaneSession(info: PaneInfo, options?: Pick<OpenOptions, 'env' | 'homes'>): Promise<SessionInfo | undefined>;
|
|
106
|
+
/**
|
|
107
|
+
* Shows the pane full screen in this terminal until the person leaves it
|
|
108
|
+
* (Ctrl+Q, or the CLI exits). The pane takes the terminal's size; the
|
|
109
|
+
* caller resizes it back to its view afterwards.
|
|
110
|
+
*/
|
|
111
|
+
export declare function attachPane(pane: string, options?: {
|
|
112
|
+
hint?: string;
|
|
113
|
+
} & PaneSettings): Promise<number | null>;
|
|
114
|
+
/** Ends the CLI in the pane (it gets SIGHUP, as when a terminal closes); its conversation stays resumable. */
|
|
115
|
+
export declare function closePane(pane: string, settings?: PaneSettings): Promise<boolean>;
|
|
116
|
+
/** Resident memory of each pane's CLI with everything it started, in bytes. */
|
|
117
|
+
export declare function paneMemory(panes: readonly PaneInfo[]): Promise<Map<string, number>>;
|
|
118
|
+
//# sourceMappingURL=panes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panes.d.ts","sourceRoot":"","sources":["../src/panes.ts"],"names":[],"mappings":"AA0BA,OAAO,EAAe,KAAK,WAAW,EAAY,MAAM,WAAW,CAAC;AAUpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC9C,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,sCAAsC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,QAAQ;IACvB,6BAA6B;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,GAAG,CAAC,EAAE,MAAM,CAA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,CAAC,MAAM,GAAG,IAAI,CAAC,CAgErH;AAED,8GAA8G;AAC9G,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,GAAE,YAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,CAI3F;AAED,+EAA+E;AAC/E,wBAAsB,UAAU,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA6BzF"}
|
package/dist/panes.js
ADDED
|
@@ -0,0 +1,478 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Panes: a CLI session that runs in tmux, so another program can show its
|
|
3
|
+
* screen, type into it and hand the whole terminal over to it — and the
|
|
4
|
+
* session outlives that program. Claude Squad works the same way.
|
|
5
|
+
*
|
|
6
|
+
* - **Its own tmux server** (`tmux -L brainyard -f /dev/null`): the person's
|
|
7
|
+
* tmux and its config are never touched, and nothing of theirs leaks in.
|
|
8
|
+
* - **The CLI is the same interactive session `open()` starts**, so it is
|
|
9
|
+
* resumable and shows up in `claude --resume`, `codex resume`, agy and OpenCode.
|
|
10
|
+
* - **Cheap to watch**: a screen is one `capture-pane` of the visible grid,
|
|
11
|
+
* with colours; nothing is read for panes nobody looks at.
|
|
12
|
+
* - **Copying works**: text selected with the mouse in a full-screen pane goes
|
|
13
|
+
* to the system clipboard (`clipboardCommand()`), not only to tmux's buffer.
|
|
14
|
+
* - **Cheap to keep**: `closePane()` ends the CLI; its conversation stays in
|
|
15
|
+
* its store, and `startPane({ resume })` brings it back. `paneMemory()` says
|
|
16
|
+
* what each live pane costs, `activityAt` how long it has been quiet.
|
|
17
|
+
*
|
|
18
|
+
* tmux is an external program, like the CLIs themselves; `panesAvailable()`
|
|
19
|
+
* says whether it is installed. Not on Windows.
|
|
20
|
+
*/
|
|
21
|
+
import { randomBytes } from 'node:crypto';
|
|
22
|
+
import { chmodSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import { tmpdir } from 'node:os';
|
|
24
|
+
import { join } from 'node:path';
|
|
25
|
+
import { BrainyardError } from './errors.js';
|
|
26
|
+
import { findStarted, planOpen } from './open.js';
|
|
27
|
+
import { capture, resolveCommand, spawnInteractive, unsetSessionVarsScript, which, withoutSessionVars, } from './process.js';
|
|
28
|
+
import { BRAIN_IDS } from './types.js';
|
|
29
|
+
const META = ['@brain', '@session', '@label', '@cwd', '@started'];
|
|
30
|
+
const SEP = '\u001f';
|
|
31
|
+
/**
|
|
32
|
+
* The fields of one line of a `-F` listing. tmux 3.4 writes a control
|
|
33
|
+
* character in its format output as an octal escape, the separator as `\037`;
|
|
34
|
+
* later versions write it as it is.
|
|
35
|
+
*/
|
|
36
|
+
export function formatFields(line) {
|
|
37
|
+
return line.replaceAll('\\037', SEP).split(SEP);
|
|
38
|
+
}
|
|
39
|
+
/** tmux refuses to start inside tmux, and a pane is not inside the terminal that started it. */
|
|
40
|
+
const NESTING = ['TMUX', 'TMUX_PANE'];
|
|
41
|
+
/** tmux takes at most 16 KB per command; hex input is three characters a byte. */
|
|
42
|
+
const SEND_CHUNK = 2_000;
|
|
43
|
+
function tmux(settings = {}) {
|
|
44
|
+
if (process.platform === 'win32')
|
|
45
|
+
return undefined;
|
|
46
|
+
// The server keeps the environment of whoever started it, for every pane to come.
|
|
47
|
+
const env = withoutSessionVars({ ...process.env, ...settings.env });
|
|
48
|
+
for (const name of NESTING)
|
|
49
|
+
delete env[name];
|
|
50
|
+
const command = resolveCommand(settings.command, 'tmux', 'BRAINYARD_TMUX_BIN', env);
|
|
51
|
+
if (!command)
|
|
52
|
+
return undefined;
|
|
53
|
+
return { command, socket: settings.socket ?? env.BRAINYARD_TMUX_SOCKET?.trim() ?? 'brainyard', env };
|
|
54
|
+
}
|
|
55
|
+
function need(settings = {}) {
|
|
56
|
+
const found = tmux(settings);
|
|
57
|
+
if (!found) {
|
|
58
|
+
throw new BrainyardError('not_installed', process.platform === 'win32'
|
|
59
|
+
? 'panes need tmux, which Windows does not have'
|
|
60
|
+
: 'panes need tmux: brew install tmux');
|
|
61
|
+
}
|
|
62
|
+
return found;
|
|
63
|
+
}
|
|
64
|
+
async function call(t, args) {
|
|
65
|
+
const got = await capture(t.command, ['-L', t.socket, '-f', '/dev/null', ...args], { env: t.env, timeoutMs: 10_000 });
|
|
66
|
+
return { ok: got.code === 0 && !got.error, out: got.stdout, err: (got.stderr || got.error?.message || '').trim() };
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* In tmux's argument form a trailing `;` ends a command. Our values (labels,
|
|
70
|
+
* ids) can end with one; `\;` keeps it literal.
|
|
71
|
+
*/
|
|
72
|
+
function literal(value) {
|
|
73
|
+
return value.endsWith(';') ? `${value.slice(0, -1)}\\;` : value;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* `=name:` — exactly this session (and its window), never one whose name
|
|
77
|
+
* merely starts the same. Plain `=name` works only where a whole session is
|
|
78
|
+
* the target, not for options, captures or keys.
|
|
79
|
+
*/
|
|
80
|
+
function target(pane) {
|
|
81
|
+
return `=${pane}:`;
|
|
82
|
+
}
|
|
83
|
+
/** Labels live in tab-separated listings: no tabs, line breaks or separators. */
|
|
84
|
+
function oneLine(value) {
|
|
85
|
+
return [...value]
|
|
86
|
+
.map((char) => (char < ' ' ? ' ' : char))
|
|
87
|
+
.join('')
|
|
88
|
+
.replace(/ {2,}/g, ' ')
|
|
89
|
+
.trim();
|
|
90
|
+
}
|
|
91
|
+
function shellQuote(value) {
|
|
92
|
+
return `'${value.replaceAll("'", `'\\''`)}'`;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* What tmux gives a mouse selection to: the system clipboard. Without it, text
|
|
96
|
+
* selected in a full-screen pane stays in tmux's own buffer, which nothing
|
|
97
|
+
* outside can paste. `BRAINYARD_COPY_COMMAND` names another command (empty:
|
|
98
|
+
* none, tmux keeps the text to itself).
|
|
99
|
+
*/
|
|
100
|
+
export function clipboardCommand(env = process.env, platform = process.platform) {
|
|
101
|
+
const own = env.BRAINYARD_COPY_COMMAND;
|
|
102
|
+
if (own !== undefined)
|
|
103
|
+
return own.trim() || undefined;
|
|
104
|
+
// pbcopy reads bytes in the locale's encoding, and the server may have none.
|
|
105
|
+
if (platform === 'darwin')
|
|
106
|
+
return which('pbcopy', env) ? 'LC_ALL=en_US.UTF-8 pbcopy' : undefined;
|
|
107
|
+
if (env.WAYLAND_DISPLAY && which('wl-copy', env))
|
|
108
|
+
return 'wl-copy';
|
|
109
|
+
if (env.DISPLAY && which('xclip', env))
|
|
110
|
+
return 'xclip -selection clipboard';
|
|
111
|
+
if (env.DISPLAY && which('xsel', env))
|
|
112
|
+
return 'xsel --clipboard --input';
|
|
113
|
+
return undefined;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Mouse selections go to the clipboard. On its own: a tmux older than 3.2 has
|
|
117
|
+
* no `copy-command`, and that must not stop a pane from starting.
|
|
118
|
+
*/
|
|
119
|
+
async function copyToClipboard(t) {
|
|
120
|
+
const command = clipboardCommand(t.env);
|
|
121
|
+
if (command)
|
|
122
|
+
await call(t, ['set-option', '-s', 'copy-command', literal(command)]);
|
|
123
|
+
}
|
|
124
|
+
/** Whether tmux is there to run panes. */
|
|
125
|
+
export function panesAvailable(settings = {}) {
|
|
126
|
+
return tmux(settings) !== undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Starts a CLI session in a new pane and returns at once; the session runs
|
|
130
|
+
* until the CLI exits or `closePane()`.
|
|
131
|
+
*/
|
|
132
|
+
export async function startPane(options, settings = {}) {
|
|
133
|
+
const t = need(settings);
|
|
134
|
+
if (options.background) {
|
|
135
|
+
throw new BrainyardError('invalid_option', 'a pane is already in the background; drop `background`');
|
|
136
|
+
}
|
|
137
|
+
const plan = await planOpen(options);
|
|
138
|
+
const pane = `${plan.brain === 'antigravity' ? 'agy' : plan.brain}-${randomBytes(4).toString('hex')}`;
|
|
139
|
+
const startedAt = new Date();
|
|
140
|
+
// The command goes through a one-shot script, not tmux's command line: a
|
|
141
|
+
// prompt can be long (tmux takes 16 KB per command) and can end with `;`.
|
|
142
|
+
const dir = join(tmpdir(), `brainyard-panes-${process.getuid?.() ?? 'user'}`);
|
|
143
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
144
|
+
const script = join(dir, `${pane}.sh`);
|
|
145
|
+
const exports = Object.entries(options.env ?? {}).map(([key, value]) => {
|
|
146
|
+
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key))
|
|
147
|
+
throw new BrainyardError('invalid_option', `bad variable name: ${key}`);
|
|
148
|
+
return `export ${key}=${shellQuote(value)}`;
|
|
149
|
+
});
|
|
150
|
+
writeFileSync(script, [
|
|
151
|
+
'#!/bin/sh',
|
|
152
|
+
'rm -f "$0"',
|
|
153
|
+
// A server started from inside a Claude Code session remembers that session's variables.
|
|
154
|
+
...unsetSessionVarsScript(),
|
|
155
|
+
`unset ${NESTING.join(' ')}`,
|
|
156
|
+
...exports,
|
|
157
|
+
`cd ${shellQuote(plan.cwd)} || exit 1`,
|
|
158
|
+
[plan.command.file, ...plan.command.args, ...plan.args].map(shellQuote).join(' '),
|
|
159
|
+
// A CLI that fails at once would take its reason with it: keep the screen until Enter.
|
|
160
|
+
'code=$?',
|
|
161
|
+
`if [ "$code" -ne 0 ] && [ "$code" -lt 128 ]; then printf '\\n\\033[2m%s exited with code %s · Enter closes\\033[0m\\n' ${shellQuote(plan.brain)} "$code"; read -r _; fi`,
|
|
162
|
+
'',
|
|
163
|
+
].join('\n'), { mode: 0o700 });
|
|
164
|
+
chmodSync(script, 0o700);
|
|
165
|
+
const width = String(Math.max(20, Math.round(options.width ?? 100)));
|
|
166
|
+
const height = String(Math.max(5, Math.round(options.height ?? 30)));
|
|
167
|
+
const meta = [
|
|
168
|
+
['@brain', plan.brain],
|
|
169
|
+
['@cwd', plan.cwd],
|
|
170
|
+
['@started', startedAt.toISOString()],
|
|
171
|
+
['@label', oneLine(options.label ?? options.name ?? '')],
|
|
172
|
+
];
|
|
173
|
+
if (plan.sessionId)
|
|
174
|
+
meta.push(['@session', plan.sessionId]);
|
|
175
|
+
const args = ['new-session', '-d', '-s', pane, '-x', width, '-y', height, '-c', plan.cwd, '--', '/bin/sh', script];
|
|
176
|
+
for (const [key, value] of meta)
|
|
177
|
+
if (value)
|
|
178
|
+
args.push(';', 'set-option', '-t', target(pane), key, literal(value));
|
|
179
|
+
// The server's own settings: no delay after Esc (CLIs use it), the wheel
|
|
180
|
+
// scrolls, Ctrl+Q leaves a full-screen pane, no status line unless attached.
|
|
181
|
+
args.push(';', 'set-option', '-s', 'escape-time', '0', ';', 'set-option', '-g', 'mouse', 'on', ';', 'set-option', '-g', 'status', 'off', ';', 'bind-key', '-n', 'C-q', 'detach-client');
|
|
182
|
+
const got = await call(t, args);
|
|
183
|
+
if (!got.ok)
|
|
184
|
+
throw new BrainyardError('failed', `tmux did not start the pane: ${got.err || 'no reason given'}`);
|
|
185
|
+
await copyToClipboard(t);
|
|
186
|
+
const result = {
|
|
187
|
+
pane,
|
|
188
|
+
brain: plan.brain,
|
|
189
|
+
startedAt: startedAt.toISOString(),
|
|
190
|
+
warnings: [...plan.warnings],
|
|
191
|
+
display: plan.display,
|
|
192
|
+
};
|
|
193
|
+
if (plan.sessionId)
|
|
194
|
+
result.sessionId = plan.sessionId;
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
const LIST_FORMAT = [
|
|
198
|
+
'#{session_name}',
|
|
199
|
+
...META.map((key) => `#{${key}}`),
|
|
200
|
+
'#{pane_pid}',
|
|
201
|
+
'#{pane_current_command}',
|
|
202
|
+
'#{session_created}',
|
|
203
|
+
'#{window_activity}',
|
|
204
|
+
'#{session_attached}',
|
|
205
|
+
'#{window_width}',
|
|
206
|
+
'#{window_height}',
|
|
207
|
+
].join(SEP);
|
|
208
|
+
function iso(seconds) {
|
|
209
|
+
const n = Number(seconds);
|
|
210
|
+
return n > 0 ? new Date(n * 1000).toISOString() : undefined;
|
|
211
|
+
}
|
|
212
|
+
/** Every live pane of this server. Empty when tmux is missing or nothing runs. */
|
|
213
|
+
export async function listPanes(settings = {}) {
|
|
214
|
+
const t = tmux(settings);
|
|
215
|
+
if (!t)
|
|
216
|
+
return [];
|
|
217
|
+
const got = await call(t, ['list-sessions', '-F', LIST_FORMAT]);
|
|
218
|
+
if (!got.ok)
|
|
219
|
+
return [];
|
|
220
|
+
const panes = [];
|
|
221
|
+
for (const line of got.out.split('\n')) {
|
|
222
|
+
if (!line.trim())
|
|
223
|
+
continue;
|
|
224
|
+
const [name, brain, session, label, cwd, started, pid, command, created, activity, attached, width, height] = formatFields(line);
|
|
225
|
+
if (!name)
|
|
226
|
+
continue;
|
|
227
|
+
const info = {
|
|
228
|
+
pane: name,
|
|
229
|
+
attached: Number(attached) > 0,
|
|
230
|
+
width: Number(width) || 0,
|
|
231
|
+
height: Number(height) || 0,
|
|
232
|
+
};
|
|
233
|
+
if (BRAIN_IDS.includes(brain ?? ''))
|
|
234
|
+
info.brain = brain;
|
|
235
|
+
if (session)
|
|
236
|
+
info.sessionId = session;
|
|
237
|
+
if (label)
|
|
238
|
+
info.label = label;
|
|
239
|
+
if (cwd)
|
|
240
|
+
info.cwd = cwd;
|
|
241
|
+
if (Number(pid) > 0)
|
|
242
|
+
info.pid = Number(pid);
|
|
243
|
+
if (command)
|
|
244
|
+
info.command = command;
|
|
245
|
+
const startedAt = started || iso(created);
|
|
246
|
+
if (startedAt)
|
|
247
|
+
info.startedAt = startedAt;
|
|
248
|
+
const activityAt = iso(activity);
|
|
249
|
+
if (activityAt)
|
|
250
|
+
info.activityAt = activityAt;
|
|
251
|
+
panes.push(info);
|
|
252
|
+
}
|
|
253
|
+
return panes;
|
|
254
|
+
}
|
|
255
|
+
const SCREEN_FORMAT = [
|
|
256
|
+
'#{pane_width}',
|
|
257
|
+
'#{pane_height}',
|
|
258
|
+
'#{cursor_x}',
|
|
259
|
+
'#{cursor_y}',
|
|
260
|
+
'#{cursor_flag}',
|
|
261
|
+
'#{window_activity}',
|
|
262
|
+
'#{history_size}',
|
|
263
|
+
'#{mouse_any_flag}#{mouse_button_flag}#{mouse_standard_flag}',
|
|
264
|
+
'#{mouse_sgr_flag}',
|
|
265
|
+
'#{alternate_on}',
|
|
266
|
+
].join(SEP);
|
|
267
|
+
/** A screen-sized viewport, optionally scrolled into history; undefined when it is gone. */
|
|
268
|
+
export async function capturePane(pane, settings = {}) {
|
|
269
|
+
const t = tmux(settings);
|
|
270
|
+
if (!t)
|
|
271
|
+
return undefined;
|
|
272
|
+
const scrolled = Number.isFinite(settings.scroll) && (settings.scroll ?? 0) > 0;
|
|
273
|
+
const args = ['display-message', '-p', '-t', target(pane), SCREEN_FORMAT];
|
|
274
|
+
if (!scrolled)
|
|
275
|
+
args.push(';', 'capture-pane', '-p', '-e', '-t', target(pane));
|
|
276
|
+
const got = await call(t, args);
|
|
277
|
+
if (!got.ok)
|
|
278
|
+
return undefined;
|
|
279
|
+
const [head = '', ...rest] = got.out.split('\n');
|
|
280
|
+
const [width, height, x, y, visible, activity, history, mouse, mouseSgr, alternate] = formatFields(head);
|
|
281
|
+
const rows = Number(height) || 0;
|
|
282
|
+
const historySize = Number(history) || 0;
|
|
283
|
+
const scrollOffset = scrolled ? Math.min(historySize, Math.floor(settings.scroll)) : 0;
|
|
284
|
+
let lines = rest.slice(0, rows);
|
|
285
|
+
if (scrolled) {
|
|
286
|
+
const captured = await call(t, [
|
|
287
|
+
'capture-pane',
|
|
288
|
+
'-p',
|
|
289
|
+
'-e',
|
|
290
|
+
'-t',
|
|
291
|
+
target(pane),
|
|
292
|
+
'-S',
|
|
293
|
+
String(-scrollOffset),
|
|
294
|
+
'-E',
|
|
295
|
+
String(rows - scrollOffset - 1),
|
|
296
|
+
]);
|
|
297
|
+
if (!captured.ok)
|
|
298
|
+
return undefined;
|
|
299
|
+
lines = captured.out.split('\n').slice(0, rows);
|
|
300
|
+
}
|
|
301
|
+
while (lines.length < rows)
|
|
302
|
+
lines.push('');
|
|
303
|
+
const screen = {
|
|
304
|
+
lines,
|
|
305
|
+
width: Number(width) || 0,
|
|
306
|
+
height: rows,
|
|
307
|
+
cursor: { x: Number(x) || 0, y: Number(y) || 0, visible: visible === '1' },
|
|
308
|
+
historySize,
|
|
309
|
+
scrollOffset,
|
|
310
|
+
mouseTracking: mouse?.includes('1') ?? false,
|
|
311
|
+
mouseSgr: mouseSgr === '1',
|
|
312
|
+
alternate: alternate === '1',
|
|
313
|
+
};
|
|
314
|
+
const activityAt = iso(activity);
|
|
315
|
+
if (activityAt)
|
|
316
|
+
screen.activityAt = activityAt;
|
|
317
|
+
return screen;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Types into the pane: the bytes go to the CLI as if typed in its terminal
|
|
321
|
+
* (keys, escape sequences, pasted text in any language).
|
|
322
|
+
*/
|
|
323
|
+
export async function sendToPane(pane, data, settings = {}) {
|
|
324
|
+
const t = need(settings);
|
|
325
|
+
const bytes = typeof data === 'string' ? Buffer.from(data, 'utf8') : Buffer.from(data);
|
|
326
|
+
for (let from = 0; from < bytes.length; from += SEND_CHUNK) {
|
|
327
|
+
const hex = [...bytes.subarray(from, from + SEND_CHUNK)].map((byte) => byte.toString(16).padStart(2, '0'));
|
|
328
|
+
const got = await call(t, ['send-keys', '-t', target(pane), '-H', ...hex]);
|
|
329
|
+
if (!got.ok)
|
|
330
|
+
throw new BrainyardError('failed', `tmux did not take the keys: ${got.err || 'the pane is gone'}`);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
/** Makes the pane's screen this size, so it fits the view that shows it. */
|
|
334
|
+
export async function resizePane(pane, width, height, settings = {}) {
|
|
335
|
+
const t = tmux(settings);
|
|
336
|
+
if (!t)
|
|
337
|
+
return false;
|
|
338
|
+
const got = await call(t, [
|
|
339
|
+
'resize-window',
|
|
340
|
+
'-t',
|
|
341
|
+
target(pane),
|
|
342
|
+
'-x',
|
|
343
|
+
String(Math.max(20, Math.round(width))),
|
|
344
|
+
'-y',
|
|
345
|
+
String(Math.max(5, Math.round(height))),
|
|
346
|
+
]);
|
|
347
|
+
return got.ok;
|
|
348
|
+
}
|
|
349
|
+
/** Remembers which CLI session runs in the pane (all but Claude Code name it only after starting). */
|
|
350
|
+
export async function setPaneSession(pane, sessionId, settings = {}) {
|
|
351
|
+
const t = tmux(settings);
|
|
352
|
+
if (!t)
|
|
353
|
+
return false;
|
|
354
|
+
return (await call(t, ['set-option', '-t', target(pane), '@session', literal(sessionId)])).ok;
|
|
355
|
+
}
|
|
356
|
+
/** The session a Codex, Antigravity or OpenCode pane started, found in the CLI's store. */
|
|
357
|
+
export async function findPaneSession(info, options = {}) {
|
|
358
|
+
if (info.sessionId)
|
|
359
|
+
return undefined;
|
|
360
|
+
if (!info.brain || !info.cwd || !info.startedAt)
|
|
361
|
+
return undefined;
|
|
362
|
+
return findStarted(info.brain, info.cwd, new Date(info.startedAt), options);
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Shows the pane full screen in this terminal until the person leaves it
|
|
366
|
+
* (Ctrl+Q, or the CLI exits). The pane takes the terminal's size; the
|
|
367
|
+
* caller resizes it back to its view afterwards.
|
|
368
|
+
*/
|
|
369
|
+
export async function attachPane(pane, options = {}) {
|
|
370
|
+
const t = need(options);
|
|
371
|
+
const hint = (options.hint ?? 'Ctrl+Q — back').replaceAll('#', '##');
|
|
372
|
+
const style = await call(t, [
|
|
373
|
+
'set-option',
|
|
374
|
+
'-t',
|
|
375
|
+
target(pane),
|
|
376
|
+
'status',
|
|
377
|
+
'on',
|
|
378
|
+
';',
|
|
379
|
+
'set-option',
|
|
380
|
+
'-t',
|
|
381
|
+
target(pane),
|
|
382
|
+
'status-style',
|
|
383
|
+
'bg=default,fg=colour244',
|
|
384
|
+
';',
|
|
385
|
+
'set-option',
|
|
386
|
+
'-t',
|
|
387
|
+
target(pane),
|
|
388
|
+
'status-left',
|
|
389
|
+
'',
|
|
390
|
+
';',
|
|
391
|
+
'set-option',
|
|
392
|
+
'-t',
|
|
393
|
+
target(pane),
|
|
394
|
+
'status-right',
|
|
395
|
+
literal(hint),
|
|
396
|
+
';',
|
|
397
|
+
'set-option',
|
|
398
|
+
'-t',
|
|
399
|
+
target(pane),
|
|
400
|
+
'window-status-format',
|
|
401
|
+
'',
|
|
402
|
+
';',
|
|
403
|
+
'set-option',
|
|
404
|
+
'-t',
|
|
405
|
+
target(pane),
|
|
406
|
+
'window-status-current-format',
|
|
407
|
+
'',
|
|
408
|
+
';',
|
|
409
|
+
'set-option',
|
|
410
|
+
'-w',
|
|
411
|
+
'-t',
|
|
412
|
+
target(pane),
|
|
413
|
+
'window-size',
|
|
414
|
+
'latest',
|
|
415
|
+
]);
|
|
416
|
+
if (!style.ok)
|
|
417
|
+
throw new BrainyardError('failed', `no such pane: ${pane}`);
|
|
418
|
+
// A server started by an older Brainyard, or by another program on its socket, copies to the clipboard too.
|
|
419
|
+
await copyToClipboard(t);
|
|
420
|
+
const child = spawnInteractive(t.command, ['-L', t.socket, '-f', '/dev/null', 'attach-session', '-t', target(pane)], {
|
|
421
|
+
cwd: process.cwd(),
|
|
422
|
+
env: t.env,
|
|
423
|
+
});
|
|
424
|
+
const ignore = () => undefined;
|
|
425
|
+
process.on('SIGINT', ignore);
|
|
426
|
+
try {
|
|
427
|
+
return await new Promise((done) => {
|
|
428
|
+
child.once('error', () => done(null));
|
|
429
|
+
child.once('exit', (code) => done(code));
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
finally {
|
|
433
|
+
process.off('SIGINT', ignore);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
/** Ends the CLI in the pane (it gets SIGHUP, as when a terminal closes); its conversation stays resumable. */
|
|
437
|
+
export async function closePane(pane, settings = {}) {
|
|
438
|
+
const t = tmux(settings);
|
|
439
|
+
if (!t)
|
|
440
|
+
return false;
|
|
441
|
+
return (await call(t, ['kill-session', '-t', target(pane)])).ok;
|
|
442
|
+
}
|
|
443
|
+
/** Resident memory of each pane's CLI with everything it started, in bytes. */
|
|
444
|
+
export async function paneMemory(panes) {
|
|
445
|
+
const out = new Map();
|
|
446
|
+
const roots = panes.filter((info) => info.pid);
|
|
447
|
+
if (roots.length === 0 || process.platform === 'win32')
|
|
448
|
+
return out;
|
|
449
|
+
const ps = resolveCommand('ps', 'ps', 'BRAINYARD_PS_BIN');
|
|
450
|
+
if (!ps)
|
|
451
|
+
return out;
|
|
452
|
+
const got = await capture(ps, ['-A', '-o', 'pid=,ppid=,rss='], { timeoutMs: 5_000 });
|
|
453
|
+
if (got.code !== 0)
|
|
454
|
+
return out;
|
|
455
|
+
const parent = new Map();
|
|
456
|
+
const rss = new Map();
|
|
457
|
+
for (const line of got.stdout.split('\n')) {
|
|
458
|
+
const [pid, ppid, kb] = line.trim().split(/\s+/).map(Number);
|
|
459
|
+
if (!pid)
|
|
460
|
+
continue;
|
|
461
|
+
parent.set(pid, ppid ?? 0);
|
|
462
|
+
rss.set(pid, (kb ?? 0) * 1024);
|
|
463
|
+
}
|
|
464
|
+
const owner = new Map(roots.map((info) => [info.pid, info.pane]));
|
|
465
|
+
for (const pid of rss.keys()) {
|
|
466
|
+
let at = pid;
|
|
467
|
+
for (let hops = 0; at && hops < 64; hops++) {
|
|
468
|
+
const pane = owner.get(at);
|
|
469
|
+
if (pane) {
|
|
470
|
+
out.set(pane, (out.get(pane) ?? 0) + (rss.get(pid) ?? 0));
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
at = parent.get(at);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return out;
|
|
477
|
+
}
|
|
478
|
+
//# sourceMappingURL=panes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panes.js","sourceRoot":"","sources":["../src/panes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MA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