@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,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-envelope mapping for `StorageService` typed errors.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `routes/storage.ts` so the route module stays
|
|
5
|
+
* focused on route registration and request handling. The mapping
|
|
6
|
+
* is a data-driven `STORAGE_ERROR_DISPATCH` table — one row per
|
|
7
|
+
* typed error — plus a focused `sendXxx` helper per error so the
|
|
8
|
+
* response shape for each is reviewable in isolation.
|
|
9
|
+
*
|
|
10
|
+
* Public entry point: `handleStorageError(res, err)` returns true
|
|
11
|
+
* when it sent a response and the caller should stop. The
|
|
12
|
+
* `LegacyUserIdRejection` class is re-exported because the route
|
|
13
|
+
* module throws it from `readUserId` (storage routes reject the
|
|
14
|
+
* legacy `?user_id=` / body shape; the auth header is the only
|
|
15
|
+
* accepted source).
|
|
16
|
+
*/
|
|
17
|
+
import type { Response } from 'express';
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by `readUserId` when a storage route request carries the
|
|
20
|
+
* legacy `?user_id=` query or body `user_id` shape instead of the
|
|
21
|
+
* `X-AtomicMemory-User-Id` header. Kept here (not in
|
|
22
|
+
* `storage-service-errors.ts`) because it is a route-layer concept
|
|
23
|
+
* — the service doesn't know how identity arrived on the wire.
|
|
24
|
+
*/
|
|
25
|
+
export declare class LegacyUserIdRejection extends Error {
|
|
26
|
+
constructor();
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Map a service-layer typed error to its HTTP envelope. Returns
|
|
30
|
+
* `true` when the response was sent and the caller should stop.
|
|
31
|
+
* Returns `false` when no row matched — the caller (route layer)
|
|
32
|
+
* should fall through to its generic 500 handler.
|
|
33
|
+
*/
|
|
34
|
+
export declare function handleStorageError(res: Response, err: unknown): boolean;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-envelope mapping for `StorageService` typed errors.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from `routes/storage.ts` so the route module stays
|
|
5
|
+
* focused on route registration and request handling. The mapping
|
|
6
|
+
* is a data-driven `STORAGE_ERROR_DISPATCH` table — one row per
|
|
7
|
+
* typed error — plus a focused `sendXxx` helper per error so the
|
|
8
|
+
* response shape for each is reviewable in isolation.
|
|
9
|
+
*
|
|
10
|
+
* Public entry point: `handleStorageError(res, err)` returns true
|
|
11
|
+
* when it sent a response and the caller should stop. The
|
|
12
|
+
* `LegacyUserIdRejection` class is re-exported because the route
|
|
13
|
+
* module throws it from `readUserId` (storage routes reject the
|
|
14
|
+
* legacy `?user_id=` / body shape; the auth header is the only
|
|
15
|
+
* accepted source).
|
|
16
|
+
*/
|
|
17
|
+
import { ArtifactDeleteInFlightError, ArtifactInUseError, ArtifactNotReadyError, ArtifactUnavailableError, BackendNotRegisteredError, FilecoinDirectStorageNotSupportedError, InvalidArtifactMetadataError, ManagedStorageDisabledError, PointerContentNotManagedError, PutPostPersistError, StorageArtifactNotFoundError, UnregisteredProviderError, UnsupportedPointerSchemeError, } from '../services/storage-service-errors.js';
|
|
18
|
+
/**
|
|
19
|
+
* Thrown by `readUserId` when a storage route request carries the
|
|
20
|
+
* legacy `?user_id=` query or body `user_id` shape instead of the
|
|
21
|
+
* `X-AtomicMemory-User-Id` header. Kept here (not in
|
|
22
|
+
* `storage-service-errors.ts`) because it is a route-layer concept
|
|
23
|
+
* — the service doesn't know how identity arrived on the wire.
|
|
24
|
+
*/
|
|
25
|
+
export class LegacyUserIdRejection extends Error {
|
|
26
|
+
constructor() {
|
|
27
|
+
super('legacy ?user_id= query or body user_id is no longer accepted; ' +
|
|
28
|
+
'send X-AtomicMemory-User-Id header instead');
|
|
29
|
+
this.name = 'LegacyUserIdRejection';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const STORAGE_ERROR_DISPATCH = [
|
|
33
|
+
[StorageArtifactNotFoundError, (r, e) => send404NotFound(r, e)],
|
|
34
|
+
[PointerContentNotManagedError, (r, e) => send409PointerContent(r, e)],
|
|
35
|
+
[FilecoinDirectStorageNotSupportedError, (r, e) => send501Filecoin(r, e)],
|
|
36
|
+
[UnsupportedPointerSchemeError, (r, e) => send400UnsupportedScheme(r, e)],
|
|
37
|
+
[ArtifactInUseError, (r, e) => send409InUse(r, e)],
|
|
38
|
+
[ArtifactDeleteInFlightError, (r, e) => send409DeleteInFlight(r, e)],
|
|
39
|
+
[ManagedStorageDisabledError, (r, e) => send503ManagedDisabled(r, e)],
|
|
40
|
+
[BackendNotRegisteredError, (r, e) => send503BackendUnavailable(r, e)],
|
|
41
|
+
[UnregisteredProviderError, (r, e) => send503UnregisteredProvider(r, e)],
|
|
42
|
+
[PutPostPersistError, (r, e) => send503PutPostPersist(r, e)],
|
|
43
|
+
[ArtifactNotReadyError, (r, e) => send409ArtifactNotReady(r, e)],
|
|
44
|
+
[ArtifactUnavailableError, (r, e) => send410ArtifactUnavailable(r, e)],
|
|
45
|
+
[InvalidArtifactMetadataError, (r, e) => send400Metadata(r, e)],
|
|
46
|
+
[LegacyUserIdRejection, (r, e) => send400LegacyUserId(r, e)],
|
|
47
|
+
];
|
|
48
|
+
/**
|
|
49
|
+
* Map a service-layer typed error to its HTTP envelope. Returns
|
|
50
|
+
* `true` when the response was sent and the caller should stop.
|
|
51
|
+
* Returns `false` when no row matched — the caller (route layer)
|
|
52
|
+
* should fall through to its generic 500 handler.
|
|
53
|
+
*/
|
|
54
|
+
export function handleStorageError(res, err) {
|
|
55
|
+
for (const [ctor, handler] of STORAGE_ERROR_DISPATCH) {
|
|
56
|
+
if (err instanceof ctor)
|
|
57
|
+
return handler(res, err);
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function send404NotFound(res, err) {
|
|
62
|
+
res.status(404).json({ error_code: 'artifact_not_found', error: err.message });
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
function send409PointerContent(res, err) {
|
|
66
|
+
res.status(409).json({
|
|
67
|
+
error_code: 'pointer_content_not_managed',
|
|
68
|
+
error: err.message,
|
|
69
|
+
uri: err.uri,
|
|
70
|
+
hint: 'Fetch the URI directly; the server does not proxy pointer content.',
|
|
71
|
+
});
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
function send501Filecoin(res, err) {
|
|
75
|
+
res.status(501).json({
|
|
76
|
+
error_code: err.provider === 'filecoin'
|
|
77
|
+
? 'filecoin_direct_storage_not_yet_supported'
|
|
78
|
+
: 'provider_direct_storage_not_yet_supported',
|
|
79
|
+
error: err.message,
|
|
80
|
+
follow_up: 'Use document ingestion or pointer mode.',
|
|
81
|
+
});
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
function send400UnsupportedScheme(res, err) {
|
|
85
|
+
res.status(400).json({
|
|
86
|
+
error_code: 'invalid_pointer_uri_scheme',
|
|
87
|
+
error: err.message,
|
|
88
|
+
allowed_schemes: err.allowedSchemes,
|
|
89
|
+
});
|
|
90
|
+
return true;
|
|
91
|
+
}
|
|
92
|
+
function send409InUse(res, err) {
|
|
93
|
+
res.status(409).json({
|
|
94
|
+
error_code: 'artifact_in_use',
|
|
95
|
+
error: err.message,
|
|
96
|
+
referenced_by_document_count: err.referencedByDocumentCount,
|
|
97
|
+
follow_up: "Pass `?policy=with_documents` to cascade.",
|
|
98
|
+
});
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
function send409DeleteInFlight(res, err) {
|
|
102
|
+
res.status(409).json({
|
|
103
|
+
error_code: 'delete_in_flight',
|
|
104
|
+
error: err.message,
|
|
105
|
+
artifact_id: err.artifactId,
|
|
106
|
+
current_status: err.currentStatus,
|
|
107
|
+
retryable: true,
|
|
108
|
+
});
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
function send503ManagedDisabled(res, err) {
|
|
112
|
+
res.status(503).json({ error_code: 'managed_storage_disabled', error: err.message });
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
function send503BackendUnavailable(res, err) {
|
|
116
|
+
// Sanitized envelope: provider_id is the only identifier the
|
|
117
|
+
// client can use to ask the operator to re-register the adapter.
|
|
118
|
+
// Internal stack/error text stays server-side.
|
|
119
|
+
res.status(503).json({
|
|
120
|
+
error_code: 'storage_backend_unavailable',
|
|
121
|
+
error: `the storage backend for provider '${err.providerId}' is not registered with this deployment`,
|
|
122
|
+
provider_id: err.providerId,
|
|
123
|
+
});
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
function send503UnregisteredProvider(res, err) {
|
|
127
|
+
// Composition-level variant of `storage_backend_unavailable`:
|
|
128
|
+
// fires at putManaged entry when the active backend's provider
|
|
129
|
+
// isn't registered with the deployment's registry. Same wire
|
|
130
|
+
// envelope as `BackendNotRegisteredError` so clients have one
|
|
131
|
+
// contract.
|
|
132
|
+
res.status(503).json({
|
|
133
|
+
error_code: 'storage_backend_unavailable',
|
|
134
|
+
error: `provider '${err.providerId}' is not registered with this deployment`,
|
|
135
|
+
provider_id: err.providerId,
|
|
136
|
+
});
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
function send503PutPostPersist(res, err) {
|
|
140
|
+
// Sanitized envelope: artifact_id + provider_id are public; the
|
|
141
|
+
// orphan URI lives on the server side (event log + the row's
|
|
142
|
+
// internal `last_error`) and is NEVER on the wire.
|
|
143
|
+
res.status(503).json({
|
|
144
|
+
error_code: 'put_post_persist_failed',
|
|
145
|
+
error: 'the storage backend accepted the bytes but the server could not finalize the artifact',
|
|
146
|
+
artifact_id: err.artifactId,
|
|
147
|
+
provider_id: err.providerId,
|
|
148
|
+
});
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
function send409ArtifactNotReady(res, err) {
|
|
152
|
+
res.status(409).json({
|
|
153
|
+
error_code: 'artifact_not_ready',
|
|
154
|
+
error: err.message,
|
|
155
|
+
artifact_id: err.artifactId,
|
|
156
|
+
hint: 'The managed upload is still pending finalization; retry after a short delay.',
|
|
157
|
+
});
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
function send410ArtifactUnavailable(res, err) {
|
|
161
|
+
res.status(410).json({
|
|
162
|
+
error_code: 'artifact_unavailable',
|
|
163
|
+
error: err.message,
|
|
164
|
+
artifact_id: err.artifactId,
|
|
165
|
+
reason: err.reason,
|
|
166
|
+
});
|
|
167
|
+
return true;
|
|
168
|
+
}
|
|
169
|
+
function send400Metadata(res, err) {
|
|
170
|
+
const isHeader = err.reason.toLowerCase().includes('header');
|
|
171
|
+
res.status(400).json({
|
|
172
|
+
error_code: isHeader ? 'invalid_metadata_header' : 'invalid_metadata',
|
|
173
|
+
error: err.message,
|
|
174
|
+
hint: err.reason,
|
|
175
|
+
});
|
|
176
|
+
return true;
|
|
177
|
+
}
|
|
178
|
+
function send400LegacyUserId(res, err) {
|
|
179
|
+
res.status(400).json({
|
|
180
|
+
error_code: 'legacy_user_id_unsupported',
|
|
181
|
+
error: err.message,
|
|
182
|
+
hint: 'Pass identity in the X-AtomicMemory-User-Id header instead.',
|
|
183
|
+
});
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-shape projections for the direct storage API.
|
|
3
|
+
*
|
|
4
|
+
* Every public response for the
|
|
5
|
+
* `/v1/storage/artifacts*` routes flows through `formatStoredArtifact`
|
|
6
|
+
* which:
|
|
7
|
+
*
|
|
8
|
+
* 1. Builds the wire object by EXPLICIT named-key construction.
|
|
9
|
+
* Internal columns (`stored_hash`, `last_error`, `delete_attempt_id`)
|
|
10
|
+
* are never read. The plaintext `content_hash` is included only
|
|
11
|
+
* when the row's `disclose_content_hash` was true at put time.
|
|
12
|
+
* 2. Runs the result through provider-specific redaction
|
|
13
|
+
* (`redactArtifactPublic`) so `identifiers` / `provider_details`
|
|
14
|
+
* land in a closed allowlist for each known provider.
|
|
15
|
+
* 3. Validates the projection with `StoredArtifactResponseSchema.strict()`
|
|
16
|
+
* — the formatter is the primary projector; the schema is the
|
|
17
|
+
* defence-in-depth lock that drops any field that slipped past
|
|
18
|
+
* the named-key construction.
|
|
19
|
+
*
|
|
20
|
+
* Callers throw if the schema parse fails; that signals a regression
|
|
21
|
+
* in the projection logic itself (the schema is impossible to
|
|
22
|
+
* violate by data alone since the formatter constructs the object
|
|
23
|
+
* key-by-key).
|
|
24
|
+
*/
|
|
25
|
+
import type { StorageArtifactRow } from '../db/storage-artifact-repository.js';
|
|
26
|
+
import { type StoredArtifactResponse } from '../schemas/storage-schemas.js';
|
|
27
|
+
/**
|
|
28
|
+
* Project a repository row into its wire shape.
|
|
29
|
+
*
|
|
30
|
+
* @throws ZodError if the strict schema rejects the projected object —
|
|
31
|
+
* that means the formatter dropped an internal field on the wire.
|
|
32
|
+
* Tests must catch any regression here.
|
|
33
|
+
*/
|
|
34
|
+
export declare function formatStoredArtifact(row: StorageArtifactRow): StoredArtifactResponse;
|
|
35
|
+
/** Wire headers for `HEAD /v1/storage/artifacts/:id`. */
|
|
36
|
+
export interface ArtifactHeadHeaders {
|
|
37
|
+
contentType: string;
|
|
38
|
+
contentLength: number;
|
|
39
|
+
artifactId: string;
|
|
40
|
+
storageMode: 'pointer' | 'managed';
|
|
41
|
+
storageStatus: string;
|
|
42
|
+
provider: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function formatArtifactHeadHeaders(row: StorageArtifactRow): ArtifactHeadHeaders;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Wire-shape projections for the direct storage API.
|
|
3
|
+
*
|
|
4
|
+
* Every public response for the
|
|
5
|
+
* `/v1/storage/artifacts*` routes flows through `formatStoredArtifact`
|
|
6
|
+
* which:
|
|
7
|
+
*
|
|
8
|
+
* 1. Builds the wire object by EXPLICIT named-key construction.
|
|
9
|
+
* Internal columns (`stored_hash`, `last_error`, `delete_attempt_id`)
|
|
10
|
+
* are never read. The plaintext `content_hash` is included only
|
|
11
|
+
* when the row's `disclose_content_hash` was true at put time.
|
|
12
|
+
* 2. Runs the result through provider-specific redaction
|
|
13
|
+
* (`redactArtifactPublic`) so `identifiers` / `provider_details`
|
|
14
|
+
* land in a closed allowlist for each known provider.
|
|
15
|
+
* 3. Validates the projection with `StoredArtifactResponseSchema.strict()`
|
|
16
|
+
* — the formatter is the primary projector; the schema is the
|
|
17
|
+
* defence-in-depth lock that drops any field that slipped past
|
|
18
|
+
* the named-key construction.
|
|
19
|
+
*
|
|
20
|
+
* Callers throw if the schema parse fails; that signals a regression
|
|
21
|
+
* in the projection logic itself (the schema is impossible to
|
|
22
|
+
* violate by data alone since the formatter constructs the object
|
|
23
|
+
* key-by-key).
|
|
24
|
+
*/
|
|
25
|
+
import { redactArtifactPublic } from '../storage/artifact-public-redaction.js';
|
|
26
|
+
import { StoredArtifactResponseSchema, } from '../schemas/storage-schemas.js';
|
|
27
|
+
/** Closed allowlists of nested keys we may publish per state envelope. */
|
|
28
|
+
const REPLICATION_KEYS = ['desiredCopies', 'confirmedCopies'];
|
|
29
|
+
const VERIFICATION_KEYS = ['providerProofStatus', 'lastVerifiedAt'];
|
|
30
|
+
const RETRIEVAL_KEYS = ['status', 'lastCheckedAt'];
|
|
31
|
+
/**
|
|
32
|
+
* Project a repository row into its wire shape.
|
|
33
|
+
*
|
|
34
|
+
* @throws ZodError if the strict schema rejects the projected object —
|
|
35
|
+
* that means the formatter dropped an internal field on the wire.
|
|
36
|
+
* Tests must catch any regression here.
|
|
37
|
+
*/
|
|
38
|
+
export function formatStoredArtifact(row) {
|
|
39
|
+
const redacted = redactArtifactPublic(row.provider, {
|
|
40
|
+
identifiers: row.identifiers,
|
|
41
|
+
providerDetails: row.providerDetails,
|
|
42
|
+
});
|
|
43
|
+
const wire = {
|
|
44
|
+
artifact_id: row.id,
|
|
45
|
+
provider: row.provider,
|
|
46
|
+
mode: row.mode,
|
|
47
|
+
uri: row.uri,
|
|
48
|
+
status: row.status,
|
|
49
|
+
size_bytes: row.sizeBytes,
|
|
50
|
+
content_type: row.contentType,
|
|
51
|
+
content_encoding: row.contentEncoding,
|
|
52
|
+
identifiers: redacted.identifiers,
|
|
53
|
+
lifecycle: deriveLifecycle(row),
|
|
54
|
+
metadata: projectPublicMetadata(row.metadata),
|
|
55
|
+
created_at: row.createdAt.toISOString(),
|
|
56
|
+
updated_at: row.updatedAt.toISOString(),
|
|
57
|
+
};
|
|
58
|
+
if (row.discloseContentHash && row.plaintextHash !== null) {
|
|
59
|
+
wire.content_hash = row.plaintextHash;
|
|
60
|
+
}
|
|
61
|
+
if (Object.keys(redacted.providerDetails).length > 0) {
|
|
62
|
+
wire.provider_details = redacted.providerDetails;
|
|
63
|
+
}
|
|
64
|
+
const replication = projectStateEnvelope(row.replication, REPLICATION_KEYS);
|
|
65
|
+
if (replication !== null)
|
|
66
|
+
wire.replication = replication;
|
|
67
|
+
const verification = projectStateEnvelope(row.verification, VERIFICATION_KEYS);
|
|
68
|
+
if (verification !== null)
|
|
69
|
+
wire.verification = verification;
|
|
70
|
+
const retrieval = projectStateEnvelope(row.retrieval, RETRIEVAL_KEYS);
|
|
71
|
+
if (retrieval !== null)
|
|
72
|
+
wire.retrieval = retrieval;
|
|
73
|
+
return StoredArtifactResponseSchema.parse(wire);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Lifecycle is a derived projection from `(provider, mode)`: pointer
|
|
77
|
+
* artifacts have no async lifecycle (`availability: 'immediate'`,
|
|
78
|
+
* no delete semantics); managed artifacts get the location-addressed
|
|
79
|
+
* shape on `local_fs`/`s3` and delayed/tombstone semantics on
|
|
80
|
+
* content-addressed eventual providers (`filecoin`). Any
|
|
81
|
+
* other backend reports an empty envelope (fail-closed). The row's
|
|
82
|
+
* `lifecycle` JSONB column is reserved for future per-row overrides;
|
|
83
|
+
* the derived projection currently wins.
|
|
84
|
+
*/
|
|
85
|
+
function deriveLifecycle(row) {
|
|
86
|
+
if (row.mode === 'pointer')
|
|
87
|
+
return { availability: 'immediate' };
|
|
88
|
+
if (row.provider === 'local_fs' || row.provider === 's3') {
|
|
89
|
+
return { availability: 'immediate', deleteSemantics: 'delete' };
|
|
90
|
+
}
|
|
91
|
+
if (row.provider === 'filecoin') {
|
|
92
|
+
return { availability: 'delayed', deleteSemantics: 'tombstone' };
|
|
93
|
+
}
|
|
94
|
+
return {};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Defensive projection for the public `metadata` field.
|
|
98
|
+
*
|
|
99
|
+
* Write paths validate metadata with `validateArtifactMetadata`
|
|
100
|
+
* (closed leaf-type set: string | number | boolean; ≤4 KiB), but a
|
|
101
|
+
* row that was inserted before that check existed — or via a
|
|
102
|
+
* direct SQL ops fix — could carry arrays, nested objects, or
|
|
103
|
+
* other non-leaf values. The previous formatter blindly cast the
|
|
104
|
+
* raw JSONB through `as Record<string, string | number | boolean>`,
|
|
105
|
+
* which silently leaked the unsanitized shape onto the wire.
|
|
106
|
+
*
|
|
107
|
+
* This projection iterates the row's own keys and emits ONLY the
|
|
108
|
+
* leaf-type entries; everything else (arrays, nested objects,
|
|
109
|
+
* null, undefined, functions) is dropped. Non-object inputs
|
|
110
|
+
* project to `{}`. The closed allowlist matches the write-side
|
|
111
|
+
* `ArtifactMetadata` contract.
|
|
112
|
+
*/
|
|
113
|
+
function projectPublicMetadata(value) {
|
|
114
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
115
|
+
return {};
|
|
116
|
+
const out = {};
|
|
117
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
118
|
+
if (typeof raw === 'string' || typeof raw === 'number' || typeof raw === 'boolean') {
|
|
119
|
+
out[key] = raw;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Project a state envelope (replication / verification / retrieval)
|
|
126
|
+
* via the same project-then-validate discipline as the top-level
|
|
127
|
+
* artifact: build an allowlisted object by named keys, drop unknown
|
|
128
|
+
* keys, and only emit the envelope when at least one allowlisted
|
|
129
|
+
* key is populated.
|
|
130
|
+
*/
|
|
131
|
+
function projectStateEnvelope(raw, keys) {
|
|
132
|
+
if (raw === null)
|
|
133
|
+
return null;
|
|
134
|
+
const out = {};
|
|
135
|
+
for (const key of keys) {
|
|
136
|
+
const value = raw[key];
|
|
137
|
+
if (value === undefined || value === null)
|
|
138
|
+
continue;
|
|
139
|
+
out[key] = value;
|
|
140
|
+
}
|
|
141
|
+
if (Object.keys(out).length === 0)
|
|
142
|
+
return null;
|
|
143
|
+
return out;
|
|
144
|
+
}
|
|
145
|
+
export function formatArtifactHeadHeaders(row) {
|
|
146
|
+
return {
|
|
147
|
+
contentType: row.contentType ?? 'application/octet-stream',
|
|
148
|
+
// Pointer artifacts report 0 — the server has no bytes to count.
|
|
149
|
+
contentLength: row.mode === 'managed' ? (row.sizeBytes ?? 0) : 0,
|
|
150
|
+
artifactId: row.id,
|
|
151
|
+
storageMode: row.mode,
|
|
152
|
+
storageStatus: row.status,
|
|
153
|
+
provider: row.provider,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Direct storage API routes (`/v1/storage/*`).
|
|
3
|
+
*
|
|
4
|
+
* Step 3 added `GET /v1/storage/capabilities`; Step 5 adds the
|
|
5
|
+
* artifact CRUD surface on top of the same router:
|
|
6
|
+
*
|
|
7
|
+
* POST /v1/storage/artifacts pointer (JSON body) or
|
|
8
|
+
* ?mode=managed (raw bytes)
|
|
9
|
+
* GET /v1/storage/artifacts/:id public metadata
|
|
10
|
+
* GET /v1/storage/artifacts/:id/content bytes (managed) or 409 (pointer)
|
|
11
|
+
* HEAD /v1/storage/artifacts/:id metadata via response headers
|
|
12
|
+
* DELETE /v1/storage/artifacts/:id?policy=...
|
|
13
|
+
* POST /v1/storage/artifacts/:id/verify backend.head()-based shim
|
|
14
|
+
*
|
|
15
|
+
* Body parsing is per-route:
|
|
16
|
+
* * Pointer-mode put + verify use the standard JSON parser.
|
|
17
|
+
* * Managed-mode put uses `express.raw({ type: '*\/*' })` with the
|
|
18
|
+
* configured byte cap; the route extracts the caller-supplied
|
|
19
|
+
* `X-AtomicMemory-Metadata` header (base64-encoded JSON) and
|
|
20
|
+
* validates it against the decoded-JSON cap.
|
|
21
|
+
*
|
|
22
|
+
* Redaction posture: every public response runs through
|
|
23
|
+
* `formatStoredArtifact` (or its sibling formatters) which projects
|
|
24
|
+
* an allowlisted shape THEN `.strict()`-parses through the schema in
|
|
25
|
+
* `STORAGE_RESPONSE_SCHEMAS`. Internal columns (`stored_hash`,
|
|
26
|
+
* `last_error`, `delete_attempt_id`) never reach the wire.
|
|
27
|
+
*/
|
|
28
|
+
import { Router } from 'express';
|
|
29
|
+
import { type StorageCapabilitiesSnapshot } from '../storage/storage-capabilities.js';
|
|
30
|
+
import { type StorageService } from '../services/storage-service.js';
|
|
31
|
+
/** Composition-time inputs for the storage router. */
|
|
32
|
+
export interface StorageRouterOptions {
|
|
33
|
+
capabilities: StorageCapabilitiesSnapshot;
|
|
34
|
+
service: StorageService;
|
|
35
|
+
/** Body cap for managed-mode uploads (bytes). */
|
|
36
|
+
managedUploadMaxBytes: number;
|
|
37
|
+
}
|
|
38
|
+
export declare function createStorageRouter(opts: StorageRouterOptions): Router;
|