@omnixal/openclaw-nats-plugin 0.1.16 → 0.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omnixal/openclaw-nats-plugin",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "NATS JetStream event-driven plugin for OpenClaw",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -17,7 +17,7 @@ export const envSchema = {
17
17
  },
18
18
  gateway: {
19
19
  wsUrl: Env.string({ default: 'ws://localhost:18789', env: 'OPENCLAW_WS_URL' }),
20
- token: Env.string({ default: '', env: 'OPENCLAW_GATEWAY_TOKEN' }),
20
+ token: Env.string({ default: '', env: 'OPENCLAW_DEVICE_TOKEN' }),
21
21
  },
22
22
  consumer: {
23
23
  name: Env.string({ default: 'openclaw-main', env: 'NATS_CONSUMER_NAME' }),
@@ -25,8 +25,10 @@ export class GatewayClientService extends BaseService implements OnModuleInit, O
25
25
  async onModuleInit(): Promise<void> {
26
26
  this.wsUrl = this.config.get('gateway.wsUrl');
27
27
  this.token = this.config.get('gateway.token');
28
- if (this.wsUrl) {
28
+ if (this.wsUrl && this.token) {
29
29
  this.connect();
30
+ } else {
31
+ this.logger.warn('Gateway WebSocket not configured — skipping connection (need wsUrl + deviceToken)');
30
32
  }
31
33
  }
32
34
 
@@ -37,7 +39,7 @@ export class GatewayClientService extends BaseService implements OnModuleInit, O
37
39
 
38
40
  this.ws.onopen = () => {
39
41
  this.reconnectAttempt = 0;
40
- this.logger.info('Gateway WebSocket opened, waiting for challenge');
42
+ this.logger.info('Gateway WebSocket opened, waiting for connect.challenge');
41
43
  };
42
44
 
43
45
  this.ws.onmessage = (event) => {
@@ -83,14 +85,18 @@ export class GatewayClientService extends BaseService implements OnModuleInit, O
83
85
  return;
84
86
  }
85
87
 
86
- // Successful connect response (hello-ok)
88
+ // Successful connect response — must be hello-ok
87
89
  if (frame.type === 'res' && frame.ok === true) {
88
- if (frame.payload?.type === 'hello-ok') {
89
- this.connected = true;
90
- this.logger.info('OpenClaw handshake complete — connected');
90
+ const payload = frame.payload;
91
+ if (payload?.type === 'hello-ok') {
92
+ if (!this.connected) {
93
+ this.connected = true;
94
+ this.logger.info('OpenClaw handshake complete — connected');
95
+ }
91
96
  return;
92
97
  }
93
- // Regular RPC response ignore for now
98
+ // Regular RPC ok response (e.g. for inject calls)
99
+ this.logger.debug('Received RPC ok response', { id: frame.id });
94
100
  return;
95
101
  }
96
102
 
@@ -113,7 +119,8 @@ export class GatewayClientService extends BaseService implements OnModuleInit, O
113
119
  minProtocol: 3,
114
120
  maxProtocol: 3,
115
121
  client: {
116
- id: 'nats-sidecar',
122
+ id: 'gateway-client',
123
+ displayName: 'nats-sidecar',
117
124
  version: '1.0.0',
118
125
  platform: 'linux',
119
126
  mode: 'backend',