@open-wa/wa-automate 4.76.0 → 5.0.0-alpha.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/README.md +14 -165
- package/dist/cli-runtime-B7_3MM0c.cjs +798 -0
- package/dist/cli-runtime-B7_3MM0c.cjs.map +1 -0
- package/dist/cli-runtime-CmpYxFCk.d.cts +31 -0
- package/dist/cli-runtime-CmpYxFCk.d.cts.map +1 -0
- package/dist/cli.cjs +17 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/index.cjs +224 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.cts.map +1 -0
- package/package.json +34 -177
- package/CNAME +0 -1
- package/_tsconfig.docs.json +0 -140
- package/bin/config-schema.json +0 -1
- package/bin/oas-type-schemas.json +0 -1
- package/bin/server.js +0 -45
- package/build/build-config-json-for-bin.ts +0 -56
- package/build/generate-oas-types.ts +0 -31
- package/dist/api/Client.d.ts +0 -2255
- package/dist/api/Client.js +0 -4358
- package/dist/api/functions/exposed.enum.d.ts +0 -7
- package/dist/api/functions/exposed.enum.js +0 -11
- package/dist/api/model/aliases.d.ts +0 -110
- package/dist/api/model/aliases.js +0 -3
- package/dist/api/model/button.d.ts +0 -24
- package/dist/api/model/button.js +0 -2
- package/dist/api/model/call.d.ts +0 -51
- package/dist/api/model/call.js +0 -18
- package/dist/api/model/chat.d.ts +0 -221
- package/dist/api/model/chat.js +0 -52
- package/dist/api/model/config.d.ts +0 -836
- package/dist/api/model/config.js +0 -111
- package/dist/api/model/contact.d.ts +0 -143
- package/dist/api/model/contact.js +0 -2
- package/dist/api/model/errors.d.ts +0 -90
- package/dist/api/model/errors.js +0 -117
- package/dist/api/model/events.d.ts +0 -120
- package/dist/api/model/events.js +0 -127
- package/dist/api/model/group-metadata.d.ts +0 -124
- package/dist/api/model/group-metadata.js +0 -25
- package/dist/api/model/id.d.ts +0 -5
- package/dist/api/model/id.js +0 -2
- package/dist/api/model/index.d.ts +0 -110
- package/dist/api/model/index.js +0 -128
- package/dist/api/model/label.d.ts +0 -24
- package/dist/api/model/label.js +0 -2
- package/dist/api/model/media.d.ts +0 -93
- package/dist/api/model/media.js +0 -12
- package/dist/api/model/message.d.ts +0 -422
- package/dist/api/model/message.js +0 -40
- package/dist/api/model/product.d.ts +0 -141
- package/dist/api/model/product.js +0 -2
- package/dist/api/model/reactions.d.ts +0 -76
- package/dist/api/model/reactions.js +0 -2
- package/dist/api/model/sessionInfo.d.ts +0 -77
- package/dist/api/model/sessionInfo.js +0 -2
- package/dist/build/build-postman.d.ts +0 -1
- package/dist/build/build-postman.js +0 -262
- package/dist/cli/cli-options.d.ts +0 -9
- package/dist/cli/cli-options.js +0 -289
- package/dist/cli/collections.d.ts +0 -2
- package/dist/cli/collections.js +0 -251
- package/dist/cli/file-utils.d.ts +0 -1
- package/dist/cli/file-utils.js +0 -71
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/index.js +0 -231
- package/dist/cli/integrations/chatwoot.d.ts +0 -49
- package/dist/cli/integrations/chatwoot.js +0 -672
- package/dist/cli/integrations/cloudflare.d.ts +0 -6
- package/dist/cli/integrations/cloudflare.js +0 -76
- package/dist/cli/logo.d.ts +0 -1
- package/dist/cli/logo.js +0 -49
- package/dist/cli/server.d.ts +0 -24
- package/dist/cli/server.js +0 -540
- package/dist/cli/setup.d.ts +0 -30
- package/dist/cli/setup.js +0 -308
- package/dist/config/puppeteer.config.d.ts +0 -11
- package/dist/config/puppeteer.config.js +0 -65
- package/dist/controllers/auth.d.ts +0 -36
- package/dist/controllers/auth.js +0 -322
- package/dist/controllers/browser.d.ts +0 -17
- package/dist/controllers/browser.js +0 -603
- package/dist/controllers/events.d.ts +0 -82
- package/dist/controllers/events.js +0 -173
- package/dist/controllers/init_patch.d.ts +0 -13
- package/dist/controllers/init_patch.js +0 -42
- package/dist/controllers/initializer.d.ts +0 -22
- package/dist/controllers/initializer.js +0 -511
- package/dist/controllers/launch_checks.d.ts +0 -8
- package/dist/controllers/launch_checks.js +0 -130
- package/dist/controllers/patch_manager.d.ts +0 -37
- package/dist/controllers/patch_manager.js +0 -231
- package/dist/controllers/popup/index.d.ts +0 -3
- package/dist/controllers/popup/index.html +0 -168
- package/dist/controllers/popup/index.js +0 -148
- package/dist/controllers/script_preloader.d.ts +0 -17
- package/dist/controllers/script_preloader.js +0 -88
- package/dist/index.d.ts +0 -13
- package/dist/index.js +0 -36
- package/dist/lib/README.md +0 -5
- package/dist/lib/base64.js +0 -1
- package/dist/lib/hash.js +0 -1
- package/dist/lib/jsSha.min.js +0 -1
- package/dist/lib/launch.js +0 -1
- package/dist/lib/qr.min.js +0 -1
- package/dist/lib/wapi.js +0 -2163
- package/dist/logging/custom_transport.d.ts +0 -9
- package/dist/logging/custom_transport.js +0 -35
- package/dist/logging/logging.d.ts +0 -50
- package/dist/logging/logging.js +0 -196
- package/dist/structures/Collector.d.ts +0 -202
- package/dist/structures/Collector.js +0 -391
- package/dist/structures/Dialog.d.ts +0 -55
- package/dist/structures/Dialog.js +0 -21
- package/dist/structures/MessageCollector.d.ts +0 -78
- package/dist/structures/MessageCollector.js +0 -145
- package/dist/structures/preProcessors.d.ts +0 -58
- package/dist/structures/preProcessors.js +0 -181
- package/dist/utils/pid_utils.d.ts +0 -1
- package/dist/utils/pid_utils.js +0 -26
- package/dist/utils/tools.d.ts +0 -152
- package/dist/utils/tools.js +0 -494
- package/tos.md +0 -77
|
@@ -0,0 +1,798 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
//#endregion
|
|
23
|
+
let _open_wa_api = require("@open-wa/api");
|
|
24
|
+
let boxen = require("boxen");
|
|
25
|
+
boxen = __toESM(boxen);
|
|
26
|
+
let qrcode_terminal = require("qrcode-terminal");
|
|
27
|
+
qrcode_terminal = __toESM(qrcode_terminal);
|
|
28
|
+
let _open_wa_core = require("@open-wa/core");
|
|
29
|
+
let _open_wa_client = require("@open-wa/client");
|
|
30
|
+
let _open_wa_driver_lightpanda = require("@open-wa/driver-lightpanda");
|
|
31
|
+
let _open_wa_driver_puppeteer = require("@open-wa/driver-puppeteer");
|
|
32
|
+
let _open_wa_schema = require("@open-wa/schema");
|
|
33
|
+
let _open_wa_config = require("@open-wa/config");
|
|
34
|
+
let node_fs = require("node:fs");
|
|
35
|
+
let node_path = require("node:path");
|
|
36
|
+
let node_url = require("node:url");
|
|
37
|
+
//#region src/server/hono-server.ts
|
|
38
|
+
var WAServer = class extends _open_wa_api.ApiServer {
|
|
39
|
+
constructor(config) {
|
|
40
|
+
super({ config });
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region src/cli/output-sink.ts
|
|
45
|
+
function writeToConsole(level, message) {
|
|
46
|
+
if (level === "warn") {
|
|
47
|
+
console.warn(message);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (level === "error") {
|
|
51
|
+
console.error(message);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
console.log(message);
|
|
55
|
+
}
|
|
56
|
+
function createConsoleOutputSink() {
|
|
57
|
+
return {
|
|
58
|
+
write(entry) {
|
|
59
|
+
writeToConsole(entry.level, entry.message);
|
|
60
|
+
},
|
|
61
|
+
status() {},
|
|
62
|
+
qr(payload) {
|
|
63
|
+
qrcode_terminal.default.generate(payload.qr, { small: true }, (terminalQrCode) => {
|
|
64
|
+
console.log((0, boxen.default)(terminalQrCode, {
|
|
65
|
+
title: payload.sessionId,
|
|
66
|
+
padding: 1,
|
|
67
|
+
titleAlignment: "center"
|
|
68
|
+
}));
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
let activeSink = createConsoleOutputSink();
|
|
74
|
+
function getCliOutputSink() {
|
|
75
|
+
return activeSink;
|
|
76
|
+
}
|
|
77
|
+
function setCliOutputSink(sink) {
|
|
78
|
+
activeSink = sink;
|
|
79
|
+
}
|
|
80
|
+
function resetCliOutputSink() {
|
|
81
|
+
activeSink = createConsoleOutputSink();
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/cli-runtime.ts
|
|
85
|
+
function bridgeRuntimeEvents(openwaClient, publishRuntimeEvent) {
|
|
86
|
+
if (typeof openwaClient.events.onAny === "function" && typeof openwaClient.events.offAny === "function") {
|
|
87
|
+
openwaClient.events.onAny(publishRuntimeEvent);
|
|
88
|
+
return () => openwaClient.events.offAny(publishRuntimeEvent);
|
|
89
|
+
}
|
|
90
|
+
const unsubscribers = [];
|
|
91
|
+
new Set(_open_wa_schema.eventRegistry.getAll().map((def) => def.meta.eventName)).forEach((eventName) => {
|
|
92
|
+
const handler = (payload) => publishRuntimeEvent(eventName, payload);
|
|
93
|
+
openwaClient.events.on(eventName, handler);
|
|
94
|
+
unsubscribers.push(() => openwaClient.events.off(eventName, handler));
|
|
95
|
+
});
|
|
96
|
+
return () => {
|
|
97
|
+
unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function attachLaunchNarration(openwaClient, sink, sessionId) {
|
|
101
|
+
const unsubscribers = [];
|
|
102
|
+
const on = (event, handler) => {
|
|
103
|
+
openwaClient.events.on(event, handler);
|
|
104
|
+
unsubscribers.push(() => openwaClient.events.off(event, handler));
|
|
105
|
+
};
|
|
106
|
+
on("launch.auth.check.before", (event) => {
|
|
107
|
+
sink.status({
|
|
108
|
+
phase: "launch.auth",
|
|
109
|
+
sessionId,
|
|
110
|
+
detail: `Authenticating (timeout=${event?.details?.timeoutMs ?? "∞"}ms)`
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
on("launch.auth.check.after", (event) => {
|
|
114
|
+
sink.write({
|
|
115
|
+
level: "info",
|
|
116
|
+
message: `Auth detected via ${event?.details?.method ?? "unknown"} (${event?.details?.isAuthenticated ? "authenticated" : "not-authenticated"})`
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
on("launch.helper.pre_api.before", (event) => {
|
|
120
|
+
sink.status({
|
|
121
|
+
phase: "launch.helpers",
|
|
122
|
+
sessionId,
|
|
123
|
+
detail: event?.details?.mode === "scripts" ? "Injecting pre-API helper assets..." : "Pre-API helpers already present"
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
on("launch.helper.pre_api.after", (event) => {
|
|
127
|
+
sink.write({
|
|
128
|
+
level: "info",
|
|
129
|
+
message: `Pre-API helper phase complete (${event?.details?.mode ?? "unknown"})`
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
on("internal_launch_progress", (event) => {
|
|
133
|
+
const prefix = event?.value || event?.value === 0 ? `${event.value}% ` : "";
|
|
134
|
+
if (event?.text) sink.write({
|
|
135
|
+
level: "info",
|
|
136
|
+
message: `${prefix}${event.text}`.trim()
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
on("critical_internal_message", (event) => {
|
|
140
|
+
sink.write({
|
|
141
|
+
level: "warn",
|
|
142
|
+
message: `Internal launch message: ${event?.text ?? event?.value ?? "unknown"}`
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
on("launch.patch.init.before", (event) => {
|
|
146
|
+
if (event?.details?.phase === "preload") sink.status({
|
|
147
|
+
phase: "launch.patch",
|
|
148
|
+
sessionId,
|
|
149
|
+
detail: "Downloading patches from CDN..."
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
on("launch.patch.init.after", (event) => {
|
|
153
|
+
if (event?.details?.phase === "preload") {
|
|
154
|
+
const source = event?.details?.source ?? "unknown";
|
|
155
|
+
const tag = event?.details?.tag ? ` tag=${event.details.tag}` : "";
|
|
156
|
+
const available = Array.isArray(event?.details?.available) ? event.details.available.length : 0;
|
|
157
|
+
const durationMs = event?.durationMs;
|
|
158
|
+
const durationStr = durationMs ? ` in ${(durationMs / 1e3).toFixed(2)}s` : "";
|
|
159
|
+
sink.write({
|
|
160
|
+
level: "info",
|
|
161
|
+
message: `Downloaded patches${durationStr} (source=${source}, available=${available}${tag})`
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
on("patch.init.before", (event) => {
|
|
166
|
+
if (event?.details?.phase === "apply") {
|
|
167
|
+
const count = Array.isArray(event?.details?.patchIds) ? event.details.patchIds.length : 0;
|
|
168
|
+
sink.status({
|
|
169
|
+
phase: "launch.patch",
|
|
170
|
+
sessionId,
|
|
171
|
+
detail: `Installing patches (${count} queued)`
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
on("patch.apply.before", (event) => {
|
|
176
|
+
sink.status({
|
|
177
|
+
phase: "launch.patch",
|
|
178
|
+
sessionId,
|
|
179
|
+
detail: `Applying patch: ${event?.details?.patchId ?? "unknown"}`
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
on("patch.apply.after", (event) => {
|
|
183
|
+
sink.write({
|
|
184
|
+
level: event?.details?.outcome === "failed" ? "warn" : "info",
|
|
185
|
+
message: `Patch ${event?.details?.patchId ?? "unknown"}: ${event?.details?.outcome ?? (event?.details?.applied ? "applied" : "unknown")}${event?.details?.detail ? ` — ${event.details.detail}` : ""}`
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
on("patch.init.after", (event) => {
|
|
189
|
+
if (event?.details?.phase === "apply") {
|
|
190
|
+
const applied = Array.isArray(event?.details?.applied) ? event.details.applied : [];
|
|
191
|
+
const outcome = event?.details?.outcome ?? "unknown";
|
|
192
|
+
const tag = applied.length > 0 ? applied.join(", ") : outcome;
|
|
193
|
+
const durationMs = event?.durationMs;
|
|
194
|
+
const durationStr = durationMs ? ` in ${(durationMs / 1e3).toFixed(2)}s` : "";
|
|
195
|
+
sink.write({
|
|
196
|
+
level: event?.details?.blockingFailure ? "warn" : "info",
|
|
197
|
+
message: `Patches Installed${durationStr}: ${tag}`
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
on("launch.patch.integrity.before", () => {
|
|
202
|
+
sink.status({
|
|
203
|
+
phase: "launch.patch",
|
|
204
|
+
sessionId,
|
|
205
|
+
detail: "Validating patched runtime..."
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
on("launch.patch.integrity.after", (event) => {
|
|
209
|
+
sink.write({
|
|
210
|
+
level: event?.details?.usable ? "info" : "warn",
|
|
211
|
+
message: `Patched runtime validation: ${event?.details?.usable ? "usable" : "failed"}${event?.details?.failureReason ? ` (${event.details.failureReason})` : ""}`
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
on("launch.license.check.before", (event) => {
|
|
215
|
+
sink.status({
|
|
216
|
+
phase: "launch.license",
|
|
217
|
+
sessionId,
|
|
218
|
+
detail: `Checking license (${event?.details?.source ?? "local"})`
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
on("launch.license.check.after", (event) => {
|
|
222
|
+
sink.write({
|
|
223
|
+
level: event?.details?.blockingFailure ? "warn" : "info",
|
|
224
|
+
message: `License check: ${event?.details?.status ?? "unknown"}${event?.details?.detail ? ` — ${event.details.detail}` : ""}`
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
on("license.inject.before", () => {
|
|
228
|
+
sink.status({
|
|
229
|
+
phase: "launch.license",
|
|
230
|
+
sessionId,
|
|
231
|
+
detail: "Injecting license payload..."
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
on("license.inject.after", (event) => {
|
|
235
|
+
sink.write({
|
|
236
|
+
level: event?.details?.success ? "info" : "warn",
|
|
237
|
+
message: `License inject: ${event?.details?.success ? "success" : "failed"}${event?.details?.status ? ` (${event.details.status})` : ""}${event?.details?.detail ? ` — ${event.details.detail}` : ""}`
|
|
238
|
+
});
|
|
239
|
+
});
|
|
240
|
+
on("launch.auth.qr.generated", (event) => {
|
|
241
|
+
const qrIndex = event?.details?.qrIndex ?? "?";
|
|
242
|
+
sink.status({
|
|
243
|
+
phase: "launch.auth",
|
|
244
|
+
sessionId,
|
|
245
|
+
detail: `QR code generated (#${qrIndex})`
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
on("launch.client.finalize.before", (event) => {
|
|
249
|
+
sink.status({
|
|
250
|
+
phase: "launch.finalize",
|
|
251
|
+
sessionId,
|
|
252
|
+
detail: `Finalizing session (${event?.details?.validationStage ?? "unknown"})`
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
on("launch.client.finalize.after", (event) => {
|
|
256
|
+
sink.write({
|
|
257
|
+
level: event?.details?.success ? "info" : "warn",
|
|
258
|
+
message: `Finalize: ${event?.details?.outcome ?? "unknown"}${event?.details?.detail ? ` — ${event.details.detail}` : ""}`
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
on("error", (event) => {
|
|
262
|
+
const scope = event?.scope ?? "unknown";
|
|
263
|
+
const msg = event?.error?.message ?? String(event?.error ?? "unknown error");
|
|
264
|
+
const fatal = event?.fatal ? " [FATAL]" : "";
|
|
265
|
+
sink.write({
|
|
266
|
+
level: "error",
|
|
267
|
+
message: `${fatal} ${scope}: ${msg}`.trim()
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
return () => {
|
|
271
|
+
unsubscribers.forEach((unsubscribe) => unsubscribe());
|
|
272
|
+
};
|
|
273
|
+
}
|
|
274
|
+
const CHROME_CACHE_FILE = (0, node_path.resolve)(process.cwd(), ".open-wa", "chrome-executable-path.json");
|
|
275
|
+
function getChromeCacheFilePath() {
|
|
276
|
+
return CHROME_CACHE_FILE;
|
|
277
|
+
}
|
|
278
|
+
function readChromePathCache(cacheFilePath = getChromeCacheFilePath()) {
|
|
279
|
+
if (!(0, node_fs.existsSync)(cacheFilePath)) return;
|
|
280
|
+
try {
|
|
281
|
+
const raw = JSON.parse((0, node_fs.readFileSync)(cacheFilePath, "utf8"));
|
|
282
|
+
if (!raw || typeof raw !== "object") return;
|
|
283
|
+
return {
|
|
284
|
+
executablePath: typeof raw.executablePath === "string" ? raw.executablePath : void 0,
|
|
285
|
+
updatedAt: typeof raw.updatedAt === "string" ? raw.updatedAt : void 0
|
|
286
|
+
};
|
|
287
|
+
} catch {
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function writeChromePathCache(executablePath, cacheFilePath = getChromeCacheFilePath()) {
|
|
292
|
+
(0, node_fs.mkdirSync)((0, node_path.dirname)(cacheFilePath), { recursive: true });
|
|
293
|
+
(0, node_fs.writeFileSync)(cacheFilePath, JSON.stringify({
|
|
294
|
+
executablePath,
|
|
295
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
296
|
+
}, null, 2), "utf8");
|
|
297
|
+
}
|
|
298
|
+
function clearChromePathCache(cacheFilePath = getChromeCacheFilePath()) {
|
|
299
|
+
if ((0, node_fs.existsSync)(cacheFilePath)) (0, node_fs.rmSync)(cacheFilePath, { force: true });
|
|
300
|
+
}
|
|
301
|
+
function isUsableExecutablePath(executablePath) {
|
|
302
|
+
return !!executablePath && (0, node_fs.existsSync)(executablePath);
|
|
303
|
+
}
|
|
304
|
+
function getExplicitUseChromePreference(rawConfigs) {
|
|
305
|
+
const explicitConfigSources = [
|
|
306
|
+
rawConfigs?.file,
|
|
307
|
+
rawConfigs?.env,
|
|
308
|
+
rawConfigs?.cli,
|
|
309
|
+
rawConfigs?.programmatic
|
|
310
|
+
];
|
|
311
|
+
for (let index = explicitConfigSources.length - 1; index >= 0; index -= 1) {
|
|
312
|
+
const source = explicitConfigSources[index];
|
|
313
|
+
if (source?.useChrome !== void 0) return source.useChrome;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
function shouldPreferLocalChrome(config, rawConfigs) {
|
|
317
|
+
if (config.useLightpanda) return false;
|
|
318
|
+
if (config.executablePath) return false;
|
|
319
|
+
const explicitUseChrome = getExplicitUseChromePreference(rawConfigs);
|
|
320
|
+
if (explicitUseChrome !== void 0) return explicitUseChrome;
|
|
321
|
+
return true;
|
|
322
|
+
}
|
|
323
|
+
function getVal(argv, flag) {
|
|
324
|
+
const index = argv.findIndex((arg) => arg === flag);
|
|
325
|
+
return index !== -1 ? argv[index + 1] : void 0;
|
|
326
|
+
}
|
|
327
|
+
function parseCliArgs(argv = process.argv.slice(2)) {
|
|
328
|
+
const cliOverrides = {};
|
|
329
|
+
const unsupportedWarnings = [];
|
|
330
|
+
let verbose = false;
|
|
331
|
+
let configPath;
|
|
332
|
+
const sessionId = getVal(argv, "--session-id") || "session";
|
|
333
|
+
cliOverrides.sessionId = sessionId;
|
|
334
|
+
const portValue = getVal(argv, "--port") || getVal(argv, "-p");
|
|
335
|
+
if (portValue) cliOverrides.port = parseInt(portValue, 10);
|
|
336
|
+
const host = getVal(argv, "--host") || getVal(argv, "-h");
|
|
337
|
+
if (host) cliOverrides.host = host;
|
|
338
|
+
const apiKey = getVal(argv, "--api-key") || getVal(argv, "--key") || getVal(argv, "-k");
|
|
339
|
+
if (apiKey) cliOverrides.apiKey = apiKey;
|
|
340
|
+
const logLevel = getVal(argv, "--log-level");
|
|
341
|
+
if (logLevel) cliOverrides.logLevel = logLevel;
|
|
342
|
+
if (argv.includes("--no-ezqr")) cliOverrides.ezqr = false;
|
|
343
|
+
if (argv.includes("--headful")) cliOverrides.headless = false;
|
|
344
|
+
if (argv.includes("--headless")) cliOverrides.headless = true;
|
|
345
|
+
if (argv.includes("--use-chrome")) cliOverrides.useChrome = true;
|
|
346
|
+
if (argv.includes("--use-lightpanda")) cliOverrides.useLightpanda = true;
|
|
347
|
+
if (argv.includes("--log-console")) cliOverrides.logConsole = true;
|
|
348
|
+
if (argv.includes("--aggressive-garbage-collection")) cliOverrides.aggressiveGarbageCollection = true;
|
|
349
|
+
if (argv.includes("--no-dashboard")) cliOverrides.dashboard = false;
|
|
350
|
+
if (argv.includes("--ephemeral")) cliOverrides.ephemeral = true;
|
|
351
|
+
const qrTimeout = getVal(argv, "--qr-timeout");
|
|
352
|
+
if (qrTimeout) cliOverrides.qrTimeout = parseInt(qrTimeout, 10);
|
|
353
|
+
const dashboardPort = getVal(argv, "--dashboard-port");
|
|
354
|
+
if (dashboardPort) cliOverrides.dashboardPort = parseInt(dashboardPort, 10);
|
|
355
|
+
const licenseKey = getVal(argv, "--license-key") || getVal(argv, "-l");
|
|
356
|
+
if (licenseKey) cliOverrides.licenseKey = licenseKey;
|
|
357
|
+
const webhook = getVal(argv, "--webhook") || getVal(argv, "-w");
|
|
358
|
+
if (webhook) cliOverrides.webhook = webhook;
|
|
359
|
+
const proxyHost = getVal(argv, "--proxy-host");
|
|
360
|
+
if (proxyHost) cliOverrides.proxyHost = proxyHost;
|
|
361
|
+
const proxyToken = getVal(argv, "--proxy-token");
|
|
362
|
+
if (proxyToken) cliOverrides.proxyToken = proxyToken;
|
|
363
|
+
const readyWebhook = getVal(argv, "--ready-webhook");
|
|
364
|
+
if (readyWebhook) unsupportedWarnings.push(`--ready-webhook was provided (${readyWebhook}) but ready-webhook delivery is not yet wired in v5 CLI.`);
|
|
365
|
+
if (argv.includes("-v") || argv.includes("--verbose")) {
|
|
366
|
+
verbose = true;
|
|
367
|
+
cliOverrides.disableSpins = true;
|
|
368
|
+
cliOverrides.logConsole = true;
|
|
369
|
+
cliOverrides.logLevel = cliOverrides.logLevel || "debug";
|
|
370
|
+
}
|
|
371
|
+
if (argv.includes("--stats")) unsupportedWarnings.push("--stats was provided but swagger-stats parity is not restored; v5 only exposes the compatibility redirect/deprecation route.");
|
|
372
|
+
if (argv.includes("--generate-api-docs")) 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.");
|
|
373
|
+
if (argv.includes("--tunnel")) unsupportedWarnings.push("--tunnel was provided but tunnel setup parity is not yet restored in the v5 CLI.");
|
|
374
|
+
if (argv.includes("--chatwoot-url") || argv.includes("--twilio-webhook") || argv.includes("--bot-press-url")) unsupportedWarnings.push("Legacy integration flags (Chatwoot/Twilio/BotPress) were provided but are not yet wired into the v5 CLI boot path.");
|
|
375
|
+
if (argv.includes("--use-session-id-in-path")) cliOverrides.sessionId = sessionId;
|
|
376
|
+
configPath = getVal(argv, "--config") || getVal(argv, "-c");
|
|
377
|
+
return {
|
|
378
|
+
procName: getVal(argv, "--name") || sessionId || "@OPEN-WA EASY API",
|
|
379
|
+
pm2: argv.includes("--pm2"),
|
|
380
|
+
forwardedArgs: argv,
|
|
381
|
+
configPath,
|
|
382
|
+
cliOverrides,
|
|
383
|
+
verbose,
|
|
384
|
+
unsupportedWarnings
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
async function resolveExecutablePath(config, options = {}) {
|
|
388
|
+
if (config.executablePath) return {
|
|
389
|
+
executablePath: config.executablePath,
|
|
390
|
+
source: "config"
|
|
391
|
+
};
|
|
392
|
+
if (!(options.preferLocalChrome ?? config.useChrome)) return { source: "driver_default" };
|
|
393
|
+
const cacheFilePath = options.cacheFilePath ?? getChromeCacheFilePath();
|
|
394
|
+
const cachedPath = readChromePathCache(cacheFilePath)?.executablePath;
|
|
395
|
+
if (isUsableExecutablePath(cachedPath)) return {
|
|
396
|
+
executablePath: cachedPath,
|
|
397
|
+
source: "cache"
|
|
398
|
+
};
|
|
399
|
+
if (cachedPath) clearChromePathCache(cacheFilePath);
|
|
400
|
+
const { Launcher } = await import("chrome-launcher");
|
|
401
|
+
const detectedPath = Launcher.getInstallations().find((installationPath) => isUsableExecutablePath(installationPath));
|
|
402
|
+
if (detectedPath) {
|
|
403
|
+
writeChromePathCache(detectedPath, cacheFilePath);
|
|
404
|
+
return {
|
|
405
|
+
executablePath: detectedPath,
|
|
406
|
+
source: "chrome_installation"
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
clearChromePathCache(cacheFilePath);
|
|
410
|
+
return {
|
|
411
|
+
source: "driver_default",
|
|
412
|
+
warning: "Chrome resolution warning: no valid local Chrome installation was found. Falling back to Puppeteer/default driver browser resolution."
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function resolveLightpandaExecutablePath(config) {
|
|
416
|
+
const executablePath = config.lightpanda?.executablePath;
|
|
417
|
+
if (executablePath) return {
|
|
418
|
+
executablePath,
|
|
419
|
+
source: "lightpanda_config"
|
|
420
|
+
};
|
|
421
|
+
return { source: "lightpanda_sdk_default" };
|
|
422
|
+
}
|
|
423
|
+
async function selectRuntimeDriver(config, rawConfigs) {
|
|
424
|
+
if (config.useLightpanda) return {
|
|
425
|
+
driver: new _open_wa_driver_lightpanda.LightpandaDriver(),
|
|
426
|
+
engineLabel: "Lightpanda",
|
|
427
|
+
executableResolution: resolveLightpandaExecutablePath(config),
|
|
428
|
+
preferLocalChrome: false
|
|
429
|
+
};
|
|
430
|
+
const preferLocalChrome = shouldPreferLocalChrome(config, rawConfigs);
|
|
431
|
+
const executableResolution = await resolveExecutablePath(config, { preferLocalChrome });
|
|
432
|
+
return {
|
|
433
|
+
driver: new _open_wa_driver_puppeteer.PuppeteerDriver(),
|
|
434
|
+
engineLabel: "Puppeteer",
|
|
435
|
+
executableResolution,
|
|
436
|
+
preferLocalChrome
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
function printStartupSummary(config, resolution, preferLocalChrome, engineLabel) {
|
|
440
|
+
const host = config.host.includes("http") ? config.host : `http://${config.host}`;
|
|
441
|
+
const sink = getCliOutputSink();
|
|
442
|
+
sink.write({
|
|
443
|
+
level: "info",
|
|
444
|
+
message: `Easy API session: ${config.sessionId}`
|
|
445
|
+
});
|
|
446
|
+
sink.write({
|
|
447
|
+
level: "info",
|
|
448
|
+
message: `Health: ${host}:${config.port}/health`
|
|
449
|
+
});
|
|
450
|
+
sink.write({
|
|
451
|
+
level: "info",
|
|
452
|
+
message: `API Explorer: ${host}:${config.port}/api-docs/`
|
|
453
|
+
});
|
|
454
|
+
sink.write({
|
|
455
|
+
level: "info",
|
|
456
|
+
message: `Swagger JSON: ${host}:${config.port}/meta/swagger.json`
|
|
457
|
+
});
|
|
458
|
+
sink.write({
|
|
459
|
+
level: "info",
|
|
460
|
+
message: `Postman JSON: ${host}:${config.port}/meta/postman.json`
|
|
461
|
+
});
|
|
462
|
+
sink.write({
|
|
463
|
+
level: "info",
|
|
464
|
+
message: `Browser mode: ${config.headless ? "headless" : "headful"}`
|
|
465
|
+
});
|
|
466
|
+
sink.write({
|
|
467
|
+
level: "info",
|
|
468
|
+
message: `Browser engine: ${engineLabel}`
|
|
469
|
+
});
|
|
470
|
+
if (config.dashboard) sink.write({
|
|
471
|
+
level: "info",
|
|
472
|
+
message: `Dashboard: ${host}:${config.port}/dashboard/`
|
|
473
|
+
});
|
|
474
|
+
else sink.write({
|
|
475
|
+
level: "info",
|
|
476
|
+
message: "Dashboard: disabled (--no-dashboard)"
|
|
477
|
+
});
|
|
478
|
+
if (resolution.source === "lightpanda_config" && resolution.executablePath) sink.write({
|
|
479
|
+
level: "info",
|
|
480
|
+
message: `Browser executable: explicit Lightpanda override (${resolution.executablePath})`
|
|
481
|
+
});
|
|
482
|
+
else if (resolution.source === "lightpanda_sdk_default") sink.write({
|
|
483
|
+
level: "info",
|
|
484
|
+
message: "Browser executable: Lightpanda SDK managed executable (shared cache/default resolution)"
|
|
485
|
+
});
|
|
486
|
+
else if (resolution.source === "config" && config.executablePath) sink.write({
|
|
487
|
+
level: "info",
|
|
488
|
+
message: `Browser executable: explicit override (${config.executablePath})`
|
|
489
|
+
});
|
|
490
|
+
else if (resolution.source === "cache") sink.write({
|
|
491
|
+
level: "info",
|
|
492
|
+
message: `Browser executable: local Chrome from cache (${resolution.executablePath})`
|
|
493
|
+
});
|
|
494
|
+
else if (resolution.source === "chrome_installation") sink.write({
|
|
495
|
+
level: "info",
|
|
496
|
+
message: `Browser executable: local Chrome detected (${resolution.executablePath})`
|
|
497
|
+
});
|
|
498
|
+
else if (preferLocalChrome) sink.write({
|
|
499
|
+
level: "info",
|
|
500
|
+
message: "Browser executable: driver default fallback (local Chrome unavailable)"
|
|
501
|
+
});
|
|
502
|
+
if (config.webhook) sink.write({
|
|
503
|
+
level: "warn",
|
|
504
|
+
message: `Webhook configured (${config.webhook}) but v5 CLI webhook registration parity is not yet restored.`
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
async function start(parsedArgs = parseCliArgs()) {
|
|
508
|
+
const { configPath, cliOverrides, verbose, unsupportedWarnings } = parsedArgs;
|
|
509
|
+
const sink = getCliOutputSink();
|
|
510
|
+
sink.status({ phase: "boot" });
|
|
511
|
+
const { config, sources, configFilePath, rawConfigs } = await (0, _open_wa_config.resolveConfig)({
|
|
512
|
+
configPath,
|
|
513
|
+
cliOverrides: {
|
|
514
|
+
disableSpins: true,
|
|
515
|
+
apiLifecycle: "hybrid",
|
|
516
|
+
host: "0.0.0.0",
|
|
517
|
+
port: 8002,
|
|
518
|
+
...cliOverrides
|
|
519
|
+
},
|
|
520
|
+
includeRawConfigs: true,
|
|
521
|
+
verbose
|
|
522
|
+
});
|
|
523
|
+
if (verbose) {
|
|
524
|
+
sink.write({
|
|
525
|
+
level: "info",
|
|
526
|
+
message: `Config sources: ${sources.join(", ")}`
|
|
527
|
+
});
|
|
528
|
+
if (configFilePath) sink.write({
|
|
529
|
+
level: "info",
|
|
530
|
+
message: `Config file: ${configFilePath}`
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
sink.status({
|
|
534
|
+
phase: "config.resolved",
|
|
535
|
+
sessionId: config.sessionId
|
|
536
|
+
});
|
|
537
|
+
unsupportedWarnings.forEach((warning) => sink.write({
|
|
538
|
+
level: "warn",
|
|
539
|
+
message: `Compatibility warning: ${warning}`
|
|
540
|
+
}));
|
|
541
|
+
const { driver, engineLabel, executableResolution, preferLocalChrome } = await selectRuntimeDriver(config, rawConfigs);
|
|
542
|
+
if (executableResolution.warning) sink.write({
|
|
543
|
+
level: "warn",
|
|
544
|
+
message: executableResolution.warning
|
|
545
|
+
});
|
|
546
|
+
const server = new WAServer(config);
|
|
547
|
+
sink.status({
|
|
548
|
+
phase: "server.starting",
|
|
549
|
+
sessionId: config.sessionId
|
|
550
|
+
});
|
|
551
|
+
await server.start();
|
|
552
|
+
sink.status({
|
|
553
|
+
phase: "server.started",
|
|
554
|
+
sessionId: config.sessionId
|
|
555
|
+
});
|
|
556
|
+
printStartupSummary(config, executableResolution, preferLocalChrome, engineLabel);
|
|
557
|
+
sink.status({
|
|
558
|
+
phase: "client.starting",
|
|
559
|
+
sessionId: config.sessionId
|
|
560
|
+
});
|
|
561
|
+
sink.write({
|
|
562
|
+
level: "info",
|
|
563
|
+
message: "Starting WhatsApp Client..."
|
|
564
|
+
});
|
|
565
|
+
const openwaClient = await (0, _open_wa_core.createClient)({
|
|
566
|
+
sessionId: config.sessionId,
|
|
567
|
+
driver,
|
|
568
|
+
deleteSessionDataOnLogout: config.deleteSessionDataOnLogout,
|
|
569
|
+
killClientOnLogout: config.killClientOnLogout,
|
|
570
|
+
sessionDataPath: config.sessionDataPath,
|
|
571
|
+
debug: config.logLevel === "debug" || verbose || config.logConsole,
|
|
572
|
+
headless: config.headless,
|
|
573
|
+
qrTimeoutMs: typeof config.qrTimeout === "number" ? config.qrTimeout * 1e3 : void 0,
|
|
574
|
+
authTimeoutMs: typeof config.authTimeout === "number" ? config.authTimeout * 1e3 : void 0,
|
|
575
|
+
executablePath: executableResolution.executablePath,
|
|
576
|
+
browserArgs: config.chromiumArgs,
|
|
577
|
+
userDataDir: config.userDataDir,
|
|
578
|
+
ephemeral: config.ephemeral,
|
|
579
|
+
logConsole: config.logConsole,
|
|
580
|
+
logConsoleErrors: config.logConsoleErrors,
|
|
581
|
+
blockCrashLogs: config.blockCrashLogs,
|
|
582
|
+
blockAssets: config.blockAssets,
|
|
583
|
+
safeMode: config.safeMode,
|
|
584
|
+
licenseKey: config.licenseKey
|
|
585
|
+
});
|
|
586
|
+
server.setReadinessProvider(() => ({
|
|
587
|
+
...openwaClient.getReadiness(),
|
|
588
|
+
state: openwaClient.getState()
|
|
589
|
+
}));
|
|
590
|
+
const detachLaunchNarration = attachLaunchNarration(openwaClient, sink, config.sessionId);
|
|
591
|
+
openwaClient.events.on("launch.auth.qr.generated", (event) => {
|
|
592
|
+
const qr = event.details?.qr;
|
|
593
|
+
if (!qr) return;
|
|
594
|
+
if (config.qrLogSkip) sink.write({
|
|
595
|
+
level: "info",
|
|
596
|
+
message: "New QR Code generated. Not printing in console because qrLogSkip is set to true"
|
|
597
|
+
});
|
|
598
|
+
else {
|
|
599
|
+
sink.status({
|
|
600
|
+
phase: "auth.qr",
|
|
601
|
+
sessionId: config.sessionId,
|
|
602
|
+
detail: "QR code generated"
|
|
603
|
+
});
|
|
604
|
+
sink.qr({
|
|
605
|
+
qr,
|
|
606
|
+
sessionId: config.sessionId
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
server.setQR(qr);
|
|
610
|
+
});
|
|
611
|
+
const client = new _open_wa_client.Client({
|
|
612
|
+
client: openwaClient,
|
|
613
|
+
transport: openwaClient.getTransport()
|
|
614
|
+
});
|
|
615
|
+
server.setClient(client);
|
|
616
|
+
const runtimeBridgeListeners = /* @__PURE__ */ new Set();
|
|
617
|
+
const runtimeEventPublishers = [{ publish: (eventName, payload) => {
|
|
618
|
+
runtimeBridgeListeners.forEach((listener) => {
|
|
619
|
+
listener(eventName, payload);
|
|
620
|
+
});
|
|
621
|
+
} }];
|
|
622
|
+
const publishRuntimeEvent = (eventName, payload) => {
|
|
623
|
+
runtimeEventPublishers.forEach((publisher) => {
|
|
624
|
+
publisher.publish(eventName, payload);
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
bridgeRuntimeEvents(openwaClient, publishRuntimeEvent);
|
|
628
|
+
if (typeof server.setEventBridge === "function") server.setEventBridge({
|
|
629
|
+
onAny: (listener) => {
|
|
630
|
+
runtimeBridgeListeners.add(listener);
|
|
631
|
+
},
|
|
632
|
+
offAny: (listener) => {
|
|
633
|
+
runtimeBridgeListeners.delete(listener);
|
|
634
|
+
}
|
|
635
|
+
});
|
|
636
|
+
openwaClient.events.on("launch.browser.init.after", async () => {
|
|
637
|
+
const page = openwaClient.getTransport().getPage();
|
|
638
|
+
if (page) await server.setPage(page).catch(() => {});
|
|
639
|
+
});
|
|
640
|
+
try {
|
|
641
|
+
await client.start();
|
|
642
|
+
} catch (startError) {
|
|
643
|
+
const msg = startError instanceof Error ? startError.message : String(startError);
|
|
644
|
+
sink.write({
|
|
645
|
+
level: "error",
|
|
646
|
+
message: `Bootstrap failed: ${msg}`
|
|
647
|
+
});
|
|
648
|
+
sink.write({
|
|
649
|
+
level: "warn",
|
|
650
|
+
message: "Session kept alive for debugging. Browser page is still open."
|
|
651
|
+
});
|
|
652
|
+
sink.write({
|
|
653
|
+
level: "warn",
|
|
654
|
+
message: "The server is running — use /health and /api-docs to inspect state."
|
|
655
|
+
});
|
|
656
|
+
detachLaunchNarration();
|
|
657
|
+
return {
|
|
658
|
+
server,
|
|
659
|
+
client,
|
|
660
|
+
config,
|
|
661
|
+
events: openwaClient.events
|
|
662
|
+
};
|
|
663
|
+
}
|
|
664
|
+
const readiness = openwaClient.getReadiness();
|
|
665
|
+
sink.status({
|
|
666
|
+
phase: "client.ready",
|
|
667
|
+
sessionId: config.sessionId,
|
|
668
|
+
detail: `status=${readiness.status}, exposureSafe=${readiness.exposureSafe}`
|
|
669
|
+
});
|
|
670
|
+
sink.write({
|
|
671
|
+
level: "info",
|
|
672
|
+
message: `WhatsApp Client ready with state: ${client.getState()} (status=${readiness.status}, exposureSafe=${readiness.exposureSafe})`
|
|
673
|
+
});
|
|
674
|
+
detachLaunchNarration();
|
|
675
|
+
return {
|
|
676
|
+
server,
|
|
677
|
+
client,
|
|
678
|
+
config,
|
|
679
|
+
events: openwaClient.events
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
async function main(argv = process.argv.slice(2)) {
|
|
683
|
+
const parsedArgs = parseCliArgs(argv);
|
|
684
|
+
if (parsedArgs.pm2) {
|
|
685
|
+
const { spawn } = require("child_process");
|
|
686
|
+
const sink = getCliOutputSink();
|
|
687
|
+
const pm2Command = getPm2Command();
|
|
688
|
+
const pm2SpawnOptions = getPm2SpawnOptions();
|
|
689
|
+
try {
|
|
690
|
+
const pm2 = spawn(pm2Command, ["--version"], pm2SpawnOptions);
|
|
691
|
+
await new Promise((resolve, reject) => {
|
|
692
|
+
pm2.on("error", reject);
|
|
693
|
+
pm2.on("exit", (code) => {
|
|
694
|
+
if (code === 0) {
|
|
695
|
+
resolve();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
reject(/* @__PURE__ */ new Error(`pm2 probe exited with code ${code ?? "unknown"}`));
|
|
699
|
+
});
|
|
700
|
+
pm2.stdout.on("data", () => resolve());
|
|
701
|
+
});
|
|
702
|
+
const pm2Flags = parsedArgs.forwardedArgs.filter((flag) => flag !== "--pm2");
|
|
703
|
+
spawn(pm2Command, [
|
|
704
|
+
"start",
|
|
705
|
+
(0, node_url.fileURLToPath)(new URL("../dist/cli.cjs", require("url").pathToFileURL(__filename).href)),
|
|
706
|
+
"--name",
|
|
707
|
+
parsedArgs.procName,
|
|
708
|
+
"--stop-exit-codes",
|
|
709
|
+
"88",
|
|
710
|
+
"--",
|
|
711
|
+
...pm2Flags
|
|
712
|
+
], {
|
|
713
|
+
...pm2SpawnOptions,
|
|
714
|
+
stdio: "inherit",
|
|
715
|
+
detached: true
|
|
716
|
+
});
|
|
717
|
+
return;
|
|
718
|
+
} catch (error) {
|
|
719
|
+
if (isCommandNotFoundError(error)) {
|
|
720
|
+
sink.write({
|
|
721
|
+
level: "error",
|
|
722
|
+
message: "pm2 not found. Please install with: npm install -g pm2"
|
|
723
|
+
});
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
throw error;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
return await start(parsedArgs);
|
|
730
|
+
}
|
|
731
|
+
function getPm2Command() {
|
|
732
|
+
return process.platform === "win32" ? "pm2.cmd" : "pm2";
|
|
733
|
+
}
|
|
734
|
+
function getPm2SpawnOptions() {
|
|
735
|
+
return { shell: process.platform === "win32" };
|
|
736
|
+
}
|
|
737
|
+
function isCommandNotFoundError(error) {
|
|
738
|
+
if (typeof error !== "object" || error === null) return false;
|
|
739
|
+
const systemError = error;
|
|
740
|
+
return systemError.code === "ENOENT" || systemError.errno === -2;
|
|
741
|
+
}
|
|
742
|
+
//#endregion
|
|
743
|
+
Object.defineProperty(exports, "WAServer", {
|
|
744
|
+
enumerable: true,
|
|
745
|
+
get: function() {
|
|
746
|
+
return WAServer;
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
Object.defineProperty(exports, "__toESM", {
|
|
750
|
+
enumerable: true,
|
|
751
|
+
get: function() {
|
|
752
|
+
return __toESM;
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
Object.defineProperty(exports, "createConsoleOutputSink", {
|
|
756
|
+
enumerable: true,
|
|
757
|
+
get: function() {
|
|
758
|
+
return createConsoleOutputSink;
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
Object.defineProperty(exports, "getCliOutputSink", {
|
|
762
|
+
enumerable: true,
|
|
763
|
+
get: function() {
|
|
764
|
+
return getCliOutputSink;
|
|
765
|
+
}
|
|
766
|
+
});
|
|
767
|
+
Object.defineProperty(exports, "main", {
|
|
768
|
+
enumerable: true,
|
|
769
|
+
get: function() {
|
|
770
|
+
return main;
|
|
771
|
+
}
|
|
772
|
+
});
|
|
773
|
+
Object.defineProperty(exports, "parseCliArgs", {
|
|
774
|
+
enumerable: true,
|
|
775
|
+
get: function() {
|
|
776
|
+
return parseCliArgs;
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
Object.defineProperty(exports, "resetCliOutputSink", {
|
|
780
|
+
enumerable: true,
|
|
781
|
+
get: function() {
|
|
782
|
+
return resetCliOutputSink;
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
Object.defineProperty(exports, "setCliOutputSink", {
|
|
786
|
+
enumerable: true,
|
|
787
|
+
get: function() {
|
|
788
|
+
return setCliOutputSink;
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
Object.defineProperty(exports, "start", {
|
|
792
|
+
enumerable: true,
|
|
793
|
+
get: function() {
|
|
794
|
+
return start;
|
|
795
|
+
}
|
|
796
|
+
});
|
|
797
|
+
|
|
798
|
+
//# sourceMappingURL=cli-runtime-B7_3MM0c.cjs.map
|