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,236 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Fact Deriver
|
|
3
|
-
*
|
|
4
|
-
* Derives implicit facts from existing relationships in the knowledge graph.
|
|
5
|
-
* Example: works_on(A, X) + uses(X, Y) -> depends_on(A, Y)
|
|
6
|
-
*/
|
|
7
|
-
import { eq, and, or } from 'drizzle-orm';
|
|
8
|
-
import { getDb } from '../../db/index.js';
|
|
9
|
-
import { getSchema } from '../../db/schema.js';
|
|
10
|
-
import { logger } from '../logger.js';
|
|
11
|
-
const DERIVATION_RULES = [
|
|
12
|
-
// Transitivity rules
|
|
13
|
-
{
|
|
14
|
-
name: 'works_on_uses_depends_on',
|
|
15
|
-
fromType: 'works_on',
|
|
16
|
-
toType: 'uses',
|
|
17
|
-
derivedType: 'depends_on',
|
|
18
|
-
description: 'If A works on X and X uses Y, then A depends on Y',
|
|
19
|
-
confidence: 0.8,
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
name: 'manages_works_oversees',
|
|
23
|
-
fromType: 'manages',
|
|
24
|
-
toType: 'works_on',
|
|
25
|
-
derivedType: 'oversees',
|
|
26
|
-
description: 'If A manages B and B works on X, then A oversees X',
|
|
27
|
-
confidence: 0.75,
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: 'caused_affects_may_affect',
|
|
31
|
-
fromType: 'caused',
|
|
32
|
-
toType: 'affects',
|
|
33
|
-
derivedType: 'may_affect',
|
|
34
|
-
description: 'If X caused Y and Y affects Z, then X may affect Z',
|
|
35
|
-
confidence: 0.7,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: 'part_of_contains',
|
|
39
|
-
fromType: 'part_of',
|
|
40
|
-
toType: 'contains',
|
|
41
|
-
derivedType: 'related_to',
|
|
42
|
-
description: 'If A is part of X and X contains B, then A is related to B',
|
|
43
|
-
confidence: 0.6,
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
name: 'uses_depends_on',
|
|
47
|
-
fromType: 'uses',
|
|
48
|
-
toType: 'depends_on',
|
|
49
|
-
derivedType: 'depends_on',
|
|
50
|
-
description: 'If A uses X and X depends on Y, then A depends on Y',
|
|
51
|
-
confidence: 0.85,
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
name: 'created_resolved',
|
|
55
|
-
fromType: 'created',
|
|
56
|
-
toType: 'resolved',
|
|
57
|
-
derivedType: 'related_to',
|
|
58
|
-
description: 'If A created X and X was resolved by B, then A is related to B',
|
|
59
|
-
confidence: 0.5,
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
name: 'blocks_depends_on',
|
|
63
|
-
fromType: 'blocks',
|
|
64
|
-
toType: 'depends_on',
|
|
65
|
-
derivedType: 'blocks',
|
|
66
|
-
description: 'If X blocks A and A depends on Y, then X may block Y',
|
|
67
|
-
confidence: 0.65,
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
// ─── Main Derivation Function ─────────────────────────────────────────────────
|
|
71
|
-
/**
|
|
72
|
-
* Derive implicit facts from existing relationships in the knowledge graph.
|
|
73
|
-
* Applies transitivity and causal rules to find new relationships.
|
|
74
|
-
*/
|
|
75
|
-
export async function deriveFacts(projectId, options) {
|
|
76
|
-
const { maxDerivations = 50, minConfidence = 0.6, storeResults = true } = options || {};
|
|
77
|
-
const db = await getDb();
|
|
78
|
-
const schema = await getSchema();
|
|
79
|
-
// Get all entities for this project
|
|
80
|
-
const entities = await db
|
|
81
|
-
.select()
|
|
82
|
-
.from(schema.entities)
|
|
83
|
-
.where(eq(schema.entities.projectId, projectId));
|
|
84
|
-
if (entities.length < 2)
|
|
85
|
-
return [];
|
|
86
|
-
const entityMap = new Map(entities.map((e) => [e.id, e]));
|
|
87
|
-
const derivedFacts = [];
|
|
88
|
-
// Get all relations for this project's entities
|
|
89
|
-
const entityIds = entities.map((e) => e.id);
|
|
90
|
-
const allRelations = [];
|
|
91
|
-
// Fetch in batches to avoid query size limits
|
|
92
|
-
const batchSize = 100;
|
|
93
|
-
for (let i = 0; i < entityIds.length; i += batchSize) {
|
|
94
|
-
const batch = entityIds.slice(i, i + batchSize);
|
|
95
|
-
const relations = await db
|
|
96
|
-
.select()
|
|
97
|
-
.from(schema.entityRelations)
|
|
98
|
-
.where(or(...batch.map((id) => eq(schema.entityRelations.fromEntityId, id))));
|
|
99
|
-
allRelations.push(...relations);
|
|
100
|
-
}
|
|
101
|
-
// Build adjacency list for fast lookup
|
|
102
|
-
const outgoing = new Map();
|
|
103
|
-
for (const rel of allRelations) {
|
|
104
|
-
if (!outgoing.has(rel.fromEntityId)) {
|
|
105
|
-
outgoing.set(rel.fromEntityId, new Map());
|
|
106
|
-
}
|
|
107
|
-
outgoing.get(rel.fromEntityId).set(rel.toEntityId, {
|
|
108
|
-
relationType: rel.type,
|
|
109
|
-
weight: rel.weight || 1,
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
// Apply derivation rules
|
|
113
|
-
for (const rule of DERIVATION_RULES) {
|
|
114
|
-
if (derivedFacts.length >= maxDerivations)
|
|
115
|
-
break;
|
|
116
|
-
if (rule.confidence < minConfidence)
|
|
117
|
-
continue;
|
|
118
|
-
// Find all pairs where fromType matches
|
|
119
|
-
for (const [fromId, targets] of outgoing) {
|
|
120
|
-
if (derivedFacts.length >= maxDerivations)
|
|
121
|
-
break;
|
|
122
|
-
for (const [midId, fromRel] of targets) {
|
|
123
|
-
if (fromRel.relationType !== rule.fromType)
|
|
124
|
-
continue;
|
|
125
|
-
// Check if midId has outgoing toType relations
|
|
126
|
-
const midTargets = outgoing.get(midId);
|
|
127
|
-
if (!midTargets)
|
|
128
|
-
continue;
|
|
129
|
-
for (const [toId, toRel] of midTargets) {
|
|
130
|
-
if (toRel.relationType !== rule.toType)
|
|
131
|
-
continue;
|
|
132
|
-
// Found a derivation: fromId --fromType--> midId --toType--> toId
|
|
133
|
-
// Derive: fromId --derivedType--> toId
|
|
134
|
-
const fromEntity = entityMap.get(fromId);
|
|
135
|
-
const toEntity = entityMap.get(toId);
|
|
136
|
-
if (!fromEntity || !toEntity)
|
|
137
|
-
continue;
|
|
138
|
-
// Check if this derived relation already exists
|
|
139
|
-
const existing = await db
|
|
140
|
-
.select()
|
|
141
|
-
.from(schema.entityRelations)
|
|
142
|
-
.where(and(eq(schema.entityRelations.fromEntityId, fromId), eq(schema.entityRelations.toEntityId, toId), eq(schema.entityRelations.type, rule.derivedType)))
|
|
143
|
-
.limit(1);
|
|
144
|
-
if (existing.length > 0)
|
|
145
|
-
continue; // Already exists
|
|
146
|
-
const derivedFact = {
|
|
147
|
-
fromEntityId: fromId,
|
|
148
|
-
fromEntityName: fromEntity.name,
|
|
149
|
-
toEntityId: toId,
|
|
150
|
-
toEntityName: toEntity.name,
|
|
151
|
-
relationType: rule.derivedType,
|
|
152
|
-
rule: rule.name,
|
|
153
|
-
confidence: rule.confidence,
|
|
154
|
-
isDerived: true,
|
|
155
|
-
};
|
|
156
|
-
derivedFacts.push(derivedFact);
|
|
157
|
-
// Store the derived fact if requested
|
|
158
|
-
if (storeResults) {
|
|
159
|
-
try {
|
|
160
|
-
await db.insert(schema.entityRelations).values({
|
|
161
|
-
fromEntityId: fromId,
|
|
162
|
-
toEntityId: toId,
|
|
163
|
-
type: rule.derivedType,
|
|
164
|
-
weight: Math.round(rule.confidence * 10),
|
|
165
|
-
properties: {
|
|
166
|
-
derived: true,
|
|
167
|
-
rule: rule.name,
|
|
168
|
-
confidence: rule.confidence,
|
|
169
|
-
description: rule.description,
|
|
170
|
-
},
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
logger.debug('Error storing derived fact', {
|
|
175
|
-
rule: rule.name,
|
|
176
|
-
from: fromEntity.name,
|
|
177
|
-
to: toEntity.name,
|
|
178
|
-
error: error,
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
logger.info('Fact derivation completed', {
|
|
187
|
-
projectId,
|
|
188
|
-
derivedCount: derivedFacts.length,
|
|
189
|
-
rulesApplied: DERIVATION_RULES.length,
|
|
190
|
-
});
|
|
191
|
-
return derivedFacts;
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Get all derived facts for a project.
|
|
195
|
-
*/
|
|
196
|
-
export async function getDerivedFacts(projectId) {
|
|
197
|
-
const db = await getDb();
|
|
198
|
-
const schema = await getSchema();
|
|
199
|
-
// Get all entities for this project
|
|
200
|
-
const entities = await db
|
|
201
|
-
.select()
|
|
202
|
-
.from(schema.entities)
|
|
203
|
-
.where(eq(schema.entities.projectId, projectId));
|
|
204
|
-
const entityIds = entities.map((e) => e.id);
|
|
205
|
-
if (entityIds.length === 0)
|
|
206
|
-
return [];
|
|
207
|
-
// Get all derived relations
|
|
208
|
-
const derivedRelations = [];
|
|
209
|
-
const batchSize = 100;
|
|
210
|
-
for (let i = 0; i < entityIds.length; i += batchSize) {
|
|
211
|
-
const batch = entityIds.slice(i, i + batchSize);
|
|
212
|
-
const relations = await db
|
|
213
|
-
.select()
|
|
214
|
-
.from(schema.entityRelations)
|
|
215
|
-
.where(or(...batch.map((id) => eq(schema.entityRelations.fromEntityId, id))));
|
|
216
|
-
for (const rel of relations) {
|
|
217
|
-
const props = rel.properties;
|
|
218
|
-
if (props && props.derived === true) {
|
|
219
|
-
const fromEntity = entities.find((e) => e.id === rel.fromEntityId);
|
|
220
|
-
const toEntity = entities.find((e) => e.id === rel.toEntityId);
|
|
221
|
-
derivedRelations.push({
|
|
222
|
-
fromEntityId: rel.fromEntityId,
|
|
223
|
-
fromEntityName: fromEntity?.name || 'Unknown',
|
|
224
|
-
toEntityId: rel.toEntityId,
|
|
225
|
-
toEntityName: toEntity?.name || 'Unknown',
|
|
226
|
-
relationType: rel.type,
|
|
227
|
-
rule: props.rule || 'unknown',
|
|
228
|
-
confidence: props.confidence || 0.5,
|
|
229
|
-
isDerived: true,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return derivedRelations;
|
|
235
|
-
}
|
|
236
|
-
//# sourceMappingURL=fact-deriver.js.map
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { RememberInput } from './memories.js';
|
|
2
|
-
export interface ExtractedFact {
|
|
3
|
-
content: string;
|
|
4
|
-
confidence: number;
|
|
5
|
-
entities: string[];
|
|
6
|
-
relation?: string;
|
|
7
|
-
}
|
|
8
|
-
export interface FactExtractionResult {
|
|
9
|
-
facts: ExtractedFact[];
|
|
10
|
-
summary: string;
|
|
11
|
-
entities: string[];
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Extract facts from conversation text using Claude API
|
|
15
|
-
*
|
|
16
|
-
* This function MUST return valid facts or throw an error.
|
|
17
|
-
* NO FALLBACKS - we need real extraction to reach 90% accuracy.
|
|
18
|
-
*/
|
|
19
|
-
export declare function extractFacts(text: string, callClaude: (prompt: string, maxTokens: number) => Promise<string>): Promise<FactExtractionResult>;
|
|
20
|
-
/**
|
|
21
|
-
* Convert extracted facts to memory inputs
|
|
22
|
-
*/
|
|
23
|
-
export declare function factsToMemoryInputs(sourceMemory: RememberInput, extraction: FactExtractionResult, sourceId: string): RememberInput[];
|
|
24
|
-
//# sourceMappingURL=fact-extractor.d.ts.map
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extract facts from conversation text using Claude API
|
|
3
|
-
*
|
|
4
|
-
* This function MUST return valid facts or throw an error.
|
|
5
|
-
* NO FALLBACKS - we need real extraction to reach 90% accuracy.
|
|
6
|
-
*/
|
|
7
|
-
export async function extractFacts(text, callClaude) {
|
|
8
|
-
if (!text || text.length < 50) {
|
|
9
|
-
// Too short for meaningful extraction - return as single fact
|
|
10
|
-
return {
|
|
11
|
-
facts: [{ content: text.trim(), confidence: 1.0, entities: [] }],
|
|
12
|
-
summary: text.trim(),
|
|
13
|
-
entities: []
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
const prompt = `Extract atomic facts from this conversation.
|
|
17
|
-
|
|
18
|
-
Requirements:
|
|
19
|
-
- Extract specific, verifiable facts (names, dates, numbers, relationships)
|
|
20
|
-
- Each fact should be a standalone statement
|
|
21
|
-
- Identify entities (people, organizations, projects, locations)
|
|
22
|
-
- Note temporal information and relationships
|
|
23
|
-
|
|
24
|
-
Return ONLY valid JSON in this exact format:
|
|
25
|
-
{"facts":[{"content":"fact statement","confidence":0.95,"entities":["Name"],"relation":"optional"}],"summary":"brief summary","entities":["all","entities"]}
|
|
26
|
-
|
|
27
|
-
Text to analyze:
|
|
28
|
-
${text.substring(0, 4000)}`;
|
|
29
|
-
const response = await callClaude(prompt, 2000);
|
|
30
|
-
// Extract JSON - look for the first { and last }
|
|
31
|
-
const startIdx = response.indexOf('{');
|
|
32
|
-
const endIdx = response.lastIndexOf('}');
|
|
33
|
-
if (startIdx === -1 || endIdx === -1 || startIdx >= endIdx) {
|
|
34
|
-
throw new Error(`Fact extraction failed: No valid JSON found in response. Response: ${response.substring(0, 200)}`);
|
|
35
|
-
}
|
|
36
|
-
const jsonStr = response.substring(startIdx, endIdx + 1);
|
|
37
|
-
let parsed;
|
|
38
|
-
try {
|
|
39
|
-
parsed = JSON.parse(jsonStr);
|
|
40
|
-
}
|
|
41
|
-
catch (parseError) {
|
|
42
|
-
throw new Error(`Fact extraction failed: JSON parse error. JSON: ${jsonStr.substring(0, 200)}`);
|
|
43
|
-
}
|
|
44
|
-
// Validate facts array exists and has content
|
|
45
|
-
if (!parsed.facts || !Array.isArray(parsed.facts)) {
|
|
46
|
-
throw new Error(`Fact extraction failed: Missing 'facts' array in response. Keys: ${Object.keys(parsed).join(', ')}`);
|
|
47
|
-
}
|
|
48
|
-
// Filter and clean facts
|
|
49
|
-
const validFacts = parsed.facts
|
|
50
|
-
.filter((f) => f && typeof f.content === 'string' && f.content.trim().length > 10)
|
|
51
|
-
.map((f) => ({
|
|
52
|
-
content: f.content.trim(),
|
|
53
|
-
confidence: Math.max(0, Math.min(1, typeof f.confidence === 'number' ? f.confidence : 0.8)),
|
|
54
|
-
entities: Array.isArray(f.entities) ? f.entities.filter((e) => typeof e === 'string') : [],
|
|
55
|
-
relation: typeof f.relation === 'string' ? f.relation : undefined
|
|
56
|
-
}));
|
|
57
|
-
if (validFacts.length === 0) {
|
|
58
|
-
throw new Error(`Fact extraction failed: No valid facts after filtering. Original count: ${parsed.facts.length}`);
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
facts: validFacts,
|
|
62
|
-
summary: typeof parsed.summary === 'string' && parsed.summary.trim()
|
|
63
|
-
? parsed.summary.trim()
|
|
64
|
-
: text.substring(0, 200),
|
|
65
|
-
entities: Array.isArray(parsed.entities)
|
|
66
|
-
? parsed.entities.filter((e) => typeof e === 'string')
|
|
67
|
-
: []
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Convert extracted facts to memory inputs
|
|
72
|
-
*/
|
|
73
|
-
export function factsToMemoryInputs(sourceMemory, extraction, sourceId) {
|
|
74
|
-
return extraction.facts.map((fact, index) => ({
|
|
75
|
-
content: fact.content,
|
|
76
|
-
type: 'fact',
|
|
77
|
-
metadata: {
|
|
78
|
-
sourceMemoryId: sourceId,
|
|
79
|
-
extractedAt: new Date().toISOString(),
|
|
80
|
-
entities: fact.entities,
|
|
81
|
-
relation: fact.relation,
|
|
82
|
-
confidence: Math.floor(fact.confidence * 100),
|
|
83
|
-
factIndex: index
|
|
84
|
-
},
|
|
85
|
-
tags: [...(sourceMemory.tags || []), 'extracted-fact', ...fact.entities],
|
|
86
|
-
project: sourceMemory.project
|
|
87
|
-
}));
|
|
88
|
-
}
|
|
89
|
-
//# sourceMappingURL=fact-extractor.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** Feedback Tracker - Track memory usage in responses for Echo/Fizzle loop */
|
|
2
|
-
export declare function recordInjection(sessionId: string, memoryIds: string[], memoryContent: Map<string, string>): Promise<void>;
|
|
3
|
-
export declare function analyzeAndRecordFeedback(sessionId: string, responseText: string): Promise<void>;
|
|
4
|
-
export declare function updateRetrievalPriority(memoryId: string, delta: number): Promise<void>;
|
|
5
|
-
export declare function getMemoryFeedbackStats(memoryId: string): Promise<{
|
|
6
|
-
totalInjections: number;
|
|
7
|
-
totalReferences: number;
|
|
8
|
-
echoRate: number;
|
|
9
|
-
averagePriorityDelta: number;
|
|
10
|
-
}>;
|
|
11
|
-
export declare function cleanupInjectionTracker(maxAgeMs?: number): void;
|
|
12
|
-
//# sourceMappingURL=feedback-tracker.d.ts.map
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/** Feedback Tracker - Track memory usage in responses for Echo/Fizzle loop */
|
|
2
|
-
import { logger } from '../logger.js';
|
|
3
|
-
import { config } from '../../config.js';
|
|
4
|
-
import { getDb } from '../../db/index.js';
|
|
5
|
-
import { memoryFeedback, memories } from '../../db/drizzle/schema-sqlite.js';
|
|
6
|
-
import { eq, and } from 'drizzle-orm';
|
|
7
|
-
import { analyzeResponseForMemoryReferences, mightContainMemoryReferences } from './response-analyzer.js';
|
|
8
|
-
const injectionTracker = new Map();
|
|
9
|
-
export async function recordInjection(sessionId, memoryIds, memoryContent) {
|
|
10
|
-
if (!config.feedbackTrackingEnabled)
|
|
11
|
-
return;
|
|
12
|
-
injectionTracker.set(sessionId, {
|
|
13
|
-
memoryIds,
|
|
14
|
-
memoryContent,
|
|
15
|
-
injectedAt: new Date(),
|
|
16
|
-
});
|
|
17
|
-
const db = await getDb();
|
|
18
|
-
if (!db)
|
|
19
|
-
return;
|
|
20
|
-
try {
|
|
21
|
-
const now = new Date();
|
|
22
|
-
const sqliteDb = db;
|
|
23
|
-
for (const memoryId of memoryIds) {
|
|
24
|
-
await sqliteDb.insert(memoryFeedback).values({
|
|
25
|
-
memoryId,
|
|
26
|
-
sessionId,
|
|
27
|
-
wasInjected: true,
|
|
28
|
-
wasReferenced: false,
|
|
29
|
-
referenceCount: 0,
|
|
30
|
-
retrievalPriorityDelta: 0,
|
|
31
|
-
injectedAt: now,
|
|
32
|
-
}).onConflictDoNothing();
|
|
33
|
-
}
|
|
34
|
-
logger.debug(`[FeedbackTracker] Recorded injection of ${memoryIds.length} memories for session ${sessionId}`);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
logger.error('[FeedbackTracker] Failed to record injection:', error);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
export async function analyzeAndRecordFeedback(sessionId, responseText) {
|
|
41
|
-
if (!config.feedbackTrackingEnabled)
|
|
42
|
-
return;
|
|
43
|
-
const injection = injectionTracker.get(sessionId);
|
|
44
|
-
if (!injection) {
|
|
45
|
-
logger.debug(`[FeedbackTracker] No injection record for session ${sessionId}`);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
if (!mightContainMemoryReferences(responseText)) {
|
|
49
|
-
await applyFizzlePenalty(injection.memoryIds);
|
|
50
|
-
injectionTracker.delete(sessionId);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const analysis = analyzeResponseForMemoryReferences(responseText, injection.memoryIds, injection.memoryContent);
|
|
54
|
-
const db = await getDb();
|
|
55
|
-
if (!db)
|
|
56
|
-
return;
|
|
57
|
-
try {
|
|
58
|
-
const now = new Date();
|
|
59
|
-
const sqliteDb = db;
|
|
60
|
-
for (const memoryId of injection.memoryIds) {
|
|
61
|
-
const wasReferenced = analysis.referencedMemoryIds.includes(memoryId);
|
|
62
|
-
const delta = wasReferenced ? config.feedbackEchoBonus : -config.feedbackFizzlePenalty;
|
|
63
|
-
const existing = await sqliteDb
|
|
64
|
-
.select()
|
|
65
|
-
.from(memoryFeedback)
|
|
66
|
-
.where(and(eq(memoryFeedback.memoryId, memoryId), eq(memoryFeedback.sessionId, sessionId)))
|
|
67
|
-
.limit(1);
|
|
68
|
-
if (existing.length > 0) {
|
|
69
|
-
await sqliteDb
|
|
70
|
-
.update(memoryFeedback)
|
|
71
|
-
.set({
|
|
72
|
-
wasReferenced,
|
|
73
|
-
referenceCount: wasReferenced ? 1 : 0,
|
|
74
|
-
retrievalPriorityDelta: delta,
|
|
75
|
-
referencedAt: wasReferenced ? now : null,
|
|
76
|
-
})
|
|
77
|
-
.where(eq(memoryFeedback.id, existing[0].id));
|
|
78
|
-
}
|
|
79
|
-
await updateRetrievalPriority(memoryId, delta);
|
|
80
|
-
}
|
|
81
|
-
logger.info(`[FeedbackTracker] Feedback recorded: ${analysis.referenceCount} echoes, ${injection.memoryIds.length - analysis.referenceCount} fizzles`);
|
|
82
|
-
injectionTracker.delete(sessionId);
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
logger.error('[FeedbackTracker] Failed to record feedback:', error);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
async function applyFizzlePenalty(memoryIds) {
|
|
89
|
-
try {
|
|
90
|
-
for (const memoryId of memoryIds) {
|
|
91
|
-
await updateRetrievalPriority(memoryId, -config.feedbackFizzlePenalty);
|
|
92
|
-
}
|
|
93
|
-
logger.debug(`[FeedbackTracker] Applied fizzle penalty to ${memoryIds.length} memories`);
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
logger.error('[FeedbackTracker] Failed to apply fizzle penalty:', error);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
export async function updateRetrievalPriority(memoryId, delta) {
|
|
100
|
-
const db = await getDb();
|
|
101
|
-
if (!db)
|
|
102
|
-
return;
|
|
103
|
-
try {
|
|
104
|
-
const sqliteDb = db;
|
|
105
|
-
const [memory] = await sqliteDb
|
|
106
|
-
.select({ retrievalPriority: memories.retrievalPriority })
|
|
107
|
-
.from(memories)
|
|
108
|
-
.where(eq(memories.id, memoryId))
|
|
109
|
-
.limit(1);
|
|
110
|
-
if (!memory)
|
|
111
|
-
return;
|
|
112
|
-
const currentPriority = memory.retrievalPriority ?? 50;
|
|
113
|
-
const newPriority = Math.max(0, Math.min(100, currentPriority + delta));
|
|
114
|
-
await sqliteDb
|
|
115
|
-
.update(memories)
|
|
116
|
-
.set({ retrievalPriority: newPriority })
|
|
117
|
-
.where(eq(memories.id, memoryId));
|
|
118
|
-
logger.debug(`[FeedbackTracker] Updated priority for ${memoryId}: ${currentPriority} -> ${newPriority}`);
|
|
119
|
-
}
|
|
120
|
-
catch (error) {
|
|
121
|
-
logger.error('[FeedbackTracker] Failed to update retrieval priority:', error);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
export async function getMemoryFeedbackStats(memoryId) {
|
|
125
|
-
const db = await getDb();
|
|
126
|
-
if (!db) {
|
|
127
|
-
return { totalInjections: 0, totalReferences: 0, echoRate: 0, averagePriorityDelta: 0 };
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const sqliteDb = db;
|
|
131
|
-
const records = await sqliteDb
|
|
132
|
-
.select()
|
|
133
|
-
.from(memoryFeedback)
|
|
134
|
-
.where(eq(memoryFeedback.memoryId, memoryId));
|
|
135
|
-
const totalInjections = records.filter((r) => r.wasInjected).length;
|
|
136
|
-
const totalReferences = records.filter((r) => r.wasReferenced).length;
|
|
137
|
-
const echoRate = totalInjections > 0 ? totalReferences / totalInjections : 0;
|
|
138
|
-
const totalDelta = records.reduce((sum, r) => sum + (r.retrievalPriorityDelta ?? 0), 0);
|
|
139
|
-
const averagePriorityDelta = records.length > 0 ? totalDelta / records.length : 0;
|
|
140
|
-
return { totalInjections, totalReferences, echoRate, averagePriorityDelta };
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
logger.error('[FeedbackTracker] Failed to get feedback stats:', error);
|
|
144
|
-
return { totalInjections: 0, totalReferences: 0, echoRate: 0, averagePriorityDelta: 0 };
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
export function cleanupInjectionTracker(maxAgeMs = 3600000) {
|
|
148
|
-
const now = Date.now();
|
|
149
|
-
for (const [sessionId, injection] of injectionTracker.entries()) {
|
|
150
|
-
if (now - injection.injectedAt.getTime() > maxAgeMs) {
|
|
151
|
-
injectionTracker.delete(sessionId);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
//# sourceMappingURL=feedback-tracker.js.map
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Memory Lifecycle Hooks
|
|
3
|
-
*
|
|
4
|
-
* Provides event hooks for memory operations:
|
|
5
|
-
* - memoryCreated: When a memory is stored (DB or markdown files)
|
|
6
|
-
* - memoryUpdated: When a memory is updated
|
|
7
|
-
* - memoryDeleted: When a memory is deleted
|
|
8
|
-
* - tierChange: When memory tier changes (hot/warm/cold)
|
|
9
|
-
* - decayApplied: When decay score is updated
|
|
10
|
-
*
|
|
11
|
-
* Each hook can have sync and async handlers.
|
|
12
|
-
* Usage: Register handlers to auto-capture, sync to external systems, etc.
|
|
13
|
-
*/
|
|
14
|
-
export type HookEvent = 'memoryCreated' | 'memoryUpdated' | 'memoryDeleted' | 'tierChange' | 'decayApplied';
|
|
15
|
-
export interface MemoryHookContext {
|
|
16
|
-
memoryId: string;
|
|
17
|
-
content: string;
|
|
18
|
-
type: string;
|
|
19
|
-
tags: string[];
|
|
20
|
-
project?: string;
|
|
21
|
-
source?: string;
|
|
22
|
-
tier?: string;
|
|
23
|
-
importance?: number;
|
|
24
|
-
oldContent?: string;
|
|
25
|
-
}
|
|
26
|
-
export interface TierChangeContext extends MemoryHookContext {
|
|
27
|
-
oldTier: string;
|
|
28
|
-
newTier: string;
|
|
29
|
-
}
|
|
30
|
-
export interface DecayContext extends MemoryHookContext {
|
|
31
|
-
oldScore: number;
|
|
32
|
-
newScore: number;
|
|
33
|
-
}
|
|
34
|
-
export type HookHandler<T = MemoryHookContext> = (context: T) => void | Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* Register a hook handler for a specific event
|
|
37
|
-
*/
|
|
38
|
-
export declare function registerHook(event: HookEvent, handler: HookHandler, priority?: number): void;
|
|
39
|
-
/**
|
|
40
|
-
* Unregister a hook handler
|
|
41
|
-
*/
|
|
42
|
-
export declare function unregisterHook(event: HookEvent, handler: HookHandler): void;
|
|
43
|
-
/**
|
|
44
|
-
* Clear all hooks for an event
|
|
45
|
-
*/
|
|
46
|
-
export declare function clearHooks(event?: HookEvent): void;
|
|
47
|
-
/**
|
|
48
|
-
* Get registered hooks for an event
|
|
49
|
-
*/
|
|
50
|
-
export declare function getHooks(event: HookEvent): HookHandler[];
|
|
51
|
-
/**
|
|
52
|
-
* List all registered hooks (for debugging)
|
|
53
|
-
*/
|
|
54
|
-
export declare function listHooks(): {
|
|
55
|
-
event: HookEvent;
|
|
56
|
-
priority: number;
|
|
57
|
-
}[];
|
|
58
|
-
/**
|
|
59
|
-
* Trigger memoryCreated hooks
|
|
60
|
-
* Called when a memory is stored in DB or markdown files
|
|
61
|
-
*/
|
|
62
|
-
export declare function triggerMemoryCreated(context: MemoryHookContext): Promise<void>;
|
|
63
|
-
/**
|
|
64
|
-
* Trigger memoryUpdated hooks
|
|
65
|
-
* Called when a memory content/tags/etc changes
|
|
66
|
-
*/
|
|
67
|
-
export declare function triggerMemoryUpdated(context: MemoryHookContext, oldContent?: string): Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* Trigger memoryDeleted hooks
|
|
70
|
-
* Called when a memory is deleted
|
|
71
|
-
*/
|
|
72
|
-
export declare function triggerMemoryDeleted(context: MemoryHookContext): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Trigger tierChange hooks
|
|
75
|
-
* Called when memory tier changes
|
|
76
|
-
*/
|
|
77
|
-
export declare function triggerTierChange(context: TierChangeContext): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Trigger decayApplied hooks
|
|
80
|
-
* Called when memory decay score changes
|
|
81
|
-
*/
|
|
82
|
-
export declare function triggerDecayApplied(context: DecayContext): Promise<void>;
|
|
83
|
-
/**
|
|
84
|
-
* Built-in hook: Auto-save to memory files when storing to DB
|
|
85
|
-
* Use this to have dual storage (DB + markdown files)
|
|
86
|
-
*/
|
|
87
|
-
export declare function createMarkdownAutoSyncHook(): (context: MemoryHookContext) => Promise<void>;
|
|
88
|
-
//# sourceMappingURL=hooks.d.ts.map
|