@legioncodeinc/nectar 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +662 -0
- package/README.md +307 -0
- package/dist/api/daemon-api-wiring.d.ts +72 -0
- package/dist/api/daemon-api-wiring.d.ts.map +1 -0
- package/dist/api/daemon-api-wiring.js +150 -0
- package/dist/api/daemon-api-wiring.js.map +1 -0
- package/dist/api/hive-graph-api.d.ts +136 -0
- package/dist/api/hive-graph-api.d.ts.map +1 -0
- package/dist/api/hive-graph-api.js +234 -0
- package/dist/api/hive-graph-api.js.map +1 -0
- package/dist/api/loopback-client.d.ts +27 -0
- package/dist/api/loopback-client.d.ts.map +1 -0
- package/dist/api/loopback-client.js +87 -0
- package/dist/api/loopback-client.js.map +1 -0
- package/dist/api/router.d.ts +172 -0
- package/dist/api/router.d.ts.map +1 -0
- package/dist/api/router.js +212 -0
- package/dist/api/router.js.map +1 -0
- package/dist/api/status-query.d.ts +49 -0
- package/dist/api/status-query.d.ts.map +1 -0
- package/dist/api/status-query.js +103 -0
- package/dist/api/status-query.js.map +1 -0
- package/dist/brood-guard.d.ts +24 -0
- package/dist/brood-guard.d.ts.map +1 -0
- package/dist/brood-guard.js +19 -0
- package/dist/brood-guard.js.map +1 -0
- package/dist/brood-prereqs.d.ts +62 -0
- package/dist/brood-prereqs.d.ts.map +1 -0
- package/dist/brood-prereqs.js +87 -0
- package/dist/brood-prereqs.js.map +1 -0
- package/dist/brooding/bucketing.d.ts +68 -0
- package/dist/brooding/bucketing.d.ts.map +1 -0
- package/dist/brooding/bucketing.js +122 -0
- package/dist/brooding/bucketing.js.map +1 -0
- package/dist/brooding/cli.d.ts +78 -0
- package/dist/brooding/cli.d.ts.map +1 -0
- package/dist/brooding/cli.js +140 -0
- package/dist/brooding/cli.js.map +1 -0
- package/dist/brooding/constants.d.ts +75 -0
- package/dist/brooding/constants.d.ts.map +1 -0
- package/dist/brooding/constants.js +91 -0
- package/dist/brooding/constants.js.map +1 -0
- package/dist/brooding/cost.d.ts +110 -0
- package/dist/brooding/cost.d.ts.map +1 -0
- package/dist/brooding/cost.js +96 -0
- package/dist/brooding/cost.js.map +1 -0
- package/dist/brooding/describe.d.ts +152 -0
- package/dist/brooding/describe.d.ts.map +1 -0
- package/dist/brooding/describe.js +281 -0
- package/dist/brooding/describe.js.map +1 -0
- package/dist/brooding/discovery.d.ts +116 -0
- package/dist/brooding/discovery.d.ts.map +1 -0
- package/dist/brooding/discovery.js +179 -0
- package/dist/brooding/discovery.js.map +1 -0
- package/dist/brooding/index.d.ts +23 -0
- package/dist/brooding/index.d.ts.map +1 -0
- package/dist/brooding/index.js +33 -0
- package/dist/brooding/index.js.map +1 -0
- package/dist/brooding/pipeline-async.d.ts +97 -0
- package/dist/brooding/pipeline-async.d.ts.map +1 -0
- package/dist/brooding/pipeline-async.js +364 -0
- package/dist/brooding/pipeline-async.js.map +1 -0
- package/dist/brooding/pipeline.d.ts +198 -0
- package/dist/brooding/pipeline.d.ts.map +1 -0
- package/dist/brooding/pipeline.js +454 -0
- package/dist/brooding/pipeline.js.map +1 -0
- package/dist/brooding/precheck.d.ts +52 -0
- package/dist/brooding/precheck.d.ts.map +1 -0
- package/dist/brooding/precheck.js +143 -0
- package/dist/brooding/precheck.js.map +1 -0
- package/dist/brooding/resumability.d.ts +57 -0
- package/dist/brooding/resumability.d.ts.map +1 -0
- package/dist/brooding/resumability.js +46 -0
- package/dist/brooding/resumability.js.map +1 -0
- package/dist/cli.d.ts +139 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +912 -0
- package/dist/cli.js.map +1 -0
- package/dist/config-file.d.ts +52 -0
- package/dist/config-file.d.ts.map +1 -0
- package/dist/config-file.js +130 -0
- package/dist/config-file.js.map +1 -0
- package/dist/config.d.ts +49 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +98 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon.d.ts +265 -0
- package/dist/daemon.d.ts.map +1 -0
- package/dist/daemon.js +664 -0
- package/dist/daemon.js.map +1 -0
- package/dist/doctor-registry.d.ts +134 -0
- package/dist/doctor-registry.d.ts.map +1 -0
- package/dist/doctor-registry.js +173 -0
- package/dist/doctor-registry.js.map +1 -0
- package/dist/embeddings/cohere-portkey.d.ts +67 -0
- package/dist/embeddings/cohere-portkey.d.ts.map +1 -0
- package/dist/embeddings/cohere-portkey.js +171 -0
- package/dist/embeddings/cohere-portkey.js.map +1 -0
- package/dist/embeddings/config.d.ts +74 -0
- package/dist/embeddings/config.d.ts.map +1 -0
- package/dist/embeddings/config.js +131 -0
- package/dist/embeddings/config.js.map +1 -0
- package/dist/embeddings/guard.d.ts +34 -0
- package/dist/embeddings/guard.d.ts.map +1 -0
- package/dist/embeddings/guard.js +67 -0
- package/dist/embeddings/guard.js.map +1 -0
- package/dist/embeddings/hosted-portkey.d.ts +73 -0
- package/dist/embeddings/hosted-portkey.d.ts.map +1 -0
- package/dist/embeddings/hosted-portkey.js +179 -0
- package/dist/embeddings/hosted-portkey.js.map +1 -0
- package/dist/embeddings/http.d.ts +33 -0
- package/dist/embeddings/http.d.ts.map +1 -0
- package/dist/embeddings/http.js +19 -0
- package/dist/embeddings/http.js.map +1 -0
- package/dist/embeddings/index.d.ts +17 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/index.js +17 -0
- package/dist/embeddings/index.js.map +1 -0
- package/dist/embeddings/local-nomic.d.ts +78 -0
- package/dist/embeddings/local-nomic.d.ts.map +1 -0
- package/dist/embeddings/local-nomic.js +126 -0
- package/dist/embeddings/local-nomic.js.map +1 -0
- package/dist/embeddings/provider.d.ts +79 -0
- package/dist/embeddings/provider.d.ts.map +1 -0
- package/dist/embeddings/provider.js +50 -0
- package/dist/embeddings/provider.js.map +1 -0
- package/dist/enricher/config.d.ts +43 -0
- package/dist/enricher/config.d.ts.map +1 -0
- package/dist/enricher/config.js +34 -0
- package/dist/enricher/config.js.map +1 -0
- package/dist/enricher/content-cache.d.ts +29 -0
- package/dist/enricher/content-cache.d.ts.map +1 -0
- package/dist/enricher/content-cache.js +24 -0
- package/dist/enricher/content-cache.js.map +1 -0
- package/dist/enricher/cycle.d.ts +71 -0
- package/dist/enricher/cycle.d.ts.map +1 -0
- package/dist/enricher/cycle.js +319 -0
- package/dist/enricher/cycle.js.map +1 -0
- package/dist/enricher/describe.d.ts +61 -0
- package/dist/enricher/describe.d.ts.map +1 -0
- package/dist/enricher/describe.js +175 -0
- package/dist/enricher/describe.js.map +1 -0
- package/dist/enricher/failure.d.ts +25 -0
- package/dist/enricher/failure.d.ts.map +1 -0
- package/dist/enricher/failure.js +46 -0
- package/dist/enricher/failure.js.map +1 -0
- package/dist/enricher/index.d.ts +22 -0
- package/dist/enricher/index.d.ts.map +1 -0
- package/dist/enricher/index.js +22 -0
- package/dist/enricher/index.js.map +1 -0
- package/dist/enricher/jaccard.d.ts +11 -0
- package/dist/enricher/jaccard.d.ts.map +1 -0
- package/dist/enricher/jaccard.js +29 -0
- package/dist/enricher/jaccard.js.map +1 -0
- package/dist/enricher/loop.d.ts +22 -0
- package/dist/enricher/loop.d.ts.map +1 -0
- package/dist/enricher/loop.js +34 -0
- package/dist/enricher/loop.js.map +1 -0
- package/dist/enricher/meaningful-change.d.ts +28 -0
- package/dist/enricher/meaningful-change.d.ts.map +1 -0
- package/dist/enricher/meaningful-change.js +41 -0
- package/dist/enricher/meaningful-change.js.map +1 -0
- package/dist/enricher/observability.d.ts +22 -0
- package/dist/enricher/observability.d.ts.map +1 -0
- package/dist/enricher/observability.js +55 -0
- package/dist/enricher/observability.js.map +1 -0
- package/dist/enricher/pending-query.d.ts +35 -0
- package/dist/enricher/pending-query.d.ts.map +1 -0
- package/dist/enricher/pending-query.js +54 -0
- package/dist/enricher/pending-query.js.map +1 -0
- package/dist/enricher/sql-update.d.ts +7 -0
- package/dist/enricher/sql-update.d.ts.map +1 -0
- package/dist/enricher/sql-update.js +22 -0
- package/dist/enricher/sql-update.js.map +1 -0
- package/dist/enricher/store-adapter.d.ts +98 -0
- package/dist/enricher/store-adapter.d.ts.map +1 -0
- package/dist/enricher/store-adapter.js +129 -0
- package/dist/enricher/store-adapter.js.map +1 -0
- package/dist/enricher/store.d.ts +58 -0
- package/dist/enricher/store.d.ts.map +1 -0
- package/dist/enricher/store.js +126 -0
- package/dist/enricher/store.js.map +1 -0
- package/dist/enricher/tokenize.d.ts +10 -0
- package/dist/enricher/tokenize.d.ts.map +1 -0
- package/dist/enricher/tokenize.js +28 -0
- package/dist/enricher/tokenize.js.map +1 -0
- package/dist/errors.d.ts +41 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/health.d.ts +147 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/health.js +168 -0
- package/dist/health.js.map +1 -0
- package/dist/hive-graph/deeplake-credentials.d.ts +68 -0
- package/dist/hive-graph/deeplake-credentials.d.ts.map +1 -0
- package/dist/hive-graph/deeplake-credentials.js +135 -0
- package/dist/hive-graph/deeplake-credentials.js.map +1 -0
- package/dist/hive-graph/deeplake-heal.d.ts +63 -0
- package/dist/hive-graph/deeplake-heal.d.ts.map +1 -0
- package/dist/hive-graph/deeplake-heal.js +118 -0
- package/dist/hive-graph/deeplake-heal.js.map +1 -0
- package/dist/hive-graph/deeplake-store.d.ts +199 -0
- package/dist/hive-graph/deeplake-store.d.ts.map +1 -0
- package/dist/hive-graph/deeplake-store.js +541 -0
- package/dist/hive-graph/deeplake-store.js.map +1 -0
- package/dist/hive-graph/deeplake-transport.d.ts +89 -0
- package/dist/hive-graph/deeplake-transport.d.ts.map +1 -0
- package/dist/hive-graph/deeplake-transport.js +145 -0
- package/dist/hive-graph/deeplake-transport.js.map +1 -0
- package/dist/hive-graph/hash.d.ts +3 -0
- package/dist/hive-graph/hash.d.ts.map +1 -0
- package/dist/hive-graph/hash.js +12 -0
- package/dist/hive-graph/hash.js.map +1 -0
- package/dist/hive-graph/memory-store.d.ts +39 -0
- package/dist/hive-graph/memory-store.d.ts.map +1 -0
- package/dist/hive-graph/memory-store.js +125 -0
- package/dist/hive-graph/memory-store.js.map +1 -0
- package/dist/hive-graph/model.d.ts +109 -0
- package/dist/hive-graph/model.d.ts.map +1 -0
- package/dist/hive-graph/model.js +36 -0
- package/dist/hive-graph/model.js.map +1 -0
- package/dist/hive-graph/paths.d.ts +7 -0
- package/dist/hive-graph/paths.d.ts.map +1 -0
- package/dist/hive-graph/paths.js +26 -0
- package/dist/hive-graph/paths.js.map +1 -0
- package/dist/hive-graph/project-scope.d.ts +99 -0
- package/dist/hive-graph/project-scope.d.ts.map +1 -0
- package/dist/hive-graph/project-scope.js +286 -0
- package/dist/hive-graph/project-scope.js.map +1 -0
- package/dist/hive-graph/schema.d.ts +53 -0
- package/dist/hive-graph/schema.d.ts.map +1 -0
- package/dist/hive-graph/schema.js +139 -0
- package/dist/hive-graph/schema.js.map +1 -0
- package/dist/hive-graph/search-types.d.ts +82 -0
- package/dist/hive-graph/search-types.d.ts.map +1 -0
- package/dist/hive-graph/search-types.js +2 -0
- package/dist/hive-graph/search-types.js.map +1 -0
- package/dist/hive-graph/search.d.ts +51 -0
- package/dist/hive-graph/search.d.ts.map +1 -0
- package/dist/hive-graph/search.js +417 -0
- package/dist/hive-graph/search.js.map +1 -0
- package/dist/hive-graph/sql-guards.d.ts +99 -0
- package/dist/hive-graph/sql-guards.d.ts.map +1 -0
- package/dist/hive-graph/sql-guards.js +129 -0
- package/dist/hive-graph/sql-guards.js.map +1 -0
- package/dist/hive-graph/store.d.ts +151 -0
- package/dist/hive-graph/store.d.ts.map +1 -0
- package/dist/hive-graph/store.js +2 -0
- package/dist/hive-graph/store.js.map +1 -0
- package/dist/hive-graph/ulid.d.ts +14 -0
- package/dist/hive-graph/ulid.d.ts.map +1 -0
- package/dist/hive-graph/ulid.js +109 -0
- package/dist/hive-graph/ulid.js.map +1 -0
- package/dist/hivedoctor-registry.d.ts +111 -0
- package/dist/hivedoctor-registry.d.ts.map +1 -0
- package/dist/hivedoctor-registry.js +143 -0
- package/dist/hivedoctor-registry.js.map +1 -0
- package/dist/index.d.ts +106 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +78 -0
- package/dist/index.js.map +1 -0
- package/dist/lock.d.ts +66 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +282 -0
- package/dist/lock.js.map +1 -0
- package/dist/poll-loop.d.ts +71 -0
- package/dist/poll-loop.d.ts.map +1 -0
- package/dist/poll-loop.js +130 -0
- package/dist/poll-loop.js.map +1 -0
- package/dist/portkey/config.d.ts +46 -0
- package/dist/portkey/config.d.ts.map +1 -0
- package/dist/portkey/config.js +68 -0
- package/dist/portkey/config.js.map +1 -0
- package/dist/portkey/describe-model.d.ts +53 -0
- package/dist/portkey/describe-model.d.ts.map +1 -0
- package/dist/portkey/describe-model.js +56 -0
- package/dist/portkey/describe-model.js.map +1 -0
- package/dist/portkey/headers.d.ts +31 -0
- package/dist/portkey/headers.d.ts.map +1 -0
- package/dist/portkey/headers.js +37 -0
- package/dist/portkey/headers.js.map +1 -0
- package/dist/portkey/transport.d.ts +89 -0
- package/dist/portkey/transport.d.ts.map +1 -0
- package/dist/portkey/transport.js +167 -0
- package/dist/portkey/transport.js.map +1 -0
- package/dist/projection/format.d.ts +51 -0
- package/dist/projection/format.d.ts.map +1 -0
- package/dist/projection/format.js +81 -0
- package/dist/projection/format.js.map +1 -0
- package/dist/projection/generate.d.ts +31 -0
- package/dist/projection/generate.d.ts.map +1 -0
- package/dist/projection/generate.js +83 -0
- package/dist/projection/generate.js.map +1 -0
- package/dist/projection/inherit.d.ts +27 -0
- package/dist/projection/inherit.d.ts.map +1 -0
- package/dist/projection/inherit.js +128 -0
- package/dist/projection/inherit.js.map +1 -0
- package/dist/projection/load.d.ts +47 -0
- package/dist/projection/load.d.ts.map +1 -0
- package/dist/projection/load.js +258 -0
- package/dist/projection/load.js.map +1 -0
- package/dist/projection/store-adapter.d.ts +42 -0
- package/dist/projection/store-adapter.d.ts.map +1 -0
- package/dist/projection/store-adapter.js +42 -0
- package/dist/projection/store-adapter.js.map +1 -0
- package/dist/projection/write.d.ts +79 -0
- package/dist/projection/write.d.ts.map +1 -0
- package/dist/projection/write.js +122 -0
- package/dist/projection/write.js.map +1 -0
- package/dist/registration/classify.d.ts +33 -0
- package/dist/registration/classify.d.ts.map +1 -0
- package/dist/registration/classify.js +32 -0
- package/dist/registration/classify.js.map +1 -0
- package/dist/registration/copy-detect.d.ts +22 -0
- package/dist/registration/copy-detect.d.ts.map +1 -0
- package/dist/registration/copy-detect.js +12 -0
- package/dist/registration/copy-detect.js.map +1 -0
- package/dist/registration/disk-fs.d.ts +41 -0
- package/dist/registration/disk-fs.d.ts.map +1 -0
- package/dist/registration/disk-fs.js +175 -0
- package/dist/registration/disk-fs.js.map +1 -0
- package/dist/registration/fs-watch.d.ts +114 -0
- package/dist/registration/fs-watch.d.ts.map +1 -0
- package/dist/registration/fs-watch.js +266 -0
- package/dist/registration/fs-watch.js.map +1 -0
- package/dist/registration/ignore.d.ts +77 -0
- package/dist/registration/ignore.d.ts.map +1 -0
- package/dist/registration/ignore.js +249 -0
- package/dist/registration/ignore.js.map +1 -0
- package/dist/registration/ladder.d.ts +211 -0
- package/dist/registration/ladder.d.ts.map +1 -0
- package/dist/registration/ladder.js +378 -0
- package/dist/registration/ladder.js.map +1 -0
- package/dist/registration/paths-safe.d.ts +21 -0
- package/dist/registration/paths-safe.d.ts.map +1 -0
- package/dist/registration/paths-safe.js +88 -0
- package/dist/registration/paths-safe.js.map +1 -0
- package/dist/registration/prune-cli.d.ts +48 -0
- package/dist/registration/prune-cli.d.ts.map +1 -0
- package/dist/registration/prune-cli.js +57 -0
- package/dist/registration/prune-cli.js.map +1 -0
- package/dist/registration/review-cli.d.ts +42 -0
- package/dist/registration/review-cli.d.ts.map +1 -0
- package/dist/registration/review-cli.js +110 -0
- package/dist/registration/review-cli.js.map +1 -0
- package/dist/registration/review-store.d.ts +73 -0
- package/dist/registration/review-store.d.ts.map +1 -0
- package/dist/registration/review-store.js +243 -0
- package/dist/registration/review-store.js.map +1 -0
- package/dist/registration/service.d.ts +196 -0
- package/dist/registration/service.d.ts.map +1 -0
- package/dist/registration/service.js +384 -0
- package/dist/registration/service.js.map +1 -0
- package/dist/registration/store-bridge.d.ts +133 -0
- package/dist/registration/store-bridge.d.ts.map +1 -0
- package/dist/registration/store-bridge.js +159 -0
- package/dist/registration/store-bridge.js.map +1 -0
- package/dist/registration/tlsh.d.ts +125 -0
- package/dist/registration/tlsh.d.ts.map +1 -0
- package/dist/registration/tlsh.js +274 -0
- package/dist/registration/tlsh.js.map +1 -0
- package/dist/server.d.ts +26 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +156 -0
- package/dist/server.js.map +1 -0
- package/dist/service/argv.d.ts +52 -0
- package/dist/service/argv.d.ts.map +1 -0
- package/dist/service/argv.js +127 -0
- package/dist/service/argv.js.map +1 -0
- package/dist/service/command-runner.d.ts +54 -0
- package/dist/service/command-runner.d.ts.map +1 -0
- package/dist/service/command-runner.js +55 -0
- package/dist/service/command-runner.js.map +1 -0
- package/dist/service/index.d.ts +83 -0
- package/dist/service/index.d.ts.map +1 -0
- package/dist/service/index.js +270 -0
- package/dist/service/index.js.map +1 -0
- package/dist/service/platform.d.ts +110 -0
- package/dist/service/platform.d.ts.map +1 -0
- package/dist/service/platform.js +157 -0
- package/dist/service/platform.js.map +1 -0
- package/dist/service/templates.d.ts +88 -0
- package/dist/service/templates.d.ts.map +1 -0
- package/dist/service/templates.js +212 -0
- package/dist/service/templates.js.map +1 -0
- package/dist/source-graph/deeplake-credentials.d.ts +57 -0
- package/dist/source-graph/deeplake-credentials.d.ts.map +1 -0
- package/dist/source-graph/deeplake-credentials.js +109 -0
- package/dist/source-graph/deeplake-credentials.js.map +1 -0
- package/dist/source-graph/deeplake-heal.d.ts +53 -0
- package/dist/source-graph/deeplake-heal.d.ts.map +1 -0
- package/dist/source-graph/deeplake-heal.js +41 -0
- package/dist/source-graph/deeplake-heal.js.map +1 -0
- package/dist/source-graph/deeplake-store.d.ts +151 -0
- package/dist/source-graph/deeplake-store.d.ts.map +1 -0
- package/dist/source-graph/deeplake-store.js +389 -0
- package/dist/source-graph/deeplake-store.js.map +1 -0
- package/dist/source-graph/deeplake-transport.d.ts +74 -0
- package/dist/source-graph/deeplake-transport.d.ts.map +1 -0
- package/dist/source-graph/deeplake-transport.js +107 -0
- package/dist/source-graph/deeplake-transport.js.map +1 -0
- package/dist/source-graph/hash.d.ts +3 -0
- package/dist/source-graph/hash.d.ts.map +1 -0
- package/dist/source-graph/hash.js +12 -0
- package/dist/source-graph/hash.js.map +1 -0
- package/dist/source-graph/memory-store.d.ts +32 -0
- package/dist/source-graph/memory-store.d.ts.map +1 -0
- package/dist/source-graph/memory-store.js +81 -0
- package/dist/source-graph/memory-store.js.map +1 -0
- package/dist/source-graph/model.d.ts +102 -0
- package/dist/source-graph/model.d.ts.map +1 -0
- package/dist/source-graph/model.js +36 -0
- package/dist/source-graph/model.js.map +1 -0
- package/dist/source-graph/paths.d.ts +7 -0
- package/dist/source-graph/paths.d.ts.map +1 -0
- package/dist/source-graph/paths.js +26 -0
- package/dist/source-graph/paths.js.map +1 -0
- package/dist/source-graph/schema.d.ts +44 -0
- package/dist/source-graph/schema.d.ts.map +1 -0
- package/dist/source-graph/schema.js +123 -0
- package/dist/source-graph/schema.js.map +1 -0
- package/dist/source-graph/sql-guards.d.ts +99 -0
- package/dist/source-graph/sql-guards.d.ts.map +1 -0
- package/dist/source-graph/sql-guards.js +129 -0
- package/dist/source-graph/sql-guards.js.map +1 -0
- package/dist/source-graph/store.d.ts +101 -0
- package/dist/source-graph/store.d.ts.map +1 -0
- package/dist/source-graph/store.js +2 -0
- package/dist/source-graph/store.js.map +1 -0
- package/dist/source-graph/ulid.d.ts +9 -0
- package/dist/source-graph/ulid.d.ts.map +1 -0
- package/dist/source-graph/ulid.js +61 -0
- package/dist/source-graph/ulid.js.map +1 -0
- package/dist/telemetry/checkin.d.ts +66 -0
- package/dist/telemetry/checkin.d.ts.map +1 -0
- package/dist/telemetry/checkin.js +142 -0
- package/dist/telemetry/checkin.js.map +1 -0
- package/dist/telemetry/db.d.ts +34 -0
- package/dist/telemetry/db.d.ts.map +1 -0
- package/dist/telemetry/db.js +122 -0
- package/dist/telemetry/db.js.map +1 -0
- package/dist/telemetry/index.d.ts +76 -0
- package/dist/telemetry/index.d.ts.map +1 -0
- package/dist/telemetry/index.js +98 -0
- package/dist/telemetry/index.js.map +1 -0
- package/dist/telemetry/logs.d.ts +83 -0
- package/dist/telemetry/logs.d.ts.map +1 -0
- package/dist/telemetry/logs.js +110 -0
- package/dist/telemetry/logs.js.map +1 -0
- package/dist/telemetry/metrics.d.ts +82 -0
- package/dist/telemetry/metrics.d.ts.map +1 -0
- package/dist/telemetry/metrics.js +148 -0
- package/dist/telemetry/metrics.js.map +1 -0
- package/dist/telemetry-usage/emit.d.ts +105 -0
- package/dist/telemetry-usage/emit.d.ts.map +1 -0
- package/dist/telemetry-usage/emit.js +267 -0
- package/dist/telemetry-usage/emit.js.map +1 -0
- package/dist/telemetry-usage/posthog-key.d.ts +22 -0
- package/dist/telemetry-usage/posthog-key.d.ts.map +1 -0
- package/dist/telemetry-usage/posthog-key.js +22 -0
- package/dist/telemetry-usage/posthog-key.js.map +1 -0
- package/dist/worker.d.ts +69 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +91 -0
- package/dist/worker.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embeddings-provider config resolution (PRD-014a).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the ONE embeddings switch (DECISION #5) plus each provider's
|
|
5
|
+
* settings, with the daemon's precedence: explicit overrides -> environment ->
|
|
6
|
+
* built-in defaults (mirrors `src/config.ts` and `src/portkey/config.ts`). The
|
|
7
|
+
* selector is a three-value setting (`off | local | hosted`) that EXTENDS the
|
|
8
|
+
* vault `embeddings.enabled` boolean rather than sitting beside a parallel enable
|
|
9
|
+
* flag: a legacy truthy/falsey env value maps onto `local`/`off` so the switch is
|
|
10
|
+
* a genuine superset of the old boolean. Never throws at import time.
|
|
11
|
+
*
|
|
12
|
+
* Env names follow the `NECTAR_*` convention:
|
|
13
|
+
* - `NECTAR_EMBEDDINGS_PROVIDER` off | local | hosted (default local, AC-1)
|
|
14
|
+
* - `NECTAR_EMBED_HOST` / `_PORT` / `_TIMEOUT_MS` local nomic daemon transport
|
|
15
|
+
* - `NECTAR_EMBEDDINGS_HOSTED_MODEL` hosted embed model id (default text-embedding-3-small, decision #30 as amended)
|
|
16
|
+
* - `NECTAR_EMBEDDINGS_OUTPUT_DIMENSION` requested output dim (default 768, decision #30)
|
|
17
|
+
* - `NECTAR_PORTKEY_API_KEY` / `_CONFIG` the SAME gateway credentials the chat transport reads
|
|
18
|
+
*/
|
|
19
|
+
import { type HostedEmbeddingsConfig } from "./hosted-portkey.js";
|
|
20
|
+
import { type LocalNomicConfig } from "./local-nomic.js";
|
|
21
|
+
import { type EmbedProviderSelector } from "./provider.js";
|
|
22
|
+
/** The fully-resolved embeddings config the switch (`resolveEmbedProvider`) consumes. */
|
|
23
|
+
export interface ResolvedEmbeddingsConfig {
|
|
24
|
+
readonly selector: EmbedProviderSelector;
|
|
25
|
+
readonly local: LocalNomicConfig;
|
|
26
|
+
readonly hosted: HostedEmbeddingsConfig;
|
|
27
|
+
}
|
|
28
|
+
/** Explicit overrides for {@link resolveEmbeddingsConfig} (each wins over env + defaults). */
|
|
29
|
+
export interface EmbeddingsConfigOverrides {
|
|
30
|
+
readonly selector?: EmbedProviderSelector;
|
|
31
|
+
readonly local?: Partial<LocalNomicConfig>;
|
|
32
|
+
readonly hosted?: Partial<HostedEmbeddingsConfig>;
|
|
33
|
+
/** Injectable env bag for tests; defaults to `process.env`. */
|
|
34
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalize a raw selector value into an {@link EmbedProviderSelector}, or
|
|
38
|
+
* `undefined` when it is unrecognized (so the caller falls back to the default).
|
|
39
|
+
* Accepts the three canonical values AND the legacy boolean vocabulary the vault
|
|
40
|
+
* `embeddings.enabled` key used (`true`/`1`/`on`/`yes` -> `local`,
|
|
41
|
+
* `false`/`0`/`off`/`no` -> `off`) so the selector is a superset of the boolean.
|
|
42
|
+
*/
|
|
43
|
+
export declare function normalizeSelector(raw: string | undefined): EmbedProviderSelector | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve the embeddings config. Overrides win, then env, then defaults. The
|
|
46
|
+
* selector defaults to `local` (AC-1 / DECISION #5); the hosted credentials
|
|
47
|
+
* resolve to `null` when Portkey is not keyed (the hosted provider then fails
|
|
48
|
+
* soft to nulls).
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveEmbeddingsConfig(overrides?: EmbeddingsConfigOverrides): ResolvedEmbeddingsConfig;
|
|
51
|
+
/**
|
|
52
|
+
* The model id that produces embeddings under a resolved config, for stamping
|
|
53
|
+
* `embed_model` on persisted rows (PRD-018i / NEC-018 AC-018i.1):
|
|
54
|
+
* - `off` -> `null` (no embeddings are computed)
|
|
55
|
+
* - `local` -> the pinned {@link LOCAL_NOMIC_MODEL_ID}
|
|
56
|
+
* - `hosted` -> the configured hosted model id
|
|
57
|
+
*/
|
|
58
|
+
export declare function activeEmbedModelId(config: ResolvedEmbeddingsConfig): string | null;
|
|
59
|
+
/** The outcome of validating the requested hosted output dimension (PRD-018i / NEC-028 AC-018i.7). */
|
|
60
|
+
export interface EmbedDimensionValidation {
|
|
61
|
+
readonly ok: boolean;
|
|
62
|
+
readonly requested: number;
|
|
63
|
+
readonly expected: number;
|
|
64
|
+
readonly message?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Validate that a hosted output dimension matches the fixed {@link EMBED_DIMS}
|
|
68
|
+
* contract (PRD-018i / NEC-028 AC-018i.7). Any other value is pointless: the
|
|
69
|
+
* `FLOAT4[768]` column and the dim guard reject it, silently nulling every
|
|
70
|
+
* hosted vector. The caller warns loudly or refuses to start on `ok === false`.
|
|
71
|
+
* `off`/`local` selectors do not carry a requested dimension and always pass.
|
|
72
|
+
*/
|
|
73
|
+
export declare function validateEmbedDimension(config: ResolvedEmbeddingsConfig): EmbedDimensionValidation;
|
|
74
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/embeddings/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAML,KAAK,sBAAsB,EAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAKL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAA0B,KAAK,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAEnF,yFAAyF;AACzF,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;CACzC;AAED,8FAA8F;AAC9F,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,CAAC,EAAE,qBAAqB,CAAC;IAC1C,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC,CAAC;IAClD,+DAA+D;IAC/D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CAClC;AAeD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,GAAG,SAAS,CAO5F;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,GAAE,yBAA8B,GAAG,wBAAwB,CA8B3G;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,wBAAwB,GAAG,MAAM,GAAG,IAAI,CAalF;AAED,sGAAsG;AACtG,MAAM,WAAW,wBAAwB;IACvC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,wBAAwB,GAAG,wBAAwB,CAiBjG"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Embeddings-provider config resolution (PRD-014a).
|
|
3
|
+
*
|
|
4
|
+
* Resolves the ONE embeddings switch (DECISION #5) plus each provider's
|
|
5
|
+
* settings, with the daemon's precedence: explicit overrides -> environment ->
|
|
6
|
+
* built-in defaults (mirrors `src/config.ts` and `src/portkey/config.ts`). The
|
|
7
|
+
* selector is a three-value setting (`off | local | hosted`) that EXTENDS the
|
|
8
|
+
* vault `embeddings.enabled` boolean rather than sitting beside a parallel enable
|
|
9
|
+
* flag: a legacy truthy/falsey env value maps onto `local`/`off` so the switch is
|
|
10
|
+
* a genuine superset of the old boolean. Never throws at import time.
|
|
11
|
+
*
|
|
12
|
+
* Env names follow the `NECTAR_*` convention:
|
|
13
|
+
* - `NECTAR_EMBEDDINGS_PROVIDER` off | local | hosted (default local, AC-1)
|
|
14
|
+
* - `NECTAR_EMBED_HOST` / `_PORT` / `_TIMEOUT_MS` local nomic daemon transport
|
|
15
|
+
* - `NECTAR_EMBEDDINGS_HOSTED_MODEL` hosted embed model id (default text-embedding-3-small, decision #30 as amended)
|
|
16
|
+
* - `NECTAR_EMBEDDINGS_OUTPUT_DIMENSION` requested output dim (default 768, decision #30)
|
|
17
|
+
* - `NECTAR_PORTKEY_API_KEY` / `_CONFIG` the SAME gateway credentials the chat transport reads
|
|
18
|
+
*/
|
|
19
|
+
import { DEFAULT_HOSTED_EMBED_MODEL, DEFAULT_HOSTED_MAX_ATTEMPTS, DEFAULT_HOSTED_OUTPUT_DIMENSION, DEFAULT_HOSTED_REQUEST_TIMEOUT_MS, DEFAULT_HOSTED_RETRY_BACKOFF_MS, } from "./hosted-portkey.js";
|
|
20
|
+
import { DEFAULT_LOCAL_EMBED_HOST, DEFAULT_LOCAL_EMBED_PORT, DEFAULT_LOCAL_EMBED_TIMEOUT_MS, LOCAL_NOMIC_MODEL_ID, } from "./local-nomic.js";
|
|
21
|
+
import { PORTKEY_EMBEDDINGS_URL } from "../portkey/headers.js";
|
|
22
|
+
import { EMBED_DIMS } from "../hive-graph/model.js";
|
|
23
|
+
import { DEFAULT_EMBED_PROVIDER } from "./provider.js";
|
|
24
|
+
function envStr(env, name) {
|
|
25
|
+
const raw = env[name];
|
|
26
|
+
if (raw === undefined || raw.trim() === "")
|
|
27
|
+
return undefined;
|
|
28
|
+
return raw;
|
|
29
|
+
}
|
|
30
|
+
function envInt(env, name) {
|
|
31
|
+
const raw = envStr(env, name);
|
|
32
|
+
if (raw === undefined)
|
|
33
|
+
return undefined;
|
|
34
|
+
const parsed = Number.parseInt(raw, 10);
|
|
35
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Normalize a raw selector value into an {@link EmbedProviderSelector}, or
|
|
39
|
+
* `undefined` when it is unrecognized (so the caller falls back to the default).
|
|
40
|
+
* Accepts the three canonical values AND the legacy boolean vocabulary the vault
|
|
41
|
+
* `embeddings.enabled` key used (`true`/`1`/`on`/`yes` -> `local`,
|
|
42
|
+
* `false`/`0`/`off`/`no` -> `off`) so the selector is a superset of the boolean.
|
|
43
|
+
*/
|
|
44
|
+
export function normalizeSelector(raw) {
|
|
45
|
+
if (raw === undefined)
|
|
46
|
+
return undefined;
|
|
47
|
+
const v = raw.trim().toLowerCase();
|
|
48
|
+
if (v === "off" || v === "local" || v === "hosted")
|
|
49
|
+
return v;
|
|
50
|
+
if (v === "true" || v === "1" || v === "on" || v === "yes")
|
|
51
|
+
return "local";
|
|
52
|
+
if (v === "false" || v === "0" || v === "no")
|
|
53
|
+
return "off";
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Resolve the embeddings config. Overrides win, then env, then defaults. The
|
|
58
|
+
* selector defaults to `local` (AC-1 / DECISION #5); the hosted credentials
|
|
59
|
+
* resolve to `null` when Portkey is not keyed (the hosted provider then fails
|
|
60
|
+
* soft to nulls).
|
|
61
|
+
*/
|
|
62
|
+
export function resolveEmbeddingsConfig(overrides = {}) {
|
|
63
|
+
const env = overrides.env ?? process.env;
|
|
64
|
+
const selector = overrides.selector ?? normalizeSelector(env.NECTAR_EMBEDDINGS_PROVIDER) ?? DEFAULT_EMBED_PROVIDER;
|
|
65
|
+
const local = {
|
|
66
|
+
host: overrides.local?.host ?? envStr(env, "NECTAR_EMBED_HOST") ?? DEFAULT_LOCAL_EMBED_HOST,
|
|
67
|
+
port: overrides.local?.port ?? envInt(env, "NECTAR_EMBED_PORT") ?? DEFAULT_LOCAL_EMBED_PORT,
|
|
68
|
+
requestTimeoutMs: overrides.local?.requestTimeoutMs ??
|
|
69
|
+
envInt(env, "NECTAR_EMBED_TIMEOUT_MS") ??
|
|
70
|
+
DEFAULT_LOCAL_EMBED_TIMEOUT_MS,
|
|
71
|
+
};
|
|
72
|
+
const hosted = {
|
|
73
|
+
model: overrides.hosted?.model ?? envStr(env, "NECTAR_EMBEDDINGS_HOSTED_MODEL") ?? DEFAULT_HOSTED_EMBED_MODEL,
|
|
74
|
+
outputDimension: overrides.hosted?.outputDimension ??
|
|
75
|
+
envInt(env, "NECTAR_EMBEDDINGS_OUTPUT_DIMENSION") ??
|
|
76
|
+
DEFAULT_HOSTED_OUTPUT_DIMENSION,
|
|
77
|
+
apiKey: overrides.hosted?.apiKey ?? envStr(env, "NECTAR_PORTKEY_API_KEY") ?? null,
|
|
78
|
+
configId: overrides.hosted?.configId ?? envStr(env, "NECTAR_PORTKEY_CONFIG") ?? null,
|
|
79
|
+
url: overrides.hosted?.url ?? PORTKEY_EMBEDDINGS_URL,
|
|
80
|
+
maxAttempts: overrides.hosted?.maxAttempts ?? DEFAULT_HOSTED_MAX_ATTEMPTS,
|
|
81
|
+
retryBackoffMs: overrides.hosted?.retryBackoffMs ?? DEFAULT_HOSTED_RETRY_BACKOFF_MS,
|
|
82
|
+
requestTimeoutMs: overrides.hosted?.requestTimeoutMs ?? DEFAULT_HOSTED_REQUEST_TIMEOUT_MS,
|
|
83
|
+
};
|
|
84
|
+
return { selector, local, hosted };
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The model id that produces embeddings under a resolved config, for stamping
|
|
88
|
+
* `embed_model` on persisted rows (PRD-018i / NEC-018 AC-018i.1):
|
|
89
|
+
* - `off` -> `null` (no embeddings are computed)
|
|
90
|
+
* - `local` -> the pinned {@link LOCAL_NOMIC_MODEL_ID}
|
|
91
|
+
* - `hosted` -> the configured hosted model id
|
|
92
|
+
*/
|
|
93
|
+
export function activeEmbedModelId(config) {
|
|
94
|
+
switch (config.selector) {
|
|
95
|
+
case "off":
|
|
96
|
+
return null;
|
|
97
|
+
case "local":
|
|
98
|
+
return LOCAL_NOMIC_MODEL_ID;
|
|
99
|
+
case "hosted":
|
|
100
|
+
return config.hosted.model;
|
|
101
|
+
default: {
|
|
102
|
+
const unreachable = config.selector;
|
|
103
|
+
return unreachable;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Validate that a hosted output dimension matches the fixed {@link EMBED_DIMS}
|
|
109
|
+
* contract (PRD-018i / NEC-028 AC-018i.7). Any other value is pointless: the
|
|
110
|
+
* `FLOAT4[768]` column and the dim guard reject it, silently nulling every
|
|
111
|
+
* hosted vector. The caller warns loudly or refuses to start on `ok === false`.
|
|
112
|
+
* `off`/`local` selectors do not carry a requested dimension and always pass.
|
|
113
|
+
*/
|
|
114
|
+
export function validateEmbedDimension(config) {
|
|
115
|
+
if (config.selector !== "hosted") {
|
|
116
|
+
return { ok: true, requested: EMBED_DIMS, expected: EMBED_DIMS };
|
|
117
|
+
}
|
|
118
|
+
const requested = config.hosted.outputDimension;
|
|
119
|
+
if (requested === EMBED_DIMS) {
|
|
120
|
+
return { ok: true, requested, expected: EMBED_DIMS };
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
ok: false,
|
|
124
|
+
requested,
|
|
125
|
+
expected: EMBED_DIMS,
|
|
126
|
+
message: `NECTAR_EMBEDDINGS_OUTPUT_DIMENSION=${requested} does not match the fixed ${EMBED_DIMS}-dim ` +
|
|
127
|
+
`embedding contract (FLOAT4[${EMBED_DIMS}]); every hosted vector would be guard-discarded to null ` +
|
|
128
|
+
`and semantic recall would be permanently lexical-only. Set it to ${EMBED_DIMS} or unset it.`,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/embeddings/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,+BAA+B,EAC/B,iCAAiC,EACjC,+BAA+B,GAEhC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,8BAA8B,EAC9B,oBAAoB,GAErB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAA8B,MAAM,eAAe,CAAC;AAkBnF,SAAS,MAA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,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AACrC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAgC;IACjE,QAAQ,MAAM,CAAC,QAAQ,EAAE,CAAC;QACxB,KAAK,KAAK;YACR,OAAO,IAAI,CAAC;QACd,KAAK,OAAO;YACV,OAAO,oBAAoB,CAAC;QAC9B,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC;QAC7B,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,WAAW,GAAU,MAAM,CAAC,QAAQ,CAAC;YAC3C,OAAO,WAAW,CAAC;QACrB,CAAC;IACH,CAAC;AACH,CAAC;AAUD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAgC;IACrE,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC;QACjC,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IACnE,CAAC;IACD,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC,eAAe,CAAC;IAChD,IAAI,SAAS,KAAK,UAAU,EAAE,CAAC;QAC7B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;IACvD,CAAC;IACD,OAAO;QACL,EAAE,EAAE,KAAK;QACT,SAAS;QACT,QAAQ,EAAE,UAAU;QACpB,OAAO,EACL,sCAAsC,SAAS,6BAA6B,UAAU,OAAO;YAC7F,8BAA8B,UAAU,2DAA2D;YACnG,oEAAoE,UAAU,eAAe;KAChG,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { EmbedProvider, EmbedProviderSelector } from "./provider.js";
|
|
2
|
+
/** One discarded-vector event: which provider produced it, the contract dim, and the actual length. */
|
|
3
|
+
export interface DimRejection {
|
|
4
|
+
/** The provider whose vector was discarded (`local` or `cohere`). */
|
|
5
|
+
readonly provider: EmbedProviderSelector;
|
|
6
|
+
/** The required dimension (always {@link EMBED_DIMS} = 768). */
|
|
7
|
+
readonly expected: number;
|
|
8
|
+
/** The actual length of the rejected vector. */
|
|
9
|
+
readonly actual: number;
|
|
10
|
+
}
|
|
11
|
+
/** The observability sink for a discarded wrong-dim vector (the `embed.dim_rejected` count/log seam). */
|
|
12
|
+
export type DimRejectionSink = (rejection: DimRejection) => void;
|
|
13
|
+
/**
|
|
14
|
+
* A body-free stderr sink an integrator can wire as the default observability for
|
|
15
|
+
* a discarded vector: it emits the dimension mismatch (never the vector itself)
|
|
16
|
+
* so an operator sees WHY recall degraded, mirroring honeycomb's "observable, not
|
|
17
|
+
* silently swallowed" posture. Never throws.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stderrDimRejectionSink(rejection: DimRejection): void;
|
|
20
|
+
/**
|
|
21
|
+
* Apply the dim guard to ONE vector: a `null` passes through, a 768-dim vector
|
|
22
|
+
* passes through, anything else is discarded to `null` and reported to `sink`.
|
|
23
|
+
* `sink` is invoked defensively — a faulty sink never breaks the embed path.
|
|
24
|
+
*/
|
|
25
|
+
export declare function guardVector(vec: number[] | null, provider: EmbedProviderSelector, sink?: DimRejectionSink): number[] | null;
|
|
26
|
+
/**
|
|
27
|
+
* Wrap a computing provider so every returned vector passes the 768-dim guard
|
|
28
|
+
* (AC-3). The wrapper preserves the provider's `kind` and its 1:1 ordering; a
|
|
29
|
+
* wrong-dim vector at any position becomes `null` (reported to `sink`) while the
|
|
30
|
+
* rest pass through. The wrapped `embed` inherits the provider's never-throw
|
|
31
|
+
* contract.
|
|
32
|
+
*/
|
|
33
|
+
export declare function withDimGuard(provider: EmbedProvider, sink?: DimRejectionSink): EmbedProvider;
|
|
34
|
+
//# sourceMappingURL=guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.d.ts","sourceRoot":"","sources":["../../src/embeddings/guard.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE1E,uGAAuG;AACvG,MAAM,WAAW,YAAY;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,gDAAgD;IAChD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED,yGAAyG;AACzG,MAAM,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,YAAY,KAAK,IAAI,CAAC;AAEjE;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,YAAY,GAAG,IAAI,CAIpE;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CACzB,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EACpB,QAAQ,EAAE,qBAAqB,EAC/B,IAAI,CAAC,EAAE,gBAAgB,GACtB,MAAM,EAAE,GAAG,IAAI,CAYjB;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,aAAa,CAQ5F"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The 768-dim guard applied at the provider boundary (PRD-014 AC-3 / 014b
|
|
3
|
+
* US-014b.2 / 014c US-014c.3).
|
|
4
|
+
*
|
|
5
|
+
* The 768-dim contract is load-bearing: it ties to the `FLOAT4[768]` column and
|
|
6
|
+
* `EMBED_DIMS` (`hive-graph/model.ts`), matching `sessions.message_embedding`
|
|
7
|
+
* and `memory.summary_embedding` so the hybrid recall vector index sees one
|
|
8
|
+
* consistent dimensionality across every semantic arm
|
|
9
|
+
* (`ai/enricher-and-llm-model.md` § Embeddings). A vector of the wrong dimension
|
|
10
|
+
* from EITHER provider is discarded HERE — replaced with `null` so the caller
|
|
11
|
+
* leaves the column NULL and recall degrades to BM25, never stored as valid
|
|
12
|
+
* recall data. This is nectar's client-side mirror of honeycomb's
|
|
13
|
+
* `embed.dim_rejected` guard (`honeycomb .../embed-client.ts` returns `null` on
|
|
14
|
+
* `parsed.vector.length !== EMBEDDING_DIMS`).
|
|
15
|
+
*
|
|
16
|
+
* The rejection is reported through an injectable sink so the daemon can count /
|
|
17
|
+
* log it (the `embed.dim_rejected` semantics) without this module depending on a
|
|
18
|
+
* concrete telemetry surface. The default sink is a no-op — a wrong-dim vector
|
|
19
|
+
* still fails soft to `null` whether or not a sink is wired.
|
|
20
|
+
*/
|
|
21
|
+
import { EMBED_DIMS, isValidEmbedding } from "../hive-graph/model.js";
|
|
22
|
+
/**
|
|
23
|
+
* A body-free stderr sink an integrator can wire as the default observability for
|
|
24
|
+
* a discarded vector: it emits the dimension mismatch (never the vector itself)
|
|
25
|
+
* so an operator sees WHY recall degraded, mirroring honeycomb's "observable, not
|
|
26
|
+
* silently swallowed" posture. Never throws.
|
|
27
|
+
*/
|
|
28
|
+
export function stderrDimRejectionSink(rejection) {
|
|
29
|
+
process.stderr.write(`nectar: embed.dim_rejected provider=${rejection.provider} expected=${rejection.expected} actual=${rejection.actual}\n`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Apply the dim guard to ONE vector: a `null` passes through, a 768-dim vector
|
|
33
|
+
* passes through, anything else is discarded to `null` and reported to `sink`.
|
|
34
|
+
* `sink` is invoked defensively — a faulty sink never breaks the embed path.
|
|
35
|
+
*/
|
|
36
|
+
export function guardVector(vec, provider, sink) {
|
|
37
|
+
if (isValidEmbedding(vec))
|
|
38
|
+
return vec;
|
|
39
|
+
// `isValidEmbedding` only returns false for a non-null wrong-length vector, so `vec` is non-null here.
|
|
40
|
+
const actual = vec === null ? 0 : vec.length;
|
|
41
|
+
if (sink !== undefined) {
|
|
42
|
+
try {
|
|
43
|
+
sink({ provider, expected: EMBED_DIMS, actual });
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// A rejection-sink fault is swallowed: observability is best-effort, never breaks the embed path.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Wrap a computing provider so every returned vector passes the 768-dim guard
|
|
53
|
+
* (AC-3). The wrapper preserves the provider's `kind` and its 1:1 ordering; a
|
|
54
|
+
* wrong-dim vector at any position becomes `null` (reported to `sink`) while the
|
|
55
|
+
* rest pass through. The wrapped `embed` inherits the provider's never-throw
|
|
56
|
+
* contract.
|
|
57
|
+
*/
|
|
58
|
+
export function withDimGuard(provider, sink) {
|
|
59
|
+
return {
|
|
60
|
+
kind: provider.kind,
|
|
61
|
+
async embed(texts) {
|
|
62
|
+
const raw = await provider.embed(texts);
|
|
63
|
+
return raw.map((vec) => guardVector(vec, provider.kind, sink));
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guard.js","sourceRoot":"","sources":["../../src/embeddings/guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAgBtE;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CAAC,SAAuB;IAC5D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,uCAAuC,SAAS,CAAC,QAAQ,aAAa,SAAS,CAAC,QAAQ,WAAW,SAAS,CAAC,MAAM,IAAI,CACxH,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CACzB,GAAoB,EACpB,QAA+B,EAC/B,IAAuB;IAEvB,IAAI,gBAAgB,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACtC,uGAAuG;IACvG,MAAM,MAAM,GAAG,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC;IAC7C,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,IAAI,CAAC;YACH,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,kGAAkG;QACpG,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB,EAAE,IAAuB;IAC3E,OAAO;QACL,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,KAAK,CAAC,KAAK,CAAC,KAAwB;YAClC,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACxC,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,WAAW,CAAC,GAAG,EAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;QACjE,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { type FetchLike, type SleepFn } from "./http.js";
|
|
2
|
+
import type { EmbedProvider } from "./provider.js";
|
|
3
|
+
/**
|
|
4
|
+
* SIGNED OFF 2026-07-02 (decision #30 AS AMENDED, PM): the hosted embed model
|
|
5
|
+
* the opt-in targets. OpenAI `text-embedding-3-small` natively supports a 768
|
|
6
|
+
* `dimensions` request, so the opt-in produces contract-valid vectors with no
|
|
7
|
+
* client-side math. (The original #30 pick, Cohere embed-v4.0, accepts only
|
|
8
|
+
* [256, 512, 1024, 1536] and was amended away; it stays reachable by config
|
|
9
|
+
* for an operator whose gateway maps dimensions, with the guard as backstop.)
|
|
10
|
+
* Config-overridable.
|
|
11
|
+
*/
|
|
12
|
+
export declare const DEFAULT_HOSTED_EMBED_MODEL: "text-embedding-3-small";
|
|
13
|
+
/**
|
|
14
|
+
* SIGNED OFF 2026-07-02 (decision #30 as amended): the requested output
|
|
15
|
+
* dimension. 768 keeps the opt-in on the fixed 768-dim contract; the guard
|
|
16
|
+
* discards anything else. Config-overridable.
|
|
17
|
+
*/
|
|
18
|
+
export declare const DEFAULT_HOSTED_OUTPUT_DIMENSION: 768;
|
|
19
|
+
/** HTTP statuses that trigger a bounded retry (429 rate limit + transient 5xx), matching the chat transport. */
|
|
20
|
+
export declare const HOSTED_RETRYABLE_STATUSES: ReadonlySet<number>;
|
|
21
|
+
/** Maximum attempts including the first POST (mirrors `src/portkey/transport.ts`'s `PORTKEY_MAX_ATTEMPTS`). */
|
|
22
|
+
export declare const DEFAULT_HOSTED_MAX_ATTEMPTS: 3;
|
|
23
|
+
/** Backoff between retryable failures in ms (mirrors `src/portkey/transport.ts`'s backoff). */
|
|
24
|
+
export declare const DEFAULT_HOSTED_RETRY_BACKOFF_MS: 250;
|
|
25
|
+
/**
|
|
26
|
+
* Per-attempt request timeout (ms), mirroring `deeplake-transport.ts`'s
|
|
27
|
+
* `DEFAULT_TRANSPORT_TIMEOUT_MS` AbortController pattern: an unresponsive gateway
|
|
28
|
+
* aborts rather than hanging the embed path indefinitely (fail-soft, AC-4).
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_HOSTED_REQUEST_TIMEOUT_MS: 15000;
|
|
31
|
+
/** The resolved hosted-via-Portkey config. `apiKey`/`configId` are `null` when Portkey is not keyed. */
|
|
32
|
+
export interface HostedEmbeddingsConfig {
|
|
33
|
+
/** The hosted embed model id (default {@link DEFAULT_HOSTED_EMBED_MODEL}). Config-overridable (AC-2). */
|
|
34
|
+
readonly model: string;
|
|
35
|
+
/** The requested output dimension (default {@link DEFAULT_HOSTED_OUTPUT_DIMENSION}). Config-overridable (AC-2). */
|
|
36
|
+
readonly outputDimension: number;
|
|
37
|
+
/** The resolved Portkey API key, or `null` when unkeyed (then embed fails soft to nulls). */
|
|
38
|
+
readonly apiKey: string | null;
|
|
39
|
+
/** The `portkey.config` / virtual-key id, or `null` when unset. */
|
|
40
|
+
readonly configId: string | null;
|
|
41
|
+
/** The endpoint URL (default {@link PORTKEY_EMBEDDINGS_URL}); overridable for a fake-fetch test. */
|
|
42
|
+
readonly url: string;
|
|
43
|
+
/** Max attempts including the first POST. */
|
|
44
|
+
readonly maxAttempts: number;
|
|
45
|
+
/** Backoff between retryable failures (ms). */
|
|
46
|
+
readonly retryBackoffMs: number;
|
|
47
|
+
/** Per-attempt request timeout (ms) before the attempt aborts (default {@link DEFAULT_HOSTED_REQUEST_TIMEOUT_MS}). */
|
|
48
|
+
readonly requestTimeoutMs: number;
|
|
49
|
+
}
|
|
50
|
+
/** Construction deps for {@link createHostedPortkeyProvider}; fetch + sleep are injectable for tests. */
|
|
51
|
+
export interface HostedPortkeyDeps {
|
|
52
|
+
/** The `fetch` implementation; defaults to `globalThis.fetch`. Tests inject a fake (no network). */
|
|
53
|
+
readonly fetch?: FetchLike;
|
|
54
|
+
/** The backoff sleep; a test passes a no-op so retry paths run without real time. */
|
|
55
|
+
readonly sleep?: SleepFn;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Parse the embeddings response into one vector (or `null`) per input index,
|
|
59
|
+
* defensively. Primary shape is Portkey's OpenAI-compatible
|
|
60
|
+
* `{ data: [{ embedding: number[], index }] }`; a Cohere-native
|
|
61
|
+
* `{ embeddings: number[][] }` or `{ embeddings: { float: number[][] } }` body is
|
|
62
|
+
* tolerated as a fallback. Anything else yields all-nulls. Never throws. The
|
|
63
|
+
* per-vector dimension is NOT checked here — the guard owns that (AC-3).
|
|
64
|
+
*/
|
|
65
|
+
export declare function parseEmbeddingsResponse(raw: string, count: number): (number[] | null)[];
|
|
66
|
+
/**
|
|
67
|
+
* Build the hosted-via-Portkey embeddings {@link EmbedProvider} (PRD-014b). A
|
|
68
|
+
* batch is sent as ONE POST reusing the rerank transport's auth pattern; the body
|
|
69
|
+
* carries the config model id + `dimensions` (AC-2). Every failure resolves
|
|
70
|
+
* to nulls for the batch (fail-soft, AC-4); the key is never logged or thrown.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createHostedPortkeyProvider(config: HostedEmbeddingsConfig, deps?: HostedPortkeyDeps): EmbedProvider;
|
|
73
|
+
//# sourceMappingURL=hosted-portkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-portkey.d.ts","sourceRoot":"","sources":["../../src/embeddings/hosted-portkey.ts"],"names":[],"mappings":"AA+BA,OAAO,EAA8B,KAAK,SAAS,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AACrF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD;;;;;;;;GAQG;AACH,eAAO,MAAM,0BAA0B,EAAG,wBAAiC,CAAC;AAE5E;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,EAAG,GAAY,CAAC;AAE5D,gHAAgH;AAChH,eAAO,MAAM,yBAAyB,EAAE,WAAW,CAAC,MAAM,CAAsC,CAAC;AAEjG,+GAA+G;AAC/G,eAAO,MAAM,2BAA2B,EAAG,CAAU,CAAC;AAEtD,+FAA+F;AAC/F,eAAO,MAAM,+BAA+B,EAAG,GAAY,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAG,KAAe,CAAC;AAEjE,wGAAwG;AACxG,MAAM,WAAW,sBAAsB;IACrC,yGAAyG;IACzG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mHAAmH;IACnH,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,6FAA6F;IAC7F,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,mEAAmE;IACnE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,oGAAoG;IACpG,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6CAA6C;IAC7C,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,+CAA+C;IAC/C,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,sHAAsH;IACtH,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC;AAED,yGAAyG;AACzG,MAAM,WAAW,iBAAiB;IAChC,oGAAoG;IACpG,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC1B;AAOD;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,CAyCvF;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,sBAAsB,EAC9B,IAAI,GAAE,iBAAsB,GAC3B,aAAa,CAwDf"}
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hosted-via-Portkey embeddings transport (PRD-014b — the operator opt-in).
|
|
3
|
+
*
|
|
4
|
+
* Modeled on honeycomb's shipped Cohere-rerank-via-Portkey transport
|
|
5
|
+
* (`honeycomb/src/daemon/runtime/recall/rerank-portkey.ts`): it reuses the SAME
|
|
6
|
+
* `x-portkey-api-key` + `x-portkey-config` auth pair (via
|
|
7
|
+
* {@link buildPortkeyHeaders}) and the SAME gateway host; the ONE difference is
|
|
8
|
+
* the path — `/v1/embeddings` ({@link PORTKEY_EMBEDDINGS_URL}) instead of
|
|
9
|
+
* `/v1/rerank` — and the request/response shape.
|
|
10
|
+
*
|
|
11
|
+
* ── Model + dimension are config, not hardcoded (decision #30 as amended) ────
|
|
12
|
+
* The opt-in targets OpenAI `text-embedding-3-small` with `dimensions: 768` so
|
|
13
|
+
* it produces contract-valid 768-dim vectors with no client-side math. Both the
|
|
14
|
+
* model id and the dimension are config values
|
|
15
|
+
* ({@link HostedEmbeddingsConfig}); recall's 768-dim guard (`guard.ts`) stays as
|
|
16
|
+
* the backstop for whatever the gateway actually returns.
|
|
17
|
+
*
|
|
18
|
+
* ── Fail-soft is the cardinal rule (AC-4 / US-014b.3) ────────────────────────
|
|
19
|
+
* EVERY failure path — Portkey not keyed, a network/transport error, a non-2xx
|
|
20
|
+
* gateway status, or a malformed body — resolves to `null` for the affected
|
|
21
|
+
* texts, NEVER a throw into the caller's hot path. A bounded retry covers 429 +
|
|
22
|
+
* transient 5xx (the same statuses the sibling chat transport retries); the
|
|
23
|
+
* bound is exhausted to nulls rather than thrown.
|
|
24
|
+
*
|
|
25
|
+
* ── The secret-never-logged invariant (US-014b.3) ────────────────────────────
|
|
26
|
+
* The resolved key is placed ONLY in the `x-portkey-api-key` header (via
|
|
27
|
+
* {@link buildPortkeyHeaders}) and is NEVER included in a returned value, a log
|
|
28
|
+
* line, or an error. On any failure the response body is not read into a message
|
|
29
|
+
* (it could echo a credential).
|
|
30
|
+
*/
|
|
31
|
+
import { buildPortkeyHeaders, PORTKEY_EMBEDDINGS_URL } from "../portkey/headers.js";
|
|
32
|
+
import { defaultFetch, defaultSleep } from "./http.js";
|
|
33
|
+
/**
|
|
34
|
+
* SIGNED OFF 2026-07-02 (decision #30 AS AMENDED, PM): the hosted embed model
|
|
35
|
+
* the opt-in targets. OpenAI `text-embedding-3-small` natively supports a 768
|
|
36
|
+
* `dimensions` request, so the opt-in produces contract-valid vectors with no
|
|
37
|
+
* client-side math. (The original #30 pick, Cohere embed-v4.0, accepts only
|
|
38
|
+
* [256, 512, 1024, 1536] and was amended away; it stays reachable by config
|
|
39
|
+
* for an operator whose gateway maps dimensions, with the guard as backstop.)
|
|
40
|
+
* Config-overridable.
|
|
41
|
+
*/
|
|
42
|
+
export const DEFAULT_HOSTED_EMBED_MODEL = "text-embedding-3-small";
|
|
43
|
+
/**
|
|
44
|
+
* SIGNED OFF 2026-07-02 (decision #30 as amended): the requested output
|
|
45
|
+
* dimension. 768 keeps the opt-in on the fixed 768-dim contract; the guard
|
|
46
|
+
* discards anything else. Config-overridable.
|
|
47
|
+
*/
|
|
48
|
+
export const DEFAULT_HOSTED_OUTPUT_DIMENSION = 768;
|
|
49
|
+
/** HTTP statuses that trigger a bounded retry (429 rate limit + transient 5xx), matching the chat transport. */
|
|
50
|
+
export const HOSTED_RETRYABLE_STATUSES = new Set([429, 500, 502, 503, 504]);
|
|
51
|
+
/** Maximum attempts including the first POST (mirrors `src/portkey/transport.ts`'s `PORTKEY_MAX_ATTEMPTS`). */
|
|
52
|
+
export const DEFAULT_HOSTED_MAX_ATTEMPTS = 3;
|
|
53
|
+
/** Backoff between retryable failures in ms (mirrors `src/portkey/transport.ts`'s backoff). */
|
|
54
|
+
export const DEFAULT_HOSTED_RETRY_BACKOFF_MS = 250;
|
|
55
|
+
/**
|
|
56
|
+
* Per-attempt request timeout (ms), mirroring `deeplake-transport.ts`'s
|
|
57
|
+
* `DEFAULT_TRANSPORT_TIMEOUT_MS` AbortController pattern: an unresponsive gateway
|
|
58
|
+
* aborts rather than hanging the embed path indefinitely (fail-soft, AC-4).
|
|
59
|
+
*/
|
|
60
|
+
export const DEFAULT_HOSTED_REQUEST_TIMEOUT_MS = 15_000;
|
|
61
|
+
/** All-nulls result of length `n` (the fail-soft shape, built in one place). */
|
|
62
|
+
function allNull(n) {
|
|
63
|
+
return new Array(n).fill(null);
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Parse the embeddings response into one vector (or `null`) per input index,
|
|
67
|
+
* defensively. Primary shape is Portkey's OpenAI-compatible
|
|
68
|
+
* `{ data: [{ embedding: number[], index }] }`; a Cohere-native
|
|
69
|
+
* `{ embeddings: number[][] }` or `{ embeddings: { float: number[][] } }` body is
|
|
70
|
+
* tolerated as a fallback. Anything else yields all-nulls. Never throws. The
|
|
71
|
+
* per-vector dimension is NOT checked here — the guard owns that (AC-3).
|
|
72
|
+
*/
|
|
73
|
+
export function parseEmbeddingsResponse(raw, count) {
|
|
74
|
+
let body;
|
|
75
|
+
try {
|
|
76
|
+
body = raw.length > 0 ? JSON.parse(raw) : null;
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return allNull(count);
|
|
80
|
+
}
|
|
81
|
+
if (typeof body !== "object" || body === null)
|
|
82
|
+
return allNull(count);
|
|
83
|
+
const out = allNull(count);
|
|
84
|
+
const asFinite = (v) => Array.isArray(v) && v.every((n) => typeof n === "number" && Number.isFinite(n)) ? v : null;
|
|
85
|
+
// Primary: OpenAI-compatible `data: [{ embedding, index }]`.
|
|
86
|
+
const data = body.data;
|
|
87
|
+
if (Array.isArray(data)) {
|
|
88
|
+
data.forEach((entry, i) => {
|
|
89
|
+
if (typeof entry !== "object" || entry === null)
|
|
90
|
+
return;
|
|
91
|
+
const e = entry;
|
|
92
|
+
const idx = typeof e.index === "number" && Number.isInteger(e.index) ? e.index : i;
|
|
93
|
+
if (idx < 0 || idx >= count)
|
|
94
|
+
return;
|
|
95
|
+
out[idx] = asFinite(e.embedding);
|
|
96
|
+
});
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
// Fallback: Cohere-native `embeddings: number[][]` or `embeddings: { float: number[][] }`.
|
|
100
|
+
const embeddings = body.embeddings;
|
|
101
|
+
const rows = Array.isArray(embeddings)
|
|
102
|
+
? embeddings
|
|
103
|
+
: typeof embeddings === "object" && embeddings !== null && Array.isArray(embeddings.float)
|
|
104
|
+
? (embeddings.float)
|
|
105
|
+
: null;
|
|
106
|
+
if (rows !== null) {
|
|
107
|
+
rows.forEach((row, i) => {
|
|
108
|
+
if (i < count)
|
|
109
|
+
out[i] = asFinite(row);
|
|
110
|
+
});
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
return allNull(count);
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Build the hosted-via-Portkey embeddings {@link EmbedProvider} (PRD-014b). A
|
|
117
|
+
* batch is sent as ONE POST reusing the rerank transport's auth pattern; the body
|
|
118
|
+
* carries the config model id + `dimensions` (AC-2). Every failure resolves
|
|
119
|
+
* to nulls for the batch (fail-soft, AC-4); the key is never logged or thrown.
|
|
120
|
+
*/
|
|
121
|
+
export function createHostedPortkeyProvider(config, deps = {}) {
|
|
122
|
+
const doFetch = deps.fetch ?? defaultFetch();
|
|
123
|
+
const sleep = deps.sleep ?? defaultSleep;
|
|
124
|
+
return {
|
|
125
|
+
kind: "hosted",
|
|
126
|
+
async embed(texts) {
|
|
127
|
+
if (texts.length === 0)
|
|
128
|
+
return [];
|
|
129
|
+
// Not keyed -> fail soft to nulls (no POST). A missing key is a misconfiguration, not a crash (AC-4).
|
|
130
|
+
if (config.apiKey === null || config.configId === null)
|
|
131
|
+
return allNull(texts.length);
|
|
132
|
+
const headers = buildPortkeyHeaders(config.apiKey, config.configId);
|
|
133
|
+
// The embeddings body (decision #30 as amended): the config model id + the
|
|
134
|
+
// OpenAI-compatible `dimensions` field (Portkey's unified API maps it to the
|
|
135
|
+
// provider's own parameter, e.g. Cohere's `output_dimension`), both overridable (AC-2).
|
|
136
|
+
const body = JSON.stringify({
|
|
137
|
+
model: config.model,
|
|
138
|
+
input: [...texts],
|
|
139
|
+
dimensions: config.outputDimension,
|
|
140
|
+
});
|
|
141
|
+
for (let attempt = 1; attempt <= config.maxAttempts; attempt++) {
|
|
142
|
+
let res;
|
|
143
|
+
const controller = new AbortController();
|
|
144
|
+
const timer = setTimeout(() => controller.abort(), config.requestTimeoutMs);
|
|
145
|
+
try {
|
|
146
|
+
res = await doFetch(config.url, { method: "POST", headers, body, signal: controller.signal });
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
// Network/transport failure, or our own abort on `requestTimeoutMs` (an unresponsive
|
|
150
|
+
// gateway) -> retry within the bound, else fail soft to nulls. Never surface the error
|
|
151
|
+
// (it could carry a body/key); only the fail-soft nulls escape.
|
|
152
|
+
if (attempt < config.maxAttempts) {
|
|
153
|
+
await sleep(config.retryBackoffMs * attempt);
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
return allNull(texts.length);
|
|
157
|
+
}
|
|
158
|
+
finally {
|
|
159
|
+
clearTimeout(timer);
|
|
160
|
+
}
|
|
161
|
+
if (!res.ok) {
|
|
162
|
+
// A non-2xx gateway status: retry the retryable ones within the bound, else fail soft. Never
|
|
163
|
+
// read the body into a message (it could echo a credential).
|
|
164
|
+
if (attempt < config.maxAttempts && HOSTED_RETRYABLE_STATUSES.has(res.status)) {
|
|
165
|
+
await sleep(config.retryBackoffMs * attempt);
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
return allNull(texts.length);
|
|
169
|
+
}
|
|
170
|
+
// A 2xx: parse defensively. A malformed body fails soft to nulls (the gateway was reachable,
|
|
171
|
+
// the body was just unusable) rather than throwing.
|
|
172
|
+
const text = await res.text().catch(() => "");
|
|
173
|
+
return parseEmbeddingsResponse(text, texts.length);
|
|
174
|
+
}
|
|
175
|
+
return allNull(texts.length);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
//# sourceMappingURL=hosted-portkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hosted-portkey.js","sourceRoot":"","sources":["../../src/embeddings/hosted-portkey.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAgC,MAAM,WAAW,CAAC;AAGrF;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAiC,CAAC;AAE5E;;;;GAIG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAY,CAAC;AAE5D,gHAAgH;AAChH,MAAM,CAAC,MAAM,yBAAyB,GAAwB,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,G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* A minimal `fetch`-shaped surface so neither the local nomic client nor the
|
|
5
|
+
* hosted-via-Portkey transport touches the network in a unit test: production
|
|
6
|
+
* binds `globalThis.fetch`, a test injects a fake that returns a canned
|
|
7
|
+
* response. The shape is deliberately identical to the sibling chat transport's
|
|
8
|
+
* `PortkeyFetch` (`src/portkey/transport.ts`) so the Wave-2 integrator can fold
|
|
9
|
+
* the two onto one shared seam without a signature change.
|
|
10
|
+
*/
|
|
11
|
+
/** The subset of a `fetch` `Response` the transports read. */
|
|
12
|
+
export interface FetchResponseLike {
|
|
13
|
+
/** True on a 2xx status. */
|
|
14
|
+
readonly ok: boolean;
|
|
15
|
+
/** The HTTP status code (routed to the bounded-retry decision + the fail-soft path). */
|
|
16
|
+
readonly status: number;
|
|
17
|
+
/** The raw response body; parsed defensively by the caller (never trusted). */
|
|
18
|
+
text(): Promise<string>;
|
|
19
|
+
}
|
|
20
|
+
/** The injectable `fetch` implementation. Production: `globalThis.fetch`; tests inject a fake. */
|
|
21
|
+
export type FetchLike = (url: string, init: {
|
|
22
|
+
method: string;
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
body: string;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}) => Promise<FetchResponseLike>;
|
|
27
|
+
/** Bind the real global `fetch` to the {@link FetchLike} shape (Node >=22 ships it as a built-in). */
|
|
28
|
+
export declare function defaultFetch(): FetchLike;
|
|
29
|
+
/** An injectable backoff sleep; tests pass a no-op so retry paths run without real time. */
|
|
30
|
+
export type SleepFn = (ms: number) => Promise<void>;
|
|
31
|
+
/** The production sleep, backed by a real timer. */
|
|
32
|
+
export declare function defaultSleep(ms: number): Promise<void>;
|
|
33
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/embeddings/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,wFAAwF;IACxF,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+EAA+E;IAC/E,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB;AAED,kGAAkG;AAClG,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,KAC1F,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAEhC,sGAAsG;AACtG,wBAAgB,YAAY,IAAI,SAAS,CAExC;AAED,4FAA4F;AAC5F,MAAM,MAAM,OAAO,GAAG,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpD,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEtD"}
|