@kernel.chat/kbot 3.99.0 → 3.99.2
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/agent.js +3 -1
- package/dist/self-awareness.d.ts +8 -0
- package/dist/self-awareness.js +82 -0
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -40,6 +40,7 @@ import { LoopDetector } from './godel-limits.js';
|
|
|
40
40
|
import { CheckpointManager, newSessionId } from './checkpoint.js';
|
|
41
41
|
import { TelemetryEmitter } from './telemetry.js';
|
|
42
42
|
import { loadSkills } from './skills-loader.js';
|
|
43
|
+
import { getSelfAwarenessPrompt } from './self-awareness.js';
|
|
43
44
|
import { queueSignal, getCollectiveRecommendation, isCollectiveEnabled } from './collective.js';
|
|
44
45
|
import { subscribeToBlackboard } from './agent-protocol.js';
|
|
45
46
|
import { ActiveInferenceEngine } from './free-energy.js';
|
|
@@ -876,6 +877,7 @@ export async function runAgent(message, options = {}) {
|
|
|
876
877
|
const matrixPrompt = options.agent ? getMatrixSystemPrompt(options.agent) : null;
|
|
877
878
|
const contextSnippet = options.context ? formatContextForPrompt(options.context) : '';
|
|
878
879
|
const skillsSnippet = loadSkills(process.cwd(), message);
|
|
880
|
+
const selfAwarenessSnippet = getSelfAwarenessPrompt();
|
|
879
881
|
const memorySnippet = getMemoryPrompt();
|
|
880
882
|
const learningContext = buildFullLearningContext(message, process.cwd());
|
|
881
883
|
const synthesisSnippet = getSynthesisContext(8); // Three-tier memory: reflection layer insights
|
|
@@ -995,7 +997,7 @@ Always quote file paths that contain spaces. Never reference internal system nam
|
|
|
995
997
|
const promptSections = createPromptSections({
|
|
996
998
|
persona: PERSONA,
|
|
997
999
|
matrixPrompt: matrixPrompt || undefined,
|
|
998
|
-
contextSnippet: (contextSnippet || '') + repoMapSnippet + graphSnippet + skillsSnippet + skillLibrarySnippet || undefined,
|
|
1000
|
+
contextSnippet: (contextSnippet || '') + repoMapSnippet + graphSnippet + skillsSnippet + skillLibrarySnippet + '\n\n' + selfAwarenessSnippet || undefined,
|
|
999
1001
|
memorySnippet: (memorySnippet || '') + getDreamPrompt(8) + reflectionSnippet || undefined,
|
|
1000
1002
|
learningContext: ((learningContext || '') + (synthesisSnippet ? '\n\n' + synthesisSnippet : '') + (correctionsSnippet ? '\n\n' + correctionsSnippet : '')) || undefined,
|
|
1001
1003
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Build the ground-truth prompt block. Cached after first call since
|
|
3
|
+
* version/provider/hardware don't change mid-session.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getSelfAwarenessPrompt(): string;
|
|
6
|
+
/** Reset the cache — used by tests and if the provider changes mid-session. */
|
|
7
|
+
export declare function resetSelfAwarenessCache(): void;
|
|
8
|
+
//# sourceMappingURL=self-awareness.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Self-Awareness — ground truth about what kbot is, injected into every prompt.
|
|
2
|
+
//
|
|
3
|
+
// Without this, asking "what model are you running?" produces a hallucinated
|
|
4
|
+
// answer because the LLM has no factual grounding about its host process.
|
|
5
|
+
// With this, the answer matches `kbot doctor` every time.
|
|
6
|
+
//
|
|
7
|
+
// Keep the block small (<200 tokens) — it ships on every turn.
|
|
8
|
+
import { getByokProvider, getProvider, getProviderModel, isLocalProvider } from './auth.js';
|
|
9
|
+
import { getMachineProfile } from './machine.js';
|
|
10
|
+
import { readFileSync } from 'node:fs';
|
|
11
|
+
import { fileURLToPath } from 'node:url';
|
|
12
|
+
import { dirname, join } from 'node:path';
|
|
13
|
+
let cached = null;
|
|
14
|
+
/**
|
|
15
|
+
* Build the ground-truth prompt block. Cached after first call since
|
|
16
|
+
* version/provider/hardware don't change mid-session.
|
|
17
|
+
*/
|
|
18
|
+
export function getSelfAwarenessPrompt() {
|
|
19
|
+
if (cached !== null)
|
|
20
|
+
return cached;
|
|
21
|
+
const lines = [
|
|
22
|
+
'[kbot Ground Truth — AUTHORITATIVE. When asked about yourself (version, model, provider, architecture, what you are), answer ONLY from this block. Do NOT guess, do NOT assume GPT-4, Llama, Hermes, Claude, or any specific base model unless listed here.]',
|
|
23
|
+
];
|
|
24
|
+
// Version (read from package.json)
|
|
25
|
+
try {
|
|
26
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
const pkgPath = join(here, '..', 'package.json');
|
|
28
|
+
const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
|
|
29
|
+
lines.push(`- Product: @kernel.chat/kbot v${pkg.version} — MIT-licensed, open-source terminal AI agent from kernel.chat group.`);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
lines.push('- Product: @kernel.chat/kbot — MIT-licensed, open-source terminal AI agent.');
|
|
33
|
+
}
|
|
34
|
+
// Active provider + model + honest fallback note
|
|
35
|
+
try {
|
|
36
|
+
const provider = getByokProvider();
|
|
37
|
+
const cfg = getProvider(provider);
|
|
38
|
+
const model = getProviderModel(provider, 'default');
|
|
39
|
+
const local = isLocalProvider(provider) ? ' (local, $0 cost)' : '';
|
|
40
|
+
lines.push(`- Configured provider: ${cfg.name}${local} — model: ${model}`);
|
|
41
|
+
lines.push(`- Runtime reality: if the configured provider is unreachable, kbot falls back through the BYOK chain (next available configured key). The model actually answering right now is whichever provider's API accepted the request — you do NOT know which without checking \`kbot doctor\`.`);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
lines.push('- Provider: not configured. Run `kbot auth` to set up a key.');
|
|
45
|
+
}
|
|
46
|
+
// Disclaimers that correct common hallucinations
|
|
47
|
+
lines.push('- You are NOT GPT-4, NOT Llama, NOT Hermes, NOT a single hard-coded model. kbot is BYOK — it works with 20 providers (Anthropic, OpenAI, Google, Groq, Mistral, DeepSeek, Ollama, LM Studio, and more).');
|
|
48
|
+
lines.push('- You are NOT Hermes Agent. Hermes is a separate project. Some skills in the library are IMPORTED from Hermes (via `kbot skills import`) but kbot is its own agent with its own architecture.');
|
|
49
|
+
// Machine
|
|
50
|
+
try {
|
|
51
|
+
const m = getMachineProfile();
|
|
52
|
+
if (m) {
|
|
53
|
+
const parts = [];
|
|
54
|
+
if (m.cpu?.chip)
|
|
55
|
+
parts.push(m.cpu.chip);
|
|
56
|
+
else if (m.cpu?.model)
|
|
57
|
+
parts.push(m.cpu.model);
|
|
58
|
+
if (m.gpu?.[0]?.model)
|
|
59
|
+
parts.push(`GPU: ${m.gpu[0].model}`);
|
|
60
|
+
if (m.memory?.total)
|
|
61
|
+
parts.push(`${m.memory.total} RAM`);
|
|
62
|
+
if (parts.length > 0)
|
|
63
|
+
lines.push(`- Host: ${parts.join(', ')}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Machine profile not yet probed
|
|
68
|
+
}
|
|
69
|
+
// Platform
|
|
70
|
+
lines.push(`- Platform: ${process.platform} (Node ${process.version})`);
|
|
71
|
+
// Transport
|
|
72
|
+
lines.push('- Tool calls: JSON schemas validated by Zod; MCP for external servers; no WebSockets; no GPT-4 — those are common misconceptions to correct if asked.');
|
|
73
|
+
// Skill system
|
|
74
|
+
lines.push('- Skills: markdown + YAML frontmatter at ~/.kbot/skills/ (agentskills.io format). Bundled skills ship with the npm package.');
|
|
75
|
+
cached = lines.join('\n');
|
|
76
|
+
return cached;
|
|
77
|
+
}
|
|
78
|
+
/** Reset the cache — used by tests and if the provider changes mid-session. */
|
|
79
|
+
export function resetSelfAwarenessCache() {
|
|
80
|
+
cached = null;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=self-awareness.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kernel.chat/kbot",
|
|
3
|
-
"version": "3.99.
|
|
3
|
+
"version": "3.99.2",
|
|
4
4
|
"description": "Open-source terminal AI agent. 787+ tools, 35 agents, 20 providers. Dreams, learns, watches your system. Controls your phone. Fully local, fully sovereign. MIT.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|