squish-memory 1.2.0 → 1.2.1
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/bin/squish-mcp.mjs +40 -42
- package/core/scheduler/cron-scheduler.ts +10 -1
- package/core/worker.ts +10 -1
- package/package.json +119 -119
- package/packages/mcp/src/index.ts +99 -36
- package/dist/config.d.ts +0 -106
- package/dist/config.js +0 -194
- package/dist/core/adapters/config/claude-code.d.ts +0 -45
- package/dist/core/adapters/config/claude-code.js +0 -113
- package/dist/core/adapters/config/cursor.d.ts +0 -26
- package/dist/core/adapters/config/cursor.js +0 -74
- package/dist/core/adapters/config/opencode.d.ts +0 -23
- package/dist/core/adapters/config/opencode.js +0 -73
- package/dist/core/adapters/config/windsurf.d.ts +0 -26
- package/dist/core/adapters/config/windsurf.js +0 -74
- package/dist/core/adapters/index.d.ts +0 -45
- package/dist/core/adapters/index.js +0 -84
- package/dist/core/adapters/scripts/install-adapter.d.ts +0 -19
- package/dist/core/adapters/scripts/install-adapter.js +0 -149
- package/dist/core/adapters/timeline.d.ts +0 -23
- package/dist/core/adapters/timeline.js +0 -88
- package/dist/core/adapters/types.d.ts +0 -137
- package/dist/core/adapters/types.js +0 -50
- package/dist/core/agent-preferences.d.ts +0 -16
- package/dist/core/agent-preferences.js +0 -124
- package/dist/core/algorithms/analytics/token-estimator.d.ts +0 -50
- package/dist/core/algorithms/analytics/token-estimator.js +0 -154
- package/dist/core/algorithms/detection/hash-filters.d.ts +0 -47
- package/dist/core/algorithms/detection/hash-filters.js +0 -190
- package/dist/core/algorithms/detection/semantic-ranker.d.ts +0 -32
- package/dist/core/algorithms/detection/semantic-ranker.js +0 -118
- package/dist/core/algorithms/detection/two-stage-detector.d.ts +0 -52
- package/dist/core/algorithms/detection/two-stage-detector.js +0 -299
- package/dist/core/algorithms/handlers/approve-merge.d.ts +0 -22
- package/dist/core/algorithms/handlers/approve-merge.js +0 -179
- package/dist/core/algorithms/handlers/detect-duplicates.d.ts +0 -47
- package/dist/core/algorithms/handlers/detect-duplicates.js +0 -145
- package/dist/core/algorithms/handlers/get-stats.d.ts +0 -39
- package/dist/core/algorithms/handlers/get-stats.js +0 -88
- package/dist/core/algorithms/handlers/list-proposals.d.ts +0 -45
- package/dist/core/algorithms/handlers/list-proposals.js +0 -83
- package/dist/core/algorithms/handlers/preview-merge.d.ts +0 -39
- package/dist/core/algorithms/handlers/preview-merge.js +0 -93
- package/dist/core/algorithms/handlers/reject-merge.d.ts +0 -28
- package/dist/core/algorithms/handlers/reject-merge.js +0 -69
- package/dist/core/algorithms/handlers/reverse-merge.d.ts +0 -21
- package/dist/core/algorithms/handlers/reverse-merge.js +0 -121
- package/dist/core/algorithms/index.d.ts +0 -21
- package/dist/core/algorithms/index.js +0 -26
- package/dist/core/algorithms/operations/cache-maintenance.d.ts +0 -12
- package/dist/core/algorithms/operations/cache-maintenance.js +0 -157
- package/dist/core/algorithms/safety/safety-checks.d.ts +0 -18
- package/dist/core/algorithms/safety/safety-checks.js +0 -179
- package/dist/core/algorithms/strategies/merge-strategies.d.ts +0 -50
- package/dist/core/algorithms/strategies/merge-strategies.js +0 -288
- package/dist/core/algorithms/types.d.ts +0 -125
- package/dist/core/algorithms/types.js +0 -5
- package/dist/core/algorithms/utils/response-builder.d.ts +0 -28
- package/dist/core/algorithms/utils/response-builder.js +0 -37
- package/dist/core/associations.d.ts +0 -33
- package/dist/core/associations.js +0 -284
- package/dist/core/autosave.d.ts +0 -19
- package/dist/core/autosave.js +0 -16
- package/dist/core/beliefs/decay.d.ts +0 -27
- package/dist/core/beliefs/decay.js +0 -217
- package/dist/core/beliefs/extractor.d.ts +0 -9
- package/dist/core/beliefs/extractor.js +0 -113
- package/dist/core/beliefs/store.d.ts +0 -46
- package/dist/core/beliefs/store.js +0 -466
- package/dist/core/beliefs/types.d.ts +0 -28
- package/dist/core/beliefs/types.js +0 -2
- package/dist/core/commands/mcp-server.d.ts +0 -2
- package/dist/core/commands/mcp-server.js +0 -6
- package/dist/core/commands/remember.d.ts +0 -24
- package/dist/core/commands/remember.js +0 -144
- package/dist/core/compression.d.ts +0 -45
- package/dist/core/compression.js +0 -160
- package/dist/core/consolidation.d.ts +0 -37
- package/dist/core/consolidation.js +0 -248
- package/dist/core/context/agent-context.d.ts +0 -106
- package/dist/core/context/agent-context.js +0 -274
- package/dist/core/context/context-paging.d.ts +0 -80
- package/dist/core/context/context-paging.js +0 -328
- package/dist/core/context/context-window.d.ts +0 -40
- package/dist/core/context/context-window.js +0 -177
- package/dist/core/context/context.d.ts +0 -7
- package/dist/core/context/context.js +0 -22
- package/dist/core/embeddings/embeddings.d.ts +0 -29
- package/dist/core/embeddings/embeddings.js +0 -546
- package/dist/core/embeddings/google-multimodal.d.ts +0 -14
- package/dist/core/embeddings/google-multimodal.js +0 -146
- package/dist/core/embeddings/local-embeddings.d.ts +0 -11
- package/dist/core/embeddings/local-embeddings.js +0 -11
- package/dist/core/embeddings/qmd-client.d.ts +0 -136
- package/dist/core/embeddings/qmd-client.js +0 -403
- package/dist/core/embeddings/transformers-local.d.ts +0 -64
- package/dist/core/embeddings/transformers-local.js +0 -213
- package/dist/core/embeddings.d.ts +0 -2
- package/dist/core/embeddings.js +0 -3
- package/dist/core/error-handling.d.ts +0 -63
- package/dist/core/error-handling.js +0 -173
- package/dist/core/graph/entity-deduplicator.d.ts +0 -24
- package/dist/core/graph/entity-deduplicator.js +0 -183
- package/dist/core/graph/graph-builder.d.ts +0 -46
- package/dist/core/graph/graph-builder.js +0 -174
- package/dist/core/graph/graph-traversal.d.ts +0 -80
- package/dist/core/graph/graph-traversal.js +0 -315
- package/dist/core/graph/index.d.ts +0 -19
- package/dist/core/graph/index.js +0 -13
- package/dist/core/graph/llm-entity-extractor.d.ts +0 -49
- package/dist/core/graph/llm-entity-extractor.js +0 -313
- package/dist/core/graph/multi-hop-retrieval.d.ts +0 -48
- package/dist/core/graph/multi-hop-retrieval.js +0 -215
- package/dist/core/graph/relationship-extractor.d.ts +0 -48
- package/dist/core/graph/relationship-extractor.js +0 -351
- package/dist/core/hooks/agent-hooks.d.ts +0 -83
- package/dist/core/hooks/agent-hooks.js +0 -521
- package/dist/core/hooks/auto-tagger.d.ts +0 -19
- package/dist/core/hooks/auto-tagger.js +0 -155
- package/dist/core/hooks/capture-filter.d.ts +0 -41
- package/dist/core/hooks/capture-filter.js +0 -128
- package/dist/core/hot-cache.d.ts +0 -86
- package/dist/core/hot-cache.js +0 -285
- package/dist/core/index.d.ts +0 -10
- package/dist/core/index.js +0 -11
- package/dist/core/ingestion/agent-memory.d.ts +0 -22
- package/dist/core/ingestion/agent-memory.js +0 -109
- package/dist/core/ingestion/core-memory.d.ts +0 -78
- package/dist/core/ingestion/core-memory.js +0 -226
- package/dist/core/ingestion/learnings.d.ts +0 -57
- package/dist/core/ingestion/learnings.js +0 -205
- package/dist/core/ingestion/signal-engine.d.ts +0 -41
- package/dist/core/ingestion/signal-engine.js +0 -201
- package/dist/core/integrations/obsidian-vault.d.ts +0 -31
- package/dist/core/integrations/obsidian-vault.js +0 -156
- package/dist/core/layers/generator.d.ts +0 -25
- package/dist/core/layers/generator.js +0 -76
- package/dist/core/lib/db-client.d.ts +0 -114
- package/dist/core/lib/db-client.js +0 -130
- package/dist/core/lib/parse-embedding.d.ts +0 -9
- package/dist/core/lib/parse-embedding.js +0 -58
- package/dist/core/lib/schemas.d.ts +0 -132
- package/dist/core/lib/schemas.js +0 -87
- package/dist/core/lib/types.d.ts +0 -45
- package/dist/core/lib/types.js +0 -6
- package/dist/core/lib/utils.d.ts +0 -18
- package/dist/core/lib/utils.js +0 -145
- package/dist/core/lib/validation.d.ts +0 -38
- package/dist/core/lib/validation.js +0 -151
- package/dist/core/lifecycle.d.ts +0 -25
- package/dist/core/lifecycle.js +0 -292
- package/dist/core/logger.d.ts +0 -17
- package/dist/core/logger.js +0 -46
- package/dist/core/mcp/client.d.ts +0 -17
- package/dist/core/mcp/client.js +0 -101
- package/dist/core/mcp/index.d.ts +0 -6
- package/dist/core/mcp/index.js +0 -6
- package/dist/core/mcp/server.d.ts +0 -18
- package/dist/core/mcp/server.js +0 -157
- package/dist/core/mcp/standalone-server.d.ts +0 -13
- package/dist/core/mcp/standalone-server.js +0 -46
- package/dist/core/mcp/tools.d.ts +0 -7
- package/dist/core/mcp/tools.js +0 -278
- package/dist/core/mcp/types.d.ts +0 -87
- package/dist/core/mcp/types.js +0 -48
- package/dist/core/memory/bridge-discovery.d.ts +0 -50
- package/dist/core/memory/bridge-discovery.js +0 -291
- package/dist/core/memory/categorizer.d.ts +0 -27
- package/dist/core/memory/categorizer.js +0 -306
- package/dist/core/memory/conflict-detector.d.ts +0 -7
- package/dist/core/memory/conflict-detector.js +0 -43
- package/dist/core/memory/consolidation.d.ts +0 -42
- package/dist/core/memory/consolidation.js +0 -277
- package/dist/core/memory/context-collector.d.ts +0 -10
- package/dist/core/memory/context-collector.js +0 -56
- package/dist/core/memory/contradiction-resolver.d.ts +0 -40
- package/dist/core/memory/contradiction-resolver.js +0 -368
- package/dist/core/memory/edit-workflow.d.ts +0 -19
- package/dist/core/memory/edit-workflow.js +0 -120
- package/dist/core/memory/entity-extractor.d.ts +0 -37
- package/dist/core/memory/entity-extractor.js +0 -350
- package/dist/core/memory/entity-resolver.d.ts +0 -23
- package/dist/core/memory/entity-resolver.js +0 -64
- package/dist/core/memory/explain.d.ts +0 -18
- package/dist/core/memory/explain.js +0 -92
- package/dist/core/memory/fact-deriver.d.ts +0 -31
- package/dist/core/memory/fact-deriver.js +0 -236
- package/dist/core/memory/fact-extractor.d.ts +0 -24
- package/dist/core/memory/fact-extractor.js +0 -89
- package/dist/core/memory/feedback-tracker.d.ts +0 -12
- package/dist/core/memory/feedback-tracker.js +0 -155
- package/dist/core/memory/hooks.d.ts +0 -88
- package/dist/core/memory/hooks.js +0 -174
- package/dist/core/memory/hybrid-retrieval.d.ts +0 -27
- package/dist/core/memory/hybrid-retrieval.js +0 -37
- package/dist/core/memory/hybrid-scorer.d.ts +0 -40
- package/dist/core/memory/hybrid-scorer.js +0 -267
- package/dist/core/memory/hybrid-search.d.ts +0 -23
- package/dist/core/memory/hybrid-search.js +0 -596
- package/dist/core/memory/importance.d.ts +0 -46
- package/dist/core/memory/importance.js +0 -241
- package/dist/core/memory/index.d.ts +0 -9
- package/dist/core/memory/index.js +0 -11
- package/dist/core/memory/loader.d.ts +0 -31
- package/dist/core/memory/loader.js +0 -141
- package/dist/core/memory/markdown/markdown-storage.d.ts +0 -72
- package/dist/core/memory/markdown/markdown-storage.js +0 -243
- package/dist/core/memory/memories.d.ts +0 -43
- package/dist/core/memory/memories.js +0 -452
- package/dist/core/memory/memory-lifecycle.d.ts +0 -8
- package/dist/core/memory/memory-lifecycle.js +0 -47
- package/dist/core/memory/memory-manager.d.ts +0 -15
- package/dist/core/memory/memory-manager.js +0 -46
- package/dist/core/memory/migrate.d.ts +0 -21
- package/dist/core/memory/migrate.js +0 -134
- package/dist/core/memory/normalization.d.ts +0 -7
- package/dist/core/memory/normalization.js +0 -26
- package/dist/core/memory/path-strengthener.d.ts +0 -39
- package/dist/core/memory/path-strengthener.js +0 -150
- package/dist/core/memory/progressive-disclosure.d.ts +0 -43
- package/dist/core/memory/progressive-disclosure.js +0 -280
- package/dist/core/memory/query-processor.d.ts +0 -21
- package/dist/core/memory/query-processor.js +0 -106
- package/dist/core/memory/query-rewriter.d.ts +0 -13
- package/dist/core/memory/query-rewriter.js +0 -118
- package/dist/core/memory/response-analyzer.d.ts +0 -9
- package/dist/core/memory/response-analyzer.js +0 -61
- package/dist/core/memory/retrieval-feedback.d.ts +0 -70
- package/dist/core/memory/retrieval-feedback.js +0 -213
- package/dist/core/memory/serialization.d.ts +0 -10
- package/dist/core/memory/serialization.js +0 -84
- package/dist/core/memory/stale-cleaner.d.ts +0 -26
- package/dist/core/memory/stale-cleaner.js +0 -97
- package/dist/core/memory/stats.d.ts +0 -32
- package/dist/core/memory/stats.js +0 -143
- package/dist/core/memory/telemetry.d.ts +0 -69
- package/dist/core/memory/telemetry.js +0 -313
- package/dist/core/memory/temporal-facts.d.ts +0 -41
- package/dist/core/memory/temporal-facts.js +0 -283
- package/dist/core/memory/temporal-parser.d.ts +0 -32
- package/dist/core/memory/temporal-parser.js +0 -385
- package/dist/core/memory/trigger-detector.d.ts +0 -21
- package/dist/core/memory/trigger-detector.js +0 -79
- package/dist/core/memory/write-gate.d.ts +0 -54
- package/dist/core/memory/write-gate.js +0 -210
- package/dist/core/places/index.d.ts +0 -14
- package/dist/core/places/index.js +0 -14
- package/dist/core/places/memory-places.d.ts +0 -68
- package/dist/core/places/memory-places.js +0 -261
- package/dist/core/places/places.d.ts +0 -88
- package/dist/core/places/places.js +0 -314
- package/dist/core/places/rules.d.ts +0 -74
- package/dist/core/places/rules.js +0 -240
- package/dist/core/places/walking.d.ts +0 -56
- package/dist/core/places/walking.js +0 -121
- package/dist/core/projects.d.ts +0 -17
- package/dist/core/projects.js +0 -116
- package/dist/core/redis.d.ts +0 -11
- package/dist/core/redis.js +0 -69
- package/dist/core/responses.d.ts +0 -96
- package/dist/core/responses.js +0 -122
- package/dist/core/runtime/trust-report.d.ts +0 -102
- package/dist/core/runtime/trust-report.js +0 -107
- package/dist/core/runtime/trust-state.d.ts +0 -12
- package/dist/core/runtime/trust-state.js +0 -309
- package/dist/core/scheduler/cron-scheduler.d.ts +0 -32
- package/dist/core/scheduler/cron-scheduler.js +0 -493
- package/dist/core/scheduler/heartbeat.d.ts +0 -11
- package/dist/core/scheduler/heartbeat.js +0 -73
- package/dist/core/scheduler/index.d.ts +0 -8
- package/dist/core/scheduler/index.js +0 -8
- package/dist/core/scheduler/job-runner.d.ts +0 -11
- package/dist/core/scheduler/job-runner.js +0 -164
- package/dist/core/search/conversations.d.ts +0 -25
- package/dist/core/search/conversations.js +0 -110
- package/dist/core/search/entities.d.ts +0 -12
- package/dist/core/search/entities.js +0 -31
- package/dist/core/search/folder-context.d.ts +0 -25
- package/dist/core/search/folder-context.js +0 -119
- package/dist/core/search/graph-boost.d.ts +0 -7
- package/dist/core/search/graph-boost.js +0 -23
- package/dist/core/search/index.d.ts +0 -4
- package/dist/core/search/index.js +0 -5
- package/dist/core/search/qmd-wrapper.d.ts +0 -36
- package/dist/core/search/qmd-wrapper.js +0 -58
- package/dist/core/security/encrypt.d.ts +0 -6
- package/dist/core/security/encrypt.js +0 -47
- package/dist/core/security/governance.d.ts +0 -26
- package/dist/core/security/governance.js +0 -79
- package/dist/core/security/privacy.d.ts +0 -23
- package/dist/core/security/privacy.js +0 -82
- package/dist/core/security/secret-detector.d.ts +0 -32
- package/dist/core/security/secret-detector.js +0 -88
- package/dist/core/session/auto-load.d.ts +0 -6
- package/dist/core/session/auto-load.js +0 -144
- package/dist/core/session/entity-tracker.d.ts +0 -62
- package/dist/core/session/entity-tracker.js +0 -287
- package/dist/core/session/index.d.ts +0 -7
- package/dist/core/session/index.js +0 -7
- package/dist/core/session/reference-resolver.d.ts +0 -26
- package/dist/core/session/reference-resolver.js +0 -121
- package/dist/core/session/self-iteration-job.d.ts +0 -35
- package/dist/core/session/self-iteration-job.js +0 -387
- package/dist/core/session/session-hooks.d.ts +0 -18
- package/dist/core/session/session-hooks.js +0 -58
- package/dist/core/session/types.d.ts +0 -26
- package/dist/core/session/types.js +0 -10
- package/dist/core/session/working-set.d.ts +0 -50
- package/dist/core/session/working-set.js +0 -212
- package/dist/core/snapshots/cleanup.d.ts +0 -9
- package/dist/core/snapshots/cleanup.js +0 -12
- package/dist/core/snapshots/comparison.d.ts +0 -19
- package/dist/core/snapshots/comparison.js +0 -43
- package/dist/core/snapshots/creation.d.ts +0 -13
- package/dist/core/snapshots/creation.js +0 -117
- package/dist/core/snapshots/retrieval.d.ts +0 -7
- package/dist/core/snapshots/retrieval.js +0 -41
- package/dist/core/snapshots/stats.d.ts +0 -11
- package/dist/core/snapshots/stats.js +0 -52
- package/dist/core/storage/cache.d.ts +0 -13
- package/dist/core/storage/cache.js +0 -202
- package/dist/core/storage/database.d.ts +0 -12
- package/dist/core/storage/database.js +0 -12
- package/dist/core/summarization/cleanup.d.ts +0 -9
- package/dist/core/summarization/cleanup.js +0 -12
- package/dist/core/summarization/queries.d.ts +0 -9
- package/dist/core/summarization/queries.js +0 -28
- package/dist/core/summarization/stats.d.ts +0 -14
- package/dist/core/summarization/stats.js +0 -52
- package/dist/core/summarization/strategies.d.ts +0 -24
- package/dist/core/summarization/strategies.js +0 -28
- package/dist/core/summarization.d.ts +0 -37
- package/dist/core/summarization.js +0 -188
- package/dist/core/temporal-facts.d.ts +0 -54
- package/dist/core/temporal-facts.js +0 -193
- package/dist/core/tracing/collector.d.ts +0 -111
- package/dist/core/tracing/collector.js +0 -350
- package/dist/core/tracing/visualizer.d.ts +0 -32
- package/dist/core/tracing/visualizer.js +0 -165
- package/dist/core/utils/cleanup-operations.d.ts +0 -13
- package/dist/core/utils/cleanup-operations.js +0 -44
- package/dist/core/utils/content-extraction.d.ts +0 -19
- package/dist/core/utils/content-extraction.js +0 -75
- package/dist/core/utils/filter-builder.d.ts +0 -13
- package/dist/core/utils/filter-builder.js +0 -44
- package/dist/core/utils/history-traversal.d.ts +0 -13
- package/dist/core/utils/history-traversal.js +0 -50
- package/dist/core/utils/memory-operations.d.ts +0 -17
- package/dist/core/utils/memory-operations.js +0 -43
- package/dist/core/utils/query-operations.d.ts +0 -18
- package/dist/core/utils/query-operations.js +0 -65
- package/dist/core/utils/summarization-helpers.d.ts +0 -17
- package/dist/core/utils/summarization-helpers.js +0 -33
- package/dist/core/utils/temporal-queries.d.ts +0 -13
- package/dist/core/utils/temporal-queries.js +0 -27
- package/dist/core/utils/vector-operations.d.ts +0 -71
- package/dist/core/utils/vector-operations.js +0 -129
- package/dist/core/utils/version-management.d.ts +0 -9
- package/dist/core/utils/version-management.js +0 -61
- package/dist/core/worker.d.ts +0 -82
- package/dist/core/worker.js +0 -272
- package/dist/db/adapter.d.ts +0 -7
- package/dist/db/adapter.js +0 -175
- package/dist/db/bootstrap.d.ts +0 -11
- package/dist/db/bootstrap.js +0 -1034
- package/dist/db/drizzle/schema-sqlite.d.ts +0 -5538
- package/dist/db/drizzle/schema-sqlite.js +0 -763
- package/dist/db/drizzle/schema.d.ts +0 -4734
- package/dist/db/drizzle/schema.js +0 -859
- package/dist/db/drizzle.config.d.ts +0 -3
- package/dist/db/drizzle.config.js +0 -12
- package/dist/db/index.d.ts +0 -7
- package/dist/db/index.js +0 -89
- package/dist/db/migrations/associations.d.ts +0 -6
- package/dist/db/migrations/associations.js +0 -29
- package/dist/db/migrations/beliefs.d.ts +0 -10
- package/dist/db/migrations/beliefs.js +0 -76
- package/dist/db/migrations/core-memory.d.ts +0 -6
- package/dist/db/migrations/core-memory.js +0 -29
- package/dist/db/migrations/fts.d.ts +0 -6
- package/dist/db/migrations/fts.js +0 -52
- package/dist/db/migrations/index.d.ts +0 -25
- package/dist/db/migrations/index.js +0 -51
- package/dist/db/migrations/indexes.d.ts +0 -6
- package/dist/db/migrations/indexes.js +0 -30
- package/dist/db/migrations/learnings.d.ts +0 -7
- package/dist/db/migrations/learnings.js +0 -26
- package/dist/db/migrations/maintenance.d.ts +0 -6
- package/dist/db/migrations/maintenance.js +0 -61
- package/dist/db/migrations/memories.d.ts +0 -7
- package/dist/db/migrations/memories.js +0 -16
- package/dist/db/migrations/memory-places.d.ts +0 -6
- package/dist/db/migrations/memory-places.js +0 -29
- package/dist/db/migrations/places.d.ts +0 -6
- package/dist/db/migrations/places.js +0 -43
- package/dist/db/migrations/projects.d.ts +0 -3
- package/dist/db/migrations/projects.js +0 -13
- package/dist/db/migrations/tier-conversion.d.ts +0 -7
- package/dist/db/migrations/tier-conversion.js +0 -20
- package/dist/db/neon.d.ts +0 -8
- package/dist/db/neon.js +0 -20
- package/dist/db/schema/beliefs.d.ts +0 -9
- package/dist/db/schema/beliefs.js +0 -46
- package/dist/db/schema/generator.d.ts +0 -38
- package/dist/db/schema/generator.js +0 -108
- package/dist/db/schema/index.d.ts +0 -39
- package/dist/db/schema/index.js +0 -51
- package/dist/db/schema/learnings.d.ts +0 -7
- package/dist/db/schema/learnings.js +0 -30
- package/dist/db/schema/memories.d.ts +0 -7
- package/dist/db/schema/memories.js +0 -81
- package/dist/db/schema/projects.d.ts +0 -4
- package/dist/db/schema/projects.js +0 -31
- package/dist/db/schema/tables/context-sessions.d.ts +0 -9
- package/dist/db/schema/tables/context-sessions.js +0 -37
- package/dist/db/schema/tables/conversations.d.ts +0 -9
- package/dist/db/schema/tables/conversations.js +0 -47
- package/dist/db/schema/tables/core-memory.d.ts +0 -9
- package/dist/db/schema/tables/core-memory.js +0 -41
- package/dist/db/schema/tables/entities.d.ts +0 -9
- package/dist/db/schema/tables/entities.js +0 -39
- package/dist/db/schema/tables/entity-relations.d.ts +0 -9
- package/dist/db/schema/tables/entity-relations.js +0 -31
- package/dist/db/schema/tables/learnings.d.ts +0 -9
- package/dist/db/schema/tables/learnings.js +0 -66
- package/dist/db/schema/tables/memories.d.ts +0 -9
- package/dist/db/schema/tables/memories.js +0 -161
- package/dist/db/schema/tables/memory-associations.d.ts +0 -9
- package/dist/db/schema/tables/memory-associations.js +0 -39
- package/dist/db/schema/tables/memory-hash-cache.d.ts +0 -9
- package/dist/db/schema/tables/memory-hash-cache.js +0 -29
- package/dist/db/schema/tables/memory-merge-history.d.ts +0 -9
- package/dist/db/schema/tables/memory-merge-history.js +0 -33
- package/dist/db/schema/tables/memory-merge-proposals.d.ts +0 -9
- package/dist/db/schema/tables/memory-merge-proposals.js +0 -39
- package/dist/db/schema/tables/messages.d.ts +0 -9
- package/dist/db/schema/tables/messages.js +0 -41
- package/dist/db/schema/tables/namespaces.d.ts +0 -9
- package/dist/db/schema/tables/namespaces.js +0 -37
- package/dist/db/schema/tables/projects.d.ts +0 -9
- package/dist/db/schema/tables/projects.js +0 -31
- package/dist/db/schema/tables/users.d.ts +0 -9
- package/dist/db/schema/tables/users.js +0 -27
- package/dist/db/schema.d.ts +0 -3
- package/dist/db/schema.js +0 -11
- package/dist/db/supabase.d.ts +0 -9
- package/dist/db/supabase.js +0 -24
- package/dist/packages/mcp/src/index.d.ts +0 -3
- package/dist/packages/mcp/src/index.js +0 -733
|
@@ -1,452 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import { eq } from 'drizzle-orm';
|
|
3
|
-
import { config } from '../../config.js';
|
|
4
|
-
import { logger } from '../../core/logger.js';
|
|
5
|
-
import { getOrCreateProject, requireProject } from '../../core/projects.js';
|
|
6
|
-
import { getEmbedding } from '../../core/embeddings.js';
|
|
7
|
-
import { normalizeTags, serializeTags, deserializeTags, serializeMetadata, deserializeMetadata } from '../../core/memory/serialization.js';
|
|
8
|
-
import { normalizeTimestamp, clampLimit, prepareEmbedding } from '../lib/utils.js';
|
|
9
|
-
import { requireUuid } from '../lib/validation.js';
|
|
10
|
-
import { cosineSimilarity } from '../utils/vector-operations.js';
|
|
11
|
-
import { hybridSearch as hybridSearchImpl } from './hybrid-search.js';
|
|
12
|
-
import { calculateImportance } from './importance.js';
|
|
13
|
-
import { detectMemorySignals } from './trigger-detector.js';
|
|
14
|
-
import { resolveContradictions, applySupersession } from './contradiction-resolver.js';
|
|
15
|
-
import { encrypt, decrypt } from '../security/encrypt.js';
|
|
16
|
-
import { estimateTokens } from '../context/context-window.js';
|
|
17
|
-
import { getDbClient } from '../lib/db-client.js';
|
|
18
|
-
import { extractBeliefsFromMemory } from '../beliefs/extractor.js';
|
|
19
|
-
import { upsertBeliefsForMemory } from '../beliefs/store.js';
|
|
20
|
-
import { extractEntityNames } from './entity-extractor.js';
|
|
21
|
-
import { autoLinkByEntities } from '../associations.js';
|
|
22
|
-
import { addMemoryToGraph } from '../graph/graph-builder.js';
|
|
23
|
-
import { parseEmbedding } from '../lib/parse-embedding.js';
|
|
24
|
-
export async function rememberMemory(input) {
|
|
25
|
-
const { db, schema } = await getDbClient();
|
|
26
|
-
const tags = normalizeTags(input.tags);
|
|
27
|
-
const project = await getOrCreateProject(input.project);
|
|
28
|
-
const embedding = await getEmbedding(input.content);
|
|
29
|
-
const id = randomUUID();
|
|
30
|
-
const signals = detectMemorySignals(input.content);
|
|
31
|
-
const type = input.type ?? signals.suggestedType;
|
|
32
|
-
const baseValues = {
|
|
33
|
-
id,
|
|
34
|
-
projectId: project?.id ?? null,
|
|
35
|
-
type,
|
|
36
|
-
content: input.content,
|
|
37
|
-
source: input.source ?? 'mcp',
|
|
38
|
-
};
|
|
39
|
-
// Calculate initial importance score
|
|
40
|
-
const importance = calculateImportance({
|
|
41
|
-
type,
|
|
42
|
-
createdAt: new Date().toISOString(),
|
|
43
|
-
accessCount: 0,
|
|
44
|
-
usageCount: 0,
|
|
45
|
-
isPinned: false,
|
|
46
|
-
isProtected: false,
|
|
47
|
-
isImmutable: false,
|
|
48
|
-
});
|
|
49
|
-
const embeddingValues = prepareEmbedding(embedding);
|
|
50
|
-
const tokensEstimate = estimateTokens(input.content);
|
|
51
|
-
let tagsValue = serializeTags(tags);
|
|
52
|
-
const enrichedMetadata = {
|
|
53
|
-
...(input.metadata ?? {}),
|
|
54
|
-
// Rich context fields (Agent 4 feedback)
|
|
55
|
-
reasoning: input.reasoning,
|
|
56
|
-
memoryContext: input.memoryContext,
|
|
57
|
-
examples: input.examples,
|
|
58
|
-
exceptions: input.exceptions,
|
|
59
|
-
memorySignals: {
|
|
60
|
-
explicitTriggers: signals.explicitTriggers,
|
|
61
|
-
implicit: signals.implicit,
|
|
62
|
-
priority: signals.priority,
|
|
63
|
-
requiresConflictCheck: signals.implicit.correction,
|
|
64
|
-
},
|
|
65
|
-
// Session metadata for temporal queries (Task 1)
|
|
66
|
-
sessionMetadata: {
|
|
67
|
-
sessionId: input.sessionId,
|
|
68
|
-
sessionStartTime: input.sessionStartTime,
|
|
69
|
-
toolName: input.toolName,
|
|
70
|
-
},
|
|
71
|
-
};
|
|
72
|
-
let metadataValue = serializeMetadata(enrichedMetadata);
|
|
73
|
-
// Prepare fields for insertion, handling optional encryption
|
|
74
|
-
let insertValues = {
|
|
75
|
-
...baseValues,
|
|
76
|
-
tags: tagsValue,
|
|
77
|
-
metadata: metadataValue,
|
|
78
|
-
...embeddingValues,
|
|
79
|
-
importanceScore: importance.score,
|
|
80
|
-
lastImportanceRecalc: new Date(),
|
|
81
|
-
tokensEstimate,
|
|
82
|
-
createdAt: new Date(),
|
|
83
|
-
status: 'active',
|
|
84
|
-
tier: input.tier || 'hot', // Default to hot tier
|
|
85
|
-
};
|
|
86
|
-
// Add namespace if specified
|
|
87
|
-
if (input.namespaceId) {
|
|
88
|
-
insertValues.namespaceId = input.namespaceId;
|
|
89
|
-
}
|
|
90
|
-
// For cold tier, store original content in metadata
|
|
91
|
-
if (input.tier === 'cold') {
|
|
92
|
-
enrichedMetadata.originalContent = input.content;
|
|
93
|
-
}
|
|
94
|
-
if (config.clientEncryptionEnabled) {
|
|
95
|
-
const { ciphertext, nonce } = encrypt(input.content);
|
|
96
|
-
insertValues.encrypted_content = ciphertext;
|
|
97
|
-
insertValues.encryption_nonce = nonce;
|
|
98
|
-
insertValues.is_encrypted = true;
|
|
99
|
-
// Store empty placeholder for plain content
|
|
100
|
-
insertValues.content = '';
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
insertValues.content = input.content;
|
|
104
|
-
insertValues.is_encrypted = false;
|
|
105
|
-
}
|
|
106
|
-
await db.insert(schema.memories).values(insertValues);
|
|
107
|
-
if (project?.id) {
|
|
108
|
-
try {
|
|
109
|
-
const beliefs = extractBeliefsFromMemory({
|
|
110
|
-
memoryId: id,
|
|
111
|
-
content: input.content,
|
|
112
|
-
type,
|
|
113
|
-
metadata: enrichedMetadata,
|
|
114
|
-
});
|
|
115
|
-
if (beliefs.length > 0) {
|
|
116
|
-
await upsertBeliefsForMemory({
|
|
117
|
-
projectId: project.id,
|
|
118
|
-
memoryId: id,
|
|
119
|
-
beliefs,
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
catch (beliefError) {
|
|
124
|
-
logger.warn(`[Beliefs] Failed to derive beliefs for memory ${id}: ${beliefError}`);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
// Auto-link by entity overlap (synchronous - Task 5)
|
|
128
|
-
// Now memories are immediately findable via associations after storage
|
|
129
|
-
const entityNames = extractEntityNames(input.content);
|
|
130
|
-
if (entityNames.length > 0 && project?.id) {
|
|
131
|
-
try {
|
|
132
|
-
const linked = await autoLinkByEntities(id, entityNames, project.id);
|
|
133
|
-
if (linked > 0)
|
|
134
|
-
logger.debug(`[AutoLink] Linked memory ${id} to ${linked} related memories`);
|
|
135
|
-
}
|
|
136
|
-
catch (err) {
|
|
137
|
-
logger.debug(`[AutoLink] Failed: ${err}`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
// Build graph for this memory (auto-build if enabled)
|
|
141
|
-
// This populates the entity_entities and entity_relations tables
|
|
142
|
-
if (config.graphAutoBuild && project?.id) {
|
|
143
|
-
try {
|
|
144
|
-
const graphResult = await addMemoryToGraph(id, {
|
|
145
|
-
preferLLM: config.llmEnabled,
|
|
146
|
-
});
|
|
147
|
-
if (graphResult.entitiesCreated > 0 || graphResult.relationsCreated > 0) {
|
|
148
|
-
logger.debug(`[Graph] Built graph for memory ${id}: ${graphResult.entitiesCreated} entities, ${graphResult.relationsCreated} relations`);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
catch (graphError) {
|
|
152
|
-
logger.debug(`[Graph] Failed to build graph for memory ${id}: ${graphError}`);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
// Append to Obsidian vault if enabled and hot tier (NEW)
|
|
156
|
-
if (config.obsidianEnabled && config.obsidianVaultPath && insertValues.tier === 'hot') {
|
|
157
|
-
try {
|
|
158
|
-
const { appendToObsidianVault } = await import('../integrations/obsidian-vault.js');
|
|
159
|
-
await appendToObsidianVault({
|
|
160
|
-
content: input.content,
|
|
161
|
-
id,
|
|
162
|
-
type,
|
|
163
|
-
tags,
|
|
164
|
-
reasoning: input.reasoning,
|
|
165
|
-
memoryContext: input.memoryContext,
|
|
166
|
-
examples: input.examples,
|
|
167
|
-
exceptions: input.exceptions,
|
|
168
|
-
source: input.source,
|
|
169
|
-
}, config.obsidianVaultPath);
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
logger.warn(`[Obsidian] Failed to append to vault: ${error}`);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
// Resolve contradictions and supersede old memories (async, non-blocking)
|
|
176
|
-
resolveContradictions(input.content, type, project?.id)
|
|
177
|
-
.then(async (result) => {
|
|
178
|
-
if (result.supersededIds.length > 0) {
|
|
179
|
-
await applySupersession(id, result.supersededIds, result.confidence);
|
|
180
|
-
// Update metadata with contradiction resolution info
|
|
181
|
-
const updatedMetadata = {
|
|
182
|
-
...enrichedMetadata,
|
|
183
|
-
contradictionResolution: {
|
|
184
|
-
supersededCount: result.supersededIds.length,
|
|
185
|
-
confidence: result.confidence,
|
|
186
|
-
reason: result.reason,
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
metadataValue = serializeMetadata(updatedMetadata);
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
.catch((error) => {
|
|
193
|
-
import('../logger.js').then(({ logger }) => {
|
|
194
|
-
logger?.debug?.(`Contradiction resolution failed: ${error}`);
|
|
195
|
-
});
|
|
196
|
-
});
|
|
197
|
-
// Sync to QMD if enabled (async, don't block)
|
|
198
|
-
const memoryRecord = {
|
|
199
|
-
id,
|
|
200
|
-
projectId: project?.id ?? null,
|
|
201
|
-
type,
|
|
202
|
-
content: input.content,
|
|
203
|
-
tags,
|
|
204
|
-
metadata: enrichedMetadata,
|
|
205
|
-
importance: importance.score,
|
|
206
|
-
};
|
|
207
|
-
return memoryRecord;
|
|
208
|
-
}
|
|
209
|
-
export async function getMemory(id, incrementAccess = true) {
|
|
210
|
-
try {
|
|
211
|
-
// Validate UUID
|
|
212
|
-
requireUuid(id);
|
|
213
|
-
const { db, schema } = await getDbClient();
|
|
214
|
-
const rows = await db.select().from(schema.memories).where(eq(schema.memories.id, id)).limit(1);
|
|
215
|
-
const row = rows[0];
|
|
216
|
-
if (!row)
|
|
217
|
-
return null;
|
|
218
|
-
// Increment access count and update last accessed time
|
|
219
|
-
if (incrementAccess) {
|
|
220
|
-
await db.update(schema.memories)
|
|
221
|
-
.set({
|
|
222
|
-
accessCount: (row.accessCount ?? 0) + 1,
|
|
223
|
-
lastAccessedAt: new Date(),
|
|
224
|
-
})
|
|
225
|
-
.where(eq(schema.memories.id, id));
|
|
226
|
-
}
|
|
227
|
-
let content = row.content;
|
|
228
|
-
if (row.is_encrypted) {
|
|
229
|
-
try {
|
|
230
|
-
content = decrypt(row.encrypted_content, row.encryption_nonce);
|
|
231
|
-
}
|
|
232
|
-
catch (e) {
|
|
233
|
-
console.warn('Failed to decrypt memory', e);
|
|
234
|
-
content = row.content; // fall back to stored content
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
const decryptedRow = { ...row, content };
|
|
238
|
-
return normalizeMemory(decryptedRow);
|
|
239
|
-
}
|
|
240
|
-
catch (error) {
|
|
241
|
-
throw error;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
export async function setConfidence(id, level) {
|
|
245
|
-
try {
|
|
246
|
-
// Validate UUID
|
|
247
|
-
requireUuid(id);
|
|
248
|
-
const { db, schema } = await getDbClient();
|
|
249
|
-
await db.update(schema.memories)
|
|
250
|
-
.set({ confidenceLevel: level, updatedAt: new Date() })
|
|
251
|
-
.where(eq(schema.memories.id, id));
|
|
252
|
-
return true;
|
|
253
|
-
}
|
|
254
|
-
catch (error) {
|
|
255
|
-
throw error;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
export async function getRecent(projectPath, limit) {
|
|
259
|
-
try {
|
|
260
|
-
const { db } = await getDbClient();
|
|
261
|
-
const sqlite = db.$client;
|
|
262
|
-
const project = await requireProject(projectPath);
|
|
263
|
-
// Use raw SQL to avoid drizzle column name issues
|
|
264
|
-
const rows = sqlite.prepare(`
|
|
265
|
-
SELECT * FROM memories
|
|
266
|
-
WHERE project_id = ?
|
|
267
|
-
ORDER BY created_at DESC
|
|
268
|
-
LIMIT ?
|
|
269
|
-
`).all(project.id, limit);
|
|
270
|
-
return rows.map((row) => normalizeMemory(row));
|
|
271
|
-
}
|
|
272
|
-
catch (error) {
|
|
273
|
-
throw error;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
export async function search(input) {
|
|
277
|
-
const limit = clampLimit(input.limit, 10, 1, 100);
|
|
278
|
-
const tags = normalizeTags(input.tags);
|
|
279
|
-
// Always use hybrid search for both SQLite and PostgreSQL
|
|
280
|
-
// Graph boost requires hybrid path for proper scoring
|
|
281
|
-
const dbResults = await hybridSearchImpl(input, { limit });
|
|
282
|
-
return dbResults.slice(0, limit);
|
|
283
|
-
}
|
|
284
|
-
// parseEmbedding imported from ../lib/parse-embedding.js
|
|
285
|
-
async function searchMemoriesSqlite(input, tags, limit) {
|
|
286
|
-
const { db } = await getDbClient();
|
|
287
|
-
const sqlite = db.$client;
|
|
288
|
-
// Get embedding for the query (for semantic search)
|
|
289
|
-
const queryEmbedding = await getEmbedding(input.query);
|
|
290
|
-
// Build the base query
|
|
291
|
-
const conditions = [];
|
|
292
|
-
const params = [];
|
|
293
|
-
if (input.type) {
|
|
294
|
-
conditions.push('m.type = ?');
|
|
295
|
-
params.push(input.type);
|
|
296
|
-
}
|
|
297
|
-
if (tags.length) {
|
|
298
|
-
conditions.push('m.tags IS NOT NULL AND (' + tags.map(() => 'm.tags LIKE ?').join(' OR ') + ')');
|
|
299
|
-
params.push(...tags.map((tag) => `%${tag}%`));
|
|
300
|
-
}
|
|
301
|
-
let projectId = null;
|
|
302
|
-
if (input.project) {
|
|
303
|
-
const project = await requireProject(input.project);
|
|
304
|
-
projectId = project.id;
|
|
305
|
-
conditions.push('m.project_id = ?');
|
|
306
|
-
params.push(project.id);
|
|
307
|
-
}
|
|
308
|
-
const whereClause = conditions.length > 0 ? 'WHERE ' + conditions.join(' AND ') : '';
|
|
309
|
-
// Fetch memories with embeddings for semantic search
|
|
310
|
-
const fetchLimit = Math.max(limit * 3, 50); // Fetch more for re-ranking
|
|
311
|
-
const statement = sqlite.prepare(`
|
|
312
|
-
SELECT
|
|
313
|
-
m.id as id,
|
|
314
|
-
m.project_id as projectId,
|
|
315
|
-
m.type as type,
|
|
316
|
-
m.content as content,
|
|
317
|
-
m.summary as summary,
|
|
318
|
-
m.tags as tags,
|
|
319
|
-
m.metadata as metadata,
|
|
320
|
-
m.embedding as embedding,
|
|
321
|
-
m.embedding_json as embeddingJson,
|
|
322
|
-
m.created_at as createdAt
|
|
323
|
-
FROM memories m
|
|
324
|
-
${whereClause}
|
|
325
|
-
ORDER BY m.created_at DESC
|
|
326
|
-
LIMIT ?
|
|
327
|
-
`);
|
|
328
|
-
const rows = statement.all(...params, fetchLimit);
|
|
329
|
-
if (rows.length === 0)
|
|
330
|
-
return [];
|
|
331
|
-
// If we have query embedding, do semantic ranking
|
|
332
|
-
if (queryEmbedding) {
|
|
333
|
-
const scored = rows.map((row) => {
|
|
334
|
-
let embedding = parseEmbedding(row.embedding);
|
|
335
|
-
// Fallback to embedding_json if embedding blob is null
|
|
336
|
-
if (!embedding && row.embeddingJson) {
|
|
337
|
-
embedding = parseEmbedding(row.embeddingJson);
|
|
338
|
-
}
|
|
339
|
-
const score = embedding ? cosineSimilarity(queryEmbedding, embedding) : 0;
|
|
340
|
-
return { row, score };
|
|
341
|
-
});
|
|
342
|
-
// Sort by similarity score (descending)
|
|
343
|
-
scored.sort((a, b) => b.score - a.score);
|
|
344
|
-
// Return top results WITH their similarity scores
|
|
345
|
-
return scored.slice(0, limit).map((item) => ({
|
|
346
|
-
...normalizeMemory(item.row),
|
|
347
|
-
similarity: item.score,
|
|
348
|
-
}));
|
|
349
|
-
}
|
|
350
|
-
// No embeddings available, return results with 0 similarity
|
|
351
|
-
return rows.slice(0, limit).map((row, i) => ({
|
|
352
|
-
...normalizeMemory(row),
|
|
353
|
-
similarity: 0,
|
|
354
|
-
}));
|
|
355
|
-
}
|
|
356
|
-
async function searchMemoriesPostgres(input, tags, limit) {
|
|
357
|
-
const { db } = await getDbClient();
|
|
358
|
-
const values = [];
|
|
359
|
-
const whereParts = [];
|
|
360
|
-
values.push(`%${input.query}%`);
|
|
361
|
-
whereParts.push(`content ILIKE $1`);
|
|
362
|
-
if (input.type) {
|
|
363
|
-
values.push(input.type);
|
|
364
|
-
whereParts.push(`type = $${values.length}`);
|
|
365
|
-
}
|
|
366
|
-
if (tags.length) {
|
|
367
|
-
values.push(tags);
|
|
368
|
-
whereParts.push(`tags && $${values.length}::text[]`);
|
|
369
|
-
}
|
|
370
|
-
if (input.project) {
|
|
371
|
-
const project = await requireProject(input.project);
|
|
372
|
-
values.push(project.id);
|
|
373
|
-
whereParts.push(`project_id = $${values.length}`);
|
|
374
|
-
}
|
|
375
|
-
const whereClause = whereParts.length ? `WHERE ${whereParts.join(' AND ')}` : '';
|
|
376
|
-
const embedding = await getEmbedding(input.query);
|
|
377
|
-
if (embedding) {
|
|
378
|
-
const rows = await db.$client.query(`SELECT
|
|
379
|
-
id,
|
|
380
|
-
project_id as "projectId",
|
|
381
|
-
type,
|
|
382
|
-
content,
|
|
383
|
-
summary,
|
|
384
|
-
tags,
|
|
385
|
-
metadata,
|
|
386
|
-
created_at as "createdAt",
|
|
387
|
-
valid_from as "validFrom",
|
|
388
|
-
valid_to as "validTo",
|
|
389
|
-
recorded_at as "recordedAt"
|
|
390
|
-
FROM memories
|
|
391
|
-
${whereClause}
|
|
392
|
-
ORDER BY created_at DESC
|
|
393
|
-
LIMIT $${values.length + 1}`, [...values, limit]);
|
|
394
|
-
return rows.rows.map((row) => ({
|
|
395
|
-
...normalizeMemory(row),
|
|
396
|
-
similarity: row.similarity ?? 0,
|
|
397
|
-
}));
|
|
398
|
-
}
|
|
399
|
-
const rows = await db.$client.query(`SELECT
|
|
400
|
-
id,
|
|
401
|
-
project_id as "projectId",
|
|
402
|
-
type,
|
|
403
|
-
content,
|
|
404
|
-
summary,
|
|
405
|
-
tags,
|
|
406
|
-
metadata,
|
|
407
|
-
created_at as "createdAt",
|
|
408
|
-
valid_from as "validFrom",
|
|
409
|
-
valid_to as "validTo",
|
|
410
|
-
recorded_at as "recordedAt"
|
|
411
|
-
FROM memories
|
|
412
|
-
${whereClause}
|
|
413
|
-
ORDER BY created_at DESC
|
|
414
|
-
LIMIT $${values.length + 1}`, [...values, limit]);
|
|
415
|
-
return rows.rows.map((row) => ({
|
|
416
|
-
...normalizeMemory(row),
|
|
417
|
-
similarity: 0,
|
|
418
|
-
}));
|
|
419
|
-
}
|
|
420
|
-
function normalizeMemory(row) {
|
|
421
|
-
const tags = deserializeTags(row.tags ?? null);
|
|
422
|
-
const metadata = deserializeMetadata(row.metadata ?? null);
|
|
423
|
-
const createdAtStr = normalizeTimestamp(row.createdAt ?? row.created_at);
|
|
424
|
-
return {
|
|
425
|
-
id: row.id,
|
|
426
|
-
projectId: row.projectId ?? row.project_id ?? null,
|
|
427
|
-
type: row.type,
|
|
428
|
-
content: row.content,
|
|
429
|
-
summary: row.summary ?? null,
|
|
430
|
-
tags,
|
|
431
|
-
metadata,
|
|
432
|
-
createdAt: createdAtStr,
|
|
433
|
-
validFrom: row.validFrom ?? row.valid_from ?? null,
|
|
434
|
-
validTo: row.validTo ?? row.valid_to ?? null,
|
|
435
|
-
recordedAt: row.recordedAt ?? row.recorded_at ?? null,
|
|
436
|
-
confidenceLevel: row.confidenceLevel ?? row.confidence_level ?? null,
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Find similar memories to prevent duplicates
|
|
441
|
-
* Returns memories with similarity >= threshold
|
|
442
|
-
*/
|
|
443
|
-
export async function findSimilarMemories(content, threshold = 0.85, limit = 5) {
|
|
444
|
-
// Use search with high similarity
|
|
445
|
-
const results = await search({
|
|
446
|
-
query: content,
|
|
447
|
-
limit,
|
|
448
|
-
});
|
|
449
|
-
// Filter by similarity threshold
|
|
450
|
-
return results.filter(r => (r.similarity ?? 0) >= threshold);
|
|
451
|
-
}
|
|
452
|
-
//# sourceMappingURL=memories.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Promote a memory to a higher tier (cold -> hot only, simplified from warm hierarchy) */
|
|
2
|
-
export declare function promoteTier(memoryId: string): Promise<void>;
|
|
3
|
-
/** Demote a memory tier or expire it based on decay (simplified: hot -> cold only) */
|
|
4
|
-
export declare function demoteTier(memoryId: string): Promise<void>;
|
|
5
|
-
export declare function expireMemory(memoryId: string): Promise<void>;
|
|
6
|
-
export declare function markMerged(memoryId: string, targetId: string): Promise<void>;
|
|
7
|
-
export declare function markSuperseded(memoryId: string): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=memory-lifecycle.d.ts.map
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { getDb } from '../../db/index.js';
|
|
2
|
-
import { memories } from '../../db/drizzle/schema.js';
|
|
3
|
-
import { eq } from 'drizzle-orm';
|
|
4
|
-
import { logger } from '../logger.js';
|
|
5
|
-
/** Promote a memory to a higher tier (cold -> hot only, simplified from warm hierarchy) */
|
|
6
|
-
export async function promoteTier(memoryId) {
|
|
7
|
-
const db = await getDb();
|
|
8
|
-
// @ts-ignore - drizzle overloads
|
|
9
|
-
const row = await db.select().from(memories).where(eq(memories.id, memoryId)).limit(1);
|
|
10
|
-
const mem = row[0];
|
|
11
|
-
if (!mem)
|
|
12
|
-
return;
|
|
13
|
-
// Simplified: cold -> hot (no warm tier)
|
|
14
|
-
if (mem.tier === 'cold') {
|
|
15
|
-
await db.update(memories).set({ tier: 'hot' }).where(eq(memories.id, memoryId));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
/** Demote a memory tier or expire it based on decay (simplified: hot -> cold only) */
|
|
19
|
-
export async function demoteTier(memoryId) {
|
|
20
|
-
const db = await getDb();
|
|
21
|
-
// @ts-ignore
|
|
22
|
-
const row = await db.select().from(memories).where(eq(memories.id, memoryId)).limit(1);
|
|
23
|
-
const mem = row[0];
|
|
24
|
-
if (!mem)
|
|
25
|
-
return;
|
|
26
|
-
// Simplified: hot -> cold (no warm tier)
|
|
27
|
-
if (mem.tier === 'hot') {
|
|
28
|
-
await db.update(memories).set({ tier: 'cold' }).where(eq(memories.id, memoryId));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export async function expireMemory(memoryId) {
|
|
32
|
-
const db = await getDb();
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
await db.update(memories).set({ status: 'expired' }).where(eq(memories.id, memoryId));
|
|
35
|
-
}
|
|
36
|
-
export async function markMerged(memoryId, targetId) {
|
|
37
|
-
const db = await getDb();
|
|
38
|
-
// @ts-ignore
|
|
39
|
-
await db.update(memories).set({ is_merged: true, merged_into_id: targetId }).where(eq(memories.id, memoryId));
|
|
40
|
-
}
|
|
41
|
-
export async function markSuperseded(memoryId) {
|
|
42
|
-
const db = await getDb();
|
|
43
|
-
// @ts-ignore
|
|
44
|
-
await db.update(memories).set({ is_merged: true }).where(eq(memories.id, memoryId));
|
|
45
|
-
}
|
|
46
|
-
logger.info('Memory lifecycle helpers loaded');
|
|
47
|
-
//# sourceMappingURL=memory-lifecycle.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
declare class MemoryManager {
|
|
2
|
-
private lastGcTime;
|
|
3
|
-
private gcIntervalMs;
|
|
4
|
-
shouldGc(): boolean;
|
|
5
|
-
gc(): void;
|
|
6
|
-
getStats(): {
|
|
7
|
-
heapUsed: number;
|
|
8
|
-
heapTotal: number;
|
|
9
|
-
external: number;
|
|
10
|
-
rss: number;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export declare const memoryManager: MemoryManager;
|
|
14
|
-
export {};
|
|
15
|
-
//# sourceMappingURL=memory-manager.d.ts.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { logger } from '../../core/logger.js';
|
|
2
|
-
// Memory monitoring and optimization
|
|
3
|
-
class MemoryManager {
|
|
4
|
-
lastGcTime = 0;
|
|
5
|
-
gcIntervalMs = 5 * 60 * 1000; // 5 minutes
|
|
6
|
-
shouldGc() {
|
|
7
|
-
const now = Date.now();
|
|
8
|
-
if (now - this.lastGcTime > this.gcIntervalMs) {
|
|
9
|
-
const usage = process.memoryUsage();
|
|
10
|
-
const heapUsedMB = usage.heapUsed / 1024 / 1024;
|
|
11
|
-
const heapTotalMB = usage.heapTotal / 1024 / 1024;
|
|
12
|
-
// Trigger GC if heap usage is high (>80% of total)
|
|
13
|
-
if (heapUsedMB > heapTotalMB * 0.8) {
|
|
14
|
-
this.lastGcTime = now;
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
gc() {
|
|
21
|
-
if (global.gc && this.shouldGc()) {
|
|
22
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
-
logger.info('Running garbage collection');
|
|
24
|
-
}
|
|
25
|
-
global.gc();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
getStats() {
|
|
29
|
-
const usage = process.memoryUsage();
|
|
30
|
-
return {
|
|
31
|
-
heapUsed: Math.round(usage.heapUsed / 1024 / 1024),
|
|
32
|
-
heapTotal: Math.round(usage.heapTotal / 1024 / 1024),
|
|
33
|
-
external: Math.round(usage.external / 1024 / 1024),
|
|
34
|
-
rss: Math.round(usage.rss / 1024 / 1024),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
export const memoryManager = new MemoryManager();
|
|
39
|
-
// Periodic memory monitoring (production-safe)
|
|
40
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
41
|
-
setInterval(() => {
|
|
42
|
-
const stats = memoryManager.getStats();
|
|
43
|
-
logger.info(`Memory: ${stats.heapUsed}MB used, ${stats.heapTotal}MB total`);
|
|
44
|
-
}, 10 * 60 * 1000); // Every 10 minutes
|
|
45
|
-
}
|
|
46
|
-
//# sourceMappingURL=memory-manager.js.map
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Migration Module
|
|
3
|
-
* Migrate memories between .squish directories/databases
|
|
4
|
-
*/
|
|
5
|
-
export interface MigrateOptions {
|
|
6
|
-
dryRun?: boolean;
|
|
7
|
-
deleteSource?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface MigrateResult {
|
|
10
|
-
memoriesCopied: number;
|
|
11
|
-
observationsCopied: number;
|
|
12
|
-
associationsCopied: number;
|
|
13
|
-
projectsMapped: number;
|
|
14
|
-
sourceDeleted?: boolean;
|
|
15
|
-
message: string;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Migrate memories from one .squish directory to another
|
|
19
|
-
*/
|
|
20
|
-
export declare function migrateMemories(sourceDir: string, targetDir: string, options?: MigrateOptions): Promise<MigrateResult>;
|
|
21
|
-
//# sourceMappingURL=migrate.d.ts.map
|