omowright 0.3.0 → 0.3.2
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 +20 -8
- package/TOOLS.md +3 -2
- package/dist/agent-tabs.d.ts +2 -2
- package/dist/bsk/external-extension.d.ts +4 -4
- package/dist/bsk/install-cli.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +508 -197
- package/dist/page-bundle.js +14 -4
- package/package.json +17 -14
- package/skills/omowright/SKILL.md +8 -4
- package/skills/omowright/references/ego.md +2 -2
- package/skills/omowright/references/quickstart.md +5 -2
- package/skills/omowright/references/stealth.md +4 -1
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ var require_constants = __commonJS(function(exports, module) {
|
|
|
69
69
|
|
|
70
70
|
// node_modules/ws/lib/buffer-util.js
|
|
71
71
|
var require_buffer_util = __commonJS(function(exports, module) {
|
|
72
|
+
var { websocketMask, websocketUnmask } = __require("http");
|
|
72
73
|
var { EMPTY_BUFFER } = require_constants();
|
|
73
74
|
var FastBuffer = Buffer[Symbol.species];
|
|
74
75
|
function concat(list, totalLength) {
|
|
@@ -126,7 +127,20 @@ var require_buffer_util = __commonJS(function(exports, module) {
|
|
|
126
127
|
toBuffer,
|
|
127
128
|
unmask: _unmask
|
|
128
129
|
};
|
|
129
|
-
if (
|
|
130
|
+
if (websocketMask) {
|
|
131
|
+
module.exports.mask = function(source, mask, output, offset, length) {
|
|
132
|
+
if (length < 24)
|
|
133
|
+
_mask(source, mask, output, offset, length);
|
|
134
|
+
else
|
|
135
|
+
websocketMask(source, mask, output, offset, length);
|
|
136
|
+
};
|
|
137
|
+
module.exports.unmask = function(buffer, mask) {
|
|
138
|
+
if (buffer.length < 24)
|
|
139
|
+
_unmask(buffer, mask);
|
|
140
|
+
else
|
|
141
|
+
websocketUnmask(buffer, mask);
|
|
142
|
+
};
|
|
143
|
+
} else if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
130
144
|
try {
|
|
131
145
|
const bufferUtil = (()=>{throw new Error("Cannot require module "+"bufferutil");})();
|
|
132
146
|
module.exports.mask = function(source, mask2, output, offset, length) {
|
|
@@ -878,6 +892,7 @@ var require_receiver = __commonJS(function(exports, module) {
|
|
|
878
892
|
unmask(data, this._mask);
|
|
879
893
|
}
|
|
880
894
|
}
|
|
895
|
+
this._mask = undefined;
|
|
881
896
|
if (this._opcode > 7) {
|
|
882
897
|
this.controlMessage(data, cb);
|
|
883
898
|
return;
|
|
@@ -1114,13 +1129,16 @@ var require_sender = __commonJS(function(exports, module) {
|
|
|
1114
1129
|
target[2] = target[3] = 0;
|
|
1115
1130
|
target.writeUIntBE(dataLength, 4, 6);
|
|
1116
1131
|
}
|
|
1117
|
-
if (!options.mask)
|
|
1118
|
-
return [target, data];
|
|
1132
|
+
if (!options.mask) {
|
|
1133
|
+
return dataLength ? [target, data] : [target];
|
|
1134
|
+
}
|
|
1119
1135
|
target[1] |= 128;
|
|
1120
1136
|
target[offset - 4] = mask[0];
|
|
1121
1137
|
target[offset - 3] = mask[1];
|
|
1122
1138
|
target[offset - 2] = mask[2];
|
|
1123
1139
|
target[offset - 1] = mask[3];
|
|
1140
|
+
if (!dataLength)
|
|
1141
|
+
return [target];
|
|
1124
1142
|
if (skipMasking)
|
|
1125
1143
|
return [target, data];
|
|
1126
1144
|
if (merge) {
|
|
@@ -1703,6 +1721,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
1703
1721
|
var https = __require("https");
|
|
1704
1722
|
var http = __require("http");
|
|
1705
1723
|
var net = __require("net");
|
|
1724
|
+
var querystring = __require("querystring");
|
|
1706
1725
|
var tls = __require("tls");
|
|
1707
1726
|
var { randomBytes, createHash } = __require("crypto");
|
|
1708
1727
|
var { Duplex, Readable } = __require("stream");
|
|
@@ -1754,21 +1773,38 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
1754
1773
|
this._isServer = false;
|
|
1755
1774
|
this._redirects = 0;
|
|
1756
1775
|
if (protocols === undefined) {
|
|
1757
|
-
protocols
|
|
1776
|
+
if (!options || options.protocols === undefined) {
|
|
1777
|
+
protocols = [];
|
|
1778
|
+
} else if (Array.isArray(options.protocols)) {
|
|
1779
|
+
protocols = options.protocols;
|
|
1780
|
+
} else {
|
|
1781
|
+
protocols = [options.protocols];
|
|
1782
|
+
}
|
|
1758
1783
|
} else if (!Array.isArray(protocols)) {
|
|
1759
1784
|
if (typeof protocols === "object" && protocols !== null) {
|
|
1760
1785
|
options = protocols;
|
|
1761
|
-
protocols
|
|
1786
|
+
if (options.protocols === undefined) {
|
|
1787
|
+
protocols = [];
|
|
1788
|
+
} else if (Array.isArray(options.protocols)) {
|
|
1789
|
+
protocols = options.protocols;
|
|
1790
|
+
} else {
|
|
1791
|
+
protocols = [options.protocols];
|
|
1792
|
+
}
|
|
1762
1793
|
} else {
|
|
1763
1794
|
protocols = [protocols];
|
|
1764
1795
|
}
|
|
1765
1796
|
}
|
|
1766
|
-
initAsClient(this, address, protocols, options);
|
|
1797
|
+
options = initAsClient(this, address, protocols, options);
|
|
1767
1798
|
} else {
|
|
1768
|
-
this._autoPong = options.autoPong;
|
|
1769
|
-
this._closeTimeout = options.closeTimeout;
|
|
1770
1799
|
this._isServer = true;
|
|
1771
1800
|
}
|
|
1801
|
+
if (options.autoPong) {
|
|
1802
|
+
this._autoPong = true;
|
|
1803
|
+
this._autoPongComplete = () => autoPongComplete(this);
|
|
1804
|
+
this._pendingAutoPongs = 0;
|
|
1805
|
+
this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
|
|
1806
|
+
}
|
|
1807
|
+
this._closeTimeout = options.closeTimeout;
|
|
1772
1808
|
}
|
|
1773
1809
|
get binaryType() {
|
|
1774
1810
|
return this._binaryType;
|
|
@@ -1877,7 +1913,6 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
1877
1913
|
}
|
|
1878
1914
|
return;
|
|
1879
1915
|
}
|
|
1880
|
-
this._readyState = WebSocket.CLOSING;
|
|
1881
1916
|
this._sender.close(code, data, !this._isServer, (err) => {
|
|
1882
1917
|
if (err)
|
|
1883
1918
|
return;
|
|
@@ -1886,6 +1921,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
1886
1921
|
this._socket.end();
|
|
1887
1922
|
}
|
|
1888
1923
|
});
|
|
1924
|
+
this._readyState = WebSocket.CLOSING;
|
|
1889
1925
|
setCloseTimer(this);
|
|
1890
1926
|
}
|
|
1891
1927
|
pause() {
|
|
@@ -2065,6 +2101,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2065
2101
|
maxBufferedChunks: 256 * 1024,
|
|
2066
2102
|
maxFragments: 16 * 1024,
|
|
2067
2103
|
maxPayload: 100 * 1024 * 1024,
|
|
2104
|
+
maxPendingAutoPongs: 60,
|
|
2068
2105
|
skipUTF8Validation: false,
|
|
2069
2106
|
perMessageDeflate: true,
|
|
2070
2107
|
followRedirects: false,
|
|
@@ -2073,14 +2110,13 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2073
2110
|
socketPath: undefined,
|
|
2074
2111
|
hostname: undefined,
|
|
2075
2112
|
protocol: undefined,
|
|
2113
|
+
protocols: undefined,
|
|
2076
2114
|
timeout: undefined,
|
|
2077
2115
|
method: "GET",
|
|
2078
2116
|
host: undefined,
|
|
2079
2117
|
path: undefined,
|
|
2080
2118
|
port: undefined
|
|
2081
2119
|
};
|
|
2082
|
-
websocket._autoPong = opts.autoPong;
|
|
2083
|
-
websocket._closeTimeout = opts.closeTimeout;
|
|
2084
2120
|
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
2085
2121
|
throw new RangeError(`Unsupported protocol version: ${opts.protocolVersion} ` + `(supported versions: ${protocolVersions.join(", ")})`);
|
|
2086
2122
|
}
|
|
@@ -2094,10 +2130,9 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2094
2130
|
throw new SyntaxError(`Invalid URL: ${address}`);
|
|
2095
2131
|
}
|
|
2096
2132
|
}
|
|
2097
|
-
if (parsedUrl.protocol === "http:") {
|
|
2098
|
-
parsedUrl
|
|
2099
|
-
|
|
2100
|
-
parsedUrl.protocol = "wss:";
|
|
2133
|
+
if (parsedUrl.protocol === "http:" || parsedUrl.protocol === "https:") {
|
|
2134
|
+
parsedUrl = new URL2(parsedUrl);
|
|
2135
|
+
parsedUrl.protocol = parsedUrl.protocol === "http:" ? "ws:" : "wss:";
|
|
2101
2136
|
}
|
|
2102
2137
|
websocket._url = parsedUrl.href;
|
|
2103
2138
|
const isSecure = parsedUrl.protocol === "wss:";
|
|
@@ -2164,12 +2199,19 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2164
2199
|
}
|
|
2165
2200
|
}
|
|
2166
2201
|
if (parsedUrl.username || parsedUrl.password) {
|
|
2167
|
-
|
|
2202
|
+
const username = querystring.unescape(parsedUrl.username);
|
|
2203
|
+
const password = querystring.unescape(parsedUrl.password);
|
|
2204
|
+
opts.auth = `${username}:${password}`;
|
|
2168
2205
|
}
|
|
2169
2206
|
if (isIpcUrl) {
|
|
2170
|
-
const
|
|
2171
|
-
|
|
2172
|
-
|
|
2207
|
+
const i = opts.path.indexOf(":");
|
|
2208
|
+
if (i === -1) {
|
|
2209
|
+
opts.socketPath = opts.path;
|
|
2210
|
+
opts.path = "";
|
|
2211
|
+
} else {
|
|
2212
|
+
opts.socketPath = opts.path.slice(0, i);
|
|
2213
|
+
opts.path = opts.path.slice(i + 1);
|
|
2214
|
+
}
|
|
2173
2215
|
}
|
|
2174
2216
|
let req;
|
|
2175
2217
|
if (opts.followRedirects) {
|
|
@@ -2313,6 +2355,7 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2313
2355
|
} else {
|
|
2314
2356
|
req.end();
|
|
2315
2357
|
}
|
|
2358
|
+
return opts;
|
|
2316
2359
|
}
|
|
2317
2360
|
function emitErrorAndClose(websocket, err) {
|
|
2318
2361
|
websocket._readyState = WebSocket.CLOSING;
|
|
@@ -2364,8 +2407,13 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2364
2407
|
function receiverOnConclude(code, reason) {
|
|
2365
2408
|
const websocket = this[kWebSocket];
|
|
2366
2409
|
websocket._closeFrameReceived = true;
|
|
2367
|
-
websocket._closeMessage = reason;
|
|
2368
2410
|
websocket._closeCode = code;
|
|
2411
|
+
if (reason.length === 0) {
|
|
2412
|
+
websocket._closeMessage = EMPTY_BUFFER;
|
|
2413
|
+
} else {
|
|
2414
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
2415
|
+
websocket._closeMessage.set(reason);
|
|
2416
|
+
}
|
|
2369
2417
|
if (websocket._socket[kWebSocket] === undefined)
|
|
2370
2418
|
return;
|
|
2371
2419
|
websocket._socket.removeListener("data", socketOnData);
|
|
@@ -2400,10 +2448,19 @@ var require_websocket = __commonJS(function(exports, module) {
|
|
|
2400
2448
|
}
|
|
2401
2449
|
function receiverOnPing(data) {
|
|
2402
2450
|
const websocket = this[kWebSocket];
|
|
2403
|
-
if (websocket._autoPong)
|
|
2404
|
-
websocket.
|
|
2451
|
+
if (websocket._autoPong && websocket.readyState === WebSocket.OPEN) {
|
|
2452
|
+
if (websocket._maxPendingAutoPongs > 0 && websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs) {
|
|
2453
|
+
websocket.terminate();
|
|
2454
|
+
} else {
|
|
2455
|
+
websocket._pendingAutoPongs++;
|
|
2456
|
+
websocket.pong(data, !this._isServer, websocket._autoPongComplete);
|
|
2457
|
+
}
|
|
2458
|
+
}
|
|
2405
2459
|
websocket.emit("ping", data);
|
|
2406
2460
|
}
|
|
2461
|
+
function autoPongComplete(websocket) {
|
|
2462
|
+
websocket._pendingAutoPongs--;
|
|
2463
|
+
}
|
|
2407
2464
|
function receiverOnPong(data) {
|
|
2408
2465
|
this[kWebSocket].emit("pong", data);
|
|
2409
2466
|
}
|
|
@@ -2642,6 +2699,7 @@ var require_websocket_server = __commonJS(function(exports, module) {
|
|
|
2642
2699
|
maxBufferedChunks: 256 * 1024,
|
|
2643
2700
|
maxFragments: 16 * 1024,
|
|
2644
2701
|
maxPayload: 100 * 1024 * 1024,
|
|
2702
|
+
maxPendingAutoPongs: 60,
|
|
2645
2703
|
skipUTF8Validation: false,
|
|
2646
2704
|
perMessageDeflate: false,
|
|
2647
2705
|
handleProtocols: null,
|
|
@@ -3843,6 +3901,7 @@ __export(exports_util, {
|
|
|
3843
3901
|
required: () => required,
|
|
3844
3902
|
safeExtend: () => safeExtend,
|
|
3845
3903
|
shallowClone: () => shallowClone,
|
|
3904
|
+
sizeCaps: () => sizeCaps,
|
|
3846
3905
|
slugify: () => slugify,
|
|
3847
3906
|
stringifyPrimitive: () => stringifyPrimitive,
|
|
3848
3907
|
toZod: () => toZod,
|
|
@@ -5164,6 +5223,18 @@ function prefixIssues(path, issues) {
|
|
|
5164
5223
|
function unwrapMessage(message) {
|
|
5165
5224
|
return typeof message === "string" ? message : message?.message;
|
|
5166
5225
|
}
|
|
5226
|
+
function sizeCaps(defChecks) {
|
|
5227
|
+
const caps = [];
|
|
5228
|
+
for (const ch of defChecks ?? []) {
|
|
5229
|
+
const d = ch._zod.def;
|
|
5230
|
+
if (!/_(length|size)$|_equals$/.test(d.check))
|
|
5231
|
+
break;
|
|
5232
|
+
const max = d.maximum ?? d.length ?? d.size;
|
|
5233
|
+
if (max >= 0)
|
|
5234
|
+
caps.push([max, ch]);
|
|
5235
|
+
}
|
|
5236
|
+
return caps;
|
|
5237
|
+
}
|
|
5167
5238
|
function attachSchema(issues, start, inst) {
|
|
5168
5239
|
var _a;
|
|
5169
5240
|
for (let i = start;i < issues.length; i++) {
|
|
@@ -6516,7 +6587,7 @@ ${content.join(`
|
|
|
6516
6587
|
var version = {
|
|
6517
6588
|
major: 4,
|
|
6518
6589
|
minor: 6,
|
|
6519
|
-
patch:
|
|
6590
|
+
patch: 7
|
|
6520
6591
|
};
|
|
6521
6592
|
|
|
6522
6593
|
// node_modules/zod/v4/core/schemas.js
|
|
@@ -7265,6 +7336,31 @@ var $ZodDate = /* @__PURE__ */ $constructor("$ZodDate", (inst, def) => {
|
|
|
7265
7336
|
return payload;
|
|
7266
7337
|
};
|
|
7267
7338
|
});
|
|
7339
|
+
function capSize(inst, size) {
|
|
7340
|
+
const caps = sizeCaps(inst._zod.def.checks);
|
|
7341
|
+
if (!caps.length)
|
|
7342
|
+
return;
|
|
7343
|
+
const cap = Math.min(...caps.map((c) => c[0]));
|
|
7344
|
+
const parse = inst._zod.parse;
|
|
7345
|
+
inst._zod.parse = (payload, ctx) => {
|
|
7346
|
+
const n = size(payload.value);
|
|
7347
|
+
if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
|
|
7348
|
+
for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
|
|
7349
|
+
if (n > max && ch._zod.def.when(payload)) {
|
|
7350
|
+
const start = payload.issues.length;
|
|
7351
|
+
ch._zod.check(payload);
|
|
7352
|
+
payload.issues[start].continue = false;
|
|
7353
|
+
attachSchema(payload.issues, start, inst);
|
|
7354
|
+
return payload;
|
|
7355
|
+
}
|
|
7356
|
+
}
|
|
7357
|
+
}
|
|
7358
|
+
return parse(payload, ctx);
|
|
7359
|
+
};
|
|
7360
|
+
}
|
|
7361
|
+
var arraySize = (input) => Array.isArray(input) ? input.length : -1;
|
|
7362
|
+
var mapSize = (input) => input instanceof Map ? input.size : -1;
|
|
7363
|
+
var setSize = (input) => input instanceof Set ? input.size : -1;
|
|
7268
7364
|
function handleArrayResult(result, final, index) {
|
|
7269
7365
|
if (result.issues.length) {
|
|
7270
7366
|
final.issues.push(...prefixIssues(index, result.issues));
|
|
@@ -7308,6 +7404,7 @@ var $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
7308
7404
|
}
|
|
7309
7405
|
return payload;
|
|
7310
7406
|
};
|
|
7407
|
+
capSize(inst, arraySize);
|
|
7311
7408
|
});
|
|
7312
7409
|
function handlePropertyResult(result, final, key, input, optin, optout) {
|
|
7313
7410
|
const isPresent = key in input;
|
|
@@ -8262,6 +8359,7 @@ var $ZodMap = /* @__PURE__ */ $constructor("$ZodMap", (inst, def) => {
|
|
|
8262
8359
|
return Promise.all(proms).then(() => payload);
|
|
8263
8360
|
return payload;
|
|
8264
8361
|
};
|
|
8362
|
+
capSize(inst, mapSize);
|
|
8265
8363
|
});
|
|
8266
8364
|
function handleMapResult(keyResult, valueResult, final, key, input, inst, ctx) {
|
|
8267
8365
|
if (keyResult.issues.length) {
|
|
@@ -8328,6 +8426,7 @@ var $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
|
|
|
8328
8426
|
return Promise.all(proms).then(() => payload);
|
|
8329
8427
|
return payload;
|
|
8330
8428
|
};
|
|
8429
|
+
capSize(inst, setSize);
|
|
8331
8430
|
});
|
|
8332
8431
|
function handleSetResult(result, final) {
|
|
8333
8432
|
if (result.issues.length) {
|
|
@@ -17709,9 +17808,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
|
17709
17808
|
doc.write(`}`);
|
|
17710
17809
|
return outputVar;
|
|
17711
17810
|
}
|
|
17811
|
+
function generateSizeGate(doc, schema, size) {
|
|
17812
|
+
for (const [max, check] of sizeCaps(schema._zod.def.checks)) {
|
|
17813
|
+
doc.write(`if (${size} > ${numericOperand(max, check._zod.def.check)}) return INVALID;`);
|
|
17814
|
+
}
|
|
17815
|
+
}
|
|
17712
17816
|
function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
|
|
17713
17817
|
const def = schema._zod.def;
|
|
17714
17818
|
doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
|
|
17819
|
+
generateSizeGate(doc, schema, `${accessor}.length`);
|
|
17715
17820
|
const outputVar = buildsValue ? newVar(ctx) : null;
|
|
17716
17821
|
const iVar = newVar(ctx);
|
|
17717
17822
|
const elemVar = newVar(ctx);
|
|
@@ -18111,6 +18216,7 @@ function literalPropertyKey(ctx, key) {
|
|
|
18111
18216
|
function generateMapCheck(doc, ctx, schema, accessor) {
|
|
18112
18217
|
const def = schema._zod.def;
|
|
18113
18218
|
doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
|
|
18219
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
18114
18220
|
const outputVar = newVar(ctx);
|
|
18115
18221
|
const kVar = newVar(ctx);
|
|
18116
18222
|
const valVar = newVar(ctx);
|
|
@@ -18127,6 +18233,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
|
|
|
18127
18233
|
function generateSetCheck(doc, ctx, schema, accessor) {
|
|
18128
18234
|
const def = schema._zod.def;
|
|
18129
18235
|
doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
|
|
18236
|
+
generateSizeGate(doc, schema, `${accessor}.size`);
|
|
18130
18237
|
const outputVar = newVar(ctx);
|
|
18131
18238
|
const valVar = newVar(ctx);
|
|
18132
18239
|
doc.write(`const ${outputVar} = new Set();`);
|
|
@@ -25927,11 +26034,11 @@ function collectTrackedSessionIds(xn, jn) {
|
|
|
25927
26034
|
Vn.add(jn.sessionId);
|
|
25928
26035
|
return Vn;
|
|
25929
26036
|
}
|
|
25930
|
-
async function waitForNavigationReadiness(page, mode = `interactive`, timeoutMs = ACTION_MAX_WAIT_MS) {
|
|
26037
|
+
async function waitForNavigationReadiness(page, mode = `interactive`, timeoutMs = ACTION_MAX_WAIT_MS, signal) {
|
|
25931
26038
|
let timer;
|
|
25932
26039
|
try {
|
|
25933
26040
|
return await Promise.race([
|
|
25934
|
-
waitForNavigationReadinessInner(page, mode, timeoutMs),
|
|
26041
|
+
waitForNavigationReadinessInner(page, mode, timeoutMs, signal),
|
|
25935
26042
|
new Promise((_, reject) => {
|
|
25936
26043
|
timer = setTimeout(() => reject(new NavigationReadinessTimeoutError(mode, timeoutMs)), timeoutMs + 1000);
|
|
25937
26044
|
})
|
|
@@ -25970,7 +26077,7 @@ async function waitForNavigationDomQuiet(page, budgetMs) {
|
|
|
25970
26077
|
window.addEventListener("load", onLoad, { once: true });
|
|
25971
26078
|
}), budgetMs);
|
|
25972
26079
|
}
|
|
25973
|
-
async function waitForNavigationReadinessInner(page, mode, timeoutMs) {
|
|
26080
|
+
async function waitForNavigationReadinessInner(page, mode, timeoutMs, signal) {
|
|
25974
26081
|
if (isPdfViewerUrl(page.url())) {
|
|
25975
26082
|
await waitForDomReady(page, Math.min(DOM_READY_TIMEOUT_MS, timeoutMs)).catch(() => {});
|
|
25976
26083
|
return { bodyExists: true, interactiveCount: 0, landmarkCount: 0, textChars: 0, state: "ready" };
|
|
@@ -25991,6 +26098,7 @@ async function waitForNavigationReadinessInner(page, mode, timeoutMs) {
|
|
|
25991
26098
|
await ensureDomMonitor(page).catch(() => {});
|
|
25992
26099
|
while (Date.now() < deadline) {
|
|
25993
26100
|
await sleep$12(PROBE_INTERVAL_MS);
|
|
26101
|
+
signal?.throwIfAborted();
|
|
25994
26102
|
try {
|
|
25995
26103
|
if (navigated) {
|
|
25996
26104
|
navigated = false;
|
|
@@ -26006,17 +26114,23 @@ async function waitForNavigationReadinessInner(page, mode, timeoutMs) {
|
|
|
26006
26114
|
quietSamples = 0;
|
|
26007
26115
|
continue;
|
|
26008
26116
|
}
|
|
26009
|
-
|
|
26117
|
+
const hasPendingRequests = network.captureTrackedRequests(page.url()).size > 0;
|
|
26118
|
+
if (hasPendingRequests) {
|
|
26010
26119
|
networkStarted ??= Date.now();
|
|
26011
26120
|
if (Date.now() - networkStarted < NAVIGATION_NETWORK_BUDGET_MS) {
|
|
26012
26121
|
quietSamples = 0;
|
|
26013
26122
|
continue;
|
|
26014
26123
|
}
|
|
26015
26124
|
}
|
|
26016
|
-
const settleDeadline = Math.min(deadline,
|
|
26125
|
+
const settleDeadline = Math.min(deadline, Date.now() + (hasPendingRequests ? 0 : NAVIGATION_NETWORK_BUDGET_MS));
|
|
26017
26126
|
await waitForNavigationDomQuiet(page, Math.max(settleDeadline - Date.now(), 0));
|
|
26018
26127
|
if (navigated)
|
|
26019
26128
|
continue;
|
|
26129
|
+
if (network.captureTrackedRequests(page.url()).size > 0) {
|
|
26130
|
+
networkStarted ??= Date.now();
|
|
26131
|
+
if (Date.now() - networkStarted < NAVIGATION_NETWORK_BUDGET_MS)
|
|
26132
|
+
continue;
|
|
26133
|
+
}
|
|
26020
26134
|
if (mode === "interactive")
|
|
26021
26135
|
return probe;
|
|
26022
26136
|
const sample = await readDomMonitor(page);
|
|
@@ -29453,10 +29567,12 @@ function createOmOPageClass() {
|
|
|
29453
29567
|
await networkReady(this);
|
|
29454
29568
|
const releaseNetwork = [`interactive`, `stable`, `networkidle`].includes(jn.waitUntil ?? `interactive`) ? acquireNetwork(this.cdp, await this.resolveSessionId()) : null;
|
|
29455
29569
|
const documents = trackDocumentResponses(this, this.frameManager.mainFrameId);
|
|
29570
|
+
const readinessController = new AbortController;
|
|
29571
|
+
let readiness;
|
|
29456
29572
|
try {
|
|
29457
29573
|
await releaseNetwork?.ready;
|
|
29458
29574
|
await documents.ready;
|
|
29459
|
-
let Vn = jn.waitUntil ?? `interactive`, qn = await this.resolveSessionId(this.#n), Jn = () => {}, Yn = Vn === `commit` ? null : Vn === `interactive` || Vn === `stable` ? waitForNavigationReadiness(this, Vn, DEFAULT_WAIT_TIMEOUT_MS).then(() => {}) : Vn === `networkidle` ? this.#S(DEFAULT_WAIT_TIMEOUT_MS) : new Promise((xn, jn) => {
|
|
29575
|
+
let Vn = jn.waitUntil ?? `interactive`, qn = await this.resolveSessionId(this.#n), Jn = () => {}, Yn = Vn === `commit` ? null : Vn === `interactive` || Vn === `stable` ? readiness = waitForNavigationReadiness(this, Vn, DEFAULT_WAIT_TIMEOUT_MS, readinessController.signal).then(() => {}) : Vn === `networkidle` ? this.#S(DEFAULT_WAIT_TIMEOUT_MS) : new Promise((xn, jn) => {
|
|
29460
29576
|
let Yn = false, Zn, Qn = () => {}, ei = (xn) => {
|
|
29461
29577
|
Yn || (Yn = true, clearTimeout(Zn), Qn(), xn());
|
|
29462
29578
|
};
|
|
@@ -29467,10 +29583,13 @@ function createOmOPageClass() {
|
|
|
29467
29583
|
Qn = this.cdp.on(ti, (jn, Vn) => {
|
|
29468
29584
|
Vn.sessionId === qn && ei(xn);
|
|
29469
29585
|
}), Jn = () => ei(xn);
|
|
29470
|
-
})
|
|
29586
|
+
});
|
|
29587
|
+
Yn?.catch(() => {});
|
|
29588
|
+
const Zn = await this.cdp.send(`Page.navigate`, { url: xn }, qn);
|
|
29471
29589
|
if (Zn.errorText)
|
|
29472
29590
|
throw Error(Zn.errorText);
|
|
29473
|
-
|
|
29591
|
+
this.#r = (await this.cdp.send(`Page.getFrameTree`, {}, qn)).frameTree.frame.url;
|
|
29592
|
+
if (Vn === `domcontentloaded` && Yn) {
|
|
29474
29593
|
if (!Zn.loaderId) {
|
|
29475
29594
|
Jn(), await this.#v(`Timed out waiting for "${Vn}" after goto`);
|
|
29476
29595
|
return null;
|
|
@@ -29486,6 +29605,8 @@ function createOmOPageClass() {
|
|
|
29486
29605
|
Yn && await Yn;
|
|
29487
29606
|
return documents.response(Zn.loaderId);
|
|
29488
29607
|
} finally {
|
|
29608
|
+
readinessController.abort();
|
|
29609
|
+
await readiness?.catch(() => {});
|
|
29489
29610
|
documents.dispose(), releaseNetwork?.();
|
|
29490
29611
|
}
|
|
29491
29612
|
}
|
|
@@ -30321,19 +30442,18 @@ class AgentTabManager {
|
|
|
30321
30442
|
if (await this.#isHeadless())
|
|
30322
30443
|
await this.#connection.cdp.send("Target.activateTarget", { targetId });
|
|
30323
30444
|
const tab = await this.adopt(targetId, { viewport });
|
|
30445
|
+
if (tab.page === null)
|
|
30446
|
+
throw new TypeError(`Target ${targetId} is still being adopted`);
|
|
30324
30447
|
if (url !== "about:blank")
|
|
30325
30448
|
await tab.page.goto(url);
|
|
30326
|
-
return tab;
|
|
30449
|
+
return Object.freeze({ ...tab, page: tab.page });
|
|
30327
30450
|
}
|
|
30328
30451
|
async adopt(targetId, options = {}) {
|
|
30329
30452
|
if (this.#disposed)
|
|
30330
30453
|
throw Error("Agent tab manager is disposed");
|
|
30331
30454
|
const existing = this.#owned.get(targetId);
|
|
30332
|
-
if (existing)
|
|
30333
|
-
|
|
30334
|
-
throw new TypeError(`Target ${targetId} is still being adopted`);
|
|
30335
|
-
return this.#public(existing, existing.page);
|
|
30336
|
-
}
|
|
30455
|
+
if (existing)
|
|
30456
|
+
return this.#public(existing);
|
|
30337
30457
|
const viewport = { ...this.viewport, ...options.viewport };
|
|
30338
30458
|
const record = {
|
|
30339
30459
|
targetId,
|
|
@@ -30750,6 +30870,8 @@ class BrowserConnection {
|
|
|
30750
30870
|
async#attachPopup(targetId, pending) {
|
|
30751
30871
|
const tabs = getAgentTabs(this) ?? createAgentTabs(this);
|
|
30752
30872
|
const { page } = await tabs.adopt(targetId);
|
|
30873
|
+
if (page === null)
|
|
30874
|
+
throw new TypeError(`Popup target ${targetId} is still being adopted`);
|
|
30753
30875
|
Object.assign(page, { popupMetadata: Object.freeze(pending.metadata) });
|
|
30754
30876
|
await page.waitForLoadState("interactive");
|
|
30755
30877
|
pending.resolve(page);
|
|
@@ -31350,6 +31472,7 @@ class PipeCdpClient {
|
|
|
31350
31472
|
#malformedFrameCount = 0;
|
|
31351
31473
|
#events = new SerialEmitter;
|
|
31352
31474
|
#connected = false;
|
|
31475
|
+
#closedByCaller = false;
|
|
31353
31476
|
#commandTimeoutMs;
|
|
31354
31477
|
#readinessTimeoutMs;
|
|
31355
31478
|
#browserPath;
|
|
@@ -31395,6 +31518,7 @@ class PipeCdpClient {
|
|
|
31395
31518
|
this.#dialogPolicy = normalizeDialogPolicy(policy);
|
|
31396
31519
|
}
|
|
31397
31520
|
async ensureConnected() {
|
|
31521
|
+
this.#closedByCaller = false;
|
|
31398
31522
|
if (this.#connected)
|
|
31399
31523
|
return;
|
|
31400
31524
|
const stdio = ["ignore", "pipe", "pipe", "pipe", "pipe"];
|
|
@@ -31557,6 +31681,15 @@ ${tail}` : ""));
|
|
|
31557
31681
|
if (String(method).startsWith("OmO.")) {
|
|
31558
31682
|
throw Error(`Extension commands are unavailable over pipe transport: ${method}`);
|
|
31559
31683
|
}
|
|
31684
|
+
if (this.#closedByCaller) {
|
|
31685
|
+
throw this.#commandError(CdpPipeClosedError, "CDP pipe client closed", {
|
|
31686
|
+
method,
|
|
31687
|
+
sessionId,
|
|
31688
|
+
targetId: this.#sessionTargets.get(sessionId),
|
|
31689
|
+
sentAt: performance.now(),
|
|
31690
|
+
receivedBytes: this.#receivedBytes
|
|
31691
|
+
});
|
|
31692
|
+
}
|
|
31560
31693
|
await this.ensureConnected();
|
|
31561
31694
|
return this.#dispatch(method, params, sessionId, opts);
|
|
31562
31695
|
}
|
|
@@ -31615,6 +31748,7 @@ ${tail}` : ""));
|
|
|
31615
31748
|
this.#failCommands(CdpSessionDetachedError, "Page closed", sessionId);
|
|
31616
31749
|
}
|
|
31617
31750
|
async close() {
|
|
31751
|
+
this.#closedByCaller = true;
|
|
31618
31752
|
const child = this.#child;
|
|
31619
31753
|
this.#child = undefined;
|
|
31620
31754
|
if (child && child.exitCode === null) {
|
|
@@ -31622,7 +31756,7 @@ ${tail}` : ""));
|
|
|
31622
31756
|
let quitRequested = false;
|
|
31623
31757
|
if (this.#connected) {
|
|
31624
31758
|
await Promise.race([
|
|
31625
|
-
this
|
|
31759
|
+
this.#dispatch("Browser.close", undefined, undefined, {
|
|
31626
31760
|
timeoutMs: GRACEFUL_CLOSE_TIMEOUT_MS
|
|
31627
31761
|
}).then(() => {
|
|
31628
31762
|
quitRequested = true;
|
|
@@ -34429,9 +34563,10 @@ var systemBinary = (...segments) => {
|
|
|
34429
34563
|
throw new Error(`${file} is missing`);
|
|
34430
34564
|
return file;
|
|
34431
34565
|
};
|
|
34566
|
+
var RUN_TIMEOUT_MS = 60000;
|
|
34432
34567
|
function run(file, args) {
|
|
34433
34568
|
return new Promise((resolve, reject) => {
|
|
34434
|
-
execFile3(file, args, { timeout:
|
|
34569
|
+
execFile3(file, args, { timeout: RUN_TIMEOUT_MS, windowsHide: true, maxBuffer: 4 * 1024 * 1024, encoding: "utf8" }, (error, stdout, stderr) => {
|
|
34435
34570
|
if (error && (typeof error.code !== "number" || error.killed))
|
|
34436
34571
|
reject(error);
|
|
34437
34572
|
else
|
|
@@ -35527,9 +35662,98 @@ async function snapshotWithFrames(page, opts = {}) {
|
|
|
35527
35662
|
const missingFrames = collectMissingFrames(page, result.refs);
|
|
35528
35663
|
return missingFrames.length > 0 ? { ...result, missingFrames } : result;
|
|
35529
35664
|
}
|
|
35665
|
+
// package.json
|
|
35666
|
+
var package_default = {
|
|
35667
|
+
name: "omowright",
|
|
35668
|
+
version: "0.3.2",
|
|
35669
|
+
description: "OmOWright browser automation for standard Chromium CDP endpoints.",
|
|
35670
|
+
keywords: [
|
|
35671
|
+
"accessibility-snapshot",
|
|
35672
|
+
"ai-agent",
|
|
35673
|
+
"browser-automation",
|
|
35674
|
+
"bun",
|
|
35675
|
+
"cdp",
|
|
35676
|
+
"chrome-devtools-protocol",
|
|
35677
|
+
"chromium",
|
|
35678
|
+
"llm"
|
|
35679
|
+
],
|
|
35680
|
+
homepage: "https://github.com/code-yeongyu/omowright#readme",
|
|
35681
|
+
bugs: {
|
|
35682
|
+
url: "https://github.com/code-yeongyu/omowright/issues"
|
|
35683
|
+
},
|
|
35684
|
+
license: "MIT",
|
|
35685
|
+
repository: {
|
|
35686
|
+
type: "git",
|
|
35687
|
+
url: "git+https://github.com/code-yeongyu/omowright.git"
|
|
35688
|
+
},
|
|
35689
|
+
bin: {
|
|
35690
|
+
"omowright-cloak": "./dist/bin/omowright-cloak.js"
|
|
35691
|
+
},
|
|
35692
|
+
files: [
|
|
35693
|
+
"dist/",
|
|
35694
|
+
"skills/",
|
|
35695
|
+
"presets/",
|
|
35696
|
+
"README.md",
|
|
35697
|
+
"LICENSE",
|
|
35698
|
+
"TOOLS.md"
|
|
35699
|
+
],
|
|
35700
|
+
type: "module",
|
|
35701
|
+
exports: {
|
|
35702
|
+
".": {
|
|
35703
|
+
types: "./dist/index.d.ts",
|
|
35704
|
+
import: "./dist/index.js",
|
|
35705
|
+
default: "./dist/index.js"
|
|
35706
|
+
},
|
|
35707
|
+
"./package.json": "./package.json"
|
|
35708
|
+
},
|
|
35709
|
+
publishConfig: {
|
|
35710
|
+
access: "public",
|
|
35711
|
+
provenance: true
|
|
35712
|
+
},
|
|
35713
|
+
scripts: {
|
|
35714
|
+
test: "bun test --parallel",
|
|
35715
|
+
"test:node": "bun scripts/node-test.ts",
|
|
35716
|
+
"test:cloak-profile": "bun test test/cloak-profile.test.ts test/cloak-profile.integration.test.ts",
|
|
35717
|
+
typecheck: "bun check --no-script --no-pretty -p tsconfig.json",
|
|
35718
|
+
"typecheck:control": "bun scripts/typecheck-control.ts",
|
|
35719
|
+
check: "bun run typecheck:control && bun run typecheck && bun run lint && bun run fmt:check",
|
|
35720
|
+
lint: "oxlint --deny-warnings src bin bridge test scripts && bun scripts/lint-ratchet.ts",
|
|
35721
|
+
"lint:ratchet:update": "bun scripts/lint-ratchet.ts --update",
|
|
35722
|
+
"lint:fix": "oxlint --fix src bin bridge test scripts",
|
|
35723
|
+
fmt: "bun fmt --no-script --write src bin bridge test scripts",
|
|
35724
|
+
"fmt:check": "bun fmt --no-script --check src bin bridge test scripts",
|
|
35725
|
+
format: "bun run fmt",
|
|
35726
|
+
"format:check": "bun run fmt:check",
|
|
35727
|
+
verify: "bun run check",
|
|
35728
|
+
"check:push": "bun run check && bun run build && git diff --exit-code HEAD --",
|
|
35729
|
+
prepare: "husky",
|
|
35730
|
+
build: "bun build.ts",
|
|
35731
|
+
"build:extension": "bun bridge/build-extension.ts",
|
|
35732
|
+
prepack: "bun run build",
|
|
35733
|
+
preversion: "git diff --quiet HEAD --"
|
|
35734
|
+
},
|
|
35735
|
+
dependencies: {
|
|
35736
|
+
ws: "^8.23.0",
|
|
35737
|
+
zod: "^4.6.7"
|
|
35738
|
+
},
|
|
35739
|
+
devDependencies: {
|
|
35740
|
+
"@types/bun": "1.4.5",
|
|
35741
|
+
acorn: "8.19.0",
|
|
35742
|
+
"gpt-tokenizer": "4.1.2",
|
|
35743
|
+
husky: "9.1.7",
|
|
35744
|
+
"oxc-parser": "0.159.0",
|
|
35745
|
+
oxlint: "^1.94.0",
|
|
35746
|
+
"typescript-5": "npm:typescript@5.9.3"
|
|
35747
|
+
},
|
|
35748
|
+
engines: {
|
|
35749
|
+
bun: ">=1.4",
|
|
35750
|
+
node: ">=22"
|
|
35751
|
+
}
|
|
35752
|
+
};
|
|
35753
|
+
|
|
35530
35754
|
// src/har.ts
|
|
35531
35755
|
var HTTP_VERSION = "HTTP/1.1";
|
|
35532
|
-
var CREATOR = Object.freeze({ name: "omowright", version:
|
|
35756
|
+
var CREATOR = Object.freeze({ name: "omowright", version: package_default.version });
|
|
35533
35757
|
function headerList(headers) {
|
|
35534
35758
|
return Object.entries(headers ?? {}).map(([name, value]) => ({ name, value: String(value) }));
|
|
35535
35759
|
}
|
|
@@ -36365,16 +36589,130 @@ function createTrace(page, options = {}) {
|
|
|
36365
36589
|
}
|
|
36366
36590
|
// src/bsk/ipc-client.ts
|
|
36367
36591
|
import { connect as connect2 } from "node:net";
|
|
36368
|
-
import { existsSync as
|
|
36369
|
-
import
|
|
36592
|
+
import { existsSync as existsSync6, readdirSync } from "node:fs";
|
|
36593
|
+
import path20 from "node:path";
|
|
36370
36594
|
import { randomBytes } from "node:crypto";
|
|
36371
36595
|
|
|
36372
36596
|
// src/bsk/daemon-info.ts
|
|
36373
|
-
import { existsSync as
|
|
36597
|
+
import { existsSync as existsSync5, readFileSync as readFileSync5 } from "node:fs";
|
|
36598
|
+
import { homedir as homedir4 } from "node:os";
|
|
36599
|
+
import path19 from "node:path";
|
|
36600
|
+
import { spawn as spawn7 } from "node:child_process";
|
|
36601
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
36602
|
+
|
|
36603
|
+
// src/bsk/install-cli.ts
|
|
36604
|
+
import { existsSync as existsSync4, readFileSync as readFileSync4, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
36374
36605
|
import { homedir as homedir3 } from "node:os";
|
|
36375
36606
|
import path18 from "node:path";
|
|
36376
36607
|
import { spawn as spawn6 } from "node:child_process";
|
|
36377
|
-
|
|
36608
|
+
var BSK_CLI_VERSION = "0.5.0";
|
|
36609
|
+
var RELEASE_TAG = `cli-v${BSK_CLI_VERSION}`;
|
|
36610
|
+
var INSTALL_SH = `https://raw.githubusercontent.com/Tencent/BrowserSkill/${RELEASE_TAG}/install.sh`;
|
|
36611
|
+
var INSTALL_PS1 = `https://raw.githubusercontent.com/Tencent/BrowserSkill/${RELEASE_TAG}/install.ps1`;
|
|
36612
|
+
var BSK_PINNED_MANIFEST_URL = `https://github.com/Tencent/BrowserSkill/releases/download/${RELEASE_TAG}/version.json`;
|
|
36613
|
+
var RC_FILES = [".zshrc", ".bashrc", ".profile"];
|
|
36614
|
+
function windowsPowerShellEnv(env) {
|
|
36615
|
+
const key = Object.keys(process.env).find((name) => name.toUpperCase() === "PSMODULEPATH");
|
|
36616
|
+
if (!key)
|
|
36617
|
+
return env;
|
|
36618
|
+
const value = process.env[key];
|
|
36619
|
+
if (value === undefined)
|
|
36620
|
+
throw new TypeError(`${key} has no value`);
|
|
36621
|
+
const kept = value.split(";").filter((entry) => entry && !/[\\/]PowerShell[\\/]/i.test(entry));
|
|
36622
|
+
return { ...env, [key]: kept.length > 0 ? kept.join(";") : undefined };
|
|
36623
|
+
}
|
|
36624
|
+
function cliInstallCommand({
|
|
36625
|
+
platform = process.platform,
|
|
36626
|
+
installDir,
|
|
36627
|
+
version = BSK_CLI_VERSION
|
|
36628
|
+
} = {}) {
|
|
36629
|
+
const env = { BSK_INSTALL_DIR: installDir, BSK_VERSION: version };
|
|
36630
|
+
if (platform === "win32") {
|
|
36631
|
+
return {
|
|
36632
|
+
command: windowsSystemTool("WindowsPowerShell\\v1.0\\powershell.exe"),
|
|
36633
|
+
args: ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${INSTALL_PS1} | iex`],
|
|
36634
|
+
env: windowsPowerShellEnv(env)
|
|
36635
|
+
};
|
|
36636
|
+
}
|
|
36637
|
+
return { command: "sh", args: ["-c", `curl -fsSL ${INSTALL_SH} | sh`], env };
|
|
36638
|
+
}
|
|
36639
|
+
function runDefault(command, args, env) {
|
|
36640
|
+
return new Promise((resolve) => {
|
|
36641
|
+
const child = spawn6(command, args, {
|
|
36642
|
+
env: { ...process.env, ...env },
|
|
36643
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36644
|
+
windowsHide: true
|
|
36645
|
+
});
|
|
36646
|
+
let stdout = "", stderr = "";
|
|
36647
|
+
child.stdout.on("data", (c) => {
|
|
36648
|
+
stdout = (stdout + c).slice(-8192);
|
|
36649
|
+
});
|
|
36650
|
+
child.stderr.on("data", (c) => {
|
|
36651
|
+
stderr = (stderr + c).slice(-8192);
|
|
36652
|
+
});
|
|
36653
|
+
child.on("error", (error) => resolve({ code: -1, stdout, stderr: error.message }));
|
|
36654
|
+
child.on("exit", (code) => resolve({ code, stdout, stderr }));
|
|
36655
|
+
});
|
|
36656
|
+
}
|
|
36657
|
+
function snapshotRcFiles(home) {
|
|
36658
|
+
const snapshot = new Map;
|
|
36659
|
+
for (const name of RC_FILES) {
|
|
36660
|
+
const file = path18.join(home, name);
|
|
36661
|
+
snapshot.set(file, existsSync4(file) ? readFileSync4(file) : null);
|
|
36662
|
+
}
|
|
36663
|
+
return snapshot;
|
|
36664
|
+
}
|
|
36665
|
+
function restoreRcFiles(snapshot) {
|
|
36666
|
+
const restored = [];
|
|
36667
|
+
for (const [file, before] of snapshot) {
|
|
36668
|
+
const after = existsSync4(file) ? readFileSync4(file) : null;
|
|
36669
|
+
if (before === null && after === null)
|
|
36670
|
+
continue;
|
|
36671
|
+
if (before !== null && after !== null && before.equals(after))
|
|
36672
|
+
continue;
|
|
36673
|
+
if (before === null)
|
|
36674
|
+
rmSync3(file, { force: true });
|
|
36675
|
+
else
|
|
36676
|
+
writeFileSync3(file, before);
|
|
36677
|
+
restored.push(file);
|
|
36678
|
+
}
|
|
36679
|
+
return restored;
|
|
36680
|
+
}
|
|
36681
|
+
async function installBskCli({
|
|
36682
|
+
platform = process.platform,
|
|
36683
|
+
home = homedir3(),
|
|
36684
|
+
installDir = path18.join(home, ".local", "bin"),
|
|
36685
|
+
version,
|
|
36686
|
+
run = runDefault
|
|
36687
|
+
} = {}) {
|
|
36688
|
+
const spec = cliInstallCommand({ platform, installDir, version });
|
|
36689
|
+
const rcBefore = platform === "win32" ? new Map : snapshotRcFiles(home);
|
|
36690
|
+
const result = await run(spec.command, spec.args, spec.env);
|
|
36691
|
+
const restoredRcFiles = restoreRcFiles(rcBefore);
|
|
36692
|
+
const bskBin = path18.join(installDir, platform === "win32" ? "bsk.exe" : "bsk");
|
|
36693
|
+
const installed = result.code === 0 && existsSync4(bskBin);
|
|
36694
|
+
return {
|
|
36695
|
+
installed,
|
|
36696
|
+
bskBin: installed ? bskBin : null,
|
|
36697
|
+
code: result.code,
|
|
36698
|
+
stdout: result.stdout,
|
|
36699
|
+
stderr: result.stderr,
|
|
36700
|
+
restoredRcFiles
|
|
36701
|
+
};
|
|
36702
|
+
}
|
|
36703
|
+
function cliVersionDefault(bskBin) {
|
|
36704
|
+
return new Promise((resolve) => {
|
|
36705
|
+
const child = spawn6(bskBin, ["--version"], { stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
36706
|
+
let out = "";
|
|
36707
|
+
child.stdout.on("data", (c) => {
|
|
36708
|
+
out += c;
|
|
36709
|
+
});
|
|
36710
|
+
child.on("error", () => resolve(null));
|
|
36711
|
+
child.on("exit", (code) => resolve(code === 0 ? out.trim() : null));
|
|
36712
|
+
});
|
|
36713
|
+
}
|
|
36714
|
+
|
|
36715
|
+
// src/bsk/daemon-info.ts
|
|
36378
36716
|
function isDaemonInfo(value) {
|
|
36379
36717
|
if (!value || typeof value !== "object" || !("sock_path" in value))
|
|
36380
36718
|
return false;
|
|
@@ -36384,16 +36722,16 @@ function resolveBskHome(env = process.env) {
|
|
|
36384
36722
|
const override = env["BSK_HOME"];
|
|
36385
36723
|
if (typeof override === "string" && override.length > 0)
|
|
36386
36724
|
return override;
|
|
36387
|
-
const home = env["HOME"] && env["HOME"].length > 0 ? env["HOME"] :
|
|
36388
|
-
return
|
|
36725
|
+
const home = env["HOME"] && env["HOME"].length > 0 ? env["HOME"] : homedir4();
|
|
36726
|
+
return path19.join(home, ".bsk");
|
|
36389
36727
|
}
|
|
36390
36728
|
function daemonInfoPath(home) {
|
|
36391
|
-
return
|
|
36729
|
+
return path19.join(home, "daemon.json");
|
|
36392
36730
|
}
|
|
36393
36731
|
function readDaemonInfo(home) {
|
|
36394
36732
|
let raw;
|
|
36395
36733
|
try {
|
|
36396
|
-
raw =
|
|
36734
|
+
raw = readFileSync5(daemonInfoPath(home), "utf8");
|
|
36397
36735
|
} catch {
|
|
36398
36736
|
return null;
|
|
36399
36737
|
}
|
|
@@ -36408,27 +36746,37 @@ function readDaemonInfo(home) {
|
|
|
36408
36746
|
return info;
|
|
36409
36747
|
}
|
|
36410
36748
|
function findBskBinary(env = process.env) {
|
|
36411
|
-
const home = env["HOME"] && env["HOME"].length > 0 ? env["HOME"] :
|
|
36749
|
+
const home = env["HOME"] && env["HOME"].length > 0 ? env["HOME"] : homedir4();
|
|
36412
36750
|
const candidates = [
|
|
36413
36751
|
env["BSK_BIN"],
|
|
36414
|
-
|
|
36752
|
+
path19.join(home, ".local", "bin", process.platform === "win32" ? "bsk.exe" : "bsk")
|
|
36415
36753
|
].filter((candidate) => Boolean(candidate));
|
|
36416
36754
|
for (const candidate of candidates)
|
|
36417
|
-
if (
|
|
36755
|
+
if (existsSync5(candidate))
|
|
36418
36756
|
return candidate;
|
|
36419
36757
|
return "bsk";
|
|
36420
36758
|
}
|
|
36421
36759
|
var NO_BREAKAWAY = /Job Object/;
|
|
36422
36760
|
function windowsDaemonTaskName(home) {
|
|
36423
|
-
return `bsk-daemon-${createHash2("sha256").update(
|
|
36761
|
+
return `bsk-daemon-${createHash2("sha256").update(path19.resolve(home).toLowerCase()).digest("hex").slice(0, 12)}`;
|
|
36424
36762
|
}
|
|
36425
36763
|
var powershellLiteral = (value) => `'${value.replace(/['\u2018\u2019\u201A\u201B]/g, (quote) => quote + quote)}'`;
|
|
36426
|
-
function
|
|
36427
|
-
|
|
36764
|
+
function daemonEnv(env, home) {
|
|
36765
|
+
return {
|
|
36766
|
+
...env,
|
|
36767
|
+
BSK_HOME: home,
|
|
36768
|
+
BSK_AUTO_UPDATE: env["BSK_AUTO_UPDATE"] ?? "off",
|
|
36769
|
+
BSK_UPDATE_MANIFEST_URL: env["BSK_UPDATE_MANIFEST_URL"] ?? BSK_PINNED_MANIFEST_URL
|
|
36770
|
+
};
|
|
36771
|
+
}
|
|
36772
|
+
function windowsDaemonLaunch(env, bskBin) {
|
|
36773
|
+
const assignments = ["BSK_HOME", "BSK_AUTO_UPDATE", "BSK_UPDATE_MANIFEST_URL"].map((name) => `$env:${name} = ${powershellLiteral(env[name] ?? "")}; `).join("");
|
|
36774
|
+
const script = `${assignments}& ${powershellLiteral(bskBin)} daemon start --foreground; exit $LASTEXITCODE`;
|
|
36428
36775
|
return `--headless "${windowsSystemTool("WindowsPowerShell\\v1.0\\powershell.exe")}" -NoProfile -NonInteractive -EncodedCommand ${Buffer.from(script, "utf16le").toString("base64")}`;
|
|
36429
36776
|
}
|
|
36430
36777
|
function startDaemonInWindowsTask({
|
|
36431
36778
|
home,
|
|
36779
|
+
env,
|
|
36432
36780
|
bskBin,
|
|
36433
36781
|
timeoutMs
|
|
36434
36782
|
}) {
|
|
@@ -36442,7 +36790,7 @@ function startDaemonInWindowsTask({
|
|
|
36442
36790
|
env: {
|
|
36443
36791
|
...process.env,
|
|
36444
36792
|
BSK_TASK_NAME: windowsDaemonTaskName(home),
|
|
36445
|
-
BSK_TASK_ARGUMENT: windowsDaemonLaunch(
|
|
36793
|
+
BSK_TASK_ARGUMENT: windowsDaemonLaunch(env, bskBin)
|
|
36446
36794
|
},
|
|
36447
36795
|
timeoutMs,
|
|
36448
36796
|
label: "registering the bsk daemon task"
|
|
@@ -36450,7 +36798,7 @@ function startDaemonInWindowsTask({
|
|
|
36450
36798
|
}
|
|
36451
36799
|
function runToExit(command, args, { env, timeoutMs, label }) {
|
|
36452
36800
|
return new Promise((resolve, reject) => {
|
|
36453
|
-
const child =
|
|
36801
|
+
const child = spawn7(command, args, { env, stdio: ["ignore", "pipe", "pipe"], windowsHide: true });
|
|
36454
36802
|
let output = "";
|
|
36455
36803
|
const keep = (chunk) => {
|
|
36456
36804
|
output = (output + chunk).slice(-4096);
|
|
@@ -36477,8 +36825,9 @@ async function startDaemonWithCli({
|
|
|
36477
36825
|
bskBin = findBskBinary(env),
|
|
36478
36826
|
timeoutMs = 20000
|
|
36479
36827
|
} = {}) {
|
|
36828
|
+
const daemon = daemonEnv(env, home);
|
|
36480
36829
|
const status = await runToExit(bskBin, ["status", "--json"], {
|
|
36481
|
-
env:
|
|
36830
|
+
env: daemon,
|
|
36482
36831
|
timeoutMs,
|
|
36483
36832
|
label: "bsk status"
|
|
36484
36833
|
});
|
|
@@ -36487,7 +36836,7 @@ async function startDaemonWithCli({
|
|
|
36487
36836
|
if (process.platform === "win32" && NO_BREAKAWAY.test(status.output)) {
|
|
36488
36837
|
if (home === undefined)
|
|
36489
36838
|
throw new TypeError("startDaemonWithCli needs a home to register the Windows daemon task");
|
|
36490
|
-
const task = await startDaemonInWindowsTask({ home, bskBin, timeoutMs });
|
|
36839
|
+
const task = await startDaemonInWindowsTask({ home, env: daemon, bskBin, timeoutMs });
|
|
36491
36840
|
if (task.code === 0)
|
|
36492
36841
|
return;
|
|
36493
36842
|
throw new Error(`${status.output}; registering the bsk daemon task exited with ${task.code}${task.output ? `: ${task.output}` : ""}`);
|
|
@@ -36522,7 +36871,7 @@ function ownBudgetMs(params) {
|
|
|
36522
36871
|
var PROBE_TIMEOUT_MS = 2000;
|
|
36523
36872
|
function defaultSocketPath(home, env = process.env) {
|
|
36524
36873
|
if (process.platform !== "win32")
|
|
36525
|
-
return
|
|
36874
|
+
return path20.join(home, "run", "daemon.sock");
|
|
36526
36875
|
return `\\\\.\\pipe\\bsk-daemon-${rustStrHash(env["USERNAME"] ?? "default", home)}`;
|
|
36527
36876
|
}
|
|
36528
36877
|
function rustStrHash(...values) {
|
|
@@ -36562,9 +36911,9 @@ function rustStrHash(...values) {
|
|
|
36562
36911
|
}
|
|
36563
36912
|
function socketExists(sockPath) {
|
|
36564
36913
|
if (process.platform !== "win32")
|
|
36565
|
-
return
|
|
36914
|
+
return existsSync6(sockPath);
|
|
36566
36915
|
try {
|
|
36567
|
-
return readdirSync("\\\\.\\pipe\\").includes(
|
|
36916
|
+
return readdirSync("\\\\.\\pipe\\").includes(path20.win32.basename(sockPath));
|
|
36568
36917
|
} catch {
|
|
36569
36918
|
return false;
|
|
36570
36919
|
}
|
|
@@ -37186,7 +37535,7 @@ function isTabGroupingExtension(browser) {
|
|
|
37186
37535
|
}
|
|
37187
37536
|
var TAB_GROUPING_EXTENSION_STEP = `Update the BrowserSkill extension to 0.4.1 or later (chrome://extensions -> Developer mode -> Update, or wait for the store update). Version 0.4.0 puts each task's tabs into a "BrowserSkill" tab group that the browser saves and syncs, so the group stays after the task ends; delete any saved "BrowserSkill" tab groups by hand.`;
|
|
37188
37537
|
function outdatedError(browser) {
|
|
37189
|
-
return new BskRpcError("extension_outdated", `the BrowserSkill extension in ${
|
|
37538
|
+
return new BskRpcError("extension_outdated", `the BrowserSkill extension in ${textField(browser, "browser_name") ?? "the browser"} [${textField(browser, "instance_id") ?? "unknown id"}] is 0.4.0, which leaves a "BrowserSkill" tab group behind in the user's browser after each task. ${TAB_GROUPING_EXTENSION_STEP}`);
|
|
37190
37539
|
}
|
|
37191
37540
|
function namesBrowser(b, browser) {
|
|
37192
37541
|
return readProperty(b, "instance_id") === browser || Boolean(readProperty(b, "label") && readProperty(b, "label") === browser);
|
|
@@ -37220,10 +37569,40 @@ function resolveBrowser(browser, browsers) {
|
|
|
37220
37569
|
return browser;
|
|
37221
37570
|
const named = browsers.filter((b) => readProperty(b, "browser_name") === browser);
|
|
37222
37571
|
if (named.length > 1) {
|
|
37223
|
-
throw new BskRpcError("invalid_params", `browser "${browser}" matches ${named.length} connected browsers (${named.map((b) =>
|
|
37572
|
+
throw new BskRpcError("invalid_params", `browser "${browser}" matches ${named.length} connected browsers (${named.map((b) => textField(b, "instance_id") ?? "unknown id").join(", ")}); pass the instance id instead`);
|
|
37224
37573
|
}
|
|
37225
37574
|
return named.length === 1 ? readProperty(named[0], "instance_id") : browser;
|
|
37226
37575
|
}
|
|
37576
|
+
function textField(b, key) {
|
|
37577
|
+
const value = optionalProperty(b, key);
|
|
37578
|
+
if (typeof value === "string")
|
|
37579
|
+
return value;
|
|
37580
|
+
if (typeof value === "number" && Number.isFinite(value))
|
|
37581
|
+
return String(value);
|
|
37582
|
+
return;
|
|
37583
|
+
}
|
|
37584
|
+
function describeBrowser(b) {
|
|
37585
|
+
const name = textField(b, "browser_name");
|
|
37586
|
+
const parts = [
|
|
37587
|
+
`${textField(b, "label") || name || "browser"} [${textField(b, "instance_id") ?? "unknown id"}]`,
|
|
37588
|
+
[name, textField(b, "browser_version")].filter(Boolean).join(" ")
|
|
37589
|
+
];
|
|
37590
|
+
const sessions = optionalProperty(b, "session_count");
|
|
37591
|
+
if (typeof sessions === "number" && Number.isFinite(sessions))
|
|
37592
|
+
parts.push(`${sessions} session${sessions === 1 ? "" : "s"}`);
|
|
37593
|
+
const since = optionalProperty(b, "connected_at_ms");
|
|
37594
|
+
if (typeof since === "number" && Number.isFinite(since) && Math.abs(since) <= 8640000000000000) {
|
|
37595
|
+
parts.push(`online since ${new Date(since).toISOString()}`);
|
|
37596
|
+
}
|
|
37597
|
+
return parts.filter(Boolean).join(", ");
|
|
37598
|
+
}
|
|
37599
|
+
function multipleBrowsersError(error, statusBrowsers) {
|
|
37600
|
+
const listed = optionalProperty(error.data, "browsers");
|
|
37601
|
+
const browsers = Array.isArray(listed) ? listed : statusBrowsers;
|
|
37602
|
+
const data = error.data;
|
|
37603
|
+
const extra = typeof data === "object" && data !== null ? data : {};
|
|
37604
|
+
return new BskRpcError(error.code, `more than one browser is online; pass browser: "<instance_id or label>" to connectBrowserSkill(). Online: ${browsers.map(describeBrowser).join("; ")}. Tabs are only visible inside a session: ask the user which browser holds the page, or open a session per browser and read tabList({ scope: "user" }) before stopping it.`, { ...extra, browsers });
|
|
37605
|
+
}
|
|
37227
37606
|
async function connectBrowserSkill({
|
|
37228
37607
|
client,
|
|
37229
37608
|
home,
|
|
@@ -37244,13 +37623,22 @@ async function connectBrowserSkill({
|
|
|
37244
37623
|
if (browsers.length === 0) {
|
|
37245
37624
|
throw new BskRpcError("no_browser_connected", "the BrowserSkill daemon is up but no browser extension is connected; open the browser that has the BrowserSkill extension enabled (bskDoctor() explains the remaining step); never substitute another browser for the user's without telling them");
|
|
37246
37625
|
}
|
|
37247
|
-
const
|
|
37248
|
-
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
|
|
37252
|
-
|
|
37253
|
-
|
|
37626
|
+
const browserInstanceId = chooseBrowser(browser, browsers);
|
|
37627
|
+
let started;
|
|
37628
|
+
try {
|
|
37629
|
+
started = await ipc.call("session.start", compact({
|
|
37630
|
+
task_name: name,
|
|
37631
|
+
browser_instance_id: browserInstanceId,
|
|
37632
|
+
width,
|
|
37633
|
+
height,
|
|
37634
|
+
focused
|
|
37635
|
+
}), { idPrefix: "session-start" });
|
|
37636
|
+
} catch (error) {
|
|
37637
|
+
if (error instanceof BskRpcError && error.code === "multiple_browsers_online") {
|
|
37638
|
+
throw multipleBrowsersError(error, browsers);
|
|
37639
|
+
}
|
|
37640
|
+
throw error;
|
|
37641
|
+
}
|
|
37254
37642
|
return new BskSession(ipc, {
|
|
37255
37643
|
sessionId: readProperty(started, "session_id"),
|
|
37256
37644
|
browserInstanceId: readProperty(started, "browser_instance_id") ?? null,
|
|
@@ -37324,7 +37712,7 @@ import { randomBytes as randomBytes2 } from "node:crypto";
|
|
|
37324
37712
|
|
|
37325
37713
|
// src/aside/cli-contract.ts
|
|
37326
37714
|
var SCRIPT_AT_EOF = /piped stdin runs as one script/i;
|
|
37327
|
-
var LISTS_REPL_TOOL = /^\s*repl\
|
|
37715
|
+
var LISTS_REPL_TOOL = /^\s*repl(?:[ \t]|$)/m;
|
|
37328
37716
|
function captureCli({
|
|
37329
37717
|
spawn,
|
|
37330
37718
|
command,
|
|
@@ -37392,6 +37780,7 @@ class AsideReplError extends Error {
|
|
|
37392
37780
|
|
|
37393
37781
|
// src/aside/line-transport.ts
|
|
37394
37782
|
var CLOSE_TIMEOUT_MS = 5000;
|
|
37783
|
+
var KILL_GRACE_MS = 2000;
|
|
37395
37784
|
var PROMPT = "repl > ";
|
|
37396
37785
|
var MARKER = /^\[(ok|error) \| \d+ms\]$/;
|
|
37397
37786
|
var ANSI = /\x1B\[[0-9;?]*[ -/]*[@-~]/g;
|
|
@@ -37404,11 +37793,14 @@ class LineTransport {
|
|
|
37404
37793
|
#lines = [];
|
|
37405
37794
|
#waiter = null;
|
|
37406
37795
|
#closed = false;
|
|
37796
|
+
#exited = false;
|
|
37797
|
+
#terminated = false;
|
|
37407
37798
|
#exit;
|
|
37408
37799
|
constructor(child) {
|
|
37409
37800
|
this.#child = child;
|
|
37410
37801
|
this.#exit = new Promise((resolve) => child.once("exit", (code, signal) => {
|
|
37411
37802
|
this.#closed = true;
|
|
37803
|
+
this.#exited = true;
|
|
37412
37804
|
this.#settle(new AsideReplError("repl_closed", `aside repl exited (code ${code}, signal ${signal})`, {
|
|
37413
37805
|
output: this.#lines.splice(0)
|
|
37414
37806
|
}));
|
|
@@ -37456,20 +37848,34 @@ class LineTransport {
|
|
|
37456
37848
|
return body;
|
|
37457
37849
|
}
|
|
37458
37850
|
async close() {
|
|
37459
|
-
|
|
37851
|
+
this.#closed = true;
|
|
37852
|
+
if (this.#exited)
|
|
37460
37853
|
return;
|
|
37461
|
-
this.#
|
|
37854
|
+
if (!this.#terminated) {
|
|
37855
|
+
this.#child.stdin.end(`exit
|
|
37462
37856
|
`);
|
|
37857
|
+
if (await this.#exitsWithin(CLOSE_TIMEOUT_MS))
|
|
37858
|
+
return;
|
|
37859
|
+
this.#terminate();
|
|
37860
|
+
}
|
|
37861
|
+
if (await this.#exitsWithin(KILL_GRACE_MS))
|
|
37862
|
+
return;
|
|
37863
|
+
this.#child.kill("SIGKILL");
|
|
37864
|
+
await this.#exit;
|
|
37865
|
+
}
|
|
37866
|
+
async#exitsWithin(ms) {
|
|
37463
37867
|
let timer;
|
|
37464
37868
|
const timedOut = new Promise((resolve) => {
|
|
37465
|
-
timer = setTimeout(() => resolve(
|
|
37869
|
+
timer = setTimeout(() => resolve(false), ms);
|
|
37466
37870
|
});
|
|
37467
|
-
const
|
|
37871
|
+
const exited = await Promise.race([this.#exit.then(() => true), timedOut]);
|
|
37468
37872
|
clearTimeout(timer);
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
|
|
37472
|
-
|
|
37873
|
+
return exited;
|
|
37874
|
+
}
|
|
37875
|
+
#terminate() {
|
|
37876
|
+
this.#closed = true;
|
|
37877
|
+
this.#terminated = true;
|
|
37878
|
+
this.#child.kill();
|
|
37473
37879
|
}
|
|
37474
37880
|
#onData(chunk) {
|
|
37475
37881
|
this.#buffer += chunk;
|
|
@@ -37490,7 +37896,7 @@ class LineTransport {
|
|
|
37490
37896
|
this.#waiter = null;
|
|
37491
37897
|
const output = this.#lines.splice(0);
|
|
37492
37898
|
reject(new AsideReplError(timeoutCode, `aside repl did not answer within ${timeoutMs} ms`, { output }));
|
|
37493
|
-
this.#
|
|
37899
|
+
this.#terminate();
|
|
37494
37900
|
}, timeoutMs);
|
|
37495
37901
|
this.#waiter = { isDone, resolve, reject, timer };
|
|
37496
37902
|
this.#check();
|
|
@@ -37518,7 +37924,7 @@ class LineTransport {
|
|
|
37518
37924
|
// src/aside/mcp-transport.ts
|
|
37519
37925
|
var PROTOCOL_VERSION = "2025-06-18";
|
|
37520
37926
|
var CLOSE_TIMEOUT_MS2 = 5000;
|
|
37521
|
-
var
|
|
37927
|
+
var KILL_GRACE_MS2 = 2000;
|
|
37522
37928
|
var STDERR_LINES = 50;
|
|
37523
37929
|
var optional2 = (value, key) => value === null || value === undefined ? undefined : readProperty(value, key);
|
|
37524
37930
|
var textLines = (part) => {
|
|
@@ -37602,7 +38008,7 @@ class McpTransport {
|
|
|
37602
38008
|
return;
|
|
37603
38009
|
this.#terminate();
|
|
37604
38010
|
}
|
|
37605
|
-
if (await this.#exitsWithin(
|
|
38011
|
+
if (await this.#exitsWithin(KILL_GRACE_MS2))
|
|
37606
38012
|
return;
|
|
37607
38013
|
this.#child.kill("SIGKILL");
|
|
37608
38014
|
await this.#exit;
|
|
@@ -37696,117 +38102,6 @@ import { homedir as homedir6 } from "node:os";
|
|
|
37696
38102
|
import path22 from "node:path";
|
|
37697
38103
|
import { spawn as spawn8 } from "node:child_process";
|
|
37698
38104
|
|
|
37699
|
-
// src/bsk/install-cli.ts
|
|
37700
|
-
import { existsSync as existsSync6, readFileSync as readFileSync5, rmSync as rmSync3, writeFileSync as writeFileSync3 } from "node:fs";
|
|
37701
|
-
import { homedir as homedir4 } from "node:os";
|
|
37702
|
-
import path20 from "node:path";
|
|
37703
|
-
import { spawn as spawn7 } from "node:child_process";
|
|
37704
|
-
var INSTALL_SH = "https://raw.githubusercontent.com/Tencent/BrowserSkill/main/install.sh";
|
|
37705
|
-
var INSTALL_PS1 = "https://raw.githubusercontent.com/Tencent/BrowserSkill/main/install.ps1";
|
|
37706
|
-
var RC_FILES = [".zshrc", ".bashrc", ".profile"];
|
|
37707
|
-
function windowsPowerShellEnv(env) {
|
|
37708
|
-
const key = Object.keys(process.env).find((name) => name.toUpperCase() === "PSMODULEPATH");
|
|
37709
|
-
if (!key)
|
|
37710
|
-
return env;
|
|
37711
|
-
const value = process.env[key];
|
|
37712
|
-
if (value === undefined)
|
|
37713
|
-
throw new TypeError(`${key} has no value`);
|
|
37714
|
-
const kept = value.split(";").filter((entry) => entry && !/[\\/]PowerShell[\\/]/i.test(entry));
|
|
37715
|
-
return { ...env, [key]: kept.length > 0 ? kept.join(";") : undefined };
|
|
37716
|
-
}
|
|
37717
|
-
function cliInstallCommand({
|
|
37718
|
-
platform = process.platform,
|
|
37719
|
-
installDir,
|
|
37720
|
-
version
|
|
37721
|
-
} = {}) {
|
|
37722
|
-
const env = { BSK_INSTALL_DIR: installDir };
|
|
37723
|
-
if (version)
|
|
37724
|
-
env["BSK_VERSION"] = version;
|
|
37725
|
-
if (platform === "win32") {
|
|
37726
|
-
return {
|
|
37727
|
-
command: windowsSystemTool("WindowsPowerShell\\v1.0\\powershell.exe"),
|
|
37728
|
-
args: ["-NoProfile", "-ExecutionPolicy", "Bypass", "-Command", `irm ${INSTALL_PS1} | iex`],
|
|
37729
|
-
env: windowsPowerShellEnv(env)
|
|
37730
|
-
};
|
|
37731
|
-
}
|
|
37732
|
-
return { command: "sh", args: ["-c", `curl -fsSL ${INSTALL_SH} | sh`], env };
|
|
37733
|
-
}
|
|
37734
|
-
function runDefault(command, args, env) {
|
|
37735
|
-
return new Promise((resolve) => {
|
|
37736
|
-
const child = spawn7(command, args, {
|
|
37737
|
-
env: { ...process.env, ...env },
|
|
37738
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
37739
|
-
windowsHide: true
|
|
37740
|
-
});
|
|
37741
|
-
let stdout = "", stderr = "";
|
|
37742
|
-
child.stdout.on("data", (c) => {
|
|
37743
|
-
stdout = (stdout + c).slice(-8192);
|
|
37744
|
-
});
|
|
37745
|
-
child.stderr.on("data", (c) => {
|
|
37746
|
-
stderr = (stderr + c).slice(-8192);
|
|
37747
|
-
});
|
|
37748
|
-
child.on("error", (error) => resolve({ code: -1, stdout, stderr: error.message }));
|
|
37749
|
-
child.on("exit", (code) => resolve({ code, stdout, stderr }));
|
|
37750
|
-
});
|
|
37751
|
-
}
|
|
37752
|
-
function snapshotRcFiles(home) {
|
|
37753
|
-
const snapshot = new Map;
|
|
37754
|
-
for (const name of RC_FILES) {
|
|
37755
|
-
const file = path20.join(home, name);
|
|
37756
|
-
snapshot.set(file, existsSync6(file) ? readFileSync5(file) : null);
|
|
37757
|
-
}
|
|
37758
|
-
return snapshot;
|
|
37759
|
-
}
|
|
37760
|
-
function restoreRcFiles(snapshot) {
|
|
37761
|
-
const restored = [];
|
|
37762
|
-
for (const [file, before] of snapshot) {
|
|
37763
|
-
const after = existsSync6(file) ? readFileSync5(file) : null;
|
|
37764
|
-
if (before === null && after === null)
|
|
37765
|
-
continue;
|
|
37766
|
-
if (before !== null && after !== null && before.equals(after))
|
|
37767
|
-
continue;
|
|
37768
|
-
if (before === null)
|
|
37769
|
-
rmSync3(file, { force: true });
|
|
37770
|
-
else
|
|
37771
|
-
writeFileSync3(file, before);
|
|
37772
|
-
restored.push(file);
|
|
37773
|
-
}
|
|
37774
|
-
return restored;
|
|
37775
|
-
}
|
|
37776
|
-
async function installBskCli({
|
|
37777
|
-
platform = process.platform,
|
|
37778
|
-
home = homedir4(),
|
|
37779
|
-
installDir = path20.join(home, ".local", "bin"),
|
|
37780
|
-
version,
|
|
37781
|
-
run = runDefault
|
|
37782
|
-
} = {}) {
|
|
37783
|
-
const spec = cliInstallCommand({ platform, installDir, version });
|
|
37784
|
-
const rcBefore = platform === "win32" ? new Map : snapshotRcFiles(home);
|
|
37785
|
-
const result = await run(spec.command, spec.args, spec.env);
|
|
37786
|
-
const restoredRcFiles = restoreRcFiles(rcBefore);
|
|
37787
|
-
const bskBin = path20.join(installDir, platform === "win32" ? "bsk.exe" : "bsk");
|
|
37788
|
-
const installed = result.code === 0 && existsSync6(bskBin);
|
|
37789
|
-
return {
|
|
37790
|
-
installed,
|
|
37791
|
-
bskBin: installed ? bskBin : null,
|
|
37792
|
-
code: result.code,
|
|
37793
|
-
stdout: result.stdout,
|
|
37794
|
-
stderr: result.stderr,
|
|
37795
|
-
restoredRcFiles
|
|
37796
|
-
};
|
|
37797
|
-
}
|
|
37798
|
-
function cliVersionDefault(bskBin) {
|
|
37799
|
-
return new Promise((resolve) => {
|
|
37800
|
-
const child = spawn7(bskBin, ["--version"], { stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
37801
|
-
let out = "";
|
|
37802
|
-
child.stdout.on("data", (c) => {
|
|
37803
|
-
out += c;
|
|
37804
|
-
});
|
|
37805
|
-
child.on("error", () => resolve(null));
|
|
37806
|
-
child.on("exit", (code) => resolve(code === 0 ? out.trim() : null));
|
|
37807
|
-
});
|
|
37808
|
-
}
|
|
37809
|
-
|
|
37810
38105
|
// src/aside/cli-binary.ts
|
|
37811
38106
|
import { existsSync as existsSync7 } from "node:fs";
|
|
37812
38107
|
import { homedir as homedir5 } from "node:os";
|
|
@@ -38112,7 +38407,7 @@ async function connectAside({
|
|
|
38112
38407
|
try {
|
|
38113
38408
|
return await session.ready(startTimeoutMs);
|
|
38114
38409
|
} catch (error) {
|
|
38115
|
-
|
|
38410
|
+
await session.close();
|
|
38116
38411
|
if (!(error instanceof AsideReplError) || error.code !== "repl_start_timeout")
|
|
38117
38412
|
throw error;
|
|
38118
38413
|
const version = await asideCliVersion({ ...cli, timeoutMs: CLI_PROBE_TIMEOUT_MS });
|
|
@@ -38476,7 +38771,9 @@ async function registerExternalExtension({
|
|
|
38476
38771
|
writeFile = writeFileSync4,
|
|
38477
38772
|
readFile = readFileSync7,
|
|
38478
38773
|
runReg = runRegDefault
|
|
38479
|
-
}) {
|
|
38774
|
+
} = {}) {
|
|
38775
|
+
if (browser === undefined)
|
|
38776
|
+
throw readProperty(browser, "store");
|
|
38480
38777
|
const entry = externalExtensionEntry({ platform, browser });
|
|
38481
38778
|
const id = BROWSERSKILL_EXTENSION_IDS[browser.store];
|
|
38482
38779
|
const label = browser.label ?? browser.id;
|
|
@@ -38533,7 +38830,9 @@ async function unregisterExternalExtension({
|
|
|
38533
38830
|
platform = process.platform,
|
|
38534
38831
|
browser,
|
|
38535
38832
|
runReg = runRegDefault
|
|
38536
|
-
}) {
|
|
38833
|
+
} = {}) {
|
|
38834
|
+
if (browser === undefined)
|
|
38835
|
+
throw readProperty(browser, "store");
|
|
38537
38836
|
const entry = externalExtensionEntry({ platform, browser });
|
|
38538
38837
|
if (entry.kind === "store")
|
|
38539
38838
|
return { ...entry, removed: false };
|
|
@@ -39138,10 +39437,22 @@ async function connectBrowser({
|
|
|
39138
39437
|
attached: opened.map((entry) => entry.engine),
|
|
39139
39438
|
crossCheck: extra,
|
|
39140
39439
|
closeAll: async () => {
|
|
39141
|
-
await Promise.all(opened.map(({ handle }) =>
|
|
39440
|
+
const failures = (await Promise.all(opened.map(async ({ engine, handle }) => {
|
|
39441
|
+
try {
|
|
39442
|
+
await closeHandle(handle);
|
|
39443
|
+
return null;
|
|
39444
|
+
} catch (cause) {
|
|
39445
|
+
return new Error(`${engine} failed to close: ${reasonOf(cause)}`, { cause });
|
|
39446
|
+
}
|
|
39447
|
+
}))).filter((error) => error !== null);
|
|
39448
|
+
if (failures.length)
|
|
39449
|
+
throw new AggregateError(failures, failures.map((error) => error.message).join("; "));
|
|
39142
39450
|
}
|
|
39143
39451
|
};
|
|
39144
39452
|
}
|
|
39453
|
+
|
|
39454
|
+
// src/index.ts
|
|
39455
|
+
/*! omowright | MIT License | Copyright (c) 2026 Yeongyu Kim | https://github.com/code-yeongyu/omowright */
|
|
39145
39456
|
export {
|
|
39146
39457
|
AgentTabManager,
|
|
39147
39458
|
AsideReplError,
|