@xbrowser/cli 1.0.2 → 1.0.3
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/{browser-GITRHHFO.js → browser-5CTOA2WS.js} +3 -3
- package/dist/{browser-R56O3CW6.js → browser-ITLZZDHJ.js} +4 -2
- package/dist/{browser-ZJOZB5CR.js → browser-IUJXXNBT.js} +5 -4
- package/dist/{cdp-driver-BE3FOMRN.js → cdp-driver-4X3DK6PS.js} +19 -5
- package/dist/{cdp-driver-TOPYJIFL.js → cdp-driver-D6WMSMWX.js} +3 -2
- package/dist/{chunk-Q4IGYTKR.js → chunk-6WOSXSCQ.js} +6 -2
- package/dist/{chunk-ZZ2TFWIV.js → chunk-ABXMBNQ6.js} +1 -1
- package/dist/{chunk-JPHCY4TC.js → chunk-AMI64BSD.js} +9 -1
- package/dist/{chunk-CAFNSGYM.js → chunk-DKWR54XQ.js} +24 -8
- package/dist/chunk-GDKLH7ZY.js +8 -0
- package/dist/{chunk-QIK2I3VQ.js → chunk-LRBSUKUZ.js} +7 -4
- package/dist/{chunk-PPG4D2EW.js → chunk-N2JFPWMI.js} +21 -5
- package/dist/{chunk-BBMRDUYQ.js → chunk-TNEN6VQ2.js} +4 -1
- package/dist/{chunk-JPA2ZT2R.js → chunk-TWWOIJM7.js} +7 -4
- package/dist/cli.js +134 -56
- package/dist/{daemon-client-UZZEHHIV.js → daemon-client-3JOKX2L2.js} +2 -1
- package/dist/{daemon-client-DRCUMNHK.js → daemon-client-DIEHGP5B.js} +5 -2
- package/dist/daemon-main.js +122 -57
- package/dist/index.d.ts +1 -1
- package/dist/index.js +140 -65
- package/dist/{launcher-QUJ4M2VS.js → launcher-L2JNDB2H.js} +2 -1
- package/dist/{launcher-YARP45UY.js → launcher-OZXJQPNG.js} +1 -1
- package/dist/{proxy-LV4BJ5RC.js → proxy-C6CK3UH5.js} +1 -1
- package/dist/{session-replayer-GLTUICSD.js → session-replayer-MY27H4DX.js} +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,8 +25,8 @@ import {
|
|
|
25
25
|
resolveLaunchOpts,
|
|
26
26
|
saveSessionDiskMeta,
|
|
27
27
|
setActivePage
|
|
28
|
-
} from "./chunk-
|
|
29
|
-
import "./chunk-
|
|
28
|
+
} from "./chunk-DKWR54XQ.js";
|
|
29
|
+
import "./chunk-TNEN6VQ2.js";
|
|
30
30
|
import {
|
|
31
31
|
forwardCommandLog,
|
|
32
32
|
forwardNetworkAnalyze,
|
|
@@ -54,11 +54,16 @@ import {
|
|
|
54
54
|
killAllDaemonProcesses,
|
|
55
55
|
startDaemonProcess,
|
|
56
56
|
stopDaemonProcess
|
|
57
|
-
} from "./chunk-
|
|
58
|
-
import
|
|
57
|
+
} from "./chunk-6WOSXSCQ.js";
|
|
58
|
+
import {
|
|
59
|
+
errMsg
|
|
60
|
+
} from "./chunk-GDKLH7ZY.js";
|
|
61
|
+
import {
|
|
62
|
+
__require
|
|
63
|
+
} from "./chunk-KFQGP6VL.js";
|
|
59
64
|
|
|
60
65
|
// src/router.ts
|
|
61
|
-
import { parseArgs, outputFormatter as outputFormatter2, isCommandResult as isCommandResult2, helpGenerator as helpGenerator2, TipCollector as
|
|
66
|
+
import { parseArgs, outputFormatter as outputFormatter2, isCommandResult as isCommandResult2, helpGenerator as helpGenerator2, TipCollector as TipCollector3, normalizeTips as normalizeTips7, tip as makeTip } from "@dyyz1993/xcli-core";
|
|
62
67
|
|
|
63
68
|
// src/utils/positional-params.ts
|
|
64
69
|
import { unquote } from "@dyyz1993/xcli-core";
|
|
@@ -170,6 +175,11 @@ function parsePluginParams(args, schema, base = {}) {
|
|
|
170
175
|
return result;
|
|
171
176
|
}
|
|
172
177
|
|
|
178
|
+
// src/utils/zod-internal.ts
|
|
179
|
+
function asZodSchema(value) {
|
|
180
|
+
return value;
|
|
181
|
+
}
|
|
182
|
+
|
|
173
183
|
// src/version.ts
|
|
174
184
|
import { createRequire } from "module";
|
|
175
185
|
var require2 = createRequire(import.meta.url);
|
|
@@ -181,8 +191,8 @@ import {
|
|
|
181
191
|
ok as ok25,
|
|
182
192
|
fail as fail7,
|
|
183
193
|
isCommandResult,
|
|
184
|
-
CompositeStorage,
|
|
185
|
-
TipCollector,
|
|
194
|
+
CompositeStorage as CompositeStorage2,
|
|
195
|
+
TipCollector as TipCollector2,
|
|
186
196
|
normalizeTips as normalizeTips6,
|
|
187
197
|
configureArchiveStore,
|
|
188
198
|
appendCommandToArchive,
|
|
@@ -190,6 +200,67 @@ import {
|
|
|
190
200
|
unquote as unquote2
|
|
191
201
|
} from "@dyyz1993/xcli-core";
|
|
192
202
|
|
|
203
|
+
// src/utils/stub-context.ts
|
|
204
|
+
import { TipCollector, CompositeStorage } from "@dyyz1993/xcli-core";
|
|
205
|
+
var CONFIG_DIR = __require("path").join(__require("os").homedir(), ".xbrowser");
|
|
206
|
+
var NoopSiteInstance = class {
|
|
207
|
+
name = "stub";
|
|
208
|
+
url = "";
|
|
209
|
+
config = { name: "stub" };
|
|
210
|
+
command() {
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
group() {
|
|
214
|
+
return this;
|
|
215
|
+
}
|
|
216
|
+
login() {
|
|
217
|
+
return this;
|
|
218
|
+
}
|
|
219
|
+
logout() {
|
|
220
|
+
return this;
|
|
221
|
+
}
|
|
222
|
+
async isLoggedIn() {
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
async requireLogin() {
|
|
226
|
+
}
|
|
227
|
+
getStorage() {
|
|
228
|
+
return new CompositeStorage("stub", CONFIG_DIR, "xbrowser");
|
|
229
|
+
}
|
|
230
|
+
getAllCommands() {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
getCommand() {
|
|
234
|
+
return null;
|
|
235
|
+
}
|
|
236
|
+
getOriginalHandler() {
|
|
237
|
+
return void 0;
|
|
238
|
+
}
|
|
239
|
+
async executeLogin() {
|
|
240
|
+
}
|
|
241
|
+
async executeLogout() {
|
|
242
|
+
}
|
|
243
|
+
async restoreLogin() {
|
|
244
|
+
return false;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
function createStubContext(pluginName) {
|
|
248
|
+
return {
|
|
249
|
+
args: [],
|
|
250
|
+
options: {},
|
|
251
|
+
cwd: process.cwd(),
|
|
252
|
+
storage: new CompositeStorage(pluginName, CONFIG_DIR, "xbrowser"),
|
|
253
|
+
output: { mode: "text", showTips: false, color: false, emoji: false },
|
|
254
|
+
error: (msg) => {
|
|
255
|
+
throw new Error(msg);
|
|
256
|
+
},
|
|
257
|
+
config: {},
|
|
258
|
+
site: new NoopSiteInstance(),
|
|
259
|
+
cliName: "xbrowser",
|
|
260
|
+
tips: new TipCollector()
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
193
264
|
// src/commands/navigation.ts
|
|
194
265
|
import { z } from "zod";
|
|
195
266
|
import { ok } from "@dyyz1993/xcli-core";
|
|
@@ -237,7 +308,7 @@ async function detectSsr(page) {
|
|
|
237
308
|
try {
|
|
238
309
|
const result = await page.evaluate((vars) => {
|
|
239
310
|
for (const varName of vars) {
|
|
240
|
-
const value = window
|
|
311
|
+
const value = Reflect.get(window, varName);
|
|
241
312
|
if (value != null && typeof value === "object") {
|
|
242
313
|
const keys = Object.keys(value).slice(0, 10);
|
|
243
314
|
return { variable: varName, keys };
|
|
@@ -1586,7 +1657,7 @@ var healthCheckCommand = registerCommand({
|
|
|
1586
1657
|
issues.push({
|
|
1587
1658
|
severity: "error",
|
|
1588
1659
|
category: "links",
|
|
1589
|
-
message: `Broken link (fetch error): ${href} \u2014 ${err
|
|
1660
|
+
message: `Broken link (fetch error): ${href} \u2014 ${errMsg(err) || "unknown"}`
|
|
1590
1661
|
});
|
|
1591
1662
|
}
|
|
1592
1663
|
}
|
|
@@ -4685,7 +4756,7 @@ async function actOnPage(page, sessionId, input) {
|
|
|
4685
4756
|
ref: normalizedRef,
|
|
4686
4757
|
success: false,
|
|
4687
4758
|
reason: "browser_error",
|
|
4688
|
-
message: error
|
|
4759
|
+
message: errMsg(error),
|
|
4689
4760
|
stale,
|
|
4690
4761
|
screenHash: hash,
|
|
4691
4762
|
target: refMatch?.target
|
|
@@ -4769,7 +4840,7 @@ async function waitForPage(page, input) {
|
|
|
4769
4840
|
matched: input.selector ? "selector" : input.text ? "text" : input.url ? "url" : input.load ? "load" : input.fn ? "fn" : "screenHashChanged",
|
|
4770
4841
|
timeout,
|
|
4771
4842
|
elapsed: Date.now() - startedAt,
|
|
4772
|
-
message: error
|
|
4843
|
+
message: errMsg(error)
|
|
4773
4844
|
};
|
|
4774
4845
|
}
|
|
4775
4846
|
return {
|
|
@@ -5704,11 +5775,11 @@ async function detectWebdriverExposure(page) {
|
|
|
5704
5775
|
try {
|
|
5705
5776
|
const webdriver = await page.evaluate(() => {
|
|
5706
5777
|
return {
|
|
5707
|
-
webdriver:
|
|
5778
|
+
webdriver: navigator.webdriver,
|
|
5708
5779
|
webdriverScriptFn: !!window.__webdriver_script_fn,
|
|
5709
5780
|
webdriverEvaluate: !!window.__webdriver_evaluate,
|
|
5710
5781
|
chrome: !!window.chrome,
|
|
5711
|
-
permissions:
|
|
5782
|
+
permissions: navigator.permissions
|
|
5712
5783
|
};
|
|
5713
5784
|
}).catch(() => null);
|
|
5714
5785
|
if (!webdriver) {
|
|
@@ -6068,19 +6139,26 @@ var patched = false;
|
|
|
6068
6139
|
function patchLoginRequired() {
|
|
6069
6140
|
if (patched) return;
|
|
6070
6141
|
patched = true;
|
|
6071
|
-
const
|
|
6072
|
-
const
|
|
6073
|
-
|
|
6074
|
-
const result =
|
|
6142
|
+
const target = SiteInstanceImpl.prototype;
|
|
6143
|
+
const originalCommand = target.command;
|
|
6144
|
+
const wrapped = function(...args) {
|
|
6145
|
+
const result = originalCommand.apply(this, args);
|
|
6146
|
+
const [name, cmd] = args;
|
|
6075
6147
|
const loginRequired = cmd.loginRequired;
|
|
6076
6148
|
if (loginRequired) {
|
|
6077
|
-
const
|
|
6149
|
+
const commands = this.commands;
|
|
6150
|
+
const entry = commands?.get(name);
|
|
6078
6151
|
if (entry) {
|
|
6079
6152
|
entry.loginRequired = loginRequired;
|
|
6080
6153
|
}
|
|
6081
6154
|
}
|
|
6082
6155
|
return result;
|
|
6083
6156
|
};
|
|
6157
|
+
Object.defineProperty(target, "command", {
|
|
6158
|
+
value: wrapped,
|
|
6159
|
+
writable: true,
|
|
6160
|
+
configurable: true
|
|
6161
|
+
});
|
|
6084
6162
|
}
|
|
6085
6163
|
|
|
6086
6164
|
// src/plugin/loader.ts
|
|
@@ -6774,15 +6852,14 @@ var HOOK_REGISTRY = {
|
|
|
6774
6852
|
recorder: {
|
|
6775
6853
|
name: "recorder",
|
|
6776
6854
|
onAfterCommand: async (ctx) => {
|
|
6777
|
-
const
|
|
6778
|
-
const logs = ctxAny.__commandLogs || [];
|
|
6855
|
+
const logs = ("__commandLogs" in ctx ? ctx.__commandLogs : void 0) || [];
|
|
6779
6856
|
logs.push({
|
|
6780
6857
|
timestamp: Date.now(),
|
|
6781
6858
|
command: ctx.command,
|
|
6782
6859
|
params: JSON.parse(JSON.stringify(ctx.params)),
|
|
6783
6860
|
duration: ctx.duration
|
|
6784
6861
|
});
|
|
6785
|
-
|
|
6862
|
+
Reflect.set(ctx, "__commandLogs", logs);
|
|
6786
6863
|
return void 0;
|
|
6787
6864
|
}
|
|
6788
6865
|
}
|
|
@@ -6814,11 +6891,11 @@ import { homedir as homedir5 } from "os";
|
|
|
6814
6891
|
import { join as join5 } from "path";
|
|
6815
6892
|
var NAVIGATION_COMMANDS = /* @__PURE__ */ new Set(["goto", "back", "forward", "refresh"]);
|
|
6816
6893
|
var snapshotHintShown = /* @__PURE__ */ new WeakSet();
|
|
6817
|
-
var
|
|
6894
|
+
var CONFIG_DIR2 = join5(homedir5(), ".xbrowser");
|
|
6818
6895
|
var storageCache = /* @__PURE__ */ new Map();
|
|
6819
6896
|
function getPluginStorage(pluginName) {
|
|
6820
6897
|
if (!storageCache.has(pluginName)) {
|
|
6821
|
-
storageCache.set(pluginName, new
|
|
6898
|
+
storageCache.set(pluginName, new CompositeStorage2(pluginName, CONFIG_DIR2, "xbrowser"));
|
|
6822
6899
|
}
|
|
6823
6900
|
return storageCache.get(pluginName);
|
|
6824
6901
|
}
|
|
@@ -6883,7 +6960,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
6883
6960
|
}
|
|
6884
6961
|
let targetPageOverride = null;
|
|
6885
6962
|
if (_target && extraOpts?.cdpEndpoint) {
|
|
6886
|
-
const { findTargetPage } = await import("./browser-
|
|
6963
|
+
const { findTargetPage } = await import("./browser-5CTOA2WS.js");
|
|
6887
6964
|
targetPageOverride = await findTargetPage(extraOpts.cdpEndpoint, _target);
|
|
6888
6965
|
if (!targetPageOverride) {
|
|
6889
6966
|
return errorResult(`Target "${_target}" not found. Use 'xbrowser targets --cdp ${extraOpts.cdpEndpoint}' to list available pages.`);
|
|
@@ -6900,7 +6977,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
6900
6977
|
params = result.data;
|
|
6901
6978
|
}
|
|
6902
6979
|
if (command.scope !== "cli" && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
6903
|
-
const { forwardExec } = await import("./daemon-client-
|
|
6980
|
+
const { forwardExec } = await import("./daemon-client-3JOKX2L2.js");
|
|
6904
6981
|
const result = await forwardExec(commandName, params, sessionName, extraOpts?.cdpEndpoint);
|
|
6905
6982
|
if (result) return result;
|
|
6906
6983
|
}
|
|
@@ -6951,9 +7028,9 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
6951
7028
|
throw new Error(msg);
|
|
6952
7029
|
},
|
|
6953
7030
|
config: {},
|
|
6954
|
-
site:
|
|
7031
|
+
site: new NoopSiteInstance(),
|
|
6955
7032
|
cliName: "xbrowser",
|
|
6956
|
-
tips: new
|
|
7033
|
+
tips: new TipCollector2()
|
|
6957
7034
|
};
|
|
6958
7035
|
const start = Date.now();
|
|
6959
7036
|
if (session) {
|
|
@@ -7066,7 +7143,7 @@ async function executeCommand(commandName, params, sessionName = "default", extr
|
|
|
7066
7143
|
} catch (err) {
|
|
7067
7144
|
const end = Date.now();
|
|
7068
7145
|
const duration = end - start;
|
|
7069
|
-
const errorMessage = err
|
|
7146
|
+
const errorMessage = errMsg(err);
|
|
7070
7147
|
if (session) {
|
|
7071
7148
|
streamCommandEvent(session.id, {
|
|
7072
7149
|
sessionId: session.id,
|
|
@@ -7179,7 +7256,7 @@ async function executeChain(input, options) {
|
|
|
7179
7256
|
config: {},
|
|
7180
7257
|
site,
|
|
7181
7258
|
cliName: "xbrowser",
|
|
7182
|
-
tips: new
|
|
7259
|
+
tips: new TipCollector2()
|
|
7183
7260
|
};
|
|
7184
7261
|
const start2 = Date.now();
|
|
7185
7262
|
try {
|
|
@@ -7266,7 +7343,7 @@ async function executeChain(input, options) {
|
|
|
7266
7343
|
}
|
|
7267
7344
|
} catch (err) {
|
|
7268
7345
|
const duration2 = Date.now() - start2;
|
|
7269
|
-
const errorMessage = err
|
|
7346
|
+
const errorMessage = errMsg(err);
|
|
7270
7347
|
recordArchive(session.id, sessionName, {
|
|
7271
7348
|
step: results.length,
|
|
7272
7349
|
command: `${cmdName} ${subCommand}`,
|
|
@@ -7669,7 +7746,8 @@ async function ensureProxyFetch() {
|
|
|
7669
7746
|
const body = init?.body;
|
|
7670
7747
|
if (body instanceof globalThis.FormData && !(body instanceof UFormData)) {
|
|
7671
7748
|
const ufd = new UFormData();
|
|
7672
|
-
|
|
7749
|
+
const domFormData = body;
|
|
7750
|
+
domFormData.forEach((value, key) => {
|
|
7673
7751
|
if (value instanceof Blob) {
|
|
7674
7752
|
ufd.append(key, value, value.name || "file");
|
|
7675
7753
|
} else {
|
|
@@ -8584,7 +8662,7 @@ async function searchFromMarketplacePlugin(options, loader) {
|
|
|
8584
8662
|
site: options.site,
|
|
8585
8663
|
limit: options.limit
|
|
8586
8664
|
},
|
|
8587
|
-
|
|
8665
|
+
createStubContext("marketplace")
|
|
8588
8666
|
);
|
|
8589
8667
|
const items = extractItems(result);
|
|
8590
8668
|
return items.map((item) => ({
|
|
@@ -9360,16 +9438,16 @@ async function handleBrowserCommand(command, args, options, sessionName, mode, c
|
|
|
9360
9438
|
if (cmdDef) {
|
|
9361
9439
|
if (mode === "json") {
|
|
9362
9440
|
const paramsList = [];
|
|
9363
|
-
const schema = cmdDef.parameters;
|
|
9441
|
+
const schema = asZodSchema(cmdDef.parameters);
|
|
9364
9442
|
const shape = schema?.shape ?? schema?._def?.shape;
|
|
9365
9443
|
if (shape) {
|
|
9366
9444
|
for (const [key, value] of Object.entries(shape)) {
|
|
9367
|
-
const fieldSchema = value;
|
|
9445
|
+
const fieldSchema = asZodSchema(value);
|
|
9368
9446
|
const fieldDef = fieldSchema._def;
|
|
9369
9447
|
const description = fieldSchema.description || fieldDef?.description || "";
|
|
9370
9448
|
const typeName = fieldDef?.typeName || "";
|
|
9371
9449
|
const isOptional = typeName === "ZodOptional" || typeof fieldSchema.isOptional === "function" && fieldSchema.isOptional();
|
|
9372
|
-
const innerType = fieldDef?.innerType;
|
|
9450
|
+
const innerType = asZodSchema(fieldDef?.innerType);
|
|
9373
9451
|
const innerTypeName = innerType?._def ? innerType._def.typeName : typeName;
|
|
9374
9452
|
let type = "unknown";
|
|
9375
9453
|
if (innerTypeName === "ZodString" || typeName === "ZodString") type = "string";
|
|
@@ -9779,8 +9857,7 @@ async function buildRuntimePluginInfo() {
|
|
|
9779
9857
|
const cmds = site.getAllCommands();
|
|
9780
9858
|
const commandNames = cmds.map((c) => c.name);
|
|
9781
9859
|
if (commandNames.length === 0) continue;
|
|
9782
|
-
const
|
|
9783
|
-
const hasLoginHandler = typeof anySite.hasLoginCommand === "function" && anySite.hasLoginCommand();
|
|
9860
|
+
const hasLoginHandler = "hasLoginCommand" in site && typeof site.hasLoginCommand === "function" && site.hasLoginCommand();
|
|
9784
9861
|
const configRequiresLogin = !!site.config.requiresLogin;
|
|
9785
9862
|
const hasLogin = hasLoginHandler || configRequiresLogin;
|
|
9786
9863
|
let loggedIn = null;
|
|
@@ -9830,7 +9907,7 @@ async function searchFromMarketplacePlugin2(options, loader) {
|
|
|
9830
9907
|
site: options.site,
|
|
9831
9908
|
limit: options.limit
|
|
9832
9909
|
},
|
|
9833
|
-
|
|
9910
|
+
createStubContext("marketplace")
|
|
9834
9911
|
);
|
|
9835
9912
|
const items = extractItems2(result);
|
|
9836
9913
|
return items.map((item) => ({ ...item, source: "marketplace" }));
|
|
@@ -9845,7 +9922,7 @@ async function infoFromMarketplacePlugin(slug, loader) {
|
|
|
9845
9922
|
const infoCmd = marketplaceSite.getCommand("info");
|
|
9846
9923
|
if (!infoCmd) return null;
|
|
9847
9924
|
try {
|
|
9848
|
-
const result = await infoCmd.handler({ slug },
|
|
9925
|
+
const result = await infoCmd.handler({ slug }, createStubContext("marketplace"));
|
|
9849
9926
|
if (!result || typeof result !== "object") return null;
|
|
9850
9927
|
const r = result;
|
|
9851
9928
|
let plugin = null;
|
|
@@ -9953,7 +10030,7 @@ async function handlePluginInfo(args, options, mode) {
|
|
|
9953
10030
|
}
|
|
9954
10031
|
console.error(`\u63D2\u4EF6 '${slug}' \u672A\u627E\u5230`);
|
|
9955
10032
|
} catch (err) {
|
|
9956
|
-
console.error("\u67E5\u8BE2\u5931\u8D25:", err
|
|
10033
|
+
console.error("\u67E5\u8BE2\u5931\u8D25:", errMsg(err));
|
|
9957
10034
|
}
|
|
9958
10035
|
}
|
|
9959
10036
|
async function handlePluginSchema(args, mode) {
|
|
@@ -10644,9 +10721,9 @@ interface XBPage {
|
|
|
10644
10721
|
}
|
|
10645
10722
|
|
|
10646
10723
|
function ensurePage(ctx: CommandContext): XBPage {
|
|
10647
|
-
const page = (ctx as Record<string, unknown>).page;
|
|
10724
|
+
const page = 'page' in ctx ? (ctx as Record<string, unknown>).page : undefined;
|
|
10648
10725
|
if (!page) throw new Error('No active page. Start a session first.');
|
|
10649
|
-
return page as
|
|
10726
|
+
return page as XBPage;
|
|
10650
10727
|
}
|
|
10651
10728
|
|
|
10652
10729
|
export default createSite({
|
|
@@ -10679,7 +10756,7 @@ async function handleRun(filePath, options) {
|
|
|
10679
10756
|
try {
|
|
10680
10757
|
commands = readCommandFile(filePath);
|
|
10681
10758
|
} catch (e) {
|
|
10682
|
-
outputError(`Failed to read file '${filePath}': ${e
|
|
10759
|
+
outputError(`Failed to read file '${filePath}': ${errMsg(e)}`);
|
|
10683
10760
|
return;
|
|
10684
10761
|
}
|
|
10685
10762
|
if (commands.length === 0) {
|
|
@@ -11035,7 +11112,7 @@ async function handleNetCommand(args, options, mode, sessionName) {
|
|
|
11035
11112
|
outputError(`Unknown net sub-command: ${subCommand}. Use: list, clear, top, log, around, analyze, curl, replay, inspect, like, dislike, export`);
|
|
11036
11113
|
}
|
|
11037
11114
|
} catch (err) {
|
|
11038
|
-
outputError(err
|
|
11115
|
+
outputError(errMsg(err) || "Network command failed");
|
|
11039
11116
|
}
|
|
11040
11117
|
}
|
|
11041
11118
|
|
|
@@ -11560,7 +11637,7 @@ async function createSessionHandler(req) {
|
|
|
11560
11637
|
createdAt: session.createdAt
|
|
11561
11638
|
});
|
|
11562
11639
|
} catch (err) {
|
|
11563
|
-
return errorResponse(500, "INTERNAL_ERROR", err
|
|
11640
|
+
return errorResponse(500, "INTERNAL_ERROR", errMsg(err));
|
|
11564
11641
|
}
|
|
11565
11642
|
}
|
|
11566
11643
|
async function closeSession2(req) {
|
|
@@ -11655,7 +11732,7 @@ async function route(method, url, headers, body) {
|
|
|
11655
11732
|
try {
|
|
11656
11733
|
return await match.route.handler(req);
|
|
11657
11734
|
} catch (err) {
|
|
11658
|
-
return errorResponse(500, "INTERNAL_ERROR", err
|
|
11735
|
+
return errorResponse(500, "INTERNAL_ERROR", errMsg(err));
|
|
11659
11736
|
}
|
|
11660
11737
|
}
|
|
11661
11738
|
async function handleRequest(req, res, validateAuthFn) {
|
|
@@ -11813,8 +11890,9 @@ function showCommandHelp(siteName, cmd, siteConfig, mode) {
|
|
|
11813
11890
|
if (mode === "json") {
|
|
11814
11891
|
const paramsList = [];
|
|
11815
11892
|
if (c.parameters) {
|
|
11816
|
-
const def = c.parameters._def;
|
|
11817
|
-
const
|
|
11893
|
+
const def = asZodSchema(c.parameters)._def;
|
|
11894
|
+
const rawShape = def?.shape;
|
|
11895
|
+
const shape = typeof rawShape === "function" ? rawShape() : rawShape;
|
|
11818
11896
|
if (shape) {
|
|
11819
11897
|
for (const [key, value] of Object.entries(shape)) {
|
|
11820
11898
|
const info = extractZodFieldInfo(value);
|
|
@@ -12041,16 +12119,16 @@ async function routeCommand(argv, stdinCommands) {
|
|
|
12041
12119
|
if (builtinCmd) {
|
|
12042
12120
|
if (mode === "json") {
|
|
12043
12121
|
const paramsList = [];
|
|
12044
|
-
const schema = builtinCmd.parameters;
|
|
12122
|
+
const schema = asZodSchema(builtinCmd.parameters);
|
|
12045
12123
|
const shape = schema?.shape ?? schema?._def?.shape;
|
|
12046
12124
|
if (shape) {
|
|
12047
12125
|
for (const [key, value] of Object.entries(shape)) {
|
|
12048
|
-
const fieldSchema = value;
|
|
12126
|
+
const fieldSchema = asZodSchema(value);
|
|
12049
12127
|
const fieldDef = fieldSchema._def;
|
|
12050
12128
|
const description = fieldSchema.description || fieldDef?.description || "";
|
|
12051
12129
|
const typeName = fieldDef?.typeName || "";
|
|
12052
12130
|
const isOptional = typeName === "ZodOptional" || typeof fieldSchema.isOptional === "function" && fieldSchema.isOptional();
|
|
12053
|
-
const innerType = fieldDef?.innerType;
|
|
12131
|
+
const innerType = asZodSchema(fieldDef?.innerType);
|
|
12054
12132
|
const innerTypeName = innerType?._def ? innerType._def.typeName : typeName;
|
|
12055
12133
|
let type = "unknown";
|
|
12056
12134
|
if (innerTypeName === "ZodString" || typeName === "ZodString") type = "string";
|
|
@@ -12225,7 +12303,7 @@ Run "xbrowser ${command} --help" to see available commands.`
|
|
|
12225
12303
|
const rawPluginArgs = subCmdIdx >= 0 ? argv.slice(subCmdIdx + 1) : [];
|
|
12226
12304
|
const params = parsePluginParams(rawPluginArgs, cmdEntry.parameters);
|
|
12227
12305
|
if (cmdEntry.parameters) {
|
|
12228
|
-
const schemaAny = cmdEntry.parameters;
|
|
12306
|
+
const schemaAny = asZodSchema(cmdEntry.parameters);
|
|
12229
12307
|
const def = schemaAny._def;
|
|
12230
12308
|
const shapeOrFn = def?.shape ?? schemaAny.shape;
|
|
12231
12309
|
const shapeObj = typeof shapeOrFn === "function" ? shapeOrFn() : shapeOrFn;
|
|
@@ -12249,10 +12327,10 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
|
|
|
12249
12327
|
}
|
|
12250
12328
|
const needsBrowser = cmdEntry.scope === "page" || cmdEntry.scope === "browser";
|
|
12251
12329
|
if (needsBrowser && !process.env.XBROWSER_DAEMON_WORKER) {
|
|
12252
|
-
const { forwardExec } = await import("./daemon-client-
|
|
12330
|
+
const { forwardExec } = await import("./daemon-client-3JOKX2L2.js");
|
|
12253
12331
|
const userTimeout = typeof params.timeout === "number" && params.timeout > 0 ? params.timeout * 1e3 + 3e4 : void 0;
|
|
12254
12332
|
const result = await forwardExec(`${command}.${subCommand}`, params, sessionName, cdpEndpoint, userTimeout);
|
|
12255
|
-
const resultData = result && typeof result === "object" ? result.data : void 0;
|
|
12333
|
+
const resultData = result && typeof result === "object" && "data" in result ? result.data : void 0;
|
|
12256
12334
|
if (result && result.success === false && resultData?.code === "LOGIN_REQUIRED") {
|
|
12257
12335
|
outputLoginRequired(result, mode);
|
|
12258
12336
|
return;
|
|
@@ -12301,7 +12379,7 @@ Run "xbrowser ${command} ${subCommand} --help" to see available parameters.`
|
|
|
12301
12379
|
waitForHuman: async (_opts) => {
|
|
12302
12380
|
return { solved: false, timedOut: true };
|
|
12303
12381
|
},
|
|
12304
|
-
tips: new
|
|
12382
|
+
tips: new TipCollector3()
|
|
12305
12383
|
};
|
|
12306
12384
|
try {
|
|
12307
12385
|
const cmdStart = Date.now();
|
|
@@ -12555,7 +12633,7 @@ async function main() {
|
|
|
12555
12633
|
const command = process.argv[2];
|
|
12556
12634
|
const isLongRunning = command === "preview" || command === "serve";
|
|
12557
12635
|
if (!isLongRunning) {
|
|
12558
|
-
const { ensureProcessCanExit } = await import("./browser-
|
|
12636
|
+
const { ensureProcessCanExit } = await import("./browser-5CTOA2WS.js");
|
|
12559
12637
|
await ensureProcessCanExit().catch(() => {
|
|
12560
12638
|
});
|
|
12561
12639
|
process.exit(exitCode);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
startDaemonProcess
|
|
3
3
|
} from "./chunk-WJRE55TN.js";
|
|
4
|
+
import {
|
|
5
|
+
errMsg
|
|
6
|
+
} from "./chunk-GDKLH7ZY.js";
|
|
4
7
|
import "./chunk-KFQGP6VL.js";
|
|
5
8
|
|
|
6
9
|
// src/client/daemon-client.ts
|
|
@@ -91,7 +94,7 @@ async function forwardExec(command, params, session = "default", cdpEndpoint, ti
|
|
|
91
94
|
try {
|
|
92
95
|
return await rpcCall("exec", rpcParams, timeoutMs);
|
|
93
96
|
} catch (e) {
|
|
94
|
-
return { success: false, data: null, message: e
|
|
97
|
+
return { success: false, data: null, message: errMsg(e), duration: 0 };
|
|
95
98
|
}
|
|
96
99
|
}
|
|
97
100
|
async function forwardChain(input, session = "default", cdpEndpoint) {
|
|
@@ -100,7 +103,7 @@ async function forwardChain(input, session = "default", cdpEndpoint) {
|
|
|
100
103
|
try {
|
|
101
104
|
return await rpcCall("chain", params, 12e4);
|
|
102
105
|
} catch (e) {
|
|
103
|
-
return { success: false, steps: [], totalDuration: 0, stoppedReason: e
|
|
106
|
+
return { success: false, steps: [], totalDuration: 0, stoppedReason: errMsg(e) };
|
|
104
107
|
}
|
|
105
108
|
}
|
|
106
109
|
async function forwardAgentObserve(session = "default", options) {
|