@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,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchViaBackend = searchViaBackend;
|
|
4
|
-
const errors_1 = require("../../shared/errors/errors");
|
|
5
|
-
const get_1 = require("../actions/get");
|
|
6
|
-
const keys_1 = require("./keys");
|
|
7
|
-
const score_direction_1 = require("./score-direction");
|
|
8
|
-
const search_filter_1 = require("./search-filter");
|
|
9
|
-
/**
|
|
10
|
-
* Warn when a backend's own ordering disagrees with its scores. A backend
|
|
11
|
-
* returning a raw distance still hands back nearest-first, so the order looks
|
|
12
|
-
* right while every score means the opposite of what {@link VectorMatch.score}
|
|
13
|
-
* promises — ascending scores are that exact signature. Results are never
|
|
14
|
-
* reordered on this basis: a correctly-scored backend's order is authoritative.
|
|
15
|
-
*/
|
|
16
|
-
function warnOnNonDescendingScores(context, matches, namespacePrefix) {
|
|
17
|
-
const descending = matches.every((match, position) => position === 0 || matches[position - 1].score >= match.score);
|
|
18
|
-
if (descending)
|
|
19
|
-
return;
|
|
20
|
-
context.logger.warn('search: vectorBackend returned ascending scores; VectorMatch.score must be a relevance ' +
|
|
21
|
-
'(higher is better), not a distance — results are forwarded in the order the backend gave', { namespacePrefix });
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Read the canonical item a backend match points at, or `undefined` when the
|
|
25
|
-
* match is unusable. `getItem` validates, so a backend returning a namespace
|
|
26
|
-
* element containing the reserved separator would otherwise turn the whole
|
|
27
|
-
* search into a ValidationError instead of dropping the one bad match.
|
|
28
|
-
*/
|
|
29
|
-
async function fetchMatch(context, match) {
|
|
30
|
-
try {
|
|
31
|
-
return await (0, get_1.getItem)(context, match.namespace, match.key);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
context.logger.warn('search: skipped an unusable vectorBackend match', {
|
|
35
|
-
namespace: match.namespace,
|
|
36
|
-
key: match.key,
|
|
37
|
-
reason: error.name,
|
|
38
|
-
});
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
async function searchViaBackend(context, backend, index, op, offset, limit) {
|
|
43
|
-
const queryVector = await index.embeddings.embedQuery(op.query);
|
|
44
|
-
const need = offset + limit;
|
|
45
|
-
if (need > context.maxSearchCandidates) {
|
|
46
|
-
throw new errors_1.ValidationError(`Requested page (offset ${offset} + limit ${limit} = ${need}) exceeds maxSearchCandidates ` +
|
|
47
|
-
`(${context.maxSearchCandidates}); narrow the page or raise maxSearchCandidates`, 'maxSearchCandidates');
|
|
48
|
-
}
|
|
49
|
-
let topK = Math.min(need, context.maxSearchCandidates);
|
|
50
|
-
let results;
|
|
51
|
-
for (;;) {
|
|
52
|
-
const matches = (0, score_direction_1.toRelevanceScores)(await backend.query(op.namespacePrefix, queryVector, topK), context.vectorScoreDirection);
|
|
53
|
-
warnOnNonDescendingScores(context, matches, op.namespacePrefix);
|
|
54
|
-
results = [];
|
|
55
|
-
for (const match of matches) {
|
|
56
|
-
if (!(0, keys_1.namespaceMatchesPrefix)(match.namespace, op.namespacePrefix))
|
|
57
|
-
continue;
|
|
58
|
-
const item = await fetchMatch(context, match);
|
|
59
|
-
if (item && (0, search_filter_1.passesFilter)(item, op))
|
|
60
|
-
results.push({ ...item, score: match.score });
|
|
61
|
-
}
|
|
62
|
-
if (results.length >= need || matches.length < topK || topK >= context.maxSearchCandidates)
|
|
63
|
-
break;
|
|
64
|
-
topK = Math.min(topK * 2, context.maxSearchCandidates);
|
|
65
|
-
}
|
|
66
|
-
return results;
|
|
67
|
-
}
|
|
68
|
-
//# sourceMappingURL=backend-search.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"backend-search.js","sourceRoot":"","sources":["../../../src/store/internal/backend-search.ts"],"names":[],"mappings":";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AAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../../src/store/internal/filter.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,MAAM,MAAM,SAAS,GACnB,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAyFhF;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAChC,OAAO,CAMT"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter.js","sourceRoot":"","sources":["../../../src/store/internal/filter.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAM9C;;;;;;GAMG;AACH,SAAS,OAAO,CAA4B,MAAS,EAAE,QAAW;IAChE,IAAI,MAAM,GAAG,QAAQ;QAAE,OAAO,CAAC,CAAC,CAAC;IACjC,IAAI,MAAM,GAAG,QAAQ;QAAE,OAAO,CAAC,CAAC;IAChC,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC;AAED,yEAAyE;AACzE,SAAS,SAAS,CAAC,KAAyB,EAAE,IAAgC;IAC5E,OAAO,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAS,cAAc,CACrB,MAAmB,EACnB,QAAmB,EACnB,IAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC/D,OAAO,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,CAAC,E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,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE;IACzD;qEACiE;IACjE,gBAAgB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CACpF,CAAC;AACJ,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { VectorBackend, VectorRef } from '../vector-backend';
|
|
2
|
-
import type { StoreContext } from './setup';
|
|
3
|
-
/** A canonical item's location plus the embedding recomputed for it. */
|
|
4
|
-
export interface ReconcileTarget {
|
|
5
|
-
namespace: string[];
|
|
6
|
-
key: string;
|
|
7
|
-
embedding: number[] | undefined;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Enumerate canonical items under `prefix`, recomputing each embedding. A failed
|
|
11
|
-
* embedding rejects the whole reconcile by design: silently skipping an item
|
|
12
|
-
* would drop it from the live set, after which {@link selectOrphans} would prune
|
|
13
|
-
* its still-valid backend vector. Fail-fast keeps the backend from losing data.
|
|
14
|
-
*/
|
|
15
|
-
export declare function collectReconcileTargets(context: StoreContext, prefix: string[]): Promise<ReconcileTarget[]>;
|
|
16
|
-
/** Re-push every live embedding to the backend; returns the upsert count. */
|
|
17
|
-
export declare function pushEmbeddings(backend: VectorBackend, targets: ReconcileTarget[]): Promise<number>;
|
|
18
|
-
/** Refs present in the backend but absent from `live` — orphans to prune. */
|
|
19
|
-
export declare function selectOrphans(backendRefs: VectorRef[], live: ReconcileTarget[]): VectorRef[];
|
|
20
|
-
/** Delete backend vectors with no canonical item; returns the prune count. */
|
|
21
|
-
export declare function pruneOrphans(context: StoreContext, backend: VectorBackend, prefix: string[], live: ReconcileTarget[]): Promise<number>;
|
|
22
|
-
//# sourceMappingURL=index-reconcile.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-reconcile.d.ts","sourceRoot":"","sources":["../../../src/store/internal/index-reconcile.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMlE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,wEAAwE;AACxE,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACjC;AAOD;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,MAAM,EAAE,GACf,OAAO,CAAC,eAAe,EAAE,CAAC,CAqB5B;AAED,6EAA6E;AAC7E,wBAAsB,cAAc,CAClC,OAAO,EAAE,aAAa,EACtB,OAAO,EAAE,eAAe,EAAE,GACzB,OAAO,CAAC,MAAM,CAAC,CAQjB;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,WAAW,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE,GAAG,SAAS,EAAE,CAO5F;AAeD,8EAA8E;AAC9E,wBAAsB,YAAY,CAChC,OAAO,EAAE,YAAY,EACrB,OAAO,EAAE,aAAa,EACtB,MAAM,EAAE,MAAM,EAAE,EAChB,IAAI,EAAE,eAAe,EAAE,GACtB,OAAO,CAAC,MAAM,CAAC,CA6BjB"}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectReconcileTargets = collectReconcileTargets;
|
|
4
|
-
exports.pushEmbeddings = pushEmbeddings;
|
|
5
|
-
exports.selectOrphans = selectOrphans;
|
|
6
|
-
exports.pruneOrphans = pruneOrphans;
|
|
7
|
-
const paginate_1 = require("../../shared/dynamodb/paginate");
|
|
8
|
-
const item_mapper_1 = require("./item-mapper");
|
|
9
|
-
const keys_1 = require("./keys");
|
|
10
|
-
const query_1 = require("./query");
|
|
11
|
-
const semantic_search_1 = require("./semantic-search");
|
|
12
|
-
const write_verify_1 = require("./write-verify");
|
|
13
|
-
/** Stable, collision-free identity for a (namespace, key) pair. */
|
|
14
|
-
function refIdentity(namespace, key) {
|
|
15
|
-
return JSON.stringify([...namespace, key]);
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Enumerate canonical items under `prefix`, recomputing each embedding. A failed
|
|
19
|
-
* embedding rejects the whole reconcile by design: silently skipping an item
|
|
20
|
-
* would drop it from the live set, after which {@link selectOrphans} would prune
|
|
21
|
-
* its still-valid backend vector. Fail-fast keeps the backend from losing data.
|
|
22
|
-
*/
|
|
23
|
-
async function collectReconcileTargets(context, prefix) {
|
|
24
|
-
const targets = [];
|
|
25
|
-
const source = (0, paginate_1.paginateQuery)({
|
|
26
|
-
client: context.client,
|
|
27
|
-
params: (0, query_1.scopedQuery)(context.tableName, prefix),
|
|
28
|
-
maxItems: context.maxScanItems,
|
|
29
|
-
});
|
|
30
|
-
for await (const raw of source) {
|
|
31
|
-
const record = (0, item_mapper_1.narrowStoreRecord)(raw);
|
|
32
|
-
if (!record) {
|
|
33
|
-
context.logger.warn('reconcileVectorIndex: skipped a row that is not a store item', {
|
|
34
|
-
sortKey: raw.SK,
|
|
35
|
-
});
|
|
36
|
-
continue;
|
|
37
|
-
}
|
|
38
|
-
if (!(0, keys_1.namespaceMatchesPrefix)(record.namespace, prefix))
|
|
39
|
-
continue;
|
|
40
|
-
const item = await (0, item_mapper_1.readStoreItem)(context, record);
|
|
41
|
-
const embedding = await (0, semantic_search_1.embedValue)(context, item.value);
|
|
42
|
-
targets.push({ namespace: record.namespace, key: record.key, embedding });
|
|
43
|
-
}
|
|
44
|
-
return targets;
|
|
45
|
-
}
|
|
46
|
-
/** Re-push every live embedding to the backend; returns the upsert count. */
|
|
47
|
-
async function pushEmbeddings(backend, targets) {
|
|
48
|
-
let upserted = 0;
|
|
49
|
-
for (const target of targets) {
|
|
50
|
-
if (!target.embedding)
|
|
51
|
-
continue;
|
|
52
|
-
await backend.upsert(target.namespace, target.key, target.embedding);
|
|
53
|
-
upserted += 1;
|
|
54
|
-
}
|
|
55
|
-
return upserted;
|
|
56
|
-
}
|
|
57
|
-
/** Refs present in the backend but absent from `live` — orphans to prune. */
|
|
58
|
-
function selectOrphans(backendRefs, live) {
|
|
59
|
-
const liveKeys = new Set(live
|
|
60
|
-
.filter((target) => target.embedding !== undefined)
|
|
61
|
-
.map((target) => refIdentity(target.namespace, target.key)));
|
|
62
|
-
return backendRefs.filter((ref) => !liveKeys.has(refIdentity(ref.namespace, ref.key)));
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* True when a candidate's canonical item is confirmed absent right now. The
|
|
66
|
-
* live-set snapshot and this read are not one point in time, so an item
|
|
67
|
-
* written between them looks orphaned even though it is live — and deleting
|
|
68
|
-
* its vector would silently drop a just-written item out of semantic search.
|
|
69
|
-
*/
|
|
70
|
-
async function confirmedGone(context, ref) {
|
|
71
|
-
return (0, write_verify_1.rowIsAbsent)(context, {
|
|
72
|
-
PK: (0, keys_1.partitionKey)(ref.namespace),
|
|
73
|
-
SK: (0, keys_1.sortKey)(ref.namespace, ref.key),
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
/** Delete backend vectors with no canonical item; returns the prune count. */
|
|
77
|
-
async function pruneOrphans(context, backend, prefix, live) {
|
|
78
|
-
if (!backend.listKeys) {
|
|
79
|
-
context.logger.info('reconcileVectorIndex prune skipped: backend has no listKeys', { prefix });
|
|
80
|
-
return 0;
|
|
81
|
-
}
|
|
82
|
-
const candidates = selectOrphans(await backend.listKeys(prefix), live);
|
|
83
|
-
/**
|
|
84
|
-
* Every item the snapshot actually saw, embedded or not. A candidate in here
|
|
85
|
-
* is prunable on the evidence already gathered — its item exists but yields
|
|
86
|
-
* no embedding (its indexable text became empty), so its vector really is
|
|
87
|
-
* stale. Only a candidate the snapshot never saw at all is ambiguous.
|
|
88
|
-
*/
|
|
89
|
-
const observed = new Set(live.map((target) => refIdentity(target.namespace, target.key)));
|
|
90
|
-
let pruned = 0;
|
|
91
|
-
for (const ref of candidates) {
|
|
92
|
-
if (!observed.has(refIdentity(ref.namespace, ref.key)) &&
|
|
93
|
-
!(await confirmedGone(context, ref))) {
|
|
94
|
-
context.logger.info('reconcileVectorIndex: kept a vector whose item reappeared', {
|
|
95
|
-
namespace: ref.namespace,
|
|
96
|
-
key: ref.key,
|
|
97
|
-
});
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
|
-
await backend.delete(ref.namespace, ref.key);
|
|
101
|
-
pruned += 1;
|
|
102
|
-
}
|
|
103
|
-
return pruned;
|
|
104
|
-
}
|
|
105
|
-
//# sourceMappingURL=index-reconcile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-reconcile.js","sourceRoot":"","sources":["../../../src/store/internal/index-reconcile.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA+D;AAG/D,+CAAiE;AACjE,iCAAuE;AACvE,mCAAsC;AACtC,uDAA+C;AAE/C,iDAA6C;AAS7C,mEAAmE;AACnE,SAAS,WAAW,CAAC,SAAmB,EAAE,GAAW;IACnD,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;AAC7C,CAAC;AAED;;;;;GAKG;AACI,KAAK,kCACV,OAAqB,EACrB,MAAgB;IAEhB,MAAM,OAAO,GAAsB,EAAE,CAAC;IACtC,MAAM,MAAM,GAAG,IAAA,wBAAa,EAAC;QAC3B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,MAAM,EAAE,IAAA,mBAAW,EAAC,OAAO,CAAC,SAAS,EAAE,MAAM,CAAC;QAC9C,QAAQ,EAAE,OAAO,CAAC,YAAY;KAC/B,CAAC,CAAC;IACH,IAAI,KAAK,EAAE,MA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AM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,IACE,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;YAClD,CAAC,CAAC,MAAM,aAAa,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,EACpC,CAAC;YACD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2DAA2D,EAAE;gBAC/E,SAAS,EAAE,GAAG,CAAC,SAAS;gBACxB,GAAG,EAAE,GAAG,CAAC,GAAG;aACb,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,MAAM,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,IAAI,CAAC,CAAC;IACd,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Logger } from '../../shared/logging/logger';
|
|
2
|
-
import type { VectorBackend } from '../vector-backend';
|
|
3
|
-
/**
|
|
4
|
-
* Best-effort sync of one item's embedding to the vector backend after the
|
|
5
|
-
* canonical DynamoDB write has already succeeded. A present embedding upserts;
|
|
6
|
-
* its absence deletes any stale vector. Failures are logged at `warn` and
|
|
7
|
-
* swallowed — the canonical item stands and `reconcileVectorIndex` repairs any
|
|
8
|
-
* drift — so a backend hiccup never fails an otherwise-successful put.
|
|
9
|
-
*/
|
|
10
|
-
export declare function syncVectorIndex(backend: VectorBackend, namespace: string[], key: string, embedding: number[] | undefined, logger: Logger): Promise<void>;
|
|
11
|
-
//# sourceMappingURL=index-sync.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-sync.d.ts","sourceRoot":"","sources":["../../../src/store/internal/index-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAEvD;;;;;;GAMG;AACH,wBAAsB,eAAe,CACnC,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EAAE,GAAG,SAAS,EAC/B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAWf"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.syncVectorIndex = syncVectorIndex;
|
|
4
|
-
/**
|
|
5
|
-
* Best-effort sync of one item's embedding to the vector backend after the
|
|
6
|
-
* canonical DynamoDB write has already succeeded. A present embedding upserts;
|
|
7
|
-
* its absence deletes any stale vector. Failures are logged at `warn` and
|
|
8
|
-
* swallowed — the canonical item stands and `reconcileVectorIndex` repairs any
|
|
9
|
-
* drift — so a backend hiccup never fails an otherwise-successful put.
|
|
10
|
-
*/
|
|
11
|
-
async function syncVectorIndex(backend, namespace, key, embedding, logger) {
|
|
12
|
-
try {
|
|
13
|
-
if (embedding)
|
|
14
|
-
await backend.upsert(namespace, key, embedding);
|
|
15
|
-
else
|
|
16
|
-
await backend.delete(namespace, key);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
logger.warn('store.put vector-index sync failed; reconcileVectorIndex will repair', {
|
|
20
|
-
namespace,
|
|
21
|
-
key,
|
|
22
|
-
message: error.message,
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=index-sync.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-sync.js","sourceRoot":"","sources":["../../../src/store/internal/index-sync.ts"],"names":[],"mappings":";;;AAGA;;;;;;GAMG;AACI,KAAK,0BACV,OAAsB,EACtB,SAAmB,EACnB,GAAW,EACX,SAA+B,EAC/B,MAAc;IAEd,IAAI,CAAC;QACH,IAAI,SAAS;YAAE,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;;YAC1D,MAAM,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;IAC5C,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,CAAC,IAAI,CAAC,sEAAsE,EAAE;YAClF,SAAS;YACT,GAAG;YACH,OAAO,EAAG,KAAe,CAAC,OAAO;SAClC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Item } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
import type { DocItem } from '../../shared/dynamodb/types';
|
|
3
|
-
import type { StoreItemRecord } from '../types';
|
|
4
|
-
import type { JsonValue } from './filter';
|
|
5
|
-
import type { StoreContext } from './setup';
|
|
6
|
-
/**
|
|
7
|
-
* Narrow a raw scanned row to a {@link StoreItemRecord}, or `undefined` for a
|
|
8
|
-
* foreign row on a shared table (no `namespace`). Replaces an unchecked cast at
|
|
9
|
-
* the scan boundary, the one place rows are not written by this library.
|
|
10
|
-
*/
|
|
11
|
-
export declare function narrowStoreRecord(raw: DocItem): StoreItemRecord | undefined;
|
|
12
|
-
/** Fields controlling a stored item's timestamps, embedding, ttl, and S3 key nonce. */
|
|
13
|
-
export interface BuildItemOptions {
|
|
14
|
-
createdAt: string;
|
|
15
|
-
updatedAt: string;
|
|
16
|
-
embedding?: number[];
|
|
17
|
-
ttlTimestamp?: number;
|
|
18
|
-
/** Per-call nonce: uniquifies the S3 key and becomes the row's revision token. */
|
|
19
|
-
nonce?: string;
|
|
20
|
-
}
|
|
21
|
-
/** Encode a value into the DynamoDB record for a stored item. */
|
|
22
|
-
export declare function buildStoreItem(context: StoreContext, namespace: string[], key: string, value: Record<string, JsonValue>, options: BuildItemOptions): Promise<StoreItemRecord>;
|
|
23
|
-
/** Decode a DynamoDB record back into a store {@link Item}. */
|
|
24
|
-
export declare function readStoreItem(context: StoreContext, record: StoreItemRecord): Promise<Item>;
|
|
25
|
-
//# sourceMappingURL=item-mapper.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item-mapper.d.ts","sourceRoot":"","sources":["../../../src/store/internal/item-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iCAAiC,CAAC;AAG5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAE5C;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAE3E;AAOD,uFAAuF;AACvF,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kFAAkF;IAClF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,iEAAiE;AACjE,wBAAsB,cAAc,CAClC,OAAO,EAAE,YAAY,EACrB,SAAS,EAAE,MAAM,EAAE,EACnB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAChC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,CAkB1B;AAED,+DAA+D;AAC/D,wBAAsB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAYjG"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.narrowStoreRecord = narrowStoreRecord;
|
|
4
|
-
exports.buildStoreItem = buildStoreItem;
|
|
5
|
-
exports.readStoreItem = readStoreItem;
|
|
6
|
-
const codec_1 = require("../../shared/codec/codec");
|
|
7
|
-
const keys_1 = require("./keys");
|
|
8
|
-
/**
|
|
9
|
-
* Narrow a raw scanned row to a {@link StoreItemRecord}, or `undefined` for a
|
|
10
|
-
* foreign row on a shared table (no `namespace`). Replaces an unchecked cast at
|
|
11
|
-
* the scan boundary, the one place rows are not written by this library.
|
|
12
|
-
*/
|
|
13
|
-
function narrowStoreRecord(raw) {
|
|
14
|
-
return Array.isArray(raw.namespace) ? raw : undefined;
|
|
15
|
-
}
|
|
16
|
-
/** Map a store context to the codec collaborators. */
|
|
17
|
-
function storeCodecDeps(context) {
|
|
18
|
-
return { serde: context.serde, compression: context.compression, offloader: context.offloader };
|
|
19
|
-
}
|
|
20
|
-
/** Encode a value into the DynamoDB record for a stored item. */
|
|
21
|
-
async function buildStoreItem(context, namespace, key, value, options) {
|
|
22
|
-
const descriptor = await (0, codec_1.encodePayload)(value, storeCodecDeps(context), {
|
|
23
|
-
keyParts: options.nonce === undefined ? [...namespace, key] : [...namespace, key, options.nonce],
|
|
24
|
-
});
|
|
25
|
-
const record = {
|
|
26
|
-
PK: (0, keys_1.partitionKey)(namespace),
|
|
27
|
-
SK: (0, keys_1.sortKey)(namespace, key),
|
|
28
|
-
namespace,
|
|
29
|
-
key,
|
|
30
|
-
value: descriptor,
|
|
31
|
-
createdAt: options.createdAt,
|
|
32
|
-
updatedAt: options.updatedAt,
|
|
33
|
-
};
|
|
34
|
-
if (options.embedding)
|
|
35
|
-
record.embedding = options.embedding;
|
|
36
|
-
if (options.ttlTimestamp !== undefined)
|
|
37
|
-
record.ttl = options.ttlTimestamp;
|
|
38
|
-
if (options.nonce !== undefined)
|
|
39
|
-
record.rev = options.nonce;
|
|
40
|
-
return record;
|
|
41
|
-
}
|
|
42
|
-
/** Decode a DynamoDB record back into a store {@link Item}. */
|
|
43
|
-
async function readStoreItem(context, record) {
|
|
44
|
-
const value = await (0, codec_1.decodePayload)(record.value, storeCodecDeps(context));
|
|
45
|
-
return {
|
|
46
|
-
namespace: record.namespace,
|
|
47
|
-
key: record.key,
|
|
48
|
-
value,
|
|
49
|
-
createdAt: new Date(record.createdAt),
|
|
50
|
-
updatedAt: new Date(record.updatedAt),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=item-mapper.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"item-mapper.js","sourceRoot":"","sources":["../../../src/store/internal/item-mapper.ts"],"names":[],"mappings":";;;;;AAEA,oDAAwF;AAIxF,iCAA+C;AAG/C;;;;GAIG;AACH,2BAAkC,GAAY;IAC5C,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAE,GAAuB,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7E,CAAC;AAED,sDAAsD;AACtD,SAAS,cAAc,CAAC,OAAqB;IAC3C,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;AAClG,CAAC;AAYD,iEAAiE;AAC1D,KAAK,yBACV,OAAqB,EACrB,SAAmB,EACnB,GAAW,EACX,KAAgC,EAChC,OAAyB;IAEzB,MAAM,UAAU,GAAG,MAAM,IAAA,qBAAa,EAAC,KAAK,EAAE,cAAc,CAAC,OAAO,CAAC,EAAE;QACrE,QAAQ,EACN,OAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC;KACzF,CAAC,CAAC;IACH,MAAM,MAAM,GAAoB;QAC9B,EAAE,EAAE,IAAA,mBAAY,EAAC,SAAS,CAAC;QAC3B,EAAE,EAAE,IAAA,cAAO,EAAC,SAAS,EAAE,GAAG,CAAC;QAC3B,SAAS;QACT,GAAG;QACH,KAAK,EAAE,UAAU;QACjB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS;KAC7B,CAAC;IACF,IAAI,OAAO,CAAC,SAAS;QAAE,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;IAC5D,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,YAAY,CAAC;IAC1E,IAAI,OAAO,CAAC,KAAK,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,+DAA+D;AACxD,KAAK,wBAAwB,OAAqB,EAAE,MAAuB;IAChF,MAAM,KAAK,GAAG,MAAM,IAAA,qBAAa,EAC/B,MAAM,CAAC,KAAK,EACZ,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;IACF,OAAO;QACL,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,GAAG,EAAE,MAAM,CAAC,GAAG;QACf,KAAK;QACL,SAAS,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;QACrC,SAAS,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC;KACtC,CAAC;AACJ,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/** Separator joining namespace elements (and the trailing key) in the sort key. */
|
|
2
|
-
export declare const NAMESPACE_SEPARATOR = "#";
|
|
3
|
-
/** Partition key for an item: the adapter tag plus the scope-root element. */
|
|
4
|
-
export declare function partitionKey(namespace: string[]): string;
|
|
5
|
-
/** Sort key: the rest of the namespace plus the key, separator-joined. */
|
|
6
|
-
export declare function sortKey(namespace: string[], key: string): string;
|
|
7
|
-
/**
|
|
8
|
-
* `begins_with` prefix selecting a scoped subtree within `prefix[0]`'s
|
|
9
|
-
* partition. Terminated with the separator so `['users','u1']` does not match a
|
|
10
|
-
* sibling like `u10`. An empty rest yields '' (matches the whole partition).
|
|
11
|
-
*/
|
|
12
|
-
export declare function sortKeyPrefix(prefix: string[]): string;
|
|
13
|
-
/**
|
|
14
|
-
* True when `namespace` starts with `prefix`, compared element-by-element (not
|
|
15
|
-
* as a string prefix, so ["userspace"] does not match prefix ["users"]).
|
|
16
|
-
*/
|
|
17
|
-
export declare function namespaceMatchesPrefix(namespace: string[], prefix: string[]): boolean;
|
|
18
|
-
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../../../src/store/internal/keys.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,MAAM,CAAC;AASvC,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,CAExD;AAED,0EAA0E;AAC1E,wBAAgB,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAEhE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAGtD;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAGrF"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NAMESPACE_SEPARATOR = void 0;
|
|
4
|
-
exports.partitionKey = partitionKey;
|
|
5
|
-
exports.sortKey = sortKey;
|
|
6
|
-
exports.sortKeyPrefix = sortKeyPrefix;
|
|
7
|
-
exports.namespaceMatchesPrefix = namespaceMatchesPrefix;
|
|
8
|
-
/** Separator joining namespace elements (and the trailing key) in the sort key. */
|
|
9
|
-
exports.NAMESPACE_SEPARATOR = '#';
|
|
10
|
-
/**
|
|
11
|
-
* Adapter tag prefixed to every store partition key — see the equivalent in
|
|
12
|
-
* checkpointer/internal/keys.ts for why the three adapters' partitions must
|
|
13
|
-
* not overlap on a shared table.
|
|
14
|
-
*/
|
|
15
|
-
const ADAPTER_PARTITION_PREFIX = `STORE${exports.NAMESPACE_SEPARATOR}`;
|
|
16
|
-
/** Partition key for an item: the adapter tag plus the scope-root element. */
|
|
17
|
-
function partitionKey(namespace) {
|
|
18
|
-
return `${ADAPTER_PARTITION_PREFIX}${namespace[0]}`;
|
|
19
|
-
}
|
|
20
|
-
/** Sort key: the rest of the namespace plus the key, separator-joined. */
|
|
21
|
-
function sortKey(namespace, key) {
|
|
22
|
-
return [...namespace.slice(1), key].join(exports.NAMESPACE_SEPARATOR);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `begins_with` prefix selecting a scoped subtree within `prefix[0]`'s
|
|
26
|
-
* partition. Terminated with the separator so `['users','u1']` does not match a
|
|
27
|
-
* sibling like `u10`. An empty rest yields '' (matches the whole partition).
|
|
28
|
-
*/
|
|
29
|
-
function sortKeyPrefix(prefix) {
|
|
30
|
-
const rest = prefix.slice(1);
|
|
31
|
-
return rest.length === 0 ? '' : `${rest.join(exports.NAMESPACE_SEPARATOR)}${exports.NAMESPACE_SEPARATOR}`;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* True when `namespace` starts with `prefix`, compared element-by-element (not
|
|
35
|
-
* as a string prefix, so ["userspace"] does not match prefix ["users"]).
|
|
36
|
-
*/
|
|
37
|
-
function namespaceMatchesPrefix(namespace, prefix) {
|
|
38
|
-
if (prefix.length > namespace.length)
|
|
39
|
-
return false;
|
|
40
|
-
return prefix.every((element, index) => namespace[index] === element);
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/store/internal/keys.ts"],"names":[],"mappings":";;;;;;;AAAA,mFAAmF;AACtE,QAAA,mBAAmB,GAAG,GAAG,CAAC;AAEvC;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,QAAQ,QAAA,mBAAmB,EAAE,CAAC;AAE/D,8EAA8E;AAC9E,sBAA6B,SAAmB;IAC9C,OAAO,GAAG,wBAAwB,GAAG,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;AACtD,CAAC;AAED,0EAA0E;AAC1E,iBAAwB,SAAmB,EAAE,GAAW;IACtD,OAAO,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,QAAA,mBAAmB,CAAC,CAAC;AAChE,CAAC;AAED;;;;GAIG;AACH,uBAA8B,MAAgB;IAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC7B,OAAO,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAA,mBAAmB,CAAC,GAAG,QAAA,mBAAmB,EAAE,CAAC;AAC5F,CAAC;AAED;;;GAGG;AACH,gCAAuC,SAAmB,EAAE,MAAgB;IAC1E,IAAI,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IACnD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,OAAO,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { MatchCondition } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
/** True when `namespace` satisfies a prefix/suffix match condition (with `*`). */
|
|
3
|
-
export declare function matchNamespace(namespace: string[], condition: MatchCondition): boolean;
|
|
4
|
-
/** Cap a namespace to at most `maxDepth` elements (no-op when undefined). */
|
|
5
|
-
export declare function truncateDepth(namespace: string[], maxDepth?: number): string[];
|
|
6
|
-
/**
|
|
7
|
-
* Leading concrete (non-wildcard) elements of the first prefix condition. An
|
|
8
|
-
* empty result means the listing cannot be scoped to a single partition and
|
|
9
|
-
* must fall back to a Scan.
|
|
10
|
-
*/
|
|
11
|
-
export declare function prefixRoot(conditions?: MatchCondition[]): string[];
|
|
12
|
-
//# sourceMappingURL=namespace-match.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"namespace-match.d.ts","sourceRoot":"","sources":["../../../src/store/internal/namespace-match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAQtE,kFAAkF;AAClF,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,cAAc,GAAG,OAAO,CAQtF;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,GAAG,MAAM,EAAE,CASlE"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchNamespace = matchNamespace;
|
|
4
|
-
exports.truncateDepth = truncateDepth;
|
|
5
|
-
exports.prefixRoot = prefixRoot;
|
|
6
|
-
const WILDCARD = '*';
|
|
7
|
-
function segmentMatches(actual, path) {
|
|
8
|
-
return path.every((element, index) => element === WILDCARD || element === actual[index]);
|
|
9
|
-
}
|
|
10
|
-
/** True when `namespace` satisfies a prefix/suffix match condition (with `*`). */
|
|
11
|
-
function matchNamespace(namespace, condition) {
|
|
12
|
-
const { matchType, path } = condition;
|
|
13
|
-
if (path.length > namespace.length)
|
|
14
|
-
return false;
|
|
15
|
-
const slice = matchType === 'prefix'
|
|
16
|
-
? namespace.slice(0, path.length)
|
|
17
|
-
: namespace.slice(namespace.length - path.length);
|
|
18
|
-
return segmentMatches(slice, path);
|
|
19
|
-
}
|
|
20
|
-
/** Cap a namespace to at most `maxDepth` elements (no-op when undefined). */
|
|
21
|
-
function truncateDepth(namespace, maxDepth) {
|
|
22
|
-
return maxDepth === undefined ? namespace : namespace.slice(0, maxDepth);
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Leading concrete (non-wildcard) elements of the first prefix condition. An
|
|
26
|
-
* empty result means the listing cannot be scoped to a single partition and
|
|
27
|
-
* must fall back to a Scan.
|
|
28
|
-
*/
|
|
29
|
-
function prefixRoot(conditions) {
|
|
30
|
-
const prefixCondition = conditions?.find((condition) => condition.matchType === 'prefix');
|
|
31
|
-
if (!prefixCondition)
|
|
32
|
-
return [];
|
|
33
|
-
const root = [];
|
|
34
|
-
for (const element of prefixCondition.path) {
|
|
35
|
-
if (element === WILDCARD)
|
|
36
|
-
break;
|
|
37
|
-
root.push(element);
|
|
38
|
-
}
|
|
39
|
-
return root;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=namespace-match.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"namespace-match.js","sourceRoot":"","sources":["../../../src/store/internal/namespace-match.ts"],"names":[],"mappings":";;;;;AAEA,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,SAAS,cAAc,CAAC,MAAgB,EAAE,IAAsB;IAC9D,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,MAAM,CAAC,KAAK,CAAC,C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
3
|
-
import type { StoreContext } from './setup';
|
|
4
|
-
/**
|
|
5
|
-
* Commit `record`, re-reading and retrying while another writer holds the row,
|
|
6
|
-
* and return the state this write actually superseded — the only descriptor
|
|
7
|
-
* safe to delete afterwards.
|
|
8
|
-
*
|
|
9
|
-
* Without the swap both racers read the same previous descriptor, both commit,
|
|
10
|
-
* and both delete it, orphaning the loser's own upload. Retrying against the
|
|
11
|
-
* *re-read* state is what makes each writer supersede exactly one payload.
|
|
12
|
-
*
|
|
13
|
-
* A rejection is not proof a competitor won: `withDynamoDBRetry` retries
|
|
14
|
-
* transient errors, so an attempt can commit server-side, its response can be
|
|
15
|
-
* lost, and the retried put can hit the row it just wrote and fail the same
|
|
16
|
-
* guard — indistinguishable from a competitor's win by the rejection alone.
|
|
17
|
-
* Each attempt's pinned observation is captured in `attempted` before the
|
|
18
|
-
* put, so that when a re-read finds the row already holding *this call's
|
|
19
|
-
* own* `rev`, the swap returns whatever `attempted` held — never this
|
|
20
|
-
* record's own just-committed value, which would strand the live row
|
|
21
|
-
* pointing at a deleted object. That comparison is guarded on `rev` being
|
|
22
|
-
* set: `rev` is optional on the record type, and an unnonced record against a
|
|
23
|
-
* pre-0.9.0 revision-less row would otherwise match `undefined === undefined`
|
|
24
|
-
* and claim a race it never entered.
|
|
25
|
-
*
|
|
26
|
-
* On exhaustion the write proceeds unconditionally and warns. That is
|
|
27
|
-
* deliberate: the fallback is precisely the pre-0.9.0 behaviour — one possible
|
|
28
|
-
* orphan, reclaimed by a lifecycle rule — so pathological contention degrades
|
|
29
|
-
* instead of turning a working put into an error. `createdAt` is refreshed from
|
|
30
|
-
* each re-read so a row created by whoever won keeps its true creation time.
|
|
31
|
-
*/
|
|
32
|
-
export declare function putWithRevisionSwap(context: StoreContext, record: StoreItemRecord, existing: ExistingRecordMeta): Promise<ExistingRecordMeta>;
|
|
33
|
-
//# sourceMappingURL=overwrite-swap.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overwrite-swap.d.ts","sourceRoot":"","sources":["../../../src/store/internal/overwrite-swap.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,KAAK,kBAAkB,EAAgB,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAc5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,YAAY,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,kBAAkB,CAAC,CAqB7B"}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.putWithRevisionSwap = putWithRevisionSwap;
|
|
4
|
-
const conditional_put_1 = require("../../shared/dynamodb/conditional-put");
|
|
5
|
-
const retry_1 = require("../../shared/dynamodb/retry");
|
|
6
|
-
const read_existing_1 = require("./read-existing");
|
|
7
|
-
/** Put the record, optionally pinned to the revision the caller observed. */
|
|
8
|
-
async function put(context, record, observed) {
|
|
9
|
-
const guard = observed ? (0, conditional_put_1.revisionGuard)(conditional_put_1.REVISION_ATTRIBUTE, observed) : {};
|
|
10
|
-
await (0, retry_1.withDynamoDBRetry)(() => context.client.put({ TableName: context.tableName, Item: record, ...guard }));
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Commit `record`, re-reading and retrying while another writer holds the row,
|
|
14
|
-
* and return the state this write actually superseded — the only descriptor
|
|
15
|
-
* safe to delete afterwards.
|
|
16
|
-
*
|
|
17
|
-
* Without the swap both racers read the same previous descriptor, both commit,
|
|
18
|
-
* and both delete it, orphaning the loser's own upload. Retrying against the
|
|
19
|
-
* *re-read* state is what makes each writer supersede exactly one payload.
|
|
20
|
-
*
|
|
21
|
-
* A rejection is not proof a competitor won: `withDynamoDBRetry` retries
|
|
22
|
-
* transient errors, so an attempt can commit server-side, its response can be
|
|
23
|
-
* lost, and the retried put can hit the row it just wrote and fail the same
|
|
24
|
-
* guard — indistinguishable from a competitor's win by the rejection alone.
|
|
25
|
-
* Each attempt's pinned observation is captured in `attempted` before the
|
|
26
|
-
* put, so that when a re-read finds the row already holding *this call's
|
|
27
|
-
* own* `rev`, the swap returns whatever `attempted` held — never this
|
|
28
|
-
* record's own just-committed value, which would strand the live row
|
|
29
|
-
* pointing at a deleted object. That comparison is guarded on `rev` being
|
|
30
|
-
* set: `rev` is optional on the record type, and an unnonced record against a
|
|
31
|
-
* pre-0.9.0 revision-less row would otherwise match `undefined === undefined`
|
|
32
|
-
* and claim a race it never entered.
|
|
33
|
-
*
|
|
34
|
-
* On exhaustion the write proceeds unconditionally and warns. That is
|
|
35
|
-
* deliberate: the fallback is precisely the pre-0.9.0 behaviour — one possible
|
|
36
|
-
* orphan, reclaimed by a lifecycle rule — so pathological contention degrades
|
|
37
|
-
* instead of turning a working put into an error. `createdAt` is refreshed from
|
|
38
|
-
* each re-read so a row created by whoever won keeps its true creation time.
|
|
39
|
-
*/
|
|
40
|
-
async function putWithRevisionSwap(context, record, existing) {
|
|
41
|
-
let observed = existing;
|
|
42
|
-
for (let attempt = 1; attempt <= conditional_put_1.OVERWRITE_CAS_MAX_ATTEMPTS; attempt++) {
|
|
43
|
-
const attempted = observed;
|
|
44
|
-
try {
|
|
45
|
-
await put(context, record, attempted);
|
|
46
|
-
return attempted;
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (!(0, conditional_put_1.isConditionalCheckFailed)(error))
|
|
50
|
-
throw error;
|
|
51
|
-
observed = await (0, read_existing_1.readExisting)(context, record.PK, record.SK);
|
|
52
|
-
if (record.rev !== undefined && observed.revision === record.rev)
|
|
53
|
-
return attempted;
|
|
54
|
-
record.createdAt = observed.createdAt ?? record.createdAt;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
context.logger.warn('store.put: compare-and-swap exhausted; overwriting unconditionally, which can orphan one ' +
|
|
58
|
-
'S3 object under a concurrent put (reclaimed by ensureS3LifecycleRule)', { namespace: record.namespace, key: record.key, attempts: conditional_put_1.OVERWRITE_CAS_MAX_ATTEMPTS });
|
|
59
|
-
await put(context, record);
|
|
60
|
-
return observed;
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=overwrite-swap.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overwrite-swap.js","sourceRoot":"","sources":["../../../src/store/internal/overwrite-swap.ts"],"names":[],"mappings":";;;AAAA,2EAK+C;AAC/C,uDAAgE;AAEhE,mDAAwE;AAGxE,6EAA6E;AAC7E,KAAK,UAAU,GAAG,CAChB,OAAqB,EACrB,MAAuB,EACvB,QAA6B;IAE7B,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAA,+BAAa,EAAC,oCAAkB,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1E,MAAM,IAAA,yBAAiB,EAAC,GAAG,EAAE,CAC3B,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACI,KAAK,8BACV,OAAqB,EACrB,MAAuB,EACvB,QAA4B;IAE5B,IAAI,QAAQ,GAAG,QAAQ,CAAC;IACxB,KAAK,IAAI,OAAO,GAAG,CAAC,EAAE,OAAO,IAAI,4CAA0B,EAAE,OAAO,EAAE,EAAE,CAAC;QACvE,MAAM,SAAS,GAAG,QAAQ,CAAC;QAC3B,IAAI,CAAC;YACH,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YACtC,OAAO,SAAS,CAAC;QACnB,CAAC;QAAC,OAA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