@xbrowser/cli 1.0.0 → 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/README.md +17 -26
- package/dist/{browser-DSVV4GHS.js → browser-5CTOA2WS.js} +4 -3
- package/dist/{browser-53KUFEEM.js → browser-ITLZZDHJ.js} +5 -5
- package/dist/{browser-GURRY444.js → browser-IUJXXNBT.js} +6 -3
- package/dist/{cdp-driver-MNPR3HZH.js → cdp-driver-4X3DK6PS.js} +339 -59
- package/dist/{cdp-driver-SSXUGXP6.js → cdp-driver-D6WMSMWX.js} +4 -3
- package/dist/chunk-2SVQTI2O.js +2794 -0
- package/dist/{chunk-IDVD44ED.js → chunk-6WOSXSCQ.js} +23 -7
- package/dist/{chunk-ZZ2TFWIV.js → chunk-ABXMBNQ6.js} +1 -1
- package/dist/{chunk-2MFXKN32.js → chunk-ACFE6PKF.js} +1013 -119
- package/dist/chunk-AMI64BSD.js +268 -0
- package/dist/{chunk-E4O5ZU3H.js → chunk-DKWR54XQ.js} +412 -98
- package/dist/{chunk-DTJRVA76.js → chunk-ETCO4SNK.js} +2 -2
- package/dist/chunk-GDKLH7ZY.js +8 -0
- package/dist/chunk-KFQGP6VL.js +33 -0
- package/dist/{chunk-2BQZIT3S.js → chunk-LRBSUKUZ.js} +85 -2497
- package/dist/{chunk-ITKPSIP7.js → chunk-MDAPTB7C.js} +6 -25
- package/dist/{chunk-42RPMJ76.js → chunk-N2JFPWMI.js} +342 -60
- package/dist/chunk-OZKD3W4X.js +417 -0
- package/dist/{chunk-T4J4C2NZ.js → chunk-TNEN6VQ2.js} +17 -4
- package/dist/{chunk-YKOHDEFV.js → chunk-TWWOIJM7.js} +74 -38
- package/dist/chunk-WJRE55TN.js +83 -0
- package/dist/cli.js +1558 -1122
- package/dist/{convert-EGFYNICZ.js → convert-LB3GJTLR.js} +3 -3
- package/dist/{convert-EKQVHKB4.js → convert-R3XXYKC6.js} +2 -2
- package/dist/{daemon-client-YAVQ343A.js → daemon-client-3JOKX2L2.js} +3 -2
- package/dist/{daemon-client-3VM7VU7O.js → daemon-client-DIEHGP5B.js} +28 -74
- package/dist/daemon-main.js +2296 -1722
- package/dist/{extract-JUOQQX4V.js → extract-2ZFW2MX7.js} +1 -1
- package/dist/{extract-L2IW3IUB.js → extract-BSYBM4MR.js} +1 -1
- package/dist/{filter-HC4RA7JY.js → filter-KCFO4RSV.js} +1 -1
- package/dist/{filter-VID2GGZ7.js → filter-T7DSZ2X7.js} +1 -1
- package/dist/{human-interaction-W753RVJB.js → human-interaction-UKAS5ZXV.js} +2 -2
- package/dist/index.d.ts +166 -109
- package/dist/index.js +2668 -1742
- package/dist/launcher-L2JNDB2H.js +20 -0
- package/dist/{launcher-KA7J32K5.js → launcher-OZXJQPNG.js} +1 -1
- package/dist/{network-store-66A2RATI.js → network-store-XGZ25FFC.js} +1 -1
- package/dist/{network-store-BN6QEZ7R.js → network-store-YVDNUREI.js} +1 -1
- package/dist/{parse-action-dsl-T3DYC33D.js → parse-action-dsl-UM333TL2.js} +1 -1
- package/dist/{proxy-WKGUCH2C.js → proxy-C6CK3UH5.js} +2 -2
- package/dist/session-recorder-RTDGURIJ.js +8 -0
- package/dist/session-recorder-YI7YYM36.js +7 -0
- package/dist/session-replayer-MY27H4DX.js +276 -0
- package/dist/site-knowledge-SYC6VCDB.js +23 -0
- package/package.json +5 -4
- package/dist/screenshot-CWAWMXVA.js +0 -28
- package/dist/session-recorder-MA75PKTQ.js +0 -7
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
errMsg
|
|
3
|
+
} from "./chunk-GDKLH7ZY.js";
|
|
4
|
+
|
|
1
5
|
// src/daemon/daemon.ts
|
|
2
6
|
import { spawn } from "child_process";
|
|
3
7
|
import { join, dirname } from "path";
|
|
@@ -110,6 +114,12 @@ async function ensureDaemonRunning() {
|
|
|
110
114
|
_ensurePromise = null;
|
|
111
115
|
throw new Error("Daemon not available");
|
|
112
116
|
}
|
|
117
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
118
|
+
const ready = await fetch(`${DAEMON_BASE}/health`, { signal: AbortSignal.timeout(1e3) }).then((r) => r.ok ? r.json() : null).then((d) => d?.status === "ok").catch(() => false);
|
|
119
|
+
if (ready) return;
|
|
120
|
+
await new Promise((r) => setTimeout(r, 200));
|
|
121
|
+
}
|
|
122
|
+
throw new Error("Daemon HTTP server not ready after 4s");
|
|
113
123
|
}
|
|
114
124
|
async function rpcCall(method, params = {}, timeoutMs = 1e4) {
|
|
115
125
|
await ensureDaemonRunning();
|
|
@@ -120,7 +130,13 @@ async function rpcCall(method, params = {}, timeoutMs = 1e4) {
|
|
|
120
130
|
signal: AbortSignal.timeout(timeoutMs)
|
|
121
131
|
});
|
|
122
132
|
if (!resp.ok) {
|
|
123
|
-
|
|
133
|
+
let detail = resp.statusText;
|
|
134
|
+
try {
|
|
135
|
+
const body = await resp.json();
|
|
136
|
+
if (body?.error) detail = body.error;
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
throw new Error(`Daemon error: ${detail}`);
|
|
124
140
|
}
|
|
125
141
|
return resp.json();
|
|
126
142
|
}
|
|
@@ -157,8 +173,8 @@ async function forwardExec(command, params, session = "default", cdpEndpoint, ti
|
|
|
157
173
|
if (cdpEndpoint) rpcParams.cdpEndpoint = cdpEndpoint;
|
|
158
174
|
try {
|
|
159
175
|
return await rpcCall("exec", rpcParams, timeoutMs);
|
|
160
|
-
} catch {
|
|
161
|
-
return { success: false, data: null, message:
|
|
176
|
+
} catch (e) {
|
|
177
|
+
return { success: false, data: null, message: errMsg(e), duration: 0 };
|
|
162
178
|
}
|
|
163
179
|
}
|
|
164
180
|
async function forwardChain(input, session = "default", cdpEndpoint) {
|
|
@@ -166,8 +182,8 @@ async function forwardChain(input, session = "default", cdpEndpoint) {
|
|
|
166
182
|
if (cdpEndpoint) params.cdpEndpoint = cdpEndpoint;
|
|
167
183
|
try {
|
|
168
184
|
return await rpcCall("chain", params, 12e4);
|
|
169
|
-
} catch {
|
|
170
|
-
return { success: false, steps: [], totalDuration: 0, stoppedReason:
|
|
185
|
+
} catch (e) {
|
|
186
|
+
return { success: false, steps: [], totalDuration: 0, stoppedReason: errMsg(e) };
|
|
171
187
|
}
|
|
172
188
|
}
|
|
173
189
|
async function forwardAgentObserve(session = "default", options) {
|
|
@@ -223,8 +239,8 @@ async function forwardNetworkExport(sessionName, id, lang) {
|
|
|
223
239
|
async function forwardNetworkInspect(sessionName, id) {
|
|
224
240
|
return rpcCall("network:inspect", { session: sessionName, id }, 1e4);
|
|
225
241
|
}
|
|
226
|
-
async function forwardRecordStart(session, url) {
|
|
227
|
-
return rpcCall("record:start", { session, url }, 15e3);
|
|
242
|
+
async function forwardRecordStart(session, url, cdpEndpoint) {
|
|
243
|
+
return rpcCall("record:start", { session, url, cdpEndpoint }, 15e3);
|
|
228
244
|
}
|
|
229
245
|
async function forwardRecordStop(session) {
|
|
230
246
|
return rpcCall("record:stop", { session }, 1e4);
|
|
@@ -1290,7 +1290,7 @@ var CDPInterceptorProxy = class {
|
|
|
1290
1290
|
const ctx = {
|
|
1291
1291
|
method: request.method,
|
|
1292
1292
|
params: request.params ?? {},
|
|
1293
|
-
sessionId: makeCompoundId(browserWs._cdpSession, request.sessionId),
|
|
1293
|
+
sessionId: makeCompoundId("_cdpSession" in browserWs ? browserWs._cdpSession : void 0, request.sessionId),
|
|
1294
1294
|
direction: "client\u2192browser"
|
|
1295
1295
|
};
|
|
1296
1296
|
const decision = this.engine.evaluate(ctx);
|