@kernel.chat/kbot 3.10.0 → 3.12.0
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/a2a-client.d.ts +162 -0
- package/dist/a2a-client.d.ts.map +1 -0
- package/dist/a2a-client.js +376 -0
- package/dist/a2a-client.js.map +1 -0
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +31 -0
- package/dist/agent.js.map +1 -1
- package/dist/cli.js +268 -1
- package/dist/cli.js.map +1 -1
- package/dist/mcp-apps.d.ts +90 -0
- package/dist/mcp-apps.d.ts.map +1 -0
- package/dist/mcp-apps.js +497 -0
- package/dist/mcp-apps.js.map +1 -0
- package/dist/prompt-evolution.d.ts +92 -0
- package/dist/prompt-evolution.d.ts.map +1 -0
- package/dist/prompt-evolution.js +389 -0
- package/dist/prompt-evolution.js.map +1 -0
- package/dist/replit.d.ts +33 -0
- package/dist/replit.d.ts.map +1 -0
- package/dist/replit.js +95 -0
- package/dist/replit.js.map +1 -0
- package/dist/serve.d.ts.map +1 -1
- package/dist/serve.js +56 -6
- package/dist/serve.js.map +1 -1
- package/dist/tool-pipeline.d.ts +7 -0
- package/dist/tool-pipeline.d.ts.map +1 -1
- package/dist/tool-pipeline.js +32 -0
- package/dist/tool-pipeline.js.map +1 -1
- package/dist/tools/index.d.ts +5 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +21 -2
- package/dist/tools/index.js.map +1 -1
- package/dist/tree-planner.d.ts +63 -0
- package/dist/tree-planner.d.ts.map +1 -0
- package/dist/tree-planner.js +810 -0
- package/dist/tree-planner.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export interface PromptTrace {
|
|
2
|
+
agent: string;
|
|
3
|
+
taskType: string;
|
|
4
|
+
toolsUsed: string[];
|
|
5
|
+
evalScore: number;
|
|
6
|
+
success: boolean;
|
|
7
|
+
messageLength: number;
|
|
8
|
+
timestamp: string;
|
|
9
|
+
}
|
|
10
|
+
export interface PromptMutation {
|
|
11
|
+
agent: string;
|
|
12
|
+
original: string;
|
|
13
|
+
mutated: string;
|
|
14
|
+
reason: string;
|
|
15
|
+
appliedAt: string;
|
|
16
|
+
scoreBefore: number;
|
|
17
|
+
scoreAfter: number;
|
|
18
|
+
}
|
|
19
|
+
export interface PromptEvolutionState {
|
|
20
|
+
traces: PromptTrace[];
|
|
21
|
+
mutations: PromptMutation[];
|
|
22
|
+
generation: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Record an execution trace after each agent response.
|
|
26
|
+
* Called from agent.ts in the post-response learning block.
|
|
27
|
+
*/
|
|
28
|
+
export declare function recordTrace(trace: PromptTrace): void;
|
|
29
|
+
/**
|
|
30
|
+
* Check if an agent has accumulated enough traces to trigger evolution.
|
|
31
|
+
* Returns true if 20+ traces exist since the last evolution cycle for this agent.
|
|
32
|
+
*/
|
|
33
|
+
export declare function shouldEvolve(agent: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Analyze execution traces for an agent and generate prompt mutations.
|
|
36
|
+
* This is the core GEPA heuristic engine — entirely local, no LLM calls.
|
|
37
|
+
*
|
|
38
|
+
* Mutation rules:
|
|
39
|
+
* 1. Low success rate (<0.6) → add verification/self-checking emphasis
|
|
40
|
+
* 2. Narrow tool usage → encourage broader tool exploration
|
|
41
|
+
* 3. Low scores on specific task types → add task-specific instructions
|
|
42
|
+
* 4. Responses too long → add conciseness instruction
|
|
43
|
+
* 5. Missing the question → add "answer first" instruction
|
|
44
|
+
*
|
|
45
|
+
* Returns the generated mutation, or null if no improvement is needed.
|
|
46
|
+
*/
|
|
47
|
+
export declare function evolvePrompt(agent: string): PromptMutation | null;
|
|
48
|
+
/**
|
|
49
|
+
* Get the current active prompt amendment for an agent.
|
|
50
|
+
* Called before prompt assembly to inject evolved instructions.
|
|
51
|
+
* Returns empty string if no active mutation exists.
|
|
52
|
+
*/
|
|
53
|
+
export declare function getPromptAmendment(agent: string): string;
|
|
54
|
+
/**
|
|
55
|
+
* Rollback the most recent mutation for an agent if it made things worse.
|
|
56
|
+
* Compares scoreAfter vs scoreBefore — if worse, removes the mutation.
|
|
57
|
+
*
|
|
58
|
+
* Call this after updating scoreAfter from the latest trace batch.
|
|
59
|
+
* Returns true if a rollback was performed.
|
|
60
|
+
*/
|
|
61
|
+
export declare function rollbackMutation(agent: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Update the scoreAfter for the most recent mutation of an agent.
|
|
64
|
+
* Called when enough post-mutation traces are available.
|
|
65
|
+
*/
|
|
66
|
+
export declare function updateMutationScore(agent: string): void;
|
|
67
|
+
/**
|
|
68
|
+
* Get evolution statistics — how prompts have evolved over time.
|
|
69
|
+
*/
|
|
70
|
+
export declare function getEvolutionStats(): {
|
|
71
|
+
generation: number;
|
|
72
|
+
totalTraces: number;
|
|
73
|
+
totalMutations: number;
|
|
74
|
+
agentStats: Record<string, {
|
|
75
|
+
traces: number;
|
|
76
|
+
avgScore: number;
|
|
77
|
+
successRate: number;
|
|
78
|
+
activeMutation: boolean;
|
|
79
|
+
mutationCount: number;
|
|
80
|
+
lastEvolved: string | null;
|
|
81
|
+
}>;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Reset all evolution data for a specific agent (or all agents).
|
|
85
|
+
* Useful for debugging or when a major prompt rewrite happens.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resetEvolution(agent?: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Flush pending state to disk. Call on process exit.
|
|
90
|
+
*/
|
|
91
|
+
export declare function flushEvolutionState(): void;
|
|
92
|
+
//# sourceMappingURL=prompt-evolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-evolution.d.ts","sourceRoot":"","sources":["../src/prompt-evolution.ts"],"names":[],"mappings":"AAoBA,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CA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CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,WAAW,EAAE,MAAM,CAAA;QACnB,cAAc,EAAE,OAAO,CAAA;QACvB,aAAa,EAAE,MAAM,CAAA;QACrB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;KAC3B,CAAC,CAAA;CACH,CA0DA;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAanD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAM1C"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
// kbot Prompt Evolution — GEPA-style self-optimizing specialist prompts
|
|
2
|
+
//
|
|
3
|
+
// Each specialist agent has a system prompt (in agents/specialists.ts or matrix.ts).
|
|
4
|
+
// This module tracks execution traces per specialist and periodically analyzes them
|
|
5
|
+
// to generate heuristic-based prompt mutations — no LLM calls needed.
|
|
6
|
+
//
|
|
7
|
+
// Design: simplified GEPA (Generative Evolution of Prompts for Agents) for CLI:
|
|
8
|
+
// 1. Record execution traces (agent, taskType, tools, score, success, length)
|
|
9
|
+
// 2. Every 20 runs of an agent, analyze trace patterns
|
|
10
|
+
// 3. Generate prompt amendments (suffixes, not full rewrites)
|
|
11
|
+
// 4. Track before/after scores to auto-rollback bad mutations
|
|
12
|
+
//
|
|
13
|
+
// Storage: ~/.kbot/memory/prompt-evolution.json
|
|
14
|
+
import { homedir } from 'node:os';
|
|
15
|
+
import { join } from 'node:path';
|
|
16
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
|
|
17
|
+
// ── Storage ──
|
|
18
|
+
const MEMORY_DIR = join(homedir(), '.kbot', 'memory');
|
|
19
|
+
const EVOLUTION_FILE = join(MEMORY_DIR, 'prompt-evolution.json');
|
|
20
|
+
const MAX_TRACES = 500;
|
|
21
|
+
const MAX_MUTATIONS = 50;
|
|
22
|
+
const EVOLUTION_THRESHOLD = 20; // traces per agent before evolution triggers
|
|
23
|
+
function ensureDir() {
|
|
24
|
+
if (!existsSync(MEMORY_DIR))
|
|
25
|
+
mkdirSync(MEMORY_DIR, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
function loadState() {
|
|
28
|
+
ensureDir();
|
|
29
|
+
if (!existsSync(EVOLUTION_FILE)) {
|
|
30
|
+
return { traces: [], mutations: [], generation: 0 };
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return JSON.parse(readFileSync(EVOLUTION_FILE, 'utf-8'));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return { traces: [], mutations: [], generation: 0 };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function saveState(state) {
|
|
40
|
+
ensureDir();
|
|
41
|
+
try {
|
|
42
|
+
writeFileSync(EVOLUTION_FILE, JSON.stringify(state, null, 2));
|
|
43
|
+
}
|
|
44
|
+
catch { /* non-critical — prompt evolution data can be regenerated */ }
|
|
45
|
+
}
|
|
46
|
+
// ── Lazy-loaded singleton state ──
|
|
47
|
+
let _state = null;
|
|
48
|
+
function getState() {
|
|
49
|
+
if (!_state)
|
|
50
|
+
_state = loadState();
|
|
51
|
+
return _state;
|
|
52
|
+
}
|
|
53
|
+
function persist() {
|
|
54
|
+
if (_state)
|
|
55
|
+
saveState(_state);
|
|
56
|
+
}
|
|
57
|
+
// ── Core API ──
|
|
58
|
+
/**
|
|
59
|
+
* Record an execution trace after each agent response.
|
|
60
|
+
* Called from agent.ts in the post-response learning block.
|
|
61
|
+
*/
|
|
62
|
+
export function recordTrace(trace) {
|
|
63
|
+
const state = getState();
|
|
64
|
+
state.traces.push(trace);
|
|
65
|
+
// Cap at MAX_TRACES — drop oldest traces
|
|
66
|
+
if (state.traces.length > MAX_TRACES) {
|
|
67
|
+
state.traces = state.traces.slice(-MAX_TRACES);
|
|
68
|
+
}
|
|
69
|
+
persist();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Check if an agent has accumulated enough traces to trigger evolution.
|
|
73
|
+
* Returns true if 20+ traces exist since the last evolution cycle for this agent.
|
|
74
|
+
*/
|
|
75
|
+
export function shouldEvolve(agent) {
|
|
76
|
+
const state = getState();
|
|
77
|
+
// Find the last mutation for this agent (if any)
|
|
78
|
+
const lastMutation = [...state.mutations]
|
|
79
|
+
.reverse()
|
|
80
|
+
.find(m => m.agent === agent);
|
|
81
|
+
const lastMutationTime = lastMutation
|
|
82
|
+
? new Date(lastMutation.appliedAt).getTime()
|
|
83
|
+
: 0;
|
|
84
|
+
// Count traces for this agent since last mutation
|
|
85
|
+
const recentTraces = state.traces.filter(t => t.agent === agent && new Date(t.timestamp).getTime() > lastMutationTime);
|
|
86
|
+
return recentTraces.length >= EVOLUTION_THRESHOLD;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Analyze execution traces for an agent and generate prompt mutations.
|
|
90
|
+
* This is the core GEPA heuristic engine — entirely local, no LLM calls.
|
|
91
|
+
*
|
|
92
|
+
* Mutation rules:
|
|
93
|
+
* 1. Low success rate (<0.6) → add verification/self-checking emphasis
|
|
94
|
+
* 2. Narrow tool usage → encourage broader tool exploration
|
|
95
|
+
* 3. Low scores on specific task types → add task-specific instructions
|
|
96
|
+
* 4. Responses too long → add conciseness instruction
|
|
97
|
+
* 5. Missing the question → add "answer first" instruction
|
|
98
|
+
*
|
|
99
|
+
* Returns the generated mutation, or null if no improvement is needed.
|
|
100
|
+
*/
|
|
101
|
+
export function evolvePrompt(agent) {
|
|
102
|
+
const state = getState();
|
|
103
|
+
// Get the last mutation for this agent to know the baseline
|
|
104
|
+
const lastMutation = [...state.mutations]
|
|
105
|
+
.reverse()
|
|
106
|
+
.find(m => m.agent === agent);
|
|
107
|
+
const lastMutationTime = lastMutation
|
|
108
|
+
? new Date(lastMutation.appliedAt).getTime()
|
|
109
|
+
: 0;
|
|
110
|
+
// Gather traces since last evolution
|
|
111
|
+
const recentTraces = state.traces.filter(t => t.agent === agent && new Date(t.timestamp).getTime() > lastMutationTime);
|
|
112
|
+
if (recentTraces.length < EVOLUTION_THRESHOLD)
|
|
113
|
+
return null;
|
|
114
|
+
// ── Analyze trace patterns ──
|
|
115
|
+
const successRate = recentTraces.filter(t => t.success).length / recentTraces.length;
|
|
116
|
+
const avgScore = recentTraces.reduce((sum, t) => sum + t.evalScore, 0) / recentTraces.length;
|
|
117
|
+
const avgLength = recentTraces.reduce((sum, t) => sum + t.messageLength, 0) / recentTraces.length;
|
|
118
|
+
// Tool diversity: how many unique tools out of all tools used
|
|
119
|
+
const allToolsUsed = recentTraces.flatMap(t => t.toolsUsed);
|
|
120
|
+
const uniqueTools = new Set(allToolsUsed);
|
|
121
|
+
const toolDiversity = allToolsUsed.length > 0
|
|
122
|
+
? uniqueTools.size / Math.min(allToolsUsed.length, 20) // normalize against 20 max
|
|
123
|
+
: 0;
|
|
124
|
+
// Per-task-type scores
|
|
125
|
+
const taskTypeScores = {};
|
|
126
|
+
for (const trace of recentTraces) {
|
|
127
|
+
if (!taskTypeScores[trace.taskType]) {
|
|
128
|
+
taskTypeScores[trace.taskType] = { total: 0, count: 0 };
|
|
129
|
+
}
|
|
130
|
+
taskTypeScores[trace.taskType].total += trace.evalScore;
|
|
131
|
+
taskTypeScores[trace.taskType].count++;
|
|
132
|
+
}
|
|
133
|
+
// Identify weak task types (avg score < 0.5 with at least 3 samples)
|
|
134
|
+
const weakTaskTypes = Object.entries(taskTypeScores)
|
|
135
|
+
.filter(([, v]) => v.count >= 3 && (v.total / v.count) < 0.5)
|
|
136
|
+
.map(([taskType, v]) => ({ taskType, avgScore: v.total / v.count }));
|
|
137
|
+
// Low relevancy indicator: traces where evalScore < 0.4 (often means missing the question)
|
|
138
|
+
const lowRelevancyRate = recentTraces.filter(t => t.evalScore < 0.4).length / recentTraces.length;
|
|
139
|
+
// ── Generate mutation amendments ──
|
|
140
|
+
// Priority order: address the most impactful issue first
|
|
141
|
+
const amendments = [];
|
|
142
|
+
const reasons = [];
|
|
143
|
+
// Rule 1: Low success rate → add verification emphasis
|
|
144
|
+
if (successRate < 0.6) {
|
|
145
|
+
amendments.push('IMPORTANT: After completing any action, verify the result explicitly. ' +
|
|
146
|
+
'If writing code, run the build or type-checker. If modifying files, read them back to confirm. ' +
|
|
147
|
+
'If a command fails, analyze the error before retrying with a different approach.');
|
|
148
|
+
reasons.push(`low success rate (${(successRate * 100).toFixed(0)}%)`);
|
|
149
|
+
}
|
|
150
|
+
// Rule 2: Narrow tool usage → encourage exploration
|
|
151
|
+
if (toolDiversity < 0.15 && allToolsUsed.length > 5) {
|
|
152
|
+
const topTools = Array.from(uniqueTools).slice(0, 3).join(', ');
|
|
153
|
+
amendments.push('You have many tools available beyond ' + topTools + '. ' +
|
|
154
|
+
'Consider using web_search for external info, grep for codebase exploration, ' +
|
|
155
|
+
'git tools for history, and multiple file operations for thorough changes. ' +
|
|
156
|
+
'Use the right tool for each sub-task rather than relying on a single tool.');
|
|
157
|
+
reasons.push(`narrow tool usage (${uniqueTools.size} unique tools, diversity ${(toolDiversity * 100).toFixed(0)}%)`);
|
|
158
|
+
}
|
|
159
|
+
// Rule 3: Weak task types → add targeted instructions
|
|
160
|
+
if (weakTaskTypes.length > 0) {
|
|
161
|
+
const taskInstructions = weakTaskTypes.map(wt => {
|
|
162
|
+
switch (wt.taskType) {
|
|
163
|
+
case 'debug':
|
|
164
|
+
return 'For debugging: read error messages carefully, check recent git changes, ' +
|
|
165
|
+
'reproduce the issue before attempting fixes, and verify the fix works.';
|
|
166
|
+
case 'build':
|
|
167
|
+
return 'For building/creating: plan the file structure first, write complete files ' +
|
|
168
|
+
'(not partial snippets), and run the build to verify.';
|
|
169
|
+
case 'refactor':
|
|
170
|
+
return 'For refactoring: understand all callers of the code being changed, ' +
|
|
171
|
+
'make incremental changes, and verify each step compiles.';
|
|
172
|
+
case 'test':
|
|
173
|
+
return 'For testing: cover both happy paths and edge cases, mock external dependencies, ' +
|
|
174
|
+
'and ensure tests actually assert meaningful behavior.';
|
|
175
|
+
case 'deploy':
|
|
176
|
+
return 'For deployment: check all prerequisites first, verify environment configuration, ' +
|
|
177
|
+
'and always do a dry-run or build before the actual deploy.';
|
|
178
|
+
case 'explain':
|
|
179
|
+
return 'For explanations: lead with a clear, direct answer. Then provide supporting ' +
|
|
180
|
+
'details. Use code examples where relevant. Keep it scannable.';
|
|
181
|
+
case 'review':
|
|
182
|
+
return 'For reviews: check for security issues, performance concerns, and code style. ' +
|
|
183
|
+
'Provide specific line-level feedback, not just general comments.';
|
|
184
|
+
default:
|
|
185
|
+
return `For ${wt.taskType} tasks: pay extra attention to accuracy and completeness. ` +
|
|
186
|
+
'Verify your work before presenting results.';
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
amendments.push(taskInstructions.join('\n'));
|
|
190
|
+
reasons.push(`weak on: ${weakTaskTypes.map(wt => `${wt.taskType} (${(wt.avgScore * 100).toFixed(0)}%)`).join(', ')}`);
|
|
191
|
+
}
|
|
192
|
+
// Rule 4: Responses too long → add conciseness
|
|
193
|
+
if (avgLength > 3000) {
|
|
194
|
+
amendments.push('Keep responses concise and focused. Lead with the answer or action, ' +
|
|
195
|
+
'then add explanation only if needed. Avoid repeating the question or restating the problem. ' +
|
|
196
|
+
'For code changes, show only the relevant diff, not the entire file.');
|
|
197
|
+
reasons.push(`verbose responses (avg ${Math.round(avgLength)} chars)`);
|
|
198
|
+
}
|
|
199
|
+
// Rule 5: Missing the question → add "answer first" instruction
|
|
200
|
+
if (lowRelevancyRate > 0.3) {
|
|
201
|
+
amendments.push('CRITICAL: Answer the actual question first. Do not go on tangents or provide ' +
|
|
202
|
+
'unsolicited information. If the user asks a yes/no question, start with yes or no. ' +
|
|
203
|
+
'If they ask for a specific thing, provide that specific thing before anything else.');
|
|
204
|
+
reasons.push(`high off-topic rate (${(lowRelevancyRate * 100).toFixed(0)}% of responses scored < 0.4)`);
|
|
205
|
+
}
|
|
206
|
+
// If no issues detected, no mutation needed
|
|
207
|
+
if (amendments.length === 0)
|
|
208
|
+
return null;
|
|
209
|
+
// Build the combined amendment
|
|
210
|
+
const mutatedText = `\n\n[Evolved Instructions — Generation ${state.generation + 1}]\n` +
|
|
211
|
+
amendments.join('\n\n');
|
|
212
|
+
const mutation = {
|
|
213
|
+
agent,
|
|
214
|
+
original: lastMutation?.mutated || '',
|
|
215
|
+
mutated: mutatedText,
|
|
216
|
+
reason: reasons.join('; '),
|
|
217
|
+
appliedAt: new Date().toISOString(),
|
|
218
|
+
scoreBefore: avgScore,
|
|
219
|
+
scoreAfter: 0, // filled in after next evolution cycle
|
|
220
|
+
};
|
|
221
|
+
// Store the mutation
|
|
222
|
+
state.mutations.push(mutation);
|
|
223
|
+
if (state.mutations.length > MAX_MUTATIONS) {
|
|
224
|
+
state.mutations = state.mutations.slice(-MAX_MUTATIONS);
|
|
225
|
+
}
|
|
226
|
+
state.generation++;
|
|
227
|
+
persist();
|
|
228
|
+
return mutation;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the current active prompt amendment for an agent.
|
|
232
|
+
* Called before prompt assembly to inject evolved instructions.
|
|
233
|
+
* Returns empty string if no active mutation exists.
|
|
234
|
+
*/
|
|
235
|
+
export function getPromptAmendment(agent) {
|
|
236
|
+
const state = getState();
|
|
237
|
+
// Find the most recent mutation for this agent
|
|
238
|
+
const latestMutation = [...state.mutations]
|
|
239
|
+
.reverse()
|
|
240
|
+
.find(m => m.agent === agent);
|
|
241
|
+
if (!latestMutation)
|
|
242
|
+
return '';
|
|
243
|
+
return latestMutation.mutated;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* Rollback the most recent mutation for an agent if it made things worse.
|
|
247
|
+
* Compares scoreAfter vs scoreBefore — if worse, removes the mutation.
|
|
248
|
+
*
|
|
249
|
+
* Call this after updating scoreAfter from the latest trace batch.
|
|
250
|
+
* Returns true if a rollback was performed.
|
|
251
|
+
*/
|
|
252
|
+
export function rollbackMutation(agent) {
|
|
253
|
+
const state = getState();
|
|
254
|
+
// Find the most recent mutation for this agent
|
|
255
|
+
const mutationIndex = state.mutations.length - 1 -
|
|
256
|
+
[...state.mutations].reverse().findIndex(m => m.agent === agent);
|
|
257
|
+
if (mutationIndex < 0 || mutationIndex >= state.mutations.length)
|
|
258
|
+
return false;
|
|
259
|
+
const mutation = state.mutations[mutationIndex];
|
|
260
|
+
// Only rollback if we have scoreAfter data and it's worse
|
|
261
|
+
if (mutation.scoreAfter > 0 && mutation.scoreAfter < mutation.scoreBefore) {
|
|
262
|
+
state.mutations.splice(mutationIndex, 1);
|
|
263
|
+
persist();
|
|
264
|
+
return true;
|
|
265
|
+
}
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Update the scoreAfter for the most recent mutation of an agent.
|
|
270
|
+
* Called when enough post-mutation traces are available.
|
|
271
|
+
*/
|
|
272
|
+
export function updateMutationScore(agent) {
|
|
273
|
+
const state = getState();
|
|
274
|
+
const latestMutation = [...state.mutations]
|
|
275
|
+
.reverse()
|
|
276
|
+
.find(m => m.agent === agent);
|
|
277
|
+
if (!latestMutation || latestMutation.scoreAfter > 0)
|
|
278
|
+
return;
|
|
279
|
+
const mutationTime = new Date(latestMutation.appliedAt).getTime();
|
|
280
|
+
const postTraces = state.traces.filter(t => t.agent === agent && new Date(t.timestamp).getTime() > mutationTime);
|
|
281
|
+
// Need at least 10 post-mutation traces to evaluate
|
|
282
|
+
if (postTraces.length < 10)
|
|
283
|
+
return;
|
|
284
|
+
// Use eval scores if available, otherwise fall back to success rate.
|
|
285
|
+
// This fixes the issue where auto-rollback was a no-op when self-eval
|
|
286
|
+
// is disabled (default), since evalScore defaults to 0.7 for everyone.
|
|
287
|
+
const allScoresDefault = postTraces.every(t => Math.abs(t.evalScore - 0.7) < 0.01);
|
|
288
|
+
let scoreAfter;
|
|
289
|
+
if (allScoresDefault) {
|
|
290
|
+
// Self-eval is likely disabled — use success rate as the signal instead
|
|
291
|
+
scoreAfter = postTraces.filter(t => t.success).length / postTraces.length;
|
|
292
|
+
}
|
|
293
|
+
else {
|
|
294
|
+
// Real eval scores available — use them
|
|
295
|
+
scoreAfter = postTraces.reduce((sum, t) => sum + t.evalScore, 0) / postTraces.length;
|
|
296
|
+
}
|
|
297
|
+
latestMutation.scoreAfter = Math.round(scoreAfter * 1000) / 1000;
|
|
298
|
+
// If scoreBefore was also default 0.7, recalculate it the same way
|
|
299
|
+
if (allScoresDefault && Math.abs(latestMutation.scoreBefore - 0.7) < 0.01) {
|
|
300
|
+
const preTraces = state.traces.filter(t => t.agent === agent && new Date(t.timestamp).getTime() <= mutationTime).slice(-20); // last 20 pre-mutation traces
|
|
301
|
+
if (preTraces.length >= 5) {
|
|
302
|
+
latestMutation.scoreBefore = preTraces.filter(t => t.success).length / preTraces.length;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
persist();
|
|
306
|
+
// Auto-rollback if mutation made things worse (>10% drop)
|
|
307
|
+
if (latestMutation.scoreBefore > 0 && latestMutation.scoreAfter < latestMutation.scoreBefore * 0.9) {
|
|
308
|
+
rollbackMutation(agent);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get evolution statistics — how prompts have evolved over time.
|
|
313
|
+
*/
|
|
314
|
+
export function getEvolutionStats() {
|
|
315
|
+
const state = getState();
|
|
316
|
+
// Build per-agent stats
|
|
317
|
+
const agentStats = {};
|
|
318
|
+
// Group traces by agent
|
|
319
|
+
const agentTraces = {};
|
|
320
|
+
for (const trace of state.traces) {
|
|
321
|
+
if (!agentTraces[trace.agent])
|
|
322
|
+
agentTraces[trace.agent] = [];
|
|
323
|
+
agentTraces[trace.agent].push(trace);
|
|
324
|
+
}
|
|
325
|
+
// Group mutations by agent
|
|
326
|
+
const agentMutations = {};
|
|
327
|
+
for (const mutation of state.mutations) {
|
|
328
|
+
if (!agentMutations[mutation.agent])
|
|
329
|
+
agentMutations[mutation.agent] = [];
|
|
330
|
+
agentMutations[mutation.agent].push(mutation);
|
|
331
|
+
}
|
|
332
|
+
// Combine into stats
|
|
333
|
+
const allAgents = new Set([
|
|
334
|
+
...Object.keys(agentTraces),
|
|
335
|
+
...Object.keys(agentMutations),
|
|
336
|
+
]);
|
|
337
|
+
for (const agent of allAgents) {
|
|
338
|
+
const traces = agentTraces[agent] || [];
|
|
339
|
+
const mutations = agentMutations[agent] || [];
|
|
340
|
+
const latestMutation = mutations.length > 0 ? mutations[mutations.length - 1] : null;
|
|
341
|
+
agentStats[agent] = {
|
|
342
|
+
traces: traces.length,
|
|
343
|
+
avgScore: traces.length > 0
|
|
344
|
+
? Math.round((traces.reduce((s, t) => s + t.evalScore, 0) / traces.length) * 1000) / 1000
|
|
345
|
+
: 0,
|
|
346
|
+
successRate: traces.length > 0
|
|
347
|
+
? Math.round((traces.filter(t => t.success).length / traces.length) * 1000) / 1000
|
|
348
|
+
: 0,
|
|
349
|
+
activeMutation: !!latestMutation,
|
|
350
|
+
mutationCount: mutations.length,
|
|
351
|
+
lastEvolved: latestMutation?.appliedAt || null,
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
generation: state.generation,
|
|
356
|
+
totalTraces: state.traces.length,
|
|
357
|
+
totalMutations: state.mutations.length,
|
|
358
|
+
agentStats,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Reset all evolution data for a specific agent (or all agents).
|
|
363
|
+
* Useful for debugging or when a major prompt rewrite happens.
|
|
364
|
+
*/
|
|
365
|
+
export function resetEvolution(agent) {
|
|
366
|
+
const state = getState();
|
|
367
|
+
if (agent) {
|
|
368
|
+
state.traces = state.traces.filter(t => t.agent !== agent);
|
|
369
|
+
state.mutations = state.mutations.filter(m => m.agent !== agent);
|
|
370
|
+
}
|
|
371
|
+
else {
|
|
372
|
+
state.traces = [];
|
|
373
|
+
state.mutations = [];
|
|
374
|
+
state.generation = 0;
|
|
375
|
+
}
|
|
376
|
+
persist();
|
|
377
|
+
}
|
|
378
|
+
/**
|
|
379
|
+
* Flush pending state to disk. Call on process exit.
|
|
380
|
+
*/
|
|
381
|
+
export function flushEvolutionState() {
|
|
382
|
+
if (_state) {
|
|
383
|
+
try {
|
|
384
|
+
saveState(_state);
|
|
385
|
+
}
|
|
386
|
+
catch { /* best-effort */ }
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
//# sourceMappingURL=prompt-evolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt-evolution.js","sourceRoot":"","sources":["../src/prompt-evolution.ts"],"names":[],"mappings":"AAAA,wEAAwE;AACxE,EAAE;AACF,qFAAqF;AACrF,oFAAoF;AACpF,sEAAsE;AACtE,EAAE;AACF,gFAAgF;AAChF,gFAAgF;AAChF,yDAAyD;AACzD,gEAAgE;AAChE,gEAAgE;AAChE,EAAE;AACF,gDAAgD;AAEhD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AA8B5E,gBAAgB;AAEhB,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAA;AACrD,MAAM,cAAc,GAAG,IAAI,CAAC,UAAU,EAAE,uBAAuB,CAAC,CAAA;AAEhE,MAAM,UAAU,GAAG,GAAG,CAAA;AACtB,MAAM,aAAa,GAAG,EAAE,CAAA;AACxB,MAAM,mBAAmB,GAAG,EAAE,CAAA,CAAE,6CAA6C;AAE7E,SAAS,SAAS;IAChB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,SAAS,CAAC,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;AACzE,CAAC;AAED,SAAS,SAAS;IAChB,SAAS,EAAE,CAAA;IACX,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,MA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K,GAAG,QAAQ,EAAE,CAAA;IAExB,IAAI,KAAK,EAAE,CAAC;QACV,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;QAC1D,KAAK,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,CAAA;IAClE,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,MAAM,GAAG,EAAE,CAAA;QACjB,KAAK,CAAC,SAAS,GAAG,EAAE,CAAA;QACpB,KAAK,CAAC,UAAU,GAAG,CAAC,CAAA;IACtB,CAAC;IAED,OAAO,EAAE,CAAA;AACX,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,MAAM,EAAE,CAAC;QACX,IAAI,CAAC;YACH,SAAS,CAAC,MAAM,CAAC,CAAA;QACnB,CAAC;QAAC,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAAC;IAC/B,CAAC;AACH,CAAC"}
|
package/dist/replit.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Replit environment info */
|
|
2
|
+
export interface ReplitEnv {
|
|
3
|
+
/** Running inside Replit */
|
|
4
|
+
detected: boolean;
|
|
5
|
+
/** Repl ID */
|
|
6
|
+
replId?: string;
|
|
7
|
+
/** Repl slug (project name) */
|
|
8
|
+
slug?: string;
|
|
9
|
+
/** Repl owner */
|
|
10
|
+
owner?: string;
|
|
11
|
+
/** Replit DB URL for key-value storage */
|
|
12
|
+
dbUrl?: string;
|
|
13
|
+
/** Public URL for the repl (for serve mode) */
|
|
14
|
+
publicUrl?: string;
|
|
15
|
+
/** Persistent home directory */
|
|
16
|
+
homePath: string;
|
|
17
|
+
/** Whether Replit Secrets has API keys configured */
|
|
18
|
+
hasSecrets: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Detect if running inside Replit and gather environment info */
|
|
21
|
+
export declare function detectReplit(): ReplitEnv;
|
|
22
|
+
/** Check if running inside Replit */
|
|
23
|
+
export declare function isReplit(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Modules to SKIP in lite mode (Replit or --lite flag).
|
|
26
|
+
* These require Docker, native binaries, display servers, or excessive disk/RAM.
|
|
27
|
+
*/
|
|
28
|
+
export declare const LITE_SKIP_MODULES: Set<string>;
|
|
29
|
+
/** Get the kbot home directory, respecting Replit environment */
|
|
30
|
+
export declare function getKbotHome(): string;
|
|
31
|
+
/** Print Replit-specific onboarding message */
|
|
32
|
+
export declare function printReplitWelcome(): string;
|
|
33
|
+
//# sourceMappingURL=replit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replit.d.ts","sourceRoot":"","sources":["../src/replit.ts"],"names":[],"mappings":"AAYA,8BAA8B;AAC9B,MAAM,WAAW,SAAS;IACxB,4BAA4B;IAC5B,QAAQ,EAAE,OAAO,CAAA;IACjB,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+BAA+B;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,iBAAiB;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,gCAAgC;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,qDAAqD;IACrD,UAAU,EAAE,OAAO,CAAA;CACpB;AAED,kEAAkE;AAClE,wBAAgB,YAAY,IAAI,SAAS,CA6CxC;AAED,qCAAqC;AACrC,wBAAgB,QAAQ,IAAI,OAAO,CAElC;AAED;;;GAGG;AACH,eAAO,MAAM,iBAAiB,aAa5B,CAAA;AAEF,iEAAiE;AACjE,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED,+CAA+C;AAC/C,wBAAgB,kBAAkB,IAAI,MAAM,CAc3C"}
|
package/dist/replit.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// kbot Replit Integration
|
|
2
|
+
//
|
|
3
|
+
// Detects Replit environment and adapts kbot for cloud IDE constraints:
|
|
4
|
+
// - Persistent storage path detection
|
|
5
|
+
// - Lightweight mode (skip heavy tools)
|
|
6
|
+
// - Replit Secrets → API key auto-detection
|
|
7
|
+
// - Resource-aware defaults
|
|
8
|
+
import { join } from 'node:path';
|
|
9
|
+
import { homedir } from 'node:os';
|
|
10
|
+
/** Detect if running inside Replit and gather environment info */
|
|
11
|
+
export function detectReplit() {
|
|
12
|
+
const replId = process.env.REPL_ID;
|
|
13
|
+
const slug = process.env.REPL_SLUG;
|
|
14
|
+
const owner = process.env.REPL_OWNER;
|
|
15
|
+
if (!replId) {
|
|
16
|
+
return {
|
|
17
|
+
detected: false,
|
|
18
|
+
homePath: join(homedir(), '.kbot'),
|
|
19
|
+
hasSecrets: false,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
// Replit persistent storage is under /home/runner
|
|
23
|
+
// Free tier: ephemeral, but /home/runner persists within a session
|
|
24
|
+
// Paid tier: /home/runner persists across restarts
|
|
25
|
+
const homePath = join('/home/runner', '.kbot');
|
|
26
|
+
// Check if any API keys are available via Replit Secrets (env vars)
|
|
27
|
+
const hasSecrets = !!(process.env.ANTHROPIC_API_KEY ||
|
|
28
|
+
process.env.OPENAI_API_KEY ||
|
|
29
|
+
process.env.GOOGLE_API_KEY ||
|
|
30
|
+
process.env.MISTRAL_API_KEY ||
|
|
31
|
+
process.env.XAI_API_KEY ||
|
|
32
|
+
process.env.DEEPSEEK_API_KEY ||
|
|
33
|
+
process.env.GROQ_API_KEY ||
|
|
34
|
+
process.env.OPENROUTER_API_KEY);
|
|
35
|
+
// Build the public URL for serve mode
|
|
36
|
+
const publicUrl = slug && owner
|
|
37
|
+
? `https://${slug}.${owner}.repl.co`
|
|
38
|
+
: undefined;
|
|
39
|
+
return {
|
|
40
|
+
detected: true,
|
|
41
|
+
replId,
|
|
42
|
+
slug,
|
|
43
|
+
owner,
|
|
44
|
+
dbUrl: process.env.REPLIT_DB_URL,
|
|
45
|
+
publicUrl,
|
|
46
|
+
homePath,
|
|
47
|
+
hasSecrets,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Check if running inside Replit */
|
|
51
|
+
export function isReplit() {
|
|
52
|
+
return !!process.env.REPL_ID;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Modules to SKIP in lite mode (Replit or --lite flag).
|
|
56
|
+
* These require Docker, native binaries, display servers, or excessive disk/RAM.
|
|
57
|
+
*/
|
|
58
|
+
export const LITE_SKIP_MODULES = new Set([
|
|
59
|
+
'./sandbox.js', // Docker sandbox
|
|
60
|
+
'./e2b-sandbox.js', // E2B cloud sandbox
|
|
61
|
+
'./browser.js', // Puppeteer/Playwright (heavy binary)
|
|
62
|
+
'./browser-agent.js', // Browser automation agent
|
|
63
|
+
'./containers.js', // Docker container management
|
|
64
|
+
'./computer.js', // Computer use (needs display server)
|
|
65
|
+
'./comfyui-plugin.js', // ComfyUI (GPU + large models)
|
|
66
|
+
'./magenta-plugin.js', // Magenta (GPU + audio models)
|
|
67
|
+
'./vfx.js', // VFX tools (GPU-dependent)
|
|
68
|
+
'./gamedev.js', // Game dev tools (heavy assets)
|
|
69
|
+
'./kbot-local.js', // Local model gateway (downloads 4GB+ models)
|
|
70
|
+
'./training.js', // Fine-tuning (GPU + disk intensive)
|
|
71
|
+
]);
|
|
72
|
+
/** Get the kbot home directory, respecting Replit environment */
|
|
73
|
+
export function getKbotHome() {
|
|
74
|
+
if (isReplit()) {
|
|
75
|
+
return join('/home/runner', '.kbot');
|
|
76
|
+
}
|
|
77
|
+
return join(homedir(), '.kbot');
|
|
78
|
+
}
|
|
79
|
+
/** Print Replit-specific onboarding message */
|
|
80
|
+
export function printReplitWelcome() {
|
|
81
|
+
return [
|
|
82
|
+
' Running on Replit — lite mode active',
|
|
83
|
+
' Heavy tools (Docker, browser, local models) are disabled.',
|
|
84
|
+
' All cloud AI providers work normally.',
|
|
85
|
+
'',
|
|
86
|
+
' Quick setup:',
|
|
87
|
+
' 1. Add your API key to Replit Secrets (e.g. ANTHROPIC_API_KEY)',
|
|
88
|
+
' 2. Run: kbot auth',
|
|
89
|
+
' 3. Start chatting: kbot "hello"',
|
|
90
|
+
'',
|
|
91
|
+
' Serve mode: kbot serve --port 3000',
|
|
92
|
+
' Exposes all tools as a REST API on your Repl\'s public URL.',
|
|
93
|
+
].join('\n');
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=replit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replit.js","sourceRoot":"","sources":["../src/replit.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,EAAE;AACF,wEAAwE;AACxE,sCAAsC;AACtC,wCAAwC;AACxC,4CAA4C;AAC5C,4BAA4B;AAG5B,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAsBjC,kEAAkE;AAClE,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,CAAA;IAClC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAA;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAA;IAEpC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO;YACL,QAAQ,EAAE,KAAK;YACf,QAAQ,EAAE,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC;YAClC,UAAU,EAAE,KAAK;SAClB,CAAA;IACH,CAAC;IAED,kDAAkD;IAClD,mEAAmE;IACnE,mDAAmD;IACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IAE9C,oE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U,WAAW;IACzB,IAAI,QAAQ,EAAE,EAAE,CAAC;QACf,OAAO,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;IACD,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;AACjC,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,wCAAwC;QACxC,6DAA6D;QAC7D,yCAAyC;QACzC,EAAE;QACF,gBAAgB;QAChB,oEAAoE;QACpE,uBAAuB;QACvB,qCAAqC;QACrC,EAAE;QACF,sCAAsC;QACtC,iEAAiE;KAClE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACd,CAAC"}
|
package/dist/serve.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"serve.d.ts","sourceRoot":"","sources":["../src/serve.ts"],"names":[],"mappings":"AA2BA,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAuBD,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuOrE"}
|