@strands-agents/sdk 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (352) hide show
  1. package/README.md +11 -11
  2. package/dist/src/__fixtures__/agent-helpers.d.ts.map +1 -1
  3. package/dist/src/__fixtures__/agent-helpers.js +6 -0
  4. package/dist/src/__fixtures__/agent-helpers.js.map +1 -1
  5. package/dist/src/__fixtures__/register-node-defaults.d.ts +2 -0
  6. package/dist/src/__fixtures__/register-node-defaults.d.ts.map +1 -0
  7. package/dist/src/__fixtures__/register-node-defaults.js +6 -0
  8. package/dist/src/__fixtures__/register-node-defaults.js.map +1 -0
  9. package/dist/src/__fixtures__/test-sandbox.node.d.ts.map +1 -1
  10. package/dist/src/__fixtures__/test-sandbox.node.js +4 -3
  11. package/dist/src/__fixtures__/test-sandbox.node.js.map +1 -1
  12. package/dist/src/__tests__/default-slot.test.d.ts +2 -0
  13. package/dist/src/__tests__/default-slot.test.d.ts.map +1 -0
  14. package/dist/src/__tests__/default-slot.test.js +33 -0
  15. package/dist/src/__tests__/default-slot.test.js.map +1 -0
  16. package/dist/src/a2a/__tests__/async-lock.test.d.ts +2 -0
  17. package/dist/src/a2a/__tests__/async-lock.test.d.ts.map +1 -0
  18. package/dist/src/a2a/__tests__/async-lock.test.js +137 -0
  19. package/dist/src/a2a/__tests__/async-lock.test.js.map +1 -0
  20. package/dist/src/a2a/__tests__/executor.test.js +146 -8
  21. package/dist/src/a2a/__tests__/executor.test.js.map +1 -1
  22. package/dist/src/a2a/__tests__/server.test.js +20 -0
  23. package/dist/src/a2a/__tests__/server.test.js.map +1 -1
  24. package/dist/src/a2a/async-lock.d.ts +22 -0
  25. package/dist/src/a2a/async-lock.d.ts.map +1 -0
  26. package/dist/src/a2a/async-lock.js +38 -0
  27. package/dist/src/a2a/async-lock.js.map +1 -0
  28. package/dist/src/a2a/executor.d.ts +59 -24
  29. package/dist/src/a2a/executor.d.ts.map +1 -1
  30. package/dist/src/a2a/executor.js +209 -32
  31. package/dist/src/a2a/executor.js.map +1 -1
  32. package/dist/src/a2a/index.d.ts +1 -1
  33. package/dist/src/a2a/index.d.ts.map +1 -1
  34. package/dist/src/a2a/index.js +1 -1
  35. package/dist/src/a2a/index.js.map +1 -1
  36. package/dist/src/a2a/server.d.ts +18 -2
  37. package/dist/src/a2a/server.d.ts.map +1 -1
  38. package/dist/src/a2a/server.js +13 -2
  39. package/dist/src/a2a/server.js.map +1 -1
  40. package/dist/src/agent/__tests__/agent.context-manager.test.d.ts +2 -0
  41. package/dist/src/agent/__tests__/agent.context-manager.test.d.ts.map +1 -0
  42. package/dist/src/agent/__tests__/agent.context-manager.test.js +107 -0
  43. package/dist/src/agent/__tests__/agent.context-manager.test.js.map +1 -0
  44. package/dist/src/agent/__tests__/agent.tracer.test.node.js +14 -0
  45. package/dist/src/agent/__tests__/agent.tracer.test.node.js.map +1 -1
  46. package/dist/src/agent/agent.d.ts +132 -2
  47. package/dist/src/agent/agent.d.ts.map +1 -1
  48. package/dist/src/agent/agent.js +478 -188
  49. package/dist/src/agent/agent.js.map +1 -1
  50. package/dist/src/conversation-manager/__tests__/pin.test.d.ts +2 -0
  51. package/dist/src/conversation-manager/__tests__/pin.test.d.ts.map +1 -0
  52. package/dist/src/conversation-manager/__tests__/pin.test.js +119 -0
  53. package/dist/src/conversation-manager/__tests__/pin.test.js.map +1 -0
  54. package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js +49 -0
  55. package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js.map +1 -1
  56. package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js +58 -0
  57. package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js.map +1 -1
  58. package/dist/src/conversation-manager/pin-message.d.ts +45 -0
  59. package/dist/src/conversation-manager/pin-message.d.ts.map +1 -0
  60. package/dist/src/conversation-manager/pin-message.js +106 -0
  61. package/dist/src/conversation-manager/pin-message.js.map +1 -0
  62. package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts +7 -0
  63. package/dist/src/conversation-manager/sliding-window-conversation-manager.d.ts.map +1 -1
  64. package/dist/src/conversation-manager/sliding-window-conversation-manager.js +27 -4
  65. package/dist/src/conversation-manager/sliding-window-conversation-manager.js.map +1 -1
  66. package/dist/src/conversation-manager/summarizing-conversation-manager.d.ts +7 -0
  67. package/dist/src/conversation-manager/summarizing-conversation-manager.d.ts.map +1 -1
  68. package/dist/src/conversation-manager/summarizing-conversation-manager.js +18 -4
  69. package/dist/src/conversation-manager/summarizing-conversation-manager.js.map +1 -1
  70. package/dist/src/default-slot.d.ts +6 -0
  71. package/dist/src/default-slot.d.ts.map +1 -0
  72. package/dist/src/default-slot.js +18 -0
  73. package/dist/src/default-slot.js.map +1 -0
  74. package/dist/src/errors.d.ts +8 -0
  75. package/dist/src/errors.d.ts.map +1 -1
  76. package/dist/src/errors.js +11 -0
  77. package/dist/src/errors.js.map +1 -1
  78. package/dist/src/index.d.ts +8 -1
  79. package/dist/src/index.d.ts.map +1 -1
  80. package/dist/src/index.js +7 -1
  81. package/dist/src/index.js.map +1 -1
  82. package/dist/src/index.node.d.ts +2 -0
  83. package/dist/src/index.node.d.ts.map +1 -0
  84. package/dist/src/index.node.js +9 -0
  85. package/dist/src/index.node.js.map +1 -0
  86. package/dist/src/interrupt.d.ts +5 -1
  87. package/dist/src/interrupt.d.ts.map +1 -1
  88. package/dist/src/interrupt.js +6 -0
  89. package/dist/src/interrupt.js.map +1 -1
  90. package/dist/src/memory/__tests__/memory-manager.test.d.ts +2 -0
  91. package/dist/src/memory/__tests__/memory-manager.test.d.ts.map +1 -0
  92. package/dist/src/memory/__tests__/memory-manager.test.js +493 -0
  93. package/dist/src/memory/__tests__/memory-manager.test.js.map +1 -0
  94. package/dist/src/memory/extraction/__tests__/extraction.test.d.ts +2 -0
  95. package/dist/src/memory/extraction/__tests__/extraction.test.d.ts.map +1 -0
  96. package/dist/src/memory/extraction/__tests__/extraction.test.js +637 -0
  97. package/dist/src/memory/extraction/__tests__/extraction.test.js.map +1 -0
  98. package/dist/src/memory/extraction/__tests__/model-extractor.test.d.ts +2 -0
  99. package/dist/src/memory/extraction/__tests__/model-extractor.test.d.ts.map +1 -0
  100. package/dist/src/memory/extraction/__tests__/model-extractor.test.js +68 -0
  101. package/dist/src/memory/extraction/__tests__/model-extractor.test.js.map +1 -0
  102. package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.d.ts +2 -0
  103. package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.d.ts.map +1 -0
  104. package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.js +81 -0
  105. package/dist/src/memory/extraction/__tests__/resolve-extraction-config.test.js.map +1 -0
  106. package/dist/src/memory/extraction/coordinator.d.ts +128 -0
  107. package/dist/src/memory/extraction/coordinator.d.ts.map +1 -0
  108. package/dist/src/memory/extraction/coordinator.js +245 -0
  109. package/dist/src/memory/extraction/coordinator.js.map +1 -0
  110. package/dist/src/memory/extraction/model-extractor.d.ts +32 -0
  111. package/dist/src/memory/extraction/model-extractor.d.ts.map +1 -0
  112. package/dist/src/memory/extraction/model-extractor.js +118 -0
  113. package/dist/src/memory/extraction/model-extractor.js.map +1 -0
  114. package/dist/src/memory/extraction/resolve-extraction-config.d.ts +46 -0
  115. package/dist/src/memory/extraction/resolve-extraction-config.d.ts.map +1 -0
  116. package/dist/src/memory/extraction/resolve-extraction-config.js +59 -0
  117. package/dist/src/memory/extraction/resolve-extraction-config.js.map +1 -0
  118. package/dist/src/memory/extraction/triggers.d.ts +41 -0
  119. package/dist/src/memory/extraction/triggers.d.ts.map +1 -0
  120. package/dist/src/memory/extraction/triggers.js +59 -0
  121. package/dist/src/memory/extraction/triggers.js.map +1 -0
  122. package/dist/src/memory/extraction/types.d.ts +133 -0
  123. package/dist/src/memory/extraction/types.d.ts.map +1 -0
  124. package/dist/src/memory/extraction/types.js +19 -0
  125. package/dist/src/memory/extraction/types.js.map +1 -0
  126. package/dist/src/memory/index.d.ts +9 -0
  127. package/dist/src/memory/index.d.ts.map +1 -0
  128. package/dist/src/memory/index.js +5 -0
  129. package/dist/src/memory/index.js.map +1 -0
  130. package/dist/src/memory/memory-manager.d.ts +131 -0
  131. package/dist/src/memory/memory-manager.d.ts.map +1 -0
  132. package/dist/src/memory/memory-manager.js +404 -0
  133. package/dist/src/memory/memory-manager.js.map +1 -0
  134. package/dist/src/memory/types.d.ts +213 -0
  135. package/dist/src/memory/types.d.ts.map +1 -0
  136. package/dist/src/memory/types.js +2 -0
  137. package/dist/src/memory/types.js.map +1 -0
  138. package/dist/src/middleware/__tests__/agent-middleware.test.d.ts +2 -0
  139. package/dist/src/middleware/__tests__/agent-middleware.test.d.ts.map +1 -0
  140. package/dist/src/middleware/__tests__/agent-middleware.test.js +1207 -0
  141. package/dist/src/middleware/__tests__/agent-middleware.test.js.map +1 -0
  142. package/dist/src/middleware/__tests__/custom-stages.test.d.ts +2 -0
  143. package/dist/src/middleware/__tests__/custom-stages.test.d.ts.map +1 -0
  144. package/dist/src/middleware/__tests__/custom-stages.test.js +97 -0
  145. package/dist/src/middleware/__tests__/custom-stages.test.js.map +1 -0
  146. package/dist/src/middleware/__tests__/middleware-interrupts.test.d.ts +2 -0
  147. package/dist/src/middleware/__tests__/middleware-interrupts.test.d.ts.map +1 -0
  148. package/dist/src/middleware/__tests__/middleware-interrupts.test.js +267 -0
  149. package/dist/src/middleware/__tests__/middleware-interrupts.test.js.map +1 -0
  150. package/dist/src/middleware/__tests__/registry.test.d.ts +2 -0
  151. package/dist/src/middleware/__tests__/registry.test.d.ts.map +1 -0
  152. package/dist/src/middleware/__tests__/registry.test.js +525 -0
  153. package/dist/src/middleware/__tests__/registry.test.js.map +1 -0
  154. package/dist/src/middleware/index.d.ts +5 -0
  155. package/dist/src/middleware/index.d.ts.map +1 -0
  156. package/dist/src/middleware/index.js +3 -0
  157. package/dist/src/middleware/index.js.map +1 -0
  158. package/dist/src/middleware/registry.d.ts +58 -0
  159. package/dist/src/middleware/registry.d.ts.map +1 -0
  160. package/dist/src/middleware/registry.js +107 -0
  161. package/dist/src/middleware/registry.js.map +1 -0
  162. package/dist/src/middleware/stages.d.ts +138 -0
  163. package/dist/src/middleware/stages.d.ts.map +1 -0
  164. package/dist/src/middleware/stages.js +31 -0
  165. package/dist/src/middleware/stages.js.map +1 -0
  166. package/dist/src/middleware/types.d.ts +88 -0
  167. package/dist/src/middleware/types.d.ts.map +1 -0
  168. package/dist/src/middleware/types.js +2 -0
  169. package/dist/src/middleware/types.js.map +1 -0
  170. package/dist/src/models/__tests__/anthropic.test.js +16 -1
  171. package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
  172. package/dist/src/models/__tests__/bedrock.test.js +39 -0
  173. package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
  174. package/dist/src/models/__tests__/model.test.js +46 -3
  175. package/dist/src/models/__tests__/model.test.js.map +1 -1
  176. package/dist/src/models/anthropic.js +2 -2
  177. package/dist/src/models/anthropic.js.map +1 -1
  178. package/dist/src/models/bedrock.d.ts.map +1 -1
  179. package/dist/src/models/bedrock.js +12 -5
  180. package/dist/src/models/bedrock.js.map +1 -1
  181. package/dist/src/models/defaults.d.ts.map +1 -1
  182. package/dist/src/models/defaults.js +2 -0
  183. package/dist/src/models/defaults.js.map +1 -1
  184. package/dist/src/models/model.d.ts.map +1 -1
  185. package/dist/src/models/model.js +7 -3
  186. package/dist/src/models/model.js.map +1 -1
  187. package/dist/src/models/openai/__tests__/responses.test.js +8 -14
  188. package/dist/src/models/openai/__tests__/responses.test.js.map +1 -1
  189. package/dist/src/sandbox/__tests__/default.test.browser.d.ts +2 -0
  190. package/dist/src/sandbox/__tests__/default.test.browser.d.ts.map +1 -0
  191. package/dist/src/sandbox/__tests__/default.test.browser.js +11 -0
  192. package/dist/src/sandbox/__tests__/default.test.browser.js.map +1 -0
  193. package/dist/src/sandbox/__tests__/default.test.node.d.ts +2 -0
  194. package/dist/src/sandbox/__tests__/default.test.node.d.ts.map +1 -0
  195. package/dist/src/sandbox/__tests__/default.test.node.js +23 -0
  196. package/dist/src/sandbox/__tests__/default.test.node.js.map +1 -0
  197. package/dist/src/sandbox/__tests__/docker.test.node.d.ts +2 -0
  198. package/dist/src/sandbox/__tests__/docker.test.node.d.ts.map +1 -0
  199. package/dist/src/sandbox/__tests__/docker.test.node.js +89 -0
  200. package/dist/src/sandbox/__tests__/docker.test.node.js.map +1 -0
  201. package/dist/src/sandbox/__tests__/errors.test.node.d.ts +2 -0
  202. package/dist/src/sandbox/__tests__/errors.test.node.d.ts.map +1 -0
  203. package/dist/src/sandbox/__tests__/errors.test.node.js +33 -0
  204. package/dist/src/sandbox/__tests__/errors.test.node.js.map +1 -0
  205. package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.d.ts +2 -0
  206. package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.d.ts.map +1 -0
  207. package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.js +124 -0
  208. package/dist/src/sandbox/__tests__/not-a-sandbox-local-environment.test.node.js.map +1 -0
  209. package/dist/src/sandbox/__tests__/posix-shell.test.node.js +50 -4
  210. package/dist/src/sandbox/__tests__/posix-shell.test.node.js.map +1 -1
  211. package/dist/src/sandbox/__tests__/ssh.test.node.d.ts +2 -0
  212. package/dist/src/sandbox/__tests__/ssh.test.node.d.ts.map +1 -0
  213. package/dist/src/sandbox/__tests__/ssh.test.node.js +262 -0
  214. package/dist/src/sandbox/__tests__/ssh.test.node.js.map +1 -0
  215. package/dist/src/sandbox/base.d.ts +22 -4
  216. package/dist/src/sandbox/base.d.ts.map +1 -1
  217. package/dist/src/sandbox/base.js +15 -2
  218. package/dist/src/sandbox/base.js.map +1 -1
  219. package/dist/src/sandbox/constants.d.ts +18 -0
  220. package/dist/src/sandbox/constants.d.ts.map +1 -1
  221. package/dist/src/sandbox/constants.js +20 -0
  222. package/dist/src/sandbox/constants.js.map +1 -1
  223. package/dist/src/sandbox/default.d.ts +3 -0
  224. package/dist/src/sandbox/default.d.ts.map +1 -0
  225. package/dist/src/sandbox/default.js +3 -0
  226. package/dist/src/sandbox/default.js.map +1 -0
  227. package/dist/src/sandbox/docker.d.ts +38 -0
  228. package/dist/src/sandbox/docker.d.ts.map +1 -0
  229. package/dist/src/sandbox/docker.js +59 -0
  230. package/dist/src/sandbox/docker.js.map +1 -0
  231. package/dist/src/sandbox/errors.d.ts +26 -0
  232. package/dist/src/sandbox/errors.d.ts.map +1 -0
  233. package/dist/src/sandbox/errors.js +35 -0
  234. package/dist/src/sandbox/errors.js.map +1 -0
  235. package/dist/src/sandbox/index.d.ts +5 -0
  236. package/dist/src/sandbox/index.d.ts.map +1 -0
  237. package/dist/src/sandbox/index.js +4 -0
  238. package/dist/src/sandbox/index.js.map +1 -0
  239. package/dist/src/sandbox/not-a-sandbox-local-environment.d.ts +16 -0
  240. package/dist/src/sandbox/not-a-sandbox-local-environment.d.ts.map +1 -0
  241. package/dist/src/sandbox/not-a-sandbox-local-environment.js +83 -0
  242. package/dist/src/sandbox/not-a-sandbox-local-environment.js.map +1 -0
  243. package/dist/src/sandbox/posix-shell.d.ts +21 -0
  244. package/dist/src/sandbox/posix-shell.d.ts.map +1 -1
  245. package/dist/src/sandbox/posix-shell.js +41 -3
  246. package/dist/src/sandbox/posix-shell.js.map +1 -1
  247. package/dist/src/sandbox/ssh.d.ts +56 -0
  248. package/dist/src/sandbox/ssh.d.ts.map +1 -0
  249. package/dist/src/sandbox/ssh.js +119 -0
  250. package/dist/src/sandbox/ssh.js.map +1 -0
  251. package/dist/src/sandbox/stream-process.d.ts.map +1 -1
  252. package/dist/src/sandbox/stream-process.js +3 -2
  253. package/dist/src/sandbox/stream-process.js.map +1 -1
  254. package/dist/src/tsconfig.tsbuildinfo +1 -1
  255. package/dist/src/types/agent.d.ts +21 -0
  256. package/dist/src/types/agent.d.ts.map +1 -1
  257. package/dist/src/types/agent.js.map +1 -1
  258. package/dist/src/types/messages.d.ts +1 -1
  259. package/dist/src/types/messages.d.ts.map +1 -1
  260. package/dist/src/types/messages.js.map +1 -1
  261. package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.d.ts +2 -0
  262. package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.d.ts.map +1 -0
  263. package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.js +611 -0
  264. package/dist/src/vended-memory-stores/bedrock-knowledge-base/__tests__/bedrock-knowledge-base-store.test.js.map +1 -0
  265. package/dist/src/vended-memory-stores/bedrock-knowledge-base/index.d.ts +2 -0
  266. package/dist/src/vended-memory-stores/bedrock-knowledge-base/index.d.ts.map +1 -0
  267. package/dist/src/vended-memory-stores/bedrock-knowledge-base/index.js +2 -0
  268. package/dist/src/vended-memory-stores/bedrock-knowledge-base/index.js.map +1 -0
  269. package/dist/src/vended-memory-stores/bedrock-knowledge-base/store.d.ts +230 -0
  270. package/dist/src/vended-memory-stores/bedrock-knowledge-base/store.d.ts.map +1 -0
  271. package/dist/src/vended-memory-stores/bedrock-knowledge-base/store.js +370 -0
  272. package/dist/src/vended-memory-stores/bedrock-knowledge-base/store.js.map +1 -0
  273. package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.d.ts +2 -0
  274. package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.d.ts.map +1 -0
  275. package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.js +68 -0
  276. package/dist/src/vended-plugins/context-offloader/__tests__/file-storage-sandbox.test.node.js.map +1 -0
  277. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.d.ts +2 -0
  278. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.d.ts.map +1 -0
  279. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.js +93 -0
  280. package/dist/src/vended-plugins/context-offloader/__tests__/plugin.test.node.js.map +1 -0
  281. package/dist/src/vended-plugins/context-offloader/index.d.ts +1 -1
  282. package/dist/src/vended-plugins/context-offloader/index.d.ts.map +1 -1
  283. package/dist/src/vended-plugins/context-offloader/plugin.d.ts +4 -1
  284. package/dist/src/vended-plugins/context-offloader/plugin.d.ts.map +1 -1
  285. package/dist/src/vended-plugins/context-offloader/plugin.js +29 -7
  286. package/dist/src/vended-plugins/context-offloader/plugin.js.map +1 -1
  287. package/dist/src/vended-plugins/context-offloader/search.d.ts.map +1 -1
  288. package/dist/src/vended-plugins/context-offloader/search.js +3 -5
  289. package/dist/src/vended-plugins/context-offloader/search.js.map +1 -1
  290. package/dist/src/vended-plugins/context-offloader/storage.d.ts +29 -5
  291. package/dist/src/vended-plugins/context-offloader/storage.d.ts.map +1 -1
  292. package/dist/src/vended-plugins/context-offloader/storage.js +75 -11
  293. package/dist/src/vended-plugins/context-offloader/storage.js.map +1 -1
  294. package/dist/src/vended-plugins/goal/__tests__/plugin.test.d.ts +2 -0
  295. package/dist/src/vended-plugins/goal/__tests__/plugin.test.d.ts.map +1 -0
  296. package/dist/src/vended-plugins/goal/__tests__/plugin.test.js +736 -0
  297. package/dist/src/vended-plugins/goal/__tests__/plugin.test.js.map +1 -0
  298. package/dist/src/vended-plugins/goal/index.d.ts +21 -0
  299. package/dist/src/vended-plugins/goal/index.d.ts.map +1 -0
  300. package/dist/src/vended-plugins/goal/index.js +20 -0
  301. package/dist/src/vended-plugins/goal/index.js.map +1 -0
  302. package/dist/src/vended-plugins/goal/judge.d.ts +41 -0
  303. package/dist/src/vended-plugins/goal/judge.d.ts.map +1 -0
  304. package/dist/src/vended-plugins/goal/judge.js +92 -0
  305. package/dist/src/vended-plugins/goal/judge.js.map +1 -0
  306. package/dist/src/vended-plugins/goal/plugin.d.ts +214 -0
  307. package/dist/src/vended-plugins/goal/plugin.d.ts.map +1 -0
  308. package/dist/src/vended-plugins/goal/plugin.js +287 -0
  309. package/dist/src/vended-plugins/goal/plugin.js.map +1 -0
  310. package/dist/src/vended-plugins/index.d.ts +2 -1
  311. package/dist/src/vended-plugins/index.d.ts.map +1 -1
  312. package/dist/src/vended-plugins/index.js +2 -1
  313. package/dist/src/vended-plugins/index.js.map +1 -1
  314. package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js +17 -7
  315. package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js.map +1 -1
  316. package/dist/src/vended-plugins/skills/agent-skills.d.ts +21 -7
  317. package/dist/src/vended-plugins/skills/agent-skills.d.ts.map +1 -1
  318. package/dist/src/vended-plugins/skills/agent-skills.js +144 -77
  319. package/dist/src/vended-plugins/skills/agent-skills.js.map +1 -1
  320. package/dist/src/vended-tools/bash/__tests__/bash.test.node.js +44 -4
  321. package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -1
  322. package/dist/src/vended-tools/bash/bash.d.ts +3 -24
  323. package/dist/src/vended-tools/bash/bash.d.ts.map +1 -1
  324. package/dist/src/vended-tools/bash/bash.js +9 -9
  325. package/dist/src/vended-tools/bash/bash.js.map +1 -1
  326. package/dist/src/vended-tools/bash/index.d.ts +3 -1
  327. package/dist/src/vended-tools/bash/index.d.ts.map +1 -1
  328. package/dist/src/vended-tools/bash/index.js +2 -1
  329. package/dist/src/vended-tools/bash/index.js.map +1 -1
  330. package/dist/src/vended-tools/bash/make-bash.d.ts +22 -0
  331. package/dist/src/vended-tools/bash/make-bash.d.ts.map +1 -0
  332. package/dist/src/vended-tools/bash/make-bash.js +40 -0
  333. package/dist/src/vended-tools/bash/make-bash.js.map +1 -0
  334. package/dist/src/vended-tools/bash/types.d.ts +1 -0
  335. package/dist/src/vended-tools/bash/types.d.ts.map +1 -1
  336. package/dist/src/vended-tools/bash/types.js +2 -0
  337. package/dist/src/vended-tools/bash/types.js.map +1 -1
  338. package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js +83 -1
  339. package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js.map +1 -1
  340. package/dist/src/vended-tools/file-editor/file-editor.d.ts +19 -10
  341. package/dist/src/vended-tools/file-editor/file-editor.d.ts.map +1 -1
  342. package/dist/src/vended-tools/file-editor/file-editor.js +188 -218
  343. package/dist/src/vended-tools/file-editor/file-editor.js.map +1 -1
  344. package/dist/src/vended-tools/file-editor/index.d.ts +2 -1
  345. package/dist/src/vended-tools/file-editor/index.d.ts.map +1 -1
  346. package/dist/src/vended-tools/file-editor/index.js +1 -1
  347. package/dist/src/vended-tools/file-editor/index.js.map +1 -1
  348. package/package.json +41 -6
  349. package/dist/src/utils/shell-quote.d.ts +0 -12
  350. package/dist/src/utils/shell-quote.d.ts.map +0 -1
  351. package/dist/src/utils/shell-quote.js +0 -14
  352. package/dist/src/utils/shell-quote.js.map +0 -1
@@ -0,0 +1,404 @@
1
+ import { MessageAddedEvent } from '../hooks/events.js';
2
+ import { ExtractionCoordinator } from './extraction/coordinator.js';
3
+ import { resolveExtractionConfig } from './extraction/resolve-extraction-config.js';
4
+ import { tool } from '../tools/tool-factory.js';
5
+ import { z } from 'zod';
6
+ import { logger } from '../logging/logger.js';
7
+ import { normalizeError } from '../errors.js';
8
+ const SEARCH_TOOL_DESCRIPTION = 'Search long-term memory for facts, preferences, or context from previous conversations. Use when you need background about the user or topic that may have been discussed before.';
9
+ const ADD_TOOL_DESCRIPTION = 'Add facts, preferences, or decisions to long-term memory so they are remembered across conversations. Use when the user shares something worth recalling later.';
10
+ /**
11
+ * Default maximum results per store when neither the caller nor the store specifies one.
12
+ * Resolved by the {@link MemoryManager}.
13
+ */
14
+ export const DEFAULT_MAX_SEARCH_RESULTS = 3;
15
+ /** Flattens nested AggregateErrors so the leaves are concrete reasons, not errors-of-errors. */
16
+ function _flattenReasons(reasons) {
17
+ return reasons.flatMap((reason) => (reason instanceof AggregateError ? _flattenReasons(reason.errors) : [reason]));
18
+ }
19
+ /**
20
+ * Whether a store has any write sink. The `add_memory` tool and programmatic `add` use `add`;
21
+ * extraction additionally accepts `addMessages`. A writable store must have at least one.
22
+ */
23
+ function _hasWriteSink(store) {
24
+ return typeof store.add === 'function' || typeof store.addMessages === 'function';
25
+ }
26
+ /**
27
+ * Provides cross-session memory retrieval and storage for agents.
28
+ *
29
+ * Manages one or more {@link MemoryStore} backends, exposing `search_memory` and
30
+ * `add_memory` tools for agent-driven recall and persistence. Any tools the stores
31
+ * themselves provide (via {@link MemoryStore.getTools}) are registered alongside these.
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * import { Agent, MemoryManager } from '@strands-agents/sdk'
36
+ *
37
+ * // Config shorthand
38
+ * const agent = new Agent({
39
+ * model,
40
+ * memoryManager: { stores: [myStore], addToolConfig: true },
41
+ * })
42
+ *
43
+ * // Class instance (for programmatic access)
44
+ * const memoryManager = new MemoryManager({ stores: [myStore], addToolConfig: true })
45
+ * const agent = new Agent({ model, memoryManager })
46
+ * await memoryManager.search('user preferences')
47
+ * ```
48
+ */
49
+ export class MemoryManager {
50
+ name = 'strands:memory-manager';
51
+ _config;
52
+ _searchStores;
53
+ /** All writable stores — the unscoped target set for the programmatic {@link add} method. */
54
+ _addStores;
55
+ _searchToolConfig;
56
+ _addToolConfig;
57
+ _addToolStores;
58
+ /** Stores with extraction enabled, each paired with its resolved config; wired up in {@link initAgent}. */
59
+ _extractionStores;
60
+ /** Background extraction coordinator, created in {@link initAgent} when extraction is configured. */
61
+ _coordinator;
62
+ constructor(config) {
63
+ if (config.stores.length === 0) {
64
+ throw new Error('MemoryManager: at least one store is required');
65
+ }
66
+ const seenNames = new Set();
67
+ const extractionStores = [];
68
+ for (const store of config.stores) {
69
+ if (seenNames.has(store.name)) {
70
+ throw new Error(`MemoryManager: duplicate store name '${store.name}'`);
71
+ }
72
+ seenNames.add(store.name);
73
+ if (store.writable && !_hasWriteSink(store)) {
74
+ throw new Error(`MemoryManager: store '${store.name}' is writable but has no add or addMessages method`);
75
+ }
76
+ if (store.extraction) {
77
+ if (!store.writable) {
78
+ throw new Error(`MemoryManager: store '${store.name}' has extraction config but is not writable`);
79
+ }
80
+ const resolved = resolveExtractionConfig(store.extraction, store);
81
+ if (resolved.triggers.length === 0) {
82
+ throw new Error(`MemoryManager: store '${store.name}' has extraction config but no triggers`);
83
+ }
84
+ // Each extraction shape needs its matching write sink. An extractor produces discrete entries
85
+ // written via `add`; without an extractor the raw message batch goes to `addMessages`.
86
+ if (resolved.extractor) {
87
+ if (typeof store.add !== 'function') {
88
+ throw new Error(`MemoryManager: store '${store.name}' has an extractor but no add method (extracted entries are written via add)`);
89
+ }
90
+ }
91
+ else if (typeof store.addMessages !== 'function') {
92
+ throw new Error(`MemoryManager: store '${store.name}' has extraction config without an extractor but no addMessages method`);
93
+ }
94
+ extractionStores.push({ store, config: resolved });
95
+ }
96
+ }
97
+ this._config = config;
98
+ this._searchStores = config.stores;
99
+ // `add`-targeting paths (tool / programmatic) need an `add` method specifically.
100
+ this._addStores = config.stores.filter((s) => s.writable && typeof s.add === 'function');
101
+ this._extractionStores = extractionStores;
102
+ this._searchToolConfig =
103
+ config.searchToolConfig === false
104
+ ? false
105
+ : typeof config.searchToolConfig === 'object'
106
+ ? config.searchToolConfig
107
+ : {};
108
+ if (config.addToolConfig === undefined || config.addToolConfig === false) {
109
+ this._addToolConfig = false;
110
+ this._addToolStores = [];
111
+ }
112
+ else {
113
+ // The `add_memory` tool writes via `add` (not `addMessages`), so it needs an `add`-capable store.
114
+ if (this._addStores.length === 0) {
115
+ throw new Error('MemoryManager: addToolConfig is enabled but no writable stores implement add');
116
+ }
117
+ this._addToolConfig = typeof config.addToolConfig === 'object' ? config.addToolConfig : {};
118
+ this._addToolStores = this._resolveAddToolStores(this._addToolConfig);
119
+ }
120
+ }
121
+ /**
122
+ * Resolves the writable stores the `add_memory` tool may write to. When `stores` is given, each
123
+ * entry (a store name or a {@link MemoryStore} instance) must resolve by name to a configured,
124
+ * `add`-capable writable store (else throws). Omitted means all such stores.
125
+ */
126
+ _resolveAddToolStores(toolConfig) {
127
+ if (toolConfig.stores === undefined) {
128
+ return this._addStores;
129
+ }
130
+ const names = toolConfig.stores.map((store) => (typeof store === 'string' ? store : store.name));
131
+ return [...new Set(names)].map((name) => {
132
+ const found = this._config.stores.find((s) => s.name === name);
133
+ if (!found) {
134
+ throw new Error(`MemoryManager: addToolConfig store '${name}' not found`);
135
+ }
136
+ if (!found.writable) {
137
+ throw new Error(`MemoryManager: addToolConfig store '${name}' is not writable`);
138
+ }
139
+ if (typeof found.add !== 'function') {
140
+ throw new Error(`MemoryManager: addToolConfig store '${name}' has no add method (only addMessages)`);
141
+ }
142
+ return found;
143
+ });
144
+ }
145
+ /**
146
+ * Initializes the plugin with the agent.
147
+ *
148
+ * Wires up automatic extraction for any store configured with {@link ExtractionConfig}: buffers
149
+ * conversation messages and attaches each store's triggers. A no-op when no store uses extraction.
150
+ *
151
+ * @param agent - The agent this plugin is being attached to
152
+ */
153
+ initAgent(agent) {
154
+ if (this._extractionStores.length === 0) {
155
+ return;
156
+ }
157
+ const coordinator = new ExtractionCoordinator(this._extractionStores, agent.model);
158
+ this._coordinator = coordinator;
159
+ // Buffer every message the agent adds, so extraction has its own copy to save from.
160
+ agent.addHook(MessageAddedEvent, (event) => {
161
+ coordinator.record(event.message.toJSON());
162
+ });
163
+ for (const { store, config } of this._extractionStores) {
164
+ for (const trigger of config.triggers) {
165
+ trigger.attach({ agent, fire: () => void coordinator.process(store) });
166
+ }
167
+ }
168
+ }
169
+ /**
170
+ * Saves every store's remaining messages and waits for all saves to finish. No-op when no store has
171
+ * extraction configured.
172
+ *
173
+ * Extraction normally runs in the background, so the most recent turn may not be saved yet when the
174
+ * agent responds. Call this once at a boundary you control - typically your app's shutdown handler -
175
+ * so nothing is lost. A process killed before then (crash, hard timeout) may still lose the last
176
+ * unsaved turn; a more frequent trigger narrows that window.
177
+ *
178
+ * Do not call this after every turn alongside a periodic trigger: it forces a save each time and so
179
+ * defeats the trigger's schedule.
180
+ */
181
+ async flush() {
182
+ await this._coordinator?.flush();
183
+ }
184
+ /**
185
+ * Returns tools registered by this plugin.
186
+ *
187
+ * Includes the manager's own `search_memory` / `add_memory` tools (per their config) plus any
188
+ * tools the configured stores expose via {@link MemoryStore.getTools}.
189
+ *
190
+ * @returns Array of tools to register with the agent
191
+ */
192
+ getTools() {
193
+ const tools = [];
194
+ if (this._searchToolConfig !== false) {
195
+ tools.push(this._createSearchTool(this._searchToolConfig));
196
+ }
197
+ if (this._addToolConfig !== false) {
198
+ tools.push(this._createAddTool(this._addToolConfig, this._addToolStores));
199
+ }
200
+ for (const store of this._config.stores) {
201
+ const storeTools = store.getTools?.() ?? [];
202
+ tools.push(...storeTools);
203
+ }
204
+ return tools;
205
+ }
206
+ /**
207
+ * Search stores for entries matching the query. If `stores` is provided, only searches to those named stores.
208
+ *
209
+ * This method is unscoped with full access to all configured stores.
210
+ * Tool-level store scoping is applied by the search tool callback.
211
+ * When `options.stores` is omitted, all stores are searched.
212
+ *
213
+ * Only `maxSearchResults` and routing (`stores`) cross this layer. Store-specific search
214
+ * parameters (e.g. a Bedrock metadata `filter` or search-type override) are not expressible here
215
+ * across heterogeneous stores — set them as per-instance defaults on the store, or call the
216
+ * store's own `search()` directly for full control. Per-instance store policy (such as a tenant
217
+ * filter) always applies, including when reached through the `search_memory` tool.
218
+ *
219
+ * @param query - The search query string
220
+ * @param options - Optional max results (forwarded to all stores) and store name filter
221
+ * @returns Array of memory entries from matching stores
222
+ */
223
+ async search(query, options) {
224
+ logger.debug(`query=<${query}>, max_search_results=<${options?.maxSearchResults}>, stores=<${options?.stores}> | searching stores`);
225
+ const targetStores = options?.stores !== undefined
226
+ ? [...new Set(options.stores)].map((name) => {
227
+ const found = this._config.stores.find((s) => s.name === name);
228
+ if (!found) {
229
+ throw new Error(`MemoryManager: store '${name}' not found`);
230
+ }
231
+ return found;
232
+ })
233
+ : this._config.stores;
234
+ const settled = await Promise.allSettled(targetStores.map((store) => store.search(query, {
235
+ maxSearchResults: options?.maxSearchResults ?? store.maxSearchResults ?? DEFAULT_MAX_SEARCH_RESULTS,
236
+ })));
237
+ const results = [];
238
+ for (let i = 0; i < settled.length; i++) {
239
+ const settledResult = settled[i];
240
+ const storeName = targetStores[i].name;
241
+ if (settledResult.status === 'rejected') {
242
+ logger.warn(`store=<${storeName}>, reason=<${normalizeError(settledResult.reason).message}> | store search failed`);
243
+ continue;
244
+ }
245
+ for (const entry of settledResult.value) {
246
+ results.push({ ...entry, storeName });
247
+ }
248
+ }
249
+ logger.debug(`results=<${results.length}> | search complete`);
250
+ return results;
251
+ }
252
+ /**
253
+ * Add content to writable stores. If `stores` is provided, only writes to those named stores;
254
+ * otherwise all writable stores are targeted.
255
+ *
256
+ * This method is unscoped, with full access to all configured writable stores; tool-level store
257
+ * scoping is applied by the add tool callback. Target stores are validated first (an unknown or
258
+ * read-only named store throws), then the writes are awaited: per-store failures are logged, and
259
+ * an `AggregateError` is thrown if any store fails.
260
+ *
261
+ * @param content - The text content to add
262
+ * @param options - Optional metadata and store name filter
263
+ */
264
+ async add(content, options) {
265
+ let writableStores;
266
+ if (options?.stores !== undefined) {
267
+ writableStores = [...new Set(options.stores)].map((name) => {
268
+ const found = this._config.stores.find((s) => s.name === name);
269
+ if (!found) {
270
+ throw new Error(`MemoryManager: store '${name}' not found`);
271
+ }
272
+ if (!found.writable) {
273
+ throw new Error(`MemoryManager: store '${name}' is read-only`);
274
+ }
275
+ return found;
276
+ });
277
+ }
278
+ else {
279
+ writableStores = this._addStores;
280
+ }
281
+ if (writableStores.length === 0) {
282
+ throw new Error('MemoryManager: no writable store matched');
283
+ }
284
+ const settled = await Promise.allSettled(writableStores.map((store) => store.add(content, options?.metadata)));
285
+ const failures = [];
286
+ for (let i = 0; i < settled.length; i++) {
287
+ const settledResult = settled[i];
288
+ if (settledResult.status === 'rejected') {
289
+ const storeName = writableStores[i].name;
290
+ logger.warn(`store=<${storeName}>, reason=<${normalizeError(settledResult.reason).message}> | store write failed`);
291
+ failures.push({ store: storeName, reason: settledResult.reason });
292
+ }
293
+ }
294
+ if (failures.length > 0) {
295
+ throw new AggregateError(failures.map((failure) => failure.reason), `MemoryManager: store writes failed: ${failures.map((failure) => failure.store).join(', ')}`);
296
+ }
297
+ }
298
+ /**
299
+ * Resolves the store names that a tool callback should target against the tool's scoped set.
300
+ *
301
+ * - Omitting `requested` targets all scoped stores.
302
+ * - Names that are in scope are kept; out-of-scope names are dropped with a warning.
303
+ * - When every requested name is out of scope, throws so the model receives an actionable error
304
+ * (the tool layer turns the thrown error into a model-visible result it can correct from).
305
+ *
306
+ * @param scopedNames - Store names available to this tool
307
+ * @param requested - Store names the model asked for, if any
308
+ * @returns A non-empty list of in-scope store names to target
309
+ */
310
+ _resolveToolTargets(scopedNames, requested) {
311
+ if (requested === undefined || requested.length === 0) {
312
+ return scopedNames;
313
+ }
314
+ const inScope = requested.filter((name) => scopedNames.includes(name));
315
+ const outOfScope = requested.filter((name) => !scopedNames.includes(name));
316
+ if (inScope.length === 0) {
317
+ throw new Error(`MemoryManager: requested=<${requested.join(', ')}> | none of the requested memory stores are available; available stores: ${scopedNames.join(', ')}`);
318
+ }
319
+ if (outOfScope.length > 0) {
320
+ logger.warn(`requested=<${outOfScope.join(', ')}> | ignoring memory stores outside this tool's scope`);
321
+ }
322
+ return inScope;
323
+ }
324
+ _createSearchTool(config) {
325
+ let description = config.description ?? SEARCH_TOOL_DESCRIPTION;
326
+ const storeDescriptions = this._searchStores
327
+ .filter((s) => s.description)
328
+ .map((s) => `- ${s.name}: ${s.description}`);
329
+ if (storeDescriptions.length > 0) {
330
+ description += `\n\nAvailable memory stores:\n${storeDescriptions.join('\n')}`;
331
+ description +=
332
+ '\n\nYou can target one or more memory stores by name if you know which domains are relevant, or omit the stores parameter to search all.';
333
+ }
334
+ const scopedNames = this._searchStores.map((s) => s.name);
335
+ const inputSchema = z.object({
336
+ query: z.string().describe('What to search for'),
337
+ maxSearchResults: z.number().optional().describe('Maximum number of results per store'),
338
+ stores: z
339
+ .array(z.string())
340
+ .optional()
341
+ .describe('Filter to specific stores by name. Omit to search all available stores.'),
342
+ });
343
+ return tool({
344
+ name: config.name ?? 'search_memory',
345
+ description,
346
+ inputSchema,
347
+ callback: async (input) => {
348
+ const stores = this._resolveToolTargets(scopedNames, input.stores);
349
+ const results = await this.search(input.query, {
350
+ ...(input.maxSearchResults != null && { maxSearchResults: input.maxSearchResults }),
351
+ stores,
352
+ });
353
+ return results.map((entry) => ({
354
+ content: entry.content,
355
+ ...(entry.storeName && { storeName: entry.storeName }),
356
+ ...(entry.metadata && { metadata: entry.metadata }),
357
+ }));
358
+ },
359
+ });
360
+ }
361
+ _createAddTool(config, stores) {
362
+ let description = config.description ?? ADD_TOOL_DESCRIPTION;
363
+ const storeDescriptions = stores.filter((s) => s.description).map((s) => `- ${s.name}: ${s.description}`);
364
+ if (storeDescriptions.length > 0) {
365
+ description += `\n\nAvailable writable stores:\n${storeDescriptions.join('\n')}`;
366
+ description +=
367
+ '\n\nYou can target a specific store by name to route facts to the right place, or omit to add to all available writable stores.';
368
+ }
369
+ const scopedNames = stores.map((s) => s.name);
370
+ const waitForWrites = config.waitForWrites ?? true;
371
+ const inputSchema = z.object({
372
+ entries: z.array(z.string()).min(1).describe('Data to add to long-term memory'),
373
+ stores: z
374
+ .array(z.string())
375
+ .optional()
376
+ .describe('Target specific stores by name. Omit to add to all writable stores.'),
377
+ });
378
+ return tool({
379
+ name: config.name ?? 'add_memory',
380
+ description,
381
+ inputSchema,
382
+ callback: async (input) => {
383
+ const stores = this._resolveToolTargets(scopedNames, input.stores);
384
+ if (!waitForWrites) {
385
+ // Fire-and-forget: dispatch the writes without awaiting so the agent loop isn't blocked.
386
+ // add() logs per-store failures; swallow the rejection so it isn't an unhandled rejection.
387
+ for (const content of input.entries) {
388
+ void this.add(content, { stores }).catch(() => { });
389
+ }
390
+ return { accepted: input.entries.length };
391
+ }
392
+ // Await mode: surface failures to the model with concrete reasons (not nested AggregateErrors).
393
+ const settled = await Promise.allSettled(input.entries.map((content) => this.add(content, { stores })));
394
+ const failures = settled.filter((settledResult) => settledResult.status === 'rejected');
395
+ if (failures.length > 0) {
396
+ const reasons = _flattenReasons(failures.map((failure) => failure.reason));
397
+ throw new AggregateError(reasons, `MemoryManager: failed to add ${failures.length} of ${input.entries.length} entries: ${reasons.map((reason) => normalizeError(reason).message).join('; ')}`);
398
+ }
399
+ return { stored: input.entries.length };
400
+ },
401
+ });
402
+ }
403
+ }
404
+ //# sourceMappingURL=memory-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-manager.js","sourceRoot":"","sources":["../../../src/memory/memory-manager.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EAAE,qBAAqB,EAA0B,MAAM,6BAA6B,CAAA;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAA;AACnF,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C,MAAM,uBAAuB,GAC3B,mLAAmL,CAAA;AAErL,MAAM,oBAAoB,GACxB,iKAAiK,CAAA;AAEnK;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAA;AAE3C,gGAAgG;AAChG,SAAS,eAAe,CAAC,OAAkB;IACzC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,YAAY,cAAc,CAAC,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AACpH,CAAC;AAED;;;GAGG;AACH,SAAS,aAAa,CAAC,KAAkB;IACvC,OAAO,OAAO,KAAK,CAAC,GAAG,KAAK,UAAU,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,UAAU,CAA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e,CAAA;gBACxD,CAAC;gBAED,gGAAgG;gBAChG,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,CAAA;gBACvG,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAC7B,CAAC,aAAa,EAAE,EAAE,CAAC,aAAa,CAAC,MAAM,KAAK,UAAU,CAC5B,CAAA;gBAE5B,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxB,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;oBAC1E,MAAM,IAAI,cAAc,CACtB,OAAO,EACP,gCAAgC,QAAQ,CAAC,MAAM,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,aAAa,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5J,CAAA;gBACH,CAAC;gBAED,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,MAAM,EAAe,CAAA;YACtD,CAAC;SACF,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,213 @@
1
+ import type { JSONValue } from '../types/json.js';
2
+ import type { MessageData } from '../types/messages.js';
3
+ import type { Tool } from '../tools/tool.js';
4
+ import type { ExtractionConfig } from './extraction/types.js';
5
+ /**
6
+ * A single memory entry retrieved from or stored to a memory store.
7
+ */
8
+ export interface MemoryEntry {
9
+ /** The textual content of this memory entry. */
10
+ content: string;
11
+ /**
12
+ * Name of the store this entry came from. Populated by {@link MemoryManager.search} so callers
13
+ * (and the model, via `search_memory`) can tell which store produced each result and refine
14
+ * targeting. Stores need not set this themselves.
15
+ */
16
+ storeName?: string;
17
+ /** Optional metadata (e.g., score, source, id, timestamp). */
18
+ metadata?: Record<string, JSONValue>;
19
+ }
20
+ /**
21
+ * Options passed to {@link MemoryStore.search}.
22
+ *
23
+ * Store implementations may extend this with backend-specific fields (e.g. a metadata filter or
24
+ * search-type override) in their own `search` signature. Note that {@link MemoryManager.search}
25
+ * only forwards the base fields here across its (potentially heterogeneous) stores — to use a
26
+ * store's extended options, call that store's `search` directly, or set them as per-instance
27
+ * defaults on the store.
28
+ */
29
+ export interface SearchOptions {
30
+ /** Maximum number of results to return from this store. */
31
+ maxSearchResults?: number;
32
+ }
33
+ /**
34
+ * Context the {@link MemoryManager} supplies to {@link MemoryStore.addMessages} alongside a batch.
35
+ *
36
+ * An extension point: fields are added here without changing the {@link MemoryStore.addMessages}
37
+ * signature.
38
+ */
39
+ export interface AddMessagesContext {
40
+ /**
41
+ * Per-message identities aligned one-to-one with `messages` (`sequenceNumbers[i]` identifies
42
+ * `messages[i]`). A retried batch reuses the same numbers, so a store can build an idempotency key
43
+ * that survives retries - unlike a content hash, which collides when two messages share text (e.g.
44
+ * "ok"). Numbers increase with order but may have gaps, and reset to 0 each agent run, so a durable
45
+ * dedup token must combine one with a run-unique id.
46
+ */
47
+ readonly sequenceNumbers?: readonly number[];
48
+ }
49
+ /**
50
+ * Declarative properties shared by every memory store and its config.
51
+ *
52
+ * This is the single source of truth for a store's identity and behavior knobs. Both the runtime
53
+ * {@link MemoryStore} interface and concrete store configs extend it, so these fields are declared
54
+ * once. Concrete stores add their own backend-specific config fields on top.
55
+ */
56
+ export interface MemoryStoreConfig {
57
+ /** Identifier for this store, used to target specific stores in search/add tools. Must be unique. */
58
+ readonly name: string;
59
+ /** Human-readable description of what this store contains. Included in tool descriptions. */
60
+ readonly description?: string;
61
+ /**
62
+ * Default maximum number of results this store returns per search, used when a caller does not
63
+ * pass a per-call `maxSearchResults`.
64
+ */
65
+ readonly maxSearchResults?: number;
66
+ /**
67
+ * Whether this store accepts writes. Optional at config time (caller intent, defaults to `false`);
68
+ * concrete stores resolve it to a definite boolean on the {@link MemoryStore} interface.
69
+ *
70
+ * @defaultValue false
71
+ */
72
+ readonly writable?: boolean;
73
+ /**
74
+ * Automatic-extraction config for this writable store, as a `boolean | config` shorthand. `true`
75
+ * enables it with defaults; an {@link ExtractionConfig} defaults any unset field; `false`/omitted is off.
76
+ *
77
+ * The defaults run every 5 turns, and the extraction method depends on the store's write methods. A
78
+ * store implementing `addMessages` uses server-side extraction: the manager hands it the raw messages
79
+ * and the backend extracts them, with no model call. A store implementing only `add` uses a
80
+ * {@link ModelExtractor} for client-side extraction: it calls the agent's model to distill facts and
81
+ * stores each one via `add`.
82
+ *
83
+ * @defaultValue false
84
+ */
85
+ readonly extraction?: boolean | ExtractionConfig;
86
+ }
87
+ /**
88
+ * Interface for a memory store backend.
89
+ *
90
+ * Extends {@link MemoryStoreConfig} with the runtime methods a store provides. Every store is
91
+ * searchable; the resolved `writable` flag declares whether it also accepts writes, which is how
92
+ * the {@link MemoryManager} decides where to route them. `search_memory` can query all stores, while
93
+ * `add_memory` can only write to `writable` stores.
94
+ */
95
+ export interface MemoryStore extends MemoryStoreConfig {
96
+ /**
97
+ * Whether this store accepts writes.
98
+ * - `false`: searchable only; never written to.
99
+ * - `true`: searchable and writable. Requires at least one write sink — `add`, `addMessages`,
100
+ * or both — to be implemented.
101
+ */
102
+ readonly writable: boolean;
103
+ /** Search the store for entries matching the query, ordered by relevance. */
104
+ search(query: string, options?: SearchOptions): Promise<MemoryEntry[]>;
105
+ /**
106
+ * Add a single piece of content to the store. Used by the `add_memory` tool, the programmatic
107
+ * {@link MemoryManager.add}, and by extraction when an {@link ExtractionConfig.extractor} produces
108
+ * discrete entries (an extraction config with an extractor requires this method).
109
+ *
110
+ * A store satisfies `writable: true` with `add`, {@link addMessages}, or both. A store may also
111
+ * implement `add` while declaring `writable: false`, in which case it is never invoked.
112
+ *
113
+ * Extraction writes are at-least-once: if one entry in a batch fails, the whole batch is retried, so
114
+ * `add` may be called again with content it already stored. Implementations used with extraction
115
+ * should tolerate duplicate writes (e.g. dedupe, or accept that retries may re-store an entry).
116
+ *
117
+ * The resolved value is store-specific (e.g. a created record id or a write receipt) — each backend
118
+ * may return whatever shape fits it. The {@link MemoryManager} does not consume this value (it only
119
+ * awaits completion); callers using a store directly can read it.
120
+ */
121
+ add?(content: string, metadata?: Record<string, JSONValue>): Promise<unknown>;
122
+ /**
123
+ * Ingest a batch of conversation messages, preserving their role structure. This is the sink for
124
+ * automatic extraction that does not distill facts client-side: the manager hands the filtered
125
+ * {@link MessageData} batch straight here in one call — no serialization, no model call. Backends
126
+ * that turn raw turns into memory themselves (e.g. role-aware conversational APIs that summarize
127
+ * server-side) implement this so the user/assistant structure survives. A store using extraction
128
+ * implements this method, unless it configures an {@link ExtractionConfig.extractor} (which produces
129
+ * discrete entries written via {@link add} instead).
130
+ *
131
+ * Satisfies `writable: true` the same way {@link add} does. The resolved value is store-specific
132
+ * and not consumed by the manager.
133
+ *
134
+ * A store scopes its writes (e.g. by tenant or namespace) through its own configuration. The
135
+ * {@link AddMessagesContext} parameter lets the manager pass additional per-batch context to the
136
+ * store.
137
+ *
138
+ * @param messages - The filtered messages to ingest, in order
139
+ * @param context - Manager-supplied per-batch context (see {@link AddMessagesContext})
140
+ */
141
+ addMessages?(messages: MessageData[], context?: AddMessagesContext): Promise<unknown>;
142
+ /**
143
+ * Returns store-specific tools to register with the agent, through a {@link MemoryManager}. Registers
144
+ * tools alongside `search_memory` / `add_memory` tools if enabled on the {@link MemoryManager}.
145
+ * Implement to expose backend-specific capabilities (e.g. a store-native query tool).
146
+ * Optional, mirrors {@link Plugin.getTools}.
147
+ *
148
+ * @returns Array of tools provided by this store
149
+ */
150
+ getTools?(): Tool[];
151
+ }
152
+ /**
153
+ * Options for {@link MemoryManager.search}.
154
+ *
155
+ * Extends the store primitive {@link SearchOptions} with manager-level store routing.
156
+ */
157
+ export interface MemorySearchOptions extends SearchOptions {
158
+ /** Filter to specific stores by name. Omit to search all. */
159
+ stores?: string[];
160
+ }
161
+ /**
162
+ * Options for {@link MemoryManager.add}.
163
+ */
164
+ export interface MemoryAddOptions {
165
+ /** Metadata to associate with the added entry. */
166
+ metadata?: Record<string, JSONValue>;
167
+ /** Filter to specific writable stores by name. Omit to write to all writable stores. */
168
+ stores?: string[];
169
+ }
170
+ /**
171
+ * Configuration for customizing a memory tool's name or description.
172
+ */
173
+ export interface MemoryToolConfig {
174
+ /** Custom tool name. */
175
+ name?: string;
176
+ /** Custom tool description. */
177
+ description?: string;
178
+ }
179
+ /**
180
+ * Configuration for the `add_memory` tool. Extends {@link MemoryToolConfig} with an explicit
181
+ * allowlist of stores the tool may write to.
182
+ */
183
+ export interface MemoryAddToolConfig extends MemoryToolConfig {
184
+ /**
185
+ * The writable stores the `add_memory` tool may write to, given as store names or the
186
+ * {@link MemoryStore} instances themselves. Each must be a configured, `writable` store.
187
+ * Omit (or set `addToolConfig: true`) to allow all writable stores.
188
+ */
189
+ stores?: (string | MemoryStore)[];
190
+ /**
191
+ * Whether the tool waits for store writes before returning to the model. Defaults to `true`.
192
+ * - `true` (default): waits for writes — the tool returns `{ stored }` on success, or surfaces a
193
+ * failure to the model if any store write fails.
194
+ * - `false`: fire-and-forget — the tool returns `{ accepted }` once writes are dispatched (so a
195
+ * slow backend never blocks the agent loop); per-store failures are logged.
196
+ */
197
+ waitForWrites?: boolean;
198
+ }
199
+ /**
200
+ * Configuration for the {@link MemoryManager}.
201
+ */
202
+ export interface MemoryManagerConfig {
203
+ /** One or more memory stores to manage. */
204
+ stores: MemoryStore[];
205
+ /** Search tool configuration. Defaults to `true`. */
206
+ searchToolConfig?: MemoryToolConfig | boolean;
207
+ /**
208
+ * Add tool configuration. Defaults to `false` (opt-in). `true` lets the tool write to all
209
+ * writable stores; pass a {@link MemoryAddToolConfig} with `stores` to restrict it to specific ones.
210
+ */
211
+ addToolConfig?: MemoryAddToolConfig | boolean;
212
+ }
213
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/memory/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAE7D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,gDAAgD;IAChD,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAA;CACrC;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,aAAa;IAC5B,2DAA2D;IAC3D,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;GAKG;AACH,MAAM,WAAW,kBAAkB;IACjC;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC7C;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,qGAAqG;IACrG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,6FAA6F;IAC7F,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAA;IAC7B;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAC3B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,GAAG,gBAAgB,CAAA;CACjD;AAED;;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CAAC,EAAE,OAAO,CAAA;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,2CAA2C;IAC3C,MAAM,EAAE,WAAW,EAAE,CAAA;IACrB,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAA;IAC7C;;;OAGG;IACH,aAAa,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAA;CAC9C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/memory/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=agent-middleware.test.d.ts.map