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,859 +0,0 @@
|
|
|
1
|
-
import { pgTable, text, timestamp, uuid, integer, boolean, jsonb, index, vector, numeric } from 'drizzle-orm/pg-core';
|
|
2
|
-
import { relations } from 'drizzle-orm';
|
|
3
|
-
// Core Tables
|
|
4
|
-
// ============================================================================
|
|
5
|
-
/**
|
|
6
|
-
* Users - represents Claude Code users
|
|
7
|
-
*/
|
|
8
|
-
export const users = pgTable('users', {
|
|
9
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
10
|
-
externalId: text('external_id').unique(), // Claude user ID if available
|
|
11
|
-
name: text('name'),
|
|
12
|
-
email: text('email'),
|
|
13
|
-
preferences: jsonb('preferences').$type(),
|
|
14
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
15
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
16
|
-
});
|
|
17
|
-
// Memory Editing Tables
|
|
18
|
-
// ============================================================================
|
|
19
|
-
/**
|
|
20
|
-
* Memory Edit Proposals - tracks suggested edits before user approval
|
|
21
|
-
*/
|
|
22
|
-
export const memoryEditProposals = pgTable('memory_edit_proposals', {
|
|
23
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
24
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
25
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
26
|
-
// Memory to edit
|
|
27
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
28
|
-
// Current content
|
|
29
|
-
currentContent: text('current_content').notNull(),
|
|
30
|
-
proposedContent: text('proposed_content').notNull(),
|
|
31
|
-
// Edit metadata
|
|
32
|
-
reason: text('reason').notNull(),
|
|
33
|
-
conflictWarnings: jsonb('conflict_warnings').$type(),
|
|
34
|
-
status: text('status').notNull().$type().default('pending'),
|
|
35
|
-
// Versioning
|
|
36
|
-
version: integer('version').default(1).notNull(),
|
|
37
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
38
|
-
reviewedAt: timestamp('reviewed_at'),
|
|
39
|
-
reviewNotes: text('review_notes'),
|
|
40
|
-
}, (table) => [
|
|
41
|
-
index('memory_edit_proposals_memory_idx').on(table.memoryId),
|
|
42
|
-
index('memory_edit_proposals_status_idx').on(table.status),
|
|
43
|
-
index('memory_edit_proposals_created_at_idx').on(table.createdAt),
|
|
44
|
-
]);
|
|
45
|
-
/**
|
|
46
|
-
* Core Memory - Always-in-context memory (Tier 1)
|
|
47
|
-
* Small, persistent, always-visible memory block (< 2KB total)
|
|
48
|
-
*/
|
|
49
|
-
export const projects = pgTable('projects', {
|
|
50
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
51
|
-
name: text('name').notNull(),
|
|
52
|
-
path: text('path').notNull(), // Absolute path to project root
|
|
53
|
-
description: text('description'),
|
|
54
|
-
metadata: jsonb('metadata').$type(),
|
|
55
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
56
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
57
|
-
}, (table) => [
|
|
58
|
-
index('projects_path_idx').on(table.path),
|
|
59
|
-
]);
|
|
60
|
-
/**
|
|
61
|
-
* Memories - core memory storage with semantic search
|
|
62
|
-
*/
|
|
63
|
-
export const memories = pgTable('memories', {
|
|
64
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
65
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
66
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
67
|
-
// Content
|
|
68
|
-
type: text('type').notNull().$type(),
|
|
69
|
-
content: text('content').notNull(),
|
|
70
|
-
summary: text('summary'), // Compressed/summarized version
|
|
71
|
-
// Semantic search
|
|
72
|
-
embedding: vector('embedding', { dimensions: 1536 }), // OpenAI ada-002 compatible
|
|
73
|
-
// Metadata
|
|
74
|
-
source: text('source'), // Where this memory came from (tool, hook, user)
|
|
75
|
-
confidence: integer('confidence').default(50), // 0-100 confidence score (default: speculative)
|
|
76
|
-
confidenceLevel: text('confidence_level').default('speculative').$type(), // Iteration 3: Confidence flags (default: speculative)
|
|
77
|
-
tags: text('tags').array(),
|
|
78
|
-
metadata: jsonb('metadata').$type(),
|
|
79
|
-
// v0.2.0: Privacy and relevance
|
|
80
|
-
isPrivate: boolean('is_private').default(false),
|
|
81
|
-
hasSecrets: boolean('has_secrets').default(false),
|
|
82
|
-
relevanceScore: integer('relevance_score').default(50), // 0-100
|
|
83
|
-
// v0.3.0: Lifecycle Management
|
|
84
|
-
sector: text('sector').default('episodic').$type(),
|
|
85
|
-
tier: text('tier').default('hot').$type(),
|
|
86
|
-
status: text('status').notNull().default('active'),
|
|
87
|
-
encrypted_content: text('encrypted_content'),
|
|
88
|
-
encryption_nonce: text('encryption_nonce'),
|
|
89
|
-
is_encrypted: boolean('is_encrypted').default(false),
|
|
90
|
-
// Per-memory decay rate (integer percentage, e.g., 30 = 30% decay per cycle)
|
|
91
|
-
decayRate: integer('decay_rate').default(30),
|
|
92
|
-
coactivationScore: integer('coactivation_score').default(0), // 0-100
|
|
93
|
-
lastDecayAt: timestamp('last_decay_at').defaultNow(),
|
|
94
|
-
// v0.3.0: Agent-Aware
|
|
95
|
-
agentId: text('agent_id'), // e.g., 'main', 'research-agent'
|
|
96
|
-
agentRole: text('agent_role'), // e.g., 'general', 'specialist'
|
|
97
|
-
visibilityScope: text('visibility_scope').default('private').$type(),
|
|
98
|
-
// v0.3.0: Governance
|
|
99
|
-
isProtected: boolean('is_protected').default(false), // Cannot be evicted
|
|
100
|
-
isPinned: boolean('is_pinned').default(false), // Always inject
|
|
101
|
-
isImmutable: boolean('is_immutable').default(false), // Cannot be updated
|
|
102
|
-
writeScope: text('write_scope').array(), // Who can modify
|
|
103
|
-
readScope: text('read_scope').array(), // Who can read
|
|
104
|
-
// v0.3.0: Provenance
|
|
105
|
-
triggeredBy: text('triggered_by'), // What triggered this memory
|
|
106
|
-
captureReason: text('capture_reason'), // Why was this remembered
|
|
107
|
-
lastUsedAt: timestamp('last_used_at'),
|
|
108
|
-
usageCount: integer('usage_count').default(0),
|
|
109
|
-
// v0.3.0: Temporal Facts
|
|
110
|
-
validFrom: timestamp('valid_from'),
|
|
111
|
-
validTo: timestamp('valid_to'),
|
|
112
|
-
recordedAt: timestamp('recorded_at').defaultNow().notNull(), // When agent learned/stored the fact
|
|
113
|
-
supersededBy: uuid('superseded_by').references(() => memories.id),
|
|
114
|
-
version: integer('version').default(1),
|
|
115
|
-
// Lifecycle
|
|
116
|
-
isActive: boolean('is_active').default(true),
|
|
117
|
-
expiresAt: timestamp('expires_at'),
|
|
118
|
-
accessCount: integer('access_count').default(0),
|
|
119
|
-
lastAccessedAt: timestamp('last_accessed_at'),
|
|
120
|
-
// Merge tracking
|
|
121
|
-
isMerged: boolean('is_merged').default(false), // Soft archive flag
|
|
122
|
-
mergedIntoId: uuid('merged_into_id').references(() => memories.id), // Points to canonical memory
|
|
123
|
-
mergedAt: timestamp('merged_at'),
|
|
124
|
-
isCanonical: boolean('is_canonical').default(false), // True if result of merge
|
|
125
|
-
mergeSourceIds: jsonb('merge_source_ids').$type(), // IDs merged into this one
|
|
126
|
-
isMergeable: boolean('is_mergeable').default(true), // Immutability flag
|
|
127
|
-
mergeVersion: integer('merge_version').default(1), // Incremented on each merge
|
|
128
|
-
// v0.4.2: Namespace support
|
|
129
|
-
namespaceId: uuid('namespace_id').references(() => namespaces.id, { onDelete: 'set null' }),
|
|
130
|
-
namespacePath: text('namespace_path'),
|
|
131
|
-
// v1.1.5: Places support (spatial memory organization)
|
|
132
|
-
placeId: uuid('place_id').references(() => places.id, { onDelete: 'set null' }),
|
|
133
|
-
placeSortOrder: integer('place_sort_order'),
|
|
134
|
-
// v0.4.3: Layer support
|
|
135
|
-
hasL0Abstract: boolean('has_l0_abstract').default(false),
|
|
136
|
-
hasL1Overview: boolean('has_l1_overview').default(false),
|
|
137
|
-
lastLayerUpdate: timestamp('last_layer_update'),
|
|
138
|
-
// v1.0.x: Token tracking
|
|
139
|
-
tokensEstimate: integer('tokens_estimate').default(0).notNull(),
|
|
140
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
141
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
142
|
-
}, (table) => [
|
|
143
|
-
index('memories_project_idx').on(table.projectId),
|
|
144
|
-
index('memories_type_idx').on(table.type),
|
|
145
|
-
index('memories_created_idx').on(table.createdAt),
|
|
146
|
-
index('memories_tags_idx').on(table.tags),
|
|
147
|
-
index('memories_relevance_idx').on(table.relevanceScore),
|
|
148
|
-
index('memories_private_idx').on(table.isPrivate),
|
|
149
|
-
index('memories_merged_idx').on(table.isMerged),
|
|
150
|
-
index('memories_canonical_idx').on(table.isCanonical),
|
|
151
|
-
// v0.3.0: Lifecycle indexes
|
|
152
|
-
index('memories_sector_idx').on(table.sector),
|
|
153
|
-
index('memories_tier_idx').on(table.tier),
|
|
154
|
-
index('memories_agent_idx').on(table.agentId),
|
|
155
|
-
index('memories_visibility_idx').on(table.visibilityScope),
|
|
156
|
-
index('memories_protected_idx').on(table.isProtected),
|
|
157
|
-
index('memories_pinned_idx').on(table.isPinned),
|
|
158
|
-
index('memories_valid_from_idx').on(table.validFrom),
|
|
159
|
-
index('memories_valid_to_idx').on(table.validTo),
|
|
160
|
-
// v0.4.2: Composite indexes for performance optimization
|
|
161
|
-
// Duplicate detection query optimization
|
|
162
|
-
index('memories_duplicate_detection_idx').on(table.projectId, table.isMerged, table.isMergeable, table.isActive),
|
|
163
|
-
// Eviction query optimization (lifecycle.ts line 170-183)
|
|
164
|
-
index('memories_eviction_idx').on(table.projectId, table.tier, table.relevanceScore, table.createdAt),
|
|
165
|
-
// Decay operations optimization (lifecycle.ts line 70-100)
|
|
166
|
-
index('memories_decay_idx').on(table.sector, table.lastDecayAt, table.isProtected),
|
|
167
|
-
// Temporal query optimization
|
|
168
|
-
index('memories_temporal_idx').on(table.projectId, table.validFrom, table.validTo),
|
|
169
|
-
// Agent-aware retrieval optimization
|
|
170
|
-
index('memories_agent_visibility_idx').on(table.agentId, table.visibilityScope, table.isActive),
|
|
171
|
-
]);
|
|
172
|
-
/**
|
|
173
|
-
* Conversations - chat session tracking
|
|
174
|
-
*/
|
|
175
|
-
export const conversations = pgTable('conversations', {
|
|
176
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
177
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
178
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
179
|
-
sessionId: text('session_id').notNull(), // Claude session ID
|
|
180
|
-
title: text('title'),
|
|
181
|
-
summary: text('summary'),
|
|
182
|
-
// Stats
|
|
183
|
-
messageCount: integer('message_count').default(0),
|
|
184
|
-
tokenCount: integer('token_count').default(0),
|
|
185
|
-
startedAt: timestamp('started_at').defaultNow().notNull(),
|
|
186
|
-
endedAt: timestamp('ended_at'),
|
|
187
|
-
metadata: jsonb('metadata').$type(),
|
|
188
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
189
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
190
|
-
}, (table) => [
|
|
191
|
-
index('conversations_project_idx').on(table.projectId),
|
|
192
|
-
index('conversations_session_idx').on(table.sessionId),
|
|
193
|
-
index('conversations_started_idx').on(table.startedAt),
|
|
194
|
-
]);
|
|
195
|
-
/**
|
|
196
|
-
* Messages - individual messages within conversations
|
|
197
|
-
*/
|
|
198
|
-
export const messages = pgTable('messages', {
|
|
199
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
200
|
-
conversationId: uuid('conversation_id').references(() => conversations.id, { onDelete: 'cascade' }).notNull(),
|
|
201
|
-
role: text('role').notNull().$type(),
|
|
202
|
-
content: text('content').notNull(),
|
|
203
|
-
// Semantic search
|
|
204
|
-
embedding: vector('embedding', { dimensions: 1536 }),
|
|
205
|
-
// Token tracking
|
|
206
|
-
tokenCount: integer('token_count'),
|
|
207
|
-
// Tool usage
|
|
208
|
-
toolCalls: jsonb('tool_calls').$type(),
|
|
209
|
-
metadata: jsonb('metadata').$type(),
|
|
210
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
211
|
-
}, (table) => [
|
|
212
|
-
index('messages_conversation_idx').on(table.conversationId),
|
|
213
|
-
index('messages_role_idx').on(table.role),
|
|
214
|
-
index('messages_created_idx').on(table.createdAt),
|
|
215
|
-
]);
|
|
216
|
-
/**
|
|
217
|
-
* Learnings - agent learnings: success, failure, fix, insight
|
|
218
|
-
*/
|
|
219
|
-
export const learnings = pgTable('learnings', {
|
|
220
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
221
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
222
|
-
conversationId: uuid('conversation_id').references(() => conversations.id, { onDelete: 'set null' }),
|
|
223
|
-
// Learning type: success, failure, fix, insight
|
|
224
|
-
type: text('type').notNull().$type(),
|
|
225
|
-
action: text('action').notNull(),
|
|
226
|
-
target: text('target'),
|
|
227
|
-
// Details
|
|
228
|
-
summary: text('summary').notNull(),
|
|
229
|
-
details: jsonb('details').$type(),
|
|
230
|
-
// Semantic search
|
|
231
|
-
embedding: vector('embedding', { dimensions: 1536 }),
|
|
232
|
-
// Optional link to a memory
|
|
233
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'set null' }),
|
|
234
|
-
// Folder-scoped
|
|
235
|
-
folderPath: text('folder_path'),
|
|
236
|
-
projectPath: text('project_path'),
|
|
237
|
-
// Privacy and relevance
|
|
238
|
-
isPrivate: boolean('is_private').default(false),
|
|
239
|
-
hasSecrets: boolean('has_secrets').default(false),
|
|
240
|
-
relevanceScore: integer('relevance_score').default(50),
|
|
241
|
-
// Classification
|
|
242
|
-
category: text('category'),
|
|
243
|
-
importance: integer('importance').default(50),
|
|
244
|
-
metadata: jsonb('metadata').$type(),
|
|
245
|
-
// Migration tracking
|
|
246
|
-
isImported: boolean('is_imported').default(false),
|
|
247
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
248
|
-
}, (table) => [
|
|
249
|
-
index('learnings_project_idx').on(table.projectId),
|
|
250
|
-
index('learnings_type_idx').on(table.type),
|
|
251
|
-
index('learnings_action_idx').on(table.action),
|
|
252
|
-
index('learnings_created_idx').on(table.createdAt),
|
|
253
|
-
index('learnings_folder_idx').on(table.folderPath),
|
|
254
|
-
index('learnings_relevance_idx').on(table.relevanceScore),
|
|
255
|
-
index('learnings_private_idx').on(table.isPrivate),
|
|
256
|
-
index('learnings_memory_idx').on(table.memoryId),
|
|
257
|
-
]);
|
|
258
|
-
/**
|
|
259
|
-
* Agent Preferences - learned agent preferences from learnings
|
|
260
|
-
* Enables agents to evolve and remember preferences over time
|
|
261
|
-
*/
|
|
262
|
-
export const agentPreferences = pgTable('agent_preferences', {
|
|
263
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
264
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
265
|
-
key: text('key').notNull(), // e.g., "prefer_bun", "prefer_typescript"
|
|
266
|
-
value: text('value').notNull(), // e.g., "bun", "true"
|
|
267
|
-
sourceMemoryId: uuid('source_memory_id').references(() => memories.id, { onDelete: 'set null' }),
|
|
268
|
-
confidence: numeric('confidence', { precision: 3, scale: 2 }).default('0.5'), // 0.00 to 1.00
|
|
269
|
-
usageCount: integer('usage_count').default(1),
|
|
270
|
-
lastUpdated: timestamp('last_updated').defaultNow().notNull(),
|
|
271
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
272
|
-
}, (table) => [
|
|
273
|
-
index('agent_preferences_project_idx').on(table.projectId),
|
|
274
|
-
index('agent_preferences_key_idx').on(table.key),
|
|
275
|
-
]);
|
|
276
|
-
/**
|
|
277
|
-
* Entities - knowledge graph nodes
|
|
278
|
-
*/
|
|
279
|
-
export const entities = pgTable('entities', {
|
|
280
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
281
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
282
|
-
name: text('name').notNull(),
|
|
283
|
-
type: text('type').notNull().$type(),
|
|
284
|
-
description: text('description'),
|
|
285
|
-
// Semantic search
|
|
286
|
-
embedding: vector('embedding', { dimensions: 1536 }),
|
|
287
|
-
properties: jsonb('properties').$type(),
|
|
288
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
289
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
290
|
-
}, (table) => [
|
|
291
|
-
index('entities_project_idx').on(table.projectId),
|
|
292
|
-
index('entities_type_idx').on(table.type),
|
|
293
|
-
index('entities_name_idx').on(table.name),
|
|
294
|
-
]);
|
|
295
|
-
/**
|
|
296
|
-
* Namespaces - Hierarchical folder-like namespaces for memory organization
|
|
297
|
-
*/
|
|
298
|
-
export const namespaces = pgTable('namespaces', {
|
|
299
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
300
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
301
|
-
name: text('name').notNull(),
|
|
302
|
-
parentId: uuid('parent_id').references(() => namespaces.id, { onDelete: 'set null' }),
|
|
303
|
-
type: text('type').notNull().$type(),
|
|
304
|
-
description: text('description'),
|
|
305
|
-
path: text('path').notNull(), // Full path like 'user/preferences' or 'projectX/docs/api'
|
|
306
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
307
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
308
|
-
}, (table) => [
|
|
309
|
-
index('namespaces_project_idx').on(table.projectId),
|
|
310
|
-
index('namespaces_parent_idx').on(table.parentId),
|
|
311
|
-
]);
|
|
312
|
-
/**
|
|
313
|
-
* Places - Spatial memory organization
|
|
314
|
-
*/
|
|
315
|
-
export const places = pgTable('places', {
|
|
316
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
317
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
318
|
-
name: text('name').notNull(),
|
|
319
|
-
placeType: text('place_type').notNull(),
|
|
320
|
-
parentId: uuid('parent_id').references(() => places.id, { onDelete: 'set null' }),
|
|
321
|
-
sortOrder: integer('sort_order').default(0),
|
|
322
|
-
positionX: integer('position_x').default(0),
|
|
323
|
-
positionY: integer('position_y').default(0),
|
|
324
|
-
description: text('description'),
|
|
325
|
-
purpose: text('purpose'),
|
|
326
|
-
memoryCount: integer('memory_count').default(0),
|
|
327
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
328
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
329
|
-
}, (table) => [
|
|
330
|
-
index('places_project_idx').on(table.projectId),
|
|
331
|
-
index('places_type_idx').on(table.placeType),
|
|
332
|
-
index('places_parent_idx').on(table.parentId),
|
|
333
|
-
index('places_sort_order_idx').on(table.projectId, table.sortOrder),
|
|
334
|
-
]);
|
|
335
|
-
/**
|
|
336
|
-
* Memory-Place assignments
|
|
337
|
-
*/
|
|
338
|
-
export const memoryPlaces = pgTable('memory_places', {
|
|
339
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
340
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
341
|
-
placeId: uuid('place_id').references(() => places.id, { onDelete: 'cascade' }).notNull(),
|
|
342
|
-
isManual: boolean('is_manual').default(false),
|
|
343
|
-
ruleId: uuid('rule_id'),
|
|
344
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
345
|
-
}, (table) => [
|
|
346
|
-
index('memory_places_memory_idx').on(table.memoryId),
|
|
347
|
-
index('memory_places_place_idx').on(table.placeId),
|
|
348
|
-
]);
|
|
349
|
-
/**
|
|
350
|
-
* Place auto-assignment rules
|
|
351
|
-
*/
|
|
352
|
-
export const placeRules = pgTable('place_rules', {
|
|
353
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
354
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
355
|
-
name: text('name').notNull(),
|
|
356
|
-
placeType: text('place_type').notNull(),
|
|
357
|
-
matchTool: text('match_tool'),
|
|
358
|
-
matchKeyword: text('match_keyword'),
|
|
359
|
-
matchTag: text('match_tag'),
|
|
360
|
-
matchMemoryType: text('match_memory_type'),
|
|
361
|
-
priority: integer('priority').default(0),
|
|
362
|
-
enabled: boolean('enabled').default(true),
|
|
363
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
364
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
365
|
-
}, (table) => [
|
|
366
|
-
index('place_rules_project_idx').on(table.projectId),
|
|
367
|
-
index('place_rules_type_idx').on(table.placeType),
|
|
368
|
-
]);
|
|
369
|
-
/**
|
|
370
|
-
* Memory Layers - Tiered L0/L1/L2 summaries for token-efficient retrieval
|
|
371
|
-
*/
|
|
372
|
-
export const memoryLayers = pgTable('memory_layers', {
|
|
373
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
374
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
375
|
-
layerType: text('layer_type').notNull().$type(),
|
|
376
|
-
content: text('content').notNull(),
|
|
377
|
-
tokenCount: integer('token_count').default(0),
|
|
378
|
-
embedding: vector('embedding', { dimensions: 1536 }),
|
|
379
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
380
|
-
}, (table) => [
|
|
381
|
-
index('memory_layers_memory_idx').on(table.memoryId),
|
|
382
|
-
index('memory_layers_type_idx').on(table.layerType),
|
|
383
|
-
]);
|
|
384
|
-
/**
|
|
385
|
-
* Relations - knowledge graph edges
|
|
386
|
-
*/
|
|
387
|
-
export const entityRelations = pgTable('entity_relations', {
|
|
388
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
389
|
-
fromEntityId: uuid('from_entity_id').references(() => entities.id, { onDelete: 'cascade' }).notNull(),
|
|
390
|
-
toEntityId: uuid('to_entity_id').references(() => entities.id, { onDelete: 'cascade' }).notNull(),
|
|
391
|
-
type: text('type').notNull(), // e.g., 'uses', 'extends', 'contains', 'depends_on'
|
|
392
|
-
weight: integer('weight').default(1),
|
|
393
|
-
properties: jsonb('properties').$type(),
|
|
394
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
395
|
-
}, (table) => [
|
|
396
|
-
index('relations_from_idx').on(table.fromEntityId),
|
|
397
|
-
index('relations_to_idx').on(table.toEntityId),
|
|
398
|
-
index('relations_type_idx').on(table.type),
|
|
399
|
-
]);
|
|
400
|
-
// v0.3.0: Lifecycle & Governance Tables
|
|
401
|
-
// ============================================================================
|
|
402
|
-
/**
|
|
403
|
-
* Memory Associations - Waypoint graph tracking memory relationships
|
|
404
|
-
*/
|
|
405
|
-
export const memoryAssociations = pgTable('memory_associations', {
|
|
406
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
407
|
-
fromMemoryId: uuid('from_memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
408
|
-
toMemoryId: uuid('to_memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
409
|
-
associationType: text('association_type').notNull().$type(),
|
|
410
|
-
weight: integer('weight').default(1), // Association strength
|
|
411
|
-
coactivationCount: integer('coactivation_count').default(0),
|
|
412
|
-
metadata: jsonb('metadata').$type(),
|
|
413
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
414
|
-
lastCoactivatedAt: timestamp('last_coactivated_at'),
|
|
415
|
-
}, (table) => [
|
|
416
|
-
index('associations_from_idx').on(table.fromMemoryId),
|
|
417
|
-
index('associations_to_idx').on(table.toMemoryId),
|
|
418
|
-
index('associations_type_idx').on(table.associationType),
|
|
419
|
-
index('associations_weight_idx').on(table.weight),
|
|
420
|
-
// v0.4.2: Composite index for graph traversal optimization
|
|
421
|
-
index('associations_graph_traversal_idx').on(table.fromMemoryId, table.toMemoryId, table.weight, table.associationType),
|
|
422
|
-
]);
|
|
423
|
-
/**
|
|
424
|
-
* Session Summaries - Compressed conversation snapshots
|
|
425
|
-
*/
|
|
426
|
-
export const sessionSummaries = pgTable('session_summaries', {
|
|
427
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
428
|
-
conversationId: uuid('conversation_id').references(() => conversations.id, { onDelete: 'cascade' }).notNull(),
|
|
429
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
430
|
-
summaryType: text('summary_type').notNull().$type(),
|
|
431
|
-
content: text('content').notNull(),
|
|
432
|
-
compressedFrom: integer('compressed_from'), // How many messages compressed
|
|
433
|
-
tokensSaved: integer('tokens_saved'),
|
|
434
|
-
embedding: vector('embedding', { dimensions: 1536 }),
|
|
435
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
436
|
-
}, (table) => [
|
|
437
|
-
index('session_summaries_conversation_idx').on(table.conversationId),
|
|
438
|
-
index('session_summaries_project_idx').on(table.projectId),
|
|
439
|
-
index('session_summaries_type_idx').on(table.summaryType),
|
|
440
|
-
]);
|
|
441
|
-
/**
|
|
442
|
-
* Memory Snapshots - Before/after diffs for auditability
|
|
443
|
-
*/
|
|
444
|
-
export const memorySnapshots = pgTable('memory_snapshots', {
|
|
445
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
446
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
447
|
-
snapshotType: text('snapshot_type').notNull().$type(),
|
|
448
|
-
content: text('content').notNull(),
|
|
449
|
-
metadata: jsonb('metadata').$type(),
|
|
450
|
-
diff: jsonb('diff').$type(),
|
|
451
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
452
|
-
}, (table) => [
|
|
453
|
-
index('snapshots_memory_idx').on(table.memoryId),
|
|
454
|
-
index('snapshots_type_idx').on(table.snapshotType),
|
|
455
|
-
index('snapshots_created_idx').on(table.createdAt),
|
|
456
|
-
]);
|
|
457
|
-
// Progressive Disclosure & Context Paging Tables
|
|
458
|
-
// ============================================================================
|
|
459
|
-
/**
|
|
460
|
-
* Lightweight memory indices for progressive disclosure - previews and metadata
|
|
461
|
-
* used for quick filtering before loading full memories
|
|
462
|
-
*/
|
|
463
|
-
export const lightweightMemoryIndices = pgTable('lightweight_memory_indices', {
|
|
464
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
465
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }),
|
|
466
|
-
// Hash for quick comparison
|
|
467
|
-
contentHash: text('content_hash').notNull(),
|
|
468
|
-
contentPreview: text('content_preview').notNull(),
|
|
469
|
-
keyTerms: text('key_terms').array(), // JSON array of keywords
|
|
470
|
-
// Categorization
|
|
471
|
-
category: text('category').notNull(),
|
|
472
|
-
importanceScore: integer('importance_score').notNull(),
|
|
473
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
474
|
-
}, (table) => [
|
|
475
|
-
index('lightweight_indices_memory_idx').on(table.memoryId),
|
|
476
|
-
index('lightweight_indices_category_idx').on(table.category),
|
|
477
|
-
index('lightweight_indices_importance_idx').on(table.importanceScore),
|
|
478
|
-
]);
|
|
479
|
-
/**
|
|
480
|
-
* Context paging sessions for tracking loaded/preloaded memories
|
|
481
|
-
* Agent-controlled memory loading system
|
|
482
|
-
*/
|
|
483
|
-
export const contextPagingSessions = pgTable('context_paging_sessions', {
|
|
484
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
485
|
-
sessionId: text('session_id').notNull().unique(),
|
|
486
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
487
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
488
|
-
// Loaded memories (actively in context)
|
|
489
|
-
loadedMemoryIds: text('loaded_memory_ids').array().default([]),
|
|
490
|
-
// Preload candidates (ready to load if needed)
|
|
491
|
-
preloadCandidateIds: text('preload_candidate_ids').array().default([]),
|
|
492
|
-
// Token tracking
|
|
493
|
-
tokenBudget: integer('token_budget').default(8000).notNull(),
|
|
494
|
-
tokensUsed: integer('tokens_used').default(0).notNull(),
|
|
495
|
-
loadedMemoriesTokens: integer('loaded_memories_tokens').default(0).notNull(),
|
|
496
|
-
// Session metadata
|
|
497
|
-
metadata: jsonb('metadata').$type(),
|
|
498
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
499
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
500
|
-
}, (table) => [
|
|
501
|
-
index('context_paging_session_idx').on(table.sessionId),
|
|
502
|
-
index('context_paging_project_idx').on(table.projectId),
|
|
503
|
-
index('context_paging_created_idx').on(table.createdAt),
|
|
504
|
-
]);
|
|
505
|
-
// Memory Merging Tables
|
|
506
|
-
// ============================================================================
|
|
507
|
-
/**
|
|
508
|
-
* Memory Merge Proposals - tracks suggested merges before user approval
|
|
509
|
-
*/
|
|
510
|
-
export const memoryMergeProposals = pgTable('memory_merge_proposals', {
|
|
511
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
512
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
513
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
514
|
-
// Source memories to be merged
|
|
515
|
-
sourceMemoryIds: jsonb('source_memory_ids').$type().notNull(),
|
|
516
|
-
// Proposed merged content
|
|
517
|
-
proposedContent: text('proposed_content').notNull(),
|
|
518
|
-
proposedSummary: text('proposed_summary'),
|
|
519
|
-
proposedTags: jsonb('proposed_tags').$type(),
|
|
520
|
-
proposedMetadata: jsonb('proposed_metadata').$type(),
|
|
521
|
-
// Detection metadata
|
|
522
|
-
detectionMethod: text('detection_method').notNull().$type(),
|
|
523
|
-
similarityScore: numeric('similarity_score').notNull(), // 0-1
|
|
524
|
-
confidenceLevel: text('confidence_level').notNull().$type(),
|
|
525
|
-
// Merge rationale
|
|
526
|
-
mergeReason: text('merge_reason').notNull(),
|
|
527
|
-
conflictWarnings: jsonb('conflict_warnings').$type(),
|
|
528
|
-
// Status
|
|
529
|
-
status: text('status').notNull().$type().default('pending'),
|
|
530
|
-
reviewedAt: timestamp('reviewed_at'),
|
|
531
|
-
reviewNotes: text('review_notes'),
|
|
532
|
-
// Timestamps
|
|
533
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
534
|
-
expiresAt: timestamp('expires_at'), // Auto-expire old proposals
|
|
535
|
-
}, (table) => [
|
|
536
|
-
index('memory_merge_proposals_project_status_idx').on(table.projectId, table.status),
|
|
537
|
-
index('memory_merge_proposals_created_at_idx').on(table.createdAt),
|
|
538
|
-
]);
|
|
539
|
-
/**
|
|
540
|
-
* Memory Merge History - audit trail of completed merges
|
|
541
|
-
*/
|
|
542
|
-
export const memoryMergeHistory = pgTable('memory_merge_history', {
|
|
543
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
544
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
545
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
546
|
-
// Merge details
|
|
547
|
-
proposalId: uuid('proposal_id').references(() => memoryMergeProposals.id, { onDelete: 'set null' }),
|
|
548
|
-
sourceMemoryIds: jsonb('source_memory_ids').$type().notNull(),
|
|
549
|
-
canonicalMemoryId: uuid('canonical_memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
550
|
-
// Snapshot of merged memories (for reversibility)
|
|
551
|
-
sourceMemoriesSnapshot: jsonb('source_memories_snapshot').$type().notNull(),
|
|
552
|
-
// Merge metadata
|
|
553
|
-
mergeStrategy: text('merge_strategy').notNull().$type(),
|
|
554
|
-
tokensSaved: integer('tokens_saved'), // Estimated context window savings
|
|
555
|
-
// Reversibility
|
|
556
|
-
isReversed: boolean('is_reversed').default(false),
|
|
557
|
-
reversedAt: timestamp('reversed_at'),
|
|
558
|
-
reversedBy: uuid('reversed_by'),
|
|
559
|
-
// Timestamps
|
|
560
|
-
mergedAt: timestamp('merged_at').defaultNow().notNull(),
|
|
561
|
-
});
|
|
562
|
-
/**
|
|
563
|
-
* Memory Hash Cache - cached hash signatures for efficient duplicate detection
|
|
564
|
-
*/
|
|
565
|
-
export const memoryHashCache = pgTable('memory_hash_cache', {
|
|
566
|
-
memoryId: uuid('memory_id').primaryKey().references(() => memories.id, { onDelete: 'cascade' }),
|
|
567
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }).notNull(),
|
|
568
|
-
// Hash signatures
|
|
569
|
-
simhash: text('simhash'), // 64-bit hash as hex string
|
|
570
|
-
minhash: jsonb('minhash').$type(), // Array of 128 hash values
|
|
571
|
-
// Metadata for cache invalidation
|
|
572
|
-
contentHash: text('content_hash').notNull(), // MD5/SHA of content for invalidation
|
|
573
|
-
lastUpdated: timestamp('last_updated').defaultNow().notNull(),
|
|
574
|
-
}, (table) => [
|
|
575
|
-
index('memory_hash_cache_project_id_idx').on(table.projectId),
|
|
576
|
-
index('memory_hash_cache_simhash_idx').on(table.simhash), // For Hamming distance queries
|
|
577
|
-
]);
|
|
578
|
-
/**
|
|
579
|
-
* Search Traces - Stores retrieval logs for debugging and performance analysis
|
|
580
|
-
*/
|
|
581
|
-
export const searchTraces = pgTable('search_traces', {
|
|
582
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
583
|
-
sessionId: text('session_id').notNull(),
|
|
584
|
-
query: text('query').notNull(),
|
|
585
|
-
timestamp: timestamp('timestamp_at').defaultNow(),
|
|
586
|
-
// Search pipeline stages (JSONB for flexibility)
|
|
587
|
-
queryRewrite: jsonb('query_rewrite'), // { original, rewritten, method }
|
|
588
|
-
candidateRetrieval: jsonb('candidate_retrieval'), // { candidates, timeMs }
|
|
589
|
-
entityFiltering: jsonb('entity_filtering'), // { entities: string[], results: timeMs }
|
|
590
|
-
hybridScoring: jsonb('hybrid_scoring'), // { results, timeMs }
|
|
591
|
-
reranking: jsonb('reranking'), // { results, timeMs }
|
|
592
|
-
// Final results
|
|
593
|
-
resultCount: integer('result_count').default(0),
|
|
594
|
-
topResults: jsonb('top_results'),
|
|
595
|
-
// Performance metrics
|
|
596
|
-
totalDurationMs: integer('total_duration_ms').default(0),
|
|
597
|
-
metadata: jsonb('metadata'),
|
|
598
|
-
}, (table) => [
|
|
599
|
-
index('search_traces_session_idx').on(table.sessionId),
|
|
600
|
-
index('search_traces_timestamp_idx').on(table.timestamp),
|
|
601
|
-
]);
|
|
602
|
-
/**
|
|
603
|
-
* Core Memory - Always-in-context memory (Tier 1)
|
|
604
|
-
* Small, persistent, always-visible memory block (< 2KB total)
|
|
605
|
-
*/
|
|
606
|
-
export const coreMemory = pgTable('core_memory', {
|
|
607
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
608
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
609
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
610
|
-
// Core memory sections
|
|
611
|
-
section: text('section').notNull().$type(),
|
|
612
|
-
content: text('content').notNull().default(''),
|
|
613
|
-
sizeBytes: integer('size_bytes').default(0).notNull(),
|
|
614
|
-
tokensEstimate: integer('tokens_estimate').default(0).notNull(),
|
|
615
|
-
// Version tracking
|
|
616
|
-
version: integer('version').default(1).notNull(),
|
|
617
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
618
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
619
|
-
}, (table) => [
|
|
620
|
-
index('core_memory_project_idx').on(table.projectId),
|
|
621
|
-
index('core_memory_user_idx').on(table.userId),
|
|
622
|
-
index('core_memory_section_idx').on(table.section),
|
|
623
|
-
]);
|
|
624
|
-
/**
|
|
625
|
-
* Context Sessions - Track loaded memories and context window usage
|
|
626
|
-
*/
|
|
627
|
-
export const contextSessions = pgTable('context_sessions', {
|
|
628
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
629
|
-
sessionId: text('session_id').notNull().unique(),
|
|
630
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
631
|
-
userId: uuid('user_id').references(() => users.id, { onDelete: 'set null' }),
|
|
632
|
-
// Loaded memories (paging system)
|
|
633
|
-
loadedMemoryIds: text('loaded_memory_ids').array().default([]),
|
|
634
|
-
// Token tracking
|
|
635
|
-
tokenBudget: integer('token_budget').default(8000).notNull(),
|
|
636
|
-
tokensUsed: integer('tokens_used').default(0).notNull(),
|
|
637
|
-
coreMemoryTokens: integer('core_memory_tokens').default(0).notNull(),
|
|
638
|
-
loadedMemoriesTokens: integer('loaded_memories_tokens').default(0).notNull(),
|
|
639
|
-
// Session metadata
|
|
640
|
-
metadata: jsonb('metadata').$type(),
|
|
641
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
642
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
643
|
-
}, (table) => [
|
|
644
|
-
index('context_sessions_session_idx').on(table.sessionId),
|
|
645
|
-
index('context_sessions_project_idx').on(table.projectId),
|
|
646
|
-
index('context_sessions_created_idx').on(table.createdAt),
|
|
647
|
-
]);
|
|
648
|
-
// Relations (Drizzle ORM)
|
|
649
|
-
// ============================================================================
|
|
650
|
-
export const usersRelations = relations(users, ({ many }) => ({
|
|
651
|
-
memories: many(memories),
|
|
652
|
-
conversations: many(conversations),
|
|
653
|
-
}));
|
|
654
|
-
export const projectsRelations = relations(projects, ({ many }) => ({
|
|
655
|
-
memories: many(memories),
|
|
656
|
-
conversations: many(conversations),
|
|
657
|
-
learnings: many(learnings),
|
|
658
|
-
entities: many(entities),
|
|
659
|
-
}));
|
|
660
|
-
export const memoriesRelations = relations(memories, ({ one }) => ({
|
|
661
|
-
project: one(projects, {
|
|
662
|
-
fields: [memories.projectId],
|
|
663
|
-
references: [projects.id],
|
|
664
|
-
}),
|
|
665
|
-
user: one(users, {
|
|
666
|
-
fields: [memories.userId],
|
|
667
|
-
references: [users.id],
|
|
668
|
-
}),
|
|
669
|
-
}));
|
|
670
|
-
export const conversationsRelations = relations(conversations, ({ one, many }) => ({
|
|
671
|
-
project: one(projects, {
|
|
672
|
-
fields: [conversations.projectId],
|
|
673
|
-
references: [projects.id],
|
|
674
|
-
}),
|
|
675
|
-
user: one(users, {
|
|
676
|
-
fields: [conversations.userId],
|
|
677
|
-
references: [users.id],
|
|
678
|
-
}),
|
|
679
|
-
messages: many(messages),
|
|
680
|
-
learnings: many(learnings),
|
|
681
|
-
}));
|
|
682
|
-
export const learningsRelations = relations(learnings, ({ one }) => ({
|
|
683
|
-
project: one(projects, {
|
|
684
|
-
fields: [learnings.projectId],
|
|
685
|
-
references: [projects.id],
|
|
686
|
-
}),
|
|
687
|
-
conversation: one(conversations, {
|
|
688
|
-
fields: [learnings.conversationId],
|
|
689
|
-
references: [conversations.id],
|
|
690
|
-
}),
|
|
691
|
-
memory: one(memories, {
|
|
692
|
-
fields: [learnings.memoryId],
|
|
693
|
-
references: [memories.id],
|
|
694
|
-
}),
|
|
695
|
-
}));
|
|
696
|
-
export const agentPreferencesRelations = relations(agentPreferences, ({ one }) => ({
|
|
697
|
-
project: one(projects, {
|
|
698
|
-
fields: [agentPreferences.projectId],
|
|
699
|
-
references: [projects.id],
|
|
700
|
-
}),
|
|
701
|
-
sourceMemory: one(memories, {
|
|
702
|
-
fields: [agentPreferences.sourceMemoryId],
|
|
703
|
-
references: [memories.id],
|
|
704
|
-
}),
|
|
705
|
-
}));
|
|
706
|
-
export const messagesRelations = relations(messages, ({ one }) => ({
|
|
707
|
-
conversation: one(conversations, {
|
|
708
|
-
fields: [messages.conversationId],
|
|
709
|
-
references: [conversations.id],
|
|
710
|
-
}),
|
|
711
|
-
}));
|
|
712
|
-
export const entitiesRelations = relations(entities, ({ one, many }) => ({
|
|
713
|
-
project: one(projects, {
|
|
714
|
-
fields: [entities.projectId],
|
|
715
|
-
references: [projects.id],
|
|
716
|
-
}),
|
|
717
|
-
outgoingRelations: many(entityRelations, { relationName: 'fromEntity' }),
|
|
718
|
-
incomingRelations: many(entityRelations, { relationName: 'toEntity' }),
|
|
719
|
-
}));
|
|
720
|
-
export const entityRelationsRelations = relations(entityRelations, ({ one }) => ({
|
|
721
|
-
fromEntity: one(entities, {
|
|
722
|
-
fields: [entityRelations.fromEntityId],
|
|
723
|
-
references: [entities.id],
|
|
724
|
-
relationName: 'fromEntity',
|
|
725
|
-
}),
|
|
726
|
-
toEntity: one(entities, {
|
|
727
|
-
fields: [entityRelations.toEntityId],
|
|
728
|
-
references: [entities.id],
|
|
729
|
-
relationName: 'toEntity',
|
|
730
|
-
}),
|
|
731
|
-
}));
|
|
732
|
-
export const memoryAssociationsRelations = relations(memoryAssociations, ({ one }) => ({
|
|
733
|
-
fromMemory: one(memories, {
|
|
734
|
-
fields: [memoryAssociations.fromMemoryId],
|
|
735
|
-
references: [memories.id],
|
|
736
|
-
relationName: 'fromAssociations',
|
|
737
|
-
}),
|
|
738
|
-
toMemory: one(memories, {
|
|
739
|
-
fields: [memoryAssociations.toMemoryId],
|
|
740
|
-
references: [memories.id],
|
|
741
|
-
relationName: 'toAssociations',
|
|
742
|
-
}),
|
|
743
|
-
}));
|
|
744
|
-
export const sessionSummariesRelations = relations(sessionSummaries, ({ one }) => ({
|
|
745
|
-
conversation: one(conversations, {
|
|
746
|
-
fields: [sessionSummaries.conversationId],
|
|
747
|
-
references: [conversations.id],
|
|
748
|
-
}),
|
|
749
|
-
project: one(projects, {
|
|
750
|
-
fields: [sessionSummaries.projectId],
|
|
751
|
-
references: [projects.id],
|
|
752
|
-
}),
|
|
753
|
-
}));
|
|
754
|
-
export const memorySnapshotsRelations = relations(memorySnapshots, ({ one }) => ({
|
|
755
|
-
memory: one(memories, {
|
|
756
|
-
fields: [memorySnapshots.memoryId],
|
|
757
|
-
references: [memories.id],
|
|
758
|
-
}),
|
|
759
|
-
}));
|
|
760
|
-
export const memoryMergeProposalsRelations = relations(memoryMergeProposals, ({ one }) => ({
|
|
761
|
-
project: one(projects, {
|
|
762
|
-
fields: [memoryMergeProposals.projectId],
|
|
763
|
-
references: [projects.id],
|
|
764
|
-
}),
|
|
765
|
-
user: one(users, {
|
|
766
|
-
fields: [memoryMergeProposals.userId],
|
|
767
|
-
references: [users.id],
|
|
768
|
-
}),
|
|
769
|
-
}));
|
|
770
|
-
export const memoryMergeHistoryRelations = relations(memoryMergeHistory, ({ one }) => ({
|
|
771
|
-
project: one(projects, {
|
|
772
|
-
fields: [memoryMergeHistory.projectId],
|
|
773
|
-
references: [projects.id],
|
|
774
|
-
}),
|
|
775
|
-
user: one(users, {
|
|
776
|
-
fields: [memoryMergeHistory.userId],
|
|
777
|
-
references: [users.id],
|
|
778
|
-
}),
|
|
779
|
-
canonicalMemory: one(memories, {
|
|
780
|
-
fields: [memoryMergeHistory.canonicalMemoryId],
|
|
781
|
-
references: [memories.id],
|
|
782
|
-
}),
|
|
783
|
-
proposal: one(memoryMergeProposals, {
|
|
784
|
-
fields: [memoryMergeHistory.proposalId],
|
|
785
|
-
references: [memoryMergeProposals.id],
|
|
786
|
-
}),
|
|
787
|
-
}));
|
|
788
|
-
export const memoryHashCacheRelations = relations(memoryHashCache, ({ one }) => ({
|
|
789
|
-
memory: one(memories, {
|
|
790
|
-
fields: [memoryHashCache.memoryId],
|
|
791
|
-
references: [memories.id],
|
|
792
|
-
}),
|
|
793
|
-
project: one(projects, {
|
|
794
|
-
fields: [memoryHashCache.projectId],
|
|
795
|
-
references: [projects.id],
|
|
796
|
-
}),
|
|
797
|
-
}));
|
|
798
|
-
// Belief Systems - Derived Beliefs from Memory
|
|
799
|
-
// ============================================================================
|
|
800
|
-
/**
|
|
801
|
-
* Beliefs - Derived semantic beliefs extracted from memories
|
|
802
|
-
* Represents inferred decisions, preferences, constraints, failure causes
|
|
803
|
-
*/
|
|
804
|
-
export const beliefs = pgTable('beliefs', {
|
|
805
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
806
|
-
projectId: uuid('project_id').references(() => projects.id, { onDelete: 'cascade' }),
|
|
807
|
-
// Belief identification
|
|
808
|
-
beliefType: text('belief_type').notNull(),
|
|
809
|
-
statement: text('statement').notNull(),
|
|
810
|
-
normalizedKey: text('normalized_key').notNull(),
|
|
811
|
-
// Confidence and decay
|
|
812
|
-
confidence: integer('confidence').default(50), // 0-100
|
|
813
|
-
beliefDecayRate: integer('belief_decay_rate').default(30), // days half-life
|
|
814
|
-
lastConfirmedAt: timestamp('last_confirmed_at'),
|
|
815
|
-
sourceCount: integer('source_count').default(1),
|
|
816
|
-
// Status
|
|
817
|
-
status: text('status').default('active'),
|
|
818
|
-
// Context and evidence
|
|
819
|
-
reason: text('reason'),
|
|
820
|
-
context: text('context'),
|
|
821
|
-
evidenceSummary: text('evidence_summary'),
|
|
822
|
-
// Metadata (stores edges, derivation info)
|
|
823
|
-
metadata: jsonb('metadata'),
|
|
824
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
825
|
-
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
826
|
-
}, (table) => [
|
|
827
|
-
index('beliefs_project_idx').on(table.projectId),
|
|
828
|
-
index('beliefs_type_idx').on(table.beliefType),
|
|
829
|
-
index('beliefs_status_idx').on(table.status),
|
|
830
|
-
index('beliefs_confidence_idx').on(table.confidence),
|
|
831
|
-
index('beliefs_normalized_key_idx').on(table.normalizedKey),
|
|
832
|
-
]);
|
|
833
|
-
/**
|
|
834
|
-
* Belief Memory Sources - Links beliefs to source memories
|
|
835
|
-
*/
|
|
836
|
-
export const beliefMemorySources = pgTable('belief_memory_sources', {
|
|
837
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
838
|
-
beliefId: uuid('belief_id').references(() => beliefs.id, { onDelete: 'cascade' }).notNull(),
|
|
839
|
-
memoryId: uuid('memory_id').references(() => memories.id, { onDelete: 'cascade' }).notNull(),
|
|
840
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
841
|
-
}, (table) => [
|
|
842
|
-
index('belief_sources_belief_idx').on(table.beliefId),
|
|
843
|
-
index('belief_sources_memory_idx').on(table.memoryId),
|
|
844
|
-
]);
|
|
845
|
-
/**
|
|
846
|
-
* Belief Edges - Relationships between beliefs
|
|
847
|
-
*/
|
|
848
|
-
export const beliefEdges = pgTable('belief_edges', {
|
|
849
|
-
id: uuid('id').primaryKey().defaultRandom(),
|
|
850
|
-
fromBeliefId: uuid('from_belief_id').references(() => beliefs.id, { onDelete: 'cascade' }).notNull(),
|
|
851
|
-
toBeliefId: uuid('to_belief_id').references(() => beliefs.id, { onDelete: 'cascade' }).notNull(),
|
|
852
|
-
edgeType: text('edge_type').notNull(),
|
|
853
|
-
metadata: jsonb('metadata'),
|
|
854
|
-
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
855
|
-
}, (table) => [
|
|
856
|
-
index('belief_edges_from_idx').on(table.fromBeliefId),
|
|
857
|
-
index('belief_edges_to_idx').on(table.toBeliefId),
|
|
858
|
-
]);
|
|
859
|
-
//# sourceMappingURL=schema.js.map
|