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,146 +0,0 @@
|
|
|
1
|
-
import { logger } from '../logger.js';
|
|
2
|
-
import { config } from '../../config.js';
|
|
3
|
-
export async function getGoogleMultimodalEmbedding(input) {
|
|
4
|
-
if (!config.googleCloudApiKey && !config.googleCloudProject) {
|
|
5
|
-
logger.debug('Google Cloud credentials not configured');
|
|
6
|
-
return null;
|
|
7
|
-
}
|
|
8
|
-
if (!config.googleEmbeddingModel) {
|
|
9
|
-
logger.debug('Google embedding model not configured');
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
|
-
try {
|
|
13
|
-
const endpoint = config.googleCloudLocation === 'global'
|
|
14
|
-
? `https://aiplatform.googleapis.com/v1/projects/${config.googleCloudProject}/locations/${config.googleCloudLocation}/publishers/google/models/${config.googleEmbeddingModel}:predict`
|
|
15
|
-
: `https://${config.googleCloudLocation}-aiplatform.googleapis.com/v1/projects/${config.googleCloudProject}/locations/${config.googleCloudLocation}/publishers/google/models/${config.googleEmbeddingModel}:predict`;
|
|
16
|
-
const instances = [];
|
|
17
|
-
if (input.text) {
|
|
18
|
-
instances.push({ text: input.text });
|
|
19
|
-
}
|
|
20
|
-
if (input.image) {
|
|
21
|
-
const imageBytes = typeof input.image === 'string'
|
|
22
|
-
? input.image
|
|
23
|
-
: input.image.toString('base64');
|
|
24
|
-
instances.push({
|
|
25
|
-
image: {
|
|
26
|
-
bytesBase64Encoded: imageBytes,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
if (input.video) {
|
|
31
|
-
instances.push({
|
|
32
|
-
video: {
|
|
33
|
-
gcsUri: input.video,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
if (instances.length === 0) {
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
const response = await fetch(endpoint, {
|
|
41
|
-
method: 'POST',
|
|
42
|
-
headers: {
|
|
43
|
-
'Content-Type': 'application/json',
|
|
44
|
-
'Authorization': `Bearer ${await getGoogleAccessToken()}`,
|
|
45
|
-
},
|
|
46
|
-
body: JSON.stringify({
|
|
47
|
-
instances,
|
|
48
|
-
parameters: {
|
|
49
|
-
dimension: 1408,
|
|
50
|
-
},
|
|
51
|
-
}),
|
|
52
|
-
});
|
|
53
|
-
if (!response.ok) {
|
|
54
|
-
const errorText = await response.text();
|
|
55
|
-
logger.warn(`Google Multimodal embeddings failed: ${response.status} ${errorText}`);
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
const data = await response.json();
|
|
59
|
-
const predictions = data.predictions || [];
|
|
60
|
-
const result = {
|
|
61
|
-
embedding: predictions[0]?.embedding || [],
|
|
62
|
-
};
|
|
63
|
-
if (input.text && predictions[0]?.textEmbedding) {
|
|
64
|
-
result.textEmbedding = predictions[0].textEmbedding;
|
|
65
|
-
}
|
|
66
|
-
if (input.image && predictions[0]?.imageEmbedding) {
|
|
67
|
-
result.imageEmbedding = predictions[0].imageEmbedding;
|
|
68
|
-
}
|
|
69
|
-
if (input.video && predictions[0]?.videoEmbedding) {
|
|
70
|
-
result.videoEmbedding = predictions[0].videoEmbedding;
|
|
71
|
-
}
|
|
72
|
-
return result.embedding.length > 0 ? result : null;
|
|
73
|
-
}
|
|
74
|
-
catch (error) {
|
|
75
|
-
logger.error('Google Multimodal embedding error:', error);
|
|
76
|
-
return null;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
let cachedAccessToken = null;
|
|
80
|
-
let tokenExpiry = 0;
|
|
81
|
-
async function getGoogleAccessToken() {
|
|
82
|
-
if (config.googleCloudApiKey) {
|
|
83
|
-
return config.googleCloudApiKey;
|
|
84
|
-
}
|
|
85
|
-
if (cachedAccessToken && Date.now() < tokenExpiry) {
|
|
86
|
-
return cachedAccessToken;
|
|
87
|
-
}
|
|
88
|
-
if (!process.env.GOOGLE_APPLICATION_CREDENTIALS) {
|
|
89
|
-
throw new Error('Google Application Credentials not set');
|
|
90
|
-
}
|
|
91
|
-
try {
|
|
92
|
-
const credentials = JSON.parse(await import('fs').then(fs => fs.promises.readFile(process.env.GOOGLE_APPLICATION_CREDENTIALS, 'utf-8')));
|
|
93
|
-
const now = Math.floor(Date.now() / 1000);
|
|
94
|
-
const jwt = await createJWT(credentials);
|
|
95
|
-
const tokenResponse = await fetch('https://oauth2.googleapis.com/token', {
|
|
96
|
-
method: 'POST',
|
|
97
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
98
|
-
body: new URLSearchParams({
|
|
99
|
-
grant_type: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
|
|
100
|
-
assertion: jwt,
|
|
101
|
-
}),
|
|
102
|
-
});
|
|
103
|
-
if (!tokenResponse.ok) {
|
|
104
|
-
throw new Error('Failed to get Google access token');
|
|
105
|
-
}
|
|
106
|
-
const tokenData = await tokenResponse.json();
|
|
107
|
-
cachedAccessToken = tokenData.access_token;
|
|
108
|
-
tokenExpiry = now + tokenData.expires_in - 60;
|
|
109
|
-
return cachedAccessToken;
|
|
110
|
-
}
|
|
111
|
-
catch (error) {
|
|
112
|
-
logger.error('Failed to get Google access token:', error);
|
|
113
|
-
throw error;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
async function createJWT(credentials) {
|
|
117
|
-
const now = Math.floor(Date.now() / 1000);
|
|
118
|
-
const header = {
|
|
119
|
-
alg: 'RS256',
|
|
120
|
-
typ: 'JWT',
|
|
121
|
-
};
|
|
122
|
-
const payload = {
|
|
123
|
-
iss: credentials.client_email,
|
|
124
|
-
sub: credentials.client_email,
|
|
125
|
-
aud: 'https://oauth2.googleapis.com/token',
|
|
126
|
-
iat: now,
|
|
127
|
-
exp: now + 3600,
|
|
128
|
-
scope: 'https://www.googleapis.com/auth/cloud-platform',
|
|
129
|
-
};
|
|
130
|
-
const crypto = await import('crypto');
|
|
131
|
-
const encodedHeader = Buffer.from(JSON.stringify(header)).toString('base64url');
|
|
132
|
-
const encodedPayload = Buffer.from(JSON.stringify(payload)).toString('base64url');
|
|
133
|
-
const signatureInput = `${encodedHeader}.${encodedPayload}`;
|
|
134
|
-
const sign = crypto.createSign('RSA-SHA256');
|
|
135
|
-
sign.update(signatureInput);
|
|
136
|
-
const signature = sign.sign(credentials.private_key, 'base64url');
|
|
137
|
-
return `${signatureInput}.${signature}`;
|
|
138
|
-
}
|
|
139
|
-
export function isMultimodalInput(input) {
|
|
140
|
-
return (typeof input === 'object' &&
|
|
141
|
-
(typeof input.text === 'string' ||
|
|
142
|
-
Buffer.isBuffer(input.image) ||
|
|
143
|
-
typeof input.image === 'string' ||
|
|
144
|
-
typeof input.video === 'string'));
|
|
145
|
-
}
|
|
146
|
-
//# sourceMappingURL=google-multimodal.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for local embeddings
|
|
3
|
-
* Note: Actual embedding generation is in core/embeddings.ts
|
|
4
|
-
*/
|
|
5
|
-
import { cosineSimilarity as vectorCosineSimilarity } from '../utils/vector-operations.js';
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use cosineSimilarity from core/utils/vector-operations.ts directly.
|
|
8
|
-
* This re-export is for backward compatibility and will be removed in v1.2.0.
|
|
9
|
-
*/
|
|
10
|
-
export declare const cosineSimilarity: typeof vectorCosineSimilarity;
|
|
11
|
-
//# sourceMappingURL=local-embeddings.d.ts.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Utility functions for local embeddings
|
|
3
|
-
* Note: Actual embedding generation is in core/embeddings.ts
|
|
4
|
-
*/
|
|
5
|
-
import { cosineSimilarity as vectorCosineSimilarity } from '../utils/vector-operations.js';
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use cosineSimilarity from core/utils/vector-operations.ts directly.
|
|
8
|
-
* This re-export is for backward compatibility and will be removed in v1.2.0.
|
|
9
|
-
*/
|
|
10
|
-
export const cosineSimilarity = vectorCosineSimilarity;
|
|
11
|
-
//# sourceMappingURL=local-embeddings.js.map
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QMD MCP Client
|
|
3
|
-
*
|
|
4
|
-
* Connects to QMD (Quick Markdown Search) MCP server for hybrid search capabilities.
|
|
5
|
-
* QMD provides BM25 full-text search, vector semantic search, and LLM re-ranking.
|
|
6
|
-
*
|
|
7
|
-
* Installation: bun install -g qmd
|
|
8
|
-
* GitHub: https://github.com/tobi/qmd
|
|
9
|
-
*
|
|
10
|
-
* QMD MCP Tools:
|
|
11
|
-
* - qmd_search: Fast BM25 keyword search
|
|
12
|
-
* - qmd_vsearch: Semantic vector search
|
|
13
|
-
* - qmd_query: Hybrid search with re-ranking (best quality)
|
|
14
|
-
* - qmd_get: Retrieve document by path or docid
|
|
15
|
-
* - qmd_multi_get: Retrieve multiple documents
|
|
16
|
-
* - qmd_status: Index health and collection info
|
|
17
|
-
*/
|
|
18
|
-
export interface QMDSearchOptions {
|
|
19
|
-
query: string;
|
|
20
|
-
collection?: string;
|
|
21
|
-
limit?: number;
|
|
22
|
-
minScore?: number;
|
|
23
|
-
}
|
|
24
|
-
export interface QMDSearchResult {
|
|
25
|
-
docid: string;
|
|
26
|
-
path: string;
|
|
27
|
-
title: string;
|
|
28
|
-
context: string;
|
|
29
|
-
score: number;
|
|
30
|
-
snippet: string;
|
|
31
|
-
}
|
|
32
|
-
export interface QMDStatusResult {
|
|
33
|
-
indexHealth: string;
|
|
34
|
-
collections: Array<{
|
|
35
|
-
name: string;
|
|
36
|
-
path: string;
|
|
37
|
-
documentCount: number;
|
|
38
|
-
}>;
|
|
39
|
-
}
|
|
40
|
-
export interface QMDGetOptions {
|
|
41
|
-
pathOrDocid: string;
|
|
42
|
-
full?: boolean;
|
|
43
|
-
maxBytes?: number;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* QMD MCP Client class
|
|
47
|
-
*
|
|
48
|
-
* Manages connection to QMD MCP server and provides methods for
|
|
49
|
-
* search, document retrieval, and status checking.
|
|
50
|
-
*/
|
|
51
|
-
export declare class QMDClient {
|
|
52
|
-
private client;
|
|
53
|
-
private transport;
|
|
54
|
-
private connected;
|
|
55
|
-
private connecting;
|
|
56
|
-
/**
|
|
57
|
-
* Check if QMD is installed on the system
|
|
58
|
-
*/
|
|
59
|
-
checkQMDInstalled(): Promise<boolean>;
|
|
60
|
-
/**
|
|
61
|
-
* Connect to QMD MCP server
|
|
62
|
-
* QMD must be installed: bun install -g qmd
|
|
63
|
-
*/
|
|
64
|
-
connect(): Promise<boolean>;
|
|
65
|
-
/**
|
|
66
|
-
* Check if QMD is available
|
|
67
|
-
*/
|
|
68
|
-
isAvailable(): Promise<boolean>;
|
|
69
|
-
/**
|
|
70
|
-
* Fast BM25 keyword search
|
|
71
|
-
* Uses SQLite FTS5 for fast full-text search
|
|
72
|
-
*/
|
|
73
|
-
search(options: QMDSearchOptions): Promise<QMDSearchResult[]>;
|
|
74
|
-
/**
|
|
75
|
-
* Semantic vector search
|
|
76
|
-
* Uses embedding-based similarity search
|
|
77
|
-
*/
|
|
78
|
-
vsearch(options: QMDSearchOptions): Promise<QMDSearchResult[]>;
|
|
79
|
-
/**
|
|
80
|
-
* Hybrid search with re-ranking (best quality)
|
|
81
|
-
* Combines BM25 + vector search + LLM re-ranking
|
|
82
|
-
*/
|
|
83
|
-
query(options: QMDSearchOptions): Promise<QMDSearchResult[]>;
|
|
84
|
-
/**
|
|
85
|
-
* Get QMD index status and collection info
|
|
86
|
-
*/
|
|
87
|
-
status(): Promise<QMDStatusResult | null>;
|
|
88
|
-
/**
|
|
89
|
-
* Get document by path or docid
|
|
90
|
-
*/
|
|
91
|
-
get(options: QMDGetOptions): Promise<string>;
|
|
92
|
-
/**
|
|
93
|
-
* Get multiple documents by glob pattern or list
|
|
94
|
-
*/
|
|
95
|
-
multiGet(patternOrList: string | string[], options?: {
|
|
96
|
-
maxBytes?: number;
|
|
97
|
-
limit?: number;
|
|
98
|
-
}): Promise<string[]>;
|
|
99
|
-
/**
|
|
100
|
-
* Disconnect from QMD MCP server
|
|
101
|
-
*/
|
|
102
|
-
disconnect(): Promise<void>;
|
|
103
|
-
/**
|
|
104
|
-
* Parse search results from QMD response
|
|
105
|
-
*/
|
|
106
|
-
private parseSearchResults;
|
|
107
|
-
/**
|
|
108
|
-
* Parse QMD's text output format into structured results
|
|
109
|
-
*/
|
|
110
|
-
private parseTextSearchResults;
|
|
111
|
-
/**
|
|
112
|
-
* Finalize a parsed result with defaults
|
|
113
|
-
*/
|
|
114
|
-
private finalizeResult;
|
|
115
|
-
/**
|
|
116
|
-
* Parse status result
|
|
117
|
-
*/
|
|
118
|
-
private parseStatusResult;
|
|
119
|
-
/**
|
|
120
|
-
* Parse get result
|
|
121
|
-
*/
|
|
122
|
-
private parseGetResult;
|
|
123
|
-
/**
|
|
124
|
-
* Parse multi-get result
|
|
125
|
-
*/
|
|
126
|
-
private parseMultiGetResult;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get the singleton QMD client instance
|
|
130
|
-
*/
|
|
131
|
-
export declare function getQMDClient(): Promise<QMDClient>;
|
|
132
|
-
/**
|
|
133
|
-
* Reset the singleton QMD client (useful for testing)
|
|
134
|
-
*/
|
|
135
|
-
export declare function resetQMDClient(): void;
|
|
136
|
-
//# sourceMappingURL=qmd-client.d.ts.map
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* QMD MCP Client
|
|
3
|
-
*
|
|
4
|
-
* Connects to QMD (Quick Markdown Search) MCP server for hybrid search capabilities.
|
|
5
|
-
* QMD provides BM25 full-text search, vector semantic search, and LLM re-ranking.
|
|
6
|
-
*
|
|
7
|
-
* Installation: bun install -g qmd
|
|
8
|
-
* GitHub: https://github.com/tobi/qmd
|
|
9
|
-
*
|
|
10
|
-
* QMD MCP Tools:
|
|
11
|
-
* - qmd_search: Fast BM25 keyword search
|
|
12
|
-
* - qmd_vsearch: Semantic vector search
|
|
13
|
-
* - qmd_query: Hybrid search with re-ranking (best quality)
|
|
14
|
-
* - qmd_get: Retrieve document by path or docid
|
|
15
|
-
* - qmd_multi_get: Retrieve multiple documents
|
|
16
|
-
* - qmd_status: Index health and collection info
|
|
17
|
-
*/
|
|
18
|
-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
19
|
-
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
20
|
-
import { spawn } from 'child_process';
|
|
21
|
-
import { logger } from '../logger';
|
|
22
|
-
/**
|
|
23
|
-
* QMD MCP Client class
|
|
24
|
-
*
|
|
25
|
-
* Manages connection to QMD MCP server and provides methods for
|
|
26
|
-
* search, document retrieval, and status checking.
|
|
27
|
-
*/
|
|
28
|
-
export class QMDClient {
|
|
29
|
-
client = null;
|
|
30
|
-
transport = null;
|
|
31
|
-
connected = false;
|
|
32
|
-
connecting = false;
|
|
33
|
-
/**
|
|
34
|
-
* Check if QMD is installed on the system
|
|
35
|
-
*/
|
|
36
|
-
async checkQMDInstalled() {
|
|
37
|
-
return new Promise((resolve) => {
|
|
38
|
-
const process = spawn('qmd', ['--version'], {
|
|
39
|
-
stdio: 'ignore',
|
|
40
|
-
shell: true
|
|
41
|
-
});
|
|
42
|
-
process.on('close', (code) => {
|
|
43
|
-
resolve(code === 0);
|
|
44
|
-
});
|
|
45
|
-
process.on('error', () => {
|
|
46
|
-
resolve(false);
|
|
47
|
-
});
|
|
48
|
-
// Timeout after 5 seconds
|
|
49
|
-
setTimeout(() => {
|
|
50
|
-
process.kill();
|
|
51
|
-
resolve(false);
|
|
52
|
-
}, 5000);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Connect to QMD MCP server
|
|
57
|
-
* QMD must be installed: bun install -g qmd
|
|
58
|
-
*/
|
|
59
|
-
async connect() {
|
|
60
|
-
if (this.connected || this.connecting) {
|
|
61
|
-
return this.connected;
|
|
62
|
-
}
|
|
63
|
-
this.connecting = true;
|
|
64
|
-
try {
|
|
65
|
-
// Check if QMD is installed
|
|
66
|
-
const installed = await this.checkQMDInstalled();
|
|
67
|
-
if (!installed) {
|
|
68
|
-
logger.warn('QMD is not installed. Install with: bun install -g qmd');
|
|
69
|
-
this.connecting = false;
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
this.transport = new StdioClientTransport({
|
|
73
|
-
command: 'qmd',
|
|
74
|
-
args: ['mcp'],
|
|
75
|
-
stderr: 'inherit'
|
|
76
|
-
});
|
|
77
|
-
this.client = new Client({ name: 'squish-qmd-client', version: '1.0.0' }, { capabilities: {} });
|
|
78
|
-
await this.client.connect(this.transport);
|
|
79
|
-
this.connected = true;
|
|
80
|
-
this.connecting = false;
|
|
81
|
-
logger.info('Connected to QMD MCP server');
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
logger.warn(`QMD MCP connection failed: ${error}`);
|
|
86
|
-
this.connected = false;
|
|
87
|
-
this.connecting = false;
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Check if QMD is available
|
|
93
|
-
*/
|
|
94
|
-
async isAvailable() {
|
|
95
|
-
if (this.connected && this.client) {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
return await this.connect();
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Fast BM25 keyword search
|
|
102
|
-
* Uses SQLite FTS5 for fast full-text search
|
|
103
|
-
*/
|
|
104
|
-
async search(options) {
|
|
105
|
-
if (!this.connected || !this.client) {
|
|
106
|
-
throw new Error('QMD client not connected');
|
|
107
|
-
}
|
|
108
|
-
const result = await this.client.callTool({
|
|
109
|
-
name: 'qmd_search',
|
|
110
|
-
arguments: {
|
|
111
|
-
query: options.query,
|
|
112
|
-
collection: options.collection,
|
|
113
|
-
n: options.limit || 10,
|
|
114
|
-
minScore: options.minScore || 0
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return this.parseSearchResults(result);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Semantic vector search
|
|
121
|
-
* Uses embedding-based similarity search
|
|
122
|
-
*/
|
|
123
|
-
async vsearch(options) {
|
|
124
|
-
if (!this.connected || !this.client) {
|
|
125
|
-
throw new Error('QMD client not connected');
|
|
126
|
-
}
|
|
127
|
-
const result = await this.client.callTool({
|
|
128
|
-
name: 'qmd_vsearch',
|
|
129
|
-
arguments: {
|
|
130
|
-
query: options.query,
|
|
131
|
-
collection: options.collection,
|
|
132
|
-
n: options.limit || 10,
|
|
133
|
-
minScore: options.minScore || 0
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return this.parseSearchResults(result);
|
|
137
|
-
}
|
|
138
|
-
/**
|
|
139
|
-
* Hybrid search with re-ranking (best quality)
|
|
140
|
-
* Combines BM25 + vector search + LLM re-ranking
|
|
141
|
-
*/
|
|
142
|
-
async query(options) {
|
|
143
|
-
if (!this.connected || !this.client) {
|
|
144
|
-
throw new Error('QMD client not connected');
|
|
145
|
-
}
|
|
146
|
-
const result = await this.client.callTool({
|
|
147
|
-
name: 'qmd_query',
|
|
148
|
-
arguments: {
|
|
149
|
-
query: options.query,
|
|
150
|
-
collection: options.collection,
|
|
151
|
-
n: options.limit || 10,
|
|
152
|
-
minScore: options.minScore || 0
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
return this.parseSearchResults(result);
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Get QMD index status and collection info
|
|
159
|
-
*/
|
|
160
|
-
async status() {
|
|
161
|
-
if (!this.connected || !this.client) {
|
|
162
|
-
return null;
|
|
163
|
-
}
|
|
164
|
-
try {
|
|
165
|
-
const result = await this.client.callTool({
|
|
166
|
-
name: 'qmd_status',
|
|
167
|
-
arguments: {}
|
|
168
|
-
});
|
|
169
|
-
return this.parseStatusResult(result);
|
|
170
|
-
}
|
|
171
|
-
catch (error) {
|
|
172
|
-
logger.debug(`QMD status check failed: ${error}`);
|
|
173
|
-
return null;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Get document by path or docid
|
|
178
|
-
*/
|
|
179
|
-
async get(options) {
|
|
180
|
-
if (!this.connected || !this.client) {
|
|
181
|
-
throw new Error('QMD client not connected');
|
|
182
|
-
}
|
|
183
|
-
const args = {
|
|
184
|
-
path: options.pathOrDocid
|
|
185
|
-
};
|
|
186
|
-
if (options.full !== undefined) {
|
|
187
|
-
args.full = options.full;
|
|
188
|
-
}
|
|
189
|
-
if (options.maxBytes !== undefined) {
|
|
190
|
-
args['max-bytes'] = options.maxBytes;
|
|
191
|
-
}
|
|
192
|
-
const result = await this.client.callTool({
|
|
193
|
-
name: 'qmd_get',
|
|
194
|
-
arguments: args
|
|
195
|
-
});
|
|
196
|
-
return this.parseGetResult(result);
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Get multiple documents by glob pattern or list
|
|
200
|
-
*/
|
|
201
|
-
async multiGet(patternOrList, options) {
|
|
202
|
-
if (!this.connected || !this.client) {
|
|
203
|
-
throw new Error('QMD client not connected');
|
|
204
|
-
}
|
|
205
|
-
const args = {
|
|
206
|
-
pattern: Array.isArray(patternOrList) ? patternOrList.join(',') : patternOrList
|
|
207
|
-
};
|
|
208
|
-
if (options?.maxBytes !== undefined) {
|
|
209
|
-
args['max-bytes'] = options.maxBytes;
|
|
210
|
-
}
|
|
211
|
-
if (options?.limit !== undefined) {
|
|
212
|
-
args.l = options.limit;
|
|
213
|
-
}
|
|
214
|
-
const result = await this.client.callTool({
|
|
215
|
-
name: 'qmd_multi_get',
|
|
216
|
-
arguments: args
|
|
217
|
-
});
|
|
218
|
-
return this.parseMultiGetResult(result);
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Disconnect from QMD MCP server
|
|
222
|
-
*/
|
|
223
|
-
async disconnect() {
|
|
224
|
-
if (this.client) {
|
|
225
|
-
try {
|
|
226
|
-
await this.client.close();
|
|
227
|
-
}
|
|
228
|
-
catch (error) {
|
|
229
|
-
logger.debug(`Error closing QMD client: ${error}`);
|
|
230
|
-
}
|
|
231
|
-
this.connected = false;
|
|
232
|
-
this.client = null;
|
|
233
|
-
this.transport = null;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Parse search results from QMD response
|
|
238
|
-
*/
|
|
239
|
-
parseSearchResults(result) {
|
|
240
|
-
if (!result || !result.content) {
|
|
241
|
-
return [];
|
|
242
|
-
}
|
|
243
|
-
const content = result.content;
|
|
244
|
-
// Handle text output format
|
|
245
|
-
if (typeof content === 'string') {
|
|
246
|
-
return this.parseTextSearchResults(content);
|
|
247
|
-
}
|
|
248
|
-
// Handle array content format
|
|
249
|
-
if (Array.isArray(content)) {
|
|
250
|
-
const textContent = content
|
|
251
|
-
.filter((item) => item.type === 'text')
|
|
252
|
-
.map((item) => item.text)
|
|
253
|
-
.join('\n');
|
|
254
|
-
return this.parseTextSearchResults(textContent);
|
|
255
|
-
}
|
|
256
|
-
return [];
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Parse QMD's text output format into structured results
|
|
260
|
-
*/
|
|
261
|
-
parseTextSearchResults(text) {
|
|
262
|
-
const results = [];
|
|
263
|
-
const lines = text.split('\n');
|
|
264
|
-
let currentResult = null;
|
|
265
|
-
for (const line of lines) {
|
|
266
|
-
// Match path line: "docs/guide.md:42 #a1b2c3"
|
|
267
|
-
const pathMatch = line.match(/^([^\s:]+):(\d+)\s+([#a-zA-Z0-9]+)?/);
|
|
268
|
-
if (pathMatch) {
|
|
269
|
-
if (currentResult && currentResult.path) {
|
|
270
|
-
results.push(this.finalizeResult(currentResult));
|
|
271
|
-
}
|
|
272
|
-
currentResult = {
|
|
273
|
-
path: pathMatch[1],
|
|
274
|
-
docid: pathMatch[3] || '',
|
|
275
|
-
score: 0,
|
|
276
|
-
snippet: ''
|
|
277
|
-
};
|
|
278
|
-
continue;
|
|
279
|
-
}
|
|
280
|
-
// Match score line: "Score: 93%"
|
|
281
|
-
const scoreMatch = line.match(/^Score:\s+(\d+)%/);
|
|
282
|
-
if (scoreMatch && currentResult) {
|
|
283
|
-
currentResult.score = parseInt(scoreMatch[1]) / 100;
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
// Match title line: "Title: Some Title"
|
|
287
|
-
const titleMatch = line.match(/^Title:\s+(.+)/);
|
|
288
|
-
if (titleMatch && currentResult) {
|
|
289
|
-
currentResult.title = titleMatch[1];
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
// Match context line: "Context: Some context"
|
|
293
|
-
const contextMatch = line.match(/^Context:\s+(.+)/);
|
|
294
|
-
if (contextMatch && currentResult) {
|
|
295
|
-
currentResult.context = contextMatch[1];
|
|
296
|
-
continue;
|
|
297
|
-
}
|
|
298
|
-
// Collect snippet content
|
|
299
|
-
if (currentResult && line.trim() && !line.startsWith('---')) {
|
|
300
|
-
currentResult.snippet += line + '\n';
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
// Don't forget the last result
|
|
304
|
-
if (currentResult && currentResult.path) {
|
|
305
|
-
results.push(this.finalizeResult(currentResult));
|
|
306
|
-
}
|
|
307
|
-
return results;
|
|
308
|
-
}
|
|
309
|
-
/**
|
|
310
|
-
* Finalize a parsed result with defaults
|
|
311
|
-
*/
|
|
312
|
-
finalizeResult(result) {
|
|
313
|
-
return {
|
|
314
|
-
path: result.path || '',
|
|
315
|
-
docid: result.docid || '',
|
|
316
|
-
title: result.title || result.path?.split('/').pop() || '',
|
|
317
|
-
context: result.context || '',
|
|
318
|
-
score: result.score || 0,
|
|
319
|
-
snippet: (result.snippet || '').trim()
|
|
320
|
-
};
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Parse status result
|
|
324
|
-
*/
|
|
325
|
-
parseStatusResult(result) {
|
|
326
|
-
if (!result || !result.content) {
|
|
327
|
-
return null;
|
|
328
|
-
}
|
|
329
|
-
const content = result.content;
|
|
330
|
-
if (typeof content === 'string') {
|
|
331
|
-
try {
|
|
332
|
-
return JSON.parse(content);
|
|
333
|
-
}
|
|
334
|
-
catch {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
if (Array.isArray(content)) {
|
|
339
|
-
const textContent = content
|
|
340
|
-
.filter((item) => item.type === 'text')
|
|
341
|
-
.map((item) => item.text)
|
|
342
|
-
.join('');
|
|
343
|
-
try {
|
|
344
|
-
return JSON.parse(textContent);
|
|
345
|
-
}
|
|
346
|
-
catch {
|
|
347
|
-
return null;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Parse get result
|
|
354
|
-
*/
|
|
355
|
-
parseGetResult(result) {
|
|
356
|
-
if (!result || !result.content) {
|
|
357
|
-
return '';
|
|
358
|
-
}
|
|
359
|
-
const content = result.content;
|
|
360
|
-
if (typeof content === 'string') {
|
|
361
|
-
return content;
|
|
362
|
-
}
|
|
363
|
-
if (Array.isArray(content)) {
|
|
364
|
-
return content
|
|
365
|
-
.filter((item) => item.type === 'text')
|
|
366
|
-
.map((item) => item.text)
|
|
367
|
-
.join('\n');
|
|
368
|
-
}
|
|
369
|
-
return '';
|
|
370
|
-
}
|
|
371
|
-
/**
|
|
372
|
-
* Parse multi-get result
|
|
373
|
-
*/
|
|
374
|
-
parseMultiGetResult(result) {
|
|
375
|
-
const text = this.parseGetResult(result);
|
|
376
|
-
if (!text) {
|
|
377
|
-
return [];
|
|
378
|
-
}
|
|
379
|
-
// Split by document separators and return individual documents
|
|
380
|
-
return text.split(/\n---+\n/).filter(doc => doc.trim());
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
// Singleton instance
|
|
384
|
-
let qmdClientInstance = null;
|
|
385
|
-
/**
|
|
386
|
-
* Get the singleton QMD client instance
|
|
387
|
-
*/
|
|
388
|
-
export async function getQMDClient() {
|
|
389
|
-
if (!qmdClientInstance) {
|
|
390
|
-
qmdClientInstance = new QMDClient();
|
|
391
|
-
}
|
|
392
|
-
return qmdClientInstance;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Reset the singleton QMD client (useful for testing)
|
|
396
|
-
*/
|
|
397
|
-
export function resetQMDClient() {
|
|
398
|
-
if (qmdClientInstance) {
|
|
399
|
-
qmdClientInstance.disconnect().catch(() => { });
|
|
400
|
-
qmdClientInstance = null;
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
//# sourceMappingURL=qmd-client.js.map
|