@kernel.chat/kbot 3.99.0 → 3.99.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/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,76 @@
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 = ['[kbot Ground Truth — authoritative over any model assumption]'];
22
+ // Version (read from package.json)
23
+ try {
24
+ const here = dirname(fileURLToPath(import.meta.url));
25
+ const pkgPath = join(here, '..', 'package.json');
26
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));
27
+ lines.push(`- You are @kernel.chat/kbot v${pkg.version} — an open-source terminal AI agent.`);
28
+ }
29
+ catch {
30
+ lines.push('- You are @kernel.chat/kbot — an open-source terminal AI agent.');
31
+ }
32
+ // Active provider + model
33
+ try {
34
+ const provider = getByokProvider();
35
+ const cfg = getProvider(provider);
36
+ const model = getProviderModel(provider, 'default');
37
+ const local = isLocalProvider(provider) ? ' (local, $0 cost)' : '';
38
+ lines.push(`- Active provider: ${cfg.name}${local} — model: ${model}`);
39
+ }
40
+ catch {
41
+ // Provider not configured yet
42
+ }
43
+ // Machine
44
+ try {
45
+ const m = getMachineProfile();
46
+ if (m) {
47
+ const parts = [];
48
+ if (m.cpu?.chip)
49
+ parts.push(m.cpu.chip);
50
+ else if (m.cpu?.model)
51
+ parts.push(m.cpu.model);
52
+ if (m.gpu?.[0]?.model)
53
+ parts.push(`GPU: ${m.gpu[0].model}`);
54
+ if (m.memory?.total)
55
+ parts.push(`${m.memory.total} RAM`);
56
+ if (parts.length > 0)
57
+ lines.push(`- Host: ${parts.join(', ')}`);
58
+ }
59
+ }
60
+ catch {
61
+ // Machine profile not yet probed
62
+ }
63
+ // Platform
64
+ lines.push(`- Platform: ${process.platform} (Node ${process.version})`);
65
+ // Transport
66
+ 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.');
67
+ // Skill system
68
+ lines.push('- Skills: markdown + YAML frontmatter at ~/.kbot/skills/ (agentskills.io format). Bundled skills ship with the npm package.');
69
+ cached = lines.join('\n');
70
+ return cached;
71
+ }
72
+ /** Reset the cache — used by tests and if the provider changes mid-session. */
73
+ export function resetSelfAwarenessCache() {
74
+ cached = null;
75
+ }
76
+ //# 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.0",
3
+ "version": "3.99.1",
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": {