terminal-pilot 0.0.14 → 0.0.16

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.
Files changed (62) hide show
  1. package/dist/cli.js +7386 -392
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.d.ts +1 -1
  4. package/dist/commands/close-session.js +108 -9
  5. package/dist/commands/close-session.js.map +4 -4
  6. package/dist/commands/create-session.d.ts +1 -1
  7. package/dist/commands/create-session.js +108 -9
  8. package/dist/commands/create-session.js.map +4 -4
  9. package/dist/commands/fill.d.ts +1 -1
  10. package/dist/commands/fill.js +108 -9
  11. package/dist/commands/fill.js.map +4 -4
  12. package/dist/commands/get-session.d.ts +1 -1
  13. package/dist/commands/get-session.js +108 -9
  14. package/dist/commands/get-session.js.map +4 -4
  15. package/dist/commands/index.d.ts +17 -17
  16. package/dist/commands/index.js +206 -44
  17. package/dist/commands/index.js.map +4 -4
  18. package/dist/commands/install.d.ts +1 -1
  19. package/dist/commands/install.js +114 -15
  20. package/dist/commands/install.js.map +4 -4
  21. package/dist/commands/installer.js +17 -10
  22. package/dist/commands/installer.js.map +4 -4
  23. package/dist/commands/list-sessions.d.ts +1 -1
  24. package/dist/commands/list-sessions.js +108 -9
  25. package/dist/commands/list-sessions.js.map +4 -4
  26. package/dist/commands/press-key.d.ts +1 -1
  27. package/dist/commands/press-key.js +108 -9
  28. package/dist/commands/press-key.js.map +4 -4
  29. package/dist/commands/read-history.d.ts +1 -1
  30. package/dist/commands/read-history.js +108 -9
  31. package/dist/commands/read-history.js.map +4 -4
  32. package/dist/commands/read-screen.d.ts +1 -1
  33. package/dist/commands/read-screen.js +108 -9
  34. package/dist/commands/read-screen.js.map +4 -4
  35. package/dist/commands/resize.d.ts +1 -1
  36. package/dist/commands/resize.js +108 -9
  37. package/dist/commands/resize.js.map +4 -4
  38. package/dist/commands/runtime.js +8 -1
  39. package/dist/commands/runtime.js.map +4 -4
  40. package/dist/commands/screenshot.d.ts +1 -1
  41. package/dist/commands/screenshot.js +112 -13
  42. package/dist/commands/screenshot.js.map +4 -4
  43. package/dist/commands/send-signal.d.ts +1 -1
  44. package/dist/commands/send-signal.js +108 -9
  45. package/dist/commands/send-signal.js.map +4 -4
  46. package/dist/commands/type.d.ts +1 -1
  47. package/dist/commands/type.js +108 -9
  48. package/dist/commands/type.js.map +4 -4
  49. package/dist/commands/uninstall.d.ts +1 -1
  50. package/dist/commands/uninstall.js +117 -18
  51. package/dist/commands/uninstall.js.map +4 -4
  52. package/dist/commands/wait-for-exit.d.ts +1 -1
  53. package/dist/commands/wait-for-exit.js +108 -9
  54. package/dist/commands/wait-for-exit.js.map +4 -4
  55. package/dist/commands/wait-for.d.ts +1 -1
  56. package/dist/commands/wait-for.js +108 -9
  57. package/dist/commands/wait-for.js.map +4 -4
  58. package/dist/testing/cli-repl.js +7386 -392
  59. package/dist/testing/cli-repl.js.map +4 -4
  60. package/dist/testing/qa-cli.js +7394 -400
  61. package/dist/testing/qa-cli.js.map +4 -4
  62. package/package.json +1 -1
@@ -8,5 +8,5 @@ export declare const closeSession: import("toolcraft").Command<TerminalPilotComm
8
8
  readonly session: import("toolcraft-schema").OptionalSchema<import("toolcraft-schema").StringSchema>;
9
9
  }>, {
10
10
  exitCode: number;
11
- }, readonly ["cli", "mcp", "sdk"]>;
11
+ }, readonly ["cli", "mcp", "sdk"], undefined>;
12
12
  };
@@ -1,5 +1,95 @@
1
1
  // ../toolcraft/src/index.ts
2
- import { fileURLToPath } from "node:url";
2
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
3
+
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
+ }
3
93
 
4
94
  // ../toolcraft-schema/src/index.ts
5
95
  function assertValidEnumValues(values) {
@@ -57,18 +147,21 @@ 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
 
157
+ // ../toolcraft/src/package-metadata.ts
158
+ import { existsSync, readFileSync, statSync } from "node:fs";
159
+ import path from "node:path";
160
+ import { fileURLToPath } from "node:url";
161
+
63
162
  // ../toolcraft/src/index.ts
64
163
  var commandConfigSymbol = /* @__PURE__ */ Symbol("toolcraft.command.config");
65
164
  var commandSourcePathSymbol = /* @__PURE__ */ Symbol("toolcraft.command.sourcePath");
66
- var UserError = class extends Error {
67
- constructor(message) {
68
- super(message);
69
- this.name = "UserError";
70
- }
71
- };
72
165
  function cloneScope(scope) {
73
166
  return scope === void 0 ? void 0 : [...scope];
74
167
  }
@@ -100,7 +193,7 @@ function cloneRequires(requires) {
100
193
  function parseStackPath(candidate) {
101
194
  if (candidate.startsWith("file://")) {
102
195
  try {
103
- return fileURLToPath(candidate);
196
+ return fileURLToPath2(candidate);
104
197
  } catch {
105
198
  return void 0;
106
199
  }
@@ -196,6 +289,7 @@ function createBaseCommand(config) {
196
289
  secrets: cloneSecrets(config.secrets),
197
290
  scope: resolveCommandScope(config.scope, void 0),
198
291
  confirm: config.confirm ?? false,
292
+ humanInLoop: config.humanInLoop,
199
293
  requires: cloneRequires(config.requires),
200
294
  handler: config.handler,
201
295
  render: config.render
@@ -203,6 +297,7 @@ function createBaseCommand(config) {
203
297
  Object.defineProperty(command, commandConfigSymbol, {
204
298
  value: {
205
299
  scope: cloneScope(config.scope),
300
+ humanInLoop: config.humanInLoop,
206
301
  secrets: cloneSecrets(config.secrets),
207
302
  requires: cloneRequires(config.requires),
208
303
  sourcePath: inferCommandSourcePath()
@@ -225,6 +320,7 @@ function materializeCommand(command, inherited) {
225
320
  secrets: mergeSecrets(inherited.secrets, internal.secrets),
226
321
  scope: resolveCommandScope(internal.scope, inherited.scope),
227
322
  confirm: command.confirm,
323
+ humanInLoop: mergeHumanInLoopFromGroup(inherited.humanInLoop, internal.humanInLoop),
228
324
  requires: mergeRequires(inherited.requires, internal.requires),
229
325
  handler: command.handler,
230
326
  render: command.render
@@ -232,6 +328,7 @@ function materializeCommand(command, inherited) {
232
328
  Object.defineProperty(materialized, commandConfigSymbol, {
233
329
  value: {
234
330
  scope: cloneScope(internal.scope),
331
+ humanInLoop: internal.humanInLoop,
235
332
  secrets: cloneSecrets(internal.secrets),
236
333
  requires: cloneRequires(internal.requires),
237
334
  sourcePath: internal.sourcePath
@@ -243,8 +340,10 @@ function materializeCommand(command, inherited) {
243
340
  return materialized;
244
341
  }
245
342
  function defineCommand(config) {
343
+ validateHumanInLoopOnDefine(config);
246
344
  return materializeCommand(createBaseCommand(config), {
247
345
  scope: void 0,
346
+ humanInLoop: void 0,
248
347
  secrets: {},
249
348
  requires: void 0
250
349
  });