@strands-agents/sdk 1.0.0-rc.5 → 1.0.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 (250) hide show
  1. package/LICENSE +175 -0
  2. package/README.md +340 -0
  3. package/dist/src/__fixtures__/agent-helpers.d.ts +6 -0
  4. package/dist/src/__fixtures__/agent-helpers.d.ts.map +1 -1
  5. package/dist/src/__fixtures__/agent-helpers.js +3 -1
  6. package/dist/src/__fixtures__/agent-helpers.js.map +1 -1
  7. package/dist/src/__fixtures__/mock-plugin.d.ts.map +1 -1
  8. package/dist/src/__fixtures__/mock-plugin.js +3 -1
  9. package/dist/src/__fixtures__/mock-plugin.js.map +1 -1
  10. package/dist/src/__fixtures__/tool-helpers.d.ts +3 -1
  11. package/dist/src/__fixtures__/tool-helpers.d.ts.map +1 -1
  12. package/dist/src/__fixtures__/tool-helpers.js +3 -1
  13. package/dist/src/__fixtures__/tool-helpers.js.map +1 -1
  14. package/dist/src/__tests__/mcp.test.js +222 -2
  15. package/dist/src/__tests__/mcp.test.js.map +1 -1
  16. package/dist/src/a2a/__tests__/events.test.js +2 -0
  17. package/dist/src/a2a/__tests__/events.test.js.map +1 -1
  18. package/dist/src/a2a/__tests__/executor.test.js +16 -5
  19. package/dist/src/a2a/__tests__/executor.test.js.map +1 -1
  20. package/dist/src/a2a/a2a-agent.d.ts +8 -3
  21. package/dist/src/a2a/a2a-agent.d.ts.map +1 -1
  22. package/dist/src/a2a/a2a-agent.js +12 -6
  23. package/dist/src/a2a/a2a-agent.js.map +1 -1
  24. package/dist/src/a2a/executor.d.ts +13 -0
  25. package/dist/src/a2a/executor.d.ts.map +1 -1
  26. package/dist/src/a2a/executor.js +19 -1
  27. package/dist/src/a2a/executor.js.map +1 -1
  28. package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.d.ts +2 -0
  29. package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.d.ts.map +1 -0
  30. package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.js +23 -0
  31. package/dist/src/agent/__tests__/agent-as-tool.invocation-state.test.js.map +1 -0
  32. package/dist/src/agent/__tests__/agent.cancel.test.js +1 -1
  33. package/dist/src/agent/__tests__/agent.cancel.test.js.map +1 -1
  34. package/dist/src/agent/__tests__/agent.concurrent.test.d.ts +2 -0
  35. package/dist/src/agent/__tests__/agent.concurrent.test.d.ts.map +1 -0
  36. package/dist/src/agent/__tests__/agent.concurrent.test.js +488 -0
  37. package/dist/src/agent/__tests__/agent.concurrent.test.js.map +1 -0
  38. package/dist/src/agent/__tests__/agent.hook.test.js +174 -12
  39. package/dist/src/agent/__tests__/agent.hook.test.js.map +1 -1
  40. package/dist/src/agent/__tests__/agent.invocation-state.test.d.ts +2 -0
  41. package/dist/src/agent/__tests__/agent.invocation-state.test.d.ts.map +1 -0
  42. package/dist/src/agent/__tests__/agent.invocation-state.test.js +219 -0
  43. package/dist/src/agent/__tests__/agent.invocation-state.test.js.map +1 -0
  44. package/dist/src/agent/__tests__/agent.stateful-model.test.d.ts +2 -0
  45. package/dist/src/agent/__tests__/agent.stateful-model.test.d.ts.map +1 -0
  46. package/dist/src/agent/__tests__/agent.stateful-model.test.js +169 -0
  47. package/dist/src/agent/__tests__/agent.stateful-model.test.js.map +1 -0
  48. package/dist/src/agent/__tests__/agent.test.js +99 -2
  49. package/dist/src/agent/__tests__/agent.test.js.map +1 -1
  50. package/dist/src/agent/__tests__/agent.tracer.test.node.js +39 -0
  51. package/dist/src/agent/__tests__/agent.tracer.test.node.js.map +1 -1
  52. package/dist/src/agent/__tests__/snapshot.test.js +5 -4
  53. package/dist/src/agent/__tests__/snapshot.test.js.map +1 -1
  54. package/dist/src/agent/agent-as-tool.d.ts.map +1 -1
  55. package/dist/src/agent/agent-as-tool.js +4 -2
  56. package/dist/src/agent/agent-as-tool.js.map +1 -1
  57. package/dist/src/agent/agent.d.ts +75 -1
  58. package/dist/src/agent/agent.d.ts.map +1 -1
  59. package/dist/src/agent/agent.js +323 -83
  60. package/dist/src/agent/agent.js.map +1 -1
  61. package/dist/src/agent/snapshot.d.ts +2 -2
  62. package/dist/src/agent/snapshot.d.ts.map +1 -1
  63. package/dist/src/agent/snapshot.js +8 -2
  64. package/dist/src/agent/snapshot.js.map +1 -1
  65. package/dist/src/conversation-manager/__tests__/conversation-manager.test.js +4 -4
  66. package/dist/src/conversation-manager/__tests__/conversation-manager.test.js.map +1 -1
  67. package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js +2 -2
  68. package/dist/src/conversation-manager/__tests__/null-conversation-manager.test.js.map +1 -1
  69. package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js +8 -3
  70. package/dist/src/conversation-manager/__tests__/sliding-window-conversation-manager.test.js.map +1 -1
  71. package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js +1 -0
  72. package/dist/src/conversation-manager/__tests__/summarizing-conversation-manager.test.js.map +1 -1
  73. package/dist/src/errors.d.ts +11 -0
  74. package/dist/src/errors.d.ts.map +1 -1
  75. package/dist/src/errors.js +12 -0
  76. package/dist/src/errors.js.map +1 -1
  77. package/dist/src/hooks/__tests__/events.test.js +177 -70
  78. package/dist/src/hooks/__tests__/events.test.js.map +1 -1
  79. package/dist/src/hooks/__tests__/registry.test.js +16 -16
  80. package/dist/src/hooks/__tests__/registry.test.js.map +1 -1
  81. package/dist/src/hooks/events.d.ts +95 -25
  82. package/dist/src/hooks/events.d.ts.map +1 -1
  83. package/dist/src/hooks/events.js +98 -23
  84. package/dist/src/hooks/events.js.map +1 -1
  85. package/dist/src/index.d.ts +5 -4
  86. package/dist/src/index.d.ts.map +1 -1
  87. package/dist/src/index.js.map +1 -1
  88. package/dist/src/logging/__tests__/warn-once.test.d.ts +2 -0
  89. package/dist/src/logging/__tests__/warn-once.test.d.ts.map +1 -0
  90. package/dist/src/logging/__tests__/warn-once.test.js +30 -0
  91. package/dist/src/logging/__tests__/warn-once.test.js.map +1 -0
  92. package/dist/src/logging/warn-once.d.ts +13 -0
  93. package/dist/src/logging/warn-once.d.ts.map +1 -0
  94. package/dist/src/logging/warn-once.js +18 -0
  95. package/dist/src/logging/warn-once.js.map +1 -0
  96. package/dist/src/mcp.d.ts +20 -1
  97. package/dist/src/mcp.d.ts.map +1 -1
  98. package/dist/src/mcp.js +10 -1
  99. package/dist/src/mcp.js.map +1 -1
  100. package/dist/src/mime.d.ts +2 -1
  101. package/dist/src/mime.d.ts.map +1 -1
  102. package/dist/src/mime.js +1 -0
  103. package/dist/src/mime.js.map +1 -1
  104. package/dist/src/models/__tests__/anthropic.test.js +92 -3
  105. package/dist/src/models/__tests__/anthropic.test.js.map +1 -1
  106. package/dist/src/models/__tests__/bedrock.test.js +113 -2
  107. package/dist/src/models/__tests__/bedrock.test.js.map +1 -1
  108. package/dist/src/models/__tests__/google.test.js +77 -0
  109. package/dist/src/models/__tests__/google.test.js.map +1 -1
  110. package/dist/src/models/__tests__/model.test.js +149 -1
  111. package/dist/src/models/__tests__/model.test.js.map +1 -1
  112. package/dist/src/models/anthropic.d.ts +12 -1
  113. package/dist/src/models/anthropic.d.ts.map +1 -1
  114. package/dist/src/models/anthropic.js +38 -6
  115. package/dist/src/models/anthropic.js.map +1 -1
  116. package/dist/src/models/bedrock.d.ts +12 -1
  117. package/dist/src/models/bedrock.d.ts.map +1 -1
  118. package/dist/src/models/bedrock.js +45 -11
  119. package/dist/src/models/bedrock.js.map +1 -1
  120. package/dist/src/models/defaults.d.ts +37 -0
  121. package/dist/src/models/defaults.d.ts.map +1 -0
  122. package/dist/src/models/defaults.js +41 -0
  123. package/dist/src/models/defaults.js.map +1 -0
  124. package/dist/src/models/google/model.d.ts +14 -1
  125. package/dist/src/models/google/model.d.ts.map +1 -1
  126. package/dist/src/models/google/model.js +50 -6
  127. package/dist/src/models/google/model.js.map +1 -1
  128. package/dist/src/models/model.d.ts +50 -0
  129. package/dist/src/models/model.d.ts.map +1 -1
  130. package/dist/src/models/model.js +120 -0
  131. package/dist/src/models/model.js.map +1 -1
  132. package/dist/src/models/openai/__tests__/chat.test.d.ts +2 -0
  133. package/dist/src/models/openai/__tests__/chat.test.d.ts.map +1 -0
  134. package/dist/src/models/{__tests__/openai.test.js → openai/__tests__/chat.test.js} +72 -7
  135. package/dist/src/models/openai/__tests__/chat.test.js.map +1 -0
  136. package/dist/src/models/openai/__tests__/responses.test.d.ts +2 -0
  137. package/dist/src/models/openai/__tests__/responses.test.d.ts.map +1 -0
  138. package/dist/src/models/openai/__tests__/responses.test.js +668 -0
  139. package/dist/src/models/openai/__tests__/responses.test.js.map +1 -0
  140. package/dist/src/models/openai/chat-adapter.d.ts +33 -0
  141. package/dist/src/models/openai/chat-adapter.d.ts.map +1 -0
  142. package/dist/src/models/openai/chat-adapter.js +383 -0
  143. package/dist/src/models/openai/chat-adapter.js.map +1 -0
  144. package/dist/src/models/openai/errors.d.ts +16 -0
  145. package/dist/src/models/openai/errors.d.ts.map +1 -0
  146. package/dist/src/models/openai/errors.js +40 -0
  147. package/dist/src/models/openai/errors.js.map +1 -0
  148. package/dist/src/models/openai/formatting.d.ts +18 -0
  149. package/dist/src/models/openai/formatting.d.ts.map +1 -0
  150. package/dist/src/models/openai/formatting.js +38 -0
  151. package/dist/src/models/openai/formatting.js.map +1 -0
  152. package/dist/src/models/openai/index.d.ts +19 -0
  153. package/dist/src/models/openai/index.d.ts.map +1 -0
  154. package/dist/src/models/openai/index.js +18 -0
  155. package/dist/src/models/openai/index.js.map +1 -0
  156. package/dist/src/models/openai/model.d.ts +77 -0
  157. package/dist/src/models/openai/model.d.ts.map +1 -0
  158. package/dist/src/models/openai/model.js +211 -0
  159. package/dist/src/models/openai/model.js.map +1 -0
  160. package/dist/src/models/openai/responses-adapter.d.ts +78 -0
  161. package/dist/src/models/openai/responses-adapter.d.ts.map +1 -0
  162. package/dist/src/models/openai/responses-adapter.js +467 -0
  163. package/dist/src/models/openai/responses-adapter.js.map +1 -0
  164. package/dist/src/models/openai/types.d.ts +131 -0
  165. package/dist/src/models/openai/types.d.ts.map +1 -0
  166. package/dist/src/models/openai/types.js +5 -0
  167. package/dist/src/models/openai/types.js.map +1 -0
  168. package/dist/src/multiagent/__tests__/events.test.js +122 -28
  169. package/dist/src/multiagent/__tests__/events.test.js.map +1 -1
  170. package/dist/src/multiagent/__tests__/graph.invocation-state.test.d.ts +2 -0
  171. package/dist/src/multiagent/__tests__/graph.invocation-state.test.d.ts.map +1 -0
  172. package/dist/src/multiagent/__tests__/graph.invocation-state.test.js +95 -0
  173. package/dist/src/multiagent/__tests__/graph.invocation-state.test.js.map +1 -0
  174. package/dist/src/multiagent/__tests__/nodes.test.js +5 -2
  175. package/dist/src/multiagent/__tests__/nodes.test.js.map +1 -1
  176. package/dist/src/multiagent/__tests__/swarm.invocation-state.test.d.ts +2 -0
  177. package/dist/src/multiagent/__tests__/swarm.invocation-state.test.d.ts.map +1 -0
  178. package/dist/src/multiagent/__tests__/swarm.invocation-state.test.js +56 -0
  179. package/dist/src/multiagent/__tests__/swarm.invocation-state.test.js.map +1 -0
  180. package/dist/src/multiagent/events.d.ts +19 -1
  181. package/dist/src/multiagent/events.d.ts.map +1 -1
  182. package/dist/src/multiagent/events.js +18 -0
  183. package/dist/src/multiagent/events.js.map +1 -1
  184. package/dist/src/multiagent/graph.d.ts +5 -3
  185. package/dist/src/multiagent/graph.d.ts.map +1 -1
  186. package/dist/src/multiagent/graph.js +22 -15
  187. package/dist/src/multiagent/graph.js.map +1 -1
  188. package/dist/src/multiagent/index.d.ts +1 -1
  189. package/dist/src/multiagent/index.d.ts.map +1 -1
  190. package/dist/src/multiagent/multiagent.d.ts +16 -3
  191. package/dist/src/multiagent/multiagent.d.ts.map +1 -1
  192. package/dist/src/multiagent/nodes.d.ts +10 -3
  193. package/dist/src/multiagent/nodes.d.ts.map +1 -1
  194. package/dist/src/multiagent/nodes.js +28 -6
  195. package/dist/src/multiagent/nodes.js.map +1 -1
  196. package/dist/src/multiagent/swarm.d.ts +5 -3
  197. package/dist/src/multiagent/swarm.d.ts.map +1 -1
  198. package/dist/src/multiagent/swarm.js +22 -16
  199. package/dist/src/multiagent/swarm.js.map +1 -1
  200. package/dist/src/plugins/__tests__/registry.test.js +1 -1
  201. package/dist/src/plugins/__tests__/registry.test.js.map +1 -1
  202. package/dist/src/plugins/model-plugin.d.ts +20 -0
  203. package/dist/src/plugins/model-plugin.d.ts.map +1 -0
  204. package/dist/src/plugins/model-plugin.js +29 -0
  205. package/dist/src/plugins/model-plugin.js.map +1 -0
  206. package/dist/src/session/__tests__/session-manager.test.js +13 -11
  207. package/dist/src/session/__tests__/session-manager.test.js.map +1 -1
  208. package/dist/src/session/session-manager.d.ts.map +1 -1
  209. package/dist/src/session/session-manager.js +9 -0
  210. package/dist/src/session/session-manager.js.map +1 -1
  211. package/dist/src/telemetry/__tests__/meter.test.js +23 -0
  212. package/dist/src/telemetry/__tests__/meter.test.js.map +1 -1
  213. package/dist/src/telemetry/meter.d.ts +15 -0
  214. package/dist/src/telemetry/meter.d.ts.map +1 -1
  215. package/dist/src/telemetry/meter.js +14 -0
  216. package/dist/src/telemetry/meter.js.map +1 -1
  217. package/dist/src/tools/mcp-tool.d.ts +24 -3
  218. package/dist/src/tools/mcp-tool.d.ts.map +1 -1
  219. package/dist/src/tools/mcp-tool.js +103 -31
  220. package/dist/src/tools/mcp-tool.js.map +1 -1
  221. package/dist/src/tools/tool.d.ts +11 -1
  222. package/dist/src/tools/tool.d.ts.map +1 -1
  223. package/dist/src/tools/tool.js.map +1 -1
  224. package/dist/src/tsconfig.tsbuildinfo +1 -1
  225. package/dist/src/types/__tests__/agent.test.js +48 -0
  226. package/dist/src/types/__tests__/agent.test.js.map +1 -1
  227. package/dist/src/types/agent.d.ts +55 -6
  228. package/dist/src/types/agent.d.ts.map +1 -1
  229. package/dist/src/types/agent.js +22 -6
  230. package/dist/src/types/agent.js.map +1 -1
  231. package/dist/src/types/elicitation.d.ts +15 -0
  232. package/dist/src/types/elicitation.d.ts.map +1 -0
  233. package/dist/src/types/elicitation.js +2 -0
  234. package/dist/src/types/elicitation.js.map +1 -0
  235. package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js +9 -5
  236. package/dist/src/vended-plugins/skills/__tests__/agent-skills.test.node.js.map +1 -1
  237. package/dist/src/vended-tools/bash/__tests__/bash.test.node.js +1 -0
  238. package/dist/src/vended-tools/bash/__tests__/bash.test.node.js.map +1 -1
  239. package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js +1 -0
  240. package/dist/src/vended-tools/file-editor/__tests__/file-editor.test.node.js.map +1 -1
  241. package/dist/src/vended-tools/notebook/__tests__/notebook.test.js +1 -0
  242. package/dist/src/vended-tools/notebook/__tests__/notebook.test.js.map +1 -1
  243. package/package.json +9 -5
  244. package/dist/src/models/__tests__/openai.test.d.ts +0 -2
  245. package/dist/src/models/__tests__/openai.test.d.ts.map +0 -1
  246. package/dist/src/models/__tests__/openai.test.js.map +0 -1
  247. package/dist/src/models/openai.d.ts +0 -312
  248. package/dist/src/models/openai.d.ts.map +0 -1
  249. package/dist/src/models/openai.js +0 -789
  250. package/dist/src/models/openai.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,175 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
package/README.md ADDED
@@ -0,0 +1,340 @@
1
+ <div align="center">
2
+ <div>
3
+ <a href="https://strandsagents.com">
4
+ <img src="https://strandsagents.com/latest/assets/logo-github.svg" alt="Strands Agents" width="55px" height="105px">
5
+ </a>
6
+ </div>
7
+
8
+ <h1>
9
+ Strands Agents - TypeScript SDK
10
+ </h1>
11
+
12
+ <h2>
13
+ A model-driven approach to building AI agents in TypeScript/JavaScript.
14
+ </h2>
15
+
16
+ <div align="center">
17
+ <a href="https://github.com/strands-agents/sdk-typescript/graphs/commit-activity"><img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/strands-agents/sdk-typescript"/></a>
18
+ <a href="https://github.com/strands-agents/sdk-typescript/issues"><img alt="GitHub open issues" src="https://img.shields.io/github/issues/strands-agents/sdk-typescript"/></a>
19
+ <a href="https://github.com/strands-agents/sdk-typescript/pulls"><img alt="GitHub open pull requests" src="https://img.shields.io/github/issues-pr/strands-agents/sdk-typescript"/></a>
20
+ <a href="https://github.com/strands-agents/sdk-typescript/blob/main/LICENSE.APACHE"><img alt="License" src="https://img.shields.io/github/license/strands-agents/sdk-typescript"/></a>
21
+ <a href="https://www.npmjs.com/package/@strands-agents/sdk"><img alt="NPM Version" src="https://img.shields.io/npm/v/@strands-agents/sdk"/></a>
22
+ </div>
23
+
24
+ <p>
25
+ <a href="https://strandsagents.com/">Documentation</a>
26
+ ◆ <a href="https://github.com/strands-agents/samples">Samples</a>
27
+ ◆ <a href="https://github.com/strands-agents/sdk-python">Python SDK</a>
28
+ ◆ <a href="https://github.com/strands-agents/tools">Tools</a>
29
+ ◆ <a href="https://github.com/strands-agents/agent-builder">Agent Builder</a>
30
+ ◆ <a href="https://github.com/strands-agents/mcp-server">MCP Server</a>
31
+ </p>
32
+ </div>
33
+
34
+ ---
35
+
36
+ ## Overview
37
+
38
+ Strands Agents is a simple yet powerful SDK that takes a model-driven approach to building and running AI agents. The TypeScript SDK brings key features from the Python Strands framework to Node.js environments, enabling type-safe agent development for everything from simple assistants to complex workflows.
39
+
40
+ ### Key Features
41
+
42
+ - **🪶 Lightweight & Flexible**: Simple agent loop that works seamlessly in Node.js and browser environments
43
+ - **🔒 Type-Safe Tools**: Define tools easily using Zod schemas for robust input validation and type inference
44
+ - **📋 Structured Output**: Get type-safe, validated responses from LLMs using Zod schemas with automatic retry on validation errors
45
+ - **🔌 Model Agnostic**: First-class support for Amazon Bedrock and OpenAI, with extensible architecture for custom providers
46
+ - **🔗 Built-in MCP**: Native support for Model Context Protocol (MCP) clients, enabling access to external tools and servers
47
+ - **⚡ Streaming Support**: Real-time response streaming for better user experience
48
+ - **🎣 Extensible Hooks**: Lifecycle hooks for monitoring and customizing agent behavior
49
+ - **💬 Conversation Management**: Flexible strategies for managing conversation history and context windows
50
+ - **🤝 Multi-Agent Orchestration**: Graph and Swarm patterns for coordinating multiple agents
51
+
52
+ ---
53
+
54
+ ## Quick Start
55
+
56
+ ### Installation
57
+
58
+ Ensure you have **[Node.js 20+](https://nodejs.org/)** installed, then:
59
+
60
+ ```bash
61
+ npm install @strands-agents/sdk
62
+ ```
63
+
64
+ ### Basic Usage
65
+
66
+ ```typescript
67
+ import { Agent } from '@strands-agents/sdk'
68
+
69
+ // Create agent (uses default Amazon Bedrock provider)
70
+ const agent = new Agent()
71
+
72
+ // Invoke
73
+ const result = await agent.invoke('What is the square root of 1764?')
74
+ console.log(result)
75
+ ```
76
+
77
+ > **Note**: For the default Amazon Bedrock model provider, you'll need AWS credentials configured and model access enabled for Claude Sonnet 4 in your region.
78
+
79
+ ---
80
+
81
+ ## Core Concepts
82
+
83
+ ### Agents
84
+
85
+ The `Agent` class is the central orchestrator that manages the interaction loop between users, models, and tools.
86
+
87
+ ```typescript
88
+ import { Agent } from '@strands-agents/sdk'
89
+
90
+ const agent = new Agent({
91
+ systemPrompt: 'You are a helpful assistant.',
92
+ })
93
+ ```
94
+ ### Model Providers
95
+
96
+ Switch between model providers easily:
97
+
98
+ **Amazon Bedrock (Default)**
99
+
100
+ ```typescript
101
+ import { Agent, BedrockModel } from '@strands-agents/sdk'
102
+
103
+ const model = new BedrockModel({
104
+ region: 'us-east-1',
105
+ modelId: 'anthropic.claude-3-5-sonnet-20240620-v1:0',
106
+ maxTokens: 4096,
107
+ temperature: 0.7
108
+ })
109
+
110
+ const agent = new Agent({ model })
111
+ ```
112
+
113
+ **OpenAI**
114
+
115
+ ```typescript
116
+ import { Agent } from '@strands-agents/sdk'
117
+ import { OpenAIModel } from '@strands-agents/sdk/models/openai'
118
+
119
+ // Automatically uses process.env.OPENAI_API_KEY and defaults to gpt-5.4
120
+ const model = new OpenAIModel({ api: 'chat' })
121
+
122
+ const agent = new Agent({ model })
123
+ ```
124
+
125
+ ### Streaming Responses
126
+
127
+ Access responses as they are generated:
128
+
129
+ ```typescript
130
+ const agent = new Agent()
131
+
132
+ console.log('Agent response stream:')
133
+ for await (const event of agent.stream('Tell me a story about a brave toaster.')) {
134
+ console.log('[Event]', event.type)
135
+ }
136
+ ```
137
+
138
+ ### Tools
139
+
140
+ Tools enable agents to interact with external systems and perform actions. Create type-safe tools using Zod schemas:
141
+
142
+ ```typescript
143
+ import { Agent, tool } from '@strands-agents/sdk'
144
+ import { z } from 'zod'
145
+
146
+ const weatherTool = tool({
147
+ name: 'get_weather',
148
+ description: 'Get the current weather for a specific location.',
149
+ inputSchema: z.object({
150
+ location: z.string().describe('The city and state, e.g., San Francisco, CA'),
151
+ }),
152
+ callback: (input) => {
153
+ // input is fully typed based on the Zod schema
154
+ return `The weather in ${input.location} is 72°F and sunny.`
155
+ },
156
+ })
157
+
158
+ const agent = new Agent({
159
+ tools: [weatherTool],
160
+ })
161
+
162
+ await agent.invoke('What is the weather in San Francisco?')
163
+ ```
164
+
165
+ **Vended Tools**: The SDK includes optional pre-built tools:
166
+ - **Notebook Tool**: Manage text-based notebooks for persistent note-taking
167
+ - **File Editor Tool**: Perform file system operations (read, write, edit files)
168
+ - **HTTP Request Tool**: Make HTTP requests to external APIs
169
+
170
+
171
+ ### Structured Output
172
+
173
+ Get type-safe, validated responses from LLMs by defining the expected output structure with Zod schemas. The agent automatically validates the LLM's response and retries on validation errors:
174
+
175
+ ```typescript
176
+ import { Agent } from '@strands-agents/sdk'
177
+ import { z } from 'zod'
178
+
179
+ const PersonSchema = z.object({
180
+ name: z.string().describe('Name of the person'),
181
+ age: z.number().describe('Age of the person'),
182
+ occupation: z.string().describe('Occupation of the person')
183
+ })
184
+
185
+ // Configure structured output at the agent level
186
+ const agent = new Agent({
187
+ structuredOutputSchema: PersonSchema
188
+ })
189
+
190
+ const result = await agent.invoke('John Smith is a 30 year-old software engineer')
191
+
192
+ // result.structuredOutput is fully typed based on the schema
193
+ console.log(result.structuredOutput.name) // "John Smith"
194
+ console.log(result.structuredOutput.age) // 30
195
+ ```
196
+
197
+ **Error handling**: The agent automatically retries with validation feedback when the LLM provides invalid output. If validation ultimately fails, a `StructuredOutputError` is thrown:
198
+
199
+ ```typescript
200
+ import { StructuredOutputError } from '@strands-agents/sdk'
201
+
202
+ try {
203
+ const result = await agent.invoke('Extract person info...')
204
+ console.log(result.structuredOutput)
205
+ } catch (error) {
206
+ if (error instanceof StructuredOutputError) {
207
+ console.error('Validation failed:', error.message)
208
+ }
209
+ }
210
+ ```
211
+
212
+
213
+ ### MCP Integration
214
+
215
+ Seamlessly integrate Model Context Protocol (MCP) servers:
216
+
217
+ ```typescript
218
+ import { Agent, McpClient } from "@strands-agents/sdk";
219
+ import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
220
+
221
+ // Create a client for a local MCP server
222
+ const documentationTools = new McpClient({
223
+ transport: new StdioClientTransport({
224
+ command: "uvx",
225
+ args: ["awslabs.aws-documentation-mcp-server@latest"],
226
+ }),
227
+ });
228
+
229
+ const agent = new Agent({
230
+ systemPrompt: "You are a helpful assistant using MCP tools.",
231
+ tools: [documentationTools], // Pass the MCP client directly as a tool source
232
+ });
233
+
234
+ await agent.invoke("Use a random tool from the MCP server.");
235
+
236
+ await documentationTools.disconnect();
237
+ ```
238
+
239
+ ### Multi-Agent Orchestration
240
+
241
+ Coordinate multiple agents using built-in orchestration patterns.
242
+
243
+ **Graph** — You define a deterministic execution plan. Agents run as nodes in a directed graph, with edges controlling execution order. Parallel execution is supported, and downstream nodes run once all dependencies complete.
244
+
245
+ ```typescript
246
+ import { Agent, BedrockModel, Graph } from '@strands-agents/sdk'
247
+
248
+ const model = new BedrockModel({ maxTokens: 1024 })
249
+
250
+ const researcher = new Agent({
251
+ model,
252
+ id: 'researcher',
253
+ systemPrompt: 'Research the topic and provide key facts.',
254
+ })
255
+
256
+ const writer = new Agent({
257
+ model,
258
+ id: 'writer',
259
+ systemPrompt: 'Rewrite the research into a polished paragraph.',
260
+ })
261
+
262
+ const graph = new Graph({
263
+ nodes: [researcher, writer],
264
+ edges: [['researcher', 'writer']],
265
+ })
266
+
267
+ const result = await graph.invoke('What is the largest ocean?')
268
+ ```
269
+
270
+ **Swarm** — The agents decide the routing. Each agent chooses whether to hand off to another agent or produce a final response, making the execution path dynamic and model-driven.
271
+
272
+ ```typescript
273
+ import { Agent, BedrockModel, Swarm } from '@strands-agents/sdk'
274
+
275
+ const model = new BedrockModel({ maxTokens: 1024 })
276
+
277
+ const researcher = new Agent({
278
+ model,
279
+ id: 'researcher',
280
+ description: 'Researches a topic and gathers key facts.',
281
+ systemPrompt: 'Research the answer, then hand off to the writer.',
282
+ })
283
+
284
+ const writer = new Agent({
285
+ model,
286
+ id: 'writer',
287
+ description: 'Writes a polished final answer.',
288
+ systemPrompt: 'Write the final answer. Do not hand off.',
289
+ })
290
+
291
+ const swarm = new Swarm({
292
+ nodes: [researcher, writer],
293
+ start: 'researcher',
294
+ maxSteps: 4,
295
+ })
296
+
297
+ const result = await swarm.invoke('What is the largest ocean?')
298
+ ```
299
+
300
+ Both patterns support streaming via `.stream()` for real-time access to handoff and node execution events. See the [examples](./strands-ts/examples/) directory for complete working samples.
301
+
302
+ ---
303
+
304
+ ## Documentation
305
+
306
+ For detailed guidance, tutorials, and concept overviews, please visit:
307
+
308
+ - **[Official Documentation](https://strandsagents.com/)**: Comprehensive guides and tutorials
309
+ - **[API Reference](https://strandsagents.com/docs/api/typescript/)**: Complete API documentation
310
+ - **[Examples](./strands-ts/examples/)**: Sample applications
311
+ - **[First Agent](./strands-ts/examples/first-agent/)**: Basic Node.js agent
312
+ - **[MCP](./strands-ts/examples/mcp/)**: MCP integration example
313
+ - **[Browser Agent](./strands-ts/examples/browser-agent/)**: Browser-based agent with DOM manipulation
314
+
315
+ - **[Contributing Guide](CONTRIBUTING.md)**: Development setup and guidelines
316
+
317
+ ---
318
+
319
+ ## Contributing ❤️
320
+
321
+ We welcome contributions! See our [Contributing Guide](CONTRIBUTING.md) for details on:
322
+
323
+ - Development setup and environment
324
+ - Testing and code quality standards
325
+ - Pull request process
326
+ - Code of Conduct
327
+ - Security issue reporting
328
+
329
+ ---
330
+
331
+ ## License
332
+
333
+ This project is licensed under the Apache License 2.0 - see the [LICENSE](LICENSE.APACHE) file for details.
334
+
335
+ ---
336
+
337
+ ## Security
338
+
339
+ See [CONTRIBUTING](CONTRIBUTING.md#security-issue-notifications) for more information on reporting security issues.
340
+
@@ -94,6 +94,12 @@ export interface AgentResultMatcher extends Omit<LoopMetricsMatcher, 'cycleCount
94
94
  * When omitted, asserts traces array exists with at least one element.
95
95
  */
96
96
  traceCount?: number;
97
+ /**
98
+ * Expected `invocationState` on the result. When provided, the full object
99
+ * must match exactly — extra keys fail. When omitted, only asserts
100
+ * `invocationState` is present (any object).
101
+ */
102
+ invocationState?: Record<string, unknown>;
97
103
  }
98
104
  /**
99
105
  * Creates an asymmetric matcher that validates AgentResult structure and values.
@@ -1 +1 @@
1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AEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;IAEnB;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC1C;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAgC1E"}
@@ -20,6 +20,7 @@ export function createMockAgent(data) {
20
20
  return {
21
21
  messages: data?.messages ?? [],
22
22
  appState: new StateStore(data?.appState ?? {}),
23
+ modelState: new StateStore(),
23
24
  toolRegistry: data?.toolRegistry ?? new ToolRegistry(),
24
25
  cancelSignal: new AbortController().signal,
25
26
  addHook: (eventType, callback) => {
@@ -74,7 +75,7 @@ export async function invokeTrackedHook(agent, event) {
74
75
  * ```
75
76
  */
76
77
  export function expectAgentResult(options) {
77
- const { stopReason, messageText, cycleCount, traceCount, toolNames, usage } = options;
78
+ const { stopReason, messageText, cycleCount, traceCount, toolNames, usage, invocationState } = options;
78
79
  const expectedLastMessage = messageText
79
80
  ? expect.objectContaining({
80
81
  role: 'assistant',
@@ -98,6 +99,7 @@ export function expectAgentResult(options) {
98
99
  lastMessage: expectedLastMessage,
99
100
  metrics: expectLoopMetrics(metricsOptions),
100
101
  traces: expectedTraces,
102
+ invocationState: invocationState ?? expect.any(Object),
101
103
  });
102
104
  }
103
105
  //# sourceMappingURL=agent-helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"agent-helpers.js","sourceRoot":"","sources":["../../../src/__fixtures__/agent-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAI/B,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,8B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Ae,CAAC,CAAC,MAAM,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IAErF,mEAAmE;IACnE,MAAM,cAAc,GAAuB,EAAE,UAAU,EAAE,CAAA;IACzD,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAC5B,cAAc,CAAC,SAAS,GAAG,SAAS,CAAA;IACtC,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,cAAc,CAAC,KAAK,GAAG,KAAK,CAAA;IAC9B,CAAC;IAED,OAAO,MAAM,CAAC,gBAAgB,CAAC;QAC7B,IAAI,EAAE,aAAa;QACnB,UAAU;QACV,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE,iBAAiB,CAAC,cAAc,CAAC;QAC1C,MAAM,EAAE,cAAc;QACtB,eAAe,EAAE,eAAe,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;KACvD,CAAgB,CAAA;AACnB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"mock-plugin.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/mock-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAenD;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,WAAW,EAAE,aAAa,EAAE,CAAK;IAEjC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAqBlC,KAAK,IAAI,IAAI;CAGd"}
1
+ {"version":3,"file":"mock-plugin.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/mock-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAiBnD;;GAEG;AACH,qBAAa,UAAW,YAAW,MAAM;IACvC,WAAW,EAAE,aAAa,EAAE,CAAK;IAEjC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,SAAS,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAuBlC,KAAK,IAAI,IAAI;CAGd"}
@@ -1,4 +1,4 @@
1
- import { InitializedEvent, BeforeInvocationEvent, AfterInvocationEvent, MessageAddedEvent, BeforeToolsEvent, AfterToolsEvent, BeforeToolCallEvent, AfterToolCallEvent, BeforeModelCallEvent, AfterModelCallEvent, } from '../hooks/index.js';
1
+ import { InitializedEvent, BeforeInvocationEvent, AfterInvocationEvent, MessageAddedEvent, BeforeToolsEvent, AfterToolsEvent, BeforeToolCallEvent, AfterToolCallEvent, BeforeModelCallEvent, AfterModelCallEvent, ToolResultEvent, ToolStreamUpdateEvent, } from '../hooks/index.js';
2
2
  /**
3
3
  * Mock plugin that records all hookable event invocations for testing.
4
4
  */
@@ -19,6 +19,8 @@ export class MockPlugin {
19
19
  AfterToolCallEvent,
20
20
  BeforeModelCallEvent,
21
21
  AfterModelCallEvent,
22
+ ToolResultEvent,
23
+ ToolStreamUpdateEvent,
22
24
  ];
23
25
  for (const eventType of eventTypes) {
24
26
  agent.addHook(eventType, (e) => {
@@ -1 +1 @@
1
- {"version":3,"file":"mock-plugin.js","sourceRoot":"","sources":["../../../src/__fixtures__/mock-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,mBAAmB,CAAA;AAG1B;;GAEG;AACH,MAAM,OAAO,UAAU;IACrB,WAAW,GAAoB,EAAE,CAAA;IAEjC,IAAI,IAAI;QACN,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,SAAS,CAAC,KAAiB;QACzB,MAAM,UAAU,GAA+B;YAC7C,gBAAgB;YAChB,qBAAqB;YACrB,oBAAoB;YACpB,iBAAiB;YACjB,gBAAgB;YAChB,eAAe;YACf,mBAAmB;YACnB,kBAAkB;YAClB,oBAAoB;YACpB,mBAAmB;SACpB,CAAA;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAC1B,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACvB,CAAC;CACF"}
1
+ {"version":3,"file":"mock-plugin.js","sourceRoot":"","sources":["../../../src/__fixtures__/mock-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,mBAAmB,EACnB,eAAe,EACf,qBAAqB,GACtB,MAAM,mBAAmB,CAAA;AAG1B;;GAEG;AACH,MAAM,OAAO,UAAU;IACrB,WAAW,GAAoB,EAAE,CAAA;IAEjC,IAAI,IAAI;QACN,OAAO,aAAa,CAAA;IACtB,CAAC;IAED,SAAS,CAAC,KAAiB;QACzB,MAAM,UAAU,GAA+B;YAC7C,gBAAgB;YAChB,qBAAqB;YACrB,oBAAoB;YACpB,iBAAiB;YACjB,gBAAgB;YAChB,eAAe;YACf,mBAAmB;YACnB,kBAAkB;YAClB,oBAAoB;YACpB,mBAAmB;YACnB,eAAe;YACf,qBAAqB;SACtB,CAAA;QAED,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;gBAC7B,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;YAC1B,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAA;IACvB,CAAC;CACF"}
@@ -5,18 +5,20 @@
5
5
  import type { Tool, ToolContext } from '../tools/tool.js';
6
6
  import type { JSONValue } from '../types/json.js';
7
7
  import type { PlainToolResultBlock } from './slim-types.js';
8
+ import type { InvocationState } from '../types/agent.js';
8
9
  /**
9
10
  * Helper to create a mock ToolContext for testing.
10
11
  *
11
12
  * @param toolUse - The tool use request
12
13
  * @param appState - Optional initial app state
14
+ * @param invocationState - Optional initial invocation state
13
15
  * @returns Mock ToolContext object
14
16
  */
15
17
  export declare function createMockContext(toolUse: {
16
18
  name: string;
17
19
  toolUseId: string;
18
20
  input: JSONValue;
19
- }, appState?: Record<string, JSONValue>): ToolContext;
21
+ }, appState?: Record<string, JSONValue>, invocationState?: InvocationState): ToolContext;
20
22
  /**
21
23
  * Result function type for createMockTool - accepts plain objects or class instances.
22
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../../src/__fixtures__/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAEzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAGjD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAG3D;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,M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E,QAAQ,EAAE,YAAY,GAAG,IAAI,CA8BzE;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAWpD"}
@@ -10,9 +10,10 @@ import { ToolRegistry } from '../registry/tool-registry.js';
10
10
  *
11
11
  * @param toolUse - The tool use request
12
12
  * @param appState - Optional initial app state
13
+ * @param invocationState - Optional initial invocation state
13
14
  * @returns Mock ToolContext object
14
15
  */
15
- export function createMockContext(toolUse, appState) {
16
+ export function createMockContext(toolUse, appState, invocationState) {
16
17
  return {
17
18
  toolUse,
18
19
  agent: {
@@ -22,6 +23,7 @@ export function createMockContext(toolUse, appState) {
22
23
  toolRegistry: new ToolRegistry(),
23
24
  addHook: () => () => { },
24
25
  },
26
+ invocationState: invocationState ?? {},
25
27
  };
26
28
  }
27
29
  /**