@mcp-use/cli 3.2.0-canary.9 → 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.cjs
CHANGED
|
@@ -6,13 +6,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __esm = (fn, res) => function __init() {
|
|
10
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
11
|
-
};
|
|
12
|
-
var __export = (target, all) => {
|
|
13
|
-
for (var name in all)
|
|
14
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
15
|
-
};
|
|
16
9
|
var __copyProps = (to, from, except, desc) => {
|
|
17
10
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
11
|
for (let key of __getOwnPropNames(from))
|
|
@@ -31,1276 +24,1133 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
31
24
|
));
|
|
32
25
|
|
|
33
26
|
// ../../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/cjs_shims.js
|
|
34
|
-
var getImportMetaUrl,
|
|
35
|
-
var
|
|
36
|
-
"../../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/cjs_shims.js"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
39
|
-
importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
44
|
-
function hasDockerEnv() {
|
|
45
|
-
try {
|
|
46
|
-
import_node_fs.default.statSync("/.dockerenv");
|
|
47
|
-
return true;
|
|
48
|
-
} catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
function hasDockerCGroup() {
|
|
53
|
-
try {
|
|
54
|
-
return import_node_fs.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
55
|
-
} catch {
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function isDocker() {
|
|
60
|
-
if (isDockerCached === void 0) {
|
|
61
|
-
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
62
|
-
}
|
|
63
|
-
return isDockerCached;
|
|
64
|
-
}
|
|
65
|
-
var import_node_fs, isDockerCached;
|
|
66
|
-
var init_is_docker = __esm({
|
|
67
|
-
"../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js"() {
|
|
68
|
-
"use strict";
|
|
69
|
-
init_cjs_shims();
|
|
70
|
-
import_node_fs = __toESM(require("fs"), 1);
|
|
71
|
-
}
|
|
72
|
-
});
|
|
27
|
+
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
|
|
28
|
+
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
73
29
|
|
|
74
|
-
// ../../node_modules/.pnpm/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
30
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/ansi-styles/index.js
|
|
31
|
+
var ANSI_BACKGROUND_OFFSET = 10;
|
|
32
|
+
var wrapAnsi16 = (offset = 0) => (code) => `\x1B[${code + offset}m`;
|
|
33
|
+
var wrapAnsi256 = (offset = 0) => (code) => `\x1B[${38 + offset};5;${code}m`;
|
|
34
|
+
var wrapAnsi16m = (offset = 0) => (red, green, blue) => `\x1B[${38 + offset};2;${red};${green};${blue}m`;
|
|
35
|
+
var styles = {
|
|
36
|
+
modifier: {
|
|
37
|
+
reset: [0, 0],
|
|
38
|
+
// 21 isn't widely supported and 22 does the same thing
|
|
39
|
+
bold: [1, 22],
|
|
40
|
+
dim: [2, 22],
|
|
41
|
+
italic: [3, 23],
|
|
42
|
+
underline: [4, 24],
|
|
43
|
+
overline: [53, 55],
|
|
44
|
+
inverse: [7, 27],
|
|
45
|
+
hidden: [8, 28],
|
|
46
|
+
strikethrough: [9, 29]
|
|
47
|
+
},
|
|
48
|
+
color: {
|
|
49
|
+
black: [30, 39],
|
|
50
|
+
red: [31, 39],
|
|
51
|
+
green: [32, 39],
|
|
52
|
+
yellow: [33, 39],
|
|
53
|
+
blue: [34, 39],
|
|
54
|
+
magenta: [35, 39],
|
|
55
|
+
cyan: [36, 39],
|
|
56
|
+
white: [37, 39],
|
|
57
|
+
// Bright color
|
|
58
|
+
blackBright: [90, 39],
|
|
59
|
+
gray: [90, 39],
|
|
60
|
+
// Alias of `blackBright`
|
|
61
|
+
grey: [90, 39],
|
|
62
|
+
// Alias of `blackBright`
|
|
63
|
+
redBright: [91, 39],
|
|
64
|
+
greenBright: [92, 39],
|
|
65
|
+
yellowBright: [93, 39],
|
|
66
|
+
blueBright: [94, 39],
|
|
67
|
+
magentaBright: [95, 39],
|
|
68
|
+
cyanBright: [96, 39],
|
|
69
|
+
whiteBright: [97, 39]
|
|
70
|
+
},
|
|
71
|
+
bgColor: {
|
|
72
|
+
bgBlack: [40, 49],
|
|
73
|
+
bgRed: [41, 49],
|
|
74
|
+
bgGreen: [42, 49],
|
|
75
|
+
bgYellow: [43, 49],
|
|
76
|
+
bgBlue: [44, 49],
|
|
77
|
+
bgMagenta: [45, 49],
|
|
78
|
+
bgCyan: [46, 49],
|
|
79
|
+
bgWhite: [47, 49],
|
|
80
|
+
// Bright color
|
|
81
|
+
bgBlackBright: [100, 49],
|
|
82
|
+
bgGray: [100, 49],
|
|
83
|
+
// Alias of `bgBlackBright`
|
|
84
|
+
bgGrey: [100, 49],
|
|
85
|
+
// Alias of `bgBlackBright`
|
|
86
|
+
bgRedBright: [101, 49],
|
|
87
|
+
bgGreenBright: [102, 49],
|
|
88
|
+
bgYellowBright: [103, 49],
|
|
89
|
+
bgBlueBright: [104, 49],
|
|
90
|
+
bgMagentaBright: [105, 49],
|
|
91
|
+
bgCyanBright: [106, 49],
|
|
92
|
+
bgWhiteBright: [107, 49]
|
|
78
93
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var
|
|
82
|
-
var
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
};
|
|
95
|
+
var modifierNames = Object.keys(styles.modifier);
|
|
96
|
+
var foregroundColorNames = Object.keys(styles.color);
|
|
97
|
+
var backgroundColorNames = Object.keys(styles.bgColor);
|
|
98
|
+
var colorNames = [...foregroundColorNames, ...backgroundColorNames];
|
|
99
|
+
function assembleStyles() {
|
|
100
|
+
const codes = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const [groupName, group] of Object.entries(styles)) {
|
|
102
|
+
for (const [styleName, style] of Object.entries(group)) {
|
|
103
|
+
styles[styleName] = {
|
|
104
|
+
open: `\x1B[${style[0]}m`,
|
|
105
|
+
close: `\x1B[${style[1]}m`
|
|
106
|
+
};
|
|
107
|
+
group[styleName] = styles[styleName];
|
|
108
|
+
codes.set(style[0], style[1]);
|
|
109
|
+
}
|
|
110
|
+
Object.defineProperty(styles, groupName, {
|
|
111
|
+
value: group,
|
|
112
|
+
enumerable: false
|
|
113
|
+
});
|
|
96
114
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
Object.defineProperty(styles, "codes", {
|
|
116
|
+
value: codes,
|
|
117
|
+
enumerable: false
|
|
118
|
+
});
|
|
119
|
+
styles.color.close = "\x1B[39m";
|
|
120
|
+
styles.bgColor.close = "\x1B[49m";
|
|
121
|
+
styles.color.ansi = wrapAnsi16();
|
|
122
|
+
styles.color.ansi256 = wrapAnsi256();
|
|
123
|
+
styles.color.ansi16m = wrapAnsi16m();
|
|
124
|
+
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
125
|
+
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
126
|
+
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
127
|
+
Object.defineProperties(styles, {
|
|
128
|
+
rgbToAnsi256: {
|
|
129
|
+
value(red, green, blue) {
|
|
130
|
+
if (red === green && green === blue) {
|
|
131
|
+
if (red < 8) {
|
|
132
|
+
return 16;
|
|
133
|
+
}
|
|
134
|
+
if (red > 248) {
|
|
135
|
+
return 231;
|
|
136
|
+
}
|
|
137
|
+
return Math.round((red - 8) / 247 * 24) + 232;
|
|
116
138
|
}
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
130
|
-
var import_node_process3, import_node_buffer, import_node_util, import_node_child_process, import_promises, execFile, powerShellPath, executePowerShell;
|
|
131
|
-
var init_powershell_utils = __esm({
|
|
132
|
-
"../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js"() {
|
|
133
|
-
"use strict";
|
|
134
|
-
init_cjs_shims();
|
|
135
|
-
import_node_process3 = __toESM(require("process"), 1);
|
|
136
|
-
import_node_buffer = require("buffer");
|
|
137
|
-
import_node_util = require("util");
|
|
138
|
-
import_node_child_process = __toESM(require("child_process"), 1);
|
|
139
|
-
import_promises = __toESM(require("fs/promises"), 1);
|
|
140
|
-
execFile = (0, import_node_util.promisify)(import_node_child_process.default.execFile);
|
|
141
|
-
powerShellPath = () => `${import_node_process3.default.env.SYSTEMROOT || import_node_process3.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
142
|
-
executePowerShell = async (command, options = {}) => {
|
|
143
|
-
const {
|
|
144
|
-
powerShellPath: psPath,
|
|
145
|
-
...execFileOptions
|
|
146
|
-
} = options;
|
|
147
|
-
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
148
|
-
return execFile(
|
|
149
|
-
psPath ?? powerShellPath(),
|
|
150
|
-
[
|
|
151
|
-
...executePowerShell.argumentsPrefix,
|
|
152
|
-
encodedCommand
|
|
153
|
-
],
|
|
154
|
-
{
|
|
155
|
-
encoding: "utf8",
|
|
156
|
-
...execFileOptions
|
|
139
|
+
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
140
|
+
},
|
|
141
|
+
enumerable: false
|
|
142
|
+
},
|
|
143
|
+
hexToRgb: {
|
|
144
|
+
value(hex) {
|
|
145
|
+
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
146
|
+
if (!matches) {
|
|
147
|
+
return [0, 0, 0];
|
|
157
148
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
"-NoProfile",
|
|
162
|
-
"-NonInteractive",
|
|
163
|
-
"-ExecutionPolicy",
|
|
164
|
-
"Bypass",
|
|
165
|
-
"-EncodedCommand"
|
|
166
|
-
];
|
|
167
|
-
executePowerShell.encodeCommand = (command) => import_node_buffer.Buffer.from(command, "utf16le").toString("base64");
|
|
168
|
-
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
|
|
173
|
-
function parseMountPointFromConfig(content) {
|
|
174
|
-
for (const line of content.split("\n")) {
|
|
175
|
-
if (/^\s*#/.test(line)) {
|
|
176
|
-
continue;
|
|
177
|
-
}
|
|
178
|
-
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
179
|
-
if (!match) {
|
|
180
|
-
continue;
|
|
181
|
-
}
|
|
182
|
-
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
var init_utilities = __esm({
|
|
186
|
-
"../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js"() {
|
|
187
|
-
"use strict";
|
|
188
|
-
init_cjs_shims();
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
193
|
-
var import_node_util2, import_node_child_process2, import_promises2, execFile2, wslDrivesMountPoint, powerShellPathFromWsl, powerShellPath2, canAccessPowerShellPromise, canAccessPowerShell, wslDefaultBrowser, convertWslPathToWindows;
|
|
194
|
-
var init_wsl_utils = __esm({
|
|
195
|
-
"../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js"() {
|
|
196
|
-
"use strict";
|
|
197
|
-
init_cjs_shims();
|
|
198
|
-
import_node_util2 = require("util");
|
|
199
|
-
import_node_child_process2 = __toESM(require("child_process"), 1);
|
|
200
|
-
import_promises2 = __toESM(require("fs/promises"), 1);
|
|
201
|
-
init_is_wsl();
|
|
202
|
-
init_powershell_utils();
|
|
203
|
-
init_utilities();
|
|
204
|
-
init_is_wsl();
|
|
205
|
-
execFile2 = (0, import_node_util2.promisify)(import_node_child_process2.default.execFile);
|
|
206
|
-
wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
207
|
-
const defaultMountPoint = "/mnt/";
|
|
208
|
-
let mountPoint;
|
|
209
|
-
return async function() {
|
|
210
|
-
if (mountPoint) {
|
|
211
|
-
return mountPoint;
|
|
149
|
+
let [colorString] = matches;
|
|
150
|
+
if (colorString.length === 3) {
|
|
151
|
+
colorString = [...colorString].map((character) => character + character).join("");
|
|
212
152
|
}
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
153
|
+
const integer = Number.parseInt(colorString, 16);
|
|
154
|
+
return [
|
|
155
|
+
/* eslint-disable no-bitwise */
|
|
156
|
+
integer >> 16 & 255,
|
|
157
|
+
integer >> 8 & 255,
|
|
158
|
+
integer & 255
|
|
159
|
+
/* eslint-enable no-bitwise */
|
|
160
|
+
];
|
|
161
|
+
},
|
|
162
|
+
enumerable: false
|
|
163
|
+
},
|
|
164
|
+
hexToAnsi256: {
|
|
165
|
+
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
166
|
+
enumerable: false
|
|
167
|
+
},
|
|
168
|
+
ansi256ToAnsi: {
|
|
169
|
+
value(code) {
|
|
170
|
+
if (code < 8) {
|
|
171
|
+
return 30 + code;
|
|
219
172
|
}
|
|
220
|
-
if (
|
|
221
|
-
return
|
|
173
|
+
if (code < 16) {
|
|
174
|
+
return 90 + (code - 8);
|
|
222
175
|
}
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
176
|
+
let red;
|
|
177
|
+
let green;
|
|
178
|
+
let blue;
|
|
179
|
+
if (code >= 232) {
|
|
180
|
+
red = ((code - 232) * 10 + 8) / 255;
|
|
181
|
+
green = red;
|
|
182
|
+
blue = red;
|
|
183
|
+
} else {
|
|
184
|
+
code -= 16;
|
|
185
|
+
const remainder = code % 36;
|
|
186
|
+
red = Math.floor(code / 36) / 5;
|
|
187
|
+
green = Math.floor(remainder / 6) / 5;
|
|
188
|
+
blue = remainder % 6 / 5;
|
|
227
189
|
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
};
|
|
232
|
-
})();
|
|
233
|
-
powerShellPathFromWsl = async () => {
|
|
234
|
-
const mountPoint = await wslDrivesMountPoint();
|
|
235
|
-
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
236
|
-
};
|
|
237
|
-
powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
238
|
-
canAccessPowerShell = async () => {
|
|
239
|
-
canAccessPowerShellPromise ??= (async () => {
|
|
240
|
-
try {
|
|
241
|
-
const psPath = await powerShellPath2();
|
|
242
|
-
await import_promises2.default.access(psPath, import_promises2.constants.X_OK);
|
|
243
|
-
return true;
|
|
244
|
-
} catch {
|
|
245
|
-
return false;
|
|
190
|
+
const value = Math.max(red, green, blue) * 2;
|
|
191
|
+
if (value === 0) {
|
|
192
|
+
return 30;
|
|
246
193
|
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
return stdout.trim();
|
|
255
|
-
};
|
|
256
|
-
convertWslPathToWindows = async (path11) => {
|
|
257
|
-
if (/^[a-z]+:\/\//i.test(path11)) {
|
|
258
|
-
return path11;
|
|
259
|
-
}
|
|
260
|
-
try {
|
|
261
|
-
const { stdout } = await execFile2("wslpath", ["-aw", path11], { encoding: "utf8" });
|
|
262
|
-
return stdout.trim();
|
|
263
|
-
} catch {
|
|
264
|
-
return path11;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
// ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
271
|
-
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
272
|
-
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
273
|
-
Object.defineProperty(object, propertyName, {
|
|
274
|
-
configurable: true,
|
|
275
|
-
enumerable: true,
|
|
276
|
-
get() {
|
|
277
|
-
const result = valueGetter();
|
|
278
|
-
define(result);
|
|
279
|
-
return result;
|
|
194
|
+
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
195
|
+
if (value === 2) {
|
|
196
|
+
result += 60;
|
|
197
|
+
}
|
|
198
|
+
return result;
|
|
199
|
+
},
|
|
200
|
+
enumerable: false
|
|
280
201
|
},
|
|
281
|
-
|
|
282
|
-
|
|
202
|
+
rgbToAnsi: {
|
|
203
|
+
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
204
|
+
enumerable: false
|
|
205
|
+
},
|
|
206
|
+
hexToAnsi: {
|
|
207
|
+
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
208
|
+
enumerable: false
|
|
283
209
|
}
|
|
284
210
|
});
|
|
285
|
-
return
|
|
211
|
+
return styles;
|
|
286
212
|
}
|
|
287
|
-
var
|
|
288
|
-
|
|
289
|
-
"use strict";
|
|
290
|
-
init_cjs_shims();
|
|
291
|
-
}
|
|
292
|
-
});
|
|
213
|
+
var ansiStyles = assembleStyles();
|
|
214
|
+
var ansi_styles_default = ansiStyles;
|
|
293
215
|
|
|
294
|
-
// ../../node_modules/.pnpm/
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
216
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/vendor/supports-color/index.js
|
|
217
|
+
var import_node_process = __toESM(require("process"), 1);
|
|
218
|
+
var import_node_os = __toESM(require("os"), 1);
|
|
219
|
+
var import_node_tty = __toESM(require("tty"), 1);
|
|
220
|
+
function hasFlag(flag, argv2 = globalThis.Deno ? globalThis.Deno.args : import_node_process.default.argv) {
|
|
221
|
+
const prefix = flag.startsWith("-") ? "" : flag.length === 1 ? "-" : "--";
|
|
222
|
+
const position = argv2.indexOf(prefix + flag);
|
|
223
|
+
const terminatorPosition = argv2.indexOf("--");
|
|
224
|
+
return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition);
|
|
225
|
+
}
|
|
226
|
+
var { env } = import_node_process.default;
|
|
227
|
+
var flagForceColor;
|
|
228
|
+
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
229
|
+
flagForceColor = 0;
|
|
230
|
+
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
231
|
+
flagForceColor = 1;
|
|
232
|
+
}
|
|
233
|
+
function envForceColor() {
|
|
234
|
+
if ("FORCE_COLOR" in env) {
|
|
235
|
+
if (env.FORCE_COLOR === "true") {
|
|
236
|
+
return 1;
|
|
237
|
+
}
|
|
238
|
+
if (env.FORCE_COLOR === "false") {
|
|
239
|
+
return 0;
|
|
240
|
+
}
|
|
241
|
+
return env.FORCE_COLOR.length === 0 ? 1 : Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
298
242
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
return "com.apple.Safari";
|
|
243
|
+
}
|
|
244
|
+
function translateLevel(level) {
|
|
245
|
+
if (level === 0) {
|
|
246
|
+
return false;
|
|
304
247
|
}
|
|
305
|
-
return
|
|
248
|
+
return {
|
|
249
|
+
level,
|
|
250
|
+
hasBasic: true,
|
|
251
|
+
has256: level >= 2,
|
|
252
|
+
has16m: level >= 3
|
|
253
|
+
};
|
|
306
254
|
}
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
init_cjs_shims();
|
|
312
|
-
import_node_util3 = require("util");
|
|
313
|
-
import_node_process4 = __toESM(require("process"), 1);
|
|
314
|
-
import_node_child_process3 = require("child_process");
|
|
315
|
-
execFileAsync = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
255
|
+
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
256
|
+
const noFlagForceColor = envForceColor();
|
|
257
|
+
if (noFlagForceColor !== void 0) {
|
|
258
|
+
flagForceColor = noFlagForceColor;
|
|
316
259
|
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
321
|
-
if (import_node_process5.default.platform !== "darwin") {
|
|
322
|
-
throw new Error("macOS only");
|
|
260
|
+
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
261
|
+
if (forceColor === 0) {
|
|
262
|
+
return 0;
|
|
323
263
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
264
|
+
if (sniffFlags) {
|
|
265
|
+
if (hasFlag("color=16m") || hasFlag("color=full") || hasFlag("color=truecolor")) {
|
|
266
|
+
return 3;
|
|
267
|
+
}
|
|
268
|
+
if (hasFlag("color=256")) {
|
|
269
|
+
return 2;
|
|
270
|
+
}
|
|
328
271
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
332
|
-
var import_node_process5, import_node_util4, import_node_child_process4, execFileAsync2;
|
|
333
|
-
var init_run_applescript = __esm({
|
|
334
|
-
"../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js"() {
|
|
335
|
-
"use strict";
|
|
336
|
-
init_cjs_shims();
|
|
337
|
-
import_node_process5 = __toESM(require("process"), 1);
|
|
338
|
-
import_node_util4 = require("util");
|
|
339
|
-
import_node_child_process4 = require("child_process");
|
|
340
|
-
execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
|
|
272
|
+
if ("TF_BUILD" in env && "AGENT_NAME" in env) {
|
|
273
|
+
return 1;
|
|
341
274
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
// ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
345
|
-
async function bundleName(bundleId) {
|
|
346
|
-
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
347
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
348
|
-
}
|
|
349
|
-
var init_bundle_name = __esm({
|
|
350
|
-
"../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js"() {
|
|
351
|
-
"use strict";
|
|
352
|
-
init_cjs_shims();
|
|
353
|
-
init_run_applescript();
|
|
275
|
+
if (haveStream && !streamIsTTY && forceColor === void 0) {
|
|
276
|
+
return 0;
|
|
354
277
|
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
359
|
-
const { stdout } = await _execFileAsync("reg", [
|
|
360
|
-
"QUERY",
|
|
361
|
-
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
362
|
-
"/v",
|
|
363
|
-
"ProgId"
|
|
364
|
-
]);
|
|
365
|
-
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
366
|
-
if (!match) {
|
|
367
|
-
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
278
|
+
const min = forceColor || 0;
|
|
279
|
+
if (env.TERM === "dumb") {
|
|
280
|
+
return min;
|
|
368
281
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
var import_node_util5, import_node_child_process5, execFileAsync3, windowsBrowserProgIds, _windowsBrowserProgIdMap, UnknownBrowserError;
|
|
377
|
-
var init_windows = __esm({
|
|
378
|
-
"../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js"() {
|
|
379
|
-
"use strict";
|
|
380
|
-
init_cjs_shims();
|
|
381
|
-
import_node_util5 = require("util");
|
|
382
|
-
import_node_child_process5 = require("child_process");
|
|
383
|
-
execFileAsync3 = (0, import_node_util5.promisify)(import_node_child_process5.execFile);
|
|
384
|
-
windowsBrowserProgIds = {
|
|
385
|
-
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
386
|
-
// The missing `L` is correct.
|
|
387
|
-
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
388
|
-
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
389
|
-
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
390
|
-
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
391
|
-
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
392
|
-
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
393
|
-
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
394
|
-
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
395
|
-
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
396
|
-
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
397
|
-
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
398
|
-
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
399
|
-
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
400
|
-
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
401
|
-
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
402
|
-
};
|
|
403
|
-
_windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
404
|
-
UnknownBrowserError = class extends Error {
|
|
405
|
-
};
|
|
282
|
+
if (import_node_process.default.platform === "win32") {
|
|
283
|
+
const osRelease = import_node_os.default.release().split(".");
|
|
284
|
+
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
285
|
+
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
286
|
+
}
|
|
287
|
+
return 1;
|
|
406
288
|
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return
|
|
289
|
+
if ("CI" in env) {
|
|
290
|
+
if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key) => key in env)) {
|
|
291
|
+
return 3;
|
|
292
|
+
}
|
|
293
|
+
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
|
|
294
|
+
return 1;
|
|
295
|
+
}
|
|
296
|
+
return min;
|
|
415
297
|
}
|
|
416
|
-
if (
|
|
417
|
-
|
|
418
|
-
const id = stdout.trim();
|
|
419
|
-
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
420
|
-
return { name, id };
|
|
298
|
+
if ("TEAMCITY_VERSION" in env) {
|
|
299
|
+
return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
421
300
|
}
|
|
422
|
-
if (
|
|
423
|
-
return
|
|
301
|
+
if (env.COLORTERM === "truecolor") {
|
|
302
|
+
return 3;
|
|
424
303
|
}
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
var import_node_util6, import_node_process6, import_node_child_process6, execFileAsync4, titleize;
|
|
428
|
-
var init_default_browser = __esm({
|
|
429
|
-
"../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js"() {
|
|
430
|
-
"use strict";
|
|
431
|
-
init_cjs_shims();
|
|
432
|
-
import_node_util6 = require("util");
|
|
433
|
-
import_node_process6 = __toESM(require("process"), 1);
|
|
434
|
-
import_node_child_process6 = require("child_process");
|
|
435
|
-
init_default_browser_id();
|
|
436
|
-
init_bundle_name();
|
|
437
|
-
init_windows();
|
|
438
|
-
init_windows();
|
|
439
|
-
execFileAsync4 = (0, import_node_util6.promisify)(import_node_child_process6.execFile);
|
|
440
|
-
titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
304
|
+
if (env.TERM === "xterm-kitty") {
|
|
305
|
+
return 3;
|
|
441
306
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
// ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
445
|
-
var import_node_process7, isInSsh, is_in_ssh_default;
|
|
446
|
-
var init_is_in_ssh = __esm({
|
|
447
|
-
"../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js"() {
|
|
448
|
-
"use strict";
|
|
449
|
-
init_cjs_shims();
|
|
450
|
-
import_node_process7 = __toESM(require("process"), 1);
|
|
451
|
-
isInSsh = Boolean(import_node_process7.default.env.SSH_CONNECTION || import_node_process7.default.env.SSH_CLIENT || import_node_process7.default.env.SSH_TTY);
|
|
452
|
-
is_in_ssh_default = isInSsh;
|
|
307
|
+
if (env.TERM === "xterm-ghostty") {
|
|
308
|
+
return 3;
|
|
453
309
|
}
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
457
|
-
var open_exports = {};
|
|
458
|
-
__export(open_exports, {
|
|
459
|
-
apps: () => apps,
|
|
460
|
-
default: () => open_default,
|
|
461
|
-
openApp: () => openApp
|
|
462
|
-
});
|
|
463
|
-
function detectArchBinary(binary) {
|
|
464
|
-
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
465
|
-
return binary;
|
|
310
|
+
if (env.TERM === "wezterm") {
|
|
311
|
+
return 3;
|
|
466
312
|
}
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
313
|
+
if ("TERM_PROGRAM" in env) {
|
|
314
|
+
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || "").split(".")[0], 10);
|
|
315
|
+
switch (env.TERM_PROGRAM) {
|
|
316
|
+
case "iTerm.app": {
|
|
317
|
+
return version >= 3 ? 3 : 2;
|
|
318
|
+
}
|
|
319
|
+
case "Apple_Terminal": {
|
|
320
|
+
return 2;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
470
323
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
474
|
-
if (wsl && is_wsl_default) {
|
|
475
|
-
return detectArchBinary(wsl);
|
|
324
|
+
if (/-256(color)?$/i.test(env.TERM)) {
|
|
325
|
+
return 2;
|
|
476
326
|
}
|
|
477
|
-
if (
|
|
478
|
-
|
|
327
|
+
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
|
|
328
|
+
return 1;
|
|
479
329
|
}
|
|
480
|
-
|
|
330
|
+
if ("COLORTERM" in env) {
|
|
331
|
+
return 1;
|
|
332
|
+
}
|
|
333
|
+
return min;
|
|
481
334
|
}
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
init_define_lazy_prop();
|
|
495
|
-
init_default_browser();
|
|
496
|
-
init_is_inside_container();
|
|
497
|
-
init_is_in_ssh();
|
|
498
|
-
fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
499
|
-
__dirname2 = importMetaUrl ? import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl)) : "";
|
|
500
|
-
localXdgOpenPath = import_node_path.default.join(__dirname2, "xdg-open");
|
|
501
|
-
({ platform, arch } = import_node_process8.default);
|
|
502
|
-
tryEachApp = async (apps2, opener) => {
|
|
503
|
-
if (apps2.length === 0) {
|
|
504
|
-
return;
|
|
505
|
-
}
|
|
506
|
-
const errors = [];
|
|
507
|
-
for (const app of apps2) {
|
|
508
|
-
try {
|
|
509
|
-
return await opener(app);
|
|
510
|
-
} catch (error) {
|
|
511
|
-
errors.push(error);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
515
|
-
};
|
|
516
|
-
baseOpen = async (options) => {
|
|
517
|
-
options = {
|
|
518
|
-
wait: false,
|
|
519
|
-
background: false,
|
|
520
|
-
newInstance: false,
|
|
521
|
-
allowNonzeroExitCode: false,
|
|
522
|
-
...options
|
|
523
|
-
};
|
|
524
|
-
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
525
|
-
delete options[fallbackAttemptSymbol];
|
|
526
|
-
if (Array.isArray(options.app)) {
|
|
527
|
-
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
528
|
-
...options,
|
|
529
|
-
app: singleApp,
|
|
530
|
-
[fallbackAttemptSymbol]: true
|
|
531
|
-
}));
|
|
532
|
-
}
|
|
533
|
-
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
534
|
-
appArguments = [...appArguments];
|
|
535
|
-
if (Array.isArray(app)) {
|
|
536
|
-
return tryEachApp(app, (appName) => baseOpen({
|
|
537
|
-
...options,
|
|
538
|
-
app: {
|
|
539
|
-
name: appName,
|
|
540
|
-
arguments: appArguments
|
|
541
|
-
},
|
|
542
|
-
[fallbackAttemptSymbol]: true
|
|
543
|
-
}));
|
|
544
|
-
}
|
|
545
|
-
if (app === "browser" || app === "browserPrivate") {
|
|
546
|
-
const ids = {
|
|
547
|
-
"com.google.chrome": "chrome",
|
|
548
|
-
"google-chrome.desktop": "chrome",
|
|
549
|
-
"com.brave.browser": "brave",
|
|
550
|
-
"org.mozilla.firefox": "firefox",
|
|
551
|
-
"firefox.desktop": "firefox",
|
|
552
|
-
"com.microsoft.msedge": "edge",
|
|
553
|
-
"com.microsoft.edge": "edge",
|
|
554
|
-
"com.microsoft.edgemac": "edge",
|
|
555
|
-
"microsoft-edge.desktop": "edge",
|
|
556
|
-
"com.apple.safari": "safari"
|
|
557
|
-
};
|
|
558
|
-
const flags = {
|
|
559
|
-
chrome: "--incognito",
|
|
560
|
-
brave: "--incognito",
|
|
561
|
-
firefox: "--private-window",
|
|
562
|
-
edge: "--inPrivate"
|
|
563
|
-
// Safari doesn't support private mode via command line
|
|
564
|
-
};
|
|
565
|
-
let browser;
|
|
566
|
-
if (is_wsl_default) {
|
|
567
|
-
const progId = await wslDefaultBrowser();
|
|
568
|
-
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
569
|
-
browser = browserInfo ?? {};
|
|
570
|
-
} else {
|
|
571
|
-
browser = await defaultBrowser2();
|
|
572
|
-
}
|
|
573
|
-
if (browser.id in ids) {
|
|
574
|
-
const browserName = ids[browser.id.toLowerCase()];
|
|
575
|
-
if (app === "browserPrivate") {
|
|
576
|
-
if (browserName === "safari") {
|
|
577
|
-
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
578
|
-
}
|
|
579
|
-
appArguments.push(flags[browserName]);
|
|
580
|
-
}
|
|
581
|
-
return baseOpen({
|
|
582
|
-
...options,
|
|
583
|
-
app: {
|
|
584
|
-
name: apps[browserName],
|
|
585
|
-
arguments: appArguments
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
590
|
-
}
|
|
591
|
-
let command;
|
|
592
|
-
const cliArguments = [];
|
|
593
|
-
const childProcessOptions = {};
|
|
594
|
-
let shouldUseWindowsInWsl = false;
|
|
595
|
-
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
596
|
-
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
597
|
-
}
|
|
598
|
-
if (platform === "darwin") {
|
|
599
|
-
command = "open";
|
|
600
|
-
if (options.wait) {
|
|
601
|
-
cliArguments.push("--wait-apps");
|
|
602
|
-
}
|
|
603
|
-
if (options.background) {
|
|
604
|
-
cliArguments.push("--background");
|
|
605
|
-
}
|
|
606
|
-
if (options.newInstance) {
|
|
607
|
-
cliArguments.push("--new");
|
|
608
|
-
}
|
|
609
|
-
if (app) {
|
|
610
|
-
cliArguments.push("-a", app);
|
|
611
|
-
}
|
|
612
|
-
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
613
|
-
command = await powerShellPath2();
|
|
614
|
-
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
615
|
-
if (!is_wsl_default) {
|
|
616
|
-
childProcessOptions.windowsVerbatimArguments = true;
|
|
617
|
-
}
|
|
618
|
-
if (is_wsl_default && options.target) {
|
|
619
|
-
options.target = await convertWslPathToWindows(options.target);
|
|
620
|
-
}
|
|
621
|
-
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
622
|
-
if (options.wait) {
|
|
623
|
-
encodedArguments.push("-Wait");
|
|
624
|
-
}
|
|
625
|
-
if (app) {
|
|
626
|
-
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
627
|
-
if (options.target) {
|
|
628
|
-
appArguments.push(options.target);
|
|
629
|
-
}
|
|
630
|
-
} else if (options.target) {
|
|
631
|
-
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
632
|
-
}
|
|
633
|
-
if (appArguments.length > 0) {
|
|
634
|
-
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
635
|
-
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
636
|
-
}
|
|
637
|
-
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
638
|
-
if (!options.wait) {
|
|
639
|
-
childProcessOptions.stdio = "ignore";
|
|
640
|
-
}
|
|
641
|
-
} else {
|
|
642
|
-
if (app) {
|
|
643
|
-
command = app;
|
|
644
|
-
} else {
|
|
645
|
-
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
646
|
-
let exeLocalXdgOpen = false;
|
|
647
|
-
try {
|
|
648
|
-
await import_promises3.default.access(localXdgOpenPath, import_promises3.constants.X_OK);
|
|
649
|
-
exeLocalXdgOpen = true;
|
|
650
|
-
} catch {
|
|
651
|
-
}
|
|
652
|
-
const useSystemXdgOpen = import_node_process8.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
653
|
-
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
654
|
-
}
|
|
655
|
-
if (appArguments.length > 0) {
|
|
656
|
-
cliArguments.push(...appArguments);
|
|
657
|
-
}
|
|
658
|
-
if (!options.wait) {
|
|
659
|
-
childProcessOptions.stdio = "ignore";
|
|
660
|
-
childProcessOptions.detached = true;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
if (platform === "darwin" && appArguments.length > 0) {
|
|
664
|
-
cliArguments.push("--args", ...appArguments);
|
|
665
|
-
}
|
|
666
|
-
if (options.target) {
|
|
667
|
-
cliArguments.push(options.target);
|
|
668
|
-
}
|
|
669
|
-
const subprocess = import_node_child_process7.default.spawn(command, cliArguments, childProcessOptions);
|
|
670
|
-
if (options.wait) {
|
|
671
|
-
return new Promise((resolve2, reject) => {
|
|
672
|
-
subprocess.once("error", reject);
|
|
673
|
-
subprocess.once("close", (exitCode) => {
|
|
674
|
-
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
675
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
676
|
-
return;
|
|
677
|
-
}
|
|
678
|
-
resolve2(subprocess);
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
}
|
|
682
|
-
if (isFallbackAttempt) {
|
|
683
|
-
return new Promise((resolve2, reject) => {
|
|
684
|
-
subprocess.once("error", reject);
|
|
685
|
-
subprocess.once("spawn", () => {
|
|
686
|
-
subprocess.once("close", (exitCode) => {
|
|
687
|
-
subprocess.off("error", reject);
|
|
688
|
-
if (exitCode !== 0) {
|
|
689
|
-
reject(new Error(`Exited with code ${exitCode}`));
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
subprocess.unref();
|
|
693
|
-
resolve2(subprocess);
|
|
694
|
-
});
|
|
695
|
-
});
|
|
696
|
-
});
|
|
697
|
-
}
|
|
698
|
-
subprocess.unref();
|
|
699
|
-
return new Promise((resolve2, reject) => {
|
|
700
|
-
subprocess.once("error", reject);
|
|
701
|
-
subprocess.once("spawn", () => {
|
|
702
|
-
subprocess.off("error", reject);
|
|
703
|
-
resolve2(subprocess);
|
|
704
|
-
});
|
|
705
|
-
});
|
|
706
|
-
};
|
|
707
|
-
open = (target, options) => {
|
|
708
|
-
if (typeof target !== "string") {
|
|
709
|
-
throw new TypeError("Expected a `target`");
|
|
710
|
-
}
|
|
711
|
-
return baseOpen({
|
|
712
|
-
...options,
|
|
713
|
-
target
|
|
714
|
-
});
|
|
715
|
-
};
|
|
716
|
-
openApp = (name, options) => {
|
|
717
|
-
if (typeof name !== "string" && !Array.isArray(name)) {
|
|
718
|
-
throw new TypeError("Expected a valid `name`");
|
|
719
|
-
}
|
|
720
|
-
const { arguments: appArguments = [] } = options ?? {};
|
|
721
|
-
if (appArguments !== void 0 && appArguments !== null && !Array.isArray(appArguments)) {
|
|
722
|
-
throw new TypeError("Expected `appArguments` as Array type");
|
|
723
|
-
}
|
|
724
|
-
return baseOpen({
|
|
725
|
-
...options,
|
|
726
|
-
app: {
|
|
727
|
-
name,
|
|
728
|
-
arguments: appArguments
|
|
729
|
-
}
|
|
730
|
-
});
|
|
731
|
-
};
|
|
732
|
-
apps = {
|
|
733
|
-
browser: "browser",
|
|
734
|
-
browserPrivate: "browserPrivate"
|
|
735
|
-
};
|
|
736
|
-
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
737
|
-
darwin: "google chrome",
|
|
738
|
-
win32: "chrome",
|
|
739
|
-
// `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
|
|
740
|
-
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
741
|
-
}, {
|
|
742
|
-
wsl: {
|
|
743
|
-
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
744
|
-
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
745
|
-
}
|
|
746
|
-
}));
|
|
747
|
-
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
748
|
-
darwin: "brave browser",
|
|
749
|
-
win32: "brave",
|
|
750
|
-
linux: ["brave-browser", "brave"]
|
|
751
|
-
}, {
|
|
752
|
-
wsl: {
|
|
753
|
-
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
754
|
-
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
755
|
-
}
|
|
756
|
-
}));
|
|
757
|
-
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
758
|
-
darwin: "firefox",
|
|
759
|
-
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
760
|
-
linux: "firefox"
|
|
761
|
-
}, {
|
|
762
|
-
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
763
|
-
}));
|
|
764
|
-
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
765
|
-
darwin: "microsoft edge",
|
|
766
|
-
win32: "msedge",
|
|
767
|
-
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
768
|
-
}, {
|
|
769
|
-
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
770
|
-
}));
|
|
771
|
-
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
772
|
-
darwin: "Safari"
|
|
773
|
-
}));
|
|
774
|
-
open_default = open;
|
|
775
|
-
}
|
|
776
|
-
});
|
|
335
|
+
function createSupportsColor(stream, options = {}) {
|
|
336
|
+
const level = _supportsColor(stream, {
|
|
337
|
+
streamIsTTY: stream && stream.isTTY,
|
|
338
|
+
...options
|
|
339
|
+
});
|
|
340
|
+
return translateLevel(level);
|
|
341
|
+
}
|
|
342
|
+
var supportsColor = {
|
|
343
|
+
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
344
|
+
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
345
|
+
};
|
|
346
|
+
var supports_color_default = supportsColor;
|
|
777
347
|
|
|
778
|
-
//
|
|
779
|
-
|
|
348
|
+
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/utilities.js
|
|
349
|
+
function stringReplaceAll(string, substring, replacer) {
|
|
350
|
+
let index = string.indexOf(substring);
|
|
351
|
+
if (index === -1) {
|
|
352
|
+
return string;
|
|
353
|
+
}
|
|
354
|
+
const substringLength = substring.length;
|
|
355
|
+
let endIndex = 0;
|
|
356
|
+
let returnValue = "";
|
|
357
|
+
do {
|
|
358
|
+
returnValue += string.slice(endIndex, index) + substring + replacer;
|
|
359
|
+
endIndex = index + substringLength;
|
|
360
|
+
index = string.indexOf(substring, endIndex);
|
|
361
|
+
} while (index !== -1);
|
|
362
|
+
returnValue += string.slice(endIndex);
|
|
363
|
+
return returnValue;
|
|
364
|
+
}
|
|
365
|
+
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
366
|
+
let endIndex = 0;
|
|
367
|
+
let returnValue = "";
|
|
368
|
+
do {
|
|
369
|
+
const gotCR = string[index - 1] === "\r";
|
|
370
|
+
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
371
|
+
endIndex = index + 1;
|
|
372
|
+
index = string.indexOf("\n", endIndex);
|
|
373
|
+
} while (index !== -1);
|
|
374
|
+
returnValue += string.slice(endIndex);
|
|
375
|
+
return returnValue;
|
|
376
|
+
}
|
|
780
377
|
|
|
781
378
|
// ../../node_modules/.pnpm/chalk@5.6.2/node_modules/chalk/source/index.js
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
var
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
italic: [3, 23],
|
|
797
|
-
underline: [4, 24],
|
|
798
|
-
overline: [53, 55],
|
|
799
|
-
inverse: [7, 27],
|
|
800
|
-
hidden: [8, 28],
|
|
801
|
-
strikethrough: [9, 29]
|
|
802
|
-
},
|
|
803
|
-
color: {
|
|
804
|
-
black: [30, 39],
|
|
805
|
-
red: [31, 39],
|
|
806
|
-
green: [32, 39],
|
|
807
|
-
yellow: [33, 39],
|
|
808
|
-
blue: [34, 39],
|
|
809
|
-
magenta: [35, 39],
|
|
810
|
-
cyan: [36, 39],
|
|
811
|
-
white: [37, 39],
|
|
812
|
-
// Bright color
|
|
813
|
-
blackBright: [90, 39],
|
|
814
|
-
gray: [90, 39],
|
|
815
|
-
// Alias of `blackBright`
|
|
816
|
-
grey: [90, 39],
|
|
817
|
-
// Alias of `blackBright`
|
|
818
|
-
redBright: [91, 39],
|
|
819
|
-
greenBright: [92, 39],
|
|
820
|
-
yellowBright: [93, 39],
|
|
821
|
-
blueBright: [94, 39],
|
|
822
|
-
magentaBright: [95, 39],
|
|
823
|
-
cyanBright: [96, 39],
|
|
824
|
-
whiteBright: [97, 39]
|
|
825
|
-
},
|
|
826
|
-
bgColor: {
|
|
827
|
-
bgBlack: [40, 49],
|
|
828
|
-
bgRed: [41, 49],
|
|
829
|
-
bgGreen: [42, 49],
|
|
830
|
-
bgYellow: [43, 49],
|
|
831
|
-
bgBlue: [44, 49],
|
|
832
|
-
bgMagenta: [45, 49],
|
|
833
|
-
bgCyan: [46, 49],
|
|
834
|
-
bgWhite: [47, 49],
|
|
835
|
-
// Bright color
|
|
836
|
-
bgBlackBright: [100, 49],
|
|
837
|
-
bgGray: [100, 49],
|
|
838
|
-
// Alias of `bgBlackBright`
|
|
839
|
-
bgGrey: [100, 49],
|
|
840
|
-
// Alias of `bgBlackBright`
|
|
841
|
-
bgRedBright: [101, 49],
|
|
842
|
-
bgGreenBright: [102, 49],
|
|
843
|
-
bgYellowBright: [103, 49],
|
|
844
|
-
bgBlueBright: [104, 49],
|
|
845
|
-
bgMagentaBright: [105, 49],
|
|
846
|
-
bgCyanBright: [106, 49],
|
|
847
|
-
bgWhiteBright: [107, 49]
|
|
379
|
+
var { stdout: stdoutColor, stderr: stderrColor } = supports_color_default;
|
|
380
|
+
var GENERATOR = /* @__PURE__ */ Symbol("GENERATOR");
|
|
381
|
+
var STYLER = /* @__PURE__ */ Symbol("STYLER");
|
|
382
|
+
var IS_EMPTY = /* @__PURE__ */ Symbol("IS_EMPTY");
|
|
383
|
+
var levelMapping = [
|
|
384
|
+
"ansi",
|
|
385
|
+
"ansi",
|
|
386
|
+
"ansi256",
|
|
387
|
+
"ansi16m"
|
|
388
|
+
];
|
|
389
|
+
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
390
|
+
var applyOptions = (object, options = {}) => {
|
|
391
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
392
|
+
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
848
393
|
}
|
|
394
|
+
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
395
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
849
396
|
};
|
|
850
|
-
var
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
397
|
+
var chalkFactory = (options) => {
|
|
398
|
+
const chalk2 = (...strings) => strings.join(" ");
|
|
399
|
+
applyOptions(chalk2, options);
|
|
400
|
+
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
401
|
+
return chalk2;
|
|
402
|
+
};
|
|
403
|
+
function createChalk(options) {
|
|
404
|
+
return chalkFactory(options);
|
|
405
|
+
}
|
|
406
|
+
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
407
|
+
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
408
|
+
styles2[styleName] = {
|
|
409
|
+
get() {
|
|
410
|
+
const builder = createBuilder(this, createStyler(style.open, style.close, this[STYLER]), this[IS_EMPTY]);
|
|
411
|
+
Object.defineProperty(this, styleName, { value: builder });
|
|
412
|
+
return builder;
|
|
864
413
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
styles2.visible = {
|
|
417
|
+
get() {
|
|
418
|
+
const builder = createBuilder(this, this[STYLER], true);
|
|
419
|
+
Object.defineProperty(this, "visible", { value: builder });
|
|
420
|
+
return builder;
|
|
869
421
|
}
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
styles.bgColor.close = "\x1B[49m";
|
|
876
|
-
styles.color.ansi = wrapAnsi16();
|
|
877
|
-
styles.color.ansi256 = wrapAnsi256();
|
|
878
|
-
styles.color.ansi16m = wrapAnsi16m();
|
|
879
|
-
styles.bgColor.ansi = wrapAnsi16(ANSI_BACKGROUND_OFFSET);
|
|
880
|
-
styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
|
|
881
|
-
styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
|
|
882
|
-
Object.defineProperties(styles, {
|
|
883
|
-
rgbToAnsi256: {
|
|
884
|
-
value(red, green, blue) {
|
|
885
|
-
if (red === green && green === blue) {
|
|
886
|
-
if (red < 8) {
|
|
887
|
-
return 16;
|
|
888
|
-
}
|
|
889
|
-
if (red > 248) {
|
|
890
|
-
return 231;
|
|
891
|
-
}
|
|
892
|
-
return Math.round((red - 8) / 247 * 24) + 232;
|
|
893
|
-
}
|
|
894
|
-
return 16 + 36 * Math.round(red / 255 * 5) + 6 * Math.round(green / 255 * 5) + Math.round(blue / 255 * 5);
|
|
895
|
-
},
|
|
896
|
-
enumerable: false
|
|
897
|
-
},
|
|
898
|
-
hexToRgb: {
|
|
899
|
-
value(hex) {
|
|
900
|
-
const matches = /[a-f\d]{6}|[a-f\d]{3}/i.exec(hex.toString(16));
|
|
901
|
-
if (!matches) {
|
|
902
|
-
return [0, 0, 0];
|
|
903
|
-
}
|
|
904
|
-
let [colorString] = matches;
|
|
905
|
-
if (colorString.length === 3) {
|
|
906
|
-
colorString = [...colorString].map((character) => character + character).join("");
|
|
907
|
-
}
|
|
908
|
-
const integer = Number.parseInt(colorString, 16);
|
|
909
|
-
return [
|
|
910
|
-
/* eslint-disable no-bitwise */
|
|
911
|
-
integer >> 16 & 255,
|
|
912
|
-
integer >> 8 & 255,
|
|
913
|
-
integer & 255
|
|
914
|
-
/* eslint-enable no-bitwise */
|
|
915
|
-
];
|
|
916
|
-
},
|
|
917
|
-
enumerable: false
|
|
918
|
-
},
|
|
919
|
-
hexToAnsi256: {
|
|
920
|
-
value: (hex) => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
|
|
921
|
-
enumerable: false
|
|
922
|
-
},
|
|
923
|
-
ansi256ToAnsi: {
|
|
924
|
-
value(code) {
|
|
925
|
-
if (code < 8) {
|
|
926
|
-
return 30 + code;
|
|
927
|
-
}
|
|
928
|
-
if (code < 16) {
|
|
929
|
-
return 90 + (code - 8);
|
|
930
|
-
}
|
|
931
|
-
let red;
|
|
932
|
-
let green;
|
|
933
|
-
let blue;
|
|
934
|
-
if (code >= 232) {
|
|
935
|
-
red = ((code - 232) * 10 + 8) / 255;
|
|
936
|
-
green = red;
|
|
937
|
-
blue = red;
|
|
938
|
-
} else {
|
|
939
|
-
code -= 16;
|
|
940
|
-
const remainder = code % 36;
|
|
941
|
-
red = Math.floor(code / 36) / 5;
|
|
942
|
-
green = Math.floor(remainder / 6) / 5;
|
|
943
|
-
blue = remainder % 6 / 5;
|
|
944
|
-
}
|
|
945
|
-
const value = Math.max(red, green, blue) * 2;
|
|
946
|
-
if (value === 0) {
|
|
947
|
-
return 30;
|
|
948
|
-
}
|
|
949
|
-
let result = 30 + (Math.round(blue) << 2 | Math.round(green) << 1 | Math.round(red));
|
|
950
|
-
if (value === 2) {
|
|
951
|
-
result += 60;
|
|
952
|
-
}
|
|
953
|
-
return result;
|
|
954
|
-
},
|
|
955
|
-
enumerable: false
|
|
956
|
-
},
|
|
957
|
-
rgbToAnsi: {
|
|
958
|
-
value: (red, green, blue) => styles.ansi256ToAnsi(styles.rgbToAnsi256(red, green, blue)),
|
|
959
|
-
enumerable: false
|
|
960
|
-
},
|
|
961
|
-
hexToAnsi: {
|
|
962
|
-
value: (hex) => styles.ansi256ToAnsi(styles.hexToAnsi256(hex)),
|
|
963
|
-
enumerable: false
|
|
422
|
+
};
|
|
423
|
+
var getModelAnsi = (model, level, type, ...arguments_) => {
|
|
424
|
+
if (model === "rgb") {
|
|
425
|
+
if (level === "ansi16m") {
|
|
426
|
+
return ansi_styles_default[type].ansi16m(...arguments_);
|
|
964
427
|
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
var
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
if (hasFlag("no-color") || hasFlag("no-colors") || hasFlag("color=false") || hasFlag("color=never")) {
|
|
985
|
-
flagForceColor = 0;
|
|
986
|
-
} else if (hasFlag("color") || hasFlag("colors") || hasFlag("color=true") || hasFlag("color=always")) {
|
|
987
|
-
flagForceColor = 1;
|
|
988
|
-
}
|
|
989
|
-
function envForceColor() {
|
|
990
|
-
if ("FORCE_COLOR" in env) {
|
|
991
|
-
if (env.FORCE_COLOR === "true") {
|
|
992
|
-
return 1;
|
|
428
|
+
if (level === "ansi256") {
|
|
429
|
+
return ansi_styles_default[type].ansi256(ansi_styles_default.rgbToAnsi256(...arguments_));
|
|
430
|
+
}
|
|
431
|
+
return ansi_styles_default[type].ansi(ansi_styles_default.rgbToAnsi(...arguments_));
|
|
432
|
+
}
|
|
433
|
+
if (model === "hex") {
|
|
434
|
+
return getModelAnsi("rgb", level, type, ...ansi_styles_default.hexToRgb(...arguments_));
|
|
435
|
+
}
|
|
436
|
+
return ansi_styles_default[type][model](...arguments_);
|
|
437
|
+
};
|
|
438
|
+
var usedModels = ["rgb", "hex", "ansi256"];
|
|
439
|
+
for (const model of usedModels) {
|
|
440
|
+
styles2[model] = {
|
|
441
|
+
get() {
|
|
442
|
+
const { level } = this;
|
|
443
|
+
return function(...arguments_) {
|
|
444
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
445
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
446
|
+
};
|
|
993
447
|
}
|
|
994
|
-
|
|
995
|
-
|
|
448
|
+
};
|
|
449
|
+
const bgModel = "bg" + model[0].toUpperCase() + model.slice(1);
|
|
450
|
+
styles2[bgModel] = {
|
|
451
|
+
get() {
|
|
452
|
+
const { level } = this;
|
|
453
|
+
return function(...arguments_) {
|
|
454
|
+
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
455
|
+
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
456
|
+
};
|
|
996
457
|
}
|
|
997
|
-
|
|
998
|
-
}
|
|
458
|
+
};
|
|
999
459
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
460
|
+
var proto = Object.defineProperties(() => {
|
|
461
|
+
}, {
|
|
462
|
+
...styles2,
|
|
463
|
+
level: {
|
|
464
|
+
enumerable: true,
|
|
465
|
+
get() {
|
|
466
|
+
return this[GENERATOR].level;
|
|
467
|
+
},
|
|
468
|
+
set(level) {
|
|
469
|
+
this[GENERATOR].level = level;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
});
|
|
473
|
+
var createStyler = (open2, close, parent) => {
|
|
474
|
+
let openAll;
|
|
475
|
+
let closeAll;
|
|
476
|
+
if (parent === void 0) {
|
|
477
|
+
openAll = open2;
|
|
478
|
+
closeAll = close;
|
|
479
|
+
} else {
|
|
480
|
+
openAll = parent.openAll + open2;
|
|
481
|
+
closeAll = close + parent.closeAll;
|
|
1003
482
|
}
|
|
1004
483
|
return {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
484
|
+
open: open2,
|
|
485
|
+
close,
|
|
486
|
+
openAll,
|
|
487
|
+
closeAll,
|
|
488
|
+
parent
|
|
1009
489
|
};
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1014
|
-
|
|
490
|
+
};
|
|
491
|
+
var createBuilder = (self, _styler, _isEmpty) => {
|
|
492
|
+
const builder = (...arguments_) => applyStyle(builder, arguments_.length === 1 ? "" + arguments_[0] : arguments_.join(" "));
|
|
493
|
+
Object.setPrototypeOf(builder, proto);
|
|
494
|
+
builder[GENERATOR] = self;
|
|
495
|
+
builder[STYLER] = _styler;
|
|
496
|
+
builder[IS_EMPTY] = _isEmpty;
|
|
497
|
+
return builder;
|
|
498
|
+
};
|
|
499
|
+
var applyStyle = (self, string) => {
|
|
500
|
+
if (self.level <= 0 || !string) {
|
|
501
|
+
return self[IS_EMPTY] ? "" : string;
|
|
1015
502
|
}
|
|
1016
|
-
|
|
1017
|
-
if (
|
|
1018
|
-
return
|
|
503
|
+
let styler = self[STYLER];
|
|
504
|
+
if (styler === void 0) {
|
|
505
|
+
return string;
|
|
1019
506
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
return 2;
|
|
507
|
+
const { openAll, closeAll } = styler;
|
|
508
|
+
if (string.includes("\x1B")) {
|
|
509
|
+
while (styler !== void 0) {
|
|
510
|
+
string = stringReplaceAll(string, styler.close, styler.open);
|
|
511
|
+
styler = styler.parent;
|
|
1026
512
|
}
|
|
1027
513
|
}
|
|
1028
|
-
|
|
1029
|
-
|
|
514
|
+
const lfIndex = string.indexOf("\n");
|
|
515
|
+
if (lfIndex !== -1) {
|
|
516
|
+
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1030
517
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
518
|
+
return openAll + string + closeAll;
|
|
519
|
+
};
|
|
520
|
+
Object.defineProperties(createChalk.prototype, styles2);
|
|
521
|
+
var chalk = createChalk();
|
|
522
|
+
var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
|
|
523
|
+
var source_default = chalk;
|
|
524
|
+
|
|
525
|
+
// src/index.ts
|
|
526
|
+
var import_commander7 = require("commander");
|
|
527
|
+
var import_config8 = require("dotenv/config");
|
|
528
|
+
var import_node_child_process11 = require("child_process");
|
|
529
|
+
var import_node_fs14 = require("fs");
|
|
530
|
+
var import_promises8 = require("fs/promises");
|
|
531
|
+
var import_node_module2 = require("module");
|
|
532
|
+
var import_node_path12 = __toESM(require("path"), 1);
|
|
533
|
+
var import_node_url3 = require("url");
|
|
534
|
+
|
|
535
|
+
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
536
|
+
var import_node_process8 = __toESM(require("process"), 1);
|
|
537
|
+
var import_node_path = __toESM(require("path"), 1);
|
|
538
|
+
var import_node_url = require("url");
|
|
539
|
+
var import_node_child_process7 = __toESM(require("child_process"), 1);
|
|
540
|
+
var import_promises3 = __toESM(require("fs/promises"), 1);
|
|
541
|
+
|
|
542
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
543
|
+
var import_node_util2 = require("util");
|
|
544
|
+
var import_node_child_process2 = __toESM(require("child_process"), 1);
|
|
545
|
+
var import_promises2 = __toESM(require("fs/promises"), 1);
|
|
546
|
+
|
|
547
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
|
|
548
|
+
var import_node_process2 = __toESM(require("process"), 1);
|
|
549
|
+
var import_node_os2 = __toESM(require("os"), 1);
|
|
550
|
+
var import_node_fs3 = __toESM(require("fs"), 1);
|
|
551
|
+
|
|
552
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
553
|
+
var import_node_fs2 = __toESM(require("fs"), 1);
|
|
554
|
+
|
|
555
|
+
// ../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
|
|
556
|
+
var import_node_fs = __toESM(require("fs"), 1);
|
|
557
|
+
var isDockerCached;
|
|
558
|
+
function hasDockerEnv() {
|
|
559
|
+
try {
|
|
560
|
+
import_node_fs.default.statSync("/.dockerenv");
|
|
561
|
+
return true;
|
|
562
|
+
} catch {
|
|
563
|
+
return false;
|
|
1033
564
|
}
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
565
|
+
}
|
|
566
|
+
function hasDockerCGroup() {
|
|
567
|
+
try {
|
|
568
|
+
return import_node_fs.default.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
|
|
569
|
+
} catch {
|
|
570
|
+
return false;
|
|
1037
571
|
}
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
}
|
|
1043
|
-
return 1;
|
|
572
|
+
}
|
|
573
|
+
function isDocker() {
|
|
574
|
+
if (isDockerCached === void 0) {
|
|
575
|
+
isDockerCached = hasDockerEnv() || hasDockerCGroup();
|
|
1044
576
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
577
|
+
return isDockerCached;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// ../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
|
|
581
|
+
var cachedResult;
|
|
582
|
+
var hasContainerEnv = () => {
|
|
583
|
+
try {
|
|
584
|
+
import_node_fs2.default.statSync("/run/.containerenv");
|
|
585
|
+
return true;
|
|
586
|
+
} catch {
|
|
587
|
+
return false;
|
|
1053
588
|
}
|
|
1054
|
-
|
|
1055
|
-
|
|
589
|
+
};
|
|
590
|
+
function isInsideContainer() {
|
|
591
|
+
if (cachedResult === void 0) {
|
|
592
|
+
cachedResult = hasContainerEnv() || isDocker();
|
|
1056
593
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
594
|
+
return cachedResult;
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
// ../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
|
|
598
|
+
var isWsl = () => {
|
|
599
|
+
if (import_node_process2.default.platform !== "linux") {
|
|
600
|
+
return false;
|
|
1059
601
|
}
|
|
1060
|
-
if (
|
|
1061
|
-
|
|
602
|
+
if (import_node_os2.default.release().toLowerCase().includes("microsoft")) {
|
|
603
|
+
if (isInsideContainer()) {
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
return true;
|
|
1062
607
|
}
|
|
1063
|
-
|
|
1064
|
-
return
|
|
608
|
+
try {
|
|
609
|
+
return import_node_fs3.default.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
|
|
610
|
+
} catch {
|
|
611
|
+
return false;
|
|
1065
612
|
}
|
|
1066
|
-
|
|
1067
|
-
|
|
613
|
+
};
|
|
614
|
+
var is_wsl_default = import_node_process2.default.env.__IS_WSL_TEST__ ? isWsl : isWsl();
|
|
615
|
+
|
|
616
|
+
// ../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
|
|
617
|
+
var import_node_process3 = __toESM(require("process"), 1);
|
|
618
|
+
var import_node_buffer = require("buffer");
|
|
619
|
+
var import_node_util = require("util");
|
|
620
|
+
var import_node_child_process = __toESM(require("child_process"), 1);
|
|
621
|
+
var import_promises = __toESM(require("fs/promises"), 1);
|
|
622
|
+
var execFile = (0, import_node_util.promisify)(import_node_child_process.default.execFile);
|
|
623
|
+
var powerShellPath = () => `${import_node_process3.default.env.SYSTEMROOT || import_node_process3.default.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
|
|
624
|
+
var executePowerShell = async (command, options = {}) => {
|
|
625
|
+
const {
|
|
626
|
+
powerShellPath: psPath,
|
|
627
|
+
...execFileOptions
|
|
628
|
+
} = options;
|
|
629
|
+
const encodedCommand = executePowerShell.encodeCommand(command);
|
|
630
|
+
return execFile(
|
|
631
|
+
psPath ?? powerShellPath(),
|
|
632
|
+
[
|
|
633
|
+
...executePowerShell.argumentsPrefix,
|
|
634
|
+
encodedCommand
|
|
635
|
+
],
|
|
636
|
+
{
|
|
637
|
+
encoding: "utf8",
|
|
638
|
+
...execFileOptions
|
|
639
|
+
}
|
|
640
|
+
);
|
|
641
|
+
};
|
|
642
|
+
executePowerShell.argumentsPrefix = [
|
|
643
|
+
"-NoProfile",
|
|
644
|
+
"-NonInteractive",
|
|
645
|
+
"-ExecutionPolicy",
|
|
646
|
+
"Bypass",
|
|
647
|
+
"-EncodedCommand"
|
|
648
|
+
];
|
|
649
|
+
executePowerShell.encodeCommand = (command) => import_node_buffer.Buffer.from(command, "utf16le").toString("base64");
|
|
650
|
+
executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
651
|
+
|
|
652
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
|
|
653
|
+
function parseMountPointFromConfig(content) {
|
|
654
|
+
for (const line of content.split("\n")) {
|
|
655
|
+
if (/^\s*#/.test(line)) {
|
|
656
|
+
continue;
|
|
657
|
+
}
|
|
658
|
+
const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
|
|
659
|
+
if (!match) {
|
|
660
|
+
continue;
|
|
661
|
+
}
|
|
662
|
+
return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
|
|
1068
663
|
}
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
// ../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
|
|
667
|
+
var execFile2 = (0, import_node_util2.promisify)(import_node_child_process2.default.execFile);
|
|
668
|
+
var wslDrivesMountPoint = /* @__PURE__ */ (() => {
|
|
669
|
+
const defaultMountPoint = "/mnt/";
|
|
670
|
+
let mountPoint;
|
|
671
|
+
return async function() {
|
|
672
|
+
if (mountPoint) {
|
|
673
|
+
return mountPoint;
|
|
674
|
+
}
|
|
675
|
+
const configFilePath = "/etc/wsl.conf";
|
|
676
|
+
let isConfigFileExists = false;
|
|
677
|
+
try {
|
|
678
|
+
await import_promises2.default.access(configFilePath, import_promises2.constants.F_OK);
|
|
679
|
+
isConfigFileExists = true;
|
|
680
|
+
} catch {
|
|
681
|
+
}
|
|
682
|
+
if (!isConfigFileExists) {
|
|
683
|
+
return defaultMountPoint;
|
|
684
|
+
}
|
|
685
|
+
const configContent = await import_promises2.default.readFile(configFilePath, { encoding: "utf8" });
|
|
686
|
+
const parsedMountPoint = parseMountPointFromConfig(configContent);
|
|
687
|
+
if (parsedMountPoint === void 0) {
|
|
688
|
+
return defaultMountPoint;
|
|
689
|
+
}
|
|
690
|
+
mountPoint = parsedMountPoint;
|
|
691
|
+
mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
|
|
692
|
+
return mountPoint;
|
|
693
|
+
};
|
|
694
|
+
})();
|
|
695
|
+
var powerShellPathFromWsl = async () => {
|
|
696
|
+
const mountPoint = await wslDrivesMountPoint();
|
|
697
|
+
return `${mountPoint}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
|
|
698
|
+
};
|
|
699
|
+
var powerShellPath2 = is_wsl_default ? powerShellPathFromWsl : powerShellPath;
|
|
700
|
+
var canAccessPowerShellPromise;
|
|
701
|
+
var canAccessPowerShell = async () => {
|
|
702
|
+
canAccessPowerShellPromise ??= (async () => {
|
|
703
|
+
try {
|
|
704
|
+
const psPath = await powerShellPath2();
|
|
705
|
+
await import_promises2.default.access(psPath, import_promises2.constants.X_OK);
|
|
706
|
+
return true;
|
|
707
|
+
} catch {
|
|
708
|
+
return false;
|
|
709
|
+
}
|
|
710
|
+
})();
|
|
711
|
+
return canAccessPowerShellPromise;
|
|
712
|
+
};
|
|
713
|
+
var wslDefaultBrowser = async () => {
|
|
714
|
+
const psPath = await powerShellPath2();
|
|
715
|
+
const command = String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`;
|
|
716
|
+
const { stdout } = await executePowerShell(command, { powerShellPath: psPath });
|
|
717
|
+
return stdout.trim();
|
|
718
|
+
};
|
|
719
|
+
var convertWslPathToWindows = async (path11) => {
|
|
720
|
+
if (/^[a-z]+:\/\//i.test(path11)) {
|
|
721
|
+
return path11;
|
|
722
|
+
}
|
|
723
|
+
try {
|
|
724
|
+
const { stdout } = await execFile2("wslpath", ["-aw", path11], { encoding: "utf8" });
|
|
725
|
+
return stdout.trim();
|
|
726
|
+
} catch {
|
|
727
|
+
return path11;
|
|
728
|
+
}
|
|
729
|
+
};
|
|
730
|
+
|
|
731
|
+
// ../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
|
|
732
|
+
function defineLazyProperty(object, propertyName, valueGetter) {
|
|
733
|
+
const define = (value) => Object.defineProperty(object, propertyName, { value, enumerable: true, writable: true });
|
|
734
|
+
Object.defineProperty(object, propertyName, {
|
|
735
|
+
configurable: true,
|
|
736
|
+
enumerable: true,
|
|
737
|
+
get() {
|
|
738
|
+
const result = valueGetter();
|
|
739
|
+
define(result);
|
|
740
|
+
return result;
|
|
741
|
+
},
|
|
742
|
+
set(value) {
|
|
743
|
+
define(value);
|
|
1078
744
|
}
|
|
745
|
+
});
|
|
746
|
+
return object;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
750
|
+
var import_node_util6 = require("util");
|
|
751
|
+
var import_node_process6 = __toESM(require("process"), 1);
|
|
752
|
+
var import_node_child_process6 = require("child_process");
|
|
753
|
+
|
|
754
|
+
// ../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
|
|
755
|
+
var import_node_util3 = require("util");
|
|
756
|
+
var import_node_process4 = __toESM(require("process"), 1);
|
|
757
|
+
var import_node_child_process3 = require("child_process");
|
|
758
|
+
var execFileAsync = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
759
|
+
async function defaultBrowserId() {
|
|
760
|
+
if (import_node_process4.default.platform !== "darwin") {
|
|
761
|
+
throw new Error("macOS only");
|
|
1079
762
|
}
|
|
1080
|
-
|
|
1081
|
-
|
|
763
|
+
const { stdout } = await execFileAsync("defaults", ["read", "com.apple.LaunchServices/com.apple.launchservices.secure", "LSHandlers"]);
|
|
764
|
+
const match = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout);
|
|
765
|
+
const browserId = match?.groups.id ?? "com.apple.Safari";
|
|
766
|
+
if (browserId === "com.apple.safari") {
|
|
767
|
+
return "com.apple.Safari";
|
|
1082
768
|
}
|
|
1083
|
-
|
|
1084
|
-
|
|
769
|
+
return browserId;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
// ../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
|
|
773
|
+
var import_node_process5 = __toESM(require("process"), 1);
|
|
774
|
+
var import_node_util4 = require("util");
|
|
775
|
+
var import_node_child_process4 = require("child_process");
|
|
776
|
+
var execFileAsync2 = (0, import_node_util4.promisify)(import_node_child_process4.execFile);
|
|
777
|
+
async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
|
|
778
|
+
if (import_node_process5.default.platform !== "darwin") {
|
|
779
|
+
throw new Error("macOS only");
|
|
1085
780
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
781
|
+
const outputArguments = humanReadableOutput ? [] : ["-ss"];
|
|
782
|
+
const execOptions = {};
|
|
783
|
+
if (signal) {
|
|
784
|
+
execOptions.signal = signal;
|
|
1088
785
|
}
|
|
1089
|
-
|
|
786
|
+
const { stdout } = await execFileAsync2("osascript", ["-e", script, outputArguments], execOptions);
|
|
787
|
+
return stdout.trim();
|
|
1090
788
|
}
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
return translateLevel(level);
|
|
789
|
+
|
|
790
|
+
// ../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
|
|
791
|
+
async function bundleName(bundleId) {
|
|
792
|
+
return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string
|
|
793
|
+
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
|
|
1097
794
|
}
|
|
1098
|
-
var supportsColor = {
|
|
1099
|
-
stdout: createSupportsColor({ isTTY: import_node_tty.default.isatty(1) }),
|
|
1100
|
-
stderr: createSupportsColor({ isTTY: import_node_tty.default.isatty(2) })
|
|
1101
|
-
};
|
|
1102
|
-
var supports_color_default = supportsColor;
|
|
1103
795
|
|
|
1104
|
-
// ../../node_modules/.pnpm/
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
796
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/windows.js
|
|
797
|
+
var import_node_util5 = require("util");
|
|
798
|
+
var import_node_child_process5 = require("child_process");
|
|
799
|
+
var execFileAsync3 = (0, import_node_util5.promisify)(import_node_child_process5.execFile);
|
|
800
|
+
var windowsBrowserProgIds = {
|
|
801
|
+
MSEdgeHTM: { name: "Edge", id: "com.microsoft.edge" },
|
|
802
|
+
// The missing `L` is correct.
|
|
803
|
+
MSEdgeBHTML: { name: "Edge Beta", id: "com.microsoft.edge.beta" },
|
|
804
|
+
MSEdgeDHTML: { name: "Edge Dev", id: "com.microsoft.edge.dev" },
|
|
805
|
+
AppXq0fevzme2pys62n3e0fbqa7peapykr8v: { name: "Edge", id: "com.microsoft.edge.old" },
|
|
806
|
+
ChromeHTML: { name: "Chrome", id: "com.google.chrome" },
|
|
807
|
+
ChromeBHTML: { name: "Chrome Beta", id: "com.google.chrome.beta" },
|
|
808
|
+
ChromeDHTML: { name: "Chrome Dev", id: "com.google.chrome.dev" },
|
|
809
|
+
ChromiumHTM: { name: "Chromium", id: "org.chromium.Chromium" },
|
|
810
|
+
BraveHTML: { name: "Brave", id: "com.brave.Browser" },
|
|
811
|
+
BraveBHTML: { name: "Brave Beta", id: "com.brave.Browser.beta" },
|
|
812
|
+
BraveDHTML: { name: "Brave Dev", id: "com.brave.Browser.dev" },
|
|
813
|
+
BraveSSHTM: { name: "Brave Nightly", id: "com.brave.Browser.nightly" },
|
|
814
|
+
FirefoxURL: { name: "Firefox", id: "org.mozilla.firefox" },
|
|
815
|
+
OperaStable: { name: "Opera", id: "com.operasoftware.Opera" },
|
|
816
|
+
VivaldiHTM: { name: "Vivaldi", id: "com.vivaldi.Vivaldi" },
|
|
817
|
+
"IE.HTTP": { name: "Internet Explorer", id: "com.microsoft.ie" }
|
|
818
|
+
};
|
|
819
|
+
var _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
|
|
820
|
+
var UnknownBrowserError = class extends Error {
|
|
821
|
+
};
|
|
822
|
+
async function defaultBrowser(_execFileAsync = execFileAsync3) {
|
|
823
|
+
const { stdout } = await _execFileAsync("reg", [
|
|
824
|
+
"QUERY",
|
|
825
|
+
" HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
|
|
826
|
+
"/v",
|
|
827
|
+
"ProgId"
|
|
828
|
+
]);
|
|
829
|
+
const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
|
|
830
|
+
if (!match) {
|
|
831
|
+
throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
|
|
1110
832
|
}
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
index = string.indexOf(substring, endIndex);
|
|
1118
|
-
} while (index !== -1);
|
|
1119
|
-
returnValue += string.slice(endIndex);
|
|
1120
|
-
return returnValue;
|
|
1121
|
-
}
|
|
1122
|
-
function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) {
|
|
1123
|
-
let endIndex = 0;
|
|
1124
|
-
let returnValue = "";
|
|
1125
|
-
do {
|
|
1126
|
-
const gotCR = string[index - 1] === "\r";
|
|
1127
|
-
returnValue += string.slice(endIndex, gotCR ? index - 1 : index) + prefix + (gotCR ? "\r\n" : "\n") + postfix;
|
|
1128
|
-
endIndex = index + 1;
|
|
1129
|
-
index = string.indexOf("\n", endIndex);
|
|
1130
|
-
} while (index !== -1);
|
|
1131
|
-
returnValue += string.slice(endIndex);
|
|
1132
|
-
return returnValue;
|
|
833
|
+
const { id } = match.groups;
|
|
834
|
+
const dotIndex = id.lastIndexOf(".");
|
|
835
|
+
const hyphenIndex = id.lastIndexOf("-");
|
|
836
|
+
const baseIdByDot = dotIndex === -1 ? void 0 : id.slice(0, dotIndex);
|
|
837
|
+
const baseIdByHyphen = hyphenIndex === -1 ? void 0 : id.slice(0, hyphenIndex);
|
|
838
|
+
return windowsBrowserProgIds[id] ?? windowsBrowserProgIds[baseIdByDot] ?? windowsBrowserProgIds[baseIdByHyphen] ?? { name: id, id };
|
|
1133
839
|
}
|
|
1134
840
|
|
|
1135
|
-
// ../../node_modules/.pnpm/
|
|
1136
|
-
var
|
|
1137
|
-
var
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
"ansi256",
|
|
1144
|
-
"ansi16m"
|
|
1145
|
-
];
|
|
1146
|
-
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
1147
|
-
var applyOptions = (object, options = {}) => {
|
|
1148
|
-
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
1149
|
-
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
841
|
+
// ../../node_modules/.pnpm/default-browser@5.5.0/node_modules/default-browser/index.js
|
|
842
|
+
var execFileAsync4 = (0, import_node_util6.promisify)(import_node_child_process6.execFile);
|
|
843
|
+
var titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
|
|
844
|
+
async function defaultBrowser2() {
|
|
845
|
+
if (import_node_process6.default.platform === "darwin") {
|
|
846
|
+
const id = await defaultBrowserId();
|
|
847
|
+
const name = await bundleName(id);
|
|
848
|
+
return { name, id };
|
|
1150
849
|
}
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
return chalkFactory(options);
|
|
850
|
+
if (import_node_process6.default.platform === "linux") {
|
|
851
|
+
const { stdout } = await execFileAsync4("xdg-mime", ["query", "default", "x-scheme-handler/http"]);
|
|
852
|
+
const id = stdout.trim();
|
|
853
|
+
const name = titleize(id.replace(/.desktop$/, "").replace("-", " "));
|
|
854
|
+
return { name, id };
|
|
855
|
+
}
|
|
856
|
+
if (import_node_process6.default.platform === "win32") {
|
|
857
|
+
return defaultBrowser();
|
|
858
|
+
}
|
|
859
|
+
throw new Error("Only macOS, Linux, and Windows are supported");
|
|
1162
860
|
}
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
861
|
+
|
|
862
|
+
// ../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
|
|
863
|
+
var import_node_process7 = __toESM(require("process"), 1);
|
|
864
|
+
var isInSsh = Boolean(import_node_process7.default.env.SSH_CONNECTION || import_node_process7.default.env.SSH_CLIENT || import_node_process7.default.env.SSH_TTY);
|
|
865
|
+
var is_in_ssh_default = isInSsh;
|
|
866
|
+
|
|
867
|
+
// ../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
|
|
868
|
+
var fallbackAttemptSymbol = /* @__PURE__ */ Symbol("fallbackAttempt");
|
|
869
|
+
var __dirname2 = importMetaUrl ? import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl)) : "";
|
|
870
|
+
var localXdgOpenPath = import_node_path.default.join(__dirname2, "xdg-open");
|
|
871
|
+
var { platform, arch } = import_node_process8.default;
|
|
872
|
+
var tryEachApp = async (apps2, opener) => {
|
|
873
|
+
if (apps2.length === 0) {
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
const errors = [];
|
|
877
|
+
for (const app of apps2) {
|
|
878
|
+
try {
|
|
879
|
+
return await opener(app);
|
|
880
|
+
} catch (error) {
|
|
881
|
+
errors.push(error);
|
|
1170
882
|
}
|
|
1171
|
-
};
|
|
1172
|
-
}
|
|
1173
|
-
styles2.visible = {
|
|
1174
|
-
get() {
|
|
1175
|
-
const builder = createBuilder(this, this[STYLER], true);
|
|
1176
|
-
Object.defineProperty(this, "visible", { value: builder });
|
|
1177
|
-
return builder;
|
|
1178
883
|
}
|
|
884
|
+
throw new AggregateError(errors, "Failed to open in all supported apps");
|
|
1179
885
|
};
|
|
1180
|
-
var
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
886
|
+
var baseOpen = async (options) => {
|
|
887
|
+
options = {
|
|
888
|
+
wait: false,
|
|
889
|
+
background: false,
|
|
890
|
+
newInstance: false,
|
|
891
|
+
allowNonzeroExitCode: false,
|
|
892
|
+
...options
|
|
893
|
+
};
|
|
894
|
+
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
|
895
|
+
delete options[fallbackAttemptSymbol];
|
|
896
|
+
if (Array.isArray(options.app)) {
|
|
897
|
+
return tryEachApp(options.app, (singleApp) => baseOpen({
|
|
898
|
+
...options,
|
|
899
|
+
app: singleApp,
|
|
900
|
+
[fallbackAttemptSymbol]: true
|
|
901
|
+
}));
|
|
902
|
+
}
|
|
903
|
+
let { name: app, arguments: appArguments = [] } = options.app ?? {};
|
|
904
|
+
appArguments = [...appArguments];
|
|
905
|
+
if (Array.isArray(app)) {
|
|
906
|
+
return tryEachApp(app, (appName) => baseOpen({
|
|
907
|
+
...options,
|
|
908
|
+
app: {
|
|
909
|
+
name: appName,
|
|
910
|
+
arguments: appArguments
|
|
911
|
+
},
|
|
912
|
+
[fallbackAttemptSymbol]: true
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
if (app === "browser" || app === "browserPrivate") {
|
|
916
|
+
const ids = {
|
|
917
|
+
"com.google.chrome": "chrome",
|
|
918
|
+
"google-chrome.desktop": "chrome",
|
|
919
|
+
"com.brave.browser": "brave",
|
|
920
|
+
"org.mozilla.firefox": "firefox",
|
|
921
|
+
"firefox.desktop": "firefox",
|
|
922
|
+
"com.microsoft.msedge": "edge",
|
|
923
|
+
"com.microsoft.edge": "edge",
|
|
924
|
+
"com.microsoft.edgemac": "edge",
|
|
925
|
+
"microsoft-edge.desktop": "edge",
|
|
926
|
+
"com.apple.safari": "safari"
|
|
927
|
+
};
|
|
928
|
+
const flags = {
|
|
929
|
+
chrome: "--incognito",
|
|
930
|
+
brave: "--incognito",
|
|
931
|
+
firefox: "--private-window",
|
|
932
|
+
edge: "--inPrivate"
|
|
933
|
+
// Safari doesn't support private mode via command line
|
|
934
|
+
};
|
|
935
|
+
let browser;
|
|
936
|
+
if (is_wsl_default) {
|
|
937
|
+
const progId = await wslDefaultBrowser();
|
|
938
|
+
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
|
939
|
+
browser = browserInfo ?? {};
|
|
940
|
+
} else {
|
|
941
|
+
browser = await defaultBrowser2();
|
|
1184
942
|
}
|
|
1185
|
-
if (
|
|
1186
|
-
|
|
943
|
+
if (browser.id in ids) {
|
|
944
|
+
const browserName = ids[browser.id.toLowerCase()];
|
|
945
|
+
if (app === "browserPrivate") {
|
|
946
|
+
if (browserName === "safari") {
|
|
947
|
+
throw new Error("Safari doesn't support opening in private mode via command line");
|
|
948
|
+
}
|
|
949
|
+
appArguments.push(flags[browserName]);
|
|
950
|
+
}
|
|
951
|
+
return baseOpen({
|
|
952
|
+
...options,
|
|
953
|
+
app: {
|
|
954
|
+
name: apps[browserName],
|
|
955
|
+
arguments: appArguments
|
|
956
|
+
}
|
|
957
|
+
});
|
|
1187
958
|
}
|
|
1188
|
-
|
|
959
|
+
throw new Error(`${browser.name} is not supported as a default browser`);
|
|
1189
960
|
}
|
|
1190
|
-
|
|
1191
|
-
|
|
961
|
+
let command;
|
|
962
|
+
const cliArguments = [];
|
|
963
|
+
const childProcessOptions = {};
|
|
964
|
+
let shouldUseWindowsInWsl = false;
|
|
965
|
+
if (is_wsl_default && !isInsideContainer() && !is_in_ssh_default && !app) {
|
|
966
|
+
shouldUseWindowsInWsl = await canAccessPowerShell();
|
|
1192
967
|
}
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
styles2[model] = {
|
|
1198
|
-
get() {
|
|
1199
|
-
const { level } = this;
|
|
1200
|
-
return function(...arguments_) {
|
|
1201
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "color", ...arguments_), ansi_styles_default.color.close, this[STYLER]);
|
|
1202
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1203
|
-
};
|
|
968
|
+
if (platform === "darwin") {
|
|
969
|
+
command = "open";
|
|
970
|
+
if (options.wait) {
|
|
971
|
+
cliArguments.push("--wait-apps");
|
|
1204
972
|
}
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
styles2[bgModel] = {
|
|
1208
|
-
get() {
|
|
1209
|
-
const { level } = this;
|
|
1210
|
-
return function(...arguments_) {
|
|
1211
|
-
const styler = createStyler(getModelAnsi(model, levelMapping[level], "bgColor", ...arguments_), ansi_styles_default.bgColor.close, this[STYLER]);
|
|
1212
|
-
return createBuilder(this, styler, this[IS_EMPTY]);
|
|
1213
|
-
};
|
|
973
|
+
if (options.background) {
|
|
974
|
+
cliArguments.push("--background");
|
|
1214
975
|
}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
976
|
+
if (options.newInstance) {
|
|
977
|
+
cliArguments.push("--new");
|
|
978
|
+
}
|
|
979
|
+
if (app) {
|
|
980
|
+
cliArguments.push("-a", app);
|
|
981
|
+
}
|
|
982
|
+
} else if (platform === "win32" || shouldUseWindowsInWsl) {
|
|
983
|
+
command = await powerShellPath2();
|
|
984
|
+
cliArguments.push(...executePowerShell.argumentsPrefix);
|
|
985
|
+
if (!is_wsl_default) {
|
|
986
|
+
childProcessOptions.windowsVerbatimArguments = true;
|
|
987
|
+
}
|
|
988
|
+
if (is_wsl_default && options.target) {
|
|
989
|
+
options.target = await convertWslPathToWindows(options.target);
|
|
990
|
+
}
|
|
991
|
+
const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
|
|
992
|
+
if (options.wait) {
|
|
993
|
+
encodedArguments.push("-Wait");
|
|
994
|
+
}
|
|
995
|
+
if (app) {
|
|
996
|
+
encodedArguments.push(executePowerShell.escapeArgument(app));
|
|
997
|
+
if (options.target) {
|
|
998
|
+
appArguments.push(options.target);
|
|
999
|
+
}
|
|
1000
|
+
} else if (options.target) {
|
|
1001
|
+
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
|
1002
|
+
}
|
|
1003
|
+
if (appArguments.length > 0) {
|
|
1004
|
+
appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
|
|
1005
|
+
encodedArguments.push("-ArgumentList", appArguments.join(","));
|
|
1006
|
+
}
|
|
1007
|
+
options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
|
|
1008
|
+
if (!options.wait) {
|
|
1009
|
+
childProcessOptions.stdio = "ignore";
|
|
1227
1010
|
}
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
var createStyler = (open2, close, parent) => {
|
|
1231
|
-
let openAll;
|
|
1232
|
-
let closeAll;
|
|
1233
|
-
if (parent === void 0) {
|
|
1234
|
-
openAll = open2;
|
|
1235
|
-
closeAll = close;
|
|
1236
1011
|
} else {
|
|
1237
|
-
|
|
1238
|
-
|
|
1012
|
+
if (app) {
|
|
1013
|
+
command = app;
|
|
1014
|
+
} else {
|
|
1015
|
+
const isBundled = !__dirname2 || __dirname2 === "/";
|
|
1016
|
+
let exeLocalXdgOpen = false;
|
|
1017
|
+
try {
|
|
1018
|
+
await import_promises3.default.access(localXdgOpenPath, import_promises3.constants.X_OK);
|
|
1019
|
+
exeLocalXdgOpen = true;
|
|
1020
|
+
} catch {
|
|
1021
|
+
}
|
|
1022
|
+
const useSystemXdgOpen = import_node_process8.default.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen);
|
|
1023
|
+
command = useSystemXdgOpen ? "xdg-open" : localXdgOpenPath;
|
|
1024
|
+
}
|
|
1025
|
+
if (appArguments.length > 0) {
|
|
1026
|
+
cliArguments.push(...appArguments);
|
|
1027
|
+
}
|
|
1028
|
+
if (!options.wait) {
|
|
1029
|
+
childProcessOptions.stdio = "ignore";
|
|
1030
|
+
childProcessOptions.detached = true;
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
if (platform === "darwin" && appArguments.length > 0) {
|
|
1034
|
+
cliArguments.push("--args", ...appArguments);
|
|
1035
|
+
}
|
|
1036
|
+
if (options.target) {
|
|
1037
|
+
cliArguments.push(options.target);
|
|
1038
|
+
}
|
|
1039
|
+
const subprocess = import_node_child_process7.default.spawn(command, cliArguments, childProcessOptions);
|
|
1040
|
+
if (options.wait) {
|
|
1041
|
+
return new Promise((resolve2, reject) => {
|
|
1042
|
+
subprocess.once("error", reject);
|
|
1043
|
+
subprocess.once("close", (exitCode) => {
|
|
1044
|
+
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
|
1045
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
resolve2(subprocess);
|
|
1049
|
+
});
|
|
1050
|
+
});
|
|
1051
|
+
}
|
|
1052
|
+
if (isFallbackAttempt) {
|
|
1053
|
+
return new Promise((resolve2, reject) => {
|
|
1054
|
+
subprocess.once("error", reject);
|
|
1055
|
+
subprocess.once("spawn", () => {
|
|
1056
|
+
subprocess.once("close", (exitCode) => {
|
|
1057
|
+
subprocess.off("error", reject);
|
|
1058
|
+
if (exitCode !== 0) {
|
|
1059
|
+
reject(new Error(`Exited with code ${exitCode}`));
|
|
1060
|
+
return;
|
|
1061
|
+
}
|
|
1062
|
+
subprocess.unref();
|
|
1063
|
+
resolve2(subprocess);
|
|
1064
|
+
});
|
|
1065
|
+
});
|
|
1066
|
+
});
|
|
1239
1067
|
}
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1068
|
+
subprocess.unref();
|
|
1069
|
+
return new Promise((resolve2, reject) => {
|
|
1070
|
+
subprocess.once("error", reject);
|
|
1071
|
+
subprocess.once("spawn", () => {
|
|
1072
|
+
subprocess.off("error", reject);
|
|
1073
|
+
resolve2(subprocess);
|
|
1074
|
+
});
|
|
1075
|
+
});
|
|
1247
1076
|
};
|
|
1248
|
-
var
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1077
|
+
var open = (target, options) => {
|
|
1078
|
+
if (typeof target !== "string") {
|
|
1079
|
+
throw new TypeError("Expected a `target`");
|
|
1080
|
+
}
|
|
1081
|
+
return baseOpen({
|
|
1082
|
+
...options,
|
|
1083
|
+
target
|
|
1084
|
+
});
|
|
1255
1085
|
};
|
|
1256
|
-
|
|
1257
|
-
if (
|
|
1258
|
-
return
|
|
1086
|
+
function detectArchBinary(binary) {
|
|
1087
|
+
if (typeof binary === "string" || Array.isArray(binary)) {
|
|
1088
|
+
return binary;
|
|
1259
1089
|
}
|
|
1260
|
-
|
|
1261
|
-
if (
|
|
1262
|
-
|
|
1090
|
+
const { [arch]: archBinary } = binary;
|
|
1091
|
+
if (!archBinary) {
|
|
1092
|
+
throw new Error(`${arch} is not supported`);
|
|
1263
1093
|
}
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
}
|
|
1094
|
+
return archBinary;
|
|
1095
|
+
}
|
|
1096
|
+
function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
|
|
1097
|
+
if (wsl && is_wsl_default) {
|
|
1098
|
+
return detectArchBinary(wsl);
|
|
1270
1099
|
}
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
|
|
1100
|
+
if (!platformBinary) {
|
|
1101
|
+
throw new Error(`${platform} is not supported`);
|
|
1274
1102
|
}
|
|
1275
|
-
return
|
|
1103
|
+
return detectArchBinary(platformBinary);
|
|
1104
|
+
}
|
|
1105
|
+
var apps = {
|
|
1106
|
+
browser: "browser",
|
|
1107
|
+
browserPrivate: "browserPrivate"
|
|
1276
1108
|
};
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1109
|
+
defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
|
|
1110
|
+
darwin: "google chrome",
|
|
1111
|
+
win32: "chrome",
|
|
1112
|
+
// `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
|
|
1113
|
+
linux: ["google-chrome", "google-chrome-stable", "chromium", "chromium-browser"]
|
|
1114
|
+
}, {
|
|
1115
|
+
wsl: {
|
|
1116
|
+
ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
|
|
1117
|
+
x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
|
|
1118
|
+
}
|
|
1119
|
+
}));
|
|
1120
|
+
defineLazyProperty(apps, "brave", () => detectPlatformBinary({
|
|
1121
|
+
darwin: "brave browser",
|
|
1122
|
+
win32: "brave",
|
|
1123
|
+
linux: ["brave-browser", "brave"]
|
|
1124
|
+
}, {
|
|
1125
|
+
wsl: {
|
|
1126
|
+
ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
|
|
1127
|
+
x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
|
|
1128
|
+
}
|
|
1129
|
+
}));
|
|
1130
|
+
defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
|
|
1131
|
+
darwin: "firefox",
|
|
1132
|
+
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
|
1133
|
+
linux: "firefox"
|
|
1134
|
+
}, {
|
|
1135
|
+
wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe"
|
|
1136
|
+
}));
|
|
1137
|
+
defineLazyProperty(apps, "edge", () => detectPlatformBinary({
|
|
1138
|
+
darwin: "microsoft edge",
|
|
1139
|
+
win32: "msedge",
|
|
1140
|
+
linux: ["microsoft-edge", "microsoft-edge-dev"]
|
|
1141
|
+
}, {
|
|
1142
|
+
wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"
|
|
1143
|
+
}));
|
|
1144
|
+
defineLazyProperty(apps, "safari", () => detectPlatformBinary({
|
|
1145
|
+
darwin: "Safari"
|
|
1146
|
+
}));
|
|
1147
|
+
var open_default = open;
|
|
1281
1148
|
|
|
1282
1149
|
// src/index.ts
|
|
1283
|
-
var import_commander7 = require("commander");
|
|
1284
|
-
var import_config8 = require("dotenv/config");
|
|
1285
|
-
var import_node_child_process11 = require("child_process");
|
|
1286
|
-
var import_node_fs14 = require("fs");
|
|
1287
|
-
var import_promises8 = require("fs/promises");
|
|
1288
|
-
var import_node_module2 = require("module");
|
|
1289
|
-
var import_node_path12 = __toESM(require("path"), 1);
|
|
1290
|
-
var import_node_url3 = require("url");
|
|
1291
|
-
init_open();
|
|
1292
1150
|
var import_vite_plugin_singlefile = require("vite-plugin-singlefile");
|
|
1293
1151
|
var import_zod = require("zod");
|
|
1294
1152
|
|
|
1295
|
-
// src/commands/auth.ts
|
|
1296
|
-
init_cjs_shims();
|
|
1297
|
-
init_open();
|
|
1298
|
-
|
|
1299
|
-
// src/utils/api.ts
|
|
1300
|
-
init_cjs_shims();
|
|
1301
|
-
|
|
1302
1153
|
// src/utils/config.ts
|
|
1303
|
-
init_cjs_shims();
|
|
1304
1154
|
var import_node_fs4 = require("fs");
|
|
1305
1155
|
var import_node_os3 = __toESM(require("os"), 1);
|
|
1306
1156
|
var import_node_path2 = __toESM(require("path"), 1);
|
|
@@ -1679,7 +1529,6 @@ var McpUseAPI = class _McpUseAPI {
|
|
|
1679
1529
|
};
|
|
1680
1530
|
|
|
1681
1531
|
// src/utils/errors.ts
|
|
1682
|
-
init_cjs_shims();
|
|
1683
1532
|
function handleCommandError(error, context) {
|
|
1684
1533
|
if (error instanceof ApiUnauthorizedError) {
|
|
1685
1534
|
console.error(
|
|
@@ -1856,7 +1705,7 @@ async function loginCommand(options) {
|
|
|
1856
1705
|
}
|
|
1857
1706
|
await deleteConfig();
|
|
1858
1707
|
}
|
|
1859
|
-
console.log(source_default.cyan.bold("Logging in to
|
|
1708
|
+
console.log(source_default.cyan.bold("Logging in to Manufact cloud...\n"));
|
|
1860
1709
|
const authBaseUrl = await getAuthBaseUrl();
|
|
1861
1710
|
const deviceResp = await requestDeviceCode(authBaseUrl);
|
|
1862
1711
|
const {
|
|
@@ -2026,13 +1875,11 @@ async function whoamiCommand() {
|
|
|
2026
1875
|
}
|
|
2027
1876
|
|
|
2028
1877
|
// src/commands/client.ts
|
|
2029
|
-
init_cjs_shims();
|
|
2030
1878
|
var import_commander2 = require("commander");
|
|
2031
1879
|
var import_client3 = require("mcp-use/client");
|
|
2032
1880
|
var import_node_readline2 = require("readline");
|
|
2033
1881
|
|
|
2034
1882
|
// src/utils/format.ts
|
|
2035
|
-
init_cjs_shims();
|
|
2036
1883
|
var ANSI_RE = /\x1b\[[0-9;]*m/g;
|
|
2037
1884
|
var GUTTER = " ";
|
|
2038
1885
|
var MIN_TRUNCATABLE_WIDTH = 8;
|
|
@@ -2141,8 +1988,11 @@ function formatJson(data, pretty = true) {
|
|
|
2141
1988
|
function formatToolCall(result) {
|
|
2142
1989
|
const lines = [];
|
|
2143
1990
|
const { isError, structuredContent } = result;
|
|
2144
|
-
const hasContent = !!result.content?.length;
|
|
2145
1991
|
const hasStructured = structuredContent !== void 0 && structuredContent !== null;
|
|
1992
|
+
const visibleContent = (result.content ?? []).filter(
|
|
1993
|
+
(item) => !hasStructured || item.type !== "text"
|
|
1994
|
+
);
|
|
1995
|
+
const hasVisibleContent = visibleContent.length > 0;
|
|
2146
1996
|
if (isError) {
|
|
2147
1997
|
lines.push(source_default.red("\u2717 Tool execution failed"));
|
|
2148
1998
|
lines.push("");
|
|
@@ -2150,12 +2000,12 @@ function formatToolCall(result) {
|
|
|
2150
2000
|
lines.push(source_default.green("\u2713 Tool executed successfully"));
|
|
2151
2001
|
lines.push("");
|
|
2152
2002
|
}
|
|
2153
|
-
if (
|
|
2003
|
+
if (hasVisibleContent) {
|
|
2154
2004
|
if (isError) {
|
|
2155
2005
|
lines.push(source_default.red.bold("Error details:"));
|
|
2156
2006
|
}
|
|
2157
|
-
|
|
2158
|
-
if (
|
|
2007
|
+
visibleContent.forEach((item, index) => {
|
|
2008
|
+
if (visibleContent.length > 1) {
|
|
2159
2009
|
lines.push(source_default.bold(`Content ${index + 1}:`));
|
|
2160
2010
|
}
|
|
2161
2011
|
if (item.type === "text") {
|
|
@@ -2176,19 +2026,18 @@ function formatToolCall(result) {
|
|
|
2176
2026
|
} else {
|
|
2177
2027
|
lines.push(source_default.gray(`[Unknown content type: ${item.type}]`));
|
|
2178
2028
|
}
|
|
2179
|
-
if (index <
|
|
2029
|
+
if (index < visibleContent.length - 1) {
|
|
2180
2030
|
lines.push("");
|
|
2181
2031
|
}
|
|
2182
2032
|
});
|
|
2183
2033
|
}
|
|
2184
2034
|
if (hasStructured) {
|
|
2185
|
-
if (
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
);
|
|
2035
|
+
if (isError) {
|
|
2036
|
+
lines.push(source_default.bold("Structured error data:"));
|
|
2037
|
+
}
|
|
2189
2038
|
lines.push(formatJson(structuredContent));
|
|
2190
2039
|
}
|
|
2191
|
-
if (isError && !
|
|
2040
|
+
if (isError && !hasVisibleContent && !hasStructured) {
|
|
2192
2041
|
lines.push(source_default.gray("(no error details provided by server)"));
|
|
2193
2042
|
}
|
|
2194
2043
|
return lines.join("\n");
|
|
@@ -2344,7 +2193,6 @@ function formatPromptMessages(messages) {
|
|
|
2344
2193
|
}
|
|
2345
2194
|
|
|
2346
2195
|
// src/utils/parse-args.ts
|
|
2347
|
-
init_cjs_shims();
|
|
2348
2196
|
function parseToolArgs(rawArgs, inputSchema) {
|
|
2349
2197
|
if (!rawArgs || rawArgs.length === 0) return {};
|
|
2350
2198
|
if (rawArgs.length === 1) {
|
|
@@ -2474,7 +2322,6 @@ function parsePromptArgs(rawArgs) {
|
|
|
2474
2322
|
}
|
|
2475
2323
|
|
|
2476
2324
|
// src/utils/oauth.ts
|
|
2477
|
-
init_cjs_shims();
|
|
2478
2325
|
var import_node = require("mcp-use/auth/node");
|
|
2479
2326
|
var import_node_readline = require("readline");
|
|
2480
2327
|
async function buildOAuthProvider(serverUrl, options = {}) {
|
|
@@ -2484,22 +2331,15 @@ async function buildOAuthProvider(serverUrl, options = {}) {
|
|
|
2484
2331
|
storageKeyPrefix: "mcp:auth",
|
|
2485
2332
|
...options,
|
|
2486
2333
|
openBrowser: async (url) => {
|
|
2487
|
-
|
|
2488
|
-
console.error(`
|
|
2334
|
+
console.error(`
|
|
2489
2335
|
Open this URL in a browser to authenticate:`);
|
|
2490
|
-
|
|
2336
|
+
console.error(` ${url}
|
|
2491
2337
|
`);
|
|
2492
|
-
return;
|
|
2493
|
-
}
|
|
2494
|
-
const { default: open2 } = await Promise.resolve().then(() => (init_open(), open_exports));
|
|
2495
|
-
await open2(url);
|
|
2496
2338
|
}
|
|
2497
2339
|
});
|
|
2498
2340
|
}
|
|
2499
2341
|
async function runOAuthFlow(provider, serverUrl, print = console.error.bind(console)) {
|
|
2500
|
-
print(
|
|
2501
|
-
process.stdout.isTTY ? `\u2192 Opening browser to authenticate...` : `\u2192 OAuth authentication required.`
|
|
2502
|
-
);
|
|
2342
|
+
print(`\u2192 OAuth authentication required.`);
|
|
2503
2343
|
print(
|
|
2504
2344
|
` Listening on http://127.0.0.1:${provider.callbackPort}/callback (waiting up to 5m)`
|
|
2505
2345
|
);
|
|
@@ -2542,28 +2382,28 @@ async function promptYesNo(question, defaultYes = true) {
|
|
|
2542
2382
|
}
|
|
2543
2383
|
|
|
2544
2384
|
// src/utils/session-storage.ts
|
|
2545
|
-
init_cjs_shims();
|
|
2546
2385
|
var import_node_os4 = require("os");
|
|
2547
2386
|
var import_node_path3 = require("path");
|
|
2548
2387
|
var import_promises4 = require("fs/promises");
|
|
2549
2388
|
var import_node_fs5 = require("fs");
|
|
2550
2389
|
var SESSION_FILE_PATH = (0, import_node_path3.join)((0, import_node_os4.homedir)(), ".mcp-use", "cli-sessions.json");
|
|
2390
|
+
var _dirEnsured = false;
|
|
2551
2391
|
async function ensureSessionDir() {
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
}
|
|
2392
|
+
if (_dirEnsured) return;
|
|
2393
|
+
await (0, import_promises4.mkdir)((0, import_node_path3.join)((0, import_node_os4.homedir)(), ".mcp-use"), { recursive: true });
|
|
2394
|
+
_dirEnsured = true;
|
|
2556
2395
|
}
|
|
2557
2396
|
async function loadSessions() {
|
|
2558
2397
|
try {
|
|
2559
2398
|
await ensureSessionDir();
|
|
2560
2399
|
if (!(0, import_node_fs5.existsSync)(SESSION_FILE_PATH)) {
|
|
2561
|
-
return {
|
|
2400
|
+
return { sessions: {} };
|
|
2562
2401
|
}
|
|
2563
2402
|
const content = await (0, import_promises4.readFile)(SESSION_FILE_PATH, "utf-8");
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2403
|
+
const parsed = JSON.parse(content);
|
|
2404
|
+
return { sessions: parsed?.sessions ?? {} };
|
|
2405
|
+
} catch {
|
|
2406
|
+
return { sessions: {} };
|
|
2567
2407
|
}
|
|
2568
2408
|
}
|
|
2569
2409
|
async function saveSessions(storage) {
|
|
@@ -2576,40 +2416,22 @@ async function saveSession(name, config) {
|
|
|
2576
2416
|
...config,
|
|
2577
2417
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
2578
2418
|
};
|
|
2579
|
-
if (!storage.activeSession) {
|
|
2580
|
-
storage.activeSession = name;
|
|
2581
|
-
}
|
|
2582
2419
|
await saveSessions(storage);
|
|
2583
2420
|
}
|
|
2584
|
-
async function
|
|
2421
|
+
async function removeSession(name) {
|
|
2585
2422
|
const storage = await loadSessions();
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
}
|
|
2589
|
-
return {
|
|
2590
|
-
name: storage.activeSession,
|
|
2591
|
-
config: storage.sessions[storage.activeSession]
|
|
2592
|
-
};
|
|
2423
|
+
delete storage.sessions[name];
|
|
2424
|
+
await saveSessions(storage);
|
|
2593
2425
|
}
|
|
2594
2426
|
async function getSession(name) {
|
|
2595
2427
|
const storage = await loadSessions();
|
|
2596
2428
|
return storage.sessions[name] || null;
|
|
2597
2429
|
}
|
|
2598
|
-
async function setActiveSession(name) {
|
|
2599
|
-
const storage = await loadSessions();
|
|
2600
|
-
if (!storage.sessions[name]) {
|
|
2601
|
-
throw new Error(`Session '${name}' not found`);
|
|
2602
|
-
}
|
|
2603
|
-
storage.activeSession = name;
|
|
2604
|
-
storage.sessions[name].lastUsed = (/* @__PURE__ */ new Date()).toISOString();
|
|
2605
|
-
await saveSessions(storage);
|
|
2606
|
-
}
|
|
2607
2430
|
async function listAllSessions() {
|
|
2608
2431
|
const storage = await loadSessions();
|
|
2609
2432
|
return Object.entries(storage.sessions).map(([name, config]) => ({
|
|
2610
2433
|
name,
|
|
2611
|
-
config
|
|
2612
|
-
isActive: name === storage.activeSession
|
|
2434
|
+
config
|
|
2613
2435
|
}));
|
|
2614
2436
|
}
|
|
2615
2437
|
async function updateSessionInfo(name, serverInfo, capabilities) {
|
|
@@ -2623,7 +2445,6 @@ async function updateSessionInfo(name, serverInfo, capabilities) {
|
|
|
2623
2445
|
}
|
|
2624
2446
|
|
|
2625
2447
|
// src/utils/session.ts
|
|
2626
|
-
init_cjs_shims();
|
|
2627
2448
|
var import_client = require("mcp-use/client");
|
|
2628
2449
|
var import_server = require("mcp-use/server");
|
|
2629
2450
|
var activeSessions = /* @__PURE__ */ new Map();
|
|
@@ -2652,26 +2473,18 @@ async function cleanupAndExit(code) {
|
|
|
2652
2473
|
process.exit(code);
|
|
2653
2474
|
}
|
|
2654
2475
|
async function getOrRestoreSession(sessionName) {
|
|
2655
|
-
if (!sessionName) {
|
|
2656
|
-
const active = await getActiveSession();
|
|
2657
|
-
if (!active) {
|
|
2658
|
-
console.error(
|
|
2659
|
-
formatError("No active session. Connect to a server first.")
|
|
2660
|
-
);
|
|
2661
|
-
console.error(
|
|
2662
|
-
formatInfo("Use: npx mcp-use client connect <url> --name <name>")
|
|
2663
|
-
);
|
|
2664
|
-
return null;
|
|
2665
|
-
}
|
|
2666
|
-
sessionName = active.name;
|
|
2667
|
-
}
|
|
2668
2476
|
if (activeSessions.has(sessionName)) {
|
|
2669
2477
|
const { session } = activeSessions.get(sessionName);
|
|
2670
2478
|
return { name: sessionName, session };
|
|
2671
2479
|
}
|
|
2672
2480
|
const config = await getSession(sessionName);
|
|
2673
2481
|
if (!config) {
|
|
2674
|
-
console.error(formatError(`
|
|
2482
|
+
console.error(formatError(`Server '${sessionName}' not found`));
|
|
2483
|
+
console.error(
|
|
2484
|
+
formatInfo(
|
|
2485
|
+
`Connect with: npx mcp-use client connect ${sessionName} <url>`
|
|
2486
|
+
)
|
|
2487
|
+
);
|
|
2675
2488
|
return null;
|
|
2676
2489
|
}
|
|
2677
2490
|
try {
|
|
@@ -2710,14 +2523,14 @@ async function getOrRestoreSession(sessionName) {
|
|
|
2710
2523
|
} catch (err) {
|
|
2711
2524
|
if (config.type === "http" && config.authMode === "oauth" && authProvider && isUnauthorized(err)) {
|
|
2712
2525
|
const reAuth = await promptYesNo(
|
|
2713
|
-
`! Tokens for
|
|
2526
|
+
`! Tokens for server '${sessionName}' expired and could not refresh. Re-authenticate now?`,
|
|
2714
2527
|
true
|
|
2715
2528
|
);
|
|
2716
2529
|
if (!reAuth) {
|
|
2717
2530
|
console.error(formatError(`Tokens expired and could not refresh.`));
|
|
2718
2531
|
console.error(
|
|
2719
2532
|
formatInfo(
|
|
2720
|
-
`Run: mcp-use client connect ${
|
|
2533
|
+
`Run: mcp-use client connect ${sessionName} ${config.url}`
|
|
2721
2534
|
)
|
|
2722
2535
|
);
|
|
2723
2536
|
return null;
|
|
@@ -2729,39 +2542,28 @@ async function getOrRestoreSession(sessionName) {
|
|
|
2729
2542
|
}
|
|
2730
2543
|
}
|
|
2731
2544
|
activeSessions.set(sessionName, { client, session });
|
|
2732
|
-
console.error(formatInfo(`Reconnected to session '${sessionName}'`));
|
|
2733
2545
|
return { name: sessionName, session };
|
|
2734
2546
|
} catch (error) {
|
|
2735
|
-
console.error(formatError(`Failed to restore
|
|
2547
|
+
console.error(formatError(`Failed to restore server: ${error.message}`));
|
|
2736
2548
|
return null;
|
|
2737
2549
|
}
|
|
2738
2550
|
}
|
|
2739
2551
|
|
|
2740
2552
|
// src/commands/client-auth.ts
|
|
2741
|
-
|
|
2742
|
-
async function resolveSession(sessionArg) {
|
|
2743
|
-
let name = sessionArg;
|
|
2744
|
-
if (!name) {
|
|
2745
|
-
const active = await getActiveSession();
|
|
2746
|
-
if (!active) {
|
|
2747
|
-
console.error(formatError("No active session"));
|
|
2748
|
-
return null;
|
|
2749
|
-
}
|
|
2750
|
-
name = active.name;
|
|
2751
|
-
}
|
|
2553
|
+
async function resolveSession(name) {
|
|
2752
2554
|
const config = await getSession(name);
|
|
2753
2555
|
if (!config) {
|
|
2754
|
-
console.error(formatError(`
|
|
2556
|
+
console.error(formatError(`Server '${name}' not found`));
|
|
2755
2557
|
return null;
|
|
2756
2558
|
}
|
|
2757
2559
|
if (config.type !== "http") {
|
|
2758
|
-
console.error(formatError("Auth commands only apply to HTTP
|
|
2560
|
+
console.error(formatError("Auth commands only apply to HTTP servers"));
|
|
2759
2561
|
return null;
|
|
2760
2562
|
}
|
|
2761
2563
|
if (config.authMode !== "oauth") {
|
|
2762
2564
|
console.error(
|
|
2763
2565
|
formatError(
|
|
2764
|
-
`
|
|
2566
|
+
`Server '${name}' was not authenticated via OAuth (authMode=${config.authMode ?? "bearer"})`
|
|
2765
2567
|
)
|
|
2766
2568
|
);
|
|
2767
2569
|
return null;
|
|
@@ -2789,16 +2591,17 @@ function decodeJwtExp(token) {
|
|
|
2789
2591
|
return null;
|
|
2790
2592
|
}
|
|
2791
2593
|
}
|
|
2792
|
-
async function authStatusCommand(
|
|
2793
|
-
const target = await resolveSession(
|
|
2594
|
+
async function authStatusCommand(name) {
|
|
2595
|
+
const target = await resolveSession(name);
|
|
2794
2596
|
if (!target) {
|
|
2795
2597
|
process.exit(1);
|
|
2796
2598
|
}
|
|
2797
|
-
const
|
|
2599
|
+
const { name: serverName, url } = target;
|
|
2600
|
+
const provider = await buildOAuthProvider(url);
|
|
2798
2601
|
const tokens = await provider.tokens();
|
|
2799
2602
|
const fields = {
|
|
2800
|
-
|
|
2801
|
-
url
|
|
2603
|
+
server: serverName,
|
|
2604
|
+
url,
|
|
2802
2605
|
tokens: tokens?.access_token ? "present" : "missing"
|
|
2803
2606
|
};
|
|
2804
2607
|
if (tokens?.scope) fields.scope = tokens.scope;
|
|
@@ -2810,12 +2613,13 @@ async function authStatusCommand(sessionArg) {
|
|
|
2810
2613
|
console.log(formatKeyValue(fields));
|
|
2811
2614
|
if (!tokens?.access_token) process.exit(1);
|
|
2812
2615
|
}
|
|
2813
|
-
async function authRefreshCommand(
|
|
2814
|
-
const target = await resolveSession(
|
|
2616
|
+
async function authRefreshCommand(name) {
|
|
2617
|
+
const target = await resolveSession(name);
|
|
2815
2618
|
if (!target) {
|
|
2816
2619
|
process.exit(1);
|
|
2817
2620
|
}
|
|
2818
|
-
const
|
|
2621
|
+
const { name: serverName, url } = target;
|
|
2622
|
+
const provider = await buildOAuthProvider(url);
|
|
2819
2623
|
const refreshed = await provider.forceRefresh();
|
|
2820
2624
|
if (!refreshed) {
|
|
2821
2625
|
console.error(
|
|
@@ -2824,9 +2628,7 @@ async function authRefreshCommand(sessionArg) {
|
|
|
2824
2628
|
)
|
|
2825
2629
|
);
|
|
2826
2630
|
console.error(
|
|
2827
|
-
formatInfo(
|
|
2828
|
-
`Run: mcp-use client connect ${target.url} --name ${target.name}`
|
|
2829
|
-
)
|
|
2631
|
+
formatInfo(`Run: mcp-use client connect ${serverName} ${url}`)
|
|
2830
2632
|
);
|
|
2831
2633
|
process.exit(1);
|
|
2832
2634
|
}
|
|
@@ -2837,23 +2639,23 @@ async function authRefreshCommand(sessionArg) {
|
|
|
2837
2639
|
)
|
|
2838
2640
|
);
|
|
2839
2641
|
}
|
|
2840
|
-
async function authLogoutCommand(
|
|
2841
|
-
const target = await resolveSession(
|
|
2642
|
+
async function authLogoutCommand(name) {
|
|
2643
|
+
const target = await resolveSession(name);
|
|
2842
2644
|
if (!target) {
|
|
2843
2645
|
process.exit(1);
|
|
2844
2646
|
}
|
|
2845
|
-
const
|
|
2647
|
+
const { name: serverName, url } = target;
|
|
2648
|
+
const provider = await buildOAuthProvider(url);
|
|
2846
2649
|
await provider.invalidateCredentials("all");
|
|
2847
|
-
console.log(formatSuccess(`Removed tokens for ${
|
|
2650
|
+
console.log(formatSuccess(`Removed tokens for ${url}`));
|
|
2848
2651
|
console.log(
|
|
2849
2652
|
formatInfo(
|
|
2850
|
-
`
|
|
2653
|
+
`Server '${serverName}' kept; reconnect with \`mcp-use client connect\`.`
|
|
2851
2654
|
)
|
|
2852
2655
|
);
|
|
2853
2656
|
}
|
|
2854
2657
|
|
|
2855
2658
|
// src/commands/screenshot.ts
|
|
2856
|
-
init_cjs_shims();
|
|
2857
2659
|
var import_commander = require("commander");
|
|
2858
2660
|
var import_client2 = require("mcp-use/client");
|
|
2859
2661
|
var import_node_child_process9 = require("child_process");
|
|
@@ -2863,7 +2665,6 @@ var import_node_net = require("net");
|
|
|
2863
2665
|
var import_node_path6 = __toESM(require("path"), 1);
|
|
2864
2666
|
|
|
2865
2667
|
// src/utils/cdp-screenshot.ts
|
|
2866
|
-
init_cjs_shims();
|
|
2867
2668
|
var import_node_child_process8 = require("child_process");
|
|
2868
2669
|
var import_node_fs6 = require("fs");
|
|
2869
2670
|
var import_node_os5 = __toESM(require("os"), 1);
|
|
@@ -3080,7 +2881,7 @@ async function captureScreenshot(opts) {
|
|
|
3080
2881
|
{
|
|
3081
2882
|
width: opts.width,
|
|
3082
2883
|
height: opts.height,
|
|
3083
|
-
deviceScaleFactor: 1,
|
|
2884
|
+
deviceScaleFactor: opts.deviceScaleFactor ?? 1,
|
|
3084
2885
|
mobile: false
|
|
3085
2886
|
},
|
|
3086
2887
|
sessionId
|
|
@@ -3150,7 +2951,6 @@ async function captureScreenshot(opts) {
|
|
|
3150
2951
|
}
|
|
3151
2952
|
|
|
3152
2953
|
// src/utils/chrome-path.ts
|
|
3153
|
-
init_cjs_shims();
|
|
3154
2954
|
var import_node_fs7 = require("fs");
|
|
3155
2955
|
var import_node_path5 = __toESM(require("path"), 1);
|
|
3156
2956
|
var ENV_VAR_NAMES = [
|
|
@@ -3316,7 +3116,8 @@ async function captureToolScreenshot(inputs, options = {}) {
|
|
|
3316
3116
|
chromePath,
|
|
3317
3117
|
cdpUrl: options.cdpUrl,
|
|
3318
3118
|
delayMs: Number.isFinite(delayMs) && delayMs > 0 ? delayMs : 0,
|
|
3319
|
-
bundle
|
|
3119
|
+
bundle,
|
|
3120
|
+
deviceScaleFactor: options.deviceScaleFactor
|
|
3320
3121
|
});
|
|
3321
3122
|
return { outputPath, width, height, view };
|
|
3322
3123
|
} finally {
|
|
@@ -3459,11 +3260,30 @@ function parseDimension(raw, name) {
|
|
|
3459
3260
|
}
|
|
3460
3261
|
return n;
|
|
3461
3262
|
}
|
|
3263
|
+
function parseDeviceScaleFactor(raw) {
|
|
3264
|
+
const n = parseFloat(raw);
|
|
3265
|
+
if (!Number.isFinite(n) || n <= 0) {
|
|
3266
|
+
throw new Error(
|
|
3267
|
+
`--device-scale-factor must be a positive number (got "${raw}")`
|
|
3268
|
+
);
|
|
3269
|
+
}
|
|
3270
|
+
if (n > 4) {
|
|
3271
|
+
throw new Error(
|
|
3272
|
+
`--device-scale-factor must be <= 4 to avoid excessive pixel counts (got "${raw}")`
|
|
3273
|
+
);
|
|
3274
|
+
}
|
|
3275
|
+
return n;
|
|
3276
|
+
}
|
|
3277
|
+
function requiresArguments(inputSchema) {
|
|
3278
|
+
if (!inputSchema || typeof inputSchema !== "object") return false;
|
|
3279
|
+
const required = inputSchema.required;
|
|
3280
|
+
return Array.isArray(required) && required.length > 0;
|
|
3281
|
+
}
|
|
3462
3282
|
var AD_HOC_SESSION_NAME = "__screenshot_ad_hoc__";
|
|
3463
|
-
async function resolveSessionForScreenshot(options, headers) {
|
|
3464
|
-
if (
|
|
3465
|
-
const
|
|
3466
|
-
return
|
|
3283
|
+
async function resolveSessionForScreenshot(options, sessionName, headers) {
|
|
3284
|
+
if (sessionName) {
|
|
3285
|
+
const result = await getOrRestoreSession(sessionName);
|
|
3286
|
+
return result?.session ?? null;
|
|
3467
3287
|
}
|
|
3468
3288
|
if (options.mcp) {
|
|
3469
3289
|
const client = new import_client2.MCPClient();
|
|
@@ -3482,10 +3302,14 @@ async function resolveSessionForScreenshot(options, headers) {
|
|
|
3482
3302
|
return null;
|
|
3483
3303
|
}
|
|
3484
3304
|
}
|
|
3485
|
-
|
|
3486
|
-
|
|
3305
|
+
console.error(
|
|
3306
|
+
formatError(
|
|
3307
|
+
"No MCP target. Pass --mcp <url> for an ad-hoc connection, or use `mcp-use client <name> screenshot` for a saved server."
|
|
3308
|
+
)
|
|
3309
|
+
);
|
|
3310
|
+
return null;
|
|
3487
3311
|
}
|
|
3488
|
-
async function screenshotCommand(options, argsList) {
|
|
3312
|
+
async function screenshotCommand(options, argsList, context) {
|
|
3489
3313
|
let exitCode = 0;
|
|
3490
3314
|
try {
|
|
3491
3315
|
if (!options.tool) {
|
|
@@ -3502,7 +3326,7 @@ async function screenshotCommand(options, argsList) {
|
|
|
3502
3326
|
if (!options.mcp) {
|
|
3503
3327
|
console.error(
|
|
3504
3328
|
formatError(
|
|
3505
|
-
"--header is only supported with --mcp <url>. Saved
|
|
3329
|
+
"--header is only supported with --mcp <url>. Saved servers carry their own auth from `mcp-use client connect`."
|
|
3506
3330
|
)
|
|
3507
3331
|
);
|
|
3508
3332
|
exitCode = 1;
|
|
@@ -3531,7 +3355,12 @@ async function screenshotCommand(options, argsList) {
|
|
|
3531
3355
|
const height = parseDimension(options.height, "height");
|
|
3532
3356
|
const navTimeout = parseInt(options.timeout, 10) || 3e4;
|
|
3533
3357
|
const delayMs = options.delay ? parseInt(options.delay, 10) : 0;
|
|
3534
|
-
const
|
|
3358
|
+
const deviceScaleFactor = options.deviceScaleFactor ? parseDeviceScaleFactor(options.deviceScaleFactor) : void 0;
|
|
3359
|
+
const session = await resolveSessionForScreenshot(
|
|
3360
|
+
options,
|
|
3361
|
+
context.sessionName,
|
|
3362
|
+
headers
|
|
3363
|
+
);
|
|
3535
3364
|
if (!session) {
|
|
3536
3365
|
exitCode = 1;
|
|
3537
3366
|
return;
|
|
@@ -3562,13 +3391,13 @@ async function screenshotCommand(options, argsList) {
|
|
|
3562
3391
|
console.log("");
|
|
3563
3392
|
console.log(formatInfo("Usage:"));
|
|
3564
3393
|
console.log(
|
|
3565
|
-
` npx
|
|
3394
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3566
3395
|
);
|
|
3567
3396
|
console.log(
|
|
3568
|
-
` npx
|
|
3397
|
+
` npx ${context.usagePrefix} --tool ${options.tool} nested:='{"a":1}' # JSON value`
|
|
3569
3398
|
);
|
|
3570
3399
|
console.log(
|
|
3571
|
-
` npx
|
|
3400
|
+
` npx ${context.usagePrefix} --tool ${options.tool} '{"key":"value"}' # full JSON object`
|
|
3572
3401
|
);
|
|
3573
3402
|
if (tool.inputSchema) {
|
|
3574
3403
|
console.log("");
|
|
@@ -3578,6 +3407,18 @@ async function screenshotCommand(options, argsList) {
|
|
|
3578
3407
|
exitCode = 1;
|
|
3579
3408
|
return;
|
|
3580
3409
|
}
|
|
3410
|
+
} else if (requiresArguments(tool.inputSchema)) {
|
|
3411
|
+
console.error(formatError("This tool requires arguments."));
|
|
3412
|
+
console.log("");
|
|
3413
|
+
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3414
|
+
console.log(
|
|
3415
|
+
` npx ${context.usagePrefix} --tool ${options.tool} key=value [key2=value2 ...]`
|
|
3416
|
+
);
|
|
3417
|
+
console.log("");
|
|
3418
|
+
console.log(formatInfo("Tool schema:"));
|
|
3419
|
+
console.log(formatSchema(tool.inputSchema));
|
|
3420
|
+
exitCode = 1;
|
|
3421
|
+
return;
|
|
3581
3422
|
}
|
|
3582
3423
|
const toolOutput = await session.callTool(options.tool, toolArgs);
|
|
3583
3424
|
const result = await captureToolScreenshot(
|
|
@@ -3598,7 +3439,8 @@ async function screenshotCommand(options, argsList) {
|
|
|
3598
3439
|
timeoutMs: navTimeout,
|
|
3599
3440
|
inspector: options.inspector,
|
|
3600
3441
|
quiet: options.quiet,
|
|
3601
|
-
cdpUrl: options.cdpUrl
|
|
3442
|
+
cdpUrl: options.cdpUrl,
|
|
3443
|
+
deviceScaleFactor
|
|
3602
3444
|
}
|
|
3603
3445
|
);
|
|
3604
3446
|
console.log(
|
|
@@ -3612,29 +3454,19 @@ async function screenshotCommand(options, argsList) {
|
|
|
3612
3454
|
await cleanupAndExit(exitCode);
|
|
3613
3455
|
}
|
|
3614
3456
|
}
|
|
3615
|
-
function
|
|
3616
|
-
return
|
|
3617
|
-
"Render an MCP Apps view headlessly and save a PNG by calling a tool and rendering its UI resource with the result."
|
|
3618
|
-
).argument(
|
|
3457
|
+
function withCommonScreenshotOptions(cmd) {
|
|
3458
|
+
return cmd.argument(
|
|
3619
3459
|
"[args...]",
|
|
3620
3460
|
"Tool args as key=value pairs (use key:=<json> for nested values, or pass a single JSON object)."
|
|
3621
3461
|
).option(
|
|
3622
3462
|
"--tool <name>",
|
|
3623
3463
|
"Tool to call. Its UI resource is rendered with the result."
|
|
3624
3464
|
).option("--width <px>", "Browser viewport width in pixels.", "800").option("--height <px>", "Browser viewport height in pixels.", "600").option(
|
|
3625
|
-
"--
|
|
3626
|
-
"
|
|
3627
|
-
).option(
|
|
3628
|
-
"--session <name>",
|
|
3629
|
-
"Saved session name (from `mcp-use client connect`). Defaults to the active session."
|
|
3630
|
-
).option(
|
|
3631
|
-
"--mcp <url>",
|
|
3632
|
-
"Ad-hoc MCP server URL (escape hatch). Used only when no --session and no active saved session. No authentication unless --header is supplied."
|
|
3465
|
+
"--device-scale-factor <n>",
|
|
3466
|
+
"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."
|
|
3633
3467
|
).option(
|
|
3634
|
-
"
|
|
3635
|
-
|
|
3636
|
-
collectHeader,
|
|
3637
|
-
[]
|
|
3468
|
+
"--inspector <url>",
|
|
3469
|
+
"Inspector host that serves /inspector/preview/:view. When omitted, auto-spawns `@mcp-use/inspector` on a free port."
|
|
3638
3470
|
).option(
|
|
3639
3471
|
"--theme <light|dark>",
|
|
3640
3472
|
"Color scheme to render the view in.",
|
|
@@ -3652,20 +3484,124 @@ function createScreenshotCommand() {
|
|
|
3652
3484
|
).option("--timeout <ms>", "Navigation + readiness timeout in ms.", "30000").option(
|
|
3653
3485
|
"--cdp-url <url>",
|
|
3654
3486
|
"Connect to an existing CDP WebSocket (ws:// or wss://) instead of spawning local Chrome. Useful for hosted browsers like Notte."
|
|
3655
|
-
).option("--quiet", "Suppress dev-server output.")
|
|
3656
|
-
|
|
3487
|
+
).option("--quiet", "Suppress dev-server output.");
|
|
3488
|
+
}
|
|
3489
|
+
function createClientScreenshotCommand() {
|
|
3490
|
+
const cmd = withCommonScreenshotOptions(
|
|
3491
|
+
new import_commander.Command("screenshot").description(
|
|
3492
|
+
"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`."
|
|
3493
|
+
)
|
|
3494
|
+
).option(
|
|
3495
|
+
"--mcp <url>",
|
|
3496
|
+
"Ad-hoc MCP server URL. Required for the top-level form. No authentication unless --header is supplied."
|
|
3497
|
+
).option(
|
|
3498
|
+
"-H, --header <header>",
|
|
3499
|
+
'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.',
|
|
3500
|
+
collectHeader,
|
|
3501
|
+
[]
|
|
3502
|
+
);
|
|
3503
|
+
cmd.action(async (args, opts) => {
|
|
3504
|
+
await screenshotCommand(opts, args, {
|
|
3505
|
+
usagePrefix: "mcp-use client screenshot"
|
|
3506
|
+
});
|
|
3507
|
+
});
|
|
3508
|
+
return cmd;
|
|
3509
|
+
}
|
|
3510
|
+
function createPerClientScreenshotCommand(name) {
|
|
3511
|
+
const cmd = withCommonScreenshotOptions(
|
|
3512
|
+
new import_commander.Command("screenshot").description(
|
|
3513
|
+
`Render an MCP Apps view headlessly using the saved server '${name}'.`
|
|
3514
|
+
)
|
|
3515
|
+
);
|
|
3516
|
+
cmd.action(async (args, opts) => {
|
|
3517
|
+
await screenshotCommand(opts, args, {
|
|
3518
|
+
sessionName: name,
|
|
3519
|
+
usagePrefix: `mcp-use client ${name} screenshot`
|
|
3520
|
+
});
|
|
3657
3521
|
});
|
|
3522
|
+
return cmd;
|
|
3658
3523
|
}
|
|
3659
3524
|
|
|
3660
3525
|
// src/commands/client.ts
|
|
3661
|
-
|
|
3526
|
+
var RESERVED_CLIENT_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
3527
|
+
"connect",
|
|
3528
|
+
"list",
|
|
3529
|
+
"remove",
|
|
3530
|
+
"screenshot",
|
|
3531
|
+
"help"
|
|
3532
|
+
]);
|
|
3533
|
+
var PER_CLIENT_SCOPES = /* @__PURE__ */ new Set([
|
|
3534
|
+
"tools",
|
|
3535
|
+
"resources",
|
|
3536
|
+
"prompts",
|
|
3537
|
+
"auth",
|
|
3538
|
+
"disconnect",
|
|
3539
|
+
"interactive",
|
|
3540
|
+
"screenshot"
|
|
3541
|
+
]);
|
|
3542
|
+
async function connectCommand(name, urlOrCommand, options) {
|
|
3543
|
+
if (!name || !urlOrCommand) {
|
|
3544
|
+
const looksLikeUrl = !!name && /^https?:\/\//i.test(name);
|
|
3545
|
+
if (looksLikeUrl && !urlOrCommand && !options.stdio) {
|
|
3546
|
+
console.error(formatError("Missing server name."));
|
|
3547
|
+
console.error("");
|
|
3548
|
+
console.error(
|
|
3549
|
+
formatInfo(
|
|
3550
|
+
"Each saved server needs a short name you'll use to address it later."
|
|
3551
|
+
)
|
|
3552
|
+
);
|
|
3553
|
+
console.error("");
|
|
3554
|
+
console.error("Try:");
|
|
3555
|
+
console.error(` mcp-use client connect <name> ${name}`);
|
|
3556
|
+
console.error("");
|
|
3557
|
+
console.error("Example:");
|
|
3558
|
+
console.error(` mcp-use client connect my-server ${name}`);
|
|
3559
|
+
console.error(" mcp-use client my-server tools list");
|
|
3560
|
+
} else if (name && !urlOrCommand) {
|
|
3561
|
+
console.error(
|
|
3562
|
+
formatError(options.stdio ? "Missing <command>." : "Missing <url>.")
|
|
3563
|
+
);
|
|
3564
|
+
console.error("");
|
|
3565
|
+
console.error(formatInfo("Usage:"));
|
|
3566
|
+
console.error(
|
|
3567
|
+
options.stdio ? ` mcp-use client connect ${name} "<command>" --stdio` : ` mcp-use client connect ${name} <url>`
|
|
3568
|
+
);
|
|
3569
|
+
} else {
|
|
3570
|
+
console.error(formatError("Missing required arguments: <name> <url>."));
|
|
3571
|
+
console.error("");
|
|
3572
|
+
console.error(formatInfo("Usage:"));
|
|
3573
|
+
console.error(" mcp-use client connect <name> <url>");
|
|
3574
|
+
console.error("");
|
|
3575
|
+
console.error("Example:");
|
|
3576
|
+
console.error(
|
|
3577
|
+
" mcp-use client connect manufact https://mcp.manufact.com/mcp"
|
|
3578
|
+
);
|
|
3579
|
+
}
|
|
3580
|
+
await cleanupAndExit(1);
|
|
3581
|
+
}
|
|
3582
|
+
const sessionName = name;
|
|
3583
|
+
const target = urlOrCommand;
|
|
3584
|
+
if (PER_CLIENT_SCOPES.has(sessionName)) {
|
|
3585
|
+
console.error(
|
|
3586
|
+
formatError(
|
|
3587
|
+
`'${sessionName}' is a reserved name and can't be used for a saved server.`
|
|
3588
|
+
)
|
|
3589
|
+
);
|
|
3590
|
+
console.error("");
|
|
3591
|
+
console.error(
|
|
3592
|
+
`Reserved names: ${Array.from(PER_CLIENT_SCOPES).sort().join(", ")}`
|
|
3593
|
+
);
|
|
3594
|
+
console.error("");
|
|
3595
|
+
console.error("Pick a different name, e.g.:");
|
|
3596
|
+
console.error(` mcp-use client connect my-${sessionName} ${target}`);
|
|
3597
|
+
await cleanupAndExit(1);
|
|
3598
|
+
}
|
|
3662
3599
|
try {
|
|
3663
|
-
const sessionName = options.name || `session-${Date.now()}`;
|
|
3664
3600
|
const client = new import_client3.MCPClient();
|
|
3665
3601
|
let session;
|
|
3666
3602
|
const cliClientInfo = getCliClientInfo();
|
|
3667
3603
|
if (options.stdio) {
|
|
3668
|
-
const parts =
|
|
3604
|
+
const parts = target.split(" ");
|
|
3669
3605
|
const command = parts[0];
|
|
3670
3606
|
const args = parts.slice(1);
|
|
3671
3607
|
console.error(
|
|
@@ -3684,17 +3620,17 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3684
3620
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
3685
3621
|
});
|
|
3686
3622
|
} else {
|
|
3687
|
-
console.error(formatInfo(`Connecting to ${
|
|
3623
|
+
console.error(formatInfo(`Connecting to ${target}...`));
|
|
3688
3624
|
const wantOAuth = !options.auth && options.oauth !== false;
|
|
3689
3625
|
let authProvider;
|
|
3690
3626
|
if (wantOAuth) {
|
|
3691
3627
|
const authTimeoutMs = options.authTimeout ? Number.parseInt(options.authTimeout, 10) : void 0;
|
|
3692
|
-
authProvider = await buildOAuthProvider(
|
|
3628
|
+
authProvider = await buildOAuthProvider(target, {
|
|
3693
3629
|
...authTimeoutMs ? { authTimeoutMs } : {}
|
|
3694
3630
|
});
|
|
3695
3631
|
}
|
|
3696
3632
|
client.addServer(sessionName, {
|
|
3697
|
-
url:
|
|
3633
|
+
url: target,
|
|
3698
3634
|
...authProvider ? { authProvider } : options.auth ? { headers: { Authorization: `Bearer ${options.auth}` } } : {},
|
|
3699
3635
|
clientInfo: cliClientInfo
|
|
3700
3636
|
});
|
|
@@ -3707,7 +3643,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3707
3643
|
"Server requires authentication. Starting OAuth flow."
|
|
3708
3644
|
)
|
|
3709
3645
|
);
|
|
3710
|
-
await runOAuthFlow(authProvider,
|
|
3646
|
+
await runOAuthFlow(authProvider, target);
|
|
3711
3647
|
console.error(formatSuccess("Authentication successful"));
|
|
3712
3648
|
session = await client.createSession(sessionName);
|
|
3713
3649
|
} else {
|
|
@@ -3716,7 +3652,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3716
3652
|
}
|
|
3717
3653
|
await saveSession(sessionName, {
|
|
3718
3654
|
type: "http",
|
|
3719
|
-
url:
|
|
3655
|
+
url: target,
|
|
3720
3656
|
authMode: authProvider ? "oauth" : options.auth ? "bearer" : void 0,
|
|
3721
3657
|
authToken: authProvider ? void 0 : options.auth,
|
|
3722
3658
|
lastUsed: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -3728,7 +3664,7 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3728
3664
|
if (serverInfo) {
|
|
3729
3665
|
await updateSessionInfo(sessionName, serverInfo, capabilities);
|
|
3730
3666
|
}
|
|
3731
|
-
console.log(formatSuccess(`Connected
|
|
3667
|
+
console.log(formatSuccess(`Connected as '${sessionName}'`));
|
|
3732
3668
|
if (serverInfo) {
|
|
3733
3669
|
console.log("");
|
|
3734
3670
|
console.log(formatHeader("Server Information:"));
|
|
@@ -3758,31 +3694,15 @@ async function connectCommand(urlOrCommand, options) {
|
|
|
3758
3694
|
}
|
|
3759
3695
|
await cleanupAndExit(0);
|
|
3760
3696
|
}
|
|
3761
|
-
async function disconnectCommand(
|
|
3697
|
+
async function disconnectCommand(name) {
|
|
3762
3698
|
try {
|
|
3763
|
-
|
|
3764
|
-
for (const [name, { client }] of activeSessions.entries()) {
|
|
3765
|
-
await client.closeAllSessions();
|
|
3766
|
-
activeSessions.delete(name);
|
|
3767
|
-
console.log(formatSuccess(`Disconnected from ${name}`));
|
|
3768
|
-
}
|
|
3769
|
-
await cleanupAndExit(0);
|
|
3770
|
-
}
|
|
3771
|
-
if (!sessionName) {
|
|
3772
|
-
const active = await getActiveSession();
|
|
3773
|
-
if (!active) {
|
|
3774
|
-
console.error(formatError("No active session to disconnect"));
|
|
3775
|
-
await cleanupAndExit(0);
|
|
3776
|
-
}
|
|
3777
|
-
sessionName = active.name;
|
|
3778
|
-
}
|
|
3779
|
-
const sessionData = activeSessions.get(sessionName);
|
|
3699
|
+
const sessionData = activeSessions.get(name);
|
|
3780
3700
|
if (sessionData) {
|
|
3781
3701
|
await sessionData.client.closeAllSessions();
|
|
3782
|
-
activeSessions.delete(
|
|
3783
|
-
console.log(formatSuccess(`Disconnected from ${
|
|
3702
|
+
activeSessions.delete(name);
|
|
3703
|
+
console.log(formatSuccess(`Disconnected from ${name}`));
|
|
3784
3704
|
} else {
|
|
3785
|
-
console.log(formatInfo(`
|
|
3705
|
+
console.log(formatInfo(`Server '${name}' is not connected`));
|
|
3786
3706
|
}
|
|
3787
3707
|
} catch (error) {
|
|
3788
3708
|
console.error(formatError(`Failed to disconnect: ${error.message}`));
|
|
@@ -3790,15 +3710,63 @@ async function disconnectCommand(sessionName, options) {
|
|
|
3790
3710
|
}
|
|
3791
3711
|
await cleanupAndExit(0);
|
|
3792
3712
|
}
|
|
3793
|
-
async function
|
|
3713
|
+
async function removeClientCommand(name) {
|
|
3714
|
+
try {
|
|
3715
|
+
const config = await getSession(name);
|
|
3716
|
+
if (!config) {
|
|
3717
|
+
console.error(formatError(`Server '${name}' not found`));
|
|
3718
|
+
console.error("");
|
|
3719
|
+
console.error("See your saved servers with:");
|
|
3720
|
+
console.error(" mcp-use client list");
|
|
3721
|
+
await cleanupAndExit(1);
|
|
3722
|
+
}
|
|
3723
|
+
const sessionData = activeSessions.get(name);
|
|
3724
|
+
if (sessionData) {
|
|
3725
|
+
await sessionData.client.closeAllSessions();
|
|
3726
|
+
activeSessions.delete(name);
|
|
3727
|
+
}
|
|
3728
|
+
const isOAuthHttp = config.type === "http" && config.authMode === "oauth" && typeof config.url === "string";
|
|
3729
|
+
const sharedUrlSibling = isOAuthHttp ? (await listAllSessions()).find(
|
|
3730
|
+
(s) => s.name !== name && s.config.type === "http" && s.config.url === config.url
|
|
3731
|
+
) : void 0;
|
|
3732
|
+
await removeSession(name);
|
|
3733
|
+
console.log(formatSuccess(`Removed saved server '${name}'`));
|
|
3734
|
+
if (isOAuthHttp) {
|
|
3735
|
+
if (sharedUrlSibling) {
|
|
3736
|
+
console.log(
|
|
3737
|
+
formatInfo(
|
|
3738
|
+
`OAuth tokens for ${config.url} were kept because saved server '${sharedUrlSibling.name}' still uses that URL.`
|
|
3739
|
+
)
|
|
3740
|
+
);
|
|
3741
|
+
} else {
|
|
3742
|
+
try {
|
|
3743
|
+
const provider = await buildOAuthProvider(config.url);
|
|
3744
|
+
await provider.invalidateCredentials("all");
|
|
3745
|
+
console.log(formatInfo(`Removed OAuth tokens for ${config.url}`));
|
|
3746
|
+
} catch (error) {
|
|
3747
|
+
console.error(
|
|
3748
|
+
formatWarning(
|
|
3749
|
+
`Saved entry removed, but failed to clear OAuth tokens for ${config.url}: ${error.message}`
|
|
3750
|
+
)
|
|
3751
|
+
);
|
|
3752
|
+
}
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
} catch (error) {
|
|
3756
|
+
console.error(formatError(`Failed to remove server: ${error.message}`));
|
|
3757
|
+
await cleanupAndExit(1);
|
|
3758
|
+
}
|
|
3759
|
+
await cleanupAndExit(0);
|
|
3760
|
+
}
|
|
3761
|
+
async function listClientsCommand() {
|
|
3794
3762
|
try {
|
|
3795
3763
|
const sessions = await listAllSessions();
|
|
3796
3764
|
if (sessions.length === 0) {
|
|
3797
3765
|
if (isStdoutTty()) {
|
|
3798
|
-
console.log(formatInfo("No saved
|
|
3766
|
+
console.log(formatInfo("No saved servers"));
|
|
3799
3767
|
console.log(
|
|
3800
3768
|
formatInfo(
|
|
3801
|
-
"Connect to a server with: npx mcp-use client connect <url>"
|
|
3769
|
+
"Connect to a server with: npx mcp-use client connect <name> <url>"
|
|
3802
3770
|
)
|
|
3803
3771
|
);
|
|
3804
3772
|
}
|
|
@@ -3806,11 +3774,11 @@ async function listSessionsCommand() {
|
|
|
3806
3774
|
}
|
|
3807
3775
|
const tty2 = isStdoutTty();
|
|
3808
3776
|
if (tty2) {
|
|
3809
|
-
console.log(formatHeader("Saved
|
|
3777
|
+
console.log(formatHeader("Saved Servers:"));
|
|
3810
3778
|
console.log("");
|
|
3811
3779
|
}
|
|
3812
3780
|
const tableData = sessions.map((s) => ({
|
|
3813
|
-
name: s.
|
|
3781
|
+
name: s.name,
|
|
3814
3782
|
type: s.config.type,
|
|
3815
3783
|
target: s.config.type === "http" ? s.config.url || "" : `${s.config.command} ${(s.config.args || []).join(" ")}`,
|
|
3816
3784
|
server: s.config.serverInfo?.name || "unknown"
|
|
@@ -3823,29 +3791,15 @@ async function listSessionsCommand() {
|
|
|
3823
3791
|
{ key: "server", header: "Server" }
|
|
3824
3792
|
])
|
|
3825
3793
|
);
|
|
3826
|
-
if (tty2) {
|
|
3827
|
-
console.log("");
|
|
3828
|
-
console.log(source_default.gray("* = active session"));
|
|
3829
|
-
}
|
|
3830
3794
|
} catch (error) {
|
|
3831
|
-
console.error(formatError(`Failed to list
|
|
3795
|
+
console.error(formatError(`Failed to list servers: ${error.message}`));
|
|
3832
3796
|
await cleanupAndExit(1);
|
|
3833
3797
|
}
|
|
3834
3798
|
await cleanupAndExit(0);
|
|
3835
3799
|
}
|
|
3836
|
-
async function
|
|
3800
|
+
async function listToolsCommand(name, options) {
|
|
3837
3801
|
try {
|
|
3838
|
-
await
|
|
3839
|
-
console.log(formatSuccess(`Switched to session '${name}'`));
|
|
3840
|
-
} catch (error) {
|
|
3841
|
-
console.error(formatError(`Failed to switch session: ${error.message}`));
|
|
3842
|
-
await cleanupAndExit(1);
|
|
3843
|
-
}
|
|
3844
|
-
await cleanupAndExit(0);
|
|
3845
|
-
}
|
|
3846
|
-
async function listToolsCommand(options) {
|
|
3847
|
-
try {
|
|
3848
|
-
const result = await getOrRestoreSession(options.session || null);
|
|
3802
|
+
const result = await getOrRestoreSession(name);
|
|
3849
3803
|
if (!result) {
|
|
3850
3804
|
await cleanupAndExit(1);
|
|
3851
3805
|
}
|
|
@@ -3897,9 +3851,9 @@ async function listToolsCommand(options) {
|
|
|
3897
3851
|
}
|
|
3898
3852
|
await cleanupAndExit(0);
|
|
3899
3853
|
}
|
|
3900
|
-
async function describeToolCommand(
|
|
3854
|
+
async function describeToolCommand(name, toolName) {
|
|
3901
3855
|
try {
|
|
3902
|
-
const result = await getOrRestoreSession(
|
|
3856
|
+
const result = await getOrRestoreSession(name);
|
|
3903
3857
|
if (!result) {
|
|
3904
3858
|
await cleanupAndExit(1);
|
|
3905
3859
|
}
|
|
@@ -3929,9 +3883,9 @@ async function describeToolCommand(toolName, options) {
|
|
|
3929
3883
|
}
|
|
3930
3884
|
await cleanupAndExit(0);
|
|
3931
3885
|
}
|
|
3932
|
-
async function callToolCommand(toolName, argsList, options) {
|
|
3886
|
+
async function callToolCommand(name, toolName, argsList, options) {
|
|
3933
3887
|
try {
|
|
3934
|
-
const result = await getOrRestoreSession(
|
|
3888
|
+
const result = await getOrRestoreSession(name);
|
|
3935
3889
|
if (!result) {
|
|
3936
3890
|
await cleanupAndExit(1);
|
|
3937
3891
|
}
|
|
@@ -3947,13 +3901,13 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3947
3901
|
console.log("");
|
|
3948
3902
|
console.log(formatInfo("Usage:"));
|
|
3949
3903
|
console.log(
|
|
3950
|
-
` npx mcp-use client tools call ${toolName} key=value [key2=value2 ...]`
|
|
3904
|
+
` npx mcp-use client ${name} tools call ${toolName} key=value [key2=value2 ...]`
|
|
3951
3905
|
);
|
|
3952
3906
|
console.log(
|
|
3953
|
-
` npx mcp-use client tools call ${toolName} nested:='{"a":1}' # JSON value`
|
|
3907
|
+
` npx mcp-use client ${name} tools call ${toolName} nested:='{"a":1}' # JSON value`
|
|
3954
3908
|
);
|
|
3955
3909
|
console.log(
|
|
3956
|
-
` npx mcp-use client tools call ${toolName} '{"key":"value"}' # full JSON object`
|
|
3910
|
+
` npx mcp-use client ${name} tools call ${toolName} '{"key":"value"}' # full JSON object`
|
|
3957
3911
|
);
|
|
3958
3912
|
if (tool?.inputSchema) {
|
|
3959
3913
|
console.log("");
|
|
@@ -3967,7 +3921,7 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3967
3921
|
console.log("");
|
|
3968
3922
|
console.log(formatInfo("Provide arguments as key=value pairs:"));
|
|
3969
3923
|
console.log(
|
|
3970
|
-
` npx mcp-use client tools call ${toolName} key=value [key2=value2 ...]`
|
|
3924
|
+
` npx mcp-use client ${name} tools call ${toolName} key=value [key2=value2 ...]`
|
|
3971
3925
|
);
|
|
3972
3926
|
console.log("");
|
|
3973
3927
|
console.log(formatInfo("Tool schema:"));
|
|
@@ -3978,16 +3932,27 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3978
3932
|
const callResult = await session.callTool(toolName, args, {
|
|
3979
3933
|
timeout: options?.timeout
|
|
3980
3934
|
});
|
|
3935
|
+
const toolWithMeta = session.tools.find((t) => t.name === toolName);
|
|
3936
|
+
const resourceUri = detectToolResourceUri(toolWithMeta);
|
|
3937
|
+
const wantsScreenshot = options?.screenshot === true || options?.screenshotOutput !== void 0 || options?.screenshotDeviceScaleFactor !== void 0;
|
|
3981
3938
|
let screenshot = null;
|
|
3982
3939
|
let screenshotError = null;
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
if (resourceUri) {
|
|
3940
|
+
let widgetHintUri = null;
|
|
3941
|
+
if (resourceUri) {
|
|
3942
|
+
if (wantsScreenshot) {
|
|
3987
3943
|
console.error(
|
|
3988
3944
|
formatInfo(`Capturing widget screenshot (${resourceUri})...`)
|
|
3989
3945
|
);
|
|
3990
3946
|
try {
|
|
3947
|
+
const screenshotOpts = {};
|
|
3948
|
+
if (options?.screenshotOutput) {
|
|
3949
|
+
screenshotOpts.output = options.screenshotOutput;
|
|
3950
|
+
}
|
|
3951
|
+
if (options?.screenshotDeviceScaleFactor) {
|
|
3952
|
+
screenshotOpts.deviceScaleFactor = parseDeviceScaleFactor(
|
|
3953
|
+
options.screenshotDeviceScaleFactor
|
|
3954
|
+
);
|
|
3955
|
+
}
|
|
3991
3956
|
const shot = await captureToolScreenshot(
|
|
3992
3957
|
{
|
|
3993
3958
|
session,
|
|
@@ -3996,7 +3961,7 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
3996
3961
|
toolOutput: callResult,
|
|
3997
3962
|
resourceUri
|
|
3998
3963
|
},
|
|
3999
|
-
|
|
3964
|
+
screenshotOpts
|
|
4000
3965
|
);
|
|
4001
3966
|
screenshot = {
|
|
4002
3967
|
path: shot.outputPath,
|
|
@@ -4007,6 +3972,8 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
4007
3972
|
} catch (err) {
|
|
4008
3973
|
screenshotError = err?.message ?? String(err);
|
|
4009
3974
|
}
|
|
3975
|
+
} else {
|
|
3976
|
+
widgetHintUri = resourceUri;
|
|
4010
3977
|
}
|
|
4011
3978
|
}
|
|
4012
3979
|
if (options?.json) {
|
|
@@ -4026,6 +3993,13 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
4026
3993
|
formatWarning(`Skipped widget screenshot: ${screenshotError}`)
|
|
4027
3994
|
);
|
|
4028
3995
|
}
|
|
3996
|
+
if (widgetHintUri) {
|
|
3997
|
+
console.error(
|
|
3998
|
+
formatInfo(
|
|
3999
|
+
`This tool renders a widget (${widgetHintUri}). Re-run with --screenshot to save a PNG of it.`
|
|
4000
|
+
)
|
|
4001
|
+
);
|
|
4002
|
+
}
|
|
4029
4003
|
if (callResult.isError) {
|
|
4030
4004
|
await cleanupAndExit(1);
|
|
4031
4005
|
}
|
|
@@ -4042,9 +4016,9 @@ async function callToolCommand(toolName, argsList, options) {
|
|
|
4042
4016
|
}
|
|
4043
4017
|
await cleanupAndExit(0);
|
|
4044
4018
|
}
|
|
4045
|
-
async function listResourcesCommand(options) {
|
|
4019
|
+
async function listResourcesCommand(name, options) {
|
|
4046
4020
|
try {
|
|
4047
|
-
const result = await getOrRestoreSession(
|
|
4021
|
+
const result = await getOrRestoreSession(name);
|
|
4048
4022
|
if (!result) {
|
|
4049
4023
|
await cleanupAndExit(1);
|
|
4050
4024
|
}
|
|
@@ -4080,9 +4054,9 @@ async function listResourcesCommand(options) {
|
|
|
4080
4054
|
}
|
|
4081
4055
|
await cleanupAndExit(0);
|
|
4082
4056
|
}
|
|
4083
|
-
async function readResourceCommand(uri, options) {
|
|
4057
|
+
async function readResourceCommand(name, uri, options) {
|
|
4084
4058
|
try {
|
|
4085
|
-
const result = await getOrRestoreSession(
|
|
4059
|
+
const result = await getOrRestoreSession(name);
|
|
4086
4060
|
if (!result) {
|
|
4087
4061
|
await cleanupAndExit(1);
|
|
4088
4062
|
}
|
|
@@ -4100,9 +4074,9 @@ async function readResourceCommand(uri, options) {
|
|
|
4100
4074
|
}
|
|
4101
4075
|
await cleanupAndExit(0);
|
|
4102
4076
|
}
|
|
4103
|
-
async function subscribeResourceCommand(
|
|
4077
|
+
async function subscribeResourceCommand(name, uri) {
|
|
4104
4078
|
try {
|
|
4105
|
-
const result = await getOrRestoreSession(
|
|
4079
|
+
const result = await getOrRestoreSession(name);
|
|
4106
4080
|
if (!result) {
|
|
4107
4081
|
await cleanupAndExit(1);
|
|
4108
4082
|
}
|
|
@@ -4126,9 +4100,9 @@ async function subscribeResourceCommand(uri, options) {
|
|
|
4126
4100
|
await cleanupAndExit(1);
|
|
4127
4101
|
}
|
|
4128
4102
|
}
|
|
4129
|
-
async function unsubscribeResourceCommand(
|
|
4103
|
+
async function unsubscribeResourceCommand(name, uri) {
|
|
4130
4104
|
try {
|
|
4131
|
-
const result = await getOrRestoreSession(
|
|
4105
|
+
const result = await getOrRestoreSession(name);
|
|
4132
4106
|
if (!result) {
|
|
4133
4107
|
await cleanupAndExit(1);
|
|
4134
4108
|
}
|
|
@@ -4143,9 +4117,9 @@ async function unsubscribeResourceCommand(uri, options) {
|
|
|
4143
4117
|
}
|
|
4144
4118
|
await cleanupAndExit(0);
|
|
4145
4119
|
}
|
|
4146
|
-
async function listPromptsCommand(options) {
|
|
4120
|
+
async function listPromptsCommand(name, options) {
|
|
4147
4121
|
try {
|
|
4148
|
-
const result = await getOrRestoreSession(
|
|
4122
|
+
const result = await getOrRestoreSession(name);
|
|
4149
4123
|
if (!result) {
|
|
4150
4124
|
await cleanupAndExit(1);
|
|
4151
4125
|
}
|
|
@@ -4187,9 +4161,9 @@ async function listPromptsCommand(options) {
|
|
|
4187
4161
|
}
|
|
4188
4162
|
await cleanupAndExit(0);
|
|
4189
4163
|
}
|
|
4190
|
-
async function getPromptCommand(promptName, argsList, options) {
|
|
4164
|
+
async function getPromptCommand(name, promptName, argsList, options) {
|
|
4191
4165
|
try {
|
|
4192
|
-
const result = await getOrRestoreSession(
|
|
4166
|
+
const result = await getOrRestoreSession(name);
|
|
4193
4167
|
if (!result) {
|
|
4194
4168
|
await cleanupAndExit(1);
|
|
4195
4169
|
}
|
|
@@ -4203,10 +4177,10 @@ async function getPromptCommand(promptName, argsList, options) {
|
|
|
4203
4177
|
console.log("");
|
|
4204
4178
|
console.log(formatInfo("Usage:"));
|
|
4205
4179
|
console.log(
|
|
4206
|
-
` npx mcp-use client prompts get ${promptName} key=value [key2=value2 ...]`
|
|
4180
|
+
` npx mcp-use client ${name} prompts get ${promptName} key=value [key2=value2 ...]`
|
|
4207
4181
|
);
|
|
4208
4182
|
console.log(
|
|
4209
|
-
` npx mcp-use client prompts get ${promptName} '{"key":"value"}' # full JSON object`
|
|
4183
|
+
` npx mcp-use client ${name} prompts get ${promptName} '{"key":"value"}' # full JSON object`
|
|
4210
4184
|
);
|
|
4211
4185
|
await cleanupAndExit(1);
|
|
4212
4186
|
}
|
|
@@ -4234,9 +4208,9 @@ async function getPromptCommand(promptName, argsList, options) {
|
|
|
4234
4208
|
}
|
|
4235
4209
|
await cleanupAndExit(0);
|
|
4236
4210
|
}
|
|
4237
|
-
async function interactiveCommand(
|
|
4211
|
+
async function interactiveCommand(name) {
|
|
4238
4212
|
try {
|
|
4239
|
-
const result = await getOrRestoreSession(
|
|
4213
|
+
const result = await getOrRestoreSession(name);
|
|
4240
4214
|
if (!result) return;
|
|
4241
4215
|
const { name: sessionName, session } = result;
|
|
4242
4216
|
console.log(formatHeader("MCP Interactive Mode"));
|
|
@@ -4259,10 +4233,6 @@ async function interactiveCommand(options) {
|
|
|
4259
4233
|
source_default.gray(" prompts list - List available prompts")
|
|
4260
4234
|
);
|
|
4261
4235
|
console.log(source_default.gray(" prompts get <name> - Get a prompt"));
|
|
4262
|
-
console.log(source_default.gray(" sessions list - List all sessions"));
|
|
4263
|
-
console.log(
|
|
4264
|
-
source_default.gray(" sessions switch <name> - Switch to another session")
|
|
4265
|
-
);
|
|
4266
4236
|
console.log(
|
|
4267
4237
|
source_default.gray(" exit, quit - Exit interactive mode")
|
|
4268
4238
|
);
|
|
@@ -4382,22 +4352,10 @@ async function interactiveCommand(options) {
|
|
|
4382
4352
|
)
|
|
4383
4353
|
);
|
|
4384
4354
|
}
|
|
4385
|
-
} else if (scope === "sessions") {
|
|
4386
|
-
if (command === "list") {
|
|
4387
|
-
await listSessionsCommand();
|
|
4388
|
-
} else if (command === "switch" && arg) {
|
|
4389
|
-
console.log(
|
|
4390
|
-
formatWarning(
|
|
4391
|
-
"Session switching in interactive mode will be available in a future version"
|
|
4392
|
-
)
|
|
4393
|
-
);
|
|
4394
|
-
} else {
|
|
4395
|
-
console.error(formatError("Invalid command. Try: sessions list"));
|
|
4396
|
-
}
|
|
4397
4355
|
} else {
|
|
4398
4356
|
console.error(
|
|
4399
4357
|
formatError(
|
|
4400
|
-
"Unknown command. Type a valid scope: tools, resources, prompts
|
|
4358
|
+
"Unknown command. Type a valid scope: tools, resources, prompts"
|
|
4401
4359
|
)
|
|
4402
4360
|
);
|
|
4403
4361
|
}
|
|
@@ -4420,72 +4378,86 @@ async function interactiveCommand(options) {
|
|
|
4420
4378
|
}
|
|
4421
4379
|
function createClientCommand() {
|
|
4422
4380
|
const clientCommand = new import_commander2.Command("client").description(
|
|
4423
|
-
"Interactive MCP client for terminal usage"
|
|
4381
|
+
"Interactive MCP client for terminal usage. Use `mcp-use client <name> ...` to run commands against a saved server."
|
|
4382
|
+
).showHelpAfterError(
|
|
4383
|
+
"(Run `mcp-use client --help` to see available commands)"
|
|
4424
4384
|
);
|
|
4425
|
-
clientCommand.command("connect
|
|
4385
|
+
clientCommand.command("connect [name] [url]").description(
|
|
4386
|
+
"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`)."
|
|
4387
|
+
).option("--stdio", "Use stdio connector instead of HTTP").option("--auth <token>", "Static Bearer token (skips OAuth)").option(
|
|
4426
4388
|
"--no-oauth",
|
|
4427
4389
|
"Don't auto-trigger OAuth on 401; fail with the 401 instead"
|
|
4428
4390
|
).option(
|
|
4429
4391
|
"--auth-timeout <ms>",
|
|
4430
4392
|
"OAuth loopback wait timeout in ms (default 300000)"
|
|
4431
4393
|
).action(connectCommand);
|
|
4432
|
-
clientCommand.command("
|
|
4433
|
-
|
|
4434
|
-
"
|
|
4394
|
+
clientCommand.command("list").description("List saved servers").action(listClientsCommand);
|
|
4395
|
+
clientCommand.command("remove <name>").description(
|
|
4396
|
+
"Remove a saved server. Also clears any OAuth tokens for that URL, unless another saved server still uses it."
|
|
4397
|
+
).action(removeClientCommand);
|
|
4398
|
+
clientCommand.addCommand(createClientScreenshotCommand());
|
|
4399
|
+
return clientCommand;
|
|
4400
|
+
}
|
|
4401
|
+
function createPerClientCommand(name) {
|
|
4402
|
+
const cmd = new import_commander2.Command(`mcp-use client ${name}`).description(`Commands for server '${name}'`).showHelpAfterError(
|
|
4403
|
+
`(Run \`mcp-use client ${name} --help\` to see available commands)`
|
|
4435
4404
|
);
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
"Interact with MCP tools"
|
|
4405
|
+
cmd.command("disconnect").description("Disconnect from this server").action(() => disconnectCommand(name));
|
|
4406
|
+
cmd.command("interactive").description("Start interactive REPL mode for this server").action(() => interactiveCommand(name));
|
|
4407
|
+
const toolsCommand = new import_commander2.Command("tools").description("Interact with MCP tools").showHelpAfterError(
|
|
4408
|
+
`(Run \`mcp-use client ${name} tools --help\` to see available actions)`
|
|
4441
4409
|
);
|
|
4442
|
-
toolsCommand.command("list").description("List available tools").option("--
|
|
4443
|
-
toolsCommand.command("call <
|
|
4410
|
+
toolsCommand.command("list").description("List available tools").option("--json", "Output as JSON").action((options) => listToolsCommand(name, options));
|
|
4411
|
+
toolsCommand.command("call <tool> [args...]").description(
|
|
4444
4412
|
"Call a tool. Args as key=value pairs (use key:=<json> for nested values, or pass a JSON object)"
|
|
4445
|
-
).option("--
|
|
4446
|
-
"--
|
|
4447
|
-
"
|
|
4413
|
+
).option("--timeout <ms>", "Request timeout in milliseconds", parseInt).option("--json", "Output as JSON").option(
|
|
4414
|
+
"--screenshot",
|
|
4415
|
+
"Capture a PNG screenshot of the rendered widget for tools that declare a UI resource"
|
|
4448
4416
|
).option(
|
|
4449
4417
|
"--screenshot-output <path>",
|
|
4450
|
-
"Output PNG path for the widget screenshot (defaults to ./<view>-<timestamp>.png)"
|
|
4451
|
-
).
|
|
4452
|
-
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4418
|
+
"Output PNG path for the widget screenshot (implies --screenshot; defaults to ./<view>-<timestamp>.png)"
|
|
4419
|
+
).option(
|
|
4420
|
+
"--screenshot-device-scale-factor <n>",
|
|
4421
|
+
"Device pixel ratio for the widget screenshot (implies --screenshot; e.g. 2 for Retina). Defaults to 1."
|
|
4422
|
+
).action(
|
|
4423
|
+
(tool, args, options) => callToolCommand(name, tool, args, options)
|
|
4424
|
+
);
|
|
4425
|
+
toolsCommand.command("describe <tool>").description("Show tool details and schema").action((tool) => describeToolCommand(name, tool));
|
|
4426
|
+
cmd.addCommand(toolsCommand);
|
|
4427
|
+
const resourcesCommand = new import_commander2.Command("resources").description("Interact with MCP resources").showHelpAfterError(
|
|
4428
|
+
`(Run \`mcp-use client ${name} resources --help\` to see available actions)`
|
|
4456
4429
|
);
|
|
4457
|
-
resourcesCommand.command("list").description("List available resources").option("--
|
|
4458
|
-
resourcesCommand.command("read <uri>").description("Read a resource by URI").option("--
|
|
4459
|
-
resourcesCommand.command("subscribe <uri>").description("Subscribe to resource updates").
|
|
4460
|
-
resourcesCommand.command("unsubscribe <uri>").description("Unsubscribe from resource updates").
|
|
4461
|
-
|
|
4462
|
-
const promptsCommand = new import_commander2.Command("prompts").description(
|
|
4463
|
-
|
|
4430
|
+
resourcesCommand.command("list").description("List available resources").option("--json", "Output as JSON").action((options) => listResourcesCommand(name, options));
|
|
4431
|
+
resourcesCommand.command("read <uri>").description("Read a resource by URI").option("--json", "Output as JSON").action((uri, options) => readResourceCommand(name, uri, options));
|
|
4432
|
+
resourcesCommand.command("subscribe <uri>").description("Subscribe to resource updates").action((uri) => subscribeResourceCommand(name, uri));
|
|
4433
|
+
resourcesCommand.command("unsubscribe <uri>").description("Unsubscribe from resource updates").action((uri) => unsubscribeResourceCommand(name, uri));
|
|
4434
|
+
cmd.addCommand(resourcesCommand);
|
|
4435
|
+
const promptsCommand = new import_commander2.Command("prompts").description("Interact with MCP prompts").showHelpAfterError(
|
|
4436
|
+
`(Run \`mcp-use client ${name} prompts --help\` to see available actions)`
|
|
4464
4437
|
);
|
|
4465
|
-
promptsCommand.command("list").description("List available prompts").option("--
|
|
4466
|
-
promptsCommand.command("get <
|
|
4438
|
+
promptsCommand.command("list").description("List available prompts").option("--json", "Output as JSON").action((options) => listPromptsCommand(name, options));
|
|
4439
|
+
promptsCommand.command("get <prompt> [args...]").description(
|
|
4467
4440
|
"Get a prompt. Args as key=value pairs (or pass a JSON object)"
|
|
4468
|
-
).option("--
|
|
4469
|
-
|
|
4470
|
-
clientCommand.command("interactive").description("Start interactive REPL mode").option("--session <name>", "Use specific session").action(interactiveCommand);
|
|
4471
|
-
const authCommand = new import_commander2.Command("auth").description(
|
|
4472
|
-
"Manage OAuth tokens for HTTP sessions"
|
|
4441
|
+
).option("--json", "Output as JSON").action(
|
|
4442
|
+
(prompt4, args, options) => getPromptCommand(name, prompt4, args, options)
|
|
4473
4443
|
);
|
|
4474
|
-
|
|
4475
|
-
authCommand.
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4444
|
+
cmd.addCommand(promptsCommand);
|
|
4445
|
+
const authCommand = new import_commander2.Command("auth").description("Manage OAuth tokens for HTTP servers").showHelpAfterError(
|
|
4446
|
+
`(Run \`mcp-use client ${name} auth --help\` to see available actions)`
|
|
4447
|
+
);
|
|
4448
|
+
authCommand.command("status").description("Show OAuth token status for this server").action(() => authStatusCommand(name));
|
|
4449
|
+
authCommand.command("refresh").description("Force-refresh the OAuth access token").action(() => authRefreshCommand(name));
|
|
4450
|
+
authCommand.command("logout").description("Remove stored OAuth tokens for this server's URL").action(() => authLogoutCommand(name));
|
|
4451
|
+
cmd.addCommand(authCommand);
|
|
4452
|
+
cmd.addCommand(createPerClientScreenshotCommand(name));
|
|
4453
|
+
return cmd;
|
|
4479
4454
|
}
|
|
4480
4455
|
|
|
4481
4456
|
// src/commands/deploy.ts
|
|
4482
|
-
init_cjs_shims();
|
|
4483
4457
|
var import_node_fs10 = require("fs");
|
|
4484
4458
|
var import_node_path8 = __toESM(require("path"), 1);
|
|
4485
|
-
init_open();
|
|
4486
4459
|
|
|
4487
4460
|
// src/utils/git.ts
|
|
4488
|
-
init_cjs_shims();
|
|
4489
4461
|
var import_node_child_process10 = require("child_process");
|
|
4490
4462
|
var import_node_util7 = require("util");
|
|
4491
4463
|
var execFileAsync5 = (0, import_node_util7.promisify)(import_node_child_process10.execFile);
|
|
@@ -4621,7 +4593,6 @@ function isGitHubUrl(url) {
|
|
|
4621
4593
|
}
|
|
4622
4594
|
|
|
4623
4595
|
// src/utils/cloud-urls.ts
|
|
4624
|
-
init_cjs_shims();
|
|
4625
4596
|
var GATEWAY_DOMAIN = "run.mcp-use.com";
|
|
4626
4597
|
function buildGatewayUrl(slugOrId) {
|
|
4627
4598
|
return `https://${slugOrId}.${GATEWAY_DOMAIN}/mcp`;
|
|
@@ -4638,7 +4609,6 @@ function getMcpServerUrlForCloudServer(server) {
|
|
|
4638
4609
|
}
|
|
4639
4610
|
|
|
4640
4611
|
// src/utils/project-link.ts
|
|
4641
|
-
init_cjs_shims();
|
|
4642
4612
|
var import_node_fs9 = require("fs");
|
|
4643
4613
|
var import_node_path7 = __toESM(require("path"), 1);
|
|
4644
4614
|
var MCP_USE_DIR = ".mcp-use";
|
|
@@ -5861,7 +5831,6 @@ async function deployCommand(options) {
|
|
|
5861
5831
|
}
|
|
5862
5832
|
|
|
5863
5833
|
// src/commands/deployments.ts
|
|
5864
|
-
init_cjs_shims();
|
|
5865
5834
|
var import_commander3 = require("commander");
|
|
5866
5835
|
async function prompt2(question) {
|
|
5867
5836
|
const readline = await import("readline");
|
|
@@ -6274,8 +6243,8 @@ async function startDeploymentCommand(deploymentId) {
|
|
|
6274
6243
|
}
|
|
6275
6244
|
}
|
|
6276
6245
|
function createDeploymentsCommand() {
|
|
6277
|
-
const deploymentsCommand = new import_commander3.Command("deployments").description(
|
|
6278
|
-
"
|
|
6246
|
+
const deploymentsCommand = new import_commander3.Command("deployments").description("Manage cloud deployments").showHelpAfterError(
|
|
6247
|
+
"(Run `mcp-use deployments --help` to see available commands)"
|
|
6279
6248
|
);
|
|
6280
6249
|
deploymentsCommand.command("list").alias("ls").description("List all deployments").action(listDeploymentsCommand);
|
|
6281
6250
|
deploymentsCommand.command("get").argument("<deployment-id>", "Deployment ID").description("Get deployment details").action(getDeploymentCommand);
|
|
@@ -6290,11 +6259,9 @@ function createDeploymentsCommand() {
|
|
|
6290
6259
|
}
|
|
6291
6260
|
|
|
6292
6261
|
// src/commands/servers.ts
|
|
6293
|
-
init_cjs_shims();
|
|
6294
6262
|
var import_commander5 = require("commander");
|
|
6295
6263
|
|
|
6296
6264
|
// src/commands/env.ts
|
|
6297
|
-
init_cjs_shims();
|
|
6298
6265
|
var import_commander4 = require("commander");
|
|
6299
6266
|
var ALL_ENVS = ["production", "preview", "development"];
|
|
6300
6267
|
function parseEnvironments(raw) {
|
|
@@ -6440,9 +6407,7 @@ async function removeEnvCommand(varId, options) {
|
|
|
6440
6407
|
}
|
|
6441
6408
|
}
|
|
6442
6409
|
function createEnvCommand() {
|
|
6443
|
-
const envCommand = new import_commander4.Command("env").description(
|
|
6444
|
-
"Manage environment variables for a server"
|
|
6445
|
-
);
|
|
6410
|
+
const envCommand = new import_commander4.Command("env").description("Manage environment variables for a server").showHelpAfterError("(Run `mcp-use env --help` to see available commands)");
|
|
6446
6411
|
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);
|
|
6447
6412
|
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(
|
|
6448
6413
|
"--env <environments>",
|
|
@@ -6724,8 +6689,8 @@ async function deleteServerCommand(serverId, options) {
|
|
|
6724
6689
|
}
|
|
6725
6690
|
}
|
|
6726
6691
|
function createServersCommand() {
|
|
6727
|
-
const serversCommand = new import_commander5.Command("servers").description(
|
|
6728
|
-
"
|
|
6692
|
+
const serversCommand = new import_commander5.Command("servers").description("Manage cloud servers (Git-backed deploy targets)").showHelpAfterError(
|
|
6693
|
+
"(Run `mcp-use servers --help` to see available commands)"
|
|
6729
6694
|
);
|
|
6730
6695
|
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);
|
|
6731
6696
|
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);
|
|
@@ -6735,7 +6700,6 @@ function createServersCommand() {
|
|
|
6735
6700
|
}
|
|
6736
6701
|
|
|
6737
6702
|
// src/commands/org.ts
|
|
6738
|
-
init_cjs_shims();
|
|
6739
6703
|
async function ensureLoggedIn() {
|
|
6740
6704
|
if (!await isLoggedIn()) {
|
|
6741
6705
|
console.log(source_default.yellow("\u26A0\uFE0F You are not logged in."));
|
|
@@ -6843,7 +6807,6 @@ async function orgCurrentCommand() {
|
|
|
6843
6807
|
}
|
|
6844
6808
|
|
|
6845
6809
|
// src/commands/skills.ts
|
|
6846
|
-
init_cjs_shims();
|
|
6847
6810
|
var import_commander6 = require("commander");
|
|
6848
6811
|
var import_node_fs11 = require("fs");
|
|
6849
6812
|
var import_node_os6 = require("os");
|
|
@@ -6914,8 +6877,8 @@ async function addSkillsToProject(projectPath) {
|
|
|
6914
6877
|
}
|
|
6915
6878
|
}
|
|
6916
6879
|
function createSkillsCommand() {
|
|
6917
|
-
const skills = new import_commander6.Command("skills").description(
|
|
6918
|
-
"
|
|
6880
|
+
const skills = new import_commander6.Command("skills").description("Manage mcp-use AI agent skills").showHelpAfterError(
|
|
6881
|
+
"(Run `mcp-use skills --help` to see available commands)"
|
|
6919
6882
|
);
|
|
6920
6883
|
const installAction = async (options) => {
|
|
6921
6884
|
const projectPath = (0, import_node_path9.resolve)(options.path);
|
|
@@ -6960,7 +6923,6 @@ function createSkillsCommand() {
|
|
|
6960
6923
|
}
|
|
6961
6924
|
|
|
6962
6925
|
// src/utils/next-shims.ts
|
|
6963
|
-
init_cjs_shims();
|
|
6964
6926
|
var import_node_fs12 = require("fs");
|
|
6965
6927
|
var import_node_path10 = __toESM(require("path"), 1);
|
|
6966
6928
|
var import_node_url2 = require("url");
|
|
@@ -7061,7 +7023,6 @@ function quoteNodeOption(value) {
|
|
|
7061
7023
|
}
|
|
7062
7024
|
|
|
7063
7025
|
// src/utils/update-check.ts
|
|
7064
|
-
init_cjs_shims();
|
|
7065
7026
|
var import_node_fs13 = require("fs");
|
|
7066
7027
|
var import_promises7 = require("fs/promises");
|
|
7067
7028
|
var import_node_module = require("module");
|
|
@@ -7199,7 +7160,7 @@ var packageContent = (0, import_node_fs14.readFileSync)(
|
|
|
7199
7160
|
);
|
|
7200
7161
|
var packageJson = JSON.parse(packageContent);
|
|
7201
7162
|
var packageVersion = packageJson.version || "unknown";
|
|
7202
|
-
program.name("mcp-use").description("Create and run MCP servers with ui resources widgets").version(packageVersion);
|
|
7163
|
+
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)");
|
|
7203
7164
|
function displayPackageVersions(projectPath) {
|
|
7204
7165
|
const packages = [
|
|
7205
7166
|
{ name: "@mcp-use/cli", relativePath: "../package.json" },
|
|
@@ -9280,7 +9241,7 @@ Looked for:
|
|
|
9280
9241
|
process.exit(1);
|
|
9281
9242
|
}
|
|
9282
9243
|
});
|
|
9283
|
-
program.command("login").description("Login to
|
|
9244
|
+
program.command("login").description("Login to Manufact cloud").option(
|
|
9284
9245
|
"--api-key <key>",
|
|
9285
9246
|
"Login with an API key directly (non-interactive, for CI/CD)"
|
|
9286
9247
|
).option("--org <slug|id|name>", "Select an organization non-interactively").action(async (opts) => {
|
|
@@ -9350,7 +9311,6 @@ program.addCommand(createClientCommand());
|
|
|
9350
9311
|
program.addCommand(createDeploymentsCommand());
|
|
9351
9312
|
program.addCommand(createServersCommand());
|
|
9352
9313
|
program.addCommand(createSkillsCommand());
|
|
9353
|
-
program.addCommand(createScreenshotCommand());
|
|
9354
9314
|
program.command("generate-types").description(
|
|
9355
9315
|
"Generate TypeScript type definitions for tools (writes .mcp-use/tool-registry.d.ts)"
|
|
9356
9316
|
).option("-p, --path <path>", "Path to project directory", process.cwd()).option("--server <file>", "Server entry file", "index.ts").action(async (options) => {
|
|
@@ -9384,5 +9344,49 @@ program.hook("preAction", async (_thisCommand, actionCommand) => {
|
|
|
9384
9344
|
const projectPath = actionCommand.opts().path;
|
|
9385
9345
|
await notifyIfUpdateAvailable(projectPath);
|
|
9386
9346
|
});
|
|
9387
|
-
|
|
9347
|
+
var argv = process.argv;
|
|
9348
|
+
var clientIdx = argv[2] === "client" ? 2 : -1;
|
|
9349
|
+
var perClientName = clientIdx !== -1 && argv.length > clientIdx + 1 && !argv[clientIdx + 1].startsWith("-") && !RESERVED_CLIENT_SUBCOMMANDS.has(argv[clientIdx + 1]) ? argv[clientIdx + 1] : null;
|
|
9350
|
+
if (perClientName) {
|
|
9351
|
+
if (PER_CLIENT_SCOPES.has(perClientName)) {
|
|
9352
|
+
const rest2 = argv.slice(clientIdx + 1).join(" ");
|
|
9353
|
+
console.error(formatError("Missing server name."));
|
|
9354
|
+
console.error("");
|
|
9355
|
+
console.error(
|
|
9356
|
+
`'${perClientName}' is a per-server subcommand, not a server name. Address it through a saved server:`
|
|
9357
|
+
);
|
|
9358
|
+
console.error("");
|
|
9359
|
+
console.error(` mcp-use client <name> ${rest2}`);
|
|
9360
|
+
console.error("");
|
|
9361
|
+
console.error("See your saved servers with:");
|
|
9362
|
+
console.error(" mcp-use client list");
|
|
9363
|
+
process.exit(1);
|
|
9364
|
+
}
|
|
9365
|
+
const rest = argv.slice(clientIdx + 2);
|
|
9366
|
+
const isHelpOnly = rest.length === 0 || rest.length === 1 && (rest[0] === "--help" || rest[0] === "-h");
|
|
9367
|
+
(async () => {
|
|
9368
|
+
if (isHelpOnly) {
|
|
9369
|
+
const config = await getSession(perClientName);
|
|
9370
|
+
if (!config) {
|
|
9371
|
+
console.error(formatError(`Server '${perClientName}' not found.`));
|
|
9372
|
+
console.error("");
|
|
9373
|
+
console.error("Connect to an MCP server and save it under this name:");
|
|
9374
|
+
console.error(` mcp-use client connect ${perClientName} <url>`);
|
|
9375
|
+
console.error("");
|
|
9376
|
+
console.error("See your saved servers with:");
|
|
9377
|
+
console.error(" mcp-use client list");
|
|
9378
|
+
process.exit(1);
|
|
9379
|
+
}
|
|
9380
|
+
}
|
|
9381
|
+
await createPerClientCommand(perClientName).parseAsync(rest, {
|
|
9382
|
+
from: "user"
|
|
9383
|
+
});
|
|
9384
|
+
})().catch((err) => {
|
|
9385
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
9386
|
+
console.error(formatError(message));
|
|
9387
|
+
process.exit(1);
|
|
9388
|
+
});
|
|
9389
|
+
} else {
|
|
9390
|
+
program.parse();
|
|
9391
|
+
}
|
|
9388
9392
|
//# sourceMappingURL=index.cjs.map
|