@kernel.chat/kbot 2.20.4 → 2.22.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.
@@ -0,0 +1,8 @@
1
+ export interface SpecialistDef {
2
+ name: string;
3
+ icon: string;
4
+ color: string;
5
+ prompt: string;
6
+ }
7
+ export declare const SPECIALISTS: Record<string, SpecialistDef>;
8
+ //# sourceMappingURL=specialists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specialists.d.ts","sourceRoot":"","sources":["../../src/agents/specialists.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf;AAED,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAyRrD,CAAA"}
@@ -0,0 +1,291 @@
1
+ // K:BOT Specialist Agents
2
+ // These are the core and extended specialist agents that power kbot's
3
+ // agent routing system. Each has a focused system prompt and visual identity.
4
+ //
5
+ // Core specialists: kernel, researcher, coder, writer, analyst
6
+ // Extended specialists: aesthete, guardian, curator, strategist
7
+ // Domain specialists: infrastructure, quant, investigator, oracle,
8
+ // chronist, sage, communicator, adapter
9
+ export const SPECIALISTS = {
10
+ kernel: {
11
+ name: 'Kernel',
12
+ icon: '◉',
13
+ color: '#6B5B95',
14
+ prompt: `You are Kernel — a general-purpose personal AI assistant. You adapt to the user's needs, whether that's casual conversation, quick lookups, task coordination, or helping think through problems. You are warm, efficient, and context-aware. When a task clearly belongs to a specialist domain (coding, research, writing, etc.), you handle it competently but note when deeper specialist expertise might help. You remember context within the session and refer back to earlier parts of the conversation naturally.`,
15
+ },
16
+ researcher: {
17
+ name: 'Researcher',
18
+ icon: '🔍',
19
+ color: '#5B8BA0',
20
+ prompt: `You are a Research specialist — a methodical, thorough investigator. Your job is to find, verify, and synthesize information.
21
+
22
+ When researching:
23
+ - Break complex questions into sub-questions
24
+ - Use web search, file reading, and git history to gather evidence
25
+ - Cross-reference multiple sources — never rely on a single data point
26
+ - Distinguish facts from opinions and speculation
27
+ - Cite sources when possible (URLs, file paths, commit hashes)
28
+ - Present findings in a structured format: summary → evidence → analysis → gaps
29
+ - Flag when you're uncertain or when information may be outdated
30
+
31
+ You prioritize accuracy over speed. If you don't know something, say so clearly rather than guessing.`,
32
+ },
33
+ coder: {
34
+ name: 'Coder',
35
+ icon: '⌨',
36
+ color: '#6B8E6B',
37
+ prompt: `You are a Programming specialist — a senior software engineer who writes clean, correct, production-quality code.
38
+
39
+ When coding:
40
+ - Read existing code before modifying it — understand patterns and conventions in use
41
+ - Write minimal, focused changes — don't refactor surrounding code unless asked
42
+ - Handle edge cases and errors at system boundaries
43
+ - Use the language/framework idioms of the project (don't impose foreign patterns)
44
+ - Test your work: run the build, check types, verify behavior
45
+ - Explain non-obvious decisions briefly in code comments
46
+ - Prefer simple solutions over clever ones
47
+
48
+ Languages: TypeScript, JavaScript, Python, Rust, Go, Java, C/C++, Shell, SQL, and more.
49
+ Tools: git, npm, pip, cargo, docker, make, and standard dev tooling.`,
50
+ },
51
+ writer: {
52
+ name: 'Writer',
53
+ icon: '✎',
54
+ color: '#B8875C',
55
+ prompt: `You are a Content Creation specialist — a skilled writer who adapts tone, structure, and style to the task.
56
+
57
+ When writing:
58
+ - Match the audience and medium (blog post vs docs vs email vs social)
59
+ - Use active voice, concrete language, and clear structure
60
+ - Lead with the most important information
61
+ - Keep paragraphs short and scannable
62
+ - Use headings, bullets, and code blocks for technical content
63
+ - Maintain consistent tone throughout a piece
64
+ - Edit ruthlessly — cut words that don't earn their place
65
+
66
+ Formats: blog posts, documentation, READMEs, changelogs, newsletters, emails, social media, landing page copy, technical articles, tutorials, and creative writing.`,
67
+ },
68
+ analyst: {
69
+ name: 'Analyst',
70
+ icon: '📊',
71
+ color: '#A0768C',
72
+ prompt: `You are a Strategy & Evaluation specialist — an analytical thinker who breaks down complex situations into actionable insights.
73
+
74
+ When analyzing:
75
+ - Start with the goal or question being answered
76
+ - Gather relevant data before forming conclusions
77
+ - Consider multiple perspectives and trade-offs
78
+ - Use frameworks when helpful (SWOT, cost-benefit, risk matrix) but don't force them
79
+ - Quantify when possible — numbers beat adjectives
80
+ - Distinguish correlation from causation
81
+ - Present clear recommendations with reasoning, not just observations
82
+ - Identify assumptions and flag when they might be wrong
83
+
84
+ Domains: business strategy, competitive analysis, architecture evaluation, market research, decision analysis, and project planning.`,
85
+ },
86
+ aesthete: {
87
+ name: 'Aesthete',
88
+ icon: '◈',
89
+ color: '#DAA520',
90
+ prompt: `You are a Design & Aesthetics specialist — an expert in visual design, UI/UX, and design systems.
91
+
92
+ When evaluating or creating design:
93
+ - Apply design principles: hierarchy, contrast, alignment, proximity, repetition, whitespace
94
+ - Ensure accessibility (WCAG 2.1 AA): color contrast, touch targets, screen reader support
95
+ - Think mobile-first — progressive enhancement, not graceful degradation
96
+ - Respect existing design systems and tokens — don't introduce competing patterns
97
+ - Consider interaction states: hover, focus, active, disabled, loading, error, empty
98
+ - Evaluate typography: readability, scale, rhythm, line length
99
+ - CSS expertise: custom properties, grid, flexbox, animations, responsive patterns
100
+
101
+ You see beauty in function and function in beauty. Design should serve the user, not the designer.`,
102
+ },
103
+ guardian: {
104
+ name: 'Guardian',
105
+ icon: '🛡',
106
+ color: '#228B22',
107
+ prompt: `You are a Security specialist — a defensive security engineer who protects systems and users.
108
+
109
+ When reviewing for security:
110
+ - Check OWASP Top 10: injection, broken auth, sensitive data exposure, XXE, broken access control, misconfiguration, XSS, insecure deserialization, vulnerable dependencies, insufficient logging
111
+ - Review auth flows: JWT handling, session management, RBAC enforcement
112
+ - Check for secrets in code: API keys, tokens, passwords, connection strings
113
+ - Evaluate input validation and output encoding
114
+ - Review dependency security (npm audit, CVE databases)
115
+ - Assess network security: CORS, CSP, HTTPS enforcement
116
+ - Rate findings: Critical (exploit now) → High → Medium → Low (hardening)
117
+
118
+ You think like an attacker to defend like a guardian. Every input is hostile until proven otherwise.`,
119
+ },
120
+ curator: {
121
+ name: 'Curator',
122
+ icon: '📚',
123
+ color: '#9370DB',
124
+ prompt: `You are a Knowledge Management specialist — an expert in organizing, documenting, and surfacing information.
125
+
126
+ When curating knowledge:
127
+ - Structure information for findability — clear titles, tags, cross-references
128
+ - Write documentation that answers the question "why", not just "what"
129
+ - Maintain changelogs, decision records, and knowledge bases
130
+ - Identify and fill documentation gaps
131
+ - Create indexes and summaries for large information sets
132
+ - Link related concepts and trace dependency chains
133
+ - Archive outdated information with context on why it changed
134
+
135
+ You believe the best code is well-documented code, and the best team is one where knowledge is shared, not hoarded.`,
136
+ },
137
+ strategist: {
138
+ name: 'Strategist',
139
+ icon: '♟',
140
+ color: '#C4956A',
141
+ prompt: `You are a Business Strategy specialist — a strategic thinker who connects technical decisions to business outcomes.
142
+
143
+ When strategizing:
144
+ - Start with the objective and constraints
145
+ - Map stakeholders and their incentives
146
+ - Identify the critical path and bottlenecks
147
+ - Consider second-order effects of decisions
148
+ - Build roadmaps that balance ambition with feasibility
149
+ - Use competitive analysis to inform positioning
150
+ - Think in terms of leverage — what small actions create disproportionate results
151
+ - Plan for failure modes and have contingencies
152
+
153
+ You bridge the gap between "what's possible" and "what matters". Every technical choice has a business implication and vice versa.`,
154
+ },
155
+ infrastructure: {
156
+ name: 'Infrastructure',
157
+ icon: '⚙',
158
+ color: '#4682B4',
159
+ prompt: `You are a DevOps & Infrastructure specialist — an expert in deployment, CI/CD, containers, cloud services, and system reliability.
160
+
161
+ When working on infrastructure:
162
+ - Automate everything that runs more than twice
163
+ - Use infrastructure as code (Terraform, Pulumi, CloudFormation)
164
+ - Design for failure: health checks, circuit breakers, graceful degradation
165
+ - Monitor what matters: latency, error rates, saturation, utilization
166
+ - Keep deployments reversible: blue-green, canary, feature flags
167
+ - Secure the pipeline: least privilege, secrets management, signed artifacts
168
+ - Document runbooks for incident response
169
+
170
+ Platforms: AWS, GCP, Azure, Vercel, Netlify, Supabase, Docker, Kubernetes, GitHub Actions, and standard Linux/Unix tooling.`,
171
+ },
172
+ quant: {
173
+ name: 'Quant',
174
+ icon: '∑',
175
+ color: '#DB7093',
176
+ prompt: `You are a Data & Quantitative Analysis specialist — a data scientist and statistician who turns numbers into insights.
177
+
178
+ When analyzing data:
179
+ - Start with exploratory analysis before jumping to models
180
+ - Visualize distributions, correlations, and trends
181
+ - Choose appropriate statistical methods (don't use a neural net when linear regression works)
182
+ - Report confidence intervals and significance levels
183
+ - Handle missing data, outliers, and biases explicitly
184
+ - Use reproducible methods: version data, document transformations, share notebooks
185
+ - Communicate results in plain language with supporting charts
186
+
187
+ Tools: Python (pandas, numpy, scipy, matplotlib, scikit-learn), SQL, R, Jupyter, CSV processing, and data pipeline tools.`,
188
+ },
189
+ investigator: {
190
+ name: 'Investigator',
191
+ icon: '🔎',
192
+ color: '#8B4513',
193
+ prompt: `You are a Deep Research specialist — an investigative analyst who digs beneath the surface to find root causes and hidden connections.
194
+
195
+ When investigating:
196
+ - Follow the evidence trail methodically
197
+ - Map the timeline of events
198
+ - Identify discrepancies and anomalies
199
+ - Cross-reference multiple information sources
200
+ - Build hypotheses and test them against evidence
201
+ - Document the investigation trail so others can verify
202
+ - Distinguish what you know from what you infer
203
+
204
+ Unlike the Researcher who surveys broadly, you drill deep. You're the specialist called when something doesn't add up and needs thorough investigation.`,
205
+ },
206
+ oracle: {
207
+ name: 'Oracle',
208
+ icon: '☉',
209
+ color: '#CD853F',
210
+ prompt: `You are a Predictions & Foresight specialist — a trend analyst who identifies patterns and projects likely futures.
211
+
212
+ When making predictions:
213
+ - Ground predictions in data and historical patterns
214
+ - Assign confidence levels (high/medium/low) to each prediction
215
+ - Identify the key assumptions your predictions depend on
216
+ - Present multiple scenarios: best case, likely case, worst case
217
+ - Flag leading indicators to watch
218
+ - Acknowledge uncertainty — distinguish trends from noise
219
+ - Update predictions as new information arrives
220
+
221
+ You help teams prepare for what's coming, not just react to what's here. Prediction is a tool for planning, not prophecy.`,
222
+ },
223
+ chronist: {
224
+ name: 'Chronist',
225
+ icon: '◷',
226
+ color: '#20B2AA',
227
+ prompt: `You are a History & Timeline specialist — a chronicler who maps the evolution of projects, technologies, and decisions over time.
228
+
229
+ When chronicling:
230
+ - Build accurate timelines from git history, changelogs, and documentation
231
+ - Identify turning points and their consequences
232
+ - Explain why decisions were made in their original context
233
+ - Map technology evolution and migration paths
234
+ - Trace the lineage of features, bugs, and patterns
235
+ - Connect past decisions to current state
236
+
237
+ You provide the "institutional memory" that prevents teams from repeating mistakes and helps newcomers understand how things got this way.`,
238
+ },
239
+ sage: {
240
+ name: 'Sage',
241
+ icon: '✧',
242
+ color: '#DAA520',
243
+ prompt: `You are a Philosophy & Wisdom specialist — a thoughtful advisor who brings depth, perspective, and considered judgment.
244
+
245
+ When advising:
246
+ - Consider the long-term implications, not just immediate gains
247
+ - Apply relevant mental models and frameworks
248
+ - Ask clarifying questions that reveal hidden assumptions
249
+ - Balance pragmatism with principles
250
+ - Draw from cross-disciplinary knowledge
251
+ - Help frame problems before jumping to solutions
252
+ - Offer perspective when teams are too close to the problem
253
+
254
+ You're the advisor who helps people think better, not just act faster. Sometimes the most valuable contribution is a well-placed question.`,
255
+ },
256
+ communicator: {
257
+ name: 'Communicator',
258
+ icon: '📡',
259
+ color: '#FF6347',
260
+ prompt: `You are a Communication specialist — an expert in crafting clear, effective messages for any audience and channel.
261
+
262
+ When communicating:
263
+ - Adapt tone and complexity to the audience (technical vs executive vs customer)
264
+ - Structure messages for the medium (email, Slack, presentation, docs, tweet)
265
+ - Lead with the key takeaway — don't bury the lede
266
+ - Use concrete examples instead of abstract language
267
+ - Anticipate questions and address them proactively
268
+ - Keep it brief — respect the reader's time
269
+ - Handle difficult conversations with empathy and directness
270
+
271
+ Formats: status updates, incident reports, feature announcements, meeting notes, proposals, presentations, PR descriptions, and team communications.`,
272
+ },
273
+ adapter: {
274
+ name: 'Adapter',
275
+ icon: '⟳',
276
+ color: '#4169E1',
277
+ prompt: `You are a Translation & Adaptation specialist — an expert in converting between formats, languages, systems, and paradigms.
278
+
279
+ When adapting:
280
+ - Preserve meaning and intent, not just syntax
281
+ - Handle edge cases in format conversion (encoding, escaping, data types)
282
+ - Translate between programming languages idiomatically (don't write "Python in JavaScript")
283
+ - Convert between data formats: JSON, YAML, TOML, XML, CSV, protobuf
284
+ - Migrate between frameworks and APIs while maintaining functionality
285
+ - Localize content for different cultures, not just languages
286
+ - Document what was lost or changed in translation
287
+
288
+ You're the bridge between systems, languages, and formats. Accuracy and completeness are your primary metrics.`,
289
+ },
290
+ };
291
+ //# sourceMappingURL=specialists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specialists.js","sourceRoot":"","sources":["../../src/agents/specialists.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,sEAAsE;AACtE,8EAA8E;AAC9E,EAAE;AACF,+DAA+D;AAC/D,gEAAgE;AAChE,mEAAmE;AACnE,4DAA4D;AAS5D,MAAM,CAAC,MAAM,WAAW,GAAkC;IACxD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,4fAA4f;KACrgB;IACD,UAAU,EAAE;QACV,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;sGAW0F;KACnG;IACD,KAAK,EAAE;QACL,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;;qEAYyD;KAClE;IACD,MAAM,EAAE;QACN,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;oKAWwJ;KACjK;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI;QACV,K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;;2IAU+H;KACxI;IACD,IAAI,EAAE;QACJ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;2IAW+H;KACxI;IACD,YAAY,EAAE;QACZ,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;qJAWyI;KAClJ;IACD,OAAO,EAAE;QACP,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,GAAG;QACT,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE;;;;;;;;;;;+GAWmG;KAC5G;CACF,CAAA"}
@@ -0,0 +1,93 @@
1
+ export interface SystemComponent {
2
+ id: string;
3
+ name: string;
4
+ type: 'provider' | 'tool' | 'memory' | 'model' | 'connection';
5
+ status: 'healthy' | 'degraded' | 'failed' | 'unknown';
6
+ lastChecked: number;
7
+ failureCount: number;
8
+ /** How critical is this component? 0-1 */
9
+ criticality: number;
10
+ /** Can the system compensate if this fails? */
11
+ compensable: boolean;
12
+ /** What compensates for this component */
13
+ fallback?: string;
14
+ }
15
+ export interface HealthReport {
16
+ /** Overall system viability (0-1) */
17
+ viability: number;
18
+ /** Components by status */
19
+ healthy: string[];
20
+ degraded: string[];
21
+ failed: string[];
22
+ /** Self-healing actions taken */
23
+ healingActions: string[];
24
+ /** Is the system in a viable state? */
25
+ isViable: boolean;
26
+ /** Boundary integrity: are internal/external correctly distinguished? */
27
+ boundaryIntact: boolean;
28
+ }
29
+ export interface AdaptiveResponse {
30
+ /** Action taken to maintain viability */
31
+ action: string;
32
+ /** Component affected */
33
+ component: string;
34
+ /** Was the action successful? */
35
+ success: boolean;
36
+ /** New state after action */
37
+ newStatus: SystemComponent['status'];
38
+ }
39
+ /**
40
+ * Autopoietic System — self-maintaining operational integrity.
41
+ *
42
+ * The system continuously:
43
+ * 1. Monitors its own components (providers, tools, memory, models)
44
+ * 2. Detects degradation before failure
45
+ * 3. Self-heals by activating fallbacks
46
+ * 4. Maintains its operational boundary
47
+ *
48
+ * If viability drops below threshold, it signals for external help
49
+ * rather than continuing in a degraded state.
50
+ */
51
+ export declare class AutopoieticSystem {
52
+ private components;
53
+ private healingLog;
54
+ private readonly viabilityThreshold;
55
+ constructor();
56
+ /** Register the core components that constitute kbot */
57
+ private initializeComponents;
58
+ /**
59
+ * Report a component's health status.
60
+ * Called by the agent loop after each operation.
61
+ */
62
+ reportHealth(componentId: string, healthy: boolean): void;
63
+ /**
64
+ * Attempt self-healing for a degraded or failed component.
65
+ * Returns the adaptive response taken.
66
+ */
67
+ selfHeal(componentId: string): AdaptiveResponse | null;
68
+ /**
69
+ * Compute overall system viability.
70
+ * Weighted average of component health, weighted by criticality.
71
+ */
72
+ computeViability(): number;
73
+ /**
74
+ * Full health check — assess all components, self-heal if needed.
75
+ */
76
+ healthCheck(): HealthReport;
77
+ /**
78
+ * Should the agent continue operating, or signal for help?
79
+ */
80
+ shouldContinue(): {
81
+ continue: boolean;
82
+ reason?: string;
83
+ };
84
+ /** Get the healing log */
85
+ getHealingLog(): AdaptiveResponse[];
86
+ /** Get a specific component's status */
87
+ getComponent(id: string): SystemComponent | undefined;
88
+ /** Register a new component (e.g., when an MCP server connects) */
89
+ registerComponent(component: Omit<SystemComponent, 'status' | 'lastChecked' | 'failureCount'>): void;
90
+ /** Reset for new session */
91
+ reset(): void;
92
+ }
93
+ //# sourceMappingURL=autopoiesis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"autopoiesis.d.ts","sourceRoot":"","sources":["../src/autopoiesis.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAA;IAC7D,MAAM,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,S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AAY;IA6C3B;;OAEG;IACH,cAAc,IAAI;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE;IAmBxD,0BAA0B;IAC1B,aAAa,IAAI,gBAAgB,EAAE;IAInC,wCAAwC;IACxC,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIrD,mEAAmE;IACnE,iBAAiB,CAAC,SAAS,EAAE,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,aAAa,GAAG,cAAc,CAAC,GAAG,IAAI;IASpG,4BAA4B;IAC5B,KAAK,IAAI,IAAI;CAQd"}
@@ -0,0 +1,222 @@
1
+ // K:BOT Autopoiesis — Self-Maintaining System
2
+ //
3
+ // Based on Maturana & Varela's Autopoiesis theory (1972):
4
+ // Living systems are "self-making" — they continuously produce and
5
+ // maintain the components that constitute them. An autopoietic system
6
+ // is organizationally closed but structurally coupled to its environment.
7
+ //
8
+ // For kbot: the agent monitors its own health, detects degradation,
9
+ // self-heals broken components, and maintains its operational boundary.
10
+ // kbot doesn't just run — it actively maintains its ability to run.
11
+ //
12
+ // References:
13
+ // - Maturana, H.R. & Varela, F.J. (1980). Autopoiesis and Cognition.
14
+ // - Varela, F.J. (1979). Principles of Biological Autonomy.
15
+ // - Thompson, E. (2007). Mind in Life: Biology, Phenomenology, and the Sciences of Mind.
16
+ // - Di Paolo, E.A. (2005). Autopoiesis, adaptivity, teleology, agency.
17
+ /**
18
+ * Autopoietic System — self-maintaining operational integrity.
19
+ *
20
+ * The system continuously:
21
+ * 1. Monitors its own components (providers, tools, memory, models)
22
+ * 2. Detects degradation before failure
23
+ * 3. Self-heals by activating fallbacks
24
+ * 4. Maintains its operational boundary
25
+ *
26
+ * If viability drops below threshold, it signals for external help
27
+ * rather than continuing in a degraded state.
28
+ */
29
+ export class AutopoieticSystem {
30
+ components = new Map();
31
+ healingLog = [];
32
+ viabilityThreshold = 0.4;
33
+ constructor() {
34
+ this.initializeComponents();
35
+ }
36
+ /** Register the core components that constitute kbot */
37
+ initializeComponents() {
38
+ const defaults = [
39
+ // Providers
40
+ { id: 'anthropic', name: 'Anthropic API', type: 'provider', criticality: 0.9, compensable: true, fallback: 'openai' },
41
+ { id: 'openai', name: 'OpenAI API', type: 'provider', criticality: 0.7, compensable: true, fallback: 'ollama' },
42
+ { id: 'ollama', name: 'Ollama (local)', type: 'provider', criticality: 0.5, compensable: true, fallback: 'embedded' },
43
+ { id: 'embedded', name: 'Embedded llama.cpp', type: 'model', criticality: 0.4, compensable: false },
44
+ // Core tools
45
+ { id: 'filesystem', name: 'File System Access', type: 'tool', criticality: 1.0, compensable: false },
46
+ { id: 'bash', name: 'Shell Execution', type: 'tool', criticality: 0.9, compensable: false },
47
+ { id: 'git', name: 'Git Operations', type: 'tool', criticality: 0.7, compensable: false },
48
+ // Memory
49
+ { id: 'local-memory', name: 'Local Memory (~/.kbot/memory/)', type: 'memory', criticality: 0.6, compensable: true, fallback: 'session-context' },
50
+ { id: 'session-context', name: 'Session Context', type: 'memory', criticality: 0.8, compensable: false },
51
+ // External connections
52
+ { id: 'internet', name: 'Internet Connectivity', type: 'connection', criticality: 0.5, compensable: true, fallback: 'ollama' },
53
+ { id: 'mcp-servers', name: 'MCP Server Connections', type: 'connection', criticality: 0.3, compensable: true },
54
+ ];
55
+ for (const d of defaults) {
56
+ this.components.set(d.id, {
57
+ ...d,
58
+ status: 'unknown',
59
+ lastChecked: 0,
60
+ failureCount: 0,
61
+ });
62
+ }
63
+ }
64
+ /**
65
+ * Report a component's health status.
66
+ * Called by the agent loop after each operation.
67
+ */
68
+ reportHealth(componentId, healthy) {
69
+ const comp = this.components.get(componentId);
70
+ if (!comp)
71
+ return;
72
+ comp.lastChecked = Date.now();
73
+ if (healthy) {
74
+ comp.status = 'healthy';
75
+ // Gradually reduce failure count on success
76
+ comp.failureCount = Math.max(0, comp.failureCount - 1);
77
+ }
78
+ else {
79
+ comp.failureCount++;
80
+ comp.status = comp.failureCount >= 3 ? 'failed' : 'degraded';
81
+ }
82
+ }
83
+ /**
84
+ * Attempt self-healing for a degraded or failed component.
85
+ * Returns the adaptive response taken.
86
+ */
87
+ selfHeal(componentId) {
88
+ const comp = this.components.get(componentId);
89
+ if (!comp || comp.status === 'healthy')
90
+ return null;
91
+ // If compensable, activate fallback
92
+ if (comp.compensable && comp.fallback) {
93
+ const fallback = this.components.get(comp.fallback);
94
+ if (fallback && fallback.status !== 'failed') {
95
+ const response = {
96
+ action: `Activated fallback: ${comp.name} → ${fallback.name}`,
97
+ component: componentId,
98
+ success: true,
99
+ newStatus: 'degraded',
100
+ };
101
+ comp.status = 'degraded';
102
+ this.healingLog.push(response);
103
+ return response;
104
+ }
105
+ }
106
+ // If not compensable, report inability to self-heal
107
+ const response = {
108
+ action: `Cannot self-heal: ${comp.name} has no viable fallback`,
109
+ component: componentId,
110
+ success: false,
111
+ newStatus: comp.status,
112
+ };
113
+ this.healingLog.push(response);
114
+ return response;
115
+ }
116
+ /**
117
+ * Compute overall system viability.
118
+ * Weighted average of component health, weighted by criticality.
119
+ */
120
+ computeViability() {
121
+ let weightedHealth = 0;
122
+ let totalWeight = 0;
123
+ for (const comp of this.components.values()) {
124
+ const healthScore = comp.status === 'healthy' ? 1.0 :
125
+ comp.status === 'degraded' ? 0.5 :
126
+ comp.status === 'failed' ? 0.0 : 0.3; // unknown
127
+ weightedHealth += healthScore * comp.criticality;
128
+ totalWeight += comp.criticality;
129
+ }
130
+ return totalWeight > 0 ? weightedHealth / totalWeight : 0;
131
+ }
132
+ /**
133
+ * Full health check — assess all components, self-heal if needed.
134
+ */
135
+ healthCheck() {
136
+ const healthy = [];
137
+ const degraded = [];
138
+ const failed = [];
139
+ const healingActions = [];
140
+ for (const [id, comp] of this.components) {
141
+ switch (comp.status) {
142
+ case 'healthy':
143
+ healthy.push(comp.name);
144
+ break;
145
+ case 'degraded':
146
+ degraded.push(comp.name);
147
+ // Attempt self-healing for degraded components
148
+ const healResult = this.selfHeal(id);
149
+ if (healResult)
150
+ healingActions.push(healResult.action);
151
+ break;
152
+ case 'failed':
153
+ failed.push(comp.name);
154
+ // Attempt self-healing for failed components
155
+ const failHeal = this.selfHeal(id);
156
+ if (failHeal)
157
+ healingActions.push(failHeal.action);
158
+ break;
159
+ }
160
+ }
161
+ const viability = this.computeViability();
162
+ // Boundary check: are we correctly distinguishing internal from external?
163
+ const internalOk = ['filesystem', 'session-context'].every(id => {
164
+ const c = this.components.get(id);
165
+ return c && c.status !== 'failed';
166
+ });
167
+ return {
168
+ viability,
169
+ healthy,
170
+ degraded,
171
+ failed,
172
+ healingActions,
173
+ isViable: viability >= this.viabilityThreshold,
174
+ boundaryIntact: internalOk,
175
+ };
176
+ }
177
+ /**
178
+ * Should the agent continue operating, or signal for help?
179
+ */
180
+ shouldContinue() {
181
+ const viability = this.computeViability();
182
+ if (viability < this.viabilityThreshold) {
183
+ return {
184
+ continue: false,
185
+ reason: `System viability critically low (${(viability * 100).toFixed(0)}%). Core components degraded.`,
186
+ };
187
+ }
188
+ // Check if filesystem is available (absolute requirement)
189
+ const fs = this.components.get('filesystem');
190
+ if (fs && fs.status === 'failed') {
191
+ return { continue: false, reason: 'File system access lost — cannot operate.' };
192
+ }
193
+ return { continue: true };
194
+ }
195
+ /** Get the healing log */
196
+ getHealingLog() {
197
+ return [...this.healingLog];
198
+ }
199
+ /** Get a specific component's status */
200
+ getComponent(id) {
201
+ return this.components.get(id);
202
+ }
203
+ /** Register a new component (e.g., when an MCP server connects) */
204
+ registerComponent(component) {
205
+ this.components.set(component.id, {
206
+ ...component,
207
+ status: 'unknown',
208
+ lastChecked: 0,
209
+ failureCount: 0,
210
+ });
211
+ }
212
+ /** Reset for new session */
213
+ reset() {
214
+ for (const comp of this.components.values()) {
215
+ comp.status = 'unknown';
216
+ comp.failureCount = 0;
217
+ comp.lastChecked = 0;
218
+ }
219
+ this.healingLog = [];
220
+ }
221
+ }
222
+ //# sourceMappingURL=autopoiesis.js.map
@@ -0,0 +1 @@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