@atomicmemory/core 1.0.0
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/CHANGELOG.md +27 -0
- package/LICENSE +201 -0
- package/README.md +314 -0
- package/dist/app/bind-ephemeral.d.ts +18 -0
- package/dist/app/bind-ephemeral.js +22 -0
- package/dist/app/cors-headers.d.ts +12 -0
- package/dist/app/cors-headers.js +18 -0
- package/dist/app/create-app.d.ts +25 -0
- package/dist/app/create-app.js +156 -0
- package/dist/app/runtime-config-route-snapshot.d.ts +27 -0
- package/dist/app/runtime-config-route-snapshot.js +27 -0
- package/dist/app/runtime-container.d.ts +281 -0
- package/dist/app/runtime-container.js +297 -0
- package/dist/app/startup-checks.d.ts +28 -0
- package/dist/app/startup-checks.js +45 -0
- package/dist/bin.d.ts +17 -0
- package/dist/bin.js +128 -0
- package/dist/config.d.ts +680 -0
- package/dist/config.js +808 -0
- package/dist/db/agent-trust-repository.d.ts +49 -0
- package/dist/db/agent-trust-repository.js +66 -0
- package/dist/db/belief-edges-repository.d.ts +68 -0
- package/dist/db/belief-edges-repository.js +124 -0
- package/dist/db/claim-repository.d.ts +6 -0
- package/dist/db/claim-repository.js +4 -0
- package/dist/db/contradictions-repository.d.ts +56 -0
- package/dist/db/contradictions-repository.js +88 -0
- package/dist/db/document-chunk-repository.d.ts +48 -0
- package/dist/db/document-chunk-repository.js +145 -0
- package/dist/db/document-chunk-types.d.ts +35 -0
- package/dist/db/document-chunk-types.js +9 -0
- package/dist/db/document-list-cursor.d.ts +45 -0
- package/dist/db/document-list-cursor.js +111 -0
- package/dist/db/document-list-repository.d.ts +103 -0
- package/dist/db/document-list-repository.js +204 -0
- package/dist/db/entity-cards-repository.d.ts +37 -0
- package/dist/db/entity-cards-repository.js +46 -0
- package/dist/db/entity-values-repository.d.ts +26 -0
- package/dist/db/entity-values-repository.js +57 -0
- package/dist/db/link-repository.d.ts +30 -0
- package/dist/db/link-repository.js +54 -0
- package/dist/db/memory-repository.d.ts +163 -0
- package/dist/db/memory-repository.js +232 -0
- package/dist/db/migrate.d.ts +6 -0
- package/dist/db/migrate.js +36 -0
- package/dist/db/mmr.d.ts +14 -0
- package/dist/db/mmr.js +57 -0
- package/dist/db/passport-feed-repository.d.ts +91 -0
- package/dist/db/passport-feed-repository.js +198 -0
- package/dist/db/pg-episode-store.d.ts +19 -0
- package/dist/db/pg-episode-store.js +17 -0
- package/dist/db/pg-link-store.d.ts +17 -0
- package/dist/db/pg-link-store.js +14 -0
- package/dist/db/pg-memory-store.d.ts +68 -0
- package/dist/db/pg-memory-store.js +53 -0
- package/dist/db/pg-recap-store.d.ts +13 -0
- package/dist/db/pg-recap-store.js +19 -0
- package/dist/db/pg-representation-store.d.ts +17 -0
- package/dist/db/pg-representation-store.js +17 -0
- package/dist/db/pg-search-store.d.ts +29 -0
- package/dist/db/pg-search-store.js +47 -0
- package/dist/db/pool.d.ts +5 -0
- package/dist/db/pool.js +21 -0
- package/dist/db/ppr.d.ts +56 -0
- package/dist/db/ppr.js +178 -0
- package/dist/db/query-helpers.d.ts +44 -0
- package/dist/db/query-helpers.js +60 -0
- package/dist/db/raw-doc-artifact-sync.d.ts +128 -0
- package/dist/db/raw-doc-artifact-sync.js +259 -0
- package/dist/db/raw-document-blob-repository.d.ts +148 -0
- package/dist/db/raw-document-blob-repository.js +300 -0
- package/dist/db/raw-document-repository.d.ts +104 -0
- package/dist/db/raw-document-repository.js +410 -0
- package/dist/db/raw-document-status-repository.d.ts +122 -0
- package/dist/db/raw-document-status-repository.js +183 -0
- package/dist/db/raw-document-types.d.ts +236 -0
- package/dist/db/raw-document-types.js +10 -0
- package/dist/db/raw-storage-reconciliation-repository.d.ts +110 -0
- package/dist/db/raw-storage-reconciliation-repository.js +200 -0
- package/dist/db/reflection-jobs-repository.d.ts +33 -0
- package/dist/db/reflection-jobs-repository.js +48 -0
- package/dist/db/reflections-repository.d.ts +41 -0
- package/dist/db/reflections-repository.js +83 -0
- package/dist/db/repository-claims.d.ts +141 -0
- package/dist/db/repository-claims.js +376 -0
- package/dist/db/repository-deferred-audn.d.ts +33 -0
- package/dist/db/repository-deferred-audn.js +69 -0
- package/dist/db/repository-document-delete.d.ts +53 -0
- package/dist/db/repository-document-delete.js +156 -0
- package/dist/db/repository-entities.d.ts +114 -0
- package/dist/db/repository-entities.js +317 -0
- package/dist/db/repository-entity-attributes.d.ts +41 -0
- package/dist/db/repository-entity-attributes.js +65 -0
- package/dist/db/repository-entity-graph.d.ts +32 -0
- package/dist/db/repository-entity-graph.js +87 -0
- package/dist/db/repository-first-mentions.d.ts +41 -0
- package/dist/db/repository-first-mentions.js +79 -0
- package/dist/db/repository-lessons.d.ts +51 -0
- package/dist/db/repository-lessons.js +90 -0
- package/dist/db/repository-links.d.ts +26 -0
- package/dist/db/repository-links.js +105 -0
- package/dist/db/repository-observation.d.ts +26 -0
- package/dist/db/repository-observation.js +51 -0
- package/dist/db/repository-read.d.ts +56 -0
- package/dist/db/repository-read.js +271 -0
- package/dist/db/repository-recaps.d.ts +59 -0
- package/dist/db/repository-recaps.js +158 -0
- package/dist/db/repository-representations.d.ts +48 -0
- package/dist/db/repository-representations.js +162 -0
- package/dist/db/repository-temporal-state.d.ts +35 -0
- package/dist/db/repository-temporal-state.js +46 -0
- package/dist/db/repository-tll.d.ts +88 -0
- package/dist/db/repository-tll.js +179 -0
- package/dist/db/repository-types.d.ts +313 -0
- package/dist/db/repository-types.js +142 -0
- package/dist/db/repository-user-profiles.d.ts +17 -0
- package/dist/db/repository-user-profiles.js +28 -0
- package/dist/db/repository-vector-search.d.ts +33 -0
- package/dist/db/repository-vector-search.js +373 -0
- package/dist/db/repository-wipe.d.ts +34 -0
- package/dist/db/repository-wipe.js +94 -0
- package/dist/db/repository-write.d.ts +61 -0
- package/dist/db/repository-write.js +279 -0
- package/dist/db/schema.sql +1355 -0
- package/dist/db/storage-artifact-delete-tx.d.ts +56 -0
- package/dist/db/storage-artifact-delete-tx.js +123 -0
- package/dist/db/storage-artifact-providers.d.ts +21 -0
- package/dist/db/storage-artifact-providers.js +21 -0
- package/dist/db/storage-artifact-recovery-repository.d.ts +66 -0
- package/dist/db/storage-artifact-recovery-repository.js +58 -0
- package/dist/db/storage-artifact-repository.d.ts +329 -0
- package/dist/db/storage-artifact-repository.js +497 -0
- package/dist/db/stores.d.ts +220 -0
- package/dist/db/stores.js +12 -0
- package/dist/db/summaries-repository.d.ts +74 -0
- package/dist/db/summaries-repository.js +125 -0
- package/dist/eval/beam-10m-loader.d.ts +98 -0
- package/dist/eval/beam-10m-loader.js +128 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/middleware/require-bearer.d.ts +27 -0
- package/dist/middleware/require-bearer.js +60 -0
- package/dist/middleware/validate-response.d.ts +33 -0
- package/dist/middleware/validate-response.js +55 -0
- package/dist/middleware/validate.d.ts +43 -0
- package/dist/middleware/validate.js +85 -0
- package/dist/routes/agents.d.ts +13 -0
- package/dist/routes/agents.js +89 -0
- package/dist/routes/document-response-formatters.d.ts +98 -0
- package/dist/routes/document-response-formatters.js +243 -0
- package/dist/routes/documents.d.ts +74 -0
- package/dist/routes/documents.js +425 -0
- package/dist/routes/memories.d.ts +29 -0
- package/dist/routes/memories.js +725 -0
- package/dist/routes/memory-response-formatters.d.ts +179 -0
- package/dist/routes/memory-response-formatters.js +210 -0
- package/dist/routes/public-raw-storage-metadata.d.ts +54 -0
- package/dist/routes/public-raw-storage-metadata.js +56 -0
- package/dist/routes/reflect.d.ts +14 -0
- package/dist/routes/reflect.js +19 -0
- package/dist/routes/response-schema-map.d.ts +14 -0
- package/dist/routes/response-schema-map.js +69 -0
- package/dist/routes/route-errors.d.ts +12 -0
- package/dist/routes/route-errors.js +30 -0
- package/dist/routes/storage-error-handlers.d.ts +34 -0
- package/dist/routes/storage-error-handlers.js +185 -0
- package/dist/routes/storage-response-formatters.d.ts +44 -0
- package/dist/routes/storage-response-formatters.js +155 -0
- package/dist/routes/storage.d.ts +38 -0
- package/dist/routes/storage.js +369 -0
- package/dist/routes/upstream-provider-errors.d.ts +19 -0
- package/dist/routes/upstream-provider-errors.js +95 -0
- package/dist/schemas/agents.d.ts +79 -0
- package/dist/schemas/agents.js +126 -0
- package/dist/schemas/common.d.ts +110 -0
- package/dist/schemas/common.js +190 -0
- package/dist/schemas/document-list-responses.d.ts +102 -0
- package/dist/schemas/document-list-responses.js +87 -0
- package/dist/schemas/document-list-schemas.d.ts +123 -0
- package/dist/schemas/document-list-schemas.js +174 -0
- package/dist/schemas/document-response-schemas.d.ts +610 -0
- package/dist/schemas/document-response-schemas.js +264 -0
- package/dist/schemas/document-status-envelope.d.ts +48 -0
- package/dist/schemas/document-status-envelope.js +54 -0
- package/dist/schemas/documents.d.ts +292 -0
- package/dist/schemas/documents.js +449 -0
- package/dist/schemas/errors.d.ts +75 -0
- package/dist/schemas/errors.js +105 -0
- package/dist/schemas/memories.d.ts +378 -0
- package/dist/schemas/memories.js +542 -0
- package/dist/schemas/openapi.d.ts +24 -0
- package/dist/schemas/openapi.js +1038 -0
- package/dist/schemas/response-scalars.d.ts +10 -0
- package/dist/schemas/response-scalars.js +10 -0
- package/dist/schemas/responses.d.ts +536 -0
- package/dist/schemas/responses.js +350 -0
- package/dist/schemas/search-response-parts.d.ts +97 -0
- package/dist/schemas/search-response-parts.js +103 -0
- package/dist/schemas/storage-schemas.d.ts +175 -0
- package/dist/schemas/storage-schemas.js +277 -0
- package/dist/schemas/zod-setup.d.ts +15 -0
- package/dist/schemas/zod-setup.js +17 -0
- package/dist/server.d.ts +13 -0
- package/dist/server.js +57 -0
- package/dist/services/abstract-query-policy.d.ts +13 -0
- package/dist/services/abstract-query-policy.js +50 -0
- package/dist/services/affinity-clustering.d.ts +66 -0
- package/dist/services/affinity-clustering.js +125 -0
- package/dist/services/agentic-retrieval.d.ts +38 -0
- package/dist/services/agentic-retrieval.js +126 -0
- package/dist/services/answer-format.d.ts +56 -0
- package/dist/services/answer-format.js +118 -0
- package/dist/services/answer-rescue.d.ts +72 -0
- package/dist/services/answer-rescue.js +177 -0
- package/dist/services/answer-verifier.d.ts +24 -0
- package/dist/services/answer-verifier.js +73 -0
- package/dist/services/api-retry.d.ts +6 -0
- package/dist/services/api-retry.js +41 -0
- package/dist/services/assistant-turn-filter.d.ts +20 -0
- package/dist/services/assistant-turn-filter.js +69 -0
- package/dist/services/atomicmem-uri.d.ts +33 -0
- package/dist/services/atomicmem-uri.js +86 -0
- package/dist/services/audit-events.d.ts +54 -0
- package/dist/services/audit-events.js +56 -0
- package/dist/services/chunked-extraction.d.ts +21 -0
- package/dist/services/chunked-extraction.js +108 -0
- package/dist/services/claim-slotting.d.ts +27 -0
- package/dist/services/claim-slotting.js +38 -0
- package/dist/services/claude-code-llm.d.ts +19 -0
- package/dist/services/claude-code-llm.js +96 -0
- package/dist/services/composite-dedup.d.ts +50 -0
- package/dist/services/composite-dedup.js +153 -0
- package/dist/services/composite-grouping.d.ts +41 -0
- package/dist/services/composite-grouping.js +111 -0
- package/dist/services/composite-staleness.d.ts +20 -0
- package/dist/services/composite-staleness.js +50 -0
- package/dist/services/conciseness-preference.d.ts +14 -0
- package/dist/services/conciseness-preference.js +42 -0
- package/dist/services/conflict-policy.d.ts +20 -0
- package/dist/services/conflict-policy.js +335 -0
- package/dist/services/consensus-extraction.d.ts +39 -0
- package/dist/services/consensus-extraction.js +147 -0
- package/dist/services/consensus-validation.d.ts +52 -0
- package/dist/services/consensus-validation.js +206 -0
- package/dist/services/consolidation-service.d.ts +60 -0
- package/dist/services/consolidation-service.js +171 -0
- package/dist/services/content-detection.d.ts +18 -0
- package/dist/services/content-detection.js +25 -0
- package/dist/services/contradiction-surfacing.d.ts +62 -0
- package/dist/services/contradiction-surfacing.js +111 -0
- package/dist/services/cost-telemetry.d.ts +39 -0
- package/dist/services/cost-telemetry.js +58 -0
- package/dist/services/counter-evidence.d.ts +34 -0
- package/dist/services/counter-evidence.js +92 -0
- package/dist/services/current-state-ranking.d.ts +21 -0
- package/dist/services/current-state-ranking.js +152 -0
- package/dist/services/deferred-audn.d.ts +47 -0
- package/dist/services/deferred-audn.js +162 -0
- package/dist/services/document-chunker.d.ts +50 -0
- package/dist/services/document-chunker.js +153 -0
- package/dist/services/document-failure-markers.d.ts +91 -0
- package/dist/services/document-failure-markers.js +305 -0
- package/dist/services/document-indexer.d.ts +122 -0
- package/dist/services/document-indexer.js +405 -0
- package/dist/services/document-service.d.ts +245 -0
- package/dist/services/document-service.js +325 -0
- package/dist/services/document-upload-artifact-sync.d.ts +80 -0
- package/dist/services/document-upload-artifact-sync.js +162 -0
- package/dist/services/document-upload-beta2-recovery.d.ts +72 -0
- package/dist/services/document-upload-beta2-recovery.js +94 -0
- package/dist/services/document-upload.d.ts +44 -0
- package/dist/services/document-upload.js +353 -0
- package/dist/services/embedding.d.ts +57 -0
- package/dist/services/embedding.js +416 -0
- package/dist/services/entity-attribute-extractor.d.ts +34 -0
- package/dist/services/entity-attribute-extractor.js +117 -0
- package/dist/services/entity-card-synthesis.d.ts +54 -0
- package/dist/services/entity-card-synthesis.js +92 -0
- package/dist/services/entity-dedup.d.ts +9 -0
- package/dist/services/entity-dedup.js +14 -0
- package/dist/services/entity-graph.d.ts +17 -0
- package/dist/services/entity-graph.js +135 -0
- package/dist/services/entropy-gate.d.ts +52 -0
- package/dist/services/entropy-gate.js +56 -0
- package/dist/services/episode-fetcher.d.ts +47 -0
- package/dist/services/episode-fetcher.js +128 -0
- package/dist/services/event-anchor-facts.d.ts +8 -0
- package/dist/services/event-anchor-facts.js +205 -0
- package/dist/services/event-chain-detector.d.ts +52 -0
- package/dist/services/event-chain-detector.js +83 -0
- package/dist/services/extraction-cache.d.ts +9 -0
- package/dist/services/extraction-cache.js +54 -0
- package/dist/services/extraction-enrichment.d.ts +9 -0
- package/dist/services/extraction-enrichment.js +223 -0
- package/dist/services/extraction.d.ts +69 -0
- package/dist/services/extraction.js +596 -0
- package/dist/services/fact-normalization.d.ts +12 -0
- package/dist/services/fact-normalization.js +248 -0
- package/dist/services/filecoin-observability.d.ts +127 -0
- package/dist/services/filecoin-observability.js +200 -0
- package/dist/services/first-mention-service.d.ts +76 -0
- package/dist/services/first-mention-service.js +186 -0
- package/dist/services/hierarchical-retrieval.d.ts +49 -0
- package/dist/services/hierarchical-retrieval.js +50 -0
- package/dist/services/ingest-fact-pipeline.d.ts +32 -0
- package/dist/services/ingest-fact-pipeline.js +212 -0
- package/dist/services/ingest-post-write.d.ts +50 -0
- package/dist/services/ingest-post-write.js +117 -0
- package/dist/services/ingest-trace.d.ts +32 -0
- package/dist/services/ingest-trace.js +60 -0
- package/dist/services/input-sanitizer.d.ts +41 -0
- package/dist/services/input-sanitizer.js +135 -0
- package/dist/services/iterative-retrieval.d.ts +26 -0
- package/dist/services/iterative-retrieval.js +139 -0
- package/dist/services/keyword-expansion.d.ts +10 -0
- package/dist/services/keyword-expansion.js +26 -0
- package/dist/services/lesson-service.d.ts +68 -0
- package/dist/services/lesson-service.js +178 -0
- package/dist/services/literal-extractor.d.ts +16 -0
- package/dist/services/literal-extractor.js +74 -0
- package/dist/services/literal-list-protection.d.ts +17 -0
- package/dist/services/literal-list-protection.js +134 -0
- package/dist/services/literal-query-expansion.d.ts +20 -0
- package/dist/services/literal-query-expansion.js +181 -0
- package/dist/services/llm.d.ts +61 -0
- package/dist/services/llm.js +265 -0
- package/dist/services/memcell-projection.d.ts +17 -0
- package/dist/services/memcell-projection.js +41 -0
- package/dist/services/memory-audn.d.ts +43 -0
- package/dist/services/memory-audn.js +419 -0
- package/dist/services/memory-crud.d.ts +93 -0
- package/dist/services/memory-crud.js +255 -0
- package/dist/services/memory-ingest.d.ts +21 -0
- package/dist/services/memory-ingest.js +249 -0
- package/dist/services/memory-lifecycle.d.ts +75 -0
- package/dist/services/memory-lifecycle.js +108 -0
- package/dist/services/memory-lineage.d.ts +181 -0
- package/dist/services/memory-lineage.js +232 -0
- package/dist/services/memory-network.d.ts +40 -0
- package/dist/services/memory-network.js +75 -0
- package/dist/services/memory-search-types.d.ts +25 -0
- package/dist/services/memory-search-types.js +10 -0
- package/dist/services/memory-search.d.ts +48 -0
- package/dist/services/memory-search.js +505 -0
- package/dist/services/memory-service-types.d.ts +371 -0
- package/dist/services/memory-service-types.js +8 -0
- package/dist/services/memory-service.d.ts +152 -0
- package/dist/services/memory-service.js +225 -0
- package/dist/services/memory-storage.d.ts +33 -0
- package/dist/services/memory-storage.js +328 -0
- package/dist/services/msr-aggregator.d.ts +38 -0
- package/dist/services/msr-aggregator.js +97 -0
- package/dist/services/msr-detector.d.ts +35 -0
- package/dist/services/msr-detector.js +65 -0
- package/dist/services/namespace-retrieval.d.ts +60 -0
- package/dist/services/namespace-retrieval.js +180 -0
- package/dist/services/observation-date-extraction.d.ts +12 -0
- package/dist/services/observation-date-extraction.js +50 -0
- package/dist/services/observation-service.d.ts +27 -0
- package/dist/services/observation-service.js +84 -0
- package/dist/services/packaging-observability.d.ts +29 -0
- package/dist/services/packaging-observability.js +146 -0
- package/dist/services/query-expansion.d.ts +83 -0
- package/dist/services/query-expansion.js +242 -0
- package/dist/services/query-keyword-matches.d.ts +6 -0
- package/dist/services/query-keyword-matches.js +56 -0
- package/dist/services/query-term-visibility.d.ts +28 -0
- package/dist/services/query-term-visibility.js +100 -0
- package/dist/services/quick-extraction.d.ts +25 -0
- package/dist/services/quick-extraction.js +431 -0
- package/dist/services/quoted-entity-extraction.d.ts +10 -0
- package/dist/services/quoted-entity-extraction.js +161 -0
- package/dist/services/raw-storage-reconciler-backoff.d.ts +8 -0
- package/dist/services/raw-storage-reconciler-backoff.js +14 -0
- package/dist/services/raw-storage-reconciler-scheduler.d.ts +29 -0
- package/dist/services/raw-storage-reconciler-scheduler.js +43 -0
- package/dist/services/raw-storage-reconciler.d.ts +71 -0
- package/dist/services/raw-storage-reconciler.js +278 -0
- package/dist/services/recap-builder.d.ts +49 -0
- package/dist/services/recap-builder.js +157 -0
- package/dist/services/reflect-jobs.d.ts +23 -0
- package/dist/services/reflect-jobs.js +36 -0
- package/dist/services/reflect-prompts.d.ts +71 -0
- package/dist/services/reflect-prompts.js +99 -0
- package/dist/services/reflect-retrieval.d.ts +33 -0
- package/dist/services/reflect-retrieval.js +30 -0
- package/dist/services/reflect.d.ts +49 -0
- package/dist/services/reflect.js +84 -0
- package/dist/services/relative-temporal.d.ts +14 -0
- package/dist/services/relative-temporal.js +163 -0
- package/dist/services/relevance-policy.d.ts +37 -0
- package/dist/services/relevance-policy.js +109 -0
- package/dist/services/rerank.d.ts +32 -0
- package/dist/services/rerank.js +118 -0
- package/dist/services/reranker.d.ts +20 -0
- package/dist/services/reranker.js +99 -0
- package/dist/services/retrieval-channel-rules.d.ts +34 -0
- package/dist/services/retrieval-channel-rules.js +41 -0
- package/dist/services/retrieval-config-overlay.d.ts +36 -0
- package/dist/services/retrieval-config-overlay.js +44 -0
- package/dist/services/retrieval-format.d.ts +119 -0
- package/dist/services/retrieval-format.js +559 -0
- package/dist/services/retrieval-policy.d.ts +69 -0
- package/dist/services/retrieval-policy.js +275 -0
- package/dist/services/retrieval-profiles.d.ts +37 -0
- package/dist/services/retrieval-profiles.js +90 -0
- package/dist/services/retrieval-side-effects.d.ts +14 -0
- package/dist/services/retrieval-side-effects.js +26 -0
- package/dist/services/retrieval-trace.d.ts +108 -0
- package/dist/services/retrieval-trace.js +147 -0
- package/dist/services/rrf-fusion.d.ts +18 -0
- package/dist/services/rrf-fusion.js +34 -0
- package/dist/services/search-pipeline.d.ts +71 -0
- package/dist/services/search-pipeline.js +788 -0
- package/dist/services/session-date.d.ts +20 -0
- package/dist/services/session-date.js +61 -0
- package/dist/services/session-packaging.d.ts +53 -0
- package/dist/services/session-packaging.js +182 -0
- package/dist/services/session-summary-generator.d.ts +53 -0
- package/dist/services/session-summary-generator.js +134 -0
- package/dist/services/specialists/cr-specialist.d.ts +52 -0
- package/dist/services/specialists/cr-specialist.js +121 -0
- package/dist/services/specialists/dispatch.d.ts +53 -0
- package/dist/services/specialists/dispatch.js +102 -0
- package/dist/services/specialists/ie-ku-specialist.d.ts +37 -0
- package/dist/services/specialists/ie-ku-specialist.js +63 -0
- package/dist/services/specialists/msr-specialist.d.ts +61 -0
- package/dist/services/specialists/msr-specialist.js +162 -0
- package/dist/services/specialists/tr-specialist.d.ts +37 -0
- package/dist/services/specialists/tr-specialist.js +146 -0
- package/dist/services/storage-key-prefix.d.ts +42 -0
- package/dist/services/storage-key-prefix.js +45 -0
- package/dist/services/storage-put-recovery.d.ts +71 -0
- package/dist/services/storage-put-recovery.js +269 -0
- package/dist/services/storage-service-errors.d.ts +124 -0
- package/dist/services/storage-service-errors.js +189 -0
- package/dist/services/storage-service.d.ts +176 -0
- package/dist/services/storage-service.js +423 -0
- package/dist/services/subject-aware-ranking.d.ts +19 -0
- package/dist/services/subject-aware-ranking.js +161 -0
- package/dist/services/supplemental-extraction.d.ts +7 -0
- package/dist/services/supplemental-extraction.js +116 -0
- package/dist/services/tbc-execution.d.ts +49 -0
- package/dist/services/tbc-execution.js +284 -0
- package/dist/services/temporal-classifier.d.ts +56 -0
- package/dist/services/temporal-classifier.js +94 -0
- package/dist/services/temporal-endpoint-evidence.d.ts +12 -0
- package/dist/services/temporal-endpoint-evidence.js +313 -0
- package/dist/services/temporal-fingerprint.d.ts +6 -0
- package/dist/services/temporal-fingerprint.js +12 -0
- package/dist/services/temporal-format.d.ts +9 -0
- package/dist/services/temporal-format.js +21 -0
- package/dist/services/temporal-intent.d.ts +39 -0
- package/dist/services/temporal-intent.js +78 -0
- package/dist/services/temporal-query-constraints.d.ts +16 -0
- package/dist/services/temporal-query-constraints.js +107 -0
- package/dist/services/temporal-query-expansion.d.ts +14 -0
- package/dist/services/temporal-query-expansion.js +131 -0
- package/dist/services/temporal-rerank.d.ts +22 -0
- package/dist/services/temporal-rerank.js +47 -0
- package/dist/services/temporal-result-protection.d.ts +7 -0
- package/dist/services/temporal-result-protection.js +60 -0
- package/dist/services/temporal-state-write.d.ts +57 -0
- package/dist/services/temporal-state-write.js +45 -0
- package/dist/services/tiered-context.d.ts +87 -0
- package/dist/services/tiered-context.js +214 -0
- package/dist/services/tiered-loading.d.ts +88 -0
- package/dist/services/tiered-loading.js +263 -0
- package/dist/services/timeline-pack.d.ts +36 -0
- package/dist/services/timeline-pack.js +50 -0
- package/dist/services/timing.d.ts +13 -0
- package/dist/services/timing.js +72 -0
- package/dist/services/tll-augmentation.d.ts +20 -0
- package/dist/services/tll-augmentation.js +125 -0
- package/dist/services/tll-retrieval.d.ts +55 -0
- package/dist/services/tll-retrieval.js +101 -0
- package/dist/services/topic-abstraction.d.ts +36 -0
- package/dist/services/topic-abstraction.js +105 -0
- package/dist/services/trust-scoring.d.ts +43 -0
- package/dist/services/trust-scoring.js +89 -0
- package/dist/services/typed-belief-calculus.d.ts +126 -0
- package/dist/services/typed-belief-calculus.js +204 -0
- package/dist/services/upload-config.d.ts +34 -0
- package/dist/services/upload-config.js +23 -0
- package/dist/services/upload-decision.d.ts +65 -0
- package/dist/services/upload-decision.js +98 -0
- package/dist/services/upload-helpers.d.ts +107 -0
- package/dist/services/upload-helpers.js +148 -0
- package/dist/services/user-profile-builder.d.ts +22 -0
- package/dist/services/user-profile-builder.js +109 -0
- package/dist/services/voyage-embedding.d.ts +22 -0
- package/dist/services/voyage-embedding.js +77 -0
- package/dist/services/write-security.d.ts +31 -0
- package/dist/services/write-security.js +64 -0
- package/dist/storage/artifact-public-redaction.d.ts +34 -0
- package/dist/storage/artifact-public-redaction.js +83 -0
- package/dist/storage/cleanup.d.ts +103 -0
- package/dist/storage/cleanup.js +138 -0
- package/dist/storage/codec-factory.d.ts +17 -0
- package/dist/storage/codec-factory.js +33 -0
- package/dist/storage/codecs/aes-gcm-codec.d.ts +44 -0
- package/dist/storage/codecs/aes-gcm-codec.js +108 -0
- package/dist/storage/codecs/noop-codec.d.ts +16 -0
- package/dist/storage/codecs/noop-codec.js +23 -0
- package/dist/storage/factory.d.ts +44 -0
- package/dist/storage/factory.js +99 -0
- package/dist/storage/filecoin-cid-validation.d.ts +82 -0
- package/dist/storage/filecoin-cid-validation.js +122 -0
- package/dist/storage/filecoin-public-metadata.d.ts +73 -0
- package/dist/storage/filecoin-public-metadata.js +110 -0
- package/dist/storage/local-fs-store.d.ts +39 -0
- package/dist/storage/local-fs-store.js +145 -0
- package/dist/storage/pointer-uri-allowlist.d.ts +38 -0
- package/dist/storage/pointer-uri-allowlist.js +70 -0
- package/dist/storage/provider-metadata-projection.d.ts +27 -0
- package/dist/storage/provider-metadata-projection.js +68 -0
- package/dist/storage/providers/filecoin/backend.d.ts +42 -0
- package/dist/storage/providers/filecoin/backend.js +250 -0
- package/dist/storage/providers/filecoin/config.d.ts +70 -0
- package/dist/storage/providers/filecoin/config.js +275 -0
- package/dist/storage/providers/filecoin/errors.d.ts +45 -0
- package/dist/storage/providers/filecoin/errors.js +56 -0
- package/dist/storage/providers/filecoin/filecoin-pin-car.d.ts +78 -0
- package/dist/storage/providers/filecoin/filecoin-pin-car.js +155 -0
- package/dist/storage/providers/filecoin/filecoin-pin-client.d.ts +92 -0
- package/dist/storage/providers/filecoin/filecoin-pin-client.js +199 -0
- package/dist/storage/providers/filecoin/filecoin-pin-mapping.d.ts +58 -0
- package/dist/storage/providers/filecoin/filecoin-pin-mapping.js +103 -0
- package/dist/storage/providers/filecoin/filecoin-pin-timeout.d.ts +30 -0
- package/dist/storage/providers/filecoin/filecoin-pin-timeout.js +53 -0
- package/dist/storage/providers/filecoin/filecoin-pin-vendor.d.ts +111 -0
- package/dist/storage/providers/filecoin/filecoin-pin-vendor.js +87 -0
- package/dist/storage/providers/filecoin/hints.d.ts +71 -0
- package/dist/storage/providers/filecoin/hints.js +123 -0
- package/dist/storage/providers/filecoin/index.d.ts +51 -0
- package/dist/storage/providers/filecoin/index.js +103 -0
- package/dist/storage/providers/filecoin/ipfs-cid.d.ts +50 -0
- package/dist/storage/providers/filecoin/ipfs-cid.js +64 -0
- package/dist/storage/providers/filecoin/metadata.d.ts +72 -0
- package/dist/storage/providers/filecoin/metadata.js +137 -0
- package/dist/storage/providers/filecoin/piece-cid.d.ts +48 -0
- package/dist/storage/providers/filecoin/piece-cid.js +57 -0
- package/dist/storage/providers/filecoin/provider-client.d.ts +234 -0
- package/dist/storage/providers/filecoin/provider-client.js +27 -0
- package/dist/storage/providers/filecoin/readiness.d.ts +62 -0
- package/dist/storage/providers/filecoin/readiness.js +85 -0
- package/dist/storage/providers/filecoin/retriever.d.ts +82 -0
- package/dist/storage/providers/filecoin/retriever.js +63 -0
- package/dist/storage/providers/filecoin/skeleton-client.d.ts +36 -0
- package/dist/storage/providers/filecoin/skeleton-client.js +55 -0
- package/dist/storage/providers/filecoin/synapse-client.d.ts +169 -0
- package/dist/storage/providers/filecoin/synapse-client.js +343 -0
- package/dist/storage/providers/filecoin/synapse-construction.d.ts +26 -0
- package/dist/storage/providers/filecoin/synapse-construction.js +47 -0
- package/dist/storage/providers/filecoin/synapse-error-mapping.d.ts +23 -0
- package/dist/storage/providers/filecoin/synapse-error-mapping.js +49 -0
- package/dist/storage/providers/filecoin/synapse-readiness.d.ts +37 -0
- package/dist/storage/providers/filecoin/synapse-readiness.js +231 -0
- package/dist/storage/providers/filecoin/uri.d.ts +49 -0
- package/dist/storage/providers/filecoin/uri.js +84 -0
- package/dist/storage/providers/filecoin/verified-fetch-lifecycle.d.ts +77 -0
- package/dist/storage/providers/filecoin/verified-fetch-lifecycle.js +196 -0
- package/dist/storage/providers/filecoin/verified-fetch-retriever.d.ts +54 -0
- package/dist/storage/providers/filecoin/verified-fetch-retriever.js +81 -0
- package/dist/storage/providers/filecoin/verified-fetch-vendor.d.ts +71 -0
- package/dist/storage/providers/filecoin/verified-fetch-vendor.js +94 -0
- package/dist/storage/raw-content-codec.d.ts +89 -0
- package/dist/storage/raw-content-codec.js +47 -0
- package/dist/storage/raw-content-store-backend-adapter.d.ts +28 -0
- package/dist/storage/raw-content-store-backend-adapter.js +67 -0
- package/dist/storage/raw-content-store.d.ts +228 -0
- package/dist/storage/raw-content-store.js +27 -0
- package/dist/storage/s3-store.d.ts +42 -0
- package/dist/storage/s3-store.js +181 -0
- package/dist/storage/storage-backend-registry.d.ts +58 -0
- package/dist/storage/storage-backend-registry.js +56 -0
- package/dist/storage/storage-backend.d.ts +82 -0
- package/dist/storage/storage-backend.js +14 -0
- package/dist/storage/storage-capabilities.d.ts +56 -0
- package/dist/storage/storage-capabilities.js +170 -0
- package/dist/storage/store-registry.d.ts +67 -0
- package/dist/storage/store-registry.js +77 -0
- package/dist/vector-math.d.ts +15 -0
- package/dist/vector-math.js +31 -0
- package/dist/xml-escape.d.ts +5 -0
- package/dist/xml-escape.js +7 -0
- package/openapi.json +15395 -0
- package/openapi.yaml +10794 -0
- package/package.json +119 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-aware temporal evidence formatting.
|
|
3
|
+
*
|
|
4
|
+
* Produces compact date-bearing evidence blocks for temporal questions. For
|
|
5
|
+
* repeated-event comparisons it emits explicit first/second endpoints; for
|
|
6
|
+
* broader temporal questions it emits a small set of high-overlap candidate
|
|
7
|
+
* memories with their dates.
|
|
8
|
+
*/
|
|
9
|
+
import { formatDateLabel, formatDuration } from './temporal-format.js';
|
|
10
|
+
const REPEATED_EVENT_QUERY = /\bbetween\b[\s\S]*\bfirst\b[\s\S]*\bsecond\b|\bfirst\b[\s\S]*\bsecond\b/i;
|
|
11
|
+
const TEMPORAL_QUERY = /\b(when|how long|how many months|how many years|how many weeks|how many days|between|before|after|as of|recently)\b/i;
|
|
12
|
+
const DURATION_QUERY = /\b(how long|how many months|how many years|how many weeks|how many days|between|before|after)\b/i;
|
|
13
|
+
const EVIDENCE_MAX_CHARS = 160;
|
|
14
|
+
const QUERY_TERM_MIN_LENGTH = 4;
|
|
15
|
+
const GENERAL_TEMPORAL_LIMIT = 3;
|
|
16
|
+
const STEM_SUFFIXES = ['ing', 'ed', 'es', 's'];
|
|
17
|
+
const SUBJECT_MATCH_BONUS = 2;
|
|
18
|
+
const EVENT_GROUP_MATCH_BONUS = 2;
|
|
19
|
+
const PLANNING_PENALTY = 3;
|
|
20
|
+
const DURATION_ENDPOINT_LIMIT = 2;
|
|
21
|
+
const PLANNING_MARKERS = [
|
|
22
|
+
'plan to', 'planned to', 'planning to', 'going to', 'will ', 'wants to',
|
|
23
|
+
'want to', 'thinking of', 'thinking about', 'considering', 'decided to make',
|
|
24
|
+
'make a new appointment', 'book a new appointment',
|
|
25
|
+
];
|
|
26
|
+
const QUERY_SUBJECT_STOP_WORDS = new Set([
|
|
27
|
+
'When', 'What', 'Where', 'Why', 'How', 'Who', 'Which',
|
|
28
|
+
'Did', 'Does', 'Do', 'Has', 'Have', 'Had',
|
|
29
|
+
'The', 'A', 'An', 'As', 'Of', 'And', 'Or',
|
|
30
|
+
'First', 'Second',
|
|
31
|
+
]);
|
|
32
|
+
const MONTH_NAMES = new Set([
|
|
33
|
+
'January', 'February', 'March', 'April', 'May', 'June',
|
|
34
|
+
'July', 'August', 'September', 'October', 'November', 'December',
|
|
35
|
+
]);
|
|
36
|
+
const QUERY_EVENT_STOP_WORDS = new Set([
|
|
37
|
+
'between', 'first', 'second', 'months', 'month', 'weeks', 'week',
|
|
38
|
+
'days', 'many', 'much', 'long', 'lapsed', 'elapsed', 'passed',
|
|
39
|
+
'what', 'when', 'where', 'which', 'with', 'from', 'that', 'this',
|
|
40
|
+
'before', 'after', 'recently', 'start', 'started', 'plan', 'planned',
|
|
41
|
+
'recent', 'current', 'present', 'did', 'does', 'have', 'been',
|
|
42
|
+
]);
|
|
43
|
+
const EVENT_SYNONYMS = {
|
|
44
|
+
appointment: ['appointment', 'appointments', 'check-up', 'checkup', 'check up', 'visit'],
|
|
45
|
+
doctor: ['doctor', "doctor's", 'doctors', 'doc', 'medical', 'health'],
|
|
46
|
+
};
|
|
47
|
+
const IRREGULAR_NORMALIZATION = {
|
|
48
|
+
won: 'win',
|
|
49
|
+
winning: 'win',
|
|
50
|
+
met: 'meet',
|
|
51
|
+
meeting: 'meet',
|
|
52
|
+
began: 'begin',
|
|
53
|
+
begun: 'begin',
|
|
54
|
+
started: 'start',
|
|
55
|
+
starting: 'start',
|
|
56
|
+
moved: 'move',
|
|
57
|
+
moving: 'move',
|
|
58
|
+
dated: 'date',
|
|
59
|
+
dating: 'date',
|
|
60
|
+
adopted: 'adopt',
|
|
61
|
+
adopting: 'adopt',
|
|
62
|
+
adoption: 'adopt',
|
|
63
|
+
expanded: 'expand',
|
|
64
|
+
expanding: 'expand',
|
|
65
|
+
presence: 'present',
|
|
66
|
+
};
|
|
67
|
+
/** Reverse index: each synonym → its canonical key. Built once at module load. */
|
|
68
|
+
const SYNONYM_TO_CANONICAL = (() => {
|
|
69
|
+
const index = new Map();
|
|
70
|
+
for (const [canonical, synonyms] of Object.entries(EVENT_SYNONYMS)) {
|
|
71
|
+
for (const synonym of synonyms)
|
|
72
|
+
index.set(synonym, canonical);
|
|
73
|
+
}
|
|
74
|
+
return index;
|
|
75
|
+
})();
|
|
76
|
+
export function buildTemporalEvidenceBlock(memories, query) {
|
|
77
|
+
const repeatedEventBlock = buildRepeatedEventEndpointBlock(memories, query);
|
|
78
|
+
if (repeatedEventBlock)
|
|
79
|
+
return repeatedEventBlock;
|
|
80
|
+
return buildGeneralTemporalEvidenceBlock(memories, query);
|
|
81
|
+
}
|
|
82
|
+
/** Build endpoint lines for repeated-event temporal comparisons. */
|
|
83
|
+
export function buildRepeatedEventEndpointBlock(memories, query) {
|
|
84
|
+
if (!isRepeatedEventQuery(query))
|
|
85
|
+
return '';
|
|
86
|
+
const conceptGroups = extractEventConceptGroups(query);
|
|
87
|
+
if (conceptGroups.length === 0)
|
|
88
|
+
return '';
|
|
89
|
+
const candidates = findEndpointCandidates(memories, conceptGroups);
|
|
90
|
+
const endpoints = selectDistinctDateEndpoints(candidates);
|
|
91
|
+
if (endpoints.length < 2)
|
|
92
|
+
return '';
|
|
93
|
+
const [first, second] = endpoints;
|
|
94
|
+
const days = diffDays(first.memory.created_at, second.memory.created_at);
|
|
95
|
+
return [
|
|
96
|
+
'Repeated event endpoints:',
|
|
97
|
+
formatEndpointLine('first matching event', first),
|
|
98
|
+
formatEndpointLine('second matching event', second),
|
|
99
|
+
`- elapsed between endpoints: ${formatDuration(days)}`,
|
|
100
|
+
].join('\n');
|
|
101
|
+
}
|
|
102
|
+
function isRepeatedEventQuery(query) {
|
|
103
|
+
return REPEATED_EVENT_QUERY.test(query.toLowerCase());
|
|
104
|
+
}
|
|
105
|
+
function buildGeneralTemporalEvidenceBlock(memories, query) {
|
|
106
|
+
if (!TEMPORAL_QUERY.test(query.toLowerCase()))
|
|
107
|
+
return '';
|
|
108
|
+
const queryTerms = extractGeneralTemporalTerms(query);
|
|
109
|
+
const subjectTerms = extractQuerySubjects(query);
|
|
110
|
+
const conceptGroups = extractEventConceptGroups(query);
|
|
111
|
+
if (queryTerms.length === 0)
|
|
112
|
+
return '';
|
|
113
|
+
const candidates = selectGeneralTemporalCandidates(memories, queryTerms, subjectTerms, conceptGroups);
|
|
114
|
+
if (candidates.length === 0)
|
|
115
|
+
return '';
|
|
116
|
+
const endpointLines = buildGeneralDurationEndpointLines(candidates, query);
|
|
117
|
+
if (endpointLines.length > 0) {
|
|
118
|
+
return ['Temporal evidence candidates:', ...endpointLines].join('\n');
|
|
119
|
+
}
|
|
120
|
+
return [
|
|
121
|
+
'Temporal evidence candidates:',
|
|
122
|
+
...candidates.map((candidate) => formatEndpointLine('matching event', candidate)),
|
|
123
|
+
].join('\n');
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Extract one ConceptGroup per distinct canonical event term in the query.
|
|
127
|
+
* Plural and synonym forms collapse to the same group via SYNONYM_TO_CANONICAL;
|
|
128
|
+
* unknown terms become singleton groups.
|
|
129
|
+
*/
|
|
130
|
+
function extractEventConceptGroups(query) {
|
|
131
|
+
const source = extractOrdinalClauses(query);
|
|
132
|
+
const rawTerms = extractTemporalTerms(source);
|
|
133
|
+
const seenCanonicals = new Set();
|
|
134
|
+
const groups = [];
|
|
135
|
+
for (const term of rawTerms) {
|
|
136
|
+
const canonical = SYNONYM_TO_CANONICAL.get(term);
|
|
137
|
+
if (canonical) {
|
|
138
|
+
if (!seenCanonicals.has(canonical)) {
|
|
139
|
+
seenCanonicals.add(canonical);
|
|
140
|
+
groups.push(EVENT_SYNONYMS[canonical]);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
groups.push([term]);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return groups;
|
|
148
|
+
}
|
|
149
|
+
function extractOrdinalClauses(query) {
|
|
150
|
+
const pieces = query.toLowerCase().split(/\b(?:first|second)\b/).slice(1);
|
|
151
|
+
return pieces.join(' ') || query;
|
|
152
|
+
}
|
|
153
|
+
function extractGeneralTemporalTerms(query) {
|
|
154
|
+
return extractTemporalTerms(query);
|
|
155
|
+
}
|
|
156
|
+
function extractTemporalTerms(query) {
|
|
157
|
+
return query
|
|
158
|
+
.toLowerCase()
|
|
159
|
+
.replace(/\b([a-z]+)'s\b/g, '$1')
|
|
160
|
+
.replace(/[^a-z0-9'\s-]/g, ' ')
|
|
161
|
+
.split(/\s+/)
|
|
162
|
+
.filter((term) => term.length >= QUERY_TERM_MIN_LENGTH)
|
|
163
|
+
.filter((term) => !QUERY_EVENT_STOP_WORDS.has(term));
|
|
164
|
+
}
|
|
165
|
+
function extractQuerySubjects(query) {
|
|
166
|
+
const subjectMatches = query.match(/\b[A-Z][a-z]+(?:'s)?\b/g) ?? [];
|
|
167
|
+
const normalized = subjectMatches
|
|
168
|
+
.map((subject) => subject.replace(/'s$/i, ''))
|
|
169
|
+
.filter((subject) => !QUERY_SUBJECT_STOP_WORDS.has(subject))
|
|
170
|
+
.filter((subject) => !MONTH_NAMES.has(subject));
|
|
171
|
+
return [...new Set(normalized.map((subject) => subject.toLowerCase()))];
|
|
172
|
+
}
|
|
173
|
+
function findEndpointCandidates(memories, conceptGroups) {
|
|
174
|
+
return memories
|
|
175
|
+
.map((memory) => scoreEndpointCandidate(memory, conceptGroups))
|
|
176
|
+
.filter((candidate) => candidate !== null)
|
|
177
|
+
.sort((left, right) => left.memory.created_at.getTime() - right.memory.created_at.getTime());
|
|
178
|
+
}
|
|
179
|
+
function selectGeneralTemporalCandidates(memories, queryTerms, subjectTerms, conceptGroups) {
|
|
180
|
+
return memories
|
|
181
|
+
.map((memory) => scoreGeneralTemporalCandidate(memory, queryTerms, subjectTerms, conceptGroups))
|
|
182
|
+
.filter((candidate) => candidate !== null)
|
|
183
|
+
.sort((left, right) => compareGeneralTemporalCandidates(left, right))
|
|
184
|
+
.slice(0, GENERAL_TEMPORAL_LIMIT);
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* A candidate qualifies only if every concept group in the query has at
|
|
188
|
+
* least one synonym present in the memory's content. Score is the number
|
|
189
|
+
* of groups matched (ties broken by date order downstream).
|
|
190
|
+
*/
|
|
191
|
+
function scoreEndpointCandidate(memory, conceptGroups) {
|
|
192
|
+
const content = memory.content.toLowerCase();
|
|
193
|
+
const matched = conceptGroups.filter((group) => group.some((synonym) => content.includes(synonym))).length;
|
|
194
|
+
if (matched < conceptGroups.length)
|
|
195
|
+
return null;
|
|
196
|
+
return { dateKey: formatDateLabel(memory.created_at), memory, score: matched };
|
|
197
|
+
}
|
|
198
|
+
function scoreGeneralTemporalCandidate(memory, queryTerms, subjectTerms, conceptGroups) {
|
|
199
|
+
const lowerContent = memory.content.toLowerCase();
|
|
200
|
+
const tokenSet = buildNormalizedTokenSet(memory.content);
|
|
201
|
+
const termMatches = queryTerms.reduce((total, term) => total + (tokenSet.has(normalizeTemporalTerm(term)) ? 1 : 0), 0);
|
|
202
|
+
const subjectMatches = countSubjectMatches(lowerContent, subjectTerms);
|
|
203
|
+
const eventGroupMatches = countMatchedEventGroups(lowerContent, conceptGroups);
|
|
204
|
+
const isPlanningLike = containsPlanningMarker(lowerContent);
|
|
205
|
+
const score = termMatches
|
|
206
|
+
+ (subjectMatches * SUBJECT_MATCH_BONUS)
|
|
207
|
+
+ (eventGroupMatches * EVENT_GROUP_MATCH_BONUS)
|
|
208
|
+
- (isPlanningLike ? PLANNING_PENALTY : 0);
|
|
209
|
+
if (score <= 0)
|
|
210
|
+
return null;
|
|
211
|
+
return {
|
|
212
|
+
dateKey: formatDateLabel(memory.created_at),
|
|
213
|
+
memory,
|
|
214
|
+
score,
|
|
215
|
+
subjectMatches,
|
|
216
|
+
eventGroupMatches,
|
|
217
|
+
isPlanningLike,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
function compareGeneralTemporalCandidates(left, right) {
|
|
221
|
+
if (left.score !== right.score)
|
|
222
|
+
return right.score - left.score;
|
|
223
|
+
if (left.eventGroupMatches !== right.eventGroupMatches) {
|
|
224
|
+
return right.eventGroupMatches - left.eventGroupMatches;
|
|
225
|
+
}
|
|
226
|
+
if (left.subjectMatches !== right.subjectMatches) {
|
|
227
|
+
return right.subjectMatches - left.subjectMatches;
|
|
228
|
+
}
|
|
229
|
+
if (left.isPlanningLike !== right.isPlanningLike) {
|
|
230
|
+
return left.isPlanningLike ? 1 : -1;
|
|
231
|
+
}
|
|
232
|
+
return left.memory.created_at.getTime() - right.memory.created_at.getTime();
|
|
233
|
+
}
|
|
234
|
+
function buildNormalizedTokenSet(content) {
|
|
235
|
+
return new Set(content
|
|
236
|
+
.toLowerCase()
|
|
237
|
+
.replace(/\b([a-z]+)'s\b/g, '$1')
|
|
238
|
+
.replace(/[^a-z0-9'\s-]/g, ' ')
|
|
239
|
+
.split(/\s+/)
|
|
240
|
+
.filter((token) => token.length >= QUERY_TERM_MIN_LENGTH)
|
|
241
|
+
.map(normalizeTemporalTerm));
|
|
242
|
+
}
|
|
243
|
+
function normalizeTemporalTerm(term) {
|
|
244
|
+
const irregular = IRREGULAR_NORMALIZATION[term];
|
|
245
|
+
if (irregular)
|
|
246
|
+
return irregular;
|
|
247
|
+
for (const suffix of STEM_SUFFIXES) {
|
|
248
|
+
if (term.length > suffix.length + 2 && term.endsWith(suffix)) {
|
|
249
|
+
return term.slice(0, -suffix.length);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return term;
|
|
253
|
+
}
|
|
254
|
+
function buildGeneralDurationEndpointLines(candidates, query) {
|
|
255
|
+
if (!DURATION_QUERY.test(query.toLowerCase()))
|
|
256
|
+
return [];
|
|
257
|
+
const selected = selectDurationEndpoints(candidates);
|
|
258
|
+
if (selected.length < DURATION_ENDPOINT_LIMIT)
|
|
259
|
+
return [];
|
|
260
|
+
return [
|
|
261
|
+
formatEndpointLine('earliest matching event', selected[0]),
|
|
262
|
+
formatEndpointLine('latest matching event', selected[1]),
|
|
263
|
+
`- elapsed between endpoints: ${formatDuration(diffDays(selected[0].memory.created_at, selected[1].memory.created_at))}`,
|
|
264
|
+
];
|
|
265
|
+
}
|
|
266
|
+
function selectDurationEndpoints(candidates) {
|
|
267
|
+
const stableCandidates = preferCompletedCandidates(candidates);
|
|
268
|
+
const byDate = new Map();
|
|
269
|
+
for (const candidate of stableCandidates) {
|
|
270
|
+
const existing = byDate.get(candidate.dateKey);
|
|
271
|
+
if (!existing || compareGeneralTemporalCandidates(candidate, existing) < 0) {
|
|
272
|
+
byDate.set(candidate.dateKey, candidate);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const distinct = [...byDate.values()].sort((left, right) => left.memory.created_at.getTime() - right.memory.created_at.getTime());
|
|
276
|
+
if (distinct.length < DURATION_ENDPOINT_LIMIT)
|
|
277
|
+
return [];
|
|
278
|
+
return [distinct[0], distinct[distinct.length - 1]];
|
|
279
|
+
}
|
|
280
|
+
function preferCompletedCandidates(candidates) {
|
|
281
|
+
const completed = candidates.filter((candidate) => !candidate.isPlanningLike);
|
|
282
|
+
return completed.length >= DURATION_ENDPOINT_LIMIT ? completed : candidates;
|
|
283
|
+
}
|
|
284
|
+
function countSubjectMatches(content, subjectTerms) {
|
|
285
|
+
return subjectTerms.reduce((total, subject) => total + (content.includes(subject) ? 1 : 0), 0);
|
|
286
|
+
}
|
|
287
|
+
function countMatchedEventGroups(content, conceptGroups) {
|
|
288
|
+
return conceptGroups.filter((group) => group.some((synonym) => content.includes(synonym))).length;
|
|
289
|
+
}
|
|
290
|
+
function containsPlanningMarker(content) {
|
|
291
|
+
return PLANNING_MARKERS.some((marker) => content.includes(marker));
|
|
292
|
+
}
|
|
293
|
+
function selectDistinctDateEndpoints(candidates) {
|
|
294
|
+
const byDate = new Map();
|
|
295
|
+
for (const candidate of candidates) {
|
|
296
|
+
const existing = byDate.get(candidate.dateKey);
|
|
297
|
+
if (!existing || candidate.score > existing.score)
|
|
298
|
+
byDate.set(candidate.dateKey, candidate);
|
|
299
|
+
}
|
|
300
|
+
return [...byDate.values()].sort((left, right) => left.memory.created_at.getTime() - right.memory.created_at.getTime()).slice(0, 2);
|
|
301
|
+
}
|
|
302
|
+
function formatEndpointLine(label, candidate) {
|
|
303
|
+
return `- ${label}: ${candidate.dateKey} — ${truncateEvidence(candidate.memory.content)}`;
|
|
304
|
+
}
|
|
305
|
+
function truncateEvidence(content) {
|
|
306
|
+
const normalized = content.replace(/\s+/g, ' ').trim();
|
|
307
|
+
if (normalized.length <= EVIDENCE_MAX_CHARS)
|
|
308
|
+
return normalized;
|
|
309
|
+
return `${normalized.slice(0, EVIDENCE_MAX_CHARS - 3)}...`;
|
|
310
|
+
}
|
|
311
|
+
function diffDays(first, second) {
|
|
312
|
+
return Math.round((second.getTime() - first.getTime()) / 86400000);
|
|
313
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized content fingerprints for temporal retrieval protection.
|
|
3
|
+
* Different rows can duplicate the same event text, so protection needs
|
|
4
|
+
* to reason about content identity, not row identity.
|
|
5
|
+
*/
|
|
6
|
+
export declare function buildTemporalFingerprint(content: string): string;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Normalized content fingerprints for temporal retrieval protection.
|
|
3
|
+
* Different rows can duplicate the same event text, so protection needs
|
|
4
|
+
* to reason about content identity, not row identity.
|
|
5
|
+
*/
|
|
6
|
+
export function buildTemporalFingerprint(content) {
|
|
7
|
+
return content
|
|
8
|
+
.replace(/^As of [^,]+,?\s*/i, '')
|
|
9
|
+
.replace(/[^a-z0-9]+/gi, ' ')
|
|
10
|
+
.trim()
|
|
11
|
+
.toLowerCase();
|
|
12
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared temporal formatting helpers.
|
|
3
|
+
*
|
|
4
|
+
* Used by retrieval-format and temporal-endpoint-evidence to render the
|
|
5
|
+
* same date keys and duration strings without each file maintaining its
|
|
6
|
+
* own copy.
|
|
7
|
+
*/
|
|
8
|
+
export declare function formatDateLabel(date: Date): string;
|
|
9
|
+
export declare function formatDuration(days: number): string;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared temporal formatting helpers.
|
|
3
|
+
*
|
|
4
|
+
* Used by retrieval-format and temporal-endpoint-evidence to render the
|
|
5
|
+
* same date keys and duration strings without each file maintaining its
|
|
6
|
+
* own copy.
|
|
7
|
+
*/
|
|
8
|
+
const DAYS_PER_WEEK = 7;
|
|
9
|
+
const DAYS_PER_MONTH = 30;
|
|
10
|
+
export function formatDateLabel(date) {
|
|
11
|
+
return date.toISOString().slice(0, 10);
|
|
12
|
+
}
|
|
13
|
+
export function formatDuration(days) {
|
|
14
|
+
if (days < DAYS_PER_WEEK)
|
|
15
|
+
return `${days} day${days !== 1 ? 's' : ''}`;
|
|
16
|
+
const weeks = Math.round(days / DAYS_PER_WEEK);
|
|
17
|
+
if (days < DAYS_PER_MONTH)
|
|
18
|
+
return `~${weeks} week${weeks !== 1 ? 's' : ''} (${days} days)`;
|
|
19
|
+
const months = Math.round(days / DAYS_PER_MONTH);
|
|
20
|
+
return `~${months} month${months !== 1 ? 's' : ''} (${days} days)`;
|
|
21
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BEAM v38: read-time temporal intent classifier.
|
|
3
|
+
*
|
|
4
|
+
* Pure regex/keyword classification — no LLM call, no DB lookup.
|
|
5
|
+
* Used by `memory-search.ts` to decide whether to rerank candidates
|
|
6
|
+
* by `state_key` activity (CURRENT_STATE) or leave ordering alone.
|
|
7
|
+
*
|
|
8
|
+
* Scope: only CURRENT_STATE is "live" today — the other labels are
|
|
9
|
+
* recorded for observability but produce no rerank. Keeping the surface
|
|
10
|
+
* narrow avoids speculative knobs while leaving room to grow.
|
|
11
|
+
*/
|
|
12
|
+
/** Intent labels recognized at read time. */
|
|
13
|
+
export declare enum TemporalIntent {
|
|
14
|
+
/**
|
|
15
|
+
* "What is X now?" / "Where do I live?" — answer should reflect the
|
|
16
|
+
* active state. Triggers the state_key rerank.
|
|
17
|
+
*/
|
|
18
|
+
CURRENT_STATE = "current_state",
|
|
19
|
+
/**
|
|
20
|
+
* "What was X in March?" / "What was my salary last year?" — answer
|
|
21
|
+
* needs a snapshot at a past time. No rerank today; reserved.
|
|
22
|
+
*/
|
|
23
|
+
HISTORICAL_AT_TIME = "historical_at_time",
|
|
24
|
+
/**
|
|
25
|
+
* "How long have I had X?" — duration question. No rerank today.
|
|
26
|
+
*/
|
|
27
|
+
DURATION = "duration",
|
|
28
|
+
/** Everything else — no temporal intent inferred. */
|
|
29
|
+
NONE = "none"
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Classify a query into a TemporalIntent. Order matters:
|
|
33
|
+
* - HISTORICAL and DURATION are tested first because they may share
|
|
34
|
+
* phrasing ("how long have I lived…" reads like duration even if
|
|
35
|
+
* "current" appears in the question).
|
|
36
|
+
* - CURRENT_STATE is the catch-all for active-state phrasings.
|
|
37
|
+
* - Everything else returns NONE.
|
|
38
|
+
*/
|
|
39
|
+
export declare function classifyTemporalIntent(query: string): TemporalIntent;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* BEAM v38: read-time temporal intent classifier.
|
|
3
|
+
*
|
|
4
|
+
* Pure regex/keyword classification — no LLM call, no DB lookup.
|
|
5
|
+
* Used by `memory-search.ts` to decide whether to rerank candidates
|
|
6
|
+
* by `state_key` activity (CURRENT_STATE) or leave ordering alone.
|
|
7
|
+
*
|
|
8
|
+
* Scope: only CURRENT_STATE is "live" today — the other labels are
|
|
9
|
+
* recorded for observability but produce no rerank. Keeping the surface
|
|
10
|
+
* narrow avoids speculative knobs while leaving room to grow.
|
|
11
|
+
*/
|
|
12
|
+
/** Intent labels recognized at read time. */
|
|
13
|
+
export var TemporalIntent;
|
|
14
|
+
(function (TemporalIntent) {
|
|
15
|
+
/**
|
|
16
|
+
* "What is X now?" / "Where do I live?" — answer should reflect the
|
|
17
|
+
* active state. Triggers the state_key rerank.
|
|
18
|
+
*/
|
|
19
|
+
TemporalIntent["CURRENT_STATE"] = "current_state";
|
|
20
|
+
/**
|
|
21
|
+
* "What was X in March?" / "What was my salary last year?" — answer
|
|
22
|
+
* needs a snapshot at a past time. No rerank today; reserved.
|
|
23
|
+
*/
|
|
24
|
+
TemporalIntent["HISTORICAL_AT_TIME"] = "historical_at_time";
|
|
25
|
+
/**
|
|
26
|
+
* "How long have I had X?" — duration question. No rerank today.
|
|
27
|
+
*/
|
|
28
|
+
TemporalIntent["DURATION"] = "duration";
|
|
29
|
+
/** Everything else — no temporal intent inferred. */
|
|
30
|
+
TemporalIntent["NONE"] = "none";
|
|
31
|
+
})(TemporalIntent || (TemporalIntent = {}));
|
|
32
|
+
const HISTORICAL_AT_TIME_PATTERNS = [
|
|
33
|
+
/\bwhat was (?:my|the|his|her|their)\b/,
|
|
34
|
+
/\bin (?:january|february|march|april|may|june|july|august|september|october|november|december)\b/,
|
|
35
|
+
/\b(?:last|previous) (?:year|month|week|quarter)\b/,
|
|
36
|
+
/\bback in\b/,
|
|
37
|
+
/\bduring (?:the\s+)?\d{4}\b/,
|
|
38
|
+
/\bas of\b/,
|
|
39
|
+
/\bbefore (?:switching|moving|changing|leaving)\b/,
|
|
40
|
+
];
|
|
41
|
+
const DURATION_PATTERNS = [
|
|
42
|
+
/\bhow long (?:have|has|did|do)\b/,
|
|
43
|
+
/\bfor how long\b/,
|
|
44
|
+
/\b(?:since|over) the (?:past|last)\b/,
|
|
45
|
+
/\bduration of\b/,
|
|
46
|
+
];
|
|
47
|
+
const CURRENT_STATE_PATTERNS = [
|
|
48
|
+
/\bcurrent(?:ly)?\b/,
|
|
49
|
+
/\b(?:right )?now\b/,
|
|
50
|
+
/\btoday\b/,
|
|
51
|
+
/\bat (?:the )?(?:moment|present)\b/,
|
|
52
|
+
/\bwhere do (?:i|you|we) live\b/,
|
|
53
|
+
/\bwhat(?:'|\s)?s? (?:my|your|his|her|their) current\b/,
|
|
54
|
+
/\bwhat (?:is|are) (?:my|your|his|her|their) (?:current|now)\b/,
|
|
55
|
+
/\bwhere (?:am|are) (?:i|you|we) (?:living|working|based)\b/,
|
|
56
|
+
/\b(?:as of|by) (?:today|now)\b/,
|
|
57
|
+
];
|
|
58
|
+
/**
|
|
59
|
+
* Classify a query into a TemporalIntent. Order matters:
|
|
60
|
+
* - HISTORICAL and DURATION are tested first because they may share
|
|
61
|
+
* phrasing ("how long have I lived…" reads like duration even if
|
|
62
|
+
* "current" appears in the question).
|
|
63
|
+
* - CURRENT_STATE is the catch-all for active-state phrasings.
|
|
64
|
+
* - Everything else returns NONE.
|
|
65
|
+
*/
|
|
66
|
+
export function classifyTemporalIntent(query) {
|
|
67
|
+
const normalized = query.toLowerCase();
|
|
68
|
+
if (DURATION_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
69
|
+
return TemporalIntent.DURATION;
|
|
70
|
+
}
|
|
71
|
+
if (HISTORICAL_AT_TIME_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
72
|
+
return TemporalIntent.HISTORICAL_AT_TIME;
|
|
73
|
+
}
|
|
74
|
+
if (CURRENT_STATE_PATTERNS.some((pattern) => pattern.test(normalized))) {
|
|
75
|
+
return TemporalIntent.CURRENT_STATE;
|
|
76
|
+
}
|
|
77
|
+
return TemporalIntent.NONE;
|
|
78
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-time temporal constraint ranking for explicit month/date questions.
|
|
3
|
+
*
|
|
4
|
+
* This is intentionally narrow: it only reacts when the user states a month
|
|
5
|
+
* constraint in the query, then boosts/protects candidates whose content or
|
|
6
|
+
* observation timestamp matches that month. It complements temporal ordering
|
|
7
|
+
* expansion, which handles "before/after/when" phrasing.
|
|
8
|
+
*/
|
|
9
|
+
import type { SearchResult } from '../db/repository-types.js';
|
|
10
|
+
export interface TemporalConstraintRankingResult {
|
|
11
|
+
constraints: string[];
|
|
12
|
+
protectedFingerprints: string[];
|
|
13
|
+
protectedIds: string[];
|
|
14
|
+
results: SearchResult[];
|
|
15
|
+
}
|
|
16
|
+
export declare function applyTemporalQueryConstraints(query: string, results: SearchResult[], boost: number): TemporalConstraintRankingResult;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-time temporal constraint ranking for explicit month/date questions.
|
|
3
|
+
*
|
|
4
|
+
* This is intentionally narrow: it only reacts when the user states a month
|
|
5
|
+
* constraint in the query, then boosts/protects candidates whose content or
|
|
6
|
+
* observation timestamp matches that month. It complements temporal ordering
|
|
7
|
+
* expansion, which handles "before/after/when" phrasing.
|
|
8
|
+
*/
|
|
9
|
+
import { buildTemporalFingerprint } from './temporal-fingerprint.js';
|
|
10
|
+
import { countKeywordMatches } from './query-keyword-matches.js';
|
|
11
|
+
const MONTHS = [
|
|
12
|
+
'january', 'february', 'march', 'april', 'may', 'june',
|
|
13
|
+
'july', 'august', 'september', 'october', 'november', 'december',
|
|
14
|
+
];
|
|
15
|
+
const QUERY_STOP_WORDS = new Set([
|
|
16
|
+
'what', 'when', 'where', 'which', 'who', 'whom', 'whose', 'why', 'how',
|
|
17
|
+
'did', 'does', 'do', 'was', 'were', 'is', 'are', 'the', 'a', 'an', 'and',
|
|
18
|
+
'or', 'to', 'of', 'in', 'for', 'on', 'with', 'about', 'user', 'their',
|
|
19
|
+
'they', 'them', 'there', 'happen', 'happened', 'event', 'events',
|
|
20
|
+
]);
|
|
21
|
+
const MAX_PROTECTED_TEMPORAL_CONSTRAINTS = 3;
|
|
22
|
+
export function applyTemporalQueryConstraints(query, results, boost) {
|
|
23
|
+
const constraints = extractTemporalConstraints(query);
|
|
24
|
+
if (constraints.length === 0 || boost <= 0) {
|
|
25
|
+
return emptyResult(results);
|
|
26
|
+
}
|
|
27
|
+
const keywords = extractQueryKeywords(query);
|
|
28
|
+
const scored = results
|
|
29
|
+
.map((result) => scoreTemporalCandidate(result, constraints, keywords, boost))
|
|
30
|
+
.sort((left, right) => right.result.score - left.result.score);
|
|
31
|
+
const protectedCandidates = scored.filter((item) => item.matched).slice(0, MAX_PROTECTED_TEMPORAL_CONSTRAINTS);
|
|
32
|
+
return {
|
|
33
|
+
constraints: constraints.map(formatConstraint),
|
|
34
|
+
protectedFingerprints: protectedCandidates.map((item) => buildTemporalFingerprint(item.result.content)),
|
|
35
|
+
protectedIds: protectedCandidates.map((item) => item.result.id),
|
|
36
|
+
results: scored.map((item) => item.result),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function extractTemporalConstraints(query) {
|
|
40
|
+
const lower = query.toLowerCase();
|
|
41
|
+
const constraints = [];
|
|
42
|
+
for (let index = 0; index < MONTHS.length; index++) {
|
|
43
|
+
const monthName = MONTHS[index];
|
|
44
|
+
const pattern = new RegExp(`\\b${monthName}\\b(?:\\s+(\\d{4}))?`, 'i');
|
|
45
|
+
const match = lower.match(pattern);
|
|
46
|
+
if (!match)
|
|
47
|
+
continue;
|
|
48
|
+
const year = match[1] ? parseInt(match[1], 10) : undefined;
|
|
49
|
+
constraints.push({ monthIndex: index, monthName, year });
|
|
50
|
+
}
|
|
51
|
+
return constraints;
|
|
52
|
+
}
|
|
53
|
+
function scoreTemporalCandidate(result, constraints, keywords, boost) {
|
|
54
|
+
if (!matchesAnyConstraint(result, constraints) || !hasKeywordSupport(result.content, keywords)) {
|
|
55
|
+
return { result, matched: false };
|
|
56
|
+
}
|
|
57
|
+
const keywordBoost = countKeywordMatches(result.content, keywords) * 0.1;
|
|
58
|
+
return {
|
|
59
|
+
result: { ...result, score: result.score + boost + keywordBoost },
|
|
60
|
+
matched: true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function matchesAnyConstraint(result, constraints) {
|
|
64
|
+
return constraints.some((constraint) => (contentMatchesConstraint(result.content, constraint)
|
|
65
|
+
|| dateMatchesConstraint(result.created_at, constraint)
|
|
66
|
+
|| dateMatchesConstraint(result.observed_at, constraint)));
|
|
67
|
+
}
|
|
68
|
+
function contentMatchesConstraint(content, constraint) {
|
|
69
|
+
const lower = content.toLowerCase();
|
|
70
|
+
if (!lower.includes(constraint.monthName))
|
|
71
|
+
return false;
|
|
72
|
+
if (constraint.year === undefined)
|
|
73
|
+
return true;
|
|
74
|
+
return lower.includes(String(constraint.year));
|
|
75
|
+
}
|
|
76
|
+
function dateMatchesConstraint(date, constraint) {
|
|
77
|
+
if (date.getUTCMonth() !== constraint.monthIndex)
|
|
78
|
+
return false;
|
|
79
|
+
if (constraint.year === undefined)
|
|
80
|
+
return true;
|
|
81
|
+
return date.getUTCFullYear() === constraint.year;
|
|
82
|
+
}
|
|
83
|
+
function hasKeywordSupport(content, keywords) {
|
|
84
|
+
if (keywords.length === 0)
|
|
85
|
+
return true;
|
|
86
|
+
const requiredMatches = Math.min(2, keywords.length);
|
|
87
|
+
return countKeywordMatches(content, keywords) >= requiredMatches;
|
|
88
|
+
}
|
|
89
|
+
function extractQueryKeywords(query) {
|
|
90
|
+
const words = query
|
|
91
|
+
.toLowerCase()
|
|
92
|
+
.replace(/[^a-z0-9\s]/g, ' ')
|
|
93
|
+
.split(/\s+/)
|
|
94
|
+
.filter((word) => word.length > 2)
|
|
95
|
+
.filter((word) => !QUERY_STOP_WORDS.has(word))
|
|
96
|
+
.filter((word) => !MONTHS.includes(word))
|
|
97
|
+
.filter((word) => !/^\d{4}$/.test(word));
|
|
98
|
+
return [...new Set(words)];
|
|
99
|
+
}
|
|
100
|
+
function formatConstraint(constraint) {
|
|
101
|
+
return constraint.year === undefined
|
|
102
|
+
? constraint.monthName
|
|
103
|
+
: `${constraint.monthName} ${constraint.year}`;
|
|
104
|
+
}
|
|
105
|
+
function emptyResult(results) {
|
|
106
|
+
return { constraints: [], protectedFingerprints: [], protectedIds: [], results };
|
|
107
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic query expansion for temporal-order questions.
|
|
3
|
+
* Pulls exact keyword candidates and nearby session memories when the query
|
|
4
|
+
* asks about sequence, relative timing, or duration.
|
|
5
|
+
*/
|
|
6
|
+
import type { SearchResult } from '../db/repository-types.js';
|
|
7
|
+
import type { SearchStore } from '../db/stores.js';
|
|
8
|
+
export declare function isTemporalOrderingQuery(query: string): boolean;
|
|
9
|
+
export declare function extractTemporalQueryKeywords(query: string): string[];
|
|
10
|
+
export declare function expandTemporalQuery(repo: SearchStore, userId: string, query: string, queryEmbedding: number[], excludeIds: Set<string>, limit: number, referenceTime?: Date): Promise<{
|
|
11
|
+
memories: SearchResult[];
|
|
12
|
+
keywords: string[];
|
|
13
|
+
anchorIds: string[];
|
|
14
|
+
}>;
|