feat(core): give Waggle its own database, apart from memory (P1.5)

Waggle kept its own tables in the memory database. Before the memory
engine can be replaced by mem0 they need a home of their own.

- add WaggleDB (<dataDir>/waggle.db). Automations, notifications, held
  actions, skill hashes, thumbs feedback, cost tracking, the profile card
  and awareness items live there. Their stores take a WaggleDB, so passing
  a memory database is a type error.
- the profile card and awareness items are now per scope ('personal' or
  'workspace:<id>') in one table each, instead of one table per .mind file
- on the first start, copy these tables from personal.mind and every
  workspace.mind (importLegacyMindData). The legacy files are only read,
  each scope is copied once and a table only while its target is empty.
- copy the logger, injection scanner, external-memory ingress guard,
  WorkspaceManager and the embedders from @waggle/hive-mind-core into
  @waggle/core, which now re-exports its own copies
- point the server, agent orchestrator and CLI at waggle.db; update the
  tests that seeded these tables in a memory database

ADR-0007 records the layout and the licensing question about the copied
files.
This commit is contained in:
shumeiko.it
2026-10-23 14:31:28 +02:00
parent 20567ecb10
commit ad2ca875cb
65 changed files with 6131 additions and 201 deletions

View File

@@ -10,7 +10,7 @@ import readline from 'node:readline';
import os from 'node:os';
import path from 'node:path';
import chalk from 'chalk';
import { MindDB, WaggleConfig, createLiteLLMEmbedder } from '@waggle/core';
import { MindDB, WaggleConfig, WaggleDB, createLiteLLMEmbedder } from '@waggle/core';
import { Orchestrator, ModelRouter, runAgentLoop, createSystemTools, createPlanTools, createGitTools, Workspace, ensureIdentity, loadSystemPromptWithOverrides, loadSkills, CostTracker, HookRegistry, loadHooksFromConfig, needsConfirmation } from '@waggle/agent';
import { parseCommand, COMMANDS } from './commands.js';
import { renderMarkdown } from './renderer.js';
@@ -101,7 +101,8 @@ export async function startRepl(options: ReplOptions = {}): Promise<void> {
const embedder = buildEmbedder(litellmUrl, litellmApiKey);
// Build orchestrator
const orchestrator = new Orchestrator({ db, embedder });
const waggleDb = WaggleDB.openInDataDir(waggleHome);
const orchestrator = new Orchestrator({ db, waggleDb, embedder });
// Ensure identity exists (first-run wizard)
ensureIdentity(orchestrator.getIdentity());
@@ -482,6 +483,7 @@ When asked about current events, products, releases, docs, or anything you're no
rl.on('close', () => {
db.close();
waggleDb.close();
process.exit(0);
});
@@ -490,6 +492,7 @@ When asked about current events, products, releases, docs, or anything you're no
console.log('');
console.log(chalk.dim('Goodbye!'));
db.close();
waggleDb.close();
process.exit(0);
});
}