@farukada/aws-langgraph-dynamodb-ts 0.2.2 → 0.3.1
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 +224 -512
- package/dist/checkpointer/actions/delete-thread.d.ts +7 -6
- package/dist/checkpointer/actions/delete-thread.d.ts.map +1 -1
- package/dist/checkpointer/actions/delete-thread.js +47 -152
- package/dist/checkpointer/actions/delete-thread.js.map +1 -1
- package/dist/checkpointer/actions/get-tuple.d.ts +6 -14
- package/dist/checkpointer/actions/get-tuple.d.ts.map +1 -1
- package/dist/checkpointer/actions/get-tuple.js +13 -166
- package/dist/checkpointer/actions/get-tuple.js.map +1 -1
- package/dist/checkpointer/actions/list.d.ts +10 -0
- package/dist/checkpointer/actions/list.d.ts.map +1 -0
- package/dist/checkpointer/actions/list.js +51 -0
- package/dist/checkpointer/actions/list.js.map +1 -0
- package/dist/checkpointer/actions/put-writes.d.ts +6 -6
- package/dist/checkpointer/actions/put-writes.d.ts.map +1 -1
- package/dist/checkpointer/actions/put-writes.js +26 -75
- package/dist/checkpointer/actions/put-writes.js.map +1 -1
- package/dist/checkpointer/actions/put.d.ts +6 -11
- package/dist/checkpointer/actions/put.d.ts.map +1 -1
- package/dist/checkpointer/actions/put.js +29 -161
- package/dist/checkpointer/actions/put.js.map +1 -1
- package/dist/checkpointer/internal/assemble.d.ts +10 -0
- package/dist/checkpointer/internal/assemble.d.ts.map +1 -0
- package/dist/checkpointer/internal/assemble.js +37 -0
- package/dist/checkpointer/internal/assemble.js.map +1 -0
- package/dist/checkpointer/internal/configurable.d.ts +13 -0
- package/dist/checkpointer/internal/configurable.d.ts.map +1 -0
- package/dist/checkpointer/internal/configurable.js +23 -0
- package/dist/checkpointer/internal/configurable.js.map +1 -0
- package/dist/checkpointer/internal/fetch.d.ts +10 -0
- package/dist/checkpointer/internal/fetch.d.ts.map +1 -0
- package/dist/checkpointer/internal/fetch.js +46 -0
- package/dist/checkpointer/internal/fetch.js.map +1 -0
- package/dist/checkpointer/internal/filter-match.d.ts +12 -0
- package/dist/checkpointer/internal/filter-match.d.ts.map +1 -0
- package/dist/checkpointer/internal/filter-match.js +14 -0
- package/dist/checkpointer/internal/filter-match.js.map +1 -0
- package/dist/checkpointer/internal/item-reader.d.ts +10 -0
- package/dist/checkpointer/internal/item-reader.d.ts.map +1 -0
- package/dist/checkpointer/internal/item-reader.js +26 -0
- package/dist/checkpointer/internal/item-reader.js.map +1 -0
- package/dist/checkpointer/internal/item-writer.d.ts +14 -0
- package/dist/checkpointer/internal/item-writer.d.ts.map +1 -0
- package/dist/checkpointer/internal/item-writer.js +68 -0
- package/dist/checkpointer/internal/item-writer.js.map +1 -0
- package/dist/checkpointer/internal/keys.d.ts +15 -0
- package/dist/checkpointer/internal/keys.d.ts.map +1 -0
- package/dist/checkpointer/internal/keys.js +52 -0
- package/dist/checkpointer/internal/keys.js.map +1 -0
- package/dist/checkpointer/internal/query.d.ts +16 -0
- package/dist/checkpointer/internal/query.d.ts.map +1 -0
- package/dist/checkpointer/internal/query.js +33 -0
- package/dist/checkpointer/internal/query.js.map +1 -0
- package/dist/checkpointer/internal/setup.d.ts +31 -0
- package/dist/checkpointer/internal/setup.d.ts.map +1 -0
- package/dist/checkpointer/internal/setup.js +29 -0
- package/dist/checkpointer/internal/setup.js.map +1 -0
- package/dist/checkpointer/internal/validation.d.ts +9 -0
- package/dist/checkpointer/internal/validation.d.ts.map +1 -0
- package/dist/checkpointer/internal/validation.js +28 -0
- package/dist/checkpointer/internal/validation.js.map +1 -0
- package/dist/checkpointer/saver.d.ts +21 -0
- package/dist/checkpointer/saver.d.ts.map +1 -0
- package/dist/checkpointer/saver.js +49 -0
- package/dist/checkpointer/saver.js.map +1 -0
- package/dist/checkpointer/types.d.ts +43 -0
- package/dist/checkpointer/types.d.ts.map +1 -0
- package/dist/{store/types/index.js → checkpointer/types.js} +1 -1
- package/dist/checkpointer/types.js.map +1 -0
- package/dist/factory/factory.d.ts +41 -0
- package/dist/factory/factory.d.ts.map +1 -0
- package/dist/factory/factory.js +49 -0
- package/dist/factory/factory.js.map +1 -0
- package/dist/history/actions/add-messages.d.ts +12 -7
- package/dist/history/actions/add-messages.d.ts.map +1 -1
- package/dist/history/actions/add-messages.js +50 -48
- package/dist/history/actions/add-messages.js.map +1 -1
- package/dist/history/actions/clear.d.ts +5 -11
- package/dist/history/actions/clear.d.ts.map +1 -1
- package/dist/history/actions/clear.js +28 -62
- package/dist/history/actions/clear.js.map +1 -1
- package/dist/history/actions/get-messages.d.ts +6 -13
- package/dist/history/actions/get-messages.d.ts.map +1 -1
- package/dist/history/actions/get-messages.js +23 -59
- package/dist/history/actions/get-messages.js.map +1 -1
- package/dist/history/actions/list-sessions.d.ts +6 -22
- package/dist/history/actions/list-sessions.d.ts.map +1 -1
- package/dist/history/actions/list-sessions.js +26 -69
- package/dist/history/actions/list-sessions.js.map +1 -1
- package/dist/history/actions/reconcile-count.d.ts +10 -0
- package/dist/history/actions/reconcile-count.d.ts.map +1 -0
- package/dist/history/actions/reconcile-count.js +39 -0
- package/dist/history/actions/reconcile-count.js.map +1 -0
- package/dist/history/chat-message-history.d.ts +36 -0
- package/dist/history/chat-message-history.d.ts.map +1 -0
- package/dist/history/chat-message-history.js +67 -0
- package/dist/history/chat-message-history.js.map +1 -0
- package/dist/history/internal/append-saga.d.ts +17 -0
- package/dist/history/internal/append-saga.d.ts.map +1 -0
- package/dist/history/internal/append-saga.js +94 -0
- package/dist/history/internal/append-saga.js.map +1 -0
- package/dist/history/internal/item-mapper.d.ts +12 -0
- package/dist/history/internal/item-mapper.d.ts.map +1 -0
- package/dist/history/internal/item-mapper.js +33 -0
- package/dist/history/internal/item-mapper.js.map +1 -0
- package/dist/history/internal/keys.d.ts +9 -0
- package/dist/history/internal/keys.d.ts.map +1 -0
- package/dist/history/internal/keys.js +22 -0
- package/dist/history/internal/keys.js.map +1 -0
- package/dist/history/internal/message-chunker.d.ts +14 -0
- package/dist/history/internal/message-chunker.d.ts.map +1 -0
- package/dist/history/internal/message-chunker.js +60 -0
- package/dist/history/internal/message-chunker.js.map +1 -0
- package/dist/history/internal/message-transaction.d.ts +17 -0
- package/dist/history/internal/message-transaction.d.ts.map +1 -0
- package/dist/history/internal/message-transaction.js +27 -0
- package/dist/history/internal/message-transaction.js.map +1 -0
- package/dist/history/internal/query.d.ts +6 -0
- package/dist/history/internal/query.d.ts.map +1 -0
- package/dist/history/internal/query.js +28 -0
- package/dist/history/internal/query.js.map +1 -0
- package/dist/history/internal/session-update.d.ts +20 -0
- package/dist/history/internal/session-update.d.ts.map +1 -0
- package/dist/history/internal/session-update.js +46 -0
- package/dist/history/internal/session-update.js.map +1 -0
- package/dist/history/internal/setup.d.ts +28 -0
- package/dist/history/internal/setup.d.ts.map +1 -0
- package/dist/history/internal/setup.js +27 -0
- package/dist/history/internal/setup.js.map +1 -0
- package/dist/history/internal/title-generator.d.ts +7 -0
- package/dist/history/internal/title-generator.d.ts.map +1 -0
- package/dist/history/internal/title-generator.js +16 -0
- package/dist/history/internal/title-generator.js.map +1 -0
- package/dist/history/internal/ttl-anchor.d.ts +12 -0
- package/dist/history/internal/ttl-anchor.d.ts.map +1 -0
- package/dist/history/internal/ttl-anchor.js +26 -0
- package/dist/history/internal/ttl-anchor.js.map +1 -0
- package/dist/history/session-adapter.d.ts +10 -26
- package/dist/history/session-adapter.d.ts.map +1 -1
- package/dist/history/session-adapter.js +15 -57
- package/dist/history/session-adapter.js.map +1 -1
- package/dist/history/types.d.ts +36 -0
- package/dist/history/types.d.ts.map +1 -0
- package/dist/history/types.js +3 -0
- package/dist/history/types.js.map +1 -0
- package/dist/index.d.ts +18 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -16
- package/dist/index.js.map +1 -1
- package/dist/shared/clock.d.ts +3 -0
- package/dist/shared/clock.d.ts.map +1 -0
- package/dist/shared/clock.js +8 -0
- package/dist/shared/clock.js.map +1 -0
- package/dist/shared/codec/codec.d.ts +44 -0
- package/dist/shared/codec/codec.d.ts.map +1 -0
- package/dist/shared/codec/codec.js +44 -0
- package/dist/shared/codec/codec.js.map +1 -0
- package/dist/shared/codec/compression.d.ts +25 -0
- package/dist/shared/codec/compression.d.ts.map +1 -0
- package/dist/shared/codec/compression.js +49 -0
- package/dist/shared/codec/compression.js.map +1 -0
- package/dist/shared/codec/descriptor-keys.d.ts +4 -0
- package/dist/shared/codec/descriptor-keys.d.ts.map +1 -0
- package/dist/shared/codec/descriptor-keys.js +14 -0
- package/dist/shared/codec/descriptor-keys.js.map +1 -0
- package/dist/shared/codec/json-serde.d.ts +8 -0
- package/dist/shared/codec/json-serde.d.ts.map +1 -0
- package/dist/shared/codec/json-serde.js +18 -0
- package/dist/shared/codec/json-serde.js.map +1 -0
- package/dist/shared/codec/s3/client.d.ts +6 -0
- package/dist/shared/codec/s3/client.d.ts.map +1 -0
- package/dist/shared/codec/s3/client.js +18 -0
- package/dist/shared/codec/s3/client.js.map +1 -0
- package/dist/shared/codec/s3/config.d.ts +16 -0
- package/dist/shared/codec/s3/config.d.ts.map +1 -0
- package/dist/shared/codec/s3/config.js +14 -0
- package/dist/shared/codec/s3/config.js.map +1 -0
- package/dist/shared/codec/s3/delete.d.ts +8 -0
- package/dist/shared/codec/s3/delete.d.ts.map +1 -0
- package/dist/shared/codec/s3/delete.js +29 -0
- package/dist/shared/codec/s3/delete.js.map +1 -0
- package/dist/shared/codec/s3/lifecycle.d.ts +8 -0
- package/dist/shared/codec/s3/lifecycle.d.ts.map +1 -0
- package/dist/shared/codec/s3/lifecycle.js +47 -0
- package/dist/shared/codec/s3/lifecycle.js.map +1 -0
- package/dist/shared/codec/s3/offloader.d.ts +33 -0
- package/dist/shared/codec/s3/offloader.d.ts.map +1 -0
- package/dist/shared/codec/s3/offloader.js +80 -0
- package/dist/shared/codec/s3/offloader.js.map +1 -0
- package/dist/shared/codec/s3/orphans.d.ts +16 -0
- package/dist/shared/codec/s3/orphans.d.ts.map +1 -0
- package/dist/shared/codec/s3/orphans.js +73 -0
- package/dist/shared/codec/s3/orphans.js.map +1 -0
- package/dist/shared/codec/s3/read-write.d.ts +14 -0
- package/dist/shared/codec/s3/read-write.d.ts.map +1 -0
- package/dist/shared/codec/s3/read-write.js +42 -0
- package/dist/shared/codec/s3/read-write.js.map +1 -0
- package/dist/shared/constants.d.ts +37 -0
- package/dist/shared/constants.d.ts.map +1 -0
- package/dist/shared/constants.js +40 -0
- package/dist/shared/constants.js.map +1 -0
- package/dist/shared/dynamodb/backoff.d.ts +15 -0
- package/dist/shared/dynamodb/backoff.d.ts.map +1 -0
- package/dist/shared/dynamodb/backoff.js +48 -0
- package/dist/shared/dynamodb/backoff.js.map +1 -0
- package/dist/shared/dynamodb/batch-write.d.ts +10 -0
- package/dist/shared/dynamodb/batch-write.d.ts.map +1 -0
- package/dist/shared/dynamodb/batch-write.js +17 -0
- package/dist/shared/dynamodb/batch-write.js.map +1 -0
- package/dist/shared/dynamodb/client.d.ts +21 -0
- package/dist/shared/dynamodb/client.d.ts.map +1 -0
- package/dist/shared/dynamodb/client.js +19 -0
- package/dist/shared/dynamodb/client.js.map +1 -0
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +15 -0
- package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +1 -0
- package/dist/shared/dynamodb/drain-unprocessed.js +35 -0
- package/dist/shared/dynamodb/drain-unprocessed.js.map +1 -0
- package/dist/shared/dynamodb/paginate-core.d.ts +22 -0
- package/dist/shared/dynamodb/paginate-core.d.ts.map +1 -0
- package/dist/shared/dynamodb/paginate-core.js +52 -0
- package/dist/shared/dynamodb/paginate-core.js.map +1 -0
- package/dist/shared/dynamodb/paginate.d.ts +15 -0
- package/dist/shared/dynamodb/paginate.d.ts.map +1 -0
- package/dist/shared/dynamodb/paginate.js +20 -0
- package/dist/shared/dynamodb/paginate.js.map +1 -0
- package/dist/shared/dynamodb/retry-classifier.d.ts +9 -0
- package/dist/shared/dynamodb/retry-classifier.d.ts.map +1 -0
- package/dist/shared/dynamodb/retry-classifier.js +75 -0
- package/dist/shared/dynamodb/retry-classifier.js.map +1 -0
- package/dist/shared/dynamodb/retry.d.ts +18 -0
- package/dist/shared/dynamodb/retry.d.ts.map +1 -0
- package/dist/shared/dynamodb/retry.js +53 -0
- package/dist/shared/dynamodb/retry.js.map +1 -0
- package/dist/shared/dynamodb/scan.d.ts +15 -0
- package/dist/shared/dynamodb/scan.d.ts.map +1 -0
- package/dist/shared/dynamodb/scan.js +20 -0
- package/dist/shared/dynamodb/scan.js.map +1 -0
- package/dist/shared/dynamodb/types.d.ts +24 -0
- package/dist/shared/dynamodb/types.d.ts.map +1 -0
- package/dist/shared/dynamodb/types.js +3 -0
- package/dist/shared/dynamodb/types.js.map +1 -0
- package/dist/shared/errors/base-error.d.ts +22 -0
- package/dist/shared/errors/base-error.d.ts.map +1 -0
- package/dist/shared/errors/base-error.js +28 -0
- package/dist/shared/errors/base-error.js.map +1 -0
- package/dist/shared/errors/error-code.d.ts +13 -0
- package/dist/shared/errors/error-code.d.ts.map +1 -0
- package/dist/shared/errors/error-code.js +17 -0
- package/dist/shared/errors/error-code.js.map +1 -0
- package/dist/shared/errors/errors.d.ts +47 -0
- package/dist/shared/errors/errors.d.ts.map +1 -0
- package/dist/shared/errors/errors.js +82 -0
- package/dist/shared/errors/errors.js.map +1 -0
- package/dist/shared/errors/wrap-error.d.ts +16 -0
- package/dist/shared/errors/wrap-error.d.ts.map +1 -0
- package/dist/shared/errors/wrap-error.js +30 -0
- package/dist/shared/errors/wrap-error.js.map +1 -0
- package/dist/shared/logging/logger.d.ts +14 -0
- package/dist/shared/logging/logger.d.ts.map +1 -0
- package/dist/shared/logging/logger.js +16 -0
- package/dist/shared/logging/logger.js.map +1 -0
- package/dist/shared/logging/redaction.d.ts +19 -0
- package/dist/shared/logging/redaction.d.ts.map +1 -0
- package/dist/shared/logging/redaction.js +67 -0
- package/dist/shared/logging/redaction.js.map +1 -0
- package/dist/shared/options.d.ts +32 -0
- package/dist/shared/options.d.ts.map +1 -0
- package/dist/shared/options.js +3 -0
- package/dist/shared/options.js.map +1 -0
- package/dist/shared/ulid.d.ts +10 -0
- package/dist/shared/ulid.d.ts.map +1 -0
- package/dist/shared/ulid.js +65 -0
- package/dist/shared/ulid.js.map +1 -0
- package/dist/shared/validation/primitives.d.ts +17 -0
- package/dist/shared/validation/primitives.d.ts.map +1 -0
- package/dist/shared/validation/primitives.js +71 -0
- package/dist/shared/validation/primitives.js.map +1 -0
- package/dist/shared/validation/ttl.d.ts +16 -0
- package/dist/shared/validation/ttl.d.ts.map +1 -0
- package/dist/shared/validation/ttl.js +26 -0
- package/dist/shared/validation/ttl.js.map +1 -0
- package/dist/store/actions/get.d.ts +5 -0
- package/dist/store/actions/get.d.ts.map +1 -0
- package/dist/store/actions/get.js +21 -0
- package/dist/store/actions/get.js.map +1 -0
- package/dist/store/actions/list-namespaces.d.ts +9 -0
- package/dist/store/actions/list-namespaces.d.ts.map +1 -0
- package/dist/store/actions/list-namespaces.js +46 -0
- package/dist/store/actions/list-namespaces.js.map +1 -0
- package/dist/store/actions/put.d.ts +11 -0
- package/dist/store/actions/put.d.ts.map +1 -0
- package/dist/store/actions/put.js +81 -0
- package/dist/store/actions/put.js.map +1 -0
- package/dist/store/actions/reconcile-vector-index.d.ts +17 -0
- package/dist/store/actions/reconcile-vector-index.d.ts.map +1 -0
- package/dist/store/actions/reconcile-vector-index.js +27 -0
- package/dist/store/actions/reconcile-vector-index.js.map +1 -0
- package/dist/store/actions/search.d.ts +10 -0
- package/dist/store/actions/search.d.ts.map +1 -0
- package/dist/store/actions/search.js +72 -0
- package/dist/store/actions/search.js.map +1 -0
- package/dist/store/internal/filter.d.ts +10 -0
- package/dist/store/internal/filter.d.ts.map +1 -0
- package/dist/store/internal/filter.js +37 -0
- package/dist/store/internal/filter.js.map +1 -0
- package/dist/store/internal/index-reconcile.d.ts +22 -0
- package/dist/store/internal/index-reconcile.d.ts.map +1 -0
- package/dist/store/internal/index-reconcile.js +68 -0
- package/dist/store/internal/index-reconcile.js.map +1 -0
- package/dist/store/internal/index-sync.d.ts +11 -0
- package/dist/store/internal/index-sync.d.ts.map +1 -0
- package/dist/store/internal/index-sync.js +26 -0
- package/dist/store/internal/index-sync.js.map +1 -0
- package/dist/store/internal/item-mapper.d.ts +23 -0
- package/dist/store/internal/item-mapper.d.ts.map +1 -0
- package/dist/store/internal/item-mapper.js +51 -0
- package/dist/store/internal/item-mapper.js.map +1 -0
- package/dist/store/internal/keys.d.ts +18 -0
- package/dist/store/internal/keys.d.ts.map +1 -0
- package/dist/store/internal/keys.js +36 -0
- package/dist/store/internal/keys.js.map +1 -0
- package/dist/store/internal/namespace-match.d.ts +12 -0
- package/dist/store/internal/namespace-match.d.ts.map +1 -0
- package/dist/store/internal/namespace-match.js +41 -0
- package/dist/store/internal/namespace-match.js.map +1 -0
- package/dist/store/internal/query.d.ts +6 -0
- package/dist/store/internal/query.d.ts.map +1 -0
- package/dist/store/internal/query.js +32 -0
- package/dist/store/internal/query.js.map +1 -0
- package/dist/store/internal/ranker.d.ts +13 -0
- package/dist/store/internal/ranker.d.ts.map +1 -0
- package/dist/store/internal/ranker.js +29 -0
- package/dist/store/internal/ranker.js.map +1 -0
- package/dist/store/internal/semantic-search.d.ts +13 -0
- package/dist/store/internal/semantic-search.d.ts.map +1 -0
- package/dist/store/internal/semantic-search.js +47 -0
- package/dist/store/internal/semantic-search.js.map +1 -0
- package/dist/store/internal/setup.d.ts +31 -0
- package/dist/store/internal/setup.d.ts.map +1 -0
- package/dist/store/internal/setup.js +29 -0
- package/dist/store/internal/setup.js.map +1 -0
- package/dist/store/internal/validation.d.ts +7 -0
- package/dist/store/internal/validation.d.ts.map +1 -0
- package/dist/store/internal/validation.js +26 -0
- package/dist/store/internal/validation.js.map +1 -0
- package/dist/store/store.d.ts +24 -0
- package/dist/store/store.d.ts.map +1 -0
- package/dist/store/store.js +58 -0
- package/dist/store/store.js.map +1 -0
- package/dist/store/types.d.ts +28 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +3 -0
- package/dist/store/types.js.map +1 -0
- package/dist/store/vector-backend.d.ts +27 -0
- package/dist/store/vector-backend.d.ts.map +1 -0
- package/dist/store/vector-backend.js +3 -0
- package/dist/store/vector-backend.js.map +1 -0
- package/package.json +21 -22
- package/dist/checkpointer/actions/index.d.ts +0 -5
- package/dist/checkpointer/actions/index.d.ts.map +0 -1
- package/dist/checkpointer/actions/index.js +0 -21
- package/dist/checkpointer/actions/index.js.map +0 -1
- package/dist/checkpointer/actions/validate-configurable.d.ts +0 -10
- package/dist/checkpointer/actions/validate-configurable.d.ts.map +0 -1
- package/dist/checkpointer/actions/validate-configurable.js +0 -39
- package/dist/checkpointer/actions/validate-configurable.js.map +0 -1
- package/dist/checkpointer/actions/writer.d.ts +0 -52
- package/dist/checkpointer/actions/writer.d.ts.map +0 -1
- package/dist/checkpointer/actions/writer.js +0 -109
- package/dist/checkpointer/actions/writer.js.map +0 -1
- package/dist/checkpointer/index.d.ts +0 -118
- package/dist/checkpointer/index.d.ts.map +0 -1
- package/dist/checkpointer/index.js +0 -393
- package/dist/checkpointer/index.js.map +0 -1
- package/dist/checkpointer/types/index.d.ts +0 -232
- package/dist/checkpointer/types/index.d.ts.map +0 -1
- package/dist/checkpointer/types/index.js +0 -13
- package/dist/checkpointer/types/index.js.map +0 -1
- package/dist/checkpointer/utils/deserialization.d.ts +0 -20
- package/dist/checkpointer/utils/deserialization.d.ts.map +0 -1
- package/dist/checkpointer/utils/deserialization.js +0 -81
- package/dist/checkpointer/utils/deserialization.js.map +0 -1
- package/dist/checkpointer/utils/index.d.ts +0 -7
- package/dist/checkpointer/utils/index.d.ts.map +0 -1
- package/dist/checkpointer/utils/index.js +0 -27
- package/dist/checkpointer/utils/index.js.map +0 -1
- package/dist/checkpointer/utils/validation.d.ts +0 -48
- package/dist/checkpointer/utils/validation.d.ts.map +0 -1
- package/dist/checkpointer/utils/validation.js +0 -235
- package/dist/checkpointer/utils/validation.js.map +0 -1
- package/dist/factory.d.ts +0 -153
- package/dist/factory.d.ts.map +0 -1
- package/dist/factory.js +0 -206
- package/dist/factory.js.map +0 -1
- package/dist/history/actions/add-message.d.ts +0 -10
- package/dist/history/actions/add-message.d.ts.map +0 -1
- package/dist/history/actions/add-message.js +0 -24
- package/dist/history/actions/add-message.js.map +0 -1
- package/dist/history/actions/index.d.ts +0 -9
- package/dist/history/actions/index.d.ts.map +0 -1
- package/dist/history/actions/index.js +0 -17
- package/dist/history/actions/index.js.map +0 -1
- package/dist/history/index.d.ts +0 -118
- package/dist/history/index.d.ts.map +0 -1
- package/dist/history/index.js +0 -179
- package/dist/history/index.js.map +0 -1
- package/dist/history/types/index.d.ts +0 -184
- package/dist/history/types/index.d.ts.map +0 -1
- package/dist/history/types/index.js +0 -7
- package/dist/history/types/index.js.map +0 -1
- package/dist/history/utils/index.d.ts +0 -9
- package/dist/history/utils/index.d.ts.map +0 -1
- package/dist/history/utils/index.js +0 -27
- package/dist/history/utils/index.js.map +0 -1
- package/dist/history/utils/optimistic-retry.d.ts +0 -31
- package/dist/history/utils/optimistic-retry.d.ts.map +0 -1
- package/dist/history/utils/optimistic-retry.js +0 -74
- package/dist/history/utils/optimistic-retry.js.map +0 -1
- package/dist/history/utils/title-generator.d.ts +0 -12
- package/dist/history/utils/title-generator.d.ts.map +0 -1
- package/dist/history/utils/title-generator.js +0 -57
- package/dist/history/utils/title-generator.js.map +0 -1
- package/dist/history/utils/update-expression-builder.d.ts +0 -55
- package/dist/history/utils/update-expression-builder.d.ts.map +0 -1
- package/dist/history/utils/update-expression-builder.js +0 -112
- package/dist/history/utils/update-expression-builder.js.map +0 -1
- package/dist/history/utils/validation.d.ts +0 -68
- package/dist/history/utils/validation.d.ts.map +0 -1
- package/dist/history/utils/validation.js +0 -213
- package/dist/history/utils/validation.js.map +0 -1
- package/dist/shared/index.d.ts +0 -5
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js +0 -21
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/utils/batch-write.d.ts +0 -74
- package/dist/shared/utils/batch-write.d.ts.map +0 -1
- package/dist/shared/utils/batch-write.js +0 -110
- package/dist/shared/utils/batch-write.js.map +0 -1
- package/dist/shared/utils/client-factory.d.ts +0 -25
- package/dist/shared/utils/client-factory.d.ts.map +0 -1
- package/dist/shared/utils/client-factory.js +0 -23
- package/dist/shared/utils/client-factory.js.map +0 -1
- package/dist/shared/utils/compressor.d.ts +0 -66
- package/dist/shared/utils/compressor.d.ts.map +0 -1
- package/dist/shared/utils/compressor.js +0 -133
- package/dist/shared/utils/compressor.js.map +0 -1
- package/dist/shared/utils/constants.d.ts +0 -13
- package/dist/shared/utils/constants.d.ts.map +0 -1
- package/dist/shared/utils/constants.js +0 -35
- package/dist/shared/utils/constants.js.map +0 -1
- package/dist/shared/utils/index.d.ts +0 -14
- package/dist/shared/utils/index.d.ts.map +0 -1
- package/dist/shared/utils/index.js +0 -30
- package/dist/shared/utils/index.js.map +0 -1
- package/dist/shared/utils/logger.d.ts +0 -75
- package/dist/shared/utils/logger.d.ts.map +0 -1
- package/dist/shared/utils/logger.js +0 -148
- package/dist/shared/utils/logger.js.map +0 -1
- package/dist/shared/utils/retry.d.ts +0 -26
- package/dist/shared/utils/retry.d.ts.map +0 -1
- package/dist/shared/utils/retry.js +0 -169
- package/dist/shared/utils/retry.js.map +0 -1
- package/dist/shared/utils/s3-offloader.d.ts +0 -153
- package/dist/shared/utils/s3-offloader.d.ts.map +0 -1
- package/dist/shared/utils/s3-offloader.js +0 -281
- package/dist/shared/utils/s3-offloader.js.map +0 -1
- package/dist/shared/utils/s3-orphans.d.ts +0 -16
- package/dist/shared/utils/s3-orphans.d.ts.map +0 -1
- package/dist/shared/utils/s3-orphans.js +0 -79
- package/dist/shared/utils/s3-orphans.js.map +0 -1
- package/dist/shared/utils/sleep.d.ts +0 -48
- package/dist/shared/utils/sleep.d.ts.map +0 -1
- package/dist/shared/utils/sleep.js +0 -82
- package/dist/shared/utils/sleep.js.map +0 -1
- package/dist/shared/utils/ttl.d.ts +0 -24
- package/dist/shared/utils/ttl.d.ts.map +0 -1
- package/dist/shared/utils/ttl.js +0 -43
- package/dist/shared/utils/ttl.js.map +0 -1
- package/dist/store/actions/get-operation.d.ts +0 -11
- package/dist/store/actions/get-operation.d.ts.map +0 -1
- package/dist/store/actions/get-operation.js +0 -42
- package/dist/store/actions/get-operation.js.map +0 -1
- package/dist/store/actions/index.d.ts +0 -5
- package/dist/store/actions/index.d.ts.map +0 -1
- package/dist/store/actions/index.js +0 -21
- package/dist/store/actions/index.js.map +0 -1
- package/dist/store/actions/list-namespaces-operation.d.ts +0 -10
- package/dist/store/actions/list-namespaces-operation.d.ts.map +0 -1
- package/dist/store/actions/list-namespaces-operation.js +0 -227
- package/dist/store/actions/list-namespaces-operation.js.map +0 -1
- package/dist/store/actions/put-operation.d.ts +0 -9
- package/dist/store/actions/put-operation.d.ts.map +0 -1
- package/dist/store/actions/put-operation.js +0 -107
- package/dist/store/actions/put-operation.js.map +0 -1
- package/dist/store/actions/search-operation.d.ts +0 -17
- package/dist/store/actions/search-operation.d.ts.map +0 -1
- package/dist/store/actions/search-operation.js +0 -203
- package/dist/store/actions/search-operation.js.map +0 -1
- package/dist/store/index.d.ts +0 -82
- package/dist/store/index.d.ts.map +0 -1
- package/dist/store/index.js +0 -172
- package/dist/store/index.js.map +0 -1
- package/dist/store/types/index.d.ts +0 -131
- package/dist/store/types/index.d.ts.map +0 -1
- package/dist/store/types/index.js.map +0 -1
- package/dist/store/utils/filter.d.ts +0 -16
- package/dist/store/utils/filter.d.ts.map +0 -1
- package/dist/store/utils/filter.js +0 -133
- package/dist/store/utils/filter.js.map +0 -1
- package/dist/store/utils/index.d.ts +0 -7
- package/dist/store/utils/index.d.ts.map +0 -1
- package/dist/store/utils/index.js +0 -27
- package/dist/store/utils/index.js.map +0 -1
- package/dist/store/utils/validation.d.ts +0 -61
- package/dist/store/utils/validation.d.ts.map +0 -1
- package/dist/store/utils/validation.js +0 -260
- package/dist/store/utils/validation.js.map +0 -1
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Optimistic-concurrency retry helper shared by addMessage / addMessages.
|
|
4
|
-
*
|
|
5
|
-
* These actions read the current messageCount, then run a transaction that writes
|
|
6
|
-
* new items and updates the counter with a ConditionExpression. On concurrent
|
|
7
|
-
* modification the condition fails; we re-read and retry up to N times.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MAX_OPTIMISTIC_RETRIES = void 0;
|
|
11
|
-
exports.isConditionalCheckFailure = isConditionalCheckFailure;
|
|
12
|
-
exports.withOptimisticRetry = withOptimisticRetry;
|
|
13
|
-
exports.MAX_OPTIMISTIC_RETRIES = 5;
|
|
14
|
-
/**
|
|
15
|
-
* Returns true for errors that indicate an optimistic-lock conflict that is
|
|
16
|
-
* safe to retry — either a bare `ConditionalCheckFailedException`, or a
|
|
17
|
-
* `TransactionCanceledException` where every reported `CancellationReason` is
|
|
18
|
-
* either `ConditionalCheckFailed` or `None`.
|
|
19
|
-
*
|
|
20
|
-
* DynamoDB's `CancellationReasons` array pairs 1:1 with the TransactItems it
|
|
21
|
-
* was handed: participants that did not block the transaction report `None`.
|
|
22
|
-
* Mixed-outcome cases — a `ConditionalCheckFailed` in item 0 alongside a
|
|
23
|
-
* `ValidationError` or `ItemCollectionSizeLimitExceeded` in item 1 — are
|
|
24
|
-
* permanent: retrying the whole transaction will never resolve the permanent
|
|
25
|
-
* sub-reason, so we must propagate instead of looping.
|
|
26
|
-
*/
|
|
27
|
-
function isConditionalCheckFailure(err) {
|
|
28
|
-
if (!err || typeof err !== 'object')
|
|
29
|
-
return false;
|
|
30
|
-
const e = err;
|
|
31
|
-
if (e.name === 'ConditionalCheckFailedException')
|
|
32
|
-
return true;
|
|
33
|
-
if (e.name === 'TransactionCanceledException' && Array.isArray(e.CancellationReasons)) {
|
|
34
|
-
const reasons = e.CancellationReasons;
|
|
35
|
-
if (reasons.length === 0)
|
|
36
|
-
return false;
|
|
37
|
-
// Need at least one ConditionalCheckFailed (otherwise nothing suggests the
|
|
38
|
-
// transaction will differ on retry) and no permanent sub-reason mixed in.
|
|
39
|
-
let sawConditionalFailure = false;
|
|
40
|
-
for (const r of reasons) {
|
|
41
|
-
const code = r?.Code;
|
|
42
|
-
if (code === 'ConditionalCheckFailed') {
|
|
43
|
-
sawConditionalFailure = true;
|
|
44
|
-
}
|
|
45
|
-
else if (code && code !== 'None') {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return sawConditionalFailure;
|
|
50
|
-
}
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Run `fn` until it succeeds or until MAX_OPTIMISTIC_RETRIES attempts exhaust.
|
|
55
|
-
*
|
|
56
|
-
* - On conditional-check failure (any attempt but the last), `fn` is re-invoked.
|
|
57
|
-
* - On any other error, the error is re-thrown immediately.
|
|
58
|
-
* - On exhaustion, a labelled error is thrown so the caller can identify it.
|
|
59
|
-
*/
|
|
60
|
-
async function withOptimisticRetry(label, fn) {
|
|
61
|
-
for (let attempt = 0; attempt < exports.MAX_OPTIMISTIC_RETRIES; attempt++) {
|
|
62
|
-
try {
|
|
63
|
-
return await fn(attempt);
|
|
64
|
-
}
|
|
65
|
-
catch (err) {
|
|
66
|
-
if (isConditionalCheckFailure(err) && attempt < exports.MAX_OPTIMISTIC_RETRIES - 1) {
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
throw err;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
throw new Error(`${label} failed after ${exports.MAX_OPTIMISTIC_RETRIES} optimistic-lock retries`);
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=optimistic-retry.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optimistic-retry.js","sourceRoot":"","sources":["../../../src/history/utils/optimistic-retry.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AC;QAC3B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,yBAAyB,CAAC,GAAG,CAAC,IAAI,OAAO,GAAG,8BAAsB,GAAG,CAAC,EAAE,CAAC;gBAC3E,SAAS;YACX,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,iBAAiB,8BAAsB,0BAA0B,CAAC,CAAC;AAC7F,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Title generation utilities for chat sessions
|
|
3
|
-
*/
|
|
4
|
-
import { BaseMessage } from '@langchain/core/messages';
|
|
5
|
-
/**
|
|
6
|
-
* Generate a session title from the first message
|
|
7
|
-
*
|
|
8
|
-
* @param message - The first message in the session
|
|
9
|
-
* @returns A generated title string
|
|
10
|
-
*/
|
|
11
|
-
export declare function generateTitle(message: BaseMessage): string;
|
|
12
|
-
//# sourceMappingURL=title-generator.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"title-generator.d.ts","sourceRoot":"","sources":["../../../src/history/utils/title-generator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAUvD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,WAAW,GAAG,MAAM,CAuC1D"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Title generation utilities for chat sessions
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateTitle = generateTitle;
|
|
7
|
-
/**
|
|
8
|
-
* Cap for *auto-generated* titles. Separate from the user-facing
|
|
9
|
-
* validation cap in utils/validation.ts (MAX_TITLE_LENGTH = 200): we deliberately
|
|
10
|
-
* produce shorter previews when auto-deriving a title from a long first message.
|
|
11
|
-
*/
|
|
12
|
-
const GENERATED_TITLE_MAX_LENGTH = 100;
|
|
13
|
-
const DEFAULT_TITLE = 'New Conversation';
|
|
14
|
-
/**
|
|
15
|
-
* Generate a session title from the first message
|
|
16
|
-
*
|
|
17
|
-
* @param message - The first message in the session
|
|
18
|
-
* @returns A generated title string
|
|
19
|
-
*/
|
|
20
|
-
function generateTitle(message) {
|
|
21
|
-
if (!message || !message.content) {
|
|
22
|
-
return DEFAULT_TITLE;
|
|
23
|
-
}
|
|
24
|
-
// Convert content to string (it can be string or array of content parts)
|
|
25
|
-
let contentText = '';
|
|
26
|
-
if (typeof message.content === 'string') {
|
|
27
|
-
contentText = message.content;
|
|
28
|
-
}
|
|
29
|
-
else if (Array.isArray(message.content)) {
|
|
30
|
-
// Extract text from content parts if it's an array
|
|
31
|
-
contentText = message.content
|
|
32
|
-
.map((part) => {
|
|
33
|
-
if (typeof part === 'string')
|
|
34
|
-
return part;
|
|
35
|
-
if (typeof part === 'object' && part !== null && 'text' in part) {
|
|
36
|
-
return part.text;
|
|
37
|
-
}
|
|
38
|
-
return '';
|
|
39
|
-
})
|
|
40
|
-
.join(' ');
|
|
41
|
-
}
|
|
42
|
-
// Clean and truncate the title
|
|
43
|
-
const cleaned = contentText
|
|
44
|
-
.replace(/\s+/g, ' ') // Replace multiple whitespace with a single space
|
|
45
|
-
.replace(/[\r\n]+/g, ' ') // Replace newlines with space
|
|
46
|
-
.trim();
|
|
47
|
-
if (!cleaned) {
|
|
48
|
-
return DEFAULT_TITLE;
|
|
49
|
-
}
|
|
50
|
-
// Truncate to max length
|
|
51
|
-
if (cleaned.length <= GENERATED_TITLE_MAX_LENGTH) {
|
|
52
|
-
return cleaned;
|
|
53
|
-
}
|
|
54
|
-
// Truncate and add ellipsis
|
|
55
|
-
return cleaned.substring(0, GENERATED_TITLE_MAX_LENGTH - 3) + '...';
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=title-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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AAC;IAED,yBAAyB;IACzB,IAAI,OAAO,CAAC,MAAM,IAAI,0BAA0B,EAAE,CAAC;QACjD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,4BAA4B;IAC5B,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,0BAA0B,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC;AACtE,CAAC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Item builder utilities for per-message chat history storage
|
|
3
|
-
* Builds DynamoDB items for metadata and individual messages
|
|
4
|
-
*/
|
|
5
|
-
import type { BaseMessage } from '@langchain/core/messages';
|
|
6
|
-
import type { DynamoDBMessageItem } from '../types';
|
|
7
|
-
/**
|
|
8
|
-
* Format a message index as a zero-padded 6-digit string.
|
|
9
|
-
*
|
|
10
|
-
* @remarks
|
|
11
|
-
* The 6-digit width caps a session at **999 999 messages** while preserving
|
|
12
|
-
* lexicographic sort order on the composite SK. Beyond that, index 1 000 000
|
|
13
|
-
* would sort *before* 999 999 as a string, corrupting replay order. If you
|
|
14
|
-
* expect sessions to approach this bound, either shard by sub-session or widen
|
|
15
|
-
* the padding here (and migrate existing data).
|
|
16
|
-
*/
|
|
17
|
-
export declare function formatMessageIndex(index: number): string;
|
|
18
|
-
/**
|
|
19
|
-
* Build the sort key for a message item
|
|
20
|
-
*
|
|
21
|
-
* @param sessionId - Session identifier
|
|
22
|
-
* @param messageIndex - Zero-based message index
|
|
23
|
-
* @returns Composite SK like "sessionId#msg#000001"
|
|
24
|
-
*/
|
|
25
|
-
export declare function buildMessageSK(sessionId: string, messageIndex: number): string;
|
|
26
|
-
/**
|
|
27
|
-
* Build DynamoDB message items from BaseMessage array
|
|
28
|
-
*
|
|
29
|
-
* @param userId - User identifier
|
|
30
|
-
* @param sessionId - Session identifier
|
|
31
|
-
* @param messages - Messages to serialize
|
|
32
|
-
* @param startIndex - Starting message index (for appending to existing session)
|
|
33
|
-
* @param ttlDays - Optional TTL in days
|
|
34
|
-
* @returns Array of DynamoDB message items
|
|
35
|
-
*/
|
|
36
|
-
export declare function buildMessageItems(userId: string, sessionId: string, messages: BaseMessage[], startIndex: number, ttlDays?: number): DynamoDBMessageItem[];
|
|
37
|
-
/**
|
|
38
|
-
* Build an optimistic-lock metadata update expression.
|
|
39
|
-
*
|
|
40
|
-
* Writes a new messageCount conditional on the caller's observed previous value
|
|
41
|
-
* (or on the metadata item not existing yet). The caller handles the
|
|
42
|
-
* ConditionalCheckFailed case by re-reading and retrying, which prevents the
|
|
43
|
-
* counter from getting ahead of the actual messages on transient put failures.
|
|
44
|
-
*
|
|
45
|
-
* @param title - Session title (only set on first write via if_not_exists)
|
|
46
|
-
* @param newCount - Target total messageCount after this write
|
|
47
|
-
* @param expectedCount - Previously observed messageCount (undefined for new session)
|
|
48
|
-
* @param ttlDays - Optional TTL in days
|
|
49
|
-
*/
|
|
50
|
-
export declare function buildOptimisticMetadataUpdate(title: string, newCount: number, expectedCount: number | undefined, ttlDays?: number): {
|
|
51
|
-
updateExpression: string;
|
|
52
|
-
conditionExpression: string;
|
|
53
|
-
expressionAttributeValues: Record<string, any>;
|
|
54
|
-
};
|
|
55
|
-
//# sourceMappingURL=update-expression-builder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-expression-builder.d.ts","sourceRoot":"","sources":["../../../src/history/utils/update-expression-builder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,WAAW,EAAE,EACvB,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE,MAAM,GACf,mBAAmB,EAAE,CAkBvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,6BAA6B,CAC3C,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,OAAO,CAAC,EAAE,MAAM,GACf;IACD,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChD,CAoCA"}
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Item builder utilities for per-message chat history storage
|
|
4
|
-
* Builds DynamoDB items for metadata and individual messages
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.formatMessageIndex = formatMessageIndex;
|
|
8
|
-
exports.buildMessageSK = buildMessageSK;
|
|
9
|
-
exports.buildMessageItems = buildMessageItems;
|
|
10
|
-
exports.buildOptimisticMetadataUpdate = buildOptimisticMetadataUpdate;
|
|
11
|
-
const messages_1 = require("@langchain/core/messages");
|
|
12
|
-
const shared_1 = require("../../shared");
|
|
13
|
-
/**
|
|
14
|
-
* Format a message index as a zero-padded 6-digit string.
|
|
15
|
-
*
|
|
16
|
-
* @remarks
|
|
17
|
-
* The 6-digit width caps a session at **999 999 messages** while preserving
|
|
18
|
-
* lexicographic sort order on the composite SK. Beyond that, index 1 000 000
|
|
19
|
-
* would sort *before* 999 999 as a string, corrupting replay order. If you
|
|
20
|
-
* expect sessions to approach this bound, either shard by sub-session or widen
|
|
21
|
-
* the padding here (and migrate existing data).
|
|
22
|
-
*/
|
|
23
|
-
function formatMessageIndex(index) {
|
|
24
|
-
return String(index).padStart(6, '0');
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Build the sort key for a message item
|
|
28
|
-
*
|
|
29
|
-
* @param sessionId - Session identifier
|
|
30
|
-
* @param messageIndex - Zero-based message index
|
|
31
|
-
* @returns Composite SK like "sessionId#msg#000001"
|
|
32
|
-
*/
|
|
33
|
-
function buildMessageSK(sessionId, messageIndex) {
|
|
34
|
-
return `${sessionId}#msg#${formatMessageIndex(messageIndex)}`;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Build DynamoDB message items from BaseMessage array
|
|
38
|
-
*
|
|
39
|
-
* @param userId - User identifier
|
|
40
|
-
* @param sessionId - Session identifier
|
|
41
|
-
* @param messages - Messages to serialize
|
|
42
|
-
* @param startIndex - Starting message index (for appending to existing session)
|
|
43
|
-
* @param ttlDays - Optional TTL in days
|
|
44
|
-
* @returns Array of DynamoDB message items
|
|
45
|
-
*/
|
|
46
|
-
function buildMessageItems(userId, sessionId, messages, startIndex, ttlDays) {
|
|
47
|
-
const storedMessages = (0, messages_1.mapChatMessagesToStoredMessages)(messages);
|
|
48
|
-
const ttl = ttlDays !== undefined ? (0, shared_1.calculateTTLTimestamp)(ttlDays) : undefined;
|
|
49
|
-
return storedMessages.map((storedMessage, i) => {
|
|
50
|
-
const messageIndex = startIndex + i;
|
|
51
|
-
const item = {
|
|
52
|
-
userId,
|
|
53
|
-
sessionId: buildMessageSK(sessionId, messageIndex),
|
|
54
|
-
itemType: 'message',
|
|
55
|
-
messageIndex,
|
|
56
|
-
message: storedMessage,
|
|
57
|
-
};
|
|
58
|
-
if (ttl !== undefined) {
|
|
59
|
-
item.ttl = ttl;
|
|
60
|
-
}
|
|
61
|
-
return item;
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Build an optimistic-lock metadata update expression.
|
|
66
|
-
*
|
|
67
|
-
* Writes a new messageCount conditional on the caller's observed previous value
|
|
68
|
-
* (or on the metadata item not existing yet). The caller handles the
|
|
69
|
-
* ConditionalCheckFailed case by re-reading and retrying, which prevents the
|
|
70
|
-
* counter from getting ahead of the actual messages on transient put failures.
|
|
71
|
-
*
|
|
72
|
-
* @param title - Session title (only set on first write via if_not_exists)
|
|
73
|
-
* @param newCount - Target total messageCount after this write
|
|
74
|
-
* @param expectedCount - Previously observed messageCount (undefined for new session)
|
|
75
|
-
* @param ttlDays - Optional TTL in days
|
|
76
|
-
*/
|
|
77
|
-
function buildOptimisticMetadataUpdate(title, newCount, expectedCount, ttlDays) {
|
|
78
|
-
const now = Date.now();
|
|
79
|
-
const setParts = [
|
|
80
|
-
'updatedAt = :updatedAt',
|
|
81
|
-
'itemType = :itemType',
|
|
82
|
-
'messageCount = :newCount',
|
|
83
|
-
'title = if_not_exists(title, :title)',
|
|
84
|
-
'createdAt = if_not_exists(createdAt, :createdAt)',
|
|
85
|
-
];
|
|
86
|
-
const expressionAttributeValues = {
|
|
87
|
-
':updatedAt': now,
|
|
88
|
-
':createdAt': now,
|
|
89
|
-
':newCount': newCount,
|
|
90
|
-
':itemType': 'metadata',
|
|
91
|
-
':title': title,
|
|
92
|
-
};
|
|
93
|
-
let conditionExpression;
|
|
94
|
-
if (expectedCount === undefined) {
|
|
95
|
-
// New session: metadata item must not exist yet.
|
|
96
|
-
conditionExpression = 'attribute_not_exists(messageCount)';
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
conditionExpression = 'messageCount = :expectedCount';
|
|
100
|
-
expressionAttributeValues[':expectedCount'] = expectedCount;
|
|
101
|
-
}
|
|
102
|
-
if (ttlDays !== undefined) {
|
|
103
|
-
setParts.push('ttl = :ttl');
|
|
104
|
-
expressionAttributeValues[':ttl'] = (0, shared_1.calculateTTLTimestamp)(ttlDays);
|
|
105
|
-
}
|
|
106
|
-
return {
|
|
107
|
-
updateExpression: `SET ${setParts.join(', ')}`,
|
|
108
|
-
conditionExpression,
|
|
109
|
-
expressionAttributeValues,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=update-expression-builder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"update-expression-builder.js","sourceRoot":"","sources":["../../../src/history/utils/update-expression-builder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAkBH,gDAEC;AASD,wCAEC;AAYD,8CAwBC;AAeD,sEA6CC;AA5HD,uDAA2E;AAE3E,yCAAqD;AAGrD;;;;;;;;;GASG;AACH,SAAgB,kBAAkB,CAAC,KAAa;IAC9C,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,cAAc,CAAC,SAAiB,EAAE,YAAoB;IACpE,OAAO,GAAG,SAAS,QAAQ,kBAAkB,CAAC,YAAY,CAAC,EAAE,CAAC;AAChE,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,iBAAiB,CAC/B,MAAc,EACd,SAAiB,EACjB,QAAuB,EACvB,UAAkB,EAClB,OAAgB;IAEhB,MAAM,cAAc,GAAG,IAAA,0CAA+B,EAAC,QAAQ,CAAC,CAAC;IACjE,MAAM,GAAG,GAAG,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE/E,OAAO,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE;QAC7C,MAAM,YAAY,GAAG,UAAU,GAAG,CAAC,CAAC;QACpC,MAAM,IAAI,GAAwB;YAChC,MAAM;YACN,SAAS,EAAE,cAAc,CAAC,SAAS,EAAE,YAAY,CAAC;YAClD,QAAQ,EAAE,SAAS;YACnB,YAAY;YACZ,OAAO,EAAE,aAAa;SACvB,CAAC;QACF,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,6BAA6B,CAC3C,KAAa,EACb,QAAgB,EAChB,aAAiC,EACjC,OAAgB;IAMhB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG;QACf,wBAAwB;QACxB,sBAAsB;QACtB,0BAA0B;QAC1B,sCAAsC;QACtC,kDAAkD;KACnD,CAAC;IACF,MAAM,yBAAyB,GAAwB;QACrD,YAAY,EAAE,GAAG;QACjB,YAAY,EAAE,GAAG;QACjB,WAAW,EAAE,QAAQ;QACrB,WAAW,EAAE,UAAU;QACvB,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,IAAI,mBAA2B,CAAC;IAChC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;QAChC,iDAAiD;QACjD,mBAAmB,GAAG,oCAAoC,CAAC;IAC7D,CAAC;SAAM,CAAC;QACN,mBAAmB,GAAG,+BAA+B,CAAC;QACtD,yBAAyB,CAAC,gBAAgB,CAAC,GAAG,aAAa,CAAC;IAC9D,CAAC;IAED,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC5B,yBAAyB,CAAC,MAAM,CAAC,GAAG,IAAA,8BAAqB,EAAC,OAAO,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,gBAAgB,EAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;QAC9C,mBAAmB;QACnB,yBAAyB;KAC1B,CAAC;AACJ,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validation utilities for chat message history operations
|
|
3
|
-
*/
|
|
4
|
-
import { BaseMessage } from '@langchain/core/messages';
|
|
5
|
-
/**
|
|
6
|
-
* Custom error class for validation errors in chat message history
|
|
7
|
-
*/
|
|
8
|
-
export declare class HistoryValidationError extends Error {
|
|
9
|
-
constructor(message: string);
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Validate user ID
|
|
13
|
-
*
|
|
14
|
-
* @param userId - User identifier to validate
|
|
15
|
-
* @throws HistoryValidationError if validation fails
|
|
16
|
-
*/
|
|
17
|
-
export declare function validateUserId(userId: any): void;
|
|
18
|
-
/**
|
|
19
|
-
* Validate session ID
|
|
20
|
-
*
|
|
21
|
-
* @param sessionId - Session identifier to validate
|
|
22
|
-
* @throws HistoryValidationError if validation fails
|
|
23
|
-
*/
|
|
24
|
-
export declare function validateSessionId(sessionId: any): void;
|
|
25
|
-
/**
|
|
26
|
-
* Validate a single message
|
|
27
|
-
*
|
|
28
|
-
* @param message - BaseMessage to validate
|
|
29
|
-
* @throws HistoryValidationError if validation fails
|
|
30
|
-
*/
|
|
31
|
-
export declare function validateMessage(message: BaseMessage): void;
|
|
32
|
-
/**
|
|
33
|
-
* Validate messages array
|
|
34
|
-
*
|
|
35
|
-
* @param messages - Array of BaseMessage objects to validate
|
|
36
|
-
* @throws HistoryValidationError if validation fails
|
|
37
|
-
*/
|
|
38
|
-
export declare function validateMessages(messages: BaseMessage[]): void;
|
|
39
|
-
/**
|
|
40
|
-
* Validate title
|
|
41
|
-
*
|
|
42
|
-
* @param title - Optional title string to validate
|
|
43
|
-
* @throws HistoryValidationError if validation fails
|
|
44
|
-
*/
|
|
45
|
-
export declare function validateTitle(title: any): void;
|
|
46
|
-
/**
|
|
47
|
-
* Validate list limit parameter
|
|
48
|
-
*
|
|
49
|
-
* @param limit - Optional maximum number of items to return
|
|
50
|
-
* @throws HistoryValidationError if validation fails
|
|
51
|
-
*/
|
|
52
|
-
export declare function validateLimit(limit: any): void;
|
|
53
|
-
/**
|
|
54
|
-
* Validate TTL days (wraps shared validation with a history-specific error type)
|
|
55
|
-
*
|
|
56
|
-
* @param ttlDays - Optional TTL in days
|
|
57
|
-
* @throws HistoryValidationError if validation fails
|
|
58
|
-
*/
|
|
59
|
-
export declare function validateTTLDays(ttlDays: number | undefined): void;
|
|
60
|
-
/**
|
|
61
|
-
* Validate total estimated size of messages for DynamoDB transaction limits.
|
|
62
|
-
* Prevents runtime `TransactionCanceledException` due to 4MB size exceeded.
|
|
63
|
-
*
|
|
64
|
-
* @param messages - Array of BaseMessage objects to validate
|
|
65
|
-
* @throws HistoryValidationError if estimated size exceeds 4MB
|
|
66
|
-
*/
|
|
67
|
-
export declare function validateMessagesSize(messages: BaseMessage[]): void;
|
|
68
|
-
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/history/utils/validation.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAYvD;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CA0BhD;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,GAAG,GAAG,IAAI,CA2BtD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAa1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAyB9D;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAc9C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAgB9C;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAOjE;AAOD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI,CAmBlE"}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validation utilities for chat message history operations
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.HistoryValidationError = void 0;
|
|
7
|
-
exports.validateUserId = validateUserId;
|
|
8
|
-
exports.validateSessionId = validateSessionId;
|
|
9
|
-
exports.validateMessage = validateMessage;
|
|
10
|
-
exports.validateMessages = validateMessages;
|
|
11
|
-
exports.validateTitle = validateTitle;
|
|
12
|
-
exports.validateLimit = validateLimit;
|
|
13
|
-
exports.validateTTLDays = validateTTLDays;
|
|
14
|
-
exports.validateMessagesSize = validateMessagesSize;
|
|
15
|
-
const utils_1 = require("../../shared/utils");
|
|
16
|
-
const MAX_USER_ID_LENGTH = 256;
|
|
17
|
-
const MAX_SESSION_ID_LENGTH = 256;
|
|
18
|
-
const MAX_TITLE_LENGTH = 200;
|
|
19
|
-
// 99 so that N message Puts + 1 metadata Update still fit in a single
|
|
20
|
-
// 100-item DynamoDB TransactWrite (used for atomic index allocation).
|
|
21
|
-
const MAX_MESSAGES_PER_BATCH = 99;
|
|
22
|
-
const MAX_LIST_LIMIT = 1000;
|
|
23
|
-
/**
|
|
24
|
-
* Custom error class for validation errors in chat message history
|
|
25
|
-
*/
|
|
26
|
-
class HistoryValidationError extends Error {
|
|
27
|
-
constructor(message) {
|
|
28
|
-
super(message);
|
|
29
|
-
this.name = 'HistoryValidationError';
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.HistoryValidationError = HistoryValidationError;
|
|
33
|
-
/**
|
|
34
|
-
* Validate user ID
|
|
35
|
-
*
|
|
36
|
-
* @param userId - User identifier to validate
|
|
37
|
-
* @throws HistoryValidationError if validation fails
|
|
38
|
-
*/
|
|
39
|
-
function validateUserId(userId) {
|
|
40
|
-
if (typeof userId !== 'string') {
|
|
41
|
-
throw new HistoryValidationError('User ID must be a string');
|
|
42
|
-
}
|
|
43
|
-
if (userId.length === 0) {
|
|
44
|
-
throw new HistoryValidationError('User ID cannot be empty');
|
|
45
|
-
}
|
|
46
|
-
if (userId.length > MAX_USER_ID_LENGTH) {
|
|
47
|
-
throw new HistoryValidationError(`User ID exceeds maximum length of ${MAX_USER_ID_LENGTH} characters`);
|
|
48
|
-
}
|
|
49
|
-
// Prevent control characters and null bytes
|
|
50
|
-
// eslint-disable-next-line no-control-regex
|
|
51
|
-
if (/[\x00-\x1F\x7F]/.test(userId)) {
|
|
52
|
-
throw new HistoryValidationError('User ID cannot contain control characters');
|
|
53
|
-
}
|
|
54
|
-
// Reject '#' to prevent collisions with the composite sort-key separator used for
|
|
55
|
-
// message items ("${sessionId}#msg#<idx>"). Defense in depth — userId is the PK today.
|
|
56
|
-
if (userId.includes('#')) {
|
|
57
|
-
throw new HistoryValidationError('User ID cannot contain "#" character');
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Validate session ID
|
|
62
|
-
*
|
|
63
|
-
* @param sessionId - Session identifier to validate
|
|
64
|
-
* @throws HistoryValidationError if validation fails
|
|
65
|
-
*/
|
|
66
|
-
function validateSessionId(sessionId) {
|
|
67
|
-
if (typeof sessionId !== 'string') {
|
|
68
|
-
throw new HistoryValidationError('Session ID must be a string');
|
|
69
|
-
}
|
|
70
|
-
if (sessionId.length === 0) {
|
|
71
|
-
throw new HistoryValidationError('Session ID cannot be empty');
|
|
72
|
-
}
|
|
73
|
-
if (sessionId.length > MAX_SESSION_ID_LENGTH) {
|
|
74
|
-
throw new HistoryValidationError(`Session ID exceeds maximum length of ${MAX_SESSION_ID_LENGTH} characters`);
|
|
75
|
-
}
|
|
76
|
-
// Prevent control characters
|
|
77
|
-
// eslint-disable-next-line no-control-regex
|
|
78
|
-
if (/[\x00-\x1F\x7F]/.test(sessionId)) {
|
|
79
|
-
throw new HistoryValidationError('Session ID cannot contain control characters');
|
|
80
|
-
}
|
|
81
|
-
// Reject '#' to prevent injection into the composite sort-key format
|
|
82
|
-
// "${sessionId}#msg#<idx>". A sessionId containing "#msg#" could otherwise let
|
|
83
|
-
// getMessages/clear cross into another of the same user's sessions.
|
|
84
|
-
if (sessionId.includes('#')) {
|
|
85
|
-
throw new HistoryValidationError('Session ID cannot contain "#" character');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Validate a single message
|
|
90
|
-
*
|
|
91
|
-
* @param message - BaseMessage to validate
|
|
92
|
-
* @throws HistoryValidationError if validation fails
|
|
93
|
-
*/
|
|
94
|
-
function validateMessage(message) {
|
|
95
|
-
if (!message) {
|
|
96
|
-
throw new HistoryValidationError('Message cannot be null or undefined');
|
|
97
|
-
}
|
|
98
|
-
if (typeof message !== 'object') {
|
|
99
|
-
throw new HistoryValidationError('Message must be a BaseMessage object');
|
|
100
|
-
}
|
|
101
|
-
// Check for required BaseMessage properties
|
|
102
|
-
if (!message.content && message.content !== '') {
|
|
103
|
-
throw new HistoryValidationError('Message must have a content property');
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Validate messages array
|
|
108
|
-
*
|
|
109
|
-
* @param messages - Array of BaseMessage objects to validate
|
|
110
|
-
* @throws HistoryValidationError if validation fails
|
|
111
|
-
*/
|
|
112
|
-
function validateMessages(messages) {
|
|
113
|
-
if (!Array.isArray(messages)) {
|
|
114
|
-
throw new HistoryValidationError('Messages must be an array');
|
|
115
|
-
}
|
|
116
|
-
if (messages.length === 0) {
|
|
117
|
-
throw new HistoryValidationError('Messages array cannot be empty');
|
|
118
|
-
}
|
|
119
|
-
if (messages.length > MAX_MESSAGES_PER_BATCH) {
|
|
120
|
-
throw new HistoryValidationError(`Messages batch size (${messages.length}) exceeds maximum of ${MAX_MESSAGES_PER_BATCH}`);
|
|
121
|
-
}
|
|
122
|
-
for (let i = 0; i < messages.length; i++) {
|
|
123
|
-
try {
|
|
124
|
-
validateMessage(messages[i]);
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new HistoryValidationError(
|
|
128
|
-
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
129
|
-
`Invalid message at index ${i}: ${error instanceof Error ? error.message : String(error)}`);
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Validate title
|
|
135
|
-
*
|
|
136
|
-
* @param title - Optional title string to validate
|
|
137
|
-
* @throws HistoryValidationError if validation fails
|
|
138
|
-
*/
|
|
139
|
-
function validateTitle(title) {
|
|
140
|
-
if (title === undefined) {
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (typeof title !== 'string') {
|
|
144
|
-
throw new HistoryValidationError('Title must be a string');
|
|
145
|
-
}
|
|
146
|
-
if (title.length > MAX_TITLE_LENGTH) {
|
|
147
|
-
throw new HistoryValidationError(`Title exceeds maximum length of ${MAX_TITLE_LENGTH} characters`);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Validate list limit parameter
|
|
152
|
-
*
|
|
153
|
-
* @param limit - Optional maximum number of items to return
|
|
154
|
-
* @throws HistoryValidationError if validation fails
|
|
155
|
-
*/
|
|
156
|
-
function validateLimit(limit) {
|
|
157
|
-
if (limit === undefined) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
if (typeof limit !== 'number' || !Number.isInteger(limit)) {
|
|
161
|
-
throw new HistoryValidationError('Limit must be an integer');
|
|
162
|
-
}
|
|
163
|
-
if (limit <= 0) {
|
|
164
|
-
throw new HistoryValidationError('Limit must be positive');
|
|
165
|
-
}
|
|
166
|
-
if (limit > MAX_LIST_LIMIT) {
|
|
167
|
-
throw new HistoryValidationError(`Limit cannot exceed ${MAX_LIST_LIMIT}`);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
/**
|
|
171
|
-
* Validate TTL days (wraps shared validation with a history-specific error type)
|
|
172
|
-
*
|
|
173
|
-
* @param ttlDays - Optional TTL in days
|
|
174
|
-
* @throws HistoryValidationError if validation fails
|
|
175
|
-
*/
|
|
176
|
-
function validateTTLDays(ttlDays) {
|
|
177
|
-
try {
|
|
178
|
-
(0, utils_1.validateTTLDays)(ttlDays);
|
|
179
|
-
}
|
|
180
|
-
catch (error) {
|
|
181
|
-
// eslint-disable-next-line no-instanceof/no-instanceof
|
|
182
|
-
throw new HistoryValidationError(error instanceof Error ? error.message : String(error));
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/** DynamoDB transactWrite limit: 4MB total across all items */
|
|
186
|
-
const MAX_TRANSACTION_SIZE_BYTES = 4 * 1024 * 1024;
|
|
187
|
-
/** Estimated per-item overhead: PK, SK, itemType, messageIndex, ttl, DynamoDB encoding */
|
|
188
|
-
const PER_ITEM_OVERHEAD_BYTES = 500;
|
|
189
|
-
/**
|
|
190
|
-
* Validate total estimated size of messages for DynamoDB transaction limits.
|
|
191
|
-
* Prevents runtime `TransactionCanceledException` due to 4MB size exceeded.
|
|
192
|
-
*
|
|
193
|
-
* @param messages - Array of BaseMessage objects to validate
|
|
194
|
-
* @throws HistoryValidationError if estimated size exceeds 4MB
|
|
195
|
-
*/
|
|
196
|
-
function validateMessagesSize(messages) {
|
|
197
|
-
let totalSize = 0;
|
|
198
|
-
for (const message of messages) {
|
|
199
|
-
// Measure the WHOLE message, not just `content`. additional_kwargs, tool_calls,
|
|
200
|
-
// response_metadata, etc. are stored alongside and can be larger than content.
|
|
201
|
-
// Use `toJSON` when present (BaseMessage subclasses expose it) so we serialize
|
|
202
|
-
// the same shape that mapChatMessagesToStoredMessages produces.
|
|
203
|
-
const serializable = typeof message.toJSON === 'function'
|
|
204
|
-
? message.toJSON()
|
|
205
|
-
: message;
|
|
206
|
-
const size = new TextEncoder().encode(JSON.stringify(serializable)).byteLength;
|
|
207
|
-
totalSize += size + PER_ITEM_OVERHEAD_BYTES;
|
|
208
|
-
}
|
|
209
|
-
if (totalSize > MAX_TRANSACTION_SIZE_BYTES) {
|
|
210
|
-
throw new HistoryValidationError(`Estimated batch size (~${Math.round(totalSize / 1024)}KB) exceeds DynamoDB transaction limit of 4MB`);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../../src/history/utils/validation.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA8BH,wCA0BC;AAQD,8CA2BC;AAQD,0CAaC;AAQD,4CAyBC;AAQD,sCAcC;AAQD,sCAgBC;AAQD,0CAOC;AAcD,oDAmBC;AA3OD,8CAA0E;AAE1E,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AAC7B,sEAAsE;AACtE,sEAAsE;AACtE,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAClC,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B;;GAEG;AACH,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED;;;;;GAKG;AACH,SAAgB,cAAc,CAAC,MAAW;IACxC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,MAAM,IAAI,sBAAsB,CAAC,0BAA0B,CAAC,CAAC;IAC/D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,sBAAsB,CAAC,yBAAyB,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,MAAM,CAAC,MAAM,GAAG,kBAAkB,EAAE,CAAC;QACvC,MAAM,IAAI,sBAAsB,CAC9B,qCAAqC,kBAAk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AAM,0BAA0B,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACnD,0FAA0F;AAC1F,MAAM,uBAAuB,GAAG,GAAG,CAAC;AAEpC;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAAC,QAAuB;IAC1D,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC/B,gFAAgF;QAChF,+EAA+E;QAC/E,+EAA+E;QAC/E,gEAAgE;QAChE,MAAM,YAAY,GAChB,OAAQ,OAAiD,CAAC,MAAM,KAAK,UAAU;YAC7E,CAAC,CAAE,OAAgD,CAAC,MAAM,EAAE;YAC5D,CAAC,CAAC,OAAO,CAAC;QACd,MAAM,IAAI,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC;QAC/E,SAAS,IAAI,IAAI,GAAG,uBAAuB,CAAC;IAC9C,CAAC;IACD,IAAI,SAAS,GAAG,0BAA0B,EAAE,CAAC;QAC3C,MAAM,IAAI,sBAAsB,CAC9B,0BAA0B,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,+CAA+C,CACtG,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/dist/shared/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/shared/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,SAAS,CAAC"}
|
package/dist/shared/index.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared utilities and types
|
|
4
|
-
*/
|
|
5
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
-
if (k2 === undefined) k2 = k;
|
|
7
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
-
}
|
|
11
|
-
Object.defineProperty(o, k2, desc);
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
__exportStar(require("./utils"), exports);
|
|
21
|
-
//# sourceMappingURL=index.js.map
|