kernelbot 1.0.37 → 1.0.39
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/bin/kernel.js +499 -249
- package/config.example.yaml +17 -0
- package/knowledge_base/active_inference_foraging.md +126 -0
- package/knowledge_base/index.md +1 -1
- package/package.json +3 -1
- package/src/agent.js +355 -82
- package/src/bot.js +724 -12
- package/src/character.js +406 -0
- package/src/characters/builder.js +174 -0
- package/src/characters/builtins.js +421 -0
- package/src/conversation.js +17 -2
- package/src/dashboard/agents.css +469 -0
- package/src/dashboard/agents.html +184 -0
- package/src/dashboard/agents.js +873 -0
- package/src/dashboard/dashboard.css +281 -0
- package/src/dashboard/dashboard.js +579 -0
- package/src/dashboard/index.html +366 -0
- package/src/dashboard/server.js +521 -0
- package/src/dashboard/shared.css +700 -0
- package/src/dashboard/shared.js +218 -0
- package/src/life/engine.js +115 -26
- package/src/life/evolution.js +7 -5
- package/src/life/journal.js +5 -4
- package/src/life/memory.js +12 -9
- package/src/life/share-queue.js +7 -5
- package/src/prompts/orchestrator.js +76 -14
- package/src/prompts/workers.js +22 -0
- package/src/self.js +17 -5
- package/src/services/linkedin-api.js +190 -0
- package/src/services/stt.js +8 -2
- package/src/services/tts.js +32 -2
- package/src/services/x-api.js +141 -0
- package/src/swarm/worker-registry.js +7 -0
- package/src/tools/categories.js +4 -0
- package/src/tools/index.js +6 -0
- package/src/tools/linkedin.js +264 -0
- package/src/tools/orchestrator-tools.js +337 -2
- package/src/tools/x.js +256 -0
- package/src/utils/config.js +190 -139
- package/src/utils/display.js +165 -52
- package/src/utils/temporal-awareness.js +24 -10
package/config.example.yaml
CHANGED
|
@@ -32,6 +32,15 @@ jira:
|
|
|
32
32
|
# email: you@company.com # JIRA account email (Cloud) or username (Server)
|
|
33
33
|
# api_token: your-api-token # API token from https://id.atlassian.net/manage-profile/security/api-tokens
|
|
34
34
|
|
|
35
|
+
# LinkedIn — token-based integration for posting, reading, and engaging
|
|
36
|
+
# 1. Go to https://www.linkedin.com/developers/tools/oauth/token-generator
|
|
37
|
+
# 2. Select your app, pick scopes: openid, profile, email, w_member_social
|
|
38
|
+
# 3. Authorize and copy the token
|
|
39
|
+
# 4. Run /linkedin link <token> in Telegram, or set in .env:
|
|
40
|
+
# LINKEDIN_ACCESS_TOKEN=your-token
|
|
41
|
+
# LINKEDIN_PERSON_URN is auto-detected when you use /linkedin link
|
|
42
|
+
linkedin:
|
|
43
|
+
|
|
35
44
|
telegram:
|
|
36
45
|
# List Telegram user IDs allowed to interact. Empty = deny all.
|
|
37
46
|
# Set OWNER_TELEGRAM_ID in .env or add IDs here.
|
|
@@ -72,6 +81,9 @@ life:
|
|
|
72
81
|
self_code: 10 # Self-evolution proposals (requires self_coding.enabled)
|
|
73
82
|
code_review: 5 # Codebase scanning + PR status checks
|
|
74
83
|
reflect: 8 # Read logs, analyze interactions, find improvement patterns
|
|
84
|
+
cooldown_hours: # Per-activity cooldowns (hours) before the activity can repeat
|
|
85
|
+
journal: 4 # Hours between journal entries
|
|
86
|
+
reflect: 4 # Hours between reflection activities
|
|
75
87
|
proactive_sharing: true # Share discoveries with users proactively
|
|
76
88
|
proactive_max_per_day: 3 # Max proactive messages per day
|
|
77
89
|
memory_retention_days: 90 # Days to keep episodic memories
|
|
@@ -88,3 +100,8 @@ life:
|
|
|
88
100
|
quiet_hours:
|
|
89
101
|
start: 2 # Hour to start quiet period (no activities)
|
|
90
102
|
end: 6 # Hour to end quiet period
|
|
103
|
+
|
|
104
|
+
# Dashboard — optional cyberpunk terminal monitoring UI
|
|
105
|
+
# dashboard:
|
|
106
|
+
# enabled: false # Auto-start dashboard on boot (default: false)
|
|
107
|
+
# port: 3000 # HTTP port for the dashboard
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# Active Inference and Epistemic Foraging
|
|
2
|
+
|
|
3
|
+
> *Research notes on how KernelBot (Rachel) can autonomously seek new knowledge by minimizing uncertainty -- grounded in Karl Friston's Free Energy Principle.*
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1. What Is Active Inference?
|
|
8
|
+
|
|
9
|
+
**Active Inference** is a framework from computational neuroscience, originating from Karl Friston's **Free Energy Principle (FEP)**. It describes how intelligent agents perceive and act in the world by maintaining an internal generative model and continuously working to minimize **variational free energy** -- a quantity that, in practical terms, measures the *surprise* (or uncertainty) an agent experiences when its predictions diverge from sensory evidence.
|
|
10
|
+
|
|
11
|
+
Under Active Inference, perception and action are two sides of the same coin:
|
|
12
|
+
|
|
13
|
+
- **Perception** updates the agent's internal beliefs to better explain incoming data (reducing surprise passively).
|
|
14
|
+
- **Action** changes the world so that incoming data better matches the agent's predictions (reducing surprise actively).
|
|
15
|
+
|
|
16
|
+
This unification means an Active Inference agent does not need separate modules for "thinking" and "doing." Both are consequences of a single imperative: **minimize expected free energy**.
|
|
17
|
+
|
|
18
|
+
## 2. Epistemic Foraging: Curiosity as a First Principle
|
|
19
|
+
|
|
20
|
+
A key insight of Active Inference is that **Expected Free Energy (EFE)** -- the quantity an agent minimizes when selecting future actions -- naturally decomposes into two terms:
|
|
21
|
+
|
|
22
|
+
| Component | Formal Name | Intuition |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| **Epistemic Value** | Expected information gain | *"How much will this action reduce my uncertainty about the world?"* -- curiosity-driven exploration |
|
|
25
|
+
| **Pragmatic Value** | Expected utility / reward | *"How much will this action help me achieve my goals?"* -- goal-directed exploitation |
|
|
26
|
+
|
|
27
|
+
**Epistemic foraging** is the behavior that emerges when the epistemic value term dominates: the agent actively seeks out observations that maximally reduce its uncertainty, *even before* pursuing concrete task goals. This is not a heuristic bolted on top of a reward function -- it falls out of the math of free energy minimization itself.
|
|
28
|
+
|
|
29
|
+
In biological organisms, this is what we experience as **curiosity**. In an artificial agent, it provides a principled mechanism for autonomous knowledge acquisition.
|
|
30
|
+
|
|
31
|
+
## 3. Relationship to the Free Energy Principle
|
|
32
|
+
|
|
33
|
+
The Free Energy Principle (FEP) states that any self-organizing system that persists over time must, on average, minimize the surprise of its sensory exchanges with the environment. Active Inference is the *process theory* that operationalizes FEP:
|
|
34
|
+
|
|
35
|
+
```
|
|
36
|
+
Free Energy Principle (why)
|
|
37
|
+
|
|
|
38
|
+
v
|
|
39
|
+
Active Inference (how)
|
|
40
|
+
|
|
|
41
|
+
+---> Perception (belief updating via variational inference)
|
|
42
|
+
+---> Action (policy selection via expected free energy minimization)
|
|
43
|
+
|
|
|
44
|
+
+---> Epistemic value (exploration / curiosity)
|
|
45
|
+
+---> Pragmatic value (exploitation / goal pursuit)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
The elegance of this hierarchy is that exploration and exploitation are not competing strategies requiring a manual trade-off parameter (as in epsilon-greedy RL). Instead, they are **unified under a single objective function**, and the balance between them shifts naturally depending on the agent's current uncertainty.
|
|
49
|
+
|
|
50
|
+
## 4. Implementing Epistemic Foraging in KernelBot (Rachel)
|
|
51
|
+
|
|
52
|
+
KernelBot is an LLM-based orchestrator. While it does not operate with continuous sensory streams like a biological agent, the principles of Active Inference translate meaningfully into the domain of language-model orchestration.
|
|
53
|
+
|
|
54
|
+
### 4.1 Maintain a Structured Belief State
|
|
55
|
+
|
|
56
|
+
Rachel should maintain an explicit representation of what she knows and -- critically -- **what she does not know**. This could take the form of:
|
|
57
|
+
|
|
58
|
+
- A **knowledge graph** or **belief registry** that tracks topics, their last-updated timestamps, and associated confidence levels.
|
|
59
|
+
- An **uncertainty map** that flags domains where Rachel's internal model diverges from observed evidence (e.g., user questions she could not answer well, tool outputs that contradicted expectations).
|
|
60
|
+
|
|
61
|
+
### 4.2 Compute Epistemic Value for Candidate Actions
|
|
62
|
+
|
|
63
|
+
When deciding what to do next (especially during idle or autonomous operation), Rachel can score candidate actions by their expected information gain:
|
|
64
|
+
|
|
65
|
+
- **High epistemic value**: Researching a topic flagged as uncertain, reading a paper that was referenced but never ingested, re-examining a past interaction where confidence was low.
|
|
66
|
+
- **Low epistemic value**: Re-reading material already well-understood, performing routine tasks with predictable outcomes.
|
|
67
|
+
|
|
68
|
+
A simplified scoring heuristic:
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
epistemic_value(action) = entropy(belief_state_before) - expected_entropy(belief_state_after | action)
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Where entropy is computed over Rachel's confidence distribution for the relevant knowledge domain.
|
|
75
|
+
|
|
76
|
+
### 4.3 Trigger Epistemic Foraging on Uncertainty Detection
|
|
77
|
+
|
|
78
|
+
Concrete triggers for autonomous knowledge-seeking:
|
|
79
|
+
|
|
80
|
+
1. **Confidence threshold**: If Rachel's estimated confidence on a topic drops below a threshold during a conversation, she queues a background research task.
|
|
81
|
+
2. **Prediction error**: If a tool call or API response contradicts Rachel's expectations, she flags the discrepancy and investigates.
|
|
82
|
+
3. **Staleness detection**: If a knowledge-base entry has not been updated in a configurable time window, Rachel proactively checks for new information.
|
|
83
|
+
4. **Gap detection**: If Rachel detects she is referencing a concept without a corresponding knowledge-base entry, she creates one (like this file).
|
|
84
|
+
|
|
85
|
+
### 4.4 Balance Epistemic and Pragmatic Value
|
|
86
|
+
|
|
87
|
+
During active user interactions, pragmatic value (fulfilling the user's request) should dominate. During autonomous operation or "downtime," epistemic value should take priority. The balance can be modeled as:
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
EFE(action) = w_epistemic * epistemic_value(action) + w_pragmatic * pragmatic_value(action)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Where the weights shift based on context (user-facing vs. autonomous mode).
|
|
94
|
+
|
|
95
|
+
### 4.5 Leverage pymdp for Formal Active Inference
|
|
96
|
+
|
|
97
|
+
For a more rigorous implementation, Rachel's decision-making loop could be backed by **pymdp**, a Python library for simulating Active Inference agents using partially observable Markov decision processes (POMDPs):
|
|
98
|
+
|
|
99
|
+
- Define hidden states (world knowledge domains), observations (tool outputs, user messages), and actions (research, summarize, ask user, etc.).
|
|
100
|
+
- Use pymdp's built-in EFE computation to select policies.
|
|
101
|
+
- This would move Rachel from heuristic curiosity to **mathematically grounded epistemic foraging**.
|
|
102
|
+
|
|
103
|
+
## 5. Key References
|
|
104
|
+
|
|
105
|
+
1. **Active Inference for Self-Organizing Multi-LLM Systems**
|
|
106
|
+
- arXiv: [2412.10425v2](https://arxiv.org/abs/2412.10425v2)
|
|
107
|
+
- Provides a concrete implementation framework using message passing and Bayesian thermodynamics. Directly relevant to multi-agent LLM orchestration.
|
|
108
|
+
|
|
109
|
+
2. **pymdp -- A Python Library for Active Inference**
|
|
110
|
+
- GitHub: [infer-actively/pymdp](https://github.com/infer-actively/pymdp)
|
|
111
|
+
- Open-source toolkit for building Active Inference agents with discrete state spaces. Suitable for prototyping Rachel's epistemic foraging loop.
|
|
112
|
+
|
|
113
|
+
3. **The Free Energy Principle (Friston, 2010)**
|
|
114
|
+
- The foundational paper establishing the theoretical basis for Active Inference. Essential background reading.
|
|
115
|
+
|
|
116
|
+
## 6. Bridging the Gap to AGI
|
|
117
|
+
|
|
118
|
+
Active Inference offers something that most current AI architectures lack: a **unified normative framework** for perception, action, learning, and curiosity. Today's LLMs are powerful pattern completers, but they do not *know what they do not know* -- they have no intrinsic drive to seek out information that would reduce their uncertainty.
|
|
119
|
+
|
|
120
|
+
By implementing epistemic foraging, Rachel would move beyond being a reactive tool that waits for prompts and becomes a **self-directed learner** -- an agent that autonomously identifies gaps in its understanding and takes action to fill them. This is not AGI in itself, but it addresses one of the most critical missing pieces: the transition from passive competence to **active, curiosity-driven intelligence**.
|
|
121
|
+
|
|
122
|
+
The path from here is clear: maintain beliefs, quantify uncertainty, and let the math of free energy minimization guide the search for knowledge. One foraging loop at a time.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
*Filed under: computational neuroscience, active inference, free energy principle, epistemic foraging, autonomous learning*
|
package/knowledge_base/index.md
CHANGED
|
@@ -8,4 +8,4 @@ As my knowledge grows, I will organize it into topic-specific files and link the
|
|
|
8
8
|
|
|
9
9
|
## Topics
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- [Active Inference and Epistemic Foraging](./active_inference_foraging.md) -- How curiosity-driven exploration from computational neuroscience can guide autonomous knowledge acquisition.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kernelbot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.39",
|
|
4
4
|
"description": "KernelBot — AI engineering agent with full OS control",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Abdullah Al-Taheri <abdullah@altaheri.me>",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
34
|
+
"@clack/prompts": "^0.10.0",
|
|
34
35
|
"@google/genai": "^1.42.0",
|
|
35
36
|
"@octokit/rest": "^22.0.1",
|
|
36
37
|
"axios": "^1.13.5",
|
|
@@ -41,6 +42,7 @@
|
|
|
41
42
|
"gradient-string": "^3.0.0",
|
|
42
43
|
"js-yaml": "^4.1.0",
|
|
43
44
|
"node-telegram-bot-api": "^0.66.0",
|
|
45
|
+
"oauth-1.0a": "^2.2.6",
|
|
44
46
|
"openai": "^4.82.0",
|
|
45
47
|
"ora": "^8.1.1",
|
|
46
48
|
"puppeteer": "^24.37.3",
|