claude-remote-agent 0.1.1 → 0.1.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.
Files changed (2) hide show
  1. package/agent.js +13 -3
  2. package/package.json +1 -1
package/agent.js CHANGED
@@ -165,6 +165,7 @@ function killSession(id) {
165
165
  session.proc.kill('SIGTERM');
166
166
  }
167
167
  sessions.delete(id);
168
+ chatSessions.delete(id);
168
169
  console.log(`[${ts()}] Session ${id.slice(0, 8)} killed`);
169
170
  }
170
171
 
@@ -406,6 +407,8 @@ function handleChatMessage(sessionId, text, images) {
406
407
  });
407
408
 
408
409
  let buffer = '';
410
+ let lastTextLen = 0;
411
+ let sentToolIds = new Set();
409
412
 
410
413
  proc.stdout.on('data', (chunk) => {
411
414
  buffer += chunk.toString();
@@ -420,19 +423,26 @@ function handleChatMessage(sessionId, text, images) {
420
423
  session.claudeSessionId = obj.session_id;
421
424
  console.log(`[${ts()}] Chat ${sessionId.slice(0, 8)} got claude session: ${obj.session_id.slice(0, 8)}`);
422
425
  }
426
+ let fullText = '';
423
427
  for (const block of obj.message.content) {
424
428
  if (block.type === 'text') {
425
- send({ type: 'chat-text', sessionId, text: block.text, done: false });
426
- } else if (block.type === 'tool_use') {
429
+ fullText += block.text;
430
+ } else if (block.type === 'tool_use' && !sentToolIds.has(block.id)) {
431
+ sentToolIds.add(block.id);
427
432
  send({ type: 'chat-tool', sessionId, tool: block.name, input: block.input });
428
433
  }
429
434
  }
435
+ if (fullText.length > lastTextLen) {
436
+ const delta = fullText.slice(lastTextLen);
437
+ lastTextLen = fullText.length;
438
+ send({ type: 'chat-text', sessionId, text: delta, done: false });
439
+ }
430
440
  } else if (obj.type === 'result') {
431
441
  if (obj.session_id && !session.claudeSessionId) {
432
442
  session.claudeSessionId = obj.session_id;
433
443
  console.log(`[${ts()}] Chat ${sessionId.slice(0, 8)} got claude session: ${obj.session_id.slice(0, 8)}`);
434
444
  }
435
- send({ type: 'chat-text', sessionId, text: obj.result || '', done: true });
445
+ send({ type: 'chat-text', sessionId, text: '', done: true });
436
446
  }
437
447
  } catch {}
438
448
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-remote-agent",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Agent for Claude Remote — connects your machine to the relay server",
5
5
  "bin": {
6
6
  "claude-remote-agent": "./cli.js"