@pentoshi/clai 3.9.4 → 3.9.6
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/dist/agent/context-manager.d.ts +4 -4
- package/dist/agent/context-manager.js +4 -4
- package/dist/agent/reliability-policy.d.ts +2 -2
- package/dist/agent/request-budget.d.ts +1 -1
- package/dist/agent/request-budget.js +1 -1
- package/dist/agent/request-budget.js.map +1 -1
- package/dist/app/controllers/session-controller.d.ts +0 -8
- package/dist/app/controllers/session-controller.js +4 -20
- package/dist/app/controllers/session-controller.js.map +1 -1
- package/dist/index.js +8 -21
- package/dist/index.js.map +1 -1
- package/dist/repl.js +0 -10
- package/dist/repl.js.map +1 -1
- package/dist/store/config.js +1 -1
- package/dist/store/config.js.map +1 -1
- package/dist/tools/definitions.js +0 -95
- package/dist/tools/definitions.js.map +1 -1
- package/dist/tools/jobs.js +70 -2
- package/dist/tools/jobs.js.map +1 -1
- package/dist/tools/registry.js +0 -4
- package/dist/tools/registry.js.map +1 -1
- package/dist/tui-v2/bootstrap/composition-root.d.ts +0 -3
- package/dist/tui-v2/bootstrap/composition-root.js +0 -3
- package/dist/tui-v2/bootstrap/composition-root.js.map +1 -1
- package/dist/tui-v2/bootstrap/start-tui-v2.js +0 -10
- package/dist/tui-v2/bootstrap/start-tui-v2.js.map +1 -1
- package/dist/types.d.ts +0 -5
- package/dist/version.generated.d.ts +2 -2
- package/dist/version.generated.js +2 -2
- package/package.json +1 -1
- package/dist/app/adapters/current-interactive-sessions-adapter.d.ts +0 -4
- package/dist/app/adapters/current-interactive-sessions-adapter.js +0 -11
- package/dist/app/adapters/current-interactive-sessions-adapter.js.map +0 -1
- package/dist/app/controllers/cancel-all-result.d.ts +0 -8
- package/dist/app/controllers/cancel-all-result.js +0 -32
- package/dist/app/controllers/cancel-all-result.js.map +0 -1
- package/dist/app/ports/interactive-sessions-port.d.ts +0 -21
- package/dist/app/ports/interactive-sessions-port.js +0 -9
- package/dist/app/ports/interactive-sessions-port.js.map +0 -1
- package/dist/interactive-session/artifact-writer.d.ts +0 -54
- package/dist/interactive-session/artifact-writer.js +0 -161
- package/dist/interactive-session/artifact-writer.js.map +0 -1
- package/dist/interactive-session/cleanup.d.ts +0 -36
- package/dist/interactive-session/cleanup.js +0 -157
- package/dist/interactive-session/cleanup.js.map +0 -1
- package/dist/interactive-session/config.d.ts +0 -118
- package/dist/interactive-session/config.js +0 -141
- package/dist/interactive-session/config.js.map +0 -1
- package/dist/interactive-session/input-policy.d.ts +0 -41
- package/dist/interactive-session/input-policy.js +0 -163
- package/dist/interactive-session/input-policy.js.map +0 -1
- package/dist/interactive-session/manager.d.ts +0 -107
- package/dist/interactive-session/manager.js +0 -927
- package/dist/interactive-session/manager.js.map +0 -1
- package/dist/interactive-session/output-store.d.ts +0 -81
- package/dist/interactive-session/output-store.js +0 -239
- package/dist/interactive-session/output-store.js.map +0 -1
- package/dist/interactive-session/output-view.d.ts +0 -20
- package/dist/interactive-session/output-view.js +0 -142
- package/dist/interactive-session/output-view.js.map +0 -1
- package/dist/interactive-session/recovery-journal.d.ts +0 -55
- package/dist/interactive-session/recovery-journal.js +0 -115
- package/dist/interactive-session/recovery-journal.js.map +0 -1
- package/dist/interactive-session/registry.d.ts +0 -59
- package/dist/interactive-session/registry.js +0 -170
- package/dist/interactive-session/registry.js.map +0 -1
- package/dist/interactive-session/runtime.d.ts +0 -107
- package/dist/interactive-session/runtime.js +0 -191
- package/dist/interactive-session/runtime.js.map +0 -1
- package/dist/interactive-session/session-runtime.d.ts +0 -50
- package/dist/interactive-session/session-runtime.js +0 -63
- package/dist/interactive-session/session-runtime.js.map +0 -1
- package/dist/interactive-session/streaming-redactor.d.ts +0 -53
- package/dist/interactive-session/streaming-redactor.js +0 -263
- package/dist/interactive-session/streaming-redactor.js.map +0 -1
- package/dist/interactive-session/telemetry.d.ts +0 -30
- package/dist/interactive-session/telemetry.js +0 -47
- package/dist/interactive-session/telemetry.js.map +0 -1
- package/dist/interactive-session/transport-factory.d.ts +0 -8
- package/dist/interactive-session/transport-factory.js +0 -16
- package/dist/interactive-session/transport-factory.js.map +0 -1
- package/dist/interactive-session/transport-node-pty.d.ts +0 -49
- package/dist/interactive-session/transport-node-pty.js +0 -219
- package/dist/interactive-session/transport-node-pty.js.map +0 -1
- package/dist/interactive-session/transport-pipe.d.ts +0 -9
- package/dist/interactive-session/transport-pipe.js +0 -215
- package/dist/interactive-session/transport-pipe.js.map +0 -1
- package/dist/interactive-session/transport.d.ts +0 -104
- package/dist/interactive-session/transport.js +0 -89
- package/dist/interactive-session/transport.js.map +0 -1
- package/dist/interactive-session/types.d.ts +0 -254
- package/dist/interactive-session/types.js +0 -191
- package/dist/interactive-session/types.js.map +0 -1
- package/dist/os/process-identity.d.ts +0 -46
- package/dist/os/process-identity.js +0 -147
- package/dist/os/process-identity.js.map +0 -1
- package/dist/tools/interactive-session-tools.d.ts +0 -11
- package/dist/tools/interactive-session-tools.js +0 -261
- package/dist/tools/interactive-session-tools.js.map +0 -1
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Optional PTY transport.
|
|
3
|
-
*
|
|
4
|
-
* `node-pty` is an optional dependency loaded through a lazy dynamic import so
|
|
5
|
-
* an absent or unloadable native artifact degrades capability instead of failing
|
|
6
|
-
* application startup. Capability is per-platform and only claimed after the
|
|
7
|
-
* module actually loads in this packaged layout; the release pipeline must prove
|
|
8
|
-
* load/spawn/resize/cleanup on a matching-target runner before advertising it.
|
|
9
|
-
*/
|
|
10
|
-
import { processIdentityTracker } from "../os/process-identity.js";
|
|
11
|
-
import { supportsProcessGroups, terminateProcessTree, } from "../os/process-tree.js";
|
|
12
|
-
import { resolveShell } from "../tools/shell.js";
|
|
13
|
-
import { LaunchFailure, ptyControlBytes, } from "./transport.js";
|
|
14
|
-
const MODULE_SPECIFIER = "node-pty";
|
|
15
|
-
let loadPromise;
|
|
16
|
-
let loadFailureReason;
|
|
17
|
-
/** Lazily load node-pty at most once per process. */
|
|
18
|
-
async function loadNodePty() {
|
|
19
|
-
loadPromise ??= (async () => {
|
|
20
|
-
try {
|
|
21
|
-
// Indirect specifier keeps the optional dependency out of the static
|
|
22
|
-
// import graph so startup, pipe mode, and legacy tools never load it.
|
|
23
|
-
const loaded = (await import(/* @vite-ignore */ MODULE_SPECIFIER));
|
|
24
|
-
const module = "spawn" in loaded ? loaded : loaded.default;
|
|
25
|
-
if (typeof module?.spawn !== "function") {
|
|
26
|
-
loadFailureReason = "node-pty loaded without a usable spawn export";
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
return module;
|
|
30
|
-
}
|
|
31
|
-
catch (error) {
|
|
32
|
-
loadFailureReason =
|
|
33
|
-
error instanceof Error && error.message.includes("Cannot find module")
|
|
34
|
-
? "node-pty is not installed for this target"
|
|
35
|
-
: "node-pty native module failed to load for this target";
|
|
36
|
-
return undefined;
|
|
37
|
-
}
|
|
38
|
-
})();
|
|
39
|
-
return await loadPromise;
|
|
40
|
-
}
|
|
41
|
-
export async function probePtyCapability(platform = process.platform) {
|
|
42
|
-
const module = await loadNodePty();
|
|
43
|
-
if (module)
|
|
44
|
-
return { available: true, platform };
|
|
45
|
-
return {
|
|
46
|
-
available: false,
|
|
47
|
-
platform,
|
|
48
|
-
reason: loadFailureReason ?? "PTY capability is unavailable on this target",
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
/** Test seam: reset the memoized load so capability can be re-evaluated. */
|
|
52
|
-
export function resetPtyCapabilityCache() {
|
|
53
|
-
loadPromise = undefined;
|
|
54
|
-
loadFailureReason = undefined;
|
|
55
|
-
}
|
|
56
|
-
class NodePtyTransport {
|
|
57
|
-
pty;
|
|
58
|
-
kind = "pty";
|
|
59
|
-
pid;
|
|
60
|
-
processGroupId;
|
|
61
|
-
identity;
|
|
62
|
-
outputListeners = new Set();
|
|
63
|
-
exitListeners = new Set();
|
|
64
|
-
subscriptions = [];
|
|
65
|
-
inputClosed = false;
|
|
66
|
-
exited = false;
|
|
67
|
-
disposed = false;
|
|
68
|
-
constructor(pty) {
|
|
69
|
-
this.pty = pty;
|
|
70
|
-
this.pid = pty.pid;
|
|
71
|
-
// A PTY child leads its own session, so the pid doubles as the group id.
|
|
72
|
-
this.processGroupId = supportsProcessGroups() ? pty.pid : undefined;
|
|
73
|
-
this.identity = processIdentityTracker.capture(pty.pid, { refresh: true });
|
|
74
|
-
this.subscriptions.push(pty.onData((data) => {
|
|
75
|
-
const bytes = typeof data === "string"
|
|
76
|
-
? new Uint8Array(Buffer.from(data, "utf8"))
|
|
77
|
-
: new Uint8Array(data);
|
|
78
|
-
const event = {
|
|
79
|
-
stream: "terminal",
|
|
80
|
-
bytes,
|
|
81
|
-
observedAt: Date.now(),
|
|
82
|
-
};
|
|
83
|
-
for (const listener of [...this.outputListeners])
|
|
84
|
-
listener(event);
|
|
85
|
-
}));
|
|
86
|
-
this.subscriptions.push(pty.onExit(({ exitCode, signal }) => {
|
|
87
|
-
this.exited = true;
|
|
88
|
-
const outcome = {
|
|
89
|
-
endedAt: Date.now(),
|
|
90
|
-
exitCode,
|
|
91
|
-
...(signal !== undefined ? { signal: String(signal) } : {}),
|
|
92
|
-
};
|
|
93
|
-
for (const listener of [...this.exitListeners])
|
|
94
|
-
listener(outcome);
|
|
95
|
-
}));
|
|
96
|
-
}
|
|
97
|
-
async write(bytes) {
|
|
98
|
-
if (this.inputClosed || this.exited) {
|
|
99
|
-
return { status: "not-delivered", deliveredBytes: 0 };
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
// node-pty accepts latin1-safe strings; binary-preserving round trip.
|
|
103
|
-
this.pty.write(Buffer.from(bytes).toString("binary"));
|
|
104
|
-
return { status: "delivered", deliveredBytes: bytes.length };
|
|
105
|
-
}
|
|
106
|
-
catch (error) {
|
|
107
|
-
// A throwing master write cannot prove whether the child saw the bytes.
|
|
108
|
-
return { status: "unknown", deliveredBytes: 0, cause: error };
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
async control(action) {
|
|
112
|
-
const bytes = ptyControlBytes(action);
|
|
113
|
-
if (!bytes)
|
|
114
|
-
return { status: "not-delivered", deliveredBytes: 0 };
|
|
115
|
-
return await this.write(bytes);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* A pseudoterminal has no portable half-close: send the platform EOF sequence
|
|
119
|
-
* once, then treat manager-level input as permanently closed.
|
|
120
|
-
*/
|
|
121
|
-
async closeInput() {
|
|
122
|
-
if (this.inputClosed)
|
|
123
|
-
return { status: "delivered", deliveredBytes: 0 };
|
|
124
|
-
const bytes = ptyControlBytes("eof");
|
|
125
|
-
const result = bytes
|
|
126
|
-
? await this.write(bytes)
|
|
127
|
-
: { status: "delivered", deliveredBytes: 0 };
|
|
128
|
-
this.inputClosed = true;
|
|
129
|
-
return result;
|
|
130
|
-
}
|
|
131
|
-
async resize(dimensions) {
|
|
132
|
-
this.pty.resize(dimensions.columns, dimensions.rows);
|
|
133
|
-
}
|
|
134
|
-
pauseOutput() {
|
|
135
|
-
this.pty.pause();
|
|
136
|
-
}
|
|
137
|
-
resumeOutput() {
|
|
138
|
-
this.pty.resume();
|
|
139
|
-
}
|
|
140
|
-
async requestTreeTermination(kind) {
|
|
141
|
-
return terminateProcessTree(this.pid, {
|
|
142
|
-
signal: kind === "graceful" ? "SIGTERM" : "SIGKILL",
|
|
143
|
-
...(this.processGroupId !== undefined ? { processGroupId: this.processGroupId } : {}),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
onOutput(listener) {
|
|
147
|
-
this.outputListeners.add(listener);
|
|
148
|
-
return () => {
|
|
149
|
-
this.outputListeners.delete(listener);
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
onExit(listener) {
|
|
153
|
-
this.exitListeners.add(listener);
|
|
154
|
-
return () => {
|
|
155
|
-
this.exitListeners.delete(listener);
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
async dispose() {
|
|
159
|
-
if (this.disposed)
|
|
160
|
-
return;
|
|
161
|
-
this.disposed = true;
|
|
162
|
-
this.outputListeners.clear();
|
|
163
|
-
this.exitListeners.clear();
|
|
164
|
-
for (const subscription of this.subscriptions) {
|
|
165
|
-
try {
|
|
166
|
-
subscription.dispose();
|
|
167
|
-
}
|
|
168
|
-
catch {
|
|
169
|
-
// Disposing an already-exited pty is not an error.
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
this.subscriptions.length = 0;
|
|
173
|
-
processIdentityTracker.forget(this.pid);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function stringEnv(env) {
|
|
177
|
-
const result = {};
|
|
178
|
-
for (const [key, value] of Object.entries(env)) {
|
|
179
|
-
if (typeof value === "string")
|
|
180
|
-
result[key] = value;
|
|
181
|
-
}
|
|
182
|
-
return result;
|
|
183
|
-
}
|
|
184
|
-
export async function startPtyTransport(request, overrides = {}) {
|
|
185
|
-
const module = overrides.module ?? await loadNodePty();
|
|
186
|
-
if (!module) {
|
|
187
|
-
throw new LaunchFailure("PTY_UNAVAILABLE", loadFailureReason ?? "PTY capability is unavailable on this target.", false, false);
|
|
188
|
-
}
|
|
189
|
-
const shell = overrides.shell === undefined ? resolveShell() : overrides.shell;
|
|
190
|
-
if (!shell) {
|
|
191
|
-
throw new LaunchFailure("SHELL_NOT_FOUND", "No usable command shell was found for an interactive session.", false, false);
|
|
192
|
-
}
|
|
193
|
-
let pty;
|
|
194
|
-
try {
|
|
195
|
-
pty = module.spawn(shell, process.platform === "win32" ? ["/c", request.command] : ["-c", request.command], {
|
|
196
|
-
cwd: request.cwd,
|
|
197
|
-
env: stringEnv({ ...(request.env ?? process.env), TERM: "xterm-256color" }),
|
|
198
|
-
cols: request.dimensions.columns,
|
|
199
|
-
rows: request.dimensions.rows,
|
|
200
|
-
name: "xterm-256color",
|
|
201
|
-
});
|
|
202
|
-
if (!pty.pid)
|
|
203
|
-
throw new Error("node-pty returned no pid");
|
|
204
|
-
return { transport: new NodePtyTransport(pty) };
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
// Release the native terminal allocated before launch confirmation.
|
|
208
|
-
if (pty) {
|
|
209
|
-
try {
|
|
210
|
-
pty.kill();
|
|
211
|
-
}
|
|
212
|
-
catch {
|
|
213
|
-
// Best effort: the master may already be closed.
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
throw new LaunchFailure("PTY_SPAWN_FAILED", `PTY allocation failed before launch confirmation: ${error instanceof Error ? error.name : "unknown"}.`, false, false);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
//# sourceMappingURL=transport-node-pty.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transport-node-pty.js","sourceRoot":"","sources":["../../src/interactive-session/transport-node-pty.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,oBAAoB,GAErB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,OAAO,EACL,aAAa,EACb,eAAe,GAOhB,MAAM,gBAAgB,CAAC;AAoCxB,MAAM,gBAAgB,GAAG,UAAU,CAAC;AAEpC,IAAI,WAA+D,CAAC;AACpE,IAAI,iBAAqC,CAAC;AAE1C,qDAAqD;AACrD,KAAK,UAAU,WAAW;IACxB,WAAW,KAAK,CAAC,KAAK,IAAI,EAAE;QAC1B,IAAI,CAAC;YACH,qEAAqE;YACrE,sEAAsE;YACtE,MAAM,MAAM,GAAG,CAAC,MAAM,MAAM,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAE/B,CAAC;YACnC,MAAM,MAAM,GAAG,OAAO,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YAC3D,IAAI,OAAO,MAAM,EAAE,KAAK,KAAK,UAAU,EAAE,CAAC;gBACxC,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AAC;AACH,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed-pipe transport. Used directly for `terminalMode: "pipe"` and as the
|
|
3
|
-
* single fallback for `"preferred"` when PTY capability is unavailable.
|
|
4
|
-
*
|
|
5
|
-
* This module never imports or probes PTY code, and it does not touch the spawn
|
|
6
|
-
* options used by `shell.ts` or `jobs.ts`.
|
|
7
|
-
*/
|
|
8
|
-
import { type LaunchRequest, type LaunchResult } from "./transport.js";
|
|
9
|
-
export declare function startPipeTransport(request: LaunchRequest): Promise<LaunchResult>;
|
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Managed-pipe transport. Used directly for `terminalMode: "pipe"` and as the
|
|
3
|
-
* single fallback for `"preferred"` when PTY capability is unavailable.
|
|
4
|
-
*
|
|
5
|
-
* This module never imports or probes PTY code, and it does not touch the spawn
|
|
6
|
-
* options used by `shell.ts` or `jobs.ts`.
|
|
7
|
-
*/
|
|
8
|
-
import { spawn } from "node:child_process";
|
|
9
|
-
import { augmentedPathEnv } from "../os/command.js";
|
|
10
|
-
import { processIdentityTracker } from "../os/process-identity.js";
|
|
11
|
-
import { supportsProcessGroups, terminateProcessTree, } from "../os/process-tree.js";
|
|
12
|
-
import { resolveShell } from "../tools/shell.js";
|
|
13
|
-
import { LaunchFailure, pipeControlAction, } from "./transport.js";
|
|
14
|
-
class PipeTransport {
|
|
15
|
-
child;
|
|
16
|
-
kind = "pipe";
|
|
17
|
-
pid;
|
|
18
|
-
processGroupId;
|
|
19
|
-
identity;
|
|
20
|
-
outputListeners = new Set();
|
|
21
|
-
exitListeners = new Set();
|
|
22
|
-
inputClosed = false;
|
|
23
|
-
exited = false;
|
|
24
|
-
disposed = false;
|
|
25
|
-
outputDrained = false;
|
|
26
|
-
resolveOutputDrain;
|
|
27
|
-
outputDrain = new Promise((resolve) => {
|
|
28
|
-
this.resolveOutputDrain = resolve;
|
|
29
|
-
});
|
|
30
|
-
constructor(child) {
|
|
31
|
-
this.child = child;
|
|
32
|
-
this.pid = child.pid ?? -1;
|
|
33
|
-
this.processGroupId = supportsProcessGroups() ? child.pid : undefined;
|
|
34
|
-
this.identity = processIdentityTracker.capture(child.pid, { refresh: true });
|
|
35
|
-
child.stdout?.on("data", (chunk) => this.emitOutput("stdout", chunk));
|
|
36
|
-
child.stderr?.on("data", (chunk) => this.emitOutput("stderr", chunk));
|
|
37
|
-
// A broken input pipe after the child exits is an expected race, not a crash.
|
|
38
|
-
child.stdin?.on("error", () => undefined);
|
|
39
|
-
child.on("exit", (code, signal) => {
|
|
40
|
-
this.exited = true;
|
|
41
|
-
const outcome = {
|
|
42
|
-
endedAt: Date.now(),
|
|
43
|
-
...(code !== null ? { exitCode: code } : {}),
|
|
44
|
-
...(signal ? { signal } : {}),
|
|
45
|
-
};
|
|
46
|
-
for (const listener of [...this.exitListeners])
|
|
47
|
-
listener(outcome);
|
|
48
|
-
});
|
|
49
|
-
child.once("close", () => {
|
|
50
|
-
this.outputDrained = true;
|
|
51
|
-
this.resolveOutputDrain();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
emitOutput(stream, chunk) {
|
|
55
|
-
const event = {
|
|
56
|
-
stream,
|
|
57
|
-
bytes: new Uint8Array(chunk),
|
|
58
|
-
observedAt: Date.now(),
|
|
59
|
-
};
|
|
60
|
-
for (const listener of [...this.outputListeners])
|
|
61
|
-
listener(event);
|
|
62
|
-
}
|
|
63
|
-
async write(bytes) {
|
|
64
|
-
const stdin = this.child.stdin;
|
|
65
|
-
if (!stdin || this.inputClosed || stdin.destroyed || this.exited) {
|
|
66
|
-
return { status: "not-delivered", deliveredBytes: 0 };
|
|
67
|
-
}
|
|
68
|
-
return await new Promise((resolve) => {
|
|
69
|
-
let settled = false;
|
|
70
|
-
const settle = (result) => {
|
|
71
|
-
if (settled)
|
|
72
|
-
return;
|
|
73
|
-
settled = true;
|
|
74
|
-
resolve(result);
|
|
75
|
-
};
|
|
76
|
-
try {
|
|
77
|
-
stdin.write(Buffer.from(bytes), (error) => {
|
|
78
|
-
// The callback fires after the bytes leave our buffer. A late error
|
|
79
|
-
// cannot prove whether the child observed them, so it is `unknown`.
|
|
80
|
-
if (error)
|
|
81
|
-
settle({ status: "unknown", deliveredBytes: bytes.length, cause: error });
|
|
82
|
-
else
|
|
83
|
-
settle({ status: "delivered", deliveredBytes: bytes.length });
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
catch (error) {
|
|
87
|
-
settle({ status: "not-delivered", deliveredBytes: 0, cause: error });
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
async control(action) {
|
|
92
|
-
const mapped = pipeControlAction(action);
|
|
93
|
-
if (mapped.kind === "unsupported") {
|
|
94
|
-
return { status: "not-delivered", deliveredBytes: 0 };
|
|
95
|
-
}
|
|
96
|
-
if (mapped.kind === "bytes")
|
|
97
|
-
return await this.write(mapped.bytes);
|
|
98
|
-
if (mapped.kind === "close-input")
|
|
99
|
-
return await this.closeInput();
|
|
100
|
-
// Interrupt/suspend target the whole tree so a shell wrapper cannot swallow
|
|
101
|
-
// the signal while the real workload keeps running.
|
|
102
|
-
const outcome = terminateProcessTree(this.pid, {
|
|
103
|
-
signal: mapped.signal,
|
|
104
|
-
...(this.processGroupId !== undefined ? { processGroupId: this.processGroupId } : {}),
|
|
105
|
-
});
|
|
106
|
-
return outcome === "failed"
|
|
107
|
-
? { status: "unknown", deliveredBytes: 0 }
|
|
108
|
-
: { status: "delivered", deliveredBytes: 0 };
|
|
109
|
-
}
|
|
110
|
-
async closeInput() {
|
|
111
|
-
if (this.inputClosed)
|
|
112
|
-
return { status: "delivered", deliveredBytes: 0 };
|
|
113
|
-
this.inputClosed = true;
|
|
114
|
-
try {
|
|
115
|
-
this.child.stdin?.end();
|
|
116
|
-
return { status: "delivered", deliveredBytes: 0 };
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
return { status: "unknown", deliveredBytes: 0, cause: error };
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
pauseOutput() {
|
|
123
|
-
this.child.stdout?.pause();
|
|
124
|
-
this.child.stderr?.pause();
|
|
125
|
-
}
|
|
126
|
-
resumeOutput() {
|
|
127
|
-
this.child.stdout?.resume();
|
|
128
|
-
this.child.stderr?.resume();
|
|
129
|
-
}
|
|
130
|
-
async requestTreeTermination(kind) {
|
|
131
|
-
return terminateProcessTree(this.pid, {
|
|
132
|
-
signal: kind === "graceful" ? "SIGTERM" : "SIGKILL",
|
|
133
|
-
...(this.processGroupId !== undefined ? { processGroupId: this.processGroupId } : {}),
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
onOutput(listener) {
|
|
137
|
-
this.outputListeners.add(listener);
|
|
138
|
-
return () => {
|
|
139
|
-
this.outputListeners.delete(listener);
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
onExit(listener) {
|
|
143
|
-
this.exitListeners.add(listener);
|
|
144
|
-
return () => {
|
|
145
|
-
this.exitListeners.delete(listener);
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
async waitForOutputDrain() {
|
|
149
|
-
if (this.outputDrained)
|
|
150
|
-
return;
|
|
151
|
-
await this.outputDrain;
|
|
152
|
-
}
|
|
153
|
-
async dispose() {
|
|
154
|
-
if (this.disposed)
|
|
155
|
-
return;
|
|
156
|
-
this.disposed = true;
|
|
157
|
-
this.outputListeners.clear();
|
|
158
|
-
this.exitListeners.clear();
|
|
159
|
-
try {
|
|
160
|
-
this.child.stdin?.destroy();
|
|
161
|
-
this.child.stdout?.destroy();
|
|
162
|
-
this.child.stderr?.destroy();
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
// Streams may already be torn down by the exit path.
|
|
166
|
-
}
|
|
167
|
-
this.child.removeAllListeners();
|
|
168
|
-
processIdentityTracker.forget(this.child.pid);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/** Wait for the OS to confirm (or refuse) the spawn before reporting a launch. */
|
|
172
|
-
function waitForSpawn(child) {
|
|
173
|
-
return new Promise((resolve) => {
|
|
174
|
-
const onSpawn = () => {
|
|
175
|
-
child.off("error", onError);
|
|
176
|
-
resolve(undefined);
|
|
177
|
-
};
|
|
178
|
-
const onError = (error) => {
|
|
179
|
-
child.off("spawn", onSpawn);
|
|
180
|
-
resolve(error);
|
|
181
|
-
};
|
|
182
|
-
child.once("spawn", onSpawn);
|
|
183
|
-
child.once("error", onError);
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
export async function startPipeTransport(request) {
|
|
187
|
-
const shell = resolveShell();
|
|
188
|
-
if (!shell) {
|
|
189
|
-
throw new LaunchFailure("SHELL_NOT_FOUND", "No usable command shell was found for an interactive session.", false, false);
|
|
190
|
-
}
|
|
191
|
-
const child = spawn(request.command, {
|
|
192
|
-
cwd: request.cwd,
|
|
193
|
-
shell,
|
|
194
|
-
// POSIX children get their own group so cleanup can signal the whole tree.
|
|
195
|
-
detached: supportsProcessGroups(),
|
|
196
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
197
|
-
env: { ...(request.env ?? process.env), PATH: augmentedPathEnv() },
|
|
198
|
-
windowsHide: true,
|
|
199
|
-
});
|
|
200
|
-
const error = await waitForSpawn(child);
|
|
201
|
-
if (error) {
|
|
202
|
-
try {
|
|
203
|
-
child.kill();
|
|
204
|
-
}
|
|
205
|
-
catch {
|
|
206
|
-
// Nothing started; there is no process to reap.
|
|
207
|
-
}
|
|
208
|
-
throw new LaunchFailure(error.code ?? "UNKNOWN", `Interactive session launch failed before spawn: ${error.code ?? "UNKNOWN"}.`, false, error.code === "ENOENT" || error.code === "EAGAIN");
|
|
209
|
-
}
|
|
210
|
-
if (!child.pid) {
|
|
211
|
-
throw new LaunchFailure("NO_PID", "The interactive session process reported no process id after spawn.", false, true);
|
|
212
|
-
}
|
|
213
|
-
return { transport: new PipeTransport(child) };
|
|
214
|
-
}
|
|
215
|
-
//# sourceMappingURL=transport-pipe.js.map
|
|
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I,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;QACf,MAAM,IAAI,aAAa,CACrB,QAAQ,EACR,qEAAqE,EACrE,KAAK,EACL,IAAI,CACL,CAAC;IACJ,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,IAAI,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session transport contracts plus the single centralized table that maps text
|
|
3
|
-
* submission and named controls onto transport/platform byte sequences.
|
|
4
|
-
*
|
|
5
|
-
* A launch is confirmed only after the OS acknowledges spawn. Host stdin is
|
|
6
|
-
* never inherited: agent-controlled sessions must not be able to take the
|
|
7
|
-
* user's controlling terminal.
|
|
8
|
-
*/
|
|
9
|
-
import type { TreeSignalOutcome } from "../os/process-tree.js";
|
|
10
|
-
import type { Unsubscribe } from "./runtime.js";
|
|
11
|
-
import type { ControlInput, OutputStream, ProcessOutcome, SessionTransportKind, SubmitBehavior, TerminalDimensions } from "./types.js";
|
|
12
|
-
export interface TransportOutput {
|
|
13
|
-
readonly stream: OutputStream;
|
|
14
|
-
readonly bytes: Uint8Array;
|
|
15
|
-
readonly observedAt: number;
|
|
16
|
-
}
|
|
17
|
-
export type DeliveryResult = {
|
|
18
|
-
readonly status: "delivered";
|
|
19
|
-
readonly deliveredBytes: number;
|
|
20
|
-
} | {
|
|
21
|
-
readonly status: "not-delivered";
|
|
22
|
-
readonly deliveredBytes: 0;
|
|
23
|
-
readonly cause?: unknown;
|
|
24
|
-
} | {
|
|
25
|
-
readonly status: "unknown";
|
|
26
|
-
readonly deliveredBytes: number;
|
|
27
|
-
readonly cause?: unknown;
|
|
28
|
-
};
|
|
29
|
-
export interface SessionTransport {
|
|
30
|
-
readonly kind: SessionTransportKind;
|
|
31
|
-
readonly pid: number;
|
|
32
|
-
readonly processGroupId?: number | undefined;
|
|
33
|
-
/** Hashed start-time evidence captured at launch confirmation. */
|
|
34
|
-
readonly identity: string | undefined;
|
|
35
|
-
write(bytes: Uint8Array): Promise<DeliveryResult>;
|
|
36
|
-
control(action: ControlInput): Promise<DeliveryResult>;
|
|
37
|
-
closeInput(): Promise<DeliveryResult>;
|
|
38
|
-
resize?(dimensions: TerminalDimensions): Promise<void>;
|
|
39
|
-
pauseOutput(): void;
|
|
40
|
-
resumeOutput(): void;
|
|
41
|
-
requestTreeTermination(kind: "graceful" | "forceful"): Promise<TreeSignalOutcome>;
|
|
42
|
-
onOutput(listener: (event: TransportOutput) => void): Unsubscribe;
|
|
43
|
-
onExit(listener: (outcome: ProcessOutcome) => void): Unsubscribe;
|
|
44
|
-
/** Settles after transport output sources can emit no additional bytes. */
|
|
45
|
-
waitForOutputDrain?(): Promise<void>;
|
|
46
|
-
dispose(): Promise<void>;
|
|
47
|
-
}
|
|
48
|
-
export interface LaunchRequest {
|
|
49
|
-
readonly command: string;
|
|
50
|
-
readonly cwd: string;
|
|
51
|
-
readonly env?: NodeJS.ProcessEnv | undefined;
|
|
52
|
-
}
|
|
53
|
-
export interface LaunchResult {
|
|
54
|
-
readonly transport: SessionTransport;
|
|
55
|
-
}
|
|
56
|
-
export interface PtyCapability {
|
|
57
|
-
readonly available: boolean;
|
|
58
|
-
readonly platform: NodeJS.Platform;
|
|
59
|
-
/** Non-secret diagnostic for why PTY is unavailable on this target. */
|
|
60
|
-
readonly reason?: string | undefined;
|
|
61
|
-
}
|
|
62
|
-
export interface SessionTransportFactory {
|
|
63
|
-
capability(platform?: NodeJS.Platform): Promise<PtyCapability>;
|
|
64
|
-
startPipe(request: LaunchRequest): Promise<LaunchResult>;
|
|
65
|
-
startPty(request: LaunchRequest & {
|
|
66
|
-
dimensions: TerminalDimensions;
|
|
67
|
-
}): Promise<LaunchResult>;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* A transient pre-spawn failure proves no process side effect occurred, so the
|
|
71
|
-
* manager may retry the launch exactly once.
|
|
72
|
-
*/
|
|
73
|
-
export declare class LaunchFailure extends Error {
|
|
74
|
-
readonly code: string;
|
|
75
|
-
readonly spawnConfirmed: boolean;
|
|
76
|
-
readonly transient: boolean;
|
|
77
|
-
constructor(code: string, message: string, spawnConfirmed: boolean, transient: boolean);
|
|
78
|
-
}
|
|
79
|
-
/** PTY line discipline expects CR; a pipe expects LF. */
|
|
80
|
-
export declare function enterSequence(kind: SessionTransportKind): Uint8Array;
|
|
81
|
-
export declare function encodeTextInput(text: string, submit: SubmitBehavior, kind: SessionTransportKind): Uint8Array;
|
|
82
|
-
/**
|
|
83
|
-
* Byte payload for a named control on a PTY. `undefined` means the control has
|
|
84
|
-
* no byte form on that platform and must be reported as unsupported or handled
|
|
85
|
-
* out of band (signals on a pipe).
|
|
86
|
-
*/
|
|
87
|
-
export declare function ptyControlBytes(action: ControlInput, platform?: NodeJS.Platform): Uint8Array | undefined;
|
|
88
|
-
/**
|
|
89
|
-
* Pipe controls: `interrupt`/`suspend` are process signals because there is no
|
|
90
|
-
* line discipline, `eof` half-closes stdin, and the rest are the same bytes a
|
|
91
|
-
* terminal would have delivered.
|
|
92
|
-
*/
|
|
93
|
-
export type PipeControlAction = {
|
|
94
|
-
readonly kind: "signal";
|
|
95
|
-
readonly signal: NodeJS.Signals;
|
|
96
|
-
} | {
|
|
97
|
-
readonly kind: "bytes";
|
|
98
|
-
readonly bytes: Uint8Array;
|
|
99
|
-
} | {
|
|
100
|
-
readonly kind: "close-input";
|
|
101
|
-
} | {
|
|
102
|
-
readonly kind: "unsupported";
|
|
103
|
-
};
|
|
104
|
-
export declare function pipeControlAction(action: ControlInput, platform?: NodeJS.Platform): PipeControlAction;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Session transport contracts plus the single centralized table that maps text
|
|
3
|
-
* submission and named controls onto transport/platform byte sequences.
|
|
4
|
-
*
|
|
5
|
-
* A launch is confirmed only after the OS acknowledges spawn. Host stdin is
|
|
6
|
-
* never inherited: agent-controlled sessions must not be able to take the
|
|
7
|
-
* user's controlling terminal.
|
|
8
|
-
*/
|
|
9
|
-
/**
|
|
10
|
-
* A transient pre-spawn failure proves no process side effect occurred, so the
|
|
11
|
-
* manager may retry the launch exactly once.
|
|
12
|
-
*/
|
|
13
|
-
export class LaunchFailure extends Error {
|
|
14
|
-
code;
|
|
15
|
-
spawnConfirmed;
|
|
16
|
-
transient;
|
|
17
|
-
constructor(code, message, spawnConfirmed, transient) {
|
|
18
|
-
super(message);
|
|
19
|
-
this.code = code;
|
|
20
|
-
this.spawnConfirmed = spawnConfirmed;
|
|
21
|
-
this.transient = transient;
|
|
22
|
-
this.name = "LaunchFailure";
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
// --- Text and control mappings ------------------------------------------
|
|
26
|
-
/** PTY line discipline expects CR; a pipe expects LF. */
|
|
27
|
-
export function enterSequence(kind) {
|
|
28
|
-
return Buffer.from(kind === "pty" ? "\r" : "\n", "utf8");
|
|
29
|
-
}
|
|
30
|
-
export function encodeTextInput(text, submit, kind) {
|
|
31
|
-
const body = Buffer.from(text, "utf8");
|
|
32
|
-
if (submit === "none")
|
|
33
|
-
return body;
|
|
34
|
-
return Buffer.concat([body, Buffer.from(enterSequence(kind))]);
|
|
35
|
-
}
|
|
36
|
-
const ARROWS = {
|
|
37
|
-
up: "\u001b[A",
|
|
38
|
-
down: "\u001b[B",
|
|
39
|
-
right: "\u001b[C",
|
|
40
|
-
left: "\u001b[D",
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Byte payload for a named control on a PTY. `undefined` means the control has
|
|
44
|
-
* no byte form on that platform and must be reported as unsupported or handled
|
|
45
|
-
* out of band (signals on a pipe).
|
|
46
|
-
*/
|
|
47
|
-
export function ptyControlBytes(action, platform = process.platform) {
|
|
48
|
-
switch (action) {
|
|
49
|
-
case "interrupt":
|
|
50
|
-
return Buffer.from([0x03]);
|
|
51
|
-
case "eof":
|
|
52
|
-
// Windows consoles terminate input with Ctrl+Z followed by Enter.
|
|
53
|
-
return platform === "win32"
|
|
54
|
-
? Buffer.from([0x1a, 0x0d])
|
|
55
|
-
: Buffer.from([0x04]);
|
|
56
|
-
case "suspend":
|
|
57
|
-
return platform === "win32" ? undefined : Buffer.from([0x1a]);
|
|
58
|
-
case "escape":
|
|
59
|
-
return Buffer.from([0x1b]);
|
|
60
|
-
case "tab":
|
|
61
|
-
return Buffer.from([0x09]);
|
|
62
|
-
case "backspace":
|
|
63
|
-
return Buffer.from([0x7f]);
|
|
64
|
-
case "up":
|
|
65
|
-
case "down":
|
|
66
|
-
case "left":
|
|
67
|
-
case "right":
|
|
68
|
-
return Buffer.from(ARROWS[action], "utf8");
|
|
69
|
-
default:
|
|
70
|
-
return undefined;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
export function pipeControlAction(action, platform = process.platform) {
|
|
74
|
-
if (action === "interrupt") {
|
|
75
|
-
return platform === "win32"
|
|
76
|
-
? { kind: "signal", signal: "SIGTERM" }
|
|
77
|
-
: { kind: "signal", signal: "SIGINT" };
|
|
78
|
-
}
|
|
79
|
-
if (action === "suspend") {
|
|
80
|
-
return platform === "win32"
|
|
81
|
-
? { kind: "unsupported" }
|
|
82
|
-
: { kind: "signal", signal: "SIGTSTP" };
|
|
83
|
-
}
|
|
84
|
-
if (action === "eof")
|
|
85
|
-
return { kind: "close-input" };
|
|
86
|
-
const bytes = ptyControlBytes(action, platform);
|
|
87
|
-
return bytes ? { kind: "bytes", bytes } : { kind: "unsupported" };
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=transport.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/interactive-session/transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAqEH;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IAE3B;IAEA;IACA;IAJX,YACW,IAAY,EACrB,OAAe,EACN,cAAuB,EACvB,SAAkB;QAE3B,KAAK,CAAC,OAAO,CAAC,CAAC;Q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