@parall/daemon 1.32.0 → 1.33.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/bundle/bb-browser-daemon.js +15628 -0
- package/bundle/buildDomTree.js +1501 -0
- package/bundle/manifest.json +19 -11
- package/bundle/parall-claude-agent.js +224 -58
- package/bundle/parall-codex-agent.js +224 -58
- package/bundle/parall-daemon.js +4507 -2668
- package/bundle/parall-openclaw-agent.js +4 -3
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +8 -2
- package/dist/clip-runtime/browser-dependency.d.ts +20 -0
- package/dist/clip-runtime/browser-dependency.d.ts.map +1 -0
- package/dist/clip-runtime/browser-dependency.js +52 -0
- package/dist/clip-runtime/browser-profile-manager.d.ts +67 -0
- package/dist/clip-runtime/browser-profile-manager.d.ts.map +1 -0
- package/dist/clip-runtime/browser-profile-manager.js +595 -0
- package/dist/clip-runtime/bun-resolver.d.ts +24 -0
- package/dist/clip-runtime/bun-resolver.d.ts.map +1 -0
- package/dist/clip-runtime/bun-resolver.js +58 -0
- package/dist/clip-runtime/clip-installer.d.ts.map +1 -1
- package/dist/clip-runtime/clip-installer.js +59 -18
- package/dist/clip-runtime/clip-provider.d.ts +13 -2
- package/dist/clip-runtime/clip-provider.d.ts.map +1 -1
- package/dist/clip-runtime/clip-provider.js +106 -36
- package/dist/clip-runtime/hub-client.d.ts +79 -0
- package/dist/clip-runtime/hub-client.d.ts.map +1 -0
- package/dist/clip-runtime/hub-client.js +320 -0
- package/dist/clip-runtime/index.d.ts +2 -0
- package/dist/clip-runtime/index.d.ts.map +1 -1
- package/dist/clip-runtime/index.js +2 -0
- package/dist/clip-runtime/ipc.d.ts +6 -0
- package/dist/clip-runtime/ipc.d.ts.map +1 -1
- package/dist/clip-runtime/manifest.d.ts +16 -8
- package/dist/clip-runtime/manifest.d.ts.map +1 -1
- package/dist/clip-runtime/manifest.js +13 -0
- package/dist/clip-runtime/process-manager.d.ts +55 -3
- package/dist/clip-runtime/process-manager.d.ts.map +1 -1
- package/dist/clip-runtime/process-manager.js +233 -76
- package/dist/clip-runtime/process.d.ts +15 -1
- package/dist/clip-runtime/process.d.ts.map +1 -1
- package/dist/clip-runtime/process.js +73 -10
- package/dist/config.d.ts +9 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +12 -0
- package/dist/index.js +46 -5
- package/dist/runtime-bin-resolver.d.ts +7 -0
- package/dist/runtime-bin-resolver.d.ts.map +1 -0
- package/dist/runtime-bin-resolver.js +292 -0
- package/dist/supervisor.d.ts +53 -4
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +449 -117
- package/package.json +7 -6
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HubClient — Connect-RPC unary/server-streaming client the execution-side
|
|
3
|
+
* daemon uses to resolve cross-machine dependency bindings and forward
|
|
4
|
+
* dependency invokes through the Clip Service (Hub).
|
|
5
|
+
*
|
|
6
|
+
* The execution daemon (machine A) does NOT verify the binding's clip_token —
|
|
7
|
+
* it reads its binding via GetBindings, then passes clip_token straight to
|
|
8
|
+
* Invoke(clip_name="browser", ...). The hub verifies the signed token, resolves
|
|
9
|
+
* the bound BrowserProfile's host machine (B), and forwards the InvokeCommand
|
|
10
|
+
* there. See docs/engineering-design/browser-profile-clip-integration.md §11.3.
|
|
11
|
+
*
|
|
12
|
+
* Protocol (same Connect envelope framing as clip-provider.ts):
|
|
13
|
+
* POST /clip.v1.ClipHubService/GetBindings (unary)
|
|
14
|
+
* POST /clip.v1.ClipHubService/Invoke (server-streaming)
|
|
15
|
+
* Content-Type: application/connect+json
|
|
16
|
+
* Authorization: Bearer mck_xxx (scope-gated to the caller's
|
|
17
|
+
* own executing Clip)
|
|
18
|
+
* Body / Response: envelope-framed JSON
|
|
19
|
+
* [flags:1][length:4 big-endian][JSON payload]
|
|
20
|
+
* flags=0x00 data, flags=0x02 end-of-stream (trailers)
|
|
21
|
+
*/
|
|
22
|
+
import * as http2 from 'node:http2';
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Connect envelope helpers (mirror clip-provider.ts; JSON mode)
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
const ENVELOPE_FLAG_DATA = 0x00;
|
|
27
|
+
const ENVELOPE_FLAG_TRAILER = 0x02;
|
|
28
|
+
const MAX_FRAME_LENGTH = 16 * 1024 * 1024; // 16 MiB
|
|
29
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
30
|
+
function encodeEnvelope(msg) {
|
|
31
|
+
const json = Buffer.from(JSON.stringify(msg), 'utf-8');
|
|
32
|
+
const header = Buffer.alloc(5);
|
|
33
|
+
header[0] = ENVELOPE_FLAG_DATA;
|
|
34
|
+
header.writeUInt32BE(json.length, 1);
|
|
35
|
+
return Buffer.concat([header, json]);
|
|
36
|
+
}
|
|
37
|
+
class EnvelopeDecoder {
|
|
38
|
+
buf = Buffer.alloc(0);
|
|
39
|
+
push(chunk) {
|
|
40
|
+
this.buf = this.buf.length === 0 ? Buffer.from(chunk) : Buffer.concat([this.buf, chunk]);
|
|
41
|
+
}
|
|
42
|
+
*flush() {
|
|
43
|
+
while (this.buf.length >= 5) {
|
|
44
|
+
const flags = this.buf[0];
|
|
45
|
+
const length = this.buf.readUInt32BE(1);
|
|
46
|
+
if (length > MAX_FRAME_LENGTH) {
|
|
47
|
+
this.buf = Buffer.alloc(0);
|
|
48
|
+
throw new Error(`envelope frame too large: ${length} bytes`);
|
|
49
|
+
}
|
|
50
|
+
if (this.buf.length < 5 + length)
|
|
51
|
+
break; // incomplete frame
|
|
52
|
+
const payload = this.buf.subarray(5, 5 + length);
|
|
53
|
+
this.buf = Buffer.from(this.buf.subarray(5 + length));
|
|
54
|
+
yield { flags, payload };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error surfaced by a hub Invoke that the hub flagged as a clip
|
|
60
|
+
* application-level rejection (errorIsCommand=true). The execution-side IPC
|
|
61
|
+
* layer maps this to a non-fatal ClipCommandError so the calling clip is not
|
|
62
|
+
* crashed by a recoverable browser command failure.
|
|
63
|
+
*/
|
|
64
|
+
export class HubCommandError extends Error {
|
|
65
|
+
code;
|
|
66
|
+
constructor(message, code) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = 'HubCommandError';
|
|
69
|
+
this.code = code;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Stateless Connect-RPC client. Each call opens a short-lived HTTP/2 session;
|
|
74
|
+
* dependency invokes are infrequent relative to the agent dispatch loop, so a
|
|
75
|
+
* pooled session is not worth the lifecycle complexity here.
|
|
76
|
+
*/
|
|
77
|
+
export class HubClient {
|
|
78
|
+
opts;
|
|
79
|
+
constructor(opts) {
|
|
80
|
+
this.opts = opts;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* GetBindings(clip_name=clipId) → slot→binding map. The hub gates
|
|
84
|
+
* this to Clips the caller machine actually executes. GetBindings is a
|
|
85
|
+
* UNARY Connect RPC, so it uses raw JSON framing (not the streaming envelope).
|
|
86
|
+
*/
|
|
87
|
+
async getBindings(clipId) {
|
|
88
|
+
const res = await this.unary('GetBindings', {
|
|
89
|
+
clipName: clipId,
|
|
90
|
+
});
|
|
91
|
+
return res.bindings ?? {};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Invoke a clip command through the hub, passing the binding's clip_token
|
|
95
|
+
* through untouched. Aggregates server-streamed output chunks into one value.
|
|
96
|
+
* The execution daemon does not verify clip_token — the hub does.
|
|
97
|
+
*/
|
|
98
|
+
async invoke(clipName, command, input, clipToken) {
|
|
99
|
+
const inputBytes = Buffer.from(input === undefined ? '{}' : JSON.stringify(input), 'utf-8').toString('base64');
|
|
100
|
+
const responses = await this.serverStream('Invoke', {
|
|
101
|
+
clipName,
|
|
102
|
+
command,
|
|
103
|
+
input: inputBytes,
|
|
104
|
+
clipToken,
|
|
105
|
+
});
|
|
106
|
+
const chunks = [];
|
|
107
|
+
for (const resp of responses) {
|
|
108
|
+
if (resp.error) {
|
|
109
|
+
const message = resp.error.message || 'hub invoke failed';
|
|
110
|
+
if (resp.errorIsCommand)
|
|
111
|
+
throw new HubCommandError(message, resp.error.code);
|
|
112
|
+
throw new Error(message);
|
|
113
|
+
}
|
|
114
|
+
if (resp.output)
|
|
115
|
+
chunks.push(decodeOutput(resp.output));
|
|
116
|
+
}
|
|
117
|
+
if (chunks.length === 0)
|
|
118
|
+
return null;
|
|
119
|
+
if (chunks.length === 1)
|
|
120
|
+
return chunks[0];
|
|
121
|
+
return chunks;
|
|
122
|
+
}
|
|
123
|
+
// -------------------------------------------------------------------------
|
|
124
|
+
// Transport
|
|
125
|
+
// -------------------------------------------------------------------------
|
|
126
|
+
/**
|
|
127
|
+
* Unary Connect call: raw JSON body (no envelope), Content-Type
|
|
128
|
+
* application/json. The response is raw JSON; a non-2xx status carries a
|
|
129
|
+
* Connect error envelope ({code,message}) in the body.
|
|
130
|
+
*/
|
|
131
|
+
unary(method, request) {
|
|
132
|
+
const timeoutMs = this.opts.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
133
|
+
const url = new URL(this.opts.serviceUrl);
|
|
134
|
+
return new Promise((resolve, reject) => {
|
|
135
|
+
let settled = false;
|
|
136
|
+
const session = http2.connect(url.origin);
|
|
137
|
+
const chunks = [];
|
|
138
|
+
let status = 0;
|
|
139
|
+
const cleanup = () => {
|
|
140
|
+
clearTimeout(timer);
|
|
141
|
+
try {
|
|
142
|
+
session.close();
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
/* already closed */
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
const fail = (err) => {
|
|
149
|
+
if (settled)
|
|
150
|
+
return;
|
|
151
|
+
settled = true;
|
|
152
|
+
cleanup();
|
|
153
|
+
reject(err);
|
|
154
|
+
};
|
|
155
|
+
const timer = setTimeout(() => fail(new Error(`hub ${method} timed out`)), timeoutMs);
|
|
156
|
+
timer.unref?.();
|
|
157
|
+
session.on('error', (err) => fail(new Error(`hub h2 session error: ${String(err)}`)));
|
|
158
|
+
const body = Buffer.from(JSON.stringify(request), 'utf-8');
|
|
159
|
+
const stream = session.request({
|
|
160
|
+
':method': 'POST',
|
|
161
|
+
':path': `/clip.v1.ClipHubService/${method}`,
|
|
162
|
+
'content-type': 'application/json',
|
|
163
|
+
'connect-protocol-version': '1',
|
|
164
|
+
authorization: `Bearer ${this.opts.authKey}`,
|
|
165
|
+
});
|
|
166
|
+
stream.on('response', (headers) => {
|
|
167
|
+
status = Number(headers[':status'] ?? 0);
|
|
168
|
+
});
|
|
169
|
+
stream.on('error', (err) => fail(new Error(`hub ${method} stream error: ${String(err)}`)));
|
|
170
|
+
stream.on('data', (chunk) => chunks.push(chunk));
|
|
171
|
+
stream.on('end', () => {
|
|
172
|
+
if (settled)
|
|
173
|
+
return;
|
|
174
|
+
settled = true;
|
|
175
|
+
cleanup();
|
|
176
|
+
const text = Buffer.concat(chunks).toString('utf-8');
|
|
177
|
+
if (status < 200 || status >= 300) {
|
|
178
|
+
reject(new Error(`hub ${method} failed (${status}): ${connectErrorMessage(text)}`));
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
try {
|
|
182
|
+
resolve((text ? JSON.parse(text) : {}));
|
|
183
|
+
}
|
|
184
|
+
catch (err) {
|
|
185
|
+
reject(new Error(`hub ${method} bad response: ${String(err)}`));
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
stream.end(body);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Server-streaming Connect call: enveloped frames over
|
|
193
|
+
* application/connect+json. Collects all response envelopes.
|
|
194
|
+
*/
|
|
195
|
+
serverStream(method, request) {
|
|
196
|
+
const timeoutMs = this.opts.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
197
|
+
const url = new URL(this.opts.serviceUrl);
|
|
198
|
+
return new Promise((resolve, reject) => {
|
|
199
|
+
let settled = false;
|
|
200
|
+
const session = http2.connect(url.origin);
|
|
201
|
+
const decoder = new EnvelopeDecoder();
|
|
202
|
+
const messages = [];
|
|
203
|
+
const rawChunks = [];
|
|
204
|
+
let status = 0;
|
|
205
|
+
const cleanup = () => {
|
|
206
|
+
clearTimeout(timer);
|
|
207
|
+
try {
|
|
208
|
+
session.close();
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
/* already closed */
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
const fail = (err) => {
|
|
215
|
+
if (settled)
|
|
216
|
+
return;
|
|
217
|
+
settled = true;
|
|
218
|
+
cleanup();
|
|
219
|
+
reject(err);
|
|
220
|
+
};
|
|
221
|
+
const succeed = () => {
|
|
222
|
+
if (settled)
|
|
223
|
+
return;
|
|
224
|
+
settled = true;
|
|
225
|
+
cleanup();
|
|
226
|
+
resolve(messages);
|
|
227
|
+
};
|
|
228
|
+
const timer = setTimeout(() => fail(new Error(`hub ${method} timed out`)), timeoutMs);
|
|
229
|
+
timer.unref?.();
|
|
230
|
+
session.on('error', (err) => fail(new Error(`hub h2 session error: ${String(err)}`)));
|
|
231
|
+
const stream = session.request({
|
|
232
|
+
':method': 'POST',
|
|
233
|
+
':path': `/clip.v1.ClipHubService/${method}`,
|
|
234
|
+
'content-type': 'application/connect+json',
|
|
235
|
+
'connect-protocol-version': '1',
|
|
236
|
+
authorization: `Bearer ${this.opts.authKey}`,
|
|
237
|
+
});
|
|
238
|
+
stream.on('response', (headers) => {
|
|
239
|
+
status = Number(headers[':status'] ?? 0);
|
|
240
|
+
});
|
|
241
|
+
stream.on('error', (err) => fail(new Error(`hub ${method} stream error: ${String(err)}`)));
|
|
242
|
+
stream.on('data', (chunk) => {
|
|
243
|
+
try {
|
|
244
|
+
// A non-2xx response is NOT a Connect envelope stream (auth/arg/server
|
|
245
|
+
// failures return a JSON error body); buffer it raw so we surface the
|
|
246
|
+
// hub's code/message instead of a misleading frame-decode error.
|
|
247
|
+
if (status < 200 || status >= 300) {
|
|
248
|
+
rawChunks.push(chunk);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
decoder.push(chunk);
|
|
252
|
+
for (const envelope of decoder.flush()) {
|
|
253
|
+
if (envelope.flags === ENVELOPE_FLAG_TRAILER) {
|
|
254
|
+
const trailer = parseTrailer(envelope.payload);
|
|
255
|
+
if (trailer?.error) {
|
|
256
|
+
fail(new Error(`hub ${method} error: ${trailer.error}`));
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
messages.push(JSON.parse(envelope.payload.toString('utf-8')));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
catch (err) {
|
|
265
|
+
fail(err instanceof Error ? err : new Error(String(err)));
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
const finish = () => {
|
|
269
|
+
if (status !== 0 && (status < 200 || status >= 300)) {
|
|
270
|
+
fail(new Error(`hub ${method} failed (${status}): ${connectErrorMessage(Buffer.concat(rawChunks).toString('utf-8'))}`));
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
succeed();
|
|
274
|
+
};
|
|
275
|
+
stream.on('end', finish);
|
|
276
|
+
stream.on('close', finish);
|
|
277
|
+
stream.end(encodeEnvelope(request));
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Connect unary errors carry a JSON body {"code","message"} alongside the HTTP
|
|
283
|
+
* status. Surface the message (with code) so a hub rejection is actionable.
|
|
284
|
+
*/
|
|
285
|
+
function connectErrorMessage(text) {
|
|
286
|
+
try {
|
|
287
|
+
const obj = JSON.parse(text);
|
|
288
|
+
if (obj?.message)
|
|
289
|
+
return obj.code ? `${obj.code}: ${obj.message}` : obj.message;
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
/* not JSON */
|
|
293
|
+
}
|
|
294
|
+
return text || 'unknown error';
|
|
295
|
+
}
|
|
296
|
+
function decodeOutput(output) {
|
|
297
|
+
const decoded = Buffer.from(output, 'base64').toString('utf-8');
|
|
298
|
+
try {
|
|
299
|
+
return JSON.parse(decoded);
|
|
300
|
+
}
|
|
301
|
+
catch {
|
|
302
|
+
return decoded;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Connect end-of-stream trailers carry an `error` object when the RPC failed.
|
|
307
|
+
* Surface its message so a hub-level rejection (e.g. 403 BROWSER_BINDING_INVALID)
|
|
308
|
+
* does not silently resolve to an empty stream.
|
|
309
|
+
*/
|
|
310
|
+
function parseTrailer(payload) {
|
|
311
|
+
try {
|
|
312
|
+
const obj = JSON.parse(payload.toString('utf-8'));
|
|
313
|
+
if (obj?.error)
|
|
314
|
+
return { error: obj.error.message || 'hub error' };
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
catch {
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
@@ -3,5 +3,7 @@ export { ClipProcess, ClipCommandError, type ClipProcessStatus, type InvokeEvent
|
|
|
3
3
|
export { type IpcMessage, type IpcManifest, type ListClipInfo, type ListCommandInfo, type IpcError, MessageType, NdjsonReader, NdjsonWriter, } from './ipc.js';
|
|
4
4
|
export { type ClipConfig, type ManifestCache, type CommandDetail, type ClipJson, } from './manifest.js';
|
|
5
5
|
export { ClipProvider, type ClipProviderOptions } from './clip-provider.js';
|
|
6
|
+
export { HubClient, HubCommandError, type HubClientOptions, type ClipBinding, } from './hub-client.js';
|
|
7
|
+
export { BrowserProfileManager } from './browser-profile-manager.js';
|
|
6
8
|
export { installClip, removeClip, parseSource, type InstallOptions, type InstallResult, } from './clip-installer.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAC1F,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,UAAU,CAAC;AAClB,OAAO,EACL,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,QAAQ,GACd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC5E,OAAO,EACL,SAAS,EACT,eAAe,EACf,KAAK,gBAAgB,EACrB,KAAK,WAAW,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,WAAW,EACX,UAAU,EACV,WAAW,EACX,KAAK,cAAc,EACnB,KAAK,aAAa,GACnB,MAAM,qBAAqB,CAAC"}
|
|
@@ -2,4 +2,6 @@ export { ClipProcessManager } from './process-manager.js';
|
|
|
2
2
|
export { ClipProcess, ClipCommandError, } from './process.js';
|
|
3
3
|
export { MessageType, NdjsonReader, NdjsonWriter, } from './ipc.js';
|
|
4
4
|
export { ClipProvider } from './clip-provider.js';
|
|
5
|
+
export { HubClient, HubCommandError, } from './hub-client.js';
|
|
6
|
+
export { BrowserProfileManager } from './browser-profile-manager.js';
|
|
5
7
|
export { installClip, removeClip, parseSource, } from './clip-installer.js';
|
|
@@ -22,6 +22,8 @@ export interface IpcMessage {
|
|
|
22
22
|
input?: unknown;
|
|
23
23
|
output?: unknown;
|
|
24
24
|
error?: string;
|
|
25
|
+
processExit?: boolean;
|
|
26
|
+
process_exit?: boolean;
|
|
25
27
|
manifest?: IpcManifest;
|
|
26
28
|
clips?: ListClipInfo[];
|
|
27
29
|
operation?: string;
|
|
@@ -43,6 +45,10 @@ export interface IpcManifest {
|
|
|
43
45
|
package?: string;
|
|
44
46
|
version?: string;
|
|
45
47
|
}>;
|
|
48
|
+
dependency_slots?: Record<string, {
|
|
49
|
+
package?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
}>;
|
|
46
52
|
patterns?: string[];
|
|
47
53
|
entities?: Record<string, unknown>;
|
|
48
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ipc.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/ipc.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa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AC,IAAI,CAAC;IAO9C,OAAO,CAAC,OAAO;IAkBf,KAAK,IAAI,IAAI;CAMd"}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
import type { IpcManifest } from './ipc.js';
|
|
2
|
+
export type DependencyMap = Record<string, {
|
|
3
|
+
package?: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
}>;
|
|
2
6
|
export interface ClipConfig {
|
|
7
|
+
clipId?: string;
|
|
3
8
|
name: string;
|
|
4
9
|
package?: string;
|
|
5
10
|
version?: string;
|
|
6
11
|
source: string;
|
|
7
12
|
path: string;
|
|
13
|
+
sourceType?: string;
|
|
14
|
+
sourceRef?: string;
|
|
8
15
|
token?: string;
|
|
9
16
|
manifest?: ManifestCache;
|
|
10
17
|
}
|
|
@@ -17,10 +24,8 @@ export interface ManifestCache {
|
|
|
17
24
|
commands: string[];
|
|
18
25
|
commandDetails: CommandDetail[];
|
|
19
26
|
hasWeb?: boolean;
|
|
20
|
-
dependencies?:
|
|
21
|
-
|
|
22
|
-
version?: string;
|
|
23
|
-
}>;
|
|
27
|
+
dependencies?: DependencyMap;
|
|
28
|
+
dependencySlots?: DependencyMap;
|
|
24
29
|
patterns?: string[];
|
|
25
30
|
entities?: Record<string, unknown>;
|
|
26
31
|
}
|
|
@@ -37,6 +42,11 @@ export interface ClipJson {
|
|
|
37
42
|
runtime?: string;
|
|
38
43
|
main?: string;
|
|
39
44
|
web?: string;
|
|
45
|
+
domain?: string;
|
|
46
|
+
dependencies?: DependencyMap;
|
|
47
|
+
dependency_slots?: DependencyMap;
|
|
48
|
+
patterns?: string[];
|
|
49
|
+
commands?: CommandDetail[];
|
|
40
50
|
author?: string;
|
|
41
51
|
license?: string;
|
|
42
52
|
repository?: string;
|
|
@@ -48,10 +58,8 @@ interface ProjectMetadata {
|
|
|
48
58
|
domain?: string;
|
|
49
59
|
main?: string;
|
|
50
60
|
web?: string;
|
|
51
|
-
dependencies?:
|
|
52
|
-
|
|
53
|
-
version?: string;
|
|
54
|
-
}>;
|
|
61
|
+
dependencies?: DependencyMap;
|
|
62
|
+
dependencySlots?: DependencyMap;
|
|
55
63
|
patterns?: string[];
|
|
56
64
|
commands?: CommandDetail[];
|
|
57
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,cAAc,EAAE,aAAa,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/manifest.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAEnF,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,MAAM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.name;
|
|
28
28
|
meta.version = clipJson.version;
|
|
29
29
|
meta.description = clipJson.description;
|
|
30
|
+
meta.domain = clipJson.domain;
|
|
30
31
|
meta.main = clipJson.main;
|
|
31
32
|
meta.web = clipJson.web;
|
|
33
|
+
meta.dependencies = clipJson.dependencies;
|
|
34
|
+
meta.dependencySlots = clipJson.dependency_slots;
|
|
35
|
+
meta.patterns = clipJson.patterns;
|
|
36
|
+
meta.commands = clipJson.commands;
|
|
32
37
|
}
|
|
33
38
|
const pkgJson = loadPackageJson(clip.path);
|
|
34
39
|
if (pkgJson) {
|
|
@@ -112,6 +117,13 @@ export function enrichManifest(clip, manifest) {
|
|
|
112
117
|
enriched.description = meta.description;
|
|
113
118
|
if (!enriched.domain && meta.domain)
|
|
114
119
|
enriched.domain = meta.domain;
|
|
120
|
+
if (!enriched.dependencies && meta.dependencies)
|
|
121
|
+
enriched.dependencies = meta.dependencies;
|
|
122
|
+
if (!enriched.dependencySlots && meta.dependencySlots) {
|
|
123
|
+
enriched.dependencySlots = meta.dependencySlots;
|
|
124
|
+
}
|
|
125
|
+
if (!enriched.patterns && meta.patterns)
|
|
126
|
+
enriched.patterns = meta.patterns;
|
|
115
127
|
if (meta.commands && meta.commands.length > 0 && enriched.commandDetails.length === 0) {
|
|
116
128
|
enriched.commandDetails = meta.commands;
|
|
117
129
|
enriched.commands = meta.commands.map((c) => c.name);
|
|
@@ -136,6 +148,7 @@ export function manifestFromIpc(ipcManifest) {
|
|
|
136
148
|
commandDetails: details,
|
|
137
149
|
hasWeb: ipcManifest.has_web,
|
|
138
150
|
dependencies: ipcManifest.dependencies,
|
|
151
|
+
dependencySlots: ipcManifest.dependency_slots,
|
|
139
152
|
patterns: ipcManifest.patterns,
|
|
140
153
|
entities: ipcManifest.entities,
|
|
141
154
|
};
|
|
@@ -1,14 +1,35 @@
|
|
|
1
|
-
import { type ClipProcessStatus } from './process.js';
|
|
1
|
+
import { type ClipInvokeContext, type ClipProcessStatus } from './process.js';
|
|
2
2
|
import type { ClipConfig, ManifestCache } from './manifest.js';
|
|
3
|
+
import type { BrowserProfileManager } from './browser-profile-manager.js';
|
|
4
|
+
import { type HubClient } from './hub-client.js';
|
|
3
5
|
export interface ClipProcessManagerOptions {
|
|
4
6
|
bunPath?: string;
|
|
5
7
|
clipsDir: string;
|
|
6
8
|
dataDir: string;
|
|
9
|
+
/**
|
|
10
|
+
* Host-side browser runtime. Present only on daemons that can host a
|
|
11
|
+
* BrowserProfile; drives inbound hub browser InvokeCommands. The execution
|
|
12
|
+
* side never calls this directly — nested browser invokes go out through the
|
|
13
|
+
* hub (see hubClient).
|
|
14
|
+
*/
|
|
15
|
+
browserProfileManager?: BrowserProfileManager;
|
|
16
|
+
/**
|
|
17
|
+
* Lazily-supplied hub client used by the execution side to resolve a
|
|
18
|
+
* dependency binding (GetBindings) and forward the dependency invoke
|
|
19
|
+
* (Invoke). Provided by the supervisor once machine identity + the clip
|
|
20
|
+
* service endpoint are resolved; may change on endpoint rollout.
|
|
21
|
+
*/
|
|
22
|
+
hubClient?: () => HubClient | null;
|
|
23
|
+
/** Ensure a server-declared clip is installed locally before spawn. */
|
|
24
|
+
ensureInstalled?: (config: ClipConfig) => Promise<ClipConfig>;
|
|
7
25
|
}
|
|
8
26
|
export declare class ClipProcessManager {
|
|
9
27
|
private bunPath;
|
|
10
28
|
private clipsDir;
|
|
11
29
|
private dataDir;
|
|
30
|
+
private browserProfileManager?;
|
|
31
|
+
private hubClient?;
|
|
32
|
+
private ensureInstalled?;
|
|
12
33
|
private processes;
|
|
13
34
|
private startingUp;
|
|
14
35
|
private statuses;
|
|
@@ -17,6 +38,8 @@ export declare class ClipProcessManager {
|
|
|
17
38
|
private statusListeners;
|
|
18
39
|
private manifestListeners;
|
|
19
40
|
constructor(opts: ClipProcessManagerOptions);
|
|
41
|
+
/** True when this daemon can host BrowserProfiles (serve inbound hub browser invokes). */
|
|
42
|
+
canHostBrowser(): boolean;
|
|
20
43
|
/** Backward-compat: set a single status listener (wraps addStatusListener). */
|
|
21
44
|
set onStatusChange(fn: ((name: string, status: ClipProcessStatus, message: string) => void) | undefined);
|
|
22
45
|
/** Subscribe to clip status changes. Returns an unsubscribe function. */
|
|
@@ -25,6 +48,7 @@ export declare class ClipProcessManager {
|
|
|
25
48
|
private notifyManifestUpdate;
|
|
26
49
|
private resolveBun;
|
|
27
50
|
registerClip(config: ClipConfig): void;
|
|
51
|
+
replaceClipConfig(config: ClipConfig): Promise<void>;
|
|
28
52
|
unregisterClip(name: string): Promise<void>;
|
|
29
53
|
startClip(name: string): Promise<void>;
|
|
30
54
|
stopClip(name: string): Promise<void>;
|
|
@@ -34,8 +58,8 @@ export declare class ClipProcessManager {
|
|
|
34
58
|
* Application-level errors (ClipCommandError) are NOT retried.
|
|
35
59
|
* Corresponds to Pinix ProcessManager.Invoke().
|
|
36
60
|
*/
|
|
37
|
-
invoke(name: string, command: string, input?: unknown): Promise<unknown>;
|
|
38
|
-
invokeStream(name: string, command: string, input?: unknown, onChunk?: (chunk: unknown) => void): Promise<unknown>;
|
|
61
|
+
invoke(name: string, command: string, input?: unknown, context?: ClipInvokeContext): Promise<unknown>;
|
|
62
|
+
invokeStream(name: string, command: string, input?: unknown, onChunk?: (chunk: unknown) => void, context?: ClipInvokeContext): Promise<unknown>;
|
|
39
63
|
loadManifest(name: string): Promise<ManifestCache>;
|
|
40
64
|
clipStatus(name: string): {
|
|
41
65
|
status: ClipProcessStatus;
|
|
@@ -43,6 +67,14 @@ export declare class ClipProcessManager {
|
|
|
43
67
|
};
|
|
44
68
|
isRunning(name: string): boolean;
|
|
45
69
|
getRegisteredClips(): ClipConfig[];
|
|
70
|
+
/**
|
|
71
|
+
* Clips this daemon advertises to the hub as a provider: the locally
|
|
72
|
+
* installed clips plus, when this machine hosts BrowserProfiles, a synthetic
|
|
73
|
+
* "browser" capability so the hub can route cross-machine browser invokes
|
|
74
|
+
* here. The browser capability has no local subprocess — it is served by
|
|
75
|
+
* invokeBrowserCapability() against bb-browser.
|
|
76
|
+
*/
|
|
77
|
+
getProviderClips(): ClipConfig[];
|
|
46
78
|
/**
|
|
47
79
|
* Load clip configs from the clips directory.
|
|
48
80
|
* Reads clip-config.json if present, or scans subdirectories for clip.json files.
|
|
@@ -52,6 +84,26 @@ export declare class ClipProcessManager {
|
|
|
52
84
|
private spawnProcess;
|
|
53
85
|
private ensureClipDataDir;
|
|
54
86
|
private removeIfSame;
|
|
87
|
+
private processKey;
|
|
88
|
+
private processKeyBelongsToName;
|
|
89
|
+
private processNameFromKey;
|
|
90
|
+
/**
|
|
91
|
+
* Execution-side nested dependency invoke (from a child clip's IPC). The
|
|
92
|
+
* browser slot is resolved UNIQUELY via the hub: read the Clip's binding
|
|
93
|
+
* (GetBindings), then forward the invoke through the hub (Invoke) to the bound
|
|
94
|
+
* BrowserProfile's host. No local shortcut, no fallback — unbound is rejected.
|
|
95
|
+
* The execution daemon never verifies clip_token; the hub does.
|
|
96
|
+
* See docs/engineering-design/browser-profile-clip-integration.md §11.3.
|
|
97
|
+
*/
|
|
98
|
+
private invokeDependency;
|
|
99
|
+
/**
|
|
100
|
+
* Host-side browser capability handler (inbound hub InvokeCommand for the
|
|
101
|
+
* synthetic "browser" clip). The hub forwards clip_token as the PLAINTEXT
|
|
102
|
+
* browser_profile_id, which the host daemon uses directly as the bb-browser
|
|
103
|
+
* account. Only daemons that host BrowserProfiles register this capability.
|
|
104
|
+
* See docs/engineering-design/browser-profile-clip-integration.md §11.2.
|
|
105
|
+
*/
|
|
106
|
+
invokeBrowserCapability(clipToken: string, command: string, input: unknown): Promise<unknown>;
|
|
55
107
|
private setStatus;
|
|
56
108
|
}
|
|
57
109
|
//# sourceMappingURL=process-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/process-manager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-manager.d.ts","sourceRoot":"","sources":["../../src/clip-runtime/process-manager.ts"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