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,212 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import { eq } from 'drizzle-orm';
|
|
3
|
-
import { getDbClient } from '../lib/db-client.js';
|
|
4
|
-
import { ensureProject, getProjectByPath } from '../projects.js';
|
|
5
|
-
import { deserializeMetadata, serializeMetadata } from '../memory/serialization.js';
|
|
6
|
-
const EMPTY_WORKING_SET = (sessionId, projectPath) => ({
|
|
7
|
-
activeFiles: [],
|
|
8
|
-
activePlaces: [],
|
|
9
|
-
graphEntities: [],
|
|
10
|
-
recentCommands: [],
|
|
11
|
-
currentHypotheses: [],
|
|
12
|
-
recentFailures: [],
|
|
13
|
-
recentAttempts: [],
|
|
14
|
-
projectPath,
|
|
15
|
-
sessionId,
|
|
16
|
-
signalStats: {
|
|
17
|
-
captured: 0,
|
|
18
|
-
suppressed: 0,
|
|
19
|
-
sessionOnly: 0,
|
|
20
|
-
durable: 0,
|
|
21
|
-
durableWithRaw: 0,
|
|
22
|
-
tokensSaved: 0,
|
|
23
|
-
placeRouted: 0,
|
|
24
|
-
graphEnriched: 0,
|
|
25
|
-
},
|
|
26
|
-
recentEvents: [],
|
|
27
|
-
});
|
|
28
|
-
function dedupe(items, limit) {
|
|
29
|
-
return [...new Set(items.filter(Boolean))].slice(0, limit);
|
|
30
|
-
}
|
|
31
|
-
function normalizeSessionMetadata(metadata, sessionId, projectPath) {
|
|
32
|
-
const parsed = (metadata ?? {});
|
|
33
|
-
return {
|
|
34
|
-
...EMPTY_WORKING_SET(sessionId, projectPath),
|
|
35
|
-
...parsed,
|
|
36
|
-
activeFiles: parsed.activeFiles ?? [],
|
|
37
|
-
activePlaces: parsed.activePlaces ?? [],
|
|
38
|
-
graphEntities: parsed.graphEntities ?? [],
|
|
39
|
-
recentCommands: parsed.recentCommands ?? [],
|
|
40
|
-
currentHypotheses: parsed.currentHypotheses ?? [],
|
|
41
|
-
recentFailures: parsed.recentFailures ?? [],
|
|
42
|
-
recentAttempts: parsed.recentAttempts ?? [],
|
|
43
|
-
recentEvents: parsed.recentEvents ?? [],
|
|
44
|
-
signalStats: {
|
|
45
|
-
...EMPTY_WORKING_SET(sessionId, projectPath).signalStats,
|
|
46
|
-
...(parsed.signalStats ?? {}),
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
async function getOrCreateContextSession(sessionId, projectPath) {
|
|
51
|
-
const { db, schema, raw } = await getDbClient();
|
|
52
|
-
const project = await ensureProject(projectPath);
|
|
53
|
-
const existing = await db
|
|
54
|
-
.select()
|
|
55
|
-
.from(schema.contextSessions)
|
|
56
|
-
.where(eq(schema.contextSessions.sessionId, sessionId))
|
|
57
|
-
.limit(1);
|
|
58
|
-
if (existing[0])
|
|
59
|
-
return { row: existing[0], projectId: project?.id ?? null, db, schema };
|
|
60
|
-
const sqlite = raw.$client;
|
|
61
|
-
const id = randomUUID();
|
|
62
|
-
const metadata = serializeMetadata(EMPTY_WORKING_SET(sessionId, projectPath));
|
|
63
|
-
sqlite.prepare(`
|
|
64
|
-
INSERT INTO context_sessions (
|
|
65
|
-
id, session_id, project_id, metadata, token_budget, tokens_used, core_memory_tokens, loaded_memories_tokens, created_at, updated_at
|
|
66
|
-
) VALUES (?, ?, ?, ?, 8000, 0, 0, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
|
67
|
-
`).run(id, sessionId, project?.id ?? null, metadata);
|
|
68
|
-
const inserted = await db
|
|
69
|
-
.select()
|
|
70
|
-
.from(schema.contextSessions)
|
|
71
|
-
.where(eq(schema.contextSessions.sessionId, sessionId))
|
|
72
|
-
.limit(1);
|
|
73
|
-
return { row: inserted[0], projectId: project?.id ?? null, db, schema };
|
|
74
|
-
}
|
|
75
|
-
export async function getSessionWorkingSet(sessionId, projectPath) {
|
|
76
|
-
const { db, schema } = await getDbClient();
|
|
77
|
-
const rows = await db
|
|
78
|
-
.select()
|
|
79
|
-
.from(schema.contextSessions)
|
|
80
|
-
.where(eq(schema.contextSessions.sessionId, sessionId))
|
|
81
|
-
.limit(1);
|
|
82
|
-
if (!rows[0])
|
|
83
|
-
return EMPTY_WORKING_SET(sessionId, projectPath);
|
|
84
|
-
return normalizeSessionMetadata(deserializeMetadata(rows[0].metadata ?? null), sessionId, projectPath);
|
|
85
|
-
}
|
|
86
|
-
export async function recordSessionSignal(input) {
|
|
87
|
-
const { row, db, schema } = await getOrCreateContextSession(input.sessionId, input.projectPath);
|
|
88
|
-
const current = normalizeSessionMetadata(deserializeMetadata(row.metadata ?? null), input.sessionId, input.projectPath);
|
|
89
|
-
const meta = input.metadata ?? {};
|
|
90
|
-
const now = new Date().toISOString();
|
|
91
|
-
const next = normalizeSessionMetadata(current, input.sessionId, input.projectPath);
|
|
92
|
-
next.activeFiles = dedupe([
|
|
93
|
-
...next.activeFiles,
|
|
94
|
-
...((meta.activeFiles ?? [])),
|
|
95
|
-
], 8);
|
|
96
|
-
next.activePlaces = dedupe([
|
|
97
|
-
...next.activePlaces,
|
|
98
|
-
...((meta.activePlaces ?? [])),
|
|
99
|
-
], 6);
|
|
100
|
-
next.graphEntities = dedupe([
|
|
101
|
-
...next.graphEntities,
|
|
102
|
-
...((meta.graphEntities ?? [])),
|
|
103
|
-
], 8);
|
|
104
|
-
const command = typeof meta.command === 'string' ? meta.command : undefined;
|
|
105
|
-
if (command) {
|
|
106
|
-
next.recentCommands = [{ command, outcome: typeof meta.outcome === 'string' ? meta.outcome : undefined, at: now }, ...next.recentCommands].slice(0, 8);
|
|
107
|
-
}
|
|
108
|
-
if (/hypothesis/i.test(input.distilledContent)) {
|
|
109
|
-
next.currentHypotheses = dedupe([input.distilledContent, ...next.currentHypotheses], 5);
|
|
110
|
-
}
|
|
111
|
-
if ((typeof meta.outcome === 'string' && meta.outcome === 'failure') || /fail|error|exception/i.test(input.distilledContent)) {
|
|
112
|
-
next.recentFailures = dedupe([input.target ?? input.distilledContent, ...next.recentFailures], 5);
|
|
113
|
-
}
|
|
114
|
-
next.recentAttempts = dedupe([input.distilledContent, ...next.recentAttempts], 8);
|
|
115
|
-
next.recentEvents = [
|
|
116
|
-
{
|
|
117
|
-
classification: input.classification,
|
|
118
|
-
content: input.distilledContent,
|
|
119
|
-
target: input.target,
|
|
120
|
-
hash: typeof meta.contentHash === 'string' ? meta.contentHash : undefined,
|
|
121
|
-
at: now,
|
|
122
|
-
},
|
|
123
|
-
...next.recentEvents,
|
|
124
|
-
].slice(0, 20);
|
|
125
|
-
if (input.classification === 'discard')
|
|
126
|
-
next.signalStats.suppressed += 1;
|
|
127
|
-
else
|
|
128
|
-
next.signalStats.captured += 1;
|
|
129
|
-
if (input.classification === 'session-only')
|
|
130
|
-
next.signalStats.sessionOnly += 1;
|
|
131
|
-
if (input.classification === 'durable-distilled')
|
|
132
|
-
next.signalStats.durable += 1;
|
|
133
|
-
if (input.classification === 'durable-raw+distilled')
|
|
134
|
-
next.signalStats.durableWithRaw += 1;
|
|
135
|
-
next.signalStats.tokensSaved += Number(meta.tokensSaved ?? 0);
|
|
136
|
-
next.signalStats.placeRouted += meta.placeRouted ? 1 : 0;
|
|
137
|
-
next.signalStats.graphEnriched += meta.graphEnriched ? 1 : 0;
|
|
138
|
-
await db
|
|
139
|
-
.update(schema.contextSessions)
|
|
140
|
-
.set({
|
|
141
|
-
metadata: serializeMetadata(next),
|
|
142
|
-
updatedAt: new Date(),
|
|
143
|
-
})
|
|
144
|
-
.where(eq(schema.contextSessions.sessionId, input.sessionId));
|
|
145
|
-
return next;
|
|
146
|
-
}
|
|
147
|
-
export async function compactSessionWorkingSet(sessionId, projectPath) {
|
|
148
|
-
const workingSet = await getSessionWorkingSet(sessionId, projectPath);
|
|
149
|
-
const lines = [];
|
|
150
|
-
if (workingSet.currentHypotheses.length > 0) {
|
|
151
|
-
lines.push(`Hypotheses: ${dedupe(workingSet.currentHypotheses, 3).join(' | ')}`);
|
|
152
|
-
}
|
|
153
|
-
if (workingSet.recentFailures.length > 0) {
|
|
154
|
-
lines.push(`Failures: ${dedupe(workingSet.recentFailures, 3).join(' | ')}`);
|
|
155
|
-
}
|
|
156
|
-
if (workingSet.activeFiles.length > 0) {
|
|
157
|
-
lines.push(`Active files: ${dedupe(workingSet.activeFiles, 5).join(', ')}`);
|
|
158
|
-
}
|
|
159
|
-
if (workingSet.activePlaces.length > 0) {
|
|
160
|
-
lines.push(`Active places: ${dedupe(workingSet.activePlaces, 4).join(', ')}`);
|
|
161
|
-
}
|
|
162
|
-
if (workingSet.graphEntities.length > 0) {
|
|
163
|
-
lines.push(`Graph entities: ${dedupe(workingSet.graphEntities, 4).join(', ')}`);
|
|
164
|
-
}
|
|
165
|
-
if (workingSet.recentCommands.length > 0) {
|
|
166
|
-
lines.push(`Recent commands: ${dedupe(workingSet.recentCommands.map((entry) => entry.command), 3).join(' | ')}`);
|
|
167
|
-
}
|
|
168
|
-
return {
|
|
169
|
-
summary: lines.join('\n'),
|
|
170
|
-
workingSet,
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
export async function getProjectSignalStats(projectPath) {
|
|
174
|
-
const { db, schema } = await getDbClient();
|
|
175
|
-
const project = await getProjectByPath(projectPath);
|
|
176
|
-
if (!project) {
|
|
177
|
-
return EMPTY_WORKING_SET('project-stats', projectPath).signalStats;
|
|
178
|
-
}
|
|
179
|
-
const rows = await db
|
|
180
|
-
.select()
|
|
181
|
-
.from(schema.contextSessions)
|
|
182
|
-
.where(eq(schema.contextSessions.projectId, project.id));
|
|
183
|
-
return rows.reduce((acc, row) => {
|
|
184
|
-
const workingSet = normalizeSessionMetadata(deserializeMetadata(row.metadata ?? null), row.sessionId, projectPath);
|
|
185
|
-
acc.captured += workingSet.signalStats.captured;
|
|
186
|
-
acc.suppressed += workingSet.signalStats.suppressed;
|
|
187
|
-
acc.sessionOnly += workingSet.signalStats.sessionOnly;
|
|
188
|
-
acc.durable += workingSet.signalStats.durable;
|
|
189
|
-
acc.durableWithRaw += workingSet.signalStats.durableWithRaw;
|
|
190
|
-
acc.tokensSaved += workingSet.signalStats.tokensSaved;
|
|
191
|
-
return acc;
|
|
192
|
-
}, { ...EMPTY_WORKING_SET('project-stats', projectPath).signalStats });
|
|
193
|
-
}
|
|
194
|
-
export async function getLatestProjectWorkingSetSummary(projectPath) {
|
|
195
|
-
const { db, schema } = await getDbClient();
|
|
196
|
-
const project = await getProjectByPath(projectPath);
|
|
197
|
-
if (!project)
|
|
198
|
-
return '';
|
|
199
|
-
const rows = await db
|
|
200
|
-
.select()
|
|
201
|
-
.from(schema.contextSessions)
|
|
202
|
-
.where(eq(schema.contextSessions.projectId, project.id));
|
|
203
|
-
const latest = rows.sort((a, b) => {
|
|
204
|
-
const left = new Date(a.updatedAt ?? a.createdAt ?? 0).getTime();
|
|
205
|
-
const right = new Date(b.updatedAt ?? b.createdAt ?? 0).getTime();
|
|
206
|
-
return right - left;
|
|
207
|
-
})[0];
|
|
208
|
-
if (!latest)
|
|
209
|
-
return '';
|
|
210
|
-
return compactSessionWorkingSet(latest.sessionId, projectPath).then((result) => result.summary);
|
|
211
|
-
}
|
|
212
|
-
//# sourceMappingURL=working-set.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Cleanup Operations
|
|
3
|
-
* Maintenance and cleanup for snapshot data
|
|
4
|
-
*/
|
|
5
|
-
import { cleanupOldMemorySnapshots } from '../utils/cleanup-operations.js';
|
|
6
|
-
/**
|
|
7
|
-
* Delete old snapshots
|
|
8
|
-
*/
|
|
9
|
-
export async function deleteOldSnapshots(olderThanDays = 90) {
|
|
10
|
-
return cleanupOldMemorySnapshots(olderThanDays);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=cleanup.js.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Comparison Operations
|
|
3
|
-
* Functions for comparing and diffing snapshots
|
|
4
|
-
*/
|
|
5
|
-
export interface MemoryDiff {
|
|
6
|
-
added?: string[];
|
|
7
|
-
removed?: string[];
|
|
8
|
-
changed?: Record<string, {
|
|
9
|
-
from: unknown;
|
|
10
|
-
to: unknown;
|
|
11
|
-
}>;
|
|
12
|
-
}
|
|
13
|
-
export declare function calculateDiff(before: string, after: string): MemoryDiff;
|
|
14
|
-
export declare function compareSnapshots(snapshotId1: string, snapshotId2: string): Promise<{
|
|
15
|
-
diff: MemoryDiff;
|
|
16
|
-
contextBefore: string;
|
|
17
|
-
contextAfter: string;
|
|
18
|
-
}>;
|
|
19
|
-
//# sourceMappingURL=comparison.d.ts.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Comparison Operations
|
|
3
|
-
* Functions for comparing and diffing snapshots
|
|
4
|
-
*/
|
|
5
|
-
import { getMemorySnapshot } from './retrieval.js';
|
|
6
|
-
import { logger } from '../logger.js';
|
|
7
|
-
export function calculateDiff(before, after) {
|
|
8
|
-
const beforeLines = before === '' ? [] : before.split('\n');
|
|
9
|
-
const afterLines = after === '' ? [] : after.split('\n');
|
|
10
|
-
const beforeSet = new Set(beforeLines);
|
|
11
|
-
const afterSet = new Set(afterLines);
|
|
12
|
-
const added = afterLines.filter(line => !beforeSet.has(line));
|
|
13
|
-
const removed = beforeLines.filter(line => !afterSet.has(line));
|
|
14
|
-
if (added.length === 0 && removed.length === 0 && before !== after) {
|
|
15
|
-
return {
|
|
16
|
-
added: afterLines.length > 0 ? afterLines : undefined,
|
|
17
|
-
removed: beforeLines.length > 0 ? beforeLines : undefined,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
added: added.length > 0 ? added : undefined,
|
|
22
|
-
removed: removed.length > 0 ? removed : undefined,
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export async function compareSnapshots(snapshotId1, snapshotId2) {
|
|
26
|
-
try {
|
|
27
|
-
const snap1 = await getMemorySnapshot(snapshotId1);
|
|
28
|
-
const snap2 = await getMemorySnapshot(snapshotId2);
|
|
29
|
-
if (!snap1 || !snap2) {
|
|
30
|
-
throw new Error('One or both snapshots not found');
|
|
31
|
-
}
|
|
32
|
-
return {
|
|
33
|
-
diff: calculateDiff(snap1.content, snap2.content),
|
|
34
|
-
contextBefore: snap1.content.substring(0, 200),
|
|
35
|
-
contextAfter: snap2.content.substring(0, 200),
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
catch (error) {
|
|
39
|
-
logger.error('Error comparing snapshots', error);
|
|
40
|
-
throw error;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=comparison.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Creation Operations
|
|
3
|
-
* Functions for creating different types of memory snapshots
|
|
4
|
-
*/
|
|
5
|
-
import { MemoryDiff, calculateDiff } from './comparison.js';
|
|
6
|
-
export { MemoryDiff, calculateDiff };
|
|
7
|
-
export declare function createBeforeSnapshot(memoryId: string): Promise<string>;
|
|
8
|
-
export declare function createAfterSnapshot(memoryId: string, beforeSnapshotId: string): Promise<{
|
|
9
|
-
snapshotId: string;
|
|
10
|
-
diff: MemoryDiff;
|
|
11
|
-
}>;
|
|
12
|
-
export declare function createPeriodicSnapshot(memoryId: string): Promise<string>;
|
|
13
|
-
//# sourceMappingURL=creation.d.ts.map
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Creation Operations
|
|
3
|
-
* Functions for creating different types of memory snapshots
|
|
4
|
-
*/
|
|
5
|
-
import { eq } from 'drizzle-orm';
|
|
6
|
-
import { randomUUID } from 'crypto';
|
|
7
|
-
import { getDb } from '../../db/index.js';
|
|
8
|
-
import { getSchema } from '../../db/schema.js';
|
|
9
|
-
import { logger } from '../logger.js';
|
|
10
|
-
import { calculateDiff } from './comparison.js';
|
|
11
|
-
// Re-export for convenience
|
|
12
|
-
export { calculateDiff };
|
|
13
|
-
export async function createBeforeSnapshot(memoryId) {
|
|
14
|
-
try {
|
|
15
|
-
const db = await getDb();
|
|
16
|
-
const schema = await getSchema();
|
|
17
|
-
const memory = await db
|
|
18
|
-
.select()
|
|
19
|
-
.from(schema.memories)
|
|
20
|
-
.where(eq(schema.memories.id, memoryId))
|
|
21
|
-
.limit(1);
|
|
22
|
-
if (memory.length === 0) {
|
|
23
|
-
throw new Error('Memory not found: ' + memoryId);
|
|
24
|
-
}
|
|
25
|
-
const snapshotId = randomUUID();
|
|
26
|
-
await db.insert(schema.memorySnapshots).values({
|
|
27
|
-
id: snapshotId,
|
|
28
|
-
memoryId,
|
|
29
|
-
snapshotType: 'before_update',
|
|
30
|
-
content: memory[0].content,
|
|
31
|
-
metadata: extractMetadata(memory[0]),
|
|
32
|
-
createdAt: new Date(),
|
|
33
|
-
});
|
|
34
|
-
return snapshotId;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
logger.error('Error creating before snapshot', error);
|
|
38
|
-
throw error;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
export async function createAfterSnapshot(memoryId, beforeSnapshotId) {
|
|
42
|
-
try {
|
|
43
|
-
const db = await getDb();
|
|
44
|
-
const schema = await getSchema();
|
|
45
|
-
const memory = await db
|
|
46
|
-
.select()
|
|
47
|
-
.from(schema.memories)
|
|
48
|
-
.where(eq(schema.memories.id, memoryId))
|
|
49
|
-
.limit(1);
|
|
50
|
-
if (memory.length === 0) {
|
|
51
|
-
throw new Error('Memory not found');
|
|
52
|
-
}
|
|
53
|
-
const before = await db
|
|
54
|
-
.select()
|
|
55
|
-
.from(schema.memorySnapshots)
|
|
56
|
-
.where(eq(schema.memorySnapshots.id, beforeSnapshotId))
|
|
57
|
-
.limit(1);
|
|
58
|
-
if (before.length === 0) {
|
|
59
|
-
throw new Error('Before snapshot not found');
|
|
60
|
-
}
|
|
61
|
-
const diff = calculateDiff(before[0].content, memory[0].content);
|
|
62
|
-
const snapshotId = randomUUID();
|
|
63
|
-
await db.insert(schema.memorySnapshots).values({
|
|
64
|
-
id: snapshotId,
|
|
65
|
-
memoryId,
|
|
66
|
-
snapshotType: 'after_update',
|
|
67
|
-
content: memory[0].content,
|
|
68
|
-
metadata: extractMetadata(memory[0]),
|
|
69
|
-
diff,
|
|
70
|
-
createdAt: new Date(),
|
|
71
|
-
});
|
|
72
|
-
return { snapshotId, diff };
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
logger.error('Error creating after snapshot', error);
|
|
76
|
-
throw error;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
export async function createPeriodicSnapshot(memoryId) {
|
|
80
|
-
try {
|
|
81
|
-
const db = await getDb();
|
|
82
|
-
const schema = await getSchema();
|
|
83
|
-
const memory = await db
|
|
84
|
-
.select()
|
|
85
|
-
.from(schema.memories)
|
|
86
|
-
.where(eq(schema.memories.id, memoryId))
|
|
87
|
-
.limit(1);
|
|
88
|
-
if (memory.length === 0) {
|
|
89
|
-
throw new Error('Memory not found');
|
|
90
|
-
}
|
|
91
|
-
const snapshotId = randomUUID();
|
|
92
|
-
await db.insert(schema.memorySnapshots).values({
|
|
93
|
-
id: snapshotId,
|
|
94
|
-
memoryId,
|
|
95
|
-
snapshotType: 'periodic',
|
|
96
|
-
content: memory[0].content,
|
|
97
|
-
metadata: extractMetadata(memory[0]),
|
|
98
|
-
createdAt: new Date(),
|
|
99
|
-
});
|
|
100
|
-
return snapshotId;
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
logger.error('Error creating periodic snapshot', error);
|
|
104
|
-
throw error;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
function extractMetadata(memory) {
|
|
108
|
-
return {
|
|
109
|
-
type: memory.type,
|
|
110
|
-
sector: memory.sector,
|
|
111
|
-
confidence: memory.confidence,
|
|
112
|
-
relevanceScore: memory.relevanceScore,
|
|
113
|
-
tags: memory.tags,
|
|
114
|
-
agentId: memory.agentId,
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
//# sourceMappingURL=creation.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Retrieval Operations
|
|
3
|
-
* Functions for retrieving and querying snapshots
|
|
4
|
-
*/
|
|
5
|
-
export declare function getMemoryHistory(memoryId: string, limit?: number): Promise<any[]>;
|
|
6
|
-
export declare function getMemorySnapshot(snapshotId: string): Promise<any>;
|
|
7
|
-
//# sourceMappingURL=retrieval.d.ts.map
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Retrieval Operations
|
|
3
|
-
* Functions for retrieving and querying snapshots
|
|
4
|
-
*/
|
|
5
|
-
import { eq, desc } from 'drizzle-orm';
|
|
6
|
-
import { getDb } from '../../db/index.js';
|
|
7
|
-
import { getSchema } from '../../db/schema.js';
|
|
8
|
-
import { logger } from '../logger.js';
|
|
9
|
-
export async function getMemoryHistory(memoryId, limit = 50) {
|
|
10
|
-
try {
|
|
11
|
-
const db = await getDb();
|
|
12
|
-
const schema = await getSchema();
|
|
13
|
-
return await db
|
|
14
|
-
.select()
|
|
15
|
-
.from(schema.memorySnapshots)
|
|
16
|
-
.where(eq(schema.memorySnapshots.memoryId, memoryId))
|
|
17
|
-
.orderBy(desc(schema.memorySnapshots.createdAt))
|
|
18
|
-
.limit(limit);
|
|
19
|
-
}
|
|
20
|
-
catch (error) {
|
|
21
|
-
logger.error('Error getting memory history', error);
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export async function getMemorySnapshot(snapshotId) {
|
|
26
|
-
try {
|
|
27
|
-
const db = await getDb();
|
|
28
|
-
const schema = await getSchema();
|
|
29
|
-
const snapshot = await db
|
|
30
|
-
.select()
|
|
31
|
-
.from(schema.memorySnapshots)
|
|
32
|
-
.where(eq(schema.memorySnapshots.id, snapshotId))
|
|
33
|
-
.limit(1);
|
|
34
|
-
return snapshot.length > 0 ? snapshot[0] : null;
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
logger.error('Error getting snapshot', error);
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=retrieval.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Statistics
|
|
3
|
-
* Analytics and statistics for snapshot operations
|
|
4
|
-
*/
|
|
5
|
-
export declare function getSnapshotStats(memoryId?: string): Promise<{
|
|
6
|
-
totalSnapshots: number;
|
|
7
|
-
byType: Record<string, number>;
|
|
8
|
-
oldestSnapshot: Date | null;
|
|
9
|
-
newestSnapshot: Date | null;
|
|
10
|
-
}>;
|
|
11
|
-
//# sourceMappingURL=stats.d.ts.map
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Snapshot Statistics
|
|
3
|
-
* Analytics and statistics for snapshot operations
|
|
4
|
-
*/
|
|
5
|
-
import { eq } from 'drizzle-orm';
|
|
6
|
-
import { getDb } from '../../db/index.js';
|
|
7
|
-
import { getSchema } from '../../db/schema.js';
|
|
8
|
-
import { logger } from '../logger.js';
|
|
9
|
-
export async function getSnapshotStats(memoryId) {
|
|
10
|
-
try {
|
|
11
|
-
const db = await getDb();
|
|
12
|
-
const schema = await getSchema();
|
|
13
|
-
const where = memoryId ? eq(schema.memorySnapshots.memoryId, memoryId) : undefined;
|
|
14
|
-
const snapshots = await db
|
|
15
|
-
.select()
|
|
16
|
-
.from(schema.memorySnapshots)
|
|
17
|
-
.where(where);
|
|
18
|
-
const stats = {
|
|
19
|
-
totalSnapshots: snapshots.length,
|
|
20
|
-
byType: {
|
|
21
|
-
before_update: 0,
|
|
22
|
-
after_update: 0,
|
|
23
|
-
periodic: 0,
|
|
24
|
-
},
|
|
25
|
-
oldestSnapshot: null,
|
|
26
|
-
newestSnapshot: null,
|
|
27
|
-
};
|
|
28
|
-
let oldest = null;
|
|
29
|
-
let newest = null;
|
|
30
|
-
for (const snap of snapshots) {
|
|
31
|
-
stats.byType[snap.snapshotType]++;
|
|
32
|
-
const date = new Date(snap.createdAt);
|
|
33
|
-
if (!oldest || date < oldest)
|
|
34
|
-
oldest = date;
|
|
35
|
-
if (!newest || date > newest)
|
|
36
|
-
newest = date;
|
|
37
|
-
}
|
|
38
|
-
stats.oldestSnapshot = oldest;
|
|
39
|
-
stats.newestSnapshot = newest;
|
|
40
|
-
return stats;
|
|
41
|
-
}
|
|
42
|
-
catch (error) {
|
|
43
|
-
logger.error('Error getting snapshot stats', error);
|
|
44
|
-
return {
|
|
45
|
-
totalSnapshots: 0,
|
|
46
|
-
byType: {},
|
|
47
|
-
oldestSnapshot: null,
|
|
48
|
-
newestSnapshot: null,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=stats.js.map
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare function cacheGet<T>(key: string): Promise<T | null>;
|
|
2
|
-
export declare function cacheSet<T>(key: string, value: T, ttlMs?: number): Promise<void>;
|
|
3
|
-
export declare function getCacheStats(): {
|
|
4
|
-
entries: number;
|
|
5
|
-
sizeBytes: number;
|
|
6
|
-
maxSize: number;
|
|
7
|
-
maxSizeBytes: number;
|
|
8
|
-
utilizationPercent: number;
|
|
9
|
-
memoryUtilizationPercent: number;
|
|
10
|
-
};
|
|
11
|
-
export declare function closeCache(): Promise<void>;
|
|
12
|
-
export declare function checkRedisHealth(): Promise<boolean>;
|
|
13
|
-
//# sourceMappingURL=cache.d.ts.map
|