@coclaw/openclaw-coclaw 0.1.4 → 0.1.5

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/index.js CHANGED
@@ -117,8 +117,8 @@ const plugin = {
117
117
  }
118
118
 
119
119
  try {
120
- const serverUrl = options.server ?? api.pluginConfig?.serverUrl;
121
120
  if (action === 'bind') {
121
+ const serverUrl = options.server ?? api.pluginConfig?.serverUrl;
122
122
  const result = await bindBot({
123
123
  code: positionals[0],
124
124
  serverUrl,
@@ -128,7 +128,7 @@ const plugin = {
128
128
  }
129
129
 
130
130
  if (action === 'unbind') {
131
- const result = await unbindBot({ serverUrl });
131
+ const result = await unbindBot({ serverUrl: options.server });
132
132
  await stopRealtimeBridge();
133
133
  return { text: unbindOk(result) };
134
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coclaw/openclaw-coclaw",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "OpenClaw CoClaw channel plugin for remote chat",
@@ -8,7 +8,7 @@ import {
8
8
 
9
9
  function resolveServerUrl(opts, config) {
10
10
  return opts?.server
11
- ?? config?.plugins?.entries?.['coclaw']?.config?.serverUrl
11
+ ?? config?.plugins?.entries?.['openclaw-coclaw']?.config?.serverUrl
12
12
  ?? process.env.COCLAW_SERVER_URL;
13
13
  }
14
14
 
@@ -69,8 +69,7 @@ export function registerCoclawCli({ program, config, logger }, deps = {}) {
69
69
  .option('--server <url>', 'CoClaw server URL')
70
70
  .action(async (opts) => {
71
71
  try {
72
- const serverUrl = resolveServerUrl(opts, config);
73
- const result = await unbindBot({ serverUrl });
72
+ const result = await unbindBot({ serverUrl: opts?.server });
74
73
  /* c8 ignore next */
75
74
  console.log(unbindOk(result));
76
75
  await notifyGateway('coclaw.stopBridge');
@@ -1,7 +1,7 @@
1
1
  import { bindWithServer, unbindWithServer } from '../api.js';
2
2
  import { clearConfig, readConfig, writeConfig } from '../config.js';
3
3
 
4
- const DEFAULT_SERVER_URL = 'http://127.0.0.1:3000';
4
+ const DEFAULT_SERVER_URL = 'https://im.coclaw.net';
5
5
 
6
6
  export async function bindBot({ code, serverUrl }) {
7
7
  if (!code) {
@@ -50,8 +50,10 @@ export async function unbindBot({ serverUrl }) {
50
50
  throw err;
51
51
  }
52
52
 
53
- /* c8 ignore next */
54
- const baseUrl = serverUrl ?? config.serverUrl ?? process.env.COCLAW_SERVER_URL ?? DEFAULT_SERVER_URL;
53
+ const baseUrl = serverUrl ?? config.serverUrl;
54
+ if (!baseUrl) {
55
+ throw new Error('cannot determine server URL for unbind: missing in bindings config');
56
+ }
55
57
  let data = null;
56
58
  let alreadyServerUnbound = false;
57
59
  try {
@@ -6,7 +6,6 @@ import nodePath from 'node:path';
6
6
  import { clearConfig, getBindingsPath, readConfig } from './config.js';
7
7
  import { getRuntime } from './runtime.js';
8
8
 
9
- const DEFAULT_SERVER_URL = 'http://127.0.0.1:3000';
10
9
  const DEFAULT_GATEWAY_WS_URL = 'ws://127.0.0.1:18789';
11
10
  const RECONNECT_MS = 10_000;
12
11
  const CONNECT_TIMEOUT_MS = 10_000;
@@ -410,7 +409,11 @@ async function connectIfNeeded() {
410
409
  return;
411
410
  }
412
411
 
413
- const baseUrl = currentPluginConfig?.serverUrl ?? cfg.serverUrl ?? process.env.COCLAW_SERVER_URL ?? DEFAULT_SERVER_URL;
412
+ const baseUrl = cfg.serverUrl;
413
+ if (!baseUrl) {
414
+ currentLogger.warn?.(`[coclaw] realtime bridge skip connect: missing serverUrl in ${bindingsPath}`);
415
+ return;
416
+ }
414
417
  const target = toServerWsUrl(baseUrl, cfg.token);
415
418
  const WebSocketCtor = globalThis.WebSocket;
416
419
  if (!WebSocketCtor) {