terminal-pilot 0.0.13 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +7210 -470
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.d.ts +5 -5
- package/dist/commands/close-session.js +107 -13
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.d.ts +17 -17
- package/dist/commands/create-session.js +107 -13
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.d.ts +7 -7
- package/dist/commands/fill.js +107 -13
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.d.ts +5 -5
- package/dist/commands/get-session.js +107 -13
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.d.ts +124 -124
- package/dist/commands/index.js +184 -27
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.d.ts +9 -9
- package/dist/commands/install.js +107 -13
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +3 -1
- package/dist/commands/installer.js.map +3 -3
- package/dist/commands/list-sessions.d.ts +3 -3
- package/dist/commands/list-sessions.js +107 -13
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.d.ts +7 -7
- package/dist/commands/press-key.js +107 -13
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.d.ts +7 -7
- package/dist/commands/read-history.js +107 -13
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.d.ts +5 -5
- package/dist/commands/read-screen.js +107 -13
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.d.ts +9 -9
- package/dist/commands/resize.js +107 -13
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/runtime.d.ts +1 -1
- package/dist/commands/runtime.js +3 -1
- package/dist/commands/runtime.js.map +3 -3
- package/dist/commands/screenshot.d.ts +11 -11
- package/dist/commands/screenshot.js +107 -13
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.d.ts +7 -7
- package/dist/commands/send-signal.js +107 -13
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.d.ts +7 -7
- package/dist/commands/type.js +107 -13
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.d.ts +5 -5
- package/dist/commands/uninstall.js +107 -13
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.d.ts +7 -7
- package/dist/commands/wait-for-exit.js +107 -13
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.d.ts +11 -11
- package/dist/commands/wait-for.js +107 -13
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +7209 -470
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +7218 -479
- package/dist/testing/qa-cli.js.map +4 -4
- package/package.json +3 -3
package/dist/commands/index.js
CHANGED
|
@@ -1,7 +1,97 @@
|
|
|
1
|
-
// ../
|
|
1
|
+
// ../toolcraft/src/index.ts
|
|
2
2
|
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
|
-
// ../
|
|
4
|
+
// ../toolcraft/src/user-error.ts
|
|
5
|
+
var UserError = class extends Error {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = "UserError";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// ../toolcraft/src/human-in-loop/config.ts
|
|
13
|
+
function validateHumanInLoopOnDefine(config) {
|
|
14
|
+
const label = Array.isArray(config.children) ? "group" : "command";
|
|
15
|
+
if (config.confirm === true && config.humanInLoop !== void 0 && config.humanInLoop !== null) {
|
|
16
|
+
throw new Error(`${label} '${config.name}': use either confirm or humanInLoop, not both`);
|
|
17
|
+
}
|
|
18
|
+
if (config.humanInLoop === void 0 || config.humanInLoop === null) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (config.humanInLoop.mode !== "sync" && config.humanInLoop.mode !== "async") {
|
|
22
|
+
throw new Error(`${label} '${config.name}': humanInLoop.mode must be "sync" or "async"`);
|
|
23
|
+
}
|
|
24
|
+
if (typeof config.humanInLoop.message !== "function") {
|
|
25
|
+
throw new Error(`${label} '${config.name}': humanInLoop.message must be a function`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function mergeHumanInLoopFromGroup(groupHumanInLoop, childHumanInLoop) {
|
|
29
|
+
if (childHumanInLoop !== void 0) {
|
|
30
|
+
return childHumanInLoop;
|
|
31
|
+
}
|
|
32
|
+
return groupHumanInLoop;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ../toolcraft-schema/src/json.ts
|
|
36
|
+
function Json() {
|
|
37
|
+
return {
|
|
38
|
+
kind: "json"
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ../toolcraft-schema/src/oneof.ts
|
|
43
|
+
function assertValidBranches(branches) {
|
|
44
|
+
if (Object.keys(branches).length === 0) {
|
|
45
|
+
throw new Error("OneOf schema requires at least one branch");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function OneOf(config) {
|
|
49
|
+
assertValidBranches(config.branches);
|
|
50
|
+
return {
|
|
51
|
+
kind: "oneOf",
|
|
52
|
+
discriminator: config.discriminator,
|
|
53
|
+
branches: config.branches
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// ../toolcraft-schema/src/record.ts
|
|
58
|
+
function Record(value) {
|
|
59
|
+
return {
|
|
60
|
+
kind: "record",
|
|
61
|
+
value
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ../toolcraft-schema/src/union.ts
|
|
66
|
+
function isOptionalSchema(schema) {
|
|
67
|
+
return schema.kind === "optional";
|
|
68
|
+
}
|
|
69
|
+
function getRequiredKeyFingerprint(schema) {
|
|
70
|
+
const requiredKeys = Object.keys(schema.shape).filter((key) => !isOptionalSchema(schema.shape[key])).sort();
|
|
71
|
+
return JSON.stringify(requiredKeys);
|
|
72
|
+
}
|
|
73
|
+
function assertValidBranches2(branches) {
|
|
74
|
+
if (branches.length === 0) {
|
|
75
|
+
throw new Error("Union schema requires at least one branch");
|
|
76
|
+
}
|
|
77
|
+
const fingerprints = /* @__PURE__ */ new Set();
|
|
78
|
+
for (const branch of branches) {
|
|
79
|
+
const fingerprint = getRequiredKeyFingerprint(branch);
|
|
80
|
+
if (fingerprints.has(fingerprint)) {
|
|
81
|
+
throw new Error("Union schema branches must have unique required-key fingerprints");
|
|
82
|
+
}
|
|
83
|
+
fingerprints.add(fingerprint);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function Union(branches) {
|
|
87
|
+
assertValidBranches2(branches);
|
|
88
|
+
return {
|
|
89
|
+
kind: "union",
|
|
90
|
+
branches
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ../toolcraft-schema/src/index.ts
|
|
5
95
|
function assertValidEnumValues(values) {
|
|
6
96
|
if (values.length === 0) {
|
|
7
97
|
throw new Error("Enum schema requires at least one value");
|
|
@@ -57,19 +147,17 @@ var S = {
|
|
|
57
147
|
kind: "optional",
|
|
58
148
|
inner
|
|
59
149
|
};
|
|
60
|
-
}
|
|
150
|
+
},
|
|
151
|
+
OneOf,
|
|
152
|
+
Union,
|
|
153
|
+
Record,
|
|
154
|
+
Json
|
|
61
155
|
};
|
|
62
156
|
|
|
63
|
-
// ../
|
|
64
|
-
var commandConfigSymbol = /* @__PURE__ */ Symbol("
|
|
65
|
-
var groupConfigSymbol = /* @__PURE__ */ Symbol("
|
|
66
|
-
var commandSourcePathSymbol = /* @__PURE__ */ Symbol("
|
|
67
|
-
var UserError = class extends Error {
|
|
68
|
-
constructor(message) {
|
|
69
|
-
super(message);
|
|
70
|
-
this.name = "UserError";
|
|
71
|
-
}
|
|
72
|
-
};
|
|
157
|
+
// ../toolcraft/src/index.ts
|
|
158
|
+
var commandConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.command.config");
|
|
159
|
+
var groupConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.group.config");
|
|
160
|
+
var commandSourcePathSymbol = /* @__PURE__ */ Symbol("toolcraft.command.sourcePath");
|
|
73
161
|
function cloneScope(scope) {
|
|
74
162
|
return scope === void 0 ? void 0 : [...scope];
|
|
75
163
|
}
|
|
@@ -98,6 +186,56 @@ function cloneRequires(requires) {
|
|
|
98
186
|
check: requires.check
|
|
99
187
|
};
|
|
100
188
|
}
|
|
189
|
+
function cloneStringArray(values) {
|
|
190
|
+
return values === void 0 ? void 0 : [...values];
|
|
191
|
+
}
|
|
192
|
+
function cloneStringRecord(values) {
|
|
193
|
+
return values === void 0 ? void 0 : { ...values };
|
|
194
|
+
}
|
|
195
|
+
function cloneMcpServerConfig(config) {
|
|
196
|
+
if (config === void 0) {
|
|
197
|
+
return void 0;
|
|
198
|
+
}
|
|
199
|
+
if (config.transport === "stdio") {
|
|
200
|
+
return {
|
|
201
|
+
transport: "stdio",
|
|
202
|
+
command: config.command,
|
|
203
|
+
args: cloneStringArray(config.args),
|
|
204
|
+
env: cloneStringRecord(config.env)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
return {
|
|
208
|
+
transport: "http",
|
|
209
|
+
url: config.url,
|
|
210
|
+
headers: cloneStringRecord(config.headers)
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
function cloneRenameMap(rename) {
|
|
214
|
+
return rename === void 0 ? void 0 : { ...rename };
|
|
215
|
+
}
|
|
216
|
+
function validateRenameMap(rename) {
|
|
217
|
+
if (rename === void 0) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const seenTargets = /* @__PURE__ */ new Map();
|
|
221
|
+
for (const [upstreamName, targetPath] of Object.entries(rename)) {
|
|
222
|
+
if (targetPath.length === 0) {
|
|
223
|
+
throw new UserError(`Invalid rename target for upstream tool "${upstreamName}": path cannot be empty.`);
|
|
224
|
+
}
|
|
225
|
+
if (targetPath.split(".").some((segment) => segment.length === 0)) {
|
|
226
|
+
throw new UserError(
|
|
227
|
+
`Invalid rename target for upstream tool "${upstreamName}": "${targetPath}" contains an empty segment.`
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
const existingUpstreamName = seenTargets.get(targetPath);
|
|
231
|
+
if (existingUpstreamName !== void 0) {
|
|
232
|
+
throw new UserError(
|
|
233
|
+
`Duplicate rename target "${targetPath}" for upstream tools "${existingUpstreamName}" and "${upstreamName}".`
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
seenTargets.set(targetPath, upstreamName);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
101
239
|
function parseStackPath(candidate) {
|
|
102
240
|
if (candidate.startsWith("file://")) {
|
|
103
241
|
try {
|
|
@@ -141,7 +279,7 @@ function inferCommandSourcePath() {
|
|
|
141
279
|
if (candidate === void 0) {
|
|
142
280
|
continue;
|
|
143
281
|
}
|
|
144
|
-
if (candidate.includes("/packages/
|
|
282
|
+
if (candidate.includes("/packages/toolcraft/src/index.ts") || candidate.includes("/packages/toolcraft/dist/index.js") || candidate.includes("/node_modules/toolcraft/dist/index.js")) {
|
|
145
283
|
continue;
|
|
146
284
|
}
|
|
147
285
|
return candidate;
|
|
@@ -200,6 +338,7 @@ function createBaseCommand(config) {
|
|
|
200
338
|
secrets: cloneSecrets(config.secrets),
|
|
201
339
|
scope: resolveCommandScope(config.scope, void 0),
|
|
202
340
|
confirm: config.confirm ?? false,
|
|
341
|
+
humanInLoop: config.humanInLoop,
|
|
203
342
|
requires: cloneRequires(config.requires),
|
|
204
343
|
handler: config.handler,
|
|
205
344
|
render: config.render
|
|
@@ -207,6 +346,7 @@ function createBaseCommand(config) {
|
|
|
207
346
|
Object.defineProperty(command, commandConfigSymbol, {
|
|
208
347
|
value: {
|
|
209
348
|
scope: cloneScope(config.scope),
|
|
349
|
+
humanInLoop: config.humanInLoop,
|
|
210
350
|
secrets: cloneSecrets(config.secrets),
|
|
211
351
|
requires: cloneRequires(config.requires),
|
|
212
352
|
sourcePath: inferCommandSourcePath()
|
|
@@ -221,6 +361,7 @@ function createBaseGroup(config) {
|
|
|
221
361
|
description: config.description,
|
|
222
362
|
aliases: [...config.aliases ?? []],
|
|
223
363
|
scope: resolveGroupScope(config.scope, void 0),
|
|
364
|
+
humanInLoop: config.humanInLoop,
|
|
224
365
|
secrets: cloneSecrets(config.secrets),
|
|
225
366
|
requires: cloneRequires(config.requires),
|
|
226
367
|
children: [],
|
|
@@ -228,8 +369,12 @@ function createBaseGroup(config) {
|
|
|
228
369
|
};
|
|
229
370
|
Object.defineProperty(group, groupConfigSymbol, {
|
|
230
371
|
value: {
|
|
372
|
+
mcp: cloneMcpServerConfig(config.mcp),
|
|
231
373
|
scope: cloneScope(config.scope),
|
|
374
|
+
humanInLoop: config.humanInLoop,
|
|
232
375
|
secrets: cloneSecrets(config.secrets),
|
|
376
|
+
tools: cloneStringArray(config.tools),
|
|
377
|
+
rename: cloneRenameMap(config.rename),
|
|
233
378
|
requires: cloneRequires(config.requires),
|
|
234
379
|
children: [...config.children],
|
|
235
380
|
default: config.default
|
|
@@ -255,6 +400,7 @@ function materializeCommand(command, inherited) {
|
|
|
255
400
|
secrets: mergeSecrets(inherited.secrets, internal.secrets),
|
|
256
401
|
scope: resolveCommandScope(internal.scope, inherited.scope),
|
|
257
402
|
confirm: command.confirm,
|
|
403
|
+
humanInLoop: mergeHumanInLoopFromGroup(inherited.humanInLoop, internal.humanInLoop),
|
|
258
404
|
requires: mergeRequires(inherited.requires, internal.requires),
|
|
259
405
|
handler: command.handler,
|
|
260
406
|
render: command.render
|
|
@@ -262,6 +408,7 @@ function materializeCommand(command, inherited) {
|
|
|
262
408
|
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
263
409
|
value: {
|
|
264
410
|
scope: cloneScope(internal.scope),
|
|
411
|
+
humanInLoop: internal.humanInLoop,
|
|
265
412
|
secrets: cloneSecrets(internal.secrets),
|
|
266
413
|
requires: cloneRequires(internal.requires),
|
|
267
414
|
sourcePath: internal.sourcePath
|
|
@@ -272,18 +419,18 @@ function materializeCommand(command, inherited) {
|
|
|
272
419
|
});
|
|
273
420
|
return materialized;
|
|
274
421
|
}
|
|
422
|
+
function mergeInheritedMetadata(group, inherited) {
|
|
423
|
+
return {
|
|
424
|
+
scope: resolveGroupScope(group.scope, inherited.scope),
|
|
425
|
+
humanInLoop: mergeHumanInLoopFromGroup(inherited.humanInLoop, group.humanInLoop),
|
|
426
|
+
secrets: mergeSecrets(inherited.secrets, group.secrets),
|
|
427
|
+
requires: mergeRequires(inherited.requires, group.requires)
|
|
428
|
+
};
|
|
429
|
+
}
|
|
275
430
|
function materializeGroup(group, inherited) {
|
|
276
431
|
const internal = getInternalGroupConfig(group);
|
|
277
|
-
const
|
|
278
|
-
const
|
|
279
|
-
const requires = mergeRequires(inherited.requires, internal.requires);
|
|
280
|
-
const materializedChildren = internal.children.map(
|
|
281
|
-
(child) => materializeNode(child, {
|
|
282
|
-
scope,
|
|
283
|
-
secrets,
|
|
284
|
-
requires
|
|
285
|
-
})
|
|
286
|
-
);
|
|
432
|
+
const mergedInherited = mergeInheritedMetadata(internal, inherited);
|
|
433
|
+
const materializedChildren = internal.children.map((child) => materializeNode(child, mergedInherited));
|
|
287
434
|
let defaultChild;
|
|
288
435
|
if (internal.default !== void 0) {
|
|
289
436
|
const defaultIndex = internal.children.indexOf(internal.default);
|
|
@@ -301,16 +448,21 @@ function materializeGroup(group, inherited) {
|
|
|
301
448
|
name: group.name,
|
|
302
449
|
description: group.description,
|
|
303
450
|
aliases: [...group.aliases],
|
|
304
|
-
scope,
|
|
305
|
-
|
|
306
|
-
|
|
451
|
+
scope: mergedInherited.scope,
|
|
452
|
+
humanInLoop: mergedInherited.humanInLoop,
|
|
453
|
+
secrets: mergedInherited.secrets,
|
|
454
|
+
requires: mergedInherited.requires,
|
|
307
455
|
children: materializedChildren,
|
|
308
456
|
default: defaultChild
|
|
309
457
|
};
|
|
310
458
|
Object.defineProperty(materialized, groupConfigSymbol, {
|
|
311
459
|
value: {
|
|
460
|
+
mcp: cloneMcpServerConfig(internal.mcp),
|
|
312
461
|
scope: cloneScope(internal.scope),
|
|
462
|
+
humanInLoop: internal.humanInLoop,
|
|
313
463
|
secrets: cloneSecrets(internal.secrets),
|
|
464
|
+
tools: cloneStringArray(internal.tools),
|
|
465
|
+
rename: cloneRenameMap(internal.rename),
|
|
314
466
|
requires: cloneRequires(internal.requires),
|
|
315
467
|
children: [...internal.children],
|
|
316
468
|
default: internal.default
|
|
@@ -325,15 +477,20 @@ function materializeNode(node, inherited) {
|
|
|
325
477
|
return materializeGroup(node, inherited);
|
|
326
478
|
}
|
|
327
479
|
function defineCommand(config) {
|
|
480
|
+
validateHumanInLoopOnDefine(config);
|
|
328
481
|
return materializeCommand(createBaseCommand(config), {
|
|
329
482
|
scope: void 0,
|
|
483
|
+
humanInLoop: void 0,
|
|
330
484
|
secrets: {},
|
|
331
485
|
requires: void 0
|
|
332
486
|
});
|
|
333
487
|
}
|
|
334
488
|
function defineGroup(config) {
|
|
489
|
+
validateRenameMap(config.rename);
|
|
490
|
+
validateHumanInLoopOnDefine(config);
|
|
335
491
|
return materializeGroup(createBaseGroup(config), {
|
|
336
492
|
scope: void 0,
|
|
493
|
+
humanInLoop: void 0,
|
|
337
494
|
secrets: {},
|
|
338
495
|
requires: void 0
|
|
339
496
|
});
|