@clawchatsai/connector 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",
package/server/gateway.js CHANGED
@@ -292,7 +292,7 @@ export class GatewayClient {
292
292
  if (!db.prepare('SELECT id FROM threads WHERE id = ?').get(parsed.threadId)) return;
293
293
  const now = Date.now();
294
294
  try {
295
- db.prepare('INSERT INTO messages (id, thread_id, role, content, status, metadata, timestamp, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)').run(`gw-error-${parsed.threadId}-${now}`, parsed.threadId, 'system', `[error] ${gwErrorMessage || message?.error || message?.content || 'Unknown error'}`, 'sent', '{"transient":true}', now, now);
295
+ db.prepare('INSERT INTO messages (id, thread_id, role, content, status, metadata, timestamp, created_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)').run(`gw-error-${parsed.threadId}-${now}`, parsed.threadId, 'system', `[error] ${message?.error || message?.content || 'Unknown error'}`, 'sent', '{"transient":true}', now, now);
296
296
  // Clear stale pending flag so browsers reloading the chat don't re-derive "thinking..." state.
297
297
  db.prepare("UPDATE messages SET metadata = json_remove(metadata, '$.pending') WHERE thread_id = ? AND role = 'assistant' AND json_extract(metadata, '$.pending') = 1").run(parsed.threadId);
298
298
  } catch (e) { console.error('Failed to save error marker:', e.message); }
@@ -428,6 +428,11 @@ export class GatewayClient {
428
428
  this._syntheticErrorRuns.add(runId);
429
429
  const parsed = parseSessionKey(sessionKey);
430
430
  if (parsed) {
431
+ // Mirror the state:'error' path — writeActivityToDb just set metadata.pending=true,
432
+ // and without this the flag survives: loadHistory re-derives has_pending on reconnect,
433
+ // "thinking…" sticks, and sendMessage's isStreaming() guard queues future sends into
434
+ // _pendingSend forever.
435
+ this.saveErrorMarker(sessionKey, { error: data?.error || 'Agent failed before reply' });
431
436
  this.broadcastToBrowsers(JSON.stringify({
432
437
  type: 'clawchats',
433
438
  event: 'streaming-end',