@kernel.chat/kbot 3.11.0 → 3.13.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/agents/replit.d.ts +3 -0
- package/dist/agents/replit.d.ts.map +1 -0
- package/dist/agents/replit.js +68 -0
- package/dist/agents/replit.js.map +1 -0
- package/dist/cli.js +16 -0
- package/dist/cli.js.map +1 -1
- package/dist/integrations/openclaw/plugin.d.ts +22 -0
- package/dist/integrations/openclaw/plugin.d.ts.map +1 -0
- package/dist/integrations/openclaw/plugin.js +132 -0
- package/dist/integrations/openclaw/plugin.js.map +1 -0
- package/dist/interference.d.ts +208 -0
- package/dist/interference.d.ts.map +1 -0
- package/dist/interference.js +845 -0
- package/dist/interference.js.map +1 -0
- package/dist/matrix.d.ts.map +1 -1
- package/dist/matrix.js +7 -0
- package/dist/matrix.js.map +1 -1
- package/dist/prompt-evolution.d.ts.map +1 -1
- package/dist/prompt-evolution.js +23 -5
- package/dist/prompt-evolution.js.map +1 -1
- 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/tools/index.d.ts +4 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +19 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tree-planner.d.ts.map +1 -1
- package/dist/tree-planner.js +24 -32
- package/dist/tree-planner.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface PluginApi {
|
|
2
|
+
registerTool(tool: {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
parameters: Record<string, unknown>;
|
|
6
|
+
execute: (id: string, params: Record<string, unknown>) => Promise<{
|
|
7
|
+
content: Array<{
|
|
8
|
+
type: string;
|
|
9
|
+
text: string;
|
|
10
|
+
}>;
|
|
11
|
+
}>;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|
|
14
|
+
interface KbotConfig {
|
|
15
|
+
port?: number;
|
|
16
|
+
host?: string;
|
|
17
|
+
agent?: string;
|
|
18
|
+
token?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function register(api: PluginApi, config?: KbotConfig): void;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/integrations/openclaw/plugin.ts"],"names":[],"mappings":"AAQA,UAAU,SAAS;IACjB,YAAY,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;QACnC,OAAO,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;YAAE,OAAO,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,IAAI,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,CAAC,CAAA;KACtH,GAAG,IAAI,CAAA;CACT;AAED,UAAU,UAAU;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAoCD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,SAAS,EAAE,MAAM,GAAE,UAAe,GAAG,IAAI,CA6GtE"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// kbot OpenClaw Plugin
|
|
2
|
+
//
|
|
3
|
+
// Registers kbot's cognitive stack as native OpenClaw tools.
|
|
4
|
+
// Requires kbot serve running on the configured port.
|
|
5
|
+
//
|
|
6
|
+
// Install: openclaw plugins install @kernel.chat/kbot
|
|
7
|
+
// Or copy this directory to ~/.openclaw/extensions/kbot/
|
|
8
|
+
function getBaseUrl(config) {
|
|
9
|
+
const host = config.host || 'http://localhost';
|
|
10
|
+
const port = config.port || 7437;
|
|
11
|
+
return `${host}:${port}`;
|
|
12
|
+
}
|
|
13
|
+
async function kbotFetch(config, path, options) {
|
|
14
|
+
const url = `${getBaseUrl(config)}${path}`;
|
|
15
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
16
|
+
if (config.token) {
|
|
17
|
+
headers['Authorization'] = `Bearer ${config.token}`;
|
|
18
|
+
}
|
|
19
|
+
const response = await fetch(url, {
|
|
20
|
+
method: options?.method || 'GET',
|
|
21
|
+
headers,
|
|
22
|
+
body: options?.body ? JSON.stringify(options.body) : undefined,
|
|
23
|
+
});
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new Error(`kbot error: ${response.status} ${response.statusText}`);
|
|
26
|
+
}
|
|
27
|
+
return response.json();
|
|
28
|
+
}
|
|
29
|
+
function textResult(text) {
|
|
30
|
+
return { content: [{ type: 'text', text }] };
|
|
31
|
+
}
|
|
32
|
+
export function register(api, config = {}) {
|
|
33
|
+
// ── kbot_chat: Full agent loop ──
|
|
34
|
+
api.registerTool({
|
|
35
|
+
name: 'kbot_chat',
|
|
36
|
+
description: 'Send a message to kbot\'s cognitive engine. Routes to the best specialist agent (coder, researcher, writer, analyst, guardian, etc.). Learns from every interaction. Use for complex tasks that need multi-step reasoning and tool use.',
|
|
37
|
+
parameters: {
|
|
38
|
+
type: 'object',
|
|
39
|
+
properties: {
|
|
40
|
+
message: { type: 'string', description: 'The message or task to send to kbot' },
|
|
41
|
+
agent: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Specialist agent to use. Default: auto (kbot picks the best one)',
|
|
44
|
+
enum: [
|
|
45
|
+
'auto', 'kernel', 'coder', 'researcher', 'writer', 'analyst',
|
|
46
|
+
'aesthete', 'guardian', 'curator', 'strategist', 'infrastructure',
|
|
47
|
+
'quant', 'investigator', 'oracle', 'chronist', 'sage',
|
|
48
|
+
'communicator', 'adapter', 'replit',
|
|
49
|
+
],
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['message'],
|
|
53
|
+
},
|
|
54
|
+
execute: async (_id, params) => {
|
|
55
|
+
const result = await kbotFetch(config, '/stream', {
|
|
56
|
+
method: 'POST',
|
|
57
|
+
body: {
|
|
58
|
+
message: params.message,
|
|
59
|
+
agent: params.agent || config.agent || 'auto',
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return textResult(result.content || result.error || 'No response');
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
// ── kbot_tool: Execute a specific tool ──
|
|
66
|
+
api.registerTool({
|
|
67
|
+
name: 'kbot_tool',
|
|
68
|
+
description: 'Execute one of kbot\'s 290 built-in tools directly. Use for specific operations like web search, file read/write, git operations, etc. Use kbot_tools_list to see available tools.',
|
|
69
|
+
parameters: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
properties: {
|
|
72
|
+
name: { type: 'string', description: 'Tool name (e.g., web_search, read_file, bash)' },
|
|
73
|
+
args: { type: 'object', description: 'Tool arguments as key-value pairs' },
|
|
74
|
+
},
|
|
75
|
+
required: ['name'],
|
|
76
|
+
},
|
|
77
|
+
execute: async (_id, params) => {
|
|
78
|
+
const result = await kbotFetch(config, '/execute', {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: { name: params.name, args: params.args || {} },
|
|
81
|
+
});
|
|
82
|
+
return textResult(result.result || result.error || 'No result');
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
// ── kbot_tools_list: Discover available tools ──
|
|
86
|
+
api.registerTool({
|
|
87
|
+
name: 'kbot_tools_list',
|
|
88
|
+
description: 'List all tools available in kbot. Returns tool names and descriptions. Use to discover what kbot can do before calling kbot_tool.',
|
|
89
|
+
parameters: {
|
|
90
|
+
type: 'object',
|
|
91
|
+
properties: {
|
|
92
|
+
filter: { type: 'string', description: 'Optional keyword to filter tools by name or description' },
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
execute: async (_id, params) => {
|
|
96
|
+
const tools = await kbotFetch(config, '/tools');
|
|
97
|
+
let filtered = tools;
|
|
98
|
+
if (params.filter) {
|
|
99
|
+
const query = params.filter.toLowerCase();
|
|
100
|
+
filtered = tools.filter((t) => t.name.toLowerCase().includes(query) || t.description.toLowerCase().includes(query));
|
|
101
|
+
}
|
|
102
|
+
const list = filtered.map((t) => `${t.name} — ${t.description}`).join('\n');
|
|
103
|
+
return textResult(list || 'No tools found');
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
// ── kbot_health: Check kbot status ──
|
|
107
|
+
api.registerTool({
|
|
108
|
+
name: 'kbot_health',
|
|
109
|
+
description: 'Check if kbot\'s cognitive engine is running and healthy. Returns version, tool count, and uptime.',
|
|
110
|
+
parameters: { type: 'object', properties: {} },
|
|
111
|
+
execute: async () => {
|
|
112
|
+
try {
|
|
113
|
+
const health = await kbotFetch(config, '/health');
|
|
114
|
+
return textResult(JSON.stringify(health, null, 2));
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
return textResult(`kbot is not running. Start it with: kbot serve --port ${config.port || 7437}\n\nError: ${err instanceof Error ? err.message : String(err)}`);
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
// ── kbot_metrics: Tool execution metrics ──
|
|
122
|
+
api.registerTool({
|
|
123
|
+
name: 'kbot_metrics',
|
|
124
|
+
description: 'Get execution metrics for kbot\'s tools — call counts, error rates, average duration. Useful for understanding which tools are being used and how they perform.',
|
|
125
|
+
parameters: { type: 'object', properties: {} },
|
|
126
|
+
execute: async () => {
|
|
127
|
+
const metrics = await kbotFetch(config, '/metrics');
|
|
128
|
+
return textResult(JSON.stringify(metrics, null, 2));
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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AI,EAAE,cAAc;QACpB,WAAW,EAAE,iKAAiK;QAC9K,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;QAC9C,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,UAAU,CAAY,CAAA;YAC9D,OAAO,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;QACrD,CAAC;KACF,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/** All 11 cognitive modules in the kbot cognitive architecture */
|
|
2
|
+
export type CognitiveModule = 'free-energy' | 'predictive-processing' | 'strange-loops' | 'integrated-information' | 'autopoiesis' | 'quality-diversity' | 'skill-rating' | 'tree-planner' | 'prompt-evolution' | 'memory-synthesis' | 'reflection';
|
|
3
|
+
/** How two module signals combine */
|
|
4
|
+
export type InterferenceType = 'CONSTRUCTIVE' | 'DESTRUCTIVE' | 'NEUTRAL';
|
|
5
|
+
/** Outcome of the interference resolution */
|
|
6
|
+
export type InterferenceOutcome = 'success' | 'failure' | 'pending';
|
|
7
|
+
/** A single interference event between two cognitive modules */
|
|
8
|
+
export interface InterferenceEvent {
|
|
9
|
+
/** Unique event identifier */
|
|
10
|
+
id: string;
|
|
11
|
+
/** ISO timestamp of the event */
|
|
12
|
+
timestamp: string;
|
|
13
|
+
/** First module involved */
|
|
14
|
+
moduleA: CognitiveModule;
|
|
15
|
+
/** Second module involved */
|
|
16
|
+
moduleB: CognitiveModule;
|
|
17
|
+
/** How the signals combined */
|
|
18
|
+
type: InterferenceType;
|
|
19
|
+
/** Free-form description of what triggered the interference */
|
|
20
|
+
context: string;
|
|
21
|
+
/** Which module's signal was ultimately followed */
|
|
22
|
+
resolution: CognitiveModule;
|
|
23
|
+
/** Whether following that module led to a good outcome */
|
|
24
|
+
outcome: InterferenceOutcome;
|
|
25
|
+
}
|
|
26
|
+
/** A known tension or synergy between two modules */
|
|
27
|
+
export interface KnownInteraction {
|
|
28
|
+
moduleA: CognitiveModule;
|
|
29
|
+
moduleB: CognitiveModule;
|
|
30
|
+
description: string;
|
|
31
|
+
}
|
|
32
|
+
/** Aggregate statistics for a module pair */
|
|
33
|
+
export interface PairStats {
|
|
34
|
+
moduleA: CognitiveModule;
|
|
35
|
+
moduleB: CognitiveModule;
|
|
36
|
+
total: number;
|
|
37
|
+
constructive: number;
|
|
38
|
+
destructive: number;
|
|
39
|
+
neutral: number;
|
|
40
|
+
/** How often moduleA was the resolution winner */
|
|
41
|
+
aWins: number;
|
|
42
|
+
/** How often moduleB was the resolution winner */
|
|
43
|
+
bWins: number;
|
|
44
|
+
/** Success rate when moduleA wins */
|
|
45
|
+
aWinSuccessRate: number;
|
|
46
|
+
/** Success rate when moduleB wins */
|
|
47
|
+
bWinSuccessRate: number;
|
|
48
|
+
/** Overall conflict rate (destructive / total) */
|
|
49
|
+
conflictRate: number;
|
|
50
|
+
}
|
|
51
|
+
/** Full interference state persisted to disk */
|
|
52
|
+
export interface InterferenceState {
|
|
53
|
+
events: InterferenceEvent[];
|
|
54
|
+
/** ISO timestamp of last event */
|
|
55
|
+
lastUpdated: string;
|
|
56
|
+
}
|
|
57
|
+
/** All cognitive module identifiers for validation */
|
|
58
|
+
export declare const ALL_MODULES: CognitiveModule[];
|
|
59
|
+
export declare const KNOWN_TENSIONS: KnownInteraction[];
|
|
60
|
+
export declare const KNOWN_SYNERGIES: KnownInteraction[];
|
|
61
|
+
/**
|
|
62
|
+
* Classify how two module signals interfere based on their output values.
|
|
63
|
+
*
|
|
64
|
+
* - Same sign (both positive or both negative) = CONSTRUCTIVE
|
|
65
|
+
* (both modules agree on direction)
|
|
66
|
+
* - Opposite signs = DESTRUCTIVE
|
|
67
|
+
* (modules disagree — one says go, the other says stop)
|
|
68
|
+
* - Either signal near zero = NEUTRAL
|
|
69
|
+
* (one module is inactive or indifferent)
|
|
70
|
+
*
|
|
71
|
+
* @param signalA - Numeric output from module A (positive = activate, negative = inhibit)
|
|
72
|
+
* @param signalB - Numeric output from module B
|
|
73
|
+
* @returns The interference type
|
|
74
|
+
*/
|
|
75
|
+
export declare function classifyInterference(signalA: number, signalB: number): InterferenceType;
|
|
76
|
+
/**
|
|
77
|
+
* Validate that a string is a valid CognitiveModule.
|
|
78
|
+
*/
|
|
79
|
+
export declare function isValidModule(id: string): id is CognitiveModule;
|
|
80
|
+
/**
|
|
81
|
+
* Record an interference event between two cognitive modules.
|
|
82
|
+
*
|
|
83
|
+
* @param moduleA - First module in the interference
|
|
84
|
+
* @param moduleB - Second module (order doesn't matter for stats)
|
|
85
|
+
* @param type - CONSTRUCTIVE, DESTRUCTIVE, or NEUTRAL
|
|
86
|
+
* @param context - Free-form description of what triggered this
|
|
87
|
+
* @param resolution - Which module was ultimately followed
|
|
88
|
+
* @param outcome - Whether following that module led to success
|
|
89
|
+
* @returns The recorded event
|
|
90
|
+
*/
|
|
91
|
+
export declare function recordInterference(moduleA: CognitiveModule, moduleB: CognitiveModule, type: InterferenceType, context: string, resolution: CognitiveModule, outcome?: InterferenceOutcome): InterferenceEvent;
|
|
92
|
+
/**
|
|
93
|
+
* Record an interference by classifying signals automatically.
|
|
94
|
+
* Convenience wrapper around classifyInterference + recordInterference.
|
|
95
|
+
*/
|
|
96
|
+
export declare function recordSignalInterference(moduleA: CognitiveModule, signalA: number, moduleB: CognitiveModule, signalB: number, context: string, resolution: CognitiveModule, outcome?: InterferenceOutcome): InterferenceEvent;
|
|
97
|
+
/**
|
|
98
|
+
* Update the outcome of a pending interference event.
|
|
99
|
+
* Called after the resolution's result is known.
|
|
100
|
+
*
|
|
101
|
+
* @param eventId - The event to update
|
|
102
|
+
* @param outcome - The actual outcome
|
|
103
|
+
* @returns true if the event was found and updated, false otherwise
|
|
104
|
+
*/
|
|
105
|
+
export declare function resolveInterference(eventId: string, outcome: InterferenceOutcome): boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Check if two modules have a known tension.
|
|
108
|
+
* Returns the tension description or null.
|
|
109
|
+
*/
|
|
110
|
+
export declare function getKnownTension(moduleA: CognitiveModule, moduleB: CognitiveModule): string | null;
|
|
111
|
+
/**
|
|
112
|
+
* Check if two modules have a known synergy.
|
|
113
|
+
* Returns the synergy description or null.
|
|
114
|
+
*/
|
|
115
|
+
export declare function getKnownSynergy(moduleA: CognitiveModule, moduleB: CognitiveModule): string | null;
|
|
116
|
+
/**
|
|
117
|
+
* Get all known tensions for a specific module.
|
|
118
|
+
*/
|
|
119
|
+
export declare function getTensionsFor(module: CognitiveModule): KnownInteraction[];
|
|
120
|
+
/**
|
|
121
|
+
* Get all known synergies for a specific module.
|
|
122
|
+
*/
|
|
123
|
+
export declare function getSynergiesFor(module: CognitiveModule): KnownInteraction[];
|
|
124
|
+
/**
|
|
125
|
+
* Get the conflict rate (destructive / total) for a specific module pair.
|
|
126
|
+
* Returns 0 if no events exist for the pair.
|
|
127
|
+
*/
|
|
128
|
+
export declare function getConflictRate(moduleA: CognitiveModule, moduleB: CognitiveModule): number;
|
|
129
|
+
/**
|
|
130
|
+
* Get interference statistics for all module pairs that have events.
|
|
131
|
+
* Returns an array of PairStats, sorted by total events descending.
|
|
132
|
+
*/
|
|
133
|
+
export declare function getInterferenceStats(): PairStats[];
|
|
134
|
+
/**
|
|
135
|
+
* Get statistics for a single module — how often it is involved
|
|
136
|
+
* in interference, and its win/success rates.
|
|
137
|
+
*/
|
|
138
|
+
export declare function getModuleStats(module: CognitiveModule): {
|
|
139
|
+
totalEvents: number;
|
|
140
|
+
asModuleA: number;
|
|
141
|
+
asModuleB: number;
|
|
142
|
+
timesWon: number;
|
|
143
|
+
winSuccessRate: number;
|
|
144
|
+
topPartner: CognitiveModule | null;
|
|
145
|
+
dominantType: InterferenceType;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Generate a formatted interference report string for the daemon.
|
|
149
|
+
* Includes:
|
|
150
|
+
* - Total event count and time range
|
|
151
|
+
* - Top conflicting pairs
|
|
152
|
+
* - Top synergistic pairs
|
|
153
|
+
* - Known tensions with observed conflict rates
|
|
154
|
+
* - Recommendations based on resolution success rates
|
|
155
|
+
*/
|
|
156
|
+
export declare function getInterferenceReport(): string;
|
|
157
|
+
/**
|
|
158
|
+
* Get all interference events, optionally filtered.
|
|
159
|
+
*/
|
|
160
|
+
export declare function getEvents(filter?: {
|
|
161
|
+
module?: CognitiveModule;
|
|
162
|
+
type?: InterferenceType;
|
|
163
|
+
outcome?: InterferenceOutcome;
|
|
164
|
+
since?: string;
|
|
165
|
+
limit?: number;
|
|
166
|
+
}): InterferenceEvent[];
|
|
167
|
+
/**
|
|
168
|
+
* Get the most recent interference events (for dashboard display).
|
|
169
|
+
*/
|
|
170
|
+
export declare function getRecentEvents(count?: number): InterferenceEvent[];
|
|
171
|
+
/**
|
|
172
|
+
* Count total recorded interference events.
|
|
173
|
+
*/
|
|
174
|
+
export declare function getEventCount(): number;
|
|
175
|
+
/**
|
|
176
|
+
* Clear all interference events. Use with caution — this is destructive.
|
|
177
|
+
* Returns the number of events that were cleared.
|
|
178
|
+
*/
|
|
179
|
+
export declare function clearEvents(): number;
|
|
180
|
+
/**
|
|
181
|
+
* Predict the likely interference type for a module pair based on
|
|
182
|
+
* historical data and known interactions.
|
|
183
|
+
*
|
|
184
|
+
* Returns a prediction with confidence, or null if insufficient data.
|
|
185
|
+
*/
|
|
186
|
+
export declare function predictInterference(moduleA: CognitiveModule, moduleB: CognitiveModule): {
|
|
187
|
+
predicted: InterferenceType;
|
|
188
|
+
confidence: number;
|
|
189
|
+
basis: string;
|
|
190
|
+
} | null;
|
|
191
|
+
/**
|
|
192
|
+
* Suggest which module to follow when two modules conflict,
|
|
193
|
+
* based on historical win/success rates.
|
|
194
|
+
*
|
|
195
|
+
* Returns the recommended module and the basis for the recommendation,
|
|
196
|
+
* or null if insufficient data.
|
|
197
|
+
*/
|
|
198
|
+
export declare function suggestResolution(moduleA: CognitiveModule, moduleB: CognitiveModule): {
|
|
199
|
+
recommended: CognitiveModule;
|
|
200
|
+
confidence: number;
|
|
201
|
+
reason: string;
|
|
202
|
+
} | null;
|
|
203
|
+
/**
|
|
204
|
+
* Generate a compact interference summary suitable for system prompt injection.
|
|
205
|
+
* Returns empty string if no meaningful patterns exist.
|
|
206
|
+
*/
|
|
207
|
+
export declare function getInterferenceSummary(): string;
|
|
208
|
+
//# sourceMappingURL=interference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interference.d.ts","sourceRoot":"","sources":["../src/interference.ts"],"names":[],"mappings":"AA8BA,kEAAkE;AAClE,MAAM,MAAM,eAAe,GACvB,aAAa,GACb,uBAAuB,GACvB,eAAe,GACf,wBAAwB,GACxB,aAAa,GACb,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,kBAAkB,GAClB,kBAAkB,GAClB,YAAY,CAAA;AAEhB,qCAAqC;AACrC,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,aAAa,GAAG,SAAS,CAAA;AAEzE,6CAA6C;AAC7C,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;AAEnE,gEAAgE;AAChE,MAAM,WAAW,iBAAiB;IAChC,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,4BAA4B;IAC5B,OAAO,EAAE,eAAe,CAAA;IACxB,6BAA6B;IAC7B,OAAO,EAAE,eAAe,CAAA;IACxB,+BAA+B;IAC/B,IAAI,EAAE,gBAAgB,CAAA;IACtB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAA;IACf,oDAAoD;IACpD,UAAU,EAAE,eAAe,CAAA;IAC3B,0DAA0D;IAC1D,OAAO,EAAE,mBAAmB,CAAA;CAC7B;AAED,qDAAqD;AACrD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,eAAe,CAAA;I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