tuna-agent 0.1.72 → 0.1.73

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.
@@ -986,10 +986,11 @@ export class ClaudeCodeAdapter {
986
986
  const separator = existingContent.endsWith('\n') ? '\n' : '\n\n';
987
987
  fs.writeFileSync(claudeMdPath, existingContent + separator + `${SECTION_HEADER}\n${rulesBlock}\n`);
988
988
  }
989
- this.metrics.patternsLearnedCount += toAdd.length;
990
- this.metrics.rulesCount += toAdd.length;
991
- this.metrics.lastPatternAt = new Date().toISOString();
992
- this.metrics.latestLearnedRule = toAdd[toAdd.length - 1].rule.substring(0, 500);
989
+ const m = agentId ? this.getMetricsForAgent(agentId) : this.metrics;
990
+ m.patternsLearnedCount += toAdd.length;
991
+ m.rulesCount += toAdd.length;
992
+ m.lastPatternAt = new Date().toISOString();
993
+ m.latestLearnedRule = toAdd[toAdd.length - 1].rule.substring(0, 500);
993
994
  console.log(`[Self-Improve] Added ${toAdd.length} new rules to CLAUDE.md:`);
994
995
  toAdd.forEach(p => console.log(`[Self-Improve] - ${p.rule}`));
995
996
  // Sync learned rules to heartbeat metrics
@@ -778,7 +778,7 @@ ${skillContent.slice(0, 15000)}`;
778
778
  outputFormat: 'stream-json',
779
779
  includePartialMessages: true,
780
780
  agentTeam: true,
781
- maxTurns: 50,
781
+ maxTurns: 200,
782
782
  resumeSessionId: sessionId,
783
783
  signal: abort.signal,
784
784
  inputFiles: currentInputFiles,
@@ -813,6 +813,24 @@ ${skillContent.slice(0, 15000)}`;
813
813
  if (data.type === 'system' && data.subtype === 'init') {
814
814
  sessionId = data.session_id;
815
815
  }
816
+ // Patch missing stream chunks from assistant message (same as handleTask)
817
+ if (data.type === 'assistant' && data.message) {
818
+ const msg = data.message;
819
+ const content = msg.content;
820
+ if (content) {
821
+ const fullText = content
822
+ .filter(b => b.type === 'text' && b.text)
823
+ .map(b => b.text)
824
+ .join('');
825
+ if (fullText && fullText.length > turnAccumulatedText.length) {
826
+ const missed = fullText.slice(turnAccumulatedText.length);
827
+ if (missed.length > 0) {
828
+ turnAccumulatedText = fullText;
829
+ wsClient.sendPMStream(taskId, missed);
830
+ }
831
+ }
832
+ }
833
+ }
816
834
  },
817
835
  });
818
836
  wsClient.sendPMStreamEnd(taskId, streamMsgId);
@@ -868,7 +886,7 @@ ${skillContent.slice(0, 15000)}`;
868
886
  if (adapter.type === 'claude-code') {
869
887
  const ccAdapter = adapter;
870
888
  ccAdapter.trackMetricsPublic('done', totalDurationMs, savedState.agentId);
871
- ccAdapter.runReflection({ id: taskId, description: firstMessage, repoPath: cwd, enableReflection: true }, lastResumeOutput || 'Task completed (no follow-up)', 'done', cwd).then(() => ccAdapter.runSelfImprovement(cwd)).catch(() => { });
889
+ ccAdapter.runReflection({ id: taskId, description: firstMessage, repoPath: cwd, enableReflection: true }, lastResumeOutput || 'Task completed (no follow-up)', 'done', cwd).then(() => ccAdapter.runSelfImprovement(cwd, savedState.agentId)).catch(() => { });
872
890
  }
873
891
  return;
874
892
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuna-agent",
3
- "version": "0.1.72",
3
+ "version": "0.1.73",
4
4
  "description": "Tuna Agent - Run AI coding tasks on your machine",
5
5
  "bin": {
6
6
  "tuna-agent": "dist/cli/index.js"