@ahpd/server 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/README.md +87 -81
- package/dist/config.d.ts +65 -0
- package/dist/config.js +75 -0
- package/dist/daemon.d.ts +26 -0
- package/dist/daemon.js +160 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +297 -0
- package/dist/pty.d.ts +12 -0
- package/dist/pty.js +56 -0
- package/package.json +15 -25
- package/dist/automations.d.ts +0 -4
- package/dist/automations.d.ts.map +0 -1
- package/dist/automations.js +0 -191
- package/dist/automations.js.map +0 -1
- package/dist/catalog.d.ts +0 -48
- package/dist/catalog.d.ts.map +0 -1
- package/dist/catalog.js +0 -51
- package/dist/catalog.js.map +0 -1
- package/dist/changes.d.ts +0 -4
- package/dist/changes.d.ts.map +0 -1
- package/dist/changes.js +0 -601
- package/dist/changes.js.map +0 -1
- package/dist/cron.d.ts +0 -43
- package/dist/cron.d.ts.map +0 -1
- package/dist/cron.js +0 -211
- package/dist/cron.js.map +0 -1
- package/dist/git.d.ts +0 -16
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js +0 -126
- package/dist/git.js.map +0 -1
- package/dist/host.d.ts +0 -24
- package/dist/host.d.ts.map +0 -1
- package/dist/host.js +0 -5850
- package/dist/host.js.map +0 -1
- package/dist/index.d.ts +0 -36
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -34
- package/dist/index.js.map +0 -1
- package/dist/listen.d.ts +0 -3
- package/dist/listen.d.ts.map +0 -1
- package/dist/listen.js +0 -183
- package/dist/listen.js.map +0 -1
- package/dist/paging.d.ts +0 -38
- package/dist/paging.d.ts.map +0 -1
- package/dist/paging.js +0 -53
- package/dist/paging.js.map +0 -1
- package/dist/paths.d.ts +0 -15
- package/dist/paths.d.ts.map +0 -1
- package/dist/paths.js +0 -19
- package/dist/paths.js.map +0 -1
- package/dist/resources.d.ts +0 -122
- package/dist/resources.d.ts.map +0 -1
- package/dist/resources.js +0 -494
- package/dist/resources.js.map +0 -1
- package/dist/rpc.d.ts +0 -63
- package/dist/rpc.d.ts.map +0 -1
- package/dist/rpc.js +0 -208
- package/dist/rpc.js.map +0 -1
- package/dist/scheduled.d.ts +0 -48
- package/dist/scheduled.d.ts.map +0 -1
- package/dist/scheduled.js +0 -325
- package/dist/scheduled.js.map +0 -1
- package/dist/terminals.d.ts +0 -29
- package/dist/terminals.d.ts.map +0 -1
- package/dist/terminals.js +0 -346
- package/dist/terminals.js.map +0 -1
- package/dist/tools.d.ts +0 -18
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -65
- package/dist/tools.js.map +0 -1
- package/dist/types/agent.d.ts +0 -245
- package/dist/types/agent.d.ts.map +0 -1
- package/dist/types/agent.js +0 -3
- package/dist/types/agent.js.map +0 -1
- package/dist/types/automations.d.ts +0 -164
- package/dist/types/automations.d.ts.map +0 -1
- package/dist/types/automations.js +0 -3
- package/dist/types/automations.js.map +0 -1
- package/dist/types/catalog.d.ts +0 -30
- package/dist/types/catalog.d.ts.map +0 -1
- package/dist/types/catalog.js +0 -3
- package/dist/types/catalog.js.map +0 -1
- package/dist/types/changes.d.ts +0 -272
- package/dist/types/changes.d.ts.map +0 -1
- package/dist/types/changes.js +0 -3
- package/dist/types/changes.js.map +0 -1
- package/dist/types/common.d.ts +0 -9
- package/dist/types/common.d.ts.map +0 -1
- package/dist/types/common.js +0 -3
- package/dist/types/common.js.map +0 -1
- package/dist/types/host.d.ts +0 -372
- package/dist/types/host.d.ts.map +0 -1
- package/dist/types/host.js +0 -3
- package/dist/types/host.js.map +0 -1
- package/dist/types/index.d.ts +0 -20
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -8
- package/dist/types/index.js.map +0 -1
- package/dist/types/listen.d.ts +0 -48
- package/dist/types/listen.d.ts.map +0 -1
- package/dist/types/listen.js +0 -3
- package/dist/types/listen.js.map +0 -1
- package/dist/types/paging.d.ts +0 -10
- package/dist/types/paging.d.ts.map +0 -1
- package/dist/types/paging.js +0 -3
- package/dist/types/paging.js.map +0 -1
- package/dist/types/probe.d.ts +0 -46
- package/dist/types/probe.d.ts.map +0 -1
- package/dist/types/probe.js +0 -3
- package/dist/types/probe.js.map +0 -1
- package/dist/types/resources.d.ts +0 -83
- package/dist/types/resources.d.ts.map +0 -1
- package/dist/types/resources.js +0 -3
- package/dist/types/resources.js.map +0 -1
- package/dist/types/rpc.d.ts +0 -65
- package/dist/types/rpc.d.ts.map +0 -1
- package/dist/types/rpc.js +0 -3
- package/dist/types/rpc.js.map +0 -1
- package/dist/types/session.d.ts +0 -395
- package/dist/types/session.d.ts.map +0 -1
- package/dist/types/session.js +0 -3
- package/dist/types/session.js.map +0 -1
- package/dist/types/terminals.d.ts +0 -131
- package/dist/types/terminals.d.ts.map +0 -1
- package/dist/types/terminals.js +0 -3
- package/dist/types/terminals.js.map +0 -1
- package/dist/types/wire.d.ts +0 -62
- package/dist/types/wire.d.ts.map +0 -1
- package/dist/types/wire.js +0 -13
- package/dist/types/wire.js.map +0 -1
- package/dist/types/worktrees.d.ts +0 -86
- package/dist/types/worktrees.d.ts.map +0 -1
- package/dist/types/worktrees.js +0 -3
- package/dist/types/worktrees.js.map +0 -1
- package/dist/worktrees.d.ts +0 -27
- package/dist/worktrees.d.ts.map +0 -1
- package/dist/worktrees.js +0 -152
- package/dist/worktrees.js.map +0 -1
- package/src/automations.ts +0 -204
- package/src/catalog.ts +0 -53
- package/src/changes.ts +0 -629
- package/src/cron.ts +0 -251
- package/src/git.ts +0 -132
- package/src/host.ts +0 -5947
- package/src/index.ts +0 -40
- package/src/listen.ts +0 -240
- package/src/paging.ts +0 -56
- package/src/paths.ts +0 -19
- package/src/resources.ts +0 -513
- package/src/rpc.ts +0 -222
- package/src/scheduled.ts +0 -369
- package/src/terminals.ts +0 -353
- package/src/tools.ts +0 -64
- package/src/types/agent.ts +0 -255
- package/src/types/automations.ts +0 -164
- package/src/types/catalog.ts +0 -26
- package/src/types/changes.ts +0 -266
- package/src/types/common.ts +0 -9
- package/src/types/host.ts +0 -386
- package/src/types/index.ts +0 -27
- package/src/types/listen.ts +0 -53
- package/src/types/paging.ts +0 -11
- package/src/types/probe.ts +0 -42
- package/src/types/resources.ts +0 -107
- package/src/types/rpc.ts +0 -68
- package/src/types/session.ts +0 -415
- package/src/types/terminals.ts +0 -133
- package/src/types/wire.ts +0 -69
- package/src/types/worktrees.ts +0 -91
- package/src/worktrees.ts +0 -162
package/dist/terminals.js
DELETED
|
@@ -1,346 +0,0 @@
|
|
|
1
|
-
import { spawn } from 'node:child_process';
|
|
2
|
-
/**
|
|
3
|
-
* A shell on the host machine, as a terminal channel.
|
|
4
|
-
*
|
|
5
|
-
* Pipes, not a pseudoterminal: a PTY needs a native binding this daemon does
|
|
6
|
-
* not depend on, and the protocol has `isPty: false` for exactly this - "output
|
|
7
|
-
* is plain text and clients do not need to parse VT sequences". So a command
|
|
8
|
-
* runs and its output arrives, and anything that draws itself with cursor
|
|
9
|
-
* movement will not look right. Said in the state rather than discovered.
|
|
10
|
-
*
|
|
11
|
-
* `node:child_process` is used because all three supported runtimes provide it.
|
|
12
|
-
*/
|
|
13
|
-
/** What runs, when nothing else was asked for. */
|
|
14
|
-
const shellOf = (asked) => asked ?? process.env.SHELL ?? '/bin/sh';
|
|
15
|
-
/**
|
|
16
|
-
* What a shell says about itself, in the escape sequences it says it with.
|
|
17
|
-
*
|
|
18
|
-
* OSC 133 is the command-boundary convention every shell integration script
|
|
19
|
-
* writes - `A` before the prompt, `B` where the command starts, `C` where its
|
|
20
|
-
* output does, `D;<code>` when it finished - and OSC 7 is the directory. They
|
|
21
|
-
* arrive mixed into the output, so this reads them out and leaves the rest
|
|
22
|
-
* alone: the bytes still go to the client, which is drawing a terminal and
|
|
23
|
-
* needs them.
|
|
24
|
-
*
|
|
25
|
-
* Only under a pseudoterminal, because only then is there a shell running its
|
|
26
|
-
* own prompt to emit them.
|
|
27
|
-
*/
|
|
28
|
-
const MARKS = /\u001b\](133|7);([^\u0007\u001b]*)(?:\u0007|\u001b\\)/g;
|
|
29
|
-
export function createTerminal(options, pty) {
|
|
30
|
-
const { uri, cwd, emit } = options;
|
|
31
|
-
const shell = shellOf(options.shell);
|
|
32
|
-
let title = options.name ?? shell.slice(shell.lastIndexOf('/') + 1);
|
|
33
|
-
let claim = options.claim;
|
|
34
|
-
let cols = options.cols ?? 80;
|
|
35
|
-
let rows = options.rows ?? 24;
|
|
36
|
-
let exitCode;
|
|
37
|
-
/**
|
|
38
|
-
* Everything written so far, so a client that subscribes late sees it.
|
|
39
|
-
*
|
|
40
|
-
* Capped: a terminal left running `tail -f` for a day is a host holding a
|
|
41
|
-
* day of output for a client that may never come back.
|
|
42
|
-
*/
|
|
43
|
-
let buffered = '';
|
|
44
|
-
const KEEP = 200_000;
|
|
45
|
-
const said = (data) => {
|
|
46
|
-
buffered = (buffered + data).slice(-KEEP);
|
|
47
|
-
emit('terminal', { type: 'terminal/data', data });
|
|
48
|
-
};
|
|
49
|
-
/*
|
|
50
|
-
* `-c` when there is a command, and nothing when there is not.
|
|
51
|
-
*
|
|
52
|
-
* A shell given `-c` runs the one thing and exits. Under pipes that is the
|
|
53
|
-
* only completion signal there is; under a pseudoterminal the shell says so
|
|
54
|
-
* itself, in OSC 133.
|
|
55
|
-
*/
|
|
56
|
-
const args = options.command === undefined ? [] : ['-c', options.command];
|
|
57
|
-
const environment = {
|
|
58
|
-
...process.env,
|
|
59
|
-
// A real terminal under a pty, and an honest `dumb` without one.
|
|
60
|
-
TERM: pty ? (process.env.TERM ?? 'xterm-256color') : 'dumb',
|
|
61
|
-
COLUMNS: String(cols),
|
|
62
|
-
LINES: String(rows),
|
|
63
|
-
};
|
|
64
|
-
/** Where the shell says it is, once it has said. */
|
|
65
|
-
let where = cwd;
|
|
66
|
-
/** The command being run, from `C` until `D`. */
|
|
67
|
-
let command;
|
|
68
|
-
/** What has been typed since the prompt, so the command line can be read back. */
|
|
69
|
-
let typed = '';
|
|
70
|
-
/**
|
|
71
|
-
* Read the shell's own marks out of a chunk, and say what they meant.
|
|
72
|
-
*
|
|
73
|
-
* The chunk still reaches the client whole: this is a reader, not a filter,
|
|
74
|
-
* and a client drawing a terminal needs the bytes it was sent.
|
|
75
|
-
*/
|
|
76
|
-
const marked = (data) => {
|
|
77
|
-
for (const found of data.matchAll(MARKS)) {
|
|
78
|
-
const [, kind, body = ''] = found;
|
|
79
|
-
if (kind === '7') {
|
|
80
|
-
// `file://host/path`, per the convention. The host part is dropped:
|
|
81
|
-
// the path is on this machine, and that is what a client opens.
|
|
82
|
-
const path = body.replace(/^file:\/\/[^/]*/, '');
|
|
83
|
-
if (path !== '' && path !== where) {
|
|
84
|
-
where = path;
|
|
85
|
-
emit('terminal', { type: 'terminal/cwdChanged', cwd: `file://${path}` });
|
|
86
|
-
}
|
|
87
|
-
continue;
|
|
88
|
-
}
|
|
89
|
-
const mark = body.split(';')[0];
|
|
90
|
-
if (mark === 'A') {
|
|
91
|
-
typed = '';
|
|
92
|
-
continue;
|
|
93
|
-
}
|
|
94
|
-
if (mark === 'C') {
|
|
95
|
-
command = { id: `c${String(Date.now())}`, line: typed.trim(), at: Date.now() };
|
|
96
|
-
emit('terminal', {
|
|
97
|
-
type: 'terminal/commandExecuted',
|
|
98
|
-
commandId: command.id,
|
|
99
|
-
commandLine: command.line,
|
|
100
|
-
timestamp: command.at,
|
|
101
|
-
});
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
if (mark !== 'D' || command === undefined)
|
|
105
|
-
continue;
|
|
106
|
-
const code = Number(body.split(';')[1]);
|
|
107
|
-
emit('terminal', {
|
|
108
|
-
type: 'terminal/commandFinished',
|
|
109
|
-
commandId: command.id,
|
|
110
|
-
...(Number.isFinite(code) ? { exitCode: code } : {}),
|
|
111
|
-
durationMs: Date.now() - command.at,
|
|
112
|
-
});
|
|
113
|
-
command = undefined;
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
const terminal = pty?.(shell, args, {
|
|
117
|
-
...(cwd !== undefined ? { cwd } : {}),
|
|
118
|
-
cols,
|
|
119
|
-
rows,
|
|
120
|
-
env: environment,
|
|
121
|
-
});
|
|
122
|
-
if (terminal !== undefined) {
|
|
123
|
-
terminal.onData((data) => { marked(data); said(data); });
|
|
124
|
-
terminal.onExit(({ exitCode: code }) => { exitCode = code; ended(); });
|
|
125
|
-
// Said once, at the start. A client MUST check this before relying on
|
|
126
|
-
// command boundaries, and the same fact is on the state.
|
|
127
|
-
emit('terminal', { type: 'terminal/commandDetectionAvailable' });
|
|
128
|
-
}
|
|
129
|
-
const child = terminal !== undefined ? undefined : spawn(shell, args, {
|
|
130
|
-
cwd,
|
|
131
|
-
/*
|
|
132
|
-
* Its own process group, so a signal reaches what it started.
|
|
133
|
-
*
|
|
134
|
-
* A shell reading from a pipe runs each command as its own child, and a
|
|
135
|
-
* signal sent to the shell alone leaves the command running. The group is
|
|
136
|
-
* what a terminal driver would have signalled, and this has no driver.
|
|
137
|
-
*/
|
|
138
|
-
detached: true,
|
|
139
|
-
// A shell reading commands from a pipe. Without a pseudoterminal there is
|
|
140
|
-
// no point asking it to be interactive: it would print a prompt nobody
|
|
141
|
-
// can answer the way it expects.
|
|
142
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
143
|
-
env: environment,
|
|
144
|
-
});
|
|
145
|
-
child?.stdout.on('data', (chunk) => said(chunk.toString('utf8')));
|
|
146
|
-
child?.stderr.on('data', (chunk) => said(chunk.toString('utf8')));
|
|
147
|
-
/**
|
|
148
|
-
* Said once, whichever of the three got here first.
|
|
149
|
-
*
|
|
150
|
-
* `error` and `close` can both fire for one failed spawn, and a terminal
|
|
151
|
-
* that announced its own exit twice would be one every client draws as
|
|
152
|
-
* having died, come back, and died again.
|
|
153
|
-
*/
|
|
154
|
-
let announced = false;
|
|
155
|
-
const ended = () => {
|
|
156
|
-
if (announced)
|
|
157
|
-
return;
|
|
158
|
-
announced = true;
|
|
159
|
-
emit('terminal', { type: 'terminal/exited', exitCode });
|
|
160
|
-
};
|
|
161
|
-
child?.on('error', (error) => {
|
|
162
|
-
said(`${error.message}\n`);
|
|
163
|
-
exitCode = 127;
|
|
164
|
-
ended();
|
|
165
|
-
});
|
|
166
|
-
child?.on('exit', (code, signal) => {
|
|
167
|
-
// A signal is not an exit code, and 128+n is the shell's own convention
|
|
168
|
-
// for one - better than reporting nothing, which reads as still running.
|
|
169
|
-
exitCode = code ?? (signal ? 128 : 0);
|
|
170
|
-
});
|
|
171
|
-
/*
|
|
172
|
-
* Announced on `close` rather than on `exit`, which is a race this lost.
|
|
173
|
-
*
|
|
174
|
-
* `exit` fires when the process goes; `close` fires once its pipes are
|
|
175
|
-
* drained. Between the two there is output already written and not yet
|
|
176
|
-
* read, so a host that reported the exit on `exit` reported a command's
|
|
177
|
-
* result before the result had arrived - which is exactly what a `!`
|
|
178
|
-
* command in the composer reads back.
|
|
179
|
-
*/
|
|
180
|
-
child?.on('close', () => {
|
|
181
|
-
// A process that closed without an exit event was killed outright.
|
|
182
|
-
exitCode ??= 0;
|
|
183
|
-
ended();
|
|
184
|
-
});
|
|
185
|
-
return {
|
|
186
|
-
uri,
|
|
187
|
-
title: () => title,
|
|
188
|
-
claim: () => claim,
|
|
189
|
-
exitCode: () => exitCode,
|
|
190
|
-
lifecycle: () => (exitCode === undefined
|
|
191
|
-
? { status: 'running' }
|
|
192
|
-
: { status: 'exited', exitCode }),
|
|
193
|
-
state: () => ({
|
|
194
|
-
title,
|
|
195
|
-
cwd: `file://${cwd}`,
|
|
196
|
-
cols,
|
|
197
|
-
rows,
|
|
198
|
-
// One part, because without command detection there are no boundaries
|
|
199
|
-
// to divide the output at. The protocol's shape, not a flat string.
|
|
200
|
-
content: buffered === '' ? [] : [{ type: 'unclassified', value: buffered }],
|
|
201
|
-
claim,
|
|
202
|
-
// Both true only under a pseudoterminal: without one there is no shell
|
|
203
|
-
// running its own prompt, so there are no boundaries to report and no
|
|
204
|
-
// VT sequences for a client to parse.
|
|
205
|
-
supportsCommandDetection: terminal !== undefined,
|
|
206
|
-
isPty: terminal !== undefined,
|
|
207
|
-
/*
|
|
208
|
-
* Both spellings, because this host speaks five versions.
|
|
209
|
-
*
|
|
210
|
-
* `lifecycle` is what 0.9.0 requires and is not optional there - a
|
|
211
|
-
* client reading `lifecycle.status` on a 0.8.0-shaped terminal gets
|
|
212
|
-
* `undefined`, which reads as a process that never exits. The flat
|
|
213
|
-
* `exitCode` is what every version before it reads, and this daemon
|
|
214
|
-
* negotiates down to 0.5.1.
|
|
215
|
-
*/
|
|
216
|
-
lifecycle: exitCode === undefined
|
|
217
|
-
? { status: 'running' }
|
|
218
|
-
: { status: 'exited', exitCode },
|
|
219
|
-
...(exitCode !== undefined ? { exitCode } : {}),
|
|
220
|
-
}),
|
|
221
|
-
write: (data) => {
|
|
222
|
-
if (exitCode !== undefined)
|
|
223
|
-
return;
|
|
224
|
-
/*
|
|
225
|
-
* `^C` is a signal, and there is nothing here to turn it into one.
|
|
226
|
-
*
|
|
227
|
-
* A pseudoterminal has a line discipline that sees the byte and sends
|
|
228
|
-
* SIGINT to the foreground group. Pipes have none, so the byte arrives
|
|
229
|
-
* as input and the command runs on - which is a terminal a runaway
|
|
230
|
-
* command cannot be stopped in. Sending the signal is what the driver
|
|
231
|
-
* would have done.
|
|
232
|
-
*/
|
|
233
|
-
/*
|
|
234
|
-
* Under a pseudoterminal the byte is the signal.
|
|
235
|
-
*
|
|
236
|
-
* A pty has a line discipline: `^C` reaches it as input and it sends
|
|
237
|
-
* SIGINT to the foreground group itself, which is the whole point of
|
|
238
|
-
* having one. So this writes it through and does nothing clever.
|
|
239
|
-
*/
|
|
240
|
-
if (terminal !== undefined) {
|
|
241
|
-
terminal.write(data);
|
|
242
|
-
// Kept so a command line can be read back at the next `C` mark; the
|
|
243
|
-
// shell echoes what was typed, but the echo arrives as output and
|
|
244
|
-
// this is the only place the input itself is seen.
|
|
245
|
-
typed += data;
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
const at = data.indexOf('\u0003');
|
|
249
|
-
if (at !== -1) {
|
|
250
|
-
const rest = data.slice(0, at) + data.slice(at + 1);
|
|
251
|
-
if (rest !== '' && child?.stdin.writable)
|
|
252
|
-
child.stdin.write(rest);
|
|
253
|
-
/*
|
|
254
|
-
* The group, named by the child's own pid, and only when there is one.
|
|
255
|
-
*
|
|
256
|
-
* A spawn that failed leaves no pid, and `0` is not a safe stand-in:
|
|
257
|
-
* to `kill` it means every process in *this* process group, so a
|
|
258
|
-
* terminal whose shell never started would signal the host and
|
|
259
|
-
* whatever started the host.
|
|
260
|
-
*/
|
|
261
|
-
const group = child?.pid;
|
|
262
|
-
if (group !== undefined) {
|
|
263
|
-
try {
|
|
264
|
-
process.kill(-group, 'SIGINT');
|
|
265
|
-
}
|
|
266
|
-
// The group is gone, which is the outcome asked for.
|
|
267
|
-
catch { /* nothing left to interrupt */ }
|
|
268
|
-
}
|
|
269
|
-
return;
|
|
270
|
-
}
|
|
271
|
-
if (child?.stdin.writable)
|
|
272
|
-
child.stdin.write(data);
|
|
273
|
-
},
|
|
274
|
-
// Told, when there is something to tell: a pseudoterminal gets the new
|
|
275
|
-
// size and sends SIGWINCH itself. Without one these are kept because the
|
|
276
|
-
// state reports them and a client draws to them.
|
|
277
|
-
resize: (nextCols, nextRows) => {
|
|
278
|
-
terminal?.resize(nextCols, nextRows);
|
|
279
|
-
cols = nextCols;
|
|
280
|
-
rows = nextRows;
|
|
281
|
-
emit('terminal', { type: 'terminal/resized', cols, rows });
|
|
282
|
-
},
|
|
283
|
-
// The scrollback and nothing else. `cols`, `rows`, `title` and `claim` are
|
|
284
|
-
// untouched, which is what the reference suite checks for.
|
|
285
|
-
clear: () => {
|
|
286
|
-
buffered = '';
|
|
287
|
-
emit('terminal', { type: 'terminal/cleared' });
|
|
288
|
-
},
|
|
289
|
-
setTitle: (next) => {
|
|
290
|
-
if (next === title)
|
|
291
|
-
return;
|
|
292
|
-
title = next;
|
|
293
|
-
emit('terminal', { type: 'terminal/titleChanged', title });
|
|
294
|
-
},
|
|
295
|
-
setClaim: (next) => {
|
|
296
|
-
claim = next;
|
|
297
|
-
emit('terminal', { type: 'terminal/claimed', claim });
|
|
298
|
-
},
|
|
299
|
-
close: () => {
|
|
300
|
-
if (terminal !== undefined) {
|
|
301
|
-
terminal.kill();
|
|
302
|
-
return;
|
|
303
|
-
}
|
|
304
|
-
child?.stdin.end();
|
|
305
|
-
// The group, not the shell: detached, its children outlive it otherwise.
|
|
306
|
-
// Only when there is a pid to name it - see the interrupt above.
|
|
307
|
-
const group = child?.pid;
|
|
308
|
-
if (group === undefined) {
|
|
309
|
-
child?.kill();
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
|
-
try {
|
|
313
|
-
process.kill(-group, 'SIGKILL');
|
|
314
|
-
}
|
|
315
|
-
catch {
|
|
316
|
-
child?.kill();
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
/**
|
|
322
|
-
* A shell on this machine, as a host's `TerminalStore`.
|
|
323
|
-
*
|
|
324
|
-
* Kept out of `createHost` for the reason above: spawning is the runtime's
|
|
325
|
-
* business, and a host that opens no terminal should not have to have one.
|
|
326
|
-
*
|
|
327
|
-
* ```ts
|
|
328
|
-
* createHost({ path, agents, terminals: shellTerminals() });
|
|
329
|
-
* ```
|
|
330
|
-
*
|
|
331
|
-
* Given a `pty` it runs shells under a pseudoterminal instead, which is what
|
|
332
|
-
* makes shell integration possible: the shell prints its own OSC 133 marks, so
|
|
333
|
-
* command boundaries and the working directory become facts rather than
|
|
334
|
-
* guesses. The binding is handed in because it is native code - `node-pty` is
|
|
335
|
-
* the daemon's dependency and never this library's, and a host on another
|
|
336
|
-
* runtime passes whatever it has.
|
|
337
|
-
*
|
|
338
|
-
* ```ts
|
|
339
|
-
* import { spawn } from 'node-pty';
|
|
340
|
-
* createHost({ path, agents, terminals: shellTerminals({ pty: spawn }) });
|
|
341
|
-
* ```
|
|
342
|
-
*/
|
|
343
|
-
export const shellTerminals = (options = {}) => ({
|
|
344
|
-
create: (asked) => createTerminal(asked, options.pty),
|
|
345
|
-
});
|
|
346
|
-
//# sourceMappingURL=terminals.js.map
|
package/dist/terminals.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"terminals.js","sourceRoot":"","sources":["../src/terminals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C;;;;;;;;;;GAUG;AAEH,kDAAkD;AAClD,MAAM,OAAO,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,KAAK,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,SAAS,CAAC;AAEpF;;;;;;;;;;;;GAYG;AACH,MAAM,KAAK,GAAG,wDAAwD,CAAC;AAEvE,MAAM,UAAU,cAAc,CAAC,OAAwB,EAAE,GAAc;IACrE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;IACnC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,OAAO,CAAC,IAAI,IAAI,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;IACpE,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC1B,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9B,IAAI,QAA4B,CAAC;IACjC;;;;;OAKG;IACH,IAAI,QAAQ,GAAG,EAAE,CAAC;IAClB,MAAM,IAAI,GAAG,OAAO,CAAC;IAErB,MAAM,IAAI,GAAG,CAAC,IAAY,EAAQ,EAAE;QAClC,QAAQ,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,KAAK,CAAC,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} from './types/host.js';
|
|
2
|
-
/**
|
|
3
|
-
* The tools this package contributes to every session, as a host's `tools`.
|
|
4
|
-
*
|
|
5
|
-
* The protocol's `serverTools` are the *host's* own - not a backend's and not
|
|
6
|
-
* a client's - and what makes one worth contributing is that the host knows
|
|
7
|
-
* something the agent inside a session cannot: the other sessions running
|
|
8
|
-
* beside it, and the terminals the person is watching. Both are read-only.
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* createHost({ path, agents, tools: hostTools() });
|
|
12
|
-
* ```
|
|
13
|
-
*
|
|
14
|
-
* A host that wants its own passes its own; a host that passes none
|
|
15
|
-
* contributes none, and its sessions report no `serverTools` at all.
|
|
16
|
-
*/
|
|
17
|
-
export declare const hostTools: () => HostTool[];
|
|
18
|
-
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,QAAO,QAAQ,EA8CpC,CAAC"}
|
package/dist/tools.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The tools this package contributes to every session, as a host's `tools`.
|
|
3
|
-
*
|
|
4
|
-
* The protocol's `serverTools` are the *host's* own - not a backend's and not
|
|
5
|
-
* a client's - and what makes one worth contributing is that the host knows
|
|
6
|
-
* something the agent inside a session cannot: the other sessions running
|
|
7
|
-
* beside it, and the terminals the person is watching. Both are read-only.
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* createHost({ path, agents, tools: hostTools() });
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* A host that wants its own passes its own; a host that passes none
|
|
14
|
-
* contributes none, and its sessions report no `serverTools` at all.
|
|
15
|
-
*/
|
|
16
|
-
export const hostTools = () => [
|
|
17
|
-
{
|
|
18
|
-
definition: {
|
|
19
|
-
name: 'ahp_sessions',
|
|
20
|
-
title: 'Sessions on this host',
|
|
21
|
-
description: 'The other agent sessions running on this host, with the directories each works in. '
|
|
22
|
-
+ 'Use it before touching a file to find out whether another agent is already working there.',
|
|
23
|
-
inputSchema: { type: 'object', properties: {} },
|
|
24
|
-
annotations: { title: 'Sessions on this host', readOnlyHint: true, openWorldHint: false },
|
|
25
|
-
},
|
|
26
|
-
run: (_input, at) => {
|
|
27
|
-
const others = at.sessions().filter((one) => one.uri !== at.session);
|
|
28
|
-
if (others.length === 0)
|
|
29
|
-
return 'No other session is running on this host.';
|
|
30
|
-
return others
|
|
31
|
-
.map((one) => `${one.uri}\t${one.provider}\t${one.title}\t${one.workingDirectories.join(' ')}`)
|
|
32
|
-
.join('\n');
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
definition: {
|
|
37
|
-
name: 'ahp_resource',
|
|
38
|
-
title: 'Read a resource this host serves',
|
|
39
|
-
description: 'Read a resource by URI, including one a connected client publishes and this machine has no copy of '
|
|
40
|
-
+ '- a plugin\u2019s virtual files, an editor\u2019s unsaved buffers. Addressed as <scheme>://<client>/<path>.',
|
|
41
|
-
inputSchema: { type: 'object', properties: { uri: { type: 'string' } }, required: ['uri'] },
|
|
42
|
-
annotations: { title: 'Read a resource this host serves', readOnlyHint: true },
|
|
43
|
-
},
|
|
44
|
-
run: async (input, at) => await at.read(String(input.uri ?? '')),
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
definition: {
|
|
48
|
-
name: 'ahp_terminals',
|
|
49
|
-
title: 'Terminals on this host',
|
|
50
|
-
description: 'The terminals this host has open, with what each is running and where. '
|
|
51
|
-
+ 'These are the terminals the person can see, which is not the same as a shell run from a tool.',
|
|
52
|
-
inputSchema: { type: 'object', properties: {} },
|
|
53
|
-
annotations: { title: 'Terminals on this host', readOnlyHint: true, openWorldHint: false },
|
|
54
|
-
},
|
|
55
|
-
run: (_input, at) => {
|
|
56
|
-
const open = at.terminals();
|
|
57
|
-
if (open.length === 0)
|
|
58
|
-
return 'This host has no terminal open.';
|
|
59
|
-
return open
|
|
60
|
-
.map((one) => `${one.uri}\t${one.title}\t${one.cwd}\t${one.running ? 'running' : 'exited'}`)
|
|
61
|
-
.join('\n');
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
];
|
|
65
|
-
//# sourceMappingURL=tools.js.map
|
package/dist/tools.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAe,EAAE,CAAC;IACzC;QACE,UAAU,EAAE;YACV,IAAI,EAAE,cAAc;YACpB,KAAK,EAAE,uBAAuB;YAC9B,WAAW,EAAE,qFAAqF;kBAC9F,2FAA2F;YAC/F,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;YAC/C,WAAW,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;SAC1F;QACD,GAAG,EAAE,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE;YAClB,MAAM,MAAM,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,CAAC;YACrE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,2CAA2C,CAAC;YAC5E,OAAO,MAAM;iBACV,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,QAAQ,KAAK,GAAG,CAAC,KAAK,KAAK,G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