@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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* then written together is `appendMessages`' decision, not this module's.
|
|
10
10
|
*/
|
|
11
11
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
12
|
-
import type { HistoryContext } from '../internal/setup';
|
|
12
|
+
import type { HistoryContext } from '../internal/setup.js';
|
|
13
13
|
/**
|
|
14
14
|
* Append messages as one item per message. Each chunk writes its message Puts
|
|
15
15
|
* and the session-metadata count `ADD` in a single `TransactWriteItems`, so
|
|
@@ -29,15 +29,23 @@ import type { HistoryContext } from '../internal/setup';
|
|
|
29
29
|
* Returns: nothing, and only once every message has landed.
|
|
30
30
|
*
|
|
31
31
|
* Throws: `VALIDATION` naming `sessionId` or `messages` (with the offending
|
|
32
|
-
* index) before any write
|
|
33
|
-
*
|
|
34
|
-
*
|
|
32
|
+
* index) before any write, or naming `payload` for a message too large to
|
|
33
|
+
* store inline without `s3`, or, once offloaded, larger than
|
|
34
|
+
* `s3.maxDownloadBytes`; `S3_OFFLOAD_FAILED`; whatever the transaction
|
|
35
|
+
* throws, after the rollback; `COMPENSATION_FAILED` when that rollback could
|
|
36
|
+
* not finish, or when a failing chunk's own outcome could not be established;
|
|
37
|
+
* `ABORTED` when the signal fires, after the same rollback.
|
|
35
38
|
*
|
|
36
|
-
* Guarantees: a caller observes all messages or none
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
39
|
+
* Guarantees: a caller observes all messages or none — except the one chunk
|
|
40
|
+
* a failed call could not settle: an `ABORTED` append whose in-flight chunk
|
|
41
|
+
* commits after the call returns, or a `COMPENSATION_FAILED` append whose
|
|
42
|
+
* failing chunk's own outcome could not be established. Read the session
|
|
43
|
+
* back before deciding whether to resend those messages. `messageCount`
|
|
44
|
+
* always agrees with the messages that landed, because each chunk writes
|
|
45
|
+
* both in one transaction. Every message of the append shares one
|
|
46
|
+
* creation-anchored expiry, so a conversation expires whole rather than
|
|
47
|
+
* losing its oldest turns first. No S3 object is left behind by a failure,
|
|
48
|
+
* at any stage — including a failure partway through encoding, before the
|
|
49
|
+
* saga exists.
|
|
42
50
|
*/
|
|
43
51
|
export declare function addMessages(context: HistoryContext, sessionId: string, messages: BaseMessage[], signal?: AbortSignal): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addMessages = addMessages;
|
|
4
|
+
const ttl_js_1 = require("../../shared/validation/ttl.js");
|
|
5
|
+
const append_js_1 = require("../internal/append.js");
|
|
6
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
7
|
+
const session_js_1 = require("../internal/session.js");
|
|
8
|
+
async function addMessages(context, sessionId, messages, signal) {
|
|
9
|
+
const session = (0, parse_js_1.parseSessionId)(sessionId);
|
|
10
|
+
const stored = (0, parse_js_1.parseMessages)(messages);
|
|
11
|
+
if (stored.length === 0)
|
|
12
|
+
return;
|
|
13
|
+
const anchor = context.ttl
|
|
14
|
+
? await (0, session_js_1.resolveTtlAnchor)(context, session, (0, ttl_js_1.calculateTtlTimestamp)(context.ttl), signal)
|
|
15
|
+
: undefined;
|
|
16
|
+
await (0, append_js_1.appendMessages)(context, { sessionId: session, messages: stored, anchor, signal });
|
|
17
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* deleted; the paging, the per-row deletes and the S3 cleanup are the shared
|
|
10
10
|
* partition delete's.
|
|
11
11
|
*/
|
|
12
|
-
import type { HistoryContext } from '../internal/setup';
|
|
12
|
+
import type { HistoryContext } from '../internal/setup.js';
|
|
13
13
|
/**
|
|
14
14
|
* Delete exactly the message rows and the session row of one session that the
|
|
15
15
|
* partition read observed.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearSession = clearSession;
|
|
4
|
+
const idempotent_write_js_1 = require("../../shared/dynamodb/idempotent-write.js");
|
|
5
|
+
const partition_delete_js_1 = require("../../shared/dynamodb/partition-delete.js");
|
|
6
|
+
const retry_js_1 = require("../../shared/dynamodb/retry.js");
|
|
7
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
8
|
+
const rows_js_1 = require("../internal/rows.js");
|
|
9
|
+
function descriptorsOf(row) {
|
|
10
|
+
const entry = (0, partition_delete_js_1.namedDescriptor)(row, 'message');
|
|
11
|
+
return entry === undefined ? [] : [entry];
|
|
12
|
+
}
|
|
13
|
+
async function clearSession(context, sessionId, options = {}) {
|
|
14
|
+
const session = (0, parse_js_1.parseSessionId)(sessionId);
|
|
15
|
+
await (0, partition_delete_js_1.deletePartitionRows)({
|
|
16
|
+
client: context.client,
|
|
17
|
+
tableName: context.tableName,
|
|
18
|
+
params: (0, rows_js_1.sessionRowsQuery)(context.tableName, session, { consistent: true }),
|
|
19
|
+
logger: context.logger,
|
|
20
|
+
retry: (0, retry_js_1.retryFor)(context, options.signal),
|
|
21
|
+
signal: options.signal,
|
|
22
|
+
offloader: context.offloader,
|
|
23
|
+
operation: 'history.clear',
|
|
24
|
+
ownsSortKey: rows_js_1.isHistorySortKey,
|
|
25
|
+
descriptorsOf,
|
|
26
|
+
idAttribute: idempotent_write_js_1.WRITE_ID_ATTRIBUTE,
|
|
27
|
+
scope: [session],
|
|
28
|
+
});
|
|
29
|
+
}
|
|
@@ -11,16 +11,16 @@
|
|
|
11
11
|
* however many downloads run at once.
|
|
12
12
|
*/
|
|
13
13
|
import { type BaseMessage } from '@langchain/core/messages';
|
|
14
|
-
import type { CancelOptions } from '../../shared/options';
|
|
15
|
-
import type { HistoryContext } from '../internal/setup';
|
|
16
|
-
import type { MessageWindow } from '../types';
|
|
14
|
+
import type { CancelOptions } from '../../shared/options.js';
|
|
15
|
+
import type { HistoryContext } from '../internal/setup.js';
|
|
16
|
+
import type { MessageWindow } from '../types.js';
|
|
17
17
|
/**
|
|
18
18
|
* Return a session's messages in chronological order — the whole session, or
|
|
19
19
|
* the window `options` selects: `limit` keeps only the newest `limit`
|
|
20
20
|
* messages, `before` only those appended before that instant (see
|
|
21
21
|
* {@link readWindow}). Items past their TTL are filtered out on read
|
|
22
|
-
* (DynamoDB
|
|
23
|
-
* history is never stale. A corrupt item — see
|
|
22
|
+
* (DynamoDB deletes an expired row within a few days, with no fixed bound),
|
|
23
|
+
* so the returned history is never stale. A corrupt item — see
|
|
24
24
|
* {@link decodeMessage} for exactly what counts — is handled per
|
|
25
25
|
* `onCorruptMessage`: `'throw'` fails the read with the underlying error;
|
|
26
26
|
* `'skip'` (the default) reports it at `error` with its sort key and returns
|
|
@@ -46,10 +46,12 @@ import type { MessageWindow } from '../types';
|
|
|
46
46
|
* did not write, naming
|
|
47
47
|
* `s3Key` for a row addressing an object outside the session's own path, and
|
|
48
48
|
* naming `serde` for a row whose payload the serializer refuses to
|
|
49
|
-
* reconstruct, all three whatever the policy;
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
49
|
+
* reconstruct, all three whatever the policy; `COMPRESSION_LIMIT` for a
|
|
50
|
+
* payload larger than this reader's `compression.maxDecompressedBytes`,
|
|
51
|
+
* whatever the policy too; any infrastructure failure — a throttle, a
|
|
52
|
+
* permission, a transport error — whatever the policy, because dropping a
|
|
53
|
+
* message for one of those would hand back a silently truncated conversation
|
|
54
|
+
* that the chain then re-persists as the truth.
|
|
53
55
|
*
|
|
54
56
|
* Guarantees: strongly consistent, so the turn just appended is visible.
|
|
55
57
|
* Offloaded messages download several at a time, and the corruption policy is
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getMessages = getMessages;
|
|
4
|
+
const messages_1 = require("@langchain/core/messages");
|
|
5
|
+
const codec_js_1 = require("../../shared/codec/codec.js");
|
|
6
|
+
const concurrency_js_1 = require("../../shared/concurrency.js");
|
|
7
|
+
const base_error_js_1 = require("../../shared/errors/base-error.js");
|
|
8
|
+
const truncate_js_1 = require("../../shared/logging/truncate.js");
|
|
9
|
+
const message_read_js_1 = require("../internal/message-read.js");
|
|
10
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
11
|
+
function corruptOrRethrow(error) {
|
|
12
|
+
if ((0, codec_js_1.isPermanentPayloadLoss)(error))
|
|
13
|
+
return { kind: 'corrupt', error };
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
async function decodeMessage(context, item, sessionId, signal) {
|
|
17
|
+
const deps = (0, codec_js_1.codecDepsOf)(context, signal);
|
|
18
|
+
let bytes;
|
|
19
|
+
try {
|
|
20
|
+
bytes = await (0, codec_js_1.readPayloadBytes)(item.message, deps, [sessionId]);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
return corruptOrRethrow(error);
|
|
24
|
+
}
|
|
25
|
+
let stored;
|
|
26
|
+
try {
|
|
27
|
+
stored = await (0, codec_js_1.loadPayloadValue)(item.message.serdeType, bytes, deps);
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
return corruptOrRethrow(error);
|
|
31
|
+
}
|
|
32
|
+
try {
|
|
33
|
+
return { kind: 'ok', message: (0, messages_1.mapStoredMessagesToChatMessages)([stored])[0] };
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
return { kind: 'corrupt', error: (0, base_error_js_1.toError)(error) };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
async function getMessages(context, sessionId, options = {}) {
|
|
40
|
+
const request = (0, parse_js_1.parseGetMessagesRequest)(sessionId, options);
|
|
41
|
+
const items = await (0, message_read_js_1.readWindow)(context, request.sessionId, request.window, request.signal);
|
|
42
|
+
const decoded = await (0, concurrency_js_1.mapWithConcurrency)(items, context.readConcurrency ?? concurrency_js_1.DEFAULT_READ_CONCURRENCY, (item) => decodeMessage(context, item, request.sessionId, request.signal));
|
|
43
|
+
const messages = [];
|
|
44
|
+
decoded.forEach((result, index) => {
|
|
45
|
+
if (result.kind === 'ok') {
|
|
46
|
+
messages.push(result.message);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (context.onCorruptMessage === 'throw')
|
|
50
|
+
throw result.error;
|
|
51
|
+
context.logger.error('getMessages: skipped a corrupt message item', {
|
|
52
|
+
sessionId: request.sessionId,
|
|
53
|
+
sortKey: (0, truncate_js_1.truncateForLog)(items[index].SK),
|
|
54
|
+
reason: (0, truncate_js_1.truncateForLog)((0, base_error_js_1.failureLabel)(result.error)),
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
return messages;
|
|
58
|
+
}
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* `0` reads neither, and the same rule summarises each session and drops the
|
|
9
9
|
* expired, foreign and malformed ones.
|
|
10
10
|
*/
|
|
11
|
-
import type { HistoryContext } from '../internal/setup';
|
|
12
|
-
import type { ListSessionsOptions, SessionPage } from '../types';
|
|
11
|
+
import type { HistoryContext } from '../internal/setup.js';
|
|
12
|
+
import type { ListSessionsOptions, SessionPage } from '../types.js';
|
|
13
13
|
/**
|
|
14
14
|
* List sessions as metadata summaries, most recently updated first.
|
|
15
15
|
*
|
|
@@ -50,6 +50,6 @@ import type { ListSessionsOptions, SessionPage } from '../types';
|
|
|
50
50
|
* shards are queried at once. Memory is the page being built, up to `limit`
|
|
51
51
|
* rows and so bounded by the page ceiling, plus at most one DynamoDB page per shard,
|
|
52
52
|
* whatever the table holds. Without one it is a filtered table scan that holds
|
|
53
|
-
* every session at once and returns no cursor
|
|
53
|
+
* every session at once and returns no cursor.
|
|
54
54
|
*/
|
|
55
55
|
export declare function listSessions(context: HistoryContext, options?: ListSessionsOptions): Promise<SessionPage>;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.listSessions = listSessions;
|
|
4
|
+
const clock_js_1 = require("../../shared/clock.js");
|
|
5
|
+
const concurrency_js_1 = require("../../shared/concurrency.js");
|
|
6
|
+
const paginate_js_1 = require("../../shared/dynamodb/paginate.js");
|
|
7
|
+
const recency_index_js_1 = require("../../shared/dynamodb/recency-index.js");
|
|
8
|
+
const retry_js_1 = require("../../shared/dynamodb/retry.js");
|
|
9
|
+
const table_schema_js_1 = require("../../shared/dynamodb/table-schema.js");
|
|
10
|
+
const primitives_js_1 = require("../../shared/validation/primitives.js");
|
|
11
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
12
|
+
const rows_js_1 = require("../internal/rows.js");
|
|
13
|
+
const session_js_1 = require("../internal/session.js");
|
|
14
|
+
const DEFAULT_PAGE_SIZE = (0, primitives_js_1.parseLimit)(100, 0);
|
|
15
|
+
async function pageFromIndex(context, indexName, request) {
|
|
16
|
+
const atSeconds = (0, clock_js_1.nowSeconds)();
|
|
17
|
+
const page = await (0, recency_index_js_1.queryRecencyIndex)({
|
|
18
|
+
client: context.client,
|
|
19
|
+
tableName: context.tableName,
|
|
20
|
+
indexName,
|
|
21
|
+
tag: 'SESS',
|
|
22
|
+
shards: context.indexShards ?? recency_index_js_1.DEFAULT_INDEX_SHARDS,
|
|
23
|
+
concurrency: context.readConcurrency ?? concurrency_js_1.DEFAULT_READ_CONCURRENCY,
|
|
24
|
+
limit: request.limit ?? DEFAULT_PAGE_SIZE,
|
|
25
|
+
cursor: request.cursor,
|
|
26
|
+
retry: (0, retry_js_1.retryFor)(context, request.signal),
|
|
27
|
+
signal: request.signal,
|
|
28
|
+
});
|
|
29
|
+
const sessions = page.items
|
|
30
|
+
.map((raw) => (0, session_js_1.summariseSession)(raw, atSeconds))
|
|
31
|
+
.filter((session) => session !== undefined);
|
|
32
|
+
return { sessions, ...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }) };
|
|
33
|
+
}
|
|
34
|
+
async function allByScan(context, request) {
|
|
35
|
+
const sessions = [];
|
|
36
|
+
const atSeconds = (0, clock_js_1.nowSeconds)();
|
|
37
|
+
for await (const raw of (0, paginate_js_1.paginateScan)({
|
|
38
|
+
retry: (0, retry_js_1.retryFor)(context, request.signal),
|
|
39
|
+
signal: request.signal,
|
|
40
|
+
client: context.client,
|
|
41
|
+
params: {
|
|
42
|
+
TableName: context.tableName,
|
|
43
|
+
FilterExpression: 'begins_with(#pk, :pkp) AND #sk = :session',
|
|
44
|
+
ExpressionAttributeNames: { '#pk': table_schema_js_1.PARTITION_KEY_ATTRIBUTE, '#sk': table_schema_js_1.SORT_KEY_ATTRIBUTE },
|
|
45
|
+
ExpressionAttributeValues: {
|
|
46
|
+
':pkp': (0, rows_js_1.historyPartitionPrefix)(),
|
|
47
|
+
':session': rows_js_1.SESSION_SORT_KEY,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
maxIterations: request.maxIterations,
|
|
51
|
+
maxItems: request.maxItems,
|
|
52
|
+
})) {
|
|
53
|
+
const session = (0, session_js_1.summariseSession)(raw, atSeconds);
|
|
54
|
+
if (session)
|
|
55
|
+
sessions.push(session);
|
|
56
|
+
}
|
|
57
|
+
sessions.sort((a, b) => (a.updatedAt < b.updatedAt ? 1 : a.updatedAt > b.updatedAt ? -1 : 0));
|
|
58
|
+
return { sessions: request.limit === undefined ? sessions : sessions.slice(0, request.limit) };
|
|
59
|
+
}
|
|
60
|
+
async function listSessions(context, options = {}) {
|
|
61
|
+
const request = (0, parse_js_1.parseListSessionsRequest)(options, context.indexName);
|
|
62
|
+
if (request.limit === 0)
|
|
63
|
+
return { sessions: [] };
|
|
64
|
+
return context.indexName === undefined
|
|
65
|
+
? allByScan(context, request)
|
|
66
|
+
: pageFromIndex(context, context.indexName, request);
|
|
67
|
+
}
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* there, beside the append that keeps the count in step, so the repair and
|
|
8
8
|
* the append cannot come to disagree about what the count means.
|
|
9
9
|
*/
|
|
10
|
-
import type { HistoryContext } from '../internal/setup';
|
|
10
|
+
import type { HistoryContext } from '../internal/setup.js';
|
|
11
11
|
/**
|
|
12
12
|
* Recompute `messageCount` from the number of stored message items and write it
|
|
13
13
|
* back, repairing drift. The append path keeps the count consistent
|
|
@@ -16,15 +16,17 @@ import type { HistoryContext } from '../internal/setup';
|
|
|
16
16
|
* **Safe to run on a live session.** The count is written under a condition on
|
|
17
17
|
* the value the row held when the count was computed, so an append landing in
|
|
18
18
|
* between makes the write fail rather than clobber the increment; the tool then
|
|
19
|
-
* recounts and tries again.
|
|
20
|
-
*
|
|
21
|
-
*
|
|
19
|
+
* recounts and tries again. Written unconditionally, it would silently discard
|
|
20
|
+
* concurrent appends on exactly the sessions an operator reaches for this tool
|
|
21
|
+
* to fix. The count itself is a consistent read, because the pin can only
|
|
22
|
+
* catch a counter that moved, not a count taken off a stale replica.
|
|
22
23
|
*
|
|
23
24
|
* Accepts: `sessionId` — validated, and an existing session: repairing one that
|
|
24
25
|
* does not exist would mean creating it. `signal` — aborts the reads.
|
|
25
26
|
*
|
|
26
|
-
* Returns: the count now stored
|
|
27
|
-
*
|
|
27
|
+
* Returns: the count now stored: the session's live message rows, which is
|
|
28
|
+
* what `getMessages` returns, except for a row it drops as corrupt under
|
|
29
|
+
* `onCorruptMessage: 'skip'`, which is counted here all the same.
|
|
28
30
|
*
|
|
29
31
|
* Throws: `VALIDATION` naming `sessionId`; `CONDITION_CONFLICT` when the
|
|
30
32
|
* session does not exist — rather than creating a permanent, TTL-less
|
|
@@ -38,8 +40,10 @@ import type { HistoryContext } from '../internal/setup';
|
|
|
38
40
|
*
|
|
39
41
|
* Guarantees: safe on a live session. The write is pinned to the value the row
|
|
40
42
|
* held when the count was computed, so an append landing in between fails the
|
|
41
|
-
* write rather than clobbering its increment, and the tool recounts
|
|
42
|
-
*
|
|
43
|
-
*
|
|
43
|
+
* write rather than clobbering its increment, and the tool recounts; the rows
|
|
44
|
+
* are counted with a consistent read, so a chunk that just committed or was
|
|
45
|
+
* just rolled back is counted as it stands. Expired messages are not counted,
|
|
46
|
+
* so the repaired number agrees with what `getMessages` returns rather than
|
|
47
|
+
* with what the table still holds.
|
|
44
48
|
*/
|
|
45
49
|
export declare function reconcileMessageCount(context: HistoryContext, sessionId: string, signal?: AbortSignal): Promise<number>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.reconcileMessageCount = reconcileMessageCount;
|
|
4
|
+
const parse_js_1 = require("../internal/parse.js");
|
|
5
|
+
const session_js_1 = require("../internal/session.js");
|
|
6
|
+
async function reconcileMessageCount(context, sessionId, signal) {
|
|
7
|
+
return (0, session_js_1.repairMessageCount)(context, (0, parse_js_1.parseSessionId)(sessionId), signal);
|
|
8
|
+
}
|
|
@@ -3,17 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The public class holds only what it resolved from its options and routes
|
|
5
5
|
* each read and write to the action that implements it, through
|
|
6
|
-
* `guardPublic`.
|
|
7
|
-
*
|
|
8
|
-
* `destroy` and `forSession`
|
|
9
|
-
* one route from it to
|
|
10
|
-
*
|
|
11
|
-
* change without touching
|
|
6
|
+
* `guardPublic`. Every method is the error boundary, so no error but the
|
|
7
|
+
* library's own reaches a caller (record 13) — an asynchronous one through
|
|
8
|
+
* `guardPublic`, and the synchronous `destroy` and `forSession` through
|
|
9
|
+
* `guardPublicSync`; `forSession` is also the one route from it to
|
|
10
|
+
* LangChain's single-session history. Where an action lives, how it reads or
|
|
11
|
+
* writes, and which client or offloader it uses can change without touching
|
|
12
|
+
* this surface.
|
|
12
13
|
*/
|
|
13
14
|
import type { BaseMessage } from '@langchain/core/messages';
|
|
14
|
-
import type { CancelOptions } from '../shared/options';
|
|
15
|
-
import { type AdapterWindow, DynamoDBSessionChatMessageHistory } from './session-adapter';
|
|
16
|
-
import type { DynamoDBChatMessageHistoryOptions, GetMessagesOptions, ListSessionsOptions, SessionPage } from './types';
|
|
15
|
+
import type { CancelOptions } from '../shared/options.js';
|
|
16
|
+
import { type AdapterWindow, DynamoDBSessionChatMessageHistory } from './session-adapter.js';
|
|
17
|
+
import type { DynamoDBChatMessageHistoryOptions, GetMessagesOptions, ListSessionsOptions, SessionPage } from './types.js';
|
|
17
18
|
/**
|
|
18
19
|
* DynamoDB-backed multi-session chat history. Each message is its own row,
|
|
19
20
|
* ordered by when it was appended, beside one metadata row per session, and
|
|
@@ -41,7 +42,7 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
41
42
|
* Get a session's messages in chronological order.
|
|
42
43
|
*
|
|
43
44
|
* Accepts: `sessionId` — validated. `options.limit` — an integer from 1 to
|
|
44
|
-
*
|
|
45
|
+
* 10,000; only the newest that many messages. `0` is
|
|
45
46
|
* refused rather than answered with an empty conversation, which is the one
|
|
46
47
|
* place this package refuses a `limit` of zero. `options.before` — a valid
|
|
47
48
|
* `Date`; only messages appended before that instant. Neither given reads
|
|
@@ -56,6 +57,8 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
56
57
|
* session's own path, and naming `message` for a row in this session's
|
|
57
58
|
* message key space that this adapter did not write, both whatever the
|
|
58
59
|
* corruption policy;
|
|
60
|
+
* `COMPRESSION_LIMIT` for a payload larger than this reader's
|
|
61
|
+
* `compression.maxDecompressedBytes`, whatever the corruption policy too;
|
|
59
62
|
* `FORMAT_UNSUPPORTED` for a row, or a payload, a newer release wrote;
|
|
60
63
|
* a classified AWS failure;
|
|
61
64
|
* `ABORTED`; and, under `onCorruptMessage: 'throw'`, the decode error of a
|
|
@@ -70,23 +73,34 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
70
73
|
* Append messages to a session.
|
|
71
74
|
*
|
|
72
75
|
* Accepts: `sessionId` — validated. `messages` — LangChain messages; an empty
|
|
73
|
-
* list writes nothing and is not an error. `options.signal` —
|
|
74
|
-
*
|
|
76
|
+
* list writes nothing and is not an error. `options.signal` — ends the
|
|
77
|
+
* upload or chunk transaction in flight and any wait between them; a chunk
|
|
78
|
+
* that landed before the cancel is rolled back like any other committed
|
|
79
|
+
* chunk of a failed append.
|
|
75
80
|
*
|
|
76
81
|
* Returns: nothing, and only once every message has landed.
|
|
77
82
|
*
|
|
78
83
|
* Throws: `VALIDATION` naming `messages`, for a value that is not itself
|
|
79
84
|
* an array, or, with the offending index, for an element that is not a
|
|
80
|
-
* message or one that could never be read back;
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
85
|
+
* message or one that could never be read back; naming `payload` for a
|
|
86
|
+
* message too large to store inline without `s3`, or, once offloaded,
|
|
87
|
+
* larger than `s3.maxDownloadBytes`; naming `s3Key` for an offloaded
|
|
88
|
+
* object's key over S3's cap; or naming `signal` or `options.<key>` for a
|
|
89
|
+
* key this package does not read; `S3_OFFLOAD_FAILED` when an offloaded
|
|
90
|
+
* message cannot be uploaded;
|
|
91
|
+
* `COMPENSATION_FAILED` when a chunk fails and either the rollback fails
|
|
92
|
+
* too or that chunk's own outcome could not be established;
|
|
93
|
+
* `RETRY_EXHAUSTED` after 18 contended attempts; a classified AWS failure;
|
|
84
94
|
* `ABORTED`.
|
|
85
95
|
*
|
|
86
|
-
* Guarantees: a caller observes all messages or none
|
|
87
|
-
* chunk
|
|
88
|
-
*
|
|
89
|
-
*
|
|
96
|
+
* Guarantees: a caller observes all messages or none — except the one
|
|
97
|
+
* chunk a failed call could not settle: an `ABORTED` append whose in-flight
|
|
98
|
+
* chunk commits after the call returns, or a `COMPENSATION_FAILED` append
|
|
99
|
+
* whose failing chunk's own outcome could not be established. Read the
|
|
100
|
+
* session back before deciding whether to resend those messages. One
|
|
101
|
+
* transaction per chunk of up to 99 keeps `messageCount` exact. Lock-free
|
|
102
|
+
* and safe under concurrent appends to one session; every message shares
|
|
103
|
+
* the session's TTL when one is configured.
|
|
90
104
|
*/
|
|
91
105
|
addMessages(sessionId: string, messages: BaseMessage[], options?: CancelOptions): Promise<void>;
|
|
92
106
|
/**
|
|
@@ -102,7 +116,9 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
102
116
|
/**
|
|
103
117
|
* Delete a session's messages, metadata and offloaded objects.
|
|
104
118
|
*
|
|
105
|
-
* Accepts: `sessionId` — validated. `options.signal` —
|
|
119
|
+
* Accepts: `sessionId` — validated. `options.signal` — ends the read or
|
|
120
|
+
* delete in flight and any wait between them; rows already deleted stay
|
|
121
|
+
* deleted.
|
|
106
122
|
*
|
|
107
123
|
* Returns: nothing. Clearing a session that does not exist is not an error.
|
|
108
124
|
*
|
|
@@ -132,7 +148,7 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
132
148
|
* bounded by `maxItems` / `maxIterations`, and returning the newest `limit`
|
|
133
149
|
* sessions, or every session when no limit is given, with no cursor.
|
|
134
150
|
*
|
|
135
|
-
* Accepts: `options.limit` — an integer from 0 to
|
|
151
|
+
* Accepts: `options.limit` — an integer from 0 to 10,000;
|
|
136
152
|
* the page size with the index, the newest N without it, and `0` an empty
|
|
137
153
|
* page read from neither. `options.cursor` — from a previous page,
|
|
138
154
|
* and only with a configured `indexName`. `options.maxItems` /
|
|
@@ -157,7 +173,7 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
157
173
|
* page still needs one, so a shard can cost a query whose rows the page never
|
|
158
174
|
* takes; at most `readConcurrency` shards are queried at once. Memory is the
|
|
159
175
|
* page being built, up to `limit` rows and so bounded by
|
|
160
|
-
*
|
|
176
|
+
* 10,000, plus at most one DynamoDB page per shard,
|
|
161
177
|
* whatever the table holds.
|
|
162
178
|
*/
|
|
163
179
|
listSessions(options?: ListSessionsOptions): Promise<SessionPage>;
|
|
@@ -168,8 +184,9 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
168
184
|
* Accepts: `sessionId` — validated, and an existing session.
|
|
169
185
|
* `options.signal` — aborts the reads.
|
|
170
186
|
*
|
|
171
|
-
* Returns: the count now stored
|
|
172
|
-
*
|
|
187
|
+
* Returns: the count now stored: the session's live message rows, which is
|
|
188
|
+
* what `getMessages` returns, except for a row it drops as corrupt under
|
|
189
|
+
* `onCorruptMessage: 'skip'`, which is counted here all the same.
|
|
173
190
|
*
|
|
174
191
|
* Throws: `VALIDATION` for a malformed session id, an invalid `signal`,
|
|
175
192
|
* or an `options.<key>` this package does not read; `CONDITION_CONFLICT` when the
|
|
@@ -210,9 +227,10 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
210
227
|
* Returns: nothing. Idempotent, and a no-op for a client the caller injected
|
|
211
228
|
* — that one is theirs to close.
|
|
212
229
|
*
|
|
213
|
-
* Throws:
|
|
214
|
-
*
|
|
215
|
-
*
|
|
230
|
+
* Throws: the first failure a resource's own `destroy` raised, as a
|
|
231
|
+
* `DynamoDBLangGraphError` (`UNEXPECTED_ERROR` unless the failure was AWS's)
|
|
232
|
+
* with it as `cause` — raised only after every other resource has been
|
|
233
|
+
* released, and only by the first call: `destroy()` is idempotent.
|
|
216
234
|
*/
|
|
217
235
|
destroy(): void;
|
|
218
236
|
/**
|
|
@@ -223,13 +241,27 @@ export declare class DynamoDBChatMessageHistory {
|
|
|
223
241
|
* without both.
|
|
224
242
|
*
|
|
225
243
|
* Returns: nothing. Installing a rule that is already there is a no-op too.
|
|
244
|
+
* When it writes the rules but cannot confirm within its polling window
|
|
245
|
+
* that a re-read shows them — S3 documents that a lifecycle configuration
|
|
246
|
+
* can take minutes to propagate — it logs a `warn` and returns rather than
|
|
247
|
+
* throwing: the rules were written, and a later call can confirm them.
|
|
226
248
|
*
|
|
227
249
|
* Throws: `VALIDATION` naming `s3.keyPrefix` on a rule-id collision;
|
|
228
|
-
* a classified AWS failure when the bucket's lifecycle cannot be read or
|
|
250
|
+
* a classified AWS failure when the bucket's lifecycle cannot be read or
|
|
251
|
+
* written; `CONTENTION` when every one of the five rounds this call polls
|
|
252
|
+
* needs a write — a competing writer replacing the configuration on every
|
|
253
|
+
* single re-read.
|
|
229
254
|
* @remarks Requires the bucket-level `s3:GetLifecycleConfiguration` /
|
|
230
255
|
* `s3:PutLifecycleConfiguration` permissions, broader than the object-level
|
|
231
256
|
* CRUD the rest of S3 offload needs — call it once during provisioning, not
|
|
232
|
-
* per request.
|
|
257
|
+
* per request. When several adapters or processes provision the same
|
|
258
|
+
* bucket, call them one at a time and run each again after a few minutes
|
|
259
|
+
* once every one of them has run.
|
|
260
|
+
*
|
|
261
|
+
* Lowering the `ttl` is safe for new rows at once; the rule is not. Lower
|
|
262
|
+
* `ttl` now, and call this again only once the old `ttl` has elapsed since,
|
|
263
|
+
* because until then rows written under the old value still name objects
|
|
264
|
+
* the shorter rule would expire. Raising the `ttl` is safe at once.
|
|
233
265
|
*/
|
|
234
266
|
ensureS3LifecycleRule(): Promise<void>;
|
|
235
267
|
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoDBChatMessageHistory = void 0;
|
|
4
|
+
const boundary_js_1 = require("../shared/errors/boundary.js");
|
|
5
|
+
const collaborators_js_1 = require("../shared/validation/collaborators.js");
|
|
6
|
+
const add_messages_js_1 = require("./actions/add-messages.js");
|
|
7
|
+
const clear_js_1 = require("./actions/clear.js");
|
|
8
|
+
const get_messages_js_1 = require("./actions/get-messages.js");
|
|
9
|
+
const list_sessions_js_1 = require("./actions/list-sessions.js");
|
|
10
|
+
const reconcile_count_js_1 = require("./actions/reconcile-count.js");
|
|
11
|
+
const setup_js_1 = require("./internal/setup.js");
|
|
12
|
+
const session_adapter_js_1 = require("./session-adapter.js");
|
|
13
|
+
class DynamoDBChatMessageHistory {
|
|
14
|
+
context;
|
|
15
|
+
shell;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
const setup = (0, setup_js_1.setUpHistory)(options);
|
|
18
|
+
this.context = setup.context;
|
|
19
|
+
this.shell = setup.shell;
|
|
20
|
+
}
|
|
21
|
+
getMessages(sessionId, options) {
|
|
22
|
+
return (0, boundary_js_1.guardPublic)('history.getMessages', () => (0, get_messages_js_1.getMessages)(this.context, sessionId, options), this.context.tableName);
|
|
23
|
+
}
|
|
24
|
+
addMessages(sessionId, messages, options) {
|
|
25
|
+
return (0, boundary_js_1.guardPublic)('history.addMessages', () => {
|
|
26
|
+
(0, collaborators_js_1.assertCancelOptions)(options);
|
|
27
|
+
return (0, add_messages_js_1.addMessages)(this.context, sessionId, messages, options?.signal);
|
|
28
|
+
}, this.context.tableName);
|
|
29
|
+
}
|
|
30
|
+
addMessage(sessionId, message, options) {
|
|
31
|
+
return (0, boundary_js_1.guardPublic)('history.addMessage', () => {
|
|
32
|
+
(0, collaborators_js_1.assertCancelOptions)(options);
|
|
33
|
+
return (0, add_messages_js_1.addMessages)(this.context, sessionId, [message], options?.signal);
|
|
34
|
+
}, this.context.tableName);
|
|
35
|
+
}
|
|
36
|
+
clear(sessionId, options) {
|
|
37
|
+
return (0, boundary_js_1.guardPublic)('history.clear', () => {
|
|
38
|
+
(0, collaborators_js_1.assertCancelOptions)(options);
|
|
39
|
+
return (0, clear_js_1.clearSession)(this.context, sessionId, options);
|
|
40
|
+
}, this.context.tableName);
|
|
41
|
+
}
|
|
42
|
+
listSessions(options) {
|
|
43
|
+
return (0, boundary_js_1.guardPublic)('history.listSessions', () => (0, list_sessions_js_1.listSessions)(this.context, options), this.context.tableName);
|
|
44
|
+
}
|
|
45
|
+
reconcileMessageCount(sessionId, options) {
|
|
46
|
+
return (0, boundary_js_1.guardPublic)('history.reconcileMessageCount', () => {
|
|
47
|
+
(0, collaborators_js_1.assertCancelOptions)(options);
|
|
48
|
+
return (0, reconcile_count_js_1.reconcileMessageCount)(this.context, sessionId, options?.signal);
|
|
49
|
+
}, this.context.tableName);
|
|
50
|
+
}
|
|
51
|
+
forSession(sessionId, window) {
|
|
52
|
+
return (0, boundary_js_1.guardPublicSync)('history.forSession', () => new session_adapter_js_1.DynamoDBSessionChatMessageHistory(this, sessionId, window), this.context.tableName);
|
|
53
|
+
}
|
|
54
|
+
destroy() {
|
|
55
|
+
(0, boundary_js_1.guardPublicSync)('history.destroy', () => this.shell.release(), this.context.tableName);
|
|
56
|
+
}
|
|
57
|
+
async ensureS3LifecycleRule() {
|
|
58
|
+
return (0, boundary_js_1.guardPublic)('history.ensureS3LifecycleRule', () => this.shell.ensureLifecycleRule(), this.context.tableName);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.DynamoDBChatMessageHistory = DynamoDBChatMessageHistory;
|