@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 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/README.md +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which public methods share one guarded dispatch, and which do not.
|
|
3
|
+
*
|
|
4
|
+
* `get`, `put`, `delete`, `listNamespaces` and `batch` parse their arguments
|
|
5
|
+
* and hand the parsed operations to the same batch runner and dispatch, so
|
|
6
|
+
* the five answer and refuse alike. `search` guards the same way but calls
|
|
7
|
+
* its own action directly, to carry a signal that `batch` cannot;
|
|
8
|
+
* `reconcileVectorIndex` and `ensureS3LifecycleRule` guard directly too,
|
|
9
|
+
* since neither is a batchable store operation. Each public method declared
|
|
10
|
+
* here is also the error boundary (record 13) — an asynchronous one through
|
|
11
|
+
* `guardPublic`, and the synchronous `destroy`, releasing what the store owns
|
|
12
|
+
* through its shell, through `guardPublicSync`; `stop` is that same guarded
|
|
13
|
+
* call under upstream's lifecycle name. The inherited `start()` no-op —
|
|
14
|
+
* declared by `BaseStore`, not overridden here — is neither guarded nor
|
|
15
|
+
* routed through any of this.
|
|
16
|
+
*/
|
|
17
|
+
import { BaseStore, type Item, type Operation, type OperationResults, type SearchItem } from '@langchain/langgraph-checkpoint';
|
|
18
|
+
import type { CancelOptions } from '../shared/options.js';
|
|
19
|
+
import type { DynamoDBStoreOptions, ListNamespacesOptions, SearchOptions, VectorReconcileResult } from './types.js';
|
|
20
|
+
/**
|
|
21
|
+
* DynamoDB-backed LangGraph store for long-term memory with optional semantic
|
|
22
|
+
* search. `get`, `put`, `delete` and `listNamespaces` answer and refuse exactly
|
|
23
|
+
* as the same operation inside a {@link batch} does, and `put` keeps upstream's
|
|
24
|
+
* own namespace rules. Every public method rejects only with this library's
|
|
25
|
+
* error.
|
|
26
|
+
*/
|
|
27
|
+
export declare class DynamoDBStore extends BaseStore {
|
|
28
|
+
private readonly context;
|
|
29
|
+
private readonly shell;
|
|
30
|
+
/**
|
|
31
|
+
* Accepts: `options` — validated here, so a misconfiguration surfaces at
|
|
32
|
+
* construction rather than on the first request. A `vectorBackend` without an
|
|
33
|
+
* `index` is refused outright, since every put would then clear the item's
|
|
34
|
+
* vector and every query would answer unranked.
|
|
35
|
+
*
|
|
36
|
+
* Returns: a store that owns the client it built, or borrows the one it was
|
|
37
|
+
* given.
|
|
38
|
+
*
|
|
39
|
+
* Throws: `VALIDATION` naming the offending option.
|
|
40
|
+
*
|
|
41
|
+
* Guarantees: no I/O. Constructing a store issues no request.
|
|
42
|
+
*/
|
|
43
|
+
constructor(options: DynamoDBStoreOptions);
|
|
44
|
+
/**
|
|
45
|
+
* One operation's result: the item for a get, the page for a search, the
|
|
46
|
+
* namespaces for a listing, and `null` for a put or a delete — the value the
|
|
47
|
+
* reference store's `batch` answers a put or a delete with. The kind was
|
|
48
|
+
* decided once, by the parser that built `operation`, so this switches on it
|
|
49
|
+
* instead of asking the operation's shape again. `readConcurrency` — this
|
|
50
|
+
* operation's share of the call's decode budget, which only a search spends
|
|
51
|
+
* more than one of.
|
|
52
|
+
*/
|
|
53
|
+
private dispatch;
|
|
54
|
+
/**
|
|
55
|
+
* Run a batch of already-parsed operations, with no boundary of its own.
|
|
56
|
+
*
|
|
57
|
+
* The guard is the caller's method, not this: a nested `guardPublic` keeps
|
|
58
|
+
* the brand the *inner* one assigned, so routing `get`, `put`, `delete` and
|
|
59
|
+
* `listNamespaces` through the public {@link batch} reported all four as
|
|
60
|
+
* `store.batch` and left an operator counting AWS failures by
|
|
61
|
+
* `context.operation` unable to tell them apart. The operations one phase
|
|
62
|
+
* keeps in flight together share `this.context.readConcurrency`, the call's
|
|
63
|
+
* one decode budget, so a phase of several concurrent searches never
|
|
64
|
+
* multiplies it (see {@link runBatch}).
|
|
65
|
+
*/
|
|
66
|
+
private execute;
|
|
67
|
+
/**
|
|
68
|
+
* Execute a batch of operations and return their results in operation
|
|
69
|
+
* order.
|
|
70
|
+
*
|
|
71
|
+
* Accepts: `operations` — an array of operation objects; an empty batch
|
|
72
|
+
* does nothing and returns `[]`. Every
|
|
73
|
+
* operation is checked before any of them runs. A put carrying a `null`
|
|
74
|
+
* value deletes its item. `get`, `put`, `delete` and `listNamespaces` check
|
|
75
|
+
* their own call by the same rules and run the same dispatch, as upstream's
|
|
76
|
+
* implementations do, so the field a malformed call names is the same
|
|
77
|
+
* whichever of the five reached it — `put` alone adds what is about the
|
|
78
|
+
* method: upstream's own `.` and `"langgraph"` namespace rules, and a refusal
|
|
79
|
+
* of a `null` value, since `delete` is how an item is removed. Each of the
|
|
80
|
+
* four keeps its own name in `context.operation`, so a failure says which
|
|
81
|
+
* method the caller called rather than reporting all five alike.
|
|
82
|
+
*
|
|
83
|
+
* Returns: the results in operation order — an item or `null` for a get,
|
|
84
|
+
* matches for a search, namespaces for a listing, `null` for a put or a
|
|
85
|
+
* delete, as the reference store answers them.
|
|
86
|
+
*
|
|
87
|
+
* Throws: `VALIDATION`, raised for every operation before any operation
|
|
88
|
+
* runs, naming `operations` for a value that is not an array or an entry that
|
|
89
|
+
* is not an object; `namespace`, `namespace element`, `key` or `sortKey` for an
|
|
90
|
+
* item address; `value` or `index` for a put; `namespacePrefix`,
|
|
91
|
+
* `namespacePrefix element`, `filter`, `query`, `offset` or `limit` for a
|
|
92
|
+
* search; `offset`, `limit`, `maxDepth`, `matchConditions`, `prefix`,
|
|
93
|
+
* `prefix element`, `suffix` or `suffix element` for a listing; and later,
|
|
94
|
+
* from a running operation, `value` for one JSON cannot represent,
|
|
95
|
+
* `maxSearchCandidates` or `index.dims`, or — once a put's row is built —
|
|
96
|
+
* `index` or `value` again for one over DynamoDB's 400 KB item limit, naming
|
|
97
|
+
* `index` when its inline vectors are what pushed it over. A classified AWS
|
|
98
|
+
* failure; `RETRY_EXHAUSTED`;
|
|
99
|
+
* `RESULT_TRUNCATED` from a search or a listing that reads past
|
|
100
|
+
* `maxScanItems` or `maxIterations`. One failing operation rejects the
|
|
101
|
+
* whole batch.
|
|
102
|
+
*
|
|
103
|
+
* Guarantees: the batch is evaluated as the reference store evaluates one —
|
|
104
|
+
* every get, search and listing is answered as the batch found things, and
|
|
105
|
+
* the puts and deletes land afterwards, one per item, the last one written
|
|
106
|
+
* winning — so two tasks of one superstep that touch one item get the same
|
|
107
|
+
* answers whichever was enqueued first. The reads run concurrently, then the
|
|
108
|
+
* writes, so a batch of ten gets costs about one round trip rather than ten,
|
|
109
|
+
* sharing one `readConcurrency` decode budget between them rather than each
|
|
110
|
+
* holding a full one.
|
|
111
|
+
*/
|
|
112
|
+
batch<Op extends Operation[]>(operations: Op): Promise<OperationResults<Op>>;
|
|
113
|
+
/**
|
|
114
|
+
* Retrieve one item. Overrides the base implementation so the call is
|
|
115
|
+
* guarded here; the operation is the one upstream builds.
|
|
116
|
+
*
|
|
117
|
+
* Accepts: `namespace` — at least one label, each a non-blank identifier of
|
|
118
|
+
* at most 256 bytes, free of `#` and control characters and well-formed
|
|
119
|
+
* UTF-16. A `.` and a `"langgraph"` root are accepted, as the reference store
|
|
120
|
+
* accepts them. `key` — an identifier by the same rules. Together they may
|
|
121
|
+
* compose a sort key of at most 1024 bytes. **No signal**: upstream's
|
|
122
|
+
* `BaseStore.get` takes no parameter for one, so the S3 download an
|
|
123
|
+
* offloaded value costs is not cancellable here. `store.search` is the read
|
|
124
|
+
* that takes one.
|
|
125
|
+
*
|
|
126
|
+
* Returns: the item, or `null` for one that does not exist or has expired.
|
|
127
|
+
*
|
|
128
|
+
* Throws: `VALIDATION` naming `namespace`, `namespace element`, `key` or
|
|
129
|
+
* `sortKey`, and — from the row rather than from the call — `descriptor` for
|
|
130
|
+
* a payload descriptor no reader could make sense of, `s3` for an offloaded
|
|
131
|
+
* row with no offloader configured, `s3Key` for a row addressing an object
|
|
132
|
+
* outside its own path, or `serde` for a payload the configured serializer
|
|
133
|
+
* refuses to reconstruct; `FORMAT_UNSUPPORTED` for an item, or its payload,
|
|
134
|
+
* written by a newer version, which is reported rather than hidden as
|
|
135
|
+
* absent; `PAYLOAD_CORRUPT` for a payload that is no longer the form its row
|
|
136
|
+
* declares; `S3_OFFLOAD_FAILED` for an offloaded payload that cannot be
|
|
137
|
+
* downloaded; `COMPRESSION_LIMIT` for one whose decompressed size would pass
|
|
138
|
+
* the cap; a classified AWS failure; `RETRY_EXHAUSTED`. Not `ABORTED`: there is no
|
|
139
|
+
* signal to fire.
|
|
140
|
+
*/
|
|
141
|
+
get(namespace: string[], key: string): Promise<Item | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Store or replace one item. Overrides the base implementation, whose own
|
|
144
|
+
* namespace check threw an error this package does not brand. The value and
|
|
145
|
+
* index are checked by {@link batch}, so LangGraph's own puts hold them too.
|
|
146
|
+
*
|
|
147
|
+
* Accepts: `namespace` and `key` — as {@link get}, plus upstream
|
|
148
|
+
* `BaseStore.put`'s own two rules, which only this method applies: no label
|
|
149
|
+
* holding `.`, and a root other than `"langgraph"`. `value` — an object; `null`
|
|
150
|
+
* is refused, since {@link delete} is how an item is removed. `index` —
|
|
151
|
+
* absent uses the store's configuration, `false` indexes nothing, and field
|
|
152
|
+
* paths override it for this put.
|
|
153
|
+
*
|
|
154
|
+
* Returns: nothing.
|
|
155
|
+
*
|
|
156
|
+
* Throws: `VALIDATION` naming `namespace`, `namespace element`, `key`,
|
|
157
|
+
* `sortKey`, `value` or `index`; `payload` for a value too large to store
|
|
158
|
+
* inline without `s3`, or, once offloaded, larger than
|
|
159
|
+
* `s3.maxDownloadBytes`; `s3Key` for an offloaded object's key over S3's
|
|
160
|
+
* cap; `VALIDATION` again, naming `index` or `value`, for the built row over
|
|
161
|
+
* DynamoDB's 400 KB item limit — `index` when its inline vectors are what
|
|
162
|
+
* pushed it over — checked before anything is written; `S3_OFFLOAD_FAILED`
|
|
163
|
+
* when an offloaded payload cannot be uploaded; a classified AWS failure;
|
|
164
|
+
* `RETRY_EXHAUSTED`.
|
|
165
|
+
*/
|
|
166
|
+
put(namespace: string[], key: string, value: Parameters<BaseStore['put']>[2], index?: Parameters<BaseStore['put']>[3]): Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Remove one item, as upstream does: a put operation carrying `null`.
|
|
169
|
+
*
|
|
170
|
+
* Accepts: `namespace` and `key` — as {@link get}.
|
|
171
|
+
*
|
|
172
|
+
* Returns: nothing. Deleting an item that is not there is not an error —
|
|
173
|
+
* which now describes the outcome rather than the round trip, since the row
|
|
174
|
+
* is read before it is removed.
|
|
175
|
+
*
|
|
176
|
+
* Throws: `VALIDATION` naming `namespace`, `namespace element`, `key` or
|
|
177
|
+
* `sortKey`; a classified AWS failure; `RETRY_EXHAUSTED`. The set of types is
|
|
178
|
+
* unchanged, but the occasions are not: that pre-read is a request like any
|
|
179
|
+
* other, so a delete of a key with **no row** can now fail where it always
|
|
180
|
+
* succeeded. Nothing has been written when it does — no row removed, no
|
|
181
|
+
* object released, no vector touched. A delete the row's revision turns away
|
|
182
|
+
* never reaches a caller at all: it is re-pinned on the row the rejection
|
|
183
|
+
* returned and re-issued, because refusing to remove a row a concurrent put
|
|
184
|
+
* replaced is what stops this call erasing that put.
|
|
185
|
+
*
|
|
186
|
+
* Guarantees: the item is gone, was already gone, or — when three attempts in
|
|
187
|
+
* a row are each turned away by a write that landed since the observation
|
|
188
|
+
* that attempt pinned — is still there and was left alone. That last case
|
|
189
|
+
* **resolves**, logging one `warn` naming the namespace, the key and the
|
|
190
|
+
* attempt count, where the reference store always removes the item;
|
|
191
|
+
* throwing instead would add a failure mode to an interleaving that succeeds
|
|
192
|
+
* today, which every caller deleting in a `finally` would have to handle.
|
|
193
|
+
* Re-run once the key is quiescent. Nothing is released on that path, which
|
|
194
|
+
* is correct: a live row still names the object.
|
|
195
|
+
*/
|
|
196
|
+
delete(namespace: string[], key: string): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* List the distinct namespaces, sorted, optionally filtered and truncated.
|
|
199
|
+
*
|
|
200
|
+
* Accepts: `options.prefix`/`suffix` — labels a namespace can hold, where
|
|
201
|
+
* `'*'` matches any one label. `options.maxDepth` — at least 1.
|
|
202
|
+
* `options.limit` — an integer from 0 to 10,000, defaulting
|
|
203
|
+
* to 100, where `0` returns an empty listing without reading the table.
|
|
204
|
+
* `options.offset` — a non-negative integer, defaulting to 0.
|
|
205
|
+
*
|
|
206
|
+
* Returns: at most `limit` namespaces from `offset`.
|
|
207
|
+
*
|
|
208
|
+
* Throws: `VALIDATION` naming `options`, `prefix`, `prefix element`,
|
|
209
|
+
* `suffix`, `suffix element`, `maxDepth`, `limit` or `offset`;
|
|
210
|
+
* `RESULT_TRUNCATED` past `maxScanItems` or `maxIterations`;
|
|
211
|
+
* `FORMAT_UNSUPPORTED` for an item written by a newer version; a classified
|
|
212
|
+
* AWS failure. An option key this version does not read is ignored rather
|
|
213
|
+
* than refused, since the options are LangGraph's (decision record 28).
|
|
214
|
+
*/
|
|
215
|
+
listNamespaces(options?: ListNamespacesOptions): Promise<string[][]>;
|
|
216
|
+
/**
|
|
217
|
+
* Search with optional cancellation. Overrides the base implementation, which
|
|
218
|
+
* routes through {@link batch} and therefore cannot carry a signal.
|
|
219
|
+
*
|
|
220
|
+
* Accepts: `namespacePrefix` — labels a namespace can hold; empty spans the
|
|
221
|
+
* whole table. `options.query` —
|
|
222
|
+
* absent or empty ranks nothing. `options.filter` — metadata equality on the
|
|
223
|
+
* item's value. `options.offset` — a non-negative integer, defaulting to 0.
|
|
224
|
+
* `options.limit` — an integer from 0 to 10,000, defaulting
|
|
225
|
+
* to 10, where `0` returns an empty page without a read or an embedding.
|
|
226
|
+
* `options.signal` — aborts the reads.
|
|
227
|
+
*
|
|
228
|
+
* Returns: at most `limit` items from `offset`, each carrying a `score` when
|
|
229
|
+
* a query and an index are configured.
|
|
230
|
+
*
|
|
231
|
+
* Throws: `VALIDATION` naming `namespacePrefix`, `namespacePrefix element`,
|
|
232
|
+
* `options` for options that are not an object, `filter`, `query`, `offset`,
|
|
233
|
+
* `limit`, `maxSearchCandidates`, `index.dims` or `signal`; `ABORTED`;
|
|
234
|
+
* `RESULT_TRUNCATED` when the walk reaches `maxScanItems` or `maxIterations`;
|
|
235
|
+
* `FORMAT_UNSUPPORTED` for an item, or its payload, written by a newer
|
|
236
|
+
* version — a search reads rows it did not name, so one such row anywhere in
|
|
237
|
+
* the prefix it walks reports rather than being passed over; a classified AWS failure.
|
|
238
|
+
* An option key this version does not read is ignored rather than refused:
|
|
239
|
+
* the options are LangGraph's, and a key a later LangGraph adds must not turn
|
|
240
|
+
* a search into a refusal (decision record 28).
|
|
241
|
+
*
|
|
242
|
+
* Guarantees: a plain search stops reading once `offset + limit` matches are
|
|
243
|
+
* in hand; a query ranks in-process up to `maxSearchCandidates`, or through
|
|
244
|
+
* the `vectorBackend` when one is configured.
|
|
245
|
+
*/
|
|
246
|
+
search(namespacePrefix: string[], options?: SearchOptions): Promise<SearchItem[]>;
|
|
247
|
+
/**
|
|
248
|
+
* Repair the configured vector backend against the canonical items under
|
|
249
|
+
* `namespacePrefix`. A maintenance tool; see the action of the same name.
|
|
250
|
+
*
|
|
251
|
+
* Accepts: `namespacePrefix` — a non-empty namespace. `options.signal` —
|
|
252
|
+
* ends the read or download in flight and any wait between them; vectors
|
|
253
|
+
* already upserted or pruned stay so.
|
|
254
|
+
*
|
|
255
|
+
* Returns: how many vectors were upserted and how many pruned.
|
|
256
|
+
*
|
|
257
|
+
* Throws: `VALIDATION` without both an `index` and a `vectorBackend`, for
|
|
258
|
+
* an empty prefix, for an invalid `signal`, or for `options.<key>` naming a
|
|
259
|
+
* key this package does not read; `RESULT_TRUNCATED` past `maxScanItems` or
|
|
260
|
+
* `maxIterations`; `FORMAT_UNSUPPORTED` for an item, or its payload, written by a newer
|
|
261
|
+
* version — repairing a backend from a view of the prefix that silently
|
|
262
|
+
* omitted such a row would prune the vectors of items that are still there;
|
|
263
|
+
* a classified AWS failure.
|
|
264
|
+
*
|
|
265
|
+
* Guarantees: DynamoDB is never written — only the backend is repaired — and
|
|
266
|
+
* a vector is deleted only on evidence that its item is gone, or unchanged
|
|
267
|
+
* since a snapshot that already found it with nothing to embed.
|
|
268
|
+
*/
|
|
269
|
+
reconcileVectorIndex(namespacePrefix: string[], options?: CancelOptions): Promise<VectorReconcileResult>;
|
|
270
|
+
/**
|
|
271
|
+
* LangGraph's lifecycle hook.
|
|
272
|
+
*
|
|
273
|
+
* Accepts: nothing.
|
|
274
|
+
*
|
|
275
|
+
* Returns: nothing. A host that manages stores through the upstream
|
|
276
|
+
* `BaseStore` interface calls `stop()`, so it releases the owned client
|
|
277
|
+
* exactly like {@link destroy}, which stays the explicit API. Both are
|
|
278
|
+
* idempotent.
|
|
279
|
+
*
|
|
280
|
+
* Throws: exactly what {@link destroy} throws, since it is that call.
|
|
281
|
+
*/
|
|
282
|
+
stop(): void;
|
|
283
|
+
/**
|
|
284
|
+
* Release owned resources.
|
|
285
|
+
*
|
|
286
|
+
* Accepts: nothing.
|
|
287
|
+
*
|
|
288
|
+
* Returns: nothing. Idempotent, and a no-op for a client the caller injected
|
|
289
|
+
* — that one is theirs to close.
|
|
290
|
+
*
|
|
291
|
+
* Throws: the first failure a resource's own `destroy` raised, as a
|
|
292
|
+
* `DynamoDBLangGraphError` (`UNEXPECTED_ERROR` unless the failure was AWS's)
|
|
293
|
+
* with it as `cause` — raised only after every other resource has been
|
|
294
|
+
* released, and only by the first call: `destroy()` is idempotent.
|
|
295
|
+
*/
|
|
296
|
+
destroy(): void;
|
|
297
|
+
/**
|
|
298
|
+
* Provision an S3 lifecycle expiration rule matching the configured TTL, so
|
|
299
|
+
* offloaded objects don't outlive their DynamoDB item forever.
|
|
300
|
+
*
|
|
301
|
+
* Accepts: nothing; the rule follows the configured `s3` and `ttl`. A no-op
|
|
302
|
+
* without both.
|
|
303
|
+
*
|
|
304
|
+
* Returns: nothing. Installing a rule that is already there is a no-op too,
|
|
305
|
+
* so calling it on every deploy is safe. When it writes the rules but
|
|
306
|
+
* cannot confirm within its polling window that a re-read shows them — S3
|
|
307
|
+
* documents that a lifecycle configuration can take minutes to propagate —
|
|
308
|
+
* it logs a `warn` and returns rather than throwing: the rules were
|
|
309
|
+
* written, and a later call can confirm them.
|
|
310
|
+
*
|
|
311
|
+
* Throws: `VALIDATION` naming `s3.keyPrefix` on a rule-id collision;
|
|
312
|
+
* a classified AWS failure when the bucket's lifecycle cannot be read or
|
|
313
|
+
* written; `CONTENTION` when every one of the five rounds this call polls
|
|
314
|
+
* needs a write — a competing writer replacing the configuration on every
|
|
315
|
+
* single re-read.
|
|
316
|
+
* @remarks Requires the bucket-level `s3:GetLifecycleConfiguration` /
|
|
317
|
+
* `s3:PutLifecycleConfiguration` permissions, broader than the object-level
|
|
318
|
+
* CRUD the rest of S3 offload needs — call it once during provisioning, not
|
|
319
|
+
* per request. When several adapters or processes provision the same
|
|
320
|
+
* bucket, call them one at a time and run each again after a few minutes
|
|
321
|
+
* once every one of them has run.
|
|
322
|
+
*
|
|
323
|
+
* Lowering the `ttl` is safe for new rows at once; the rule is not. Lower
|
|
324
|
+
* `ttl` now, and call this again only once the old `ttl` has elapsed since,
|
|
325
|
+
* because until then rows written under the old value still name objects
|
|
326
|
+
* the shorter rule would expire. Raising the `ttl` is safe at once.
|
|
327
|
+
*/
|
|
328
|
+
ensureS3LifecycleRule(): Promise<void>;
|
|
329
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { BaseStore, } from '@langchain/langgraph-checkpoint';
|
|
2
|
+
import { guardPublic, guardPublicSync } from '../shared/errors/boundary.js';
|
|
3
|
+
import { assertSignalLike, assertCancelOptions } from '../shared/validation/collaborators.js';
|
|
4
|
+
import { assertObjectShape } from '../shared/validation/option-shape.js';
|
|
5
|
+
import { listNamespaces } from './actions/list-namespaces.js';
|
|
6
|
+
import { putItem } from './actions/put.js';
|
|
7
|
+
import { reconcileVectorIndex as reconcileVectorIndexAction } from './actions/reconcile-vector-index.js';
|
|
8
|
+
import { searchItems } from './actions/search.js';
|
|
9
|
+
import { runBatch } from './internal/batch-plan.js';
|
|
10
|
+
import { getItem } from './internal/get-item.js';
|
|
11
|
+
import { parseListNamespacesOptions, parseNamespacePrefix, parseOperations, parsePutArguments, parseSearch, parseStoreAddress, } from './internal/parse.js';
|
|
12
|
+
import { setUpStore } from './internal/setup.js';
|
|
13
|
+
export class DynamoDBStore extends BaseStore {
|
|
14
|
+
context;
|
|
15
|
+
shell;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
super();
|
|
18
|
+
const setup = setUpStore(options);
|
|
19
|
+
this.context = setup.context;
|
|
20
|
+
this.shell = setup.shell;
|
|
21
|
+
}
|
|
22
|
+
async dispatch(operation, readConcurrency) {
|
|
23
|
+
switch (operation.kind) {
|
|
24
|
+
case 'search':
|
|
25
|
+
return searchItems({ ...this.context, readConcurrency }, operation);
|
|
26
|
+
case 'put':
|
|
27
|
+
case 'delete':
|
|
28
|
+
await putItem(this.context, operation);
|
|
29
|
+
return null;
|
|
30
|
+
case 'get':
|
|
31
|
+
return getItem(this.context, operation.address);
|
|
32
|
+
case 'list':
|
|
33
|
+
return listNamespaces(this.context, operation);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async execute(operations) {
|
|
37
|
+
return runBatch(operations, (operation, readConcurrency) => this.dispatch(operation, readConcurrency), this.context.readConcurrency);
|
|
38
|
+
}
|
|
39
|
+
async batch(operations) {
|
|
40
|
+
return guardPublic('store.batch', async () => {
|
|
41
|
+
const results = await this.execute(parseOperations(operations));
|
|
42
|
+
return results;
|
|
43
|
+
}, this.context.tableName);
|
|
44
|
+
}
|
|
45
|
+
async get(namespace, key) {
|
|
46
|
+
return guardPublic('store.get', async () => {
|
|
47
|
+
const [item] = await this.execute([
|
|
48
|
+
{ kind: 'get', address: parseStoreAddress(namespace, key) },
|
|
49
|
+
]);
|
|
50
|
+
return item;
|
|
51
|
+
}, this.context.tableName);
|
|
52
|
+
}
|
|
53
|
+
async put(namespace, key, value, index) {
|
|
54
|
+
return guardPublic('store.put', async () => {
|
|
55
|
+
await this.execute([parsePutArguments(namespace, key, value, index)]);
|
|
56
|
+
}, this.context.tableName);
|
|
57
|
+
}
|
|
58
|
+
async delete(namespace, key) {
|
|
59
|
+
return guardPublic('store.delete', async () => {
|
|
60
|
+
await this.execute([{ kind: 'delete', address: parseStoreAddress(namespace, key) }]);
|
|
61
|
+
}, this.context.tableName);
|
|
62
|
+
}
|
|
63
|
+
async listNamespaces(options = {}) {
|
|
64
|
+
return guardPublic('store.listNamespaces', async () => {
|
|
65
|
+
const [namespaces] = await this.execute([parseListNamespacesOptions(options)]);
|
|
66
|
+
return namespaces;
|
|
67
|
+
}, this.context.tableName);
|
|
68
|
+
}
|
|
69
|
+
async search(namespacePrefix, options = {}) {
|
|
70
|
+
return guardPublic('store.search', () => {
|
|
71
|
+
const prefix = parseNamespacePrefix(namespacePrefix, 'namespacePrefix');
|
|
72
|
+
assertObjectShape(options, 'options');
|
|
73
|
+
assertSignalLike(options.signal);
|
|
74
|
+
const { signal, ...rest } = options;
|
|
75
|
+
return searchItems(this.context, parseSearch(prefix, rest), signal);
|
|
76
|
+
}, this.context.tableName);
|
|
77
|
+
}
|
|
78
|
+
reconcileVectorIndex(namespacePrefix, options) {
|
|
79
|
+
return guardPublic('store.reconcileVectorIndex', () => {
|
|
80
|
+
assertCancelOptions(options);
|
|
81
|
+
return reconcileVectorIndexAction(this.context, namespacePrefix, options);
|
|
82
|
+
}, this.context.tableName);
|
|
83
|
+
}
|
|
84
|
+
stop() {
|
|
85
|
+
this.destroy();
|
|
86
|
+
}
|
|
87
|
+
destroy() {
|
|
88
|
+
guardPublicSync('store.destroy', () => this.shell.release(), this.context.tableName);
|
|
89
|
+
}
|
|
90
|
+
async ensureS3LifecycleRule() {
|
|
91
|
+
return guardPublic('store.ensureS3LifecycleRule', () => this.shell.ensureLifecycleRule(), this.context.tableName);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides the store's own option and result shapes, composed from building
|
|
3
|
+
* blocks declared elsewhere.
|
|
4
|
+
*
|
|
5
|
+
* `DynamoDBStoreOptions`, `SearchOptions`, `ListNamespacesOptions` and
|
|
6
|
+
* `VectorReconcileResult` are declared here. `DynamoDBStoreOptions` composes
|
|
7
|
+
* `BaseAdapterOptions` and `CodecOptions`, and `SearchOptions` composes
|
|
8
|
+
* `CancelOptions` — all three declared once in the shared options module, not
|
|
9
|
+
* copied here — plus `VectorBackend` and `VectorScoreDirection`, declared
|
|
10
|
+
* once in `vector-backend.ts`. Which keys each bag accepts, and the defaults
|
|
11
|
+
* filled in, are decided by the store's setup and parsers, so a caller can
|
|
12
|
+
* type what it builds without learning how it is checked.
|
|
13
|
+
*/
|
|
14
|
+
import type { IndexConfig, SearchOperation, SerializerProtocol } from '@langchain/langgraph-checkpoint';
|
|
15
|
+
import type { BaseAdapterOptions, CancelOptions, CodecOptions } from '../shared/options.js';
|
|
16
|
+
import type { VectorBackend, VectorScoreDirection } from './vector-backend.js';
|
|
17
|
+
/**
|
|
18
|
+
* Options for {@link DynamoDBStore}.
|
|
19
|
+
*
|
|
20
|
+
* `indexName` and `indexShards` are not store options: no store read uses the
|
|
21
|
+
* recency index, so a store given either refuses it as an unknown key.
|
|
22
|
+
*/
|
|
23
|
+
export type DynamoDBStoreOptions = Omit<BaseAdapterOptions, 'indexName' | 'indexShards'> & CodecOptions & {
|
|
24
|
+
/**
|
|
25
|
+
* Optional semantic-search index configuration (embeddings + fields).
|
|
26
|
+
*
|
|
27
|
+
* Without a `vectorBackend` the vectors live on the item itself, one per
|
|
28
|
+
* text the configured fields extract — a wildcard path such as
|
|
29
|
+
* `sections[*].text` extracts one per element — at up to 10 bytes per
|
|
30
|
+
* dimension. They are not counted toward `s3.thresholdBytes` — offload
|
|
31
|
+
* decides on the payload alone — and a row they would take past
|
|
32
|
+
* DynamoDB's 400 KB item limit is refused with `VALIDATION` naming
|
|
33
|
+
* `index` before anything is written.
|
|
34
|
+
*/
|
|
35
|
+
index?: IndexConfig;
|
|
36
|
+
/**
|
|
37
|
+
* Optional serializer override. The default is the exported `JSON_SERDE`,
|
|
38
|
+
* plain JSON: what it stores is the JSON projection of a value, and the
|
|
39
|
+
* README's *Table schema* section tabulates where that differs from the
|
|
40
|
+
* value itself.
|
|
41
|
+
*/
|
|
42
|
+
serde?: SerializerProtocol;
|
|
43
|
+
/** Optional external vector index; when set, similarity search delegates to it. */
|
|
44
|
+
vectorBackend?: VectorBackend;
|
|
45
|
+
/**
|
|
46
|
+
* Max candidates a semantic search may hold in memory to rank, and the
|
|
47
|
+
* furthest a `vectorBackend` page may reach, before erroring (default
|
|
48
|
+
* 1000). It bounds this process's memory, not the corpus — a corpus larger
|
|
49
|
+
* than this belongs behind a `vectorBackend`.
|
|
50
|
+
*/
|
|
51
|
+
maxSearchCandidates?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Cap on rows read into memory by one search, namespace listing or
|
|
54
|
+
* reconcile before `RESULT_TRUNCATED`. Reaching it is an error, not a
|
|
55
|
+
* truncation: a partial answer is never returned as a complete one.
|
|
56
|
+
* Defaults to 10,000; the ceiling is 1,000,000.
|
|
57
|
+
*/
|
|
58
|
+
maxScanItems?: number;
|
|
59
|
+
/**
|
|
60
|
+
* Cap on DynamoDB pages one search, namespace listing or reconcile reads
|
|
61
|
+
* before `RESULT_TRUNCATED` (default 1000; a page is at most 1 MB).
|
|
62
|
+
* `Infinity` reads to the end. It is the cap a rootless search or listing
|
|
63
|
+
* over a large table meets first when most of what it scans is not store
|
|
64
|
+
* rows, since those pages hold few rows for `maxScanItems` to count.
|
|
65
|
+
*/
|
|
66
|
+
maxIterations?: number;
|
|
67
|
+
/**
|
|
68
|
+
* Direction of the score a `vectorBackend` returns. `'relevance'` (the
|
|
69
|
+
* default) forwards it unchanged; `'distance'` negates and re-sorts, so a
|
|
70
|
+
* distance-native backend (S3 Vectors, FAISS L2, pgvector `<->`) satisfies
|
|
71
|
+
* the higher-is-better contract without the caller wrapping it. Any other
|
|
72
|
+
* value is rejected at construction with a `VALIDATION` error rather than
|
|
73
|
+
* silently ranking one direction as the other.
|
|
74
|
+
*/
|
|
75
|
+
vectorScoreDirection?: VectorScoreDirection;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Options {@link DynamoDBStore.search} accepts: the metadata/paging fields of
|
|
79
|
+
* `SearchOperation` it exposes as its own parameter (`namespacePrefix` is a
|
|
80
|
+
* separate positional argument instead), plus cancellation.
|
|
81
|
+
*/
|
|
82
|
+
export type SearchOptions = Pick<SearchOperation, 'filter' | 'limit' | 'offset' | 'query'> & CancelOptions;
|
|
83
|
+
/**
|
|
84
|
+
* Options {@link DynamoDBStore.listNamespaces} accepts: the object
|
|
85
|
+
* `BaseStore.listNamespaces` declares inline, with the same five optional
|
|
86
|
+
* fields, named so a caller can type the options it builds. A test pins it
|
|
87
|
+
* equal to upstream's parameter type.
|
|
88
|
+
*/
|
|
89
|
+
export interface ListNamespacesOptions {
|
|
90
|
+
/** Only namespaces starting with these labels; `'*'` matches any one label. */
|
|
91
|
+
prefix?: string[];
|
|
92
|
+
/** Only namespaces ending with these labels; `'*'` matches any one label. */
|
|
93
|
+
suffix?: string[];
|
|
94
|
+
/**
|
|
95
|
+
* Truncate each namespace to at most this many labels, at least 1; the
|
|
96
|
+
* namespaces that truncation makes equal are listed once.
|
|
97
|
+
*/
|
|
98
|
+
maxDepth?: number;
|
|
99
|
+
/**
|
|
100
|
+
* How many namespaces to return, from 0 to 10,000;
|
|
101
|
+
* default 100. `0` returns an empty array without reading the table.
|
|
102
|
+
*/
|
|
103
|
+
limit?: number;
|
|
104
|
+
/** How many namespaces to skip first, a non-negative integer; default 0. */
|
|
105
|
+
offset?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Counts returned by {@link DynamoDBStore.reconcileVectorIndex}. */
|
|
108
|
+
export interface VectorReconcileResult {
|
|
109
|
+
upserted: number;
|
|
110
|
+
pruned: number;
|
|
111
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which vector index the store talks to.
|
|
3
|
+
*
|
|
4
|
+
* The store sees only `VectorBackend` — upsert, query, delete and an optional
|
|
5
|
+
* listing — with what it promises and requires stated per method, so any
|
|
6
|
+
* index that keeps those terms plugs in without the store changing. The table
|
|
7
|
+
* stays the truth: a backend may lag it and may score by distance, and every
|
|
8
|
+
* match is re-read before a caller sees it.
|
|
9
|
+
*/
|
|
10
|
+
/** A vector-similarity match returned by an external {@link VectorBackend}. */
|
|
11
|
+
export interface VectorMatch {
|
|
12
|
+
namespace: string[];
|
|
13
|
+
key: string;
|
|
14
|
+
/**
|
|
15
|
+
* Relevance, where **higher means a better match** — the same direction as
|
|
16
|
+
* upstream `SearchItem.score`, which this value is forwarded to verbatim.
|
|
17
|
+
*
|
|
18
|
+
* A backend whose native output is a *distance* (S3 Vectors, FAISS L2,
|
|
19
|
+
* pgvector's `<->`) has two options: convert before returning, or declare
|
|
20
|
+
* `vectorScoreDirection: 'distance'` on the store, which negates and
|
|
21
|
+
* re-sorts for you. Forwarding an unconverted distance without declaring it
|
|
22
|
+
* yields results ordered correctly but scored backwards, which silently
|
|
23
|
+
* breaks any caller that thresholds or displays the number; that case is
|
|
24
|
+
* warned about but never reordered.
|
|
25
|
+
*/
|
|
26
|
+
score: number;
|
|
27
|
+
}
|
|
28
|
+
/** A stored vector's location, returned by {@link VectorBackend.listKeys}. */
|
|
29
|
+
export interface VectorRef {
|
|
30
|
+
namespace: string[];
|
|
31
|
+
key: string;
|
|
32
|
+
}
|
|
33
|
+
/** Which direction a {@link VectorBackend} reports its score in. */
|
|
34
|
+
export type VectorScoreDirection = 'relevance' | 'distance';
|
|
35
|
+
/**
|
|
36
|
+
* Pluggable vector index. When provided to the store, embeddings live here and
|
|
37
|
+
* similarity search is delegated to it; DynamoDB still holds the canonical item.
|
|
38
|
+
*
|
|
39
|
+
* This is an interface you implement, so what the store promises and what it
|
|
40
|
+
* requires are both stated per method. Two properties hold throughout: the
|
|
41
|
+
* store writes DynamoDB first and syncs here afterwards, so the backend may lag
|
|
42
|
+
* the canonical item and `reconcileVectorIndex` exists to close that gap; and
|
|
43
|
+
* every result is re-read from DynamoDB before a caller sees it, so a stale
|
|
44
|
+
* entry costs a wasted read, never a wrong answer.
|
|
45
|
+
*/
|
|
46
|
+
export interface VectorBackend {
|
|
47
|
+
/**
|
|
48
|
+
* Store one item's vector.
|
|
49
|
+
*
|
|
50
|
+
* Receives: a validated `namespace` and `key`, and a vector of the width
|
|
51
|
+
* `index.dims` declares. Called once per indexed put, after the item is
|
|
52
|
+
* committed, and again for every item of a `reconcileVectorIndex`.
|
|
53
|
+
*
|
|
54
|
+
* Must: replace any vector already held for that `(namespace, key)` —
|
|
55
|
+
* upserting the same pair repeatedly is normal and must not accumulate
|
|
56
|
+
* entries.
|
|
57
|
+
*
|
|
58
|
+
* May throw: a rejection is logged and swallowed on the put path (the item
|
|
59
|
+
* still stands) and propagates from a reconcile.
|
|
60
|
+
*/
|
|
61
|
+
upsert(namespace: string[], key: string, vector: number[]): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Return up to `topK` matches under `namespacePrefix`, best first.
|
|
64
|
+
*
|
|
65
|
+
* Receives: the same query vector width as `upsert`, and a `topK` the store
|
|
66
|
+
* raises — up to `maxSearchCandidates` — while its filter leaves the page
|
|
67
|
+
* short, so returning fewer than `topK` is read as "that is all there is".
|
|
68
|
+
*
|
|
69
|
+
* Must: order best-first, and score each match as a relevance, not a
|
|
70
|
+
* distance (see {@link VectorMatch.score}). Matches outside the prefix, and
|
|
71
|
+
* matches whose item has since been deleted, are dropped by the store rather
|
|
72
|
+
* than trusted — over-returning is safe, under-returning silently shortens
|
|
73
|
+
* the page.
|
|
74
|
+
*/
|
|
75
|
+
query(namespacePrefix: string[], queryVector: number[], topK: number): Promise<VectorMatch[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Drop one item's vector.
|
|
78
|
+
*
|
|
79
|
+
* Receives: the item's address. Called when the item is deleted, and also
|
|
80
|
+
* after any put that produced no vector — `index: false`, or a value with no
|
|
81
|
+
* indexable text — because the previous vector would otherwise keep matching
|
|
82
|
+
* an item that no longer has that text.
|
|
83
|
+
*
|
|
84
|
+
* Must: succeed for a key that holds no vector. That is the common case on
|
|
85
|
+
* the no-vector put path, and treating it as an error would warn on every
|
|
86
|
+
* such put.
|
|
87
|
+
*/
|
|
88
|
+
delete(namespace: string[], key: string): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Optionally enumerate every stored vector under `namespacePrefix`. Enables
|
|
91
|
+
* `reconcileVectorIndex` to prune vectors orphaned by a lost delete. Omit it
|
|
92
|
+
* when the backend cannot enumerate — reconciliation then re-pushes only.
|
|
93
|
+
*
|
|
94
|
+
* Must: not return keys from outside `namespacePrefix`. Under-reporting only
|
|
95
|
+
* leaves an orphan for a later reconcile; over-reporting offers a vector
|
|
96
|
+
* outside the scope for pruning, and the reconcile is what would delete it.
|
|
97
|
+
*/
|
|
98
|
+
listKeys?(namespacePrefix: string[]): Promise<VectorRef[]>;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Every direction `toRelevanceScores` (store/internal/vector-index.ts)
|
|
102
|
+
* recognises, for validating input.
|
|
103
|
+
*/
|
|
104
|
+
export declare const VECTOR_SCORE_DIRECTIONS: readonly VectorScoreDirection[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const VECTOR_SCORE_DIRECTIONS = ['relevance', 'distance'];
|