@farukada/aws-langgraph-dynamodb-ts 0.9.0 → 1.0.0-rc.2
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 +1720 -154
- package/dist/backfill/backfill.d.ts +168 -0
- package/dist/backfill/backfill.js +393 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +47 -6
- package/dist/checkpointer/actions/delete-thread.js +58 -21
- package/dist/checkpointer/actions/get-tuple.d.ts +29 -4
- package/dist/checkpointer/actions/get-tuple.js +44 -10
- package/dist/checkpointer/actions/list.d.ts +46 -4
- package/dist/checkpointer/actions/list.js +121 -66
- package/dist/checkpointer/actions/put-writes.d.ts +41 -9
- package/dist/checkpointer/actions/put-writes.js +62 -77
- package/dist/checkpointer/actions/put.d.ts +83 -4
- package/dist/checkpointer/actions/put.js +177 -25
- package/dist/checkpointer/internal/delta-history.d.ts +112 -0
- package/dist/checkpointer/internal/delta-history.js +252 -0
- package/dist/checkpointer/internal/listing.d.ts +149 -0
- package/dist/checkpointer/internal/listing.js +245 -0
- package/dist/checkpointer/internal/parse.d.ts +262 -0
- package/dist/checkpointer/internal/parse.js +372 -0
- package/dist/checkpointer/internal/pending-writes.d.ts +275 -0
- package/dist/checkpointer/internal/pending-writes.js +588 -0
- package/dist/checkpointer/internal/read.d.ts +130 -0
- package/dist/checkpointer/internal/read.js +264 -0
- package/dist/checkpointer/internal/rows.d.ts +571 -0
- package/dist/checkpointer/internal/rows.js +834 -0
- package/dist/checkpointer/internal/setup.d.ts +42 -19
- package/dist/checkpointer/internal/setup.js +65 -29
- package/dist/checkpointer/saver.d.ts +256 -16
- package/dist/checkpointer/saver.js +275 -29
- package/dist/checkpointer/types.d.ts +39 -39
- package/dist/checkpointer/types.js +10 -1
- package/dist/factory/factory.d.ts +134 -28
- package/dist/factory/factory.js +240 -21
- package/dist/factory/types.d.ts +76 -0
- package/dist/factory/types.js +10 -0
- package/dist/history/actions/add-messages.d.ts +31 -4
- package/dist/history/actions/add-messages.js +38 -58
- package/dist/history/actions/clear.d.ts +49 -6
- package/dist/history/actions/clear.js +66 -14
- package/dist/history/actions/get-messages.d.ts +54 -6
- package/dist/history/actions/get-messages.js +126 -43
- package/dist/history/actions/list-sessions.d.ts +52 -10
- package/dist/history/actions/list-sessions.js +139 -40
- package/dist/history/actions/reconcile-count.d.ts +42 -10
- package/dist/history/actions/reconcile-count.js +45 -45
- package/dist/history/chat-message-history.d.ts +220 -33
- package/dist/history/chat-message-history.js +240 -43
- package/dist/history/internal/append.d.ts +212 -0
- package/dist/history/internal/append.js +500 -0
- package/dist/history/internal/message-read.d.ts +84 -0
- package/dist/history/internal/message-read.js +204 -0
- package/dist/history/internal/parse.d.ts +153 -0
- package/dist/history/internal/parse.js +252 -0
- package/dist/history/internal/rows.d.ts +195 -0
- package/dist/history/internal/rows.js +250 -0
- package/dist/history/internal/session.d.ts +331 -0
- package/dist/history/internal/session.js +628 -0
- package/dist/history/internal/setup.d.ts +52 -17
- package/dist/history/internal/setup.js +92 -21
- package/dist/history/session-adapter.d.ts +102 -7
- package/dist/history/session-adapter.js +103 -9
- package/dist/history/types.d.ts +80 -29
- package/dist/history/types.js +10 -1
- package/dist/index.d.ts +42 -11
- package/dist/index.js +33 -12
- package/dist/shared/adapter.d.ts +135 -0
- package/dist/shared/adapter.js +143 -0
- package/dist/shared/clock.d.ts +51 -2
- package/dist/shared/clock.js +57 -2
- package/dist/shared/codec/codec.d.ts +288 -13
- package/dist/shared/codec/codec.js +416 -19
- package/dist/shared/codec/compression.d.ts +43 -7
- package/dist/shared/codec/compression.js +53 -13
- package/dist/shared/codec/json-serde.d.ts +76 -4
- package/dist/shared/codec/json-serde.js +181 -8
- package/dist/shared/codec/s3/client-types.d.ts +53 -0
- package/dist/shared/codec/s3/client-types.js +26 -0
- package/dist/shared/codec/s3/client.d.ts +43 -10
- package/dist/shared/codec/s3/client.js +82 -9
- package/dist/shared/codec/s3/config.d.ts +242 -11
- package/dist/shared/codec/s3/config.js +293 -11
- package/dist/shared/codec/s3/lifecycle.d.ts +164 -6
- package/dist/shared/codec/s3/lifecycle.js +335 -27
- package/dist/shared/codec/s3/offloader.d.ts +393 -18
- package/dist/shared/codec/s3/offloader.js +595 -37
- package/dist/shared/concurrency.d.ts +43 -0
- package/dist/shared/concurrency.js +78 -0
- package/dist/shared/dynamodb/abort.d.ts +47 -0
- package/dist/shared/dynamodb/abort.js +59 -0
- package/dist/shared/dynamodb/batch-write.d.ts +77 -14
- package/dist/shared/dynamodb/batch-write.js +146 -27
- package/dist/shared/dynamodb/cancellation.d.ts +121 -4
- package/dist/shared/dynamodb/cancellation.js +147 -3
- package/dist/shared/dynamodb/client.d.ts +162 -8
- package/dist/shared/dynamodb/client.js +153 -5
- package/dist/shared/dynamodb/idempotent-write.d.ts +551 -0
- package/dist/shared/dynamodb/idempotent-write.js +593 -0
- package/dist/shared/dynamodb/paginate.d.ts +105 -9
- package/dist/shared/dynamodb/paginate.js +175 -7
- package/dist/shared/dynamodb/partition-delete.d.ts +185 -14
- package/dist/shared/dynamodb/partition-delete.js +314 -44
- package/dist/shared/dynamodb/recency-index.d.ts +231 -0
- package/dist/shared/dynamodb/recency-index.js +377 -0
- package/dist/shared/dynamodb/retry.d.ts +276 -8
- package/dist/shared/dynamodb/retry.js +433 -23
- package/dist/shared/dynamodb/table-schema.d.ts +190 -0
- package/dist/shared/dynamodb/table-schema.js +209 -0
- package/dist/shared/errors/base-error.d.ts +184 -10
- package/dist/shared/errors/base-error.js +160 -14
- package/dist/shared/errors/boundary.d.ts +71 -0
- package/dist/shared/errors/boundary.js +143 -0
- package/dist/shared/errors/classify.d.ts +97 -0
- package/dist/shared/errors/classify.js +257 -0
- package/dist/shared/errors/error-code.d.ts +77 -2
- package/dist/shared/errors/error-code.js +83 -1
- package/dist/shared/errors/errors.d.ts +158 -59
- package/dist/shared/errors/errors.js +219 -92
- package/dist/shared/logging/logger.d.ts +69 -3
- package/dist/shared/logging/logger.js +97 -3
- package/dist/shared/logging/redaction.d.ts +92 -8
- package/dist/shared/logging/redaction.js +273 -17
- package/dist/shared/logging/secret-patterns.d.ts +149 -19
- package/dist/shared/logging/secret-patterns.js +188 -27
- package/dist/shared/logging/truncate.d.ts +197 -0
- package/dist/shared/logging/truncate.js +231 -0
- package/dist/shared/options.d.ts +59 -7
- package/dist/shared/options.js +9 -1
- package/dist/shared/ulid.d.ts +77 -7
- package/dist/shared/ulid.js +103 -8
- package/dist/shared/validation/collaborators.d.ts +141 -0
- package/dist/shared/validation/collaborators.js +188 -0
- package/dist/shared/validation/option-shape.d.ts +89 -0
- package/dist/shared/validation/option-shape.js +113 -0
- package/dist/shared/validation/options.d.ts +145 -0
- package/dist/shared/validation/options.js +328 -0
- package/dist/shared/validation/primitives.d.ts +288 -21
- package/dist/shared/validation/primitives.js +353 -50
- package/dist/shared/validation/ttl.d.ts +66 -10
- package/dist/shared/validation/ttl.js +113 -15
- package/dist/store/actions/list-namespaces.d.ts +76 -6
- package/dist/store/actions/list-namespaces.js +166 -24
- package/dist/store/actions/put.d.ts +33 -8
- package/dist/store/actions/put.js +53 -60
- package/dist/store/actions/reconcile-vector-index.d.ts +31 -10
- package/dist/store/actions/reconcile-vector-index.js +34 -15
- package/dist/store/actions/search.d.ts +34 -6
- package/dist/store/actions/search.js +56 -51
- package/dist/store/internal/batch-plan.d.ts +26 -0
- package/dist/store/internal/batch-plan.js +109 -0
- package/dist/store/internal/filter.d.ts +36 -3
- package/dist/store/internal/filter.js +66 -15
- package/dist/store/internal/get-item.d.ts +45 -0
- package/dist/store/internal/get-item.js +115 -0
- package/dist/store/internal/item-write.d.ts +230 -0
- package/dist/store/internal/item-write.js +463 -0
- package/dist/store/internal/parse.d.ts +225 -0
- package/dist/store/internal/parse.js +350 -0
- package/dist/store/internal/rows.d.ts +355 -0
- package/dist/store/internal/rows.js +447 -0
- package/dist/store/internal/semantic-search.d.ts +161 -6
- package/dist/store/internal/semantic-search.js +360 -18
- package/dist/store/internal/setup.d.ts +77 -20
- package/dist/store/internal/setup.js +178 -47
- package/dist/store/internal/table-search.d.ts +100 -0
- package/dist/store/internal/table-search.js +213 -0
- package/dist/store/internal/vector-index.d.ts +247 -0
- package/dist/store/internal/vector-index.js +546 -0
- package/dist/store/store.d.ts +270 -17
- package/dist/store/store.js +329 -38
- package/dist/store/types.d.ts +76 -26
- package/dist/store/types.js +13 -1
- package/dist/store/vector-backend.d.ts +64 -4
- package/dist/store/vector-backend.js +15 -1
- package/package.json +58 -36
- package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
- package/dist/checkpointer/actions/delete-thread.js.map +0 -1
- package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
- package/dist/checkpointer/actions/get-tuple.js.map +0 -1
- package/dist/checkpointer/actions/list.d.ts.map +0 -1
- package/dist/checkpointer/actions/list.js.map +0 -1
- package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
- package/dist/checkpointer/actions/put-writes.js.map +0 -1
- package/dist/checkpointer/actions/put.d.ts.map +0 -1
- package/dist/checkpointer/actions/put.js.map +0 -1
- package/dist/checkpointer/internal/assemble.d.ts +0 -10
- package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
- package/dist/checkpointer/internal/assemble.js +0 -37
- package/dist/checkpointer/internal/assemble.js.map +0 -1
- package/dist/checkpointer/internal/configurable.d.ts +0 -13
- package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
- package/dist/checkpointer/internal/configurable.js +0 -23
- package/dist/checkpointer/internal/configurable.js.map +0 -1
- package/dist/checkpointer/internal/fetch.d.ts +0 -10
- package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
- package/dist/checkpointer/internal/fetch.js +0 -46
- package/dist/checkpointer/internal/fetch.js.map +0 -1
- package/dist/checkpointer/internal/filter-match.d.ts +0 -12
- package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
- package/dist/checkpointer/internal/filter-match.js +0 -14
- package/dist/checkpointer/internal/filter-match.js.map +0 -1
- package/dist/checkpointer/internal/item-reader.d.ts +0 -55
- package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-reader.js +0 -88
- package/dist/checkpointer/internal/item-reader.js.map +0 -1
- package/dist/checkpointer/internal/item-writer.d.ts +0 -26
- package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-writer.js +0 -92
- package/dist/checkpointer/internal/item-writer.js.map +0 -1
- package/dist/checkpointer/internal/keys.d.ts +0 -31
- package/dist/checkpointer/internal/keys.d.ts.map +0 -1
- package/dist/checkpointer/internal/keys.js +0 -87
- package/dist/checkpointer/internal/keys.js.map +0 -1
- package/dist/checkpointer/internal/query.d.ts +0 -20
- package/dist/checkpointer/internal/query.d.ts.map +0 -1
- package/dist/checkpointer/internal/query.js +0 -36
- package/dist/checkpointer/internal/query.js.map +0 -1
- package/dist/checkpointer/internal/setup.d.ts.map +0 -1
- package/dist/checkpointer/internal/setup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -30
- package/dist/checkpointer/internal/special-write-cas.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cas.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -24
- package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -47
- package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -54
- package/dist/checkpointer/internal/special-write-verify.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.js +0 -65
- package/dist/checkpointer/internal/special-write-verify.js.map +0 -1
- package/dist/checkpointer/internal/validation.d.ts +0 -13
- package/dist/checkpointer/internal/validation.d.ts.map +0 -1
- package/dist/checkpointer/internal/validation.js +0 -30
- package/dist/checkpointer/internal/validation.js.map +0 -1
- package/dist/checkpointer/internal/write-guard.d.ts +0 -13
- package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-guard.js +0 -39
- package/dist/checkpointer/internal/write-guard.js.map +0 -1
- package/dist/checkpointer/internal/write-index.d.ts +0 -37
- package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-index.js +0 -42
- package/dist/checkpointer/internal/write-index.js.map +0 -1
- package/dist/checkpointer/saver.d.ts.map +0 -1
- package/dist/checkpointer/saver.js.map +0 -1
- package/dist/checkpointer/types.d.ts.map +0 -1
- package/dist/checkpointer/types.js.map +0 -1
- package/dist/factory/factory.d.ts.map +0 -1
- package/dist/factory/factory.js.map +0 -1
- package/dist/history/actions/add-messages.d.ts.map +0 -1
- package/dist/history/actions/add-messages.js.map +0 -1
- package/dist/history/actions/clear.d.ts.map +0 -1
- package/dist/history/actions/clear.js.map +0 -1
- package/dist/history/actions/get-messages.d.ts.map +0 -1
- package/dist/history/actions/get-messages.js.map +0 -1
- package/dist/history/actions/list-sessions.d.ts.map +0 -1
- package/dist/history/actions/list-sessions.js.map +0 -1
- package/dist/history/actions/reconcile-count.d.ts.map +0 -1
- package/dist/history/actions/reconcile-count.js.map +0 -1
- package/dist/history/chat-message-history.d.ts.map +0 -1
- package/dist/history/chat-message-history.js.map +0 -1
- package/dist/history/internal/append-saga.d.ts +0 -20
- package/dist/history/internal/append-saga.d.ts.map +0 -1
- package/dist/history/internal/append-saga.js +0 -35
- package/dist/history/internal/append-saga.js.map +0 -1
- package/dist/history/internal/compensation.d.ts +0 -21
- package/dist/history/internal/compensation.d.ts.map +0 -1
- package/dist/history/internal/compensation.js +0 -84
- package/dist/history/internal/compensation.js.map +0 -1
- package/dist/history/internal/item-mapper.d.ts +0 -12
- package/dist/history/internal/item-mapper.d.ts.map +0 -1
- package/dist/history/internal/item-mapper.js +0 -33
- package/dist/history/internal/item-mapper.js.map +0 -1
- package/dist/history/internal/keys.d.ts +0 -17
- package/dist/history/internal/keys.d.ts.map +0 -1
- package/dist/history/internal/keys.js +0 -49
- package/dist/history/internal/keys.js.map +0 -1
- package/dist/history/internal/message-chunker.d.ts +0 -14
- package/dist/history/internal/message-chunker.d.ts.map +0 -1
- package/dist/history/internal/message-chunker.js +0 -68
- package/dist/history/internal/message-chunker.js.map +0 -1
- package/dist/history/internal/message-transaction.d.ts +0 -26
- package/dist/history/internal/message-transaction.d.ts.map +0 -1
- package/dist/history/internal/message-transaction.js +0 -60
- package/dist/history/internal/message-transaction.js.map +0 -1
- package/dist/history/internal/query.d.ts +0 -10
- package/dist/history/internal/query.d.ts.map +0 -1
- package/dist/history/internal/query.js +0 -31
- package/dist/history/internal/query.js.map +0 -1
- package/dist/history/internal/session-count.d.ts +0 -41
- package/dist/history/internal/session-count.d.ts.map +0 -1
- package/dist/history/internal/session-count.js +0 -109
- package/dist/history/internal/session-count.js.map +0 -1
- package/dist/history/internal/session-title.d.ts +0 -20
- package/dist/history/internal/session-title.d.ts.map +0 -1
- package/dist/history/internal/session-title.js +0 -44
- package/dist/history/internal/session-title.js.map +0 -1
- package/dist/history/internal/session-update.d.ts +0 -28
- package/dist/history/internal/session-update.d.ts.map +0 -1
- package/dist/history/internal/session-update.js +0 -70
- package/dist/history/internal/session-update.js.map +0 -1
- package/dist/history/internal/setup.d.ts.map +0 -1
- package/dist/history/internal/setup.js.map +0 -1
- package/dist/history/internal/title-generator.d.ts +0 -13
- package/dist/history/internal/title-generator.d.ts.map +0 -1
- package/dist/history/internal/title-generator.js +0 -25
- package/dist/history/internal/title-generator.js.map +0 -1
- package/dist/history/internal/ttl-anchor.d.ts +0 -25
- package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/ttl-anchor.js.map +0 -1
- package/dist/history/internal/validation.d.ts +0 -9
- package/dist/history/internal/validation.d.ts.map +0 -1
- package/dist/history/internal/validation.js +0 -16
- package/dist/history/internal/validation.js.map +0 -1
- package/dist/history/session-adapter.d.ts.map +0 -1
- package/dist/history/session-adapter.js.map +0 -1
- package/dist/history/types.d.ts.map +0 -1
- package/dist/history/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shared/clock.d.ts.map +0 -1
- package/dist/shared/clock.js.map +0 -1
- package/dist/shared/codec/codec.d.ts.map +0 -1
- package/dist/shared/codec/codec.js.map +0 -1
- package/dist/shared/codec/compression.d.ts.map +0 -1
- package/dist/shared/codec/compression.js.map +0 -1
- package/dist/shared/codec/descriptor-keys.d.ts +0 -4
- package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/descriptor-keys.js.map +0 -1
- package/dist/shared/codec/json-serde.d.ts.map +0 -1
- package/dist/shared/codec/json-serde.js.map +0 -1
- package/dist/shared/codec/s3/client.d.ts.map +0 -1
- package/dist/shared/codec/s3/client.js.map +0 -1
- package/dist/shared/codec/s3/config.d.ts.map +0 -1
- package/dist/shared/codec/s3/config.js.map +0 -1
- package/dist/shared/codec/s3/delete.d.ts +0 -8
- package/dist/shared/codec/s3/delete.d.ts.map +0 -1
- package/dist/shared/codec/s3/delete.js +0 -29
- package/dist/shared/codec/s3/delete.js.map +0 -1
- package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
- package/dist/shared/codec/s3/lifecycle.js.map +0 -1
- package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
- package/dist/shared/codec/s3/offloader.js.map +0 -1
- package/dist/shared/codec/s3/orphans.d.ts +0 -18
- package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
- package/dist/shared/codec/s3/orphans.js +0 -58
- package/dist/shared/codec/s3/orphans.js.map +0 -1
- package/dist/shared/codec/s3/read-write.d.ts +0 -14
- package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
- package/dist/shared/codec/s3/read-write.js +0 -43
- package/dist/shared/codec/s3/read-write.js.map +0 -1
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.d.ts.map +0 -1
- package/dist/shared/codec/s3/retry.js +0 -25
- package/dist/shared/codec/s3/retry.js.map +0 -1
- package/dist/shared/constants.d.ts +0 -64
- package/dist/shared/constants.d.ts.map +0 -1
- package/dist/shared/constants.js +0 -67
- package/dist/shared/constants.js.map +0 -1
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/backoff.js.map +0 -1
- package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
- package/dist/shared/dynamodb/batch-write.js.map +0 -1
- package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
- package/dist/shared/dynamodb/cancellation.js.map +0 -1
- package/dist/shared/dynamodb/client.d.ts.map +0 -1
- package/dist/shared/dynamodb/client.js.map +0 -1
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -51
- package/dist/shared/dynamodb/conditional-put.d.ts.map +0 -1
- package/dist/shared/dynamodb/conditional-put.js +0 -59
- package/dist/shared/dynamodb/conditional-put.js.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -19
- package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -44
- package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -22
- package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate-core.js +0 -52
- package/dist/shared/dynamodb/paginate-core.js.map +0 -1
- package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate.js.map +0 -1
- package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
- package/dist/shared/dynamodb/partition-delete.js.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -9
- package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.js +0 -87
- package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
- package/dist/shared/dynamodb/retry.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry.js.map +0 -1
- package/dist/shared/dynamodb/scan.d.ts +0 -15
- package/dist/shared/dynamodb/scan.d.ts.map +0 -1
- package/dist/shared/dynamodb/scan.js +0 -20
- package/dist/shared/dynamodb/scan.js.map +0 -1
- package/dist/shared/dynamodb/types.d.ts +0 -24
- package/dist/shared/dynamodb/types.d.ts.map +0 -1
- package/dist/shared/dynamodb/types.js +0 -3
- package/dist/shared/dynamodb/types.js.map +0 -1
- package/dist/shared/errors/base-error.d.ts.map +0 -1
- package/dist/shared/errors/base-error.js.map +0 -1
- package/dist/shared/errors/error-code.d.ts.map +0 -1
- package/dist/shared/errors/error-code.js.map +0 -1
- package/dist/shared/errors/errors.d.ts.map +0 -1
- package/dist/shared/errors/errors.js.map +0 -1
- package/dist/shared/errors/wrap-error.d.ts +0 -16
- package/dist/shared/errors/wrap-error.d.ts.map +0 -1
- package/dist/shared/errors/wrap-error.js +0 -30
- package/dist/shared/errors/wrap-error.js.map +0 -1
- package/dist/shared/logging/logger.d.ts.map +0 -1
- package/dist/shared/logging/logger.js.map +0 -1
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
- package/dist/shared/logging/redaction-walk.js +0 -92
- package/dist/shared/logging/redaction-walk.js.map +0 -1
- package/dist/shared/logging/redaction.d.ts.map +0 -1
- package/dist/shared/logging/redaction.js.map +0 -1
- package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
- package/dist/shared/logging/secret-patterns.js.map +0 -1
- package/dist/shared/options.d.ts.map +0 -1
- package/dist/shared/options.js.map +0 -1
- package/dist/shared/ulid.d.ts.map +0 -1
- package/dist/shared/ulid.js.map +0 -1
- package/dist/shared/validation/primitives.d.ts.map +0 -1
- package/dist/shared/validation/primitives.js.map +0 -1
- package/dist/shared/validation/ttl.d.ts.map +0 -1
- package/dist/shared/validation/ttl.js.map +0 -1
- package/dist/store/actions/get.d.ts +0 -5
- package/dist/store/actions/get.d.ts.map +0 -1
- package/dist/store/actions/get.js +0 -35
- package/dist/store/actions/get.js.map +0 -1
- package/dist/store/actions/list-namespaces.d.ts.map +0 -1
- package/dist/store/actions/list-namespaces.js.map +0 -1
- package/dist/store/actions/put.d.ts.map +0 -1
- package/dist/store/actions/put.js.map +0 -1
- package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
- package/dist/store/actions/reconcile-vector-index.js.map +0 -1
- package/dist/store/actions/search.d.ts.map +0 -1
- package/dist/store/actions/search.js.map +0 -1
- package/dist/store/internal/backend-search.d.ts +0 -5
- package/dist/store/internal/backend-search.d.ts.map +0 -1
- package/dist/store/internal/backend-search.js +0 -68
- package/dist/store/internal/backend-search.js.map +0 -1
- package/dist/store/internal/filter.d.ts.map +0 -1
- package/dist/store/internal/filter.js.map +0 -1
- package/dist/store/internal/index-reconcile.d.ts +0 -22
- package/dist/store/internal/index-reconcile.d.ts.map +0 -1
- package/dist/store/internal/index-reconcile.js +0 -105
- package/dist/store/internal/index-reconcile.js.map +0 -1
- package/dist/store/internal/index-sync.d.ts +0 -11
- package/dist/store/internal/index-sync.d.ts.map +0 -1
- package/dist/store/internal/index-sync.js +0 -26
- package/dist/store/internal/index-sync.js.map +0 -1
- package/dist/store/internal/item-mapper.d.ts +0 -25
- package/dist/store/internal/item-mapper.d.ts.map +0 -1
- package/dist/store/internal/item-mapper.js +0 -53
- package/dist/store/internal/item-mapper.js.map +0 -1
- package/dist/store/internal/keys.d.ts +0 -18
- package/dist/store/internal/keys.d.ts.map +0 -1
- package/dist/store/internal/keys.js +0 -42
- package/dist/store/internal/keys.js.map +0 -1
- package/dist/store/internal/namespace-match.d.ts +0 -12
- package/dist/store/internal/namespace-match.d.ts.map +0 -1
- package/dist/store/internal/namespace-match.js +0 -41
- package/dist/store/internal/namespace-match.js.map +0 -1
- package/dist/store/internal/overwrite-swap.d.ts +0 -33
- package/dist/store/internal/overwrite-swap.d.ts.map +0 -1
- package/dist/store/internal/overwrite-swap.js +0 -62
- package/dist/store/internal/overwrite-swap.js.map +0 -1
- package/dist/store/internal/persist.d.ts +0 -27
- package/dist/store/internal/persist.d.ts.map +0 -1
- package/dist/store/internal/persist.js +0 -59
- package/dist/store/internal/persist.js.map +0 -1
- package/dist/store/internal/query.d.ts +0 -6
- package/dist/store/internal/query.d.ts.map +0 -1
- package/dist/store/internal/query.js +0 -32
- package/dist/store/internal/query.js.map +0 -1
- package/dist/store/internal/ranker.d.ts +0 -13
- package/dist/store/internal/ranker.d.ts.map +0 -1
- package/dist/store/internal/ranker.js +0 -31
- package/dist/store/internal/ranker.js.map +0 -1
- package/dist/store/internal/read-existing.d.ts +0 -19
- package/dist/store/internal/read-existing.d.ts.map +0 -1
- package/dist/store/internal/read-existing.js +0 -29
- package/dist/store/internal/read-existing.js.map +0 -1
- package/dist/store/internal/score-direction.d.ts +0 -32
- package/dist/store/internal/score-direction.d.ts.map +0 -1
- package/dist/store/internal/score-direction.js +0 -39
- package/dist/store/internal/score-direction.js.map +0 -1
- package/dist/store/internal/search-filter.d.ts +0 -4
- package/dist/store/internal/search-filter.d.ts.map +0 -1
- package/dist/store/internal/search-filter.js +0 -11
- package/dist/store/internal/search-filter.js.map +0 -1
- package/dist/store/internal/semantic-search.d.ts.map +0 -1
- package/dist/store/internal/semantic-search.js.map +0 -1
- package/dist/store/internal/setup.d.ts.map +0 -1
- package/dist/store/internal/setup.js.map +0 -1
- package/dist/store/internal/validation.d.ts +0 -13
- package/dist/store/internal/validation.d.ts.map +0 -1
- package/dist/store/internal/validation.js +0 -35
- package/dist/store/internal/validation.js.map +0 -1
- package/dist/store/internal/write-verify.d.ts +0 -37
- package/dist/store/internal/write-verify.d.ts.map +0 -1
- package/dist/store/internal/write-verify.js +0 -68
- package/dist/store/internal/write-verify.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js.map +0 -1
- package/dist/store/vector-backend.d.ts.map +0 -1
- package/dist/store/vector-backend.js.map +0 -1
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides that chat history is a set of actions behind one error boundary.
|
|
4
|
+
*
|
|
5
|
+
* The public class holds only what it resolved from its options and routes
|
|
6
|
+
* each read and write to the action that implements it, through
|
|
7
|
+
* `guardPublic`. Each asynchronous method is the error boundary, so no error
|
|
8
|
+
* but the library's own reaches a caller (record 13); the synchronous
|
|
9
|
+
* `destroy` and `forSession` are the exceptions — the latter is also the
|
|
10
|
+
* one route from it to LangChain's single-session history. Where an action
|
|
11
|
+
* lives, how it reads or writes, and which client or offloader it uses can
|
|
12
|
+
* change without touching this surface.
|
|
13
|
+
*/
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.DynamoDBChatMessageHistory = void 0;
|
|
4
|
-
const
|
|
16
|
+
const boundary_1 = require("../shared/errors/boundary");
|
|
17
|
+
const collaborators_1 = require("../shared/validation/collaborators");
|
|
5
18
|
const add_messages_1 = require("./actions/add-messages");
|
|
6
19
|
const clear_1 = require("./actions/clear");
|
|
7
20
|
const get_messages_1 = require("./actions/get-messages");
|
|
@@ -10,72 +23,256 @@ const reconcile_count_1 = require("./actions/reconcile-count");
|
|
|
10
23
|
const setup_1 = require("./internal/setup");
|
|
11
24
|
const session_adapter_1 = require("./session-adapter");
|
|
12
25
|
/**
|
|
13
|
-
* DynamoDB-backed multi-session chat history. Each message is its own
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* LangChain adapter.
|
|
26
|
+
* DynamoDB-backed multi-session chat history. Each message is its own row,
|
|
27
|
+
* ordered by when it was appended, beside one metadata row per session, and
|
|
28
|
+
* every message in a session shares one TTL. An append costs the same however
|
|
29
|
+
* long the session is and takes no lock. Use {@link forSession} to get a
|
|
30
|
+
* single-session LangChain adapter. Every public method rejects only with this
|
|
31
|
+
* library's error.
|
|
18
32
|
*/
|
|
19
33
|
class DynamoDBChatMessageHistory {
|
|
20
34
|
context;
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
shell;
|
|
36
|
+
/**
|
|
37
|
+
* Accepts: `options` — validated here, so a misconfiguration surfaces at
|
|
38
|
+
* construction rather than on the first request.
|
|
39
|
+
*
|
|
40
|
+
* Returns: an adapter that owns the client it built, or borrows the one it
|
|
41
|
+
* was given.
|
|
42
|
+
*
|
|
43
|
+
* Throws: `VALIDATION` naming the offending option.
|
|
44
|
+
*
|
|
45
|
+
* Guarantees: no I/O. Constructing the adapter issues no request.
|
|
46
|
+
*/
|
|
23
47
|
constructor(options) {
|
|
24
48
|
const setup = (0, setup_1.setUpHistory)(options);
|
|
25
49
|
this.context = setup.context;
|
|
26
|
-
this.
|
|
27
|
-
this.ddbClient = setup.ddbClient;
|
|
50
|
+
this.shell = setup.shell;
|
|
28
51
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Get a session's messages in chronological order.
|
|
54
|
+
*
|
|
55
|
+
* Accepts: `sessionId` — validated. `options.limit` — an integer from 1 to
|
|
56
|
+
* `MAX_PAGE_LIMIT` (10,000); only the newest that many messages. `0` is
|
|
57
|
+
* refused rather than answered with an empty conversation, which is the one
|
|
58
|
+
* place this package refuses a `limit` of zero. `options.before` — a valid
|
|
59
|
+
* `Date`; only messages appended before that instant. Neither given reads
|
|
60
|
+
* the whole session. `options.signal` — aborts the reads.
|
|
61
|
+
*
|
|
62
|
+
* Returns: the messages, oldest first. A session that does not exist and one
|
|
63
|
+
* whose messages have all expired both return nothing.
|
|
64
|
+
*
|
|
65
|
+
* Throws: `VALIDATION` for a malformed session id or window, an invalid
|
|
66
|
+
* `signal`, or naming `options.<key>` for a key this package does not read;
|
|
67
|
+
* `VALIDATION` naming `s3Key` for a row addressing an object outside the
|
|
68
|
+
* session's own path, and naming `message` for a row in this session's
|
|
69
|
+
* message key space that this adapter did not write, both whatever the
|
|
70
|
+
* corruption policy;
|
|
71
|
+
* `FORMAT_UNSUPPORTED` for a row, or a payload, a newer release wrote;
|
|
72
|
+
* a classified AWS failure;
|
|
73
|
+
* `ABORTED`; and, under `onCorruptMessage: 'throw'`, the decode error of a
|
|
74
|
+
* corrupt row.
|
|
75
|
+
*
|
|
76
|
+
* Guarantees: strongly consistent, so the turn just appended is visible.
|
|
77
|
+
* Expired messages are filtered on read, so the history is never stale.
|
|
78
|
+
* @remarks One query page plus one S3 download per offloaded message.
|
|
79
|
+
*/
|
|
80
|
+
getMessages(sessionId, options) {
|
|
81
|
+
return (0, boundary_1.guardPublic)('history.getMessages', () => (0, get_messages_1.getMessages)(this.context, sessionId, options));
|
|
32
82
|
}
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
83
|
+
/**
|
|
84
|
+
* Append messages to a session.
|
|
85
|
+
*
|
|
86
|
+
* Accepts: `sessionId` — validated. `messages` — LangChain messages; an empty
|
|
87
|
+
* list writes nothing and is not an error. `options.signal` — aborts between
|
|
88
|
+
* chunks.
|
|
89
|
+
*
|
|
90
|
+
* Returns: nothing, and only once every message has landed.
|
|
91
|
+
*
|
|
92
|
+
* Throws: `VALIDATION` naming `messages`, for a value that is not itself
|
|
93
|
+
* an array, or, with the offending index, for an element that is not a
|
|
94
|
+
* message or one that could never be read back; or naming `signal` or
|
|
95
|
+
* `options.<key>` for a key this package does not read;
|
|
96
|
+
* `COMPENSATION_FAILED` when a later chunk fails and the rollback fails
|
|
97
|
+
* too; `RETRY_EXHAUSTED` after 18 contended attempts; a classified AWS failure;
|
|
98
|
+
* `ABORTED`.
|
|
99
|
+
*
|
|
100
|
+
* Guarantees: a caller observes all messages or none. One transaction per
|
|
101
|
+
* chunk of up to 99 keeps `messageCount` exact. Lock-free and safe under
|
|
102
|
+
* concurrent appends to one session; every message shares the session's TTL
|
|
103
|
+
* when one is configured.
|
|
104
|
+
*/
|
|
105
|
+
addMessages(sessionId, messages, options) {
|
|
106
|
+
return (0, boundary_1.guardPublic)('history.addMessages', () => {
|
|
107
|
+
(0, collaborators_1.assertCancelOptions)(options);
|
|
108
|
+
return (0, add_messages_1.addMessages)(this.context, sessionId, messages, options?.signal);
|
|
109
|
+
});
|
|
36
110
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
111
|
+
/**
|
|
112
|
+
* Append one message.
|
|
113
|
+
*
|
|
114
|
+
* Accepts: as {@link addMessages}, for a single message.
|
|
115
|
+
*
|
|
116
|
+
* Returns: nothing.
|
|
117
|
+
*
|
|
118
|
+
* Throws: as {@link addMessages}.
|
|
119
|
+
*/
|
|
120
|
+
addMessage(sessionId, message, options) {
|
|
121
|
+
return (0, boundary_1.guardPublic)('history.addMessage', () => {
|
|
122
|
+
(0, collaborators_1.assertCancelOptions)(options);
|
|
123
|
+
return (0, add_messages_1.addMessages)(this.context, sessionId, [message], options?.signal);
|
|
124
|
+
});
|
|
40
125
|
}
|
|
41
|
-
/**
|
|
42
|
-
|
|
43
|
-
|
|
126
|
+
/**
|
|
127
|
+
* Delete a session's messages, metadata and offloaded objects.
|
|
128
|
+
*
|
|
129
|
+
* Accepts: `sessionId` — validated. `options.signal` — aborts between pages.
|
|
130
|
+
*
|
|
131
|
+
* Returns: nothing. Clearing a session that does not exist is not an error.
|
|
132
|
+
*
|
|
133
|
+
* Throws: `VALIDATION` for a malformed session id, an invalid `signal`,
|
|
134
|
+
* or an `options.<key>` this package does not read;
|
|
135
|
+
* `BATCH_WRITE_INCOMPLETE` when a row's delete fails, counting rows
|
|
136
|
+
* rather than batches; a classified AWS failure; `ABORTED` when the signal fires,
|
|
137
|
+
* which is what a cancel surfaces as rather than an incomplete delete, even
|
|
138
|
+
* when it fires part-way through the pass. A row refused because it
|
|
139
|
+
* was rewritten after the partition read raises nothing: it is left in place,
|
|
140
|
+
* reported at `warn`, and counted as skipped.
|
|
141
|
+
*
|
|
142
|
+
* Guarantees: a row this adapter did not write is left in place and logged,
|
|
143
|
+
* and neither is a row rewritten since the read — an append landing during
|
|
144
|
+
* the call moves the session row's own write id, so that row survives with
|
|
145
|
+
* the session it belongs to instead of being removed under a live
|
|
146
|
+
* conversation. Single pass: call it when the session is quiescent, since a
|
|
147
|
+
* message appended while it runs may survive it, and the surviving session
|
|
148
|
+
* row then over-counts until `reconcileMessageCount` repairs it.
|
|
149
|
+
*/
|
|
150
|
+
clear(sessionId, options) {
|
|
151
|
+
return (0, boundary_1.guardPublic)('history.clear', () => {
|
|
152
|
+
(0, collaborators_1.assertCancelOptions)(options);
|
|
153
|
+
return (0, clear_1.clearSession)(this.context, sessionId, options);
|
|
154
|
+
});
|
|
44
155
|
}
|
|
45
|
-
/**
|
|
156
|
+
/**
|
|
157
|
+
* List every session as a metadata summary, most recently updated first.
|
|
158
|
+
* With a configured `indexName` this reads each index shard newest-first,
|
|
159
|
+
* merges the shards and pages by the opaque `nextCursor`. Without one it
|
|
160
|
+
* falls back to a filtered table scan — cross-tenant by construction,
|
|
161
|
+
* bounded by `maxItems` / `maxIterations`, and returning the newest `limit`
|
|
162
|
+
* sessions, or every session when no limit is given, with no cursor.
|
|
163
|
+
*
|
|
164
|
+
* Accepts: `options.limit` — an integer from 0 to `MAX_PAGE_LIMIT` (10,000);
|
|
165
|
+
* the page size with the index, the newest N without it, and `0` an empty
|
|
166
|
+
* page read from neither. `options.cursor` — from a previous page,
|
|
167
|
+
* and only with a configured `indexName`. `options.maxItems` /
|
|
168
|
+
* `maxIterations` — caps on the scan path. `options.signal` — aborts the
|
|
169
|
+
* reads.
|
|
170
|
+
*
|
|
171
|
+
* Returns: the page and, while rows may remain, a `nextCursor`. A page may
|
|
172
|
+
* come back shorter than `limit` while more rows remain: expired and foreign
|
|
173
|
+
* rows are dropped after the read. A cursor does not promise more rows:
|
|
174
|
+
* DynamoDB can end a shard's page at its last row and still return a key to
|
|
175
|
+
* continue from, and the page after such a cursor can come back empty. Stop
|
|
176
|
+
* when `nextCursor` is absent, never when a page looks short.
|
|
177
|
+
*
|
|
178
|
+
* Throws: `VALIDATION` naming `limit`, `cursor`, `maxItems`,
|
|
179
|
+
* `maxIterations`, `signal`, or `options.<key>` for a key this package does
|
|
180
|
+
* not read; `RESULT_TRUNCATED` past either cap on the scan path, or for an
|
|
181
|
+
* index shard whose pages do not end; `FORMAT_UNSUPPORTED` for a session row
|
|
182
|
+
* a newer release wrote; a classified AWS failure; `ABORTED`.
|
|
183
|
+
*
|
|
184
|
+
* Guarantees: with a configured `indexName` each shard is read one DynamoDB
|
|
185
|
+
* page at a time, and its next page whenever it has no row buffered and the
|
|
186
|
+
* page still needs one, so a shard can cost a query whose rows the page never
|
|
187
|
+
* takes; at most `readConcurrency` shards are queried at once. Memory is the
|
|
188
|
+
* page being built, up to `limit` rows and so bounded by
|
|
189
|
+
* `MAX_PAGE_LIMIT` (10,000), plus at most one DynamoDB page per shard,
|
|
190
|
+
* whatever the table holds.
|
|
191
|
+
*/
|
|
46
192
|
listSessions(options) {
|
|
47
|
-
return (0, list_sessions_1.listSessions)(this.context, options);
|
|
193
|
+
return (0, boundary_1.guardPublic)('history.listSessions', () => (0, list_sessions_1.listSessions)(this.context, options));
|
|
48
194
|
}
|
|
49
195
|
/**
|
|
50
196
|
* Recompute and repair a session's `messageCount` from the stored messages.
|
|
51
197
|
* A maintenance tool for external corruption; run it when the session is idle.
|
|
198
|
+
*
|
|
199
|
+
* Accepts: `sessionId` — validated, and an existing session.
|
|
200
|
+
* `options.signal` — aborts the reads.
|
|
201
|
+
*
|
|
202
|
+
* Returns: the count now stored, which is the number of messages a reader
|
|
203
|
+
* would see.
|
|
204
|
+
*
|
|
205
|
+
* Throws: `VALIDATION` for a malformed session id, an invalid `signal`,
|
|
206
|
+
* or an `options.<key>` this package does not read; `CONDITION_CONFLICT` when the
|
|
207
|
+
* session does not exist or stayed busy through every attempt;
|
|
208
|
+
* `FORMAT_UNSUPPORTED` for a message row a newer release wrote, and
|
|
209
|
+
* `VALIDATION` naming `message` for a row in the session's message key
|
|
210
|
+
* space that this adapter did not write, both of which `getMessages` refuses
|
|
211
|
+
* too — a count is a repair only while it agrees with the read;
|
|
212
|
+
* a classified AWS failure; `ABORTED`.
|
|
213
|
+
*
|
|
214
|
+
* Guarantees: safe on a live session — the write is pinned to the value the
|
|
215
|
+
* row held when the count was computed, so a concurrent append makes it
|
|
216
|
+
* recount instead of clobbering the increment.
|
|
52
217
|
*/
|
|
53
|
-
reconcileMessageCount(sessionId) {
|
|
54
|
-
return (0,
|
|
218
|
+
reconcileMessageCount(sessionId, options) {
|
|
219
|
+
return (0, boundary_1.guardPublic)('history.reconcileMessageCount', () => {
|
|
220
|
+
(0, collaborators_1.assertCancelOptions)(options);
|
|
221
|
+
return (0, reconcile_count_1.reconcileMessageCount)(this.context, sessionId, options?.signal);
|
|
222
|
+
});
|
|
55
223
|
}
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
224
|
+
/**
|
|
225
|
+
* Get a single-session LangChain adapter for `sessionId`.
|
|
226
|
+
*
|
|
227
|
+
* Accepts: `sessionId` — validated by the adapter's own constructor, the
|
|
228
|
+
* same rule every other method applies. `window.limit` — bounds what the
|
|
229
|
+
* adapter feeds the chain to the newest that many messages; validated the
|
|
230
|
+
* same way.
|
|
231
|
+
*
|
|
232
|
+
* Returns: an adapter implementing `BaseListChatMessageHistory`, which is
|
|
233
|
+
* what `RunnableWithMessageHistory` takes.
|
|
234
|
+
*
|
|
235
|
+
* Throws: `VALIDATION` naming `sessionId`, `window` for a window that is
|
|
236
|
+
* not an object, `window.<key>` for a key the adapter does not declare, or
|
|
237
|
+
* `limit` — raised by the constructed adapter, so a bad id or window fails
|
|
238
|
+
* here rather than on first use.
|
|
239
|
+
*/
|
|
240
|
+
forSession(sessionId, window) {
|
|
241
|
+
return new session_adapter_1.DynamoDBSessionChatMessageHistory(this, sessionId, window);
|
|
59
242
|
}
|
|
60
|
-
/**
|
|
243
|
+
/**
|
|
244
|
+
* Release owned resources.
|
|
245
|
+
*
|
|
246
|
+
* Accepts: nothing.
|
|
247
|
+
*
|
|
248
|
+
* Returns: nothing. Idempotent, and a no-op for a client the caller injected
|
|
249
|
+
* — that one is theirs to close.
|
|
250
|
+
*
|
|
251
|
+
* Throws: whatever a resource's own `destroy` raises — but only after every
|
|
252
|
+
* other one has been released, so a client that fails to close never strands
|
|
253
|
+
* the one behind it.
|
|
254
|
+
*/
|
|
61
255
|
destroy() {
|
|
62
|
-
this.
|
|
63
|
-
if (this.ownsClient)
|
|
64
|
-
this.ddbClient?.destroy();
|
|
256
|
+
this.shell.release();
|
|
65
257
|
}
|
|
66
258
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
* `s3
|
|
71
|
-
*
|
|
72
|
-
*
|
|
259
|
+
* Provision an S3 lifecycle expiration rule matching the configured TTL, so
|
|
260
|
+
* offloaded objects don't outlive their DynamoDB item forever.
|
|
261
|
+
*
|
|
262
|
+
* Accepts: nothing; the rule follows the configured `s3` and `ttl`. A no-op
|
|
263
|
+
* without both.
|
|
264
|
+
*
|
|
265
|
+
* Returns: nothing. Installing a rule that is already there is a no-op too.
|
|
266
|
+
*
|
|
267
|
+
* Throws: `VALIDATION` naming `s3.keyPrefix` on a rule-id collision;
|
|
268
|
+
* a classified AWS failure when the bucket's lifecycle cannot be read or written.
|
|
269
|
+
* @remarks Requires the bucket-level `s3:GetLifecycleConfiguration` /
|
|
270
|
+
* `s3:PutLifecycleConfiguration` permissions, broader than the object-level
|
|
271
|
+
* CRUD the rest of S3 offload needs — call it once during provisioning, not
|
|
272
|
+
* per request.
|
|
73
273
|
*/
|
|
74
274
|
async ensureS3LifecycleRule() {
|
|
75
|
-
|
|
76
|
-
return;
|
|
77
|
-
await this.context.offloader.ensureLifecycleRule((0, ttl_1.resolveTtlDaysCeil)(this.context.ttl));
|
|
275
|
+
return (0, boundary_1.guardPublic)('history.ensureS3LifecycleRule', () => this.shell.ensureLifecycleRule());
|
|
78
276
|
}
|
|
79
277
|
}
|
|
80
278
|
exports.DynamoDBChatMessageHistory = DynamoDBChatMessageHistory;
|
|
81
|
-
//# sourceMappingURL=chat-message-history.js.map
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how an append of any size commits all-or-nothing, as its caller sees it.
|
|
3
|
+
*
|
|
4
|
+
* One `TransactWriteItems` carries at most a hundred items and four megabytes,
|
|
5
|
+
* so a large append is several transactions, each writing its messages and the
|
|
6
|
+
* SESSION row's update together. When one of them fails the append is rolled
|
|
7
|
+
* back: committed chunks are deleted and their effect on the SESSION row
|
|
8
|
+
* reverted, and each S3 object is released only once no row can name it. An
|
|
9
|
+
* ambiguous failure is read back before anything is undone. This is also the
|
|
10
|
+
* one module that writes a message row, which is what lets a delete pin a
|
|
11
|
+
* message row to the SESSION row's `writeId`.
|
|
12
|
+
*/
|
|
13
|
+
import { type RowKey } from '../../shared/dynamodb/table-schema';
|
|
14
|
+
import type { SessionId, StorableMessages } from './parse';
|
|
15
|
+
import { type MessageRow } from './rows';
|
|
16
|
+
import { type SessionUpdateFields, type TtlAnchorResult } from './session';
|
|
17
|
+
import { type HistoryContext } from './setup';
|
|
18
|
+
/** One append, parsed: the session, its messages in stored form, and the session's ttl anchor. */
|
|
19
|
+
export interface AppendRequest {
|
|
20
|
+
readonly sessionId: SessionId;
|
|
21
|
+
readonly messages: StorableMessages;
|
|
22
|
+
/** The session's creation-anchored ttl, when the adapter has a ttl. */
|
|
23
|
+
readonly anchor: TtlAnchorResult | undefined;
|
|
24
|
+
readonly signal?: AbortSignal;
|
|
25
|
+
}
|
|
26
|
+
/** Shared per-append metadata applied to every chunk's session update. */
|
|
27
|
+
interface AppendFields {
|
|
28
|
+
now: string;
|
|
29
|
+
title?: string;
|
|
30
|
+
ttlTimestamp?: number;
|
|
31
|
+
forceTtlRefresh?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** An append cut into chunks, with the fields every chunk's SESSION update stamps. */
|
|
34
|
+
export interface ChunkedAppend {
|
|
35
|
+
readonly sessionId: SessionId;
|
|
36
|
+
readonly chunks: MessageRow[][];
|
|
37
|
+
readonly fields: AppendFields;
|
|
38
|
+
readonly signal?: AbortSignal;
|
|
39
|
+
}
|
|
40
|
+
/** A chunk that committed, retained so it can be rolled back on a later failure. */
|
|
41
|
+
interface CommittedChunk {
|
|
42
|
+
keys: RowKey[];
|
|
43
|
+
count: number;
|
|
44
|
+
}
|
|
45
|
+
/** How far a failed append got, which decides what its rollback undoes. */
|
|
46
|
+
export interface FailedAppend {
|
|
47
|
+
readonly committed: CommittedChunk[];
|
|
48
|
+
readonly trigger: Error;
|
|
49
|
+
/** True when the failing chunk's own outcome could not be read back. */
|
|
50
|
+
readonly uncertain: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Append messages to a session: encode them, cut them into transactions, and
|
|
54
|
+
* commit them all or undo what committed.
|
|
55
|
+
*
|
|
56
|
+
* Accepts: `request` — the parsed session and messages, the ttl anchor, and
|
|
57
|
+
* the caller's signal.
|
|
58
|
+
*
|
|
59
|
+
* Returns: nothing, once every chunk has committed.
|
|
60
|
+
*
|
|
61
|
+
* Throws: the first chunk's failure after the append is rolled back;
|
|
62
|
+
* `COMPENSATION_FAILED` when the rollback itself fails; whatever encoding a
|
|
63
|
+
* message throws, after this call's own uploads are released.
|
|
64
|
+
*/
|
|
65
|
+
export declare function appendMessages(context: HistoryContext, request: AppendRequest): Promise<void>;
|
|
66
|
+
/**
|
|
67
|
+
* Undo a failed batch. Always throws. S3 cleanup is split by commit status so
|
|
68
|
+
* no live row is ever left pointing at a deleted object: the never-committed
|
|
69
|
+
* suffix is cleaned immediately, the committed prefix only after its rows are
|
|
70
|
+
* confirmed deleted. If the rollback itself fails, the committed chunks' S3
|
|
71
|
+
* objects are deliberately left in place (their rows may survive) and it
|
|
72
|
+
* raises `COMPENSATION_FAILED` carrying both the trigger and the
|
|
73
|
+
* rollback error; otherwise it rethrows the trigger.
|
|
74
|
+
*
|
|
75
|
+
* `failure.uncertain` marks the failed chunk
|
|
76
|
+
* (`append.chunks[failure.committed.length]`) as one whose outcome could not be
|
|
77
|
+
* verified: its rows may be live, so its objects are leaked rather than
|
|
78
|
+
* deleted, while the never-attempted chunks after it are still cleaned.
|
|
79
|
+
*
|
|
80
|
+
* Accepts: `append` — the append that failed: its `sessionId`, its `chunks` in
|
|
81
|
+
* order, and the `fields.now` and `fields.title` its first chunk stamped on
|
|
82
|
+
* the session row. `failure.committed` — the chunks known to have landed, in
|
|
83
|
+
* order; empty means the very first chunk failed, and then the only thing to
|
|
84
|
+
* undo is the session row this call may have created. `failure.trigger` — the
|
|
85
|
+
* failure that started this. `failure.uncertain` — see above.
|
|
86
|
+
*
|
|
87
|
+
* Returns: never; the declared `Promise<never>` is the contract.
|
|
88
|
+
*
|
|
89
|
+
* Throws: `failure.trigger` when the rollback succeeded, `COMPENSATION_FAILED`
|
|
90
|
+
* when it did not.
|
|
91
|
+
*
|
|
92
|
+
* Guarantees: an object is deleted only once no row can reference it — the
|
|
93
|
+
* never-committed suffix immediately, the committed prefix only after its rows
|
|
94
|
+
* are confirmed gone, and an unverified chunk never. Storage is leaked in
|
|
95
|
+
* preference to leaving a live row pointing at a deleted object.
|
|
96
|
+
*
|
|
97
|
+
* Neither of its two log lines can stop it: both go through
|
|
98
|
+
* {@link reportStep}. Otherwise a throw from the first would skip the S3
|
|
99
|
+
* cleanup, the rollback, the count revert and the rethrow all at once, leaving
|
|
100
|
+
* every committed chunk in the table with `messageCount` still counting it,
|
|
101
|
+
* and handing the caller the logger's own error in place of the failure that
|
|
102
|
+
* started this. Announcing the rollback is not the rollback.
|
|
103
|
+
*/
|
|
104
|
+
export declare function compensate(context: HistoryContext, append: ChunkedAppend, failure: FailedAppend): Promise<never>;
|
|
105
|
+
/**
|
|
106
|
+
* Append message chunks with caller-observed atomicity. Each chunk commits its
|
|
107
|
+
* messages and count in one transaction; if a later chunk fails, every
|
|
108
|
+
* already-committed chunk is deleted and its count reverted, and the batch's
|
|
109
|
+
* S3 objects are cleaned once their rows are gone, restoring the pre-call
|
|
110
|
+
* state before the error is rethrown. Except on a failed rollback, which
|
|
111
|
+
* surfaces as `COMPENSATION_FAILED` and deliberately leaves the
|
|
112
|
+
* committed chunks' S3 objects behind, since their rows may survive.
|
|
113
|
+
*
|
|
114
|
+
* A `RETRY_EXHAUSTED` error is ambiguous — the transaction may have committed
|
|
115
|
+
* and lost its response — so the chunk is read back first: present means it
|
|
116
|
+
* committed (continue), absent means it did not (compensate), and a failed
|
|
117
|
+
* read compensates but leaks that chunk's objects rather than delete objects
|
|
118
|
+
* its possibly-live rows reference.
|
|
119
|
+
*
|
|
120
|
+
* Accepts: `append.sessionId` — the session every chunk writes to.
|
|
121
|
+
* `append.chunks` — in order, each already within the transaction's limits;
|
|
122
|
+
* no chunks is no work and no write. `append.fields` — the session update every
|
|
123
|
+
* chunk carries. `append.signal` — aborts between chunks.
|
|
124
|
+
*
|
|
125
|
+
* Returns: nothing, and only when every chunk is known to have committed.
|
|
126
|
+
*
|
|
127
|
+
* Throws: the first chunk's failure, after the rollback has restored the
|
|
128
|
+
* pre-call state; or `COMPENSATION_FAILED` carrying both that failure
|
|
129
|
+
* and the rollback's own, when the rollback could not finish.
|
|
130
|
+
*
|
|
131
|
+
* Guarantees: each message's S3 key carries its own ULID, so no two rows of any
|
|
132
|
+
* call can address the same object and the rollback's cleanup can never delete
|
|
133
|
+
* an object a surviving row still points at. What a caller observes is
|
|
134
|
+
* all-or-nothing; what the table holds is all-or-nothing only until a rollback
|
|
135
|
+
* fails, which is why that case is a distinct error and not a rethrow.
|
|
136
|
+
*/
|
|
137
|
+
export declare function appendChunks(context: HistoryContext, append: ChunkedAppend): Promise<void>;
|
|
138
|
+
/** Per-call retry seams (injected in tests to keep backoff instant). */
|
|
139
|
+
export interface ChunkRetryOptions {
|
|
140
|
+
rng?: () => number;
|
|
141
|
+
signal?: AbortSignal;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Atomically write a chunk of message items together with the session-metadata
|
|
145
|
+
* count update in one {@link https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_TransactWriteItems.html | TransactWriteItems}
|
|
146
|
+
* call, so `messageCount` can never disagree with the messages that landed. A
|
|
147
|
+
* single `ClientRequestToken` is used per attempt so a re-sent commit (e.g.
|
|
148
|
+
* after a lost response) is idempotent and never double-applies the count
|
|
149
|
+
* `ADD`. When `fields.forceTtlRefresh` is set, the session update carries a
|
|
150
|
+
* monotonic ConditionExpression (see session.ts); if — and only if —
|
|
151
|
+
* that specific condition loses a race against a concurrent caller who just
|
|
152
|
+
* healed the same anchor, this retries the identical chunk once with
|
|
153
|
+
* `forceTtlRefresh: false` (safe: `if_not_exists` then converges to whatever
|
|
154
|
+
* already won) rather than losing the message writes to a benign ttl race. A
|
|
155
|
+
* cancellation caused by any other item (a genuine message-row conflict) is
|
|
156
|
+
* not retried here — it propagates for the normal transient-conflict retry
|
|
157
|
+
* budget inside `withDynamoDBRetry` to handle, or to the caller otherwise.
|
|
158
|
+
*
|
|
159
|
+
* Accepts: `items` — one chunk, already within the transaction's limits.
|
|
160
|
+
* `fields` — the session-metadata update accompanying it; its `indexShards` and
|
|
161
|
+
* its `writeId` are taken from the adapter's context, never from the caller.
|
|
162
|
+
* `retry.signal` — aborts between attempts.
|
|
163
|
+
*
|
|
164
|
+
* Returns: nothing. The chunk and the count are committed together or not at
|
|
165
|
+
* all.
|
|
166
|
+
*
|
|
167
|
+
* Throws: whatever the transaction throws — including a
|
|
168
|
+
* `TransactionCanceledException` for a genuine conflict, after the retry budget
|
|
169
|
+
* is spent. The caller compensates; this function never partially succeeds.
|
|
170
|
+
*
|
|
171
|
+
* Guarantees: `messageCount` can never disagree with the messages that landed,
|
|
172
|
+
* because they land in one transaction. At most one extra attempt is spent on
|
|
173
|
+
* the benign ttl race, and it carries its own request token, so a retry can
|
|
174
|
+
* never double-apply the count — and its own deadline of
|
|
175
|
+
* `MAX_WRITE_LIFETIME_MS`, so the retrying stops while that token is
|
|
176
|
+
* still deduplicating rather than after it has expired. The SESSION row's
|
|
177
|
+
* `writeId` moves if and only if a message row was added: the update travels in
|
|
178
|
+
* the same transaction as the rows, and nothing else writes it.
|
|
179
|
+
*/
|
|
180
|
+
export declare function writeMessageChunk(context: HistoryContext, items: MessageRow[], fields: Omit<SessionUpdateFields, 'writeId'>, retry?: ChunkRetryOptions): Promise<void>;
|
|
181
|
+
/**
|
|
182
|
+
* Conservatively estimate a message row's stored size.
|
|
183
|
+
*
|
|
184
|
+
* Accepts: any message row, inline or offloaded — an offloaded one measures
|
|
185
|
+
* its S3 key, since that is what the row actually carries.
|
|
186
|
+
*
|
|
187
|
+
* Returns: an estimate at or above the real marshalled size. Erring high is the
|
|
188
|
+
* whole point: an underestimate builds a transaction DynamoDB refuses, and the
|
|
189
|
+
* cost of erring high is one extra transaction.
|
|
190
|
+
*
|
|
191
|
+
* Throws: nothing.
|
|
192
|
+
*/
|
|
193
|
+
export declare function estimateRowBytes(item: MessageRow): number;
|
|
194
|
+
/**
|
|
195
|
+
* Split message items into transaction-sized chunks.
|
|
196
|
+
*
|
|
197
|
+
* Accepts: `items` — in order; empty yields no chunks, so an append of nothing
|
|
198
|
+
* issues no write. `maxItems` and `maxBytes` — the transaction's two limits,
|
|
199
|
+
* both binding.
|
|
200
|
+
*
|
|
201
|
+
* Returns: the chunks, in order, each within both limits — except that a single
|
|
202
|
+
* item larger than `maxBytes` is placed alone rather than dropped: refusing it
|
|
203
|
+
* here would lose a message that DynamoDB might still accept, and if it does
|
|
204
|
+
* not, the transaction says so.
|
|
205
|
+
*
|
|
206
|
+
* Throws: nothing.
|
|
207
|
+
*
|
|
208
|
+
* Guarantees: order is preserved across chunks, so messages keep the order the
|
|
209
|
+
* caller wrote them in, which is the order their ULIDs already encode.
|
|
210
|
+
*/
|
|
211
|
+
export declare function chunkBySize(items: MessageRow[], maxItems: number, maxBytes: number): MessageRow[][];
|
|
212
|
+
export {};
|