toolroll 0.9.63 → 0.9.65
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 +51 -0
- package/README.md +15 -5
- package/dist/acp-agents.d.ts +43 -0
- package/dist/acp-agents.js +62 -0
- package/dist/acp-attest.d.ts +44 -0
- package/dist/acp-attest.js +269 -0
- package/dist/acp-check.d.ts +28 -0
- package/dist/acp-check.js +410 -0
- package/dist/acp-client.d.ts +163 -0
- package/dist/acp-client.js +738 -0
- package/dist/acp-inspect.d.ts +23 -0
- package/dist/acp-inspect.js +109 -0
- package/dist/agent-board.d.ts +19 -6
- package/dist/agent-board.js +30 -9
- package/dist/agent-fence.d.ts +50 -2
- package/dist/agent-fence.js +157 -10
- package/dist/agent-pulse.js +9 -2
- package/dist/agent-state-words.d.ts +19 -0
- package/dist/agent-state-words.js +20 -0
- package/dist/agent-state.d.ts +65 -0
- package/dist/agent-state.js +229 -0
- package/dist/agentconfig.js +36 -13
- package/dist/agents-board.d.ts +34 -2
- package/dist/agents-board.js +110 -1
- package/dist/approval-rules-ui.js +2 -2
- package/dist/assignment-delivery.d.ts +14 -0
- package/dist/assignment-delivery.js +13 -0
- package/dist/assignment.js +13 -0
- package/dist/attest.js +7 -0
- package/dist/backup-ui.js +2 -2
- package/dist/browser/THIRD_PARTY_NOTICES.txt +48 -0
- package/dist/browser/terminal.css +37 -0
- package/dist/browser/terminal.js +117 -0
- package/dist/browser/workspace.css +2 -2
- package/dist/browser/workspace.js +42 -38
- package/dist/browser-shell.js +6 -3
- package/dist/browser-workspace.d.ts +235 -1
- package/dist/browser-workspace.js +60 -0
- package/dist/builder.d.ts +6 -1
- package/dist/builder.js +34 -13
- package/dist/chat-actions.d.ts +13 -1
- package/dist/chat-actions.js +197 -15
- package/dist/chat-ask.d.ts +4 -0
- package/dist/chat-ask.js +14 -0
- package/dist/chat-channel.js +20 -0
- package/dist/chat-continuity.js +5 -4
- package/dist/chat-decide.d.ts +0 -14
- package/dist/chat-decide.js +4 -1
- package/dist/chat-delivery.d.ts +9 -0
- package/dist/chat-delivery.js +45 -6
- package/dist/chat-messages.d.ts +8 -0
- package/dist/chat-messages.js +36 -4
- package/dist/check-levels-ui.js +2 -2
- package/dist/checkout-proof.d.ts +28 -0
- package/dist/checkout-proof.js +62 -0
- package/dist/claim.d.ts +12 -0
- package/dist/claim.js +19 -0
- package/dist/cli-help.d.ts +1 -1
- package/dist/cli-help.js +4 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +21 -2
- package/dist/coding-ui.js +6 -4
- package/dist/console-instance.d.ts +124 -0
- package/dist/console-instance.js +337 -0
- package/dist/contracts/chat-actions.d.ts +16 -0
- package/dist/contracts/chat-actions.js +4 -0
- package/dist/contracts/chat-content.d.ts +19 -0
- package/dist/contracts/chat-content.js +6 -0
- package/dist/contracts/console-api.d.ts +12 -4
- package/dist/contracts/console-api.js +12 -4
- package/dist/contracts/flow-card.d.ts +4 -0
- package/dist/contracts/flow-card.js +3 -0
- package/dist/contracts/flow.d.ts +46 -0
- package/dist/contracts/flow.js +11 -2
- package/dist/contracts/lead-tools.d.ts +92 -0
- package/dist/contracts/lead-tools.js +13 -0
- package/dist/contracts/provider.d.ts +11 -1
- package/dist/contracts/provider.js +1 -1
- package/dist/contracts/route.d.ts +76 -1
- package/dist/contracts/route.js +1 -1
- package/dist/contracts/store-json.d.ts +2 -0
- package/dist/control-setup.d.ts +1 -1
- package/dist/control-ui.js +2 -2
- package/dist/converse.d.ts +16 -0
- package/dist/converse.js +32 -4
- package/dist/demo-chat.js +4 -4
- package/dist/demo.js +2 -2
- package/dist/desktop-update-gate.js +6 -0
- package/dist/desktop-update.d.ts +1 -1
- package/dist/discord-chat.js +4 -1
- package/dist/doctor.js +1 -1
- package/dist/egress-bridge.d.ts +17 -0
- package/dist/egress-bridge.js +111 -0
- package/dist/egress.d.ts +119 -0
- package/dist/egress.js +423 -0
- package/dist/exec.d.ts +78 -0
- package/dist/exec.js +367 -9
- package/dist/export-ui.js +2 -2
- package/dist/flow-engine.js +24 -5
- package/dist/flow-gallery-ui.js +2 -2
- package/dist/flow-gallery.js +27 -8
- package/dist/flow-share.js +16 -5
- package/dist/flow-triggers.d.ts +77 -8
- package/dist/flow-triggers.js +517 -70
- package/dist/flows-cli.js +8 -2
- package/dist/flows-ui.d.ts +0 -2
- package/dist/flows-ui.js +52 -4
- package/dist/flows.d.ts +4 -0
- package/dist/flows.js +9 -1
- package/dist/html.d.ts +9 -0
- package/dist/html.js +11 -0
- package/dist/invoke.d.ts +17 -0
- package/dist/invoke.js +217 -21
- package/dist/keys.d.ts +18 -14
- package/dist/keys.js +5 -0
- package/dist/lead-capabilities.js +3 -2
- package/dist/lead-contract.js +2 -0
- package/dist/lead-doors.d.ts +2 -0
- package/dist/lead-doors.js +7 -0
- package/dist/lead-follow.d.ts +2 -0
- package/dist/lead-follow.js +58 -2
- package/dist/lead-progress.js +1 -0
- package/dist/lead-queue-runtime.d.ts +46 -0
- package/dist/lead-queue-runtime.js +191 -0
- package/dist/lead-queue.d.ts +104 -0
- package/dist/lead-queue.js +187 -0
- package/dist/lead-sweep.d.ts +67 -0
- package/dist/lead-sweep.js +99 -0
- package/dist/lead-tools.d.ts +22 -0
- package/dist/lead-tools.js +152 -1
- package/dist/lead.d.ts +13 -5
- package/dist/lead.js +89 -29
- package/dist/limits-ui.d.ts +8 -1
- package/dist/limits-ui.js +26 -0
- package/dist/live-bus.d.ts +8 -0
- package/dist/live-bus.js +40 -4
- package/dist/live-detail.d.ts +27 -0
- package/dist/live-detail.js +57 -0
- package/dist/live-notes.d.ts +20 -0
- package/dist/live-notes.js +47 -0
- package/dist/live-records.d.ts +140 -0
- package/dist/live-records.js +935 -0
- package/dist/live-terminal.d.ts +258 -0
- package/dist/live-terminal.js +649 -0
- package/dist/live.d.ts +38 -27
- package/dist/live.js +142 -124
- package/dist/mcp-oauth.d.ts +6 -3
- package/dist/mcp-oauth.js +8 -4
- package/dist/memory-pass.js +2 -2
- package/dist/mobile-viewport.d.ts +5 -1
- package/dist/mobile-viewport.js +18 -2
- package/dist/model-catalog.js +4 -0
- package/dist/monitoring-ui.js +2 -2
- package/dist/needs-you.d.ts +1 -1
- package/dist/needs-you.js +11 -4
- package/dist/operate.d.ts +2 -0
- package/dist/operate.js +275 -17
- package/dist/passwordless.d.ts +23 -0
- package/dist/passwordless.js +26 -0
- package/dist/peek-cli.d.ts +12 -4
- package/dist/peek-cli.js +19 -11
- package/dist/phase-routing.js +10 -3
- package/dist/planner-source.d.ts +3 -0
- package/dist/planner-source.js +14 -0
- package/dist/planner.d.ts +2 -1
- package/dist/planner.js +7 -1
- package/dist/policy-ui.js +2 -2
- package/dist/policy.d.ts +1 -20
- package/dist/policy.js +29 -2
- package/dist/project-delete-ui.d.ts +12 -0
- package/dist/project-delete-ui.js +41 -9
- package/dist/project-delete.js +2 -2
- package/dist/project-memory.d.ts +3 -1
- package/dist/project-memory.js +57 -25
- package/dist/project-tools.d.ts +5 -3
- package/dist/project-tools.js +12 -9
- package/dist/provider-auth.d.ts +4 -3
- package/dist/provider-auth.js +5 -4
- package/dist/provider-connection.d.ts +2 -1
- package/dist/provider-connection.js +5 -0
- package/dist/provider.d.ts +25 -2
- package/dist/provider.js +63 -9
- package/dist/pull-request-ui.js +2 -2
- package/dist/push.js +1 -1
- package/dist/quick-start.d.ts +24 -0
- package/dist/quick-start.js +127 -0
- package/dist/release.d.ts +3 -0
- package/dist/release.js +14 -8
- package/dist/request-budget-ui.js +2 -2
- package/dist/result-review.d.ts +1 -1
- package/dist/result-review.js +9 -3
- package/dist/retention-ui.js +2 -2
- package/dist/retention.js +10 -1
- package/dist/run-efficiency.d.ts +73 -0
- package/dist/run-efficiency.js +228 -0
- package/dist/runner.d.ts +5 -1
- package/dist/runner.js +22 -1
- package/dist/scope.d.ts +170 -5
- package/dist/scope.js +251 -31
- package/dist/scout-net.d.ts +4 -1
- package/dist/scout-net.js +37 -12
- package/dist/scout.d.ts +20 -6
- package/dist/scout.js +27 -3
- package/dist/serve.js +247 -40
- package/dist/server/chat.d.ts +1 -1
- package/dist/server/chat.js +122 -31
- package/dist/server/chrome.d.ts +6 -1
- package/dist/server/chrome.js +18 -7
- package/dist/server/console.css +52 -38
- package/dist/server/flows.js +38 -8
- package/dist/server/guards.d.ts +1 -0
- package/dist/server/guards.js +23 -9
- package/dist/server/http.d.ts +7 -0
- package/dist/server/http.js +3 -2
- package/dist/server/live.d.ts +34 -1
- package/dist/server/live.js +39 -17
- package/dist/server/pages-assets.js +5 -0
- package/dist/server/pages.js +90 -13
- package/dist/server/people-tokens.d.ts +3 -0
- package/dist/server/people-tokens.js +55 -17
- package/dist/server/remote-hooks.js +12 -6
- package/dist/server/remote.d.ts +2 -1
- package/dist/server/remote.js +14 -5
- package/dist/server/render-chat.d.ts +12 -3
- package/dist/server/render-chat.js +47 -16
- package/dist/server/render-pages.d.ts +4 -1
- package/dist/server/render-pages.js +5 -4
- package/dist/server/render-people.d.ts +3 -2
- package/dist/server/render-people.js +3 -2
- package/dist/server/render-results.d.ts +18 -2
- package/dist/server/render-results.js +37 -28
- package/dist/server/render-settings.js +6 -5
- package/dist/server/render-tasks.d.ts +35 -10
- package/dist/server/render-tasks.js +110 -27
- package/dist/server/request-context.d.ts +2 -0
- package/dist/server/request-context.js +2 -1
- package/dist/server/route-table.d.ts +3 -0
- package/dist/server/route-table.js +46 -5
- package/dist/server/runtime.d.ts +33 -2
- package/dist/server/session.d.ts +25 -1
- package/dist/server/session.js +18 -4
- package/dist/server/settings.js +121 -10
- package/dist/server/sweeps.d.ts +4 -0
- package/dist/server/sweeps.js +58 -0
- package/dist/server/task-views.d.ts +2 -1
- package/dist/server/task-views.js +96 -6
- package/dist/server/tasks.js +320 -74
- package/dist/server/terminals.d.ts +31 -0
- package/dist/server/terminals.js +365 -0
- package/dist/setup-guide.js +3 -2
- package/dist/slack-chat.js +4 -1
- package/dist/spend-ui.js +3 -3
- package/dist/spend.js +2 -1
- package/dist/steer-capabilities.d.ts +32 -0
- package/dist/steer-capabilities.js +60 -0
- package/dist/steer-controls.d.ts +14 -0
- package/dist/steer-controls.js +36 -0
- package/dist/steer-status.js +2 -2
- package/dist/storage-ui.js +4 -4
- package/dist/store-baseline.d.ts +1 -1
- package/dist/store-baseline.js +1 -1
- package/dist/store.d.ts +430 -15
- package/dist/store.js +1041 -52
- package/dist/subagent-desk.js +1 -1
- package/dist/summary.js +3 -0
- package/dist/task-source.d.ts +58 -0
- package/dist/task-source.js +93 -0
- package/dist/team-leads.js +1 -1
- package/dist/teams-chat.js +4 -1
- package/dist/telegram-lead.d.ts +3 -0
- package/dist/telegram-lead.js +44 -7
- package/dist/telegram.d.ts +11 -2
- package/dist/telegram.js +51 -17
- package/dist/terminal-catalog.d.ts +11 -0
- package/dist/terminal-catalog.js +129 -0
- package/dist/text-limits.d.ts +2 -0
- package/dist/text-limits.js +2 -0
- package/dist/tool-broker.d.ts +2 -0
- package/dist/tool-broker.js +1 -0
- package/dist/toolroll-update-ui.js +2 -2
- package/dist/toolroll-update.js +13 -3
- package/dist/tools-ui.js +2 -2
- package/dist/webhook-limits.d.ts +23 -0
- package/dist/webhook-limits.js +30 -0
- package/dist/webhook-readers.d.ts +56 -0
- package/dist/webhook-readers.js +138 -0
- package/dist/webhook-signing.d.ts +27 -0
- package/dist/webhook-signing.js +119 -0
- package/dist/work-index.d.ts +29 -0
- package/dist/work-index.js +16 -2
- package/dist/workspace-revision.js +3 -1
- package/package.json +11 -2
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { type Git } from "./teardown-git.js";
|
|
2
|
+
export type TerminalProgram = "claude" | "codex" | "shell";
|
|
3
|
+
export declare const TERMINAL_PROGRAMS: readonly TerminalProgram[];
|
|
4
|
+
/** At most this many running sessions per console, and this many kept at all (ended ones count until removed). */
|
|
5
|
+
export declare const MAX_LIVE_TERMINALS = 8;
|
|
6
|
+
export declare const MAX_KEPT_TERMINALS = 16;
|
|
7
|
+
/** At most this many pages attached to one session (a desktop, a phone, a spare tab or two). */
|
|
8
|
+
export declare const MAX_VIEWERS = 4;
|
|
9
|
+
/** Raw output kept per session for a page that attaches later. */
|
|
10
|
+
export declare const SCROLLBACK_BYTES: number;
|
|
11
|
+
/** After SIGHUP, the terminal's processes have this long before SIGKILL. */
|
|
12
|
+
export declare const CLOSE_GRACE_MS = 2000;
|
|
13
|
+
/** Typed input not yet read by the program, per terminal: past this, more is refused until it reads. */
|
|
14
|
+
export declare const MAX_PENDING_INPUT: number;
|
|
15
|
+
/** How often a running terminal's processes are noted, so ones that outlive their parent are still known. */
|
|
16
|
+
export declare const CUSTODY_REFRESH_MS = 5000;
|
|
17
|
+
export declare const COLS: {
|
|
18
|
+
readonly min: 2;
|
|
19
|
+
readonly max: 500;
|
|
20
|
+
};
|
|
21
|
+
export declare const ROWS: {
|
|
22
|
+
readonly min: 1;
|
|
23
|
+
readonly max: 200;
|
|
24
|
+
};
|
|
25
|
+
/** The slice of node-pty this module uses, so tests can stand a fake in. */
|
|
26
|
+
export type Pty = {
|
|
27
|
+
readonly pid: number;
|
|
28
|
+
/** The terminal device its processes have as their controlling terminal ("ttys012", "pts/3"); null when unknown. */
|
|
29
|
+
readonly tty: string | null;
|
|
30
|
+
/** Typed bytes queued for the program and not yet taken by the kernel; Infinity when it can't be measured. */
|
|
31
|
+
pendingInput(): number;
|
|
32
|
+
onData(listener: (data: string) => void): unknown;
|
|
33
|
+
onExit(listener: (exit: {
|
|
34
|
+
exitCode: number;
|
|
35
|
+
signal?: number;
|
|
36
|
+
}) => void): unknown;
|
|
37
|
+
write(data: string): void;
|
|
38
|
+
resize(cols: number, rows: number): void;
|
|
39
|
+
kill(signal?: string): void;
|
|
40
|
+
};
|
|
41
|
+
export type PtySpawn = (file: string, args: string[], options: {
|
|
42
|
+
cwd: string;
|
|
43
|
+
env: NodeJS.ProcessEnv;
|
|
44
|
+
cols: number;
|
|
45
|
+
rows: number;
|
|
46
|
+
}) => Pty;
|
|
47
|
+
/** A device path as `ps` prints it: /dev/ttys012 → ttys012, /dev/pts/3 → pts/3. */
|
|
48
|
+
export declare const ttyName: (path: unknown) => string | null;
|
|
49
|
+
/**
|
|
50
|
+
* node-pty's write queue (@lydell/node-pty 1.2.0-beta.15, pinned exactly): typed input waits in its
|
|
51
|
+
* `_writeStream._writeQueue` until the kernel takes it. A shape this doesn't recognise is unmeasurable: Infinity, so
|
|
52
|
+
* input is refused rather than queued without bound (a test pins the shape against the installed package).
|
|
53
|
+
*/
|
|
54
|
+
export declare function pendingInputOf(pty: unknown): number;
|
|
55
|
+
/** node-pty, if this install has it (an optional dependency with prebuilt binaries); null when it doesn't load. */
|
|
56
|
+
export declare function loadPtySpawn(): PtySpawn | null;
|
|
57
|
+
/** Raw output, oldest dropped first, never more than `cap` bytes. */
|
|
58
|
+
export declare class Scrollback {
|
|
59
|
+
private readonly cap;
|
|
60
|
+
private chunks;
|
|
61
|
+
private size;
|
|
62
|
+
constructor(cap?: number);
|
|
63
|
+
push(chunk: Buffer): void;
|
|
64
|
+
bytes(): Buffer;
|
|
65
|
+
get length(): number;
|
|
66
|
+
}
|
|
67
|
+
/** One attached page. The host never waits on it. */
|
|
68
|
+
export type TerminalViewer = {
|
|
69
|
+
output(data: Buffer): void;
|
|
70
|
+
control(message: TerminalControl): void;
|
|
71
|
+
};
|
|
72
|
+
export type TerminalControl = {
|
|
73
|
+
t: "hello";
|
|
74
|
+
cols: number;
|
|
75
|
+
rows: number;
|
|
76
|
+
program: TerminalProgram;
|
|
77
|
+
ended: boolean;
|
|
78
|
+
} | {
|
|
79
|
+
t: "exit";
|
|
80
|
+
code: number | null;
|
|
81
|
+
signal: number | null;
|
|
82
|
+
}
|
|
83
|
+
/** The program isn't reading what's typed: input waits until it does. */
|
|
84
|
+
| {
|
|
85
|
+
t: "input-full";
|
|
86
|
+
};
|
|
87
|
+
export type TerminalSummary = {
|
|
88
|
+
id: string;
|
|
89
|
+
owner: string;
|
|
90
|
+
/** The owner's account generation at start: a rotated credential or a re-sign-in elsewhere no longer reaches it. */
|
|
91
|
+
generation: number;
|
|
92
|
+
repo: string;
|
|
93
|
+
program: TerminalProgram;
|
|
94
|
+
branch: string;
|
|
95
|
+
worktree: string;
|
|
96
|
+
startedAt: string;
|
|
97
|
+
endedAt: string | null;
|
|
98
|
+
exit: {
|
|
99
|
+
code: number | null;
|
|
100
|
+
signal: number | null;
|
|
101
|
+
} | null;
|
|
102
|
+
/** Who ended it, when Toolroll did. */
|
|
103
|
+
endedBy: "owner" | "console" | null;
|
|
104
|
+
/**
|
|
105
|
+
* After it ends: "clean" once every process known to be its own is proved gone; "uncertain" when one outlived
|
|
106
|
+
* SIGKILL or the process table couldn't be read. Null while it runs or is being swept.
|
|
107
|
+
*/
|
|
108
|
+
cleanup: "clean" | "uncertain" | null;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Where a console's terminals are written down for the updater, which runs as another process (terminal-catalog.ts):
|
|
112
|
+
* a start is reserved before any work and refused while an update owns admission; a program is running until its
|
|
113
|
+
* sweep ends. The default keeps nothing (tests, a console without a database file).
|
|
114
|
+
*/
|
|
115
|
+
export type TerminalLedger = {
|
|
116
|
+
/** Throws (with the reason in words) when no terminal may start now. */
|
|
117
|
+
reserve(id: string): void;
|
|
118
|
+
running(id: string): void;
|
|
119
|
+
release(id: string, cleanup: "clean" | "uncertain" | null): void;
|
|
120
|
+
/** The terminal is removed (its worktree went after a clean sweep): nothing of it is left to count. */
|
|
121
|
+
forget(id: string): void;
|
|
122
|
+
};
|
|
123
|
+
export declare class TerminalError extends Error {
|
|
124
|
+
constructor(message: string);
|
|
125
|
+
}
|
|
126
|
+
export type TerminalHostOptions = {
|
|
127
|
+
spawn: PtySpawn;
|
|
128
|
+
worktreeRoot: string;
|
|
129
|
+
/** Git for making and removing worktrees: hardened by default (teardown-git.ts), since a build can write .git/config. */
|
|
130
|
+
git?: Git;
|
|
131
|
+
/** How each program starts; the default looks up `claude`, `codex` and the login shell on PATH. */
|
|
132
|
+
programs?: Partial<Record<TerminalProgram, {
|
|
133
|
+
file: string;
|
|
134
|
+
args: string[];
|
|
135
|
+
}>>;
|
|
136
|
+
env?: () => NodeJS.ProcessEnv;
|
|
137
|
+
clock?: () => Date;
|
|
138
|
+
/** Start, close and remove, for the event log (never input or output). */
|
|
139
|
+
record?: (event: "start" | "close" | "remove" | "exit", session: TerminalSummary) => void;
|
|
140
|
+
maxSessions?: number;
|
|
141
|
+
scrollbackBytes?: number;
|
|
142
|
+
closeGraceMs?: number;
|
|
143
|
+
ledger?: TerminalLedger;
|
|
144
|
+
/** The process table (tests stand a failing one in); null when it can't be read. */
|
|
145
|
+
processes?: () => ProcessTable | null;
|
|
146
|
+
/** Who else works in a worktree (tests stand theirs in); default worktreeResidents. */
|
|
147
|
+
residents?: (table: ProcessTable, worktreeReal: string, terminalStartedMs: number) => Set<number> | null;
|
|
148
|
+
};
|
|
149
|
+
/** The executable on PATH, or null. */
|
|
150
|
+
export declare function onPath(name: string, env?: NodeJS.ProcessEnv): string | null;
|
|
151
|
+
export declare class TerminalHost {
|
|
152
|
+
private readonly options;
|
|
153
|
+
private readonly sessions;
|
|
154
|
+
private starting;
|
|
155
|
+
private stopped;
|
|
156
|
+
private readonly clock;
|
|
157
|
+
private readonly env;
|
|
158
|
+
private readonly ledger;
|
|
159
|
+
private readonly processes;
|
|
160
|
+
private custodyTimer;
|
|
161
|
+
constructor(options: TerminalHostOptions);
|
|
162
|
+
private summary;
|
|
163
|
+
/** This person's sessions, newest first. */
|
|
164
|
+
list(owner: string): TerminalSummary[];
|
|
165
|
+
get(id: string): TerminalSummary | null;
|
|
166
|
+
private running;
|
|
167
|
+
/**
|
|
168
|
+
* Make the worktree and start the program in it. `admit` is asked again right before the program starts (after the
|
|
169
|
+
* slow git work): a person whose access or project went in between starts nothing.
|
|
170
|
+
*/
|
|
171
|
+
start({ name: owner, generation }: {
|
|
172
|
+
name: string;
|
|
173
|
+
generation: number;
|
|
174
|
+
}, repoPath: string, program: TerminalProgram, size?: {
|
|
175
|
+
cols: number;
|
|
176
|
+
rows: number;
|
|
177
|
+
}, admit?: () => string | null): Promise<TerminalSummary>;
|
|
178
|
+
/** Attach a page: it gets the scrollback, then `hello`, then live output. Returns its detach. */
|
|
179
|
+
attach(id: string, viewer: TerminalViewer): () => void;
|
|
180
|
+
/** How many pages are attached now. */
|
|
181
|
+
viewerCount(id: string): number;
|
|
182
|
+
/** Type into the program. False (nothing queued) while it has MAX_PENDING_INPUT unread, or can't be measured. */
|
|
183
|
+
input(id: string, data: string): boolean;
|
|
184
|
+
resize(id: string, cols: number, rows: number): void;
|
|
185
|
+
private noteTimer;
|
|
186
|
+
/** Activity (output, typing) usually means a command started: note processes shortly after, at most every 250 ms. */
|
|
187
|
+
private noteSoon;
|
|
188
|
+
/** Note every running terminal's processes now, and keep doing so while any runs. */
|
|
189
|
+
private noteCustody;
|
|
190
|
+
/**
|
|
191
|
+
* End the program and everything that is its own: SIGHUP to every member (an interactive shell gives each job its own
|
|
192
|
+
* process group, so the leader's group is not enough), then SIGKILL, re-reading the process table each time so a
|
|
193
|
+
* child started during the close is caught too. Membership is the leader's descendants, every process with this
|
|
194
|
+
* terminal as its controlling terminal (started before the program ended), and every one noted while it ran, by pid
|
|
195
|
+
* and start time. A process that detached itself from the terminal AND its parents before it was noted is not seen —
|
|
196
|
+
* the same as any terminal. Resolves when the sweep is done; never waits without bound.
|
|
197
|
+
*/
|
|
198
|
+
close(id: string, by?: "owner" | "console"): Promise<void>;
|
|
199
|
+
private sweep;
|
|
200
|
+
/** Drop an ended session and its worktree (the branch stays: the work is there). Only after a clean sweep. */
|
|
201
|
+
remove(id: string): Promise<void>;
|
|
202
|
+
/** Whether new sessions may start (false once the console is stopping). */
|
|
203
|
+
get admitting(): boolean;
|
|
204
|
+
/**
|
|
205
|
+
* The console is stopping: admit nothing more, end every program, and wait (each sweep is bounded) for them.
|
|
206
|
+
* `clean` is false when any terminal's processes couldn't be proved gone.
|
|
207
|
+
*/
|
|
208
|
+
stop(): Promise<{
|
|
209
|
+
clean: boolean;
|
|
210
|
+
}>;
|
|
211
|
+
}
|
|
212
|
+
/** One process: its parent, owner, controlling terminal and start time. */
|
|
213
|
+
export type ProcessTable = Map<number, {
|
|
214
|
+
ppid: number;
|
|
215
|
+
uid: number;
|
|
216
|
+
tty: string;
|
|
217
|
+
started: string;
|
|
218
|
+
}>;
|
|
219
|
+
/** Every process from `ps` (macOS and Linux take these options); null when it can't be read, never an empty guess. */
|
|
220
|
+
export declare function readProcessTable(): ProcessTable | null;
|
|
221
|
+
/**
|
|
222
|
+
* A terminal's processes in this table, by pid and start time: what was noted while it ran (still the same process),
|
|
223
|
+
* the leader, everything whose controlling terminal is its terminal and that started before it ended (a later process
|
|
224
|
+
* on a reused device is someone else's), and every descendant of those. Never this console itself.
|
|
225
|
+
*/
|
|
226
|
+
export declare function membersOf(table: ProcessTable, session: {
|
|
227
|
+
leader: number;
|
|
228
|
+
tty: string | null;
|
|
229
|
+
known: ReadonlyMap<number, string>;
|
|
230
|
+
exitedAt: number | null;
|
|
231
|
+
}): Map<number, string>;
|
|
232
|
+
/**
|
|
233
|
+
* Each listed process's working directory (Linux: /proc; macOS: lsof), and which ones couldn't be read (a setgid
|
|
234
|
+
* helper such as ssh-agent is unreadable even to its own user). Null when the lookup itself failed: a timeout, a signal
|
|
235
|
+
* or partial output is never a smaller answer. A process gone in between is simply absent.
|
|
236
|
+
*/
|
|
237
|
+
export declare function cwdsOf(pids: readonly number[]): {
|
|
238
|
+
cwds: Map<number, string>;
|
|
239
|
+
unreadable: number[];
|
|
240
|
+
} | null;
|
|
241
|
+
/**
|
|
242
|
+
* This user's processes working inside a terminal's worktree, whoever started them. They are never signalled (one may
|
|
243
|
+
* be the person's own shell or a server they started from elsewhere); while any remains, the terminal's cleanup is
|
|
244
|
+
* uncertain and its worktree stays. Null when that can't be known: the lookup failed, or a process whose working
|
|
245
|
+
* directory can't be read started after the terminal did (one from before — a login's ssh-agent — can't be its own).
|
|
246
|
+
*/
|
|
247
|
+
export declare function worktreeResidents(table: ProcessTable, worktreeReal: string, terminalStartedMs?: number): Set<number> | null;
|
|
248
|
+
/** One client frame, read strictly; null closes the socket. */
|
|
249
|
+
export type TerminalInput = {
|
|
250
|
+
t: "in";
|
|
251
|
+
d: string;
|
|
252
|
+
} | {
|
|
253
|
+
t: "resize";
|
|
254
|
+
cols: number;
|
|
255
|
+
rows: number;
|
|
256
|
+
};
|
|
257
|
+
export declare const MAX_FRAME_BYTES: number;
|
|
258
|
+
export declare function parseTerminalFrame(text: string): TerminalInput | null;
|