tuna-agent 0.1.30 → 0.1.32
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.
|
@@ -10,7 +10,11 @@ export interface AgentMetrics {
|
|
|
10
10
|
reflectionCount: number;
|
|
11
11
|
reflectionSkipCount: number;
|
|
12
12
|
patternsLearnedCount: number;
|
|
13
|
+
rulesCount: number;
|
|
13
14
|
lastTaskAt: string | null;
|
|
15
|
+
lastReflectionAt: string | null;
|
|
16
|
+
lastPatternAt: string | null;
|
|
17
|
+
latestLearnedRule: string | null;
|
|
14
18
|
upSince: string;
|
|
15
19
|
}
|
|
16
20
|
export declare class ClaudeCodeAdapter implements AgentAdapter {
|
|
@@ -48,6 +52,8 @@ export declare class ClaudeCodeAdapter implements AgentAdapter {
|
|
|
48
52
|
* Runs every N tasks to evolve the agent's permanent knowledge.
|
|
49
53
|
*/
|
|
50
54
|
runSelfImprovement(cwd: string): Promise<void>;
|
|
55
|
+
/** Track task completion metrics (public for daemon resume path). */
|
|
56
|
+
trackMetricsPublic(status: 'done' | 'failed', durationMs: number): void;
|
|
51
57
|
/** Track task completion metrics. */
|
|
52
58
|
private trackMetrics;
|
|
53
59
|
dispose(): Promise<void>;
|
|
@@ -24,7 +24,11 @@ export class ClaudeCodeAdapter {
|
|
|
24
24
|
reflectionCount: 0,
|
|
25
25
|
reflectionSkipCount: 0,
|
|
26
26
|
patternsLearnedCount: 0,
|
|
27
|
+
rulesCount: 0,
|
|
27
28
|
lastTaskAt: null,
|
|
29
|
+
lastReflectionAt: null,
|
|
30
|
+
lastPatternAt: null,
|
|
31
|
+
latestLearnedRule: null,
|
|
28
32
|
upSince: new Date().toISOString(),
|
|
29
33
|
};
|
|
30
34
|
constructor(config) {
|
|
@@ -723,6 +727,7 @@ export class ClaudeCodeAdapter {
|
|
|
723
727
|
console.log(`[Reflection] Storing: "${aiReflection.substring(0, 100)}..."`);
|
|
724
728
|
await callMem0AddMemory(aiReflection, this.agentConfig.name);
|
|
725
729
|
this.metrics.reflectionCount++;
|
|
730
|
+
this.metrics.lastReflectionAt = new Date().toISOString();
|
|
726
731
|
console.log(`[Reflection] Stored for task ${task.id}`);
|
|
727
732
|
}
|
|
728
733
|
catch (err) {
|
|
@@ -811,6 +816,9 @@ export class ClaudeCodeAdapter {
|
|
|
811
816
|
fs.writeFileSync(claudeMdPath, existingContent + separator + `${SECTION_HEADER}\n${rulesBlock}\n`);
|
|
812
817
|
}
|
|
813
818
|
this.metrics.patternsLearnedCount += newPatterns.length;
|
|
819
|
+
this.metrics.rulesCount += newPatterns.length;
|
|
820
|
+
this.metrics.lastPatternAt = new Date().toISOString();
|
|
821
|
+
this.metrics.latestLearnedRule = newPatterns[newPatterns.length - 1].rule.substring(0, 500);
|
|
814
822
|
console.log(`[Self-Improve] Added ${newPatterns.length} new rules to CLAUDE.md:`);
|
|
815
823
|
newPatterns.forEach(p => console.log(`[Self-Improve] - ${p.rule}`));
|
|
816
824
|
}
|
|
@@ -818,6 +826,10 @@ export class ClaudeCodeAdapter {
|
|
|
818
826
|
console.warn(`[Self-Improve] Failed:`, err instanceof Error ? err.message : err);
|
|
819
827
|
}
|
|
820
828
|
}
|
|
829
|
+
/** Track task completion metrics (public for daemon resume path). */
|
|
830
|
+
trackMetricsPublic(status, durationMs) {
|
|
831
|
+
this.trackMetrics(status, durationMs);
|
|
832
|
+
}
|
|
821
833
|
/** Track task completion metrics. */
|
|
822
834
|
trackMetrics(status, durationMs) {
|
|
823
835
|
this.metrics.taskCount++;
|
package/dist/daemon/index.js
CHANGED
|
@@ -616,6 +616,7 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
616
616
|
wsClient.sendProgress(taskId, 'executing', { startedAt: new Date().toISOString() });
|
|
617
617
|
const cwd = savedState.repoPath;
|
|
618
618
|
const MAX_RESUMED_ROUNDS = 50;
|
|
619
|
+
let lastResumeOutput = '';
|
|
619
620
|
for (let round = 0; round < MAX_RESUMED_ROUNDS; round++) {
|
|
620
621
|
let streamMsgId = `team-resume-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
621
622
|
let firstChunkIso = '';
|
|
@@ -677,6 +678,7 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
677
678
|
startedAt: firstChunkIso || undefined,
|
|
678
679
|
});
|
|
679
680
|
}
|
|
681
|
+
lastResumeOutput = turnAccumulatedText.trim() || lastResumeOutput;
|
|
680
682
|
if (result.isError) {
|
|
681
683
|
wsClient.sendTaskFailed(taskId, result.result);
|
|
682
684
|
return;
|
|
@@ -708,6 +710,17 @@ ${skillContent.slice(0, 15000)}`;
|
|
|
708
710
|
if (err instanceof Error && err.message === '__FOLLOW_UP_TIMEOUT__') {
|
|
709
711
|
console.log(`[Daemon] Resumed agent_team: no follow-up after 60s — closing`);
|
|
710
712
|
resolvers.delete(taskId);
|
|
713
|
+
wsClient.sendTaskDone(taskId, {
|
|
714
|
+
result: 'Resumed agent team task completed',
|
|
715
|
+
durationMs: totalDurationMs,
|
|
716
|
+
sessionId,
|
|
717
|
+
});
|
|
718
|
+
// Track metrics + reflection on the adapter
|
|
719
|
+
if (adapter.type === 'claude-code') {
|
|
720
|
+
const ccAdapter = adapter;
|
|
721
|
+
ccAdapter.trackMetricsPublic('done', totalDurationMs);
|
|
722
|
+
ccAdapter.runReflection({ id: taskId, description: firstMessage, repoPath: cwd, enableReflection: true }, lastResumeOutput || 'Task completed (no follow-up)', 'done', cwd).then(() => ccAdapter.runSelfImprovement(cwd)).catch(() => { });
|
|
723
|
+
}
|
|
711
724
|
return;
|
|
712
725
|
}
|
|
713
726
|
throw err;
|