owpenwork 0.1.8 → 0.1.10
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.js +12 -1
- package/dist/whatsapp.js +17 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -7,8 +7,9 @@ import { startBridge } from "./bridge.js";
|
|
|
7
7
|
import { loadConfig, normalizeWhatsAppId, readConfigFile, writeConfigFile, } from "./config.js";
|
|
8
8
|
import { BridgeStore } from "./db.js";
|
|
9
9
|
import { createLogger } from "./logger.js";
|
|
10
|
+
import { createClient } from "./opencode.js";
|
|
10
11
|
import { loginWhatsApp, unpairWhatsApp } from "./whatsapp.js";
|
|
11
|
-
const VERSION = "0.1.
|
|
12
|
+
const VERSION = "0.1.10";
|
|
12
13
|
const STEP_OPTIONS = [
|
|
13
14
|
{
|
|
14
15
|
value: "config",
|
|
@@ -468,6 +469,16 @@ program
|
|
|
468
469
|
console.log("WhatsApp linked.");
|
|
469
470
|
}
|
|
470
471
|
console.log(`OpenCode URL: ${config.opencodeUrl}`);
|
|
472
|
+
try {
|
|
473
|
+
const client = createClient(config);
|
|
474
|
+
const health = await client.global.health();
|
|
475
|
+
const healthy = Boolean(health.healthy);
|
|
476
|
+
console.log(`OpenCode reachable: ${healthy ? "yes" : "no"}`);
|
|
477
|
+
}
|
|
478
|
+
catch (error) {
|
|
479
|
+
console.log("OpenCode reachable: no");
|
|
480
|
+
console.log(`Error: ${String(error)}`);
|
|
481
|
+
}
|
|
471
482
|
console.log("If replies fail, ensure the server is running.");
|
|
472
483
|
const resetRequested = Boolean(opts.reset);
|
|
473
484
|
if (!resetRequested && !process.stdin.isTTY)
|
package/dist/whatsapp.js
CHANGED
|
@@ -120,7 +120,7 @@ export async function loginWhatsApp(config, logger) {
|
|
|
120
120
|
const log = logger.child({ channel: "whatsapp" });
|
|
121
121
|
const { state, saveCreds } = await useMultiFileAuthState(authDir);
|
|
122
122
|
const { version } = await fetchLatestBaileysVersion();
|
|
123
|
-
await new Promise((resolve) => {
|
|
123
|
+
await new Promise((resolve, reject) => {
|
|
124
124
|
let finished = false;
|
|
125
125
|
const sock = makeWASocket({
|
|
126
126
|
auth: {
|
|
@@ -156,8 +156,22 @@ export async function loginWhatsApp(config, logger) {
|
|
|
156
156
|
if (update.connection === "open") {
|
|
157
157
|
finish("connection.open");
|
|
158
158
|
}
|
|
159
|
-
if (update.connection === "close"
|
|
160
|
-
|
|
159
|
+
if (update.connection === "close") {
|
|
160
|
+
const lastDisconnect = update.lastDisconnect;
|
|
161
|
+
const statusCode = lastDisconnect?.error?.output?.statusCode;
|
|
162
|
+
if (statusCode === 515) {
|
|
163
|
+
if (state.creds?.registered) {
|
|
164
|
+
log.info("whatsapp login requires reconnect; completing login");
|
|
165
|
+
finish("connection.restart.required");
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
log.warn("whatsapp restart requested before creds registered");
|
|
169
|
+
reject(new Error("WhatsApp login restart required"));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (state.creds?.registered) {
|
|
173
|
+
finish("connection.close.registered");
|
|
174
|
+
}
|
|
161
175
|
}
|
|
162
176
|
});
|
|
163
177
|
});
|