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.
- package/dist/daemon/index.js +23 -10
- package/package.json +1 -1
package/dist/daemon/index.js
CHANGED
|
@@ -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
|
-
//
|
|
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
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
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, {
|