@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
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides when a listing reads, and when it stops.
|
|
4
|
-
*
|
|
5
|
-
* A `limit` of `0` is answered before any request is built, a config that
|
|
6
|
-
* pins one checkpoint in a known namespace is a single direct read rather than
|
|
7
|
-
* a range, and every other listing streams tuples until the caller stops
|
|
8
|
-
* pulling or `limit` is reached. The read is deliberately unbounded and
|
|
9
|
-
* eventually consistent; past a threshold an operator is warned instead of the
|
|
10
|
-
* caller being refused. Where the rows come from is `listing`'s concern.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.listCheckpoints = listCheckpoints;
|
|
14
|
-
const clock_1 = require("../../shared/clock");
|
|
15
|
-
const paginate_1 = require("../../shared/dynamodb/paginate");
|
|
16
|
-
const table_schema_1 = require("../../shared/dynamodb/table-schema");
|
|
17
|
-
const listing_1 = require("../internal/listing");
|
|
18
|
-
const parse_1 = require("../internal/parse");
|
|
19
|
-
const read_1 = require("../internal/read");
|
|
20
|
-
/**
|
|
21
|
-
* The tuple for one META item that passes every filter, assembled eventually
|
|
22
|
-
* consistently (a history listing tolerates a replica lag `getTuple` does not)
|
|
23
|
-
* and reusing the metadata the filter already decoded. Undefined when the row
|
|
24
|
-
* is filtered out or its payload is missing.
|
|
25
|
-
*/
|
|
26
|
-
async function tupleFor(context, meta, scope) {
|
|
27
|
-
if (!(0, listing_1.passesKeyFilters)(meta, scope))
|
|
28
|
-
return undefined;
|
|
29
|
-
const verdict = await (0, listing_1.passesMetadataFilter)(context, meta, scope);
|
|
30
|
-
if (!verdict.pass)
|
|
31
|
-
return undefined;
|
|
32
|
-
return (0, read_1.assembleTuple)(context, { threadId: meta.threadId, checkpointNs: meta.checkpointNs }, meta, {
|
|
33
|
-
signal: scope.signal,
|
|
34
|
-
consistent: false,
|
|
35
|
-
metadata: verdict.metadata,
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/** A `checkpoint_id` addresses one row: read it directly instead of scanning the namespace for it. */
|
|
39
|
-
async function* listOne(context, scope) {
|
|
40
|
-
const meta = await (0, read_1.fetchTargetMeta)(context, {
|
|
41
|
-
threadId: scope.threadId,
|
|
42
|
-
checkpointNs: scope.checkpointNs,
|
|
43
|
-
checkpointId: scope.checkpointId,
|
|
44
|
-
}, scope.signal);
|
|
45
|
-
if (!meta)
|
|
46
|
-
return;
|
|
47
|
-
const tuple = await tupleFor(context, meta, scope);
|
|
48
|
-
if (tuple)
|
|
49
|
-
yield tuple;
|
|
50
|
-
}
|
|
51
|
-
/**
|
|
52
|
-
* True when the caller asked for no tuples at all. Answered before any request
|
|
53
|
-
* is built: DynamoDB rejects `Limit: 0`, and yielding one tuple and only then
|
|
54
|
-
* testing the limit returns a result the caller did not ask for. The reference
|
|
55
|
-
* saver returns nothing here (`@langchain/langgraph-checkpoint@1.1.5`
|
|
56
|
-
* `dist/memory.js:172`).
|
|
57
|
-
*
|
|
58
|
-
* Exactly `0`, not "zero or less": a negative limit is refused by
|
|
59
|
-
* {@link parseListScope} before this runs, so treating one as a request for
|
|
60
|
-
* nothing would be a branch no call could reach.
|
|
61
|
-
*/
|
|
62
|
-
function asksForNothing(scope) {
|
|
63
|
-
return scope.limit === 0;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* True when the scope names exactly one row, which is only so once the
|
|
67
|
-
* namespace is known. A `checkpoint_id` without a `checkpoint_ns` may address a
|
|
68
|
-
* checkpoint in any namespace — a subgraph's, for instance — so the read stays
|
|
69
|
-
* namespace-wide and `passesKeyFilters` narrows it to that id.
|
|
70
|
-
*/
|
|
71
|
-
function addressesOneRow(scope) {
|
|
72
|
-
return (scope.threadId !== undefined &&
|
|
73
|
-
scope.checkpointId !== undefined &&
|
|
74
|
-
scope.checkpointNs !== undefined);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Yield checkpoint tuples for a thread, newest first: every namespace when the
|
|
78
|
-
* config names none (grouped by namespace, newest first within each), else the
|
|
79
|
-
* one namespace given. Without a `thread_id` every thread in the table is
|
|
80
|
-
* listed: through a table scan, as the reference savers do, which is unordered
|
|
81
|
-
* across threads, or through the recency index when `indexName` is set. Either
|
|
82
|
-
* read is cross-tenant by construction. Honors `options.before` (only
|
|
83
|
-
* checkpoints older than the given id), `options.filter` (metadata equality),
|
|
84
|
-
* and `options.limit` (max tuples yielded; the read stops right after the
|
|
85
|
-
* yield that reaches it).
|
|
86
|
-
*
|
|
87
|
-
* Accepts: `config` — `thread_id` scopes the read to one thread and its absence
|
|
88
|
-
* lists every thread in the table, through a scan as the reference savers do or
|
|
89
|
-
* through the recency index when `indexName` is set; `checkpoint_ns` scopes to
|
|
90
|
-
* one namespace and its absence spans every namespace of the thread.
|
|
91
|
-
* `options.before` — only checkpoints older than that id. `options.filter` —
|
|
92
|
-
* metadata equality. `options.limit` — at most this many tuples, up to the
|
|
93
|
-
* package's page ceiling; `0` yields nothing, which is what the reference
|
|
94
|
-
* returns, and a negative value is refused.
|
|
95
|
-
*
|
|
96
|
-
* Returns: an async generator over the tuples, newest first within a namespace,
|
|
97
|
-
* unordered across threads on the scan path. The read stops right after the
|
|
98
|
-
* yield that reaches `limit`, and abandoning the generator stops it too.
|
|
99
|
-
*
|
|
100
|
-
* Throws: `VALIDATION`, from the first `.next()` and before any read, for
|
|
101
|
-
* a config of the wrong shape (`config`, `configurable`, `signal`), a
|
|
102
|
-
* malformed identifier, or options that fail the checks
|
|
103
|
-
* {@link parseListScope} makes;
|
|
104
|
-
* `FORMAT_UNSUPPORTED` for a row of ours written by a newer version; whatever
|
|
105
|
-
* the reads and decodes throw.
|
|
106
|
-
*
|
|
107
|
-
* Guarantees: eventually consistent — a listing tolerates the replica lag
|
|
108
|
-
* `getTuple` does not. The read is deliberately unbounded: this generator
|
|
109
|
-
* streams and never accumulates, `limit` returns early, and a raw-row cap would
|
|
110
|
-
* turn a caller asking for a handful of rare matches over a large thread into a
|
|
111
|
-
* hard error instead of the true (possibly empty) answer. Past the warning
|
|
112
|
-
* threshold an operator is told to narrow the filter or pass a limit.
|
|
113
|
-
*/
|
|
114
|
-
async function* listCheckpoints(context, config, options) {
|
|
115
|
-
const scope = (0, parse_1.parseListScope)(config, options);
|
|
116
|
-
if (asksForNothing(scope))
|
|
117
|
-
return;
|
|
118
|
-
if (addressesOneRow(scope)) {
|
|
119
|
-
yield* listOne(context, scope);
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
const now = (0, clock_1.nowSeconds)();
|
|
123
|
-
let yielded = 0;
|
|
124
|
-
let scanned = 0;
|
|
125
|
-
for await (const raw of (0, listing_1.metaRows)(context, scope, now)) {
|
|
126
|
-
scanned += 1;
|
|
127
|
-
if (scanned === paginate_1.LIST_SCAN_WARN_THRESHOLD) {
|
|
128
|
-
context.logger.warn('list: scanned a large number of rows without the caller stopping; this read is ' +
|
|
129
|
-
'deliberately unbounded, so narrow the filter or pass options.limit', { threadId: scope.threadId, checkpointNs: scope.checkpointNs, scanned });
|
|
130
|
-
}
|
|
131
|
-
const meta = (0, listing_1.parseListedRow)(context, raw);
|
|
132
|
-
if (!meta || (0, table_schema_1.isExpiredRow)(meta, now))
|
|
133
|
-
continue;
|
|
134
|
-
const tuple = await tupleFor(context, meta, scope);
|
|
135
|
-
if (!tuple)
|
|
136
|
-
continue;
|
|
137
|
-
yield tuple;
|
|
138
|
-
yielded += 1;
|
|
139
|
-
if (scope.limit !== undefined && yielded >= scope.limit)
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides what it takes for a checkpoint to land exactly once.
|
|
4
|
-
*
|
|
5
|
-
* The META and PAYLOAD rows go out as one transaction under a request token
|
|
6
|
-
* drawn once, and a failure with S3 offload configured is read back before
|
|
7
|
-
* any upload is released, so a lost acknowledgement reports success and only a
|
|
8
|
-
* confirmed non-commit cleans up (record 6). Every channel value is stored
|
|
9
|
-
* whatever `newVersions` says (record 10). A caller gets back the config that
|
|
10
|
-
* addresses the stored checkpoint and none of this.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.putCheckpoint = putCheckpoint;
|
|
14
|
-
exports.verifyCheckpointLanded = verifyCheckpointLanded;
|
|
15
|
-
const codec_1 = require("../../shared/codec/codec");
|
|
16
|
-
const offloader_1 = require("../../shared/codec/s3/offloader");
|
|
17
|
-
const idempotent_write_1 = require("../../shared/dynamodb/idempotent-write");
|
|
18
|
-
const table_schema_1 = require("../../shared/dynamodb/table-schema");
|
|
19
|
-
const ttl_1 = require("../../shared/validation/ttl");
|
|
20
|
-
const parse_1 = require("../internal/parse");
|
|
21
|
-
const rows_1 = require("../internal/rows");
|
|
22
|
-
/**
|
|
23
|
-
* Persist a checkpoint and its metadata as a transactional pair of META and
|
|
24
|
-
* PAYLOAD rows, returning the config that addresses the stored checkpoint. The
|
|
25
|
-
* incoming `checkpoint_id` (if any) becomes the new checkpoint's parent.
|
|
26
|
-
*
|
|
27
|
-
* **Every channel value the checkpoint carries is stored.** `newVersions` is
|
|
28
|
-
* accepted because `BaseCheckpointSaver.put` declares it
|
|
29
|
-
* (`@langchain/langgraph-checkpoint@1.1.5` `dist/base.d.ts:68`) and is
|
|
30
|
-
* deliberately ignored: narrowing the stored values to the ones it names, and
|
|
31
|
-
* carrying the rest forward from the parent, made a put whose `newVersions` is
|
|
32
|
-
* `{}` write no values at all. LangGraph passes `{}` when forking a checkpoint
|
|
33
|
-
* and when writing an empty-checkpoint update (`@langchain/langgraph@1.4.13`
|
|
34
|
-
* `dist/pregel/index.js:668` and `:613`), so that put silently dropped user
|
|
35
|
-
* state. The reference saver does not narrow either: `MemorySaver.put` takes
|
|
36
|
-
* three parameters and stores the whole checkpoint (`dist/memory.js:206`).
|
|
37
|
-
*
|
|
38
|
-
* Accepts: `config` — its `checkpoint_id`, when present, becomes the new
|
|
39
|
-
* checkpoint's parent. `checkpoint.id` — validated as the sort-key segment it
|
|
40
|
-
* becomes. `metadata` — stored beside it, on the light row a listing reads.
|
|
41
|
-
* `config.signal` — cancels the writes' retries; checked before anything is
|
|
42
|
-
* encoded.
|
|
43
|
-
*
|
|
44
|
-
* Returns: the config addressing the stored checkpoint, which is what the
|
|
45
|
-
* caller passes back to continue the thread.
|
|
46
|
-
*
|
|
47
|
-
* Throws: `VALIDATION` naming `config`, `configurable` or `signal` for a
|
|
48
|
-
* config of the wrong shape, `thread_id`, `checkpoint_ns`, `checkpoint_id` or
|
|
49
|
-
* `thread_ts` for a malformed identifier, `checkpoint` for a `null` or
|
|
50
|
-
* `undefined` checkpoint, `checkpoint_id` for a malformed `checkpoint.id`,
|
|
51
|
-
* `payload` for a payload too large to store inline without `s3`, or `s3Key`
|
|
52
|
-
* for an offloaded object's key over S3's cap; `S3_OFFLOAD_FAILED`; whatever
|
|
53
|
-
* the transaction throws once the outcome is established.
|
|
54
|
-
*
|
|
55
|
-
* Guarantees: both rows land or neither does — they are one transaction, so a
|
|
56
|
-
* META row never names a payload that is not there. That transaction goes out
|
|
57
|
-
* under a client request token drawn once, with the request it travels on, so
|
|
58
|
-
* a retry that follows a lost acknowledgement is discarded by the service
|
|
59
|
-
* rather than applied a second time. Writing the same `checkpoint.id` again
|
|
60
|
-
* replaces both, which is what a retry and a repair tool both need; the objects
|
|
61
|
-
* the replaced rows named are not deleted by the put, and are left to the
|
|
62
|
-
* lifecycle rule. A payload the serde refuses is refused before any write and
|
|
63
|
-
* releases whatever the same call had already uploaded, so an encode that fails
|
|
64
|
-
* halfway leaves nothing behind either. On failure with S3 offload configured
|
|
65
|
-
* the row carrying an offloaded descriptor is read back before any upload is
|
|
66
|
-
* deleted (see {@link verifyCheckpointLanded}): a transaction that committed
|
|
67
|
-
* and lost its response is reported as success, a confirmed non-commit cleans
|
|
68
|
-
* up the objects this call uploaded, and an unverifiable outcome leaks them
|
|
69
|
-
* rather than risk stranding a live row. Each put uploads under an object id of
|
|
70
|
-
* its own, so no row another put commits names this call's uploads.
|
|
71
|
-
*/
|
|
72
|
-
async function putCheckpoint(context, config, checkpoint, metadata, _newVersions) {
|
|
73
|
-
const request = (0, parse_1.parsePutRequest)(config, checkpoint, metadata);
|
|
74
|
-
const { threadId, checkpointNs, checkpointId } = request.address;
|
|
75
|
-
const ttlTimestamp = context.ttl ? (0, ttl_1.calculateTtlTimestamp)(context.ttl) : undefined;
|
|
76
|
-
const { meta, payload } = await (0, rows_1.buildCheckpointRows)(context, request, ttlTimestamp);
|
|
77
|
-
const stored = {
|
|
78
|
-
configurable: { thread_id: threadId, checkpoint_ns: checkpointNs, checkpoint_id: checkpointId },
|
|
79
|
-
};
|
|
80
|
-
try {
|
|
81
|
-
// One request, one token, re-sent unchanged for every attempt of the
|
|
82
|
-
// budget — which is what the token is worth here, since a token minted on
|
|
83
|
-
// a request the retry closure rebuilt would be a fresh one per attempt and
|
|
84
|
-
// would deduplicate nothing.
|
|
85
|
-
//
|
|
86
|
-
// Neither row is guarded, so nothing else can turn a re-send away: a retry
|
|
87
|
-
// that follows a lost acknowledgement puts both rows back, and one
|
|
88
|
-
// arriving after a `deleteThread` removed them puts back two live rows
|
|
89
|
-
// naming two objects that call has already released. Inside the service's
|
|
90
|
-
// idempotency window the token discards it instead. The pair is atomic, so
|
|
91
|
-
// what that window covers is the pair: a re-send either re-applies both
|
|
92
|
-
// rows or neither.
|
|
93
|
-
//
|
|
94
|
-
// A condition on either row is not the alternative it looks like. Two
|
|
95
|
-
// guarded items would make one genuine race cancel with two
|
|
96
|
-
// `ConditionalCheckFailed` reasons, and `conditionalCheckFailure` reads a
|
|
97
|
-
// cancellation as a guard rejection only while a single cause remains — so
|
|
98
|
-
// the race would surface as an unrecognised non-retryable error.
|
|
99
|
-
//
|
|
100
|
-
// Because neither row is guarded, the precondition on what a token
|
|
101
|
-
// guarantees — see {@link transactIdempotently} — never bites on the rows
|
|
102
|
-
// themselves: no condition here can turn an attempt away, so an attempt
|
|
103
|
-
// either committed the pair, and its re-send is discarded, or committed
|
|
104
|
-
// nothing. It does bite on the transaction, which a conflict with a
|
|
105
|
-
// concurrent writer of the same id can still cancel: a cancellation
|
|
106
|
-
// completes nothing and is cached as nothing, so the attempt after one is
|
|
107
|
-
// a fresh evaluation rather than a replay. That is the wanted outcome here
|
|
108
|
-
// — the pair did not land, so it must still land — and it is why the
|
|
109
|
-
// token's promise is worded about a write that *committed* rather than one
|
|
110
|
-
// that was merely sent.
|
|
111
|
-
//
|
|
112
|
-
// The deadline that helper carries is what keeps this budget inside the
|
|
113
|
-
// window the token is honoured for. The token enforces no window itself,
|
|
114
|
-
// and a re-send arriving after it has closed is simply a new request: both
|
|
115
|
-
// rows land again, over whatever has replaced them and after whatever
|
|
116
|
-
// released the objects they name.
|
|
117
|
-
await (0, idempotent_write_1.transactIdempotently)(context, [
|
|
118
|
-
{ Put: { TableName: context.tableName, Item: meta } },
|
|
119
|
-
{ Put: { TableName: context.tableName, Item: payload } },
|
|
120
|
-
], { signal: request.signal });
|
|
121
|
-
}
|
|
122
|
-
catch (error) {
|
|
123
|
-
if (!context.offloader)
|
|
124
|
-
throw error;
|
|
125
|
-
const verdict = await verifyCheckpointLanded(context, meta, payload);
|
|
126
|
-
if (verdict === 'landed') {
|
|
127
|
-
context.logger.debug('put: transaction committed although its response was lost', {
|
|
128
|
-
threadId,
|
|
129
|
-
checkpointId,
|
|
130
|
-
});
|
|
131
|
-
return stored;
|
|
132
|
-
}
|
|
133
|
-
if (verdict === 'not-landed') {
|
|
134
|
-
await (0, offloader_1.cleanUpS3Orphans)(context.offloader, {
|
|
135
|
-
keys: (0, codec_1.collectS3Keys)([meta.metadata, payload.checkpoint]),
|
|
136
|
-
operation: 'put',
|
|
137
|
-
logger: context.logger,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
return stored;
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Pick the row carrying an offloaded descriptor, projected to that
|
|
146
|
-
* descriptor's `location` and `s3Key`. The META and PAYLOAD rows commit in one
|
|
147
|
-
* transaction, so one of them is enough; with neither offloaded there is
|
|
148
|
-
* nothing to protect and no read to spend, which {@link verifyRow} answers
|
|
149
|
-
* `'not-landed'` for an absent `expected`.
|
|
150
|
-
*/
|
|
151
|
-
function chooseProbe(meta, payload) {
|
|
152
|
-
const metaKey = (0, idempotent_write_1.offloadedKey)(meta.metadata);
|
|
153
|
-
if (metaKey !== undefined) {
|
|
154
|
-
return {
|
|
155
|
-
key: (0, table_schema_1.rowKeyOf)(meta),
|
|
156
|
-
kind: 'descriptor',
|
|
157
|
-
attribute: 'metadata',
|
|
158
|
-
expected: metaKey,
|
|
159
|
-
descriptors: ['metadata'],
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
return {
|
|
163
|
-
key: (0, table_schema_1.rowKeyOf)(payload),
|
|
164
|
-
kind: 'descriptor',
|
|
165
|
-
attribute: 'checkpoint',
|
|
166
|
-
expected: (0, idempotent_write_1.offloadedKey)(payload.checkpoint),
|
|
167
|
-
descriptors: ['checkpoint'],
|
|
168
|
-
};
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Read one of the two rows back after the META+PAYLOAD transaction failed and
|
|
172
|
-
* report what that failure actually did — never assuming it did nothing.
|
|
173
|
-
*
|
|
174
|
-
* Accepts: `meta` and `payload` — the two rows the failed transaction carried.
|
|
175
|
-
* Whichever of them has something offloaded is the one read back; a fully
|
|
176
|
-
* inline write has no object at stake and spends no read.
|
|
177
|
-
*
|
|
178
|
-
* Returns: the verdict. See {@link WriteVerdict} for what each answer licenses
|
|
179
|
-
* the caller to do. `'landed'` when the row holds this attempt's key,
|
|
180
|
-
* `'not-landed'` when it holds another or none, `'unverified'` when the read
|
|
181
|
-
* failed.
|
|
182
|
-
*
|
|
183
|
-
* Throws: nothing — a failed read is the `'unverified'` answer.
|
|
184
|
-
*
|
|
185
|
-
* Guarantees: both descriptors' keys end in the object id this put drew, which
|
|
186
|
-
* no other put uses. The row holds this attempt's key only if this put's
|
|
187
|
-
* transaction committed, and the other row commits with it, so one read decides
|
|
188
|
-
* the landing. A row holding any other key was committed by another put, whose
|
|
189
|
-
* rows name only that put's objects, so a `'not-landed'` answer leaves both of
|
|
190
|
-
* this put's uploads named by no row.
|
|
191
|
-
*/
|
|
192
|
-
async function verifyCheckpointLanded(context, meta, payload) {
|
|
193
|
-
const { verdict } = await (0, idempotent_write_1.verifyRow)(context, chooseProbe(meta, payload));
|
|
194
|
-
return verdict;
|
|
195
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides how a delta channel's history is rebuilt, and what a hole in it means.
|
|
4
|
-
*
|
|
5
|
-
* A delta channel stores a full value only every `snapshotFrequency` updates,
|
|
6
|
-
* so its value at a checkpoint is its last snapshot plus the writes since,
|
|
7
|
-
* collected by walking parent pointers. The walk, the order the writes are
|
|
8
|
-
* collected in, and the one read that tells an expired ancestor (a hole to
|
|
9
|
-
* report) from one that never existed (the history's true start) are decided
|
|
10
|
-
* here.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.deltaChannelHistory = deltaChannelHistory;
|
|
14
|
-
exports.probeAncestor = probeAncestor;
|
|
15
|
-
exports.ancestorExpired = ancestorExpired;
|
|
16
|
-
const clock_1 = require("../../shared/clock");
|
|
17
|
-
const retry_1 = require("../../shared/dynamodb/retry");
|
|
18
|
-
const table_schema_1 = require("../../shared/dynamodb/table-schema");
|
|
19
|
-
const base_error_1 = require("../../shared/errors/base-error");
|
|
20
|
-
const error_code_1 = require("../../shared/errors/error-code");
|
|
21
|
-
const truncate_1 = require("../../shared/logging/truncate");
|
|
22
|
-
const rows_1 = require("./rows");
|
|
23
|
-
/** An empty accumulator wanting every channel named. */
|
|
24
|
-
function startWalk(channels) {
|
|
25
|
-
const writes = {};
|
|
26
|
-
for (const channel of channels)
|
|
27
|
-
writes[channel] = [];
|
|
28
|
-
return { remaining: new Set(channels), writes, seeds: {} };
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Collect one ancestor's pending writes for the channels still being walked,
|
|
32
|
-
* newest task first within the ancestor, matching the reference walk.
|
|
33
|
-
*/
|
|
34
|
-
function collectWrites(tuple, walk) {
|
|
35
|
-
const perChannel = {};
|
|
36
|
-
for (const write of tuple.pendingWrites ?? []) {
|
|
37
|
-
const channel = write[1];
|
|
38
|
-
if (walk.remaining.has(channel))
|
|
39
|
-
(perChannel[channel] ??= []).push(write);
|
|
40
|
-
}
|
|
41
|
-
for (const channel of Object.keys(perChannel)) {
|
|
42
|
-
const block = perChannel[channel];
|
|
43
|
-
block.sort((a, b) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0));
|
|
44
|
-
for (let i = block.length - 1; i >= 0; i -= 1)
|
|
45
|
-
walk.writes[channel].push(block[i]);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Take the seed for every channel this ancestor stores a value for, and stop
|
|
50
|
-
* walking those channels: the nearest stored value is the one that counts.
|
|
51
|
-
*/
|
|
52
|
-
function takeSeeds(tuple, walk) {
|
|
53
|
-
for (const channel of [...walk.remaining]) {
|
|
54
|
-
if (Object.prototype.hasOwnProperty.call(tuple.checkpoint.channel_values, channel)) {
|
|
55
|
-
walk.seeds[channel] = tuple.checkpoint.channel_values[channel];
|
|
56
|
-
walk.remaining.delete(channel);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* The parent pointer a tuple carries, re-given the caller's `signal`.
|
|
62
|
-
*
|
|
63
|
-
* A tuple's `config` and `parentConfig` are built by `assembleTuple` as bare
|
|
64
|
-
* `{ configurable }` addresses, and they stay that way: they are handed to
|
|
65
|
-
* whoever called `getTuple`, who may keep a `parentConfig` and read from it
|
|
66
|
-
* later, long after this call's signal has fired. So the signal is re-attached
|
|
67
|
-
* here, to the cursor this walk reads with, rather than stamped onto the value
|
|
68
|
-
* the tuple publishes.
|
|
69
|
-
*
|
|
70
|
-
* The cursor is a `RunnableConfig`, and `config.signal` is how every reader in
|
|
71
|
-
* this package already takes a cancel, so nothing new carries it: the second
|
|
72
|
-
* hop is cancellable for exactly the reason the first one is.
|
|
73
|
-
*/
|
|
74
|
-
function cursorFor(parent, signal) {
|
|
75
|
-
if (parent === undefined || signal === undefined)
|
|
76
|
-
return parent;
|
|
77
|
-
return { ...parent, signal };
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Follow `parentConfig` from `from.start` until every channel has a seed or the
|
|
81
|
-
* chain ends, feeding each ancestor to {@link collectWrites} and
|
|
82
|
-
* {@link takeSeeds}.
|
|
83
|
-
*
|
|
84
|
-
* An ancestor that cannot be read ends the walk — quietly when it was never
|
|
85
|
-
* written or the cursor names no checkpoint, both ordinary ends of a chain, and
|
|
86
|
-
* with {@link ancestorExpired} when the row is still stored but past its ttl,
|
|
87
|
-
* which is a hole in the thread.
|
|
88
|
-
*
|
|
89
|
-
* `from.signal` cancels every hop, not just the first. The chain is unbounded
|
|
90
|
-
* in principle — a delta channel rebuilds from the nearest ancestor that stored
|
|
91
|
-
* a value — and each hop is a `getTuple`, which can cost an S3 download, so a
|
|
92
|
-
* walk that could not be stopped part-way would be the one read in this
|
|
93
|
-
* package that ignores a cancel it is given. A cancel is read before each
|
|
94
|
-
* request is sent, so the hop the signal fires on is the last read the call
|
|
95
|
-
* makes.
|
|
96
|
-
*/
|
|
97
|
-
async function walkAncestors(context, getTuple, walk, from) {
|
|
98
|
-
let cursor = cursorFor(from.start, from.signal);
|
|
99
|
-
while (cursor !== undefined && walk.remaining.size > 0) {
|
|
100
|
-
const tuple = await getTuple(cursor);
|
|
101
|
-
if (tuple === undefined) {
|
|
102
|
-
const stop = await probeAncestor(context, cursor);
|
|
103
|
-
if (stop?.expired)
|
|
104
|
-
throw ancestorExpired(stop, [...walk.remaining]);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
collectWrites(tuple, walk);
|
|
108
|
-
takeSeeds(tuple, walk);
|
|
109
|
-
cursor = cursorFor(tuple.parentConfig, from.signal);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
/** Shape one channel's accumulated writes and seed into its public history. */
|
|
113
|
-
function historyOf(walk, channel) {
|
|
114
|
-
const writes = walk.writes[channel].slice().reverse();
|
|
115
|
-
return Object.prototype.hasOwnProperty.call(walk.seeds, channel)
|
|
116
|
-
? { writes, seed: walk.seeds[channel] }
|
|
117
|
-
: { writes };
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Walk a checkpoint's ancestors for the delta channels named, accumulating
|
|
121
|
-
* their writes oldest-first and the nearest stored value of each.
|
|
122
|
-
*
|
|
123
|
-
* Same contract and same result as the inherited implementation
|
|
124
|
-
* (`@langchain/langgraph-checkpoint@1.1.5` `dist/base.js:78`), with one
|
|
125
|
-
* difference that is the reason for overriding it: where the inherited walk
|
|
126
|
-
* meets an ancestor it cannot read it simply stops (`if (tup === void 0)
|
|
127
|
-
* break`), reports no seed, and the consumer rebuilds the channel from its
|
|
128
|
-
* initial value (`@langchain/langgraph@1.4.13` `dist/channels/delta.js:65`).
|
|
129
|
-
* That is silent state loss, and this package can produce it: a ttl is computed
|
|
130
|
-
* per put, so a long-running thread expires its own older checkpoints while the
|
|
131
|
-
* newer ones live on.
|
|
132
|
-
*
|
|
133
|
-
* Accepts: `channels` — the delta channels to rebuild; none returns nothing and
|
|
134
|
-
* reads nothing. `getTuple` — the saver's own, so the walk sees exactly what a
|
|
135
|
-
* reader would. `config` — the checkpoint to walk back from. `config.signal` —
|
|
136
|
-
* cancels the whole walk: it is re-attached to each ancestor cursor
|
|
137
|
-
* ({@link cursorFor}), because the pointer a tuple carries is a bare address.
|
|
138
|
-
*
|
|
139
|
-
* Returns: per channel, its on-path writes oldest-first and the nearest stored
|
|
140
|
-
* value found. A channel whose value was never stored gets none, which is the
|
|
141
|
-
* consumer's cue to start from its initial value — correctly, because there is
|
|
142
|
-
* nothing to lose.
|
|
143
|
-
*
|
|
144
|
-
* Throws: `ANCESTOR_EXPIRED` when an ancestor a channel still needs exists but
|
|
145
|
-
* has expired ({@link ancestorExpired}). An ancestor that was never written
|
|
146
|
-
* still ends the walk quietly — that is an ordinary root. `ABORTED` when the
|
|
147
|
-
* signal fires, at whichever hop it fires on, and in preference to a diagnosis
|
|
148
|
-
* of the stop: a walk cancelled just as it reached an expired ancestor reports
|
|
149
|
-
* the cancel, since the caller stopped waiting for the answer either way.
|
|
150
|
-
*
|
|
151
|
-
* Guarantees: the walk stops at the first ancestor that answers for every
|
|
152
|
-
* channel, so a deep thread costs reads only as far back as the nearest
|
|
153
|
-
* snapshot.
|
|
154
|
-
*/
|
|
155
|
-
async function deltaChannelHistory(context, getTuple, config, channels) {
|
|
156
|
-
if (channels.length === 0)
|
|
157
|
-
return {};
|
|
158
|
-
const walk = startWalk(channels);
|
|
159
|
-
const target = await getTuple(config);
|
|
160
|
-
await walkAncestors(context, getTuple, walk, {
|
|
161
|
-
start: target?.parentConfig,
|
|
162
|
-
signal: config.signal,
|
|
163
|
-
});
|
|
164
|
-
const result = {};
|
|
165
|
-
for (const channel of channels)
|
|
166
|
-
result[channel] = historyOf(walk, channel);
|
|
167
|
-
return result;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Read the META row an ancestor walk could not follow, **ignoring expiry**, to
|
|
171
|
-
* tell "this checkpoint was never written" apart from "it expired out from
|
|
172
|
-
* under its own descendants".
|
|
173
|
-
*
|
|
174
|
-
* Every other read in this package treats an expired row as absent, which is
|
|
175
|
-
* the right rule for a reader asking for state. Here the distinction is the
|
|
176
|
-
* whole point: one is an ordinary root, the other is data loss.
|
|
177
|
-
*
|
|
178
|
-
* Accepts: `config` — the parent pointer a walk stopped at. `config.signal` —
|
|
179
|
-
* cancels the read, and is read before it is sent. The walk re-attaches the
|
|
180
|
-
* caller's signal to every cursor, so the probe takes its cancel from the same
|
|
181
|
-
* place every other reader in this package takes it, rather than from a
|
|
182
|
-
* parameter of its own.
|
|
183
|
-
*
|
|
184
|
-
* Returns: whether that checkpoint exists and whether it has expired, or
|
|
185
|
-
* `undefined` when the config names no thread or no checkpoint — such a pointer
|
|
186
|
-
* addresses nothing that could have expired, so the walk has simply run out of
|
|
187
|
-
* chain.
|
|
188
|
-
*
|
|
189
|
-
* Throws: whatever the read throws after retries; `ABORTED` when the signal
|
|
190
|
-
* has already fired, which is answered in preference to the expiry this read
|
|
191
|
-
* exists to diagnose — a caller who cancelled is owed its own stop, and is no
|
|
192
|
-
* longer waiting to be told why the walk ended.
|
|
193
|
-
*
|
|
194
|
-
* Guarantees: the read ignores the ttl, deliberately. Every other read in this
|
|
195
|
-
* package treats an expired row as absent, which is the right rule for a reader
|
|
196
|
-
* asking for state; here the distinction is the whole point, because one answer
|
|
197
|
-
* is an ordinary root and the other is data loss.
|
|
198
|
-
*/
|
|
199
|
-
async function probeAncestor(context, config) {
|
|
200
|
-
const ids = config.configurable;
|
|
201
|
-
const threadId = ids?.thread_id;
|
|
202
|
-
const checkpointId = ids?.checkpoint_id;
|
|
203
|
-
if (typeof threadId !== 'string' || typeof checkpointId !== 'string')
|
|
204
|
-
return undefined;
|
|
205
|
-
const checkpointNs = ids?.checkpoint_ns ?? '';
|
|
206
|
-
const result = await (0, retry_1.withDynamoDBRetry)((request) => context.client.get({
|
|
207
|
-
TableName: context.tableName,
|
|
208
|
-
Key: (0, rows_1.metaRowKey)({ threadId, checkpointNs, checkpointId }),
|
|
209
|
-
ConsistentRead: true,
|
|
210
|
-
}, request), (0, retry_1.retryFor)(context, config.signal));
|
|
211
|
-
const row = result.Item;
|
|
212
|
-
return {
|
|
213
|
-
threadId,
|
|
214
|
-
checkpointId,
|
|
215
|
-
expired: row !== undefined && (0, table_schema_1.isExpiredRow)(row, (0, clock_1.nowSeconds)()),
|
|
216
|
-
};
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* The error a read raises when a delta channel's history has a hole in it.
|
|
220
|
-
*
|
|
221
|
-
* Accepts: `stop` — the expired ancestor the walk reached. `channels` — the
|
|
222
|
-
* delta channels that still needed it, named in the message so the operator
|
|
223
|
-
* knows what was lost.
|
|
224
|
-
*
|
|
225
|
-
* Returns: the error, coded `ANCESTOR_EXPIRED` and carrying the thread and
|
|
226
|
-
* checkpoint. The message bounds all three: after the first hop the walk's
|
|
227
|
-
* cursor is a row's own `parentConfig`, so the identifiers it names come off a
|
|
228
|
-
* row, and `channels` is checked for being an array of strings and for nothing
|
|
229
|
-
* else — neither how many nor how long. `context` carries both identifiers
|
|
230
|
-
* whole, which is what a caller branches on.
|
|
231
|
-
*
|
|
232
|
-
* Throws: nothing — it builds the error, the caller throws it.
|
|
233
|
-
*
|
|
234
|
-
* Guarantees: returning the partial history instead would hand the caller a
|
|
235
|
-
* channel rebuilt from its initial value plus whatever writes survived — a
|
|
236
|
-
* shorter message list, say, with nothing to say that anything is missing. The
|
|
237
|
-
* reference contract has no way to express "incomplete", so refusing the read
|
|
238
|
-
* is the only honest answer.
|
|
239
|
-
*/
|
|
240
|
-
function ancestorExpired(stop, channels) {
|
|
241
|
-
const named = (0, truncate_1.truncateLabelsForLog)(channels)
|
|
242
|
-
.map((channel) => `"${channel}"`)
|
|
243
|
-
.join(', ');
|
|
244
|
-
return new base_error_1.DynamoDBLangGraphError(`checkpoint "${(0, truncate_1.truncateForLog)(stop.checkpointId)}" of thread ` +
|
|
245
|
-
`"${(0, truncate_1.truncateForLog)(stop.threadId)}" has expired, but later ` +
|
|
246
|
-
`checkpoints still need it to reconstruct ${named}. ` +
|
|
247
|
-
'A delta channel writes a full snapshot only every `snapshotFrequency` updates and leaves ' +
|
|
248
|
-
'itself out of the checkpoints in between, so its value is rebuilt from an earlier ' +
|
|
249
|
-
'ancestor — which a per-checkpoint ttl expires while its descendants live on. Lower ' +
|
|
250
|
-
'`snapshotFrequency` (1 makes every checkpoint self-contained), or do not configure a ttl ' +
|
|
251
|
-
'on threads that use delta channels.', error_code_1.ErrorCode.ANCESTOR_EXPIRED, { threadId: stop.threadId, checkpointId: stop.checkpointId });
|
|
252
|
-
}
|