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,151 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Input validation utilities for Squish
|
|
3
|
-
* Consolidates scattered validation patterns into a unified module
|
|
4
|
-
*/
|
|
5
|
-
import { normalizeTags } from '../memory/serialization.js';
|
|
6
|
-
/**
|
|
7
|
-
* Validate and normalize a limit value with bounds checking
|
|
8
|
-
*/
|
|
9
|
-
export function validateLimit(value, defaultValue = 20, min = 1, max = 100) {
|
|
10
|
-
// Handle undefined, null, empty string
|
|
11
|
-
if (value === undefined || value === null || value === '') {
|
|
12
|
-
return defaultValue;
|
|
13
|
-
}
|
|
14
|
-
// Convert string to number, truncate decimals
|
|
15
|
-
let num;
|
|
16
|
-
if (typeof value === 'string') {
|
|
17
|
-
const parsed = parseInt(value, 10);
|
|
18
|
-
if (isNaN(parsed)) {
|
|
19
|
-
return NaN;
|
|
20
|
-
}
|
|
21
|
-
num = parsed;
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
// Truncate decimals for numbers
|
|
25
|
-
num = Math.trunc(value);
|
|
26
|
-
}
|
|
27
|
-
// Handle NaN
|
|
28
|
-
if (isNaN(num)) {
|
|
29
|
-
return NaN;
|
|
30
|
-
}
|
|
31
|
-
// Clamp to bounds
|
|
32
|
-
return Math.min(Math.max(num, min), max);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Parse an integer with bounds checking
|
|
36
|
-
*/
|
|
37
|
-
export function parseIntBounded(value, defaultValue, min, max) {
|
|
38
|
-
return validateLimit(value, defaultValue, min, max);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Validate a project path
|
|
42
|
-
*/
|
|
43
|
-
export async function validateProjectPath(path, options) {
|
|
44
|
-
const { createIfMissing = false, require: requireProject = false } = options || {};
|
|
45
|
-
// If path is undefined, throw if required or return current directory
|
|
46
|
-
if (path === undefined || path === '') {
|
|
47
|
-
if (requireProject) {
|
|
48
|
-
throw new Error('Project path is required');
|
|
49
|
-
}
|
|
50
|
-
return process.cwd();
|
|
51
|
-
}
|
|
52
|
-
// Resolve to absolute path
|
|
53
|
-
const absolutePath = path.startsWith('/') || /^[a-zA-Z]:\\/.test(path)
|
|
54
|
-
? path
|
|
55
|
-
: path.startsWith('~')
|
|
56
|
-
? path.replace(/^~/, process.env.HOME || process.env.USERPROFILE || '')
|
|
57
|
-
: path.startsWith('.')
|
|
58
|
-
? path
|
|
59
|
-
: path;
|
|
60
|
-
// Check if project exists in database
|
|
61
|
-
const { getProjectByPath } = await import('../projects.js');
|
|
62
|
-
const existingProject = await getProjectByPath(absolutePath);
|
|
63
|
-
if (existingProject) {
|
|
64
|
-
return absolutePath;
|
|
65
|
-
}
|
|
66
|
-
// Project doesn't exist
|
|
67
|
-
if (requireProject) {
|
|
68
|
-
throw new Error(`Project not found: ${absolutePath}`);
|
|
69
|
-
}
|
|
70
|
-
if (createIfMissing) {
|
|
71
|
-
const { ensureProject } = await import('../projects.js');
|
|
72
|
-
await ensureProject(absolutePath);
|
|
73
|
-
return absolutePath;
|
|
74
|
-
}
|
|
75
|
-
// Return the path even if it doesn't exist in database (for non-db validation)
|
|
76
|
-
return absolutePath;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Validate a UUID
|
|
80
|
-
*/
|
|
81
|
-
export function validateUuid(id) {
|
|
82
|
-
if (typeof id !== 'string' || !id) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
// UUID v4/v5 regex pattern (8-4-4-4-12 hex digits)
|
|
86
|
-
const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
87
|
-
return uuidRegex.test(id);
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Require a valid UUID, throws if invalid
|
|
91
|
-
*/
|
|
92
|
-
export function requireUuid(id) {
|
|
93
|
-
if (!validateUuid(id)) {
|
|
94
|
-
throw new Error('Invalid UUID');
|
|
95
|
-
}
|
|
96
|
-
return id;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Validate a date value
|
|
100
|
-
*
|
|
101
|
-
* @param value - The date to validate (string, Date, number, or undefined)
|
|
102
|
-
* @returns Date object if valid, null otherwise
|
|
103
|
-
*/
|
|
104
|
-
export function validateDate(value) {
|
|
105
|
-
if (!value) {
|
|
106
|
-
return null;
|
|
107
|
-
}
|
|
108
|
-
try {
|
|
109
|
-
let date;
|
|
110
|
-
if (value instanceof Date) {
|
|
111
|
-
date = value;
|
|
112
|
-
}
|
|
113
|
-
else if (typeof value === 'number') {
|
|
114
|
-
// Handle both milliseconds and seconds timestamps
|
|
115
|
-
if (value > 100000000000000) {
|
|
116
|
-
// Microseconds, convert to milliseconds
|
|
117
|
-
date = new Date(value / 1000);
|
|
118
|
-
}
|
|
119
|
-
else if (value > 1000000000000) {
|
|
120
|
-
// Milliseconds
|
|
121
|
-
date = new Date(value);
|
|
122
|
-
}
|
|
123
|
-
else if (value >= 0) {
|
|
124
|
-
// Seconds
|
|
125
|
-
date = new Date(value * 1000);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
else if (typeof value === 'string') {
|
|
132
|
-
date = new Date(value);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
return null;
|
|
136
|
-
}
|
|
137
|
-
// Check if date is valid
|
|
138
|
-
if (isNaN(date.getTime())) {
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
return date;
|
|
142
|
-
}
|
|
143
|
-
catch {
|
|
144
|
-
return null;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
// Re-export normalizeTags for tag validation
|
|
148
|
-
export { normalizeTags };
|
|
149
|
-
// Re-export clampLimit for backward compatibility
|
|
150
|
-
export { clampLimit } from './utils.js';
|
|
151
|
-
//# sourceMappingURL=validation.js.map
|
package/dist/core/lifecycle.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Lifecycle Management
|
|
3
|
-
* Implements sector-based decay, tier classification, and eviction policies
|
|
4
|
-
*
|
|
5
|
-
* Decay Formula: newScore = importanceScore * (1 - decayRate/100)^days
|
|
6
|
-
* - decayRate: per-memory integer (e.g., 30 = 30% decay per decay cycle)
|
|
7
|
-
* - days: days since lastDecayAt
|
|
8
|
-
* - Tier demotion occurs when score drops below decayThreshold
|
|
9
|
-
* - Cold memories below threshold get status = 'expired'
|
|
10
|
-
*/
|
|
11
|
-
export interface LifecycleStats {
|
|
12
|
-
decayed: number;
|
|
13
|
-
evicted: number;
|
|
14
|
-
promoted: number;
|
|
15
|
-
tierChanges: {
|
|
16
|
-
hot: number;
|
|
17
|
-
cold: number;
|
|
18
|
-
};
|
|
19
|
-
expired: number;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Run full lifecycle maintenance on all memories
|
|
23
|
-
*/
|
|
24
|
-
export declare function runLifecycleMaintenance(projectId?: string): Promise<LifecycleStats>;
|
|
25
|
-
//# sourceMappingURL=lifecycle.d.ts.map
|
package/dist/core/lifecycle.js
DELETED
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Lifecycle Management
|
|
3
|
-
* Implements sector-based decay, tier classification, and eviction policies
|
|
4
|
-
*
|
|
5
|
-
* Decay Formula: newScore = importanceScore * (1 - decayRate/100)^days
|
|
6
|
-
* - decayRate: per-memory integer (e.g., 30 = 30% decay per decay cycle)
|
|
7
|
-
* - days: days since lastDecayAt
|
|
8
|
-
* - Tier demotion occurs when score drops below decayThreshold
|
|
9
|
-
* - Cold memories below threshold get status = 'expired'
|
|
10
|
-
*/
|
|
11
|
-
import { and, eq, lt, inArray } from 'drizzle-orm';
|
|
12
|
-
import { getDb } from '../db/index.js';
|
|
13
|
-
import { getSchema } from '../db/schema.js';
|
|
14
|
-
import { config } from '../config.js';
|
|
15
|
-
import { logger } from './logger.js';
|
|
16
|
-
import { triggerTierChange, triggerDecayApplied } from './memory/hooks.js';
|
|
17
|
-
/**
|
|
18
|
-
* Default decay intervals by sector (days until decay check)
|
|
19
|
-
* These determine how often memories in each sector are evaluated for decay
|
|
20
|
-
* Can be configured via config.sectorDecayIntervals
|
|
21
|
-
*/
|
|
22
|
-
const SECTOR_DECAY_INTERVAL_DAYS = {
|
|
23
|
-
episodic: config.sectorDecayIntervals?.episodic || 30,
|
|
24
|
-
semantic: config.sectorDecayIntervals?.semantic || 90,
|
|
25
|
-
procedural: config.sectorDecayIntervals?.procedural || 180,
|
|
26
|
-
autobiographical: config.sectorDecayIntervals?.autobiographical || 365,
|
|
27
|
-
working: config.sectorDecayIntervals?.working || 7,
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Default decay rates by memory type (percentage per decay cycle)
|
|
31
|
-
* Used as fallback when memory.decayRate is not set
|
|
32
|
-
*/
|
|
33
|
-
const DEFAULT_DECAY_RATES = {
|
|
34
|
-
observation: 5,
|
|
35
|
-
fact: 3,
|
|
36
|
-
decision: 2,
|
|
37
|
-
context: 4,
|
|
38
|
-
preference: 3,
|
|
39
|
-
note: 5,
|
|
40
|
-
reflection: 2,
|
|
41
|
-
};
|
|
42
|
-
const TIER_THRESHOLDS = {
|
|
43
|
-
hot: { recency: 7, coactivation: 10, salience: 70 },
|
|
44
|
-
cold: { recency: Infinity, coactivation: 0, salience: 0 },
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Run full lifecycle maintenance on all memories
|
|
48
|
-
*/
|
|
49
|
-
export async function runLifecycleMaintenance(projectId) {
|
|
50
|
-
if (!config.lifecycleEnabled) {
|
|
51
|
-
return { decayed: 0, evicted: 0, promoted: 0, tierChanges: { hot: 0, cold: 0 }, expired: 0 };
|
|
52
|
-
}
|
|
53
|
-
const stats = {
|
|
54
|
-
decayed: 0,
|
|
55
|
-
evicted: 0,
|
|
56
|
-
promoted: 0,
|
|
57
|
-
tierChanges: { hot: 0, cold: 0 },
|
|
58
|
-
expired: 0,
|
|
59
|
-
};
|
|
60
|
-
try {
|
|
61
|
-
await applyDecay(projectId, stats);
|
|
62
|
-
await updateTiers(projectId, stats);
|
|
63
|
-
await evictOldMemories(projectId, stats);
|
|
64
|
-
}
|
|
65
|
-
catch (error) {
|
|
66
|
-
logger.error('Lifecycle maintenance error', error);
|
|
67
|
-
}
|
|
68
|
-
return stats;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Apply decay to memories using per-memory decay rate formula
|
|
72
|
-
*
|
|
73
|
-
* Formula: newScore = importanceScore * (1 - decayRate/100)^days
|
|
74
|
-
* - Uses per-memory decayRate (stored as integer percentage, e.g., 30 = 30%)
|
|
75
|
-
* - Calculates days since lastDecayAt
|
|
76
|
-
* - Demotes tier when score drops below decayThreshold
|
|
77
|
-
* - Sets status = 'expired' for cold memories below threshold
|
|
78
|
-
*/
|
|
79
|
-
async function applyDecay(projectId, stats) {
|
|
80
|
-
try {
|
|
81
|
-
const db = await getDb();
|
|
82
|
-
const schema = await getSchema();
|
|
83
|
-
const now = new Date();
|
|
84
|
-
const decayThreshold = config.decayThreshold || 0.1;
|
|
85
|
-
// Fetch memories that need decay processing (not protected, not expired)
|
|
86
|
-
let whereClause;
|
|
87
|
-
const conditions = [
|
|
88
|
-
eq(schema.memories.isProtected, false),
|
|
89
|
-
eq(schema.memories.status, 'active'),
|
|
90
|
-
];
|
|
91
|
-
if (projectId) {
|
|
92
|
-
conditions.push(eq(schema.memories.projectId, projectId));
|
|
93
|
-
}
|
|
94
|
-
whereClause = and(...conditions);
|
|
95
|
-
const memories = await db
|
|
96
|
-
.select()
|
|
97
|
-
.from(schema.memories)
|
|
98
|
-
.where(whereClause)
|
|
99
|
-
.limit(10000);
|
|
100
|
-
let decayed = 0;
|
|
101
|
-
let expired = 0;
|
|
102
|
-
const expiredIds = [];
|
|
103
|
-
for (const memory of memories) {
|
|
104
|
-
// Get decay rate for this memory (fallback to type-based default)
|
|
105
|
-
const decayRate = memory.decayRate || DEFAULT_DECAY_RATES[memory.type] || 5;
|
|
106
|
-
// Calculate days since last decay
|
|
107
|
-
const lastDecayAt = memory.lastDecayAt ? new Date(memory.lastDecayAt) : new Date(memory.createdAt);
|
|
108
|
-
const daysSinceDecay = Math.max(0, (now.getTime() - lastDecayAt.getTime()) / (24 * 60 * 60 * 1000));
|
|
109
|
-
// Skip if not enough time has passed for this sector
|
|
110
|
-
const sectorInterval = SECTOR_DECAY_INTERVAL_DAYS[memory.sector] || 30;
|
|
111
|
-
if (daysSinceDecay < sectorInterval) {
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
// Apply decay formula: newScore = oldScore * (1 - decayRate/100)^days
|
|
115
|
-
const currentScore = memory.importanceScore || memory.relevanceScore || 50;
|
|
116
|
-
const decayMultiplier = Math.pow(1 - decayRate / 100, daysSinceDecay / sectorInterval);
|
|
117
|
-
const newScore = Math.max(0, Math.round(currentScore * decayMultiplier));
|
|
118
|
-
// Check if memory should expire (cold tier + below threshold)
|
|
119
|
-
const shouldExpire = memory.tier === 'cold' && newScore < (decayThreshold * 100);
|
|
120
|
-
if (shouldExpire) {
|
|
121
|
-
expiredIds.push(memory.id);
|
|
122
|
-
expired++;
|
|
123
|
-
logger.debug('Memory expiring', { id: memory.id, score: newScore, tier: memory.tier });
|
|
124
|
-
}
|
|
125
|
-
else if (newScore !== currentScore) {
|
|
126
|
-
// Only update if score changed
|
|
127
|
-
await db
|
|
128
|
-
.update(schema.memories)
|
|
129
|
-
.set({
|
|
130
|
-
importanceScore: newScore,
|
|
131
|
-
relevanceScore: newScore,
|
|
132
|
-
lastDecayAt: now,
|
|
133
|
-
updatedAt: now,
|
|
134
|
-
})
|
|
135
|
-
.where(eq(schema.memories.id, memory.id));
|
|
136
|
-
decayed++;
|
|
137
|
-
// Trigger decay applied hook
|
|
138
|
-
try {
|
|
139
|
-
await triggerDecayApplied({
|
|
140
|
-
memoryId: memory.id,
|
|
141
|
-
content: memory.content,
|
|
142
|
-
type: memory.type,
|
|
143
|
-
tags: typeof memory.tags === 'string' ? memory.tags.split(',') : [],
|
|
144
|
-
project: memory.projectId || undefined,
|
|
145
|
-
source: memory.source || undefined,
|
|
146
|
-
tier: memory.tier,
|
|
147
|
-
importance: newScore,
|
|
148
|
-
oldScore: currentScore,
|
|
149
|
-
newScore: newScore,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
catch (hookError) {
|
|
153
|
-
logger.error('Error triggering decayApplied hook', hookError);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
// Batch expire memories
|
|
158
|
-
if (expiredIds.length > 0) {
|
|
159
|
-
await db
|
|
160
|
-
.update(schema.memories)
|
|
161
|
-
.set({
|
|
162
|
-
status: 'expired',
|
|
163
|
-
updatedAt: now,
|
|
164
|
-
})
|
|
165
|
-
.where(inArray(schema.memories.id, expiredIds));
|
|
166
|
-
}
|
|
167
|
-
stats.decayed += decayed;
|
|
168
|
-
stats.expired += expired;
|
|
169
|
-
logger.info('Decay applied', { decayed, expired, total: memories.length });
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
logger.error('Error applying decay', error);
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Update memory tiers based on recency, coactivation, and salience
|
|
177
|
-
*/
|
|
178
|
-
async function updateTiers(projectId, stats) {
|
|
179
|
-
try {
|
|
180
|
-
const db = await getDb();
|
|
181
|
-
const schema = await getSchema();
|
|
182
|
-
const now = new Date();
|
|
183
|
-
// Fetch all memories to classify
|
|
184
|
-
const where = projectId ? eq(schema.memories.projectId, projectId) : undefined;
|
|
185
|
-
const memories = await db
|
|
186
|
-
.select()
|
|
187
|
-
.from(schema.memories)
|
|
188
|
-
.where(where)
|
|
189
|
-
.limit(10000); // Process larger batches now
|
|
190
|
-
// Calculate tiers in memory (simplified: hot or cold only)
|
|
191
|
-
const tierAssignments = new Map();
|
|
192
|
-
const tierCounts = { hot: 0, cold: 0 };
|
|
193
|
-
for (const memory of memories) {
|
|
194
|
-
const recencyDays = (now.getTime() - new Date(memory.createdAt).getTime()) / (24 * 60 * 60 * 1000);
|
|
195
|
-
const coactivation = memory.coactivationScore || 0;
|
|
196
|
-
const salience = memory.relevanceScore || 50;
|
|
197
|
-
let newTier = 'cold';
|
|
198
|
-
if (recencyDays <= TIER_THRESHOLDS.hot.recency &&
|
|
199
|
-
coactivation >= TIER_THRESHOLDS.hot.coactivation &&
|
|
200
|
-
salience >= TIER_THRESHOLDS.hot.salience) {
|
|
201
|
-
newTier = 'hot';
|
|
202
|
-
}
|
|
203
|
-
if (newTier !== memory.tier) {
|
|
204
|
-
tierAssignments.set(memory.id, newTier);
|
|
205
|
-
tierCounts[newTier]++;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (tierAssignments.size === 0)
|
|
209
|
-
return;
|
|
210
|
-
// Group by tier for efficient batched updates
|
|
211
|
-
const hotIds = Array.from(tierAssignments.entries())
|
|
212
|
-
.filter(([_, tier]) => tier === 'hot')
|
|
213
|
-
.map(([id]) => id);
|
|
214
|
-
const coldIds = Array.from(tierAssignments.entries())
|
|
215
|
-
.filter(([_, tier]) => tier === 'cold')
|
|
216
|
-
.map(([id]) => id);
|
|
217
|
-
// Execute batched updates instead of individual queries
|
|
218
|
-
if (hotIds.length > 0) {
|
|
219
|
-
await db
|
|
220
|
-
.update(schema.memories)
|
|
221
|
-
.set({ tier: 'hot', updatedAt: now })
|
|
222
|
-
.where(inArray(schema.memories.id, hotIds));
|
|
223
|
-
}
|
|
224
|
-
if (coldIds.length > 0) {
|
|
225
|
-
await db
|
|
226
|
-
.update(schema.memories)
|
|
227
|
-
.set({ tier: 'cold', updatedAt: now })
|
|
228
|
-
.where(inArray(schema.memories.id, coldIds));
|
|
229
|
-
}
|
|
230
|
-
if (coldIds.length > 0) {
|
|
231
|
-
await db
|
|
232
|
-
.update(schema.memories)
|
|
233
|
-
.set({ tier: 'cold', updatedAt: now })
|
|
234
|
-
.where(inArray(schema.memories.id, coldIds));
|
|
235
|
-
}
|
|
236
|
-
// Trigger tier change hooks for each memory that changed tier
|
|
237
|
-
if (tierAssignments.size > 0) {
|
|
238
|
-
for (const memory of memories) {
|
|
239
|
-
const newTier = tierAssignments.get(memory.id);
|
|
240
|
-
if (newTier && newTier !== memory.tier) {
|
|
241
|
-
try {
|
|
242
|
-
await triggerTierChange({
|
|
243
|
-
memoryId: memory.id,
|
|
244
|
-
content: memory.content,
|
|
245
|
-
type: memory.type,
|
|
246
|
-
tags: typeof memory.tags === 'string' ? memory.tags.split(',') : [],
|
|
247
|
-
project: memory.projectId || undefined,
|
|
248
|
-
source: memory.source || undefined,
|
|
249
|
-
tier: newTier,
|
|
250
|
-
importance: memory.importanceScore || memory.relevanceScore || 50,
|
|
251
|
-
oldTier: memory.tier,
|
|
252
|
-
newTier: newTier,
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
catch (hookError) {
|
|
256
|
-
logger.error('Error triggering tierChange hook', hookError);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
// Update stats
|
|
262
|
-
stats.tierChanges.hot = tierCounts.hot;
|
|
263
|
-
stats.tierChanges.cold = tierCounts.cold;
|
|
264
|
-
logger.debug('Tier updates complete', {
|
|
265
|
-
hot: tierCounts.hot,
|
|
266
|
-
cold: tierCounts.cold,
|
|
267
|
-
});
|
|
268
|
-
}
|
|
269
|
-
catch (error) {
|
|
270
|
-
logger.error('Error updating tiers', error);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
/**
|
|
274
|
-
* Evict old, cold memories with low relevance
|
|
275
|
-
*/
|
|
276
|
-
async function evictOldMemories(projectId, stats) {
|
|
277
|
-
try {
|
|
278
|
-
const db = await getDb();
|
|
279
|
-
const schema = await getSchema();
|
|
280
|
-
const evictionThreshold = new Date(Date.now() - 180 * 24 * 60 * 60 * 1000); // 180 days
|
|
281
|
-
const where = projectId
|
|
282
|
-
? and(eq(schema.memories.projectId, projectId), lt(schema.memories.createdAt, evictionThreshold), eq(schema.memories.isProtected, false), eq(schema.memories.isPinned, false), eq(schema.memories.tier, 'cold'), lt(schema.memories.relevanceScore, 20) // Very low relevance
|
|
283
|
-
)
|
|
284
|
-
: and(lt(schema.memories.createdAt, evictionThreshold), eq(schema.memories.isProtected, false), eq(schema.memories.isPinned, false), eq(schema.memories.tier, 'cold'), lt(schema.memories.relevanceScore, 20));
|
|
285
|
-
const result = await db.delete(schema.memories).where(where);
|
|
286
|
-
stats.evicted = result?.rowCount || 0;
|
|
287
|
-
}
|
|
288
|
-
catch (error) {
|
|
289
|
-
logger.error('Error evicting memories', error);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
//# sourceMappingURL=lifecycle.js.map
|
package/dist/core/logger.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
interface LogContext {
|
|
2
|
-
[key: string]: any;
|
|
3
|
-
}
|
|
4
|
-
declare class Logger {
|
|
5
|
-
private prefix;
|
|
6
|
-
private debugEnabled;
|
|
7
|
-
constructor(prefix?: string);
|
|
8
|
-
private format;
|
|
9
|
-
private isQuiet;
|
|
10
|
-
info(message: string, context?: LogContext): void;
|
|
11
|
-
warn(message: string, context?: LogContext): void;
|
|
12
|
-
error(message: string, error?: Error | any, context?: LogContext): void;
|
|
13
|
-
debug(message: string, context?: LogContext): void;
|
|
14
|
-
}
|
|
15
|
-
export declare const logger: Logger;
|
|
16
|
-
export {};
|
|
17
|
-
//# sourceMappingURL=logger.d.ts.map
|
package/dist/core/logger.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
class Logger {
|
|
2
|
-
prefix;
|
|
3
|
-
debugEnabled;
|
|
4
|
-
constructor(prefix = 'squish') {
|
|
5
|
-
this.prefix = prefix;
|
|
6
|
-
this.debugEnabled = process.env.DEBUG === 'true' || process.env.DEBUG === '1';
|
|
7
|
-
}
|
|
8
|
-
format(level, message, context) {
|
|
9
|
-
const timestamp = new Date().toISOString();
|
|
10
|
-
const ctx = context ? ` ${JSON.stringify(context)}` : '';
|
|
11
|
-
return `[${this.prefix}:${level}] ${message}${ctx}`;
|
|
12
|
-
}
|
|
13
|
-
isQuiet() {
|
|
14
|
-
return process.env.SQUISH_QUIET === 'true' || process.env.SQUISH_QUIET === '1';
|
|
15
|
-
}
|
|
16
|
-
info(message, context) {
|
|
17
|
-
if (this.isQuiet()) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
console.error(this.format('info', message, context));
|
|
21
|
-
}
|
|
22
|
-
warn(message, context) {
|
|
23
|
-
if (this.isQuiet()) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
console.error(this.format('warn', message, context));
|
|
27
|
-
}
|
|
28
|
-
error(message, error, context) {
|
|
29
|
-
if (this.isQuiet()) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const errorMsg = error instanceof Error ? error.message : error;
|
|
33
|
-
const ctx = { ...context, error: errorMsg };
|
|
34
|
-
console.error(this.format('error', message, ctx));
|
|
35
|
-
if (error instanceof Error && error.stack) {
|
|
36
|
-
console.error(error.stack);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
debug(message, context) {
|
|
40
|
-
if (this.debugEnabled && !this.isQuiet()) {
|
|
41
|
-
console.error(this.format('debug', message, context));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
export const logger = new Logger();
|
|
46
|
-
//# sourceMappingURL=logger.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { MCPToolResult, MCPInitializeResponse } from './types.js';
|
|
2
|
-
export declare class MCPClient {
|
|
3
|
-
private baseUrl;
|
|
4
|
-
private connected;
|
|
5
|
-
private serverInfo;
|
|
6
|
-
constructor(baseUrl?: string);
|
|
7
|
-
initialize(): Promise<MCPInitializeResponse>;
|
|
8
|
-
listTools(): Promise<any[]>;
|
|
9
|
-
callTool(name: string, args?: Record<string, any>): Promise<MCPToolResult>;
|
|
10
|
-
healthCheck(): Promise<boolean>;
|
|
11
|
-
isConnected(): boolean;
|
|
12
|
-
getServerInfo(): {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
15
|
-
} | null;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=client.d.ts.map
|
package/dist/core/mcp/client.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { logger } from '../logger.js';
|
|
2
|
-
export class MCPClient {
|
|
3
|
-
baseUrl;
|
|
4
|
-
connected = false;
|
|
5
|
-
serverInfo = null;
|
|
6
|
-
constructor(baseUrl = 'http://localhost:8766') {
|
|
7
|
-
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
8
|
-
}
|
|
9
|
-
async initialize() {
|
|
10
|
-
const request = {
|
|
11
|
-
protocolVersion: '2024-11-05',
|
|
12
|
-
capabilities: {
|
|
13
|
-
tools: {},
|
|
14
|
-
},
|
|
15
|
-
clientInfo: {
|
|
16
|
-
name: 'squish-mcp-client',
|
|
17
|
-
version: '0.9.0',
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
try {
|
|
21
|
-
const response = await fetch(`${this.baseUrl}/initialize`, {
|
|
22
|
-
method: 'POST',
|
|
23
|
-
headers: { 'Content-Type': 'application/json' },
|
|
24
|
-
body: JSON.stringify(request),
|
|
25
|
-
});
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
throw new Error(`Initialize failed: ${response.statusText}`);
|
|
28
|
-
}
|
|
29
|
-
const result = await response.json();
|
|
30
|
-
this.serverInfo = result.serverInfo;
|
|
31
|
-
this.connected = true;
|
|
32
|
-
logger.info(`Connected to MCP server: ${result.serverInfo.name} v${result.serverInfo.version}`);
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
catch (error) {
|
|
36
|
-
logger.error('Failed to initialize MCP connection:', error);
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
async listTools() {
|
|
41
|
-
try {
|
|
42
|
-
const response = await fetch(`${this.baseUrl}/tools/list`);
|
|
43
|
-
if (!response.ok) {
|
|
44
|
-
throw new Error(`List tools failed: ${response.statusText}`);
|
|
45
|
-
}
|
|
46
|
-
const data = await response.json();
|
|
47
|
-
return data.tools || [];
|
|
48
|
-
}
|
|
49
|
-
catch (error) {
|
|
50
|
-
logger.error('Failed to list tools:', error);
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
async callTool(name, args = {}) {
|
|
55
|
-
if (!this.connected) {
|
|
56
|
-
await this.initialize();
|
|
57
|
-
}
|
|
58
|
-
const toolCall = { name, arguments: args };
|
|
59
|
-
try {
|
|
60
|
-
const response = await fetch(`${this.baseUrl}/tools/call`, {
|
|
61
|
-
method: 'POST',
|
|
62
|
-
headers: { 'Content-Type': 'application/json' },
|
|
63
|
-
body: JSON.stringify(toolCall),
|
|
64
|
-
});
|
|
65
|
-
if (!response.ok) {
|
|
66
|
-
const errorText = await response.text();
|
|
67
|
-
throw new Error(`Tool call failed: ${response.statusText} - ${errorText}`);
|
|
68
|
-
}
|
|
69
|
-
const result = await response.json();
|
|
70
|
-
return result;
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
logger.error(`Tool call error (${name}):`, error);
|
|
74
|
-
return {
|
|
75
|
-
content: [{
|
|
76
|
-
type: 'text',
|
|
77
|
-
text: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`,
|
|
78
|
-
}],
|
|
79
|
-
isError: true,
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
async healthCheck() {
|
|
84
|
-
try {
|
|
85
|
-
const response = await fetch(`${this.baseUrl}/health`, {
|
|
86
|
-
method: 'GET',
|
|
87
|
-
});
|
|
88
|
-
return response.ok;
|
|
89
|
-
}
|
|
90
|
-
catch (error) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
isConnected() {
|
|
95
|
-
return this.connected;
|
|
96
|
-
}
|
|
97
|
-
getServerInfo() {
|
|
98
|
-
return this.serverInfo;
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=client.js.map
|
package/dist/core/mcp/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { MCPServer } from './server.js';
|
|
2
|
-
export { MCPClient } from './client.js';
|
|
3
|
-
export { SquishMCPServer, startMCPServer, stopMCPServer, getSquishMCPServer } from './standalone-server.js';
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
export * from './tools.js';
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/mcp/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { MCPServer } from './server.js';
|
|
2
|
-
export { MCPClient } from './client.js';
|
|
3
|
-
export { SquishMCPServer, startMCPServer, stopMCPServer, getSquishMCPServer } from './standalone-server.js';
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
export * from './tools.js';
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { MCPToolDefinition } from './types.js';
|
|
2
|
-
export declare class MCPServer {
|
|
3
|
-
private app;
|
|
4
|
-
private httpServer;
|
|
5
|
-
private tools;
|
|
6
|
-
private port;
|
|
7
|
-
private serverName;
|
|
8
|
-
private serverVersion;
|
|
9
|
-
constructor(port?: number, serverName?: string, serverVersion?: string);
|
|
10
|
-
private setupMiddleware;
|
|
11
|
-
private setupRoutes;
|
|
12
|
-
registerTool(definition: MCPToolDefinition): void;
|
|
13
|
-
registerTools(definitions: MCPToolDefinition[]): void;
|
|
14
|
-
start(): Promise<void>;
|
|
15
|
-
stop(): Promise<void>;
|
|
16
|
-
getToolCount(): number;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=server.d.ts.map
|