@namzu/sdk 52.3.0 → 52.4.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 +14 -0
- package/dist/connector/web/guarded-fetch.d.ts.map +1 -1
- package/dist/connector/web/guarded-fetch.js +44 -0
- package/dist/connector/web/guarded-fetch.js.map +1 -1
- package/dist/process/kill-tree.d.ts +3 -2
- package/dist/process/kill-tree.d.ts.map +1 -1
- package/dist/process/kill-tree.js.map +1 -1
- package/dist/public-runtime.d.ts +1 -1
- package/dist/public-runtime.d.ts.map +1 -1
- package/dist/public-tools.d.ts +2 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +1 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/runtime/jobs/registry.d.ts +80 -2
- package/dist/runtime/jobs/registry.d.ts.map +1 -1
- package/dist/runtime/jobs/registry.js +70 -5
- package/dist/runtime/jobs/registry.js.map +1 -1
- package/dist/runtime/jobs/websocket-source.d.ts +120 -0
- package/dist/runtime/jobs/websocket-source.d.ts.map +1 -0
- package/dist/runtime/jobs/websocket-source.js +379 -0
- package/dist/runtime/jobs/websocket-source.js.map +1 -0
- package/dist/runtime/query/steering.d.ts +2 -2
- package/dist/runtime/query/steering.d.ts.map +1 -1
- package/dist/runtime/query/steering.js +16 -3
- package/dist/runtime/query/steering.js.map +1 -1
- package/dist/tools/builtins/monitor.d.ts +38 -4
- package/dist/tools/builtins/monitor.d.ts.map +1 -1
- package/dist/tools/builtins/monitor.js +236 -97
- package/dist/tools/builtins/monitor.js.map +1 -1
- package/dist/types/sandbox/index.d.ts +10 -0
- package/dist/types/sandbox/index.d.ts.map +1 -1
- package/dist/types/sandbox/index.js.map +1 -1
- package/dist/types/tool/index.d.ts +35 -0
- package/dist/types/tool/index.d.ts.map +1 -1
- package/dist/types/tool/index.js.map +1 -1
- package/package.json +4 -2
- package/src/connector/web/guarded-fetch.ts +41 -0
- package/src/process/kill-tree.ts +4 -2
- package/src/public-runtime.ts +1 -1
- package/src/public-tools.ts +3 -0
- package/src/runtime/jobs/registry.ts +162 -13
- package/src/runtime/jobs/websocket-source.ts +438 -0
- package/src/runtime/query/steering.ts +32 -6
- package/src/tools/builtins/monitor.ts +293 -123
- package/src/types/sandbox/index.ts +10 -0
- package/src/types/tool/index.ts +27 -0
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { lookup as dnsLookup } from 'node:dns/promises';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { isIP } from 'node:net';
|
|
4
|
+
import { isPrivateAddress } from '../../connector/web/guarded-fetch.js';
|
|
5
|
+
import { isolationOf } from '../../sandbox/isolation.js';
|
|
6
|
+
/**
|
|
7
|
+
* A WebSocket as a monitor's source.
|
|
8
|
+
*
|
|
9
|
+
* A command's stdout is not the only thing worth watching: some services push
|
|
10
|
+
* their events (a CI run's log stream, a server's change feed) and offer no
|
|
11
|
+
* command that prints them. This module turns such a connection into the same
|
|
12
|
+
* thing a command is to the registry: a process-shaped object that writes
|
|
13
|
+
* lines on stdout, can be asked to stop, and ends. Everything after that (the
|
|
14
|
+
* 200 ms batches, the rationing, the expiry, the stop, the untrusted frame the
|
|
15
|
+
* model reads it in) is the registry's and is shared with commands unchanged.
|
|
16
|
+
*
|
|
17
|
+
* What is different is where it runs and what it can reach. A command runs
|
|
18
|
+
* where the registry's spawn puts it, inside a sandbox if there is one; this
|
|
19
|
+
* connection is opened by the HOST process, outside any sandbox. So the
|
|
20
|
+
* address is checked before anything is sent, a sandbox that isolates the
|
|
21
|
+
* network refuses it unless it has said the host is allowed, and the tool
|
|
22
|
+
* asks a person first (see `tools/builtins/monitor.ts`).
|
|
23
|
+
*/
|
|
24
|
+
/** The largest frame accepted; a bigger one ends the watch. Same as the reference. */
|
|
25
|
+
export const WEBSOCKET_MAX_PAYLOAD_BYTES = 1_048_576;
|
|
26
|
+
export const WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 15_000;
|
|
27
|
+
/** After a polite close, how long a peer gets to answer before the socket is destroyed. */
|
|
28
|
+
export const WEBSOCKET_CLOSE_GRACE_MS = 1000;
|
|
29
|
+
export const WEBSOCKET_URL_MAX_CHARS = 2048;
|
|
30
|
+
export const WEBSOCKET_PROTOCOLS_MAX = 16;
|
|
31
|
+
/** Longest close reason relayed; the protocol allows 123 bytes. */
|
|
32
|
+
const CLOSE_REASON_MAX_CHARS = 123;
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Input
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
/** RFC 6455 subprotocol names are RFC 2616 tokens: no separators, no controls. */
|
|
37
|
+
const TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
38
|
+
/** Why a URL cannot be a monitor's source, or undefined when it can. */
|
|
39
|
+
export function webSocketUrlProblem(raw) {
|
|
40
|
+
if (raw.length > WEBSOCKET_URL_MAX_CHARS) {
|
|
41
|
+
return `The URL is longer than ${WEBSOCKET_URL_MAX_CHARS} characters.`;
|
|
42
|
+
}
|
|
43
|
+
// ASCII without whitespace or controls: a model that wants a non-ASCII host
|
|
44
|
+
// writes it in punycode, and nothing here is left to the parser's leniency
|
|
45
|
+
// (it strips tabs and newlines silently).
|
|
46
|
+
if (!/^[\x21-\x7e]+$/.test(raw)) {
|
|
47
|
+
return 'The URL must be ASCII, with no spaces or control characters.';
|
|
48
|
+
}
|
|
49
|
+
let url;
|
|
50
|
+
try {
|
|
51
|
+
url = new URL(raw);
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return 'That is not a URL.';
|
|
55
|
+
}
|
|
56
|
+
if (url.protocol !== 'ws:' && url.protocol !== 'wss:') {
|
|
57
|
+
return 'The URL must start with ws:// or wss://.';
|
|
58
|
+
}
|
|
59
|
+
if (url.username !== '' || url.password !== '') {
|
|
60
|
+
return 'A URL with a user name or password is not opened.';
|
|
61
|
+
}
|
|
62
|
+
if (url.hash !== '')
|
|
63
|
+
return 'A WebSocket URL cannot have a fragment (#...).';
|
|
64
|
+
if (url.hostname === '')
|
|
65
|
+
return 'The URL has no host.';
|
|
66
|
+
return undefined;
|
|
67
|
+
}
|
|
68
|
+
/** Why a subprotocol list is not valid, or undefined when it is. */
|
|
69
|
+
export function webSocketProtocolsProblem(protocols) {
|
|
70
|
+
if (protocols.length > WEBSOCKET_PROTOCOLS_MAX) {
|
|
71
|
+
return `At most ${WEBSOCKET_PROTOCOLS_MAX} subprotocols.`;
|
|
72
|
+
}
|
|
73
|
+
for (const protocol of protocols) {
|
|
74
|
+
if (!TOKEN.test(protocol))
|
|
75
|
+
return `"${protocol}" is not a valid subprotocol name.`;
|
|
76
|
+
}
|
|
77
|
+
if (new Set(protocols).size !== protocols.length)
|
|
78
|
+
return 'Subprotocol names must be unique.';
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
/** What a record and an approval call this source: the URL as given, which can carry no credentials. */
|
|
82
|
+
export function webSocketJobCommand(url) {
|
|
83
|
+
return `websocket ${url}`;
|
|
84
|
+
}
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Where it may connect
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
/** The address check refused, in words for the model. */
|
|
89
|
+
export class WebSocketRefusedError extends Error {
|
|
90
|
+
constructor(message) {
|
|
91
|
+
super(message);
|
|
92
|
+
this.name = 'WebSocketRefusedError';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/** The host name of a WebSocket URL as a resolver or an address check wants it. */
|
|
96
|
+
export function webSocketHostname(raw) {
|
|
97
|
+
return new URL(raw).hostname.toLowerCase().replace(/^\[|\]$/g, '');
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Resolve the host and refuse unless EVERY address is outside the host's own
|
|
101
|
+
* network; return the addresses that were checked.
|
|
102
|
+
*
|
|
103
|
+
* Refusal covers a name that does not resolve, one that resolves to nothing,
|
|
104
|
+
* and one with any private address among its answers: a name that answers both
|
|
105
|
+
* a public and a private address is a name an attacker controls, and a
|
|
106
|
+
* connection may pick either. Failing to resolve is a refusal and never a
|
|
107
|
+
* pass: an empty list satisfies "no private address found" and the connection
|
|
108
|
+
* that followed would resolve the name again against whatever answered.
|
|
109
|
+
*/
|
|
110
|
+
export async function vetWebSocketTarget(raw, options = {}) {
|
|
111
|
+
const hostname = webSocketHostname(raw);
|
|
112
|
+
let addresses;
|
|
113
|
+
const literal = isIP(hostname);
|
|
114
|
+
if (literal !== 0) {
|
|
115
|
+
addresses = [hostname];
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
const resolve = options.resolve ??
|
|
119
|
+
(async (name) => (await dnsLookup(name, { all: true })).map((r) => r.address));
|
|
120
|
+
try {
|
|
121
|
+
addresses = await resolve(hostname);
|
|
122
|
+
}
|
|
123
|
+
catch (err) {
|
|
124
|
+
throw new WebSocketRefusedError(`Refused "${hostname}": it could not be resolved (${err instanceof Error ? err.message : String(err)}), so nothing here can say where it points.`);
|
|
125
|
+
}
|
|
126
|
+
if (addresses.length === 0) {
|
|
127
|
+
throw new WebSocketRefusedError(`Refused "${hostname}": it resolves to no addresses.`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (options.allowPrivateAddresses !== true) {
|
|
131
|
+
for (const address of addresses) {
|
|
132
|
+
if (isPrivateAddress(address)) {
|
|
133
|
+
throw new WebSocketRefusedError(`Refused "${hostname}": it resolves to ${address}, inside this host's own network. A WebSocket monitor only connects to public addresses.`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return addresses.map((address) => ({ address, family: isIP(address) === 6 ? 6 : 4 }));
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* A `lookup` for the socket that answers with the addresses that were checked
|
|
141
|
+
* and nothing else.
|
|
142
|
+
*
|
|
143
|
+
* This is what closes the gap `web_fetch` documents: there the address is
|
|
144
|
+
* checked, then the platform `fetch` resolves the name AGAIN, so a name that
|
|
145
|
+
* answers publicly the first time and privately the second (DNS rebinding)
|
|
146
|
+
* gets through. Here the connection never asks DNS: it is handed the checked
|
|
147
|
+
* addresses, so there is no second answer to differ. The URL still names the
|
|
148
|
+
* host, so TLS keeps its SNI and its certificate check on the hostname and not
|
|
149
|
+
* on an address.
|
|
150
|
+
*/
|
|
151
|
+
export function pinnedLookup(addresses) {
|
|
152
|
+
return (_hostname, options, callback) => {
|
|
153
|
+
// A caller that wants one family gets that family's addresses; asking for
|
|
154
|
+
// one we hold none of is an error rather than a fall back to DNS.
|
|
155
|
+
const wanted = options?.family === 4 || options?.family === 6 ? options.family : undefined;
|
|
156
|
+
const usable = wanted === undefined ? addresses : addresses.filter((a) => a.family === wanted);
|
|
157
|
+
const first = usable[0];
|
|
158
|
+
if (first === undefined) {
|
|
159
|
+
const error = new Error('no vetted address of that family');
|
|
160
|
+
error.code = 'ENOTFOUND';
|
|
161
|
+
callback(error, '', 0);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (options?.all === true) {
|
|
165
|
+
callback(null, usable.map((a) => ({ address: a.address, family: a.family })));
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
callback(null, first.address, first.family);
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
/** `api.example.com` is that host; `.example.com` is the domain and its subdomains. */
|
|
172
|
+
export function hostMatchesPolicy(hostname, allowedHosts) {
|
|
173
|
+
const host = hostname.toLowerCase().replace(/\.$/, '');
|
|
174
|
+
return allowedHosts.some((entry) => {
|
|
175
|
+
const allowed = entry.toLowerCase().replace(/\.$/, '');
|
|
176
|
+
if (allowed.startsWith('.'))
|
|
177
|
+
return host === allowed.slice(1) || host.endsWith(allowed);
|
|
178
|
+
return host === allowed;
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Why a sandbox forbids this connection, or undefined when it does not.
|
|
183
|
+
*
|
|
184
|
+
* The connection is opened by the host process, outside the boundary, so a
|
|
185
|
+
* sandbox's network rules do not bind it. If a turn runs under a sandbox that
|
|
186
|
+
* isolates the network, letting the host connect would be a way out of that
|
|
187
|
+
* isolation, so it is refused unless the sandbox's live policy names the host.
|
|
188
|
+
* A sandbox that does not isolate the network says nothing about it, and the
|
|
189
|
+
* connection is allowed, subject to the address check and to review.
|
|
190
|
+
*/
|
|
191
|
+
export function webSocketSandboxRefusal(sandbox, hostname) {
|
|
192
|
+
if (sandbox === undefined)
|
|
193
|
+
return undefined;
|
|
194
|
+
if (!isolationOf(sandbox.environment).network)
|
|
195
|
+
return undefined;
|
|
196
|
+
const allowed = sandbox.networkPolicy?.allowedHosts;
|
|
197
|
+
if (allowed !== undefined && hostMatchesPolicy(hostname, allowed))
|
|
198
|
+
return undefined;
|
|
199
|
+
return `A WebSocket monitor connects from the host, outside this turn's sandbox, which blocks the network. "${hostname}" is not on the sandbox's list of allowed hosts, so the connection was not opened. Allow the host in the sandbox's network policy, or watch the service from inside the sandbox with a command.`;
|
|
200
|
+
}
|
|
201
|
+
// ---------------------------------------------------------------------------
|
|
202
|
+
// Notices
|
|
203
|
+
// ---------------------------------------------------------------------------
|
|
204
|
+
/** Server-written text, made one short line before it goes into a notice. */
|
|
205
|
+
function oneLine(text) {
|
|
206
|
+
const line = Array.from(text, (character) => {
|
|
207
|
+
const code = character.charCodeAt(0);
|
|
208
|
+
return code < 0x20 || (code >= 0x7f && code <= 0x9f) ? ' ' : character;
|
|
209
|
+
})
|
|
210
|
+
.join('')
|
|
211
|
+
.replace(/\s+/g, ' ')
|
|
212
|
+
.trim();
|
|
213
|
+
return line.length <= CLOSE_REASON_MAX_CHARS
|
|
214
|
+
? line
|
|
215
|
+
: `${line.slice(0, CLOSE_REASON_MAX_CHARS)}...`;
|
|
216
|
+
}
|
|
217
|
+
export const webSocketRejectedNotice = (status) => `[WebSocket upgrade rejected: HTTP ${status}]`;
|
|
218
|
+
export const webSocketErrorNotice = (message) => `[WebSocket error: ${oneLine(message)}]`;
|
|
219
|
+
export const webSocketClosedNotice = (code, reason) => {
|
|
220
|
+
const why = oneLine(reason);
|
|
221
|
+
return why === '' ? `[WebSocket closed: ${code}]` : `[WebSocket closed: ${code} ${why}]`;
|
|
222
|
+
};
|
|
223
|
+
export const webSocketDroppedNotice = () => `[Dropped a frame larger than ${WEBSOCKET_MAX_PAYLOAD_BYTES} bytes; closing]`;
|
|
224
|
+
function frameBytes(data) {
|
|
225
|
+
if (Array.isArray(data))
|
|
226
|
+
return data.reduce((sum, part) => sum + part.length, 0);
|
|
227
|
+
return data instanceof ArrayBuffer ? data.byteLength : data.length;
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Open the connection and return it as a job's process.
|
|
231
|
+
*
|
|
232
|
+
* The socket library is loaded when the first monitor of this kind starts, so
|
|
233
|
+
* a session that never watches a WebSocket never pays for it.
|
|
234
|
+
*/
|
|
235
|
+
export function connectWebSocketSource(options) {
|
|
236
|
+
const { target, host } = options;
|
|
237
|
+
const stand = Object.assign(new EventEmitter(), {
|
|
238
|
+
pid: undefined,
|
|
239
|
+
stdout: new EventEmitter(),
|
|
240
|
+
stderr: new EventEmitter(),
|
|
241
|
+
});
|
|
242
|
+
let socket;
|
|
243
|
+
let graceTimer;
|
|
244
|
+
// Set once somebody asked the connection to stop (a kill, the expiry, the
|
|
245
|
+
// output rule). From then on the connection says nothing: the registry has
|
|
246
|
+
// already told the model why the watch ended, and nothing follows that.
|
|
247
|
+
let stopping = false;
|
|
248
|
+
let opened = false;
|
|
249
|
+
let rejected = false;
|
|
250
|
+
let oversize = false;
|
|
251
|
+
// The connection failed before it opened: the error notice was the last word.
|
|
252
|
+
let failedToOpen = false;
|
|
253
|
+
let ended = false;
|
|
254
|
+
const write = (text) => {
|
|
255
|
+
if (stopping || ended)
|
|
256
|
+
return;
|
|
257
|
+
stand.stdout.emit('data', text);
|
|
258
|
+
};
|
|
259
|
+
const end = (exitCode) => {
|
|
260
|
+
if (ended)
|
|
261
|
+
return;
|
|
262
|
+
ended = true;
|
|
263
|
+
clearTimeout(graceTimer);
|
|
264
|
+
stand.emit('close', exitCode, null);
|
|
265
|
+
};
|
|
266
|
+
void import('ws')
|
|
267
|
+
.then(({ WebSocket }) => {
|
|
268
|
+
if (stopping) {
|
|
269
|
+
end(0);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const client = new WebSocket(target.url, target.protocols && target.protocols.length > 0 ? [...target.protocols] : undefined, {
|
|
273
|
+
maxPayload: WEBSOCKET_MAX_PAYLOAD_BYTES,
|
|
274
|
+
// A redirect could lead to an address nobody checked.
|
|
275
|
+
followRedirects: false,
|
|
276
|
+
// A compressed frame inflates past the size cap before it is
|
|
277
|
+
// measured; refusing the extension leaves every frame as sent.
|
|
278
|
+
perMessageDeflate: false,
|
|
279
|
+
handshakeTimeout: WEBSOCKET_HANDSHAKE_TIMEOUT_MS,
|
|
280
|
+
// Only the vetted addresses; see `pinnedLookup`.
|
|
281
|
+
lookup: pinnedLookup(target.addresses),
|
|
282
|
+
});
|
|
283
|
+
socket = client;
|
|
284
|
+
client.on('open', () => {
|
|
285
|
+
opened = true;
|
|
286
|
+
});
|
|
287
|
+
client.on('unexpected-response', (_request, response) => {
|
|
288
|
+
if (stopping)
|
|
289
|
+
return;
|
|
290
|
+
rejected = true;
|
|
291
|
+
response.resume();
|
|
292
|
+
host.notice(webSocketRejectedNotice(response.statusCode ?? 0), { final: true });
|
|
293
|
+
// With a listener for this event the library leaves the half-open
|
|
294
|
+
// request to us.
|
|
295
|
+
client.terminate();
|
|
296
|
+
});
|
|
297
|
+
client.on('error', (error) => {
|
|
298
|
+
if (stopping || rejected || oversize)
|
|
299
|
+
return;
|
|
300
|
+
if (error.code === 'WS_ERR_UNSUPPORTED_MESSAGE_LENGTH') {
|
|
301
|
+
// The library knows a frame was too big and not how big: it stops
|
|
302
|
+
// reading at the length field.
|
|
303
|
+
oversize = true;
|
|
304
|
+
host.notice(webSocketDroppedNotice(), { final: true });
|
|
305
|
+
client.terminate();
|
|
306
|
+
return;
|
|
307
|
+
}
|
|
308
|
+
if (!opened) {
|
|
309
|
+
// It never opened, so there is no close to report after this:
|
|
310
|
+
// one notice says it failed, and it is the last.
|
|
311
|
+
failedToOpen = true;
|
|
312
|
+
host.notice(webSocketErrorNotice(error.message), { final: true });
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
host.notice(webSocketErrorNotice(error.message));
|
|
316
|
+
});
|
|
317
|
+
client.on('message', (data, isBinary) => {
|
|
318
|
+
if (isBinary) {
|
|
319
|
+
write(`[binary frame, ${frameBytes(data)} bytes]\n`);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const text = Array.isArray(data)
|
|
323
|
+
? Buffer.concat(data).toString('utf8')
|
|
324
|
+
: Buffer.from(data).toString('utf8');
|
|
325
|
+
// Frames are not lines. A newline closes this one, so the next frame
|
|
326
|
+
// starts a fresh line and a frame without one is not glued to it.
|
|
327
|
+
write(text.endsWith('\n') ? text : `${text}\n`);
|
|
328
|
+
});
|
|
329
|
+
client.on('close', (code, reason) => {
|
|
330
|
+
const why = reason.toString('utf8');
|
|
331
|
+
if (!stopping && !rejected && !oversize && !failedToOpen) {
|
|
332
|
+
host.notice(webSocketClosedNotice(code, why), { final: true });
|
|
333
|
+
if (opened)
|
|
334
|
+
host.connectionClosed(code, oneLine(why));
|
|
335
|
+
}
|
|
336
|
+
// A normal or going-away close is the stream ending; anything else,
|
|
337
|
+
// and a connection that never opened, is a failure.
|
|
338
|
+
end(opened && (code === 1000 || code === 1001 || code === 1005) ? 0 : 1);
|
|
339
|
+
});
|
|
340
|
+
})
|
|
341
|
+
.catch((error) => {
|
|
342
|
+
host.notice(webSocketErrorNotice(error instanceof Error ? error.message : String(error)), {
|
|
343
|
+
final: true,
|
|
344
|
+
});
|
|
345
|
+
end(1);
|
|
346
|
+
});
|
|
347
|
+
return {
|
|
348
|
+
child: stand,
|
|
349
|
+
// Not a process, so the registry's group kill has nothing to signal; this
|
|
350
|
+
// is how it is stopped. SIGTERM asks politely, SIGKILL (and the grace
|
|
351
|
+
// running out) destroys the socket.
|
|
352
|
+
kill(signal) {
|
|
353
|
+
if (ended)
|
|
354
|
+
return;
|
|
355
|
+
if (signal === 'SIGKILL') {
|
|
356
|
+
stopping = true;
|
|
357
|
+
if (socket)
|
|
358
|
+
socket.terminate();
|
|
359
|
+
else
|
|
360
|
+
end(0);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if (stopping)
|
|
364
|
+
return;
|
|
365
|
+
stopping = true;
|
|
366
|
+
if (!socket)
|
|
367
|
+
return; // the import resolves, sees `stopping`, and ends
|
|
368
|
+
if (socket.readyState === socket.OPEN) {
|
|
369
|
+
socket.close(1000);
|
|
370
|
+
graceTimer = setTimeout(() => socket?.terminate(), WEBSOCKET_CLOSE_GRACE_MS);
|
|
371
|
+
graceTimer.unref?.();
|
|
372
|
+
}
|
|
373
|
+
else {
|
|
374
|
+
socket.terminate();
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
//# sourceMappingURL=websocket-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"websocket-source.js","sourceRoot":"","sources":["../../../src/runtime/jobs/websocket-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAI/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,sCAAsC,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAKxD;;;;;;;;;;;;;;;;;GAiBG;AAEH,sFAAsF;AACtF,MAAM,CAAC,MAAM,2BAA2B,GAAG,SAAS,CAAA;AACpD,MAAM,CAAC,MAAM,8BAA8B,GAAG,MAAM,CAAA;AACpD,2FAA2F;AAC3F,MAAM,CA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C;YACD,IAAI,QAAQ;gBAAE,OAAM;YACpB,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,CAAC,MAAM;gBAAE,OAAM,CAAC,iDAAiD;YACrE,IAAI,MAAM,CAAC,UAAU,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;gBACvC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBAClB,UAAU,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,EAAE,wBAAwB,CAAC,CAAA;gBAC5E,UAAU,CAAC,KAAK,EAAE,EAAE,CAAA;YACrB,CAAC;iBAAM,CAAC;gBACP,MAAM,CAAC,SAAS,EAAE,CAAA;YACnB,CAAC;QACF,CAAC;KACD,CAAA;AACF,CAAC"}
|
|
@@ -98,9 +98,9 @@ export declare function formatMonitorNote(text: string): string;
|
|
|
98
98
|
* in-turn delivery with this, and a host that holds events for a later turn
|
|
99
99
|
* renders them with it too, so both read the same words.
|
|
100
100
|
*/
|
|
101
|
-
export declare function formatMonitorEvent(event: Pick<MonitorEvent, 'jobId' | 'description' | 'kind' | 'text'
|
|
101
|
+
export declare function formatMonitorEvent(event: Pick<MonitorEvent, 'jobId' | 'description' | 'kind' | 'text'> & Partial<Pick<MonitorEvent, 'transport'>>, command: string): string;
|
|
102
102
|
/** A monitor's end as the system-event envelope, in the words {@link describeMonitorEnd} gives it. */
|
|
103
|
-
export declare function formatMonitorEnd(job: Pick<BackgroundJob, 'id' | 'command' | 'description' | 'status' | 'exitCode' | 'signal' | 'error'>, stats: {
|
|
103
|
+
export declare function formatMonitorEnd(job: Pick<BackgroundJob, 'id' | 'command' | 'description' | 'status' | 'exitCode' | 'signal' | 'error' | 'transport' | 'closeCode' | 'closeReason'>, stats: {
|
|
104
104
|
readonly stdoutChars: number;
|
|
105
105
|
}): string;
|
|
106
106
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steering.d.ts","sourceRoot":"","sources":["../../../src/run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kind === 'output' ? 'monitor-output' : 'monitor-notice',
|
|
119
119
|
attributes: { job: event.jobId },
|
|
120
|
-
provenance: event.kind
|
|
121
|
-
? 'Lines the watched command printed to stdout. The command, or whatever it reads, wrote them; they are not the operator.'
|
|
122
|
-
: 'Written by the monitor itself, not by the watched command.',
|
|
120
|
+
provenance: monitorProvenance(event.kind, event.transport),
|
|
123
121
|
},
|
|
124
122
|
content: capMonitorContent(event.text),
|
|
125
123
|
},
|
|
126
124
|
});
|
|
127
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Who wrote what is inside the frame. For a WebSocket the server wrote the
|
|
128
|
+
* frames and also the close reason and error text the monitor quotes in its
|
|
129
|
+
* notices, so neither is claimed to be the monitor's own words.
|
|
130
|
+
*/
|
|
131
|
+
function monitorProvenance(kind, transport) {
|
|
132
|
+
if (transport === 'websocket') {
|
|
133
|
+
return kind === 'output'
|
|
134
|
+
? 'Text frames the WebSocket server sent. The server, or whatever it relays, wrote them; they are not the operator.'
|
|
135
|
+
: 'A notice from the monitor about the WebSocket connection. It can quote text the server sent (a close reason, an error message); that text is not the operator.';
|
|
136
|
+
}
|
|
137
|
+
return kind === 'output'
|
|
138
|
+
? 'Lines the watched command printed to stdout. The command, or whatever it reads, wrote them; they are not the operator.'
|
|
139
|
+
: 'Written by the monitor itself, not by the watched command.';
|
|
140
|
+
}
|
|
128
141
|
/** A monitor's end as the system-event envelope, in the words {@link describeMonitorEnd} gives it. */
|
|
129
142
|
export function formatMonitorEnd(job, stats) {
|
|
130
143
|
const end = describeMonitorEnd(job, stats);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"steering.js","sourceRoot":"","sources":["../../../src/runtime/query/steering.ts"],"names":[],"mappings":"AACA,OAAO,EACN,+BAA+B,EAC/B,8BAA8B,GAC9B,MAAM,2BAA2B,CAAA;AAClC,OAAO,EAAyC,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AAC/F,OAAO,EAAE,iBAAiB,EAAE,eAAe,E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} from '../../runtime/jobs/websocket-source.js';
|
|
1
2
|
export declare const MONITOR_TOOL_NAME = "monitor";
|
|
2
3
|
/**
|
|
3
4
|
* What a sandbox without `spawnDetached` is told. The wording of `bash`'s own
|
|
@@ -6,10 +7,42 @@ export declare const MONITOR_TOOL_NAME = "monitor";
|
|
|
6
7
|
* rule: the watch is never run on the host to get around the sandbox.
|
|
7
8
|
*/
|
|
8
9
|
export declare const MONITOR_CANNOT_DETACH = "monitor is unavailable: this sandbox cannot start a detached process, and the watch will not be run on the host to get around it. Run the command in the foreground with bash, with a timeout.";
|
|
9
|
-
|
|
10
|
-
|
|
10
|
+
/** What a host can tune about the WebSocket source; for tests only, see {@link WebSocketVetOptions}. */
|
|
11
|
+
export interface MonitorToolOptions {
|
|
12
|
+
readonly webSocket?: WebSocketVetOptions;
|
|
13
|
+
/**
|
|
14
|
+
* How to turn web access on, in the host's own words, appended to the
|
|
15
|
+
* refusal a WebSocket call gets while it is off. The SDK cannot name a
|
|
16
|
+
* switch it does not own (a CLI config key, a desktop setting), and a
|
|
17
|
+
* refusal that only says "off" leaves the operator guessing. One short
|
|
18
|
+
* sentence; it is shown to the model and the operator as written.
|
|
19
|
+
*/
|
|
20
|
+
readonly webAccessHint?: string;
|
|
21
|
+
}
|
|
22
|
+
/** The text that says a WebSocket watch was refused because the host has web access off. */
|
|
23
|
+
export declare const MONITOR_WEBSOCKET_WEB_OFF = "WebSocket monitors follow the host's web access setting, and web access is switched off here, so no connection was opened. Watch the service with a command (for example curl or websocat through monitor) if the operator allows it.";
|
|
24
|
+
/**
|
|
25
|
+
* The tool, built once with defaults for a host and again by a test that needs
|
|
26
|
+
* to reach a server on this machine. The options belong to whoever builds the
|
|
27
|
+
* tool; nothing a model sends can set them.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createMonitorTool(options?: MonitorToolOptions): import("../../types/tool/index.js").ToolDefinition<{
|
|
30
|
+
description: string;
|
|
31
|
+
timeout_ms: number;
|
|
32
|
+
command?: string | undefined;
|
|
33
|
+
ws?: {
|
|
34
|
+
url: string;
|
|
35
|
+
protocols?: string[] | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const MonitorTool: import("../../types/tool/index.js").ToolDefinition<{
|
|
11
39
|
description: string;
|
|
12
40
|
timeout_ms: number;
|
|
41
|
+
command?: string | undefined;
|
|
42
|
+
ws?: {
|
|
43
|
+
url: string;
|
|
44
|
+
protocols?: string[] | undefined;
|
|
45
|
+
} | undefined;
|
|
13
46
|
}>;
|
|
14
47
|
/**
|
|
15
48
|
* The tool, for a host that opts in.
|
|
@@ -18,7 +51,8 @@ export declare const MonitorTool: import("../../public-types.js").ToolDefinition
|
|
|
18
51
|
* wakes on them, and offering a tool that starts a job nobody will hear from
|
|
19
52
|
* is worse than not offering it. A function rather than a constant so a host
|
|
20
53
|
* can decide per turn, and so it reads like `getCodeAnalysisTools`, beside
|
|
21
|
-
* which a host mounts it deferred.
|
|
54
|
+
* which a host mounts it deferred. Called with no options it returns the
|
|
55
|
+
* shared {@link MonitorTool}.
|
|
22
56
|
*/
|
|
23
|
-
export declare function getMonitorTools(): (typeof MonitorTool)[];
|
|
57
|
+
export declare function getMonitorTools(options?: MonitorToolOptions): (typeof MonitorTool)[];
|
|
24
58
|
//# sourceMappingURL=monitor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/monitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"monitor.d.ts","sourceRoot":"","sources":["../../../src/tools/builtins/monitor.ts"],"names":[],"mappings":"AAQA,OAAO,EAGN,KAAK,mBAAmB,EAMxB,MAAM,wCAAwC,CAAA;AAgH/C,eAAO,MAAM,iBAAiB,YAAY,CAAA;AAE1C;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,mMAC+J,CAAA;AAMjM,wGAAwG;AACxG,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,SAAS,CAAC,EAAE,mBAAmB,CAAA;IACxC;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED,4FAA4F;AAC5F,eAAO,MAAM,yBAAyB,0OACkM,CAAA;AAKxO;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,kBAAuB;;;;;;;;GA8LjE;AAED,eAAO,MAAM,WAAW;;;;;;;;EAAsB,CAAA;AAE9C;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,CAAC,OAAO,WAAW,CAAC,EAAE,CAEpF"}
|