@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
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
* each adapter's own answer, asked here, and a row that gained keys since the
|
|
8
8
|
* scan read it is left alone.
|
|
9
9
|
*/
|
|
10
|
-
import type { AttributeMap, DynamoDBDocumentLike } from '../shared/dynamodb/client';
|
|
11
|
-
import { type IndexTarget } from '../shared/dynamodb/recency-index';
|
|
12
|
-
import { type RetryOptions } from '../shared/dynamodb/retry';
|
|
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
13
|
/**
|
|
14
14
|
* Give rows written before the recency index their index keys.
|
|
15
15
|
*
|
|
16
16
|
* **Run this before setting `indexName` on any adapter.** A row without the
|
|
17
17
|
* keys is not in the index, so enabling the index first would make every
|
|
18
|
-
* pre-existing session
|
|
18
|
+
* pre-existing session and checkpoint silently vanish from the listings
|
|
19
19
|
* that read it — the rows are still there, and every other read still returns
|
|
20
20
|
* them, but a listing would not.
|
|
21
21
|
*
|
|
@@ -25,8 +25,9 @@ import { type RetryOptions } from '../shared/dynamodb/retry';
|
|
|
25
25
|
* after the scan found it stays deleted rather than being re-created by an
|
|
26
26
|
* `UpdateItem`, which upserts.
|
|
27
27
|
*
|
|
28
|
-
* `indexShards` must match what the
|
|
29
|
-
* shards no listing queries, which looks exactly like the rows
|
|
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.
|
|
30
31
|
*
|
|
31
32
|
* Accepts: `options` — validated in full before any read: only the keys
|
|
32
33
|
* `BackfillOptions` declares; `tableName`, `indexShards` and the numbers in
|
|
@@ -35,7 +36,7 @@ import { type RetryOptions } from '../shared/dynamodb/retry';
|
|
|
35
36
|
* default 100. `options.cursor` — from a previous run, to resume.
|
|
36
37
|
* `options.maxPages` — how far one run goes, so a large table can be
|
|
37
38
|
* backfilled in bounded slices. `options.indexShards` — must equal the
|
|
38
|
-
*
|
|
39
|
+
* saver's and the history's setting, and has their ceiling. `options.dryRun` — a boolean.
|
|
39
40
|
* `options.signal` — cancels the run; `retry.signal` does so when there is no
|
|
40
41
|
* top-level `signal`, and the top-level one wins when both are given.
|
|
41
42
|
*
|
|
@@ -64,13 +65,15 @@ import { type RetryOptions } from '../shared/dynamodb/retry';
|
|
|
64
65
|
*/
|
|
65
66
|
export declare function backfillRecencyIndex(options: BackfillOptions): Promise<BackfillResult>;
|
|
66
67
|
/**
|
|
67
|
-
* Which rows the index covers:
|
|
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.
|
|
68
70
|
*
|
|
69
71
|
* Accepts: `row` — any row a table scan returns, including a foreign one and
|
|
70
72
|
* one whose `PK`/`SK` are not strings.
|
|
71
73
|
*
|
|
72
74
|
* Returns: the index identity, or undefined for a row no listing reaches — a
|
|
73
|
-
* foreign row, a payload or write row, a META row carrying no `checkpointId
|
|
75
|
+
* foreign row, a payload or write row, a META row carrying no `checkpointId`,
|
|
76
|
+
* or a store row.
|
|
74
77
|
*
|
|
75
78
|
* Throws: nothing. A backfill walks the whole table; one unrecognised row must
|
|
76
79
|
* be skipped, not fatal.
|
|
@@ -107,7 +110,7 @@ export declare function encodeScanCursor(key: AttributeMap): string;
|
|
|
107
110
|
export declare function decodeScanCursor(cursor: string): AttributeMap;
|
|
108
111
|
/** What one pass of the backfill did, and where to resume. */
|
|
109
112
|
export interface BackfillResult {
|
|
110
|
-
/** Rows the scan evaluated. */
|
|
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. */
|
|
111
114
|
scanned: number;
|
|
112
115
|
/** Rows given index keys. */
|
|
113
116
|
indexed: number;
|
|
@@ -126,7 +129,7 @@ export interface BackfillResult {
|
|
|
126
129
|
export interface BackfillOptions {
|
|
127
130
|
client: DynamoDBDocumentLike;
|
|
128
131
|
tableName: string;
|
|
129
|
-
/** Must equal the
|
|
132
|
+
/** Must equal the saver's and the history's `indexShards`, or rows land on shards no listing queries. */
|
|
130
133
|
indexShards?: number;
|
|
131
134
|
/** Rows per scan page. */
|
|
132
135
|
pageSize?: number;
|
|
@@ -152,7 +155,7 @@ export interface BackfillOptions {
|
|
|
152
155
|
* rest optional; each, when given, follows the same rule an adapter's own
|
|
153
156
|
* option of the same name does. `tableName` reuses the adapters' own
|
|
154
157
|
* `tableName` validator outright; `indexShards` is held to the adapters'
|
|
155
|
-
* shard cap
|
|
158
|
+
* shard cap of 1024; and `retry` shares its numeric bounds with
|
|
156
159
|
* the adapters' own `retry` validator while accepting the wider surface
|
|
157
160
|
* backfill's `RetryOptions` needs, so a mismatch between backfill and the
|
|
158
161
|
* adapters it feeds cannot drift in on what a bound means.
|
|
@@ -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
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* write rewritten after the read is left alone. A caller names a thread and
|
|
8
8
|
* never learns the row kinds, their sort keys or how a refusal is counted.
|
|
9
9
|
*/
|
|
10
|
-
import type { CheckpointerContext } from '../internal/setup';
|
|
10
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
11
11
|
/**
|
|
12
12
|
* Delete exactly the checkpoint, payload and write rows of one thread that the
|
|
13
13
|
* partition read observed.
|
|
@@ -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
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
11
11
|
import type { CheckpointTuple } from '@langchain/langgraph-checkpoint';
|
|
12
|
-
import type { CheckpointerContext } from '../internal/setup';
|
|
12
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
13
13
|
/**
|
|
14
14
|
* One checkpoint with its metadata and pending writes.
|
|
15
15
|
*
|
|
@@ -22,8 +22,9 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
22
22
|
* `config.signal` — cancels the reads; checked before any of them.
|
|
23
23
|
*
|
|
24
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
|
-
*
|
|
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.
|
|
27
28
|
*
|
|
28
29
|
* Throws: `VALIDATION`, before any read, naming `config`, `configurable` or
|
|
29
30
|
* `signal` for a config of the wrong shape, or `thread_id`, `checkpoint_ns`,
|
|
@@ -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
|
+
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
12
12
|
import type { CheckpointListOptions, CheckpointTuple } from '@langchain/langgraph-checkpoint';
|
|
13
|
-
import type { CheckpointerContext } from '../internal/setup';
|
|
13
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
14
14
|
/**
|
|
15
15
|
* Yield checkpoint tuples for a thread, newest first: every namespace when the
|
|
16
16
|
* config names none (grouped by namespace, newest first within each), else the
|
|
@@ -31,9 +31,12 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
31
31
|
* package's page ceiling; `0` yields nothing, which is what the reference
|
|
32
32
|
* returns, and a negative value is refused.
|
|
33
33
|
*
|
|
34
|
-
* Returns: an async generator over the tuples
|
|
35
|
-
*
|
|
36
|
-
*
|
|
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.
|
|
37
40
|
*
|
|
38
41
|
* Throws: `VALIDATION`, from the first `.next()` and before any read, for
|
|
39
42
|
* a config of the wrong shape (`config`, `configurable`, `signal`), a
|
|
@@ -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
|
+
}
|
|
@@ -10,15 +10,17 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
12
12
|
import type { PendingWrite } from '@langchain/langgraph-checkpoint';
|
|
13
|
-
import type { CheckpointerContext } from '../internal/setup';
|
|
13
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
14
14
|
/**
|
|
15
15
|
* Persist a task's intermediate writes for a checkpoint, one row per write.
|
|
16
16
|
*
|
|
17
17
|
* Accepts: `config` — must name a `checkpoint_id`, since writes always attach
|
|
18
18
|
* to a checkpoint. `writes` — one task's, in order; their channels are
|
|
19
19
|
* validated before anything is encoded or uploaded. `taskId` — validated as the
|
|
20
|
-
* sort-key segment it becomes. `
|
|
21
|
-
*
|
|
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.
|
|
22
24
|
*
|
|
23
25
|
* Returns: nothing. Every write is attempted; a regular write that loses its
|
|
24
26
|
* first-write-wins race is a normal outcome, not a failure.
|
|
@@ -26,8 +28,8 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
26
28
|
* Throws: `VALIDATION` naming `config`, `configurable` or `signal` for a
|
|
27
29
|
* config of the wrong shape; `thread_id`, `checkpoint_ns`, `checkpoint_id` or
|
|
28
30
|
* `thread_ts` for a malformed identifier, and `checkpoint_id` when the config
|
|
29
|
-
* names none; `taskId`, `writes`, `channel`, `sortKey` — every one
|
|
30
|
-
* before anything is encoded or uploaded — `payload` or `s3Key`; the first
|
|
31
|
+
* names none; `taskId`, `taskPath`, `writes`, `channel`, `sortKey` — every one
|
|
32
|
+
* of them before anything is encoded or uploaded — `payload` or `s3Key`; the first
|
|
31
33
|
* genuine write failure, after every write has settled and the cleanup has
|
|
32
34
|
* run.
|
|
33
35
|
*
|
|
@@ -44,4 +46,4 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
44
46
|
* so no row another call writes names one of this call's uploads, and no
|
|
45
47
|
* release reads the row again first.
|
|
46
48
|
*/
|
|
47
|
-
export declare function putWrites(context: CheckpointerContext, config: RunnableConfig, writes: PendingWrite[], taskId: string): Promise<void>;
|
|
49
|
+
export declare function putWrites(context: CheckpointerContext, config: RunnableConfig, writes: PendingWrite[], taskId: string, taskPath?: string): Promise<void>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.putWrites = putWrites;
|
|
4
|
+
const ulid_js_1 = require("../../shared/ulid.js");
|
|
5
|
+
const ttl_js_1 = require("../../shared/validation/ttl.js");
|
|
6
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
7
|
+
const pending_writes_js_1 = require("../internal/pending-writes.js");
|
|
8
|
+
const rows_js_1 = require("../internal/rows.js");
|
|
9
|
+
const nextWriteGroup = (0, ulid_js_1.createUlidFactory)();
|
|
10
|
+
async function putWrites(context, config, writes, taskId, taskPath) {
|
|
11
|
+
const request = (0, parse_js_1.parsePutWritesRequest)(config, writes, taskId, taskPath);
|
|
12
|
+
if (request.writes.length === 0)
|
|
13
|
+
return;
|
|
14
|
+
const ttlTimestamp = context.ttl ? (0, ttl_js_1.calculateTtlTimestamp)(context.ttl) : undefined;
|
|
15
|
+
const items = await (0, rows_js_1.buildWriteRows)(context, request, nextWriteGroup(), ttlTimestamp);
|
|
16
|
+
await (0, pending_writes_js_1.commitPendingWrites)(context, {
|
|
17
|
+
threadId: request.address.threadId,
|
|
18
|
+
items,
|
|
19
|
+
signal: request.signal,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
@@ -9,19 +9,19 @@
|
|
|
9
9
|
* addresses the stored checkpoint and none of this.
|
|
10
10
|
*/
|
|
11
11
|
import type { RunnableConfig } from '@langchain/core/runnables';
|
|
12
|
-
import type {
|
|
13
|
-
import { type WriteVerdict } from '../../shared/dynamodb/idempotent-write';
|
|
14
|
-
import { type CheckpointMetaRow, type CheckpointPayloadRow } from '../internal/rows';
|
|
15
|
-
import type { CheckpointerContext } from '../internal/setup';
|
|
12
|
+
import type { Checkpoint, CheckpointMetadata } from '@langchain/langgraph-checkpoint';
|
|
13
|
+
import { type WriteVerdict } from '../../shared/dynamodb/idempotent-write.js';
|
|
14
|
+
import { type CheckpointMetaRow, type CheckpointPayloadRow } from '../internal/rows.js';
|
|
15
|
+
import type { CheckpointerContext } from '../internal/setup.js';
|
|
16
16
|
/**
|
|
17
17
|
* Persist a checkpoint and its metadata as a transactional pair of META and
|
|
18
18
|
* PAYLOAD rows, returning the config that addresses the stored checkpoint. The
|
|
19
19
|
* incoming `checkpoint_id` (if any) becomes the new checkpoint's parent.
|
|
20
20
|
*
|
|
21
|
-
* **Every channel value the checkpoint carries is stored.**
|
|
22
|
-
*
|
|
23
|
-
* (`@langchain/langgraph-checkpoint@1.1.5` `dist/base.d.ts:68`)
|
|
24
|
-
*
|
|
21
|
+
* **Every channel value the checkpoint carries is stored.** The saver's
|
|
22
|
+
* `put` accepts a `newVersions` argument because `BaseCheckpointSaver.put`
|
|
23
|
+
* declares it (`@langchain/langgraph-checkpoint@1.1.5` `dist/base.d.ts:68`)
|
|
24
|
+
* and does not hand it on: narrowing the stored values to the ones it names, and
|
|
25
25
|
* carrying the rest forward from the parent, made a put whose `newVersions` is
|
|
26
26
|
* `{}` write no values at all. LangGraph passes `{}` when forking a checkpoint
|
|
27
27
|
* and when writing an empty-checkpoint update (`@langchain/langgraph@1.4.13`
|
|
@@ -42,9 +42,10 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
42
42
|
* config of the wrong shape, `thread_id`, `checkpoint_ns`, `checkpoint_id` or
|
|
43
43
|
* `thread_ts` for a malformed identifier, `checkpoint` for a `null` or
|
|
44
44
|
* `undefined` checkpoint, `checkpoint_id` for a malformed `checkpoint.id`,
|
|
45
|
-
* `payload` for a payload too large to store inline without `s3`, or
|
|
46
|
-
*
|
|
47
|
-
*
|
|
45
|
+
* `payload` for a payload too large to store inline without `s3`, or, once
|
|
46
|
+
* offloaded, larger than `s3.maxDownloadBytes`; `s3Key` for an offloaded
|
|
47
|
+
* object's key over S3's cap; `S3_OFFLOAD_FAILED`; whatever the transaction
|
|
48
|
+
* throws once the outcome is established.
|
|
48
49
|
*
|
|
49
50
|
* Guarantees: both rows land or neither does — they are one transaction, so a
|
|
50
51
|
* META row never names a payload that is not there. That transaction goes out
|
|
@@ -59,11 +60,16 @@ import type { CheckpointerContext } from '../internal/setup';
|
|
|
59
60
|
* the row carrying an offloaded descriptor is read back before any upload is
|
|
60
61
|
* deleted (see {@link verifyCheckpointLanded}): a transaction that committed
|
|
61
62
|
* and lost its response is reported as success, a confirmed non-commit cleans
|
|
62
|
-
* up the objects this call uploaded, and an unverifiable outcome
|
|
63
|
-
*
|
|
64
|
-
*
|
|
63
|
+
* up the objects this call uploaded, and an unverifiable outcome — a failed
|
|
64
|
+
* read, or a failure after which DynamoDB may still apply the write, because
|
|
65
|
+
* an attempt of its budget got no answer, was answered
|
|
66
|
+
* `TransactionInProgressException` or failed with a server error (5xx) —
|
|
67
|
+
* leaks them rather than risk stranding a live row, and a put
|
|
68
|
+
* whose signal fired before the transaction was sent sends nothing and
|
|
69
|
+
* releases its uploads. Each put uploads under an object id of its own, so no
|
|
70
|
+
* row another put commits names this call's uploads.
|
|
65
71
|
*/
|
|
66
|
-
export declare function putCheckpoint(context: CheckpointerContext, config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata
|
|
72
|
+
export declare function putCheckpoint(context: CheckpointerContext, config: RunnableConfig, checkpoint: Checkpoint, metadata: CheckpointMetadata): Promise<RunnableConfig>;
|
|
67
73
|
/**
|
|
68
74
|
* Read one of the two rows back after the META+PAYLOAD transaction failed and
|
|
69
75
|
* report what that failure actually did — never assuming it did nothing.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.putCheckpoint = putCheckpoint;
|
|
4
|
+
exports.verifyCheckpointLanded = verifyCheckpointLanded;
|
|
5
|
+
const codec_js_1 = require("../../shared/codec/codec.js");
|
|
6
|
+
const offloader_js_1 = require("../../shared/codec/s3/offloader.js");
|
|
7
|
+
const abort_js_1 = require("../../shared/dynamodb/abort.js");
|
|
8
|
+
const idempotent_write_js_1 = require("../../shared/dynamodb/idempotent-write.js");
|
|
9
|
+
const table_schema_js_1 = require("../../shared/dynamodb/table-schema.js");
|
|
10
|
+
const ttl_js_1 = require("../../shared/validation/ttl.js");
|
|
11
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
12
|
+
const rows_js_1 = require("../internal/rows.js");
|
|
13
|
+
async function putCheckpoint(context, config, checkpoint, metadata) {
|
|
14
|
+
const request = (0, parse_js_1.parsePutRequest)(config, checkpoint, metadata);
|
|
15
|
+
const { threadId, checkpointNs, checkpointId } = request.address;
|
|
16
|
+
const ttlTimestamp = context.ttl ? (0, ttl_js_1.calculateTtlTimestamp)(context.ttl) : undefined;
|
|
17
|
+
const { meta, payload } = await (0, rows_js_1.buildCheckpointRows)(context, request, ttlTimestamp);
|
|
18
|
+
const stored = {
|
|
19
|
+
configurable: { thread_id: threadId, checkpoint_ns: checkpointNs, checkpoint_id: checkpointId },
|
|
20
|
+
};
|
|
21
|
+
if (request.signal?.aborted) {
|
|
22
|
+
await releaseOwnUploads(context, meta, payload);
|
|
23
|
+
throw (0, abort_js_1.abortErrorFrom)(request.signal);
|
|
24
|
+
}
|
|
25
|
+
try {
|
|
26
|
+
await (0, idempotent_write_js_1.transactIdempotently)(context, [
|
|
27
|
+
{ Put: { TableName: context.tableName, Item: meta } },
|
|
28
|
+
{ Put: { TableName: context.tableName, Item: payload } },
|
|
29
|
+
], { signal: request.signal });
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (!context.offloader)
|
|
33
|
+
throw error;
|
|
34
|
+
const verdict = (0, idempotent_write_js_1.settledVerdict)(await verifyCheckpointLanded(context, meta, payload), error);
|
|
35
|
+
if (verdict === 'landed') {
|
|
36
|
+
context.logger.debug('put: transaction committed although its response was lost', {
|
|
37
|
+
threadId,
|
|
38
|
+
checkpointId,
|
|
39
|
+
});
|
|
40
|
+
return stored;
|
|
41
|
+
}
|
|
42
|
+
if (verdict === 'not-landed')
|
|
43
|
+
await releaseOwnUploads(context, meta, payload);
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
return stored;
|
|
47
|
+
}
|
|
48
|
+
async function releaseOwnUploads(context, meta, payload) {
|
|
49
|
+
if (!context.offloader)
|
|
50
|
+
return;
|
|
51
|
+
await (0, offloader_js_1.cleanUpS3Orphans)(context.offloader, {
|
|
52
|
+
keys: (0, codec_js_1.collectS3Keys)([meta.metadata, payload.checkpoint]),
|
|
53
|
+
operation: 'put',
|
|
54
|
+
logger: context.logger,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function chooseProbe(meta, payload) {
|
|
58
|
+
const metaKey = (0, idempotent_write_js_1.offloadedKey)(meta.metadata);
|
|
59
|
+
if (metaKey !== undefined) {
|
|
60
|
+
return {
|
|
61
|
+
key: (0, table_schema_js_1.rowKeyOf)(meta),
|
|
62
|
+
kind: 'descriptor',
|
|
63
|
+
attribute: 'metadata',
|
|
64
|
+
expected: metaKey,
|
|
65
|
+
descriptors: ['metadata'],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
key: (0, table_schema_js_1.rowKeyOf)(payload),
|
|
70
|
+
kind: 'descriptor',
|
|
71
|
+
attribute: 'checkpoint',
|
|
72
|
+
expected: (0, idempotent_write_js_1.offloadedKey)(payload.checkpoint),
|
|
73
|
+
descriptors: ['checkpoint'],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
async function verifyCheckpointLanded(context, meta, payload) {
|
|
77
|
+
const { verdict } = await (0, idempotent_write_js_1.verifyRow)(context, chooseProbe(meta, payload));
|
|
78
|
+
return verdict;
|
|
79
|
+
}
|