tuna-agent 0.1.83 → 0.1.85

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.
@@ -224,7 +224,7 @@ export class ClaudeCodeAdapter {
224
224
  prompt: userMessage,
225
225
  cwd,
226
226
  outputFormat: 'stream-json',
227
- includePartialMessages: true,
227
+ includePartialMessages: false,
228
228
  maxTurns: 200,
229
229
  resumeSessionId: round > 0 ? sessionId : undefined,
230
230
  signal,
@@ -244,20 +244,23 @@ export class ClaudeCodeAdapter {
244
244
  if (event?.type === 'message_start') {
245
245
  messageCount++;
246
246
  console.log(`[ClaudeCode] message_start #${messageCount}, accumulated=${turnAccumulatedText.length} chars`);
247
- if (messageCount > 1 && turnAccumulatedText.trim()) {
248
- console.log(`[ClaudeCode] ✂️ Splitting bubble finalizing ${turnAccumulatedText.length} chars from previous turn`);
247
+ if (messageCount > 1) {
248
+ // Always clear streaming bubble on new turn (prevents cross-turn accumulation)
249
249
  ws.sendPMStreamEnd(task.id, streamMsgId);
250
- const simplified = simplifyMarkdown(turnAccumulatedText);
251
- if (!isSimilar(simplified, lastSentContent)) {
252
- ws.sendPMMessage(task.id, {
253
- sender: 'pm',
254
- content: simplified,
255
- startedAt: firstChunkIso || undefined,
256
- });
257
- lastSentContent = simplified;
258
- }
259
- else {
260
- console.log(`[ClaudeCode] ⏭️ Skipping duplicate message (${simplified.length} chars)`);
250
+ if (turnAccumulatedText.trim()) {
251
+ console.log(`[ClaudeCode] ✂️ Splitting bubble — finalizing ${turnAccumulatedText.length} chars from previous turn`);
252
+ const simplified = simplifyMarkdown(turnAccumulatedText);
253
+ if (!isSimilar(simplified, lastSentContent)) {
254
+ ws.sendPMMessage(task.id, {
255
+ sender: 'pm',
256
+ content: simplified,
257
+ startedAt: firstChunkIso || undefined,
258
+ });
259
+ lastSentContent = simplified;
260
+ }
261
+ else {
262
+ console.log(`[ClaudeCode] ⏭️ Skipping duplicate message (${simplified.length} chars)`);
263
+ }
261
264
  }
262
265
  turnAccumulatedText = '';
263
266
  firstChunkIso = '';
@@ -294,27 +297,11 @@ export class ClaudeCodeAdapter {
294
297
  console.log(`[ClaudeCode] Init tools: total=${toolNames.length}, mcp=${mcpTools.length} (${mcpTools.join(', ') || 'none'})`);
295
298
  console.log(`[ClaudeCode] All tools: ${toolNames.join(', ')}`);
296
299
  }
297
- // Extract text + tool usage from assistant messages
300
+ // Extract tool usage from assistant messages (for activity tab)
298
301
  if (data.type === 'assistant' && data.message) {
299
302
  const msg = data.message;
300
303
  const content = msg.content;
301
304
  if (content) {
302
- // Extract full text from assistant message as source of truth
303
- // (stream_event content_block_delta may miss chunks on rate limits)
304
- const fullText = content
305
- .filter(b => b.type === 'text' && b.text)
306
- .map(b => b.text)
307
- .join('');
308
- if (fullText && fullText.length > turnAccumulatedText.length) {
309
- const missed = fullText.slice(turnAccumulatedText.length);
310
- if (missed.length > 0) {
311
- console.log(`[ClaudeCode] 🔧 Stream missed ${missed.length} chars — patching from assistant message`);
312
- turnAccumulatedText = fullText;
313
- // Stream the missed portion to app
314
- ws.sendPMStream(task.id, missed);
315
- }
316
- }
317
- // Send tool usage to activity tab
318
305
  for (const block of content) {
319
306
  if (block.type === 'tool_use') {
320
307
  const toolName = block.name;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.83",
3
+ "version": "0.1.85",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"