@masstensor/diagnose 0.2.0 → 0.3.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 +43 -6
- package/dist/cli.js +233 -69
- package/dist/discover.d.ts +1 -0
- package/dist/discover.js +23 -0
- package/dist/engine.d.ts +12 -3
- package/dist/engine.js +47 -10
- package/dist/executor.js +46 -3
- package/dist/forward.d.ts +10 -0
- package/dist/forward.js +115 -0
- package/dist/journal.d.ts +32 -0
- package/dist/journal.js +81 -0
- package/dist/mcp.js +68 -5
- package/dist/operator.d.ts +3 -1
- package/dist/operator.js +28 -2
- package/dist/peer.d.ts +1 -0
- package/dist/peer.js +1 -1
- package/dist/prepare-pty.d.ts +1 -0
- package/dist/prepare-pty.js +26 -0
- package/dist/relay.js +5 -2
- package/dist/resources.d.ts +28 -0
- package/dist/resources.js +427 -0
- package/dist/schema.d.ts +479 -1
- package/dist/schema.js +16 -1
- package/dist/transfers.d.ts +19 -0
- package/dist/transfers.js +118 -0
- package/npm-shrinkwrap.json +21 -3
- package/package.json +4 -2
- package/src/cli.ts +77 -21
- package/src/discover.ts +17 -0
- package/src/engine.ts +33 -12
- package/src/executor.ts +20 -3
- package/src/forward.ts +50 -0
- package/src/journal.ts +48 -0
- package/src/mcp.ts +33 -5
- package/src/operator.ts +13 -2
- package/src/peer.ts +2 -2
- package/src/prepare-pty.ts +15 -0
- package/src/relay.ts +1 -1
- package/src/resources.ts +180 -0
- package/src/schema.ts +21 -1
- package/src/transfers.ts +48 -0
- package/test/cli.test.ts +30 -1
- package/test/mcp.test.ts +10 -1
- package/test/resources.test.ts +146 -0
package/dist/schema.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import { z } from 'zod';
|
|
|
2
2
|
export declare const MAX_FRAME: number;
|
|
3
3
|
export declare const CHUNK_SIZE: number;
|
|
4
4
|
export declare const MAX_OUTPUT: number;
|
|
5
|
-
export declare const atomicOperationNames: readonly ['system.inspect', 'file.read', 'file.write', 'process.run', 'process.script', 'serial.capture', 'serial.exchange'];
|
|
5
|
+
export declare const atomicOperationNames: readonly ['system.inspect', 'file.read', 'file.write', 'file.stat', 'file.list', 'file.mkdir', 'file.remove', 'file.rename', 'file.chmod', 'file.transfer', 'process.run', 'process.script', 'process.open', 'resource.resume', 'net.forward', 'serial.capture', 'serial.exchange'];
|
|
6
|
+
export declare const batchOperationNames: readonly ['system.inspect', 'file.read', 'file.write', 'file.stat', 'file.list', 'file.mkdir', 'file.remove', 'file.rename', 'file.chmod', 'process.run', 'process.script', 'serial.capture', 'serial.exchange'];
|
|
6
7
|
export declare const atomicTaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
7
8
|
id: z.ZodString;
|
|
8
9
|
reason: z.ZodString;
|
|
@@ -26,6 +27,113 @@ export declare const atomicTaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
26
27
|
content: z.ZodString;
|
|
27
28
|
expectedSha256: z.ZodOptional<z.ZodString>;
|
|
28
29
|
}, z.core.$strict>;
|
|
30
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
31
|
+
id: z.ZodString;
|
|
32
|
+
reason: z.ZodString;
|
|
33
|
+
operation: z.ZodLiteral<"file.stat">;
|
|
34
|
+
arguments: z.ZodObject<{
|
|
35
|
+
path: z.ZodString;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
reason: z.ZodString;
|
|
40
|
+
operation: z.ZodLiteral<"file.list">;
|
|
41
|
+
arguments: z.ZodObject<{
|
|
42
|
+
path: z.ZodString;
|
|
43
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
44
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
45
|
+
}, z.core.$strict>;
|
|
46
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
47
|
+
id: z.ZodString;
|
|
48
|
+
reason: z.ZodString;
|
|
49
|
+
operation: z.ZodLiteral<"file.mkdir">;
|
|
50
|
+
arguments: z.ZodObject<{
|
|
51
|
+
path: z.ZodString;
|
|
52
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
}, z.core.$strict>;
|
|
54
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
55
|
+
id: z.ZodString;
|
|
56
|
+
reason: z.ZodString;
|
|
57
|
+
operation: z.ZodLiteral<"file.remove">;
|
|
58
|
+
arguments: z.ZodObject<{
|
|
59
|
+
path: z.ZodString;
|
|
60
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
reason: z.ZodString;
|
|
65
|
+
operation: z.ZodLiteral<"file.rename">;
|
|
66
|
+
arguments: z.ZodObject<{
|
|
67
|
+
path: z.ZodString;
|
|
68
|
+
destination: z.ZodString;
|
|
69
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
70
|
+
}, z.core.$strict>;
|
|
71
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
reason: z.ZodString;
|
|
74
|
+
operation: z.ZodLiteral<"file.chmod">;
|
|
75
|
+
arguments: z.ZodObject<{
|
|
76
|
+
path: z.ZodString;
|
|
77
|
+
mode: z.ZodNumber;
|
|
78
|
+
}, z.core.$strict>;
|
|
79
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
80
|
+
id: z.ZodString;
|
|
81
|
+
reason: z.ZodString;
|
|
82
|
+
operation: z.ZodLiteral<"file.transfer">;
|
|
83
|
+
arguments: z.ZodObject<{
|
|
84
|
+
path: z.ZodString;
|
|
85
|
+
direction: z.ZodEnum<{
|
|
86
|
+
download: "download";
|
|
87
|
+
upload: "upload";
|
|
88
|
+
}>;
|
|
89
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
90
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
91
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
92
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
95
|
+
id: z.ZodString;
|
|
96
|
+
reason: z.ZodString;
|
|
97
|
+
operation: z.ZodLiteral<"process.open">;
|
|
98
|
+
arguments: z.ZodObject<{
|
|
99
|
+
executable: z.ZodOptional<z.ZodString>;
|
|
100
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
101
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
102
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
103
|
+
pty: z.ZodDefault<z.ZodBoolean>;
|
|
104
|
+
cols: z.ZodDefault<z.ZodNumber>;
|
|
105
|
+
rows: z.ZodDefault<z.ZodNumber>;
|
|
106
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
107
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
108
|
+
maxOutputBytes: z.ZodDefault<z.ZodNumber>;
|
|
109
|
+
}, z.core.$strict>;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
id: z.ZodString;
|
|
112
|
+
reason: z.ZodString;
|
|
113
|
+
operation: z.ZodLiteral<"resource.resume">;
|
|
114
|
+
arguments: z.ZodObject<{
|
|
115
|
+
id: z.ZodString;
|
|
116
|
+
resumeToken: z.ZodString;
|
|
117
|
+
}, z.core.$strict>;
|
|
118
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
119
|
+
id: z.ZodString;
|
|
120
|
+
reason: z.ZodString;
|
|
121
|
+
operation: z.ZodLiteral<"net.forward">;
|
|
122
|
+
arguments: z.ZodObject<{
|
|
123
|
+
direction: z.ZodEnum<{
|
|
124
|
+
local: "local";
|
|
125
|
+
remote: "remote";
|
|
126
|
+
socks: "socks";
|
|
127
|
+
}>;
|
|
128
|
+
host: z.ZodDefault<z.ZodString>;
|
|
129
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
130
|
+
bindHost: z.ZodDefault<z.ZodEnum<{
|
|
131
|
+
"127.0.0.1": "127.0.0.1";
|
|
132
|
+
"::1": "::1";
|
|
133
|
+
}>>;
|
|
134
|
+
bindPort: z.ZodDefault<z.ZodNumber>;
|
|
135
|
+
allowedHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
136
|
+
}, z.core.$strict>;
|
|
29
137
|
}, z.core.$strict>, z.ZodObject<{
|
|
30
138
|
id: z.ZodString;
|
|
31
139
|
reason: z.ZodString;
|
|
@@ -86,6 +194,113 @@ export declare const batchTaskSchema: z.ZodObject<{
|
|
|
86
194
|
content: z.ZodString;
|
|
87
195
|
expectedSha256: z.ZodOptional<z.ZodString>;
|
|
88
196
|
}, z.core.$strict>;
|
|
197
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
198
|
+
id: z.ZodString;
|
|
199
|
+
reason: z.ZodString;
|
|
200
|
+
operation: z.ZodLiteral<"file.stat">;
|
|
201
|
+
arguments: z.ZodObject<{
|
|
202
|
+
path: z.ZodString;
|
|
203
|
+
}, z.core.$strict>;
|
|
204
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
205
|
+
id: z.ZodString;
|
|
206
|
+
reason: z.ZodString;
|
|
207
|
+
operation: z.ZodLiteral<"file.list">;
|
|
208
|
+
arguments: z.ZodObject<{
|
|
209
|
+
path: z.ZodString;
|
|
210
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
211
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
212
|
+
}, z.core.$strict>;
|
|
213
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
214
|
+
id: z.ZodString;
|
|
215
|
+
reason: z.ZodString;
|
|
216
|
+
operation: z.ZodLiteral<"file.mkdir">;
|
|
217
|
+
arguments: z.ZodObject<{
|
|
218
|
+
path: z.ZodString;
|
|
219
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
220
|
+
}, z.core.$strict>;
|
|
221
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
222
|
+
id: z.ZodString;
|
|
223
|
+
reason: z.ZodString;
|
|
224
|
+
operation: z.ZodLiteral<"file.remove">;
|
|
225
|
+
arguments: z.ZodObject<{
|
|
226
|
+
path: z.ZodString;
|
|
227
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
228
|
+
}, z.core.$strict>;
|
|
229
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
230
|
+
id: z.ZodString;
|
|
231
|
+
reason: z.ZodString;
|
|
232
|
+
operation: z.ZodLiteral<"file.rename">;
|
|
233
|
+
arguments: z.ZodObject<{
|
|
234
|
+
path: z.ZodString;
|
|
235
|
+
destination: z.ZodString;
|
|
236
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
237
|
+
}, z.core.$strict>;
|
|
238
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
+
id: z.ZodString;
|
|
240
|
+
reason: z.ZodString;
|
|
241
|
+
operation: z.ZodLiteral<"file.chmod">;
|
|
242
|
+
arguments: z.ZodObject<{
|
|
243
|
+
path: z.ZodString;
|
|
244
|
+
mode: z.ZodNumber;
|
|
245
|
+
}, z.core.$strict>;
|
|
246
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
247
|
+
id: z.ZodString;
|
|
248
|
+
reason: z.ZodString;
|
|
249
|
+
operation: z.ZodLiteral<"file.transfer">;
|
|
250
|
+
arguments: z.ZodObject<{
|
|
251
|
+
path: z.ZodString;
|
|
252
|
+
direction: z.ZodEnum<{
|
|
253
|
+
download: "download";
|
|
254
|
+
upload: "upload";
|
|
255
|
+
}>;
|
|
256
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
257
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
258
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
259
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
260
|
+
}, z.core.$strict>;
|
|
261
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
262
|
+
id: z.ZodString;
|
|
263
|
+
reason: z.ZodString;
|
|
264
|
+
operation: z.ZodLiteral<"process.open">;
|
|
265
|
+
arguments: z.ZodObject<{
|
|
266
|
+
executable: z.ZodOptional<z.ZodString>;
|
|
267
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
268
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
269
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
270
|
+
pty: z.ZodDefault<z.ZodBoolean>;
|
|
271
|
+
cols: z.ZodDefault<z.ZodNumber>;
|
|
272
|
+
rows: z.ZodDefault<z.ZodNumber>;
|
|
273
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
274
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
275
|
+
maxOutputBytes: z.ZodDefault<z.ZodNumber>;
|
|
276
|
+
}, z.core.$strict>;
|
|
277
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
278
|
+
id: z.ZodString;
|
|
279
|
+
reason: z.ZodString;
|
|
280
|
+
operation: z.ZodLiteral<"resource.resume">;
|
|
281
|
+
arguments: z.ZodObject<{
|
|
282
|
+
id: z.ZodString;
|
|
283
|
+
resumeToken: z.ZodString;
|
|
284
|
+
}, z.core.$strict>;
|
|
285
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
286
|
+
id: z.ZodString;
|
|
287
|
+
reason: z.ZodString;
|
|
288
|
+
operation: z.ZodLiteral<"net.forward">;
|
|
289
|
+
arguments: z.ZodObject<{
|
|
290
|
+
direction: z.ZodEnum<{
|
|
291
|
+
local: "local";
|
|
292
|
+
remote: "remote";
|
|
293
|
+
socks: "socks";
|
|
294
|
+
}>;
|
|
295
|
+
host: z.ZodDefault<z.ZodString>;
|
|
296
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
297
|
+
bindHost: z.ZodDefault<z.ZodEnum<{
|
|
298
|
+
"127.0.0.1": "127.0.0.1";
|
|
299
|
+
"::1": "::1";
|
|
300
|
+
}>>;
|
|
301
|
+
bindPort: z.ZodDefault<z.ZodNumber>;
|
|
302
|
+
allowedHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
303
|
+
}, z.core.$strict>;
|
|
89
304
|
}, z.core.$strict>, z.ZodObject<{
|
|
90
305
|
id: z.ZodString;
|
|
91
306
|
reason: z.ZodString;
|
|
@@ -145,6 +360,113 @@ export declare const taskSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z
|
|
|
145
360
|
content: z.ZodString;
|
|
146
361
|
expectedSha256: z.ZodOptional<z.ZodString>;
|
|
147
362
|
}, z.core.$strict>;
|
|
363
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
364
|
+
id: z.ZodString;
|
|
365
|
+
reason: z.ZodString;
|
|
366
|
+
operation: z.ZodLiteral<"file.stat">;
|
|
367
|
+
arguments: z.ZodObject<{
|
|
368
|
+
path: z.ZodString;
|
|
369
|
+
}, z.core.$strict>;
|
|
370
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
371
|
+
id: z.ZodString;
|
|
372
|
+
reason: z.ZodString;
|
|
373
|
+
operation: z.ZodLiteral<"file.list">;
|
|
374
|
+
arguments: z.ZodObject<{
|
|
375
|
+
path: z.ZodString;
|
|
376
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
377
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
378
|
+
}, z.core.$strict>;
|
|
379
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
380
|
+
id: z.ZodString;
|
|
381
|
+
reason: z.ZodString;
|
|
382
|
+
operation: z.ZodLiteral<"file.mkdir">;
|
|
383
|
+
arguments: z.ZodObject<{
|
|
384
|
+
path: z.ZodString;
|
|
385
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
386
|
+
}, z.core.$strict>;
|
|
387
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
388
|
+
id: z.ZodString;
|
|
389
|
+
reason: z.ZodString;
|
|
390
|
+
operation: z.ZodLiteral<"file.remove">;
|
|
391
|
+
arguments: z.ZodObject<{
|
|
392
|
+
path: z.ZodString;
|
|
393
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
394
|
+
}, z.core.$strict>;
|
|
395
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
396
|
+
id: z.ZodString;
|
|
397
|
+
reason: z.ZodString;
|
|
398
|
+
operation: z.ZodLiteral<"file.rename">;
|
|
399
|
+
arguments: z.ZodObject<{
|
|
400
|
+
path: z.ZodString;
|
|
401
|
+
destination: z.ZodString;
|
|
402
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
403
|
+
}, z.core.$strict>;
|
|
404
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
405
|
+
id: z.ZodString;
|
|
406
|
+
reason: z.ZodString;
|
|
407
|
+
operation: z.ZodLiteral<"file.chmod">;
|
|
408
|
+
arguments: z.ZodObject<{
|
|
409
|
+
path: z.ZodString;
|
|
410
|
+
mode: z.ZodNumber;
|
|
411
|
+
}, z.core.$strict>;
|
|
412
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
413
|
+
id: z.ZodString;
|
|
414
|
+
reason: z.ZodString;
|
|
415
|
+
operation: z.ZodLiteral<"file.transfer">;
|
|
416
|
+
arguments: z.ZodObject<{
|
|
417
|
+
path: z.ZodString;
|
|
418
|
+
direction: z.ZodEnum<{
|
|
419
|
+
download: "download";
|
|
420
|
+
upload: "upload";
|
|
421
|
+
}>;
|
|
422
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
423
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
424
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
425
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
426
|
+
}, z.core.$strict>;
|
|
427
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
428
|
+
id: z.ZodString;
|
|
429
|
+
reason: z.ZodString;
|
|
430
|
+
operation: z.ZodLiteral<"process.open">;
|
|
431
|
+
arguments: z.ZodObject<{
|
|
432
|
+
executable: z.ZodOptional<z.ZodString>;
|
|
433
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
434
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
435
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
436
|
+
pty: z.ZodDefault<z.ZodBoolean>;
|
|
437
|
+
cols: z.ZodDefault<z.ZodNumber>;
|
|
438
|
+
rows: z.ZodDefault<z.ZodNumber>;
|
|
439
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
440
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
441
|
+
maxOutputBytes: z.ZodDefault<z.ZodNumber>;
|
|
442
|
+
}, z.core.$strict>;
|
|
443
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
444
|
+
id: z.ZodString;
|
|
445
|
+
reason: z.ZodString;
|
|
446
|
+
operation: z.ZodLiteral<"resource.resume">;
|
|
447
|
+
arguments: z.ZodObject<{
|
|
448
|
+
id: z.ZodString;
|
|
449
|
+
resumeToken: z.ZodString;
|
|
450
|
+
}, z.core.$strict>;
|
|
451
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
452
|
+
id: z.ZodString;
|
|
453
|
+
reason: z.ZodString;
|
|
454
|
+
operation: z.ZodLiteral<"net.forward">;
|
|
455
|
+
arguments: z.ZodObject<{
|
|
456
|
+
direction: z.ZodEnum<{
|
|
457
|
+
local: "local";
|
|
458
|
+
remote: "remote";
|
|
459
|
+
socks: "socks";
|
|
460
|
+
}>;
|
|
461
|
+
host: z.ZodDefault<z.ZodString>;
|
|
462
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
463
|
+
bindHost: z.ZodDefault<z.ZodEnum<{
|
|
464
|
+
"127.0.0.1": "127.0.0.1";
|
|
465
|
+
"::1": "::1";
|
|
466
|
+
}>>;
|
|
467
|
+
bindPort: z.ZodDefault<z.ZodNumber>;
|
|
468
|
+
allowedHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
469
|
+
}, z.core.$strict>;
|
|
148
470
|
}, z.core.$strict>, z.ZodObject<{
|
|
149
471
|
id: z.ZodString;
|
|
150
472
|
reason: z.ZodString;
|
|
@@ -204,6 +526,113 @@ export declare const taskSchema: z.ZodUnion<readonly [z.ZodDiscriminatedUnion<[z
|
|
|
204
526
|
content: z.ZodString;
|
|
205
527
|
expectedSha256: z.ZodOptional<z.ZodString>;
|
|
206
528
|
}, z.core.$strict>;
|
|
529
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
530
|
+
id: z.ZodString;
|
|
531
|
+
reason: z.ZodString;
|
|
532
|
+
operation: z.ZodLiteral<"file.stat">;
|
|
533
|
+
arguments: z.ZodObject<{
|
|
534
|
+
path: z.ZodString;
|
|
535
|
+
}, z.core.$strict>;
|
|
536
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
537
|
+
id: z.ZodString;
|
|
538
|
+
reason: z.ZodString;
|
|
539
|
+
operation: z.ZodLiteral<"file.list">;
|
|
540
|
+
arguments: z.ZodObject<{
|
|
541
|
+
path: z.ZodString;
|
|
542
|
+
offset: z.ZodDefault<z.ZodNumber>;
|
|
543
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
544
|
+
}, z.core.$strict>;
|
|
545
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
546
|
+
id: z.ZodString;
|
|
547
|
+
reason: z.ZodString;
|
|
548
|
+
operation: z.ZodLiteral<"file.mkdir">;
|
|
549
|
+
arguments: z.ZodObject<{
|
|
550
|
+
path: z.ZodString;
|
|
551
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
552
|
+
}, z.core.$strict>;
|
|
553
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
554
|
+
id: z.ZodString;
|
|
555
|
+
reason: z.ZodString;
|
|
556
|
+
operation: z.ZodLiteral<"file.remove">;
|
|
557
|
+
arguments: z.ZodObject<{
|
|
558
|
+
path: z.ZodString;
|
|
559
|
+
recursive: z.ZodDefault<z.ZodBoolean>;
|
|
560
|
+
}, z.core.$strict>;
|
|
561
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
562
|
+
id: z.ZodString;
|
|
563
|
+
reason: z.ZodString;
|
|
564
|
+
operation: z.ZodLiteral<"file.rename">;
|
|
565
|
+
arguments: z.ZodObject<{
|
|
566
|
+
path: z.ZodString;
|
|
567
|
+
destination: z.ZodString;
|
|
568
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
569
|
+
}, z.core.$strict>;
|
|
570
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
571
|
+
id: z.ZodString;
|
|
572
|
+
reason: z.ZodString;
|
|
573
|
+
operation: z.ZodLiteral<"file.chmod">;
|
|
574
|
+
arguments: z.ZodObject<{
|
|
575
|
+
path: z.ZodString;
|
|
576
|
+
mode: z.ZodNumber;
|
|
577
|
+
}, z.core.$strict>;
|
|
578
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
579
|
+
id: z.ZodString;
|
|
580
|
+
reason: z.ZodString;
|
|
581
|
+
operation: z.ZodLiteral<"file.transfer">;
|
|
582
|
+
arguments: z.ZodObject<{
|
|
583
|
+
path: z.ZodString;
|
|
584
|
+
direction: z.ZodEnum<{
|
|
585
|
+
download: "download";
|
|
586
|
+
upload: "upload";
|
|
587
|
+
}>;
|
|
588
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
589
|
+
sha256: z.ZodOptional<z.ZodString>;
|
|
590
|
+
overwrite: z.ZodDefault<z.ZodBoolean>;
|
|
591
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
592
|
+
}, z.core.$strict>;
|
|
593
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
594
|
+
id: z.ZodString;
|
|
595
|
+
reason: z.ZodString;
|
|
596
|
+
operation: z.ZodLiteral<"process.open">;
|
|
597
|
+
arguments: z.ZodObject<{
|
|
598
|
+
executable: z.ZodOptional<z.ZodString>;
|
|
599
|
+
args: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
600
|
+
cwd: z.ZodOptional<z.ZodString>;
|
|
601
|
+
env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
602
|
+
pty: z.ZodDefault<z.ZodBoolean>;
|
|
603
|
+
cols: z.ZodDefault<z.ZodNumber>;
|
|
604
|
+
rows: z.ZodDefault<z.ZodNumber>;
|
|
605
|
+
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
606
|
+
retainOnDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
607
|
+
maxOutputBytes: z.ZodDefault<z.ZodNumber>;
|
|
608
|
+
}, z.core.$strict>;
|
|
609
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
610
|
+
id: z.ZodString;
|
|
611
|
+
reason: z.ZodString;
|
|
612
|
+
operation: z.ZodLiteral<"resource.resume">;
|
|
613
|
+
arguments: z.ZodObject<{
|
|
614
|
+
id: z.ZodString;
|
|
615
|
+
resumeToken: z.ZodString;
|
|
616
|
+
}, z.core.$strict>;
|
|
617
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
618
|
+
id: z.ZodString;
|
|
619
|
+
reason: z.ZodString;
|
|
620
|
+
operation: z.ZodLiteral<"net.forward">;
|
|
621
|
+
arguments: z.ZodObject<{
|
|
622
|
+
direction: z.ZodEnum<{
|
|
623
|
+
local: "local";
|
|
624
|
+
remote: "remote";
|
|
625
|
+
socks: "socks";
|
|
626
|
+
}>;
|
|
627
|
+
host: z.ZodDefault<z.ZodString>;
|
|
628
|
+
port: z.ZodDefault<z.ZodNumber>;
|
|
629
|
+
bindHost: z.ZodDefault<z.ZodEnum<{
|
|
630
|
+
"127.0.0.1": "127.0.0.1";
|
|
631
|
+
"::1": "::1";
|
|
632
|
+
}>>;
|
|
633
|
+
bindPort: z.ZodDefault<z.ZodNumber>;
|
|
634
|
+
allowedHosts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
635
|
+
}, z.core.$strict>;
|
|
207
636
|
}, z.core.$strict>, z.ZodObject<{
|
|
208
637
|
id: z.ZodString;
|
|
209
638
|
reason: z.ZodString;
|
|
@@ -265,6 +694,37 @@ export type Result = {
|
|
|
265
694
|
exitCode?: number | null;
|
|
266
695
|
truncated?: boolean;
|
|
267
696
|
};
|
|
697
|
+
export declare const resourceRequestSchema: z.ZodObject<{
|
|
698
|
+
id: z.ZodOptional<z.ZodString>;
|
|
699
|
+
action: z.ZodEnum<{
|
|
700
|
+
accept: "accept";
|
|
701
|
+
close: "close";
|
|
702
|
+
commit: "commit";
|
|
703
|
+
connect: "connect";
|
|
704
|
+
input: "input";
|
|
705
|
+
list: "list";
|
|
706
|
+
read: "read";
|
|
707
|
+
resize: "resize";
|
|
708
|
+
signal: "signal";
|
|
709
|
+
status: "status";
|
|
710
|
+
}>;
|
|
711
|
+
cursor: z.ZodDefault<z.ZodNumber>;
|
|
712
|
+
limit: z.ZodDefault<z.ZodNumber>;
|
|
713
|
+
data: z.ZodOptional<z.ZodString>;
|
|
714
|
+
eof: z.ZodDefault<z.ZodBoolean>;
|
|
715
|
+
cols: z.ZodOptional<z.ZodNumber>;
|
|
716
|
+
rows: z.ZodOptional<z.ZodNumber>;
|
|
717
|
+
signal: z.ZodOptional<z.ZodEnum<{
|
|
718
|
+
SIGHUP: "SIGHUP";
|
|
719
|
+
SIGINT: "SIGINT";
|
|
720
|
+
SIGKILL: "SIGKILL";
|
|
721
|
+
SIGQUIT: "SIGQUIT";
|
|
722
|
+
SIGTERM: "SIGTERM";
|
|
723
|
+
}>>;
|
|
724
|
+
host: z.ZodOptional<z.ZodString>;
|
|
725
|
+
port: z.ZodOptional<z.ZodNumber>;
|
|
726
|
+
}, z.core.$strict>;
|
|
727
|
+
export type ResourceRequest = z.infer<typeof resourceRequestSchema>;
|
|
268
728
|
export type WireMessage = {
|
|
269
729
|
type: 'session.accepted';
|
|
270
730
|
label: string;
|
|
@@ -292,6 +752,24 @@ export type WireMessage = {
|
|
|
292
752
|
} | {
|
|
293
753
|
type: 'task.cancel';
|
|
294
754
|
id: string;
|
|
755
|
+
} | {
|
|
756
|
+
type: 'resource.request';
|
|
757
|
+
requestId: string;
|
|
758
|
+
request: ResourceRequest;
|
|
759
|
+
} | {
|
|
760
|
+
type: 'resource.result';
|
|
761
|
+
requestId: string;
|
|
762
|
+
value?: unknown;
|
|
763
|
+
error?: string;
|
|
764
|
+
} | {
|
|
765
|
+
type: 'resource.request';
|
|
766
|
+
requestId: string;
|
|
767
|
+
request: ResourceRequest;
|
|
768
|
+
} | {
|
|
769
|
+
type: 'resource.result';
|
|
770
|
+
requestId: string;
|
|
771
|
+
value?: unknown;
|
|
772
|
+
error?: string;
|
|
295
773
|
} | {
|
|
296
774
|
type: 'ping' | 'pong';
|
|
297
775
|
};
|
package/dist/schema.js
CHANGED
|
@@ -4,22 +4,37 @@ export const CHUNK_SIZE = 12 * 1024;
|
|
|
4
4
|
export const MAX_OUTPUT = 10 * 1024 * 1024;
|
|
5
5
|
const path = z.string().min(1).max(4096);
|
|
6
6
|
const common = { id: z.string().uuid(), reason: z.string().min(1).max(1000) };
|
|
7
|
-
export const atomicOperationNames = ['system.inspect', 'file.read', 'file.write', 'process.run', 'process.script', 'serial.capture', 'serial.exchange'];
|
|
7
|
+
export const atomicOperationNames = ['system.inspect', 'file.read', 'file.write', 'file.stat', 'file.list', 'file.mkdir', 'file.remove', 'file.rename', 'file.chmod', 'file.transfer', 'process.run', 'process.script', 'process.open', 'resource.resume', 'net.forward', 'serial.capture', 'serial.exchange'];
|
|
8
|
+
export const batchOperationNames = ['system.inspect', 'file.read', 'file.write', 'file.stat', 'file.list', 'file.mkdir', 'file.remove', 'file.rename', 'file.chmod', 'process.run', 'process.script', 'serial.capture', 'serial.exchange'];
|
|
9
|
+
const environment = z.record(z.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/), z.string().max(65536)).optional();
|
|
8
10
|
export const atomicTaskSchema = z.discriminatedUnion('operation', [
|
|
9
11
|
z.object({ ...common, operation: z.literal('system.inspect'), arguments: z.object({}).strict() }).strict(),
|
|
10
12
|
z.object({ ...common, operation: z.literal('file.read'), arguments: z.object({ path, offset: z.number().int().min(0).default(0), length: z.number().int().min(1).max(1024 * 1024).default(65536) }).strict() }).strict(),
|
|
11
13
|
z.object({ ...common, operation: z.literal('file.write'), arguments: z.object({ path, content: z.string().max(1024 * 1024), expectedSha256: z.string().regex(/^[a-f0-9]{64}$/).optional() }).strict() }).strict(),
|
|
14
|
+
z.object({ ...common, operation: z.literal('file.stat'), arguments: z.object({ path }).strict() }).strict(),
|
|
15
|
+
z.object({ ...common, operation: z.literal('file.list'), arguments: z.object({ path, offset: z.number().int().min(0).default(0), limit: z.number().int().min(1).max(200).default(50) }).strict() }).strict(),
|
|
16
|
+
z.object({ ...common, operation: z.literal('file.mkdir'), arguments: z.object({ path, recursive: z.boolean().default(false) }).strict() }).strict(),
|
|
17
|
+
z.object({ ...common, operation: z.literal('file.remove'), arguments: z.object({ path, recursive: z.boolean().default(false) }).strict() }).strict(),
|
|
18
|
+
z.object({ ...common, operation: z.literal('file.rename'), arguments: z.object({ path, destination: path, overwrite: z.boolean().default(false) }).strict() }).strict(),
|
|
19
|
+
z.object({ ...common, operation: z.literal('file.chmod'), arguments: z.object({ path, mode: z.number().int().min(0).max(0o777) }).strict() }).strict(),
|
|
20
|
+
z.object({ ...common, operation: z.literal('file.transfer'), arguments: z.object({ path, direction: z.enum(['upload', 'download']), size: z.number().int().min(0).max(1024 ** 4).optional(), sha256: z.string().regex(/^[a-f0-9]{64}$/).optional(), overwrite: z.boolean().default(false), retainOnDisconnect: z.boolean().default(true) }).strict() }).strict(),
|
|
21
|
+
z.object({ ...common, operation: z.literal('process.open'), arguments: z.object({ executable: path.optional(), args: z.array(z.string().max(65536)).max(128).default([]), cwd: path.optional(), env: environment, pty: z.boolean().default(false), cols: z.number().int().min(20).max(500).default(100), rows: z.number().int().min(5).max(200).default(30), timeoutMs: z.number().int().min(0).max(86400000).default(3600000), retainOnDisconnect: z.boolean().default(false), maxOutputBytes: z.number().int().min(1024).max(1024 ** 3).default(64 * 1024 ** 2) }).strict() }).strict(),
|
|
22
|
+
z.object({ ...common, operation: z.literal('resource.resume'), arguments: z.object({ id: z.string().uuid(), resumeToken: z.string().regex(/^[A-Za-z0-9_-]{43}$/) }).strict() }).strict(),
|
|
23
|
+
z.object({ ...common, operation: z.literal('net.forward'), arguments: z.object({ direction: z.enum(['local', 'remote', 'socks']), host: z.string().min(1).max(253).default('127.0.0.1'), port: z.number().int().min(0).max(65535).default(0), bindHost: z.enum(['127.0.0.1', '::1']).default('127.0.0.1'), bindPort: z.number().int().min(0).max(65535).default(0), allowedHosts: z.array(z.string().min(1).max(253)).min(1).max(100).default(['*']) }).strict() }).strict(),
|
|
12
24
|
z.object({ ...common, operation: z.literal('process.run'), arguments: z.object({ executable: path, args: z.array(z.string().max(65536)).max(128).default([]), cwd: path.optional(), timeoutMs: z.number().int().min(100).max(300000).default(60000) }).strict() }).strict(),
|
|
13
25
|
z.object({ ...common, operation: z.literal('process.script'), arguments: z.object({ interpreter: path, script: z.string().min(1).max(256 * 1024), args: z.array(z.string().max(65536)).max(128).default([]), cwd: path.optional(), timeoutMs: z.number().int().min(100).max(300000).default(60000) }).strict() }).strict(),
|
|
14
26
|
...['serial.capture', 'serial.exchange'].map(operation => z.object({ ...common, operation: z.literal(operation), arguments: z.object({ path, baudRate: z.number().int().min(300).max(3000000).default(115200), durationMs: z.number().int().min(100).max(300000).default(20000), dataHex: z.string().regex(/^(?:[a-fA-F0-9]{2})*$/).max(65536).optional() }).strict() }).strict()),
|
|
15
27
|
]);
|
|
16
28
|
export const batchTaskSchema = z.object({ ...common, operation: z.literal('batch.run'), arguments: z.object({ steps: z.array(atomicTaskSchema).min(1).max(32), stopOnError: z.boolean().default(true), timeoutMs: z.number().int().min(100).max(300000).default(300000) }).strict() }).strict().refine(task => new Set([task.id, ...task.arguments.steps.map(step => step.id)]).size === task.arguments.steps.length + 1, 'Batch task IDs must be unique');
|
|
17
29
|
export const taskSchema = z.union([atomicTaskSchema, batchTaskSchema]);
|
|
30
|
+
export const resourceRequestSchema = z.object({ id: z.string().uuid().optional(), action: z.enum(['list', 'read', 'input', 'resize', 'signal', 'status', 'close', 'commit', 'connect', 'accept']), cursor: z.number().int().min(0).default(0), limit: z.number().int().min(1).max(65536).default(65536), data: z.string().max(90000).optional(), eof: z.boolean().default(false), cols: z.number().int().min(20).max(500).optional(), rows: z.number().int().min(5).max(200).optional(), signal: z.enum(['SIGINT', 'SIGTERM', 'SIGKILL', 'SIGHUP', 'SIGQUIT']).optional(), host: z.string().min(1).max(253).optional(), port: z.number().int().min(1).max(65535).optional() }).strict();
|
|
18
31
|
export function parseMessage(value) {
|
|
19
32
|
const basic = z.object({ type: z.string() }).passthrough().parse(value);
|
|
20
33
|
switch (basic.type) {
|
|
21
34
|
case 'task.request': return { type: basic.type, task: taskSchema.parse(basic.task) };
|
|
22
35
|
case 'task.cancel': return { type: basic.type, id: z.string().uuid().parse(basic.id) };
|
|
36
|
+
case 'resource.request': return { type: basic.type, requestId: z.string().uuid().parse(basic.requestId), request: resourceRequestSchema.parse(basic.request) };
|
|
37
|
+
case 'resource.result': return z.object({ type: z.literal('resource.result'), requestId: z.string().uuid(), value: z.unknown().optional(), error: z.string().max(2000).optional() }).strict().parse(value);
|
|
23
38
|
case 'ping':
|
|
24
39
|
case 'pong': return { type: basic.type };
|
|
25
40
|
case 'session.accepted': return z.object({ type: z.literal('session.accepted'), label: z.string().max(120), fingerprint: z.string().max(100) }).strict().parse(value);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Operator } from './operator.js';
|
|
2
|
+
export type TransferProgress = {
|
|
3
|
+
state: string;
|
|
4
|
+
bytes: number;
|
|
5
|
+
size: number;
|
|
6
|
+
resourceId?: string;
|
|
7
|
+
resumeToken?: string;
|
|
8
|
+
sha256?: string;
|
|
9
|
+
error?: string;
|
|
10
|
+
};
|
|
11
|
+
export type TransferOptions = {
|
|
12
|
+
resumeId?: string;
|
|
13
|
+
resumeToken?: string;
|
|
14
|
+
overwrite?: boolean;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
progress?: (progress: TransferProgress) => void;
|
|
17
|
+
};
|
|
18
|
+
export declare function upload(operator: Operator, localPath: string, remotePath: string, reason: string, options?: TransferOptions): Promise<TransferProgress>;
|
|
19
|
+
export declare function download(operator: Operator, remotePath: string, localPath: string, reason: string, options?: TransferOptions): Promise<TransferProgress>;
|