@coclaw/openclaw-coclaw 0.5.0 → 0.5.2

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
@@ -6,7 +6,7 @@ import { registerCoclawCli } from './src/cli-registrar.js';
6
6
  import { resolveErrorMessage } from './src/common/errors.js';
7
7
  import { notBound, bindOk, unbindOk } from './src/common/messages.js';
8
8
  import { coclawChannelPlugin } from './src/channel-plugin.js';
9
- import { ensureAgentSession, gatewayAgentRpc, restartRealtimeBridge, stopRealtimeBridge } from './src/realtime-bridge.js';
9
+ import { ensureAgentSession, gatewayAgentRpc, restartRealtimeBridge, stopRealtimeBridge, waitForSessionsReady } from './src/realtime-bridge.js';
10
10
  import { setRuntime } from './src/runtime.js';
11
11
  import { createSessionManager } from './src/session-manager/manager.js';
12
12
  import { TopicManager } from './src/topic-manager/manager.js';
@@ -167,6 +167,7 @@ const plugin = {
167
167
 
168
168
  api.registerGatewayMethod('coclaw.info', async ({ respond }) => {
169
169
  try {
170
+ await waitForSessionsReady();
170
171
  const version = await getPluginVersion();
171
172
  respond(true, { version, capabilities: ['topics', 'chatHistory'] });
172
173
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coclaw/openclaw-coclaw",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "description": "OpenClaw CoClaw channel plugin for remote chat",
@@ -11,7 +11,7 @@ import {
11
11
  } from './device-identity.js';
12
12
  import { getRuntime } from './runtime.js';
13
13
 
14
- const DEFAULT_GATEWAY_WS_URL = 'ws://127.0.0.1:18789';
14
+ const DEFAULT_GATEWAY_WS_URL = `ws://127.0.0.1:${process.env.OPENCLAW_GATEWAY_PORT || '18789'}`;
15
15
  const RECONNECT_MS = 10_000;
16
16
  const CONNECT_TIMEOUT_MS = 10_000;
17
17
  const SERVER_HB_PING_MS = 25_000;
@@ -479,7 +479,7 @@ export class RealtimeBridge {
479
479
  this.gatewayReady = true;
480
480
  this.__logDebug(`gateway connect ok <- id=${payload.id}`);
481
481
  this.gatewayConnectReqId = null;
482
- void this.__ensureAllAgentSessions();
482
+ this.__ensureSessionsPromise = this.__ensureAllAgentSessions();
483
483
  }
484
484
  else {
485
485
  this.gatewayReady = false;
@@ -814,6 +814,11 @@ export async function stopRealtimeBridge() {
814
814
  singleton = null; // 置 null 后须通过 restartRealtimeBridge 重建
815
815
  }
816
816
 
817
+ export async function waitForSessionsReady() {
818
+ if (!singleton?.__ensureSessionsPromise) return;
819
+ await singleton.__ensureSessionsPromise;
820
+ }
821
+
817
822
  export async function ensureAgentSession(agentId) {
818
823
  if (!singleton) {
819
824
  return { ok: false, error: 'bridge_not_started' };