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
+27 -1
View File
@@ -1,6 +1,7 @@
import type { Message } from '../models/types.js';
import type { AgentOrchestrator } from '../backends/native/orchestrator.js';
import { COMPACTION_SYSTEM_PROMPT } from '../backends/native/prompts.js';
import type { MemoryStore } from '../memory/store.js';
import { COMPACTION_SYSTEM_PROMPT, MEMORY_EXTRACTION_PROMPT } from '../backends/native/prompts.js';
import { estimateMessageTokens } from './tokens.js';
export interface CompactionConfig {
@@ -33,6 +34,8 @@ export async function compactHistory(opts: {
messages: Message[];
orchestrator: AgentOrchestrator;
config: CompactionConfig;
memoryStore?: MemoryStore;
autoExtract?: boolean;
}): Promise<CompactionResult> {
const { messages, orchestrator, config } = opts;
@@ -65,6 +68,29 @@ export async function compactHistory(opts: {
content: '[Summary of earlier conversation]\n\n' + result.content,
};
// Phase 2: Extract persistent facts and append to memory (if enabled)
if (opts.memoryStore && opts.autoExtract !== false) {
try {
const extractionTier = orchestrator.getDelegationTier('memory_extraction');
const extraction = await orchestrator.delegate({
tier: extractionTier,
systemPrompt: MEMORY_EXTRACTION_PROMPT,
message: `Extract persistent facts from this conversation:\n\n${formattedConversation}`,
maxTokens: 512,
});
// Only write if the extraction produced meaningful content
const extractedContent = extraction.content.trim();
if (extractedContent.length > 0 && !extractedContent.toLowerCase().includes('no facts')) {
opts.memoryStore.write('global', extractedContent, 'append');
console.log(`[Flynn:memory] Extracted ${extractedContent.length} chars of facts to global memory`);
}
} catch (error) {
// Memory extraction is best-effort — don't fail compaction if it errors
console.warn('[Flynn:memory] Failed to extract facts during compaction:', error);
}
}
return {
messages: [summaryMessage, ...toKeep],
compactedCount: toCompact.length,