@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,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how rows written before the recency index are given its keys.
|
|
3
|
+
*
|
|
4
|
+
* The index is opt-in (record 8), so a table can hold rows from before it
|
|
5
|
+
* existed. An operator walks the table a page at a time, resumably, and gives
|
|
6
|
+
* each row the keys its adapter would have written; which rows those are is
|
|
7
|
+
* each adapter's own answer, asked here, and a row that gained keys since the
|
|
8
|
+
* scan read it is left alone.
|
|
9
|
+
*/
|
|
10
|
+
import type { AttributeMap, DynamoDBDocumentLike } from '../shared/dynamodb/client.js';
|
|
11
|
+
import { type IndexTarget } from '../shared/dynamodb/recency-index.js';
|
|
12
|
+
import { type RetryOptions } from '../shared/dynamodb/retry.js';
|
|
13
|
+
/**
|
|
14
|
+
* Give rows written before the recency index their index keys.
|
|
15
|
+
*
|
|
16
|
+
* **Run this before setting `indexName` on any adapter.** A row without the
|
|
17
|
+
* keys is not in the index, so enabling the index first would make every
|
|
18
|
+
* pre-existing session and checkpoint silently vanish from the listings
|
|
19
|
+
* that read it — the rows are still there, and every other read still returns
|
|
20
|
+
* them, but a listing would not.
|
|
21
|
+
*
|
|
22
|
+
* Safe to re-run and safe to run while adapters are writing: every write is
|
|
23
|
+
* conditional on the row still being there and having no keys yet, so a row a
|
|
24
|
+
* live adapter has already indexed is left exactly as it is, and a row deleted
|
|
25
|
+
* after the scan found it stays deleted rather than being re-created by an
|
|
26
|
+
* `UpdateItem`, which upserts.
|
|
27
|
+
*
|
|
28
|
+
* `indexShards` must match what the saver and the history use. A mismatch
|
|
29
|
+
* puts rows on shards no listing queries, which looks exactly like the rows
|
|
30
|
+
* being missing.
|
|
31
|
+
*
|
|
32
|
+
* Accepts: `options` — validated in full before any read: only the keys
|
|
33
|
+
* `BackfillOptions` declares; `tableName`, `indexShards` and the numbers in
|
|
34
|
+
* `retry` by the adapters' rules; `signal` as their methods check it; a
|
|
35
|
+
* `client` providing `scan` and `update`. `options.pageSize` — a positive integer,
|
|
36
|
+
* default 100. `options.cursor` — from a previous run, to resume.
|
|
37
|
+
* `options.maxPages` — how far one run goes, so a large table can be
|
|
38
|
+
* backfilled in bounded slices. `options.indexShards` — must equal the
|
|
39
|
+
* saver's and the history's setting, and has their ceiling. `options.dryRun` — a boolean.
|
|
40
|
+
* `options.signal` — cancels the run; `retry.signal` does so when there is no
|
|
41
|
+
* top-level `signal`, and the top-level one wins when both are given.
|
|
42
|
+
*
|
|
43
|
+
* Returns: how many rows were scanned, how many were given keys and how many
|
|
44
|
+
* were skipped — a row no listing reaches, and a row whose write the condition
|
|
45
|
+
* refused because the row already has keys or is gone — plus a `nextCursor`
|
|
46
|
+
* when the run stopped short of the end. An absent cursor means the table is
|
|
47
|
+
* fully backfilled.
|
|
48
|
+
*
|
|
49
|
+
* Throws: `VALIDATION` naming the offending option, before any DynamoDB
|
|
50
|
+
* call; `RETRY_EXHAUSTED` once a transient failure has used every attempt;
|
|
51
|
+
* `ABORTED` when `signal` fires, or `retry.signal` when no top-level `signal`
|
|
52
|
+
* is given; any other error the scan or the writes throw, wrapped with the
|
|
53
|
+
* code the classifier assigns — this is the function's own error boundary,
|
|
54
|
+
* the same as every adapter's public methods, so a caller's mistake never escapes as a bare
|
|
55
|
+
* exception. A refused write is none of these: it is an outcome for one row,
|
|
56
|
+
* reported in `skipped`.
|
|
57
|
+
*
|
|
58
|
+
* Guarantees: every write is conditional on the row still being there and
|
|
59
|
+
* having no keys yet, so re-running is safe, running against a live table is
|
|
60
|
+
* safe, a row a live adapter has already indexed is left exactly as it is, and
|
|
61
|
+
* a row deleted between the scan and the write is never re-created. Neither
|
|
62
|
+
* refusal stops the run: both mean this run has nothing to do for that row, so
|
|
63
|
+
* the row is counted as skipped and the walk carries on to the rest of the
|
|
64
|
+
* table.
|
|
65
|
+
*/
|
|
66
|
+
export declare function backfillRecencyIndex(options: BackfillOptions): Promise<BackfillResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Which rows the index covers: the checkpointer and the chat history each
|
|
69
|
+
* answer for their own rows; a store row is in no listing the index serves.
|
|
70
|
+
*
|
|
71
|
+
* Accepts: `row` — any row a table scan returns, including a foreign one and
|
|
72
|
+
* one whose `PK`/`SK` are not strings.
|
|
73
|
+
*
|
|
74
|
+
* Returns: the index identity, or undefined for a row no listing reaches — a
|
|
75
|
+
* foreign row, a payload or write row, a META row carrying no `checkpointId`,
|
|
76
|
+
* or a store row.
|
|
77
|
+
*
|
|
78
|
+
* Throws: nothing. A backfill walks the whole table; one unrecognised row must
|
|
79
|
+
* be skipped, not fatal.
|
|
80
|
+
*/
|
|
81
|
+
export declare function indexTargetOf(row: AttributeMap): IndexTarget | undefined;
|
|
82
|
+
/**
|
|
83
|
+
* A scan position, as an opaque string.
|
|
84
|
+
*
|
|
85
|
+
* Accepts: `key` — a `LastEvaluatedKey` from the scan being resumed.
|
|
86
|
+
*
|
|
87
|
+
* Returns: it base64url-encoded. Opaque to the caller: its shape is not a
|
|
88
|
+
* promise, which is what leaves the encoding free to change.
|
|
89
|
+
*
|
|
90
|
+
* Throws: nothing.
|
|
91
|
+
*/
|
|
92
|
+
export declare function encodeScanCursor(key: AttributeMap): string;
|
|
93
|
+
/**
|
|
94
|
+
* The scan position a cursor encodes.
|
|
95
|
+
*
|
|
96
|
+
* Accepts: `cursor` — as a previous page returned it.
|
|
97
|
+
*
|
|
98
|
+
* Returns: the `ExclusiveStartKey` to resume from — always exactly `{ PK,
|
|
99
|
+
* SK }`, both strings, since a plain table `Scan` (no `IndexName`) never
|
|
100
|
+
* returns a `LastEvaluatedKey` shaped any other way.
|
|
101
|
+
*
|
|
102
|
+
* Throws: `VALIDATION` naming `cursor` for anything this tool did not
|
|
103
|
+
* issue — text that is not base64url, that does not decode to JSON, or that
|
|
104
|
+
* decodes to anything but `{ PK: string, SK: string }`: an array, an object
|
|
105
|
+
* missing either key, carrying an extra one, or carrying a non-string value
|
|
106
|
+
* for either. A cursor is fed straight back to DynamoDB as
|
|
107
|
+
* `ExclusiveStartKey`, so a value of the wrong shape is refused here rather
|
|
108
|
+
* than surfacing as a raw `ValidationException` from the service.
|
|
109
|
+
*/
|
|
110
|
+
export declare function decodeScanCursor(cursor: string): AttributeMap;
|
|
111
|
+
/** What one pass of the backfill did, and where to resume. */
|
|
112
|
+
export interface BackfillResult {
|
|
113
|
+
/** Rows the scan returned: those without index keys, since its filter drops every row that has them. Not the rows DynamoDB evaluated, which a filter does not reduce. */
|
|
114
|
+
scanned: number;
|
|
115
|
+
/** Rows given index keys. */
|
|
116
|
+
indexed: number;
|
|
117
|
+
/**
|
|
118
|
+
* Rows this run wrote no keys for: one no listing reaches, and one whose
|
|
119
|
+
* write the condition refused because it already has keys or is gone.
|
|
120
|
+
*/
|
|
121
|
+
skipped: number;
|
|
122
|
+
/**
|
|
123
|
+
* Opaque; absent when the table is fully walked. Pass it back to continue —
|
|
124
|
+
* the pass is resumable, so a large table can be backfilled in bounded runs.
|
|
125
|
+
*/
|
|
126
|
+
nextCursor?: string;
|
|
127
|
+
}
|
|
128
|
+
/** What the backfill needs to walk a table. A key this type does not declare is refused. */
|
|
129
|
+
export interface BackfillOptions {
|
|
130
|
+
client: DynamoDBDocumentLike;
|
|
131
|
+
tableName: string;
|
|
132
|
+
/** Must equal the saver's and the history's `indexShards`, or rows land on shards no listing queries. */
|
|
133
|
+
indexShards?: number;
|
|
134
|
+
/** Rows per scan page. */
|
|
135
|
+
pageSize?: number;
|
|
136
|
+
/** Stop after this many pages and return a cursor. Default: walk the whole table. */
|
|
137
|
+
maxPages?: number;
|
|
138
|
+
cursor?: string;
|
|
139
|
+
/** Report what would change without writing. */
|
|
140
|
+
dryRun?: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* The full retry surface, not the adapters' narrower `RetryPolicy`:
|
|
143
|
+
* `onRetry` is backfill's only way to observe retries in progress, since it
|
|
144
|
+
* takes no `logger`.
|
|
145
|
+
*/
|
|
146
|
+
retry?: RetryOptions;
|
|
147
|
+
signal?: AbortSignal;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Validate every option `backfillRecencyIndex` reads, before any of them is
|
|
151
|
+
* read for real.
|
|
152
|
+
*
|
|
153
|
+
* Accepts: `options` — must be an object naming only the nine keys
|
|
154
|
+
* {@link BackfillOptions} declares. `tableName` and `client` are required, the
|
|
155
|
+
* rest optional; each, when given, follows the same rule an adapter's own
|
|
156
|
+
* option of the same name does. `tableName` reuses the adapters' own
|
|
157
|
+
* `tableName` validator outright; `indexShards` is held to the adapters'
|
|
158
|
+
* shard cap of 1024; and `retry` shares its numeric bounds with
|
|
159
|
+
* the adapters' own `retry` validator while accepting the wider surface
|
|
160
|
+
* backfill's `RetryOptions` needs, so a mismatch between backfill and the
|
|
161
|
+
* adapters it feeds cannot drift in on what a bound means.
|
|
162
|
+
*
|
|
163
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
164
|
+
* checks it.
|
|
165
|
+
*
|
|
166
|
+
* Throws: `VALIDATION` naming `options.<key>` for an unknown key;
|
|
167
|
+
* `tableName`; `client` or `client.<member>`; `indexShards`, `pageSize` or
|
|
168
|
+
* `maxPages` for a non-positive-integer bound (`indexShards` is additionally
|
|
169
|
+
* capped); `dryRun` for a non-boolean; `retry`/`retry.<key>`; `signal`.
|
|
170
|
+
*/
|
|
171
|
+
export declare function assertBackfillOptions(options: BackfillOptions): void;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.backfillRecencyIndex = backfillRecencyIndex;
|
|
4
|
+
exports.indexTargetOf = indexTargetOf;
|
|
5
|
+
exports.encodeScanCursor = encodeScanCursor;
|
|
6
|
+
exports.decodeScanCursor = decodeScanCursor;
|
|
7
|
+
exports.assertBackfillOptions = assertBackfillOptions;
|
|
8
|
+
const rows_js_1 = require("../checkpointer/internal/rows.js");
|
|
9
|
+
const session_js_1 = require("../history/internal/session.js");
|
|
10
|
+
const concurrency_js_1 = require("../shared/concurrency.js");
|
|
11
|
+
const idempotent_write_js_1 = require("../shared/dynamodb/idempotent-write.js");
|
|
12
|
+
const recency_index_js_1 = require("../shared/dynamodb/recency-index.js");
|
|
13
|
+
const retry_js_1 = require("../shared/dynamodb/retry.js");
|
|
14
|
+
const table_schema_js_1 = require("../shared/dynamodb/table-schema.js");
|
|
15
|
+
const boundary_js_1 = require("../shared/errors/boundary.js");
|
|
16
|
+
const errors_js_1 = require("../shared/errors/errors.js");
|
|
17
|
+
const collaborators_js_1 = require("../shared/validation/collaborators.js");
|
|
18
|
+
const option_shape_js_1 = require("../shared/validation/option-shape.js");
|
|
19
|
+
const options_js_1 = require("../shared/validation/options.js");
|
|
20
|
+
const primitives_js_1 = require("../shared/validation/primitives.js");
|
|
21
|
+
function runRetry(options) {
|
|
22
|
+
return { ...options.retry, signal: options.signal ?? options.retry?.signal };
|
|
23
|
+
}
|
|
24
|
+
async function indexRow(options, row, shards) {
|
|
25
|
+
const target = indexTargetOf(row);
|
|
26
|
+
if (target === undefined)
|
|
27
|
+
return false;
|
|
28
|
+
const keys = (0, recency_index_js_1.indexKeys)(target.tag, target.id, target.at, shards);
|
|
29
|
+
if (options.dryRun)
|
|
30
|
+
return true;
|
|
31
|
+
try {
|
|
32
|
+
await writeIndexKeys(options, row, keys);
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
if (!(0, idempotent_write_js_1.isConditionalCheckFailed)(error))
|
|
36
|
+
throw error;
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
async function writeIndexKeys(options, row, keys) {
|
|
42
|
+
await (0, retry_js_1.withDynamoDBRetry)((request) => options.client.update({
|
|
43
|
+
TableName: options.tableName,
|
|
44
|
+
Key: (0, table_schema_js_1.rowKeyOf)(row),
|
|
45
|
+
UpdateExpression: 'SET #gpk = :gpk, #gsk = :gsk',
|
|
46
|
+
ExpressionAttributeNames: {
|
|
47
|
+
'#gpk': recency_index_js_1.INDEX_PARTITION_ATTRIBUTE,
|
|
48
|
+
'#gsk': recency_index_js_1.INDEX_SORT_ATTRIBUTE,
|
|
49
|
+
},
|
|
50
|
+
ExpressionAttributeValues: { ':gpk': keys.gsi1pk, ':gsk': keys.gsi1sk },
|
|
51
|
+
ConditionExpression: `attribute_exists(${table_schema_js_1.PARTITION_KEY_ATTRIBUTE}) AND attribute_not_exists(#gpk)`,
|
|
52
|
+
}, request), runRetry(options));
|
|
53
|
+
}
|
|
54
|
+
async function backfillPage(options, shards, startKey) {
|
|
55
|
+
const result = await (0, retry_js_1.withDynamoDBRetry)((request) => options.client.scan({
|
|
56
|
+
TableName: options.tableName,
|
|
57
|
+
Limit: options.pageSize ?? 100,
|
|
58
|
+
ExclusiveStartKey: startKey,
|
|
59
|
+
FilterExpression: 'attribute_not_exists(#gpk)',
|
|
60
|
+
ExpressionAttributeNames: { '#gpk': recency_index_js_1.INDEX_PARTITION_ATTRIBUTE },
|
|
61
|
+
}, request), runRetry(options));
|
|
62
|
+
const rows = (result.Items ?? []);
|
|
63
|
+
const written = await (0, concurrency_js_1.mapWithConcurrency)(rows, concurrency_js_1.DEFAULT_READ_CONCURRENCY, (row) => indexRow(options, row, shards));
|
|
64
|
+
return {
|
|
65
|
+
rows: rows.length,
|
|
66
|
+
indexed: written.filter(Boolean).length,
|
|
67
|
+
nextKey: result.LastEvaluatedKey,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
async function backfillRecencyIndex(options) {
|
|
71
|
+
return (0, boundary_js_1.guardPublic)('backfillRecencyIndex', async () => {
|
|
72
|
+
assertBackfillOptions(options);
|
|
73
|
+
const shards = options.indexShards ?? recency_index_js_1.DEFAULT_INDEX_SHARDS;
|
|
74
|
+
let startKey = options.cursor === undefined ? undefined : decodeScanCursor(options.cursor);
|
|
75
|
+
let scanned = 0;
|
|
76
|
+
let indexed = 0;
|
|
77
|
+
for (let page = 1;; page++) {
|
|
78
|
+
const result = await backfillPage(options, shards, startKey);
|
|
79
|
+
scanned += result.rows;
|
|
80
|
+
indexed += result.indexed;
|
|
81
|
+
startKey = result.nextKey;
|
|
82
|
+
if (startKey === undefined)
|
|
83
|
+
break;
|
|
84
|
+
if (options.maxPages !== undefined && page >= options.maxPages) {
|
|
85
|
+
return {
|
|
86
|
+
scanned,
|
|
87
|
+
indexed,
|
|
88
|
+
skipped: scanned - indexed,
|
|
89
|
+
nextCursor: encodeScanCursor(startKey),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return { scanned, indexed, skipped: scanned - indexed };
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function indexTargetOf(row) {
|
|
97
|
+
return (0, rows_js_1.checkpointIndexTarget)(row) ?? (0, session_js_1.sessionIndexTarget)(row);
|
|
98
|
+
}
|
|
99
|
+
function encodeScanCursor(key) {
|
|
100
|
+
return Buffer.from(JSON.stringify(key), 'utf8').toString('base64url');
|
|
101
|
+
}
|
|
102
|
+
function isTableKeyShape(value) {
|
|
103
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value))
|
|
104
|
+
return false;
|
|
105
|
+
const keys = Object.keys(value);
|
|
106
|
+
return keys.length === 2 && typeof value.PK === 'string' && typeof value.SK === 'string';
|
|
107
|
+
}
|
|
108
|
+
function decodeScanCursor(cursor) {
|
|
109
|
+
try {
|
|
110
|
+
const decoded = JSON.parse(Buffer.from(cursor, 'base64url').toString('utf8'));
|
|
111
|
+
if (!isTableKeyShape(decoded))
|
|
112
|
+
throw new Error('not a scan position');
|
|
113
|
+
return decoded;
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
throw (0, errors_js_1.validationError)('cursor is not one this tool issued', 'cursor');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const BACKFILL_KEYS = (0, option_shape_js_1.allKeysOf)({
|
|
120
|
+
client: 'client',
|
|
121
|
+
tableName: 'tableName',
|
|
122
|
+
indexShards: 'indexShards',
|
|
123
|
+
pageSize: 'pageSize',
|
|
124
|
+
maxPages: 'maxPages',
|
|
125
|
+
cursor: 'cursor',
|
|
126
|
+
dryRun: 'dryRun',
|
|
127
|
+
retry: 'retry',
|
|
128
|
+
signal: 'signal',
|
|
129
|
+
});
|
|
130
|
+
const BACKFILL_CLIENT_MEMBERS = ['scan', 'update'];
|
|
131
|
+
const BACKFILL_RETRY_KEYS = (0, option_shape_js_1.allKeysOf)({
|
|
132
|
+
maxAttempts: 'maxAttempts',
|
|
133
|
+
baseDelayMs: 'baseDelayMs',
|
|
134
|
+
maxDelayMs: 'maxDelayMs',
|
|
135
|
+
retryableErrors: 'retryableErrors',
|
|
136
|
+
isRetryable: 'isRetryable',
|
|
137
|
+
onRetry: 'onRetry',
|
|
138
|
+
signal: 'signal',
|
|
139
|
+
rng: 'rng',
|
|
140
|
+
});
|
|
141
|
+
function assertBackfillRetryOptions(retry) {
|
|
142
|
+
(0, option_shape_js_1.assertShape)(retry, BACKFILL_RETRY_KEYS, 'retry');
|
|
143
|
+
(0, options_js_1.assertRetryBounds)(retry);
|
|
144
|
+
if (retry.retryableErrors !== undefined) {
|
|
145
|
+
(0, primitives_js_1.assertStringArray)(retry.retryableErrors, 'retry.retryableErrors');
|
|
146
|
+
}
|
|
147
|
+
if (retry.isRetryable !== undefined && typeof retry.isRetryable !== 'function') {
|
|
148
|
+
throw (0, errors_js_1.validationError)('retry.isRetryable must be a function', 'retry.isRetryable');
|
|
149
|
+
}
|
|
150
|
+
if (retry.onRetry !== undefined && typeof retry.onRetry !== 'function') {
|
|
151
|
+
throw (0, errors_js_1.validationError)('retry.onRetry must be a function', 'retry.onRetry');
|
|
152
|
+
}
|
|
153
|
+
if (retry.rng !== undefined && typeof retry.rng !== 'function') {
|
|
154
|
+
throw (0, errors_js_1.validationError)('retry.rng must be a function', 'retry.rng');
|
|
155
|
+
}
|
|
156
|
+
(0, collaborators_js_1.assertSignalLike)(retry.signal, 'retry.signal');
|
|
157
|
+
}
|
|
158
|
+
function assertPositiveBound(value, field, max) {
|
|
159
|
+
if (value === undefined)
|
|
160
|
+
return;
|
|
161
|
+
(0, primitives_js_1.assertInteger)(value, field, max === undefined ? { min: 1 } : { min: 1, max });
|
|
162
|
+
}
|
|
163
|
+
function assertBackfillOptions(options) {
|
|
164
|
+
(0, option_shape_js_1.assertShape)(options, BACKFILL_KEYS, 'options');
|
|
165
|
+
(0, options_js_1.assertTableName)(options.tableName);
|
|
166
|
+
(0, collaborators_js_1.assertMembers)(options.client, BACKFILL_CLIENT_MEMBERS, 'client');
|
|
167
|
+
(0, collaborators_js_1.assertClientTranslation)(options.client);
|
|
168
|
+
assertPositiveBound(options.indexShards, 'indexShards', recency_index_js_1.MAX_INDEX_SHARDS);
|
|
169
|
+
assertPositiveBound(options.pageSize, 'pageSize');
|
|
170
|
+
assertPositiveBound(options.maxPages, 'maxPages');
|
|
171
|
+
if (options.dryRun !== undefined && typeof options.dryRun !== 'boolean') {
|
|
172
|
+
throw (0, errors_js_1.validationError)('dryRun must be a boolean', 'dryRun');
|
|
173
|
+
}
|
|
174
|
+
if (options.retry !== undefined)
|
|
175
|
+
assertBackfillRetryOptions(options.retry);
|
|
176
|
+
(0, collaborators_js_1.assertSignalLike)(options.signal);
|
|
177
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides what deleting a thread means for the checkpointer's rows.
|
|
3
|
+
*
|
|
4
|
+
* The partition delete itself is shared; what is decided here is which rows of
|
|
5
|
+
* a thread's partition are the checkpointer's to remove, which objects each one
|
|
6
|
+
* names, and which write id pins each delete, so a checkpoint or a pending
|
|
7
|
+
* write rewritten after the read is left alone. A caller names a thread and
|
|
8
|
+
* never learns the row kinds, their sort keys or how a refusal is counted.
|
|
9
|
+
*/
|
|
10
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
11
|
+
/**
|
|
12
|
+
* Delete exactly the checkpoint, payload and write rows of one thread that the
|
|
13
|
+
* partition read observed.
|
|
14
|
+
*
|
|
15
|
+
* Accepts: `threadId` — validated like every identifier. `options.signal` —
|
|
16
|
+
* stops the read between pages.
|
|
17
|
+
*
|
|
18
|
+
* Returns: nothing. Deleting a thread that does not exist is not an error:
|
|
19
|
+
* there is simply nothing in the partition.
|
|
20
|
+
*
|
|
21
|
+
* Throws: `VALIDATION` for a malformed `threadId`;
|
|
22
|
+
* `BATCH_WRITE_INCOMPLETE` when a row's delete fails, carrying what did
|
|
23
|
+
* succeed; `ABORTED` when the signal fires, whether between pages or during
|
|
24
|
+
* a row's delete — a cancel is reported as a cancel and never as an incomplete
|
|
25
|
+
* delete, and no further row is issued after it. A refused row is **not** one of
|
|
26
|
+
* those failures and raises nothing: the pin turned it away because it was
|
|
27
|
+
* rewritten after the read, and deleting it would erase a write already
|
|
28
|
+
* acknowledged to its author and release the object that write uploaded, so
|
|
29
|
+
* leaving it is the safe answer rather than a degraded one. The error's two
|
|
30
|
+
* counts are **rows**, not batches — rows deleted and rows attempted, summed
|
|
31
|
+
* across every flush of the pass, with `details.succeededCount` repeating the first
|
|
32
|
+
* and `details.failedChunks` holding each failing row's own error — and its message says so,
|
|
33
|
+
* because a pass that sends one request per row is not a batch that did not
|
|
34
|
+
* drain. Refused rows are in neither count; they are reported at `warn` with
|
|
35
|
+
* their sort keys and counted as skipped. The remedy for a refusal is the same
|
|
36
|
+
* as for a row written after the read: re-run once the thread is quiescent.
|
|
37
|
+
*
|
|
38
|
+
* Guarantees: a row this adapter did not write is left in place and logged, so
|
|
39
|
+
* a shared-table partition is never collaterally wiped. A row written or
|
|
40
|
+
* rewritten after the read is left in place and reported too: every delete is
|
|
41
|
+
* pinned on the id of the write that produced the row it names, so a checkpoint
|
|
42
|
+
* re-put while this runs keeps both its rows and the objects they name, and its
|
|
43
|
+
* pending writes are then left alone with them. A row written before that id
|
|
44
|
+
* existed carries none and is deleted as it always was. A row written at a key
|
|
45
|
+
* the read never saw still survives the pass, which is why the thread should be
|
|
46
|
+
* quiescent.
|
|
47
|
+
*/
|
|
48
|
+
export declare function deleteThread(context: CheckpointerContext, threadId: string, options?: {
|
|
49
|
+
signal?: AbortSignal;
|
|
50
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteThread = deleteThread;
|
|
4
|
+
const partition_delete_js_1 = require("../../shared/dynamodb/partition-delete.js");
|
|
5
|
+
const retry_js_1 = require("../../shared/dynamodb/retry.js");
|
|
6
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
7
|
+
const rows_js_1 = require("../internal/rows.js");
|
|
8
|
+
async function deleteThread(context, threadId, options = {}) {
|
|
9
|
+
const thread = (0, parse_js_1.parseThreadId)(threadId);
|
|
10
|
+
await (0, partition_delete_js_1.deletePartitionRows)({
|
|
11
|
+
client: context.client,
|
|
12
|
+
tableName: context.tableName,
|
|
13
|
+
params: (0, rows_js_1.partitionQuery)(context.tableName, (0, rows_js_1.partitionKey)(thread), { consistent: true }),
|
|
14
|
+
logger: context.logger,
|
|
15
|
+
retry: (0, retry_js_1.retryFor)(context, options.signal),
|
|
16
|
+
signal: options.signal,
|
|
17
|
+
offloader: context.offloader,
|
|
18
|
+
operation: 'deleteThread',
|
|
19
|
+
ownsSortKey: rows_js_1.isCheckpointerSortKey,
|
|
20
|
+
descriptorsOf: rows_js_1.checkpointRowDescriptors,
|
|
21
|
+
idAttribute: rows_js_1.WRITE_GROUP_ATTRIBUTE,
|
|
22
|
+
unitOf: rows_js_1.checkpointRowUnit,
|
|
23
|
+
kindOf: rows_js_1.checkpointRowKind,
|
|
24
|
+
scope: [thread],
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which checkpoint a read config resolves to.
|
|
3
|
+
*
|
|
4
|
+
* A config may name a checkpoint, only a namespace, or no thread at all, and
|
|
5
|
+
* each has one answer here: the checkpoint named, else the newest in the
|
|
6
|
+
* namespace (the root when none is given), else nothing rather than an error,
|
|
7
|
+
* as the reference saver answers. That the read is strongly consistent, so a
|
|
8
|
+
* checkpoint just written is always seen, is fixed here too.
|
|
9
|
+
*/
|
|
10
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
11
|
+
import type { CheckpointTuple } from '@langchain/langgraph-checkpoint';
|
|
12
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
13
|
+
/**
|
|
14
|
+
* One checkpoint with its metadata and pending writes.
|
|
15
|
+
*
|
|
16
|
+
* Accepts: `config` — `checkpoint_id` names the checkpoint, and its absence
|
|
17
|
+
* asks for the newest in the namespace. A config naming **no thread** is
|
|
18
|
+
* accepted: its other identifiers are still validated, and the answer is
|
|
19
|
+
* "nothing" rather than an error, which is what the reference saver does
|
|
20
|
+
* (`@langchain/langgraph-checkpoint@1.1.5` `dist/memory.js:86-92`: `thread_id`
|
|
21
|
+
* is read optionally while `checkpoint_ns` is asserted either way).
|
|
22
|
+
* `config.signal` — cancels the reads; checked before any of them.
|
|
23
|
+
*
|
|
24
|
+
* Returns: the tuple, or undefined for an unknown thread, an unknown
|
|
25
|
+
* checkpoint, a config naming no thread, or a META row whose PAYLOAD row is
|
|
26
|
+
* gone — a thread mid-delete, or an expiry sweep that reached the PAYLOAD row
|
|
27
|
+
* first; the two are written in one transaction, so no write leaves that gap.
|
|
28
|
+
*
|
|
29
|
+
* Throws: `VALIDATION`, before any read, naming `config`, `configurable` or
|
|
30
|
+
* `signal` for a config of the wrong shape, or `thread_id`, `checkpoint_ns`,
|
|
31
|
+
* `checkpoint_id` or `thread_ts` for a malformed identifier; whatever the
|
|
32
|
+
* reads throw.
|
|
33
|
+
*
|
|
34
|
+
* Guarantees: strongly consistent, so a checkpoint just written is always seen.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getCheckpointTuple(context: CheckpointerContext, config: RunnableConfig): Promise<CheckpointTuple | undefined>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCheckpointTuple = getCheckpointTuple;
|
|
4
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
5
|
+
const read_js_1 = require("../internal/read.js");
|
|
6
|
+
async function getCheckpointTuple(context, config) {
|
|
7
|
+
const parsed = (0, parse_js_1.parseConfig)(config);
|
|
8
|
+
if (parsed.threadId === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
const address = {
|
|
11
|
+
threadId: parsed.threadId,
|
|
12
|
+
checkpointNs: parsed.checkpointNs ?? parse_js_1.ROOT_NAMESPACE,
|
|
13
|
+
checkpointId: parsed.checkpointId,
|
|
14
|
+
};
|
|
15
|
+
const meta = await (0, read_js_1.fetchTargetMeta)(context, address, parsed.signal);
|
|
16
|
+
if (!meta)
|
|
17
|
+
return undefined;
|
|
18
|
+
return (0, read_js_1.assembleTuple)(context, { threadId: address.threadId, checkpointNs: address.checkpointNs }, meta, {
|
|
19
|
+
signal: parsed.signal,
|
|
20
|
+
consistent: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides when a listing reads, and when it stops.
|
|
3
|
+
*
|
|
4
|
+
* A `limit` of `0` is answered before any request is built, a config that
|
|
5
|
+
* pins one checkpoint in a known namespace is a single direct read rather than
|
|
6
|
+
* a range, and every other listing streams tuples until the caller stops
|
|
7
|
+
* pulling or `limit` is reached. The read is deliberately unbounded and
|
|
8
|
+
* eventually consistent; past a threshold an operator is warned instead of the
|
|
9
|
+
* caller being refused. Where the rows come from is `listing`'s concern.
|
|
10
|
+
*/
|
|
11
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
12
|
+
import type { CheckpointListOptions, CheckpointTuple } from '@langchain/langgraph-checkpoint';
|
|
13
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
14
|
+
/**
|
|
15
|
+
* Yield checkpoint tuples for a thread, newest first: every namespace when the
|
|
16
|
+
* config names none (grouped by namespace, newest first within each), else the
|
|
17
|
+
* one namespace given. Without a `thread_id` every thread in the table is
|
|
18
|
+
* listed: through a table scan, as the reference savers do, which is unordered
|
|
19
|
+
* across threads, or through the recency index when `indexName` is set. Either
|
|
20
|
+
* read is cross-tenant by construction. Honors `options.before` (only
|
|
21
|
+
* checkpoints older than the given id), `options.filter` (metadata equality),
|
|
22
|
+
* and `options.limit` (max tuples yielded; the read stops right after the
|
|
23
|
+
* yield that reaches it).
|
|
24
|
+
*
|
|
25
|
+
* Accepts: `config` — `thread_id` scopes the read to one thread and its absence
|
|
26
|
+
* lists every thread in the table, through a scan as the reference savers do or
|
|
27
|
+
* through the recency index when `indexName` is set; `checkpoint_ns` scopes to
|
|
28
|
+
* one namespace and its absence spans every namespace of the thread.
|
|
29
|
+
* `options.before` — only checkpoints older than that id. `options.filter` —
|
|
30
|
+
* metadata equality. `options.limit` — at most this many tuples, up to the
|
|
31
|
+
* package's page ceiling; `0` yields nothing, which is what the reference
|
|
32
|
+
* returns, and a negative value is refused.
|
|
33
|
+
*
|
|
34
|
+
* Returns: an async generator over the tuples. With a `thread_id`, newest
|
|
35
|
+
* first within each namespace; without one, newest first across threads
|
|
36
|
+
* through the recency index, and on the scan path in the table's own order —
|
|
37
|
+
* oldest first within a thread, as DynamoDB stores an item collection, and
|
|
38
|
+
* threads in no particular order. The read stops right after the yield that
|
|
39
|
+
* reaches `limit`, and abandoning the generator stops it too.
|
|
40
|
+
*
|
|
41
|
+
* Throws: `VALIDATION`, from the first `.next()` and before any read, for
|
|
42
|
+
* a config of the wrong shape (`config`, `configurable`, `signal`), a
|
|
43
|
+
* malformed identifier, or options that fail the checks
|
|
44
|
+
* {@link parseListScope} makes;
|
|
45
|
+
* `FORMAT_UNSUPPORTED` for a row of ours written by a newer version; whatever
|
|
46
|
+
* the reads and decodes throw.
|
|
47
|
+
*
|
|
48
|
+
* Guarantees: eventually consistent — a listing tolerates the replica lag
|
|
49
|
+
* `getTuple` does not. The read is deliberately unbounded: this generator
|
|
50
|
+
* streams and never accumulates, `limit` returns early, and a raw-row cap would
|
|
51
|
+
* turn a caller asking for a handful of rare matches over a large thread into a
|
|
52
|
+
* hard error instead of the true (possibly empty) answer. Past the warning
|
|
53
|
+
* threshold an operator is told to narrow the filter or pass a limit.
|
|
54
|
+
*/
|
|
55
|
+
export declare function listCheckpoints(context: CheckpointerContext, config: RunnableConfig, options?: CheckpointListOptions): AsyncGenerator<CheckpointTuple>;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listCheckpoints = listCheckpoints;
|
|
4
|
+
const clock_js_1 = require("../../shared/clock.js");
|
|
5
|
+
const paginate_js_1 = require("../../shared/dynamodb/paginate.js");
|
|
6
|
+
const table_schema_js_1 = require("../../shared/dynamodb/table-schema.js");
|
|
7
|
+
const listing_js_1 = require("../internal/listing.js");
|
|
8
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
9
|
+
const read_js_1 = require("../internal/read.js");
|
|
10
|
+
async function tupleFor(context, meta, scope) {
|
|
11
|
+
if (!(0, listing_js_1.passesKeyFilters)(meta, scope))
|
|
12
|
+
return undefined;
|
|
13
|
+
const verdict = await (0, listing_js_1.passesMetadataFilter)(context, meta, scope);
|
|
14
|
+
if (!verdict.pass)
|
|
15
|
+
return undefined;
|
|
16
|
+
return (0, read_js_1.assembleTuple)(context, { threadId: meta.threadId, checkpointNs: meta.checkpointNs }, meta, {
|
|
17
|
+
signal: scope.signal,
|
|
18
|
+
consistent: false,
|
|
19
|
+
metadata: verdict.metadata,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function* listOne(context, scope) {
|
|
23
|
+
const meta = await (0, read_js_1.fetchTargetMeta)(context, {
|
|
24
|
+
threadId: scope.threadId,
|
|
25
|
+
checkpointNs: scope.checkpointNs,
|
|
26
|
+
checkpointId: scope.checkpointId,
|
|
27
|
+
}, scope.signal, 'list');
|
|
28
|
+
if (!meta)
|
|
29
|
+
return;
|
|
30
|
+
const tuple = await tupleFor(context, meta, scope);
|
|
31
|
+
if (tuple)
|
|
32
|
+
yield tuple;
|
|
33
|
+
}
|
|
34
|
+
function asksForNothing(scope) {
|
|
35
|
+
return scope.limit === 0;
|
|
36
|
+
}
|
|
37
|
+
function addressesOneRow(scope) {
|
|
38
|
+
return (scope.threadId !== undefined &&
|
|
39
|
+
scope.checkpointId !== undefined &&
|
|
40
|
+
scope.checkpointNs !== undefined);
|
|
41
|
+
}
|
|
42
|
+
async function* listCheckpoints(context, config, options) {
|
|
43
|
+
const scope = (0, parse_js_1.parseListScope)(config, options);
|
|
44
|
+
if (asksForNothing(scope))
|
|
45
|
+
return;
|
|
46
|
+
if (addressesOneRow(scope)) {
|
|
47
|
+
yield* listOne(context, scope);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const now = (0, clock_js_1.nowSeconds)();
|
|
51
|
+
let yielded = 0;
|
|
52
|
+
let scanned = 0;
|
|
53
|
+
for await (const raw of (0, listing_js_1.metaRows)(context, scope, now)) {
|
|
54
|
+
scanned += 1;
|
|
55
|
+
if (scanned === paginate_js_1.LIST_SCAN_WARN_THRESHOLD) {
|
|
56
|
+
context.logger.warn('list: scanned a large number of rows without the caller stopping; this read is ' +
|
|
57
|
+
'deliberately unbounded, so narrow the filter or pass options.limit', { threadId: scope.threadId, checkpointNs: scope.checkpointNs, scanned });
|
|
58
|
+
}
|
|
59
|
+
const meta = (0, listing_js_1.parseListedRow)(context, raw);
|
|
60
|
+
if (!meta || (0, table_schema_js_1.isExpiredRow)(meta, now))
|
|
61
|
+
continue;
|
|
62
|
+
const tuple = await tupleFor(context, meta, scope);
|
|
63
|
+
if (!tuple)
|
|
64
|
+
continue;
|
|
65
|
+
yield tuple;
|
|
66
|
+
yielded += 1;
|
|
67
|
+
if (scope.limit !== undefined && yielded >= scope.limit)
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how one `putWrites` call's rows are known to be one call's.
|
|
3
|
+
*
|
|
4
|
+
* Every call draws a write group from a strictly monotonic ULID factory, and
|
|
5
|
+
* that one id serves three ends: the object id each offloaded write is uploaded
|
|
6
|
+
* under (record 4), the owner a guard rejection is compared against to tell a
|
|
7
|
+
* rival call from this call's own retry, and the order the read side uses to
|
|
8
|
+
* pick the earliest call that wrote a channel. A caller passes writes and a
|
|
9
|
+
* task id and never sees the group.
|
|
10
|
+
*/
|
|
11
|
+
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
12
|
+
import type { PendingWrite } from '@langchain/langgraph-checkpoint';
|
|
13
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
14
|
+
/**
|
|
15
|
+
* Persist a task's intermediate writes for a checkpoint, one row per write.
|
|
16
|
+
*
|
|
17
|
+
* Accepts: `config` — must name a `checkpoint_id`, since writes always attach
|
|
18
|
+
* to a checkpoint. `writes` — one task's, in order; their channels are
|
|
19
|
+
* validated before anything is encoded or uploaded. `taskId` — validated as the
|
|
20
|
+
* sort-key segment it becomes. `taskPath` — the task's serialized path, which
|
|
21
|
+
* LangGraph 1.5 passes and earlier LangGraphs do not; stored beside every row
|
|
22
|
+
* of the call, to lead the order the writes are read back in. `config.signal`
|
|
23
|
+
* — cancels the writes' retries; checked before anything is encoded.
|
|
24
|
+
*
|
|
25
|
+
* Returns: nothing. Every write is attempted; a regular write that loses its
|
|
26
|
+
* first-write-wins race is a normal outcome, not a failure.
|
|
27
|
+
*
|
|
28
|
+
* Throws: `VALIDATION` naming `config`, `configurable` or `signal` for a
|
|
29
|
+
* config of the wrong shape; `thread_id`, `checkpoint_ns`, `checkpoint_id` or
|
|
30
|
+
* `thread_ts` for a malformed identifier, and `checkpoint_id` when the config
|
|
31
|
+
* names none; `taskId`, `taskPath`, `writes`, `channel`, `sortKey` — every one
|
|
32
|
+
* of them before anything is encoded or uploaded — `payload` or `s3Key`; the first
|
|
33
|
+
* genuine write failure, after every write has settled and the cleanup has
|
|
34
|
+
* run.
|
|
35
|
+
*
|
|
36
|
+
* Guarantees: regular writes are first-write-wins, matching the reference
|
|
37
|
+
* checkpointer; special negative-index writes always overwrite (see
|
|
38
|
+
* {@link commitPendingWrites}). Cleanup of this call's own uploads only ever
|
|
39
|
+
* targets uploads confirmed unreferenced: a verified non-commit, or a guard
|
|
40
|
+
* rejection whose returned row provably belongs to another call. A special write's superseded
|
|
41
|
+
* payload is released only once the write that superseded it committed. An
|
|
42
|
+
* upload can leak. A payload refused partway through the encode releases the
|
|
43
|
+
* objects the earlier writes of the same call had already uploaded, before the
|
|
44
|
+
* refusal reaches the caller and while no row of the call exists. Every
|
|
45
|
+
* offloaded write of this call is uploaded under the call's own `writeGroup`,
|
|
46
|
+
* so no row another call writes names one of this call's uploads, and no
|
|
47
|
+
* release reads the row again first.
|
|
48
|
+
*/
|
|
49
|
+
export declare function putWrites(context: CheckpointerContext, config: RunnableConfig, writes: PendingWrite[], taskId: string, taskPath?: string): Promise<void>;
|