terminal-pilot 0.0.6 → 0.0.7
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 +5708 -1261
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +249 -4
- package/dist/commands/close-session.js.map +4 -4
- package/dist/commands/create-session.js +249 -4
- package/dist/commands/create-session.js.map +4 -4
- package/dist/commands/fill.js +249 -4
- package/dist/commands/fill.js.map +4 -4
- package/dist/commands/get-session.js +249 -4
- package/dist/commands/get-session.js.map +4 -4
- package/dist/commands/index.js +2376 -184
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +1377 -16
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +181 -15
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +249 -4
- package/dist/commands/list-sessions.js.map +4 -4
- package/dist/commands/press-key.js +249 -4
- package/dist/commands/press-key.js.map +4 -4
- package/dist/commands/read-history.js +249 -4
- package/dist/commands/read-history.js.map +4 -4
- package/dist/commands/read-screen.js +249 -4
- package/dist/commands/read-screen.js.map +4 -4
- package/dist/commands/resize.js +249 -4
- package/dist/commands/resize.js.map +4 -4
- package/dist/commands/runtime.js +8 -2
- package/dist/commands/runtime.js.map +3 -3
- package/dist/commands/screenshot.js +1014 -8
- package/dist/commands/screenshot.js.map +4 -4
- package/dist/commands/send-signal.js +249 -4
- package/dist/commands/send-signal.js.map +4 -4
- package/dist/commands/type.js +249 -4
- package/dist/commands/type.js.map +4 -4
- package/dist/commands/uninstall.js +421 -16
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +249 -4
- package/dist/commands/wait-for-exit.js.map +4 -4
- package/dist/commands/wait-for.js +249 -4
- package/dist/commands/wait-for.js.map +4 -4
- package/dist/testing/cli-repl.js +5633 -1185
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +5674 -1226
- package/dist/testing/qa-cli.js.map +4 -4
- package/package.json +17 -8
|
@@ -1,8 +1,253 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
import {
|
|
1
|
+
// ../cmdkit/src/index.ts
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
3
|
|
|
4
|
-
// src/
|
|
5
|
-
|
|
4
|
+
// ../cmdkit-schema/src/index.ts
|
|
5
|
+
function assertValidEnumValues(values) {
|
|
6
|
+
if (values.length === 0) {
|
|
7
|
+
throw new Error("Enum schema requires at least one value");
|
|
8
|
+
}
|
|
9
|
+
const uniqueValues = new Set(values);
|
|
10
|
+
if (uniqueValues.size !== values.length) {
|
|
11
|
+
throw new Error("Enum schema values must be unique");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
var S = {
|
|
15
|
+
String(options = {}) {
|
|
16
|
+
return {
|
|
17
|
+
kind: "string",
|
|
18
|
+
...options
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
Number(options = {}) {
|
|
22
|
+
return {
|
|
23
|
+
kind: "number",
|
|
24
|
+
...options
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
Boolean(options = {}) {
|
|
28
|
+
return {
|
|
29
|
+
kind: "boolean",
|
|
30
|
+
...options
|
|
31
|
+
};
|
|
32
|
+
},
|
|
33
|
+
Enum(values, options = {}) {
|
|
34
|
+
assertValidEnumValues(values);
|
|
35
|
+
return {
|
|
36
|
+
kind: "enum",
|
|
37
|
+
values,
|
|
38
|
+
...options
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
Array(item, options = {}) {
|
|
42
|
+
return {
|
|
43
|
+
kind: "array",
|
|
44
|
+
item,
|
|
45
|
+
...options
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
Object(shape) {
|
|
49
|
+
return {
|
|
50
|
+
kind: "object",
|
|
51
|
+
shape
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
Optional(inner) {
|
|
55
|
+
return {
|
|
56
|
+
kind: "optional",
|
|
57
|
+
inner
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// ../cmdkit/src/index.ts
|
|
63
|
+
var commandConfigSymbol = /* @__PURE__ */ Symbol("cmdkit.command.config");
|
|
64
|
+
var commandSourcePathSymbol = /* @__PURE__ */ Symbol("cmdkit.command.sourcePath");
|
|
65
|
+
var UserError = class extends Error {
|
|
66
|
+
constructor(message) {
|
|
67
|
+
super(message);
|
|
68
|
+
this.name = "UserError";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
function cloneScope(scope) {
|
|
72
|
+
return scope === void 0 ? void 0 : [...scope];
|
|
73
|
+
}
|
|
74
|
+
function cloneSecretDefinition(secret) {
|
|
75
|
+
return {
|
|
76
|
+
env: secret.env,
|
|
77
|
+
description: secret.description,
|
|
78
|
+
optional: secret.optional
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function cloneSecrets(secrets) {
|
|
82
|
+
if (secrets === void 0) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
return Object.fromEntries(
|
|
86
|
+
Object.entries(secrets).map(([key, secret]) => [key, cloneSecretDefinition(secret)])
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function cloneRequires(requires) {
|
|
90
|
+
if (requires === void 0) {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
return {
|
|
94
|
+
auth: requires.auth,
|
|
95
|
+
apiVersion: requires.apiVersion,
|
|
96
|
+
check: requires.check
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function parseStackPath(candidate) {
|
|
100
|
+
if (candidate.startsWith("file://")) {
|
|
101
|
+
try {
|
|
102
|
+
return fileURLToPath(candidate);
|
|
103
|
+
} catch {
|
|
104
|
+
return void 0;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (candidate.startsWith("/")) {
|
|
108
|
+
return candidate;
|
|
109
|
+
}
|
|
110
|
+
return void 0;
|
|
111
|
+
}
|
|
112
|
+
function extractStackPath(line) {
|
|
113
|
+
const trimmed = line.trim();
|
|
114
|
+
const fileIndex = trimmed.indexOf("file://");
|
|
115
|
+
if (fileIndex >= 0) {
|
|
116
|
+
const location2 = trimmed.slice(fileIndex);
|
|
117
|
+
const separatorIndex2 = location2.lastIndexOf(":");
|
|
118
|
+
const previousSeparatorIndex2 = separatorIndex2 >= 0 ? location2.lastIndexOf(":", separatorIndex2 - 1) : -1;
|
|
119
|
+
const candidate2 = separatorIndex2 >= 0 && previousSeparatorIndex2 >= 0 ? location2.slice(0, previousSeparatorIndex2) : location2;
|
|
120
|
+
return parseStackPath(candidate2);
|
|
121
|
+
}
|
|
122
|
+
const slashIndex = trimmed.indexOf("/");
|
|
123
|
+
if (slashIndex < 0) {
|
|
124
|
+
return void 0;
|
|
125
|
+
}
|
|
126
|
+
const location = trimmed.slice(slashIndex);
|
|
127
|
+
const separatorIndex = location.lastIndexOf(":");
|
|
128
|
+
const previousSeparatorIndex = separatorIndex >= 0 ? location.lastIndexOf(":", separatorIndex - 1) : -1;
|
|
129
|
+
const candidate = separatorIndex >= 0 && previousSeparatorIndex >= 0 ? location.slice(0, previousSeparatorIndex) : location;
|
|
130
|
+
return parseStackPath(candidate);
|
|
131
|
+
}
|
|
132
|
+
function inferCommandSourcePath() {
|
|
133
|
+
const stack = new Error().stack;
|
|
134
|
+
if (typeof stack !== "string") {
|
|
135
|
+
return void 0;
|
|
136
|
+
}
|
|
137
|
+
for (const line of stack.split("\n").slice(1)) {
|
|
138
|
+
const candidate = extractStackPath(line);
|
|
139
|
+
if (candidate === void 0) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
if (candidate.includes("/packages/cmdkit/src/index.ts") || candidate.includes("/packages/cmdkit/dist/index.js")) {
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
return candidate;
|
|
146
|
+
}
|
|
147
|
+
return void 0;
|
|
148
|
+
}
|
|
149
|
+
function composeChecks(parentCheck, childCheck) {
|
|
150
|
+
if (parentCheck === void 0) {
|
|
151
|
+
return childCheck;
|
|
152
|
+
}
|
|
153
|
+
if (childCheck === void 0) {
|
|
154
|
+
return parentCheck;
|
|
155
|
+
}
|
|
156
|
+
return async (ctx) => {
|
|
157
|
+
const parentResult = await parentCheck(ctx);
|
|
158
|
+
if (!parentResult.ok) {
|
|
159
|
+
return parentResult;
|
|
160
|
+
}
|
|
161
|
+
return childCheck(ctx);
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
function mergeRequires(parent, child) {
|
|
165
|
+
if (parent === void 0 && child === void 0) {
|
|
166
|
+
return void 0;
|
|
167
|
+
}
|
|
168
|
+
const merged = {
|
|
169
|
+
auth: child?.auth ?? parent?.auth,
|
|
170
|
+
apiVersion: child?.apiVersion ?? parent?.apiVersion,
|
|
171
|
+
check: composeChecks(parent?.check, child?.check)
|
|
172
|
+
};
|
|
173
|
+
if (merged.auth === void 0 && merged.apiVersion === void 0 && merged.check === void 0) {
|
|
174
|
+
return void 0;
|
|
175
|
+
}
|
|
176
|
+
return merged;
|
|
177
|
+
}
|
|
178
|
+
function mergeSecrets(parent, child) {
|
|
179
|
+
return cloneSecrets({
|
|
180
|
+
...parent,
|
|
181
|
+
...child
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function resolveCommandScope(ownScope, inheritedScope) {
|
|
185
|
+
return cloneScope(ownScope ?? inheritedScope) ?? ["cli", "sdk"];
|
|
186
|
+
}
|
|
187
|
+
function createBaseCommand(config) {
|
|
188
|
+
const command = {
|
|
189
|
+
kind: "command",
|
|
190
|
+
name: config.name,
|
|
191
|
+
description: config.description,
|
|
192
|
+
aliases: [...config.aliases ?? []],
|
|
193
|
+
positional: [...config.positional ?? []],
|
|
194
|
+
params: config.params,
|
|
195
|
+
secrets: cloneSecrets(config.secrets),
|
|
196
|
+
scope: resolveCommandScope(config.scope, void 0),
|
|
197
|
+
confirm: config.confirm ?? false,
|
|
198
|
+
requires: cloneRequires(config.requires),
|
|
199
|
+
handler: config.handler,
|
|
200
|
+
render: config.render
|
|
201
|
+
};
|
|
202
|
+
Object.defineProperty(command, commandConfigSymbol, {
|
|
203
|
+
value: {
|
|
204
|
+
scope: cloneScope(config.scope),
|
|
205
|
+
secrets: cloneSecrets(config.secrets),
|
|
206
|
+
requires: cloneRequires(config.requires),
|
|
207
|
+
sourcePath: inferCommandSourcePath()
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
return command;
|
|
211
|
+
}
|
|
212
|
+
function getInternalCommandConfig(command) {
|
|
213
|
+
return command[commandConfigSymbol];
|
|
214
|
+
}
|
|
215
|
+
function materializeCommand(command, inherited) {
|
|
216
|
+
const internal = getInternalCommandConfig(command);
|
|
217
|
+
const materialized = {
|
|
218
|
+
kind: "command",
|
|
219
|
+
name: command.name,
|
|
220
|
+
description: command.description,
|
|
221
|
+
aliases: [...command.aliases],
|
|
222
|
+
positional: [...command.positional],
|
|
223
|
+
params: command.params,
|
|
224
|
+
secrets: mergeSecrets(inherited.secrets, internal.secrets),
|
|
225
|
+
scope: resolveCommandScope(internal.scope, inherited.scope),
|
|
226
|
+
confirm: command.confirm,
|
|
227
|
+
requires: mergeRequires(inherited.requires, internal.requires),
|
|
228
|
+
handler: command.handler,
|
|
229
|
+
render: command.render
|
|
230
|
+
};
|
|
231
|
+
Object.defineProperty(materialized, commandConfigSymbol, {
|
|
232
|
+
value: {
|
|
233
|
+
scope: cloneScope(internal.scope),
|
|
234
|
+
secrets: cloneSecrets(internal.secrets),
|
|
235
|
+
requires: cloneRequires(internal.requires),
|
|
236
|
+
sourcePath: internal.sourcePath
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
Object.defineProperty(materialized, commandSourcePathSymbol, {
|
|
240
|
+
value: internal.sourcePath
|
|
241
|
+
});
|
|
242
|
+
return materialized;
|
|
243
|
+
}
|
|
244
|
+
function defineCommand(config) {
|
|
245
|
+
return materializeCommand(createBaseCommand(config), {
|
|
246
|
+
scope: void 0,
|
|
247
|
+
secrets: {},
|
|
248
|
+
requires: void 0
|
|
249
|
+
});
|
|
250
|
+
}
|
|
6
251
|
|
|
7
252
|
// src/terminal-pilot.ts
|
|
8
253
|
import { randomUUID } from "node:crypto";
|