@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,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Zod schemas for the direct storage API (`/v1/storage/*`).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Step-2 SDK type surface (`atomicmemory-sdk/src/storage`)
|
|
5
|
+
* closely enough for two purposes:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Capability response validation** — `GET /v1/storage/capabilities`
|
|
8
|
+
* runs its emitted body through `StorageCapabilitiesResponseSchema`
|
|
9
|
+
* so the response formatter cannot leak internal fields.
|
|
10
|
+
* 2. **Future request validation** — pointer-mode put bodies, managed
|
|
11
|
+
* mode put query params, and delete-policy query params have
|
|
12
|
+
* strict schemas defined here even though their routes don't ship
|
|
13
|
+
* until the storage-route implementation. Locking the shape now means the storage-route implementation can wire the
|
|
14
|
+
* schemas straight into `validateBody` / `validateQuery` without
|
|
15
|
+
* relitigating the contract.
|
|
16
|
+
*
|
|
17
|
+
* Every object schema is `.strict()` so unknown keys are rejected as
|
|
18
|
+
* an additional defence in depth against accidental field leaks. The
|
|
19
|
+
* route formatter is the primary projector; `.strict()` is the lock.
|
|
20
|
+
*
|
|
21
|
+
* Wire shape matches the SDK's `StorageCapabilities` type field names
|
|
22
|
+
* (camelCase). The plan's rev-6 smoke test pins this:
|
|
23
|
+
*
|
|
24
|
+
* `curl GET /v1/storage/capabilities` →
|
|
25
|
+
* `{ provider: "local_fs", supportsDirectUpload: true, ... }`
|
|
26
|
+
*/
|
|
27
|
+
import { z } from './zod-setup.js';
|
|
28
|
+
export declare const StorageCapabilitiesResponseSchema: z.ZodObject<{
|
|
29
|
+
provider: z.ZodString;
|
|
30
|
+
addressing: z.ZodArray<z.ZodEnum<{
|
|
31
|
+
location: "location";
|
|
32
|
+
content: "content";
|
|
33
|
+
provider_native: "provider_native";
|
|
34
|
+
}>>;
|
|
35
|
+
consistency: z.ZodEnum<{
|
|
36
|
+
immediate: "immediate";
|
|
37
|
+
eventual: "eventual";
|
|
38
|
+
}>;
|
|
39
|
+
maxUploadBytes: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
minUploadBytes: z.ZodOptional<z.ZodNumber>;
|
|
41
|
+
supportsDirectUpload: z.ZodBoolean;
|
|
42
|
+
supportsRangeRead: z.ZodBoolean;
|
|
43
|
+
supportsDelete: z.ZodBoolean;
|
|
44
|
+
supportsTombstone: z.ZodBoolean;
|
|
45
|
+
supportsBundles: z.ZodBoolean;
|
|
46
|
+
supportedBundleFormats: z.ZodArray<z.ZodString>;
|
|
47
|
+
supportsVerification: z.ZodBoolean;
|
|
48
|
+
supportsProviderProofs: z.ZodBoolean;
|
|
49
|
+
supportsReplication: z.ZodBoolean;
|
|
50
|
+
supportsRetrievalStatus: z.ZodBoolean;
|
|
51
|
+
supportsContentHash: z.ZodBoolean;
|
|
52
|
+
supportsContentAddressedUri: z.ZodBoolean;
|
|
53
|
+
deleteSemantics: z.ZodArray<z.ZodEnum<{
|
|
54
|
+
delete: "delete";
|
|
55
|
+
unpin: "unpin";
|
|
56
|
+
tombstone: "tombstone";
|
|
57
|
+
provider_retained: "provider_retained";
|
|
58
|
+
}>>;
|
|
59
|
+
availabilityModel: z.ZodEnum<{
|
|
60
|
+
scheduled: "scheduled";
|
|
61
|
+
immediate: "immediate";
|
|
62
|
+
delayed: "delayed";
|
|
63
|
+
best_effort: "best_effort";
|
|
64
|
+
}>;
|
|
65
|
+
}, z.core.$strict>;
|
|
66
|
+
export type StorageCapabilitiesResponse = z.infer<typeof StorageCapabilitiesResponseSchema>;
|
|
67
|
+
export declare const PutPointerBodySchema: z.ZodObject<{
|
|
68
|
+
mode: z.ZodLiteral<"pointer">;
|
|
69
|
+
uri: z.ZodString;
|
|
70
|
+
content_type: z.ZodString;
|
|
71
|
+
size_bytes: z.ZodOptional<z.ZodNumber>;
|
|
72
|
+
content_hash: z.ZodOptional<z.ZodString>;
|
|
73
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
74
|
+
}, z.core.$strict>;
|
|
75
|
+
export type PutPointerBody = z.infer<typeof PutPointerBodySchema>;
|
|
76
|
+
export declare const PutArtifactBodySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
77
|
+
mode: z.ZodLiteral<"pointer">;
|
|
78
|
+
uri: z.ZodString;
|
|
79
|
+
content_type: z.ZodString;
|
|
80
|
+
size_bytes: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
content_hash: z.ZodOptional<z.ZodString>;
|
|
82
|
+
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
83
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
84
|
+
mode: z.ZodLiteral<"managed">;
|
|
85
|
+
}, z.core.$strict>], "mode">;
|
|
86
|
+
export declare const DeleteArtifactPolicySchema: z.ZodEnum<{
|
|
87
|
+
artifact_only: "artifact_only";
|
|
88
|
+
with_documents: "with_documents";
|
|
89
|
+
}>;
|
|
90
|
+
export declare const StoredArtifactResponseSchema: z.ZodObject<{
|
|
91
|
+
artifact_id: z.ZodString;
|
|
92
|
+
provider: z.ZodString;
|
|
93
|
+
mode: z.ZodEnum<{
|
|
94
|
+
pointer: "pointer";
|
|
95
|
+
managed: "managed";
|
|
96
|
+
}>;
|
|
97
|
+
uri: z.ZodNullable<z.ZodString>;
|
|
98
|
+
status: z.ZodEnum<{
|
|
99
|
+
deleted: "deleted";
|
|
100
|
+
stored: "stored";
|
|
101
|
+
pending: "pending";
|
|
102
|
+
failed: "failed";
|
|
103
|
+
available: "available";
|
|
104
|
+
unavailable: "unavailable";
|
|
105
|
+
deleting: "deleting";
|
|
106
|
+
delete_failed: "delete_failed";
|
|
107
|
+
}>;
|
|
108
|
+
size_bytes: z.ZodNullable<z.ZodNumber>;
|
|
109
|
+
content_type: z.ZodNullable<z.ZodString>;
|
|
110
|
+
content_hash: z.ZodOptional<z.ZodString>;
|
|
111
|
+
content_encoding: z.ZodEnum<{
|
|
112
|
+
aes_gcm: "aes_gcm";
|
|
113
|
+
identity: "identity";
|
|
114
|
+
}>;
|
|
115
|
+
identifiers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
116
|
+
lifecycle: z.ZodObject<{
|
|
117
|
+
availability: z.ZodOptional<z.ZodEnum<{
|
|
118
|
+
scheduled: "scheduled";
|
|
119
|
+
immediate: "immediate";
|
|
120
|
+
delayed: "delayed";
|
|
121
|
+
best_effort: "best_effort";
|
|
122
|
+
}>>;
|
|
123
|
+
deleteSemantics: z.ZodOptional<z.ZodEnum<{
|
|
124
|
+
delete: "delete";
|
|
125
|
+
unpin: "unpin";
|
|
126
|
+
tombstone: "tombstone";
|
|
127
|
+
provider_retained: "provider_retained";
|
|
128
|
+
}>>;
|
|
129
|
+
}, z.core.$strict>;
|
|
130
|
+
replication: z.ZodOptional<z.ZodObject<{
|
|
131
|
+
desiredCopies: z.ZodOptional<z.ZodNumber>;
|
|
132
|
+
confirmedCopies: z.ZodOptional<z.ZodNumber>;
|
|
133
|
+
}, z.core.$strict>>;
|
|
134
|
+
verification: z.ZodOptional<z.ZodObject<{
|
|
135
|
+
providerProofStatus: z.ZodOptional<z.ZodEnum<{
|
|
136
|
+
pending: "pending";
|
|
137
|
+
unsupported: "unsupported";
|
|
138
|
+
failed: "failed";
|
|
139
|
+
verified: "verified";
|
|
140
|
+
}>>;
|
|
141
|
+
lastVerifiedAt: z.ZodOptional<z.ZodString>;
|
|
142
|
+
}, z.core.$strict>>;
|
|
143
|
+
retrieval: z.ZodOptional<z.ZodObject<{
|
|
144
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
unsupported: "unsupported";
|
|
146
|
+
retrievable: "retrievable";
|
|
147
|
+
not_checked: "not_checked";
|
|
148
|
+
not_retrievable: "not_retrievable";
|
|
149
|
+
}>>;
|
|
150
|
+
lastCheckedAt: z.ZodOptional<z.ZodString>;
|
|
151
|
+
}, z.core.$strict>>;
|
|
152
|
+
metadata: z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
153
|
+
provider_details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
154
|
+
created_at: z.ZodString;
|
|
155
|
+
updated_at: z.ZodString;
|
|
156
|
+
}, z.core.$strict>;
|
|
157
|
+
export type StoredArtifactResponse = z.infer<typeof StoredArtifactResponseSchema>;
|
|
158
|
+
export declare const VerifyArtifactResultSchema: z.ZodObject<{
|
|
159
|
+
artifact_id: z.ZodString;
|
|
160
|
+
kind: z.ZodEnum<{
|
|
161
|
+
unsupported: "unsupported";
|
|
162
|
+
failed: "failed";
|
|
163
|
+
verified: "verified";
|
|
164
|
+
}>;
|
|
165
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
166
|
+
details: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
167
|
+
}, z.core.$strict>;
|
|
168
|
+
export declare const DeleteArtifactResultSchema: z.ZodObject<{
|
|
169
|
+
artifact_id: z.ZodString;
|
|
170
|
+
status: z.ZodEnum<{
|
|
171
|
+
deleted: "deleted";
|
|
172
|
+
delete_failed: "delete_failed";
|
|
173
|
+
}>;
|
|
174
|
+
cascaded_document_ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
175
|
+
}, z.core.$strict>;
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Zod schemas for the direct storage API (`/v1/storage/*`).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the Step-2 SDK type surface (`atomicmemory-sdk/src/storage`)
|
|
5
|
+
* closely enough for two purposes:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Capability response validation** — `GET /v1/storage/capabilities`
|
|
8
|
+
* runs its emitted body through `StorageCapabilitiesResponseSchema`
|
|
9
|
+
* so the response formatter cannot leak internal fields.
|
|
10
|
+
* 2. **Future request validation** — pointer-mode put bodies, managed
|
|
11
|
+
* mode put query params, and delete-policy query params have
|
|
12
|
+
* strict schemas defined here even though their routes don't ship
|
|
13
|
+
* until the storage-route implementation. Locking the shape now means the storage-route implementation can wire the
|
|
14
|
+
* schemas straight into `validateBody` / `validateQuery` without
|
|
15
|
+
* relitigating the contract.
|
|
16
|
+
*
|
|
17
|
+
* Every object schema is `.strict()` so unknown keys are rejected as
|
|
18
|
+
* an additional defence in depth against accidental field leaks. The
|
|
19
|
+
* route formatter is the primary projector; `.strict()` is the lock.
|
|
20
|
+
*
|
|
21
|
+
* Wire shape matches the SDK's `StorageCapabilities` type field names
|
|
22
|
+
* (camelCase). The plan's rev-6 smoke test pins this:
|
|
23
|
+
*
|
|
24
|
+
* `curl GET /v1/storage/capabilities` →
|
|
25
|
+
* `{ provider: "local_fs", supportsDirectUpload: true, ... }`
|
|
26
|
+
*/
|
|
27
|
+
import { z } from './zod-setup.js';
|
|
28
|
+
// ---------------------------------------------------------------------------
|
|
29
|
+
// Closed enums — internal building blocks for the public schemas below.
|
|
30
|
+
// File-private; mirror the SDK type unions one-to-one.
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
const StorageAddressingModeSchema = z
|
|
33
|
+
.enum(['location', 'content', 'provider_native'])
|
|
34
|
+
.openapi({ description: 'How the backend addresses stored bytes.' });
|
|
35
|
+
const StorageConsistencySchema = z
|
|
36
|
+
.enum(['immediate', 'eventual'])
|
|
37
|
+
.openapi({ description: 'When bytes become retrievable after put.' });
|
|
38
|
+
const StorageAvailabilityModelSchema = z
|
|
39
|
+
.enum(['immediate', 'delayed', 'scheduled', 'best_effort'])
|
|
40
|
+
.openapi({ description: 'Coarse availability category for the backend.' });
|
|
41
|
+
const StorageDeleteSemanticsSchema = z
|
|
42
|
+
.enum(['delete', 'unpin', 'tombstone', 'provider_retained'])
|
|
43
|
+
.openapi({
|
|
44
|
+
description: 'What the backend does on delete. `delete` issues provider ' +
|
|
45
|
+
'removal; `unpin` removes the AtomicMemory reference only; ' +
|
|
46
|
+
"`tombstone` stops managing without provider removal (typical " +
|
|
47
|
+
'for decentralized providers); `provider_retained` is reserved.',
|
|
48
|
+
});
|
|
49
|
+
// ---------------------------------------------------------------------------
|
|
50
|
+
// Capabilities response — the wire shape `GET /v1/storage/capabilities`
|
|
51
|
+
// emits. Mirrors `StorageCapabilities` from the SDK.
|
|
52
|
+
// ---------------------------------------------------------------------------
|
|
53
|
+
export const StorageCapabilitiesResponseSchema = z
|
|
54
|
+
.object({
|
|
55
|
+
provider: z.string(),
|
|
56
|
+
addressing: z.array(StorageAddressingModeSchema),
|
|
57
|
+
consistency: StorageConsistencySchema,
|
|
58
|
+
maxUploadBytes: z.number().int().positive().optional(),
|
|
59
|
+
minUploadBytes: z.number().int().nonnegative().optional(),
|
|
60
|
+
supportsDirectUpload: z.boolean(),
|
|
61
|
+
supportsRangeRead: z.boolean(),
|
|
62
|
+
supportsDelete: z.boolean(),
|
|
63
|
+
supportsTombstone: z.boolean(),
|
|
64
|
+
supportsBundles: z.boolean(),
|
|
65
|
+
supportedBundleFormats: z.array(z.string()),
|
|
66
|
+
supportsVerification: z.boolean(),
|
|
67
|
+
supportsProviderProofs: z.boolean(),
|
|
68
|
+
supportsReplication: z.boolean(),
|
|
69
|
+
supportsRetrievalStatus: z.boolean(),
|
|
70
|
+
supportsContentHash: z.boolean(),
|
|
71
|
+
supportsContentAddressedUri: z.boolean(),
|
|
72
|
+
deleteSemantics: z.array(StorageDeleteSemanticsSchema),
|
|
73
|
+
availabilityModel: StorageAvailabilityModelSchema,
|
|
74
|
+
})
|
|
75
|
+
.strict()
|
|
76
|
+
.openapi({
|
|
77
|
+
description: 'Capability snapshot for the direct storage API ' +
|
|
78
|
+
'(`/v1/storage/artifacts/*`). Composition-time projection; no ' +
|
|
79
|
+
"per-user state. Document ingestion's own capability surface " +
|
|
80
|
+
'lives at `/v1/documents/limits` and may report different ' +
|
|
81
|
+
'flags (e.g. Filecoin reports `supportsContentHash: true` ' +
|
|
82
|
+
'through documents but `false` here in v1 because direct ' +
|
|
83
|
+
'managed Filecoin upload is not yet supported).',
|
|
84
|
+
});
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Caller-supplied artifact metadata. Shape matches the SDK's
|
|
87
|
+
// `Record<string, string | number | boolean>` and is reused by the
|
|
88
|
+
// pointer-mode JSON body + the managed-mode `X-AtomicMemory-Metadata`
|
|
89
|
+
// header (wired in the storage-route implementation).
|
|
90
|
+
// ---------------------------------------------------------------------------
|
|
91
|
+
const ArtifactMetadataSchema = z
|
|
92
|
+
.record(z.string(), z.union([z.string(), z.number(), z.boolean()]))
|
|
93
|
+
.openapi({
|
|
94
|
+
description: 'Caller-supplied metadata. Decoded JSON must be ≤4 KiB; encoded ' +
|
|
95
|
+
'header value must be ≤8 KiB when sent via ' +
|
|
96
|
+
'`X-AtomicMemory-Metadata`.',
|
|
97
|
+
});
|
|
98
|
+
// ---------------------------------------------------------------------------
|
|
99
|
+
// Put-artifact request shapes. Pointer mode lives in the JSON body;
|
|
100
|
+
// managed mode is `?mode=managed&...` with raw bytes in the body (no
|
|
101
|
+
// JSON envelope). Both schemas are wired now so the storage-route implementation's routes can
|
|
102
|
+
// validate without re-deriving the contract.
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
export const PutPointerBodySchema = z
|
|
105
|
+
.object({
|
|
106
|
+
mode: z.literal('pointer'),
|
|
107
|
+
uri: z.string().min(1),
|
|
108
|
+
content_type: z.string().min(1),
|
|
109
|
+
size_bytes: z.number().int().nonnegative().optional(),
|
|
110
|
+
content_hash: z.string().min(1).optional(),
|
|
111
|
+
metadata: ArtifactMetadataSchema.optional(),
|
|
112
|
+
})
|
|
113
|
+
.strict()
|
|
114
|
+
.openapi({
|
|
115
|
+
description: 'Pointer-mode artifact registration body. The server stores ' +
|
|
116
|
+
'the URI as a reference; it NEVER fetches the URI itself.',
|
|
117
|
+
});
|
|
118
|
+
const PutManagedBodySchema = z
|
|
119
|
+
.object({
|
|
120
|
+
mode: z.literal('managed'),
|
|
121
|
+
})
|
|
122
|
+
.strict()
|
|
123
|
+
.openapi({
|
|
124
|
+
description: 'Managed-mode marker. The route uses query params for the ' +
|
|
125
|
+
'managed-mode contract; the body is raw bytes, not JSON. ' +
|
|
126
|
+
'Included in the discriminated union so a managed-mode JSON ' +
|
|
127
|
+
'body (caller mistake) parses cleanly and is rejected at the ' +
|
|
128
|
+
'route layer.',
|
|
129
|
+
});
|
|
130
|
+
export const PutArtifactBodySchema = z
|
|
131
|
+
.discriminatedUnion('mode', [PutPointerBodySchema, PutManagedBodySchema])
|
|
132
|
+
.openapi({ description: 'Discriminated union over put-artifact mode.' });
|
|
133
|
+
// Note: the managed-mode put route parses query params manually
|
|
134
|
+
// (Content-Length, force-rejection, and the disclose flag have
|
|
135
|
+
// distinct error envelopes that don't compose cleanly with
|
|
136
|
+
// `validateQuery`). The schema lives here as authoritative
|
|
137
|
+
// documentation of the contract; OpenAPI references it indirectly
|
|
138
|
+
// via the discriminated `PutArtifactBodySchema`.
|
|
139
|
+
// ---------------------------------------------------------------------------
|
|
140
|
+
// Delete-artifact closed-policy enum. No `force`; orphan recovery is
|
|
141
|
+
// intentionally restricted to operator workflows.
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
export const DeleteArtifactPolicySchema = z
|
|
144
|
+
.enum(['artifact_only', 'with_documents'])
|
|
145
|
+
.openapi({
|
|
146
|
+
description: 'Delete behaviour when documents reference the artifact. ' +
|
|
147
|
+
'`artifact_only` (default) returns 409 `artifact_in_use` if ' +
|
|
148
|
+
'any non-deleted documents reference it. `with_documents` ' +
|
|
149
|
+
'cascades a soft-delete to those documents first.',
|
|
150
|
+
});
|
|
151
|
+
// The delete route parses query params manually so it can reject
|
|
152
|
+
// `force` explicitly (the plan disallows the verb in the public API).
|
|
153
|
+
// OpenAPI references `DeleteArtifactPolicySchema` directly in the
|
|
154
|
+
// route registration; no separate query-object export is needed.
|
|
155
|
+
// ---------------------------------------------------------------------------
|
|
156
|
+
// Stored artifact response shape — wire projection emitted by every
|
|
157
|
+
// public route that returns artifact metadata (PUT pointer/managed,
|
|
158
|
+
// GET, verify, delete).
|
|
159
|
+
//
|
|
160
|
+
// Mirrors the SDK's `StoredArtifact`. Field naming is snake_case to
|
|
161
|
+
// match the existing core wire convention. The route formatter is
|
|
162
|
+
// responsible for explicit projection; this schema is the final
|
|
163
|
+
// `.strict()` lock.
|
|
164
|
+
// ---------------------------------------------------------------------------
|
|
165
|
+
const ArtifactIdentifiersSchema = z
|
|
166
|
+
.record(z.string(), z.string())
|
|
167
|
+
.openapi({ description: 'Provider-native identifiers (CID, etc.); allowlisted per provider.' });
|
|
168
|
+
const ProviderDetailsSchema = z
|
|
169
|
+
.record(z.string(), z.unknown())
|
|
170
|
+
.openapi({ description: 'Allowlisted provider-specific public state.' });
|
|
171
|
+
const LifecycleSchema = z
|
|
172
|
+
.object({
|
|
173
|
+
availability: StorageAvailabilityModelSchema.optional(),
|
|
174
|
+
deleteSemantics: StorageDeleteSemanticsSchema.optional(),
|
|
175
|
+
})
|
|
176
|
+
.strict()
|
|
177
|
+
.openapi({
|
|
178
|
+
description: 'Provider-agnostic summary of availability + delete-semantics. ' +
|
|
179
|
+
'Both fields are optional so a row whose lifecycle is not yet ' +
|
|
180
|
+
'known to the API surface validates cleanly.',
|
|
181
|
+
});
|
|
182
|
+
const ReplicationStateSchema = z
|
|
183
|
+
.object({
|
|
184
|
+
desiredCopies: z.number().int().nonnegative().optional(),
|
|
185
|
+
confirmedCopies: z.number().int().nonnegative().optional(),
|
|
186
|
+
})
|
|
187
|
+
.strict()
|
|
188
|
+
.openapi({ description: 'Optional replication state for eventual storage providers.' });
|
|
189
|
+
const VerificationStateSchema = z
|
|
190
|
+
.object({
|
|
191
|
+
providerProofStatus: z
|
|
192
|
+
.enum(['pending', 'verified', 'failed', 'unsupported'])
|
|
193
|
+
.optional(),
|
|
194
|
+
lastVerifiedAt: z.string().optional(),
|
|
195
|
+
})
|
|
196
|
+
.strict()
|
|
197
|
+
.openapi({ description: 'Optional verification state (provider proofs).' });
|
|
198
|
+
const RetrievalStateSchema = z
|
|
199
|
+
.object({
|
|
200
|
+
status: z
|
|
201
|
+
.enum(['not_checked', 'retrievable', 'not_retrievable', 'unsupported'])
|
|
202
|
+
.optional(),
|
|
203
|
+
lastCheckedAt: z.string().optional(),
|
|
204
|
+
})
|
|
205
|
+
.strict()
|
|
206
|
+
.openapi({ description: 'Optional retrieval-readiness state.' });
|
|
207
|
+
export const StoredArtifactResponseSchema = z
|
|
208
|
+
.object({
|
|
209
|
+
artifact_id: z.string().uuid(),
|
|
210
|
+
provider: z.string(),
|
|
211
|
+
mode: z.enum(['pointer', 'managed']),
|
|
212
|
+
// Nullable for managed pending/failed rows whose backend put
|
|
213
|
+
// never returned a URI. Pointer rows always carry the
|
|
214
|
+
// caller-supplied URI; managed `stored` / `available` rows
|
|
215
|
+
// carry the adapter URI. `pending` / `failed` rows surface
|
|
216
|
+
// `uri: null` honestly.
|
|
217
|
+
uri: z.string().nullable(),
|
|
218
|
+
status: z.enum([
|
|
219
|
+
'stored',
|
|
220
|
+
'pending',
|
|
221
|
+
'available',
|
|
222
|
+
'unavailable',
|
|
223
|
+
'deleting',
|
|
224
|
+
'deleted',
|
|
225
|
+
'delete_failed',
|
|
226
|
+
'failed',
|
|
227
|
+
]),
|
|
228
|
+
size_bytes: z.number().int().nonnegative().nullable(),
|
|
229
|
+
content_type: z.string().nullable(),
|
|
230
|
+
/** Plaintext SHA-256 of caller bytes — present only when the put
|
|
231
|
+
* was made with `disclose_content_hash=true`. Stored internally
|
|
232
|
+
* for diagnostic queries either way. */
|
|
233
|
+
content_hash: z.string().optional(),
|
|
234
|
+
content_encoding: z.enum(['identity', 'aes_gcm']),
|
|
235
|
+
identifiers: ArtifactIdentifiersSchema,
|
|
236
|
+
/** Always present; populated from `(provider, mode)` derivation. */
|
|
237
|
+
lifecycle: LifecycleSchema,
|
|
238
|
+
/** Optional state envelopes — only surfaced when the row column
|
|
239
|
+
* carries data. the storage-route implementation ships them as wire-shape stubs; the paired artifact-sync implementation's
|
|
240
|
+
* sync hook populates them for Filecoin-backed rows. */
|
|
241
|
+
replication: ReplicationStateSchema.optional(),
|
|
242
|
+
verification: VerificationStateSchema.optional(),
|
|
243
|
+
retrieval: RetrievalStateSchema.optional(),
|
|
244
|
+
metadata: ArtifactMetadataSchema,
|
|
245
|
+
provider_details: ProviderDetailsSchema.optional(),
|
|
246
|
+
created_at: z.string(),
|
|
247
|
+
updated_at: z.string(),
|
|
248
|
+
})
|
|
249
|
+
.strict()
|
|
250
|
+
.openapi({
|
|
251
|
+
description: 'Public metadata projection of a `storage_artifacts` row. ' +
|
|
252
|
+
'`content_hash` is the plaintext SHA-256 of caller bytes; the ' +
|
|
253
|
+
'internal `stored_hash` column is NEVER surfaced on the wire.',
|
|
254
|
+
});
|
|
255
|
+
export const VerifyArtifactResultSchema = z
|
|
256
|
+
.object({
|
|
257
|
+
artifact_id: z.string().uuid(),
|
|
258
|
+
kind: z.enum(['verified', 'failed', 'unsupported']),
|
|
259
|
+
reason: z.string().optional(),
|
|
260
|
+
details: z.record(z.string(), z.unknown()).optional(),
|
|
261
|
+
})
|
|
262
|
+
.strict()
|
|
263
|
+
.openapi({
|
|
264
|
+
description: 'Result of `POST /v1/storage/artifacts/:id/verify`. Pointer-mode ' +
|
|
265
|
+
"artifacts always report `kind: 'unsupported'` because the server " +
|
|
266
|
+
'never fetches the registered URI.',
|
|
267
|
+
});
|
|
268
|
+
export const DeleteArtifactResultSchema = z
|
|
269
|
+
.object({
|
|
270
|
+
artifact_id: z.string().uuid(),
|
|
271
|
+
status: z.enum(['deleted', 'delete_failed']),
|
|
272
|
+
cascaded_document_ids: z.array(z.string().uuid()).optional(),
|
|
273
|
+
})
|
|
274
|
+
.strict()
|
|
275
|
+
.openapi({
|
|
276
|
+
description: 'Result of `DELETE /v1/storage/artifacts/:id`.',
|
|
277
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Zod / OpenAPI registration bootstrap.
|
|
3
|
+
*
|
|
4
|
+
* Call-site importers use `z.object({...}).openapi({...})` fluently
|
|
5
|
+
* throughout `src/schemas/*.ts`. That fluent `.openapi()` method is
|
|
6
|
+
* added by `@asteasolutions/zod-to-openapi`'s `extendZodWithOpenApi`
|
|
7
|
+
* plugin. This module calls that extension exactly once, at module
|
|
8
|
+
* load, so every subsequent `import { z } from 'zod'` in the repo
|
|
9
|
+
* sees the extended namespace.
|
|
10
|
+
*
|
|
11
|
+
* Import `./zod-setup` before any schema file that uses `.openapi()`.
|
|
12
|
+
* All files in `src/schemas/*.ts` must start with this import.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
export { z };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Zod / OpenAPI registration bootstrap.
|
|
3
|
+
*
|
|
4
|
+
* Call-site importers use `z.object({...}).openapi({...})` fluently
|
|
5
|
+
* throughout `src/schemas/*.ts`. That fluent `.openapi()` method is
|
|
6
|
+
* added by `@asteasolutions/zod-to-openapi`'s `extendZodWithOpenApi`
|
|
7
|
+
* plugin. This module calls that extension exactly once, at module
|
|
8
|
+
* load, so every subsequent `import { z } from 'zod'` in the repo
|
|
9
|
+
* sees the extended namespace.
|
|
10
|
+
*
|
|
11
|
+
* Import `./zod-setup` before any schema file that uses `.openapi()`.
|
|
12
|
+
* All files in `src/schemas/*.ts` must start with this import.
|
|
13
|
+
*/
|
|
14
|
+
import { z } from 'zod';
|
|
15
|
+
import { extendZodWithOpenApi } from '@asteasolutions/zod-to-openapi';
|
|
16
|
+
extendZodWithOpenApi(z);
|
|
17
|
+
export { z };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicMemory Core API Server — bootstrap entry point.
|
|
3
|
+
*
|
|
4
|
+
* Composes the runtime container, runs startup guards, builds the Express
|
|
5
|
+
* app, and starts listening. All composition logic lives in `./app/`;
|
|
6
|
+
* this file only owns the process lifecycle (boot → listen → shutdown).
|
|
7
|
+
*
|
|
8
|
+
* The `runtime` is the single source of truth for config, pool, repos,
|
|
9
|
+
* and services. Nothing in this file reaches around it to import
|
|
10
|
+
* singletons directly — if a consumer bootstraps with custom deps later,
|
|
11
|
+
* shutdown and lifecycle still act on the right graph.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AtomicMemory Core API Server — bootstrap entry point.
|
|
3
|
+
*
|
|
4
|
+
* Composes the runtime container, runs startup guards, builds the Express
|
|
5
|
+
* app, and starts listening. All composition logic lives in `./app/`;
|
|
6
|
+
* this file only owns the process lifecycle (boot → listen → shutdown).
|
|
7
|
+
*
|
|
8
|
+
* The `runtime` is the single source of truth for config, pool, repos,
|
|
9
|
+
* and services. Nothing in this file reaches around it to import
|
|
10
|
+
* singletons directly — if a consumer bootstraps with custom deps later,
|
|
11
|
+
* shutdown and lifecycle still act on the right graph.
|
|
12
|
+
*/
|
|
13
|
+
import { pool } from './db/pool.js';
|
|
14
|
+
import { createCoreRuntime } from './app/runtime-container.js';
|
|
15
|
+
import { createApp } from './app/create-app.js';
|
|
16
|
+
import { checkEmbeddingDimensions } from './app/startup-checks.js';
|
|
17
|
+
// Process-lifecycle signal handlers reference `runtime` via a closure
|
|
18
|
+
// captured AFTER `bootstrap()` resolves — wired below. Reconciler
|
|
19
|
+
// startup stays disabled until `buildReconcilerDeps` returns a
|
|
20
|
+
// non-null bundle backed by the active storage provider.
|
|
21
|
+
let runtime = null;
|
|
22
|
+
async function bootstrap() {
|
|
23
|
+
runtime = await createCoreRuntime({ pool });
|
|
24
|
+
const app = createApp(runtime);
|
|
25
|
+
const check = await checkEmbeddingDimensions(runtime.pool, runtime.config);
|
|
26
|
+
if (!check.ok) {
|
|
27
|
+
console.error(`[startup] FATAL: ${check.message}`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
console.log(`[startup] ${check.message}`);
|
|
31
|
+
app.listen(runtime.config.port, () => {
|
|
32
|
+
console.log(`AtomicMemory Core running on http://localhost:${runtime.config.port}`);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
bootstrap().catch((err) => {
|
|
36
|
+
console.error('[startup] bootstrap failed:', err);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
|
39
|
+
process.on('uncaughtException', (err) => {
|
|
40
|
+
console.error('[FATAL] Uncaught exception:', err);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
});
|
|
43
|
+
process.on('unhandledRejection', (reason) => {
|
|
44
|
+
console.error('[ERROR] Unhandled rejection (non-fatal):', reason);
|
|
45
|
+
});
|
|
46
|
+
async function shutdown(signal) {
|
|
47
|
+
console.log(`[shutdown] Received ${signal}, closing...`);
|
|
48
|
+
const closing = runtime ? runtime.pool.end() : pool.end();
|
|
49
|
+
await closing;
|
|
50
|
+
process.exit(0);
|
|
51
|
+
}
|
|
52
|
+
process.on('SIGTERM', () => {
|
|
53
|
+
void shutdown('SIGTERM');
|
|
54
|
+
});
|
|
55
|
+
process.on('SIGINT', () => {
|
|
56
|
+
void shutdown('SIGINT');
|
|
57
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-policy helpers for abstract "why/how/meaning" questions.
|
|
3
|
+
*
|
|
4
|
+
* These queries are often grounded in the user's memories, but they need
|
|
5
|
+
* more sentence-level context than direct slot-lookup questions. The
|
|
6
|
+
* `abstract-aware` retrieval mode uses this detector to preserve richer
|
|
7
|
+
* context and to allow a hybrid fallback only after semantic retrieval
|
|
8
|
+
* returns no candidates.
|
|
9
|
+
*/
|
|
10
|
+
import type { RetrievalMode } from './memory-service-types.js';
|
|
11
|
+
export declare function isAbstractQuery(query: string): boolean;
|
|
12
|
+
export declare function prefersAbstractAwareRetrieval(retrievalMode: RetrievalMode | undefined, query: string): boolean;
|
|
13
|
+
export declare function shouldUseAbstractHybridFallback(retrievalMode: RetrievalMode | undefined, query: string, resultCount: number): boolean;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query-policy helpers for abstract "why/how/meaning" questions.
|
|
3
|
+
*
|
|
4
|
+
* These queries are often grounded in the user's memories, but they need
|
|
5
|
+
* more sentence-level context than direct slot-lookup questions. The
|
|
6
|
+
* `abstract-aware` retrieval mode uses this detector to preserve richer
|
|
7
|
+
* context and to allow a hybrid fallback only after semantic retrieval
|
|
8
|
+
* returns no candidates.
|
|
9
|
+
*/
|
|
10
|
+
const ABSTRACT_PREFIXES = [
|
|
11
|
+
/^\s*why\b/i,
|
|
12
|
+
/^\s*how\b/i,
|
|
13
|
+
/^\s*what (?:did|does)\b/i,
|
|
14
|
+
];
|
|
15
|
+
const ABSTRACT_SIGNALS = [
|
|
16
|
+
'choose',
|
|
17
|
+
'decide',
|
|
18
|
+
'explain',
|
|
19
|
+
'how does',
|
|
20
|
+
'how did',
|
|
21
|
+
'imply',
|
|
22
|
+
'learn',
|
|
23
|
+
'meaning',
|
|
24
|
+
'mean',
|
|
25
|
+
'motivat',
|
|
26
|
+
'plan',
|
|
27
|
+
'priorit',
|
|
28
|
+
'realiz',
|
|
29
|
+
'reason',
|
|
30
|
+
'reflect',
|
|
31
|
+
'signif',
|
|
32
|
+
'symbol',
|
|
33
|
+
'takeaway',
|
|
34
|
+
'why',
|
|
35
|
+
];
|
|
36
|
+
export function isAbstractQuery(query) {
|
|
37
|
+
const normalized = query.trim().toLowerCase();
|
|
38
|
+
if (!normalized)
|
|
39
|
+
return false;
|
|
40
|
+
if (ABSTRACT_PREFIXES.some((pattern) => pattern.test(normalized))) {
|
|
41
|
+
return ABSTRACT_SIGNALS.some((signal) => normalized.includes(signal));
|
|
42
|
+
}
|
|
43
|
+
return ABSTRACT_SIGNALS.some((signal) => normalized.includes(signal));
|
|
44
|
+
}
|
|
45
|
+
export function prefersAbstractAwareRetrieval(retrievalMode, query) {
|
|
46
|
+
return retrievalMode === 'abstract-aware' && isAbstractQuery(query);
|
|
47
|
+
}
|
|
48
|
+
export function shouldUseAbstractHybridFallback(retrievalMode, query, resultCount) {
|
|
49
|
+
return prefersAbstractAwareRetrieval(retrievalMode, query) && resultCount === 0;
|
|
50
|
+
}
|