@farukada/aws-langgraph-dynamodb-ts 0.8.0 → 1.0.0-rc.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.
Files changed (482) hide show
  1. package/README.md +282 -49
  2. package/dist/checkpointer/actions/delete-thread.d.ts +3 -2
  3. package/dist/checkpointer/actions/delete-thread.js +5 -2
  4. package/dist/checkpointer/actions/get-tuple.d.ts +3 -2
  5. package/dist/checkpointer/actions/get-tuple.js +10 -4
  6. package/dist/checkpointer/actions/list.d.ts +14 -4
  7. package/dist/checkpointer/actions/list.js +94 -61
  8. package/dist/checkpointer/actions/put-writes.d.ts +5 -5
  9. package/dist/checkpointer/actions/put-writes.js +12 -40
  10. package/dist/checkpointer/actions/put.d.ts +10 -3
  11. package/dist/checkpointer/actions/put.js +42 -12
  12. package/dist/checkpointer/internal/assemble.d.ts +10 -3
  13. package/dist/checkpointer/internal/assemble.js +7 -6
  14. package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +24 -0
  15. package/dist/checkpointer/internal/checkpoint-write-verify.js +67 -0
  16. package/dist/checkpointer/internal/configurable.d.ts +0 -1
  17. package/dist/checkpointer/internal/configurable.js +10 -9
  18. package/dist/checkpointer/internal/fetch.d.ts +14 -5
  19. package/dist/checkpointer/internal/fetch.js +56 -14
  20. package/dist/checkpointer/internal/filter-match.d.ts +3 -2
  21. package/dist/checkpointer/internal/filter-match.js +4 -3
  22. package/dist/checkpointer/internal/item-reader.d.ts +31 -6
  23. package/dist/checkpointer/internal/item-reader.js +54 -15
  24. package/dist/checkpointer/internal/item-writer.d.ts +12 -3
  25. package/dist/checkpointer/internal/item-writer.js +26 -10
  26. package/dist/checkpointer/internal/keys.d.ts +11 -1
  27. package/dist/checkpointer/internal/keys.js +33 -3
  28. package/dist/checkpointer/internal/list-scope.d.ts +61 -0
  29. package/dist/checkpointer/internal/list-scope.js +108 -0
  30. package/dist/checkpointer/internal/pending-sends.d.ts +13 -0
  31. package/dist/checkpointer/internal/pending-sends.js +29 -0
  32. package/dist/checkpointer/internal/query.d.ts +2 -1
  33. package/dist/checkpointer/internal/query.js +9 -3
  34. package/dist/checkpointer/internal/regular-write.d.ts +28 -0
  35. package/dist/checkpointer/internal/regular-write.js +66 -0
  36. package/dist/checkpointer/internal/setup.d.ts +3 -1
  37. package/dist/checkpointer/internal/setup.js +10 -8
  38. package/dist/checkpointer/internal/special-write-cas.d.ts +29 -0
  39. package/dist/checkpointer/internal/special-write-cas.js +104 -0
  40. package/dist/checkpointer/internal/special-write-cleanup.d.ts +19 -14
  41. package/dist/checkpointer/internal/special-write-cleanup.js +35 -87
  42. package/dist/checkpointer/internal/special-write-verify.d.ts +53 -0
  43. package/dist/checkpointer/internal/special-write-verify.js +80 -0
  44. package/dist/checkpointer/internal/stored-channels.d.ts +31 -0
  45. package/dist/checkpointer/internal/stored-channels.js +70 -0
  46. package/dist/checkpointer/internal/validation.d.ts +11 -6
  47. package/dist/checkpointer/internal/validation.js +19 -9
  48. package/dist/checkpointer/internal/write-guard.d.ts +8 -9
  49. package/dist/checkpointer/internal/write-guard.js +16 -16
  50. package/dist/checkpointer/internal/write-index.d.ts +8 -1
  51. package/dist/checkpointer/internal/write-index.js +6 -3
  52. package/dist/checkpointer/saver.d.ts +50 -10
  53. package/dist/checkpointer/saver.js +59 -17
  54. package/dist/checkpointer/types.d.ts +14 -1
  55. package/dist/checkpointer/types.js +0 -1
  56. package/dist/factory/factory.d.ts +22 -25
  57. package/dist/factory/factory.js +58 -18
  58. package/dist/factory/types.d.ts +57 -0
  59. package/dist/factory/types.js +2 -0
  60. package/dist/history/actions/add-messages.d.ts +1 -2
  61. package/dist/history/actions/add-messages.js +4 -4
  62. package/dist/history/actions/clear.d.ts +3 -2
  63. package/dist/history/actions/clear.js +5 -2
  64. package/dist/history/actions/get-messages.d.ts +13 -6
  65. package/dist/history/actions/get-messages.js +63 -42
  66. package/dist/history/actions/list-sessions.d.ts +1 -1
  67. package/dist/history/actions/list-sessions.js +8 -12
  68. package/dist/history/actions/reconcile-count.d.ts +1 -2
  69. package/dist/history/actions/reconcile-count.js +20 -7
  70. package/dist/history/chat-message-history.d.ts +51 -26
  71. package/dist/history/chat-message-history.js +60 -30
  72. package/dist/history/internal/append-saga.d.ts +7 -2
  73. package/dist/history/internal/append-saga.js +58 -14
  74. package/dist/history/internal/compensation.d.ts +6 -2
  75. package/dist/history/internal/compensation.js +14 -6
  76. package/dist/history/internal/item-mapper.d.ts +0 -3
  77. package/dist/history/internal/item-mapper.js +2 -8
  78. package/dist/history/internal/keys.d.ts +0 -1
  79. package/dist/history/internal/keys.js +0 -1
  80. package/dist/history/internal/message-chunker.d.ts +0 -1
  81. package/dist/history/internal/message-chunker.js +0 -1
  82. package/dist/history/internal/message-transaction.d.ts +0 -1
  83. package/dist/history/internal/message-transaction.js +3 -2
  84. package/dist/history/internal/message-window.d.ts +17 -0
  85. package/dist/history/internal/message-window.js +49 -0
  86. package/dist/history/internal/query.d.ts +16 -3
  87. package/dist/history/internal/query.js +13 -5
  88. package/dist/history/internal/session-count.d.ts +8 -2
  89. package/dist/history/internal/session-count.js +14 -8
  90. package/dist/history/internal/session-title.d.ts +0 -1
  91. package/dist/history/internal/session-title.js +1 -2
  92. package/dist/history/internal/session-update.d.ts +0 -1
  93. package/dist/history/internal/session-update.js +0 -1
  94. package/dist/history/internal/setup.d.ts +3 -1
  95. package/dist/history/internal/setup.js +16 -8
  96. package/dist/history/internal/title-generator.d.ts +0 -1
  97. package/dist/history/internal/title-generator.js +19 -3
  98. package/dist/history/internal/ttl-anchor.d.ts +1 -2
  99. package/dist/history/internal/ttl-anchor.js +5 -5
  100. package/dist/history/internal/validation.d.ts +19 -3
  101. package/dist/history/internal/validation.js +41 -4
  102. package/dist/history/session-adapter.d.ts +9 -3
  103. package/dist/history/session-adapter.js +6 -3
  104. package/dist/history/types.d.ts +23 -2
  105. package/dist/history/types.js +0 -1
  106. package/dist/index.d.ts +12 -5
  107. package/dist/index.js +5 -3
  108. package/dist/shared/clock.d.ts +6 -1
  109. package/dist/shared/clock.js +9 -1
  110. package/dist/shared/codec/codec.d.ts +26 -17
  111. package/dist/shared/codec/codec.js +46 -24
  112. package/dist/shared/codec/compression.d.ts +1 -2
  113. package/dist/shared/codec/compression.js +2 -3
  114. package/dist/shared/codec/descriptor-keys.d.ts +11 -3
  115. package/dist/shared/codec/descriptor-keys.js +2 -2
  116. package/dist/shared/codec/encode.d.ts +13 -0
  117. package/dist/shared/codec/encode.js +43 -0
  118. package/dist/shared/codec/json-serde.d.ts +0 -1
  119. package/dist/shared/codec/json-serde.js +0 -1
  120. package/dist/shared/codec/payload-loss.d.ts +12 -0
  121. package/dist/shared/codec/payload-loss.js +38 -0
  122. package/dist/shared/codec/s3/adapter-config.d.ts +13 -0
  123. package/dist/shared/codec/s3/adapter-config.js +22 -0
  124. package/dist/shared/codec/s3/bounded-body.d.ts +14 -0
  125. package/dist/shared/codec/s3/bounded-body.js +47 -0
  126. package/dist/shared/codec/s3/client-types.d.ts +34 -0
  127. package/dist/shared/codec/s3/client-types.js +7 -0
  128. package/dist/shared/codec/s3/client.d.ts +11 -5
  129. package/dist/shared/codec/s3/client.js +25 -3
  130. package/dist/shared/codec/s3/config.d.ts +32 -5
  131. package/dist/shared/codec/s3/config.js +37 -5
  132. package/dist/shared/codec/s3/delete.d.ts +0 -1
  133. package/dist/shared/codec/s3/delete.js +0 -1
  134. package/dist/shared/codec/s3/key-scope.d.ts +23 -0
  135. package/dist/shared/codec/s3/key-scope.js +44 -0
  136. package/dist/shared/codec/s3/lifecycle.d.ts +11 -5
  137. package/dist/shared/codec/s3/lifecycle.js +32 -16
  138. package/dist/shared/codec/s3/offloader.d.ts +6 -2
  139. package/dist/shared/codec/s3/offloader.js +21 -3
  140. package/dist/shared/codec/s3/orphans.d.ts +6 -1
  141. package/dist/shared/codec/s3/orphans.js +15 -2
  142. package/dist/shared/codec/s3/read-write.d.ts +7 -3
  143. package/dist/shared/codec/s3/read-write.js +16 -8
  144. package/dist/shared/codec/s3/retry.d.ts +4 -4
  145. package/dist/shared/codec/s3/retry.js +13 -16
  146. package/dist/shared/concurrency.d.ts +6 -0
  147. package/dist/shared/concurrency.js +30 -0
  148. package/dist/shared/constants.d.ts +68 -5
  149. package/dist/shared/constants.js +70 -7
  150. package/dist/shared/dynamodb/abort.d.ts +9 -0
  151. package/dist/shared/dynamodb/abort.js +27 -0
  152. package/dist/shared/dynamodb/backoff.d.ts +4 -4
  153. package/dist/shared/dynamodb/backoff.js +7 -7
  154. package/dist/shared/dynamodb/batch-write.d.ts +0 -1
  155. package/dist/shared/dynamodb/batch-write.js +0 -1
  156. package/dist/shared/dynamodb/cancellation.d.ts +0 -1
  157. package/dist/shared/dynamodb/cancellation.js +0 -1
  158. package/dist/shared/dynamodb/client.d.ts +9 -2
  159. package/dist/shared/dynamodb/client.js +24 -1
  160. package/dist/shared/dynamodb/conditional-put.d.ts +67 -0
  161. package/dist/shared/dynamodb/conditional-put.js +76 -0
  162. package/dist/shared/dynamodb/drain-unprocessed.d.ts +3 -1
  163. package/dist/shared/dynamodb/drain-unprocessed.js +1 -2
  164. package/dist/shared/dynamodb/expiry.d.ts +16 -0
  165. package/dist/shared/dynamodb/expiry.js +29 -0
  166. package/dist/shared/dynamodb/paginate-core.d.ts +5 -3
  167. package/dist/shared/dynamodb/paginate-core.js +47 -17
  168. package/dist/shared/dynamodb/paginate.d.ts +0 -1
  169. package/dist/shared/dynamodb/paginate.js +1 -2
  170. package/dist/shared/dynamodb/partition-delete.d.ts +7 -1
  171. package/dist/shared/dynamodb/partition-delete.js +4 -3
  172. package/dist/shared/dynamodb/retry-classifier.d.ts +10 -2
  173. package/dist/shared/dynamodb/retry-classifier.js +42 -11
  174. package/dist/shared/dynamodb/retry-policy.d.ts +26 -0
  175. package/dist/shared/dynamodb/retry-policy.js +22 -0
  176. package/dist/shared/dynamodb/retry.d.ts +14 -1
  177. package/dist/shared/dynamodb/retry.js +11 -7
  178. package/dist/shared/dynamodb/scan.d.ts +0 -1
  179. package/dist/shared/dynamodb/scan.js +1 -2
  180. package/dist/shared/dynamodb/types.d.ts +1 -2
  181. package/dist/shared/dynamodb/types.js +0 -1
  182. package/dist/shared/errors/base-error.d.ts +14 -6
  183. package/dist/shared/errors/base-error.js +8 -9
  184. package/dist/shared/errors/boundary.d.ts +18 -0
  185. package/dist/shared/errors/boundary.js +46 -0
  186. package/dist/shared/errors/error-code.d.ts +2 -2
  187. package/dist/shared/errors/error-code.js +1 -1
  188. package/dist/shared/errors/errors.d.ts +13 -13
  189. package/dist/shared/errors/errors.js +18 -16
  190. package/dist/shared/errors/upstream-error.d.ts +16 -0
  191. package/dist/shared/errors/upstream-error.js +27 -0
  192. package/dist/shared/errors/wrap-error.d.ts +0 -9
  193. package/dist/shared/errors/wrap-error.js +0 -15
  194. package/dist/shared/logging/logger.d.ts +6 -2
  195. package/dist/shared/logging/logger.js +0 -1
  196. package/dist/shared/logging/redaction-walk.d.ts +2 -2
  197. package/dist/shared/logging/redaction-walk.js +38 -18
  198. package/dist/shared/logging/redaction.d.ts +14 -6
  199. package/dist/shared/logging/redaction.js +19 -4
  200. package/dist/shared/logging/secret-patterns.d.ts +54 -3
  201. package/dist/shared/logging/secret-patterns.js +67 -8
  202. package/dist/shared/options.d.ts +9 -4
  203. package/dist/shared/options.js +0 -1
  204. package/dist/shared/ulid.d.ts +15 -2
  205. package/dist/shared/ulid.js +35 -3
  206. package/dist/shared/validation/options.d.ts +8 -0
  207. package/dist/shared/validation/options.js +90 -0
  208. package/dist/shared/validation/primitives.d.ts +14 -10
  209. package/dist/shared/validation/primitives.js +23 -25
  210. package/dist/shared/validation/ttl.d.ts +14 -7
  211. package/dist/shared/validation/ttl.js +29 -11
  212. package/dist/store/actions/get.d.ts +11 -3
  213. package/dist/store/actions/get.js +52 -14
  214. package/dist/store/actions/list-namespaces.d.ts +0 -1
  215. package/dist/store/actions/list-namespaces.js +10 -6
  216. package/dist/store/actions/put.d.ts +0 -1
  217. package/dist/store/actions/put.js +27 -28
  218. package/dist/store/actions/reconcile-vector-index.d.ts +3 -2
  219. package/dist/store/actions/reconcile-vector-index.js +2 -3
  220. package/dist/store/actions/search.d.ts +1 -2
  221. package/dist/store/actions/search.js +11 -38
  222. package/dist/store/internal/backend-search.d.ts +1 -2
  223. package/dist/store/internal/backend-search.js +14 -7
  224. package/dist/store/internal/batch-plan.d.ts +11 -0
  225. package/dist/store/internal/batch-plan.js +52 -0
  226. package/dist/store/internal/candidates.d.ts +23 -0
  227. package/dist/store/internal/candidates.js +94 -0
  228. package/dist/store/internal/filter.d.ts +0 -1
  229. package/dist/store/internal/filter.js +25 -6
  230. package/dist/store/internal/index-reconcile.d.ts +5 -6
  231. package/dist/store/internal/index-reconcile.js +32 -13
  232. package/dist/store/internal/index-sync.d.ts +0 -1
  233. package/dist/store/internal/index-sync.js +0 -1
  234. package/dist/store/internal/item-mapper.d.ts +6 -3
  235. package/dist/store/internal/item-mapper.js +16 -6
  236. package/dist/store/internal/keys.d.ts +0 -1
  237. package/dist/store/internal/keys.js +0 -1
  238. package/dist/store/internal/namespace-match.d.ts +0 -1
  239. package/dist/store/internal/namespace-match.js +0 -1
  240. package/dist/store/internal/option-validation.d.ts +13 -0
  241. package/dist/store/internal/option-validation.js +77 -0
  242. package/dist/store/internal/overwrite-swap.d.ts +32 -0
  243. package/dist/store/internal/overwrite-swap.js +68 -0
  244. package/dist/store/internal/persist.d.ts +24 -7
  245. package/dist/store/internal/persist.js +49 -19
  246. package/dist/store/internal/query.d.ts +6 -1
  247. package/dist/store/internal/query.js +17 -1
  248. package/dist/store/internal/ranker.d.ts +7 -2
  249. package/dist/store/internal/ranker.js +10 -2
  250. package/dist/store/internal/read-existing.d.ts +23 -0
  251. package/dist/store/internal/read-existing.js +41 -0
  252. package/dist/store/internal/score-direction.d.ts +31 -0
  253. package/dist/store/internal/score-direction.js +38 -0
  254. package/dist/store/internal/search-filter.d.ts +0 -1
  255. package/dist/store/internal/search-filter.js +0 -1
  256. package/dist/store/internal/semantic-search.d.ts +26 -5
  257. package/dist/store/internal/semantic-search.js +59 -19
  258. package/dist/store/internal/setup.d.ts +6 -12
  259. package/dist/store/internal/setup.js +12 -24
  260. package/dist/store/internal/text-path.d.ts +17 -0
  261. package/dist/store/internal/text-path.js +147 -0
  262. package/dist/store/internal/validation.d.ts +8 -3
  263. package/dist/store/internal/validation.js +21 -5
  264. package/dist/store/internal/write-verify.d.ts +27 -9
  265. package/dist/store/internal/write-verify.js +35 -19
  266. package/dist/store/store.d.ts +37 -9
  267. package/dist/store/store.js +52 -17
  268. package/dist/store/types.d.ts +22 -2
  269. package/dist/store/types.js +0 -1
  270. package/dist/store/vector-backend.d.ts +6 -7
  271. package/dist/store/vector-backend.js +0 -1
  272. package/package.json +21 -15
  273. package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
  274. package/dist/checkpointer/actions/delete-thread.js.map +0 -1
  275. package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
  276. package/dist/checkpointer/actions/get-tuple.js.map +0 -1
  277. package/dist/checkpointer/actions/list.d.ts.map +0 -1
  278. package/dist/checkpointer/actions/list.js.map +0 -1
  279. package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
  280. package/dist/checkpointer/actions/put-writes.js.map +0 -1
  281. package/dist/checkpointer/actions/put.d.ts.map +0 -1
  282. package/dist/checkpointer/actions/put.js.map +0 -1
  283. package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
  284. package/dist/checkpointer/internal/assemble.js.map +0 -1
  285. package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
  286. package/dist/checkpointer/internal/configurable.js.map +0 -1
  287. package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
  288. package/dist/checkpointer/internal/fetch.js.map +0 -1
  289. package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
  290. package/dist/checkpointer/internal/filter-match.js.map +0 -1
  291. package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
  292. package/dist/checkpointer/internal/item-reader.js.map +0 -1
  293. package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
  294. package/dist/checkpointer/internal/item-writer.js.map +0 -1
  295. package/dist/checkpointer/internal/keys.d.ts.map +0 -1
  296. package/dist/checkpointer/internal/keys.js.map +0 -1
  297. package/dist/checkpointer/internal/query.d.ts.map +0 -1
  298. package/dist/checkpointer/internal/query.js.map +0 -1
  299. package/dist/checkpointer/internal/setup.d.ts.map +0 -1
  300. package/dist/checkpointer/internal/setup.js.map +0 -1
  301. package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
  302. package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
  303. package/dist/checkpointer/internal/validation.d.ts.map +0 -1
  304. package/dist/checkpointer/internal/validation.js.map +0 -1
  305. package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
  306. package/dist/checkpointer/internal/write-guard.js.map +0 -1
  307. package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
  308. package/dist/checkpointer/internal/write-index.js.map +0 -1
  309. package/dist/checkpointer/saver.d.ts.map +0 -1
  310. package/dist/checkpointer/saver.js.map +0 -1
  311. package/dist/checkpointer/types.d.ts.map +0 -1
  312. package/dist/checkpointer/types.js.map +0 -1
  313. package/dist/factory/factory.d.ts.map +0 -1
  314. package/dist/factory/factory.js.map +0 -1
  315. package/dist/history/actions/add-messages.d.ts.map +0 -1
  316. package/dist/history/actions/add-messages.js.map +0 -1
  317. package/dist/history/actions/clear.d.ts.map +0 -1
  318. package/dist/history/actions/clear.js.map +0 -1
  319. package/dist/history/actions/get-messages.d.ts.map +0 -1
  320. package/dist/history/actions/get-messages.js.map +0 -1
  321. package/dist/history/actions/list-sessions.d.ts.map +0 -1
  322. package/dist/history/actions/list-sessions.js.map +0 -1
  323. package/dist/history/actions/reconcile-count.d.ts.map +0 -1
  324. package/dist/history/actions/reconcile-count.js.map +0 -1
  325. package/dist/history/chat-message-history.d.ts.map +0 -1
  326. package/dist/history/chat-message-history.js.map +0 -1
  327. package/dist/history/internal/append-saga.d.ts.map +0 -1
  328. package/dist/history/internal/append-saga.js.map +0 -1
  329. package/dist/history/internal/compensation.d.ts.map +0 -1
  330. package/dist/history/internal/compensation.js.map +0 -1
  331. package/dist/history/internal/item-mapper.d.ts.map +0 -1
  332. package/dist/history/internal/item-mapper.js.map +0 -1
  333. package/dist/history/internal/keys.d.ts.map +0 -1
  334. package/dist/history/internal/keys.js.map +0 -1
  335. package/dist/history/internal/message-chunker.d.ts.map +0 -1
  336. package/dist/history/internal/message-chunker.js.map +0 -1
  337. package/dist/history/internal/message-transaction.d.ts.map +0 -1
  338. package/dist/history/internal/message-transaction.js.map +0 -1
  339. package/dist/history/internal/query.d.ts.map +0 -1
  340. package/dist/history/internal/query.js.map +0 -1
  341. package/dist/history/internal/session-count.d.ts.map +0 -1
  342. package/dist/history/internal/session-count.js.map +0 -1
  343. package/dist/history/internal/session-title.d.ts.map +0 -1
  344. package/dist/history/internal/session-title.js.map +0 -1
  345. package/dist/history/internal/session-update.d.ts.map +0 -1
  346. package/dist/history/internal/session-update.js.map +0 -1
  347. package/dist/history/internal/setup.d.ts.map +0 -1
  348. package/dist/history/internal/setup.js.map +0 -1
  349. package/dist/history/internal/title-generator.d.ts.map +0 -1
  350. package/dist/history/internal/title-generator.js.map +0 -1
  351. package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
  352. package/dist/history/internal/ttl-anchor.js.map +0 -1
  353. package/dist/history/internal/validation.d.ts.map +0 -1
  354. package/dist/history/internal/validation.js.map +0 -1
  355. package/dist/history/session-adapter.d.ts.map +0 -1
  356. package/dist/history/session-adapter.js.map +0 -1
  357. package/dist/history/types.d.ts.map +0 -1
  358. package/dist/history/types.js.map +0 -1
  359. package/dist/index.d.ts.map +0 -1
  360. package/dist/index.js.map +0 -1
  361. package/dist/shared/clock.d.ts.map +0 -1
  362. package/dist/shared/clock.js.map +0 -1
  363. package/dist/shared/codec/codec.d.ts.map +0 -1
  364. package/dist/shared/codec/codec.js.map +0 -1
  365. package/dist/shared/codec/compression.d.ts.map +0 -1
  366. package/dist/shared/codec/compression.js.map +0 -1
  367. package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
  368. package/dist/shared/codec/descriptor-keys.js.map +0 -1
  369. package/dist/shared/codec/json-serde.d.ts.map +0 -1
  370. package/dist/shared/codec/json-serde.js.map +0 -1
  371. package/dist/shared/codec/s3/client.d.ts.map +0 -1
  372. package/dist/shared/codec/s3/client.js.map +0 -1
  373. package/dist/shared/codec/s3/config.d.ts.map +0 -1
  374. package/dist/shared/codec/s3/config.js.map +0 -1
  375. package/dist/shared/codec/s3/delete.d.ts.map +0 -1
  376. package/dist/shared/codec/s3/delete.js.map +0 -1
  377. package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
  378. package/dist/shared/codec/s3/lifecycle.js.map +0 -1
  379. package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
  380. package/dist/shared/codec/s3/offloader.js.map +0 -1
  381. package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
  382. package/dist/shared/codec/s3/orphans.js.map +0 -1
  383. package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
  384. package/dist/shared/codec/s3/read-write.js.map +0 -1
  385. package/dist/shared/codec/s3/retry.d.ts.map +0 -1
  386. package/dist/shared/codec/s3/retry.js.map +0 -1
  387. package/dist/shared/constants.d.ts.map +0 -1
  388. package/dist/shared/constants.js.map +0 -1
  389. package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
  390. package/dist/shared/dynamodb/backoff.js.map +0 -1
  391. package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
  392. package/dist/shared/dynamodb/batch-write.js.map +0 -1
  393. package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
  394. package/dist/shared/dynamodb/cancellation.js.map +0 -1
  395. package/dist/shared/dynamodb/client.d.ts.map +0 -1
  396. package/dist/shared/dynamodb/client.js.map +0 -1
  397. package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
  398. package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
  399. package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
  400. package/dist/shared/dynamodb/paginate-core.js.map +0 -1
  401. package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
  402. package/dist/shared/dynamodb/paginate.js.map +0 -1
  403. package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
  404. package/dist/shared/dynamodb/partition-delete.js.map +0 -1
  405. package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
  406. package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
  407. package/dist/shared/dynamodb/retry.d.ts.map +0 -1
  408. package/dist/shared/dynamodb/retry.js.map +0 -1
  409. package/dist/shared/dynamodb/scan.d.ts.map +0 -1
  410. package/dist/shared/dynamodb/scan.js.map +0 -1
  411. package/dist/shared/dynamodb/types.d.ts.map +0 -1
  412. package/dist/shared/dynamodb/types.js.map +0 -1
  413. package/dist/shared/errors/base-error.d.ts.map +0 -1
  414. package/dist/shared/errors/base-error.js.map +0 -1
  415. package/dist/shared/errors/error-code.d.ts.map +0 -1
  416. package/dist/shared/errors/error-code.js.map +0 -1
  417. package/dist/shared/errors/errors.d.ts.map +0 -1
  418. package/dist/shared/errors/errors.js.map +0 -1
  419. package/dist/shared/errors/wrap-error.d.ts.map +0 -1
  420. package/dist/shared/errors/wrap-error.js.map +0 -1
  421. package/dist/shared/logging/logger.d.ts.map +0 -1
  422. package/dist/shared/logging/logger.js.map +0 -1
  423. package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
  424. package/dist/shared/logging/redaction-walk.js.map +0 -1
  425. package/dist/shared/logging/redaction.d.ts.map +0 -1
  426. package/dist/shared/logging/redaction.js.map +0 -1
  427. package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
  428. package/dist/shared/logging/secret-patterns.js.map +0 -1
  429. package/dist/shared/options.d.ts.map +0 -1
  430. package/dist/shared/options.js.map +0 -1
  431. package/dist/shared/ulid.d.ts.map +0 -1
  432. package/dist/shared/ulid.js.map +0 -1
  433. package/dist/shared/validation/primitives.d.ts.map +0 -1
  434. package/dist/shared/validation/primitives.js.map +0 -1
  435. package/dist/shared/validation/ttl.d.ts.map +0 -1
  436. package/dist/shared/validation/ttl.js.map +0 -1
  437. package/dist/store/actions/get.d.ts.map +0 -1
  438. package/dist/store/actions/get.js.map +0 -1
  439. package/dist/store/actions/list-namespaces.d.ts.map +0 -1
  440. package/dist/store/actions/list-namespaces.js.map +0 -1
  441. package/dist/store/actions/put.d.ts.map +0 -1
  442. package/dist/store/actions/put.js.map +0 -1
  443. package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
  444. package/dist/store/actions/reconcile-vector-index.js.map +0 -1
  445. package/dist/store/actions/search.d.ts.map +0 -1
  446. package/dist/store/actions/search.js.map +0 -1
  447. package/dist/store/internal/backend-search.d.ts.map +0 -1
  448. package/dist/store/internal/backend-search.js.map +0 -1
  449. package/dist/store/internal/filter.d.ts.map +0 -1
  450. package/dist/store/internal/filter.js.map +0 -1
  451. package/dist/store/internal/index-reconcile.d.ts.map +0 -1
  452. package/dist/store/internal/index-reconcile.js.map +0 -1
  453. package/dist/store/internal/index-sync.d.ts.map +0 -1
  454. package/dist/store/internal/index-sync.js.map +0 -1
  455. package/dist/store/internal/item-mapper.d.ts.map +0 -1
  456. package/dist/store/internal/item-mapper.js.map +0 -1
  457. package/dist/store/internal/keys.d.ts.map +0 -1
  458. package/dist/store/internal/keys.js.map +0 -1
  459. package/dist/store/internal/namespace-match.d.ts.map +0 -1
  460. package/dist/store/internal/namespace-match.js.map +0 -1
  461. package/dist/store/internal/persist.d.ts.map +0 -1
  462. package/dist/store/internal/persist.js.map +0 -1
  463. package/dist/store/internal/query.d.ts.map +0 -1
  464. package/dist/store/internal/query.js.map +0 -1
  465. package/dist/store/internal/ranker.d.ts.map +0 -1
  466. package/dist/store/internal/ranker.js.map +0 -1
  467. package/dist/store/internal/search-filter.d.ts.map +0 -1
  468. package/dist/store/internal/search-filter.js.map +0 -1
  469. package/dist/store/internal/semantic-search.d.ts.map +0 -1
  470. package/dist/store/internal/semantic-search.js.map +0 -1
  471. package/dist/store/internal/setup.d.ts.map +0 -1
  472. package/dist/store/internal/setup.js.map +0 -1
  473. package/dist/store/internal/validation.d.ts.map +0 -1
  474. package/dist/store/internal/validation.js.map +0 -1
  475. package/dist/store/internal/write-verify.d.ts.map +0 -1
  476. package/dist/store/internal/write-verify.js.map +0 -1
  477. package/dist/store/store.d.ts.map +0 -1
  478. package/dist/store/store.js.map +0 -1
  479. package/dist/store/types.d.ts.map +0 -1
  480. package/dist/store/types.js.map +0 -1
  481. package/dist/store/vector-backend.d.ts.map +0 -1
  482. package/dist/store/vector-backend.js.map +0 -1
@@ -9,12 +9,21 @@ const UNSCORED_RANK = -2;
9
9
  * Rank candidates by cosine similarity to `queryVector`, descending. Throws a
10
10
  * {@link ValidationError} when the candidate count exceeds `maxCandidates`
11
11
  * (steer large corpora to an external VectorBackend).
12
+ *
13
+ * A stored embedding whose length differs from the query vector's cannot be
14
+ * scored — it was written by a different embeddings model — and is ranked
15
+ * last with an undefined score. `onDimensionMismatch` is invoked once with
16
+ * how many candidates that affected, so the caller can say so instead of
17
+ * silently returning a ranking that quietly omits them.
12
18
  */
13
- function rankInMemory(candidates, queryVector, maxCandidates) {
19
+ function rankInMemory(candidates, queryVector, maxCandidates, onDimensionMismatch) {
14
20
  if (candidates.length > maxCandidates) {
15
21
  throw new errors_1.ValidationError(`Semantic search candidate set (${candidates.length}) exceeds maxSearchCandidates ` +
16
22
  `(${maxCandidates}); use a dedicated VectorBackend for large corpora`, 'maxSearchCandidates');
17
23
  }
24
+ const mismatched = candidates.filter(({ embedding }) => embedding !== undefined && embedding.length !== queryVector.length).length;
25
+ if (mismatched > 0)
26
+ onDimensionMismatch?.(mismatched);
18
27
  return candidates
19
28
  .map(({ item, embedding }) => ({
20
29
  ...item,
@@ -28,4 +37,3 @@ function rankInMemory(candidates, queryVector, maxCandidates) {
28
37
  function rankValue(item) {
29
38
  return item.score ?? UNSCORED_RANK;
30
39
  }
31
- //# sourceMappingURL=ranker.js.map
@@ -0,0 +1,23 @@
1
+ import type { DescriptorRef } from '../../shared/codec/descriptor-keys';
2
+ import type { DocItem } from '../../shared/dynamodb/types';
3
+ import type { StoreContext } from './setup';
4
+ /** The previous row's createdAt, payload descriptor and revision. */
5
+ export interface ExistingRecordMeta {
6
+ exists: boolean;
7
+ createdAt?: string;
8
+ value?: DescriptorRef;
9
+ revision?: string;
10
+ }
11
+ /**
12
+ * Read the fields a put needs from the row it is about to replace, in one
13
+ * strongly-consistent projection: `createdAt` to preserve, the descriptor's
14
+ * location and S3 key to clean up afterwards (never its inline bytes, which
15
+ * can be hundreds of kilobytes the write would only discard), and the
16
+ * revision the compare-and-swap pins.
17
+ *
18
+ * Lives apart from `actions/put.ts` so `persist.ts` can re-read on a lost swap
19
+ * without importing its own caller.
20
+ */
21
+ export declare function readExisting(context: StoreContext, pk: string, sk: string): Promise<ExistingRecordMeta>;
22
+ /** Project a raw row (a read result, or the row a rejection carried) onto {@link ExistingRecordMeta}. */
23
+ export declare function existingFrom(item: DocItem | undefined): ExistingRecordMeta;
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readExisting = readExisting;
4
+ exports.existingFrom = existingFrom;
5
+ const conditional_put_1 = require("../../shared/dynamodb/conditional-put");
6
+ const retry_1 = require("../../shared/dynamodb/retry");
7
+ /**
8
+ * Read the fields a put needs from the row it is about to replace, in one
9
+ * strongly-consistent projection: `createdAt` to preserve, the descriptor's
10
+ * location and S3 key to clean up afterwards (never its inline bytes, which
11
+ * can be hundreds of kilobytes the write would only discard), and the
12
+ * revision the compare-and-swap pins.
13
+ *
14
+ * Lives apart from `actions/put.ts` so `persist.ts` can re-read on a lost swap
15
+ * without importing its own caller.
16
+ */
17
+ async function readExisting(context, pk, sk) {
18
+ const existing = await (0, retry_1.withDynamoDBRetry)(() => context.client.get({
19
+ TableName: context.tableName,
20
+ Key: { PK: pk, SK: sk },
21
+ ConsistentRead: true,
22
+ ProjectionExpression: '#c, #r, #v.#loc, #v.#s3k',
23
+ ExpressionAttributeNames: {
24
+ '#c': 'createdAt',
25
+ '#r': conditional_put_1.REVISION_ATTRIBUTE,
26
+ '#v': 'value',
27
+ '#loc': 'location',
28
+ '#s3k': 's3Key',
29
+ },
30
+ }), context.retry);
31
+ return existingFrom(existing.Item);
32
+ }
33
+ /** Project a raw row (a read result, or the row a rejection carried) onto {@link ExistingRecordMeta}. */
34
+ function existingFrom(item) {
35
+ return {
36
+ exists: item !== undefined,
37
+ createdAt: item?.createdAt,
38
+ value: item?.value,
39
+ revision: item?.[conditional_put_1.REVISION_ATTRIBUTE],
40
+ };
41
+ }
@@ -0,0 +1,31 @@
1
+ import type { VectorMatch } from '../vector-backend';
2
+ /** Which direction a {@link VectorBackend} reports its score in. */
3
+ export type VectorScoreDirection = 'relevance' | 'distance';
4
+ /** Every direction {@link toRelevanceScores} recognises, for validating input. */
5
+ export declare const VECTOR_SCORE_DIRECTIONS: readonly VectorScoreDirection[];
6
+ /**
7
+ * Normalise a backend's matches to the relevance direction upstream
8
+ * `SearchItem.score` documents — "higher scores indicate better matches",
9
+ * typically a cosine similarity between -1 and 1.
10
+ *
11
+ * A distance is converted by **negation** rather than `1 / (1 + d)`: negation
12
+ * is monotone over the whole real line, needs no non-negativity precondition,
13
+ * and is exactly invertible, so the original distance is simply `-score`. A
14
+ * reciprocal would silently imply a different `(0, 1]` scale and is undefined
15
+ * at `d === -1`. Negative scores are already in range for this contract, so
16
+ * nothing is lost by producing them.
17
+ *
18
+ * Results are re-sorted after conversion so a backend that returns its matches
19
+ * in some other order still ranks correctly. Anything that is not `'distance'`
20
+ * is returned untouched — its own order stays authoritative, exactly as before.
21
+ *
22
+ * The test is for `'distance'` rather than against `'relevance'` on purpose:
23
+ * converting is the destructive branch, so only the exact value that asks for
24
+ * it may reach it. Testing the other way round made every unrecognised
25
+ * string — `'Distance'`, a typo, a value read from a config file — reverse the
26
+ * ranking silently, with no error and no warning (the ascending-score warning
27
+ * lives downstream of this conversion, so it could never fire). `setUpStore`
28
+ * rejects such a value outright; this keeps the failure harmless for any
29
+ * caller that reaches the function some other way.
30
+ */
31
+ export declare function toRelevanceScores(matches: VectorMatch[], direction: VectorScoreDirection): VectorMatch[];
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VECTOR_SCORE_DIRECTIONS = void 0;
4
+ exports.toRelevanceScores = toRelevanceScores;
5
+ /** Every direction {@link toRelevanceScores} recognises, for validating input. */
6
+ exports.VECTOR_SCORE_DIRECTIONS = ['relevance', 'distance'];
7
+ /**
8
+ * Normalise a backend's matches to the relevance direction upstream
9
+ * `SearchItem.score` documents — "higher scores indicate better matches",
10
+ * typically a cosine similarity between -1 and 1.
11
+ *
12
+ * A distance is converted by **negation** rather than `1 / (1 + d)`: negation
13
+ * is monotone over the whole real line, needs no non-negativity precondition,
14
+ * and is exactly invertible, so the original distance is simply `-score`. A
15
+ * reciprocal would silently imply a different `(0, 1]` scale and is undefined
16
+ * at `d === -1`. Negative scores are already in range for this contract, so
17
+ * nothing is lost by producing them.
18
+ *
19
+ * Results are re-sorted after conversion so a backend that returns its matches
20
+ * in some other order still ranks correctly. Anything that is not `'distance'`
21
+ * is returned untouched — its own order stays authoritative, exactly as before.
22
+ *
23
+ * The test is for `'distance'` rather than against `'relevance'` on purpose:
24
+ * converting is the destructive branch, so only the exact value that asks for
25
+ * it may reach it. Testing the other way round made every unrecognised
26
+ * string — `'Distance'`, a typo, a value read from a config file — reverse the
27
+ * ranking silently, with no error and no warning (the ascending-score warning
28
+ * lives downstream of this conversion, so it could never fire). `setUpStore`
29
+ * rejects such a value outright; this keeps the failure harmless for any
30
+ * caller that reaches the function some other way.
31
+ */
32
+ function toRelevanceScores(matches, direction) {
33
+ if (direction !== 'distance')
34
+ return matches;
35
+ return matches
36
+ .map((match) => ({ ...match, score: -match.score }))
37
+ .sort((left, right) => right.score - left.score);
38
+ }
@@ -1,4 +1,3 @@
1
1
  import type { Item, SearchOperation } from '@langchain/langgraph-checkpoint';
2
2
  /** True when `item` satisfies the search operation's optional metadata filter. */
3
3
  export declare function passesFilter(item: Item, op: SearchOperation): boolean;
4
- //# sourceMappingURL=search-filter.d.ts.map
@@ -8,4 +8,3 @@ function passesFilter(item, op) {
8
8
  return true;
9
9
  return (0, filter_1.matchesStoreFilter)(item.value, op.filter);
10
10
  }
11
- //# sourceMappingURL=search-filter.js.map
@@ -1,13 +1,34 @@
1
+ import type { IndexConfig } from '@langchain/langgraph-checkpoint';
1
2
  import type { JsonValue } from './filter';
2
3
  import type { StoreContext } from './setup';
3
4
  /** Cosine similarity of two equal-length vectors; 0 for zero/mismatched vectors. */
4
5
  export declare function cosineSimilarity(a: number[], b: number[]): number;
5
- /** Extract and join the indexable text of a value for the configured fields. */
6
+ /**
7
+ * Extract and join the indexable text of a value for the configured fields,
8
+ * byte-for-byte as LangGraph's `InMemoryStore` does (see `text-path.ts`), so
9
+ * the two stores embed identical text for identical documents.
10
+ */
6
11
  export declare function extractText(value: Record<string, JsonValue>, fields: string[]): string;
7
12
  /**
8
- * Embed a value for indexing, or undefined when indexing is off or the text is
9
- * empty. `fieldsOverride` (from a put's `index` option) takes precedence over
10
- * the store's configured fields.
13
+ * Reject a vector whose length disagrees with the configured `index.dims`. A
14
+ * mismatch means the embeddings model does not match the configuration, so
15
+ * every stored vector would be incomparable with every query; failing here
16
+ * surfaces that at the first put or search instead of ranking silently. The
17
+ * check is skipped when `dims` is not a positive integer, since nothing else
18
+ * in this package reads it.
19
+ */
20
+ export declare function assertVectorDims(index: IndexConfig, vector: number[], what: string): void;
21
+ /**
22
+ * Embed several values for indexing with `embedDocuments` — the document-side
23
+ * method; providers such as Titan and Cohere embed documents and queries with
24
+ * different task types, so embedding a document with `embedQuery` degrades
25
+ * retrieval — batched and order-preserving. A value with no indexable text
26
+ * yields `undefined`; without an index every value does.
27
+ */
28
+ export declare function embedValues(context: StoreContext, values: Record<string, JsonValue>[], fieldsOverride?: string[]): Promise<(number[] | undefined)[]>;
29
+ /**
30
+ * Embed one value for indexing, or undefined when indexing is off or the text
31
+ * is empty. `fieldsOverride` (from a put's `index` option) takes precedence
32
+ * over the store's configured fields. See {@link embedValues}.
11
33
  */
12
34
  export declare function embedValue(context: StoreContext, value: Record<string, JsonValue>, fieldsOverride?: string[]): Promise<number[] | undefined>;
13
- //# sourceMappingURL=semantic-search.d.ts.map
@@ -2,8 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.cosineSimilarity = cosineSimilarity;
4
4
  exports.extractText = extractText;
5
+ exports.assertVectorDims = assertVectorDims;
6
+ exports.embedValues = embedValues;
5
7
  exports.embedValue = embedValue;
6
- const langgraph_checkpoint_1 = require("@langchain/langgraph-checkpoint");
8
+ const errors_1 = require("../../shared/errors/errors");
9
+ const text_path_1 = require("./text-path");
10
+ /** Texts per `embedDocuments` call; keeps provider request sizes bounded. */
11
+ const EMBED_BATCH_SIZE = 100;
7
12
  /** Cosine similarity of two equal-length vectors; 0 for zero/mismatched vectors. */
8
13
  function cosineSimilarity(a, b) {
9
14
  if (a.length !== b.length)
@@ -20,28 +25,63 @@ function cosineSimilarity(a, b) {
20
25
  return 0;
21
26
  return dot / (Math.sqrt(normA) * Math.sqrt(normB));
22
27
  }
23
- /** Extract and join the indexable text of a value for the configured fields. */
28
+ /**
29
+ * Extract and join the indexable text of a value for the configured fields,
30
+ * byte-for-byte as LangGraph's `InMemoryStore` does (see `text-path.ts`), so
31
+ * the two stores embed identical text for identical documents.
32
+ */
24
33
  function extractText(value, fields) {
25
- const parts = [];
26
- for (const field of fields) {
27
- if (field === '$')
28
- parts.push(JSON.stringify(value));
29
- else
30
- parts.push(...(0, langgraph_checkpoint_1.getTextAtPath)(value, field));
34
+ return fields.flatMap((field) => (0, text_path_1.getTextAtPath)(value, field)).join(' ');
35
+ }
36
+ /**
37
+ * Reject a vector whose length disagrees with the configured `index.dims`. A
38
+ * mismatch means the embeddings model does not match the configuration, so
39
+ * every stored vector would be incomparable with every query; failing here
40
+ * surfaces that at the first put or search instead of ranking silently. The
41
+ * check is skipped when `dims` is not a positive integer, since nothing else
42
+ * in this package reads it.
43
+ */
44
+ function assertVectorDims(index, vector, what) {
45
+ const dims = index.dims;
46
+ if (!Number.isInteger(dims) || dims <= 0 || vector.length === dims)
47
+ return;
48
+ throw new errors_1.ValidationError(`index.embeddings returned a ${vector.length}-dimensional ${what} vector but index.dims ` +
49
+ `is ${dims}; the embeddings model does not match the configured index`, 'index.dims');
50
+ }
51
+ /**
52
+ * Embed several values for indexing with `embedDocuments` — the document-side
53
+ * method; providers such as Titan and Cohere embed documents and queries with
54
+ * different task types, so embedding a document with `embedQuery` degrades
55
+ * retrieval — batched and order-preserving. A value with no indexable text
56
+ * yields `undefined`; without an index every value does.
57
+ */
58
+ async function embedValues(context, values, fieldsOverride) {
59
+ const index = context.index;
60
+ if (!index)
61
+ return values.map(() => undefined);
62
+ const fields = fieldsOverride ?? index.fields ?? ['$'];
63
+ const pending = [];
64
+ values.forEach((value, position) => {
65
+ const text = extractText(value, fields);
66
+ if (text.length > 0)
67
+ pending.push({ text, position });
68
+ });
69
+ const vectors = values.map(() => undefined);
70
+ for (let start = 0; start < pending.length; start += EMBED_BATCH_SIZE) {
71
+ const batch = pending.slice(start, start + EMBED_BATCH_SIZE);
72
+ const embedded = await index.embeddings.embedDocuments(batch.map((entry) => entry.text));
73
+ batch.forEach((entry, i) => {
74
+ assertVectorDims(index, embedded[i], 'document');
75
+ vectors[entry.position] = embedded[i];
76
+ });
31
77
  }
32
- return parts.join(' ');
78
+ return vectors;
33
79
  }
34
80
  /**
35
- * Embed a value for indexing, or undefined when indexing is off or the text is
36
- * empty. `fieldsOverride` (from a put's `index` option) takes precedence over
37
- * the store's configured fields.
81
+ * Embed one value for indexing, or undefined when indexing is off or the text
82
+ * is empty. `fieldsOverride` (from a put's `index` option) takes precedence
83
+ * over the store's configured fields. See {@link embedValues}.
38
84
  */
39
85
  async function embedValue(context, value, fieldsOverride) {
40
- if (!context.index)
41
- return undefined;
42
- const text = extractText(value, fieldsOverride ?? context.index.fields ?? ['$']);
43
- if (text.length === 0)
44
- return undefined;
45
- return context.index.embeddings.embedQuery(text);
86
+ return (await embedValues(context, [value], fieldsOverride))[0];
46
87
  }
47
- //# sourceMappingURL=semantic-search.js.map
@@ -3,10 +3,12 @@ import type { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
3
3
  import type { IndexConfig, SerializerProtocol } from '@langchain/langgraph-checkpoint';
4
4
  import type { CompressionConfig } from '../../shared/codec/compression';
5
5
  import { S3Offloader } from '../../shared/codec/s3/offloader';
6
+ import type { RetryOptions } from '../../shared/dynamodb/retry';
6
7
  import { type Logger } from '../../shared/logging/logger';
7
8
  import type { TtlOption } from '../../shared/validation/ttl';
8
9
  import type { DynamoDBStoreOptions } from '../types';
9
10
  import type { VectorBackend } from '../vector-backend';
11
+ import type { VectorScoreDirection } from './score-direction';
10
12
  /** Resolved collaborators shared by every store action. */
11
13
  export interface StoreContext {
12
14
  client: DynamoDBDocument;
@@ -18,8 +20,11 @@ export interface StoreContext {
18
20
  logger: Logger;
19
21
  index?: IndexConfig;
20
22
  vectorBackend?: VectorBackend;
23
+ vectorScoreDirection: VectorScoreDirection;
21
24
  maxSearchCandidates: number;
22
25
  maxScanItems: number;
26
+ /** Retry budget and backoff for every DynamoDB call, with the retry debug log attached. */
27
+ retry?: RetryOptions;
23
28
  }
24
29
  /** Result of wiring up a store from its options. */
25
30
  export interface StoreSetup {
@@ -27,16 +32,5 @@ export interface StoreSetup {
27
32
  ddbClient: DynamoDBClient | undefined;
28
33
  ownsClient: boolean;
29
34
  }
30
- /**
31
- * Resolve the client, optional S3 offloader, serializer, and index config.
32
- *
33
- * A `vectorBackend` without an `index` is rejected outright rather than
34
- * silently degrading: with no embeddings configured, every `put` would compute
35
- * no vector and instruct the backend to *delete* the item's entry instead of
36
- * indexing it, and `search()` would fall through to an unranked scan-order
37
- * listing with no `.score` field and no error — a semantic query returning a
38
- * normal-looking but meaningless response. `reconcileVectorIndex` already
39
- * refused this exact misconfiguration.
40
- */
35
+ /** Validate the options, then resolve the client, offloader, serializer, and index. */
41
36
  export declare function setUpStore(options: DynamoDBStoreOptions): StoreSetup;
42
- //# sourceMappingURL=setup.d.ts.map
@@ -2,30 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setUpStore = setUpStore;
4
4
  const json_serde_1 = require("../../shared/codec/json-serde");
5
- const config_1 = require("../../shared/codec/s3/config");
5
+ const adapter_config_1 = require("../../shared/codec/s3/adapter-config");
6
6
  const offloader_1 = require("../../shared/codec/s3/offloader");
7
7
  const constants_1 = require("../../shared/constants");
8
8
  const client_1 = require("../../shared/dynamodb/client");
9
- const errors_1 = require("../../shared/errors/errors");
9
+ const retry_policy_1 = require("../../shared/dynamodb/retry-policy");
10
10
  const logger_1 = require("../../shared/logging/logger");
11
- /**
12
- * Resolve the client, optional S3 offloader, serializer, and index config.
13
- *
14
- * A `vectorBackend` without an `index` is rejected outright rather than
15
- * silently degrading: with no embeddings configured, every `put` would compute
16
- * no vector and instruct the backend to *delete* the item's entry instead of
17
- * indexing it, and `search()` would fall through to an unranked scan-order
18
- * listing with no `.score` field and no error — a semantic query returning a
19
- * normal-looking but meaningless response. `reconcileVectorIndex` already
20
- * refused this exact misconfiguration.
21
- */
11
+ const option_validation_1 = require("./option-validation");
12
+ /** Validate the options, then resolve the client, offloader, serializer, and index. */
22
13
  function setUpStore(options) {
23
- if (options.vectorBackend && !options.index) {
24
- throw new errors_1.ValidationError('vectorBackend requires a configured `index` (dims + embeddings); without one no embedding ' +
25
- 'is computed, every put would clear the item vector, and search would silently return ' +
26
- 'unranked, score-less results', 'vectorBackend');
27
- }
14
+ (0, option_validation_1.validateStoreOptions)(options);
15
+ const logger = (0, logger_1.resolveLogger)(options.logger);
28
16
  const resolved = (0, client_1.resolveDynamoDBClient)(options);
17
+ if (!resolved.ownsClient)
18
+ void (0, client_1.warnOnStackedRetries)(resolved.client, logger);
29
19
  return {
30
20
  context: {
31
21
  client: resolved.client,
@@ -33,15 +23,14 @@ function setUpStore(options) {
33
23
  serde: options.serde ?? json_serde_1.JSON_SERDE,
34
24
  compression: options.compression,
35
25
  offloader: options.s3
36
- ? new offloader_1.S3Offloader({
37
- ...options.s3,
38
- keyPrefix: options.s3.keyPrefix ?? (0, config_1.defaultAdapterKeyPrefix)(constants_1.DEFAULT_S3_KEY_PREFIX, 'store'),
39
- })
26
+ ? new offloader_1.S3Offloader((0, adapter_config_1.offloaderConfigFor)(options.s3, 'store', options.clientConfig))
40
27
  : undefined,
41
28
  ttl: options.ttl,
42
- logger: (0, logger_1.resolveLogger)(options.logger),
29
+ logger,
30
+ retry: (0, retry_policy_1.resolveRetryPolicy)(options.retry, logger),
43
31
  index: options.index,
44
32
  vectorBackend: options.vectorBackend,
33
+ vectorScoreDirection: options.vectorScoreDirection ?? 'relevance',
45
34
  maxSearchCandidates: options.maxSearchCandidates ?? constants_1.DEFAULT_MAX_SEARCH_CANDIDATES,
46
35
  maxScanItems: options.maxScanItems ?? constants_1.MAX_TOTAL_ITEMS_IN_MEMORY,
47
36
  },
@@ -49,4 +38,3 @@ function setUpStore(options) {
49
38
  ownsClient: resolved.ownsClient,
50
39
  };
51
40
  }
52
- //# sourceMappingURL=setup.js.map
@@ -0,0 +1,17 @@
1
+ import type { JsonValue } from './filter';
2
+ /**
3
+ * Split a JSON path into tokens the way LangGraph's `InMemoryStore` does: dots
4
+ * separate plain segments, while a `[…]` index and a `{…}` field group each
5
+ * become a token of their own (`tags[0]` → `['tags', '[0]']`).
6
+ */
7
+ export declare function tokenizePath(path: string): string[];
8
+ /**
9
+ * Extract the indexable text of `value` at `path`, byte-for-byte as LangGraph's
10
+ * `InMemoryStore` does (`store/utils`), so an embedding computed here matches
11
+ * one computed by the reference store for the same document. Supports plain
12
+ * paths, `[n]`/`[-n]`/`[*]` indexing, a bare `*` wildcard, `{a,b.c}` field
13
+ * groups and `$` for the whole document. The package root's `getTextAtPath` is
14
+ * a string-only variant that returns nothing for numbers, booleans, objects
15
+ * and arrays and throws on a `null` intermediate; it must not be used here.
16
+ */
17
+ export declare function getTextAtPath(value: JsonValue, path: string): string[];
@@ -0,0 +1,147 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokenizePath = tokenizePath;
4
+ exports.getTextAtPath = getTextAtPath;
5
+ /** Pretty JSON, exactly as `InMemoryStore` embeds non-scalar values. */
6
+ function pretty(value) {
7
+ return JSON.stringify(value, null, 2);
8
+ }
9
+ function isScalar(value) {
10
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
11
+ }
12
+ /** Text for a leaf: scalars stringify, containers pretty-print, null yields nothing. */
13
+ function leafText(value) {
14
+ if (isScalar(value))
15
+ return [String(value)];
16
+ if (value === null)
17
+ return [];
18
+ return [pretty(value)];
19
+ }
20
+ /** Index just past the closer matching an opener at `start - 1`, honouring nesting. */
21
+ function scanGroup(path, start, open, close) {
22
+ let depth = 1;
23
+ let i = start;
24
+ while (i < path.length && depth > 0) {
25
+ if (path[i] === open)
26
+ depth += 1;
27
+ else if (path[i] === close)
28
+ depth -= 1;
29
+ i += 1;
30
+ }
31
+ return i;
32
+ }
33
+ /**
34
+ * Split a JSON path into tokens the way LangGraph's `InMemoryStore` does: dots
35
+ * separate plain segments, while a `[…]` index and a `{…}` field group each
36
+ * become a token of their own (`tags[0]` → `['tags', '[0]']`).
37
+ */
38
+ function tokenizePath(path) {
39
+ const tokens = [];
40
+ let current = '';
41
+ const flush = () => {
42
+ if (current.length > 0)
43
+ tokens.push(current);
44
+ current = '';
45
+ };
46
+ let i = 0;
47
+ while (i < path.length) {
48
+ const char = path[i];
49
+ if (char === '[' || char === '{') {
50
+ flush();
51
+ const end = scanGroup(path, i + 1, char, char === '[' ? ']' : '}');
52
+ tokens.push(path.slice(i, end));
53
+ i = end;
54
+ continue;
55
+ }
56
+ if (char === '.')
57
+ flush();
58
+ else
59
+ current += char;
60
+ i += 1;
61
+ }
62
+ flush();
63
+ return tokens;
64
+ }
65
+ /** Walk one `{…}`-group field by plain `in` lookups, as the reference does. */
66
+ function groupFieldText(value, field) {
67
+ let current = value;
68
+ for (const token of tokenizePath(field)) {
69
+ if (current !== null && typeof current === 'object' && token in current) {
70
+ current = current[token];
71
+ }
72
+ else {
73
+ return [];
74
+ }
75
+ }
76
+ return isScalar(current) ? [String(current)] : [pretty(current)];
77
+ }
78
+ /** Resolve a `[n]`, `[-n]` or `[*]` token against an array; anything else yields nothing. */
79
+ function indexText(value, token, tokens, pos) {
80
+ if (!Array.isArray(value))
81
+ return [];
82
+ const index = token.slice(1, -1);
83
+ if (index === '*')
84
+ return value.flatMap((item) => extract(item, tokens, pos + 1));
85
+ let idx = Number.parseInt(index, 10);
86
+ if (Number.isNaN(idx))
87
+ return [];
88
+ if (idx < 0)
89
+ idx = value.length + idx;
90
+ return idx >= 0 && idx < value.length ? extract(value[idx], tokens, pos + 1) : [];
91
+ }
92
+ /** Resolve a `{a,b.c}` token: each listed field, walked from the current value. */
93
+ function groupText(value, token) {
94
+ if (typeof value !== 'object' || value === null)
95
+ return [];
96
+ const results = [];
97
+ for (const field of token.slice(1, -1).split(',')) {
98
+ const trimmed = field.trim();
99
+ if (tokenizePath(trimmed).length > 0)
100
+ results.push(...groupFieldText(value, trimmed));
101
+ }
102
+ return results;
103
+ }
104
+ /** Resolve a bare `*` token: every array item or every object value. */
105
+ function wildcardText(value, tokens, pos) {
106
+ if (Array.isArray(value))
107
+ return value.flatMap((item) => extract(item, tokens, pos + 1));
108
+ if (typeof value === 'object' && value !== null) {
109
+ return Object.values(value).flatMap((item) => extract(item, tokens, pos + 1));
110
+ }
111
+ return [];
112
+ }
113
+ /** Resolve a plain member token by an `in` lookup, exactly as the reference does. */
114
+ function memberText(value, token, tokens, pos) {
115
+ if (typeof value !== 'object' || value === null || !(token in value))
116
+ return [];
117
+ return extract(value[token], tokens, pos + 1);
118
+ }
119
+ function extract(value, tokens, pos) {
120
+ if (pos >= tokens.length)
121
+ return leafText(value);
122
+ const token = tokens[pos];
123
+ if (token.startsWith('[') && token.endsWith(']'))
124
+ return indexText(value, token, tokens, pos);
125
+ const results = pos === 0 && token === '$' ? [pretty(value)] : [];
126
+ if (token.startsWith('{') && token.endsWith('}'))
127
+ results.push(...groupText(value, token));
128
+ else if (token === '*')
129
+ results.push(...wildcardText(value, tokens, pos));
130
+ else
131
+ results.push(...memberText(value, token, tokens, pos));
132
+ return results;
133
+ }
134
+ /**
135
+ * Extract the indexable text of `value` at `path`, byte-for-byte as LangGraph's
136
+ * `InMemoryStore` does (`store/utils`), so an embedding computed here matches
137
+ * one computed by the reference store for the same document. Supports plain
138
+ * paths, `[n]`/`[-n]`/`[*]` indexing, a bare `*` wildcard, `{a,b.c}` field
139
+ * groups and `$` for the whole document. The package root's `getTextAtPath` is
140
+ * a string-only variant that returns nothing for numbers, booleans, objects
141
+ * and arrays and throws on a `null` intermediate; it must not be used here.
142
+ */
143
+ function getTextAtPath(value, path) {
144
+ if (path === '' || path === '$')
145
+ return [pretty(value)];
146
+ return extract(value, tokenizePath(path), 0);
147
+ }
@@ -1,13 +1,18 @@
1
1
  /** Validate search/listNamespaces paging is non-negative integers. */
2
2
  export declare function validatePaging(offset: number, limit: number): void;
3
- /** Validate the namespace is non-empty and each element is a valid identifier. */
3
+ /** Validate the namespace is non-empty and each element is a valid, ≤256-byte identifier. */
4
4
  export declare function validateNamespace(namespace: string[]): void;
5
- /** Validate an item key is a non-empty, separator- and control-char-free string. */
5
+ /** Validate an item key is a non-blank, separator- and control-char-free, ≤256-byte string. */
6
6
  export declare function validateKey(key: string): void;
7
+ /**
8
+ * Validate a namespace/key pair as the item address it becomes: each segment
9
+ * on its own, then the sort key they compose, which DynamoDB caps at 1024
10
+ * bytes regardless of how short the individual segments are.
11
+ */
12
+ export declare function validateStoreKey(namespace: string[], key: string): void;
7
13
  /**
8
14
  * Validate an optional namespace depth cap. Left unchecked, a negative value
9
15
  * silently inverted truncation via `Array.prototype.slice(0, -n)`, which drops
10
16
  * the *last* n elements rather than erroring.
11
17
  */
12
18
  export declare function validateMaxDepth(maxDepth?: number): void;
13
- //# sourceMappingURL=validation.d.ts.map