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,183 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Entity Deduplicator
|
|
3
|
-
*
|
|
4
|
-
* Deduplicates entities using embedding similarity and string matching.
|
|
5
|
-
* Critical for knowledge graph - prevents duplicate nodes for aliases like "AWS" / "Amazon Web Services".
|
|
6
|
-
*/
|
|
7
|
-
import { eq } from 'drizzle-orm';
|
|
8
|
-
import { getDb } from '../../db/index.js';
|
|
9
|
-
import { getSchema } from '../../db/schema.js';
|
|
10
|
-
import { cosineSimilarity } from '../utils/vector-operations.js';
|
|
11
|
-
import { parseEmbedding } from '../lib/parse-embedding.js';
|
|
12
|
-
import { logger } from '../logger.js';
|
|
13
|
-
// Common entity aliases for normalization
|
|
14
|
-
const KNOWN_ALIASES = {
|
|
15
|
-
'amazon web services': ['aws'],
|
|
16
|
-
'aws': ['amazon web services'],
|
|
17
|
-
'postgresql': ['postgres', 'pg'],
|
|
18
|
-
'kubernetes': ['k8s'],
|
|
19
|
-
'k8s': ['kubernetes'],
|
|
20
|
-
'javascript': ['js'],
|
|
21
|
-
'typescript': ['ts'],
|
|
22
|
-
'node.js': ['nodejs', 'node'],
|
|
23
|
-
'react.js': ['react'],
|
|
24
|
-
'vue.js': ['vue'],
|
|
25
|
-
'machine learning': ['ml'],
|
|
26
|
-
'artificial intelligence': ['ai'],
|
|
27
|
-
'large language model': ['llm'],
|
|
28
|
-
'natural language processing': ['nlp'],
|
|
29
|
-
};
|
|
30
|
-
/**
|
|
31
|
-
* Find and merge duplicate entities in a project.
|
|
32
|
-
*/
|
|
33
|
-
export async function deduplicateProjectEntities(projectId, options) {
|
|
34
|
-
const { similarityThreshold = 0.85, dryRun = false } = options || {};
|
|
35
|
-
const db = await getDb();
|
|
36
|
-
const schema = await getSchema();
|
|
37
|
-
// Get all entities for the project
|
|
38
|
-
const entities = await db
|
|
39
|
-
.select()
|
|
40
|
-
.from(schema.entities)
|
|
41
|
-
.where(eq(schema.entities.projectId, projectId));
|
|
42
|
-
if (entities.length < 2) {
|
|
43
|
-
return {
|
|
44
|
-
merged: 0,
|
|
45
|
-
aliases: [],
|
|
46
|
-
totalEntities: entities.length,
|
|
47
|
-
uniqueEntities: entities.length,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
const aliases = [];
|
|
51
|
-
const merged = new Set();
|
|
52
|
-
let mergeCount = 0;
|
|
53
|
-
// Compare each pair of entities
|
|
54
|
-
for (let i = 0; i < entities.length; i++) {
|
|
55
|
-
if (merged.has(entities[i].id))
|
|
56
|
-
continue;
|
|
57
|
-
for (let j = i + 1; j < entities.length; j++) {
|
|
58
|
-
if (merged.has(entities[j].id))
|
|
59
|
-
continue;
|
|
60
|
-
const similarity = await computeEntitySimilarity(entities[i], entities[j]);
|
|
61
|
-
if (similarity >= similarityThreshold) {
|
|
62
|
-
// Merge j into i (keep the one with more mentions)
|
|
63
|
-
const target = (entities[i].mentionCount || 0) >= (entities[j].mentionCount || 0)
|
|
64
|
-
? entities[i]
|
|
65
|
-
: entities[j];
|
|
66
|
-
const source = target.id === entities[i].id ? entities[j] : entities[i];
|
|
67
|
-
aliases.push({
|
|
68
|
-
from: source.name,
|
|
69
|
-
to: target.name,
|
|
70
|
-
similarity,
|
|
71
|
-
});
|
|
72
|
-
if (!dryRun) {
|
|
73
|
-
await mergeEntities(source, target, db, schema);
|
|
74
|
-
}
|
|
75
|
-
merged.add(source.id);
|
|
76
|
-
mergeCount++;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
logger.info('Entity deduplication completed', {
|
|
81
|
-
projectId,
|
|
82
|
-
totalEntities: entities.length,
|
|
83
|
-
merged: mergeCount,
|
|
84
|
-
dryRun,
|
|
85
|
-
});
|
|
86
|
-
return {
|
|
87
|
-
merged: mergeCount,
|
|
88
|
-
aliases,
|
|
89
|
-
totalEntities: entities.length,
|
|
90
|
-
uniqueEntities: entities.length - mergeCount,
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Compute similarity between two entities.
|
|
95
|
-
* Uses a combination of string matching, known aliases, and embedding similarity.
|
|
96
|
-
*/
|
|
97
|
-
async function computeEntitySimilarity(entity1, entity2) {
|
|
98
|
-
// Must be same type to be considered duplicates
|
|
99
|
-
if (entity1.type !== entity2.type) {
|
|
100
|
-
return 0;
|
|
101
|
-
}
|
|
102
|
-
const name1 = entity1.name.toLowerCase().trim();
|
|
103
|
-
const name2 = entity2.name.toLowerCase().trim();
|
|
104
|
-
// Exact match
|
|
105
|
-
if (name1 === name2)
|
|
106
|
-
return 1.0;
|
|
107
|
-
// Check known aliases
|
|
108
|
-
const name1Aliases = KNOWN_ALIASES[name1] || [];
|
|
109
|
-
const name2Aliases = KNOWN_ALIASES[name2] || [];
|
|
110
|
-
if (name1Aliases.includes(name2) || name2Aliases.includes(name1)) {
|
|
111
|
-
return 0.99; // Very high confidence for known aliases
|
|
112
|
-
}
|
|
113
|
-
// String similarity (Jaccard on words)
|
|
114
|
-
const words1 = new Set(name1.split(/[\s._-]+/).filter((w) => w.length > 1));
|
|
115
|
-
const words2 = new Set(name2.split(/[\s._-]+/).filter((w) => w.length > 1));
|
|
116
|
-
const words1Arr = Array.from(words1);
|
|
117
|
-
const words2Arr = Array.from(words2);
|
|
118
|
-
const intersection = words1Arr.filter(w => words2.has(w));
|
|
119
|
-
const union = new Set([...words1Arr, ...words2Arr]);
|
|
120
|
-
if (words1.size > 0 && words2.size > 0) {
|
|
121
|
-
const jaccard = intersection.length / union.size;
|
|
122
|
-
if (jaccard >= 0.8)
|
|
123
|
-
return jaccard;
|
|
124
|
-
}
|
|
125
|
-
// One contains the other (e.g., "React" in "React.js")
|
|
126
|
-
if (name1.includes(name2) || name2.includes(name1)) {
|
|
127
|
-
const shorter = name1.length < name2.length ? name1 : name2;
|
|
128
|
-
const longer = name1.length < name2.length ? name2 : name1;
|
|
129
|
-
// Only count as similar if the shorter name is a significant portion
|
|
130
|
-
if (shorter.length / longer.length >= 0.5) {
|
|
131
|
-
return 0.85;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
// Embedding similarity (if available)
|
|
135
|
-
const embedding1 = parseEmbedding(entity1.embedding || entity1.embedding_json);
|
|
136
|
-
const embedding2 = parseEmbedding(entity2.embedding || entity2.embedding_json);
|
|
137
|
-
if (embedding1 && embedding2) {
|
|
138
|
-
const embSimilarity = cosineSimilarity(embedding1, embedding2);
|
|
139
|
-
if (embSimilarity >= similarityThreshold) {
|
|
140
|
-
return embSimilarity;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return 0;
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Merge source entity into target entity.
|
|
147
|
-
* Updates all relations pointing to source to point to target instead.
|
|
148
|
-
*/
|
|
149
|
-
async function mergeEntities(source, target, db, schema) {
|
|
150
|
-
// Update all relations pointing FROM source to point FROM target
|
|
151
|
-
await db
|
|
152
|
-
.update(schema.entityRelations)
|
|
153
|
-
.set({ fromEntityId: target.id })
|
|
154
|
-
.where(eq(schema.entityRelations.fromEntityId, source.id));
|
|
155
|
-
// Update all relations pointing TO source to point TO target
|
|
156
|
-
await db
|
|
157
|
-
.update(schema.entityRelations)
|
|
158
|
-
.set({ toEntityId: target.id })
|
|
159
|
-
.where(eq(schema.entityRelations.toEntityId, source.id));
|
|
160
|
-
// Add source name as alias to target
|
|
161
|
-
const existingAliases = Array.isArray(target.aliases) ? target.aliases : [];
|
|
162
|
-
const updatedAliases = [...new Set([...existingAliases, source.name])];
|
|
163
|
-
await db
|
|
164
|
-
.update(schema.entities)
|
|
165
|
-
.set({
|
|
166
|
-
aliases: updatedAliases,
|
|
167
|
-
mentionCount: (target.mentionCount || 0) + (source.mentionCount || 0),
|
|
168
|
-
updatedAt: new Date(),
|
|
169
|
-
})
|
|
170
|
-
.where(eq(schema.entities.id, target.id));
|
|
171
|
-
// Delete source entity
|
|
172
|
-
await db
|
|
173
|
-
.delete(schema.entities)
|
|
174
|
-
.where(eq(schema.entities.id, source.id));
|
|
175
|
-
logger.debug('Merged entity', {
|
|
176
|
-
source: source.name,
|
|
177
|
-
target: target.name,
|
|
178
|
-
aliases: updatedAliases,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
// Module-level threshold for embedding similarity
|
|
182
|
-
const similarityThreshold = 0.85;
|
|
183
|
-
//# sourceMappingURL=entity-deduplicator.js.map
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graph Builder
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates the full pipeline: extract entities and relations from
|
|
5
|
-
* memories and store them in the knowledge graph.
|
|
6
|
-
*/
|
|
7
|
-
export interface GraphBuildStats {
|
|
8
|
-
memoriesProcessed: number;
|
|
9
|
-
entitiesCreated: number;
|
|
10
|
-
relationsCreated: number;
|
|
11
|
-
entitiesDeduplicated: number;
|
|
12
|
-
errors: number;
|
|
13
|
-
durationMs: number;
|
|
14
|
-
}
|
|
15
|
-
export interface GraphAddStats {
|
|
16
|
-
entitiesCreated: number;
|
|
17
|
-
relationsCreated: number;
|
|
18
|
-
source: 'llm' | 'regex' | 'fallback' | 'none';
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Build or rebuild the entity graph for a project.
|
|
22
|
-
* Processes all memories in the project, extracting entities and relations.
|
|
23
|
-
*/
|
|
24
|
-
export declare function buildGraphForProject(projectPath: string, options?: {
|
|
25
|
-
clearExisting?: boolean;
|
|
26
|
-
batchSize?: number;
|
|
27
|
-
preferLLM?: boolean;
|
|
28
|
-
deduplicate?: boolean;
|
|
29
|
-
}): Promise<GraphBuildStats>;
|
|
30
|
-
/**
|
|
31
|
-
* Add a single memory to the knowledge graph.
|
|
32
|
-
* Used for incremental updates when new memories are stored.
|
|
33
|
-
*/
|
|
34
|
-
export declare function addMemoryToGraph(memoryId: string, options?: {
|
|
35
|
-
preferLLM?: boolean;
|
|
36
|
-
}): Promise<GraphAddStats>;
|
|
37
|
-
/**
|
|
38
|
-
* Get graph statistics for a project.
|
|
39
|
-
*/
|
|
40
|
-
export declare function getGraphStats(projectPath: string): Promise<{
|
|
41
|
-
entityCount: number;
|
|
42
|
-
relationCount: number;
|
|
43
|
-
relationTypes: Record<string, number>;
|
|
44
|
-
avgConnections: number;
|
|
45
|
-
}>;
|
|
46
|
-
//# sourceMappingURL=graph-builder.d.ts.map
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graph Builder
|
|
3
|
-
*
|
|
4
|
-
* Orchestrates the full pipeline: extract entities and relations from
|
|
5
|
-
* memories and store them in the knowledge graph.
|
|
6
|
-
*/
|
|
7
|
-
import { eq } from 'drizzle-orm';
|
|
8
|
-
import { getDb } from '../../db/index.js';
|
|
9
|
-
import { getSchema } from '../../db/schema.js';
|
|
10
|
-
import { logger } from '../logger.js';
|
|
11
|
-
import { config } from '../../config.js';
|
|
12
|
-
import { extractAndStoreRelations } from './relationship-extractor.js';
|
|
13
|
-
import { deduplicateProjectEntities } from './entity-deduplicator.js';
|
|
14
|
-
/**
|
|
15
|
-
* Build or rebuild the entity graph for a project.
|
|
16
|
-
* Processes all memories in the project, extracting entities and relations.
|
|
17
|
-
*/
|
|
18
|
-
export async function buildGraphForProject(projectPath, options) {
|
|
19
|
-
const startTime = Date.now();
|
|
20
|
-
const { clearExisting = false, batchSize = 10, preferLLM = true, deduplicate = true, } = options || {};
|
|
21
|
-
const db = await getDb();
|
|
22
|
-
const schema = await getSchema();
|
|
23
|
-
// Get project
|
|
24
|
-
const projectRows = await db
|
|
25
|
-
.select()
|
|
26
|
-
.from(schema.projects)
|
|
27
|
-
.where(eq(schema.projects.path, projectPath))
|
|
28
|
-
.limit(1);
|
|
29
|
-
if (projectRows.length === 0) {
|
|
30
|
-
logger.warn('Project not found for graph build', { projectPath });
|
|
31
|
-
return {
|
|
32
|
-
memoriesProcessed: 0,
|
|
33
|
-
entitiesCreated: 0,
|
|
34
|
-
relationsCreated: 0,
|
|
35
|
-
entitiesDeduplicated: 0,
|
|
36
|
-
errors: 0,
|
|
37
|
-
durationMs: Date.now() - startTime,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
const projectId = projectRows[0].id;
|
|
41
|
-
// Clear existing graph if requested
|
|
42
|
-
if (clearExisting) {
|
|
43
|
-
const { clearProjectGraph } = await import('./relationship-extractor.js');
|
|
44
|
-
await clearProjectGraph(projectId);
|
|
45
|
-
logger.info('Cleared existing graph for rebuild', { projectId });
|
|
46
|
-
}
|
|
47
|
-
// Get all active memories for the project
|
|
48
|
-
const memories = await db
|
|
49
|
-
.select()
|
|
50
|
-
.from(schema.memories)
|
|
51
|
-
.where(eq(schema.memories.projectId, projectId));
|
|
52
|
-
logger.info('Starting graph build for project', {
|
|
53
|
-
projectId,
|
|
54
|
-
memoryCount: memories.length,
|
|
55
|
-
clearExisting,
|
|
56
|
-
});
|
|
57
|
-
let entitiesCreated = 0;
|
|
58
|
-
let relationsCreated = 0;
|
|
59
|
-
let errors = 0;
|
|
60
|
-
// Process memories in batches
|
|
61
|
-
for (let i = 0; i < memories.length; i += batchSize) {
|
|
62
|
-
const batch = memories.slice(i, i + batchSize);
|
|
63
|
-
for (const memory of batch) {
|
|
64
|
-
try {
|
|
65
|
-
const result = await extractAndStoreRelations(memory.id, memory.content, projectId, { preferLLM });
|
|
66
|
-
entitiesCreated += result.entities;
|
|
67
|
-
relationsCreated += result.relations;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
logger.error('Error processing memory for graph', {
|
|
71
|
-
memoryId: memory.id,
|
|
72
|
-
error: error,
|
|
73
|
-
});
|
|
74
|
-
errors++;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
logger.debug('Graph build batch progress', {
|
|
78
|
-
processed: Math.min(i + batchSize, memories.length),
|
|
79
|
-
total: memories.length,
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
// Deduplicate entities
|
|
83
|
-
let entitiesDeduplicated = 0;
|
|
84
|
-
if (deduplicate) {
|
|
85
|
-
try {
|
|
86
|
-
const dedupResult = await deduplicateProjectEntities(projectId);
|
|
87
|
-
entitiesDeduplicated = dedupResult.merged;
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
logger.error('Error during entity deduplication', { error: error });
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
const stats = {
|
|
94
|
-
memoriesProcessed: memories.length,
|
|
95
|
-
entitiesCreated,
|
|
96
|
-
relationsCreated,
|
|
97
|
-
entitiesDeduplicated,
|
|
98
|
-
errors,
|
|
99
|
-
durationMs: Date.now() - startTime,
|
|
100
|
-
};
|
|
101
|
-
logger.info('Graph build completed', stats);
|
|
102
|
-
return stats;
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Add a single memory to the knowledge graph.
|
|
106
|
-
* Used for incremental updates when new memories are stored.
|
|
107
|
-
*/
|
|
108
|
-
export async function addMemoryToGraph(memoryId, options) {
|
|
109
|
-
const db = await getDb();
|
|
110
|
-
const schema = await getSchema();
|
|
111
|
-
// Get the memory
|
|
112
|
-
const memories = await db
|
|
113
|
-
.select()
|
|
114
|
-
.from(schema.memories)
|
|
115
|
-
.where(eq(schema.memories.id, memoryId))
|
|
116
|
-
.limit(1);
|
|
117
|
-
if (memories.length === 0) {
|
|
118
|
-
return { entitiesCreated: 0, relationsCreated: 0, source: 'none' };
|
|
119
|
-
}
|
|
120
|
-
const memory = memories[0];
|
|
121
|
-
if (!memory.projectId) {
|
|
122
|
-
return { entitiesCreated: 0, relationsCreated: 0, source: 'none' };
|
|
123
|
-
}
|
|
124
|
-
// Use global config if not explicitly overridden
|
|
125
|
-
const preferLLM = options?.preferLLM ?? config.llmEnabled;
|
|
126
|
-
const result = await extractAndStoreRelations(memoryId, memory.content, memory.projectId, { preferLLM });
|
|
127
|
-
return {
|
|
128
|
-
entitiesCreated: result.entities,
|
|
129
|
-
relationsCreated: result.relations,
|
|
130
|
-
source: result.source,
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Get graph statistics for a project.
|
|
135
|
-
*/
|
|
136
|
-
export async function getGraphStats(projectPath) {
|
|
137
|
-
const db = await getDb();
|
|
138
|
-
const schema = await getSchema();
|
|
139
|
-
const projectRows = await db
|
|
140
|
-
.select({ id: schema.projects.id })
|
|
141
|
-
.from(schema.projects)
|
|
142
|
-
.where(eq(schema.projects.path, projectPath))
|
|
143
|
-
.limit(1);
|
|
144
|
-
if (projectRows.length === 0) {
|
|
145
|
-
return { entityCount: 0, relationCount: 0, relationTypes: {}, avgConnections: 0 };
|
|
146
|
-
}
|
|
147
|
-
const projectId = projectRows[0].id;
|
|
148
|
-
const entities = await db
|
|
149
|
-
.select()
|
|
150
|
-
.from(schema.entities)
|
|
151
|
-
.where(eq(schema.entities.projectId, projectId));
|
|
152
|
-
const relations = await db
|
|
153
|
-
.select()
|
|
154
|
-
.from(schema.entityRelations);
|
|
155
|
-
// Filter relations to only those involving project entities
|
|
156
|
-
const entityIds = new Set(entities.map((e) => e.id));
|
|
157
|
-
const projectRelations = relations.filter((r) => entityIds.has(r.fromEntityId) || entityIds.has(r.toEntityId));
|
|
158
|
-
// Count by type
|
|
159
|
-
const relationTypes = {};
|
|
160
|
-
for (const r of projectRelations) {
|
|
161
|
-
const type = r.type || 'unknown';
|
|
162
|
-
relationTypes[type] = (relationTypes[type] || 0) + 1;
|
|
163
|
-
}
|
|
164
|
-
const avgConnections = entities.length > 0
|
|
165
|
-
? (projectRelations.length * 2) / entities.length
|
|
166
|
-
: 0;
|
|
167
|
-
return {
|
|
168
|
-
entityCount: entities.length,
|
|
169
|
-
relationCount: projectRelations.length,
|
|
170
|
-
relationTypes,
|
|
171
|
-
avgConnections: Math.round(avgConnections * 100) / 100,
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
//# sourceMappingURL=graph-builder.js.map
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graph Traversal Engine
|
|
3
|
-
*
|
|
4
|
-
* BFS/DFS traversal of the entity relationship graph. This is the
|
|
5
|
-
* core capability that enables multi-hop queries like:
|
|
6
|
-
*
|
|
7
|
-
* "Was Alice's project affected by Tuesday's outage?"
|
|
8
|
-
*
|
|
9
|
-
* Which requires traversing: Alice → works_on → Project Atlas → uses → PostgreSQL → caused → outage
|
|
10
|
-
*
|
|
11
|
-
* Vector search alone can't answer this because the bridge fact
|
|
12
|
-
* ("Project Atlas uses PostgreSQL") mentions neither Alice nor Tuesday.
|
|
13
|
-
*/
|
|
14
|
-
import type { RelationType } from './llm-entity-extractor.js';
|
|
15
|
-
export interface GraphNode {
|
|
16
|
-
id: string;
|
|
17
|
-
name: string;
|
|
18
|
-
type: string;
|
|
19
|
-
description: string | null;
|
|
20
|
-
properties: Record<string, unknown> | null;
|
|
21
|
-
}
|
|
22
|
-
export interface GraphEdge {
|
|
23
|
-
id: string;
|
|
24
|
-
fromId: string;
|
|
25
|
-
toId: string;
|
|
26
|
-
relationType: RelationType | string;
|
|
27
|
-
weight: number;
|
|
28
|
-
properties: Record<string, unknown> | null;
|
|
29
|
-
}
|
|
30
|
-
export interface TraversalPath {
|
|
31
|
-
nodes: GraphNode[];
|
|
32
|
-
edges: GraphEdge[];
|
|
33
|
-
totalWeight: number;
|
|
34
|
-
hopCount: number;
|
|
35
|
-
}
|
|
36
|
-
export interface NeighborhoodResult {
|
|
37
|
-
center: GraphNode;
|
|
38
|
-
nodes: GraphNode[];
|
|
39
|
-
edges: GraphEdge[];
|
|
40
|
-
radius: number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* BFS traversal from a starting entity, following relationship edges.
|
|
44
|
-
* Returns all reachable entities within maxDepth hops.
|
|
45
|
-
*/
|
|
46
|
-
export declare function traverse(startEntityId: string, options?: {
|
|
47
|
-
maxDepth?: number;
|
|
48
|
-
relationTypes?: RelationType[];
|
|
49
|
-
minWeight?: number;
|
|
50
|
-
direction?: 'outgoing' | 'incoming' | 'both';
|
|
51
|
-
limit?: number;
|
|
52
|
-
}): Promise<GraphNode[]>;
|
|
53
|
-
/**
|
|
54
|
-
* Find all paths between two entities within a maximum number of hops.
|
|
55
|
-
* Uses BFS with path tracking.
|
|
56
|
-
*/
|
|
57
|
-
export declare function findPaths(fromEntityId: string, toEntityId: string, options?: {
|
|
58
|
-
maxHops?: number;
|
|
59
|
-
relationTypes?: RelationType[];
|
|
60
|
-
minWeight?: number;
|
|
61
|
-
maxPaths?: number;
|
|
62
|
-
}): Promise<TraversalPath[]>;
|
|
63
|
-
/**
|
|
64
|
-
* Get the neighborhood around an entity - all entities within N hops.
|
|
65
|
-
* Returns both the entities and the edges connecting them.
|
|
66
|
-
*/
|
|
67
|
-
export declare function getNeighborhood(centerEntityId: string, options?: {
|
|
68
|
-
radius?: number;
|
|
69
|
-
relationTypes?: RelationType[];
|
|
70
|
-
minWeight?: number;
|
|
71
|
-
limit?: number;
|
|
72
|
-
}): Promise<NeighborhoodResult | null>;
|
|
73
|
-
/**
|
|
74
|
-
* Find entities by name (fuzzy matching).
|
|
75
|
-
*/
|
|
76
|
-
export declare function findEntitiesByName(name: string, projectId: string, options?: {
|
|
77
|
-
limit?: number;
|
|
78
|
-
fuzzy?: boolean;
|
|
79
|
-
}): Promise<GraphNode[]>;
|
|
80
|
-
//# sourceMappingURL=graph-traversal.d.ts.map
|