@emqo/claudebridge 0.2.2 → 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.
@@ -129,7 +129,7 @@ export class AgentEngine {
129
129
  let buffer = "";
130
130
  child.stdout.on("data", (data) => {
131
131
  const chunk = data.toString();
132
- console.log(`[agent] stdout chunk: ${chunk.slice(0, 100)}`);
132
+ console.log(`[agent] stdout chunk: ${chunk.slice(0, 200)}`);
133
133
  buffer += chunk;
134
134
  const lines = buffer.split("\n");
135
135
  buffer = lines.pop() || "";
@@ -155,6 +155,9 @@ export class AgentEngine {
155
155
  fullText = msg.result;
156
156
  if (msg.total_cost_usd)
157
157
  cost = msg.total_cost_usd;
158
+ if (msg.is_error) {
159
+ console.error(`[agent] claude error result: subtype=${msg.subtype} message=${JSON.stringify(msg.error_message || msg.message || "unknown").slice(0, 500)}`);
160
+ }
158
161
  }
159
162
  }
160
163
  catch { }
@@ -175,12 +178,14 @@ export class AgentEngine {
175
178
  resolve({ text: fullText.trim() || "(timed out)", sessionId: newSessionId, cost });
176
179
  return;
177
180
  }
178
- if (newSessionId)
179
- this.store.setSession(userId, newSessionId, platform);
180
181
  if (code === 0 || fullText.trim()) {
182
+ if (newSessionId)
183
+ this.store.setSession(userId, newSessionId, platform);
181
184
  resolve({ text: fullText.trim() || "(no response)", sessionId: newSessionId, cost });
182
185
  }
183
186
  else {
187
+ // Don't save session on failure — stale session would lock the user in a failure loop
188
+ this.store.clearSession(userId);
184
189
  reject(new Error(`claude exited ${code}: ${stderr.slice(0, 500)}`));
185
190
  }
186
191
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@emqo/claudebridge",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Bridge Claude Code Agent SDK to chat platforms (Telegram, Discord, etc.)",
5
5
  "main": "dist/index.js",
6
6
  "bin": {