@open-wa/wa-automate 5.11.1 → 5.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{cli-runtime-C_VOjxxp.cjs → cli-runtime-B3ABNLz4.cjs} +356 -1
- package/dist/cli-runtime-B3ABNLz4.cjs.map +1 -0
- package/dist/cli-runtime-CzBEJMQd.d.cts.map +1 -1
- package/dist/cli.cjs +1 -1
- package/dist/index.cjs +1 -1
- package/package.json +16 -15
- package/dist/cli-runtime-C_VOjxxp.cjs.map +0 -1
|
@@ -34,6 +34,8 @@ let _open_wa_driver_interface = require("@open-wa/driver-interface");
|
|
|
34
34
|
let _open_wa_create_browser = require("@open-wa/create/browser");
|
|
35
35
|
let _open_wa_schema = require("@open-wa/schema");
|
|
36
36
|
let node_url = require("node:url");
|
|
37
|
+
let ws = require("ws");
|
|
38
|
+
ws = __toESM(ws, 1);
|
|
37
39
|
let _open_wa_runtime_core = require("@open-wa/runtime-core");
|
|
38
40
|
let _open_wa_runtime_node = require("@open-wa/runtime-node");
|
|
39
41
|
//#region src/server/hono-server.ts
|
|
@@ -523,7 +525,277 @@ async function create(options = {}) {
|
|
|
523
525
|
}
|
|
524
526
|
}
|
|
525
527
|
//#endregion
|
|
528
|
+
//#region src/tunnel-client.ts
|
|
529
|
+
/** Largest body slice per frame, before base64; matches the proxy. */
|
|
530
|
+
const BODY_CHUNK_BYTES = 262144;
|
|
531
|
+
/** Sent by the proxy when another instance of the same session connects. */
|
|
532
|
+
const REPLACED_CLOSE_CODE = 4001;
|
|
533
|
+
const HEARTBEAT_MS = 2e4;
|
|
534
|
+
const MAX_BUFFERED_BYTES = 4194304;
|
|
535
|
+
const HOP_BY_HOP = /* @__PURE__ */ new Set([
|
|
536
|
+
"connection",
|
|
537
|
+
"keep-alive",
|
|
538
|
+
"proxy-connection",
|
|
539
|
+
"transfer-encoding",
|
|
540
|
+
"upgrade",
|
|
541
|
+
"te",
|
|
542
|
+
"trailer",
|
|
543
|
+
"host",
|
|
544
|
+
"content-length",
|
|
545
|
+
"expect"
|
|
546
|
+
]);
|
|
547
|
+
var TunnelClient = class {
|
|
548
|
+
options;
|
|
549
|
+
ws = null;
|
|
550
|
+
streams = /* @__PURE__ */ new Map();
|
|
551
|
+
heartbeat = null;
|
|
552
|
+
lastPong = 0;
|
|
553
|
+
replaced = false;
|
|
554
|
+
retryMs = 3e3;
|
|
555
|
+
reconnectTimeout = null;
|
|
556
|
+
isDestroyed = false;
|
|
557
|
+
constructor(options) {
|
|
558
|
+
this.options = options;
|
|
559
|
+
}
|
|
560
|
+
log(level, message) {
|
|
561
|
+
if (this.options.log) {
|
|
562
|
+
this.options.log(level, message);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
if (level === "warn") {
|
|
566
|
+
console.warn(message);
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
569
|
+
if (level === "error") {
|
|
570
|
+
console.error(message);
|
|
571
|
+
return;
|
|
572
|
+
}
|
|
573
|
+
console.log(message);
|
|
574
|
+
}
|
|
575
|
+
connect() {
|
|
576
|
+
if (this.isDestroyed) return;
|
|
577
|
+
const base = this.options.proxyHost.replace(/^http/, "ws").replace(/\/+$/, "");
|
|
578
|
+
const { license } = this.options;
|
|
579
|
+
const connectUrl = license ? `${base}/upstream` : `${base}/sessions/${encodeURIComponent(this.options.sessionId)}/upstream`;
|
|
580
|
+
const headers = license ? {
|
|
581
|
+
Authorization: `License ${license.key}`,
|
|
582
|
+
"x-owa-number": license.number
|
|
583
|
+
} : { Authorization: `Bearer ${this.options.proxyToken}` };
|
|
584
|
+
this.ws = new ws.default(connectUrl, { headers });
|
|
585
|
+
this.ws.on("unexpected-response", (req, res) => {
|
|
586
|
+
let body = "";
|
|
587
|
+
res.on("data", (chunk) => {
|
|
588
|
+
body += chunk.toString();
|
|
589
|
+
});
|
|
590
|
+
res.on("end", () => {
|
|
591
|
+
this.log("error", `[TunnelClient] The proxy refused the connection (${res.statusCode}): ${body.slice(0, 200)}`);
|
|
592
|
+
this.retryMs = res.statusCode === 401 || res.statusCode === 403 ? 6e4 : 3e3;
|
|
593
|
+
req.destroy();
|
|
594
|
+
});
|
|
595
|
+
});
|
|
596
|
+
this.ws.on("open", () => {
|
|
597
|
+
this.retryMs = 3e3;
|
|
598
|
+
this.log("info", `[TunnelClient] Connected upstream for session ${this.options.sessionId}`);
|
|
599
|
+
this.lastPong = Date.now();
|
|
600
|
+
this.heartbeat = setInterval(() => {
|
|
601
|
+
if (Date.now() - this.lastPong > 45e3) {
|
|
602
|
+
this.log("warn", "[TunnelClient] No answer from the proxy; reconnecting");
|
|
603
|
+
this.ws?.terminate();
|
|
604
|
+
return;
|
|
605
|
+
}
|
|
606
|
+
this.send({ type: "ping" });
|
|
607
|
+
}, HEARTBEAT_MS);
|
|
608
|
+
});
|
|
609
|
+
this.ws.on("message", (data) => {
|
|
610
|
+
let msg;
|
|
611
|
+
try {
|
|
612
|
+
msg = JSON.parse(data.toString("utf-8"));
|
|
613
|
+
} catch {
|
|
614
|
+
return;
|
|
615
|
+
}
|
|
616
|
+
switch (msg.type) {
|
|
617
|
+
case "ping":
|
|
618
|
+
this.send({ type: "pong" });
|
|
619
|
+
return;
|
|
620
|
+
case "pong":
|
|
621
|
+
this.lastPong = Date.now();
|
|
622
|
+
return;
|
|
623
|
+
case "welcome":
|
|
624
|
+
if (typeof msg.address === "string") {
|
|
625
|
+
this.log("info", `[TunnelClient] Public address: ${msg.address} (MCP: ${msg.address}/mcp)`);
|
|
626
|
+
this.options.onAddress?.(msg.address);
|
|
627
|
+
}
|
|
628
|
+
return;
|
|
629
|
+
case "replaced":
|
|
630
|
+
this.replaced = true;
|
|
631
|
+
this.log("error", `[TunnelClient] Another instance connected as session ${this.options.sessionId}; this one stopped forwarding. Restart it to take over again.`);
|
|
632
|
+
this.ws?.close();
|
|
633
|
+
return;
|
|
634
|
+
case "req_start":
|
|
635
|
+
this.handleRequest(msg);
|
|
636
|
+
return;
|
|
637
|
+
case "req_body":
|
|
638
|
+
this.streams.get(msg.id)?.body?.enqueue(new Uint8Array(Buffer.from(msg.chunk, "base64")));
|
|
639
|
+
return;
|
|
640
|
+
case "req_end":
|
|
641
|
+
this.streams.get(msg.id)?.body?.close();
|
|
642
|
+
return;
|
|
643
|
+
case "req_abort": {
|
|
644
|
+
const stream = this.streams.get(msg.id);
|
|
645
|
+
stream?.abort.abort();
|
|
646
|
+
try {
|
|
647
|
+
stream?.body?.error(new Error(msg.error ?? "Aborted"));
|
|
648
|
+
} catch {}
|
|
649
|
+
this.streams.delete(msg.id);
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
case "rpc_request":
|
|
653
|
+
this.handleRpcAsHttp(msg);
|
|
654
|
+
return;
|
|
655
|
+
}
|
|
656
|
+
});
|
|
657
|
+
this.ws.on("close", (code) => {
|
|
658
|
+
for (const stream of this.streams.values()) stream.abort.abort();
|
|
659
|
+
this.streams.clear();
|
|
660
|
+
if (this.heartbeat) clearInterval(this.heartbeat);
|
|
661
|
+
if (this.replaced || code === REPLACED_CLOSE_CODE) return;
|
|
662
|
+
if (!this.isDestroyed) {
|
|
663
|
+
this.log("warn", `[TunnelClient] Disconnected. Reconnecting in ${this.retryMs / 1e3}s...`);
|
|
664
|
+
this.reconnectTimeout = setTimeout(() => this.connect(), this.retryMs);
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
this.ws.on("error", (err) => {
|
|
668
|
+
this.log("error", `[TunnelClient] WebSocket error: ${err.message}`);
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
send(message) {
|
|
672
|
+
if (this.ws?.readyState === ws.default.OPEN) this.ws.send(JSON.stringify(message));
|
|
673
|
+
}
|
|
674
|
+
/** Waits while the socket has a large send backlog, so a big download does not fill memory. */
|
|
675
|
+
async drain() {
|
|
676
|
+
while (this.ws && this.ws.readyState === ws.default.OPEN && this.ws.bufferedAmount > MAX_BUFFERED_BYTES) await new Promise((resolve) => setTimeout(resolve, 10));
|
|
677
|
+
}
|
|
678
|
+
async handleRequest(msg) {
|
|
679
|
+
const abort = new AbortController();
|
|
680
|
+
const stream = { abort };
|
|
681
|
+
this.streams.set(msg.id, stream);
|
|
682
|
+
const body = msg.hasBody ? new ReadableStream({ start: (controller) => {
|
|
683
|
+
stream.body = controller;
|
|
684
|
+
} }) : void 0;
|
|
685
|
+
const headers = new Headers();
|
|
686
|
+
for (const [key, value] of msg.headers) if (!HOP_BY_HOP.has(key.toLowerCase())) headers.append(key, value);
|
|
687
|
+
let started = false;
|
|
688
|
+
try {
|
|
689
|
+
const res = await fetch(`http://127.0.0.1:${this.options.localSessionPort}${msg.path}`, {
|
|
690
|
+
method: msg.method,
|
|
691
|
+
headers,
|
|
692
|
+
body,
|
|
693
|
+
signal: abort.signal,
|
|
694
|
+
redirect: "manual",
|
|
695
|
+
...body ? { duplex: "half" } : {}
|
|
696
|
+
});
|
|
697
|
+
const pairs = [];
|
|
698
|
+
res.headers.forEach((value, key) => {
|
|
699
|
+
if (key !== "set-cookie" && key !== "content-encoding" && !HOP_BY_HOP.has(key)) pairs.push([key, value]);
|
|
700
|
+
});
|
|
701
|
+
for (const cookie of res.headers.getSetCookie()) pairs.push(["set-cookie", cookie]);
|
|
702
|
+
this.send({
|
|
703
|
+
type: "res_start",
|
|
704
|
+
id: msg.id,
|
|
705
|
+
status: res.status,
|
|
706
|
+
headers: pairs
|
|
707
|
+
});
|
|
708
|
+
started = true;
|
|
709
|
+
if (res.body) for await (const chunk of res.body) {
|
|
710
|
+
if (!this.streams.has(msg.id)) return;
|
|
711
|
+
for (let offset = 0; offset < chunk.length; offset += BODY_CHUNK_BYTES) {
|
|
712
|
+
await this.drain();
|
|
713
|
+
this.send({
|
|
714
|
+
type: "res_body",
|
|
715
|
+
id: msg.id,
|
|
716
|
+
chunk: Buffer.from(chunk.subarray(offset, offset + BODY_CHUNK_BYTES)).toString("base64")
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
this.send({
|
|
721
|
+
type: "res_end",
|
|
722
|
+
id: msg.id
|
|
723
|
+
});
|
|
724
|
+
} catch (e) {
|
|
725
|
+
if (abort.signal.aborted) return;
|
|
726
|
+
const cause = e instanceof Error && e.cause instanceof Error ? ` (${e.cause.message})` : "";
|
|
727
|
+
const message = `${e instanceof Error ? e.message : String(e)}${cause}`;
|
|
728
|
+
this.log("error", `[TunnelClient] Failed to proxy ${msg.method} ${msg.path.split("?")[0]}: ${message}`);
|
|
729
|
+
if (!started) this.send({
|
|
730
|
+
type: "res_start",
|
|
731
|
+
id: msg.id,
|
|
732
|
+
status: 502,
|
|
733
|
+
headers: [["content-type", "text/plain; charset=utf-8"]]
|
|
734
|
+
});
|
|
735
|
+
if (!started) this.send({
|
|
736
|
+
type: "res_body",
|
|
737
|
+
id: msg.id,
|
|
738
|
+
chunk: Buffer.from(`Bad Gateway: ${message}`).toString("base64")
|
|
739
|
+
});
|
|
740
|
+
this.send(started ? {
|
|
741
|
+
type: "res_abort",
|
|
742
|
+
id: msg.id,
|
|
743
|
+
error: message
|
|
744
|
+
} : {
|
|
745
|
+
type: "res_end",
|
|
746
|
+
id: msg.id
|
|
747
|
+
});
|
|
748
|
+
} finally {
|
|
749
|
+
this.streams.delete(msg.id);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
async handleRpcAsHttp(msg) {
|
|
753
|
+
const refreshControl = msg.method === "requestRefresh" || msg.method === "getRefreshStatus";
|
|
754
|
+
const localUrl = `http://127.0.0.1:${this.options.localSessionPort}${refreshControl ? "/api/session/refresh" : `/api/${msg.method}`}`;
|
|
755
|
+
try {
|
|
756
|
+
const method = msg.method === "getRefreshStatus" ? "GET" : "POST";
|
|
757
|
+
const res = await fetch(localUrl, {
|
|
758
|
+
method,
|
|
759
|
+
headers: {
|
|
760
|
+
"Content-Type": "application/json",
|
|
761
|
+
...refreshControl && this.options.localApiKey ? { "X-API-Key": this.options.localApiKey } : {}
|
|
762
|
+
},
|
|
763
|
+
...method === "POST" ? { body: JSON.stringify(refreshControl ? msg.args ?? {} : { args: msg.args }) } : {}
|
|
764
|
+
});
|
|
765
|
+
const resData = await res.json();
|
|
766
|
+
if (refreshControl && !res.ok) throw new Error(resData.error || "Session controls are unavailable.");
|
|
767
|
+
const responseMsg = {
|
|
768
|
+
type: "rpc_response",
|
|
769
|
+
id: msg.id,
|
|
770
|
+
result: resData
|
|
771
|
+
};
|
|
772
|
+
this.send(responseMsg);
|
|
773
|
+
} catch (e) {
|
|
774
|
+
this.log("error", `[TunnelClient] Failed to proxy rpc_request: ${e instanceof Error ? e.message : String(e)}`);
|
|
775
|
+
this.send({
|
|
776
|
+
type: "rpc_response",
|
|
777
|
+
id: msg.id,
|
|
778
|
+
error: e.message
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
destroy() {
|
|
783
|
+
this.isDestroyed = true;
|
|
784
|
+
if (this.heartbeat) clearInterval(this.heartbeat);
|
|
785
|
+
if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);
|
|
786
|
+
if (this.ws) {
|
|
787
|
+
this.ws.close();
|
|
788
|
+
this.ws = null;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
disconnect() {
|
|
792
|
+
this.destroy();
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
//#endregion
|
|
526
796
|
//#region src/cli-runtime.ts
|
|
797
|
+
/** The hosted open-wa router; `router: true` connects here. */
|
|
798
|
+
const DEFAULT_ROUTER_URL = "https://router.openwa.cloud";
|
|
527
799
|
function bridgeRuntimeEvents(openwaClient, publishRuntimeEvent) {
|
|
528
800
|
if (typeof openwaClient.events.onAny === "function" && typeof openwaClient.events.offAny === "function") {
|
|
529
801
|
openwaClient.events.onAny(publishRuntimeEvent);
|
|
@@ -800,6 +1072,8 @@ function parseCliArgs(argv = process.argv.slice(2)) {
|
|
|
800
1072
|
if (proxyHost) cliOverrides.proxyHost = proxyHost;
|
|
801
1073
|
const proxyToken = getVal(argv, "--proxy-token");
|
|
802
1074
|
if (proxyToken) cliOverrides.proxyToken = proxyToken;
|
|
1075
|
+
if (argv.includes("--router")) cliOverrides.router = true;
|
|
1076
|
+
if (argv.includes("--mcp")) cliOverrides.mcp = { enabled: true };
|
|
803
1077
|
const readyWebhook = getVal(argv, "--ready-webhook");
|
|
804
1078
|
if (readyWebhook) unsupportedWarnings.push(`--ready-webhook was provided (${readyWebhook}) but ready-webhook delivery is not yet wired in v5 CLI.`);
|
|
805
1079
|
if (argv.includes("-v") || argv.includes("--verbose")) {
|
|
@@ -947,6 +1221,73 @@ async function start(parsedArgs = parseCliArgs()) {
|
|
|
947
1221
|
phase: "server.started",
|
|
948
1222
|
sessionId: config.sessionId
|
|
949
1223
|
});
|
|
1224
|
+
let tunnel;
|
|
1225
|
+
const proxyHost = config.proxyHost ?? (config.router ? DEFAULT_ROUTER_URL : void 0);
|
|
1226
|
+
const tunnelLog = (level, message) => sink.write({
|
|
1227
|
+
level,
|
|
1228
|
+
message
|
|
1229
|
+
});
|
|
1230
|
+
if (proxyHost && !config.apiKey) sink.write({
|
|
1231
|
+
level: "error",
|
|
1232
|
+
message: "Not connecting to the session proxy: set an API key (--api-key or apiKey) first, because the proxy makes this API reachable from the internet."
|
|
1233
|
+
});
|
|
1234
|
+
else if (config.proxyHost && config.proxyToken) {
|
|
1235
|
+
sink.write({
|
|
1236
|
+
level: "info",
|
|
1237
|
+
message: `Connecting to the session proxy at ${config.proxyHost}...`
|
|
1238
|
+
});
|
|
1239
|
+
tunnel = new TunnelClient({
|
|
1240
|
+
proxyHost: config.proxyHost,
|
|
1241
|
+
proxyToken: config.proxyToken,
|
|
1242
|
+
sessionId: config.sessionId,
|
|
1243
|
+
localSessionPort: config.port,
|
|
1244
|
+
localApiKey: config.apiKey,
|
|
1245
|
+
log: tunnelLog
|
|
1246
|
+
});
|
|
1247
|
+
tunnel.connect();
|
|
1248
|
+
}
|
|
1249
|
+
const connectLicensedRouter = async () => {
|
|
1250
|
+
if (!proxyHost || config.proxyToken || !config.apiKey || tunnel) return;
|
|
1251
|
+
try {
|
|
1252
|
+
const number = String(await client.getHostNumber()).replace(/\D/g, "");
|
|
1253
|
+
const key = await resolveRouterLicenseKey(config.licenseKey, config.sessionId, number);
|
|
1254
|
+
if (!key) {
|
|
1255
|
+
sink.write({
|
|
1256
|
+
level: "error",
|
|
1257
|
+
message: "Not connecting to the open-wa router: it needs a license key for this number (--license-key or licenseKey)."
|
|
1258
|
+
});
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
sink.write({
|
|
1262
|
+
level: "info",
|
|
1263
|
+
message: `Connecting to the open-wa router at ${proxyHost}...`
|
|
1264
|
+
});
|
|
1265
|
+
tunnel = new TunnelClient({
|
|
1266
|
+
proxyHost,
|
|
1267
|
+
sessionId: config.sessionId,
|
|
1268
|
+
localSessionPort: config.port,
|
|
1269
|
+
localApiKey: config.apiKey,
|
|
1270
|
+
license: {
|
|
1271
|
+
key,
|
|
1272
|
+
number
|
|
1273
|
+
},
|
|
1274
|
+
log: tunnelLog,
|
|
1275
|
+
onAddress: (address) => {
|
|
1276
|
+
const mcp = config.mcp?.enabled ? `\n ChatGPT / MCP server URL: ${address}${config.mcp.path || "/mcp"}` : "";
|
|
1277
|
+
sink.write({
|
|
1278
|
+
level: "info",
|
|
1279
|
+
message: `Your public address: ${address}${mcp}`
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
});
|
|
1283
|
+
tunnel.connect();
|
|
1284
|
+
} catch (error) {
|
|
1285
|
+
sink.write({
|
|
1286
|
+
level: "error",
|
|
1287
|
+
message: `Could not connect to the open-wa router: ${error instanceof Error ? error.message : String(error)}`
|
|
1288
|
+
});
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
950
1291
|
printStartupSummary(config, executableResolution, preferLocalChrome, engineLabel);
|
|
951
1292
|
sink.status({
|
|
952
1293
|
phase: "client.starting",
|
|
@@ -1081,6 +1422,7 @@ async function start(parsedArgs = parseCliArgs()) {
|
|
|
1081
1422
|
const dispose = () => {
|
|
1082
1423
|
if (disposed) return;
|
|
1083
1424
|
disposed = true;
|
|
1425
|
+
tunnel?.destroy();
|
|
1084
1426
|
detachRuntimeBridge();
|
|
1085
1427
|
openwaClient.events.off("launch.browser.init.after", handleBrowserInit);
|
|
1086
1428
|
runtimeBridgeListeners.clear();
|
|
@@ -1120,6 +1462,7 @@ async function start(parsedArgs = parseCliArgs()) {
|
|
|
1120
1462
|
level: "info",
|
|
1121
1463
|
message: `WhatsApp Client ready with state: ${client.getState()} (status=${readiness.status}, exposureSafe=${readiness.exposureSafe})`
|
|
1122
1464
|
});
|
|
1465
|
+
connectLicensedRouter();
|
|
1123
1466
|
detachLaunchNarration();
|
|
1124
1467
|
return {
|
|
1125
1468
|
server,
|
|
@@ -1129,6 +1472,18 @@ async function start(parsedArgs = parseCliArgs()) {
|
|
|
1129
1472
|
dispose
|
|
1130
1473
|
};
|
|
1131
1474
|
}
|
|
1475
|
+
/** The router checks one key per number; `licenseKey` may be a key, a number-to-key map, or a function. */
|
|
1476
|
+
async function resolveRouterLicenseKey(licenseKey, sessionId, number) {
|
|
1477
|
+
if (typeof licenseKey === "string") return licenseKey.trim() || void 0;
|
|
1478
|
+
if (typeof licenseKey === "function") {
|
|
1479
|
+
const value = await licenseKey(sessionId, number);
|
|
1480
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
1481
|
+
}
|
|
1482
|
+
if (licenseKey && typeof licenseKey === "object") {
|
|
1483
|
+
const record = licenseKey;
|
|
1484
|
+
return record[number] ?? record[`${number}@c.us`] ?? void 0;
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1132
1487
|
async function main(argv = process.argv.slice(2)) {
|
|
1133
1488
|
if (argv[0] === "init") {
|
|
1134
1489
|
const { initProject } = await Promise.resolve().then(() => require("./init-_7lq5T-b.cjs"));
|
|
@@ -1250,4 +1605,4 @@ Object.defineProperty(exports, "start", {
|
|
|
1250
1605
|
}
|
|
1251
1606
|
});
|
|
1252
1607
|
|
|
1253
|
-
//# sourceMappingURL=cli-runtime-
|
|
1608
|
+
//# sourceMappingURL=cli-runtime-B3ABNLz4.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-runtime-B3ABNLz4.cjs","names":["ApiServer","join","homedir","toPublicError","readFile","stat","access","constants","dirname","mkdir","mkdtemp","rm","writeFile","rename","existsSync","readFileSync","dirname","statSync","constants","findSystemBrowser","selectRuntimeDriver","ConfigSchema","resolveConfig","resolve","WebSocket","eventRegistry","resolve","defaultChatSandboxPolicy","selectSharedRuntimeDriver","resolveConfig","makeNodeExecutionSandbox","createClient","observeBrowserProcessMemory","ClientFacade","fileURLToPath"],"sources":["../src/server/hono-server.ts","../src/cli/output-sink.ts","../src/browser-choice.ts","../src/runtime-client.ts","../src/tunnel-client.ts","../src/cli-runtime.ts"],"sourcesContent":["import { ApiServer, createApiServer as createSharedApiServer } from '@open-wa/api';\nimport type { Config } from '@open-wa/config';\n\nexport class WAServer extends ApiServer {\n constructor(config: Config, verbose = false) {\n super({ config, verbose });\n }\n}\n\nexport function createApiServer(config: Config) {\n return createSharedApiServer(config);\n}\n","import qrcode from 'qrcode-terminal';\n\nexport type CliOutputLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface CliOutputEntry {\n level: CliOutputLevel;\n message: string;\n meta?: Record<string, unknown>;\n}\n\nexport interface CliStatusUpdate {\n phase:\n | 'boot'\n | 'config.resolved'\n | 'server.starting'\n | 'server.started'\n | 'client.starting'\n | 'launch.auth'\n | 'launch.helpers'\n | 'launch.patch'\n | 'launch.license'\n | 'launch.finalize'\n | 'auth.qr'\n | 'client.ready'\n | 'shutdown.starting'\n | 'shutdown.complete'\n | 'error';\n detail?: string;\n sessionId?: string;\n}\n\nexport interface CliQrPayload {\n qr: string;\n sessionId: string;\n}\n\nexport interface CliOutputSink {\n write(entry: CliOutputEntry): void;\n status(update: CliStatusUpdate): void;\n qr(payload: CliQrPayload): void;\n promptChoice?(question: string, choices: readonly string[]): Promise<number>;\n}\n\nexport async function promptChoice(question: string, choices: readonly string[]): Promise<number> {\n if (!process.stdin.isTTY || !process.stderr.isTTY) {\n throw new Error('No browser is installed. Choose --use-chrome, --use-chromium or --use-lightpanda to download one without a prompt.');\n }\n const { createInterface } = await import('node:readline/promises');\n const readline = createInterface({ input: process.stdin, output: process.stderr });\n const abort = new AbortController();\n readline.on('SIGINT', () => abort.abort());\n readline.on('close', () => abort.abort());\n try {\n process.stderr.write(`\\n${question}\\n${choices.map((choice, index) => ` ${index + 1}. ${choice}`).join('\\n')}\\n`);\n while (true) {\n const answer = (await readline.question('Choose a browser [1]: ', { signal: abort.signal })).trim();\n const choice = answer === '' ? 0 : Number(answer) - 1;\n if (Number.isInteger(choice) && choice >= 0 && choice < choices.length) return choice;\n process.stderr.write(`Enter a number from 1 to ${choices.length}.\\n`);\n }\n } catch (cause) {\n throw new Error('Browser selection cancelled.', { cause });\n } finally {\n readline.close();\n }\n}\n\nfunction writeToConsole(level: CliOutputLevel, message: string): void {\n if (level === 'warn') {\n console.warn(message);\n return;\n }\n\n if (level === 'error') {\n console.error(message);\n return;\n }\n\n console.log(message);\n}\n\nexport function createConsoleOutputSink(): CliOutputSink {\n return {\n promptChoice,\n write(entry) {\n writeToConsole(entry.level, entry.message);\n },\n status() {\n // Status updates are semantic signals for richer presenters.\n },\n qr(payload) {\n qrcode.generate(payload.qr, { small: true }, (terminalQrCode) => {\n console.log(`WhatsApp login: ${payload.sessionId}\\n${terminalQrCode}`);\n });\n },\n };\n}\n\nlet activeSink: CliOutputSink = createConsoleOutputSink();\n\nexport function getCliOutputSink(): CliOutputSink {\n return activeSink;\n}\n\nexport function setCliOutputSink(sink: CliOutputSink): void {\n activeSink = sink;\n}\n\nexport function resetCliOutputSink(): void {\n activeSink = createConsoleOutputSink();\n}\n","import { constants } from 'node:fs';\nimport { access, mkdir, mkdtemp, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { toPublicError } from '@open-wa/driver-interface';\nimport { getCliOutputSink, promptChoice } from './cli/output-sink';\n\nexport type BrowserChoice = 'chrome' | 'chromium' | 'lightpanda';\nexport { findSystemBrowser } from '@open-wa/create/browser';\nconst choiceFile = join(homedir(), '.cache', 'open-wa', 'browser-choice.json');\n\nexport async function readBrowserChoice(): Promise<{ kind: BrowserChoice; executablePath: string } | undefined> {\n const { Effect, Schema } = await import('effect');\n const recordSchema = Schema.fromJsonString(Schema.Struct({\n kind: Schema.Literals(['chrome', 'chromium', 'lightpanda']),\n executablePath: Schema.String,\n }));\n const io = <A>(operation: () => PromiseLike<A>) => Effect.tryPromise({ try: operation, catch: toPublicError });\n return Effect.runPromise(Effect.gen(function* () {\n const record = yield* Schema.decodeUnknownEffect(recordSchema)(yield* io(() => readFile(choiceFile, 'utf8')));\n const executable = yield* io(() => stat(record.executablePath));\n if (!executable.isFile()) return undefined;\n yield* io(() => access(record.executablePath, constants.X_OK));\n return record;\n }).pipe(Effect.catch(() => Effect.succeed(undefined))));\n}\n\nexport async function writeBrowserChoice(kind: BrowserChoice, executablePath: string): Promise<void> {\n const { Effect } = await import('effect');\n const io = <A>(operation: () => PromiseLike<A>) => Effect.tryPromise({ try: operation, catch: toPublicError });\n const program = Effect.gen(function* () {\n const directory = dirname(choiceFile);\n yield* io(() => mkdir(directory, { recursive: true }));\n const staging = yield* Effect.acquireRelease(\n io(() => mkdtemp(join(directory, '.browser-choice-'))),\n path => io(() => rm(path, { recursive: true, force: true })).pipe(Effect.orDie),\n );\n const temporary = join(staging, 'browser-choice.json');\n yield* io(() => writeFile(temporary, JSON.stringify({ kind, executablePath }), { encoding: 'utf8', flag: 'wx' }));\n yield* io(() => rename(temporary, choiceFile));\n });\n await Effect.runPromise(Effect.scoped(Effect.uninterruptible(program))).catch(cause => { throw toPublicError(cause); });\n}\n\nexport async function chooseBrowser(): Promise<BrowserChoice> {\n const sink = getCliOutputSink();\n const choice = await (sink.promptChoice ?? promptChoice)(\n 'Google Chrome was not found. Which browser would you like to download?',\n [\n 'Chrome for Testing — recommended; highest compatibility, including video and media.',\n 'Chromium — middle ground; proprietary video/audio codecs may be unavailable.',\n 'Lightpanda — lightweight basic automation; low compatibility, experimental WhatsApp support, no video or rendering.',\n ],\n );\n return (['chrome', 'chromium', 'lightpanda'] as const)[choice];\n}\n","import type { CreateClientOptions, OpenWAEventMap } from '@open-wa/core';\nimport type { Client } from '@open-wa/client';\nimport { ConfigSchema, resolveConfig, type PartialConfig, type Config, type TrackedConfig } from '@open-wa/config';\nimport { accessSync, constants, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { getCliOutputSink } from './cli/output-sink';\nimport { chooseBrowser, findSystemBrowser, readBrowserChoice, writeBrowserChoice, type BrowserChoice } from './browser-choice';\n\nexport interface ExecutablePathResolution {\n executablePath?: string;\n source:\n | 'config'\n | 'cache'\n | 'chrome_installation'\n | 'driver_default'\n | 'lightpanda_config'\n | 'lightpanda_managed'\n | 'managed_browser';\n warning?: string;\n}\n\nexport interface DriverSelection {\n driver: CreateClientOptions['driver'];\n engineLabel: 'Puppeteer' | 'Lightpanda';\n executableResolution: ExecutablePathResolution;\n preferLocalChrome: boolean;\n}\n\nfunction readChromePathCache(cacheFilePath: string): { executablePath?: string } | undefined {\n try {\n if (!existsSync(cacheFilePath)) {\n return undefined;\n }\n\n const raw = JSON.parse(readFileSync(cacheFilePath, 'utf8')) as { executablePath?: string };\n if (!raw || typeof raw !== 'object') {\n return undefined;\n }\n\n return {\n executablePath: typeof raw.executablePath === 'string' ? raw.executablePath : undefined,\n };\n } catch {\n return undefined;\n }\n}\n\nfunction writeChromePathCache(executablePath: string, cacheFilePath: string): void {\n mkdirSync(dirname(cacheFilePath), { recursive: true });\n writeFileSync(cacheFilePath, JSON.stringify({ executablePath, updatedAt: new Date().toISOString() }, null, 2), 'utf8');\n}\n\nfunction clearChromePathCache(cacheFilePath: string): void {\n if (existsSync(cacheFilePath)) {\n rmSync(cacheFilePath, { force: true });\n }\n}\n\nfunction isUsableExecutablePath(executablePath?: string): executablePath is string {\n if (!executablePath) return false;\n try {\n if (!statSync(executablePath).isFile()) return false;\n accessSync(executablePath, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction getExplicitUseChromePreference(rawConfigs?: TrackedConfig['rawConfigs']): boolean | undefined {\n const explicitConfigSources = [\n rawConfigs?.file,\n rawConfigs?.env,\n rawConfigs?.cli,\n rawConfigs?.programmatic,\n ];\n\n for (let index = explicitConfigSources.length - 1; index >= 0; index -= 1) {\n const source = explicitConfigSources[index];\n if (source?.useChrome !== undefined) {\n return source.useChrome;\n }\n }\n\n return undefined;\n}\n\nexport function shouldPreferLocalChrome(\n config: Config,\n rawConfigs?: TrackedConfig['rawConfigs'],\n defaultPreference = true,\n): boolean {\n if (config.useLightpanda || config.useChromium || config.browser?.kind === 'chromium') {\n return false;\n }\n\n if (config.executablePath || process.env.PUPPETEER_EXECUTABLE_PATH !== undefined) {\n return false;\n }\n\n const explicitUseChrome = getExplicitUseChromePreference(rawConfigs);\n if (explicitUseChrome !== undefined) {\n return explicitUseChrome;\n }\n\n return defaultPreference;\n}\n\nexport async function resolveExecutablePath(\n config: Config,\n options: {\n preferLocalChrome?: boolean;\n cacheFilePath: string;\n kind?: 'chrome' | 'chromium';\n }\n): Promise<ExecutablePathResolution> {\n const configuredPath = config.executablePath ?? process.env.PUPPETEER_EXECUTABLE_PATH;\n if (configuredPath !== undefined) {\n return {\n executablePath: configuredPath,\n source: 'config',\n };\n }\n\n const preferLocalChrome = options.preferLocalChrome ?? config.useChrome;\n if (!preferLocalChrome) {\n return {\n source: 'driver_default',\n };\n }\n\n const matchesKind = (path: string) => options.kind === 'chromium'\n ? /chromium/i.test(path)\n : !/chromium/i.test(path);\n const cachedPath = readChromePathCache(options.cacheFilePath)?.executablePath;\n if (isUsableExecutablePath(cachedPath) && matchesKind(cachedPath)) {\n return {\n executablePath: cachedPath,\n source: 'cache',\n };\n }\n\n if (cachedPath) {\n clearChromePathCache(options.cacheFilePath);\n }\n\n // Check known installation paths and PATH without a synchronous OS-wide\n // application scan, so a missing Chrome reaches the picker promptly.\n const detectedPath = await findSystemBrowser(options.kind ?? 'chrome');\n\n if (detectedPath) {\n writeChromePathCache(detectedPath, options.cacheFilePath);\n return {\n executablePath: detectedPath,\n source: 'chrome_installation',\n };\n }\n\n clearChromePathCache(options.cacheFilePath);\n\n return {\n source: 'driver_default',\n };\n}\n\nexport function resolveLightpandaExecutablePath(config: Config): ExecutablePathResolution {\n const executablePath = config.lightpanda?.executablePath ?? config.executablePath ?? process.env.LIGHTPANDA_EXECUTABLE_PATH;\n if (executablePath) {\n return {\n executablePath,\n source: 'lightpanda_config',\n };\n }\n\n return {\n source: 'lightpanda_managed',\n };\n}\n\nexport async function selectRuntimeDriver(\n config: Config,\n options: {\n rawConfigs?: TrackedConfig['rawConfigs'];\n cacheFilePath: string;\n defaultPreferLocalChrome?: boolean;\n promptForMissingBrowser?: boolean;\n nonInteractive?: boolean;\n }\n): Promise<DriverSelection> {\n const browserSource = config.browser?.source;\n const promptForMissingBrowser = options.promptForMissingBrowser || browserSource === 'auto';\n const flags = [config.useChrome, config.useChromium, config.useLightpanda].filter(Boolean);\n if (flags.length > 1) throw new Error('Choose only one browser: useChrome, useChromium or useLightpanda.');\n let kind: BrowserChoice | undefined = config.useLightpanda ? 'lightpanda'\n : config.useChromium ? 'chromium'\n : config.useChrome ? 'chrome'\n : config.browser?.kind;\n const explicitChoice = kind !== undefined || getExplicitUseChromePreference(options.rawConfigs) !== undefined\n || config.browser?.download === 'auto';\n const preferLocalChrome = browserSource ? browserSource !== 'managed'\n : shouldPreferLocalChrome(config, options.rawConfigs, options.defaultPreferLocalChrome ?? true);\n let executableResolution: ExecutablePathResolution = { source: 'driver_default' };\n if (kind !== 'lightpanda' && browserSource === 'system') {\n const executablePath = await findSystemBrowser(kind === 'chromium' ? 'chromium' : 'chrome');\n if (!executablePath) throw new Error('The selected system browser was not found. Install it or change browser.source to managed to download a browser.');\n executableResolution = { source: 'chrome_installation', executablePath };\n } else if (kind !== 'lightpanda' && browserSource !== 'managed') {\n executableResolution = await resolveExecutablePath(config, {\n preferLocalChrome: kind === 'chromium' || preferLocalChrome,\n cacheFilePath: kind === 'chromium' ? `${options.cacheFilePath}.chromium` : options.cacheFilePath,\n kind: kind === 'chromium' ? 'chromium' : 'chrome',\n });\n } else if (kind === 'lightpanda') {\n executableResolution = resolveLightpandaExecutablePath(config);\n executableResolution.executablePath ??= config.executablePath;\n }\n if (browserSource !== 'managed' && browserSource !== 'system' && !executableResolution.executablePath && (kind !== undefined || promptForMissingBrowser)\n && !(kind === 'lightpanda' && config.lightpanda?.experimentalWhatsApp !== false)) {\n const remembered = await readBrowserChoice();\n if (remembered && (kind === undefined || remembered.kind === kind)) {\n kind = remembered.kind;\n executableResolution = { source: 'cache', executablePath: remembered.executablePath };\n }\n }\n if (!kind && executableResolution.executablePath === undefined && promptForMissingBrowser) {\n // A pre-provisioned Chrome cache is usable even without a remembered choice.\n const { ensureBrowser } = await import('@open-wa/driver-puppeteer');\n try {\n const executablePath = await ensureBrowser({ browser: { ...config.browser, kind: 'chrome', download: 'never' } });\n executableResolution = { source: 'managed_browser', executablePath };\n } catch (error) {\n if (!(error instanceof Error) || !/missing from .* and browser downloads are disabled/.test(error.message)) throw error;\n }\n }\n if (!kind && !executableResolution.executablePath && !explicitChoice && promptForMissingBrowser) {\n if (config.browser?.download === 'never') {\n throw new Error('No browser is available and browser downloads are disabled. Configure executablePath or pre-provision a browser cache.');\n }\n if (options.nonInteractive || process.env.CI || process.env.NONINTERACTIVE) {\n throw new Error('No browser is installed. Choose --use-chrome, --use-chromium or --use-lightpanda to download one without a prompt.');\n }\n kind = await chooseBrowser();\n }\n kind ??= 'chrome';\n const sink = getCliOutputSink();\n const ctx = { logger: {\n debug: (message: string) => sink.write({ level: 'debug', message }),\n info: (message: string) => sink.write({ level: 'info', message }),\n warn: (message: string) => sink.write({ level: 'warn', message }),\n error: (message: string) => sink.write({ level: 'error', message }),\n } };\n const browser = {\n ...config.browser,\n ...(explicitChoice || promptForMissingBrowser ? { download: config.browser?.download ?? ('auto' as const) } : {}),\n ...(kind !== 'lightpanda' ? { kind } : {}),\n };\n if (kind === 'lightpanda') {\n const { LightpandaDriver, ensureLightpanda } = await import('@open-wa/driver-lightpanda');\n config.lightpanda = ConfigSchema.shape.lightpanda.parse({ ...config.lightpanda, experimentalWhatsApp: config.lightpanda?.experimentalWhatsApp ?? true });\n config.browser = browser;\n const executablePath = await ensureLightpanda({\n executablePath: executableResolution.executablePath,\n browser,\n preferPinnedRelease: config.lightpanda?.experimentalWhatsApp ?? true,\n }, ctx);\n config.useLightpanda = true;\n config.useChrome = false;\n config.useChromium = false;\n sink.write({ level: 'warn', message: 'Lightpanda has low compatibility and experimental WhatsApp support; video, screenshots and rendering are unavailable.' });\n if (options.promptForMissingBrowser) {\n await writeBrowserChoice(kind, executablePath).catch(error => sink.write({ level: 'warn', message: `Could not remember the browser choice: ${error instanceof Error ? error.message : String(error)}` }));\n }\n return {\n driver: new LightpandaDriver(),\n engineLabel: 'Lightpanda',\n executableResolution: { source: 'lightpanda_managed', executablePath },\n preferLocalChrome: false,\n };\n }\n config.browser = browser;\n const { PuppeteerDriver, ensureBrowser } = await import('@open-wa/driver-puppeteer');\n const executablePath = await ensureBrowser({ executablePath: executableResolution.executablePath, browser }, ctx);\n if (!executableResolution.executablePath) executableResolution = { source: 'managed_browser', executablePath };\n if (options.promptForMissingBrowser) {\n await writeBrowserChoice(kind, executablePath).catch(error => sink.write({ level: 'warn', message: `Could not remember the browser choice: ${error instanceof Error ? error.message : String(error)}` }));\n }\n return {\n driver: new PuppeteerDriver(),\n engineLabel: 'Puppeteer',\n executableResolution,\n preferLocalChrome,\n };\n}\n\n/** Load the Node media runtime only when a call needs a source or sink. */\nexport function makeDefaultCallMediaHost(): NonNullable<CreateClientOptions['callMediaHost']> {\n return {\n async prepare(...args) {\n const { makeNodeCallMediaHost } = await import('@open-wa/runtime-node');\n return makeNodeCallMediaHost({ log: message => getCliOutputSink().write({ level: 'info', message }) }).prepare(...args);\n },\n };\n}\n\nexport function toCreateClientOptions(\n config: Config,\n driverSelection: DriverSelection,\n options: {\n debug?: boolean;\n } = {},\n): CreateClientOptions {\n return {\n sessionId: config.sessionId,\n pluginRefs: config.plugins,\n pluginConfig: config.pluginConfig,\n eventMode: config.eventMode,\n driver: driverSelection.driver,\n deleteSessionDataOnLogout: config.deleteSessionDataOnLogout,\n killClientOnLogout: config.killClientOnLogout,\n sessionDataPath: config.sessionDataPath,\n sessionData: config.sessionData,\n skipSessionSave: config.skipSessionSave,\n sessionDataBucketAuth: config.sessionDataBucketAuth,\n sessionDataEncryptionKey: config.sessionDataEncryptionKey,\n sessionDataEncryptionKeyFile: config.sessionDataEncryptionKeyFile,\n s3Sync: config.s3Sync,\n debug: options.debug ?? (config.logLevel === 'debug' || config.logConsole),\n headless: config.headless,\n qrTimeoutMs: typeof config.qrTimeout === 'number' ? config.qrTimeout * 1000 : undefined,\n authTimeoutMs: typeof config.authTimeout === 'number' ? config.authTimeout * 1000 : undefined,\n executablePath: driverSelection.executableResolution.executablePath,\n browserArgs: config.chromiumArgs,\n browser: config.browser,\n allowDangerousBrowserArgs: config.allowDangerousBrowserArgs,\n userDataDir: config.userDataDir,\n ephemeral: config.ephemeral,\n linkCode: config.linkCode,\n qrMax: config.qrMax,\n oorTimeoutMs: config.oorTimeout * 1000,\n logConsole: config.logConsole,\n logConsoleErrors: config.logConsoleErrors,\n blockCrashLogs: config.blockCrashLogs,\n blockAssets: config.blockAssets,\n safeMode: config.safeMode,\n lightpanda: config.useLightpanda ? { experimentalWhatsApp: true, ...config.lightpanda } : undefined,\n licenseKey: config.licenseKey as any,\n calling: config.calling,\n callMediaHost: makeDefaultCallMediaHost(),\n licenseConfig: config.licenseConfig,\n patchConfig: { ghPatch: config.ghPatch, cachedPatch: config.cachedPatch },\n };\n}\n\n/** Options for the ready-to-use messaging client. */\nexport type CreateOptions = Omit<PartialConfig, 's3Sync' | 'calling'> & {\n calling?: import('@open-wa/schema').CallingOptions;\n s3Sync?: Omit<NonNullable<PartialConfig['s3Sync']>, 'region' | 'syncInterval'> & {\n region?: string;\n syncInterval?: number;\n };\n /** Override the default Puppeteer driver. */\n driver?: CreateClientOptions['driver'];\n};\n\n/** Start WhatsApp, display QR login when needed, and return a ready messaging client. */\nexport async function create(options: CreateOptions = {}): Promise<Client> {\n const { createClient: createCoreClient } = await import('@open-wa/core');\n const { Client } = await import('@open-wa/client');\n const { driver, sessionData, sessionDataBucketAuth, s3Sync, calling,\n sessionDataEncryptionKey, sessionDataEncryptionKeyFile, ...configOverrides } = options;\n const { config, rawConfigs } = await resolveConfig({\n programmaticOverrides: {\n qrTimeout: 0, ...configOverrides,\n // Session seeds, encryption keys and bucket credentials bypass tracked/debug config.\n },\n skipConfigFile: true,\n skipEnv: true,\n includeRawConfigs: true,\n });\n\n const driverSelection: DriverSelection = driver ? {\n driver,\n engineLabel: driver.name === 'lightpanda' ? 'Lightpanda' : 'Puppeteer',\n executableResolution: { source: 'config', executablePath: config.executablePath },\n preferLocalChrome: false,\n } : await selectRuntimeDriver(config, {\n rawConfigs,\n cacheFilePath: resolve(process.cwd(), '.open-wa', 'chrome-executable-path.json'),\n defaultPreferLocalChrome: false,\n });\n\n const coreOptions = toCreateClientOptions(config, driverSelection);\n if (calling) coreOptions.calling = calling;\n if (driver) coreOptions.driver = driver;\n coreOptions.sessionData = sessionData;\n coreOptions.sessionDataBucketAuth = sessionDataBucketAuth;\n coreOptions.sessionDataEncryptionKey = sessionDataEncryptionKey;\n coreOptions.sessionDataEncryptionKeyFile = sessionDataEncryptionKeyFile;\n coreOptions.s3Sync = s3Sync;\n\n const core = await createCoreClient(coreOptions);\n const sink = getCliOutputSink();\n const onQr = (event: OpenWAEventMap['launch.auth.qr.generated']) => {\n if (config.qrLogSkip || !event.details?.qr) return;\n sink.write({ level: 'info', message: 'Open WhatsApp on your sending phone: Linked Devices → Link a Device, then scan this QR code.' });\n sink.qr({ qr: event.details.qr, sessionId: config.sessionId });\n };\n const onLinkCode = (event: OpenWAEventMap['launch.auth.linkCode.generated']) => {\n if (event.details?.linkCode && !config.qrLogSkip) {\n sink.write({ level: 'info', message: `Enter this link code on your sending phone: ${event.details.linkCode}` });\n }\n };\n core.events.on('launch.auth.qr.generated', onQr);\n core.events.on('launch.auth.linkCode.generated', onLinkCode);\n let client: Client | undefined;\n try {\n client = new Client({ client: core, transport: core.getTransport() });\n await client.start();\n if (core.getState() !== 'READY' || !core.getReadiness().exposureSafe) {\n throw new Error('WhatsApp startup finished without a messaging-ready session.');\n }\n return client;\n } catch (error) {\n try {\n if (client) await client.stop('startup-failure');\n else await core.stop('startup-failure');\n } catch {\n // Keep the startup failure as the actionable error.\n }\n throw error;\n } finally {\n core.events.off('launch.auth.qr.generated', onQr);\n core.events.off('launch.auth.linkCode.generated', onLinkCode);\n }\n}\n","import WebSocket from 'ws';\n\nexport interface TunnelClientOptions {\n proxyHost: string;\n /** Self-hosted proxy: the shared upstream token. */\n proxyToken?: string;\n /** Licensed router: the license key and this account's number; the router answers with the session's address. */\n license?: { key: string; number: string };\n onAddress?: (address: string) => void;\n sessionId: string;\n localSessionPort: number;\n localApiKey?: string;\n log?: (level: 'info' | 'warn' | 'error', message: string) => void;\n}\n\n/** Largest body slice per frame, before base64; matches the proxy. */\nconst BODY_CHUNK_BYTES = 256 * 1024;\n/** Sent by the proxy when another instance of the same session connects. */\nconst REPLACED_CLOSE_CODE = 4001;\nconst HEARTBEAT_MS = 20_000;\nconst MAX_BUFFERED_BYTES = 4 * 1024 * 1024;\nconst HOP_BY_HOP = new Set(['connection', 'keep-alive', 'proxy-connection', 'transfer-encoding', 'upgrade', 'te', 'trailer', 'host', 'content-length', 'expect']);\n\ninterface TunnelStream {\n abort: AbortController;\n body?: ReadableStreamDefaultController<Uint8Array>;\n}\n\nexport class TunnelClient {\n private ws: WebSocket | null = null;\n private streams = new Map<string, TunnelStream>();\n private heartbeat: NodeJS.Timeout | null = null;\n private lastPong = 0;\n private replaced = false;\n private retryMs = 3_000;\n private reconnectTimeout: NodeJS.Timeout | null = null;\n private isDestroyed = false;\n\n constructor(private options: TunnelClientOptions) {}\n\n private log(level: 'info' | 'warn' | 'error', message: string) {\n if (this.options.log) {\n this.options.log(level, message);\n return;\n }\n\n if (level === 'warn') {\n console.warn(message);\n return;\n }\n\n if (level === 'error') {\n console.error(message);\n return;\n }\n\n console.log(message);\n }\n\n public connect() {\n if (this.isDestroyed) return;\n\n const base = this.options.proxyHost.replace(/^http/, 'ws').replace(/\\/+$/, '');\n const { license } = this.options;\n const connectUrl = license ? `${base}/upstream` : `${base}/sessions/${encodeURIComponent(this.options.sessionId)}/upstream`;\n // Credentials go in headers so they do not appear in request logs.\n const headers: Record<string, string> = license\n ? { Authorization: `License ${license.key}`, 'x-owa-number': license.number }\n : { Authorization: `Bearer ${this.options.proxyToken}` };\n this.ws = new WebSocket(connectUrl, { headers });\n this.ws.on('unexpected-response', (req, res) => {\n let body = '';\n res.on('data', (chunk: Buffer) => { body += chunk.toString(); });\n res.on('end', () => {\n this.log('error', `[TunnelClient] The proxy refused the connection (${res.statusCode}): ${body.slice(0, 200)}`);\n // A refused license or token won't fix itself in 3 seconds; retry slowly.\n this.retryMs = res.statusCode === 401 || res.statusCode === 403 ? 60_000 : 3_000;\n req.destroy();\n });\n });\n\n this.ws.on('open', () => {\n this.retryMs = 3_000;\n this.log('info', `[TunnelClient] Connected upstream for session ${this.options.sessionId}`);\n // The proxy answers pings at the edge; a missing answer means the connection is half open.\n this.lastPong = Date.now();\n this.heartbeat = setInterval(() => {\n if (Date.now() - this.lastPong > HEARTBEAT_MS * 2 + 5_000) {\n this.log('warn', '[TunnelClient] No answer from the proxy; reconnecting');\n this.ws?.terminate();\n return;\n }\n this.send({ type: 'ping' });\n }, HEARTBEAT_MS);\n });\n\n this.ws.on('message', (data: Buffer) => {\n let msg: any;\n try {\n msg = JSON.parse(data.toString('utf-8'));\n } catch {\n return;\n }\n\n switch (msg.type) {\n case 'ping':\n this.send({ type: 'pong' });\n return;\n case 'pong':\n this.lastPong = Date.now();\n return;\n case 'welcome':\n if (typeof msg.address === 'string') {\n this.log('info', `[TunnelClient] Public address: ${msg.address} (MCP: ${msg.address}/mcp)`);\n this.options.onAddress?.(msg.address);\n }\n return;\n case 'replaced':\n this.replaced = true;\n this.log('error', `[TunnelClient] Another instance connected as session ${this.options.sessionId}; this one stopped forwarding. Restart it to take over again.`);\n this.ws?.close();\n return;\n case 'req_start':\n void this.handleRequest(msg);\n return;\n case 'req_body':\n this.streams.get(msg.id)?.body?.enqueue(new Uint8Array(Buffer.from(msg.chunk, 'base64')));\n return;\n case 'req_end':\n this.streams.get(msg.id)?.body?.close();\n return;\n case 'req_abort': {\n const stream = this.streams.get(msg.id);\n stream?.abort.abort();\n try { stream?.body?.error(new Error(msg.error ?? 'Aborted')); } catch { /* already closed */ }\n this.streams.delete(msg.id);\n return;\n }\n case 'rpc_request':\n // Map RPC requests to the REST API.\n void this.handleRpcAsHttp(msg);\n return;\n }\n });\n\n this.ws.on('close', (code: number) => {\n for (const stream of this.streams.values()) stream.abort.abort();\n this.streams.clear();\n if (this.heartbeat) clearInterval(this.heartbeat);\n if (this.replaced || code === REPLACED_CLOSE_CODE) return;\n if (!this.isDestroyed) {\n this.log('warn', `[TunnelClient] Disconnected. Reconnecting in ${this.retryMs / 1000}s...`);\n this.reconnectTimeout = setTimeout(() => this.connect(), this.retryMs);\n }\n });\n\n this.ws.on('error', (err: any) => {\n this.log('error', `[TunnelClient] WebSocket error: ${err.message}`);\n });\n }\n\n private send(message: Record<string, unknown>) {\n if (this.ws?.readyState === WebSocket.OPEN) this.ws.send(JSON.stringify(message));\n }\n\n /** Waits while the socket has a large send backlog, so a big download does not fill memory. */\n private async drain() {\n while (this.ws && this.ws.readyState === WebSocket.OPEN && this.ws.bufferedAmount > MAX_BUFFERED_BYTES) {\n await new Promise(resolve => setTimeout(resolve, 10));\n }\n }\n\n private async handleRequest(msg: { id: string; method: string; path: string; headers: [string, string][]; hasBody: boolean }) {\n const abort = new AbortController();\n const stream: TunnelStream = { abort };\n this.streams.set(msg.id, stream);\n const body = msg.hasBody ? new ReadableStream<Uint8Array>({ start: controller => { stream.body = controller; } }) : undefined;\n const headers = new Headers();\n for (const [key, value] of msg.headers) if (!HOP_BY_HOP.has(key.toLowerCase())) headers.append(key, value);\n\n let started = false;\n try {\n const res = await fetch(`http://127.0.0.1:${this.options.localSessionPort}${msg.path}`, {\n method: msg.method, headers, body, signal: abort.signal, redirect: 'manual',\n // Required by Node to stream a request body.\n ...(body ? { duplex: 'half' } : {}),\n } as RequestInit);\n\n // fetch decodes compressed bodies, so the encoding and length headers no longer apply.\n const pairs: [string, string][] = [];\n res.headers.forEach((value, key) => {\n if (key !== 'set-cookie' && key !== 'content-encoding' && !HOP_BY_HOP.has(key)) pairs.push([key, value]);\n });\n for (const cookie of res.headers.getSetCookie()) pairs.push(['set-cookie', cookie]);\n this.send({ type: 'res_start', id: msg.id, status: res.status, headers: pairs });\n started = true;\n\n if (res.body) {\n for await (const chunk of res.body as unknown as AsyncIterable<Uint8Array>) {\n if (!this.streams.has(msg.id)) return;\n for (let offset = 0; offset < chunk.length; offset += BODY_CHUNK_BYTES) {\n await this.drain();\n this.send({ type: 'res_body', id: msg.id, chunk: Buffer.from(chunk.subarray(offset, offset + BODY_CHUNK_BYTES)).toString('base64') });\n }\n }\n }\n this.send({ type: 'res_end', id: msg.id });\n } catch (e: unknown) {\n if (abort.signal.aborted) return;\n const cause = e instanceof Error && e.cause instanceof Error ? ` (${e.cause.message})` : '';\n const message = `${e instanceof Error ? e.message : String(e)}${cause}`;\n this.log('error', `[TunnelClient] Failed to proxy ${msg.method} ${msg.path.split('?')[0]}: ${message}`);\n if (!started) this.send({ type: 'res_start', id: msg.id, status: 502, headers: [['content-type', 'text/plain; charset=utf-8']] });\n if (!started) this.send({ type: 'res_body', id: msg.id, chunk: Buffer.from(`Bad Gateway: ${message}`).toString('base64') });\n this.send(started ? { type: 'res_abort', id: msg.id, error: message } : { type: 'res_end', id: msg.id });\n } finally {\n this.streams.delete(msg.id);\n }\n }\n\n private async handleRpcAsHttp(msg: any) {\n const refreshControl = msg.method === 'requestRefresh' || msg.method === 'getRefreshStatus';\n // If the proxy sends an RPC request, map it to the REST API equivalent.\n // E.g. rpc 'sendText' -> HTTP POST /api/sendText\n const localUrl = `http://127.0.0.1:${this.options.localSessionPort}${refreshControl ? '/api/session/refresh' : `/api/${msg.method}`}`;\n try {\n const method = msg.method === 'getRefreshStatus' ? 'GET' : 'POST';\n const res = await fetch(localUrl, {\n method,\n headers: {\n 'Content-Type': 'application/json',\n ...(refreshControl && this.options.localApiKey ? { 'X-API-Key': this.options.localApiKey } : {}),\n },\n ...(method === 'POST' ? { body: JSON.stringify(refreshControl ? msg.args ?? {} : { args: msg.args }) } : {}),\n });\n \n const resData = await res.json() as { error?: string };\n if (refreshControl && !res.ok) throw new Error(resData.error || 'Session controls are unavailable.');\n \n const responseMsg = {\n type: 'rpc_response',\n id: msg.id,\n result: resData\n };\n\n this.send(responseMsg);\n } catch (e: any) {\n this.log('error', `[TunnelClient] Failed to proxy rpc_request: ${e instanceof Error ? e.message : String(e)}`);\n this.send({\n type: 'rpc_response',\n id: msg.id,\n error: e.message\n });\n }\n }\n\n public destroy() {\n this.isDestroyed = true;\n if (this.heartbeat) clearInterval(this.heartbeat);\n if (this.reconnectTimeout) clearTimeout(this.reconnectTimeout);\n if (this.ws) {\n this.ws.close();\n this.ws = null;\n }\n }\n\n public disconnect() {\n this.destroy();\n }\n}\n","import { createClient } from '@open-wa/core';\nimport { Client as ClientFacade } from '@open-wa/client';\nimport { selectRuntimeDriver as selectSharedRuntimeDriver, resolveExecutablePath as resolveSharedExecutablePath, makeDefaultCallMediaHost, type DriverSelection } from './runtime-client';\nimport { eventRegistry } from '@open-wa/schema';\nimport { WAServer } from './server/hono-server';\nimport { resolveConfig, type PartialConfig, type Config, type TrackedConfig } from '@open-wa/config';\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { getCliOutputSink, type CliOutputSink } from './cli/output-sink';\nimport { TunnelClient } from './tunnel-client';\n\n/** The hosted open-wa router; `router: true` connects here. */\nconst DEFAULT_ROUTER_URL = 'https://router.openwa.cloud';\nimport {\n defaultChatSandboxPolicy,\n type ChatSandboxPolicy,\n type SandboxIsolation,\n} from '@open-wa/runtime-core';\nimport { makeNodeExecutionSandbox, observeBrowserProcessMemory } from '@open-wa/runtime-node';\n\nexport interface CliRuntimeResult {\n server: WAServer;\n client: ClientFacade;\n config: Config;\n events: ClientFacade['events'];\n dispose(): void;\n}\n\ninterface RuntimeEventPublisher {\n publish(eventName: string, payload: any): void;\n}\n\nfunction bridgeRuntimeEvents(\n openwaClient: Awaited<ReturnType<typeof createClient>>,\n publishRuntimeEvent: (eventName: string, payload: any) => void,\n): () => void {\n if (typeof openwaClient.events.onAny === 'function' && typeof openwaClient.events.offAny === 'function') {\n openwaClient.events.onAny(publishRuntimeEvent);\n return () => openwaClient.events.offAny(publishRuntimeEvent);\n }\n\n const unsubscribers: Array<() => void> = [];\n const bridgedEvents = new Set(eventRegistry.getAll().map((def) => def.meta.eventName));\n bridgedEvents.add('session.refresh.progress');\n\n bridgedEvents.forEach((eventName) => {\n const handler = (payload: any) => publishRuntimeEvent(eventName, payload);\n openwaClient.events.on(eventName as never, handler);\n unsubscribers.push(() => openwaClient.events.off(eventName as never, handler));\n });\n\n return () => {\n unsubscribers.forEach((unsubscribe) => unsubscribe());\n };\n}\n\nfunction attachLaunchNarration(\n openwaClient: Awaited<ReturnType<typeof createClient>>,\n sink: CliOutputSink,\n sessionId: string,\n): () => void {\n const unsubscribers: Array<() => void> = [];\n const on = (event: string, handler: (...args: any[]) => void) => {\n openwaClient.events.on(event as never, handler);\n unsubscribers.push(() => openwaClient.events.off(event as never, handler));\n };\n\n on('launch.auth.check.before', (event: any) => {\n sink.status({ phase: 'launch.auth', sessionId, detail: `Authenticating (timeout=${event?.details?.timeoutMs ?? '∞'}ms)` });\n });\n\n on('launch.auth.check.after', (event: any) => {\n sink.write({ level: 'info', message: `Auth detected via ${event?.details?.method ?? 'unknown'} (${event?.details?.isAuthenticated ? 'authenticated' : 'not-authenticated'})` });\n });\n\n on('launch.helper.pre_api.before', (event: any) => {\n sink.status({ phase: 'launch.helpers', sessionId, detail: event?.details?.mode === 'scripts' ? 'Injecting pre-API helper assets...' : 'Pre-API helpers already present' });\n });\n\n on('launch.helper.pre_api.after', (event: any) => {\n sink.write({ level: 'info', message: `Pre-API helper phase complete (${event?.details?.mode ?? 'unknown'})` });\n });\n\n on('internal_launch_progress', (event: any) => {\n const prefix = (event?.value || event?.value === 0) ? `${event.value}% ` : '';\n if (event?.text) sink.write({ level: 'info', message: `${prefix}${event.text}`.trim() });\n });\n\n on('critical_internal_message', (event: any) => {\n sink.write({ level: 'warn', message: `Internal launch message: ${event?.text ?? event?.value ?? 'unknown'}` });\n });\n\n on('launch.patch.init.before', (event: any) => {\n if (event?.details?.phase === 'preload') {\n sink.status({ phase: 'launch.patch', sessionId, detail: 'Downloading patches from CDN...' });\n }\n });\n\n on('launch.patch.init.after', (event: any) => {\n if (event?.details?.phase === 'preload') {\n const source = event?.details?.source ?? 'unknown';\n const tag = event?.details?.tag ? ` tag=${event.details.tag}` : '';\n const available = Array.isArray(event?.details?.available) ? event.details.available.length : 0;\n const durationMs = event?.durationMs;\n const durationStr = durationMs ? ` in ${(durationMs / 1000).toFixed(2)}s` : '';\n sink.write({ level: 'info', message: `Downloaded patches${durationStr} (source=${source}, available=${available}${tag})` });\n }\n });\n\n on('patch.init.before', (event: any) => {\n if (event?.details?.phase === 'apply') {\n const count = Array.isArray(event?.details?.patchIds) ? event.details.patchIds.length : 0;\n sink.status({ phase: 'launch.patch', sessionId, detail: `Installing patches (${count} queued)` });\n }\n });\n\n on('patch.apply.before', (event: any) => {\n sink.status({ phase: 'launch.patch', sessionId, detail: `Applying patch: ${event?.details?.patchId ?? 'unknown'}` });\n });\n\n on('patch.apply.after', (event: any) => {\n sink.write({\n level: event?.details?.outcome === 'failed' ? 'warn' : 'info',\n message: `Patch ${event?.details?.patchId ?? 'unknown'}: ${event?.details?.outcome ?? (event?.details?.applied ? 'applied' : 'unknown')}${event?.details?.detail ? ` — ${event.details.detail}` : ''}`,\n });\n });\n\n on('patch.init.after', (event: any) => {\n if (event?.details?.phase === 'apply') {\n const applied = Array.isArray(event?.details?.applied) ? event.details.applied : [];\n const outcome = event?.details?.outcome ?? 'unknown';\n const tag = applied.length > 0 ? applied.join(', ') : outcome;\n const durationMs = event?.durationMs;\n const durationStr = durationMs ? ` in ${(durationMs / 1000).toFixed(2)}s` : '';\n sink.write({\n level: event?.details?.blockingFailure ? 'warn' : 'info',\n message: `Patches Installed${durationStr}: ${tag}`,\n });\n }\n });\n\n on('launch.patch.integrity.before', () => {\n sink.status({ phase: 'launch.patch', sessionId, detail: 'Validating patched runtime...' });\n });\n\n on('launch.patch.integrity.after', (event: any) => {\n sink.write({ level: event?.details?.usable ? 'info' : 'warn', message: `Patched runtime validation: ${event?.details?.usable ? 'usable' : 'failed'}${event?.details?.failureReason ? ` (${event.details.failureReason})` : ''}` });\n });\n\n on('launch.license.check.before', (event: any) => {\n sink.status({ phase: 'launch.license', sessionId, detail: `Checking license (${event?.details?.source ?? 'local'})` });\n });\n\n on('launch.license.check.after', (event: any) => {\n sink.write({ level: event?.details?.blockingFailure ? 'warn' : 'info', message: `License check: ${event?.details?.status ?? 'unknown'}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('license.inject.before', () => {\n sink.status({ phase: 'launch.license', sessionId, detail: 'Injecting license payload...' });\n });\n\n on('license.inject.after', (event: any) => {\n sink.write({ level: event?.details?.success ? 'info' : 'warn', message: `License inject: ${event?.details?.success ? 'success' : 'failed'}${event?.details?.status ? ` (${event.details.status})` : ''}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('launch.auth.qr.generated', (event: any) => {\n const qrIndex = event?.details?.qrIndex ?? '?';\n sink.status({ phase: 'launch.auth', sessionId, detail: `QR code generated (#${qrIndex})` });\n });\n\n on('launch.client.finalize.before', (event: any) => {\n sink.status({ phase: 'launch.finalize', sessionId, detail: `Finalizing session (${event?.details?.validationStage ?? 'unknown'})` });\n });\n\n on('launch.client.finalize.after', (event: any) => {\n sink.write({ level: event?.details?.success ? 'info' : 'warn', message: `Finalize: ${event?.details?.outcome ?? 'unknown'}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('error', (event: any) => {\n const scope = event?.scope ?? 'unknown';\n const msg = event?.error?.message ?? String(event?.error ?? 'unknown error');\n const fatal = event?.fatal ? ' [FATAL]' : '';\n sink.write({ level: 'error', message: `${fatal} ${scope}: ${msg}`.trim() });\n });\n\n return () => {\n unsubscribers.forEach((unsubscribe) => unsubscribe());\n };\n}\n\nconst CHROME_CACHE_FILE = resolve(process.cwd(), '.open-wa', 'chrome-executable-path.json');\n\ninterface ChromePathCacheRecord {\n executablePath?: string;\n updatedAt?: string;\n}\n\ninterface ExecutablePathResolution {\n executablePath?: string;\n source:\n | 'config'\n | 'cache'\n | 'chrome_installation'\n | 'driver_default'\n | 'lightpanda_config'\n | 'lightpanda_managed'\n | 'managed_browser';\n warning?: string;\n}\n\nexport interface ParsedCliArgs {\n procName: string;\n pm2: boolean;\n forwardedArgs: string[];\n configPath?: string;\n cliOverrides: PartialConfig;\n verbose: boolean;\n unsupportedWarnings: string[];\n}\n\nexport function getChromeCacheFilePath(): string {\n return CHROME_CACHE_FILE;\n}\n\nexport function readChromePathCache(cacheFilePath: string = getChromeCacheFilePath()): ChromePathCacheRecord | undefined {\n if (!existsSync(cacheFilePath)) {\n return undefined;\n }\n\n try {\n const raw = JSON.parse(readFileSync(cacheFilePath, 'utf8')) as ChromePathCacheRecord;\n if (!raw || typeof raw !== 'object') {\n return undefined;\n }\n\n return {\n executablePath: typeof raw.executablePath === 'string' ? raw.executablePath : undefined,\n updatedAt: typeof raw.updatedAt === 'string' ? raw.updatedAt : undefined,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function writeChromePathCache(executablePath: string, cacheFilePath: string = getChromeCacheFilePath()): void {\n mkdirSync(dirname(cacheFilePath), { recursive: true });\n writeFileSync(cacheFilePath, JSON.stringify({ executablePath, updatedAt: new Date().toISOString() }, null, 2), 'utf8');\n}\n\nexport function clearChromePathCache(cacheFilePath: string = getChromeCacheFilePath()): void {\n if (existsSync(cacheFilePath)) {\n rmSync(cacheFilePath, { force: true });\n }\n}\n\nexport function isUsableExecutablePath(executablePath?: string): executablePath is string {\n return !!executablePath && existsSync(executablePath);\n}\n\nfunction getExplicitUseChromePreference(rawConfigs?: TrackedConfig['rawConfigs']): boolean | undefined {\n const explicitConfigSources = [\n rawConfigs?.file,\n rawConfigs?.env,\n rawConfigs?.cli,\n rawConfigs?.programmatic,\n ];\n\n for (let index = explicitConfigSources.length - 1; index >= 0; index -= 1) {\n const source = explicitConfigSources[index];\n if (source?.useChrome !== undefined) {\n return source.useChrome;\n }\n }\n\n return undefined;\n}\n\nexport function shouldPreferLocalChrome(config: Config, rawConfigs?: TrackedConfig['rawConfigs']): boolean {\n if (config.useLightpanda || config.useChromium || config.browser?.kind === 'chromium') {\n return false;\n }\n\n if (config.executablePath) {\n return false;\n }\n\n const explicitUseChrome = getExplicitUseChromePreference(rawConfigs);\n if (explicitUseChrome !== undefined) {\n return explicitUseChrome;\n }\n\n return true;\n}\n\nfunction getVal(argv: string[], flag: string): string | undefined {\n const index = argv.findIndex(arg => arg === flag);\n return index !== -1 ? argv[index + 1] : undefined;\n}\n\nfunction parseSandboxIsolation(value: string): SandboxIsolation {\n switch (value) {\n case 'worker':\n case 'process':\n case 'container':\n return value;\n default:\n throw new Error(`Invalid --sandbox-isolation value: ${value}`);\n }\n}\n\nexport function resolveChatSandboxPolicy(config: Config['sandboxChats']): ChatSandboxPolicy | undefined {\n if (!config) return undefined;\n\n const overrides = typeof config === 'object'\n ? config as Partial<Omit<ChatSandboxPolicy, 'chats'>>\n : {};\n return {\n ...defaultChatSandboxPolicy,\n ...overrides,\n chats: true,\n networkAllowlist: [...(overrides.networkAllowlist ?? defaultChatSandboxPolicy.networkAllowlist)],\n env: overrides.env === 'none' || overrides.env === undefined\n ? overrides.env ?? defaultChatSandboxPolicy.env\n : [...overrides.env],\n capabilities: [...(overrides.capabilities ?? defaultChatSandboxPolicy.capabilities)],\n };\n}\n\nexport function parseCliArgs(argv: string[] = process.argv.slice(2)): ParsedCliArgs {\n const cliOverrides: PartialConfig = {};\n const unsupportedWarnings: string[] = [];\n let verbose = false;\n let configPath: string | undefined;\n\n const sessionId = getVal(argv, '--session-id');\n if (sessionId) cliOverrides.sessionId = sessionId;\n\n const portValue = getVal(argv, '--port') || getVal(argv, '-p');\n if (portValue) cliOverrides.port = parseInt(portValue, 10);\n\n const host = getVal(argv, '--host') || getVal(argv, '-h');\n if (host) cliOverrides.host = host;\n\n const apiKey = getVal(argv, '--api-key') || getVal(argv, '--key') || getVal(argv, '-k');\n if (apiKey) cliOverrides.apiKey = apiKey;\n\n const logLevel = getVal(argv, '--log-level');\n if (logLevel) cliOverrides.logLevel = logLevel;\n\n if (argv.includes('--no-ezqr')) cliOverrides.ezqr = false;\n if (argv.includes('--headful')) cliOverrides.headless = false;\n if (argv.includes('--headless')) cliOverrides.headless = true;\n const browserFlags = ['--use-chrome', '--use-chromium', '--use-lightpanda'].filter(flag => argv.includes(flag) || flag === '--use-lightpanda' && argv.includes('--lightpanda'));\n if (browserFlags.length > 1) throw new Error('Choose only one of --use-chrome, --use-chromium or --use-lightpanda.');\n if (browserFlags.length) {\n cliOverrides.useChrome = browserFlags[0] === '--use-chrome';\n cliOverrides.useChromium = browserFlags[0] === '--use-chromium';\n cliOverrides.useLightpanda = browserFlags[0] === '--use-lightpanda';\n }\n if (argv.includes('--log-console')) cliOverrides.logConsole = true;\n if (argv.includes('--aggressive-garbage-collection')) cliOverrides.aggressiveGarbageCollection = true;\n if (argv.includes('--no-dashboard')) cliOverrides.dashboard = false;\n if (argv.includes('--ephemeral')) cliOverrides.ephemeral = true;\n if (argv.includes('--sandbox-chats')) cliOverrides.sandboxChats = true;\n\n const sandboxIsolation = getVal(argv, '--sandbox-isolation');\n if (sandboxIsolation) {\n const { chats: _chats, ...sandboxDefaults } = defaultChatSandboxPolicy;\n cliOverrides.sandboxChats = {\n ...sandboxDefaults,\n isolation: parseSandboxIsolation(sandboxIsolation),\n networkAllowlist: [...defaultChatSandboxPolicy.networkAllowlist],\n env: defaultChatSandboxPolicy.env === 'none'\n ? 'none'\n : [...defaultChatSandboxPolicy.env],\n capabilities: [...defaultChatSandboxPolicy.capabilities],\n };\n }\n\n const qrTimeout = getVal(argv, '--qr-timeout');\n if (qrTimeout) cliOverrides.qrTimeout = parseInt(qrTimeout, 10);\n\n const dashboardPort = getVal(argv, '--dashboard-port');\n if (dashboardPort) cliOverrides.dashboardPort = parseInt(dashboardPort, 10);\n\n const licenseKey = getVal(argv, '--license-key') || getVal(argv, '-l');\n if (licenseKey) cliOverrides.licenseKey = licenseKey;\n\n const webhook = getVal(argv, '--webhook') || getVal(argv, '-w');\n if (webhook) cliOverrides.webhook = webhook;\n\n const proxyHost = getVal(argv, '--proxy-host');\n if (proxyHost) cliOverrides.proxyHost = proxyHost;\n\n const proxyToken = getVal(argv, '--proxy-token');\n if (proxyToken) cliOverrides.proxyToken = proxyToken;\n\n if (argv.includes('--router')) cliOverrides.router = true;\n if (argv.includes('--mcp')) cliOverrides.mcp = { enabled: true };\n\n const readyWebhook = getVal(argv, '--ready-webhook');\n if (readyWebhook) unsupportedWarnings.push(`--ready-webhook was provided (${readyWebhook}) but ready-webhook delivery is not yet wired in v5 CLI.`);\n\n if (argv.includes('-v') || argv.includes('--verbose')) {\n verbose = true;\n cliOverrides.disableSpins = true;\n cliOverrides.logConsole = true;\n cliOverrides.logLevel = cliOverrides.logLevel || 'debug';\n }\n\n if (argv.includes('--stats')) {\n unsupportedWarnings.push('--stats was provided but swagger-stats parity is not restored; v5 only exposes the compatibility redirect/deprecation route.');\n }\n\n if (argv.includes('--generate-api-docs')) {\n unsupportedWarnings.push('--generate-api-docs was provided; runtime docs are always served from the shared API layer and no separate collection generation step currently runs at CLI boot.');\n }\n\n if (argv.includes('--tunnel')) {\n unsupportedWarnings.push('--tunnel was provided but tunnel setup parity is not yet restored in the v5 CLI.');\n }\n\n if (argv.includes('--chatwoot-url') || argv.includes('--twilio-webhook') || argv.includes('--bot-press-url')) {\n unsupportedWarnings.push('Legacy integration flags (Chatwoot/Twilio/BotPress) were provided but are not yet wired into the v5 CLI boot path.');\n }\n\n if (argv.includes('--use-session-id-in-path') && sessionId) {\n cliOverrides.sessionId = sessionId;\n }\n\n configPath = getVal(argv, '--config') || getVal(argv, '-c');\n\n const procName = getVal(argv, '--name') || sessionId || '@OPEN-WA EASY API';\n const pm2 = argv.includes('--pm2');\n\n return {\n procName,\n pm2,\n forwardedArgs: argv,\n configPath,\n cliOverrides,\n verbose,\n unsupportedWarnings,\n };\n}\n\nexport async function resolveExecutablePath(\n config: Config,\n options: { preferLocalChrome?: boolean; cacheFilePath?: string } = {},\n): Promise<ExecutablePathResolution> {\n return resolveSharedExecutablePath(config, {\n ...options,\n cacheFilePath: options.cacheFilePath ?? getChromeCacheFilePath(),\n kind: config.useChromium || config.browser?.kind === 'chromium' ? 'chromium' : 'chrome',\n });\n}\n\nasync function selectRuntimeDriver(config: Config, rawConfigs?: TrackedConfig['rawConfigs'], nonInteractive = false): Promise<DriverSelection> {\n return selectSharedRuntimeDriver(config, {\n rawConfigs,\n cacheFilePath: getChromeCacheFilePath(),\n promptForMissingBrowser: true,\n nonInteractive,\n });\n}\n\nfunction printStartupSummary(\n config: Config,\n resolution: ExecutablePathResolution,\n preferLocalChrome: boolean,\n engineLabel: DriverSelection['engineLabel'],\n) {\n const host = config.host.includes('http') ? config.host : `http://${config.host}`;\n const sink = getCliOutputSink();\n sink.write({ level: 'info', message: `Easy API session: ${config.sessionId}` });\n sink.write({ level: 'info', message: `Health: ${host}:${config.port}/health` });\n sink.write({ level: 'info', message: `API Explorer: ${host}:${config.port}/api-docs/` });\n sink.write({ level: 'info', message: `Swagger JSON: ${host}:${config.port}/meta/swagger.json` });\n sink.write({ level: 'info', message: `Postman JSON: ${host}:${config.port}/meta/postman.json` });\n sink.write({ level: 'info', message: `Browser mode: ${config.headless ? 'headless' : 'headful'}` });\n sink.write({ level: 'info', message: `Browser engine: ${engineLabel}` });\n if (config.dashboard) {\n sink.write({ level: 'info', message: `Dashboard: ${host}:${config.port}/dashboard/` });\n } else {\n sink.write({ level: 'info', message: 'Dashboard: disabled (--no-dashboard)' });\n }\n if (resolution.source === 'lightpanda_config' && resolution.executablePath) {\n sink.write({ level: 'info', message: `Browser executable: explicit Lightpanda override (${resolution.executablePath})` });\n } else if (resolution.source === 'lightpanda_managed') {\n sink.write({ level: 'info', message: `Browser executable: Lightpanda with experimental WhatsApp setup (${resolution.executablePath})` });\n } else if (resolution.source === 'config' && config.executablePath) {\n sink.write({ level: 'info', message: `Browser executable: explicit override (${config.executablePath})` });\n } else if (resolution.source === 'cache') {\n sink.write({ level: 'info', message: `Browser executable: cached browser (${resolution.executablePath})` });\n } else if (resolution.source === 'chrome_installation') {\n sink.write({ level: 'info', message: `Browser executable: installed ${config.browser?.kind === 'chromium' ? 'Chromium' : 'Chrome'} (${resolution.executablePath})` });\n } else if (resolution.source === 'managed_browser') {\n sink.write({ level: 'info', message: `Browser executable: managed ${config.browser?.kind === 'chromium' ? 'Chromium' : 'Chrome'} (${resolution.executablePath})` });\n }\n if (config.webhook) {\n sink.write({\n level: 'warn',\n message: `Webhook configured (${config.webhook}) but v5 CLI webhook registration parity is not yet restored.`,\n });\n }\n}\n\nexport async function start(parsedArgs: ParsedCliArgs = parseCliArgs()): Promise<CliRuntimeResult> {\n const { configPath, cliOverrides, verbose, unsupportedWarnings } = parsedArgs;\n const sink = getCliOutputSink();\n\n sink.status({ phase: 'boot' });\n\n const { config, sources, configFilePath, rawConfigs } = await resolveConfig({\n configPath,\n cliOverrides: {\n disableSpins: true,\n apiLifecycle: 'hybrid',\n // Let schema defaults, config files, and WA_HOST/WA_PORT resolve\n // before applying host/port flags actually supplied by the user.\n ...cliOverrides,\n },\n includeRawConfigs: true,\n verbose,\n });\n\n if (verbose) {\n sink.write({ level: 'info', message: `Config sources: ${sources.join(', ')}` });\n if (configFilePath) {\n sink.write({ level: 'info', message: `Config file: ${configFilePath}` });\n }\n }\n\n sink.status({ phase: 'config.resolved', sessionId: config.sessionId });\n\n unsupportedWarnings.forEach((warning) => sink.write({ level: 'warn', message: `Compatibility warning: ${warning}` }));\n\n const driverSelection = await selectRuntimeDriver(config, rawConfigs, parsedArgs.forwardedArgs.includes('--non-interactive'));\n const { driver, engineLabel, executableResolution, preferLocalChrome } = driverSelection;\n if (executableResolution.warning) {\n sink.write({ level: 'warn', message: executableResolution.warning });\n }\n\n const server = new WAServer(config, verbose);\n sink.status({ phase: 'server.starting', sessionId: config.sessionId });\n\n await server.start();\n sink.status({ phase: 'server.started', sessionId: config.sessionId });\n\n // A self-hosted proxy (with a token) connects as soon as the API listens, so the session is reachable while\n // it links. The licensed router (no token) connects once WhatsApp is ready, because it checks the license\n // against this account's number.\n let tunnel: TunnelClient | undefined;\n const proxyHost = config.proxyHost ?? (config.router ? DEFAULT_ROUTER_URL : undefined);\n const tunnelLog = (level: 'info' | 'warn' | 'error', message: string) => sink.write({ level, message });\n if (proxyHost && !config.apiKey) {\n // The proxy forwards requests unchanged, so the API key is the only check on them.\n sink.write({ level: 'error', message: 'Not connecting to the session proxy: set an API key (--api-key or apiKey) first, because the proxy makes this API reachable from the internet.' });\n } else if (config.proxyHost && config.proxyToken) {\n sink.write({ level: 'info', message: `Connecting to the session proxy at ${config.proxyHost}...` });\n tunnel = new TunnelClient({\n proxyHost: config.proxyHost,\n proxyToken: config.proxyToken,\n sessionId: config.sessionId,\n localSessionPort: config.port,\n localApiKey: config.apiKey,\n log: tunnelLog,\n });\n tunnel.connect();\n }\n const connectLicensedRouter = async () => {\n if (!proxyHost || config.proxyToken || !config.apiKey || tunnel) return;\n try {\n const number = String(await client.getHostNumber()).replace(/\\D/g, '');\n const key = await resolveRouterLicenseKey(config.licenseKey, config.sessionId, number);\n if (!key) {\n sink.write({ level: 'error', message: 'Not connecting to the open-wa router: it needs a license key for this number (--license-key or licenseKey).' });\n return;\n }\n sink.write({ level: 'info', message: `Connecting to the open-wa router at ${proxyHost}...` });\n tunnel = new TunnelClient({\n proxyHost, sessionId: config.sessionId, localSessionPort: config.port, localApiKey: config.apiKey,\n license: { key, number }, log: tunnelLog,\n onAddress: address => {\n const mcp = config.mcp?.enabled ? `\\n ChatGPT / MCP server URL: ${address}${config.mcp.path || '/mcp'}` : '';\n sink.write({ level: 'info', message: `Your public address: ${address}${mcp}` });\n },\n });\n tunnel.connect();\n } catch (error) {\n sink.write({ level: 'error', message: `Could not connect to the open-wa router: ${error instanceof Error ? error.message : String(error)}` });\n }\n };\n\n printStartupSummary(config, executableResolution, preferLocalChrome, engineLabel);\n\n sink.status({ phase: 'client.starting', sessionId: config.sessionId });\n sink.write({ level: 'info', message: 'Starting WhatsApp Client...' });\n\n const sandboxPolicy = resolveChatSandboxPolicy(config.sandboxChats);\n const executionSandbox = sandboxPolicy\n ? makeNodeExecutionSandbox({ workspacePath: process.cwd() })\n : undefined;\n\n const openwaClient = await createClient({\n sessionId: config.sessionId,\n pluginRefs: config.plugins,\n pluginConfig: config.pluginConfig,\n hooks: config.hooks,\n eventMode: config.eventMode,\n driver,\n deleteSessionDataOnLogout: config.deleteSessionDataOnLogout,\n killClientOnLogout: config.killClientOnLogout,\n sessionDataPath: config.sessionDataPath,\n sessionData: config.sessionData,\n skipSessionSave: config.skipSessionSave,\n sessionDataBucketAuth: config.sessionDataBucketAuth,\n sessionDataEncryptionKey: config.sessionDataEncryptionKey,\n sessionDataEncryptionKeyFile: config.sessionDataEncryptionKeyFile,\n s3Sync: config.s3Sync,\n debug: config.logLevel === 'debug' || verbose || config.logConsole,\n headless: config.headless,\n qrTimeoutMs: typeof config.qrTimeout === 'number' ? config.qrTimeout * 1000 : undefined,\n authTimeoutMs: typeof config.authTimeout === 'number' ? config.authTimeout * 1000 : undefined,\n executablePath: executableResolution.executablePath,\n browserArgs: config.chromiumArgs,\n browser: config.browser,\n allowDangerousBrowserArgs: config.allowDangerousBrowserArgs,\n userDataDir: config.userDataDir,\n ephemeral: config.ephemeral,\n linkCode: config.linkCode,\n logConsole: config.logConsole,\n logConsoleErrors: config.logConsoleErrors,\n blockCrashLogs: config.blockCrashLogs,\n blockAssets: config.blockAssets,\n safeMode: config.safeMode,\n lightpanda: config.useLightpanda ? { experimentalWhatsApp: true, ...config.lightpanda } : undefined,\n licenseKey: config.licenseKey as any,\n licenseConfig: config.licenseConfig,\n patchConfig: { ghPatch: config.ghPatch, cachedPatch: config.cachedPatch },\n calling: config.calling,\n callMediaHost: makeDefaultCallMediaHost(),\n sandboxPolicy,\n executionSandbox,\n memoryObservation: (observability, getBrowserProcessId) => observeBrowserProcessMemory(\n observability,\n getBrowserProcessId,\n { attributes: { session: config.sessionId } },\n ),\n });\n\n server.setReadinessProvider(() => ({ ...openwaClient.getReadiness(), state: openwaClient.getState() }));\n const detachLaunchNarration = attachLaunchNarration(openwaClient, sink, config.sessionId);\n\n openwaClient.events.on('launch.auth.qr.expired', () => server.setQR(null));\n openwaClient.events.on('launch.auth.qr.scanned', () => server.setQR(null));\n openwaClient.events.on('launch.auth.qr.generated', (event) => {\n const qr = event.details?.qr;\n if (!qr) {\n return;\n }\n\n if (config.qrLogSkip) {\n sink.write({ level: 'info', message: 'New QR Code generated. Not printing in console because qrLogSkip is set to true' });\n } else {\n sink.status({ phase: 'auth.qr', sessionId: config.sessionId, detail: 'QR code generated' });\n sink.qr({ qr, sessionId: config.sessionId });\n }\n\n server.setQR(qr);\n });\n\n openwaClient.events.on('launch.auth.linkCode.generated', (event) => {\n const linkCode = event.details?.linkCode;\n if (!linkCode) {\n return;\n }\n\n sink.status({\n phase: 'launch.auth',\n sessionId: config.sessionId,\n detail: 'Link code generated; enter it on the paired phone',\n });\n sink.write({\n level: 'info',\n message: `Link code (local console only): ${linkCode}`,\n });\n });\n\n const client = new ClientFacade({\n client: openwaClient,\n transport: openwaClient.getTransport(),\n });\n\n server.setClient(client as any);\n server.mountPlugins(openwaClient.plugins);\n\n const runtimeBridgeListeners = new Set<(event: string, value: any) => void>();\n const runtimeEventPublishers: RuntimeEventPublisher[] = [\n {\n publish: (eventName, payload) => {\n runtimeBridgeListeners.forEach((listener) => {\n listener(eventName, payload);\n });\n },\n },\n ];\n\n const publishRuntimeEvent = (eventName: string, payload: any) => {\n runtimeEventPublishers.forEach((publisher) => {\n publisher.publish(eventName, payload);\n });\n };\n\n const detachRuntimeBridge = bridgeRuntimeEvents(openwaClient, publishRuntimeEvent);\n\n // Bridge core events to the socket manager so dashboard clients\n // receive live events when they send register_ev.\n if (typeof server.setEventBridge === 'function') {\n server.setEventBridge({\n onAny: (listener: (event: string, value: any) => void) => {\n runtimeBridgeListeners.add(listener);\n },\n offAny: (listener: (event: string, value: any) => void) => {\n runtimeBridgeListeners.delete(listener);\n },\n });\n }\n\n const handleBrowserInit = async () => {\n const page = openwaClient.getTransport().getPage();\n if (page) {\n await server.setPage(page as any).catch(() => {});\n }\n };\n openwaClient.events.on('launch.browser.init.after', handleBrowserInit);\n\n let disposed = false;\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n tunnel?.destroy();\n detachRuntimeBridge();\n openwaClient.events.off('launch.browser.init.after', handleBrowserInit);\n runtimeBridgeListeners.clear();\n };\n\n try {\n await client.start();\n } catch (startError) {\n const msg = startError instanceof Error ? startError.message : String(startError);\n sink.write({ level: 'error', message: `Bootstrap failed: ${msg}` });\n sink.write({ level: 'warn', message: 'The API server is still running for inspection; the client failed to start.' });\n sink.write({ level: 'warn', message: 'The server is running — use /health and /api-docs to inspect state.' });\n detachLaunchNarration();\n return { server, client, config, events: openwaClient.events, dispose };\n }\n\n const readiness = openwaClient.getReadiness();\n sink.status({\n phase: 'client.ready',\n sessionId: config.sessionId,\n detail: `status=${readiness.status}, exposureSafe=${readiness.exposureSafe}`,\n });\n sink.write({\n level: 'info',\n message: `WhatsApp Client ready with state: ${client.getState()} (status=${readiness.status}, exposureSafe=${readiness.exposureSafe})`,\n });\n\n void connectLicensedRouter();\n detachLaunchNarration();\n return { server, client, config, events: openwaClient.events, dispose };\n}\n\n/** The router checks one key per number; `licenseKey` may be a key, a number-to-key map, or a function. */\nasync function resolveRouterLicenseKey(licenseKey: Config['licenseKey'], sessionId: string, number: string): Promise<string | undefined> {\n if (typeof licenseKey === 'string') return licenseKey.trim() || undefined;\n if (typeof licenseKey === 'function') {\n const value = await (licenseKey as (sessionId: string, number: string) => unknown)(sessionId, number);\n return typeof value === 'string' && value.trim() ? value.trim() : undefined;\n }\n if (licenseKey && typeof licenseKey === 'object') {\n const record = licenseKey as Record<string, string>;\n return record[number] ?? record[`${number}@c.us`] ?? undefined;\n }\n return undefined;\n}\n\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<CliRuntimeResult | void> {\n if (argv[0] === 'init') {\n const { initProject } = await import('./cli/init');\n await initProject(argv.slice(1));\n return;\n }\n const parsedArgs = parseCliArgs(argv);\n\n if (parsedArgs.pm2) {\n const { spawn } = require('child_process');\n const sink = getCliOutputSink();\n const pm2Command = getPm2Command();\n const pm2SpawnOptions = getPm2SpawnOptions();\n try {\n const pm2 = spawn(pm2Command, ['--version'], pm2SpawnOptions);\n\n await new Promise<void>((resolve, reject) => {\n pm2.on('error', reject);\n pm2.on('exit', (code: number | null) => {\n if (code === 0) {\n resolve();\n return;\n }\n\n reject(new Error(`pm2 probe exited with code ${code ?? 'unknown'}`));\n });\n pm2.stdout.on('data', () => resolve());\n });\n\n const pm2Flags = parsedArgs.forwardedArgs.filter((flag: string) => flag !== '--pm2');\n const cliPath = fileURLToPath(new URL('../dist/cli.cjs', import.meta.url));\n\n spawn(pm2Command, [\n 'start',\n cliPath,\n '--name', parsedArgs.procName,\n '--stop-exit-codes', '88',\n '--',\n ...pm2Flags,\n ], {\n ...pm2SpawnOptions,\n stdio: 'inherit',\n detached: true\n });\n return;\n } catch (error: unknown) {\n if (isCommandNotFoundError(error)) {\n sink.write({ level: 'error', message: 'pm2 not found. Please install with: npm install -g pm2' });\n return;\n }\n throw error;\n }\n }\n\n return await start(parsedArgs);\n}\n\nfunction getPm2Command(): string {\n return process.platform === 'win32' ? 'pm2.cmd' : 'pm2';\n}\n\nfunction getPm2SpawnOptions(): { shell: boolean } {\n return { shell: process.platform === 'win32' };\n}\n\nfunction isCommandNotFoundError(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) {\n return false;\n }\n\n const systemError = error as { code?: unknown; errno?: unknown };\n return systemError.code === 'ENOENT' || systemError.errno === -2;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAa,WAAb,cAA8BA,aAAAA,UAAU;CACtC,YAAY,QAAgB,UAAU,OAAO;EAC3C,MAAM;GAAE;GAAQ;EAAQ,CAAC;CAC3B;AACF;;;ACoCA,eAAsB,aAAa,UAAkB,SAA6C;CAChG,IAAI,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,OAAO,OAC1C,MAAM,IAAI,MAAM,oHAAoH;CAEtI,MAAM,EAAE,oBAAoB,MAAM,OAAO;CACzC,MAAM,WAAW,gBAAgB;EAAE,OAAO,QAAQ;EAAO,QAAQ,QAAQ;CAAO,CAAC;CACjF,MAAM,QAAQ,IAAI,gBAAgB;CAClC,SAAS,GAAG,gBAAgB,MAAM,MAAM,CAAC;CACzC,SAAS,GAAG,eAAe,MAAM,MAAM,CAAC;CACxC,IAAI;EACF,QAAQ,OAAO,MAAM,KAAK,SAAS,IAAI,QAAQ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KAAK,GAAG;IAC/B,KAAK,MAAM;KAAE,OAAO;KAAS,SAAS;IAAyD,CAAC;IAChG;GACJ;GACA,MAAM;EACV;CACJ;CAEA,OAAO,MAAM,MAAM,UAAU;AACjC;AAEA,SAAS,gBAAwB;CAC7B,OAAO,QAAQ,aAAa,UAAU,YAAY;AACtD;AAEA,SAAS,qBAAyC;CAC9C,OAAO,EAAE,OAAO,QAAQ,aAAa,QAAQ;AACjD;AAEA,SAAS,uBAAuB,OAAyB;CACrD,IAAI,OAAO,UAAU,YAAY,UAAU,MACvC,OAAO;CAGX,MAAM,cAAc;CACpB,OAAO,YAAY,SAAS,YAAY,YAAY,UAAU;AAClE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runtime-CzBEJMQd.d.cts","names":["ClientFacade"],"sources":["../src/server/hono-server.ts","../src/cli-runtime.ts"],"mappings":";;;;;cAGa,iBAAiB;EAC5B,YAAY,QAAQ,QAAQ;;;;
|
|
1
|
+
{"version":3,"file":"cli-runtime-CzBEJMQd.d.cts","names":["ClientFacade"],"sources":["../src/server/hono-server.ts","../src/cli-runtime.ts"],"mappings":";;;;;cAGa,iBAAiB;EAC5B,YAAY,QAAQ,QAAQ;;;;UCiBb;EACb,QAAQ;EACR,QAAQA;EACR,QAAQ;EACR,QAAQA;EACR;;UAyLa;EACb;EACA;EACA;EACA;EACA,cAAc;EACd;EACA;;iBA+GY,aAAa,kBAAyC;iBAmLhD,MAAM,aAAY,gBAAiC,QAAQ;iBAyR3D,KAAK,kBAAyC,QAAQ"}
|
package/dist/cli.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const require_cli_runtime = require("./cli-runtime-
|
|
3
|
+
const require_cli_runtime = require("./cli-runtime-B3ABNLz4.cjs");
|
|
4
4
|
//#region src/cli.ts
|
|
5
5
|
if (require.main === module) require_cli_runtime.main().catch((err) => {
|
|
6
6
|
require_cli_runtime.getCliOutputSink().write({
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_cli_runtime = require("./cli-runtime-
|
|
2
|
+
const require_cli_runtime = require("./cli-runtime-B3ABNLz4.cjs");
|
|
3
3
|
let _open_wa_api = require("@open-wa/api");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
let _open_wa_logger = require("@open-wa/logger");
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-wa/wa-automate",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.
|
|
4
|
+
"version": "5.12.0",
|
|
5
5
|
"description": "WhatsApp automation CLI and API server",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
7
7
|
"types": "./dist/index.d.cts",
|
|
@@ -20,26 +20,27 @@
|
|
|
20
20
|
"skills"
|
|
21
21
|
],
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@open-wa/create": "5.
|
|
23
|
+
"@open-wa/create": "5.12.0",
|
|
24
24
|
"@elastic/elasticsearch": "^9.5.1",
|
|
25
25
|
"@hono/node-server": "^2.1.1",
|
|
26
|
-
"@open-wa/api": "5.
|
|
27
|
-
"@open-wa/client": "5.
|
|
28
|
-
"@open-wa/config": "5.
|
|
29
|
-
"@open-wa/core": "5.
|
|
30
|
-
"@open-wa/driver-interface": "5.
|
|
31
|
-
"@open-wa/driver-lightpanda": "5.
|
|
32
|
-
"@open-wa/driver-puppeteer": "5.
|
|
33
|
-
"@open-wa/logger": "5.
|
|
34
|
-
"@open-wa/runtime-core": "5.
|
|
35
|
-
"@open-wa/runtime-node": "5.
|
|
36
|
-
"@open-wa/schema": "5.
|
|
37
|
-
"@open-wa/session-sync": "5.
|
|
26
|
+
"@open-wa/api": "5.12.0",
|
|
27
|
+
"@open-wa/client": "5.12.0",
|
|
28
|
+
"@open-wa/config": "5.12.0",
|
|
29
|
+
"@open-wa/core": "5.12.0",
|
|
30
|
+
"@open-wa/driver-interface": "5.12.0",
|
|
31
|
+
"@open-wa/driver-lightpanda": "5.12.0",
|
|
32
|
+
"@open-wa/driver-puppeteer": "5.12.0",
|
|
33
|
+
"@open-wa/logger": "5.12.0",
|
|
34
|
+
"@open-wa/runtime-core": "5.12.0",
|
|
35
|
+
"@open-wa/runtime-node": "5.12.0",
|
|
36
|
+
"@open-wa/schema": "5.12.0",
|
|
37
|
+
"@open-wa/session-sync": "5.12.0",
|
|
38
38
|
"boxen": "^9.0.0",
|
|
39
39
|
"chrome-launcher": "^1.2.1",
|
|
40
40
|
"effect": "4.0.2",
|
|
41
41
|
"hono": "^4.13.9",
|
|
42
|
-
"qrcode-terminal": "^0.12.0"
|
|
42
|
+
"qrcode-terminal": "^0.12.0",
|
|
43
|
+
"ws": "^8.22.0"
|
|
43
44
|
},
|
|
44
45
|
"devDependencies": {
|
|
45
46
|
"typescript": "^7.0.2",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli-runtime-C_VOjxxp.cjs","names":["ApiServer","join","homedir","toPublicError","readFile","stat","access","constants","dirname","mkdir","mkdtemp","rm","writeFile","rename","existsSync","readFileSync","dirname","statSync","constants","findSystemBrowser","selectRuntimeDriver","ConfigSchema","resolveConfig","resolve","eventRegistry","resolve","defaultChatSandboxPolicy","selectSharedRuntimeDriver","resolveConfig","makeNodeExecutionSandbox","createClient","observeBrowserProcessMemory","ClientFacade","fileURLToPath"],"sources":["../src/server/hono-server.ts","../src/cli/output-sink.ts","../src/browser-choice.ts","../src/runtime-client.ts","../src/cli-runtime.ts"],"sourcesContent":["import { ApiServer, createApiServer as createSharedApiServer } from '@open-wa/api';\nimport type { Config } from '@open-wa/config';\n\nexport class WAServer extends ApiServer {\n constructor(config: Config, verbose = false) {\n super({ config, verbose });\n }\n}\n\nexport function createApiServer(config: Config) {\n return createSharedApiServer(config);\n}\n","import qrcode from 'qrcode-terminal';\n\nexport type CliOutputLevel = 'debug' | 'info' | 'warn' | 'error';\n\nexport interface CliOutputEntry {\n level: CliOutputLevel;\n message: string;\n meta?: Record<string, unknown>;\n}\n\nexport interface CliStatusUpdate {\n phase:\n | 'boot'\n | 'config.resolved'\n | 'server.starting'\n | 'server.started'\n | 'client.starting'\n | 'launch.auth'\n | 'launch.helpers'\n | 'launch.patch'\n | 'launch.license'\n | 'launch.finalize'\n | 'auth.qr'\n | 'client.ready'\n | 'shutdown.starting'\n | 'shutdown.complete'\n | 'error';\n detail?: string;\n sessionId?: string;\n}\n\nexport interface CliQrPayload {\n qr: string;\n sessionId: string;\n}\n\nexport interface CliOutputSink {\n write(entry: CliOutputEntry): void;\n status(update: CliStatusUpdate): void;\n qr(payload: CliQrPayload): void;\n promptChoice?(question: string, choices: readonly string[]): Promise<number>;\n}\n\nexport async function promptChoice(question: string, choices: readonly string[]): Promise<number> {\n if (!process.stdin.isTTY || !process.stderr.isTTY) {\n throw new Error('No browser is installed. Choose --use-chrome, --use-chromium or --use-lightpanda to download one without a prompt.');\n }\n const { createInterface } = await import('node:readline/promises');\n const readline = createInterface({ input: process.stdin, output: process.stderr });\n const abort = new AbortController();\n readline.on('SIGINT', () => abort.abort());\n readline.on('close', () => abort.abort());\n try {\n process.stderr.write(`\\n${question}\\n${choices.map((choice, index) => ` ${index + 1}. ${choice}`).join('\\n')}\\n`);\n while (true) {\n const answer = (await readline.question('Choose a browser [1]: ', { signal: abort.signal })).trim();\n const choice = answer === '' ? 0 : Number(answer) - 1;\n if (Number.isInteger(choice) && choice >= 0 && choice < choices.length) return choice;\n process.stderr.write(`Enter a number from 1 to ${choices.length}.\\n`);\n }\n } catch (cause) {\n throw new Error('Browser selection cancelled.', { cause });\n } finally {\n readline.close();\n }\n}\n\nfunction writeToConsole(level: CliOutputLevel, message: string): void {\n if (level === 'warn') {\n console.warn(message);\n return;\n }\n\n if (level === 'error') {\n console.error(message);\n return;\n }\n\n console.log(message);\n}\n\nexport function createConsoleOutputSink(): CliOutputSink {\n return {\n promptChoice,\n write(entry) {\n writeToConsole(entry.level, entry.message);\n },\n status() {\n // Status updates are semantic signals for richer presenters.\n },\n qr(payload) {\n qrcode.generate(payload.qr, { small: true }, (terminalQrCode) => {\n console.log(`WhatsApp login: ${payload.sessionId}\\n${terminalQrCode}`);\n });\n },\n };\n}\n\nlet activeSink: CliOutputSink = createConsoleOutputSink();\n\nexport function getCliOutputSink(): CliOutputSink {\n return activeSink;\n}\n\nexport function setCliOutputSink(sink: CliOutputSink): void {\n activeSink = sink;\n}\n\nexport function resetCliOutputSink(): void {\n activeSink = createConsoleOutputSink();\n}\n","import { constants } from 'node:fs';\nimport { access, mkdir, mkdtemp, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';\nimport { homedir } from 'node:os';\nimport { dirname, join } from 'node:path';\nimport { toPublicError } from '@open-wa/driver-interface';\nimport { getCliOutputSink, promptChoice } from './cli/output-sink';\n\nexport type BrowserChoice = 'chrome' | 'chromium' | 'lightpanda';\nexport { findSystemBrowser } from '@open-wa/create/browser';\nconst choiceFile = join(homedir(), '.cache', 'open-wa', 'browser-choice.json');\n\nexport async function readBrowserChoice(): Promise<{ kind: BrowserChoice; executablePath: string } | undefined> {\n const { Effect, Schema } = await import('effect');\n const recordSchema = Schema.fromJsonString(Schema.Struct({\n kind: Schema.Literals(['chrome', 'chromium', 'lightpanda']),\n executablePath: Schema.String,\n }));\n const io = <A>(operation: () => PromiseLike<A>) => Effect.tryPromise({ try: operation, catch: toPublicError });\n return Effect.runPromise(Effect.gen(function* () {\n const record = yield* Schema.decodeUnknownEffect(recordSchema)(yield* io(() => readFile(choiceFile, 'utf8')));\n const executable = yield* io(() => stat(record.executablePath));\n if (!executable.isFile()) return undefined;\n yield* io(() => access(record.executablePath, constants.X_OK));\n return record;\n }).pipe(Effect.catch(() => Effect.succeed(undefined))));\n}\n\nexport async function writeBrowserChoice(kind: BrowserChoice, executablePath: string): Promise<void> {\n const { Effect } = await import('effect');\n const io = <A>(operation: () => PromiseLike<A>) => Effect.tryPromise({ try: operation, catch: toPublicError });\n const program = Effect.gen(function* () {\n const directory = dirname(choiceFile);\n yield* io(() => mkdir(directory, { recursive: true }));\n const staging = yield* Effect.acquireRelease(\n io(() => mkdtemp(join(directory, '.browser-choice-'))),\n path => io(() => rm(path, { recursive: true, force: true })).pipe(Effect.orDie),\n );\n const temporary = join(staging, 'browser-choice.json');\n yield* io(() => writeFile(temporary, JSON.stringify({ kind, executablePath }), { encoding: 'utf8', flag: 'wx' }));\n yield* io(() => rename(temporary, choiceFile));\n });\n await Effect.runPromise(Effect.scoped(Effect.uninterruptible(program))).catch(cause => { throw toPublicError(cause); });\n}\n\nexport async function chooseBrowser(): Promise<BrowserChoice> {\n const sink = getCliOutputSink();\n const choice = await (sink.promptChoice ?? promptChoice)(\n 'Google Chrome was not found. Which browser would you like to download?',\n [\n 'Chrome for Testing — recommended; highest compatibility, including video and media.',\n 'Chromium — middle ground; proprietary video/audio codecs may be unavailable.',\n 'Lightpanda — lightweight basic automation; low compatibility, experimental WhatsApp support, no video or rendering.',\n ],\n );\n return (['chrome', 'chromium', 'lightpanda'] as const)[choice];\n}\n","import type { CreateClientOptions, OpenWAEventMap } from '@open-wa/core';\nimport type { Client } from '@open-wa/client';\nimport { ConfigSchema, resolveConfig, type PartialConfig, type Config, type TrackedConfig } from '@open-wa/config';\nimport { accessSync, constants, existsSync, mkdirSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { getCliOutputSink } from './cli/output-sink';\nimport { chooseBrowser, findSystemBrowser, readBrowserChoice, writeBrowserChoice, type BrowserChoice } from './browser-choice';\n\nexport interface ExecutablePathResolution {\n executablePath?: string;\n source:\n | 'config'\n | 'cache'\n | 'chrome_installation'\n | 'driver_default'\n | 'lightpanda_config'\n | 'lightpanda_managed'\n | 'managed_browser';\n warning?: string;\n}\n\nexport interface DriverSelection {\n driver: CreateClientOptions['driver'];\n engineLabel: 'Puppeteer' | 'Lightpanda';\n executableResolution: ExecutablePathResolution;\n preferLocalChrome: boolean;\n}\n\nfunction readChromePathCache(cacheFilePath: string): { executablePath?: string } | undefined {\n try {\n if (!existsSync(cacheFilePath)) {\n return undefined;\n }\n\n const raw = JSON.parse(readFileSync(cacheFilePath, 'utf8')) as { executablePath?: string };\n if (!raw || typeof raw !== 'object') {\n return undefined;\n }\n\n return {\n executablePath: typeof raw.executablePath === 'string' ? raw.executablePath : undefined,\n };\n } catch {\n return undefined;\n }\n}\n\nfunction writeChromePathCache(executablePath: string, cacheFilePath: string): void {\n mkdirSync(dirname(cacheFilePath), { recursive: true });\n writeFileSync(cacheFilePath, JSON.stringify({ executablePath, updatedAt: new Date().toISOString() }, null, 2), 'utf8');\n}\n\nfunction clearChromePathCache(cacheFilePath: string): void {\n if (existsSync(cacheFilePath)) {\n rmSync(cacheFilePath, { force: true });\n }\n}\n\nfunction isUsableExecutablePath(executablePath?: string): executablePath is string {\n if (!executablePath) return false;\n try {\n if (!statSync(executablePath).isFile()) return false;\n accessSync(executablePath, constants.X_OK);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction getExplicitUseChromePreference(rawConfigs?: TrackedConfig['rawConfigs']): boolean | undefined {\n const explicitConfigSources = [\n rawConfigs?.file,\n rawConfigs?.env,\n rawConfigs?.cli,\n rawConfigs?.programmatic,\n ];\n\n for (let index = explicitConfigSources.length - 1; index >= 0; index -= 1) {\n const source = explicitConfigSources[index];\n if (source?.useChrome !== undefined) {\n return source.useChrome;\n }\n }\n\n return undefined;\n}\n\nexport function shouldPreferLocalChrome(\n config: Config,\n rawConfigs?: TrackedConfig['rawConfigs'],\n defaultPreference = true,\n): boolean {\n if (config.useLightpanda || config.useChromium || config.browser?.kind === 'chromium') {\n return false;\n }\n\n if (config.executablePath || process.env.PUPPETEER_EXECUTABLE_PATH !== undefined) {\n return false;\n }\n\n const explicitUseChrome = getExplicitUseChromePreference(rawConfigs);\n if (explicitUseChrome !== undefined) {\n return explicitUseChrome;\n }\n\n return defaultPreference;\n}\n\nexport async function resolveExecutablePath(\n config: Config,\n options: {\n preferLocalChrome?: boolean;\n cacheFilePath: string;\n kind?: 'chrome' | 'chromium';\n }\n): Promise<ExecutablePathResolution> {\n const configuredPath = config.executablePath ?? process.env.PUPPETEER_EXECUTABLE_PATH;\n if (configuredPath !== undefined) {\n return {\n executablePath: configuredPath,\n source: 'config',\n };\n }\n\n const preferLocalChrome = options.preferLocalChrome ?? config.useChrome;\n if (!preferLocalChrome) {\n return {\n source: 'driver_default',\n };\n }\n\n const matchesKind = (path: string) => options.kind === 'chromium'\n ? /chromium/i.test(path)\n : !/chromium/i.test(path);\n const cachedPath = readChromePathCache(options.cacheFilePath)?.executablePath;\n if (isUsableExecutablePath(cachedPath) && matchesKind(cachedPath)) {\n return {\n executablePath: cachedPath,\n source: 'cache',\n };\n }\n\n if (cachedPath) {\n clearChromePathCache(options.cacheFilePath);\n }\n\n // Check known installation paths and PATH without a synchronous OS-wide\n // application scan, so a missing Chrome reaches the picker promptly.\n const detectedPath = await findSystemBrowser(options.kind ?? 'chrome');\n\n if (detectedPath) {\n writeChromePathCache(detectedPath, options.cacheFilePath);\n return {\n executablePath: detectedPath,\n source: 'chrome_installation',\n };\n }\n\n clearChromePathCache(options.cacheFilePath);\n\n return {\n source: 'driver_default',\n };\n}\n\nexport function resolveLightpandaExecutablePath(config: Config): ExecutablePathResolution {\n const executablePath = config.lightpanda?.executablePath ?? config.executablePath ?? process.env.LIGHTPANDA_EXECUTABLE_PATH;\n if (executablePath) {\n return {\n executablePath,\n source: 'lightpanda_config',\n };\n }\n\n return {\n source: 'lightpanda_managed',\n };\n}\n\nexport async function selectRuntimeDriver(\n config: Config,\n options: {\n rawConfigs?: TrackedConfig['rawConfigs'];\n cacheFilePath: string;\n defaultPreferLocalChrome?: boolean;\n promptForMissingBrowser?: boolean;\n nonInteractive?: boolean;\n }\n): Promise<DriverSelection> {\n const browserSource = config.browser?.source;\n const promptForMissingBrowser = options.promptForMissingBrowser || browserSource === 'auto';\n const flags = [config.useChrome, config.useChromium, config.useLightpanda].filter(Boolean);\n if (flags.length > 1) throw new Error('Choose only one browser: useChrome, useChromium or useLightpanda.');\n let kind: BrowserChoice | undefined = config.useLightpanda ? 'lightpanda'\n : config.useChromium ? 'chromium'\n : config.useChrome ? 'chrome'\n : config.browser?.kind;\n const explicitChoice = kind !== undefined || getExplicitUseChromePreference(options.rawConfigs) !== undefined\n || config.browser?.download === 'auto';\n const preferLocalChrome = browserSource ? browserSource !== 'managed'\n : shouldPreferLocalChrome(config, options.rawConfigs, options.defaultPreferLocalChrome ?? true);\n let executableResolution: ExecutablePathResolution = { source: 'driver_default' };\n if (kind !== 'lightpanda' && browserSource === 'system') {\n const executablePath = await findSystemBrowser(kind === 'chromium' ? 'chromium' : 'chrome');\n if (!executablePath) throw new Error('The selected system browser was not found. Install it or change browser.source to managed to download a browser.');\n executableResolution = { source: 'chrome_installation', executablePath };\n } else if (kind !== 'lightpanda' && browserSource !== 'managed') {\n executableResolution = await resolveExecutablePath(config, {\n preferLocalChrome: kind === 'chromium' || preferLocalChrome,\n cacheFilePath: kind === 'chromium' ? `${options.cacheFilePath}.chromium` : options.cacheFilePath,\n kind: kind === 'chromium' ? 'chromium' : 'chrome',\n });\n } else if (kind === 'lightpanda') {\n executableResolution = resolveLightpandaExecutablePath(config);\n executableResolution.executablePath ??= config.executablePath;\n }\n if (browserSource !== 'managed' && browserSource !== 'system' && !executableResolution.executablePath && (kind !== undefined || promptForMissingBrowser)\n && !(kind === 'lightpanda' && config.lightpanda?.experimentalWhatsApp !== false)) {\n const remembered = await readBrowserChoice();\n if (remembered && (kind === undefined || remembered.kind === kind)) {\n kind = remembered.kind;\n executableResolution = { source: 'cache', executablePath: remembered.executablePath };\n }\n }\n if (!kind && executableResolution.executablePath === undefined && promptForMissingBrowser) {\n // A pre-provisioned Chrome cache is usable even without a remembered choice.\n const { ensureBrowser } = await import('@open-wa/driver-puppeteer');\n try {\n const executablePath = await ensureBrowser({ browser: { ...config.browser, kind: 'chrome', download: 'never' } });\n executableResolution = { source: 'managed_browser', executablePath };\n } catch (error) {\n if (!(error instanceof Error) || !/missing from .* and browser downloads are disabled/.test(error.message)) throw error;\n }\n }\n if (!kind && !executableResolution.executablePath && !explicitChoice && promptForMissingBrowser) {\n if (config.browser?.download === 'never') {\n throw new Error('No browser is available and browser downloads are disabled. Configure executablePath or pre-provision a browser cache.');\n }\n if (options.nonInteractive || process.env.CI || process.env.NONINTERACTIVE) {\n throw new Error('No browser is installed. Choose --use-chrome, --use-chromium or --use-lightpanda to download one without a prompt.');\n }\n kind = await chooseBrowser();\n }\n kind ??= 'chrome';\n const sink = getCliOutputSink();\n const ctx = { logger: {\n debug: (message: string) => sink.write({ level: 'debug', message }),\n info: (message: string) => sink.write({ level: 'info', message }),\n warn: (message: string) => sink.write({ level: 'warn', message }),\n error: (message: string) => sink.write({ level: 'error', message }),\n } };\n const browser = {\n ...config.browser,\n ...(explicitChoice || promptForMissingBrowser ? { download: config.browser?.download ?? ('auto' as const) } : {}),\n ...(kind !== 'lightpanda' ? { kind } : {}),\n };\n if (kind === 'lightpanda') {\n const { LightpandaDriver, ensureLightpanda } = await import('@open-wa/driver-lightpanda');\n config.lightpanda = ConfigSchema.shape.lightpanda.parse({ ...config.lightpanda, experimentalWhatsApp: config.lightpanda?.experimentalWhatsApp ?? true });\n config.browser = browser;\n const executablePath = await ensureLightpanda({\n executablePath: executableResolution.executablePath,\n browser,\n preferPinnedRelease: config.lightpanda?.experimentalWhatsApp ?? true,\n }, ctx);\n config.useLightpanda = true;\n config.useChrome = false;\n config.useChromium = false;\n sink.write({ level: 'warn', message: 'Lightpanda has low compatibility and experimental WhatsApp support; video, screenshots and rendering are unavailable.' });\n if (options.promptForMissingBrowser) {\n await writeBrowserChoice(kind, executablePath).catch(error => sink.write({ level: 'warn', message: `Could not remember the browser choice: ${error instanceof Error ? error.message : String(error)}` }));\n }\n return {\n driver: new LightpandaDriver(),\n engineLabel: 'Lightpanda',\n executableResolution: { source: 'lightpanda_managed', executablePath },\n preferLocalChrome: false,\n };\n }\n config.browser = browser;\n const { PuppeteerDriver, ensureBrowser } = await import('@open-wa/driver-puppeteer');\n const executablePath = await ensureBrowser({ executablePath: executableResolution.executablePath, browser }, ctx);\n if (!executableResolution.executablePath) executableResolution = { source: 'managed_browser', executablePath };\n if (options.promptForMissingBrowser) {\n await writeBrowserChoice(kind, executablePath).catch(error => sink.write({ level: 'warn', message: `Could not remember the browser choice: ${error instanceof Error ? error.message : String(error)}` }));\n }\n return {\n driver: new PuppeteerDriver(),\n engineLabel: 'Puppeteer',\n executableResolution,\n preferLocalChrome,\n };\n}\n\n/** Load the Node media runtime only when a call needs a source or sink. */\nexport function makeDefaultCallMediaHost(): NonNullable<CreateClientOptions['callMediaHost']> {\n return {\n async prepare(...args) {\n const { makeNodeCallMediaHost } = await import('@open-wa/runtime-node');\n return makeNodeCallMediaHost({ log: message => getCliOutputSink().write({ level: 'info', message }) }).prepare(...args);\n },\n };\n}\n\nexport function toCreateClientOptions(\n config: Config,\n driverSelection: DriverSelection,\n options: {\n debug?: boolean;\n } = {},\n): CreateClientOptions {\n return {\n sessionId: config.sessionId,\n pluginRefs: config.plugins,\n pluginConfig: config.pluginConfig,\n eventMode: config.eventMode,\n driver: driverSelection.driver,\n deleteSessionDataOnLogout: config.deleteSessionDataOnLogout,\n killClientOnLogout: config.killClientOnLogout,\n sessionDataPath: config.sessionDataPath,\n sessionData: config.sessionData,\n skipSessionSave: config.skipSessionSave,\n sessionDataBucketAuth: config.sessionDataBucketAuth,\n sessionDataEncryptionKey: config.sessionDataEncryptionKey,\n sessionDataEncryptionKeyFile: config.sessionDataEncryptionKeyFile,\n s3Sync: config.s3Sync,\n debug: options.debug ?? (config.logLevel === 'debug' || config.logConsole),\n headless: config.headless,\n qrTimeoutMs: typeof config.qrTimeout === 'number' ? config.qrTimeout * 1000 : undefined,\n authTimeoutMs: typeof config.authTimeout === 'number' ? config.authTimeout * 1000 : undefined,\n executablePath: driverSelection.executableResolution.executablePath,\n browserArgs: config.chromiumArgs,\n browser: config.browser,\n allowDangerousBrowserArgs: config.allowDangerousBrowserArgs,\n userDataDir: config.userDataDir,\n ephemeral: config.ephemeral,\n linkCode: config.linkCode,\n qrMax: config.qrMax,\n oorTimeoutMs: config.oorTimeout * 1000,\n logConsole: config.logConsole,\n logConsoleErrors: config.logConsoleErrors,\n blockCrashLogs: config.blockCrashLogs,\n blockAssets: config.blockAssets,\n safeMode: config.safeMode,\n lightpanda: config.useLightpanda ? { experimentalWhatsApp: true, ...config.lightpanda } : undefined,\n licenseKey: config.licenseKey as any,\n calling: config.calling,\n callMediaHost: makeDefaultCallMediaHost(),\n licenseConfig: config.licenseConfig,\n patchConfig: { ghPatch: config.ghPatch, cachedPatch: config.cachedPatch },\n };\n}\n\n/** Options for the ready-to-use messaging client. */\nexport type CreateOptions = Omit<PartialConfig, 's3Sync' | 'calling'> & {\n calling?: import('@open-wa/schema').CallingOptions;\n s3Sync?: Omit<NonNullable<PartialConfig['s3Sync']>, 'region' | 'syncInterval'> & {\n region?: string;\n syncInterval?: number;\n };\n /** Override the default Puppeteer driver. */\n driver?: CreateClientOptions['driver'];\n};\n\n/** Start WhatsApp, display QR login when needed, and return a ready messaging client. */\nexport async function create(options: CreateOptions = {}): Promise<Client> {\n const { createClient: createCoreClient } = await import('@open-wa/core');\n const { Client } = await import('@open-wa/client');\n const { driver, sessionData, sessionDataBucketAuth, s3Sync, calling,\n sessionDataEncryptionKey, sessionDataEncryptionKeyFile, ...configOverrides } = options;\n const { config, rawConfigs } = await resolveConfig({\n programmaticOverrides: {\n qrTimeout: 0, ...configOverrides,\n // Session seeds, encryption keys and bucket credentials bypass tracked/debug config.\n },\n skipConfigFile: true,\n skipEnv: true,\n includeRawConfigs: true,\n });\n\n const driverSelection: DriverSelection = driver ? {\n driver,\n engineLabel: driver.name === 'lightpanda' ? 'Lightpanda' : 'Puppeteer',\n executableResolution: { source: 'config', executablePath: config.executablePath },\n preferLocalChrome: false,\n } : await selectRuntimeDriver(config, {\n rawConfigs,\n cacheFilePath: resolve(process.cwd(), '.open-wa', 'chrome-executable-path.json'),\n defaultPreferLocalChrome: false,\n });\n\n const coreOptions = toCreateClientOptions(config, driverSelection);\n if (calling) coreOptions.calling = calling;\n if (driver) coreOptions.driver = driver;\n coreOptions.sessionData = sessionData;\n coreOptions.sessionDataBucketAuth = sessionDataBucketAuth;\n coreOptions.sessionDataEncryptionKey = sessionDataEncryptionKey;\n coreOptions.sessionDataEncryptionKeyFile = sessionDataEncryptionKeyFile;\n coreOptions.s3Sync = s3Sync;\n\n const core = await createCoreClient(coreOptions);\n const sink = getCliOutputSink();\n const onQr = (event: OpenWAEventMap['launch.auth.qr.generated']) => {\n if (config.qrLogSkip || !event.details?.qr) return;\n sink.write({ level: 'info', message: 'Open WhatsApp on your sending phone: Linked Devices → Link a Device, then scan this QR code.' });\n sink.qr({ qr: event.details.qr, sessionId: config.sessionId });\n };\n const onLinkCode = (event: OpenWAEventMap['launch.auth.linkCode.generated']) => {\n if (event.details?.linkCode && !config.qrLogSkip) {\n sink.write({ level: 'info', message: `Enter this link code on your sending phone: ${event.details.linkCode}` });\n }\n };\n core.events.on('launch.auth.qr.generated', onQr);\n core.events.on('launch.auth.linkCode.generated', onLinkCode);\n let client: Client | undefined;\n try {\n client = new Client({ client: core, transport: core.getTransport() });\n await client.start();\n if (core.getState() !== 'READY' || !core.getReadiness().exposureSafe) {\n throw new Error('WhatsApp startup finished without a messaging-ready session.');\n }\n return client;\n } catch (error) {\n try {\n if (client) await client.stop('startup-failure');\n else await core.stop('startup-failure');\n } catch {\n // Keep the startup failure as the actionable error.\n }\n throw error;\n } finally {\n core.events.off('launch.auth.qr.generated', onQr);\n core.events.off('launch.auth.linkCode.generated', onLinkCode);\n }\n}\n","import { createClient } from '@open-wa/core';\nimport { Client as ClientFacade } from '@open-wa/client';\nimport { selectRuntimeDriver as selectSharedRuntimeDriver, resolveExecutablePath as resolveSharedExecutablePath, makeDefaultCallMediaHost, type DriverSelection } from './runtime-client';\nimport { eventRegistry } from '@open-wa/schema';\nimport { WAServer } from './server/hono-server';\nimport { resolveConfig, type PartialConfig, type Config, type TrackedConfig } from '@open-wa/config';\nimport { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { getCliOutputSink, type CliOutputSink } from './cli/output-sink';\nimport {\n defaultChatSandboxPolicy,\n type ChatSandboxPolicy,\n type SandboxIsolation,\n} from '@open-wa/runtime-core';\nimport { makeNodeExecutionSandbox, observeBrowserProcessMemory } from '@open-wa/runtime-node';\n\nexport interface CliRuntimeResult {\n server: WAServer;\n client: ClientFacade;\n config: Config;\n events: ClientFacade['events'];\n dispose(): void;\n}\n\ninterface RuntimeEventPublisher {\n publish(eventName: string, payload: any): void;\n}\n\nfunction bridgeRuntimeEvents(\n openwaClient: Awaited<ReturnType<typeof createClient>>,\n publishRuntimeEvent: (eventName: string, payload: any) => void,\n): () => void {\n if (typeof openwaClient.events.onAny === 'function' && typeof openwaClient.events.offAny === 'function') {\n openwaClient.events.onAny(publishRuntimeEvent);\n return () => openwaClient.events.offAny(publishRuntimeEvent);\n }\n\n const unsubscribers: Array<() => void> = [];\n const bridgedEvents = new Set(eventRegistry.getAll().map((def) => def.meta.eventName));\n bridgedEvents.add('session.refresh.progress');\n\n bridgedEvents.forEach((eventName) => {\n const handler = (payload: any) => publishRuntimeEvent(eventName, payload);\n openwaClient.events.on(eventName as never, handler);\n unsubscribers.push(() => openwaClient.events.off(eventName as never, handler));\n });\n\n return () => {\n unsubscribers.forEach((unsubscribe) => unsubscribe());\n };\n}\n\nfunction attachLaunchNarration(\n openwaClient: Awaited<ReturnType<typeof createClient>>,\n sink: CliOutputSink,\n sessionId: string,\n): () => void {\n const unsubscribers: Array<() => void> = [];\n const on = (event: string, handler: (...args: any[]) => void) => {\n openwaClient.events.on(event as never, handler);\n unsubscribers.push(() => openwaClient.events.off(event as never, handler));\n };\n\n on('launch.auth.check.before', (event: any) => {\n sink.status({ phase: 'launch.auth', sessionId, detail: `Authenticating (timeout=${event?.details?.timeoutMs ?? '∞'}ms)` });\n });\n\n on('launch.auth.check.after', (event: any) => {\n sink.write({ level: 'info', message: `Auth detected via ${event?.details?.method ?? 'unknown'} (${event?.details?.isAuthenticated ? 'authenticated' : 'not-authenticated'})` });\n });\n\n on('launch.helper.pre_api.before', (event: any) => {\n sink.status({ phase: 'launch.helpers', sessionId, detail: event?.details?.mode === 'scripts' ? 'Injecting pre-API helper assets...' : 'Pre-API helpers already present' });\n });\n\n on('launch.helper.pre_api.after', (event: any) => {\n sink.write({ level: 'info', message: `Pre-API helper phase complete (${event?.details?.mode ?? 'unknown'})` });\n });\n\n on('internal_launch_progress', (event: any) => {\n const prefix = (event?.value || event?.value === 0) ? `${event.value}% ` : '';\n if (event?.text) sink.write({ level: 'info', message: `${prefix}${event.text}`.trim() });\n });\n\n on('critical_internal_message', (event: any) => {\n sink.write({ level: 'warn', message: `Internal launch message: ${event?.text ?? event?.value ?? 'unknown'}` });\n });\n\n on('launch.patch.init.before', (event: any) => {\n if (event?.details?.phase === 'preload') {\n sink.status({ phase: 'launch.patch', sessionId, detail: 'Downloading patches from CDN...' });\n }\n });\n\n on('launch.patch.init.after', (event: any) => {\n if (event?.details?.phase === 'preload') {\n const source = event?.details?.source ?? 'unknown';\n const tag = event?.details?.tag ? ` tag=${event.details.tag}` : '';\n const available = Array.isArray(event?.details?.available) ? event.details.available.length : 0;\n const durationMs = event?.durationMs;\n const durationStr = durationMs ? ` in ${(durationMs / 1000).toFixed(2)}s` : '';\n sink.write({ level: 'info', message: `Downloaded patches${durationStr} (source=${source}, available=${available}${tag})` });\n }\n });\n\n on('patch.init.before', (event: any) => {\n if (event?.details?.phase === 'apply') {\n const count = Array.isArray(event?.details?.patchIds) ? event.details.patchIds.length : 0;\n sink.status({ phase: 'launch.patch', sessionId, detail: `Installing patches (${count} queued)` });\n }\n });\n\n on('patch.apply.before', (event: any) => {\n sink.status({ phase: 'launch.patch', sessionId, detail: `Applying patch: ${event?.details?.patchId ?? 'unknown'}` });\n });\n\n on('patch.apply.after', (event: any) => {\n sink.write({\n level: event?.details?.outcome === 'failed' ? 'warn' : 'info',\n message: `Patch ${event?.details?.patchId ?? 'unknown'}: ${event?.details?.outcome ?? (event?.details?.applied ? 'applied' : 'unknown')}${event?.details?.detail ? ` — ${event.details.detail}` : ''}`,\n });\n });\n\n on('patch.init.after', (event: any) => {\n if (event?.details?.phase === 'apply') {\n const applied = Array.isArray(event?.details?.applied) ? event.details.applied : [];\n const outcome = event?.details?.outcome ?? 'unknown';\n const tag = applied.length > 0 ? applied.join(', ') : outcome;\n const durationMs = event?.durationMs;\n const durationStr = durationMs ? ` in ${(durationMs / 1000).toFixed(2)}s` : '';\n sink.write({\n level: event?.details?.blockingFailure ? 'warn' : 'info',\n message: `Patches Installed${durationStr}: ${tag}`,\n });\n }\n });\n\n on('launch.patch.integrity.before', () => {\n sink.status({ phase: 'launch.patch', sessionId, detail: 'Validating patched runtime...' });\n });\n\n on('launch.patch.integrity.after', (event: any) => {\n sink.write({ level: event?.details?.usable ? 'info' : 'warn', message: `Patched runtime validation: ${event?.details?.usable ? 'usable' : 'failed'}${event?.details?.failureReason ? ` (${event.details.failureReason})` : ''}` });\n });\n\n on('launch.license.check.before', (event: any) => {\n sink.status({ phase: 'launch.license', sessionId, detail: `Checking license (${event?.details?.source ?? 'local'})` });\n });\n\n on('launch.license.check.after', (event: any) => {\n sink.write({ level: event?.details?.blockingFailure ? 'warn' : 'info', message: `License check: ${event?.details?.status ?? 'unknown'}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('license.inject.before', () => {\n sink.status({ phase: 'launch.license', sessionId, detail: 'Injecting license payload...' });\n });\n\n on('license.inject.after', (event: any) => {\n sink.write({ level: event?.details?.success ? 'info' : 'warn', message: `License inject: ${event?.details?.success ? 'success' : 'failed'}${event?.details?.status ? ` (${event.details.status})` : ''}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('launch.auth.qr.generated', (event: any) => {\n const qrIndex = event?.details?.qrIndex ?? '?';\n sink.status({ phase: 'launch.auth', sessionId, detail: `QR code generated (#${qrIndex})` });\n });\n\n on('launch.client.finalize.before', (event: any) => {\n sink.status({ phase: 'launch.finalize', sessionId, detail: `Finalizing session (${event?.details?.validationStage ?? 'unknown'})` });\n });\n\n on('launch.client.finalize.after', (event: any) => {\n sink.write({ level: event?.details?.success ? 'info' : 'warn', message: `Finalize: ${event?.details?.outcome ?? 'unknown'}${event?.details?.detail ? ` — ${event.details.detail}` : ''}` });\n });\n\n on('error', (event: any) => {\n const scope = event?.scope ?? 'unknown';\n const msg = event?.error?.message ?? String(event?.error ?? 'unknown error');\n const fatal = event?.fatal ? ' [FATAL]' : '';\n sink.write({ level: 'error', message: `${fatal} ${scope}: ${msg}`.trim() });\n });\n\n return () => {\n unsubscribers.forEach((unsubscribe) => unsubscribe());\n };\n}\n\nconst CHROME_CACHE_FILE = resolve(process.cwd(), '.open-wa', 'chrome-executable-path.json');\n\ninterface ChromePathCacheRecord {\n executablePath?: string;\n updatedAt?: string;\n}\n\ninterface ExecutablePathResolution {\n executablePath?: string;\n source:\n | 'config'\n | 'cache'\n | 'chrome_installation'\n | 'driver_default'\n | 'lightpanda_config'\n | 'lightpanda_managed'\n | 'managed_browser';\n warning?: string;\n}\n\nexport interface ParsedCliArgs {\n procName: string;\n pm2: boolean;\n forwardedArgs: string[];\n configPath?: string;\n cliOverrides: PartialConfig;\n verbose: boolean;\n unsupportedWarnings: string[];\n}\n\nexport function getChromeCacheFilePath(): string {\n return CHROME_CACHE_FILE;\n}\n\nexport function readChromePathCache(cacheFilePath: string = getChromeCacheFilePath()): ChromePathCacheRecord | undefined {\n if (!existsSync(cacheFilePath)) {\n return undefined;\n }\n\n try {\n const raw = JSON.parse(readFileSync(cacheFilePath, 'utf8')) as ChromePathCacheRecord;\n if (!raw || typeof raw !== 'object') {\n return undefined;\n }\n\n return {\n executablePath: typeof raw.executablePath === 'string' ? raw.executablePath : undefined,\n updatedAt: typeof raw.updatedAt === 'string' ? raw.updatedAt : undefined,\n };\n } catch {\n return undefined;\n }\n}\n\nexport function writeChromePathCache(executablePath: string, cacheFilePath: string = getChromeCacheFilePath()): void {\n mkdirSync(dirname(cacheFilePath), { recursive: true });\n writeFileSync(cacheFilePath, JSON.stringify({ executablePath, updatedAt: new Date().toISOString() }, null, 2), 'utf8');\n}\n\nexport function clearChromePathCache(cacheFilePath: string = getChromeCacheFilePath()): void {\n if (existsSync(cacheFilePath)) {\n rmSync(cacheFilePath, { force: true });\n }\n}\n\nexport function isUsableExecutablePath(executablePath?: string): executablePath is string {\n return !!executablePath && existsSync(executablePath);\n}\n\nfunction getExplicitUseChromePreference(rawConfigs?: TrackedConfig['rawConfigs']): boolean | undefined {\n const explicitConfigSources = [\n rawConfigs?.file,\n rawConfigs?.env,\n rawConfigs?.cli,\n rawConfigs?.programmatic,\n ];\n\n for (let index = explicitConfigSources.length - 1; index >= 0; index -= 1) {\n const source = explicitConfigSources[index];\n if (source?.useChrome !== undefined) {\n return source.useChrome;\n }\n }\n\n return undefined;\n}\n\nexport function shouldPreferLocalChrome(config: Config, rawConfigs?: TrackedConfig['rawConfigs']): boolean {\n if (config.useLightpanda || config.useChromium || config.browser?.kind === 'chromium') {\n return false;\n }\n\n if (config.executablePath) {\n return false;\n }\n\n const explicitUseChrome = getExplicitUseChromePreference(rawConfigs);\n if (explicitUseChrome !== undefined) {\n return explicitUseChrome;\n }\n\n return true;\n}\n\nfunction getVal(argv: string[], flag: string): string | undefined {\n const index = argv.findIndex(arg => arg === flag);\n return index !== -1 ? argv[index + 1] : undefined;\n}\n\nfunction parseSandboxIsolation(value: string): SandboxIsolation {\n switch (value) {\n case 'worker':\n case 'process':\n case 'container':\n return value;\n default:\n throw new Error(`Invalid --sandbox-isolation value: ${value}`);\n }\n}\n\nexport function resolveChatSandboxPolicy(config: Config['sandboxChats']): ChatSandboxPolicy | undefined {\n if (!config) return undefined;\n\n const overrides = typeof config === 'object'\n ? config as Partial<Omit<ChatSandboxPolicy, 'chats'>>\n : {};\n return {\n ...defaultChatSandboxPolicy,\n ...overrides,\n chats: true,\n networkAllowlist: [...(overrides.networkAllowlist ?? defaultChatSandboxPolicy.networkAllowlist)],\n env: overrides.env === 'none' || overrides.env === undefined\n ? overrides.env ?? defaultChatSandboxPolicy.env\n : [...overrides.env],\n capabilities: [...(overrides.capabilities ?? defaultChatSandboxPolicy.capabilities)],\n };\n}\n\nexport function parseCliArgs(argv: string[] = process.argv.slice(2)): ParsedCliArgs {\n const cliOverrides: PartialConfig = {};\n const unsupportedWarnings: string[] = [];\n let verbose = false;\n let configPath: string | undefined;\n\n const sessionId = getVal(argv, '--session-id');\n if (sessionId) cliOverrides.sessionId = sessionId;\n\n const portValue = getVal(argv, '--port') || getVal(argv, '-p');\n if (portValue) cliOverrides.port = parseInt(portValue, 10);\n\n const host = getVal(argv, '--host') || getVal(argv, '-h');\n if (host) cliOverrides.host = host;\n\n const apiKey = getVal(argv, '--api-key') || getVal(argv, '--key') || getVal(argv, '-k');\n if (apiKey) cliOverrides.apiKey = apiKey;\n\n const logLevel = getVal(argv, '--log-level');\n if (logLevel) cliOverrides.logLevel = logLevel;\n\n if (argv.includes('--no-ezqr')) cliOverrides.ezqr = false;\n if (argv.includes('--headful')) cliOverrides.headless = false;\n if (argv.includes('--headless')) cliOverrides.headless = true;\n const browserFlags = ['--use-chrome', '--use-chromium', '--use-lightpanda'].filter(flag => argv.includes(flag) || flag === '--use-lightpanda' && argv.includes('--lightpanda'));\n if (browserFlags.length > 1) throw new Error('Choose only one of --use-chrome, --use-chromium or --use-lightpanda.');\n if (browserFlags.length) {\n cliOverrides.useChrome = browserFlags[0] === '--use-chrome';\n cliOverrides.useChromium = browserFlags[0] === '--use-chromium';\n cliOverrides.useLightpanda = browserFlags[0] === '--use-lightpanda';\n }\n if (argv.includes('--log-console')) cliOverrides.logConsole = true;\n if (argv.includes('--aggressive-garbage-collection')) cliOverrides.aggressiveGarbageCollection = true;\n if (argv.includes('--no-dashboard')) cliOverrides.dashboard = false;\n if (argv.includes('--ephemeral')) cliOverrides.ephemeral = true;\n if (argv.includes('--sandbox-chats')) cliOverrides.sandboxChats = true;\n\n const sandboxIsolation = getVal(argv, '--sandbox-isolation');\n if (sandboxIsolation) {\n const { chats: _chats, ...sandboxDefaults } = defaultChatSandboxPolicy;\n cliOverrides.sandboxChats = {\n ...sandboxDefaults,\n isolation: parseSandboxIsolation(sandboxIsolation),\n networkAllowlist: [...defaultChatSandboxPolicy.networkAllowlist],\n env: defaultChatSandboxPolicy.env === 'none'\n ? 'none'\n : [...defaultChatSandboxPolicy.env],\n capabilities: [...defaultChatSandboxPolicy.capabilities],\n };\n }\n\n const qrTimeout = getVal(argv, '--qr-timeout');\n if (qrTimeout) cliOverrides.qrTimeout = parseInt(qrTimeout, 10);\n\n const dashboardPort = getVal(argv, '--dashboard-port');\n if (dashboardPort) cliOverrides.dashboardPort = parseInt(dashboardPort, 10);\n\n const licenseKey = getVal(argv, '--license-key') || getVal(argv, '-l');\n if (licenseKey) cliOverrides.licenseKey = licenseKey;\n\n const webhook = getVal(argv, '--webhook') || getVal(argv, '-w');\n if (webhook) cliOverrides.webhook = webhook;\n\n const proxyHost = getVal(argv, '--proxy-host');\n if (proxyHost) cliOverrides.proxyHost = proxyHost;\n\n const proxyToken = getVal(argv, '--proxy-token');\n if (proxyToken) cliOverrides.proxyToken = proxyToken;\n\n const readyWebhook = getVal(argv, '--ready-webhook');\n if (readyWebhook) unsupportedWarnings.push(`--ready-webhook was provided (${readyWebhook}) but ready-webhook delivery is not yet wired in v5 CLI.`);\n\n if (argv.includes('-v') || argv.includes('--verbose')) {\n verbose = true;\n cliOverrides.disableSpins = true;\n cliOverrides.logConsole = true;\n cliOverrides.logLevel = cliOverrides.logLevel || 'debug';\n }\n\n if (argv.includes('--stats')) {\n unsupportedWarnings.push('--stats was provided but swagger-stats parity is not restored; v5 only exposes the compatibility redirect/deprecation route.');\n }\n\n if (argv.includes('--generate-api-docs')) {\n unsupportedWarnings.push('--generate-api-docs was provided; runtime docs are always served from the shared API layer and no separate collection generation step currently runs at CLI boot.');\n }\n\n if (argv.includes('--tunnel')) {\n unsupportedWarnings.push('--tunnel was provided but tunnel setup parity is not yet restored in the v5 CLI.');\n }\n\n if (argv.includes('--chatwoot-url') || argv.includes('--twilio-webhook') || argv.includes('--bot-press-url')) {\n unsupportedWarnings.push('Legacy integration flags (Chatwoot/Twilio/BotPress) were provided but are not yet wired into the v5 CLI boot path.');\n }\n\n if (argv.includes('--use-session-id-in-path') && sessionId) {\n cliOverrides.sessionId = sessionId;\n }\n\n configPath = getVal(argv, '--config') || getVal(argv, '-c');\n\n const procName = getVal(argv, '--name') || sessionId || '@OPEN-WA EASY API';\n const pm2 = argv.includes('--pm2');\n\n return {\n procName,\n pm2,\n forwardedArgs: argv,\n configPath,\n cliOverrides,\n verbose,\n unsupportedWarnings,\n };\n}\n\nexport async function resolveExecutablePath(\n config: Config,\n options: { preferLocalChrome?: boolean; cacheFilePath?: string } = {},\n): Promise<ExecutablePathResolution> {\n return resolveSharedExecutablePath(config, {\n ...options,\n cacheFilePath: options.cacheFilePath ?? getChromeCacheFilePath(),\n kind: config.useChromium || config.browser?.kind === 'chromium' ? 'chromium' : 'chrome',\n });\n}\n\nasync function selectRuntimeDriver(config: Config, rawConfigs?: TrackedConfig['rawConfigs'], nonInteractive = false): Promise<DriverSelection> {\n return selectSharedRuntimeDriver(config, {\n rawConfigs,\n cacheFilePath: getChromeCacheFilePath(),\n promptForMissingBrowser: true,\n nonInteractive,\n });\n}\n\nfunction printStartupSummary(\n config: Config,\n resolution: ExecutablePathResolution,\n preferLocalChrome: boolean,\n engineLabel: DriverSelection['engineLabel'],\n) {\n const host = config.host.includes('http') ? config.host : `http://${config.host}`;\n const sink = getCliOutputSink();\n sink.write({ level: 'info', message: `Easy API session: ${config.sessionId}` });\n sink.write({ level: 'info', message: `Health: ${host}:${config.port}/health` });\n sink.write({ level: 'info', message: `API Explorer: ${host}:${config.port}/api-docs/` });\n sink.write({ level: 'info', message: `Swagger JSON: ${host}:${config.port}/meta/swagger.json` });\n sink.write({ level: 'info', message: `Postman JSON: ${host}:${config.port}/meta/postman.json` });\n sink.write({ level: 'info', message: `Browser mode: ${config.headless ? 'headless' : 'headful'}` });\n sink.write({ level: 'info', message: `Browser engine: ${engineLabel}` });\n if (config.dashboard) {\n sink.write({ level: 'info', message: `Dashboard: ${host}:${config.port}/dashboard/` });\n } else {\n sink.write({ level: 'info', message: 'Dashboard: disabled (--no-dashboard)' });\n }\n if (resolution.source === 'lightpanda_config' && resolution.executablePath) {\n sink.write({ level: 'info', message: `Browser executable: explicit Lightpanda override (${resolution.executablePath})` });\n } else if (resolution.source === 'lightpanda_managed') {\n sink.write({ level: 'info', message: `Browser executable: Lightpanda with experimental WhatsApp setup (${resolution.executablePath})` });\n } else if (resolution.source === 'config' && config.executablePath) {\n sink.write({ level: 'info', message: `Browser executable: explicit override (${config.executablePath})` });\n } else if (resolution.source === 'cache') {\n sink.write({ level: 'info', message: `Browser executable: cached browser (${resolution.executablePath})` });\n } else if (resolution.source === 'chrome_installation') {\n sink.write({ level: 'info', message: `Browser executable: installed ${config.browser?.kind === 'chromium' ? 'Chromium' : 'Chrome'} (${resolution.executablePath})` });\n } else if (resolution.source === 'managed_browser') {\n sink.write({ level: 'info', message: `Browser executable: managed ${config.browser?.kind === 'chromium' ? 'Chromium' : 'Chrome'} (${resolution.executablePath})` });\n }\n if (config.webhook) {\n sink.write({\n level: 'warn',\n message: `Webhook configured (${config.webhook}) but v5 CLI webhook registration parity is not yet restored.`,\n });\n }\n}\n\nexport async function start(parsedArgs: ParsedCliArgs = parseCliArgs()): Promise<CliRuntimeResult> {\n const { configPath, cliOverrides, verbose, unsupportedWarnings } = parsedArgs;\n const sink = getCliOutputSink();\n\n sink.status({ phase: 'boot' });\n\n const { config, sources, configFilePath, rawConfigs } = await resolveConfig({\n configPath,\n cliOverrides: {\n disableSpins: true,\n apiLifecycle: 'hybrid',\n // Let schema defaults, config files, and WA_HOST/WA_PORT resolve\n // before applying host/port flags actually supplied by the user.\n ...cliOverrides,\n },\n includeRawConfigs: true,\n verbose,\n });\n\n if (verbose) {\n sink.write({ level: 'info', message: `Config sources: ${sources.join(', ')}` });\n if (configFilePath) {\n sink.write({ level: 'info', message: `Config file: ${configFilePath}` });\n }\n }\n\n sink.status({ phase: 'config.resolved', sessionId: config.sessionId });\n\n unsupportedWarnings.forEach((warning) => sink.write({ level: 'warn', message: `Compatibility warning: ${warning}` }));\n\n const driverSelection = await selectRuntimeDriver(config, rawConfigs, parsedArgs.forwardedArgs.includes('--non-interactive'));\n const { driver, engineLabel, executableResolution, preferLocalChrome } = driverSelection;\n if (executableResolution.warning) {\n sink.write({ level: 'warn', message: executableResolution.warning });\n }\n\n const server = new WAServer(config, verbose);\n sink.status({ phase: 'server.starting', sessionId: config.sessionId });\n\n await server.start();\n sink.status({ phase: 'server.started', sessionId: config.sessionId });\n\n printStartupSummary(config, executableResolution, preferLocalChrome, engineLabel);\n\n sink.status({ phase: 'client.starting', sessionId: config.sessionId });\n sink.write({ level: 'info', message: 'Starting WhatsApp Client...' });\n\n const sandboxPolicy = resolveChatSandboxPolicy(config.sandboxChats);\n const executionSandbox = sandboxPolicy\n ? makeNodeExecutionSandbox({ workspacePath: process.cwd() })\n : undefined;\n\n const openwaClient = await createClient({\n sessionId: config.sessionId,\n pluginRefs: config.plugins,\n pluginConfig: config.pluginConfig,\n hooks: config.hooks,\n eventMode: config.eventMode,\n driver,\n deleteSessionDataOnLogout: config.deleteSessionDataOnLogout,\n killClientOnLogout: config.killClientOnLogout,\n sessionDataPath: config.sessionDataPath,\n sessionData: config.sessionData,\n skipSessionSave: config.skipSessionSave,\n sessionDataBucketAuth: config.sessionDataBucketAuth,\n sessionDataEncryptionKey: config.sessionDataEncryptionKey,\n sessionDataEncryptionKeyFile: config.sessionDataEncryptionKeyFile,\n s3Sync: config.s3Sync,\n debug: config.logLevel === 'debug' || verbose || config.logConsole,\n headless: config.headless,\n qrTimeoutMs: typeof config.qrTimeout === 'number' ? config.qrTimeout * 1000 : undefined,\n authTimeoutMs: typeof config.authTimeout === 'number' ? config.authTimeout * 1000 : undefined,\n executablePath: executableResolution.executablePath,\n browserArgs: config.chromiumArgs,\n browser: config.browser,\n allowDangerousBrowserArgs: config.allowDangerousBrowserArgs,\n userDataDir: config.userDataDir,\n ephemeral: config.ephemeral,\n linkCode: config.linkCode,\n logConsole: config.logConsole,\n logConsoleErrors: config.logConsoleErrors,\n blockCrashLogs: config.blockCrashLogs,\n blockAssets: config.blockAssets,\n safeMode: config.safeMode,\n lightpanda: config.useLightpanda ? { experimentalWhatsApp: true, ...config.lightpanda } : undefined,\n licenseKey: config.licenseKey as any,\n licenseConfig: config.licenseConfig,\n patchConfig: { ghPatch: config.ghPatch, cachedPatch: config.cachedPatch },\n calling: config.calling,\n callMediaHost: makeDefaultCallMediaHost(),\n sandboxPolicy,\n executionSandbox,\n memoryObservation: (observability, getBrowserProcessId) => observeBrowserProcessMemory(\n observability,\n getBrowserProcessId,\n { attributes: { session: config.sessionId } },\n ),\n });\n\n server.setReadinessProvider(() => ({ ...openwaClient.getReadiness(), state: openwaClient.getState() }));\n const detachLaunchNarration = attachLaunchNarration(openwaClient, sink, config.sessionId);\n\n openwaClient.events.on('launch.auth.qr.expired', () => server.setQR(null));\n openwaClient.events.on('launch.auth.qr.scanned', () => server.setQR(null));\n openwaClient.events.on('launch.auth.qr.generated', (event) => {\n const qr = event.details?.qr;\n if (!qr) {\n return;\n }\n\n if (config.qrLogSkip) {\n sink.write({ level: 'info', message: 'New QR Code generated. Not printing in console because qrLogSkip is set to true' });\n } else {\n sink.status({ phase: 'auth.qr', sessionId: config.sessionId, detail: 'QR code generated' });\n sink.qr({ qr, sessionId: config.sessionId });\n }\n\n server.setQR(qr);\n });\n\n openwaClient.events.on('launch.auth.linkCode.generated', (event) => {\n const linkCode = event.details?.linkCode;\n if (!linkCode) {\n return;\n }\n\n sink.status({\n phase: 'launch.auth',\n sessionId: config.sessionId,\n detail: 'Link code generated; enter it on the paired phone',\n });\n sink.write({\n level: 'info',\n message: `Link code (local console only): ${linkCode}`,\n });\n });\n\n const client = new ClientFacade({\n client: openwaClient,\n transport: openwaClient.getTransport(),\n });\n\n server.setClient(client as any);\n server.mountPlugins(openwaClient.plugins);\n\n const runtimeBridgeListeners = new Set<(event: string, value: any) => void>();\n const runtimeEventPublishers: RuntimeEventPublisher[] = [\n {\n publish: (eventName, payload) => {\n runtimeBridgeListeners.forEach((listener) => {\n listener(eventName, payload);\n });\n },\n },\n ];\n\n const publishRuntimeEvent = (eventName: string, payload: any) => {\n runtimeEventPublishers.forEach((publisher) => {\n publisher.publish(eventName, payload);\n });\n };\n\n const detachRuntimeBridge = bridgeRuntimeEvents(openwaClient, publishRuntimeEvent);\n\n // Bridge core events to the socket manager so dashboard clients\n // receive live events when they send register_ev.\n if (typeof server.setEventBridge === 'function') {\n server.setEventBridge({\n onAny: (listener: (event: string, value: any) => void) => {\n runtimeBridgeListeners.add(listener);\n },\n offAny: (listener: (event: string, value: any) => void) => {\n runtimeBridgeListeners.delete(listener);\n },\n });\n }\n\n const handleBrowserInit = async () => {\n const page = openwaClient.getTransport().getPage();\n if (page) {\n await server.setPage(page as any).catch(() => {});\n }\n };\n openwaClient.events.on('launch.browser.init.after', handleBrowserInit);\n\n let disposed = false;\n const dispose = () => {\n if (disposed) return;\n disposed = true;\n detachRuntimeBridge();\n openwaClient.events.off('launch.browser.init.after', handleBrowserInit);\n runtimeBridgeListeners.clear();\n };\n\n try {\n await client.start();\n } catch (startError) {\n const msg = startError instanceof Error ? startError.message : String(startError);\n sink.write({ level: 'error', message: `Bootstrap failed: ${msg}` });\n sink.write({ level: 'warn', message: 'The API server is still running for inspection; the client failed to start.' });\n sink.write({ level: 'warn', message: 'The server is running — use /health and /api-docs to inspect state.' });\n detachLaunchNarration();\n return { server, client, config, events: openwaClient.events, dispose };\n }\n\n const readiness = openwaClient.getReadiness();\n sink.status({\n phase: 'client.ready',\n sessionId: config.sessionId,\n detail: `status=${readiness.status}, exposureSafe=${readiness.exposureSafe}`,\n });\n sink.write({\n level: 'info',\n message: `WhatsApp Client ready with state: ${client.getState()} (status=${readiness.status}, exposureSafe=${readiness.exposureSafe})`,\n });\n\n detachLaunchNarration();\n return { server, client, config, events: openwaClient.events, dispose };\n}\n\nexport async function main(argv: string[] = process.argv.slice(2)): Promise<CliRuntimeResult | void> {\n if (argv[0] === 'init') {\n const { initProject } = await import('./cli/init');\n await initProject(argv.slice(1));\n return;\n }\n const parsedArgs = parseCliArgs(argv);\n\n if (parsedArgs.pm2) {\n const { spawn } = require('child_process');\n const sink = getCliOutputSink();\n const pm2Command = getPm2Command();\n const pm2SpawnOptions = getPm2SpawnOptions();\n try {\n const pm2 = spawn(pm2Command, ['--version'], pm2SpawnOptions);\n\n await new Promise<void>((resolve, reject) => {\n pm2.on('error', reject);\n pm2.on('exit', (code: number | null) => {\n if (code === 0) {\n resolve();\n return;\n }\n\n reject(new Error(`pm2 probe exited with code ${code ?? 'unknown'}`));\n });\n pm2.stdout.on('data', () => resolve());\n });\n\n const pm2Flags = parsedArgs.forwardedArgs.filter((flag: string) => flag !== '--pm2');\n const cliPath = fileURLToPath(new URL('../dist/cli.cjs', import.meta.url));\n\n spawn(pm2Command, [\n 'start',\n cliPath,\n '--name', parsedArgs.procName,\n '--stop-exit-codes', '88',\n '--',\n ...pm2Flags,\n ], {\n ...pm2SpawnOptions,\n stdio: 'inherit',\n detached: true\n });\n return;\n } catch (error: unknown) {\n if (isCommandNotFoundError(error)) {\n sink.write({ level: 'error', message: 'pm2 not found. Please install with: npm install -g pm2' });\n return;\n }\n throw error;\n }\n }\n\n return await start(parsedArgs);\n}\n\nfunction getPm2Command(): string {\n return process.platform === 'win32' ? 'pm2.cmd' : 'pm2';\n}\n\nfunction getPm2SpawnOptions(): { shell: boolean } {\n return { shell: process.platform === 'win32' };\n}\n\nfunction isCommandNotFoundError(error: unknown): boolean {\n if (typeof error !== 'object' || error === null) {\n return false;\n }\n\n const systemError = error as { code?: unknown; errno?: unknown };\n return systemError.code === 'ENOENT' || systemError.errno === -2;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAa,WAAb,cAA8BA,aAAAA,UAAU;CACtC,YAAY,QAAgB,UAAU,OAAO;EAC3C,MAAM;GAAE;GAAQ;EAAQ,CAAC;CAC3B;AACF;;;ACoCA,eAAsB,aAAa,UAAkB,SAA6C;CAChG,IAAI,CAAC,QAAQ,MAAM,SAAS,CAAC,QAAQ,OAAO,OAC1C,MAAM,IAAI,MAAM,oHAAoH;CAEtI,MAAM,EAAE,oBAAoB,MAAM,OAAO;CACzC,MAAM,WAAW,gBAAgB;EAAE,OAAO,QAAQ;EAAO,QAAQ,QAAQ;CAAO,CAAC;CACjF,MAAM,QAAQ,IAAI,gBAAgB;CAClC,SAAS,GAAG,gBAAgB,MAAM,MAAM,CAAC;CACzC,SAAS,GAAG,eAAe,MAAM,MAAM,CAAC;CACxC,IAAI;EACF,QAAQ,OAAO,MAAM,KAAK,SAAS,IAAI,QAAQ,KAAK,QAAQ,UAAU,KAAK,QAAQ,EAAE,IAAI,QAAQ,CAAC,CAAC,KAAK,IAAI,EAAE,GAAG;EACjH,OAAO,MAAM;GACX,MAAM,UAAU,MAAM,SAAS,SAAS,0BAA0B,EAAE,QAAQ,MAAM,OAAO,CAAC,EAAA,CAAG,KAAK;GAClG,MAAM,SAAS,WAAW,KAAK,IAAI,OAAO,MAAM,IAAI;GACpD,IAAI,OAAO,UAAU,MAAM,KAAK,UAAU,KAAK,SAAS,QAAQ,QAAQ,OAAO;GAC/E,QAAQ,OAAO,MAAM,4BAA4B,QAAQ,OAAO,IAAI;EACtE;CACF,S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