@mcp-use/cli 3.2.0-canary.8 → 3.2.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/dist/commands/client-auth.d.ts +3 -3
- package/dist/commands/client-auth.d.ts.map +1 -1
- package/dist/commands/client.d.ts +38 -70
- package/dist/commands/client.d.ts.map +1 -1
- package/dist/commands/deployments.d.ts.map +1 -1
- package/dist/commands/screenshot.d.ts +32 -3
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/servers.d.ts.map +1 -1
- package/dist/commands/skills.d.ts.map +1 -1
- package/dist/index.cjs +1485 -1481
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1323 -1321
- package/dist/index.js.map +1 -1
- package/dist/utils/cdp-screenshot.d.ts +7 -0
- package/dist/utils/cdp-screenshot.d.ts.map +1 -1
- package/dist/utils/format.d.ts.map +1 -1
- package/dist/utils/oauth.d.ts +5 -8
- package/dist/utils/oauth.d.ts.map +1 -1
- package/dist/utils/session-storage.d.ts +5 -33
- package/dist/utils/session-storage.d.ts.map +1 -1
- package/dist/utils/session.d.ts +3 -1
- package/dist/utils/session.d.ts.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,770 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __esm = (fn, res) => function __init() {
|
|
5
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
6
|
-
};
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.9_tsx@4.21.0_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/esm_shims.js
|
|
13
|
-
import path from "path";
|
|
14
|
-
import { fileURLToPath } from "url";
|
|
15
|
-
var getFilename, getDirname, __dirname;
|
|
16
|
-
var init_esm_shims = __esm({
|
|
17
|
-
"../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.9_tsx@4.21.0_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
18
|
-
"use strict";
|
|
19
|
-
getFilename = () => fileURLToPath(import.meta.url);
|
|
20
|
-
getDirname = () => path.dirname(getFilename());
|
|
21
|
-
__dirname = /* @__PURE__ */ getDirname();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
26
|
-
import fs from "fs";
|
|
27
|
-
function hasDockerEnv() {
|
|
28
|
-
try {
|
|
29
|
-
fs.statSync("/.dockerenv");
|
|
30
|
-
return true;
|
|
31
|
-
} catch {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
function hasDockerCGroup() {
|
|
36
|
-
try {
|
|
37
|
-
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function isDocker() {
|
|
43
|
-
if (isDockerCached === void 0) {
|
|
44
|
-
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
45
|
-
}
|
|
46
|
-
return isDockerCached;
|
|
47
|
-
}
|
|
48
|
-
var isDockerCached;
|
|
49
|
-
var init_is_docker = __esm({
|
|
50
|
-
"../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js"() {
|
|
51
|
-
"use strict";
|
|
52
|
-
init_esm_shims();
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
57
|
-
import fs2 from "fs";
|
|
58
|
-
function isInsideContainer() {
|
|
59
|
-
if (cachedResult === void 0) {
|
|
60
|
-
cachedResult = hasContainerEnv() || isDocker();
|
|
61
|
-
}
|
|
62
|
-
return cachedResult;
|
|
63
|
-
}
|
|
64
|
-
var cachedResult, hasContainerEnv;
|
|
65
|
-
var init_is_inside_container = __esm({
|
|
66
|
-
"../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js"() {
|
|
67
|
-
"use strict";
|
|
68
|
-
init_esm_shims();
|
|
69
|
-
init_is_docker();
|
|
70
|
-
hasContainerEnv = () => {
|
|
71
|
-
try {
|
|
72
|
-
fs2.statSync("/run/.containerenv");
|
|
73
|
-
return true;
|
|
74
|
-
} catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
// ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
|
|
82
|
-
import process3 from "process";
|
|
83
|
-
import os2 from "os";
|
|
84
|
-
import fs3 from "fs";
|
|
85
|
-
var isWsl, is_wsl_default;
|
|
86
|
-
var init_is_wsl = __esm({
|
|
87
|
-
"../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js"() {
|
|
88
|
-
"use strict";
|
|
89
|
-
init_esm_shims();
|
|
90
|
-
init_is_inside_container();
|
|
91
|
-
isWsl = () => {
|
|
92
|
-
if (process3.platform !== "linux") {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
if (os2.release().toLowerCase().includes("microsoft")) {
|
|
96
|
-
if (isInsideContainer()) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
return true;
|
|
100
|
-
}
|
|
101
|
-
try {
|
|
102
|
-
return fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
103
|
-
} catch {
|
|
104
|
-
return false;
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
is_wsl_default = process3.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
108
|
-
}
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
// ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
112
|
-
import process4 from "process";
|
|
113
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
114
|
-
import { promisify } from "util";
|
|
115
|
-
import childProcess from "child_process";
|
|
116
|
-
import fs4, { constants as fsConstants } from "fs/promises";
|
|
117
|
-
var execFile, powerShellPath, executePowerShell;
|
|
118
|
-
var init_powershell_utils = __esm({
|
|
119
|
-
"../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js"() {
|
|
120
|
-
"use strict";
|
|
121
|
-
init_esm_shims();
|
|
122
|
-
execFile = promisify(childProcess.execFile);
|
|
123
|
-
powerShellPath = () => `${process4.env.SYSTEMROOT || process4.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
124
|
-
executePowerShell = async (command, options = {}) => {
|
|
125
|
-
const {
|
|
126
|
-
powerShellPath: psPath,
|
|
127
|
-
...execFileOptions
|
|
128
|
-
} = options;
|
|
129
|
-
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
130
|
-
return execFile(
|
|
131
|
-
psPath ?? powerShellPath(),
|
|
132
|
-
[
|
|
133
|
-
...executePowerShell.argumentsPrefix,
|
|
134
|
-
encodedCommand
|
|
135
|
-
],
|
|
136
|
-
{
|
|
137
|
-
encoding: "utf8",
|
|
138
|
-
...execFileOptions
|
|
139
|
-
}
|
|
140
|
-
);
|
|
141
|
-
};
|
|
142
|
-
executePowerShell.argumentsPrefix = [
|
|
143
|
-
"-NoProfile",
|
|
144
|
-
"-NonInteractive",
|
|
145
|
-
"-ExecutionPolicy",
|
|
146
|
-
"Bypass",
|
|
147
|
-
"-EncodedCommand"
|
|
148
|
-
];
|
|
149
|
-
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
150
|
-
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
|
|
155
|
-
function parseMountPointFromConfig(content) {
|
|
156
|
-
for (const line of content.split("\n")) {
|
|
157
|
-
if (/^\s*#/.test(line)) {
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
161
|
-
if (!match) {
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
var init_utilities = __esm({
|
|
168
|
-
"../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js"() {
|
|
169
|
-
"use strict";
|
|
170
|
-
init_esm_shims();
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
175
|
-
import { promisify as promisify2 } from "util";
|
|
176
|
-
import childProcess2 from "child_process";
|
|
177
|
-
import fs5, { constants as fsConstants2 } from "fs/promises";
|
|
178
|
-
var execFile2, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell, wslDefaultBrowser, convertWslPathToWindows;
|
|
179
|
-
var init_wsl_utils = __esm({
|
|
180
|
-
"../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js"() {
|
|
181
|
-
"use strict";
|
|
182
|
-
init_esm_shims();
|
|
183
|
-
init_is_wsl();
|
|
184
|
-
init_powershell_utils();
|
|
185
|
-
init_utilities();
|
|
186
|
-
init_is_wsl();
|
|
187
|
-
execFile2 = promisify2(childProcess2.execFile);
|
|
188
|
-
wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
189
|
-
const defaultMountPoint = "/mnt/";
|
|
190
|
-
let mountPoint;
|
|
191
|
-
return async function() {
|
|
192
|
-
if (mountPoint) {
|
|
193
|
-
return mountPoint;
|
|
194
|
-
}
|
|
195
|
-
const configFilePath = "/etc/wsl.conf";
|
|
196
|
-
let isConfigFileExists = false;
|
|
197
|
-
try {
|
|
198
|
-
await fs5.access(configFilePath, fsConstants2.F_OK);
|
|
199
|
-
isConfigFileExists = true;
|
|
200
|
-
} catch {
|
|
201
|
-
}
|
|
202
|
-
if (!isConfigFileExists) {
|
|
203
|
-
return defaultMountPoint;
|
|
204
|
-
}
|
|
205
|
-
const configContent = await fs5.readFile(configFilePath, { encoding: "utf8" });
|
|
206
|
-
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
207
|
-
if (parsedMountPoint === void 0) {
|
|
208
|
-
return defaultMountPoint;
|
|
209
|
-
}
|
|
210
|
-
mountPoint = parsedMountPoint;
|
|
211
|
-
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
212
|
-
return mountPoint;
|
|
213
|
-
};
|
|
214
|
-
})();
|
|
215
|
-
powerShellPathFromWsl = async () => {
|
|
216
|
-
const mountPoint = await wslDrivesMountPoint();
|
|
217
|
-
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
218
|
-
};
|
|
219
|
-
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
220
|
-
canAccessPowerShell = async () => {
|
|
221
|
-
canAccessPowerShellPromise ??= (async () => {
|
|
222
|
-
try {
|
|
223
|
-
const psPath = await powerShellPath2();
|
|
224
|
-
await fs5.access(psPath, fsConstants2.X_OK);
|
|
225
|
-
return true;
|
|
226
|
-
} catch {
|
|
227
|
-
return false;
|
|
228
|
-
}
|
|
229
|
-
})();
|
|
230
|
-
return canAccessPowerShellPromise;
|
|
231
|
-
};
|
|
232
|
-
wslDefaultBrowser = async () => {
|
|
233
|
-
const psPath = await powerShellPath2();
|
|
234
|
-
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
235
|
-
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
236
|
-
return stdout.trim();
|
|
237
|
-
};
|
|
238
|
-
convertWslPathToWindows = async (path12) => {
|
|
239
|
-
if (/^[a-z]+:\/\//i.test(path12)) {
|
|
240
|
-
return path12;
|
|
241
|
-
}
|
|
242
|
-
try {
|
|
243
|
-
const { stdout } = await execFile2("wslpath", ["-aw", path12], { encoding: "utf8" });
|
|
244
|
-
return stdout.trim();
|
|
245
|
-
} catch {
|
|
246
|
-
return path12;
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
253
|
-
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
254
|
-
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
255
|
-
Object.defineProperty(object, propertyName, {
|
|
256
|
-
configurable: true,
|
|
257
|
-
enumerable: true,
|
|
258
|
-
get() {
|
|
259
|
-
const result = valueGetter();
|
|
260
|
-
define(result);
|
|
261
|
-
return result;
|
|
262
|
-
},
|
|
263
|
-
set(value) {
|
|
264
|
-
define(value);
|
|
265
|
-
}
|
|
266
|
-
});
|
|
267
|
-
return object;
|
|
268
|
-
}
|
|
269
|
-
var init_define_lazy_prop = __esm({
|
|
270
|
-
"../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js"() {
|
|
271
|
-
"use strict";
|
|
272
|
-
init_esm_shims();
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
277
|
-
import { promisify as promisify3 } from "util";
|
|
278
|
-
import process5 from "process";
|
|
279
|
-
import { execFile as execFile3 } from "child_process";
|
|
280
|
-
async function defaultBrowserId() {
|
|
281
|
-
if (process5.platform !== "darwin") {
|
|
282
|
-
throw new Error("macOS only");
|
|
283
|
-
}
|
|
284
|
-
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
285
|
-
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
286
|
-
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
287
|
-
if (browserId === "com.apple.safari") {
|
|
288
|
-
return "com.apple.Safari";
|
|
289
|
-
}
|
|
290
|
-
return browserId;
|
|
291
|
-
}
|
|
292
|
-
var execFileAsync;
|
|
293
|
-
var init_default_browser_id = __esm({
|
|
294
|
-
"../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js"() {
|
|
295
|
-
"use strict";
|
|
296
|
-
init_esm_shims();
|
|
297
|
-
execFileAsync = promisify3(execFile3);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
302
|
-
import process6 from "process";
|
|
303
|
-
import { promisify as promisify4 } from "util";
|
|
304
|
-
import { execFile as execFile4, execFileSync } from "child_process";
|
|
305
|
-
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
306
|
-
if (process6.platform !== "darwin") {
|
|
307
|
-
throw new Error("macOS only");
|
|
308
|
-
}
|
|
309
|
-
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
310
|
-
const execOptions = {};
|
|
311
|
-
if (signal) {
|
|
312
|
-
execOptions.signal = signal;
|
|
313
|
-
}
|
|
314
|
-
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
315
|
-
return stdout.trim();
|
|
316
|
-
}
|
|
317
|
-
var execFileAsync2;
|
|
318
|
-
var init_run_applescript = __esm({
|
|
319
|
-
"../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js"() {
|
|
320
|
-
"use strict";
|
|
321
|
-
init_esm_shims();
|
|
322
|
-
execFileAsync2 = promisify4(execFile4);
|
|
323
|
-
}
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
// ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
327
|
-
async function bundleName(bundleId) {
|
|
328
|
-
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
329
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
330
|
-
}
|
|
331
|
-
var init_bundle_name = __esm({
|
|
332
|
-
"../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js"() {
|
|
333
|
-
"use strict";
|
|
334
|
-
init_esm_shims();
|
|
335
|
-
init_run_applescript();
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
340
|
-
import { promisify as promisify5 } from "util";
|
|
341
|
-
import { execFile as execFile5 } from "child_process";
|
|
342
|
-
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
343
|
-
const { stdout } = await _execFileAsync("reg", [
|
|
344
|
-
"QUERY",
|
|
345
|
-
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
346
|
-
"/v",
|
|
347
|
-
"ProgId"
|
|
348
|
-
]);
|
|
349
|
-
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
350
|
-
if (!match) {
|
|
351
|
-
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
352
|
-
}
|
|
353
|
-
const { id } = match.groups;
|
|
354
|
-
const dotIndex = id.lastIndexOf(".");
|
|
355
|
-
const hyphenIndex = id.lastIndexOf("-");
|
|
356
|
-
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
357
|
-
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
358
|
-
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
359
|
-
}
|
|
360
|
-
var execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
361
|
-
var init_windows = __esm({
|
|
362
|
-
"../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js"() {
|
|
363
|
-
"use strict";
|
|
364
|
-
init_esm_shims();
|
|
365
|
-
execFileAsync3 = promisify5(execFile5);
|
|
366
|
-
windowsBrowserProgIds = {
|
|
367
|
-
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
368
|
-
// The missing `L` is correct.
|
|
369
|
-
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
370
|
-
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
371
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
372
|
-
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
373
|
-
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
374
|
-
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
375
|
-
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
376
|
-
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
377
|
-
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
378
|
-
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
379
|
-
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
380
|
-
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
381
|
-
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
382
|
-
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
383
|
-
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
384
|
-
};
|
|
385
|
-
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
386
|
-
UnknownBrowserError = class extends Error {
|
|
387
|
-
};
|
|
388
|
-
}
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
392
|
-
import { promisify as promisify6 } from "util";
|
|
393
|
-
import process7 from "process";
|
|
394
|
-
import { execFile as execFile6 } from "child_process";
|
|
395
|
-
async function defaultBrowser2() {
|
|
396
|
-
if (process7.platform === "darwin") {
|
|
397
|
-
const id = await defaultBrowserId();
|
|
398
|
-
const name = await bundleName(id);
|
|
399
|
-
return { name, id };
|
|
400
|
-
}
|
|
401
|
-
if (process7.platform === "linux") {
|
|
402
|
-
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
403
|
-
const id = stdout.trim();
|
|
404
|
-
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
405
|
-
return { name, id };
|
|
406
|
-
}
|
|
407
|
-
if (process7.platform === "win32") {
|
|
408
|
-
return defaultBrowser();
|
|
409
|
-
}
|
|
410
|
-
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
411
|
-
}
|
|
412
|
-
var execFileAsync4, titleize;
|
|
413
|
-
var init_default_browser = __esm({
|
|
414
|
-
"../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js"() {
|
|
415
|
-
"use strict";
|
|
416
|
-
init_esm_shims();
|
|
417
|
-
init_default_browser_id();
|
|
418
|
-
init_bundle_name();
|
|
419
|
-
init_windows();
|
|
420
|
-
init_windows();
|
|
421
|
-
execFileAsync4 = promisify6(execFile6);
|
|
422
|
-
titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
// ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
427
|
-
import process8 from "process";
|
|
428
|
-
var isInSsh, is_in_ssh_default;
|
|
429
|
-
var init_is_in_ssh = __esm({
|
|
430
|
-
"../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js"() {
|
|
431
|
-
"use strict";
|
|
432
|
-
init_esm_shims();
|
|
433
|
-
isInSsh = Boolean(process8.env.SSH_CONNECTION || process8.env.SSH_CLIENT || process8.env.SSH_TTY);
|
|
434
|
-
is_in_ssh_default = isInSsh;
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
439
|
-
var open_exports = {};
|
|
440
|
-
__export(open_exports, {
|
|
441
|
-
apps: () => apps,
|
|
442
|
-
default: () => open_default,
|
|
443
|
-
openApp: () => openApp
|
|
444
|
-
});
|
|
445
|
-
import process9 from "process";
|
|
446
|
-
import path2 from "path";
|
|
447
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
448
|
-
import childProcess3 from "child_process";
|
|
449
|
-
import fs6, { constants as fsConstants3 } from "fs/promises";
|
|
450
|
-
function detectArchBinary(binary) {
|
|
451
|
-
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
452
|
-
return binary;
|
|
453
|
-
}
|
|
454
|
-
const { [arch]: archBinary } = binary;
|
|
455
|
-
if (!archBinary) {
|
|
456
|
-
throw new Error(`${arch} is not supported`);
|
|
457
|
-
}
|
|
458
|
-
return archBinary;
|
|
459
|
-
}
|
|
460
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
461
|
-
if (wsl && is_wsl_default) {
|
|
462
|
-
return detectArchBinary(wsl);
|
|
463
|
-
}
|
|
464
|
-
if (!platformBinary) {
|
|
465
|
-
throw new Error(`${platform} is not supported`);
|
|
466
|
-
}
|
|
467
|
-
return detectArchBinary(platformBinary);
|
|
468
|
-
}
|
|
469
|
-
var fallbackAttemptSymbol, __dirname2, localXdgOpenPath, platform, arch, tryEachApp, baseOpen, open, openApp, apps, open_default;
|
|
470
|
-
var init_open = __esm({
|
|
471
|
-
"../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js"() {
|
|
472
|
-
"use strict";
|
|
473
|
-
init_esm_shims();
|
|
474
|
-
init_wsl_utils();
|
|
475
|
-
init_powershell_utils();
|
|
476
|
-
init_define_lazy_prop();
|
|
477
|
-
init_default_browser();
|
|
478
|
-
init_is_inside_container();
|
|
479
|
-
init_is_in_ssh();
|
|
480
|
-
fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
481
|
-
__dirname2 = import.meta.url ? path2.dirname(fileURLToPath2(import.meta.url)) : "";
|
|
482
|
-
localXdgOpenPath = path2.join(__dirname2, "xdg-open");
|
|
483
|
-
({ platform, arch } = process9);
|
|
484
|
-
tryEachApp = async (apps2, opener) => {
|
|
485
|
-
if (apps2.length === 0) {
|
|
486
|
-
return;
|
|
487
|
-
}
|
|
488
|
-
const errors = [];
|
|
489
|
-
for (const app of apps2) {
|
|
490
|
-
try {
|
|
491
|
-
return await opener(app);
|
|
492
|
-
} catch (error) {
|
|
493
|
-
errors.push(error);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
497
|
-
};
|
|
498
|
-
baseOpen = async (options) => {
|
|
499
|
-
options = {
|
|
500
|
-
wait: false,
|
|
501
|
-
background: false,
|
|
502
|
-
newInstance: false,
|
|
503
|
-
allowNonzeroExitCode: false,
|
|
504
|
-
...options
|
|
505
|
-
};
|
|
506
|
-
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
507
|
-
delete options[fallbackAttemptSymbol];
|
|
508
|
-
if (Array.isArray(options.app)) {
|
|
509
|
-
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
510
|
-
...options,
|
|
511
|
-
app: singleApp,
|
|
512
|
-
[fallbackAttemptSymbol]: true
|
|
513
|
-
}));
|
|
514
|
-
}
|
|
515
|
-
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
516
|
-
appArguments = [...appArguments];
|
|
517
|
-
if (Array.isArray(app)) {
|
|
518
|
-
return tryEachApp(app, (appName) => baseOpen({
|
|
519
|
-
...options,
|
|
520
|
-
app: {
|
|
521
|
-
name: appName,
|
|
522
|
-
arguments: appArguments
|
|
523
|
-
},
|
|
524
|
-
[fallbackAttemptSymbol]: true
|
|
525
|
-
}));
|
|
526
|
-
}
|
|
527
|
-
if (app === "browser" || app === "browserPrivate") {
|
|
528
|
-
const ids = {
|
|
529
|
-
"com.google.chrome": "chrome",
|
|
530
|
-
"google-chrome.desktop": "chrome",
|
|
531
|
-
"com.brave.browser": "brave",
|
|
532
|
-
"org.mozilla.firefox": "firefox",
|
|
533
|
-
"firefox.desktop": "firefox",
|
|
534
|
-
"com.microsoft.msedge": "edge",
|
|
535
|
-
"com.microsoft.edge": "edge",
|
|
536
|
-
"com.microsoft.edgemac": "edge",
|
|
537
|
-
"microsoft-edge.desktop": "edge",
|
|
538
|
-
"com.apple.safari": "safari"
|
|
539
|
-
};
|
|
540
|
-
const flags = {
|
|
541
|
-
chrome: "--incognito",
|
|
542
|
-
brave: "--incognito",
|
|
543
|
-
firefox: "--private-window",
|
|
544
|
-
edge: "--inPrivate"
|
|
545
|
-
// Safari doesn't support private mode via command line
|
|
546
|
-
};
|
|
547
|
-
let browser;
|
|
548
|
-
if (is_wsl_default) {
|
|
549
|
-
const progId = await wslDefaultBrowser();
|
|
550
|
-
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
551
|
-
browser = browserInfo ?? {};
|
|
552
|
-
} else {
|
|
553
|
-
browser = await defaultBrowser2();
|
|
554
|
-
}
|
|
555
|
-
if (browser.id in ids) {
|
|
556
|
-
const browserName = ids[browser.id.toLowerCase()];
|
|
557
|
-
if (app === "browserPrivate") {
|
|
558
|
-
if (browserName === "safari") {
|
|
559
|
-
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
560
|
-
}
|
|
561
|
-
appArguments.push(flags[browserName]);
|
|
562
|
-
}
|
|
563
|
-
return baseOpen({
|
|
564
|
-
...options,
|
|
565
|
-
app: {
|
|
566
|
-
name: apps[browserName],
|
|
567
|
-
arguments: appArguments
|
|
568
|
-
}
|
|
569
|
-
});
|
|
570
|
-
}
|
|
571
|
-
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
572
|
-
}
|
|
573
|
-
let command;
|
|
574
|
-
const cliArguments = [];
|
|
575
|
-
const childProcessOptions = {};
|
|
576
|
-
let shouldUseWindowsInWsl = false;
|
|
577
|
-
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
578
|
-
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
579
|
-
}
|
|
580
|
-
if (platform === "darwin") {
|
|
581
|
-
command = "open";
|
|
582
|
-
if (options.wait) {
|
|
583
|
-
cliArguments.push("--wait-apps");
|
|
584
|
-
}
|
|
585
|
-
if (options.background) {
|
|
586
|
-
cliArguments.push("--background");
|
|
587
|
-
}
|
|
588
|
-
if (options.newInstance) {
|
|
589
|
-
cliArguments.push("--new");
|
|
590
|
-
}
|
|
591
|
-
if (app) {
|
|
592
|
-
cliArguments.push("-a", app);
|
|
593
|
-
}
|
|
594
|
-
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
595
|
-
command = await powerShellPath2();
|
|
596
|
-
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
597
|
-
if (!is_wsl_default) {
|
|
598
|
-
childProcessOptions.windowsVerbatimArguments = true;
|
|
599
|
-
}
|
|
600
|
-
if (is_wsl_default && options.target) {
|
|
601
|
-
options.target = await convertWslPathToWindows(options.target);
|
|
602
|
-
}
|
|
603
|
-
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
604
|
-
if (options.wait) {
|
|
605
|
-
encodedArguments.push("-Wait");
|
|
606
|
-
}
|
|
607
|
-
if (app) {
|
|
608
|
-
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
609
|
-
if (options.target) {
|
|
610
|
-
appArguments.push(options.target);
|
|
611
|
-
}
|
|
612
|
-
} else if (options.target) {
|
|
613
|
-
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
614
|
-
}
|
|
615
|
-
if (appArguments.length > 0) {
|
|
616
|
-
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
617
|
-
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
618
|
-
}
|
|
619
|
-
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
620
|
-
if (!options.wait) {
|
|
621
|
-
childProcessOptions.stdio = "ignore";
|
|
622
|
-
}
|
|
623
|
-
} else {
|
|
624
|
-
if (app) {
|
|
625
|
-
command = app;
|
|
626
|
-
} else {
|
|
627
|
-
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
628
|
-
let exeLocalXdgOpen = false;
|
|
629
|
-
try {
|
|
630
|
-
await fs6.access(localXdgOpenPath, fsConstants3.X_OK);
|
|
631
|
-
exeLocalXdgOpen = true;
|
|
632
|
-
} catch {
|
|
633
|
-
}
|
|
634
|
-
const useSystemXdgOpen = process9.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
635
|
-
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
636
|
-
}
|
|
637
|
-
if (appArguments.length > 0) {
|
|
638
|
-
cliArguments.push(...appArguments);
|
|
639
|
-
}
|
|
640
|
-
if (!options.wait) {
|
|
641
|
-
childProcessOptions.stdio = "ignore";
|
|
642
|
-
childProcessOptions.detached = true;
|
|
643
|
-
}
|
|
644
|
-
}
|
|
645
|
-
if (platform === "darwin" && appArguments.length > 0) {
|
|
646
|
-
cliArguments.push("--args", ...appArguments);
|
|
647
|
-
}
|
|
648
|
-
if (options.target) {
|
|
649
|
-
cliArguments.push(options.target);
|
|
650
|
-
}
|
|
651
|
-
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
652
|
-
if (options.wait) {
|
|
653
|
-
return new Promise((resolve2, reject) => {
|
|
654
|
-
subprocess.once("error", reject);
|
|
655
|
-
subprocess.once("close", (exitCode) => {
|
|
656
|
-
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
657
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
resolve2(subprocess);
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
if (isFallbackAttempt) {
|
|
665
|
-
return new Promise((resolve2, reject) => {
|
|
666
|
-
subprocess.once("error", reject);
|
|
667
|
-
subprocess.once("spawn", () => {
|
|
668
|
-
subprocess.once("close", (exitCode) => {
|
|
669
|
-
subprocess.off("error", reject);
|
|
670
|
-
if (exitCode !== 0) {
|
|
671
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
672
|
-
return;
|
|
673
|
-
}
|
|
674
|
-
subprocess.unref();
|
|
675
|
-
resolve2(subprocess);
|
|
676
|
-
});
|
|
677
|
-
});
|
|
678
|
-
});
|
|
679
|
-
}
|
|
680
|
-
subprocess.unref();
|
|
681
|
-
return new Promise((resolve2, reject) => {
|
|
682
|
-
subprocess.once("error", reject);
|
|
683
|
-
subprocess.once("spawn", () => {
|
|
684
|
-
subprocess.off("error", reject);
|
|
685
|
-
resolve2(subprocess);
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
};
|
|
689
|
-
open = (target, options) => {
|
|
690
|
-
if (typeof target !== "string") {
|
|
691
|
-
throw new TypeError("Expected a `target`");
|
|
692
|
-
}
|
|
693
|
-
return baseOpen({
|
|
694
|
-
...options,
|
|
695
|
-
target
|
|
696
|
-
});
|
|
697
|
-
};
|
|
698
|
-
openApp = (name, options) => {
|
|
699
|
-
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
700
|
-
throw new TypeError("Expected a valid `name`");
|
|
701
|
-
}
|
|
702
|
-
const { arguments: appArguments = [] } = options ?? {};
|
|
703
|
-
if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
|
|
704
|
-
throw new TypeError("Expected `appArguments` as Array type");
|
|
705
|
-
}
|
|
706
|
-
return baseOpen({
|
|
707
|
-
...options,
|
|
708
|
-
app: {
|
|
709
|
-
name,
|
|
710
|
-
arguments: appArguments
|
|
711
|
-
}
|
|
712
|
-
});
|
|
713
|
-
};
|
|
714
|
-
apps = {
|
|
715
|
-
browser: "browser",
|
|
716
|
-
browserPrivate: "browserPrivate"
|
|
717
|
-
};
|
|
718
|
-
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
719
|
-
darwin: "google chrome",
|
|
720
|
-
win32: "chrome",
|
|
721
|
-
// `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
|
|
722
|
-
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
723
|
-
}, {
|
|
724
|
-
wsl: {
|
|
725
|
-
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
726
|
-
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
727
|
-
}
|
|
728
|
-
}));
|
|
729
|
-
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
730
|
-
darwin: "brave browser",
|
|
731
|
-
win32: "brave",
|
|
732
|
-
linux: ["brave-browser", "brave"]
|
|
733
|
-
}, {
|
|
734
|
-
wsl: {
|
|
735
|
-
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
736
|
-
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
737
|
-
}
|
|
738
|
-
}));
|
|
739
|
-
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
740
|
-
darwin: "firefox",
|
|
741
|
-
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
742
|
-
linux: "firefox"
|
|
743
|
-
}, {
|
|
744
|
-
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
745
|
-
}));
|
|
746
|
-
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
747
|
-
darwin: "microsoft edge",
|
|
748
|
-
win32: "msedge",
|
|
749
|
-
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
750
|
-
}, {
|
|
751
|
-
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
752
|
-
}));
|
|
753
|
-
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
754
|
-
darwin: "Safari"
|
|
755
|
-
}));
|
|
756
|
-
open_default = open;
|
|
757
|
-
}
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// src/index.ts
|
|
761
|
-
init_esm_shims();
|
|
762
2
|
|
|
763
|
-
// ../../node_modules/.pnpm/
|
|
764
|
-
|
|
3
|
+
// ../../node_modules/.pnpm/tsup@8.5.1_jiti@2.6.1_postcss@8.5.9_tsx@4.21.0_typescript@5.9.3_yaml@2.8.3/node_modules/tsup/assets/esm_shims.js
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var getDirname = () => path.dirname(getFilename());
|
|
8
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
765
9
|
|
|
766
10
|
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
767
|
-
init_esm_shims();
|
|
768
11
|
var ANSI_BACKGROUND_OFFSET = 10;
|
|
769
12
|
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
770
13
|
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
@@ -951,14 +194,13 @@ var ansiStyles = assembleStyles();
|
|
|
951
194
|
var ansi_styles_default = ansiStyles;
|
|
952
195
|
|
|
953
196
|
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
954
|
-
init_esm_shims();
|
|
955
197
|
import process2 from "process";
|
|
956
198
|
import os from "os";
|
|
957
199
|
import tty from "tty";
|
|
958
|
-
function hasFlag(flag,
|
|
200
|
+
function hasFlag(flag, argv2 = globalThis.Deno ? globalThis.Deno.args : process2.argv) {
|
|
959
201
|
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
960
|
-
const position =
|
|
961
|
-
const terminatorPosition =
|
|
202
|
+
const position = argv2.indexOf(prefix + flag);
|
|
203
|
+
const terminatorPosition = argv2.indexOf("--");
|
|
962
204
|
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
963
205
|
}
|
|
964
206
|
var { env } = process2;
|
|
@@ -978,311 +220,917 @@ function envForceColor() {
|
|
|
978
220
|
}
|
|
979
221
|
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
980
222
|
}
|
|
981
|
-
}
|
|
982
|
-
function translateLevel(level) {
|
|
983
|
-
if (level === 0) {
|
|
984
|
-
return false;
|
|
223
|
+
}
|
|
224
|
+
function translateLevel(level) {
|
|
225
|
+
if (level === 0) {
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return {
|
|
229
|
+
level,
|
|
230
|
+
hasBasic: true,
|
|
231
|
+
has256: level >= 2,
|
|
232
|
+
has16m: level >= 3
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
236
|
+
const noFlagForceColor = envForceColor();
|
|
237
|
+
if (noFlagForceColor !== void 0) {
|
|
238
|
+
flagForceColor = noFlagForceColor;
|
|
239
|
+
}
|
|
240
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
241
|
+
if (forceColor === 0) {
|
|
242
|
+
return 0;
|
|
243
|
+
}
|
|
244
|
+
if (sniffFlags) {
|
|
245
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
246
|
+
return 3;
|
|
247
|
+
}
|
|
248
|
+
if (hasFlag("color=256")) {
|
|
249
|
+
return 2;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
253
|
+
return 1;
|
|
254
|
+
}
|
|
255
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
256
|
+
return 0;
|
|
257
|
+
}
|
|
258
|
+
const min = forceColor || 0;
|
|
259
|
+
if (env.TERM === "dumb") {
|
|
260
|
+
return min;
|
|
261
|
+
}
|
|
262
|
+
if (process2.platform === "win32") {
|
|
263
|
+
const osRelease = os.release().split(".");
|
|
264
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
265
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
266
|
+
}
|
|
267
|
+
return 1;
|
|
268
|
+
}
|
|
269
|
+
if ("CI" in env) {
|
|
270
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
271
|
+
return 3;
|
|
272
|
+
}
|
|
273
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
274
|
+
return 1;
|
|
275
|
+
}
|
|
276
|
+
return min;
|
|
277
|
+
}
|
|
278
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
279
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
280
|
+
}
|
|
281
|
+
if (env.COLORTERM === "truecolor") {
|
|
282
|
+
return 3;
|
|
283
|
+
}
|
|
284
|
+
if (env.TERM === "xterm-kitty") {
|
|
285
|
+
return 3;
|
|
286
|
+
}
|
|
287
|
+
if (env.TERM === "xterm-ghostty") {
|
|
288
|
+
return 3;
|
|
289
|
+
}
|
|
290
|
+
if (env.TERM === "wezterm") {
|
|
291
|
+
return 3;
|
|
292
|
+
}
|
|
293
|
+
if ("TERM_PROGRAM" in env) {
|
|
294
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
295
|
+
switch (env.TERM_PROGRAM) {
|
|
296
|
+
case "iTerm.app": {
|
|
297
|
+
return version >= 3 ? 3 : 2;
|
|
298
|
+
}
|
|
299
|
+
case "Apple_Terminal": {
|
|
300
|
+
return 2;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
305
|
+
return 2;
|
|
306
|
+
}
|
|
307
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
308
|
+
return 1;
|
|
309
|
+
}
|
|
310
|
+
if ("COLORTERM" in env) {
|
|
311
|
+
return 1;
|
|
312
|
+
}
|
|
313
|
+
return min;
|
|
314
|
+
}
|
|
315
|
+
function createSupportsColor(stream, options = {}) {
|
|
316
|
+
const level = _supportsColor(stream, {
|
|
317
|
+
streamIsTTY: stream && stream.isTTY,
|
|
318
|
+
...options
|
|
319
|
+
});
|
|
320
|
+
return translateLevel(level);
|
|
321
|
+
}
|
|
322
|
+
var supportsColor = {
|
|
323
|
+
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
324
|
+
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
325
|
+
};
|
|
326
|
+
var supports_color_default = supportsColor;
|
|
327
|
+
|
|
328
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
|
|
329
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
330
|
+
let index = string.indexOf(substring);
|
|
331
|
+
if (index === -1) {
|
|
332
|
+
return string;
|
|
333
|
+
}
|
|
334
|
+
const substringLength = substring.length;
|
|
335
|
+
let endIndex = 0;
|
|
336
|
+
let returnValue = "";
|
|
337
|
+
do {
|
|
338
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
339
|
+
endIndex = index + substringLength;
|
|
340
|
+
index = string.indexOf(substring, endIndex);
|
|
341
|
+
} while (index !== -1);
|
|
342
|
+
returnValue += string.slice(endIndex);
|
|
343
|
+
return returnValue;
|
|
344
|
+
}
|
|
345
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
346
|
+
let endIndex = 0;
|
|
347
|
+
let returnValue = "";
|
|
348
|
+
do {
|
|
349
|
+
const gotCR = string[index - 1] === "\r";
|
|
350
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
351
|
+
endIndex = index + 1;
|
|
352
|
+
index = string.indexOf("\n", endIndex);
|
|
353
|
+
} while (index !== -1);
|
|
354
|
+
returnValue += string.slice(endIndex);
|
|
355
|
+
return returnValue;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
359
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
360
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
361
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
362
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
363
|
+
var levelMapping = [
|
|
364
|
+
"ansi",
|
|
365
|
+
"ansi",
|
|
366
|
+
"ansi256",
|
|
367
|
+
"ansi16m"
|
|
368
|
+
];
|
|
369
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
370
|
+
var applyOptions = (object, options = {}) => {
|
|
371
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
372
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
373
|
+
}
|
|
374
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
375
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
376
|
+
};
|
|
377
|
+
var chalkFactory = (options) => {
|
|
378
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
379
|
+
applyOptions(chalk2, options);
|
|
380
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
381
|
+
return chalk2;
|
|
382
|
+
};
|
|
383
|
+
function createChalk(options) {
|
|
384
|
+
return chalkFactory(options);
|
|
385
|
+
}
|
|
386
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
387
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
388
|
+
styles2[styleName] = {
|
|
389
|
+
get() {
|
|
390
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
391
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
392
|
+
return builder;
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
styles2.visible = {
|
|
397
|
+
get() {
|
|
398
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
399
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
400
|
+
return builder;
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
404
|
+
if (model === "rgb") {
|
|
405
|
+
if (level === "ansi16m") {
|
|
406
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
407
|
+
}
|
|
408
|
+
if (level === "ansi256") {
|
|
409
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
410
|
+
}
|
|
411
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
412
|
+
}
|
|
413
|
+
if (model === "hex") {
|
|
414
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
415
|
+
}
|
|
416
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
417
|
+
};
|
|
418
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
419
|
+
for (const model of usedModels) {
|
|
420
|
+
styles2[model] = {
|
|
421
|
+
get() {
|
|
422
|
+
const { level } = this;
|
|
423
|
+
return function(...arguments_) {
|
|
424
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
425
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
};
|
|
429
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
430
|
+
styles2[bgModel] = {
|
|
431
|
+
get() {
|
|
432
|
+
const { level } = this;
|
|
433
|
+
return function(...arguments_) {
|
|
434
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
435
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
var proto = Object.defineProperties(() => {
|
|
441
|
+
}, {
|
|
442
|
+
...styles2,
|
|
443
|
+
level: {
|
|
444
|
+
enumerable: true,
|
|
445
|
+
get() {
|
|
446
|
+
return this[GENERATOR].level;
|
|
447
|
+
},
|
|
448
|
+
set(level) {
|
|
449
|
+
this[GENERATOR].level = level;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
var createStyler = (open2, close, parent) => {
|
|
454
|
+
let openAll;
|
|
455
|
+
let closeAll;
|
|
456
|
+
if (parent === void 0) {
|
|
457
|
+
openAll = open2;
|
|
458
|
+
closeAll = close;
|
|
459
|
+
} else {
|
|
460
|
+
openAll = parent.openAll + open2;
|
|
461
|
+
closeAll = close + parent.closeAll;
|
|
985
462
|
}
|
|
986
463
|
return {
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
464
|
+
open: open2,
|
|
465
|
+
close,
|
|
466
|
+
openAll,
|
|
467
|
+
closeAll,
|
|
468
|
+
parent
|
|
991
469
|
};
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
const
|
|
995
|
-
|
|
996
|
-
|
|
470
|
+
};
|
|
471
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
472
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
473
|
+
Object.setPrototypeOf(builder, proto);
|
|
474
|
+
builder[GENERATOR] = self;
|
|
475
|
+
builder[STYLER] = _styler;
|
|
476
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
477
|
+
return builder;
|
|
478
|
+
};
|
|
479
|
+
var applyStyle = (self, string) => {
|
|
480
|
+
if (self.level <= 0 || !string) {
|
|
481
|
+
return self[IS_EMPTY] ? "" : string;
|
|
997
482
|
}
|
|
998
|
-
|
|
999
|
-
if (
|
|
1000
|
-
return
|
|
483
|
+
let styler = self[STYLER];
|
|
484
|
+
if (styler === void 0) {
|
|
485
|
+
return string;
|
|
1001
486
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
return 2;
|
|
487
|
+
const { openAll, closeAll } = styler;
|
|
488
|
+
if (string.includes("\x1B")) {
|
|
489
|
+
while (styler !== void 0) {
|
|
490
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
491
|
+
styler = styler.parent;
|
|
1008
492
|
}
|
|
1009
493
|
}
|
|
1010
|
-
|
|
1011
|
-
|
|
494
|
+
const lfIndex = string.indexOf("\n");
|
|
495
|
+
if (lfIndex !== -1) {
|
|
496
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1012
497
|
}
|
|
1013
|
-
|
|
1014
|
-
|
|
498
|
+
return openAll + string + closeAll;
|
|
499
|
+
};
|
|
500
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
501
|
+
var chalk = createChalk();
|
|
502
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
503
|
+
var source_default = chalk;
|
|
504
|
+
|
|
505
|
+
// src/index.ts
|
|
506
|
+
import { Command as Command7 } from "commander";
|
|
507
|
+
import "dotenv/config";
|
|
508
|
+
import { spawn as spawn3 } from "child_process";
|
|
509
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
510
|
+
import { access, mkdir as mkdir4, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
511
|
+
import { createRequire as createRequire2 } from "module";
|
|
512
|
+
import path11 from "path";
|
|
513
|
+
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
514
|
+
|
|
515
|
+
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
516
|
+
import process9 from "process";
|
|
517
|
+
import path2 from "path";
|
|
518
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
519
|
+
import childProcess3 from "child_process";
|
|
520
|
+
import fs6, { constants as fsConstants3 } from "fs/promises";
|
|
521
|
+
|
|
522
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
523
|
+
import { promisify as promisify2 } from "util";
|
|
524
|
+
import childProcess2 from "child_process";
|
|
525
|
+
import fs5, { constants as fsConstants2 } from "fs/promises";
|
|
526
|
+
|
|
527
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
|
|
528
|
+
import process3 from "process";
|
|
529
|
+
import os2 from "os";
|
|
530
|
+
import fs3 from "fs";
|
|
531
|
+
|
|
532
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
533
|
+
import fs2 from "fs";
|
|
534
|
+
|
|
535
|
+
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
536
|
+
import fs from "fs";
|
|
537
|
+
var isDockerCached;
|
|
538
|
+
function hasDockerEnv() {
|
|
539
|
+
try {
|
|
540
|
+
fs.statSync("/.dockerenv");
|
|
541
|
+
return true;
|
|
542
|
+
} catch {
|
|
543
|
+
return false;
|
|
1015
544
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
545
|
+
}
|
|
546
|
+
function hasDockerCGroup() {
|
|
547
|
+
try {
|
|
548
|
+
return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
549
|
+
} catch {
|
|
550
|
+
return false;
|
|
1019
551
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
}
|
|
1025
|
-
return 1;
|
|
552
|
+
}
|
|
553
|
+
function isDocker() {
|
|
554
|
+
if (isDockerCached === void 0) {
|
|
555
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
1026
556
|
}
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
557
|
+
return isDockerCached;
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
561
|
+
var cachedResult;
|
|
562
|
+
var hasContainerEnv = () => {
|
|
563
|
+
try {
|
|
564
|
+
fs2.statSync("/run/.containerenv");
|
|
565
|
+
return true;
|
|
566
|
+
} catch {
|
|
567
|
+
return false;
|
|
1035
568
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
569
|
+
};
|
|
570
|
+
function isInsideContainer() {
|
|
571
|
+
if (cachedResult === void 0) {
|
|
572
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
1038
573
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
574
|
+
return cachedResult;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
|
|
578
|
+
var isWsl = () => {
|
|
579
|
+
if (process3.platform !== "linux") {
|
|
580
|
+
return false;
|
|
1041
581
|
}
|
|
1042
|
-
if (
|
|
1043
|
-
|
|
582
|
+
if (os2.release().toLowerCase().includes("microsoft")) {
|
|
583
|
+
if (isInsideContainer()) {
|
|
584
|
+
return false;
|
|
585
|
+
}
|
|
586
|
+
return true;
|
|
1044
587
|
}
|
|
1045
|
-
|
|
1046
|
-
return
|
|
588
|
+
try {
|
|
589
|
+
return fs3.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
590
|
+
} catch {
|
|
591
|
+
return false;
|
|
1047
592
|
}
|
|
1048
|
-
|
|
1049
|
-
|
|
593
|
+
};
|
|
594
|
+
var is_wsl_default = process3.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
595
|
+
|
|
596
|
+
// ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
597
|
+
import process4 from "process";
|
|
598
|
+
import { Buffer as Buffer2 } from "buffer";
|
|
599
|
+
import { promisify } from "util";
|
|
600
|
+
import childProcess from "child_process";
|
|
601
|
+
import fs4, { constants as fsConstants } from "fs/promises";
|
|
602
|
+
var execFile = promisify(childProcess.execFile);
|
|
603
|
+
var powerShellPath = () => `${process4.env.SYSTEMROOT || process4.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
604
|
+
var executePowerShell = async (command, options = {}) => {
|
|
605
|
+
const {
|
|
606
|
+
powerShellPath: psPath,
|
|
607
|
+
...execFileOptions
|
|
608
|
+
} = options;
|
|
609
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
610
|
+
return execFile(
|
|
611
|
+
psPath ?? powerShellPath(),
|
|
612
|
+
[
|
|
613
|
+
...executePowerShell.argumentsPrefix,
|
|
614
|
+
encodedCommand
|
|
615
|
+
],
|
|
616
|
+
{
|
|
617
|
+
encoding: "utf8",
|
|
618
|
+
...execFileOptions
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
};
|
|
622
|
+
executePowerShell.argumentsPrefix = [
|
|
623
|
+
"-NoProfile",
|
|
624
|
+
"-NonInteractive",
|
|
625
|
+
"-ExecutionPolicy",
|
|
626
|
+
"Bypass",
|
|
627
|
+
"-EncodedCommand"
|
|
628
|
+
];
|
|
629
|
+
executePowerShell.encodeCommand = (command) => Buffer2.from(command, "utf16le").toString("base64");
|
|
630
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
631
|
+
|
|
632
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
|
|
633
|
+
function parseMountPointFromConfig(content) {
|
|
634
|
+
for (const line of content.split("\n")) {
|
|
635
|
+
if (/^\s*#/.test(line)) {
|
|
636
|
+
continue;
|
|
637
|
+
}
|
|
638
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
639
|
+
if (!match) {
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
1050
643
|
}
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
647
|
+
var execFile2 = promisify2(childProcess2.execFile);
|
|
648
|
+
var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
649
|
+
const defaultMountPoint = "/mnt/";
|
|
650
|
+
let mountPoint;
|
|
651
|
+
return async function() {
|
|
652
|
+
if (mountPoint) {
|
|
653
|
+
return mountPoint;
|
|
654
|
+
}
|
|
655
|
+
const configFilePath = "/etc/wsl.conf";
|
|
656
|
+
let isConfigFileExists = false;
|
|
657
|
+
try {
|
|
658
|
+
await fs5.access(configFilePath, fsConstants2.F_OK);
|
|
659
|
+
isConfigFileExists = true;
|
|
660
|
+
} catch {
|
|
661
|
+
}
|
|
662
|
+
if (!isConfigFileExists) {
|
|
663
|
+
return defaultMountPoint;
|
|
664
|
+
}
|
|
665
|
+
const configContent = await fs5.readFile(configFilePath, { encoding: "utf8" });
|
|
666
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
667
|
+
if (parsedMountPoint === void 0) {
|
|
668
|
+
return defaultMountPoint;
|
|
669
|
+
}
|
|
670
|
+
mountPoint = parsedMountPoint;
|
|
671
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
672
|
+
return mountPoint;
|
|
673
|
+
};
|
|
674
|
+
})();
|
|
675
|
+
var powerShellPathFromWsl = async () => {
|
|
676
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
677
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
678
|
+
};
|
|
679
|
+
var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
680
|
+
var canAccessPowerShellPromise;
|
|
681
|
+
var canAccessPowerShell = async () => {
|
|
682
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
683
|
+
try {
|
|
684
|
+
const psPath = await powerShellPath2();
|
|
685
|
+
await fs5.access(psPath, fsConstants2.X_OK);
|
|
686
|
+
return true;
|
|
687
|
+
} catch {
|
|
688
|
+
return false;
|
|
1060
689
|
}
|
|
690
|
+
})();
|
|
691
|
+
return canAccessPowerShellPromise;
|
|
692
|
+
};
|
|
693
|
+
var wslDefaultBrowser = async () => {
|
|
694
|
+
const psPath = await powerShellPath2();
|
|
695
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
696
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
697
|
+
return stdout.trim();
|
|
698
|
+
};
|
|
699
|
+
var convertWslPathToWindows = async (path12) => {
|
|
700
|
+
if (/^[a-z]+:\/\//i.test(path12)) {
|
|
701
|
+
return path12;
|
|
1061
702
|
}
|
|
1062
|
-
|
|
1063
|
-
|
|
703
|
+
try {
|
|
704
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path12], { encoding: "utf8" });
|
|
705
|
+
return stdout.trim();
|
|
706
|
+
} catch {
|
|
707
|
+
return path12;
|
|
1064
708
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
709
|
+
};
|
|
710
|
+
|
|
711
|
+
// ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
712
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
713
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
714
|
+
Object.defineProperty(object, propertyName, {
|
|
715
|
+
configurable: true,
|
|
716
|
+
enumerable: true,
|
|
717
|
+
get() {
|
|
718
|
+
const result = valueGetter();
|
|
719
|
+
define(result);
|
|
720
|
+
return result;
|
|
721
|
+
},
|
|
722
|
+
set(value) {
|
|
723
|
+
define(value);
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
return object;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
730
|
+
import { promisify as promisify6 } from "util";
|
|
731
|
+
import process7 from "process";
|
|
732
|
+
import { execFile as execFile6 } from "child_process";
|
|
733
|
+
|
|
734
|
+
// ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
735
|
+
import { promisify as promisify3 } from "util";
|
|
736
|
+
import process5 from "process";
|
|
737
|
+
import { execFile as execFile3 } from "child_process";
|
|
738
|
+
var execFileAsync = promisify3(execFile3);
|
|
739
|
+
async function defaultBrowserId() {
|
|
740
|
+
if (process5.platform !== "darwin") {
|
|
741
|
+
throw new Error("macOS only");
|
|
1067
742
|
}
|
|
1068
|
-
|
|
1069
|
-
|
|
743
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
744
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
745
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
746
|
+
if (browserId === "com.apple.safari") {
|
|
747
|
+
return "com.apple.Safari";
|
|
1070
748
|
}
|
|
1071
|
-
return
|
|
1072
|
-
}
|
|
1073
|
-
function createSupportsColor(stream, options = {}) {
|
|
1074
|
-
const level = _supportsColor(stream, {
|
|
1075
|
-
streamIsTTY: stream && stream.isTTY,
|
|
1076
|
-
...options
|
|
1077
|
-
});
|
|
1078
|
-
return translateLevel(level);
|
|
749
|
+
return browserId;
|
|
1079
750
|
}
|
|
1080
|
-
var supportsColor = {
|
|
1081
|
-
stdout: createSupportsColor({ isTTY: tty.isatty(1) }),
|
|
1082
|
-
stderr: createSupportsColor({ isTTY: tty.isatty(2) })
|
|
1083
|
-
};
|
|
1084
|
-
var supports_color_default = supportsColor;
|
|
1085
751
|
|
|
1086
|
-
// ../../node_modules/.pnpm/
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
752
|
+
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
753
|
+
import process6 from "process";
|
|
754
|
+
import { promisify as promisify4 } from "util";
|
|
755
|
+
import { execFile as execFile4, execFileSync } from "child_process";
|
|
756
|
+
var execFileAsync2 = promisify4(execFile4);
|
|
757
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
758
|
+
if (process6.platform !== "darwin") {
|
|
759
|
+
throw new Error("macOS only");
|
|
1092
760
|
}
|
|
1093
|
-
const
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
} while (index !== -1);
|
|
1101
|
-
returnValue += string.slice(endIndex);
|
|
1102
|
-
return returnValue;
|
|
761
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
762
|
+
const execOptions = {};
|
|
763
|
+
if (signal) {
|
|
764
|
+
execOptions.signal = signal;
|
|
765
|
+
}
|
|
766
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
767
|
+
return stdout.trim();
|
|
1103
768
|
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1110
|
-
endIndex = index + 1;
|
|
1111
|
-
index = string.indexOf("\n", endIndex);
|
|
1112
|
-
} while (index !== -1);
|
|
1113
|
-
returnValue += string.slice(endIndex);
|
|
1114
|
-
return returnValue;
|
|
769
|
+
|
|
770
|
+
// ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
771
|
+
async function bundleName(bundleId) {
|
|
772
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
773
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
1115
774
|
}
|
|
1116
775
|
|
|
1117
|
-
// ../../node_modules/.pnpm/
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
var
|
|
1121
|
-
var
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
"
|
|
1125
|
-
"
|
|
1126
|
-
"
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
|
|
776
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
777
|
+
import { promisify as promisify5 } from "util";
|
|
778
|
+
import { execFile as execFile5 } from "child_process";
|
|
779
|
+
var execFileAsync3 = promisify5(execFile5);
|
|
780
|
+
var windowsBrowserProgIds = {
|
|
781
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
782
|
+
// The missing `L` is correct.
|
|
783
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
784
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
785
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
786
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
787
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
788
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
789
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
790
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
791
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
792
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
793
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
794
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
795
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
796
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
797
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
1135
798
|
};
|
|
1136
|
-
var
|
|
1137
|
-
|
|
1138
|
-
applyOptions(chalk2, options);
|
|
1139
|
-
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
1140
|
-
return chalk2;
|
|
799
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
800
|
+
var UnknownBrowserError = class extends Error {
|
|
1141
801
|
};
|
|
1142
|
-
function
|
|
1143
|
-
|
|
802
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
803
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
804
|
+
"QUERY",
|
|
805
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
806
|
+
"/v",
|
|
807
|
+
"ProgId"
|
|
808
|
+
]);
|
|
809
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
810
|
+
if (!match) {
|
|
811
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
812
|
+
}
|
|
813
|
+
const { id } = match.groups;
|
|
814
|
+
const dotIndex = id.lastIndexOf(".");
|
|
815
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
816
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
817
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
818
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
1144
819
|
}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
820
|
+
|
|
821
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
822
|
+
var execFileAsync4 = promisify6(execFile6);
|
|
823
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
824
|
+
async function defaultBrowser2() {
|
|
825
|
+
if (process7.platform === "darwin") {
|
|
826
|
+
const id = await defaultBrowserId();
|
|
827
|
+
const name = await bundleName(id);
|
|
828
|
+
return { name, id };
|
|
829
|
+
}
|
|
830
|
+
if (process7.platform === "linux") {
|
|
831
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
832
|
+
const id = stdout.trim();
|
|
833
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
834
|
+
return { name, id };
|
|
835
|
+
}
|
|
836
|
+
if (process7.platform === "win32") {
|
|
837
|
+
return defaultBrowser();
|
|
838
|
+
}
|
|
839
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
1154
840
|
}
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
841
|
+
|
|
842
|
+
// ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
843
|
+
import process8 from "process";
|
|
844
|
+
var isInSsh = Boolean(process8.env.SSH_CONNECTION || process8.env.SSH_CLIENT || process8.env.SSH_TTY);
|
|
845
|
+
var is_in_ssh_default = isInSsh;
|
|
846
|
+
|
|
847
|
+
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
848
|
+
var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
849
|
+
var __dirname2 = import.meta.url ? path2.dirname(fileURLToPath2(import.meta.url)) : "";
|
|
850
|
+
var localXdgOpenPath = path2.join(__dirname2, "xdg-open");
|
|
851
|
+
var { platform, arch } = process9;
|
|
852
|
+
var tryEachApp = async (apps2, opener) => {
|
|
853
|
+
if (apps2.length === 0) {
|
|
854
|
+
return;
|
|
1160
855
|
}
|
|
856
|
+
const errors = [];
|
|
857
|
+
for (const app of apps2) {
|
|
858
|
+
try {
|
|
859
|
+
return await opener(app);
|
|
860
|
+
} catch (error) {
|
|
861
|
+
errors.push(error);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
1161
865
|
};
|
|
1162
|
-
var
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
866
|
+
var baseOpen = async (options) => {
|
|
867
|
+
options = {
|
|
868
|
+
wait: false,
|
|
869
|
+
background: false,
|
|
870
|
+
newInstance: false,
|
|
871
|
+
allowNonzeroExitCode: false,
|
|
872
|
+
...options
|
|
873
|
+
};
|
|
874
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
875
|
+
delete options[fallbackAttemptSymbol];
|
|
876
|
+
if (Array.isArray(options.app)) {
|
|
877
|
+
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
878
|
+
...options,
|
|
879
|
+
app: singleApp,
|
|
880
|
+
[fallbackAttemptSymbol]: true
|
|
881
|
+
}));
|
|
882
|
+
}
|
|
883
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
884
|
+
appArguments = [...appArguments];
|
|
885
|
+
if (Array.isArray(app)) {
|
|
886
|
+
return tryEachApp(app, (appName) => baseOpen({
|
|
887
|
+
...options,
|
|
888
|
+
app: {
|
|
889
|
+
name: appName,
|
|
890
|
+
arguments: appArguments
|
|
891
|
+
},
|
|
892
|
+
[fallbackAttemptSymbol]: true
|
|
893
|
+
}));
|
|
894
|
+
}
|
|
895
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
896
|
+
const ids = {
|
|
897
|
+
"com.google.chrome": "chrome",
|
|
898
|
+
"google-chrome.desktop": "chrome",
|
|
899
|
+
"com.brave.browser": "brave",
|
|
900
|
+
"org.mozilla.firefox": "firefox",
|
|
901
|
+
"firefox.desktop": "firefox",
|
|
902
|
+
"com.microsoft.msedge": "edge",
|
|
903
|
+
"com.microsoft.edge": "edge",
|
|
904
|
+
"com.microsoft.edgemac": "edge",
|
|
905
|
+
"microsoft-edge.desktop": "edge",
|
|
906
|
+
"com.apple.safari": "safari"
|
|
907
|
+
};
|
|
908
|
+
const flags = {
|
|
909
|
+
chrome: "--incognito",
|
|
910
|
+
brave: "--incognito",
|
|
911
|
+
firefox: "--private-window",
|
|
912
|
+
edge: "--inPrivate"
|
|
913
|
+
// Safari doesn't support private mode via command line
|
|
914
|
+
};
|
|
915
|
+
let browser;
|
|
916
|
+
if (is_wsl_default) {
|
|
917
|
+
const progId = await wslDefaultBrowser();
|
|
918
|
+
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
919
|
+
browser = browserInfo ?? {};
|
|
920
|
+
} else {
|
|
921
|
+
browser = await defaultBrowser2();
|
|
1166
922
|
}
|
|
1167
|
-
if (
|
|
1168
|
-
|
|
923
|
+
if (browser.id in ids) {
|
|
924
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
925
|
+
if (app === "browserPrivate") {
|
|
926
|
+
if (browserName === "safari") {
|
|
927
|
+
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
928
|
+
}
|
|
929
|
+
appArguments.push(flags[browserName]);
|
|
930
|
+
}
|
|
931
|
+
return baseOpen({
|
|
932
|
+
...options,
|
|
933
|
+
app: {
|
|
934
|
+
name: apps[browserName],
|
|
935
|
+
arguments: appArguments
|
|
936
|
+
}
|
|
937
|
+
});
|
|
1169
938
|
}
|
|
1170
|
-
|
|
939
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
1171
940
|
}
|
|
1172
|
-
|
|
1173
|
-
|
|
941
|
+
let command;
|
|
942
|
+
const cliArguments = [];
|
|
943
|
+
const childProcessOptions = {};
|
|
944
|
+
let shouldUseWindowsInWsl = false;
|
|
945
|
+
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
946
|
+
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
1174
947
|
}
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
styles2[model] = {
|
|
1180
|
-
get() {
|
|
1181
|
-
const { level } = this;
|
|
1182
|
-
return function(...arguments_) {
|
|
1183
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
1184
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1185
|
-
};
|
|
948
|
+
if (platform === "darwin") {
|
|
949
|
+
command = "open";
|
|
950
|
+
if (options.wait) {
|
|
951
|
+
cliArguments.push("--wait-apps");
|
|
1186
952
|
}
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
styles2[bgModel] = {
|
|
1190
|
-
get() {
|
|
1191
|
-
const { level } = this;
|
|
1192
|
-
return function(...arguments_) {
|
|
1193
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
1194
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1195
|
-
};
|
|
953
|
+
if (options.background) {
|
|
954
|
+
cliArguments.push("--background");
|
|
1196
955
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
956
|
+
if (options.newInstance) {
|
|
957
|
+
cliArguments.push("--new");
|
|
958
|
+
}
|
|
959
|
+
if (app) {
|
|
960
|
+
cliArguments.push("-a", app);
|
|
961
|
+
}
|
|
962
|
+
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
963
|
+
command = await powerShellPath2();
|
|
964
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
965
|
+
if (!is_wsl_default) {
|
|
966
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
967
|
+
}
|
|
968
|
+
if (is_wsl_default && options.target) {
|
|
969
|
+
options.target = await convertWslPathToWindows(options.target);
|
|
970
|
+
}
|
|
971
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
972
|
+
if (options.wait) {
|
|
973
|
+
encodedArguments.push("-Wait");
|
|
974
|
+
}
|
|
975
|
+
if (app) {
|
|
976
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
977
|
+
if (options.target) {
|
|
978
|
+
appArguments.push(options.target);
|
|
979
|
+
}
|
|
980
|
+
} else if (options.target) {
|
|
981
|
+
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
982
|
+
}
|
|
983
|
+
if (appArguments.length > 0) {
|
|
984
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
985
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
986
|
+
}
|
|
987
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
988
|
+
if (!options.wait) {
|
|
989
|
+
childProcessOptions.stdio = "ignore";
|
|
1209
990
|
}
|
|
1210
|
-
}
|
|
1211
|
-
});
|
|
1212
|
-
var createStyler = (open2, close, parent) => {
|
|
1213
|
-
let openAll;
|
|
1214
|
-
let closeAll;
|
|
1215
|
-
if (parent === void 0) {
|
|
1216
|
-
openAll = open2;
|
|
1217
|
-
closeAll = close;
|
|
1218
991
|
} else {
|
|
1219
|
-
|
|
1220
|
-
|
|
992
|
+
if (app) {
|
|
993
|
+
command = app;
|
|
994
|
+
} else {
|
|
995
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
996
|
+
let exeLocalXdgOpen = false;
|
|
997
|
+
try {
|
|
998
|
+
await fs6.access(localXdgOpenPath, fsConstants3.X_OK);
|
|
999
|
+
exeLocalXdgOpen = true;
|
|
1000
|
+
} catch {
|
|
1001
|
+
}
|
|
1002
|
+
const useSystemXdgOpen = process9.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
1003
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
1004
|
+
}
|
|
1005
|
+
if (appArguments.length > 0) {
|
|
1006
|
+
cliArguments.push(...appArguments);
|
|
1007
|
+
}
|
|
1008
|
+
if (!options.wait) {
|
|
1009
|
+
childProcessOptions.stdio = "ignore";
|
|
1010
|
+
childProcessOptions.detached = true;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
1014
|
+
cliArguments.push("--args", ...appArguments);
|
|
1015
|
+
}
|
|
1016
|
+
if (options.target) {
|
|
1017
|
+
cliArguments.push(options.target);
|
|
1018
|
+
}
|
|
1019
|
+
const subprocess = childProcess3.spawn(command, cliArguments, childProcessOptions);
|
|
1020
|
+
if (options.wait) {
|
|
1021
|
+
return new Promise((resolve2, reject) => {
|
|
1022
|
+
subprocess.once("error", reject);
|
|
1023
|
+
subprocess.once("close", (exitCode) => {
|
|
1024
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
1025
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
1026
|
+
return;
|
|
1027
|
+
}
|
|
1028
|
+
resolve2(subprocess);
|
|
1029
|
+
});
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
if (isFallbackAttempt) {
|
|
1033
|
+
return new Promise((resolve2, reject) => {
|
|
1034
|
+
subprocess.once("error", reject);
|
|
1035
|
+
subprocess.once("spawn", () => {
|
|
1036
|
+
subprocess.once("close", (exitCode) => {
|
|
1037
|
+
subprocess.off("error", reject);
|
|
1038
|
+
if (exitCode !== 0) {
|
|
1039
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
1040
|
+
return;
|
|
1041
|
+
}
|
|
1042
|
+
subprocess.unref();
|
|
1043
|
+
resolve2(subprocess);
|
|
1044
|
+
});
|
|
1045
|
+
});
|
|
1046
|
+
});
|
|
1221
1047
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1048
|
+
subprocess.unref();
|
|
1049
|
+
return new Promise((resolve2, reject) => {
|
|
1050
|
+
subprocess.once("error", reject);
|
|
1051
|
+
subprocess.once("spawn", () => {
|
|
1052
|
+
subprocess.off("error", reject);
|
|
1053
|
+
resolve2(subprocess);
|
|
1054
|
+
});
|
|
1055
|
+
});
|
|
1229
1056
|
};
|
|
1230
|
-
var
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1057
|
+
var open = (target, options) => {
|
|
1058
|
+
if (typeof target !== "string") {
|
|
1059
|
+
throw new TypeError("Expected a `target`");
|
|
1060
|
+
}
|
|
1061
|
+
return baseOpen({
|
|
1062
|
+
...options,
|
|
1063
|
+
target
|
|
1064
|
+
});
|
|
1237
1065
|
};
|
|
1238
|
-
|
|
1239
|
-
if (
|
|
1240
|
-
return
|
|
1066
|
+
function detectArchBinary(binary) {
|
|
1067
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
1068
|
+
return binary;
|
|
1241
1069
|
}
|
|
1242
|
-
|
|
1243
|
-
if (
|
|
1244
|
-
|
|
1070
|
+
const { [arch]: archBinary } = binary;
|
|
1071
|
+
if (!archBinary) {
|
|
1072
|
+
throw new Error(`${arch} is not supported`);
|
|
1245
1073
|
}
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
}
|
|
1074
|
+
return archBinary;
|
|
1075
|
+
}
|
|
1076
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
1077
|
+
if (wsl && is_wsl_default) {
|
|
1078
|
+
return detectArchBinary(wsl);
|
|
1252
1079
|
}
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1080
|
+
if (!platformBinary) {
|
|
1081
|
+
throw new Error(`${platform} is not supported`);
|
|
1256
1082
|
}
|
|
1257
|
-
return
|
|
1083
|
+
return detectArchBinary(platformBinary);
|
|
1084
|
+
}
|
|
1085
|
+
var apps = {
|
|
1086
|
+
browser: "browser",
|
|
1087
|
+
browserPrivate: "browserPrivate"
|
|
1258
1088
|
};
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1089
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
1090
|
+
darwin: "google chrome",
|
|
1091
|
+
win32: "chrome",
|
|
1092
|
+
// `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
|
|
1093
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
1094
|
+
}, {
|
|
1095
|
+
wsl: {
|
|
1096
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
1097
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
1098
|
+
}
|
|
1099
|
+
}));
|
|
1100
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
1101
|
+
darwin: "brave browser",
|
|
1102
|
+
win32: "brave",
|
|
1103
|
+
linux: ["brave-browser", "brave"]
|
|
1104
|
+
}, {
|
|
1105
|
+
wsl: {
|
|
1106
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
1107
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
1108
|
+
}
|
|
1109
|
+
}));
|
|
1110
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
1111
|
+
darwin: "firefox",
|
|
1112
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
1113
|
+
linux: "firefox"
|
|
1114
|
+
}, {
|
|
1115
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
1116
|
+
}));
|
|
1117
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
1118
|
+
darwin: "microsoft edge",
|
|
1119
|
+
win32: "msedge",
|
|
1120
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
1121
|
+
}, {
|
|
1122
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
1123
|
+
}));
|
|
1124
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
1125
|
+
darwin: "Safari"
|
|
1126
|
+
}));
|
|
1127
|
+
var open_default = open;
|
|
1263
1128
|
|
|
1264
1129
|
// src/index.ts
|
|
1265
|
-
init_open();
|
|
1266
|
-
import { Command as Command7 } from "commander";
|
|
1267
|
-
import "dotenv/config";
|
|
1268
|
-
import { spawn as spawn3 } from "child_process";
|
|
1269
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
1270
|
-
import { access, mkdir as mkdir4, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
|
|
1271
|
-
import { createRequire as createRequire2 } from "module";
|
|
1272
|
-
import path11 from "path";
|
|
1273
|
-
import { pathToFileURL as pathToFileURL2 } from "url";
|
|
1274
1130
|
import { viteSingleFile } from "vite-plugin-singlefile";
|
|
1275
1131
|
import { toJSONSchema } from "zod";
|
|
1276
1132
|
|
|
1277
|
-
// src/commands/auth.ts
|
|
1278
|
-
init_esm_shims();
|
|
1279
|
-
init_open();
|
|
1280
|
-
|
|
1281
|
-
// src/utils/api.ts
|
|
1282
|
-
init_esm_shims();
|
|
1283
|
-
|
|
1284
1133
|
// src/utils/config.ts
|
|
1285
|
-
init_esm_shims();
|
|
1286
1134
|
import { promises as fs7 } from "fs";
|
|
1287
1135
|
import os3 from "os";
|
|
1288
1136
|
import path3 from "path";
|
|
@@ -1661,7 +1509,6 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1661
1509
|
};
|
|
1662
1510
|
|
|
1663
1511
|
// src/utils/errors.ts
|
|
1664
|
-
init_esm_shims();
|
|
1665
1512
|
function handleCommandError(error, context) {
|
|
1666
1513
|
if (error instanceof ApiUnauthorizedError) {
|
|
1667
1514
|
console.error(
|
|
@@ -1838,7 +1685,7 @@ async function loginCommand(options) {
|
|
|
1838
1685
|
}
|
|
1839
1686
|
await deleteConfig();
|
|
1840
1687
|
}
|
|
1841
|
-
console.log(source_default.cyan.bold("Logging in to
|
|
1688
|
+
console.log(source_default.cyan.bold("Logging in to Manufact cloud...\n"));
|
|
1842
1689
|
const authBaseUrl = await getAuthBaseUrl();
|
|
1843
1690
|
const deviceResp = await requestDeviceCode(authBaseUrl);
|
|
1844
1691
|
const {
|
|
@@ -2008,13 +1855,11 @@ async function whoamiCommand() {
|
|
|
2008
1855
|
}
|
|
2009
1856
|
|
|
2010
1857
|
// src/commands/client.ts
|
|
2011
|
-
init_esm_shims();
|
|
2012
1858
|
import { Command as Command2 } from "commander";
|
|
2013
1859
|
import { MCPClient as MCPClient3 } from "mcp-use/client";
|
|
2014
1860
|
import { createInterface as createInterface2 } from "readline";
|
|
2015
1861
|
|
|
2016
1862
|
// src/utils/format.ts
|
|
2017
|
-
init_esm_shims();
|
|
2018
1863
|
var ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
2019
1864
|
var GUTTER = " ";
|
|
2020
1865
|
var MIN_TRUNCATABLE_WIDTH = 8;
|
|
@@ -2123,8 +1968,11 @@ function formatJson(data, pretty = true) {
|
|
|
2123
1968
|
function formatToolCall(result) {
|
|
2124
1969
|
const lines = [];
|
|
2125
1970
|
const { isError, structuredContent } = result;
|
|
2126
|
-
const hasContent = !!result.content?.length;
|
|
2127
1971
|
const hasStructured = structuredContent !== void 0 && structuredContent !== null;
|
|
1972
|
+
const visibleContent = (result.content ?? []).filter(
|
|
1973
|
+
(item) => !hasStructured || item.type !== "text"
|
|
1974
|
+
);
|
|
1975
|
+
const hasVisibleContent = visibleContent.length > 0;
|
|
2128
1976
|
if (isError) {
|
|
2129
1977
|
lines.push(source_default.red("\u2717 Tool execution failed"));
|
|
2130
1978
|
lines.push("");
|
|
@@ -2132,12 +1980,12 @@ function formatToolCall(result) {
|
|
|
2132
1980
|
lines.push(source_default.green("\u2713 Tool executed successfully"));
|
|
2133
1981
|
lines.push("");
|
|
2134
1982
|
}
|
|
2135
|
-
if (
|
|
1983
|
+
if (hasVisibleContent) {
|
|
2136
1984
|
if (isError) {
|
|
2137
1985
|
lines.push(source_default.red.bold("Error details:"));
|
|
2138
1986
|
}
|
|
2139
|
-
|
|
2140
|
-
if (
|
|
1987
|
+
visibleContent.forEach((item, index) => {
|
|
1988
|
+
if (visibleContent.length > 1) {
|
|
2141
1989
|
lines.push(source_default.bold(`Content ${index + 1}:`));
|
|
2142
1990
|
}
|
|
2143
1991
|
if (item.type === "text") {
|
|
@@ -2158,19 +2006,18 @@ function formatToolCall(result) {
|
|
|
2158
2006
|
} else {
|
|
2159
2007
|
lines.push(source_default.gray(`[Unknown content type: ${item.type}]`));
|
|
2160
2008
|
}
|
|
2161
|
-
if (index <
|
|
2009
|
+
if (index < visibleContent.length - 1) {
|
|
2162
2010
|
lines.push("");
|
|
2163
2011
|
}
|
|
2164
2012
|
});
|
|
2165
2013
|
}
|
|
2166
2014
|
if (hasStructured) {
|
|
2167
|
-
if (
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
);
|
|
2015
|
+
if (isError) {
|
|
2016
|
+
lines.push(source_default.bold("Structured error data:"));
|
|
2017
|
+
}
|
|
2171
2018
|
lines.push(formatJson(structuredContent));
|
|
2172
2019
|
}
|
|
2173
|
-
if (isError && !
|
|
2020
|
+
if (isError && !hasVisibleContent && !hasStructured) {
|
|
2174
2021
|
lines.push(source_default.gray("(no error details provided by server)"));
|
|
2175
2022
|
}
|
|
2176
2023
|
return lines.join("\n");
|
|
@@ -2326,7 +2173,6 @@ function formatPromptMessages(messages) {
|
|
|
2326
2173
|
}
|
|
2327
2174
|
|
|
2328
2175
|
// src/utils/parse-args.ts
|
|
2329
|
-
init_esm_shims();
|
|
2330
2176
|
function parseToolArgs(rawArgs, inputSchema) {
|
|
2331
2177
|
if (!rawArgs || rawArgs.length === 0) return {};
|
|
2332
2178
|
if (rawArgs.length === 1) {
|
|
@@ -2456,7 +2302,6 @@ function parsePromptArgs(rawArgs) {
|
|
|
2456
2302
|
}
|
|
2457
2303
|
|
|
2458
2304
|
// src/utils/oauth.ts
|
|
2459
|
-
init_esm_shims();
|
|
2460
2305
|
import {
|
|
2461
2306
|
auth,
|
|
2462
2307
|
NodeOAuthClientProvider,
|
|
@@ -2471,22 +2316,15 @@ async function buildOAuthProvider(serverUrl, options = {}) {
|
|
|
2471
2316
|
storageKeyPrefix: "mcp:auth",
|
|
2472
2317
|
...options,
|
|
2473
2318
|
openBrowser: async (url) => {
|
|
2474
|
-
|
|
2475
|
-
console.error(`
|
|
2319
|
+
console.error(`
|
|
2476
2320
|
Open this URL in a browser to authenticate:`);
|
|
2477
|
-
|
|
2321
|
+
console.error(` ${url}
|
|
2478
2322
|
`);
|
|
2479
|
-
return;
|
|
2480
|
-
}
|
|
2481
|
-
const { default: open2 } = await Promise.resolve().then(() => (init_open(), open_exports));
|
|
2482
|
-
await open2(url);
|
|
2483
2323
|
}
|
|
2484
2324
|
});
|
|
2485
2325
|
}
|
|
2486
2326
|
async function runOAuthFlow(provider, serverUrl, print = console.error.bind(console)) {
|
|
2487
|
-
print(
|
|
2488
|
-
process.stdout.isTTY ? `\u2192 Opening browser to authenticate...` : `\u2192 OAuth authentication required.`
|
|
2489
|
-
);
|
|
2327
|
+
print(`\u2192 OAuth authentication required.`);
|
|
2490
2328
|
print(
|
|
2491
2329
|
` Listening on http://127.0.0.1:${provider.callbackPort}/callback (waiting up to 5m)`
|
|
2492
2330
|
);
|
|
@@ -2529,28 +2367,28 @@ async function promptYesNo(question, defaultYes = true) {
|
|
|
2529
2367
|
}
|
|
2530
2368
|
|
|
2531
2369
|
// src/utils/session-storage.ts
|
|
2532
|
-
init_esm_shims();
|
|
2533
2370
|
import { homedir } from "os";
|
|
2534
2371
|
import { join } from "path";
|
|
2535
2372
|
import { readFile, writeFile, mkdir } from "fs/promises";
|
|
2536
2373
|
import { existsSync } from "fs";
|
|
2537
2374
|
var SESSION_FILE_PATH = join(homedir(), ".mcp-use", "cli-sessions.json");
|
|
2375
|
+
var _dirEnsured = false;
|
|
2538
2376
|
async function ensureSessionDir() {
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
}
|
|
2377
|
+
if (_dirEnsured) return;
|
|
2378
|
+
await mkdir(join(homedir(), ".mcp-use"), { recursive: true });
|
|
2379
|
+
_dirEnsured = true;
|
|
2543
2380
|
}
|
|
2544
2381
|
async function loadSessions() {
|
|
2545
2382
|
try {
|
|
2546
2383
|
await ensureSessionDir();
|
|
2547
2384
|
if (!existsSync(SESSION_FILE_PATH)) {
|
|
2548
|
-
return {
|
|
2385
|
+
return { sessions: {} };
|
|
2549
2386
|
}
|
|
2550
2387
|
const content = await readFile(SESSION_FILE_PATH, "utf-8");
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2388
|
+
const parsed = JSON.parse(content);
|
|
2389
|
+
return { sessions: parsed?.sessions ?? {} };
|
|
2390
|
+
} catch {
|
|
2391
|
+
return { sessions: {} };
|
|
2554
2392
|
}
|
|
2555
2393
|
}
|
|
2556
2394
|
async function saveSessions(storage) {
|
|
@@ -2563,40 +2401,22 @@ async function saveSession(name, config) {
|
|
|
2563
2401
|
...config,
|
|
2564
2402
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
2565
2403
|
};
|
|
2566
|
-
if (!storage.activeSession) {
|
|
2567
|
-
storage.activeSession = name;
|
|
2568
|
-
}
|
|
2569
2404
|
await saveSessions(storage);
|
|
2570
2405
|
}
|
|
2571
|
-
async function
|
|
2406
|
+
async function removeSession(name) {
|
|
2572
2407
|
const storage = await loadSessions();
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
}
|
|
2576
|
-
return {
|
|
2577
|
-
name: storage.activeSession,
|
|
2578
|
-
config: storage.sessions[storage.activeSession]
|
|
2579
|
-
};
|
|
2408
|
+
delete storage.sessions[name];
|
|
2409
|
+
await saveSessions(storage);
|
|
2580
2410
|
}
|
|
2581
2411
|
async function getSession(name) {
|
|
2582
2412
|
const storage = await loadSessions();
|
|
2583
2413
|
return storage.sessions[name] || null;
|
|
2584
2414
|
}
|
|
2585
|
-
async function setActiveSession(name) {
|
|
2586
|
-
const storage = await loadSessions();
|
|
2587
|
-
if (!storage.sessions[name]) {
|
|
2588
|
-
throw new Error(`Session '${name}' not found`);
|
|
2589
|
-
}
|
|
2590
|
-
storage.activeSession = name;
|
|
2591
|
-
storage.sessions[name].lastUsed = (/* @__PURE__ */ new Date()).toISOString();
|
|
2592
|
-
await saveSessions(storage);
|
|
2593
|
-
}
|
|
2594
2415
|
async function listAllSessions() {
|
|
2595
2416
|
const storage = await loadSessions();
|
|
2596
2417
|
return Object.entries(storage.sessions).map(([name, config]) => ({
|
|
2597
2418
|
name,
|
|
2598
|
-
config
|
|
2599
|
-
isActive: name === storage.activeSession
|
|
2419
|
+
config
|
|
2600
2420
|
}));
|
|
2601
2421
|
}
|
|
2602
2422
|
async function updateSessionInfo(name, serverInfo, capabilities) {
|
|
@@ -2610,7 +2430,6 @@ async function updateSessionInfo(name, serverInfo, capabilities) {
|
|
|
2610
2430
|
}
|
|
2611
2431
|
|
|
2612
2432
|
// src/utils/session.ts
|
|
2613
|
-
init_esm_shims();
|
|
2614
2433
|
import { MCPClient } from "mcp-use/client";
|
|
2615
2434
|
import { getPackageVersion } from "mcp-use/server";
|
|
2616
2435
|
var activeSessions = /* @__PURE__ */ new Map();
|
|
@@ -2639,26 +2458,18 @@ async function cleanupAndExit(code) {
|
|
|
2639
2458
|
process.exit(code);
|
|
2640
2459
|
}
|
|
2641
2460
|
async function getOrRestoreSession(sessionName) {
|
|
2642
|
-
if (!sessionName) {
|
|
2643
|
-
const active = await getActiveSession();
|
|
2644
|
-
if (!active) {
|
|
2645
|
-
console.error(
|
|
2646
|
-
formatError("No active session. Connect to a server first.")
|
|
2647
|
-
);
|
|
2648
|
-
console.error(
|
|
2649
|
-
formatInfo("Use: npx mcp-use client connect <url> --name <name>")
|
|
2650
|
-
);
|
|
2651
|
-
return null;
|
|
2652
|
-
}
|
|
2653
|
-
sessionName = active.name;
|
|
2654
|
-
}
|
|
2655
2461
|
if (activeSessions.has(sessionName)) {
|
|
2656
2462
|
const { session } = activeSessions.get(sessionName);
|
|
2657
2463
|
return { name: sessionName, session };
|
|
2658
2464
|
}
|
|
2659
2465
|
const config = await getSession(sessionName);
|
|
2660
2466
|
if (!config) {
|
|
2661
|
-
console.error(formatError(`
|
|
2467
|
+
console.error(formatError(`Server '${sessionName}' not found`));
|
|
2468
|
+
console.error(
|
|
2469
|
+
formatInfo(
|
|
2470
|
+
`Connect with: npx mcp-use client connect ${sessionName} <url>`
|
|
2471
|
+
)
|
|
2472
|
+
);
|
|
2662
2473
|
return null;
|
|
2663
2474
|
}
|
|
2664
2475
|
try {
|
|
@@ -2697,14 +2508,14 @@ async function getOrRestoreSession(sessionName) {
|
|
|
2697
2508
|
} catch (err) {
|
|
2698
2509
|
if (config.type === "http" && config.authMode === "oauth" && authProvider && isUnauthorized(err)) {
|
|
2699
2510
|
const reAuth = await promptYesNo(
|
|
2700
|
-
`! Tokens for
|
|
2511
|
+
`! Tokens for server '${sessionName}' expired and could not refresh. Re-authenticate now?`,
|
|
2701
2512
|
true
|
|
2702
2513
|
);
|
|
2703
2514
|
if (!reAuth) {
|
|
2704
2515
|
console.error(formatError(`Tokens expired and could not refresh.`));
|
|
2705
2516
|
console.error(
|
|
2706
2517
|
formatInfo(
|
|
2707
|
-
`Run: mcp-use client connect ${
|
|
2518
|
+
`Run: mcp-use client connect ${sessionName} ${config.url}`
|
|
2708
2519
|
)
|
|
2709
2520
|
);
|
|
2710
2521
|
return null;
|
|
@@ -2716,39 +2527,28 @@ async function getOrRestoreSession(sessionName) {
|
|
|
2716
2527
|
}
|
|
2717
2528
|
}
|
|
2718
2529
|
activeSessions.set(sessionName, { client, session });
|
|
2719
|
-
console.error(formatInfo(`Reconnected to session '${sessionName}'`));
|
|
2720
2530
|
return { name: sessionName, session };
|
|
2721
2531
|
} catch (error) {
|
|
2722
|
-
console.error(formatError(`Failed to restore
|
|
2532
|
+
console.error(formatError(`Failed to restore server: ${error.message}`));
|
|
2723
2533
|
return null;
|
|
2724
2534
|
}
|
|
2725
2535
|
}
|
|
2726
2536
|
|
|
2727
2537
|
// src/commands/client-auth.ts
|
|
2728
|
-
|
|
2729
|
-
async function resolveSession(sessionArg) {
|
|
2730
|
-
let name = sessionArg;
|
|
2731
|
-
if (!name) {
|
|
2732
|
-
const active = await getActiveSession();
|
|
2733
|
-
if (!active) {
|
|
2734
|
-
console.error(formatError("No active session"));
|
|
2735
|
-
return null;
|
|
2736
|
-
}
|
|
2737
|
-
name = active.name;
|
|
2738
|
-
}
|
|
2538
|
+
async function resolveSession(name) {
|
|
2739
2539
|
const config = await getSession(name);
|
|
2740
2540
|
if (!config) {
|
|
2741
|
-
console.error(formatError(`
|
|
2541
|
+
console.error(formatError(`Server '${name}' not found`));
|
|
2742
2542
|
return null;
|
|
2743
2543
|
}
|
|
2744
2544
|
if (config.type !== "http") {
|
|
2745
|
-
console.error(formatError("Auth commands only apply to HTTP
|
|
2545
|
+
console.error(formatError("Auth commands only apply to HTTP servers"));
|
|
2746
2546
|
return null;
|
|
2747
2547
|
}
|
|
2748
2548
|
if (config.authMode !== "oauth") {
|
|
2749
2549
|
console.error(
|
|
2750
2550
|
formatError(
|
|
2751
|
-
`
|
|
2551
|
+
`Server '${name}' was not authenticated via OAuth (authMode=${config.authMode ?? "bearer"})`
|
|
2752
2552
|
)
|
|
2753
2553
|
);
|
|
2754
2554
|
return null;
|
|
@@ -2776,16 +2576,17 @@ function decodeJwtExp(token) {
|
|
|
2776
2576
|
return null;
|
|
2777
2577
|
}
|
|
2778
2578
|
}
|
|
2779
|
-
async function authStatusCommand(
|
|
2780
|
-
const target = await resolveSession(
|
|
2579
|
+
async function authStatusCommand(name) {
|
|
2580
|
+
const target = await resolveSession(name);
|
|
2781
2581
|
if (!target) {
|
|
2782
2582
|
process.exit(1);
|
|
2783
2583
|
}
|
|
2784
|
-
const
|
|
2584
|
+
const { name: serverName, url } = target;
|
|
2585
|
+
const provider = await buildOAuthProvider(url);
|
|
2785
2586
|
const tokens = await provider.tokens();
|
|
2786
2587
|
const fields = {
|
|
2787
|
-
|
|
2788
|
-
url
|
|
2588
|
+
server: serverName,
|
|
2589
|
+
url,
|
|
2789
2590
|
tokens: tokens?.access_token ? "present" : "missing"
|
|
2790
2591
|
};
|
|
2791
2592
|
if (tokens?.scope) fields.scope = tokens.scope;
|
|
@@ -2797,12 +2598,13 @@ async function authStatusCommand(sessionArg) {
|
|
|
2797
2598
|
console.log(formatKeyValue(fields));
|
|
2798
2599
|
if (!tokens?.access_token) process.exit(1);
|
|
2799
2600
|
}
|
|
2800
|
-
async function authRefreshCommand(
|
|
2801
|
-
const target = await resolveSession(
|
|
2601
|
+
async function authRefreshCommand(name) {
|
|
2602
|
+
const target = await resolveSession(name);
|
|
2802
2603
|
if (!target) {
|
|
2803
2604
|
process.exit(1);
|
|
2804
2605
|
}
|
|
2805
|
-
const
|
|
2606
|
+
const { name: serverName, url } = target;
|
|
2607
|
+
const provider = await buildOAuthProvider(url);
|
|
2806
2608
|
const refreshed = await provider.forceRefresh();
|
|
2807
2609
|
if (!refreshed) {
|
|
2808
2610
|
console.error(
|
|
@@ -2811,9 +2613,7 @@ async function authRefreshCommand(sessionArg) {
|
|
|
2811
2613
|
)
|
|
2812
2614
|
);
|
|
2813
2615
|
console.error(
|
|
2814
|
-
formatInfo(
|
|
2815
|
-
`Run: mcp-use client connect ${target.url} --name ${target.name}`
|
|
2816
|
-
)
|
|
2616
|
+
formatInfo(`Run: mcp-use client connect ${serverName} ${url}`)
|
|
2817
2617
|
);
|
|
2818
2618
|
process.exit(1);
|
|
2819
2619
|
}
|
|
@@ -2824,23 +2624,23 @@ async function authRefreshCommand(sessionArg) {
|
|
|
2824
2624
|
)
|
|
2825
2625
|
);
|
|
2826
2626
|
}
|
|
2827
|
-
async function authLogoutCommand(
|
|
2828
|
-
const target = await resolveSession(
|
|
2627
|
+
async function authLogoutCommand(name) {
|
|
2628
|
+
const target = await resolveSession(name);
|
|
2829
2629
|
if (!target) {
|
|
2830
2630
|
process.exit(1);
|
|
2831
2631
|
}
|
|
2832
|
-
const
|
|
2632
|
+
const { name: serverName, url } = target;
|
|
2633
|
+
const provider = await buildOAuthProvider(url);
|
|
2833
2634
|
await provider.invalidateCredentials("all");
|
|
2834
|
-
console.log(formatSuccess(`Removed tokens for ${
|
|
2635
|
+
console.log(formatSuccess(`Removed tokens for ${url}`));
|
|
2835
2636
|
console.log(
|
|
2836
2637
|
formatInfo(
|
|
2837
|
-
`
|
|
2638
|
+
`Server '${serverName}' kept; reconnect with \`mcp-use client connect\`.`
|
|
2838
2639
|
)
|
|
2839
2640
|
);
|
|
2840
2641
|
}
|
|
2841
2642
|
|
|
2842
2643
|
// src/commands/screenshot.ts
|
|
2843
|
-
init_esm_shims();
|
|
2844
2644
|
import { Command } from "commander";
|
|
2845
2645
|
import { MCPClient as MCPClient2 } from "mcp-use/client";
|
|
2846
2646
|
import { spawn as spawn2 } from "child_process";
|
|
@@ -2850,7 +2650,6 @@ import { createServer } from "net";
|
|
|
2850
2650
|
import path6 from "path";
|
|
2851
2651
|
|
|
2852
2652
|
// src/utils/cdp-screenshot.ts
|
|
2853
|
-
init_esm_shims();
|
|
2854
2653
|
import { spawn } from "child_process";
|
|
2855
2654
|
import { mkdtempSync, rmSync, writeFileSync } from "fs";
|
|
2856
2655
|
import os4 from "os";
|
|
@@ -3067,7 +2866,7 @@ async function captureScreenshot(opts) {
|
|
|
3067
2866
|
{
|
|
3068
2867
|
width: opts.width,
|
|
3069
2868
|
height: opts.height,
|
|
3070
|
-
deviceScaleFactor: 1,
|
|
2869
|
+
deviceScaleFactor: opts.deviceScaleFactor ?? 1,
|
|
3071
2870
|
mobile: false
|
|
3072
2871
|
},
|
|
3073
2872
|
sessionId
|
|
@@ -3137,7 +2936,6 @@ async function captureScreenshot(opts) {
|
|
|
3137
2936
|
}
|
|
3138
2937
|
|
|
3139
2938
|
// src/utils/chrome-path.ts
|
|
3140
|
-
init_esm_shims();
|
|
3141
2939
|
import { accessSync, constants } from "fs";
|
|
3142
2940
|
import path5 from "path";
|
|
3143
2941
|
var ENV_VAR_NAMES = [
|
|
@@ -3303,7 +3101,8 @@ async function captureToolScreenshot(inputs, options = {}) {
|
|
|
3303
3101
|
chromePath,
|
|
3304
3102
|
cdpUrl: options.cdpUrl,
|
|
3305
3103
|
delayMs: Number.isFinite(delayMs) && delayMs > 0 ? delayMs : 0,
|
|
3306
|
-
bundle
|
|
3104
|
+
bundle,
|
|
3105
|
+
deviceScaleFactor: options.deviceScaleFactor
|
|
3307
3106
|
});
|
|
3308
3107
|
return { outputPath, width, height, view };
|
|
3309
3108
|
} finally {
|
|
@@ -3446,11 +3245,30 @@ function parseDimension(raw, name) {
|
|
|
3446
3245
|
}
|
|
3447
3246
|
return n;
|
|
3448
3247
|
}
|
|
3248
|
+
function parseDeviceScaleFactor(raw) {
|
|
3249
|
+
const n = parseFloat(raw);
|
|
3250
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
3251
|
+
throw new Error(
|
|
3252
|
+
`--device-scale-factor must be a positive number (got "${raw}")`
|
|
3253
|
+
);
|
|
3254
|
+
}
|
|
3255
|
+
if (n > 4) {
|
|
3256
|
+
throw new Error(
|
|
3257
|
+
`--device-scale-factor must be <= 4 to avoid excessive pixel counts (got "${raw}")`
|
|
3258
|
+
);
|
|
3259
|
+
}
|
|
3260
|
+
return n;
|
|
3261
|
+
}
|
|
3262
|
+
function requiresArguments(inputSchema) {
|
|
3263
|
+
if (!inputSchema || typeof inputSchema !== "object") return false;
|
|
3264
|
+
const required = inputSchema.required;
|
|
3265
|
+
return Array.isArray(required) && required.length > 0;
|
|
3266
|
+
}
|
|
3449
3267
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3450
|
-
async function resolveSessionForScreenshot(options, headers) {
|
|
3451
|
-
if (
|
|
3452
|
-
const
|
|
3453
|
-
return
|
|
3268
|
+
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3269
|
+
if (sessionName) {
|
|
3270
|
+
const result = await getOrRestoreSession(sessionName);
|
|
3271
|
+
return result?.session ?? null;
|
|
3454
3272
|
}
|
|
3455
3273
|
if (options.mcp) {
|
|
3456
3274
|
const client = new MCPClient2();
|
|
@@ -3469,10 +3287,14 @@ async function resolveSessionForScreenshot(options, headers) {
|
|
|
3469
3287
|
return null;
|
|
3470
3288
|
}
|
|
3471
3289
|
}
|
|
3472
|
-
|
|
3473
|
-
|
|
3290
|
+
console.error(
|
|
3291
|
+
formatError(
|
|
3292
|
+
"No MCP target. Pass --mcp <url> for an ad-hoc connection, or use `mcp-use client <name> screenshot` for a saved server."
|
|
3293
|
+
)
|
|
3294
|
+
);
|
|
3295
|
+
return null;
|
|
3474
3296
|
}
|
|
3475
|
-
async function screenshotCommand(options, argsList) {
|
|
3297
|
+
async function screenshotCommand(options, argsList, context) {
|
|
3476
3298
|
let exitCode = 0;
|
|
3477
3299
|
try {
|
|
3478
3300
|
if (!options.tool) {
|
|
@@ -3489,7 +3311,7 @@ async function screenshotCommand(options, argsList) {
|
|
|
3489
3311
|
if (!options.mcp) {
|
|
3490
3312
|
console.error(
|
|
3491
3313
|
formatError(
|
|
3492
|
-
"--header is only supported with --mcp <url>. Saved
|
|
3314
|
+
"--header is only supported with --mcp <url>. Saved servers carry their own auth from `mcp-use client connect`."
|
|
3493
3315
|
)
|
|
3494
3316
|
);
|
|
3495
3317
|
exitCode = 1;
|
|
@@ -3518,7 +3340,12 @@ async function screenshotCommand(options, argsList) {
|
|
|
3518
3340
|
const height = parseDimension(options.height, "height");
|
|
3519
3341
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3520
3342
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3521
|
-
const
|
|
3343
|
+
const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
|
|
3344
|
+
const session = await resolveSessionForScreenshot(
|
|
3345
|
+
options,
|
|
3346
|
+
context.sessionName,
|
|
3347
|
+
headers
|
|
3348
|
+
);
|
|
3522
3349
|
if (!session) {
|
|
3523
3350
|
exitCode = 1;
|
|
3524
3351
|
return;
|
|
@@ -3549,13 +3376,13 @@ async function screenshotCommand(options, argsList) {
|
|
|
3549
3376
|
console.log("");
|
|
3550
3377
|
console.log(formatInfo("Usage:"));
|
|
3551
3378
|
console.log(
|
|
3552
|
-
` npx
|
|
3379
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3553
3380
|
);
|
|
3554
3381
|
console.log(
|
|
3555
|
-
` npx
|
|
3382
|
+
` npx ${context.usagePrefix} --tool ${options.tool} nested:='{"a":1}' # JSON value`
|
|
3556
3383
|
);
|
|
3557
3384
|
console.log(
|
|
3558
|
-
` npx
|
|
3385
|
+
` npx ${context.usagePrefix} --tool ${options.tool} '{"key":"value"}' # full JSON object`
|
|
3559
3386
|
);
|
|
3560
3387
|
if (tool.inputSchema) {
|
|
3561
3388
|
console.log("");
|
|
@@ -3565,6 +3392,18 @@ async function screenshotCommand(options, argsList) {
|
|
|
3565
3392
|
exitCode = 1;
|
|
3566
3393
|
return;
|
|
3567
3394
|
}
|
|
3395
|
+
} else if (requiresArguments(tool.inputSchema)) {
|
|
3396
|
+
console.error(formatError("This tool requires arguments."));
|
|
3397
|
+
console.log("");
|
|
3398
|
+
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3399
|
+
console.log(
|
|
3400
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3401
|
+
);
|
|
3402
|
+
console.log("");
|
|
3403
|
+
console.log(formatInfo("Tool schema:"));
|
|
3404
|
+
console.log(formatSchema(tool.inputSchema));
|
|
3405
|
+
exitCode = 1;
|
|
3406
|
+
return;
|
|
3568
3407
|
}
|
|
3569
3408
|
const toolOutput = await session.callTool(options.tool, toolArgs);
|
|
3570
3409
|
const result = await captureToolScreenshot(
|
|
@@ -3585,7 +3424,8 @@ async function screenshotCommand(options, argsList) {
|
|
|
3585
3424
|
timeoutMs: navTimeout,
|
|
3586
3425
|
inspector: options.inspector,
|
|
3587
3426
|
quiet: options.quiet,
|
|
3588
|
-
cdpUrl: options.cdpUrl
|
|
3427
|
+
cdpUrl: options.cdpUrl,
|
|
3428
|
+
deviceScaleFactor
|
|
3589
3429
|
}
|
|
3590
3430
|
);
|
|
3591
3431
|
console.log(
|
|
@@ -3599,29 +3439,19 @@ async function screenshotCommand(options, argsList) {
|
|
|
3599
3439
|
await cleanupAndExit(exitCode);
|
|
3600
3440
|
}
|
|
3601
3441
|
}
|
|
3602
|
-
function
|
|
3603
|
-
return
|
|
3604
|
-
"Render an MCP Apps view headlessly and save a PNG by calling a tool and rendering its UI resource with the result."
|
|
3605
|
-
).argument(
|
|
3442
|
+
function withCommonScreenshotOptions(cmd) {
|
|
3443
|
+
return cmd.argument(
|
|
3606
3444
|
"[args...]",
|
|
3607
3445
|
"Tool args as key=value pairs (use key:=<json> for nested values, or pass a single JSON object)."
|
|
3608
3446
|
).option(
|
|
3609
3447
|
"--tool <name>",
|
|
3610
3448
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3611
3449
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3612
|
-
"--
|
|
3613
|
-
"
|
|
3614
|
-
).option(
|
|
3615
|
-
"--session <name>",
|
|
3616
|
-
"Saved session name (from `mcp-use client connect`). Defaults to the active session."
|
|
3617
|
-
).option(
|
|
3618
|
-
"--mcp <url>",
|
|
3619
|
-
"Ad-hoc MCP server URL (escape hatch). Used only when no --session and no active saved session. No authentication unless --header is supplied."
|
|
3450
|
+
"--device-scale-factor <n>",
|
|
3451
|
+
"Device pixel ratio for rendering (e.g. 2 for Retina). Output PNG is (width \xD7 dsf) \xD7 (height \xD7 dsf). Must be > 0 and <= 4."
|
|
3620
3452
|
).option(
|
|
3621
|
-
"
|
|
3622
|
-
|
|
3623
|
-
collectHeader,
|
|
3624
|
-
[]
|
|
3453
|
+
"--inspector <url>",
|
|
3454
|
+
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3625
3455
|
).option(
|
|
3626
3456
|
"--theme <light|dark>",
|
|
3627
3457
|
"Color scheme to render the view in.",
|
|
@@ -3639,20 +3469,124 @@ function createScreenshotCommand() {
|
|
|
3639
3469
|
).option("--timeout <ms>", "Navigation + readiness timeout in ms.", "30000").option(
|
|
3640
3470
|
"--cdp-url <url>",
|
|
3641
3471
|
"Connect to an existing CDP WebSocket (ws:// or wss://) instead of spawning local Chrome. Useful for hosted browsers like Notte."
|
|
3642
|
-
).option("--quiet", "Suppress dev-server output.")
|
|
3643
|
-
|
|
3472
|
+
).option("--quiet", "Suppress dev-server output.");
|
|
3473
|
+
}
|
|
3474
|
+
function createClientScreenshotCommand() {
|
|
3475
|
+
const cmd = withCommonScreenshotOptions(
|
|
3476
|
+
new Command("screenshot").description(
|
|
3477
|
+
"Render an MCP Apps view headlessly and save a PNG. Connects to an MCP server inline via --mcp; for a saved server, use `mcp-use client <name> screenshot`."
|
|
3478
|
+
)
|
|
3479
|
+
).option(
|
|
3480
|
+
"--mcp <url>",
|
|
3481
|
+
"Ad-hoc MCP server URL. Required for the top-level form. No authentication unless --header is supplied."
|
|
3482
|
+
).option(
|
|
3483
|
+
"-H, --header <header>",
|
|
3484
|
+
'HTTP header to send to the --mcp <url> server, formatted "Key: Value". Repeatable. Use to pass an Authorization bearer token or other auth headers when screenshotting an authenticated MCP server.',
|
|
3485
|
+
collectHeader,
|
|
3486
|
+
[]
|
|
3487
|
+
);
|
|
3488
|
+
cmd.action(async (args, opts) => {
|
|
3489
|
+
await screenshotCommand(opts, args, {
|
|
3490
|
+
usagePrefix: "mcp-use client screenshot"
|
|
3491
|
+
});
|
|
3492
|
+
});
|
|
3493
|
+
return cmd;
|
|
3494
|
+
}
|
|
3495
|
+
function createPerClientScreenshotCommand(name) {
|
|
3496
|
+
const cmd = withCommonScreenshotOptions(
|
|
3497
|
+
new Command("screenshot").description(
|
|
3498
|
+
`Render an MCP Apps view headlessly using the saved server '${name}'.`
|
|
3499
|
+
)
|
|
3500
|
+
);
|
|
3501
|
+
cmd.action(async (args, opts) => {
|
|
3502
|
+
await screenshotCommand(opts, args, {
|
|
3503
|
+
sessionName: name,
|
|
3504
|
+
usagePrefix: `mcp-use client ${name} screenshot`
|
|
3505
|
+
});
|
|
3644
3506
|
});
|
|
3507
|
+
return cmd;
|
|
3645
3508
|
}
|
|
3646
3509
|
|
|
3647
3510
|
// src/commands/client.ts
|
|
3648
|
-
|
|
3511
|
+
var RESERVED_CLIENT_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
3512
|
+
"connect",
|
|
3513
|
+
"list",
|
|
3514
|
+
"remove",
|
|
3515
|
+
"screenshot",
|
|
3516
|
+
"help"
|
|
3517
|
+
]);
|
|
3518
|
+
var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
|
|
3519
|
+
"tools",
|
|
3520
|
+
"resources",
|
|
3521
|
+
"prompts",
|
|
3522
|
+
"auth",
|
|
3523
|
+
"disconnect",
|
|
3524
|
+
"interactive",
|
|
3525
|
+
"screenshot"
|
|
3526
|
+
]);
|
|
3527
|
+
async function connectCommand(name, urlOrCommand, options) {
|
|
3528
|
+
if (!name || !urlOrCommand) {
|
|
3529
|
+
const looksLikeUrl = !!name && /^https?:\/\//i.test(name);
|
|
3530
|
+
if (looksLikeUrl && !urlOrCommand && !options.stdio) {
|
|
3531
|
+
console.error(formatError("Missing server name."));
|
|
3532
|
+
console.error("");
|
|
3533
|
+
console.error(
|
|
3534
|
+
formatInfo(
|
|
3535
|
+
"Each saved server needs a short name you'll use to address it later."
|
|
3536
|
+
)
|
|
3537
|
+
);
|
|
3538
|
+
console.error("");
|
|
3539
|
+
console.error("Try:");
|
|
3540
|
+
console.error(` mcp-use client connect <name> ${name}`);
|
|
3541
|
+
console.error("");
|
|
3542
|
+
console.error("Example:");
|
|
3543
|
+
console.error(` mcp-use client connect my-server ${name}`);
|
|
3544
|
+
console.error(" mcp-use client my-server tools list");
|
|
3545
|
+
} else if (name && !urlOrCommand) {
|
|
3546
|
+
console.error(
|
|
3547
|
+
formatError(options.stdio ? "Missing <command>." : "Missing <url>.")
|
|
3548
|
+
);
|
|
3549
|
+
console.error("");
|
|
3550
|
+
console.error(formatInfo("Usage:"));
|
|
3551
|
+
console.error(
|
|
3552
|
+
options.stdio ? ` mcp-use client connect ${name} "<command>" --stdio` : ` mcp-use client connect ${name} <url>`
|
|
3553
|
+
);
|
|
3554
|
+
} else {
|
|
3555
|
+
console.error(formatError("Missing required arguments: <name> <url>."));
|
|
3556
|
+
console.error("");
|
|
3557
|
+
console.error(formatInfo("Usage:"));
|
|
3558
|
+
console.error(" mcp-use client connect <name> <url>");
|
|
3559
|
+
console.error("");
|
|
3560
|
+
console.error("Example:");
|
|
3561
|
+
console.error(
|
|
3562
|
+
" mcp-use client connect manufact https://mcp.manufact.com/mcp"
|
|
3563
|
+
);
|
|
3564
|
+
}
|
|
3565
|
+
await cleanupAndExit(1);
|
|
3566
|
+
}
|
|
3567
|
+
const sessionName = name;
|
|
3568
|
+
const target = urlOrCommand;
|
|
3569
|
+
if (PER_CLIENT_SCOPES.has(sessionName)) {
|
|
3570
|
+
console.error(
|
|
3571
|
+
formatError(
|
|
3572
|
+
`'${sessionName}' is a reserved name and can't be used for a saved server.`
|
|
3573
|
+
)
|
|
3574
|
+
);
|
|
3575
|
+
console.error("");
|
|
3576
|
+
console.error(
|
|
3577
|
+
`Reserved names: ${Array.from(PER_CLIENT_SCOPES).sort().join(", ")}`
|
|
3578
|
+
);
|
|
3579
|
+
console.error("");
|
|
3580
|
+
console.error("Pick a different name, e.g.:");
|
|
3581
|
+
console.error(` mcp-use client connect my-${sessionName} ${target}`);
|
|
3582
|
+
await cleanupAndExit(1);
|
|
3583
|
+
}
|
|
3649
3584
|
try {
|
|
3650
|
-
const sessionName = options.name || `session-${Date.now()}`;
|
|
3651
3585
|
const client = new MCPClient3();
|
|
3652
3586
|
let session;
|
|
3653
3587
|
const cliClientInfo = getCliClientInfo();
|
|
3654
3588
|
if (options.stdio) {
|
|
3655
|
-
const parts =
|
|
3589
|
+
const parts = target.split(" ");
|
|
3656
3590
|
const command = parts[0];
|
|
3657
3591
|
const args = parts.slice(1);
|
|
3658
3592
|
console.error(
|
|
@@ -3671,17 +3605,17 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3671
3605
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
3672
3606
|
});
|
|
3673
3607
|
} else {
|
|
3674
|
-
console.error(formatInfo(`Connecting to ${
|
|
3608
|
+
console.error(formatInfo(`Connecting to ${target}...`));
|
|
3675
3609
|
const wantOAuth = !options.auth && options.oauth !== false;
|
|
3676
3610
|
let authProvider;
|
|
3677
3611
|
if (wantOAuth) {
|
|
3678
3612
|
const authTimeoutMs = options.authTimeout ? Number.parseInt(options.authTimeout, 10) : void 0;
|
|
3679
|
-
authProvider = await buildOAuthProvider(
|
|
3613
|
+
authProvider = await buildOAuthProvider(target, {
|
|
3680
3614
|
...authTimeoutMs ? { authTimeoutMs } : {}
|
|
3681
3615
|
});
|
|
3682
3616
|
}
|
|
3683
3617
|
client.addServer(sessionName, {
|
|
3684
|
-
url:
|
|
3618
|
+
url: target,
|
|
3685
3619
|
...authProvider ? { authProvider } : options.auth ? { headers: { Authorization: `Bearer ${options.auth}` } } : {},
|
|
3686
3620
|
clientInfo: cliClientInfo
|
|
3687
3621
|
});
|
|
@@ -3694,7 +3628,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3694
3628
|
"Server requires authentication. Starting OAuth flow."
|
|
3695
3629
|
)
|
|
3696
3630
|
);
|
|
3697
|
-
await runOAuthFlow(authProvider,
|
|
3631
|
+
await runOAuthFlow(authProvider, target);
|
|
3698
3632
|
console.error(formatSuccess("Authentication successful"));
|
|
3699
3633
|
session = await client.createSession(sessionName);
|
|
3700
3634
|
} else {
|
|
@@ -3703,7 +3637,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3703
3637
|
}
|
|
3704
3638
|
await saveSession(sessionName, {
|
|
3705
3639
|
type: "http",
|
|
3706
|
-
url:
|
|
3640
|
+
url: target,
|
|
3707
3641
|
authMode: authProvider ? "oauth" : options.auth ? "bearer" : void 0,
|
|
3708
3642
|
authToken: authProvider ? void 0 : options.auth,
|
|
3709
3643
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3715,7 +3649,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3715
3649
|
if (serverInfo) {
|
|
3716
3650
|
await updateSessionInfo(sessionName, serverInfo, capabilities);
|
|
3717
3651
|
}
|
|
3718
|
-
console.log(formatSuccess(`Connected
|
|
3652
|
+
console.log(formatSuccess(`Connected as '${sessionName}'`));
|
|
3719
3653
|
if (serverInfo) {
|
|
3720
3654
|
console.log("");
|
|
3721
3655
|
console.log(formatHeader("Server Information:"));
|
|
@@ -3745,31 +3679,15 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3745
3679
|
}
|
|
3746
3680
|
await cleanupAndExit(0);
|
|
3747
3681
|
}
|
|
3748
|
-
async function disconnectCommand(
|
|
3682
|
+
async function disconnectCommand(name) {
|
|
3749
3683
|
try {
|
|
3750
|
-
|
|
3751
|
-
for (const [name, { client }] of activeSessions.entries()) {
|
|
3752
|
-
await client.closeAllSessions();
|
|
3753
|
-
activeSessions.delete(name);
|
|
3754
|
-
console.log(formatSuccess(`Disconnected from ${name}`));
|
|
3755
|
-
}
|
|
3756
|
-
await cleanupAndExit(0);
|
|
3757
|
-
}
|
|
3758
|
-
if (!sessionName) {
|
|
3759
|
-
const active = await getActiveSession();
|
|
3760
|
-
if (!active) {
|
|
3761
|
-
console.error(formatError("No active session to disconnect"));
|
|
3762
|
-
await cleanupAndExit(0);
|
|
3763
|
-
}
|
|
3764
|
-
sessionName = active.name;
|
|
3765
|
-
}
|
|
3766
|
-
const sessionData = activeSessions.get(sessionName);
|
|
3684
|
+
const sessionData = activeSessions.get(name);
|
|
3767
3685
|
if (sessionData) {
|
|
3768
3686
|
await sessionData.client.closeAllSessions();
|
|
3769
|
-
activeSessions.delete(
|
|
3770
|
-
console.log(formatSuccess(`Disconnected from ${
|
|
3687
|
+
activeSessions.delete(name);
|
|
3688
|
+
console.log(formatSuccess(`Disconnected from ${name}`));
|
|
3771
3689
|
} else {
|
|
3772
|
-
console.log(formatInfo(`
|
|
3690
|
+
console.log(formatInfo(`Server '${name}' is not connected`));
|
|
3773
3691
|
}
|
|
3774
3692
|
} catch (error) {
|
|
3775
3693
|
console.error(formatError(`Failed to disconnect: ${error.message}`));
|
|
@@ -3777,15 +3695,63 @@ async function disconnectCommand(sessionName, options) {
|
|
|
3777
3695
|
}
|
|
3778
3696
|
await cleanupAndExit(0);
|
|
3779
3697
|
}
|
|
3780
|
-
async function
|
|
3698
|
+
async function removeClientCommand(name) {
|
|
3699
|
+
try {
|
|
3700
|
+
const config = await getSession(name);
|
|
3701
|
+
if (!config) {
|
|
3702
|
+
console.error(formatError(`Server '${name}' not found`));
|
|
3703
|
+
console.error("");
|
|
3704
|
+
console.error("See your saved servers with:");
|
|
3705
|
+
console.error(" mcp-use client list");
|
|
3706
|
+
await cleanupAndExit(1);
|
|
3707
|
+
}
|
|
3708
|
+
const sessionData = activeSessions.get(name);
|
|
3709
|
+
if (sessionData) {
|
|
3710
|
+
await sessionData.client.closeAllSessions();
|
|
3711
|
+
activeSessions.delete(name);
|
|
3712
|
+
}
|
|
3713
|
+
const isOAuthHttp = config.type === "http" && config.authMode === "oauth" && typeof config.url === "string";
|
|
3714
|
+
const sharedUrlSibling = isOAuthHttp ? (await listAllSessions()).find(
|
|
3715
|
+
(s) => s.name !== name && s.config.type === "http" && s.config.url === config.url
|
|
3716
|
+
) : void 0;
|
|
3717
|
+
await removeSession(name);
|
|
3718
|
+
console.log(formatSuccess(`Removed saved server '${name}'`));
|
|
3719
|
+
if (isOAuthHttp) {
|
|
3720
|
+
if (sharedUrlSibling) {
|
|
3721
|
+
console.log(
|
|
3722
|
+
formatInfo(
|
|
3723
|
+
`OAuth tokens for ${config.url} were kept because saved server '${sharedUrlSibling.name}' still uses that URL.`
|
|
3724
|
+
)
|
|
3725
|
+
);
|
|
3726
|
+
} else {
|
|
3727
|
+
try {
|
|
3728
|
+
const provider = await buildOAuthProvider(config.url);
|
|
3729
|
+
await provider.invalidateCredentials("all");
|
|
3730
|
+
console.log(formatInfo(`Removed OAuth tokens for ${config.url}`));
|
|
3731
|
+
} catch (error) {
|
|
3732
|
+
console.error(
|
|
3733
|
+
formatWarning(
|
|
3734
|
+
`Saved entry removed, but failed to clear OAuth tokens for ${config.url}: ${error.message}`
|
|
3735
|
+
)
|
|
3736
|
+
);
|
|
3737
|
+
}
|
|
3738
|
+
}
|
|
3739
|
+
}
|
|
3740
|
+
} catch (error) {
|
|
3741
|
+
console.error(formatError(`Failed to remove server: ${error.message}`));
|
|
3742
|
+
await cleanupAndExit(1);
|
|
3743
|
+
}
|
|
3744
|
+
await cleanupAndExit(0);
|
|
3745
|
+
}
|
|
3746
|
+
async function listClientsCommand() {
|
|
3781
3747
|
try {
|
|
3782
3748
|
const sessions = await listAllSessions();
|
|
3783
3749
|
if (sessions.length === 0) {
|
|
3784
3750
|
if (isStdoutTty()) {
|
|
3785
|
-
console.log(formatInfo("No saved
|
|
3751
|
+
console.log(formatInfo("No saved servers"));
|
|
3786
3752
|
console.log(
|
|
3787
3753
|
formatInfo(
|
|
3788
|
-
"Connect to a server with: npx mcp-use client connect <url>"
|
|
3754
|
+
"Connect to a server with: npx mcp-use client connect <name> <url>"
|
|
3789
3755
|
)
|
|
3790
3756
|
);
|
|
3791
3757
|
}
|
|
@@ -3793,11 +3759,11 @@ async function listSessionsCommand() {
|
|
|
3793
3759
|
}
|
|
3794
3760
|
const tty2 = isStdoutTty();
|
|
3795
3761
|
if (tty2) {
|
|
3796
|
-
console.log(formatHeader("Saved
|
|
3762
|
+
console.log(formatHeader("Saved Servers:"));
|
|
3797
3763
|
console.log("");
|
|
3798
3764
|
}
|
|
3799
3765
|
const tableData = sessions.map((s) => ({
|
|
3800
|
-
name: s.
|
|
3766
|
+
name: s.name,
|
|
3801
3767
|
type: s.config.type,
|
|
3802
3768
|
target: s.config.type === "http" ? s.config.url || "" : `${s.config.command} ${(s.config.args || []).join(" ")}`,
|
|
3803
3769
|
server: s.config.serverInfo?.name || "unknown"
|
|
@@ -3810,29 +3776,15 @@ async function listSessionsCommand() {
|
|
|
3810
3776
|
{ key: "server", header: "Server" }
|
|
3811
3777
|
])
|
|
3812
3778
|
);
|
|
3813
|
-
if (tty2) {
|
|
3814
|
-
console.log("");
|
|
3815
|
-
console.log(source_default.gray("* = active session"));
|
|
3816
|
-
}
|
|
3817
3779
|
} catch (error) {
|
|
3818
|
-
console.error(formatError(`Failed to list
|
|
3780
|
+
console.error(formatError(`Failed to list servers: ${error.message}`));
|
|
3819
3781
|
await cleanupAndExit(1);
|
|
3820
3782
|
}
|
|
3821
3783
|
await cleanupAndExit(0);
|
|
3822
3784
|
}
|
|
3823
|
-
async function
|
|
3785
|
+
async function listToolsCommand(name, options) {
|
|
3824
3786
|
try {
|
|
3825
|
-
await
|
|
3826
|
-
console.log(formatSuccess(`Switched to session '${name}'`));
|
|
3827
|
-
} catch (error) {
|
|
3828
|
-
console.error(formatError(`Failed to switch session: ${error.message}`));
|
|
3829
|
-
await cleanupAndExit(1);
|
|
3830
|
-
}
|
|
3831
|
-
await cleanupAndExit(0);
|
|
3832
|
-
}
|
|
3833
|
-
async function listToolsCommand(options) {
|
|
3834
|
-
try {
|
|
3835
|
-
const result = await getOrRestoreSession(options.session || null);
|
|
3787
|
+
const result = await getOrRestoreSession(name);
|
|
3836
3788
|
if (!result) {
|
|
3837
3789
|
await cleanupAndExit(1);
|
|
3838
3790
|
}
|
|
@@ -3884,9 +3836,9 @@ async function listToolsCommand(options) {
|
|
|
3884
3836
|
}
|
|
3885
3837
|
await cleanupAndExit(0);
|
|
3886
3838
|
}
|
|
3887
|
-
async function describeToolCommand(
|
|
3839
|
+
async function describeToolCommand(name, toolName) {
|
|
3888
3840
|
try {
|
|
3889
|
-
const result = await getOrRestoreSession(
|
|
3841
|
+
const result = await getOrRestoreSession(name);
|
|
3890
3842
|
if (!result) {
|
|
3891
3843
|
await cleanupAndExit(1);
|
|
3892
3844
|
}
|
|
@@ -3916,9 +3868,9 @@ async function describeToolCommand(toolName, options) {
|
|
|
3916
3868
|
}
|
|
3917
3869
|
await cleanupAndExit(0);
|
|
3918
3870
|
}
|
|
3919
|
-
async function callToolCommand(toolName, argsList, options) {
|
|
3871
|
+
async function callToolCommand(name, toolName, argsList, options) {
|
|
3920
3872
|
try {
|
|
3921
|
-
const result = await getOrRestoreSession(
|
|
3873
|
+
const result = await getOrRestoreSession(name);
|
|
3922
3874
|
if (!result) {
|
|
3923
3875
|
await cleanupAndExit(1);
|
|
3924
3876
|
}
|
|
@@ -3934,13 +3886,13 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3934
3886
|
console.log("");
|
|
3935
3887
|
console.log(formatInfo("Usage:"));
|
|
3936
3888
|
console.log(
|
|
3937
|
-
` npx mcp-use client tools call ${toolName} key=value [key2=value2 ...]`
|
|
3889
|
+
` npx mcp-use client ${name} tools call ${toolName} key=value [key2=value2 ...]`
|
|
3938
3890
|
);
|
|
3939
3891
|
console.log(
|
|
3940
|
-
` npx mcp-use client tools call ${toolName} nested:='{"a":1}' # JSON value`
|
|
3892
|
+
` npx mcp-use client ${name} tools call ${toolName} nested:='{"a":1}' # JSON value`
|
|
3941
3893
|
);
|
|
3942
3894
|
console.log(
|
|
3943
|
-
` npx mcp-use client tools call ${toolName} '{"key":"value"}' # full JSON object`
|
|
3895
|
+
` npx mcp-use client ${name} tools call ${toolName} '{"key":"value"}' # full JSON object`
|
|
3944
3896
|
);
|
|
3945
3897
|
if (tool?.inputSchema) {
|
|
3946
3898
|
console.log("");
|
|
@@ -3954,7 +3906,7 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3954
3906
|
console.log("");
|
|
3955
3907
|
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3956
3908
|
console.log(
|
|
3957
|
-
` npx mcp-use client tools call ${toolName} key=value [key2=value2 ...]`
|
|
3909
|
+
` npx mcp-use client ${name} tools call ${toolName} key=value [key2=value2 ...]`
|
|
3958
3910
|
);
|
|
3959
3911
|
console.log("");
|
|
3960
3912
|
console.log(formatInfo("Tool schema:"));
|
|
@@ -3965,16 +3917,27 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3965
3917
|
const callResult = await session.callTool(toolName, args, {
|
|
3966
3918
|
timeout: options?.timeout
|
|
3967
3919
|
});
|
|
3920
|
+
const toolWithMeta = session.tools.find((t) => t.name === toolName);
|
|
3921
|
+
const resourceUri = detectToolResourceUri(toolWithMeta);
|
|
3922
|
+
const wantsScreenshot = options?.screenshot === true || options?.screenshotOutput !== void 0 || options?.screenshotDeviceScaleFactor !== void 0;
|
|
3968
3923
|
let screenshot = null;
|
|
3969
3924
|
let screenshotError = null;
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
if (resourceUri) {
|
|
3925
|
+
let widgetHintUri = null;
|
|
3926
|
+
if (resourceUri) {
|
|
3927
|
+
if (wantsScreenshot) {
|
|
3974
3928
|
console.error(
|
|
3975
3929
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3976
3930
|
);
|
|
3977
3931
|
try {
|
|
3932
|
+
const screenshotOpts = {};
|
|
3933
|
+
if (options?.screenshotOutput) {
|
|
3934
|
+
screenshotOpts.output = options.screenshotOutput;
|
|
3935
|
+
}
|
|
3936
|
+
if (options?.screenshotDeviceScaleFactor) {
|
|
3937
|
+
screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
|
|
3938
|
+
options.screenshotDeviceScaleFactor
|
|
3939
|
+
);
|
|
3940
|
+
}
|
|
3978
3941
|
const shot = await captureToolScreenshot(
|
|
3979
3942
|
{
|
|
3980
3943
|
session,
|
|
@@ -3983,7 +3946,7 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3983
3946
|
toolOutput: callResult,
|
|
3984
3947
|
resourceUri
|
|
3985
3948
|
},
|
|
3986
|
-
|
|
3949
|
+
screenshotOpts
|
|
3987
3950
|
);
|
|
3988
3951
|
screenshot = {
|
|
3989
3952
|
path: shot.outputPath,
|
|
@@ -3994,6 +3957,8 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3994
3957
|
} catch (err) {
|
|
3995
3958
|
screenshotError = err?.message ?? String(err);
|
|
3996
3959
|
}
|
|
3960
|
+
} else {
|
|
3961
|
+
widgetHintUri = resourceUri;
|
|
3997
3962
|
}
|
|
3998
3963
|
}
|
|
3999
3964
|
if (options?.json) {
|
|
@@ -4013,6 +3978,13 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
4013
3978
|
formatWarning(`Skipped widget screenshot: ${screenshotError}`)
|
|
4014
3979
|
);
|
|
4015
3980
|
}
|
|
3981
|
+
if (widgetHintUri) {
|
|
3982
|
+
console.error(
|
|
3983
|
+
formatInfo(
|
|
3984
|
+
`This tool renders a widget (${widgetHintUri}). Re-run with --screenshot to save a PNG of it.`
|
|
3985
|
+
)
|
|
3986
|
+
);
|
|
3987
|
+
}
|
|
4016
3988
|
if (callResult.isError) {
|
|
4017
3989
|
await cleanupAndExit(1);
|
|
4018
3990
|
}
|
|
@@ -4029,9 +4001,9 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
4029
4001
|
}
|
|
4030
4002
|
await cleanupAndExit(0);
|
|
4031
4003
|
}
|
|
4032
|
-
async function listResourcesCommand(options) {
|
|
4004
|
+
async function listResourcesCommand(name, options) {
|
|
4033
4005
|
try {
|
|
4034
|
-
const result = await getOrRestoreSession(
|
|
4006
|
+
const result = await getOrRestoreSession(name);
|
|
4035
4007
|
if (!result) {
|
|
4036
4008
|
await cleanupAndExit(1);
|
|
4037
4009
|
}
|
|
@@ -4067,9 +4039,9 @@ async function listResourcesCommand(options) {
|
|
|
4067
4039
|
}
|
|
4068
4040
|
await cleanupAndExit(0);
|
|
4069
4041
|
}
|
|
4070
|
-
async function readResourceCommand(uri, options) {
|
|
4042
|
+
async function readResourceCommand(name, uri, options) {
|
|
4071
4043
|
try {
|
|
4072
|
-
const result = await getOrRestoreSession(
|
|
4044
|
+
const result = await getOrRestoreSession(name);
|
|
4073
4045
|
if (!result) {
|
|
4074
4046
|
await cleanupAndExit(1);
|
|
4075
4047
|
}
|
|
@@ -4087,9 +4059,9 @@ async function readResourceCommand(uri, options) {
|
|
|
4087
4059
|
}
|
|
4088
4060
|
await cleanupAndExit(0);
|
|
4089
4061
|
}
|
|
4090
|
-
async function subscribeResourceCommand(
|
|
4062
|
+
async function subscribeResourceCommand(name, uri) {
|
|
4091
4063
|
try {
|
|
4092
|
-
const result = await getOrRestoreSession(
|
|
4064
|
+
const result = await getOrRestoreSession(name);
|
|
4093
4065
|
if (!result) {
|
|
4094
4066
|
await cleanupAndExit(1);
|
|
4095
4067
|
}
|
|
@@ -4113,9 +4085,9 @@ async function subscribeResourceCommand(uri, options) {
|
|
|
4113
4085
|
await cleanupAndExit(1);
|
|
4114
4086
|
}
|
|
4115
4087
|
}
|
|
4116
|
-
async function unsubscribeResourceCommand(
|
|
4088
|
+
async function unsubscribeResourceCommand(name, uri) {
|
|
4117
4089
|
try {
|
|
4118
|
-
const result = await getOrRestoreSession(
|
|
4090
|
+
const result = await getOrRestoreSession(name);
|
|
4119
4091
|
if (!result) {
|
|
4120
4092
|
await cleanupAndExit(1);
|
|
4121
4093
|
}
|
|
@@ -4130,9 +4102,9 @@ async function unsubscribeResourceCommand(uri, options) {
|
|
|
4130
4102
|
}
|
|
4131
4103
|
await cleanupAndExit(0);
|
|
4132
4104
|
}
|
|
4133
|
-
async function listPromptsCommand(options) {
|
|
4105
|
+
async function listPromptsCommand(name, options) {
|
|
4134
4106
|
try {
|
|
4135
|
-
const result = await getOrRestoreSession(
|
|
4107
|
+
const result = await getOrRestoreSession(name);
|
|
4136
4108
|
if (!result) {
|
|
4137
4109
|
await cleanupAndExit(1);
|
|
4138
4110
|
}
|
|
@@ -4174,9 +4146,9 @@ async function listPromptsCommand(options) {
|
|
|
4174
4146
|
}
|
|
4175
4147
|
await cleanupAndExit(0);
|
|
4176
4148
|
}
|
|
4177
|
-
async function getPromptCommand(promptName, argsList, options) {
|
|
4149
|
+
async function getPromptCommand(name, promptName, argsList, options) {
|
|
4178
4150
|
try {
|
|
4179
|
-
const result = await getOrRestoreSession(
|
|
4151
|
+
const result = await getOrRestoreSession(name);
|
|
4180
4152
|
if (!result) {
|
|
4181
4153
|
await cleanupAndExit(1);
|
|
4182
4154
|
}
|
|
@@ -4190,10 +4162,10 @@ async function getPromptCommand(promptName, argsList, options) {
|
|
|
4190
4162
|
console.log("");
|
|
4191
4163
|
console.log(formatInfo("Usage:"));
|
|
4192
4164
|
console.log(
|
|
4193
|
-
` npx mcp-use client prompts get ${promptName} key=value [key2=value2 ...]`
|
|
4165
|
+
` npx mcp-use client ${name} prompts get ${promptName} key=value [key2=value2 ...]`
|
|
4194
4166
|
);
|
|
4195
4167
|
console.log(
|
|
4196
|
-
` npx mcp-use client prompts get ${promptName} '{"key":"value"}' # full JSON object`
|
|
4168
|
+
` npx mcp-use client ${name} prompts get ${promptName} '{"key":"value"}' # full JSON object`
|
|
4197
4169
|
);
|
|
4198
4170
|
await cleanupAndExit(1);
|
|
4199
4171
|
}
|
|
@@ -4221,9 +4193,9 @@ async function getPromptCommand(promptName, argsList, options) {
|
|
|
4221
4193
|
}
|
|
4222
4194
|
await cleanupAndExit(0);
|
|
4223
4195
|
}
|
|
4224
|
-
async function interactiveCommand(
|
|
4196
|
+
async function interactiveCommand(name) {
|
|
4225
4197
|
try {
|
|
4226
|
-
const result = await getOrRestoreSession(
|
|
4198
|
+
const result = await getOrRestoreSession(name);
|
|
4227
4199
|
if (!result) return;
|
|
4228
4200
|
const { name: sessionName, session } = result;
|
|
4229
4201
|
console.log(formatHeader("MCP Interactive Mode"));
|
|
@@ -4246,10 +4218,6 @@ async function interactiveCommand(options) {
|
|
|
4246
4218
|
source_default.gray(" prompts list - List available prompts")
|
|
4247
4219
|
);
|
|
4248
4220
|
console.log(source_default.gray(" prompts get <name> - Get a prompt"));
|
|
4249
|
-
console.log(source_default.gray(" sessions list - List all sessions"));
|
|
4250
|
-
console.log(
|
|
4251
|
-
source_default.gray(" sessions switch <name> - Switch to another session")
|
|
4252
|
-
);
|
|
4253
4221
|
console.log(
|
|
4254
4222
|
source_default.gray(" exit, quit - Exit interactive mode")
|
|
4255
4223
|
);
|
|
@@ -4369,22 +4337,10 @@ async function interactiveCommand(options) {
|
|
|
4369
4337
|
)
|
|
4370
4338
|
);
|
|
4371
4339
|
}
|
|
4372
|
-
} else if (scope === "sessions") {
|
|
4373
|
-
if (command === "list") {
|
|
4374
|
-
await listSessionsCommand();
|
|
4375
|
-
} else if (command === "switch" && arg) {
|
|
4376
|
-
console.log(
|
|
4377
|
-
formatWarning(
|
|
4378
|
-
"Session switching in interactive mode will be available in a future version"
|
|
4379
|
-
)
|
|
4380
|
-
);
|
|
4381
|
-
} else {
|
|
4382
|
-
console.error(formatError("Invalid command. Try: sessions list"));
|
|
4383
|
-
}
|
|
4384
4340
|
} else {
|
|
4385
4341
|
console.error(
|
|
4386
4342
|
formatError(
|
|
4387
|
-
"Unknown command. Type a valid scope: tools, resources, prompts
|
|
4343
|
+
"Unknown command. Type a valid scope: tools, resources, prompts"
|
|
4388
4344
|
)
|
|
4389
4345
|
);
|
|
4390
4346
|
}
|
|
@@ -4407,72 +4363,86 @@ async function interactiveCommand(options) {
|
|
|
4407
4363
|
}
|
|
4408
4364
|
function createClientCommand() {
|
|
4409
4365
|
const clientCommand = new Command2("client").description(
|
|
4410
|
-
"Interactive MCP client for terminal usage"
|
|
4366
|
+
"Interactive MCP client for terminal usage. Use `mcp-use client <name> ...` to run commands against a saved server."
|
|
4367
|
+
).showHelpAfterError(
|
|
4368
|
+
"(Run `mcp-use client --help` to see available commands)"
|
|
4411
4369
|
);
|
|
4412
|
-
clientCommand.command("connect
|
|
4370
|
+
clientCommand.command("connect [name] [url]").description(
|
|
4371
|
+
"Connect to an MCP server and save it under a short name. Use the name to address it in later commands (e.g. `mcp-use client <name> tools list`)."
|
|
4372
|
+
).option("--stdio", "Use stdio connector instead of HTTP").option("--auth <token>", "Static Bearer token (skips OAuth)").option(
|
|
4413
4373
|
"--no-oauth",
|
|
4414
4374
|
"Don't auto-trigger OAuth on 401; fail with the 401 instead"
|
|
4415
4375
|
).option(
|
|
4416
4376
|
"--auth-timeout <ms>",
|
|
4417
4377
|
"OAuth loopback wait timeout in ms (default 300000)"
|
|
4418
4378
|
).action(connectCommand);
|
|
4419
|
-
clientCommand.command("
|
|
4420
|
-
|
|
4421
|
-
"
|
|
4379
|
+
clientCommand.command("list").description("List saved servers").action(listClientsCommand);
|
|
4380
|
+
clientCommand.command("remove <name>").description(
|
|
4381
|
+
"Remove a saved server. Also clears any OAuth tokens for that URL, unless another saved server still uses it."
|
|
4382
|
+
).action(removeClientCommand);
|
|
4383
|
+
clientCommand.addCommand(createClientScreenshotCommand());
|
|
4384
|
+
return clientCommand;
|
|
4385
|
+
}
|
|
4386
|
+
function createPerClientCommand(name) {
|
|
4387
|
+
const cmd = new Command2(`mcp-use client ${name}`).description(`Commands for server '${name}'`).showHelpAfterError(
|
|
4388
|
+
`(Run \`mcp-use client ${name} --help\` to see available commands)`
|
|
4422
4389
|
);
|
|
4423
|
-
|
|
4424
|
-
|
|
4425
|
-
|
|
4426
|
-
|
|
4427
|
-
"Interact with MCP tools"
|
|
4390
|
+
cmd.command("disconnect").description("Disconnect from this server").action(() => disconnectCommand(name));
|
|
4391
|
+
cmd.command("interactive").description("Start interactive REPL mode for this server").action(() => interactiveCommand(name));
|
|
4392
|
+
const toolsCommand = new Command2("tools").description("Interact with MCP tools").showHelpAfterError(
|
|
4393
|
+
`(Run \`mcp-use client ${name} tools --help\` to see available actions)`
|
|
4428
4394
|
);
|
|
4429
|
-
toolsCommand.command("list").description("List available tools").option("--
|
|
4430
|
-
toolsCommand.command("call <
|
|
4395
|
+
toolsCommand.command("list").description("List available tools").option("--json", "Output as JSON").action((options) => listToolsCommand(name, options));
|
|
4396
|
+
toolsCommand.command("call <tool> [args...]").description(
|
|
4431
4397
|
"Call a tool. Args as key=value pairs (use key:=<json> for nested values, or pass a JSON object)"
|
|
4432
|
-
).option("--
|
|
4433
|
-
"--
|
|
4434
|
-
"
|
|
4398
|
+
).option("--timeout <ms>", "Request timeout in milliseconds", parseInt).option("--json", "Output as JSON").option(
|
|
4399
|
+
"--screenshot",
|
|
4400
|
+
"Capture a PNG screenshot of the rendered widget for tools that declare a UI resource"
|
|
4435
4401
|
).option(
|
|
4436
4402
|
"--screenshot-output <path>",
|
|
4437
|
-
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4438
|
-
).
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4403
|
+
"Output PNG path for the widget screenshot (implies --screenshot; defaults to ./<view>-<timestamp>.png)"
|
|
4404
|
+
).option(
|
|
4405
|
+
"--screenshot-device-scale-factor <n>",
|
|
4406
|
+
"Device pixel ratio for the widget screenshot (implies --screenshot; e.g. 2 for Retina). Defaults to 1."
|
|
4407
|
+
).action(
|
|
4408
|
+
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4409
|
+
);
|
|
4410
|
+
toolsCommand.command("describe <tool>").description("Show tool details and schema").action((tool) => describeToolCommand(name, tool));
|
|
4411
|
+
cmd.addCommand(toolsCommand);
|
|
4412
|
+
const resourcesCommand = new Command2("resources").description("Interact with MCP resources").showHelpAfterError(
|
|
4413
|
+
`(Run \`mcp-use client ${name} resources --help\` to see available actions)`
|
|
4443
4414
|
);
|
|
4444
|
-
resourcesCommand.command("list").description("List available resources").option("--
|
|
4445
|
-
resourcesCommand.command("read <uri>").description("Read a resource by URI").option("--
|
|
4446
|
-
resourcesCommand.command("subscribe <uri>").description("Subscribe to resource updates").
|
|
4447
|
-
resourcesCommand.command("unsubscribe <uri>").description("Unsubscribe from resource updates").
|
|
4448
|
-
|
|
4449
|
-
const promptsCommand = new Command2("prompts").description(
|
|
4450
|
-
|
|
4415
|
+
resourcesCommand.command("list").description("List available resources").option("--json", "Output as JSON").action((options) => listResourcesCommand(name, options));
|
|
4416
|
+
resourcesCommand.command("read <uri>").description("Read a resource by URI").option("--json", "Output as JSON").action((uri, options) => readResourceCommand(name, uri, options));
|
|
4417
|
+
resourcesCommand.command("subscribe <uri>").description("Subscribe to resource updates").action((uri) => subscribeResourceCommand(name, uri));
|
|
4418
|
+
resourcesCommand.command("unsubscribe <uri>").description("Unsubscribe from resource updates").action((uri) => unsubscribeResourceCommand(name, uri));
|
|
4419
|
+
cmd.addCommand(resourcesCommand);
|
|
4420
|
+
const promptsCommand = new Command2("prompts").description("Interact with MCP prompts").showHelpAfterError(
|
|
4421
|
+
`(Run \`mcp-use client ${name} prompts --help\` to see available actions)`
|
|
4451
4422
|
);
|
|
4452
|
-
promptsCommand.command("list").description("List available prompts").option("--
|
|
4453
|
-
promptsCommand.command("get <
|
|
4423
|
+
promptsCommand.command("list").description("List available prompts").option("--json", "Output as JSON").action((options) => listPromptsCommand(name, options));
|
|
4424
|
+
promptsCommand.command("get <prompt> [args...]").description(
|
|
4454
4425
|
"Get a prompt. Args as key=value pairs (or pass a JSON object)"
|
|
4455
|
-
).option("--
|
|
4456
|
-
|
|
4457
|
-
clientCommand.command("interactive").description("Start interactive REPL mode").option("--session <name>", "Use specific session").action(interactiveCommand);
|
|
4458
|
-
const authCommand = new Command2("auth").description(
|
|
4459
|
-
"Manage OAuth tokens for HTTP sessions"
|
|
4426
|
+
).option("--json", "Output as JSON").action(
|
|
4427
|
+
(prompt4, args, options) => getPromptCommand(name, prompt4, args, options)
|
|
4460
4428
|
);
|
|
4461
|
-
|
|
4462
|
-
authCommand
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4429
|
+
cmd.addCommand(promptsCommand);
|
|
4430
|
+
const authCommand = new Command2("auth").description("Manage OAuth tokens for HTTP servers").showHelpAfterError(
|
|
4431
|
+
`(Run \`mcp-use client ${name} auth --help\` to see available actions)`
|
|
4432
|
+
);
|
|
4433
|
+
authCommand.command("status").description("Show OAuth token status for this server").action(() => authStatusCommand(name));
|
|
4434
|
+
authCommand.command("refresh").description("Force-refresh the OAuth access token").action(() => authRefreshCommand(name));
|
|
4435
|
+
authCommand.command("logout").description("Remove stored OAuth tokens for this server's URL").action(() => authLogoutCommand(name));
|
|
4436
|
+
cmd.addCommand(authCommand);
|
|
4437
|
+
cmd.addCommand(createPerClientScreenshotCommand(name));
|
|
4438
|
+
return cmd;
|
|
4466
4439
|
}
|
|
4467
4440
|
|
|
4468
4441
|
// src/commands/deploy.ts
|
|
4469
|
-
init_esm_shims();
|
|
4470
|
-
init_open();
|
|
4471
4442
|
import { promises as fs9 } from "fs";
|
|
4472
4443
|
import path8 from "path";
|
|
4473
4444
|
|
|
4474
4445
|
// src/utils/git.ts
|
|
4475
|
-
init_esm_shims();
|
|
4476
4446
|
import { execFile as execFile7 } from "child_process";
|
|
4477
4447
|
import { promisify as promisify7 } from "util";
|
|
4478
4448
|
var execFileAsync5 = promisify7(execFile7);
|
|
@@ -4608,7 +4578,6 @@ function isGitHubUrl(url) {
|
|
|
4608
4578
|
}
|
|
4609
4579
|
|
|
4610
4580
|
// src/utils/cloud-urls.ts
|
|
4611
|
-
init_esm_shims();
|
|
4612
4581
|
var GATEWAY_DOMAIN = "run.mcp-use.com";
|
|
4613
4582
|
function buildGatewayUrl(slugOrId) {
|
|
4614
4583
|
return `https://${slugOrId}.${GATEWAY_DOMAIN}/mcp`;
|
|
@@ -4625,7 +4594,6 @@ function getMcpServerUrlForCloudServer(server) {
|
|
|
4625
4594
|
}
|
|
4626
4595
|
|
|
4627
4596
|
// src/utils/project-link.ts
|
|
4628
|
-
init_esm_shims();
|
|
4629
4597
|
import { promises as fs8 } from "fs";
|
|
4630
4598
|
import path7 from "path";
|
|
4631
4599
|
var MCP_USE_DIR = ".mcp-use";
|
|
@@ -5848,7 +5816,6 @@ async function deployCommand(options) {
|
|
|
5848
5816
|
}
|
|
5849
5817
|
|
|
5850
5818
|
// src/commands/deployments.ts
|
|
5851
|
-
init_esm_shims();
|
|
5852
5819
|
import { Command as Command3 } from "commander";
|
|
5853
5820
|
async function prompt2(question) {
|
|
5854
5821
|
const readline = await import("readline");
|
|
@@ -6261,8 +6228,8 @@ async function startDeploymentCommand(deploymentId) {
|
|
|
6261
6228
|
}
|
|
6262
6229
|
}
|
|
6263
6230
|
function createDeploymentsCommand() {
|
|
6264
|
-
const deploymentsCommand = new Command3("deployments").description(
|
|
6265
|
-
"
|
|
6231
|
+
const deploymentsCommand = new Command3("deployments").description("Manage cloud deployments").showHelpAfterError(
|
|
6232
|
+
"(Run `mcp-use deployments --help` to see available commands)"
|
|
6266
6233
|
);
|
|
6267
6234
|
deploymentsCommand.command("list").alias("ls").description("List all deployments").action(listDeploymentsCommand);
|
|
6268
6235
|
deploymentsCommand.command("get").argument("<deployment-id>", "Deployment ID").description("Get deployment details").action(getDeploymentCommand);
|
|
@@ -6277,11 +6244,9 @@ function createDeploymentsCommand() {
|
|
|
6277
6244
|
}
|
|
6278
6245
|
|
|
6279
6246
|
// src/commands/servers.ts
|
|
6280
|
-
init_esm_shims();
|
|
6281
6247
|
import { Command as Command5 } from "commander";
|
|
6282
6248
|
|
|
6283
6249
|
// src/commands/env.ts
|
|
6284
|
-
init_esm_shims();
|
|
6285
6250
|
import { Command as Command4 } from "commander";
|
|
6286
6251
|
var ALL_ENVS = ["production", "preview", "development"];
|
|
6287
6252
|
function parseEnvironments(raw) {
|
|
@@ -6427,9 +6392,7 @@ async function removeEnvCommand(varId, options) {
|
|
|
6427
6392
|
}
|
|
6428
6393
|
}
|
|
6429
6394
|
function createEnvCommand() {
|
|
6430
|
-
const envCommand = new Command4("env").description(
|
|
6431
|
-
"Manage environment variables for a server"
|
|
6432
|
-
);
|
|
6395
|
+
const envCommand = new Command4("env").description("Manage environment variables for a server").showHelpAfterError("(Run `mcp-use env --help` to see available commands)");
|
|
6433
6396
|
envCommand.command("list").alias("ls").description("List environment variables for a server").requiredOption("--server <id>", "Server UUID").option("--show-values", "Reveal non-sensitive values in output").action(listEnvCommand);
|
|
6434
6397
|
envCommand.command("add").argument("<KEY=VALUE>", "Variable assignment, e.g. API_KEY=abc123").description("Add an environment variable to a server").requiredOption("--server <id>", "Server UUID").option(
|
|
6435
6398
|
"--env <environments>",
|
|
@@ -6711,8 +6674,8 @@ async function deleteServerCommand(serverId, options) {
|
|
|
6711
6674
|
}
|
|
6712
6675
|
}
|
|
6713
6676
|
function createServersCommand() {
|
|
6714
|
-
const serversCommand = new Command5("servers").description(
|
|
6715
|
-
"
|
|
6677
|
+
const serversCommand = new Command5("servers").description("Manage cloud servers (Git-backed deploy targets)").showHelpAfterError(
|
|
6678
|
+
"(Run `mcp-use servers --help` to see available commands)"
|
|
6716
6679
|
);
|
|
6717
6680
|
serversCommand.command("list").alias("ls").description("List servers for the current organization").option("--org <slug-or-id>", "Target organization (slug, id, or name)").option("--limit <n>", "Page size (1\u2013100, default 50)").option("--skip <n>", "Offset for pagination").option("--sort <field:asc|desc>", "Sort (e.g. updatedAt:desc)").action(listServersCommand);
|
|
6718
6681
|
serversCommand.command("get").argument("<id-or-slug>", "Server UUID or slug").option("--org <slug-or-id>", "Resolve org context before fetch").description("Show server details and recent deployments").action(getServerCommand);
|
|
@@ -6722,7 +6685,6 @@ function createServersCommand() {
|
|
|
6722
6685
|
}
|
|
6723
6686
|
|
|
6724
6687
|
// src/commands/org.ts
|
|
6725
|
-
init_esm_shims();
|
|
6726
6688
|
async function ensureLoggedIn() {
|
|
6727
6689
|
if (!await isLoggedIn()) {
|
|
6728
6690
|
console.log(source_default.yellow("\u26A0\uFE0F You are not logged in."));
|
|
@@ -6830,7 +6792,6 @@ async function orgCurrentCommand() {
|
|
|
6830
6792
|
}
|
|
6831
6793
|
|
|
6832
6794
|
// src/commands/skills.ts
|
|
6833
|
-
init_esm_shims();
|
|
6834
6795
|
import { Command as Command6 } from "commander";
|
|
6835
6796
|
import { cpSync, existsSync as existsSync3, mkdtempSync as mkdtempSync2, readdirSync, rmSync as rmSync2 } from "fs";
|
|
6836
6797
|
import { tmpdir } from "os";
|
|
@@ -6901,8 +6862,8 @@ async function addSkillsToProject(projectPath) {
|
|
|
6901
6862
|
}
|
|
6902
6863
|
}
|
|
6903
6864
|
function createSkillsCommand() {
|
|
6904
|
-
const skills = new Command6("skills").description(
|
|
6905
|
-
"
|
|
6865
|
+
const skills = new Command6("skills").description("Manage mcp-use AI agent skills").showHelpAfterError(
|
|
6866
|
+
"(Run `mcp-use skills --help` to see available commands)"
|
|
6906
6867
|
);
|
|
6907
6868
|
const installAction = async (options) => {
|
|
6908
6869
|
const projectPath = resolve(options.path);
|
|
@@ -6947,7 +6908,6 @@ function createSkillsCommand() {
|
|
|
6947
6908
|
}
|
|
6948
6909
|
|
|
6949
6910
|
// src/utils/next-shims.ts
|
|
6950
|
-
init_esm_shims();
|
|
6951
6911
|
import { existsSync as existsSync4, promises as fs10 } from "fs";
|
|
6952
6912
|
import path9 from "path";
|
|
6953
6913
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "url";
|
|
@@ -7048,7 +7008,6 @@ function quoteNodeOption(value) {
|
|
|
7048
7008
|
}
|
|
7049
7009
|
|
|
7050
7010
|
// src/utils/update-check.ts
|
|
7051
|
-
init_esm_shims();
|
|
7052
7011
|
import { readFileSync } from "fs";
|
|
7053
7012
|
import { mkdir as mkdir3, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
|
|
7054
7013
|
import { createRequire } from "module";
|
|
@@ -7186,7 +7145,7 @@ var packageContent = readFileSync2(
|
|
|
7186
7145
|
);
|
|
7187
7146
|
var packageJson = JSON.parse(packageContent);
|
|
7188
7147
|
var packageVersion = packageJson.version || "unknown";
|
|
7189
|
-
program.name("mcp-use").description("Create and run MCP servers with ui resources widgets").version(packageVersion);
|
|
7148
|
+
program.name("mcp-use").description("Create and run MCP servers with ui resources widgets").version(packageVersion).showHelpAfterError("(Run `mcp-use --help` to see available commands)");
|
|
7190
7149
|
function displayPackageVersions(projectPath) {
|
|
7191
7150
|
const packages = [
|
|
7192
7151
|
{ name: "@mcp-use/cli", relativePath: "../package.json" },
|
|
@@ -9267,7 +9226,7 @@ Looked for:
|
|
|
9267
9226
|
process.exit(1);
|
|
9268
9227
|
}
|
|
9269
9228
|
});
|
|
9270
|
-
program.command("login").description("Login to
|
|
9229
|
+
program.command("login").description("Login to Manufact cloud").option(
|
|
9271
9230
|
"--api-key <key>",
|
|
9272
9231
|
"Login with an API key directly (non-interactive, for CI/CD)"
|
|
9273
9232
|
).option("--org <slug|id|name>", "Select an organization non-interactively").action(async (opts) => {
|
|
@@ -9337,7 +9296,6 @@ program.addCommand(createClientCommand());
|
|
|
9337
9296
|
program.addCommand(createDeploymentsCommand());
|
|
9338
9297
|
program.addCommand(createServersCommand());
|
|
9339
9298
|
program.addCommand(createSkillsCommand());
|
|
9340
|
-
program.addCommand(createScreenshotCommand());
|
|
9341
9299
|
program.command("generate-types").description(
|
|
9342
9300
|
"Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
|
|
9343
9301
|
).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {
|
|
@@ -9371,5 +9329,49 @@ program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
9371
9329
|
const projectPath = actionCommand.opts().path;
|
|
9372
9330
|
await notifyIfUpdateAvailable(projectPath);
|
|
9373
9331
|
});
|
|
9374
|
-
|
|
9332
|
+
var argv = process.argv;
|
|
9333
|
+
var clientIdx = argv[2] === "client" ? 2 : -1;
|
|
9334
|
+
var perClientName = clientIdx !== -1 && argv.length > clientIdx + 1 && !argv[clientIdx + 1].startsWith("-") && !RESERVED_CLIENT_SUBCOMMANDS.has(argv[clientIdx + 1]) ? argv[clientIdx + 1] : null;
|
|
9335
|
+
if (perClientName) {
|
|
9336
|
+
if (PER_CLIENT_SCOPES.has(perClientName)) {
|
|
9337
|
+
const rest2 = argv.slice(clientIdx + 1).join(" ");
|
|
9338
|
+
console.error(formatError("Missing server name."));
|
|
9339
|
+
console.error("");
|
|
9340
|
+
console.error(
|
|
9341
|
+
`'${perClientName}' is a per-server subcommand, not a server name. Address it through a saved server:`
|
|
9342
|
+
);
|
|
9343
|
+
console.error("");
|
|
9344
|
+
console.error(` mcp-use client <name> ${rest2}`);
|
|
9345
|
+
console.error("");
|
|
9346
|
+
console.error("See your saved servers with:");
|
|
9347
|
+
console.error(" mcp-use client list");
|
|
9348
|
+
process.exit(1);
|
|
9349
|
+
}
|
|
9350
|
+
const rest = argv.slice(clientIdx + 2);
|
|
9351
|
+
const isHelpOnly = rest.length === 0 || rest.length === 1 && (rest[0] === "--help" || rest[0] === "-h");
|
|
9352
|
+
(async () => {
|
|
9353
|
+
if (isHelpOnly) {
|
|
9354
|
+
const config = await getSession(perClientName);
|
|
9355
|
+
if (!config) {
|
|
9356
|
+
console.error(formatError(`Server '${perClientName}' not found.`));
|
|
9357
|
+
console.error("");
|
|
9358
|
+
console.error("Connect to an MCP server and save it under this name:");
|
|
9359
|
+
console.error(` mcp-use client connect ${perClientName} <url>`);
|
|
9360
|
+
console.error("");
|
|
9361
|
+
console.error("See your saved servers with:");
|
|
9362
|
+
console.error(" mcp-use client list");
|
|
9363
|
+
process.exit(1);
|
|
9364
|
+
}
|
|
9365
|
+
}
|
|
9366
|
+
await createPerClientCommand(perClientName).parseAsync(rest, {
|
|
9367
|
+
from: "user"
|
|
9368
|
+
});
|
|
9369
|
+
})().catch((err) => {
|
|
9370
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9371
|
+
console.error(formatError(message));
|
|
9372
|
+
process.exit(1);
|
|
9373
|
+
});
|
|
9374
|
+
} else {
|
|
9375
|
+
program.parse();
|
|
9376
|
+
}
|
|
9375
9377
|
//# sourceMappingURL=index.js.map
|