claude-memory-layer 1.0.31 → 1.0.32
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/README.md +9 -2
- package/dist/cli/index.js +1 -1
- package/package.json +11 -2
- package/scripts/postinstall-embedding-backend.cjs +16 -12
- package/AGENTS.md +0 -71
- package/CLAUDE.md +0 -30
- package/HANDOFF.md +0 -92
- package/Memo.txt +0 -558
- package/benchmarks/replay/anonymized-real-sessions.json +0 -48
- package/config/kpi-thresholds.json +0 -7
- package/context.md +0 -636
- package/docs/ARCHITECTURE_COMPARISON_AND_RECOMMENDATIONS.md +0 -627
- package/docs/HERMES_MEMORY_INGESTION_ANALYSIS.md +0 -440
- package/docs/MCP_MEMORY_SERVICE_COMPARATIVE_REVIEW.md +0 -271
- package/docs/MEMORY_USEFULNESS_AUDIT.md +0 -371
- package/docs/MEMORY_USEFULNESS_AUDIT_RAW.json +0 -80
- package/docs/MEMSEARCH_PROJECT_STRUCTURE_ANALYSIS.md +0 -333
- package/docs/MEMU_ADOPTION.md +0 -40
- package/docs/OPERATIONS.md +0 -18
- package/docs/PRODUCT_VALIDATION_MATRIX.md +0 -82
- package/docs/PROJECT_STRUCTURE_ANALYSIS.md +0 -421
- package/docs/REFACTORING_MILESTONES_AND_ISSUES.md +0 -501
- package/docs/REFACTORING_PLAN_THIN_CORE.md +0 -414
- package/docs/REFERENCE_PROJECT_ANALYSES.md +0 -25
- package/docs/SUPERLOCALMEMORY_PROJECT_STRUCTURE_ANALYSIS.md +0 -452
- package/docs/TARGET_ARCHITECTURE_AND_FOLDER_STRUCTURE.md +0 -446
- package/docs/architecture/comparison-index.md +0 -47
- package/docs/reports/codex-real-data-validation-20260505T040447Z.md +0 -46
- package/plan.md +0 -1642
- package/scripts/build.ts +0 -159
- package/scripts/bump-patch-version.sh +0 -18
- package/scripts/delete-unknown-projects.js +0 -154
- package/scripts/fix-sync-gap.js +0 -32
- package/scripts/generate-session-qrels.ts +0 -126
- package/scripts/heartbeat-memory-orchestrator.sh +0 -28
- package/scripts/replay-retrieval-benchmark.ts +0 -69
- package/scripts/report-sync-gap.js +0 -26
- package/scripts/review-queue-auto-resolve.js +0 -21
- package/scripts/sync-gap-auto-heal.sh +0 -17
- package/spec.md +0 -624
- package/specs/20260207-dashboard-upgrade/context.md +0 -38
- package/specs/20260207-dashboard-upgrade/spec.md +0 -96
- package/specs/citations-system/context.md +0 -243
- package/specs/citations-system/plan.md +0 -495
- package/specs/citations-system/spec.md +0 -371
- package/specs/endless-mode/context.md +0 -305
- package/specs/endless-mode/plan.md +0 -620
- package/specs/endless-mode/spec.md +0 -455
- package/specs/entity-edge-model/context.md +0 -401
- package/specs/entity-edge-model/plan.md +0 -459
- package/specs/entity-edge-model/spec.md +0 -391
- package/specs/evidence-aligner-v2/context.md +0 -401
- package/specs/evidence-aligner-v2/plan.md +0 -303
- package/specs/evidence-aligner-v2/spec.md +0 -312
- package/specs/mcp-desktop-integration/context.md +0 -278
- package/specs/mcp-desktop-integration/plan.md +0 -550
- package/specs/mcp-desktop-integration/spec.md +0 -494
- package/specs/memory-utilization-improvements/context.md +0 -145
- package/specs/memory-utilization-improvements/plan.md +0 -361
- package/specs/memory-utilization-improvements/spec.md +0 -361
- package/specs/post-tool-use-hook/context.md +0 -319
- package/specs/post-tool-use-hook/plan.md +0 -469
- package/specs/post-tool-use-hook/spec.md +0 -364
- package/specs/private-tags/context.md +0 -288
- package/specs/private-tags/plan.md +0 -412
- package/specs/private-tags/spec.md +0 -345
- package/specs/progressive-disclosure/context.md +0 -346
- package/specs/progressive-disclosure/plan.md +0 -663
- package/specs/progressive-disclosure/spec.md +0 -415
- package/specs/selective-tool-observation/context.md +0 -100
- package/specs/selective-tool-observation/plan.md +0 -158
- package/specs/selective-tool-observation/spec.md +0 -127
- package/specs/task-entity-system/context.md +0 -297
- package/specs/task-entity-system/plan.md +0 -301
- package/specs/task-entity-system/spec.md +0 -314
- package/specs/thin-core-refactor/context.md +0 -275
- package/specs/thin-core-refactor/plan.md +0 -536
- package/specs/thin-core-refactor/spec.md +0 -465
- package/specs/vector-outbox-v2/context.md +0 -470
- package/specs/vector-outbox-v2/plan.md +0 -562
- package/specs/vector-outbox-v2/spec.md +0 -466
- package/specs/web-viewer-ui/context.md +0 -384
- package/specs/web-viewer-ui/plan.md +0 -797
- package/specs/web-viewer-ui/spec.md +0 -516
- package/src/adapters/claude/capture/index.ts +0 -3
- package/src/adapters/claude/context/index.ts +0 -3
- package/src/adapters/claude/hooks/index.ts +0 -21
- package/src/adapters/claude/hooks/post-tool-use.ts +0 -239
- package/src/adapters/claude/hooks/prompt-injection-policy.ts +0 -104
- package/src/adapters/claude/hooks/semantic-daemon-client.ts +0 -209
- package/src/adapters/claude/hooks/semantic-daemon.ts +0 -283
- package/src/adapters/claude/hooks/session-end.ts +0 -59
- package/src/adapters/claude/hooks/session-start.ts +0 -73
- package/src/adapters/claude/hooks/stop.ts +0 -128
- package/src/adapters/claude/hooks/user-prompt-submit.ts +0 -361
- package/src/adapters/claude/index.ts +0 -4
- package/src/adapters/claude/transcript/index.ts +0 -4
- package/src/adapters/claude/transcript/transcript-reader.ts +0 -57
- package/src/adapters/claude/transcript/turn-reconstructor.ts +0 -65
- package/src/apps/cli/claude-settings-hooks.ts +0 -138
- package/src/apps/cli/codex-import-runner.ts +0 -125
- package/src/apps/cli/codex-validation-output.ts +0 -95
- package/src/apps/cli/hermes-import-runner.ts +0 -130
- package/src/apps/cli/hermes-validation-output.ts +0 -91
- package/src/apps/cli/index.ts +0 -1735
- package/src/apps/cli/mcp-install.ts +0 -106
- package/src/apps/cli/retrieval-disclosure-output.ts +0 -196
- package/src/apps/dashboard/assets/js/bootstrap.js +0 -244
- package/src/apps/dashboard/assets/js/chat.js +0 -373
- package/src/apps/dashboard/assets/js/disclosure.js +0 -232
- package/src/apps/dashboard/assets/js/modals.js +0 -298
- package/src/apps/dashboard/assets/js/overview.js +0 -655
- package/src/apps/dashboard/assets/js/state.js +0 -72
- package/src/apps/dashboard/assets/js/views.js +0 -468
- package/src/apps/dashboard/index.html +0 -543
- package/src/apps/dashboard/index.ts +0 -3
- package/src/apps/dashboard/style.css +0 -1750
- package/src/apps/index.ts +0 -5
- package/src/apps/server/api/chat.ts +0 -244
- package/src/apps/server/api/citations.ts +0 -105
- package/src/apps/server/api/events.ts +0 -137
- package/src/apps/server/api/health.ts +0 -53
- package/src/apps/server/api/index.ts +0 -26
- package/src/apps/server/api/projects.ts +0 -74
- package/src/apps/server/api/search.ts +0 -184
- package/src/apps/server/api/sessions.ts +0 -115
- package/src/apps/server/api/stats.ts +0 -723
- package/src/apps/server/api/turns.ts +0 -143
- package/src/apps/server/api/utils.ts +0 -65
- package/src/apps/server/index.ts +0 -111
- package/src/cli/index.ts +0 -3
- package/src/cli/retrieval-disclosure-output.ts +0 -2
- package/src/compat/index.ts +0 -5
- package/src/core/canonical-key.ts +0 -186
- package/src/core/citation-generator.ts +0 -63
- package/src/core/consolidated-store.ts +0 -356
- package/src/core/consolidation-worker.ts +0 -493
- package/src/core/context-formatter.ts +0 -276
- package/src/core/continuity-manager.ts +0 -341
- package/src/core/db-wrapper.ts +0 -64
- package/src/core/derive/fact-deriver.ts +0 -170
- package/src/core/derive/index.ts +0 -2
- package/src/core/derive/summary-deriver.ts +0 -76
- package/src/core/edge-repo.ts +0 -333
- package/src/core/embedder.ts +0 -4
- package/src/core/engine/embedding-maintenance-service.ts +0 -187
- package/src/core/engine/endless-memory-services.ts +0 -4
- package/src/core/engine/index.ts +0 -19
- package/src/core/engine/memory-engine-services.ts +0 -170
- package/src/core/engine/memory-ingest-service.ts +0 -317
- package/src/core/engine/memory-query-service.ts +0 -173
- package/src/core/engine/memory-runtime-service.ts +0 -162
- package/src/core/engine/memory-service-composition.ts +0 -231
- package/src/core/engine/retrieval-analytics-service.ts +0 -181
- package/src/core/engine/retrieval-disclosure-service.ts +0 -420
- package/src/core/engine/retrieval-orchestrator.ts +0 -377
- package/src/core/engine/retrieval-services.ts +0 -176
- package/src/core/engine/shared-memory-services.ts +0 -4
- package/src/core/entity-repo.ts +0 -349
- package/src/core/event-store.ts +0 -779
- package/src/core/evidence-aligner.ts +0 -635
- package/src/core/external-market-context.ts +0 -582
- package/src/core/graduation-worker.ts +0 -171
- package/src/core/graduation.ts +0 -377
- package/src/core/index.ts +0 -64
- package/src/core/ingest-interceptor.ts +0 -80
- package/src/core/markdown-mirror.ts +0 -70
- package/src/core/matcher.ts +0 -208
- package/src/core/md-mirror.ts +0 -92
- package/src/core/metadata-extractor.ts +0 -203
- package/src/core/model/memory-fact.ts +0 -30
- package/src/core/model/memory-rule.ts +0 -14
- package/src/core/model/memory-summary.ts +0 -21
- package/src/core/model/raw-event.ts +0 -28
- package/src/core/model/retrieval-result.ts +0 -35
- package/src/core/mongo-sync-config.ts +0 -165
- package/src/core/mongo-sync-worker.ts +0 -381
- package/src/core/privacy/filter.ts +0 -190
- package/src/core/privacy/index.ts +0 -20
- package/src/core/privacy/tag-parser.ts +0 -145
- package/src/core/product-validation-matrix.ts +0 -314
- package/src/core/progressive-retriever.ts +0 -414
- package/src/core/registry/project-path.ts +0 -54
- package/src/core/registry/session-registry.ts +0 -69
- package/src/core/replay-evaluator.ts +0 -625
- package/src/core/retrieval-benchmark.ts +0 -117
- package/src/core/retrieval-quality.ts +0 -109
- package/src/core/retriever.ts +0 -800
- package/src/core/session-qrels.ts +0 -360
- package/src/core/shared-event-store.ts +0 -114
- package/src/core/shared-promoter.ts +0 -249
- package/src/core/shared-store.ts +0 -289
- package/src/core/shared-vector-store.ts +0 -203
- package/src/core/sqlite-event-store.ts +0 -1846
- package/src/core/sqlite-wrapper.ts +0 -116
- package/src/core/sync-worker.ts +0 -228
- package/src/core/tag-taxonomy.ts +0 -51
- package/src/core/task/blocker-resolver.ts +0 -333
- package/src/core/task/index.ts +0 -9
- package/src/core/task/task-matcher.ts +0 -240
- package/src/core/task/task-projector.ts +0 -358
- package/src/core/task/task-resolver.ts +0 -421
- package/src/core/turn-state.ts +0 -207
- package/src/core/types.ts +0 -952
- package/src/core/vector-outbox.ts +0 -299
- package/src/core/vector-store.ts +0 -231
- package/src/core/vector-worker.ts +0 -521
- package/src/core/working-set-store.ts +0 -257
- package/src/extensions/endless-memory/endless-memory-services.ts +0 -350
- package/src/extensions/endless-memory/index.ts +0 -1
- package/src/extensions/index.ts +0 -5
- package/src/extensions/mcp/handlers.ts +0 -960
- package/src/extensions/mcp/index.ts +0 -48
- package/src/extensions/mcp/tools.ts +0 -252
- package/src/extensions/shared-memory/index.ts +0 -1
- package/src/extensions/shared-memory/shared-memory-services.ts +0 -211
- package/src/extensions/vector/embedder.ts +0 -234
- package/src/extensions/vector/index.ts +0 -1
- package/src/hooks/post-tool-use.ts +0 -9
- package/src/hooks/semantic-daemon-client.ts +0 -1
- package/src/hooks/semantic-daemon.ts +0 -11
- package/src/hooks/session-end.ts +0 -9
- package/src/hooks/session-start.ts +0 -9
- package/src/hooks/stop.ts +0 -9
- package/src/hooks/user-prompt-submit.ts +0 -9
- package/src/index.ts +0 -13
- package/src/mcp/handlers.ts +0 -2
- package/src/mcp/index.ts +0 -4
- package/src/mcp/tools.ts +0 -2
- package/src/server/api/chat.ts +0 -2
- package/src/server/api/citations.ts +0 -2
- package/src/server/api/events.ts +0 -2
- package/src/server/api/health.ts +0 -2
- package/src/server/api/index.ts +0 -2
- package/src/server/api/projects.ts +0 -2
- package/src/server/api/search.ts +0 -2
- package/src/server/api/sessions.ts +0 -2
- package/src/server/api/stats.ts +0 -2
- package/src/server/api/turns.ts +0 -2
- package/src/server/api/utils.ts +0 -2
- package/src/server/index.ts +0 -2
- package/src/services/bootstrap-organizer.ts +0 -463
- package/src/services/codex-session-history-importer.ts +0 -966
- package/src/services/hermes-session-history-importer.ts +0 -733
- package/src/services/memory-service-config.ts +0 -36
- package/src/services/memory-service-registry.ts +0 -150
- package/src/services/memory-service.ts +0 -688
- package/src/services/session-history-importer.ts +0 -629
- package/tests/README.md +0 -23
- package/tests/adapters/claude/claude-semantic-daemon-adapter.test.ts +0 -54
- package/tests/adapters/claude/claude-transcript-reconstructor.test.ts +0 -98
- package/tests/adapters/claude-hook-prompt-injection-policy.test.ts +0 -99
- package/tests/apps/app-layer-boundary.test.ts +0 -48
- package/tests/apps/claude-settings-hooks.test.ts +0 -107
- package/tests/apps/cli-disclosure-output.test.ts +0 -212
- package/tests/apps/codex-import-runner.test.ts +0 -99
- package/tests/apps/codex-validation-output.test.ts +0 -100
- package/tests/apps/hermes-import-runner.test.ts +0 -99
- package/tests/apps/mcp-install-command.test.ts +0 -59
- package/tests/apps/package-build-entrypoints.test.ts +0 -30
- package/tests/apps/postinstall-embedding-backend.test.ts +0 -185
- package/tests/apps/search-api-disclosure.test.ts +0 -162
- package/tests/apps/stats-api-lightweight.test.ts +0 -67
- package/tests/apps/ui-disclosure-output.test.ts +0 -140
- package/tests/core/bootstrap-organizer.test.ts +0 -111
- package/tests/core/canonical-key.test.ts +0 -101
- package/tests/core/codex-session-history-importer-validation.test.ts +0 -185
- package/tests/core/consolidation-worker.test.ts +0 -75
- package/tests/core/embedding-maintenance-service.test.ts +0 -282
- package/tests/core/evidence-aligner.test.ts +0 -152
- package/tests/core/external-market-context.test.ts +0 -209
- package/tests/core/fact-deriver.test.ts +0 -79
- package/tests/core/hermes-session-history-importer-validation.test.ts +0 -609
- package/tests/core/ingest-interceptor.test.ts +0 -38
- package/tests/core/markdown-mirror.test.ts +0 -85
- package/tests/core/matcher.test.ts +0 -112
- package/tests/core/md-mirror.test.ts +0 -50
- package/tests/core/memory-engine-services.test.ts +0 -240
- package/tests/core/memory-ingest-service.test.ts +0 -296
- package/tests/core/memory-query-service.test.ts +0 -129
- package/tests/core/memory-runtime-service.test.ts +0 -201
- package/tests/core/memory-service-composition.test.ts +0 -192
- package/tests/core/memory-service-config.test.ts +0 -41
- package/tests/core/memory-service-facade.test.ts +0 -30
- package/tests/core/memory-service-registry.test.ts +0 -206
- package/tests/core/product-validation-matrix.test.ts +0 -61
- package/tests/core/project-registry.test.ts +0 -78
- package/tests/core/replay-evaluator.test.ts +0 -181
- package/tests/core/retrieval-analytics-service.test.ts +0 -210
- package/tests/core/retrieval-benchmark.test.ts +0 -93
- package/tests/core/retrieval-disclosure-service.test.ts +0 -264
- package/tests/core/retrieval-orchestrator.test.ts +0 -403
- package/tests/core/retrieval-quality.test.ts +0 -31
- package/tests/core/retrieval-services.test.ts +0 -185
- package/tests/core/retriever-fallback-chain.test.ts +0 -223
- package/tests/core/retriever-strategy-scope.test.ts +0 -164
- package/tests/core/retriever.memu-adoption.test.ts +0 -122
- package/tests/core/session-history-importer-filter.test.ts +0 -78
- package/tests/core/session-qrels.test.ts +0 -250
- package/tests/core/sqlite-event-store-replication.test.ts +0 -127
- package/tests/core/summary-deriver.test.ts +0 -66
- package/tests/extensions/embedder-warning-suppression.test.ts +0 -84
- package/tests/extensions/endless-memory-extension-boundary.test.ts +0 -17
- package/tests/extensions/endless-memory-services.test.ts +0 -325
- package/tests/extensions/mcp-context-tools.test.ts +0 -905
- package/tests/extensions/mcp-extension-boundary.test.ts +0 -21
- package/tests/extensions/mcp-package-build.test.ts +0 -22
- package/tests/extensions/mcp-project-aware-tools.test.ts +0 -102
- package/tests/extensions/shared-memory-extension-boundary.test.ts +0 -24
- package/tests/extensions/shared-memory-services.test.ts +0 -309
- package/tests/extensions/vector-extension-boundary.test.ts +0 -21
- package/tsconfig.json +0 -24
- package/vitest.config.ts +0 -15
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* MCP Server for Claude Desktop
|
|
4
|
-
* Provides memory search tools via Model Context Protocol
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
8
|
-
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
9
|
-
import {
|
|
10
|
-
ListToolsRequestSchema,
|
|
11
|
-
CallToolRequestSchema
|
|
12
|
-
} from '@modelcontextprotocol/sdk/types.js';
|
|
13
|
-
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
14
|
-
|
|
15
|
-
import { tools } from './tools.js';
|
|
16
|
-
import { handleToolCall } from './handlers.js';
|
|
17
|
-
|
|
18
|
-
const server = new Server(
|
|
19
|
-
{
|
|
20
|
-
name: 'claude-memory-layer-mcp',
|
|
21
|
-
version: '1.0.0'
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
capabilities: {
|
|
25
|
-
tools: {}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
// Tool listing handler
|
|
31
|
-
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
32
|
-
return { tools };
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
// Tool call handler
|
|
36
|
-
server.setRequestHandler(CallToolRequestSchema, async (request): Promise<CallToolResult> => {
|
|
37
|
-
const { name, arguments: args } = request.params;
|
|
38
|
-
return handleToolCall(name, args || {});
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Start server
|
|
42
|
-
async function main() {
|
|
43
|
-
const transport = new StdioServerTransport();
|
|
44
|
-
await server.connect(transport);
|
|
45
|
-
console.error('claude-memory-layer MCP server started');
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
main().catch(console.error);
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Tool Definitions
|
|
3
|
-
* Available tools for Claude Desktop
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import type { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
7
|
-
|
|
8
|
-
const projectPathProperty = {
|
|
9
|
-
type: 'string',
|
|
10
|
-
description: 'Optional: absolute project path to search a project-scoped claude-memory-layer store instead of the global store'
|
|
11
|
-
} as const;
|
|
12
|
-
|
|
13
|
-
export const tools: Tool[] = [
|
|
14
|
-
{
|
|
15
|
-
name: 'external-market-context',
|
|
16
|
-
description: 'Read-only external market/company context from DART, FRED, and Finnhub with structured MarketContextSnapshot bull/bear/risk/catalyst analysis.',
|
|
17
|
-
inputSchema: {
|
|
18
|
-
type: 'object',
|
|
19
|
-
properties: {
|
|
20
|
-
company: { type: 'string', description: 'Optional company name for report subject and DART fallback search' },
|
|
21
|
-
dartCorpCode: { type: 'string', description: 'Optional exact DART corp_code for issuer-specific filings' },
|
|
22
|
-
symbol: { type: 'string', description: 'Optional listed ticker for Finnhub company profile' },
|
|
23
|
-
providers: { type: 'array', items: { type: 'string', enum: ['dart', 'fred', 'finnhub'] }, description: 'Providers to fetch (default: dart, fred, finnhub)' },
|
|
24
|
-
fredSeries: { type: 'array', items: { type: 'string' }, description: 'Optional FRED series IDs (default: FEDFUNDS, CPIAUCSL, UNRATE)' },
|
|
25
|
-
includeSnapshot: { type: 'boolean', description: 'Include structured MarketContextSnapshot and DART company snapshot (default: true)' },
|
|
26
|
-
projectPath: projectPathProperty
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
name: 'mem-search',
|
|
32
|
-
description: 'Search claude-memory-layer for relevant past conversations and insights. Returns a compact index of results - use mem-details to get full content.',
|
|
33
|
-
inputSchema: {
|
|
34
|
-
type: 'object',
|
|
35
|
-
properties: {
|
|
36
|
-
query: {
|
|
37
|
-
type: 'string',
|
|
38
|
-
description: 'Natural language search query'
|
|
39
|
-
},
|
|
40
|
-
topK: {
|
|
41
|
-
type: 'number',
|
|
42
|
-
description: 'Maximum number of results (default: 5, max: 20)'
|
|
43
|
-
},
|
|
44
|
-
sessionId: {
|
|
45
|
-
type: 'string',
|
|
46
|
-
description: 'Optional: filter by specific session ID'
|
|
47
|
-
},
|
|
48
|
-
projectPath: projectPathProperty,
|
|
49
|
-
eventType: {
|
|
50
|
-
type: 'string',
|
|
51
|
-
enum: ['user_prompt', 'agent_response', 'tool_observation', 'session_summary'],
|
|
52
|
-
description: 'Optional: filter by event type'
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
required: ['query']
|
|
56
|
-
}
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
name: 'mem-timeline',
|
|
60
|
-
description: 'Get chronological context around specific memories. Useful for understanding the conversation flow.',
|
|
61
|
-
inputSchema: {
|
|
62
|
-
type: 'object',
|
|
63
|
-
properties: {
|
|
64
|
-
ids: {
|
|
65
|
-
type: 'array',
|
|
66
|
-
items: { type: 'string' },
|
|
67
|
-
description: 'Memory IDs (from mem-search) to get timeline for'
|
|
68
|
-
},
|
|
69
|
-
windowSize: {
|
|
70
|
-
type: 'number',
|
|
71
|
-
description: 'Number of items before/after each ID (default: 3)'
|
|
72
|
-
},
|
|
73
|
-
projectPath: projectPathProperty
|
|
74
|
-
},
|
|
75
|
-
required: ['ids']
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
name: 'mem-details',
|
|
80
|
-
description: 'Get full content of specific memories. Use after mem-search to get complete information.',
|
|
81
|
-
inputSchema: {
|
|
82
|
-
type: 'object',
|
|
83
|
-
properties: {
|
|
84
|
-
ids: {
|
|
85
|
-
type: 'array',
|
|
86
|
-
items: { type: 'string' },
|
|
87
|
-
description: 'Memory IDs to fetch full details for'
|
|
88
|
-
},
|
|
89
|
-
projectPath: projectPathProperty
|
|
90
|
-
},
|
|
91
|
-
required: ['ids']
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
name: 'mem-stats',
|
|
96
|
-
description: 'Get statistics about the memory storage (total events, sessions, etc.)',
|
|
97
|
-
inputSchema: {
|
|
98
|
-
type: 'object',
|
|
99
|
-
properties: {
|
|
100
|
-
projectPath: projectPathProperty
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
name: 'mem-context-pack',
|
|
106
|
-
description: 'Build a compact, agent-ready project context pack from relevant memories plus recent project timeline. Use at the start of Hermes/Codex work to recover the important project state without reading raw transcripts.',
|
|
107
|
-
inputSchema: {
|
|
108
|
-
type: 'object',
|
|
109
|
-
properties: {
|
|
110
|
-
query: {
|
|
111
|
-
type: 'string',
|
|
112
|
-
description: 'Optional task/topic query. Defaults to recent project context.'
|
|
113
|
-
},
|
|
114
|
-
topK: {
|
|
115
|
-
type: 'number',
|
|
116
|
-
description: 'Maximum relevant memories to include (default: 5, max: 12)'
|
|
117
|
-
},
|
|
118
|
-
recentLimit: {
|
|
119
|
-
type: 'number',
|
|
120
|
-
description: 'Maximum recent events to inspect for project timeline (default: 30, max: 200)'
|
|
121
|
-
},
|
|
122
|
-
sessionLimit: {
|
|
123
|
-
type: 'number',
|
|
124
|
-
description: 'Maximum recent sessions to summarize (default: 5, max: 20)'
|
|
125
|
-
},
|
|
126
|
-
sessionId: {
|
|
127
|
-
type: 'string',
|
|
128
|
-
description: 'Optional: filter relevant memories by specific session ID'
|
|
129
|
-
},
|
|
130
|
-
projectPath: projectPathProperty,
|
|
131
|
-
refreshLatest: {
|
|
132
|
-
type: 'boolean',
|
|
133
|
-
description: 'Explicit opt-in: import latest local session history before retrieval. Requires absolute projectPath and mutates project memory (default: false).'
|
|
134
|
-
},
|
|
135
|
-
refreshSources: {
|
|
136
|
-
type: 'array',
|
|
137
|
-
items: { type: 'string', enum: ['claude', 'codex', 'hermes'] },
|
|
138
|
-
description: 'Sources to refresh when refreshLatest is true (default: hermes and codex)'
|
|
139
|
-
},
|
|
140
|
-
refreshSessionLimit: {
|
|
141
|
-
type: 'number',
|
|
142
|
-
description: 'Maximum recent matching sessions per refresh source (default: 1, max: 10)'
|
|
143
|
-
},
|
|
144
|
-
refreshMessageLimit: {
|
|
145
|
-
type: 'number',
|
|
146
|
-
description: 'Maximum messages/memories per refresh source (default: 200, max: 1000)'
|
|
147
|
-
},
|
|
148
|
-
refreshForce: {
|
|
149
|
-
type: 'boolean',
|
|
150
|
-
description: 'Force reimport during refresh by deleting existing events for imported sessions first (default: false)'
|
|
151
|
-
},
|
|
152
|
-
refreshEmbeddings: {
|
|
153
|
-
type: 'boolean',
|
|
154
|
-
description: 'Process pending embeddings after refresh (default: false for fast context retrieval)'
|
|
155
|
-
},
|
|
156
|
-
sessionsDir: {
|
|
157
|
-
type: 'string',
|
|
158
|
-
description: 'Optional Codex sessions directory override for refreshLatest'
|
|
159
|
-
},
|
|
160
|
-
stateDb: {
|
|
161
|
-
type: 'string',
|
|
162
|
-
description: 'Optional Hermes state database path override for refreshLatest'
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'mem-import-latest',
|
|
169
|
-
description: 'Explicitly import the latest local Claude Code, Codex, and/or Hermes session history into project-scoped memory before retrieving context. This mutates memory; use for freshness jobs before mem-context-pack.',
|
|
170
|
-
inputSchema: {
|
|
171
|
-
type: 'object',
|
|
172
|
-
properties: {
|
|
173
|
-
projectPath: {
|
|
174
|
-
type: 'string',
|
|
175
|
-
description: 'Required absolute project path. Import is always project-scoped to avoid cross-project memory mixing.'
|
|
176
|
-
},
|
|
177
|
-
sources: {
|
|
178
|
-
type: 'array',
|
|
179
|
-
items: { type: 'string', enum: ['claude', 'codex', 'hermes'] },
|
|
180
|
-
description: 'Sources to import (default: hermes and codex)'
|
|
181
|
-
},
|
|
182
|
-
sessionLimit: {
|
|
183
|
-
type: 'number',
|
|
184
|
-
description: 'Maximum recent matching sessions per source to import (default: 1, max: 10)'
|
|
185
|
-
},
|
|
186
|
-
messageLimit: {
|
|
187
|
-
type: 'number',
|
|
188
|
-
description: 'Maximum messages/memories per source import (default: 200, max: 1000)'
|
|
189
|
-
},
|
|
190
|
-
force: {
|
|
191
|
-
type: 'boolean',
|
|
192
|
-
description: 'Force reimport by deleting existing events for imported sessions first (default: false)'
|
|
193
|
-
},
|
|
194
|
-
processEmbeddings: {
|
|
195
|
-
type: 'boolean',
|
|
196
|
-
description: 'Process pending embeddings after import (default: false for fast freshness imports)'
|
|
197
|
-
},
|
|
198
|
-
sessionsDir: {
|
|
199
|
-
type: 'string',
|
|
200
|
-
description: 'Optional Codex sessions directory override'
|
|
201
|
-
},
|
|
202
|
-
stateDb: {
|
|
203
|
-
type: 'string',
|
|
204
|
-
description: 'Optional Hermes state database path override'
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
required: ['projectPath']
|
|
208
|
-
}
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
name: 'mem-project-timeline',
|
|
212
|
-
description: 'Summarize recent project memory by session, source agent, event counts, and safe previews. Useful for understanding what happened recently before continuing work.',
|
|
213
|
-
inputSchema: {
|
|
214
|
-
type: 'object',
|
|
215
|
-
properties: {
|
|
216
|
-
limit: {
|
|
217
|
-
type: 'number',
|
|
218
|
-
description: 'Maximum recent events to inspect (default: 50, max: 500)'
|
|
219
|
-
},
|
|
220
|
-
sessionLimit: {
|
|
221
|
-
type: 'number',
|
|
222
|
-
description: 'Maximum sessions to summarize (default: 10, max: 50)'
|
|
223
|
-
},
|
|
224
|
-
projectPath: projectPathProperty
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
name: 'mem-source-ref',
|
|
230
|
-
description: 'Resolve memory IDs, mem citation IDs, or event: IDs into privacy-safe source references with redacted previews and safe metadata only. Prefer this before mem-details when raw transcript exposure is unnecessary.',
|
|
231
|
-
inputSchema: {
|
|
232
|
-
type: 'object',
|
|
233
|
-
properties: {
|
|
234
|
-
ids: {
|
|
235
|
-
type: 'array',
|
|
236
|
-
items: { type: 'string' },
|
|
237
|
-
description: 'Memory/event IDs to resolve. Accepts full event IDs, event:<id>, mem:<citation>, or bare citation IDs.'
|
|
238
|
-
},
|
|
239
|
-
maxContentChars: {
|
|
240
|
-
type: 'number',
|
|
241
|
-
description: 'Maximum redacted preview characters per source (default: 500, max: 2000)'
|
|
242
|
-
},
|
|
243
|
-
lookupLimit: {
|
|
244
|
-
type: 'number',
|
|
245
|
-
description: 'Maximum recent events to scan for ID resolution (default: 10000, max: 50000)'
|
|
246
|
-
},
|
|
247
|
-
projectPath: projectPathProperty
|
|
248
|
-
},
|
|
249
|
-
required: ['ids']
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './shared-memory-services.js';
|
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
import * as fs from 'fs';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import type { Embedder } from '../vector/index.js';
|
|
4
|
-
import { createSharedEventStore, type SharedEventStore } from '../../core/shared-event-store.js';
|
|
5
|
-
import { createSharedPromoter, type PromotionResult, type SharedPromoter } from '../../core/shared-promoter.js';
|
|
6
|
-
import { createSharedStore, type SharedStore } from '../../core/shared-store.js';
|
|
7
|
-
import { createSharedVectorStore, type SharedVectorStore } from '../../core/shared-vector-store.js';
|
|
8
|
-
import type { Entry, SharedStoreConfig, SharedTroubleshootingEntry } from '../../core/types.js';
|
|
9
|
-
|
|
10
|
-
export interface SharedMemoryRetriever {
|
|
11
|
-
setSharedStores(sharedStore: SharedStore, sharedVectorStore: SharedVectorStore): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface SharedMemoryServicesFactories {
|
|
15
|
-
existsSync?: (targetPath: string) => boolean;
|
|
16
|
-
mkdirSync?: (targetPath: string) => void;
|
|
17
|
-
createSharedEventStore?: (dbPath: string) => SharedEventStore;
|
|
18
|
-
createSharedStore?: (sharedEventStore: SharedEventStore) => SharedStore;
|
|
19
|
-
createSharedVectorStore?: (dbPath: string) => SharedVectorStore;
|
|
20
|
-
createSharedPromoter?: (
|
|
21
|
-
sharedStore: SharedStore,
|
|
22
|
-
sharedVectorStore: SharedVectorStore,
|
|
23
|
-
embedder: Embedder,
|
|
24
|
-
config?: SharedStoreConfig
|
|
25
|
-
) => SharedPromoter;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface SharedMemoryServicesOptions {
|
|
29
|
-
config: SharedStoreConfig | null;
|
|
30
|
-
defaultSharedStoragePath: string;
|
|
31
|
-
readOnly: boolean;
|
|
32
|
-
expandPath: (targetPath: string) => string;
|
|
33
|
-
embedder: Embedder;
|
|
34
|
-
retriever: SharedMemoryRetriever;
|
|
35
|
-
factories?: SharedMemoryServicesFactories;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export type SharedStoreStats = {
|
|
39
|
-
total: number;
|
|
40
|
-
averageConfidence: number;
|
|
41
|
-
topTopics: Array<{ topic: string; count: number }>;
|
|
42
|
-
totalUsageCount: number;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export class SharedMemoryServices {
|
|
46
|
-
private sharedEventStore: SharedEventStore | null = null;
|
|
47
|
-
private sharedStore: SharedStore | null = null;
|
|
48
|
-
private sharedVectorStore: SharedVectorStore | null = null;
|
|
49
|
-
private sharedPromoter: SharedPromoter | null = null;
|
|
50
|
-
private openStorePromise: Promise<SharedStore> | null = null;
|
|
51
|
-
|
|
52
|
-
constructor(private readonly options: SharedMemoryServicesOptions) {}
|
|
53
|
-
|
|
54
|
-
get eventStore(): SharedEventStore | null {
|
|
55
|
-
return this.sharedEventStore;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
get store(): SharedStore | null {
|
|
59
|
-
return this.sharedStore;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
get vectorStore(): SharedVectorStore | null {
|
|
63
|
-
return this.sharedVectorStore;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
get promoter(): SharedPromoter | null {
|
|
67
|
-
return this.sharedPromoter;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
isEnabled(): boolean {
|
|
71
|
-
return this.sharedStore !== null;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
getSharedStoragePath(): string {
|
|
75
|
-
return this.options.config?.sharedStoragePath
|
|
76
|
-
? this.options.expandPath(this.options.config.sharedStoragePath)
|
|
77
|
-
: this.options.defaultSharedStoragePath;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
async initialize(): Promise<void> {
|
|
81
|
-
if (this.options.config?.enabled === false || this.options.readOnly) return;
|
|
82
|
-
|
|
83
|
-
const sharedPath = this.getSharedStoragePath();
|
|
84
|
-
this.ensureDirectory(sharedPath, { allowCreate: true });
|
|
85
|
-
|
|
86
|
-
const store = await this.openStore(sharedPath);
|
|
87
|
-
|
|
88
|
-
this.sharedVectorStore = this.factories.createSharedVectorStore(
|
|
89
|
-
path.join(sharedPath, 'vectors')
|
|
90
|
-
);
|
|
91
|
-
await this.sharedVectorStore.initialize();
|
|
92
|
-
|
|
93
|
-
this.sharedPromoter = this.factories.createSharedPromoter(
|
|
94
|
-
store,
|
|
95
|
-
this.sharedVectorStore,
|
|
96
|
-
this.options.embedder,
|
|
97
|
-
this.options.config || undefined
|
|
98
|
-
);
|
|
99
|
-
|
|
100
|
-
this.options.retriever.setSharedStores(store, this.sharedVectorStore);
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
async ensureStoreForRead(): Promise<SharedStore | null> {
|
|
104
|
-
if (this.options.config?.enabled === false) return null;
|
|
105
|
-
if (this.sharedStore) return this.sharedStore;
|
|
106
|
-
|
|
107
|
-
const sharedPath = this.getSharedStoragePath();
|
|
108
|
-
const directoryReady = this.ensureDirectory(sharedPath, { allowCreate: !this.options.readOnly });
|
|
109
|
-
if (!directoryReady) return null;
|
|
110
|
-
|
|
111
|
-
return this.openStore(sharedPath);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
async getEntryForDisclosure(entryId: string): Promise<SharedTroubleshootingEntry | null> {
|
|
115
|
-
const store = await this.ensureStoreForRead();
|
|
116
|
-
return store?.get(entryId) ?? null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
async promoteToShared(entry: Entry, projectHash: string | null): Promise<PromotionResult> {
|
|
120
|
-
if (!this.sharedPromoter || !projectHash) {
|
|
121
|
-
return {
|
|
122
|
-
success: false,
|
|
123
|
-
error: 'Shared store not initialized or project hash not set'
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
return this.sharedPromoter.promoteEntry(entry, projectHash);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
async getStats(): Promise<SharedStoreStats | null> {
|
|
131
|
-
if (!this.sharedStore) return null;
|
|
132
|
-
return this.sharedStore.getStats();
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
async search(
|
|
136
|
-
query: string,
|
|
137
|
-
options?: { topK?: number; minConfidence?: number }
|
|
138
|
-
): Promise<SharedTroubleshootingEntry[]> {
|
|
139
|
-
if (!this.sharedStore) return [];
|
|
140
|
-
return this.sharedStore.search(query, options);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
async close(): Promise<void> {
|
|
144
|
-
if (this.openStorePromise) {
|
|
145
|
-
await this.openStorePromise.catch(() => null);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (this.sharedEventStore) {
|
|
149
|
-
await this.sharedEventStore.close();
|
|
150
|
-
}
|
|
151
|
-
this.sharedEventStore = null;
|
|
152
|
-
this.sharedStore = null;
|
|
153
|
-
this.sharedVectorStore = null;
|
|
154
|
-
this.sharedPromoter = null;
|
|
155
|
-
this.openStorePromise = null;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
private async openStore(sharedPath: string): Promise<SharedStore> {
|
|
159
|
-
if (this.sharedStore) return this.sharedStore;
|
|
160
|
-
|
|
161
|
-
if (!this.openStorePromise) {
|
|
162
|
-
this.openStorePromise = this.createOpenStorePromise(sharedPath);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
try {
|
|
166
|
-
return await this.openStorePromise;
|
|
167
|
-
} finally {
|
|
168
|
-
this.openStorePromise = null;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
private async createOpenStorePromise(sharedPath: string): Promise<SharedStore> {
|
|
173
|
-
if (!this.sharedEventStore) {
|
|
174
|
-
const sharedEventStore = this.factories.createSharedEventStore(
|
|
175
|
-
path.join(sharedPath, 'shared.duckdb')
|
|
176
|
-
);
|
|
177
|
-
await sharedEventStore.initialize();
|
|
178
|
-
this.sharedEventStore = sharedEventStore;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (!this.sharedStore) {
|
|
182
|
-
this.sharedStore = this.factories.createSharedStore(this.sharedEventStore);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return this.sharedStore;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private ensureDirectory(sharedPath: string, options: { allowCreate: boolean }): boolean {
|
|
189
|
-
if (this.factories.existsSync(sharedPath)) return true;
|
|
190
|
-
if (!options.allowCreate) return false;
|
|
191
|
-
this.factories.mkdirSync(sharedPath);
|
|
192
|
-
return true;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
private get factories(): Required<SharedMemoryServicesFactories> {
|
|
196
|
-
return {
|
|
197
|
-
existsSync: this.options.factories?.existsSync ?? fs.existsSync,
|
|
198
|
-
mkdirSync: this.options.factories?.mkdirSync ?? ((targetPath: string) => {
|
|
199
|
-
fs.mkdirSync(targetPath, { recursive: true });
|
|
200
|
-
}),
|
|
201
|
-
createSharedEventStore: this.options.factories?.createSharedEventStore ?? createSharedEventStore,
|
|
202
|
-
createSharedStore: this.options.factories?.createSharedStore ?? createSharedStore,
|
|
203
|
-
createSharedVectorStore: this.options.factories?.createSharedVectorStore ?? createSharedVectorStore,
|
|
204
|
-
createSharedPromoter: this.options.factories?.createSharedPromoter ?? createSharedPromoter
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
export function createSharedMemoryServices(options: SharedMemoryServicesOptions): SharedMemoryServices {
|
|
210
|
-
return new SharedMemoryServices(options);
|
|
211
|
-
}
|