@kernel.chat/kbot 2.21.0 → 2.22.1
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/autopoiesis.d.ts +93 -0
- package/dist/autopoiesis.d.ts.map +1 -0
- package/dist/autopoiesis.js +222 -0
- package/dist/autopoiesis.js.map +1 -0
- package/dist/cli.js +8 -7
- package/dist/cli.js.map +1 -1
- package/dist/free-energy.d.ts +95 -0
- package/dist/free-energy.d.ts.map +1 -0
- package/dist/free-energy.js +180 -0
- package/dist/free-energy.js.map +1 -0
- package/dist/integrated-information.d.ts +56 -0
- package/dist/integrated-information.d.ts.map +1 -0
- package/dist/integrated-information.js +165 -0
- package/dist/integrated-information.js.map +1 -0
- package/dist/predictive-processing.d.ts +79 -0
- package/dist/predictive-processing.d.ts.map +1 -0
- package/dist/predictive-processing.js +250 -0
- package/dist/predictive-processing.js.map +1 -0
- package/dist/strange-loops.d.ts +89 -0
- package/dist/strange-loops.d.ts.map +1 -0
- package/dist/strange-loops.js +199 -0
- package/dist/strange-loops.js.map +1 -0
- package/dist/tutorial.d.ts.map +1 -1
- package/dist/tutorial.js +11 -8
- package/dist/tutorial.js.map +1 -1
- package/dist/ui.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
// K:BOT Predictive Processing — Anticipatory Cognition Engine
|
|
2
|
+
//
|
|
3
|
+
// Based on the Predictive Processing framework (Clark, 2013; Hohwy, 2013):
|
|
4
|
+
// The brain is fundamentally a prediction machine. It constantly generates
|
|
5
|
+
// top-down predictions about incoming sensory data, then updates when
|
|
6
|
+
// predictions are violated (prediction error).
|
|
7
|
+
//
|
|
8
|
+
// For kbot: predict what the user will ask next, pre-load relevant context,
|
|
9
|
+
// and measure prediction errors to identify what's most worth learning.
|
|
10
|
+
//
|
|
11
|
+
// High prediction error = high-value information (the user surprised us)
|
|
12
|
+
// Low prediction error = we understand the user well (act confidently)
|
|
13
|
+
//
|
|
14
|
+
// References:
|
|
15
|
+
// - Clark, A. (2013). Whatever next? Predictive brains, situated agents.
|
|
16
|
+
// - Hohwy, J. (2013). The Predictive Mind.
|
|
17
|
+
// - Rao, R.P. & Ballard, D.H. (1999). Predictive coding in the visual cortex.
|
|
18
|
+
// - Keller, G.B. & Mrsic-Flogel, T.D. (2018). Predictive processing.
|
|
19
|
+
/**
|
|
20
|
+
* Predictive Processing Engine — anticipates user intent and
|
|
21
|
+
* pre-loads context, reducing latency and improving relevance.
|
|
22
|
+
*
|
|
23
|
+
* The engine maintains a generative model of user behavior and
|
|
24
|
+
* continuously updates it based on prediction errors.
|
|
25
|
+
*/
|
|
26
|
+
export class PredictiveEngine {
|
|
27
|
+
predictions = [];
|
|
28
|
+
errors = [];
|
|
29
|
+
messageHistory = [];
|
|
30
|
+
toolHistory = [];
|
|
31
|
+
accuracy = 0.5;
|
|
32
|
+
precisionWeight = 0.5;
|
|
33
|
+
// Hyperparameters
|
|
34
|
+
learningRate = 0.12;
|
|
35
|
+
errorDecay = 0.9;
|
|
36
|
+
maxHistory = 50;
|
|
37
|
+
/**
|
|
38
|
+
* Generate a prediction for what the user will do next.
|
|
39
|
+
* Based on conversation patterns and tool usage history.
|
|
40
|
+
*/
|
|
41
|
+
predict(recentMessages, recentTools) {
|
|
42
|
+
const pattern = this.detectPattern(recentMessages);
|
|
43
|
+
const lastMessage = recentMessages[recentMessages.length - 1] || '';
|
|
44
|
+
const lastTool = recentTools[recentTools.length - 1] || '';
|
|
45
|
+
let predictedAction = '';
|
|
46
|
+
let confidence = 0.3;
|
|
47
|
+
let preloadContext = [];
|
|
48
|
+
let likelyTools = [];
|
|
49
|
+
switch (pattern) {
|
|
50
|
+
case 'iterative_refinement':
|
|
51
|
+
predictedAction = 'refine previous output with specific changes';
|
|
52
|
+
confidence = 0.7;
|
|
53
|
+
likelyTools = ['edit_file', 'write_file'];
|
|
54
|
+
preloadContext = ['previous output', 'user feedback'];
|
|
55
|
+
break;
|
|
56
|
+
case 'drill_down':
|
|
57
|
+
predictedAction = 'ask for more detail on current topic';
|
|
58
|
+
confidence = 0.6;
|
|
59
|
+
likelyTools = ['read_file', 'grep', 'web_search'];
|
|
60
|
+
preloadContext = ['current topic context', 'related files'];
|
|
61
|
+
break;
|
|
62
|
+
case 'verification':
|
|
63
|
+
predictedAction = 'test or verify previous changes';
|
|
64
|
+
confidence = 0.65;
|
|
65
|
+
likelyTools = ['bash', 'read_file', 'git_diff'];
|
|
66
|
+
preloadContext = ['recent changes', 'test commands'];
|
|
67
|
+
break;
|
|
68
|
+
case 'topic_switch':
|
|
69
|
+
predictedAction = 'start new unrelated task';
|
|
70
|
+
confidence = 0.4;
|
|
71
|
+
likelyTools = ['read_file', 'glob'];
|
|
72
|
+
preloadContext = [];
|
|
73
|
+
break;
|
|
74
|
+
case 'follow_up':
|
|
75
|
+
predictedAction = 'continue current thread naturally';
|
|
76
|
+
confidence = 0.5;
|
|
77
|
+
likelyTools = this.predictToolsFromHistory(recentTools);
|
|
78
|
+
preloadContext = ['recent context'];
|
|
79
|
+
break;
|
|
80
|
+
case 'meta_question':
|
|
81
|
+
predictedAction = 'ask about capabilities or process';
|
|
82
|
+
confidence = 0.6;
|
|
83
|
+
likelyTools = [];
|
|
84
|
+
preloadContext = ['agent capabilities'];
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
// Boost confidence based on historical accuracy
|
|
88
|
+
confidence *= (0.5 + this.accuracy * 0.5);
|
|
89
|
+
const prediction = {
|
|
90
|
+
predictedAction,
|
|
91
|
+
confidence: Math.min(0.95, confidence),
|
|
92
|
+
preloadContext,
|
|
93
|
+
likelyTools,
|
|
94
|
+
timestamp: Date.now(),
|
|
95
|
+
};
|
|
96
|
+
this.predictions.push(prediction);
|
|
97
|
+
if (this.predictions.length > this.maxHistory) {
|
|
98
|
+
this.predictions.shift();
|
|
99
|
+
}
|
|
100
|
+
return prediction;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Evaluate a prediction against what actually happened.
|
|
104
|
+
* Updates the generative model based on prediction error.
|
|
105
|
+
*/
|
|
106
|
+
evaluate(prediction, actualMessage, actualTools) {
|
|
107
|
+
// Compute prediction error (Jaccard distance between predicted and actual)
|
|
108
|
+
const predWords = new Set(prediction.predictedAction.toLowerCase().split(/\s+/));
|
|
109
|
+
const actualWords = new Set(actualMessage.toLowerCase().split(/\s+/).filter(w => w.length > 3));
|
|
110
|
+
let magnitude = 1.0;
|
|
111
|
+
if (predWords.size > 0 && actualWords.size > 0) {
|
|
112
|
+
const intersection = new Set([...predWords].filter(w => actualWords.has(w)));
|
|
113
|
+
const union = new Set([...predWords, ...actualWords]);
|
|
114
|
+
magnitude = 1 - (intersection.size / union.size);
|
|
115
|
+
}
|
|
116
|
+
// Tool prediction accuracy
|
|
117
|
+
const toolOverlap = prediction.likelyTools.filter(t => actualTools.includes(t)).length;
|
|
118
|
+
const toolAccuracy = prediction.likelyTools.length > 0
|
|
119
|
+
? toolOverlap / prediction.likelyTools.length
|
|
120
|
+
: 0.5;
|
|
121
|
+
// Combined error
|
|
122
|
+
magnitude = magnitude * 0.6 + (1 - toolAccuracy) * 0.4;
|
|
123
|
+
// What we learned
|
|
124
|
+
const insight = magnitude > 0.6
|
|
125
|
+
? `Prediction missed: expected "${prediction.predictedAction}" but user did something different`
|
|
126
|
+
: magnitude > 0.3
|
|
127
|
+
? `Partial match: prediction was in the right direction`
|
|
128
|
+
: `Good prediction: model accurately anticipated user intent`;
|
|
129
|
+
const error = {
|
|
130
|
+
prediction,
|
|
131
|
+
actual: actualMessage.slice(0, 200),
|
|
132
|
+
magnitude,
|
|
133
|
+
insight,
|
|
134
|
+
};
|
|
135
|
+
this.errors.push(error);
|
|
136
|
+
if (this.errors.length > this.maxHistory) {
|
|
137
|
+
this.errors.shift();
|
|
138
|
+
}
|
|
139
|
+
// Update accuracy (exponential moving average)
|
|
140
|
+
const correct = magnitude < 0.4 ? 1 : 0;
|
|
141
|
+
this.accuracy = this.accuracy * (1 - this.learningRate) + correct * this.learningRate;
|
|
142
|
+
// Update precision weighting
|
|
143
|
+
// High accuracy → trust predictions more (higher precision)
|
|
144
|
+
// Low accuracy → trust observations more (lower precision)
|
|
145
|
+
this.precisionWeight = this.accuracy * 0.8 + 0.1;
|
|
146
|
+
// Track history
|
|
147
|
+
this.messageHistory.push(actualMessage);
|
|
148
|
+
for (const t of actualTools)
|
|
149
|
+
this.toolHistory.push(t);
|
|
150
|
+
if (this.messageHistory.length > this.maxHistory)
|
|
151
|
+
this.messageHistory.shift();
|
|
152
|
+
if (this.toolHistory.length > this.maxHistory * 3)
|
|
153
|
+
this.toolHistory.splice(0, this.toolHistory.length - this.maxHistory * 3);
|
|
154
|
+
return error;
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Detect the current conversation pattern.
|
|
158
|
+
*/
|
|
159
|
+
detectPattern(messages) {
|
|
160
|
+
if (messages.length < 2)
|
|
161
|
+
return 'follow_up';
|
|
162
|
+
const last = (messages[messages.length - 1] || '').toLowerCase();
|
|
163
|
+
const prev = (messages[messages.length - 2] || '').toLowerCase();
|
|
164
|
+
// Meta questions about the process
|
|
165
|
+
if (/\b(how do you|can you|what are you|what tools|capabilities)\b/.test(last)) {
|
|
166
|
+
return 'meta_question';
|
|
167
|
+
}
|
|
168
|
+
// Verification patterns
|
|
169
|
+
if (/\b(test|check|verify|does it work|run it|try it|show me)\b/.test(last)) {
|
|
170
|
+
return 'verification';
|
|
171
|
+
}
|
|
172
|
+
// Refinement patterns
|
|
173
|
+
if (/\b(change|modify|update|fix|adjust|instead|rather|but make|no,)\b/.test(last)) {
|
|
174
|
+
return 'iterative_refinement';
|
|
175
|
+
}
|
|
176
|
+
// Drill-down patterns
|
|
177
|
+
if (/\b(more about|explain|detail|deeper|elaborate|specifically|what about)\b/.test(last)) {
|
|
178
|
+
return 'drill_down';
|
|
179
|
+
}
|
|
180
|
+
// Topic similarity check
|
|
181
|
+
const lastWords = new Set(last.split(/\s+/).filter(w => w.length > 4));
|
|
182
|
+
const prevWords = new Set(prev.split(/\s+/).filter(w => w.length > 4));
|
|
183
|
+
const overlap = [...lastWords].filter(w => prevWords.has(w)).length;
|
|
184
|
+
const similarity = lastWords.size > 0 ? overlap / lastWords.size : 0;
|
|
185
|
+
if (similarity < 0.1)
|
|
186
|
+
return 'topic_switch';
|
|
187
|
+
if (similarity > 0.5)
|
|
188
|
+
return 'drill_down';
|
|
189
|
+
return 'follow_up';
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Predict likely tools from recent tool usage patterns.
|
|
193
|
+
*/
|
|
194
|
+
predictToolsFromHistory(recentTools) {
|
|
195
|
+
if (recentTools.length === 0)
|
|
196
|
+
return [];
|
|
197
|
+
// Count tool frequencies
|
|
198
|
+
const counts = new Map();
|
|
199
|
+
for (const t of recentTools.slice(-10)) {
|
|
200
|
+
counts.set(t, (counts.get(t) ?? 0) + 1);
|
|
201
|
+
}
|
|
202
|
+
// Return top 3 by frequency
|
|
203
|
+
return [...counts.entries()]
|
|
204
|
+
.sort((a, b) => b[1] - a[1])
|
|
205
|
+
.slice(0, 3)
|
|
206
|
+
.map(([tool]) => tool);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Get blind spots — things the engine consistently predicts wrong.
|
|
210
|
+
*/
|
|
211
|
+
getBlindSpots() {
|
|
212
|
+
const recentErrors = this.errors.slice(-20).filter(e => e.magnitude > 0.6);
|
|
213
|
+
if (recentErrors.length < 3)
|
|
214
|
+
return [];
|
|
215
|
+
// Find common patterns in high-error predictions
|
|
216
|
+
const errorPatterns = new Map();
|
|
217
|
+
for (const err of recentErrors) {
|
|
218
|
+
const words = err.actual.toLowerCase().split(/\s+/).filter(w => w.length > 4);
|
|
219
|
+
for (const w of words) {
|
|
220
|
+
errorPatterns.set(w, (errorPatterns.get(w) ?? 0) + 1);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return [...errorPatterns.entries()]
|
|
224
|
+
.filter(([, count]) => count >= 2)
|
|
225
|
+
.sort((a, b) => b[1] - a[1])
|
|
226
|
+
.slice(0, 5)
|
|
227
|
+
.map(([word]) => word);
|
|
228
|
+
}
|
|
229
|
+
/** Get full predictive state */
|
|
230
|
+
getState() {
|
|
231
|
+
const correctCount = this.errors.filter(e => e.magnitude < 0.4).length;
|
|
232
|
+
return {
|
|
233
|
+
accuracy: this.accuracy,
|
|
234
|
+
totalPredictions: this.predictions.length,
|
|
235
|
+
correctPredictions: correctCount,
|
|
236
|
+
blindSpots: this.getBlindSpots(),
|
|
237
|
+
precisionWeight: this.precisionWeight,
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
/** Reset for new conversation */
|
|
241
|
+
reset() {
|
|
242
|
+
this.predictions = [];
|
|
243
|
+
this.errors = [];
|
|
244
|
+
this.messageHistory = [];
|
|
245
|
+
this.toolHistory = [];
|
|
246
|
+
this.accuracy = 0.5;
|
|
247
|
+
this.precisionWeight = 0.5;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
//# sourceMappingURL=predictive-processing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"predictive-processing.js","sourceRoot":"","sources":["../src/predictive-processing.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,sEAAsE;AACtE,+CAA+C;AAC/C,EAAE;AACF,4EAA4E;AAC5E,wEAAwE;AACxE,EAAE;AACF,yEAAyE;AACzE,uEAAuE;AACvE,EAAE;AACF,cAAc;AACd,2EAA2E;AAC3E,6CAA6C;AAC7C,gFAAgF;AAChF,uEAAuE;AAgDvE;;;;;;GAMG;AACH,MAAM,OAAO,gBAAgB;IACnB,WAAW,GAAiB,EAAE,CAAA;IAC9B,MAAM,GAAsB,EAAE,CAAA;IAC9B,cAAc,GAAa,EAAE,CAAA;IAC7B,WAAW,GAAa,EAAE,CAAA;IAC1B,QAAQ,GAAG,GAAG,CAAA;IACd,eAAe,GAAG,GAA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EAAE,CAAC,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,MAAM,CAAA;QAEtE,OAAO;YACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM;YACzC,kBAAkB,EAAE,YAAY;YAChC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE;YAChC,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAA;IACH,CAAC;IAED,iCAAiC;IACjC,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;QAChB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;QACrB,IAAI,CAAC,QAAQ,GAAG,GAAG,CAAA;QACnB,IAAI,CAAC,eAAe,GAAG,GAAG,CAAA;IAC5B,CAAC;CACF"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
export interface SelfReference {
|
|
2
|
+
/** What level the reference originates from */
|
|
3
|
+
sourceLevel: 'task' | 'reasoning' | 'meta-reasoning' | 'self-model';
|
|
4
|
+
/** What level it refers to */
|
|
5
|
+
targetLevel: 'task' | 'reasoning' | 'meta-reasoning' | 'self-model';
|
|
6
|
+
/** Description of the self-reference */
|
|
7
|
+
description: string;
|
|
8
|
+
/** Does this create a genuine strange loop (crosses hierarchy)? */
|
|
9
|
+
isStrangeLoop: boolean;
|
|
10
|
+
/** Timestamp */
|
|
11
|
+
timestamp: number;
|
|
12
|
+
}
|
|
13
|
+
export interface TangledHierarchy {
|
|
14
|
+
/** The levels involved in the tangle */
|
|
15
|
+
levels: string[];
|
|
16
|
+
/** How the levels are entangled */
|
|
17
|
+
description: string;
|
|
18
|
+
/** Depth of the tangle (number of level-crossings) */
|
|
19
|
+
depth: number;
|
|
20
|
+
}
|
|
21
|
+
export interface MetaCognitiveState {
|
|
22
|
+
/** Is the agent currently in a self-referential state? */
|
|
23
|
+
isSelfReferential: boolean;
|
|
24
|
+
/** Current depth of meta-reasoning (0 = task, 1 = reasoning about task, 2 = reasoning about reasoning, etc.) */
|
|
25
|
+
metaDepth: number;
|
|
26
|
+
/** Strange loops detected this session */
|
|
27
|
+
strangeLoopsDetected: number;
|
|
28
|
+
/** Tangled hierarchies active */
|
|
29
|
+
tangledHierarchies: TangledHierarchy[];
|
|
30
|
+
/** Self-model accuracy: does the agent know what it's doing? (0-1) */
|
|
31
|
+
selfModelAccuracy: number;
|
|
32
|
+
/** Is the agent reasoning about its own limitations? */
|
|
33
|
+
isReflective: boolean;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Strange Loop Detector — monitors self-referential cognition
|
|
37
|
+
* and meta-cognitive depth.
|
|
38
|
+
*
|
|
39
|
+
* When kbot reasons about its own reasoning, that's a strange loop.
|
|
40
|
+
* When kbot modifies its own behavior based on self-evaluation,
|
|
41
|
+
* that's a tangled hierarchy. This module makes those moments visible.
|
|
42
|
+
*/
|
|
43
|
+
export declare class StrangeLoopDetector {
|
|
44
|
+
private selfReferences;
|
|
45
|
+
private tangledHierarchies;
|
|
46
|
+
private metaDepth;
|
|
47
|
+
private selfModelAccuracy;
|
|
48
|
+
private declaredIntents;
|
|
49
|
+
private actualActions;
|
|
50
|
+
/**
|
|
51
|
+
* Analyze a message or response for self-referential content.
|
|
52
|
+
* Returns any self-references found.
|
|
53
|
+
*/
|
|
54
|
+
analyze(content: string, source: 'user' | 'agent' | 'tool'): SelfReference[];
|
|
55
|
+
/**
|
|
56
|
+
* Record what the agent says it intends to do.
|
|
57
|
+
* Used to measure self-model accuracy.
|
|
58
|
+
*/
|
|
59
|
+
recordIntent(intent: string): void;
|
|
60
|
+
/**
|
|
61
|
+
* Record what the agent actually did.
|
|
62
|
+
*/
|
|
63
|
+
recordAction(action: string): void;
|
|
64
|
+
/**
|
|
65
|
+
* Compute how well the agent knows itself.
|
|
66
|
+
* Compares declared intents to actual actions.
|
|
67
|
+
*/
|
|
68
|
+
private updateSelfModelAccuracy;
|
|
69
|
+
/**
|
|
70
|
+
* Is the agent currently in a strange loop?
|
|
71
|
+
* Returns true if meta-depth >= 2 (reasoning about reasoning).
|
|
72
|
+
*/
|
|
73
|
+
inStrangeLoop(): boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Should the agent break out of self-reference and return to task?
|
|
76
|
+
* Too much meta-reasoning is as bad as too little.
|
|
77
|
+
*/
|
|
78
|
+
shouldGroundItself(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Get the grounding prompt — inject into the agent when it needs
|
|
81
|
+
* to break out of self-referential spirals.
|
|
82
|
+
*/
|
|
83
|
+
getGroundingPrompt(): string;
|
|
84
|
+
/** Get full meta-cognitive state */
|
|
85
|
+
getState(): MetaCognitiveState;
|
|
86
|
+
/** Reset for new conversation */
|
|
87
|
+
reset(): void;
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=strange-loops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strange-loops.d.ts","sourceRoot":"","sources":["../src/strange-loops.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,CAAA;IACnE,8BAA8B;IAC9B,WAAW,EAAE,MAAM,GAAG,WAAW,GAAG,gBAAgB,GAAG,YAAY,CAAA;IACnE,wCAAwC;IACxC,WAAW,EAAE,MAAM,CAAA;IACnB,mEAAmE;IACnE,aAAa,EAAE,OAAO,CAAA;IACtB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,mCAAmC;IACnC,WAAW,EAAE,MAAM,CAAA;IACnB,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,kBAAkB;IACjC,0DAA0D;IAC1D,iBAAiB,EAAE,OAAO,CAAA;IAC1B,gHAAgH;IAChH,SAAS,EAAE,MAAM,CAAA;IACjB,0CAA0C;IAC1C,oBAAoB,EAAE,MAAM,CAAA;IAC5B,iCAAiC;IACjC,kBAAkB,EAAE,gBAAgB,EAAE,CAAA;IACtC,sEAAsE;IACtE,iBAAiB,EAAE,MAAM,CAAA;IACzB,wDAAwD;IACxD,YAAY,EAAE,OAAO,CAAA;CACtB;AA4BD;;;;;;;GAOG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,SAAS,CAAI;IACrB,OAAO,CAAC,iBAAiB,CAAM;IAG/B,OAAO,CAAC,eAAe,CAAe;IACtC,OAAO,CAAC,aAAa,CAAe;IAEpC;;;OAGG;IACH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,EAAE;IAiD5E;;;OAGG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKlC;;OAEG;IACH,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQlC;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IAqB/B;;;OAGG;IACH,aAAa,IAAI,OAAO;IAIxB;;;OAGG;IACH,kBAAkB,IAAI,OAAO;IAe7B;;;OAGG;IACH,kBAAkB,IAAI,MAAM;IAI5B,oCAAoC;IACpC,QAAQ,IAAI,kBAAkB;IAc9B,iCAAiC;IACjC,KAAK,IAAI,IAAI;CAQd"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// K:BOT Strange Loops — Self-Referential Cognition
|
|
2
|
+
//
|
|
3
|
+
// Based on Douglas Hofstadter's Strange Loops (GEB, 1979; I Am a Strange Loop, 2007):
|
|
4
|
+
// Consciousness arises from a "strange loop" — a self-referential cycle where
|
|
5
|
+
// a system at one level of abstraction can refer to and modify itself at
|
|
6
|
+
// another level. The "I" emerges from tangled hierarchies.
|
|
7
|
+
//
|
|
8
|
+
// For kbot: detect when the agent is reasoning about its own reasoning,
|
|
9
|
+
// when tool outputs change the agent's understanding of itself, and
|
|
10
|
+
// when hierarchical levels collapse into self-reference.
|
|
11
|
+
//
|
|
12
|
+
// This is the meta-cognition layer — kbot watching kbot think.
|
|
13
|
+
//
|
|
14
|
+
// References:
|
|
15
|
+
// - Hofstadter, D.R. (1979). Gödel, Escher, Bach: An Eternal Golden Braid.
|
|
16
|
+
// - Hofstadter, D.R. (2007). I Am a Strange Loop.
|
|
17
|
+
// - Hofstadter, D.R. & Dennett, D.C. (1981). The Mind's I.
|
|
18
|
+
/** Patterns that indicate self-referential reasoning */
|
|
19
|
+
const SELF_REFERENCE_PATTERNS = [
|
|
20
|
+
// Agent reasoning about its own capabilities
|
|
21
|
+
/\b(i can|i cannot|i don't know|my (abilities|capabilities|tools|limitations))\b/i,
|
|
22
|
+
// Agent reasoning about its own reasoning
|
|
23
|
+
/\b(my (reasoning|approach|strategy|analysis)|i (think|believe|predict|expect) (that )?i)\b/i,
|
|
24
|
+
// Agent modifying its own behavior
|
|
25
|
+
/\b(i (should|will|need to) (change|adjust|modify|update) (my|the) (approach|strategy))\b/i,
|
|
26
|
+
// Agent evaluating its own output
|
|
27
|
+
/\b(my (previous|last|earlier) (response|output|answer)|let me (reconsider|rethink|re-evaluate))\b/i,
|
|
28
|
+
// Meta-level: reasoning about the system
|
|
29
|
+
/\b(this (tool|agent|system)|the (agent|system) (is|should|can))\b/i,
|
|
30
|
+
];
|
|
31
|
+
/** Patterns indicating tangled hierarchies */
|
|
32
|
+
const TANGLE_PATTERNS = [
|
|
33
|
+
// Tool result changes tool selection
|
|
34
|
+
{ pattern: /tool.*(result|output).*(change|select|choose).*tool/i, levels: ['tool-execution', 'tool-selection'] },
|
|
35
|
+
// Output modifies the prompt that generated it
|
|
36
|
+
{ pattern: /\b(update|modify|change).*(prompt|instruction|system)/i, levels: ['output', 'input'] },
|
|
37
|
+
// Agent evaluates the agent
|
|
38
|
+
{ pattern: /\b(evaluate|assess|audit|test).*(agent|kbot|itself)/i, levels: ['evaluator', 'evaluated'] },
|
|
39
|
+
// Code that modifies the code
|
|
40
|
+
{ pattern: /\b(self|auto).*(modify|evolve|improve|upgrade|update)/i, levels: ['code', 'meta-code'] },
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Strange Loop Detector — monitors self-referential cognition
|
|
44
|
+
* and meta-cognitive depth.
|
|
45
|
+
*
|
|
46
|
+
* When kbot reasons about its own reasoning, that's a strange loop.
|
|
47
|
+
* When kbot modifies its own behavior based on self-evaluation,
|
|
48
|
+
* that's a tangled hierarchy. This module makes those moments visible.
|
|
49
|
+
*/
|
|
50
|
+
export class StrangeLoopDetector {
|
|
51
|
+
selfReferences = [];
|
|
52
|
+
tangledHierarchies = [];
|
|
53
|
+
metaDepth = 0;
|
|
54
|
+
selfModelAccuracy = 0.5;
|
|
55
|
+
// Track what the agent "thinks it's doing" vs. what it's actually doing
|
|
56
|
+
declaredIntents = [];
|
|
57
|
+
actualActions = [];
|
|
58
|
+
/**
|
|
59
|
+
* Analyze a message or response for self-referential content.
|
|
60
|
+
* Returns any self-references found.
|
|
61
|
+
*/
|
|
62
|
+
analyze(content, source) {
|
|
63
|
+
if (source === 'user')
|
|
64
|
+
return [];
|
|
65
|
+
const found = [];
|
|
66
|
+
for (const pattern of SELF_REFERENCE_PATTERNS) {
|
|
67
|
+
if (pattern.test(content)) {
|
|
68
|
+
const sourceLevel = this.metaDepth === 0 ? 'task' :
|
|
69
|
+
this.metaDepth === 1 ? 'reasoning' :
|
|
70
|
+
this.metaDepth === 2 ? 'meta-reasoning' : 'self-model';
|
|
71
|
+
// Self-reference goes one level up
|
|
72
|
+
const targetLevel = sourceLevel === 'task' ? 'reasoning' :
|
|
73
|
+
sourceLevel === 'reasoning' ? 'meta-reasoning' : 'self-model';
|
|
74
|
+
const ref = {
|
|
75
|
+
sourceLevel,
|
|
76
|
+
targetLevel,
|
|
77
|
+
description: content.slice(0, 100),
|
|
78
|
+
isStrangeLoop: sourceLevel !== 'task', // Only strange if crossing hierarchy
|
|
79
|
+
timestamp: Date.now(),
|
|
80
|
+
};
|
|
81
|
+
found.push(ref);
|
|
82
|
+
this.selfReferences.push(ref);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Update meta-depth
|
|
86
|
+
if (found.length > 0) {
|
|
87
|
+
this.metaDepth = Math.min(3, this.metaDepth + 1);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
this.metaDepth = Math.max(0, this.metaDepth - 1);
|
|
91
|
+
}
|
|
92
|
+
// Check for tangled hierarchies
|
|
93
|
+
for (const tangle of TANGLE_PATTERNS) {
|
|
94
|
+
if (tangle.pattern.test(content)) {
|
|
95
|
+
this.tangledHierarchies.push({
|
|
96
|
+
levels: tangle.levels,
|
|
97
|
+
description: content.slice(0, 100),
|
|
98
|
+
depth: this.metaDepth,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return found;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Record what the agent says it intends to do.
|
|
106
|
+
* Used to measure self-model accuracy.
|
|
107
|
+
*/
|
|
108
|
+
recordIntent(intent) {
|
|
109
|
+
this.declaredIntents.push(intent.toLowerCase());
|
|
110
|
+
if (this.declaredIntents.length > 20)
|
|
111
|
+
this.declaredIntents.shift();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Record what the agent actually did.
|
|
115
|
+
*/
|
|
116
|
+
recordAction(action) {
|
|
117
|
+
this.actualActions.push(action.toLowerCase());
|
|
118
|
+
if (this.actualActions.length > 20)
|
|
119
|
+
this.actualActions.shift();
|
|
120
|
+
// Update self-model accuracy
|
|
121
|
+
this.updateSelfModelAccuracy();
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Compute how well the agent knows itself.
|
|
125
|
+
* Compares declared intents to actual actions.
|
|
126
|
+
*/
|
|
127
|
+
updateSelfModelAccuracy() {
|
|
128
|
+
if (this.declaredIntents.length === 0 || this.actualActions.length === 0)
|
|
129
|
+
return;
|
|
130
|
+
const n = Math.min(this.declaredIntents.length, this.actualActions.length);
|
|
131
|
+
let matches = 0;
|
|
132
|
+
for (let i = 0; i < n; i++) {
|
|
133
|
+
const intentWords = new Set(this.declaredIntents[this.declaredIntents.length - 1 - i]?.split(/\s+/) || []);
|
|
134
|
+
const actionWords = new Set(this.actualActions[this.actualActions.length - 1 - i]?.split(/\s+/) || []);
|
|
135
|
+
if (intentWords.size === 0 || actionWords.size === 0)
|
|
136
|
+
continue;
|
|
137
|
+
const overlap = [...intentWords].filter(w => actionWords.has(w)).length;
|
|
138
|
+
if (overlap / Math.max(intentWords.size, actionWords.size) > 0.3) {
|
|
139
|
+
matches++;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
this.selfModelAccuracy = n > 0 ? matches / n : 0.5;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Is the agent currently in a strange loop?
|
|
146
|
+
* Returns true if meta-depth >= 2 (reasoning about reasoning).
|
|
147
|
+
*/
|
|
148
|
+
inStrangeLoop() {
|
|
149
|
+
return this.metaDepth >= 2;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Should the agent break out of self-reference and return to task?
|
|
153
|
+
* Too much meta-reasoning is as bad as too little.
|
|
154
|
+
*/
|
|
155
|
+
shouldGroundItself() {
|
|
156
|
+
// If stuck in deep self-reference for too long
|
|
157
|
+
if (this.metaDepth >= 3)
|
|
158
|
+
return true;
|
|
159
|
+
// If recent self-references are circular (same pattern repeating)
|
|
160
|
+
const recent = this.selfReferences.slice(-5);
|
|
161
|
+
if (recent.length >= 5) {
|
|
162
|
+
const descriptions = recent.map(r => r.description);
|
|
163
|
+
const unique = new Set(descriptions);
|
|
164
|
+
if (unique.size <= 2)
|
|
165
|
+
return true; // Stuck in a loop
|
|
166
|
+
}
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Get the grounding prompt — inject into the agent when it needs
|
|
171
|
+
* to break out of self-referential spirals.
|
|
172
|
+
*/
|
|
173
|
+
getGroundingPrompt() {
|
|
174
|
+
return 'Focus on the concrete task at hand. What specific action should you take next? Avoid reasoning about your own reasoning — just act.';
|
|
175
|
+
}
|
|
176
|
+
/** Get full meta-cognitive state */
|
|
177
|
+
getState() {
|
|
178
|
+
const recentRefs = this.selfReferences.slice(-20);
|
|
179
|
+
const strangeLoops = recentRefs.filter(r => r.isStrangeLoop).length;
|
|
180
|
+
return {
|
|
181
|
+
isSelfReferential: this.metaDepth >= 1,
|
|
182
|
+
metaDepth: this.metaDepth,
|
|
183
|
+
strangeLoopsDetected: strangeLoops,
|
|
184
|
+
tangledHierarchies: this.tangledHierarchies.slice(-5),
|
|
185
|
+
selfModelAccuracy: this.selfModelAccuracy,
|
|
186
|
+
isReflective: this.metaDepth >= 2,
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
/** Reset for new conversation */
|
|
190
|
+
reset() {
|
|
191
|
+
this.selfReferences = [];
|
|
192
|
+
this.tangledHierarchies = [];
|
|
193
|
+
this.metaDepth = 0;
|
|
194
|
+
this.selfModelAccuracy = 0.5;
|
|
195
|
+
this.declaredIntents = [];
|
|
196
|
+
this.actualActions = [];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=strange-loops.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strange-loops.js","sourceRoot":"","sources":["../src/strange-loops.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,sFAAsF;AACtF,8EAA8E;AAC9E,yEAAyE;AACzE,2DAA2D;AAC3D,EAAE;AACF,wEAAwE;AACxE,oEAAoE;AACpE,yDAAyD;AACzD,EAAE;AACF,+DAA+D;AAC/D,EA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|
1
|
-
{"version":3,"file":"tutorial.d.ts","sourceRoot":"","sources":["../src/tutorial.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"tutorial.d.ts","sourceRoot":"","sources":["../src/tutorial.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAwL/C,wBAAsB,WAAW,CAC/B,EAAE,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,GACrC,OAAO,CAAC,IAAI,CAAC,CAuCf"}
|
package/dist/tutorial.js
CHANGED
|
@@ -33,16 +33,19 @@ const STEPS = [
|
|
|
33
33
|
{
|
|
34
34
|
title: 'Meet the specialists',
|
|
35
35
|
body: [
|
|
36
|
-
'kbot has
|
|
36
|
+
'kbot has 22 specialist agents. Each one is an expert in a',
|
|
37
37
|
'different area. You don\'t need to pick one — kbot routes your',
|
|
38
38
|
'message to the right specialist automatically.',
|
|
39
39
|
'',
|
|
40
|
-
` ${chalk.hex('#4ADE80')('coder')}
|
|
41
|
-
` ${chalk.hex('#60A5FA')('researcher')}
|
|
42
|
-
` ${chalk.hex('#FB923C')('writer')}
|
|
43
|
-
` ${chalk.hex('#F472B6')('analyst')}
|
|
44
|
-
` ${chalk.hex('#8B4513')('guardian')}
|
|
45
|
-
` ${
|
|
40
|
+
` ${chalk.hex('#4ADE80')('coder')} Write, fix, and explain code`,
|
|
41
|
+
` ${chalk.hex('#60A5FA')('researcher')} Find information and explain topics`,
|
|
42
|
+
` ${chalk.hex('#FB923C')('writer')} Draft emails, docs, blog posts`,
|
|
43
|
+
` ${chalk.hex('#F472B6')('analyst')} Break down data and strategy`,
|
|
44
|
+
` ${chalk.hex('#8B4513')('guardian')} Review code for security issues`,
|
|
45
|
+
` ${chalk.hex('#DAA520')('strategist')} Business strategy and planning`,
|
|
46
|
+
` ${chalk.hex('#38BDF8')('infrastructure')} DevOps, servers, and deployment`,
|
|
47
|
+
` ${ACCENT('kernel')} General questions, anything else`,
|
|
48
|
+
` ${DIM('...and 14 more specialists')}`,
|
|
46
49
|
'',
|
|
47
50
|
'To force a specific agent, use the /agent command:',
|
|
48
51
|
` ${CYAN('/agent researcher')}`,
|
|
@@ -53,7 +56,7 @@ const STEPS = [
|
|
|
53
56
|
{
|
|
54
57
|
title: 'Use tools',
|
|
55
58
|
body: [
|
|
56
|
-
'kbot doesn\'t just talk — it can take action. It has
|
|
59
|
+
'kbot doesn\'t just talk — it can take action. It has 223 built-in',
|
|
57
60
|
'tools for working with your files and system:',
|
|
58
61
|
'',
|
|
59
62
|
` ${chalk.bold('Files')} Read, write, search, and edit files`,
|
package/dist/tutorial.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tutorial.js","sourceRoot":"","sources":["../src/tutorial.ts"],"names":[],"mappings":"AAAA,sEAAsE;AACtE,EAAE;AACF,qEAAqE;AACrE,kEAAkE;AAClE,+CAA+C;AAG/C,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAElE,sCAAsC;AACtC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA,CAAG,cAAc;AACpD,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA,CAAI,UAAU;AAChD,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAA,CAAK,aAAa;AACnD,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAA,CAAiB,iBAAiB;AAWvD,cAAc;AAEd,MAAM,KAAK,GAAmB;IAC5B;QACE,KAAK,EAAE,mBAAmB;QAC1B,IAAI,EAAE;YACJ,sBAAsB;YACtB,EAAE;YACF,KAAK,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,6CAA6C;YACxE,KAAK,IAAI,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ClE,MAAM,EAAE,CAAA;AACV,CAAC"}
|
package/dist/ui.js
CHANGED
|
@@ -261,7 +261,7 @@ export function printHelp() {
|
|
|
261
261
|
` ${CYAN('https://kernel.chat')} ${DIM('Web companion')}`,
|
|
262
262
|
` ${CYAN('https://github.com/isaacsight/kernel')} ${DIM('GitHub')}`,
|
|
263
263
|
'',
|
|
264
|
-
` ${DIM('
|
|
264
|
+
` ${DIM('22 specialist agents. 223 tools. Type anything to get started.')}`,
|
|
265
265
|
'',
|
|
266
266
|
];
|
|
267
267
|
status(lines.join('\n'));
|