feat: wire up all Phase 2-6 features into daemon and config

Integrate all new features into the shared infrastructure:
- Config schema: add memory, discord, slack, process, web_search schemas
- Daemon wiring: memory store init, tool registration, channel adapters
- Orchestrator: memory injection into system prompt, extraction on compaction
- Agent: add setSystemPrompt() for dynamic prompt updates
- Channel/tool index: export new adapters and tool factories
- Add @slack/bolt, discord.js, turndown, linkedom, @mozilla/readability deps
- Update state.json with Phase 3b completion (494 tests passing)
This commit is contained in:
William Valentin
2026-02-06 14:24:39 -08:00
parent 6d9e27a591
commit 7a35b22458
12 changed files with 1099 additions and 4 deletions
+4
View File
@@ -199,6 +199,10 @@ export class NativeAgent {
return this.currentTier;
}
setSystemPrompt(prompt: string): void {
this.systemPrompt = prompt;
}
setOnToolUse(callback: ((event: ToolUseEvent) => void) | undefined): void {
this.onToolUse = callback;
}
+30
View File
@@ -3,6 +3,7 @@ import type { ChatRequest, Message, TokenUsage } from '../../models/types.js';
import type { Session } from '../../session/index.js';
import type { ToolRegistry } from '../../tools/registry.js';
import type { ToolExecutor } from '../../tools/executor.js';
import type { MemoryStore } from '../../memory/store.js';
import { NativeAgent } from './agent.js';
import type { ToolUseEvent } from './agent.js';
import { shouldCompact } from '../../context/tokens.js';
@@ -64,6 +65,8 @@ export interface OrchestratorConfig {
modelName?: string;
/** Optional override for the context window size (in tokens). */
contextWindow?: number;
/** Optional memory store for injecting persistent memory into the system prompt. */
memoryStore?: MemoryStore;
}
// ── AgentOrchestrator ─────────────────────────────────────────────────
@@ -86,6 +89,8 @@ export class AgentOrchestrator {
private _compactionConfig?: CompactionConfig;
private _modelName?: string;
private _contextWindow?: number;
private _memoryStore?: MemoryStore;
private _systemPromptBase: string;
private _usageByTier: Map<string, TierUsageStats> = new Map();
constructor(config: OrchestratorConfig) {
@@ -97,6 +102,8 @@ export class AgentOrchestrator {
this._compactionConfig = config.compaction;
this._modelName = config.modelName;
this._contextWindow = config.contextWindow;
this._memoryStore = config.memoryStore;
this._systemPromptBase = config.systemPrompt;
// Create the primary NativeAgent for user-facing conversation
this._agent = new NativeAgent({
@@ -178,6 +185,7 @@ export class AgentOrchestrator {
* exceeds the context window threshold and compacts it before processing.
*/
async process(userMessage: string): Promise<string> {
this._injectMemoryContext();
await this.compactIfNeeded();
return this._agent.process(userMessage);
}
@@ -199,6 +207,7 @@ export class AgentOrchestrator {
messages,
orchestrator: this,
config,
memoryStore: this._memoryStore,
});
// If nothing was actually compacted, skip the replace
@@ -268,6 +277,27 @@ export class AgentOrchestrator {
// ── Private helpers ───────────────────────────────────────────────
/**
* Inject persistent memory context into the primary agent's system prompt.
* Reads from the memory store and appends relevant context to the base
* system prompt. If no memory store is configured or no memory content
* exists, restores the original base prompt.
*/
private _injectMemoryContext(): void {
if (!this._memoryStore) {
return;
}
const memoryContext = this._memoryStore.getContextForPrompt();
if (!memoryContext) {
this._agent.setSystemPrompt(this._systemPromptBase);
return;
}
const enrichedPrompt = `${this._systemPromptBase}\n\n# Memory Context\n\nThe following is your persistent memory. Use it to maintain continuity across sessions.\n\n${memoryContext}`;
this._agent.setSystemPrompt(enrichedPrompt);
}
/**
* Check whether automatic compaction should run, and if so, compact.
* Called before each `process()` call when compaction is configured.