owpenwork 0.1.8 → 0.1.9

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 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.8";
12
+ const VERSION = "0.1.9";
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
@@ -156,8 +156,16 @@ export async function loginWhatsApp(config, logger) {
156
156
  if (update.connection === "open") {
157
157
  finish("connection.open");
158
158
  }
159
- if (update.connection === "close" && state.creds?.registered) {
160
- finish("connection.close.registered");
159
+ if (update.connection === "close") {
160
+ const lastDisconnect = update.lastDisconnect;
161
+ const statusCode = lastDisconnect?.error?.output?.statusCode;
162
+ if (statusCode === 515 && state.creds?.registered) {
163
+ finish("connection.close.registered");
164
+ return;
165
+ }
166
+ if (state.creds?.registered) {
167
+ finish("connection.close.registered");
168
+ }
161
169
  }
162
170
  });
163
171
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "owpenwork",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "WhatsApp bridge for a running OpenCode server",
5
5
  "private": false,
6
6
  "type": "module",