expo-openclaw-chat 0.2.1 → 0.2.3

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": "expo-openclaw-chat",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Minimal chat SDK for Expo apps to connect to OpenClaw gateway",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -73,6 +73,6 @@
73
73
  "homepage": "https://github.com/brunobar79/expo-openclaw-chat",
74
74
  "repository": {
75
75
  "type": "git",
76
- "url": "https://github.com/brunobar79/expo-openclaw-chat"
76
+ "url": "git+https://github.com/brunobar79/expo-openclaw-chat.git"
77
77
  }
78
78
  }
@@ -268,6 +268,32 @@ export class GatewayClient {
268
268
  ): Promise<T> {
269
269
  return new Promise<T>((resolve, reject) => {
270
270
  if (!this.ws || this._connectionState !== "connected") {
271
+ // If autoReconnect is enabled, wait up to 5s for reconnection
272
+ // instead of immediately rejecting. This prevents transient
273
+ // "Not connected" errors during WS flaps (e.g. group chat fan-out).
274
+ if (this.options.autoReconnect !== false && this._connectionState !== "disconnected") {
275
+ const waitTimeout = 5000;
276
+ let settled = false;
277
+ const unsub = this.onConnectionStateChange((state) => {
278
+ if (settled) return;
279
+ if (state === "connected") {
280
+ settled = true;
281
+ unsub();
282
+ this.request<T>(method, params, timeoutMs).then(resolve, reject);
283
+ } else if (state === "disconnected") {
284
+ settled = true;
285
+ unsub();
286
+ reject(new Error("Not connected"));
287
+ }
288
+ });
289
+ setTimeout(() => {
290
+ if (settled) return;
291
+ settled = true;
292
+ unsub();
293
+ reject(new Error("Not connected"));
294
+ }, waitTimeout);
295
+ return;
296
+ }
271
297
  return reject(new Error("Not connected"));
272
298
  }
273
299
 
@@ -699,7 +725,6 @@ export class GatewayClient {
699
725
 
700
726
  if (payload.decision === "approved") {
701
727
  // Retry connect now that we're approved
702
- console.log("[GatewayClient] Device approved, retrying connect...");
703
728
  this.sendConnectFrame();
704
729
  } else {
705
730
  // Rejected - fail the connection
@@ -69,7 +69,7 @@ export interface ChatInstance {
69
69
  export function createChat(config: CreateChatConfig): ChatInstance {
70
70
  const {
71
71
  gatewayUrl,
72
- sessionKey = `chat-${Date.now().toString(36)}`,
72
+ sessionKey = `agent:main:chat-${Date.now().toString(36)}`,
73
73
  title,
74
74
  placeholder,
75
75
  showImagePicker,