@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.2 → 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 +390 -193
- package/dist/{backfill → cjs/backfill}/backfill.d.ts +15 -12
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/delete-thread.d.ts +1 -1
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/get-tuple.d.ts +4 -3
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/list.d.ts +7 -4
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put-writes.d.ts +8 -6
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put.d.ts +21 -15
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/delta-history.d.ts +38 -26
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/listing.d.ts +4 -4
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/parse.d.ts +51 -15
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/pending-writes.d.ts +64 -25
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/read.d.ts +15 -10
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/rows.d.ts +94 -21
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/setup.d.ts +13 -20
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/{checkpointer → cjs/checkpointer}/saver.d.ts +72 -36
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/{checkpointer → cjs/checkpointer}/types.d.ts +1 -1
- package/dist/cjs/checkpointer/types.js +2 -0
- package/dist/{factory → cjs/factory}/factory.d.ts +25 -20
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +12 -12
- package/dist/cjs/factory/types.js +2 -0
- package/dist/{history → cjs/history}/actions/add-messages.d.ts +18 -10
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/{history → cjs/history}/actions/clear.d.ts +1 -1
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/{history → cjs/history}/actions/get-messages.d.ts +11 -9
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/{history → cjs/history}/actions/list-sessions.d.ts +3 -3
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/{history → cjs/history}/actions/reconcile-count.d.ts +13 -9
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/{history → cjs/history}/chat-message-history.d.ts +62 -30
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/{history → cjs/history}/internal/append.d.ts +64 -32
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/{history → cjs/history}/internal/message-read.d.ts +3 -3
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/{history → cjs/history}/internal/parse.d.ts +2 -2
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/{history → cjs/history}/internal/rows.d.ts +11 -10
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/{history → cjs/history}/internal/session.d.ts +41 -22
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/{history → cjs/history}/internal/setup.d.ts +2 -2
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/{history → cjs/history}/session-adapter.d.ts +0 -6
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/{history → cjs/history}/types.d.ts +18 -15
- package/dist/cjs/history/types.js +2 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +27 -27
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{shared → cjs/shared}/adapter.d.ts +27 -16
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/{shared → cjs/shared}/codec/codec.d.ts +37 -20
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/{shared → cjs/shared}/codec/compression.d.ts +9 -4
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +2 -1
- package/dist/cjs/shared/codec/s3/client-types.js +6 -0
- package/dist/{shared → cjs/shared}/codec/s3/client.d.ts +25 -7
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/{shared → cjs/shared}/codec/s3/config.d.ts +12 -7
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/{shared → cjs/shared}/codec/s3/lifecycle.d.ts +71 -17
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/{shared → cjs/shared}/codec/s3/offloader.d.ts +42 -29
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.js +31 -0
- package/dist/{shared → cjs/shared}/dynamodb/abort.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/{shared → cjs/shared}/dynamodb/batch-write.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.d.ts +24 -22
- package/dist/cjs/shared/dynamodb/client.js +40 -0
- package/dist/{shared → cjs/shared}/dynamodb/idempotent-write.d.ts +64 -19
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/{shared → cjs/shared}/dynamodb/paginate.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/{shared → cjs/shared}/dynamodb/partition-delete.d.ts +6 -6
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/recency-index.d.ts +27 -15
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/{shared → cjs/shared}/dynamodb/retry.d.ts +37 -6
- 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/{shared → cjs/shared}/dynamodb/table-schema.d.ts +27 -18
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/{shared → cjs/shared}/errors/base-error.d.ts +42 -7
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/{shared → cjs/shared}/errors/boundary.d.ts +29 -14
- 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/{shared → cjs/shared}/errors/error-code.d.ts +17 -10
- package/dist/cjs/shared/errors/error-code.js +27 -0
- package/dist/{shared → cjs/shared}/errors/errors.d.ts +75 -9
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/{shared → cjs/shared}/logging/redaction.d.ts +8 -4
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/{shared → cjs/shared}/logging/secret-patterns.d.ts +30 -7
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/{shared → cjs/shared}/options.d.ts +27 -11
- package/dist/cjs/shared/options.js +2 -0
- package/dist/cjs/shared/ulid.js +83 -0
- package/dist/{shared → cjs/shared}/validation/collaborators.d.ts +21 -2
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/{shared → cjs/shared}/validation/option-shape.d.ts +7 -5
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/{shared → cjs/shared}/validation/options.d.ts +4 -4
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/{shared → cjs/shared}/validation/ttl.d.ts +26 -9
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/{store → cjs/store}/actions/list-namespaces.d.ts +5 -5
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/{store → cjs/store}/actions/put.d.ts +11 -4
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/{store → cjs/store}/actions/reconcile-vector-index.d.ts +5 -5
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/{store → cjs/store}/actions/search.d.ts +2 -2
- 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/{store → cjs/store}/internal/filter.d.ts +3 -3
- 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/{store → cjs/store}/internal/item-write.d.ts +72 -32
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/{store → cjs/store}/internal/parse.d.ts +15 -10
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/{store → cjs/store}/internal/rows.d.ts +38 -34
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/{store → cjs/store}/internal/semantic-search.d.ts +2 -2
- package/dist/cjs/store/internal/semantic-search.js +211 -0
- package/dist/{store → cjs/store}/internal/setup.d.ts +10 -15
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/{store → cjs/store}/internal/table-search.d.ts +5 -5
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/{store → cjs/store}/internal/vector-index.d.ts +26 -15
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/{store → cjs/store}/store.d.ts +82 -39
- package/dist/cjs/store/store.js +97 -0
- package/dist/{store → cjs/store}/types.d.ts +25 -10
- package/dist/cjs/store/types.js +2 -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/{checkpointer/actions/delete-thread.js → esm/checkpointer/actions/delete-thread.d.ts} +4 -26
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/{checkpointer/actions/get-tuple.js → esm/checkpointer/actions/get-tuple.d.ts} +7 -24
- 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/{checkpointer/actions/put-writes.js → esm/checkpointer/actions/put-writes.d.ts} +10 -37
- 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/{checkpointer/internal/listing.js → esm/checkpointer/internal/listing.d.ts} +22 -118
- 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/{checkpointer/saver.js → esm/checkpointer/saver.d.ts} +84 -87
- 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/{history/actions/add-messages.js → esm/history/actions/add-messages.d.ts} +20 -26
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/{history/actions/clear.js → esm/history/actions/clear.d.ts} +4 -35
- 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/{history/actions/reconcile-count.js → esm/history/actions/reconcile-count.d.ts} +14 -16
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/{history/chat-message-history.js → esm/history/chat-message-history.d.ts} +76 -87
- 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/{history/internal/rows.js → esm/history/internal/rows.d.ts} +58 -112
- 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/{history/session-adapter.js → esm/history/session-adapter.d.ts} +25 -39
- 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/{shared/clock.js → esm/shared/clock.d.ts} +3 -14
- 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/{shared/codec/s3/config.js → esm/shared/codec/s3/config.d.ts} +45 -93
- 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/{shared/concurrency.js → esm/shared/concurrency.d.ts} +2 -37
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/{shared/dynamodb/abort.js → esm/shared/dynamodb/abort.d.ts} +4 -16
- 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/{shared/dynamodb/cancellation.js → esm/shared/dynamodb/cancellation.d.ts} +25 -53
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/{shared/dynamodb/client.js → esm/shared/dynamodb/client.d.ts} +74 -64
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/{shared/dynamodb/idempotent-write.js → esm/shared/dynamodb/idempotent-write.d.ts} +172 -169
- 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/{shared/dynamodb/table-schema.js → esm/shared/dynamodb/table-schema.d.ts} +57 -67
- 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/{shared/errors/error-code.js → esm/shared/errors/error-code.d.ts} +39 -43
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/{shared/errors/errors.js → esm/shared/errors/errors.d.ts} +92 -98
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/{shared/logging/logger.js → esm/shared/logging/logger.d.ts} +22 -52
- 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/{shared/logging/secret-patterns.js → esm/shared/logging/secret-patterns.d.ts} +46 -87
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/{shared/logging/truncate.js → esm/shared/logging/truncate.d.ts} +6 -40
- 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/{shared/ulid.js → esm/shared/ulid.d.ts} +4 -84
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/{shared/validation/collaborators.js → esm/shared/validation/collaborators.d.ts} +37 -65
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/{shared/validation/option-shape.js → esm/shared/validation/option-shape.d.ts} +14 -36
- 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/{shared/validation/primitives.js → esm/shared/validation/primitives.d.ts} +30 -125
- 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/{store/actions/reconcile-vector-index.js → esm/store/actions/reconcile-vector-index.d.ts} +8 -16
- 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/{store/internal/rows.js → esm/store/internal/rows.d.ts} +111 -199
- 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/{store/store.js → esm/store/store.d.ts} +99 -133
- 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 +50 -44
- package/dist/backfill/backfill.js +0 -393
- package/dist/checkpointer/actions/list.js +0 -142
- package/dist/checkpointer/actions/put.js +0 -195
- package/dist/checkpointer/internal/delta-history.js +0 -252
- package/dist/checkpointer/internal/parse.js +0 -372
- package/dist/checkpointer/internal/pending-writes.js +0 -588
- package/dist/checkpointer/internal/read.js +0 -264
- package/dist/checkpointer/internal/rows.js +0 -834
- package/dist/checkpointer/internal/setup.js +0 -72
- package/dist/checkpointer/types.js +0 -12
- package/dist/factory/factory.js +0 -266
- package/dist/factory/types.js +0 -10
- package/dist/history/actions/get-messages.js +0 -141
- package/dist/history/actions/list-sessions.js +0 -156
- package/dist/history/internal/append.js +0 -500
- package/dist/history/internal/message-read.js +0 -204
- package/dist/history/internal/parse.js +0 -252
- package/dist/history/internal/session.js +0 -628
- package/dist/history/internal/setup.js +0 -106
- package/dist/history/types.js +0 -12
- package/dist/index.js +0 -51
- package/dist/shared/adapter.js +0 -143
- package/dist/shared/codec/codec.js +0 -441
- package/dist/shared/codec/compression.js +0 -89
- package/dist/shared/codec/json-serde.js +0 -191
- package/dist/shared/codec/s3/client-types.js +0 -26
- package/dist/shared/codec/s3/client.js +0 -97
- package/dist/shared/codec/s3/lifecycle.js +0 -355
- package/dist/shared/codec/s3/offloader.js +0 -658
- package/dist/shared/dynamodb/batch-write.js +0 -173
- package/dist/shared/dynamodb/paginate.js +0 -188
- package/dist/shared/dynamodb/partition-delete.js +0 -340
- package/dist/shared/dynamodb/recency-index.js +0 -377
- package/dist/shared/dynamodb/retry.js +0 -463
- package/dist/shared/errors/base-error.js +0 -174
- package/dist/shared/errors/boundary.js +0 -143
- package/dist/shared/errors/classify.d.ts +0 -97
- package/dist/shared/errors/classify.js +0 -257
- package/dist/shared/logging/redaction.js +0 -316
- package/dist/shared/options.js +0 -11
- package/dist/shared/validation/options.js +0 -328
- package/dist/shared/validation/ttl.js +0 -132
- package/dist/store/actions/list-namespaces.js +0 -197
- package/dist/store/actions/put.js +0 -78
- package/dist/store/actions/search.js +0 -66
- package/dist/store/internal/batch-plan.d.ts +0 -26
- package/dist/store/internal/batch-plan.js +0 -109
- package/dist/store/internal/filter.js +0 -137
- package/dist/store/internal/get-item.d.ts +0 -45
- package/dist/store/internal/get-item.js +0 -115
- package/dist/store/internal/item-write.js +0 -463
- package/dist/store/internal/parse.js +0 -350
- package/dist/store/internal/semantic-search.js +0 -389
- package/dist/store/internal/setup.js +0 -223
- package/dist/store/internal/table-search.js +0 -213
- package/dist/store/internal/vector-index.js +0 -546
- package/dist/store/types.js +0 -15
- package/dist/store/vector-backend.js +0 -17
- /package/dist/{shared → cjs/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/codec/json-serde.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/concurrency.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/dynamodb/cancellation.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/logger.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/truncate.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/ulid.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/validation/primitives.d.ts +0 -0
- /package/dist/{store → cjs/store}/vector-backend.d.ts +0 -0
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { WRITES_IDX_MAP } from '@langchain/langgraph-checkpoint';
|
|
2
|
+
import { nowIso } from '../../shared/clock.js';
|
|
3
|
+
import { codecDepsOf, collectS3Keys, decodePayload, encodePayload, } from '../../shared/codec/codec.js';
|
|
4
|
+
import { cleanUpS3Orphans } from '../../shared/codec/s3/offloader.js';
|
|
5
|
+
import { DEFAULT_READ_CONCURRENCY, mapWithConcurrency } from '../../shared/concurrency.js';
|
|
6
|
+
import { namedDescriptor } from '../../shared/dynamodb/partition-delete.js';
|
|
7
|
+
import { BACKFILLED_AT, DEFAULT_INDEX_SHARDS, indexKeys, } from '../../shared/dynamodb/recency-index.js';
|
|
8
|
+
import { ADAPTER_TAGS, assertReadableRow, KEY_SEPARATOR, PARTITION_KEY_ATTRIBUTE, ROW_FORMAT_VERSION, SORT_KEY_ATTRIBUTE, } from '../../shared/dynamodb/table-schema.js';
|
|
9
|
+
import { validationError } from '../../shared/errors/errors.js';
|
|
10
|
+
import { truncateForLog } from '../../shared/logging/truncate.js';
|
|
11
|
+
import { createUlidFactory } from '../../shared/ulid.js';
|
|
12
|
+
export const WRITE_GROUP_ATTRIBUTE = 'writeGroup';
|
|
13
|
+
const WRITE_INDEX_PAD_WIDTH = 10;
|
|
14
|
+
const WRITE_INDEX_OFFSET = 8;
|
|
15
|
+
export const MIN_ENCODABLE_WRITE_INDEX = -WRITE_INDEX_OFFSET;
|
|
16
|
+
var CheckpointRowKind;
|
|
17
|
+
(function (CheckpointRowKind) {
|
|
18
|
+
CheckpointRowKind["META"] = "META";
|
|
19
|
+
CheckpointRowKind["PAYLOAD"] = "PAYLOAD";
|
|
20
|
+
CheckpointRowKind["WRITE"] = "WRITE";
|
|
21
|
+
})(CheckpointRowKind || (CheckpointRowKind = {}));
|
|
22
|
+
const ADAPTER_PARTITION_PREFIX = `${ADAPTER_TAGS.checkpointer}${KEY_SEPARATOR}`;
|
|
23
|
+
export function checkpointerPartitionPrefix() {
|
|
24
|
+
return ADAPTER_PARTITION_PREFIX;
|
|
25
|
+
}
|
|
26
|
+
export function partitionKey(threadId) {
|
|
27
|
+
return `${ADAPTER_PARTITION_PREFIX}${threadId}`;
|
|
28
|
+
}
|
|
29
|
+
export function metaSortKey(checkpointNs, checkpointId) {
|
|
30
|
+
return `${CheckpointRowKind.META}${KEY_SEPARATOR}${checkpointNs}${KEY_SEPARATOR}${checkpointId}`;
|
|
31
|
+
}
|
|
32
|
+
export function metaSortKeyPrefix(checkpointNs) {
|
|
33
|
+
return `${CheckpointRowKind.META}${KEY_SEPARATOR}${checkpointNs}${KEY_SEPARATOR}`;
|
|
34
|
+
}
|
|
35
|
+
export function metaAnyNamespacePrefix() {
|
|
36
|
+
return `${CheckpointRowKind.META}${KEY_SEPARATOR}`;
|
|
37
|
+
}
|
|
38
|
+
export function payloadSortKey(checkpointNs, checkpointId) {
|
|
39
|
+
return `${CheckpointRowKind.PAYLOAD}${KEY_SEPARATOR}${checkpointNs}${KEY_SEPARATOR}${checkpointId}`;
|
|
40
|
+
}
|
|
41
|
+
export function writeSortKey(at) {
|
|
42
|
+
const offsetIndex = at.index + WRITE_INDEX_OFFSET;
|
|
43
|
+
if (!Number.isInteger(offsetIndex) ||
|
|
44
|
+
offsetIndex < 0 ||
|
|
45
|
+
offsetIndex.toString().length > WRITE_INDEX_PAD_WIDTH) {
|
|
46
|
+
throw validationError(`write index ${at.index} is not an integer encodable at offset ${WRITE_INDEX_OFFSET} ` +
|
|
47
|
+
`with ${WRITE_INDEX_PAD_WIDTH} digits`, 'index');
|
|
48
|
+
}
|
|
49
|
+
const paddedIndex = offsetIndex.toString().padStart(WRITE_INDEX_PAD_WIDTH, '0');
|
|
50
|
+
return [
|
|
51
|
+
CheckpointRowKind.WRITE,
|
|
52
|
+
at.checkpointNs,
|
|
53
|
+
at.checkpointId,
|
|
54
|
+
at.taskId,
|
|
55
|
+
paddedIndex,
|
|
56
|
+
at.channel,
|
|
57
|
+
].join(KEY_SEPARATOR);
|
|
58
|
+
}
|
|
59
|
+
export function writeSortKeyBytes(at) {
|
|
60
|
+
return Buffer.byteLength(writeSortKey({ ...at, index: 0 }), 'utf8');
|
|
61
|
+
}
|
|
62
|
+
export function isCheckpointerSortKey(sortKey) {
|
|
63
|
+
return Object.values(CheckpointRowKind).some((kind) => sortKey.startsWith(`${kind}${KEY_SEPARATOR}`));
|
|
64
|
+
}
|
|
65
|
+
export function writeSortKeyPrefix(checkpointNs, checkpointId) {
|
|
66
|
+
return `${CheckpointRowKind.WRITE}${KEY_SEPARATOR}${checkpointNs}${KEY_SEPARATOR}${checkpointId}${KEY_SEPARATOR}`;
|
|
67
|
+
}
|
|
68
|
+
export function metaRowKey(at) {
|
|
69
|
+
return { PK: partitionKey(at.threadId), SK: metaSortKey(at.checkpointNs, at.checkpointId) };
|
|
70
|
+
}
|
|
71
|
+
export function payloadRowKey(at) {
|
|
72
|
+
return { PK: partitionKey(at.threadId), SK: payloadSortKey(at.checkpointNs, at.checkpointId) };
|
|
73
|
+
}
|
|
74
|
+
export function partitionQuery(tableName, partition, options = {}) {
|
|
75
|
+
const params = {
|
|
76
|
+
TableName: tableName,
|
|
77
|
+
KeyConditionExpression: '#pk = :pk',
|
|
78
|
+
ExpressionAttributeNames: { '#pk': PARTITION_KEY_ATTRIBUTE },
|
|
79
|
+
ExpressionAttributeValues: { ':pk': partition },
|
|
80
|
+
};
|
|
81
|
+
if (options.consistent)
|
|
82
|
+
params.ConsistentRead = true;
|
|
83
|
+
return params;
|
|
84
|
+
}
|
|
85
|
+
export function beginsWithQuery(tableName, partition, skPrefix, options = {}) {
|
|
86
|
+
const bounded = options.beforeSortKey !== undefined;
|
|
87
|
+
const params = {
|
|
88
|
+
TableName: tableName,
|
|
89
|
+
KeyConditionExpression: bounded
|
|
90
|
+
? '#pk = :pk AND #sk BETWEEN :skPrefix AND :before'
|
|
91
|
+
: '#pk = :pk AND begins_with(#sk, :skPrefix)',
|
|
92
|
+
ExpressionAttributeNames: { '#pk': PARTITION_KEY_ATTRIBUTE, '#sk': SORT_KEY_ATTRIBUTE },
|
|
93
|
+
ExpressionAttributeValues: {
|
|
94
|
+
':pk': partition,
|
|
95
|
+
':skPrefix': skPrefix,
|
|
96
|
+
...(bounded ? { ':before': options.beforeSortKey } : {}),
|
|
97
|
+
},
|
|
98
|
+
ScanIndexForward: options.ascending ?? false,
|
|
99
|
+
};
|
|
100
|
+
if (options.limit !== undefined && options.limit >= 1)
|
|
101
|
+
params.Limit = options.limit;
|
|
102
|
+
if (options.consistent)
|
|
103
|
+
params.ConsistentRead = true;
|
|
104
|
+
return params;
|
|
105
|
+
}
|
|
106
|
+
function withTtl(item, ttlTimestamp) {
|
|
107
|
+
if (ttlTimestamp !== undefined)
|
|
108
|
+
item.ttl = ttlTimestamp;
|
|
109
|
+
return item;
|
|
110
|
+
}
|
|
111
|
+
async function releaseUploads(context, uploaded, operation) {
|
|
112
|
+
if (!context.offloader)
|
|
113
|
+
return;
|
|
114
|
+
await cleanUpS3Orphans(context.offloader, {
|
|
115
|
+
keys: collectS3Keys(uploaded),
|
|
116
|
+
operation,
|
|
117
|
+
logger: context.logger,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
const nextPutObjectId = createUlidFactory();
|
|
121
|
+
export async function buildCheckpointRows(context, request, ttlTimestamp) {
|
|
122
|
+
const { threadId, checkpointNs, checkpointId } = request.address;
|
|
123
|
+
const deps = codecDepsOf(context, request.signal);
|
|
124
|
+
const pk = partitionKey(threadId);
|
|
125
|
+
const objectId = nextPutObjectId();
|
|
126
|
+
const checkpointDescriptor = await encodePayload(request.checkpoint, deps, {
|
|
127
|
+
keyParts: [threadId, checkpointNs, checkpointId, 'checkpoint'],
|
|
128
|
+
objectId,
|
|
129
|
+
row: { pk, sk: payloadSortKey(checkpointNs, checkpointId) },
|
|
130
|
+
});
|
|
131
|
+
let metadataDescriptor;
|
|
132
|
+
try {
|
|
133
|
+
metadataDescriptor = await encodePayload(request.metadata, deps, {
|
|
134
|
+
keyParts: [threadId, checkpointNs, checkpointId, 'metadata'],
|
|
135
|
+
objectId,
|
|
136
|
+
row: { pk, sk: metaSortKey(checkpointNs, checkpointId) },
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
await releaseUploads(context, [checkpointDescriptor], 'put.encode');
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
const index = indexKeys('CHKPT', checkpointId, nowIso(), context.indexShards ?? DEFAULT_INDEX_SHARDS);
|
|
144
|
+
const meta = {
|
|
145
|
+
PK: pk,
|
|
146
|
+
SK: metaSortKey(checkpointNs, checkpointId),
|
|
147
|
+
v: ROW_FORMAT_VERSION,
|
|
148
|
+
...index,
|
|
149
|
+
threadId,
|
|
150
|
+
checkpointNs,
|
|
151
|
+
checkpointId,
|
|
152
|
+
metadata: metadataDescriptor,
|
|
153
|
+
};
|
|
154
|
+
if (request.parentCheckpointId !== undefined)
|
|
155
|
+
meta.parentCheckpointId = request.parentCheckpointId;
|
|
156
|
+
const payload = {
|
|
157
|
+
PK: pk,
|
|
158
|
+
SK: payloadSortKey(checkpointNs, checkpointId),
|
|
159
|
+
v: ROW_FORMAT_VERSION,
|
|
160
|
+
checkpoint: checkpointDescriptor,
|
|
161
|
+
};
|
|
162
|
+
return { meta: withTtl(meta, ttlTimestamp), payload: withTtl(payload, ttlTimestamp) };
|
|
163
|
+
}
|
|
164
|
+
export async function buildWriteRows(context, request, writeGroup, ttlTimestamp) {
|
|
165
|
+
const { threadId, checkpointNs, checkpointId } = request.address;
|
|
166
|
+
const { taskId, taskPath } = request;
|
|
167
|
+
const deps = codecDepsOf(context, request.signal);
|
|
168
|
+
const pk = partitionKey(threadId);
|
|
169
|
+
const items = [];
|
|
170
|
+
try {
|
|
171
|
+
for (const { channel, value, index, occurrence } of resolveWriteIndices(request.writes)) {
|
|
172
|
+
const sk = writeSortKey({ checkpointNs, checkpointId, taskId, index, channel });
|
|
173
|
+
const descriptor = await encodePayload(value, deps, {
|
|
174
|
+
keyParts: [threadId, checkpointNs, checkpointId, taskId, `write-${index}`, channel],
|
|
175
|
+
objectId: writeGroup,
|
|
176
|
+
row: { pk, sk },
|
|
177
|
+
});
|
|
178
|
+
const item = {
|
|
179
|
+
PK: pk,
|
|
180
|
+
SK: sk,
|
|
181
|
+
v: ROW_FORMAT_VERSION,
|
|
182
|
+
taskId,
|
|
183
|
+
index,
|
|
184
|
+
channel,
|
|
185
|
+
...(taskPath === undefined ? {} : { taskPath }),
|
|
186
|
+
writeGroup,
|
|
187
|
+
occurrence,
|
|
188
|
+
value: descriptor,
|
|
189
|
+
};
|
|
190
|
+
items.push(withTtl(item, ttlTimestamp));
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
await releaseUploads(context, items.map((item) => item.value), 'putWrites.encode');
|
|
195
|
+
throw error;
|
|
196
|
+
}
|
|
197
|
+
return items;
|
|
198
|
+
}
|
|
199
|
+
export function parseMetaRow(raw) {
|
|
200
|
+
assertReadableRow(raw, 'checkpoint');
|
|
201
|
+
const isCheckpoint = typeof raw.threadId === 'string' &&
|
|
202
|
+
typeof raw.checkpointId === 'string' &&
|
|
203
|
+
typeof raw.checkpointNs === 'string' &&
|
|
204
|
+
typeof raw.metadata === 'object' &&
|
|
205
|
+
raw.metadata !== null;
|
|
206
|
+
if (!isCheckpoint)
|
|
207
|
+
return undefined;
|
|
208
|
+
const item = raw;
|
|
209
|
+
const consistent = item.PK === partitionKey(item.threadId) &&
|
|
210
|
+
item.SK === metaSortKey(item.checkpointNs, item.checkpointId);
|
|
211
|
+
return consistent ? item : undefined;
|
|
212
|
+
}
|
|
213
|
+
export function parseWriteRow(raw) {
|
|
214
|
+
assertReadableRow(raw, 'pending write');
|
|
215
|
+
const isWrite = typeof raw.taskId === 'string' &&
|
|
216
|
+
typeof raw.channel === 'string' &&
|
|
217
|
+
(raw.taskPath === undefined || typeof raw.taskPath === 'string') &&
|
|
218
|
+
typeof raw.value === 'object' &&
|
|
219
|
+
raw.value !== null;
|
|
220
|
+
return isWrite ? raw : undefined;
|
|
221
|
+
}
|
|
222
|
+
export function parseHeadRow(context, raw, reader) {
|
|
223
|
+
if (raw === undefined)
|
|
224
|
+
return undefined;
|
|
225
|
+
const meta = parseMetaRow(raw);
|
|
226
|
+
if (!meta) {
|
|
227
|
+
context.logger.warn(`${reader}: skipped a row that is not a checkpoint meta item`, {
|
|
228
|
+
sortKey: truncateForLog(raw.SK),
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return meta;
|
|
232
|
+
}
|
|
233
|
+
export async function readCheckpoint(context, item, threadId, signal) {
|
|
234
|
+
return decodePayload(item.checkpoint, codecDepsOf(context, signal), [threadId]);
|
|
235
|
+
}
|
|
236
|
+
export async function readMetadata(context, item, threadId, signal) {
|
|
237
|
+
return decodePayload(item.metadata, codecDepsOf(context, signal), [threadId]);
|
|
238
|
+
}
|
|
239
|
+
export function compareByCodePoint(a, b) {
|
|
240
|
+
let i = 0;
|
|
241
|
+
let j = 0;
|
|
242
|
+
while (i < a.length && j < b.length) {
|
|
243
|
+
const left = a.codePointAt(i);
|
|
244
|
+
const right = b.codePointAt(j);
|
|
245
|
+
if (left !== right)
|
|
246
|
+
return left < right ? -1 : 1;
|
|
247
|
+
i += left > 0xffff ? 2 : 1;
|
|
248
|
+
j += right > 0xffff ? 2 : 1;
|
|
249
|
+
}
|
|
250
|
+
if (i >= a.length && j >= b.length)
|
|
251
|
+
return 0;
|
|
252
|
+
return i >= a.length ? -1 : 1;
|
|
253
|
+
}
|
|
254
|
+
export function compareWriteOrder(a, b) {
|
|
255
|
+
return (compareByCodePoint(a.taskPath ?? '', b.taskPath ?? '') ||
|
|
256
|
+
compareByCodePoint(a.taskId, b.taskId) ||
|
|
257
|
+
a.index - b.index ||
|
|
258
|
+
compareByCodePoint(a.channel, b.channel));
|
|
259
|
+
}
|
|
260
|
+
export async function toPendingWrites(context, items, threadId, signal) {
|
|
261
|
+
const deps = codecDepsOf(context, signal);
|
|
262
|
+
const live = [...dropSupersededWrites(items)].sort(compareWriteOrder);
|
|
263
|
+
const values = await mapWithConcurrency(live, context.readConcurrency ?? DEFAULT_READ_CONCURRENCY, (item) => decodePayload(item.value, deps, [threadId]));
|
|
264
|
+
return live.map((item, index) => [
|
|
265
|
+
item.taskId,
|
|
266
|
+
item.channel,
|
|
267
|
+
values[index],
|
|
268
|
+
]);
|
|
269
|
+
}
|
|
270
|
+
export function resolveWriteIndices(writes) {
|
|
271
|
+
const bySpecialIndex = new Map();
|
|
272
|
+
const regular = [];
|
|
273
|
+
const occurrences = new Map();
|
|
274
|
+
writes.forEach(([channel, value], positional) => {
|
|
275
|
+
if (Object.hasOwn(WRITES_IDX_MAP, channel)) {
|
|
276
|
+
const index = WRITES_IDX_MAP[channel];
|
|
277
|
+
bySpecialIndex.set(index, { channel, value, index, occurrence: 0 });
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
const occurrence = occurrences.get(channel) ?? 0;
|
|
281
|
+
occurrences.set(channel, occurrence + 1);
|
|
282
|
+
regular.push({ channel, value, index: positional, occurrence });
|
|
283
|
+
});
|
|
284
|
+
return [...bySpecialIndex.values(), ...regular];
|
|
285
|
+
}
|
|
286
|
+
export function dropSupersededWrites(items) {
|
|
287
|
+
const identity = (item) => JSON.stringify([item.taskId, item.channel, item.occurrence ?? 0]);
|
|
288
|
+
const groupOf = (item) => item.writeGroup ?? '';
|
|
289
|
+
const earliestGroup = new Map();
|
|
290
|
+
for (const item of items) {
|
|
291
|
+
const id = identity(item);
|
|
292
|
+
const seen = earliestGroup.get(id);
|
|
293
|
+
const group = groupOf(item);
|
|
294
|
+
if (seen === undefined || group < seen)
|
|
295
|
+
earliestGroup.set(id, group);
|
|
296
|
+
}
|
|
297
|
+
return items.filter((item) => earliestGroup.get(identity(item)) === groupOf(item));
|
|
298
|
+
}
|
|
299
|
+
const PAYLOAD_ATTRIBUTES = ['metadata', 'checkpoint', 'value'];
|
|
300
|
+
export function checkpointRowDescriptors(row) {
|
|
301
|
+
const named = [];
|
|
302
|
+
for (const attribute of PAYLOAD_ATTRIBUTES) {
|
|
303
|
+
const entry = namedDescriptor(row, attribute);
|
|
304
|
+
if (entry !== undefined)
|
|
305
|
+
named.push(entry);
|
|
306
|
+
}
|
|
307
|
+
return named;
|
|
308
|
+
}
|
|
309
|
+
export function checkpointRowUnit(row) {
|
|
310
|
+
return row.SK.split(KEY_SEPARATOR).slice(1, 3).join(KEY_SEPARATOR);
|
|
311
|
+
}
|
|
312
|
+
export function checkpointRowKind(row) {
|
|
313
|
+
return row.SK.split(KEY_SEPARATOR)[0];
|
|
314
|
+
}
|
|
315
|
+
export function checkpointIndexTarget(row) {
|
|
316
|
+
const pk = typeof row.PK === 'string' ? row.PK : '';
|
|
317
|
+
const sk = typeof row.SK === 'string' ? row.SK : '';
|
|
318
|
+
if (!pk.startsWith(ADAPTER_PARTITION_PREFIX))
|
|
319
|
+
return undefined;
|
|
320
|
+
return sk.startsWith(metaAnyNamespacePrefix()) && typeof row.checkpointId === 'string'
|
|
321
|
+
? { tag: 'CHKPT', id: row.checkpointId, at: BACKFILLED_AT }
|
|
322
|
+
: undefined;
|
|
323
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which options the saver accepts, and how the saver is assembled from
|
|
3
|
+
* them.
|
|
4
|
+
*
|
|
5
|
+
* The exhaustive key list of the constructor's options lives here,
|
|
6
|
+
* compiler-checked against its type, beside the code that resolves those
|
|
7
|
+
* options into the context every action receives. `list`'s and
|
|
8
|
+
* `getDeltaChannelHistory`'s options have no list: LangGraph defines them, so
|
|
9
|
+
* a key it adds is ignored rather than refused (decision record 28).
|
|
10
|
+
*/
|
|
11
|
+
import type { SerializerProtocol } from '@langchain/langgraph-checkpoint';
|
|
12
|
+
import { type AdapterCore, type AdapterShell } from '../../shared/adapter.js';
|
|
13
|
+
import type { DynamoDBSaverOptions } from '../types.js';
|
|
14
|
+
/**
|
|
15
|
+
* The keys of the saver's constructor options, exhaustive in both directions:
|
|
16
|
+
* `allKeysOf<T>` makes omitting or inventing one a compile error, so the list
|
|
17
|
+
* cannot rot away from the type it guards. It lives with the feature because
|
|
18
|
+
* the type it is checked against does; `shared/` knows no feature.
|
|
19
|
+
*/
|
|
20
|
+
export declare const SAVER_KEYS: readonly string[];
|
|
21
|
+
/** Resolved collaborators shared by every checkpointer action. */
|
|
22
|
+
export interface CheckpointerContext extends AdapterCore {
|
|
23
|
+
serde: SerializerProtocol;
|
|
24
|
+
}
|
|
25
|
+
/** Result of wiring up a checkpointer from its options. */
|
|
26
|
+
export interface CheckpointerSetup {
|
|
27
|
+
context: CheckpointerContext;
|
|
28
|
+
shell: AdapterShell;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check the options, then resolve the client, offloader and serializer.
|
|
32
|
+
*
|
|
33
|
+
* Accepts: `options` — already held to the saver's key list by its constructor,
|
|
34
|
+
* which must read `serde` before anything else runs; checked here before
|
|
35
|
+
* anything is built, so no half-built saver exists when one is wrong. `serde` —
|
|
36
|
+
* the serializer the base class resolved, which is the caller's own serializer
|
|
37
|
+
* when they gave one.
|
|
38
|
+
*
|
|
39
|
+
* Returns: the context every action receives, and the shell that releases what
|
|
40
|
+
* it holds — a client the caller passed in is never destroyed by `destroy()`.
|
|
41
|
+
*
|
|
42
|
+
* Throws: `VALIDATION` for an option or collaborator that fails a check,
|
|
43
|
+
* naming the offending option.
|
|
44
|
+
*
|
|
45
|
+
* Guarantees: constructing a saver performs no I/O.
|
|
46
|
+
*/
|
|
47
|
+
export declare function setUpCheckpointer(options: DynamoDBSaverOptions, serde: SerializerProtocol): CheckpointerSetup;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { openAdapter } from '../../shared/adapter.js';
|
|
2
|
+
import { allKeysOf } from '../../shared/validation/option-shape.js';
|
|
3
|
+
export const SAVER_KEYS = allKeysOf({
|
|
4
|
+
tableName: 'tableName',
|
|
5
|
+
client: 'client',
|
|
6
|
+
clientConfig: 'clientConfig',
|
|
7
|
+
createClient: 'createClient',
|
|
8
|
+
ttl: 'ttl',
|
|
9
|
+
logger: 'logger',
|
|
10
|
+
retry: 'retry',
|
|
11
|
+
indexShards: 'indexShards',
|
|
12
|
+
indexName: 'indexName',
|
|
13
|
+
readConcurrency: 'readConcurrency',
|
|
14
|
+
compression: 'compression',
|
|
15
|
+
s3: 's3',
|
|
16
|
+
serde: 'serde',
|
|
17
|
+
});
|
|
18
|
+
export function setUpCheckpointer(options, serde) {
|
|
19
|
+
const shell = openAdapter(options, 'checkpointer');
|
|
20
|
+
return { shell, context: { ...shell.core, serde } };
|
|
21
|
+
}
|