diff --git a/package-lock.json b/package-lock.json index b5f9b08..c39e27e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -24800,7 +24800,6 @@ "license": "MIT", "dependencies": { "@huggingface/transformers": "^3.8.1", - "@waggle/hive-mind-core": "*", "@waggle/memory-contract": "*", "@waggle/shared": "*", "better-sqlite3": "^12.6.2", @@ -25096,8 +25095,8 @@ "fastify-plugin": "^5.0.0", "glob": "^13.0.6", "mammoth": "^1.11.0", + "mem0ai": "3.3.1", "pdf-parse": "^2.4.5", - "sqlite-vec": "^0.1.7-alpha.2", "undici": "^6.27.0", "whatsapp-web.js": "1.34.7", "ws": "^8.21.0", @@ -25115,6 +25114,229 @@ "node": ">=20" } }, + "packages/launcher/node_modules/@anthropic-ai/sdk": { + "version": "0.40.1", + "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.40.1.tgz", + "integrity": "sha512-DJMWm8lTEM9Lk/MSFL+V+ugF7jKOn0M2Ujvb5fN8r2nY14aHbGPZ1k6sgjL+tpJ3VuOGJNG+4R83jEpOuYPv8w==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@types/node": "^18.11.18", + "@types/node-fetch": "^2.6.4", + "abort-controller": "^3.0.0", + "agentkeepalive": "^4.2.1", + "form-data-encoder": "1.7.2", + "formdata-node": "^4.3.2", + "node-fetch": "^2.6.7" + } + }, + "packages/launcher/node_modules/@types/node": { + "version": "18.19.130", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.130.tgz", + "integrity": "sha512-GRaXQx6jGfL8sKfaIDD6OupbIHBr9jv7Jnaml9tB7l4v068PAOXqfcujMMo5PhbIs6ggR1XODELqahT2R8v0fg==", + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "undici-types": "~5.26.4" + } + }, + "packages/launcher/node_modules/mem0ai": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/mem0ai/-/mem0ai-3.3.1.tgz", + "integrity": "sha512-R+T0rB8WNU4Eh8ClfZnD2BKjk7Q4MDx3XdLZMoUZ+S7dItpkpg3xkcGrKqk0COV0dyRrul/EYzkDWTr2D6YTag==", + "license": "Apache-2.0", + "dependencies": { + "axios": "^1.18.0", + "openai": "^4.93.0", + "uuid": "^11.1.1", + "zod": "^3.24.1" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@anthropic-ai/sdk": "^0.40.1", + "@aws-sdk/client-bedrock-runtime": ">=3.0.0 <3.968.0", + "@aws-sdk/client-neptune-graph": ">=3.0.0 <3.968.0", + "@aws-sdk/client-s3vectors": "3.967.0", + "@azure/identity": "^4.0.0", + "@azure/search-documents": "^12.0.0", + "@cloudflare/workers-types": "^4.20250504.0", + "@databricks/sql": "^1.16.0", + "@elastic/elasticsearch": "^9.0.0", + "@google-cloud/aiplatform": "^6.8.0", + "@google/genai": "^1.40.0", + "@huggingface/transformers": "^3.0.0 || ^4.0.0", + "@langchain/core": "^1.1.47", + "@mistralai/mistralai": "^1.5.2", + "@mochow/mochow-sdk-node": "^2.1.5", + "@opensearch-project/opensearch": "^3.5.1", + "@pinecone-database/pinecone": "^8.0.0", + "@qdrant/js-client-rest": "^1.18.0", + "@supabase/supabase-js": "^2.49.1", + "@turbopuffer/turbopuffer": "^2.0.0", + "@types/pg": "^8.11.0", + "@upstash/vector": "^1.2.3", + "@zilliz/milvus2-sdk-node": "^2.4.0 || ^3.0.0", + "better-sqlite3": "^12.6.2", + "cassandra-driver": "4.8.0", + "chromadb": "^3.5.0", + "cloudflare": "^4.2.0", + "cohere-ai": "^7.17.0 || ^8.0.0", + "compromise": "^14.0.0", + "fastembed": "^2.1.0", + "groq-sdk": "0.3.0", + "iovalkey": "^0.3.3", + "mongodb": "^7.0.0", + "mysql2": "^3.0.0", + "natural": "^8.0.1", + "ollama": "^0.5.14", + "oracledb": "^6.5.0 || ^7.0.0", + "pg": "^8.11.3", + "redis": "^4.6.13", + "weaviate-client": "^3.0.0", + "zeroentropy": "^0.1.0-alpha.10" + }, + "peerDependenciesMeta": { + "@anthropic-ai/sdk": { + "optional": true + }, + "@aws-sdk/client-bedrock-runtime": { + "optional": true + }, + "@aws-sdk/client-neptune-graph": { + "optional": true + }, + "@aws-sdk/client-s3vectors": { + "optional": true + }, + "@azure/identity": { + "optional": true + }, + "@azure/search-documents": { + "optional": true + }, + "@databricks/sql": { + "optional": true + }, + "@elastic/elasticsearch": { + "optional": true + }, + "@google-cloud/aiplatform": { + "optional": true + }, + "@google/genai": { + "optional": true + }, + "@huggingface/transformers": { + "optional": true + }, + "@langchain/core": { + "optional": true + }, + "@mistralai/mistralai": { + "optional": true + }, + "@mochow/mochow-sdk-node": { + "optional": true + }, + "@opensearch-project/opensearch": { + "optional": true + }, + "@pinecone-database/pinecone": { + "optional": true + }, + "@qdrant/js-client-rest": { + "optional": true + }, + "@supabase/supabase-js": { + "optional": true + }, + "@turbopuffer/turbopuffer": { + "optional": true + }, + "@types/pg": { + "optional": true + }, + "@upstash/vector": { + "optional": true + }, + "@zilliz/milvus2-sdk-node": { + "optional": true + }, + "cassandra-driver": { + "optional": true + }, + "chromadb": { + "optional": true + }, + "cloudflare": { + "optional": true + }, + "cohere-ai": { + "optional": true + }, + "fastembed": { + "optional": true + }, + "groq-sdk": { + "optional": true + }, + "iovalkey": { + "optional": true + }, + "mongodb": { + "optional": true + }, + "mysql2": { + "optional": true + }, + "natural": { + "optional": true + }, + "ollama": { + "optional": true + }, + "oracledb": { + "optional": true + }, + "pg": { + "optional": true + }, + "redis": { + "optional": true + }, + "weaviate-client": { + "optional": true + }, + "zeroentropy": { + "optional": true + } + } + }, + "packages/launcher/node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "license": "MIT", + "optional": true, + "peer": true + }, + "packages/launcher/node_modules/uuid": { + "version": "11.1.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-11.1.1.tgz", + "integrity": "sha512-vIYxrBCC/N/K+Js3qSN88go7kIfNPssr/hHCesKCQNAjmgvYS2oqr69kIufEG+O4+PfezOH4EbIeHCfFov8ZgQ==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist/esm/bin/uuid" + } + }, "packages/marketplace": { "name": "@waggle/marketplace", "version": "0.1.0", diff --git a/package.json b/package.json index 07ae374..8c3b39f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "build:dev": "cd apps/web && npx vite build --mode development --outDir ../../dist --emptyOutDir", "typecheck:web": "cd apps/web && npx tsc --noEmit -p tsconfig.app.json", "preview": "cd apps/web && npx vite preview", - "build:packages": "cd packages/shared && npx tsc --build && cd ../memory-contract && npx tsc --build && cd ../memory-mem0 && npx tsc --build && cd ../hive-mind-core && npx tsc --build && cd ../core && npx tsc --build && cd ../wiki-compiler && npx tsc --build && cd ../marketplace && npx tsc --build && cd ../agent && npx tsc --build && cd ../server && npx tsc --build", + "build:packages": "cd packages/shared && npx tsc --build && cd ../memory-contract && npx tsc --build && cd ../memory-mem0 && npx tsc --build && cd ../core && npx tsc --build && cd ../marketplace && npx tsc --build && cd ../agent && npx tsc --build && cd ../server && npx tsc --build", "build:hook-runtime": "node scripts/build-hook-runtime.mjs", "build:all": "npm run build:packages && npm run build", "dev:www": "npm run dev -w apps/www", diff --git a/packages/core/package.json b/packages/core/package.json index 92f9b04..b76a442 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,7 +1,7 @@ { "name": "@waggle/core", "version": "0.1.0", - "description": "Waggle-specific orchestration: config, multi-mind, workspace, vault, telemetry, install-audit, cron, skills, file-store, file-indexer, memory-import. Re-exports substrate from @waggle/hive-mind-core for backward compatibility.", + "description": "Waggle infrastructure: config, workspaces, waggle.db stores, secrets, telemetry, file storage and indexing, embeddings and recall helpers.", "type": "module", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -17,7 +17,6 @@ }, "dependencies": { "@huggingface/transformers": "^3.8.1", - "@waggle/hive-mind-core": "*", "@waggle/memory-contract": "*", "@waggle/shared": "*", "better-sqlite3": "^12.6.2", diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index ef4aecd..9c9baaf 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -1,23 +1,11 @@ -// @waggle/core — Waggle-specific orchestration layer. +// @waggle/core — Waggle's own infrastructure: config, workspaces, waggle.db +// stores (automations, cost tracking, profile, awareness, install audit), +// secrets, telemetry, file storage and indexing, embeddings and recall helpers. // -// As of CC Sesija B 2026-04-30 (PM Q3 Plan A ratification), the substrate -// (mind/ + harvest/ + logger + injection-scanner) lives in @waggle/hive-mind-core -// and is distributed as Apache 2.0 OSS through a reviewed, maintainer-curated -// forward-port. Raw subtree-split output is never a publication source. This -// barrel re-exports -// substrate symbols for backward compatibility — existing consumers (packages/agent, -// apps/web, packages/server, etc.) keep their `import { ... } from '@waggle/core'` -// imports unchanged. -// -// Waggle-specific (non-extracted) modules below the substrate re-exports stay -// in this package: config, multi-mind, workspace orchestration, vault, telemetry, -// install-audit, cron-store, skill-hashes, file-store, file-indexer, -// memory-import. +// Memory is not here: Waggle reaches it only through @waggle/memory-contract +// (ADR-0007). // ── Waggle infrastructure (not memory) ── -// Copied from @waggle/hive-mind-core so the rest of Waggle no longer depends on -// the memory substrate for them (P1.5). The substrate keeps its own copies until -// the package is removed. export { createCoreLogger, type CoreLogger } from './logger.js'; export { scanForInjection, type ScanResult } from './injection-scanner.js'; export { @@ -66,80 +54,7 @@ export { } from './execution-traces.js'; export { importLegacyMindData, type LegacyMindSource, type LegacyImportReport } from './waggle-db-import.js'; -// ── Substrate re-exports from @waggle/hive-mind-core (Apache 2.0 OSS) ── -export { - // mind/ — memory substrate - MindDB, EmbeddingDimMismatchError, - type EmbeddingFingerprint, type FingerprintCheck, - FrameStore, stripHmPrefix, hashFrameContent, - RawArchive, hashRaw, readArchiveUids, withArchiveUid, type RawArchiveRow, type ArchiveInput, - MindErasure, type EraseResult, - SuppressionStore, type SuppressedSubject, - type MemoryFrame, type FrameType, type Importance, type FrameSource, - SessionStore, type Session, - HybridSearch, type SearchResult, - // D1 (oss-drift triage, 2026-06-11) — chunk-level retrieval (flag-gated, default OFF) - chunkRetrievalEnabled, rechunkAllFrames, type RechunkResult, - chunkText, type ChunkOptions, type FrameChunk, - KnowledgeGraph, type Entity, type Relation, type ValidationSchema, - SCHEMA_SQL, VEC_TABLE_SQL, CHUNKS_VEC_TABLE_SQL, SCHEMA_VERSION, - vecTableSqlForDim, chunksVecTableSqlForDim, - computeRelevance, - computeTemporalScore, - computePopularityScore, - computeContextualScore, - computeImportanceScore, - SCORING_PROFILES, - type ScoringProfile, - type ScoringWeights, - normalizeEntityName, findDuplicates, isNoiseName, isLikelyAcronym, - Ontology, validateEntity, type EntitySchema, type ValidationResult, - reconcileIndexes, reconcileFtsIndex, reconcileVecIndex, cleanOrphanVectors, cleanOrphanFts, - type ReconcileResult, - ConceptTracker, CONCEPT_MASTERY_TABLE_SQL, - type ConceptEntry, type ConceptUpdate, - // harvest/ — universal memory ingestion pipeline - HarvestSourceStore, - HarvestRunStore, type HarvestRun, type HarvestRunStatus, - ChatGPTAdapter, - ClaudeAdapter, - ClaudeCodeAdapter, - GeminiAdapter, - UniversalAdapter, - MarkdownAdapter, - PlaintextAdapter, - UrlAdapter, - PdfAdapter, - HarvestPipeline, type LLMCallFn, type PipelineOptions, - extractMemoryLanes, writeMemoryLaneFrames, - MIND_FACT_PREFIX, MIND_EVENT_PREFIX, MIND_PROFILE_PREFIX, - type MemoryLaneExtraction, type ExtractedEvent, type ExtractedFact, type ExtractedProfile, - type WriteLaneFramesResult, - // D2 — LLM-based KG entity extraction (oss-drift triage, 2026-06-11) - extractKgEntities, writeKgEntities, KG_ENTITY_TYPES, - type KgEntity, type KgEntityType, type KgEntityExtraction, type WriteKgEntitiesResult, - // W4.6 — raw-turn storage + RAWDETAIL recall lane - writeRawTurnFrames, rawTurnHeader, parseRawTurnHeader, rawTurnConvKey, - MIND_RAWTURN_PREFIX, MAX_TURNS_PER_ITEM, RAWDETAIL_KILL_SWITCH, - type WriteRawTurnsResult, type ParsedRawTurnHeader, - fetchRawDetailLane, rawTurnBody, RAW_DETAIL_K, - type RawTurnHit, type RawDetailLaneOptions, - dedup, harvestSetHash, - HARVEST_FRAME_CONTENT_CAP, - type ImportSourceType, type ImportItemType, type UniversalImportItem, type DistilledKnowledge, - type HarvestPipelineResult, type HarvestSource, type SourceAdapter, type FilesystemAdapter, - type ClassifiedItem, type ExtractedContent, type KnowledgeProvenance, - // Plan A AMENDMENT 2026-04-30 — multi-workspace orchestration - MultiMind, type MultiMindSearchResult, type MindSource, type SearchScope, - MultiMindCache, type MultiMindCacheConfig, - // Supersession (P) + bridge (B) frame producer (mono-parity 2026-07-05) - detectSupersessionChains, detectEntityGroups, applyConsolidation, - collectObservations, getCurrentValues, - type ConsolidationLlm, type Observation, type SupersessionChain, - type EntityGroup, type ConsolidationResult, type CollectObservationsOptions, -} from '@waggle/hive-mind-core'; - -// ── Waggle-specific orchestration (stays in @waggle/core) ── +// ── Waggle-specific orchestration ── export { WaggleConfig, type ProviderEntry } from './config.js'; export { needsMigration, migrateToMultiMind } from './migration.js'; export { diff --git a/packages/core/src/workspace-manager.ts b/packages/core/src/workspace-manager.ts index e04beac..c6fc29c 100644 --- a/packages/core/src/workspace-manager.ts +++ b/packages/core/src/workspace-manager.ts @@ -131,8 +131,8 @@ function isContained(root: string, candidate: string): boolean { * WorkspaceManager manages workspace CRUD, groups, and directory structure. * Each workspace lives under {baseDir}/workspaces/{id}/ with: * - workspace.json (config) - * - workspace.mind (SQLite .mind file, created empty) * - sessions/ (JSONL session logs) + * Workspace memory lives in the memory store, not in this directory. */ export class WorkspaceManager { private readonly workspacesDir: string; @@ -217,9 +217,6 @@ export class WorkspaceManager { } fs.mkdirSync(path.join(canonicalWorkspace, 'sessions')); - // Touch workspace.mind — MindDB will init schema when first opened - fs.writeFileSync(path.join(canonicalWorkspace, 'workspace.mind'), '', { flag: 'wx' }); - const config: WorkspaceConfig = { id, name: options.name, @@ -355,7 +352,8 @@ export class WorkspaceManager { } /** - * Get the path to a workspace's .mind file. + * Get the path to a workspace's legacy .mind file. Only the one-time copy of + * legacy data reads it; new workspaces do not have one. */ getMindPath(id: string): string { this.assertWorkspaceId(id); diff --git a/packages/launcher/package.json b/packages/launcher/package.json index 423e22a..6e492e5 100644 --- a/packages/launcher/package.json +++ b/packages/launcher/package.json @@ -49,8 +49,8 @@ "fastify-plugin": "^5.0.0", "glob": "^13.0.6", "mammoth": "^1.11.0", + "mem0ai": "3.3.1", "pdf-parse": "^2.4.5", - "sqlite-vec": "^0.1.7-alpha.2", "undici": "^6.27.0", "whatsapp-web.js": "1.34.7", "ws": "^8.21.0", diff --git a/packages/launcher/tsup.config.ts b/packages/launcher/tsup.config.ts index 149d54d..93e5468 100644 --- a/packages/launcher/tsup.config.ts +++ b/packages/launcher/tsup.config.ts @@ -19,5 +19,8 @@ export default defineConfig({ 'adm-zip', 'playwright-core', 'chromium-bidi', + // mem0 loads a client for each provider it supports on demand; those are + // optional peers Waggle does not install (see scripts/build-sidecar.mjs). + 'mem0ai', ], }); diff --git a/packages/server/src/local/index.ts b/packages/server/src/local/index.ts index 9a17500..e92dc8a 100644 --- a/packages/server/src/local/index.ts +++ b/packages/server/src/local/index.ts @@ -10,7 +10,7 @@ import Fastify, { type FastifyInstance, type FastifyRequest } from 'fastify'; import cors from '@fastify/cors'; import fastifyStatic from '@fastify/static'; import websocket from '@fastify/websocket'; -import { MindDB, MultiMind, WaggleDB, importLegacyMindData, workspaceDataScope, type LegacyMindSource, MultiMindCache, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, FrameStore, SessionStore, SuppressionStore, InstallAuditStore, CronStore, AwarenessLayer, VaultStore, SkillHashStore, HarvestSourceStore, ClaudeCodeAdapter, reconcileIndexes, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore, harvestSetHash } from '@waggle/core'; +import { WaggleDB, importLegacyMindData, workspaceDataScope, type LegacyMindSource, WorkspaceManager, WaggleConfig, createEmbeddingProvider, type EmbeddingProviderConfig, type EmbeddingProviderInstance, InstallAuditStore, CronStore, AwarenessLayer, VaultStore, SkillHashStore, TelemetryStore, TELEMETRY_EVENTS, ExecutionTraceStore } from '@waggle/core'; import { corsOriginAllowed } from './cors-config.js'; import { getStorageProvider } from './storage/index.js'; import { isLoopbackBind, resolveBindHost } from './net-config.js'; @@ -331,10 +331,6 @@ export interface AgentState { * singleton and is unsafe for concurrent sessions. Being migrated per Phase A.1. */ activateWorkspaceMind: (workspaceId: string) => boolean; - /** Get a cached workspace MindDB (opens on demand). Returns null if workspace not found. */ - getWorkspaceMindDb: (workspaceId: string) => import('@waggle/core').MindDB | null; - /** Close and remove a workspace MindDB from cache. Used before workspace deletion to prevent EBUSY. */ - closeWorkspaceMind: (workspaceId: string) => void; /** Close a workspace's live sessions and detach it from the shared orchestrator. Used before workspace deletion. */ releaseWorkspace: (workspaceId: string) => void; /** List all workspaces (id + name). Used by global memory search. */ @@ -362,7 +358,6 @@ export interface AgentState { declare module 'fastify' { interface FastifyInstance { localConfig: LocalConfig; - multiMind: MultiMind; workspaceManager: WorkspaceManager; eventBus: EventEmitter; agentRunner?: AgentRunner; @@ -382,9 +377,6 @@ declare module 'fastify' { skillHashStore: import('@waggle/core').SkillHashStore; scheduler: import('./cron.js').LocalScheduler; marketplace: import('@waggle/marketplace').MarketplaceDB | null; - /** Shared per-workspace mind cache. Routes use this to reach an arbitrary - * workspace's mind (e.g. FileIndexer for L-20 auto-indexing). */ - mindCache: import('@waggle/core').MultiMindCache; offlineManager: OfflineManager; rateLimiter: import('./security-middleware.js').RateLimiter; telemetry: import('@waggle/core').TelemetryStore; @@ -492,10 +484,9 @@ export async function buildLocalServer(config: Partial = {}) { const defaultWorkspaceId = defaultWorkspaceConfig.id; server.decorate('workspaceManager', wsManager); - // MultiMind — open personal mind, no workspace yet (selected via API) + // The legacy memory file of earlier versions; only the one-time copies of + // legacy data below read it, and nothing creates it any more. const personalPath = path.join(fullConfig.dataDir, 'personal.mind'); - const multiMind = new MultiMind(personalPath); - server.decorate('multiMind', multiMind); // Waggle's own data (automations, notifications, cost tracking, profile and // awareness) lives in waggle.db, apart from memory (ADR-0007). The first @@ -1260,16 +1251,6 @@ export async function buildLocalServer(config: Partial = {}) { return [...base, ...crossTools]; }; - // ── Workspace mind cache (LRU, max 20 open) ── - // allowedRoot defends against path-traversal via a crafted workspaceId (review - // Critical #2 from cowork/Code-Review_MultiMind_April-2026.md). Any resolved - // path outside this root is rejected before MindDB construction. - const mindCache = new MultiMindCache({ - maxOpen: 20, - getMindPath: (id) => (wsManager.get(id) ? wsManager.getMindPath(id) : null), - allowedRoot: path.join(fullConfig.dataDir, 'workspaces'), - }); - server.decorate('mindCache', mindCache); let activeWorkspaceId: string | null = null; const setActiveWorkspaceId = (workspaceId: string | null): void => { activeWorkspaceId = workspaceId; @@ -1287,30 +1268,15 @@ export async function buildLocalServer(config: Partial = {}) { return true; }; - // Helper: get a cached workspace MindDB (opens on demand) - // A6: Close and remove workspace mind DB from cache before deletion - const closeWorkspaceMind = (workspaceId: string): void => { - // Pin-aware: close any live session first so it drops its cache pin (and - // stops referencing a handle we're about to force-close). Then force-close - // the cache entry — on deletion the workspace is authoritative, so we close - // regardless of remaining pins to release the file lock before FS deletion - // (A6 EBUSY). Ordering avoids the old double-close where both the session - // and this seam closed the same MindDB. + // Before a workspace is deleted: close its live sessions and detach it from + // the shared orchestrator. + const releaseWorkspace = (workspaceId: string): void => { sessionManager.close(workspaceId); - mindCache.close(workspaceId); if (activeWorkspaceId === workspaceId) { orchestrator.setWorkspace(null); setActiveWorkspaceId(null); } }; - // Until the legacy mind cache is removed, releasing a workspace also closes - // its cached mind so the workspace directory can be deleted (A6 EBUSY). - const releaseWorkspace = closeWorkspaceMind; - - const getWorkspaceMindDb = (workspaceId: string): MindDB | null => { - if (!wsManager.get(workspaceId)) return null; - return mindCache.getOrOpen(workspaceId); - }; // Decorate with shared agent state server.decorate('agentState', { @@ -1331,8 +1297,6 @@ export async function buildLocalServer(config: Partial = {}) { buildToolsForSession, bindWorkspaceCollaborationTools, activateWorkspaceMind: activateWorkspaceMind, - getWorkspaceMindDb, - closeWorkspaceMind, releaseWorkspace, listWorkspaces: () => wsManager.list().map(w => ({ id: w.id, name: w.name })), activeWorkspaceId, @@ -2523,9 +2487,6 @@ export async function buildLocalServer(config: Partial = {}) { // Close all workspace sessions (new concurrent model) sessionManager.closeAll(); - // Close all cached workspace minds - mindCache.closeAll(); - multiMind.close(); await memory.close(); waggleDb.close(); diff --git a/packages/server/src/local/routes/memory-center-legacy.ts b/packages/server/src/local/routes/memory-center-legacy.ts deleted file mode 100644 index 399eb4a..0000000 --- a/packages/server/src/local/routes/memory-center-legacy.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { MemoryFrame } from '@waggle/core'; -import type { Memory, MemoryStatus } from '@waggle/shared'; -import { asKind } from '../memory-records.js'; - -/** - * @deprecated Projects a legacy frame-store row into the Memory shape. Only - * `home.ts` and `artifacts.ts` still read frames; once they read memory through - * the contract (`recordToMemory` in memory-center.ts), delete this file. - */ -export function normalizeToMemory(frame: MemoryFrame, mind: string, workspaceId?: string): Memory { - let meta: Record = {}; - try { - const parsed: unknown = typeof frame.metadata === 'string' && frame.metadata ? JSON.parse(frame.metadata) : {}; - if (parsed && typeof parsed === 'object') meta = parsed as Record; - } catch { /* malformed metadata reads as empty */ } - const content = frame.content ?? ''; - const importance: Memory['importance'] = frame.importance ?? 'normal'; - const status: MemoryStatus = typeof meta.status === 'string' - ? meta.status as MemoryStatus - : importance === 'deprecated' - ? 'deprecated' - : importance === 'temporary' && frame.source === 'agent_inferred' ? 'unreviewed' : 'active'; - const firstLine = content.split('\n').find((l) => l.trim().length > 0)?.trim() ?? content.trim(); - return { - id: String(frame.id), - kind: asKind(meta.kind) ?? 'fact', - title: typeof meta.title === 'string' && meta.title.trim() - ? meta.title - : firstLine.length > 80 ? `${firstLine.slice(0, 79)}…` : firstLine, - content, - scope: mind === 'workspace' ? 'workspace' : 'personal', - workspaceId, - source: frame.source ?? 'user_stated', - importance, - status, - createdAt: frame.created_at ?? new Date().toISOString(), - }; -} diff --git a/packages/server/src/local/routes/memory-center.ts b/packages/server/src/local/routes/memory-center.ts index 0944c5f..59d303e 100644 --- a/packages/server/src/local/routes/memory-center.ts +++ b/packages/server/src/local/routes/memory-center.ts @@ -25,8 +25,6 @@ import { workspaceIdOf, } from '../memory-records.js'; -export { normalizeToMemory } from './memory-center-legacy.js'; - /** * Memory Center REST surface (S04, PRD §16.4) on the memory contract (ADR-0007). * diff --git a/packages/server/tsconfig.paths-check.json b/packages/server/tsconfig.paths-check.json index dcd4ef2..6e5b8bd 100644 --- a/packages/server/tsconfig.paths-check.json +++ b/packages/server/tsconfig.paths-check.json @@ -9,7 +9,6 @@ "@waggle/agent": ["../agent/src/index.ts"], "@waggle/core": ["../core/src/index.ts"], "@waggle/shared": ["../shared/src/index.ts"], - "@waggle/hive-mind-core": ["../hive-mind-core/src/index.ts"], "@waggle/marketplace": ["../marketplace/src/index.ts"], "@waggle/sdk": ["../sdk/src/index.ts"] } diff --git a/scripts/build-sidecar.mjs b/scripts/build-sidecar.mjs index ece9bb8..6fb5127 100644 --- a/scripts/build-sidecar.mjs +++ b/scripts/build-sidecar.mjs @@ -133,6 +133,11 @@ const EXTERNAL = [ // optional peer of Puppeteer's config loader). Staged as separate packages. 'whatsapp-web.js', '@puppeteer/browsers', + // Memory (ADR-0007). mem0 imports a client for every provider it supports + // (vector stores, LLMs, embedders) on demand; those are optional peers that + // Waggle does not install. Kept external and staged with its own + // dependencies, so the providers Waggle does not use are never resolved. + 'mem0ai', ]; try { @@ -181,9 +186,9 @@ try { '@waggle/agent': path.join(root, 'packages', 'agent', 'src', 'index.ts'), '@waggle/core': path.join(root, 'packages', 'core', 'src', 'index.ts'), '@waggle/marketplace': path.join(root, 'packages', 'marketplace', 'src', 'index.ts'), + '@waggle/memory-contract': path.join(root, 'packages', 'memory-contract', 'src', 'index.ts'), + '@waggle/memory-mem0': path.join(root, 'packages', 'memory-mem0', 'src', 'index.ts'), '@waggle/shared': path.join(root, 'packages', 'shared', 'src', 'index.ts'), - '@waggle/hive-mind-core': path.join(root, 'packages', 'hive-mind-core', 'src', 'index.ts'), - '@waggle/wiki-compiler': path.join(root, 'packages', 'wiki-compiler', 'src', 'index.ts'), }, sourcemap: false, minify: true,