tuna-agent 0.1.86 → 0.1.88

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.
@@ -819,20 +819,21 @@ ${skillContent.slice(0, 15000)}`;
819
819
  if (data.type === 'system' && data.subtype === 'init') {
820
820
  sessionId = data.session_id;
821
821
  }
822
- // Patch missing stream chunks from assistant message (same as handleTask)
822
+ // Extract tool usage from assistant messages (no text patching —
823
+ // content_block_delta is the sole source of streaming text)
823
824
  if (data.type === 'assistant' && data.message) {
824
825
  const msg = data.message;
825
826
  const content = msg.content;
826
827
  if (content) {
827
- const fullText = content
828
- .filter(b => b.type === 'text' && b.text)
829
- .map(b => b.text)
830
- .join('');
831
- if (fullText && fullText.length > turnAccumulatedText.length) {
832
- const missed = fullText.slice(turnAccumulatedText.length);
833
- if (missed.length > 0) {
834
- turnAccumulatedText = fullText;
835
- wsClient.sendPMStream(taskId, missed);
828
+ for (const block of content) {
829
+ if (block.type === 'tool_use') {
830
+ const toolName = block.name;
831
+ const toolInput = block.input;
832
+ const detail = toolInput?.file_path || toolInput?.command || toolInput?.pattern || '';
833
+ wsClient.sendProgress(taskId, 'subtask_log', {
834
+ subtaskId: 'agent-team',
835
+ log: { type: 'action', message: `${toolName}: ${String(detail).substring(0, 80)}` },
836
+ });
836
837
  }
837
838
  }
838
839
  }
@@ -842,6 +843,18 @@ ${skillContent.slice(0, 15000)}`;
842
843
  wsClient.sendPMStreamEnd(taskId, streamMsgId);
843
844
  sessionId = result.sessionId || sessionId;
844
845
  totalDurationMs += result.durationMs || 0;
846
+ // Detect stale/dead session: no stream events + empty or very short result
847
+ // This happens when daemon restarts and old Claude Code session is gone
848
+ const resultText = (result.result || '').trim();
849
+ if (messageCount === 0 && resultText.length < 10 && round === 0 && sessionId) {
850
+ console.log(`[Daemon] ⚠️ Stale session detected (no stream events, result=${resultText.length} chars) — retrying without resume`);
851
+ sessionId = undefined;
852
+ wsClient.sendPMMessage(taskId, {
853
+ sender: 'pm',
854
+ content: 'Session expired after restart. Starting fresh...',
855
+ });
856
+ continue; // retry this round without --resume
857
+ }
845
858
  // Send finalized message for the last turn's remaining text
846
859
  if (turnAccumulatedText.trim()) {
847
860
  wsClient.sendPMMessage(taskId, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.86",
3
+ "version": "0.1.88",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"