agentfootprint 10.3.1 → 10.4.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 (414) hide show
  1. package/AGENTS.md +2 -2
  2. package/CAPABILITIES.md +6 -0
  3. package/README.md +44 -0
  4. package/ai-instructions/claude-code/SKILL.md +2 -2
  5. package/dist/adapters/mcp/agentcoreRuntime/errorType.js +24 -0
  6. package/dist/adapters/mcp/agentcoreRuntime/errorType.js.map +1 -0
  7. package/dist/adapters/mcp/agentcoreRuntime/invoke.js +265 -0
  8. package/dist/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -0
  9. package/dist/adapters/mcp/agentcoreRuntime/safeAnswer.js +415 -0
  10. package/dist/adapters/mcp/agentcoreRuntime/safeAnswer.js.map +1 -0
  11. package/dist/adapters/mcp/agentcoreRuntime/session.js +179 -0
  12. package/dist/adapters/mcp/agentcoreRuntime/session.js.map +1 -0
  13. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js +117 -0
  14. package/dist/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -0
  15. package/dist/adapters/mcp/agentcoreRuntime/strictJson.js +220 -0
  16. package/dist/adapters/mcp/agentcoreRuntime/strictJson.js.map +1 -0
  17. package/dist/adapters/mcp/agentcoreRuntime/transport.js +204 -0
  18. package/dist/adapters/mcp/agentcoreRuntime/transport.js.map +1 -0
  19. package/dist/adapters/memory/agentcore.js +435 -20
  20. package/dist/adapters/memory/agentcore.js.map +1 -1
  21. package/dist/adapters/memory/memoryBank.js +16 -3
  22. package/dist/adapters/memory/memoryBank.js.map +1 -1
  23. package/dist/adapters/memory/pgVector.js +10 -4
  24. package/dist/adapters/memory/pgVector.js.map +1 -1
  25. package/dist/adapters/memory/redis.js +11 -3
  26. package/dist/adapters/memory/redis.js.map +1 -1
  27. package/dist/adapters/memory/s3Vectors.js +8 -3
  28. package/dist/adapters/memory/s3Vectors.js.map +1 -1
  29. package/dist/adapters/memory/sqliteVector.js +10 -4
  30. package/dist/adapters/memory/sqliteVector.js.map +1 -1
  31. package/dist/ag-ui/adapter.js +71 -0
  32. package/dist/ag-ui/adapter.js.map +1 -0
  33. package/dist/ag-ui/framing.js +66 -0
  34. package/dist/ag-ui/framing.js.map +1 -0
  35. package/dist/ag-ui/frontendTools.js +69 -0
  36. package/dist/ag-ui/frontendTools.js.map +1 -0
  37. package/dist/ag-ui/ids.js +54 -0
  38. package/dist/ag-ui/ids.js.map +1 -0
  39. package/dist/ag-ui/index.js +27 -0
  40. package/dist/ag-ui/index.js.map +1 -0
  41. package/dist/ag-ui/request.js +356 -0
  42. package/dist/ag-ui/request.js.map +1 -0
  43. package/dist/ag-ui/serializer.js +899 -0
  44. package/dist/ag-ui/serializer.js.map +1 -0
  45. package/dist/ag-ui/types.js +22 -0
  46. package/dist/ag-ui/types.js.map +1 -0
  47. package/dist/core/Agent.js +38 -5
  48. package/dist/core/Agent.js.map +1 -1
  49. package/dist/core/RunnerBase.js +16 -2
  50. package/dist/core/RunnerBase.js.map +1 -1
  51. package/dist/core/agent/buildAgentChart.js +4 -0
  52. package/dist/core/agent/buildAgentChart.js.map +1 -1
  53. package/dist/core/agent/buildDynamicAgentChart.js +4 -0
  54. package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
  55. package/dist/core/agent/callerIdentity.js +2 -1
  56. package/dist/core/agent/callerIdentity.js.map +1 -1
  57. package/dist/core/agent/stages/routeTurn.js +3 -3
  58. package/dist/core/agent/stages/routeTurn.js.map +1 -1
  59. package/dist/core/agent/stages/seed.js +49 -8
  60. package/dist/core/agent/stages/seed.js.map +1 -1
  61. package/dist/core/agent/stages/timeLayer.js +2 -2
  62. package/dist/core/agent/stages/timeLayer.js.map +1 -1
  63. package/dist/core/agent/stages/toolCalls.js +26 -5
  64. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  65. package/dist/core/memberRun.js +244 -0
  66. package/dist/core/memberRun.js.map +1 -0
  67. package/dist/core/slots/buildToolsSlot.js +1 -1
  68. package/dist/core/slots/buildToolsSlot.js.map +1 -1
  69. package/dist/core-flow/Conditional.js +29 -8
  70. package/dist/core-flow/Conditional.js.map +1 -1
  71. package/dist/core-flow/Graph.js +38 -13
  72. package/dist/core-flow/Graph.js.map +1 -1
  73. package/dist/core-flow/Loop.js +29 -9
  74. package/dist/core-flow/Loop.js.map +1 -1
  75. package/dist/core-flow/Parallel.js +35 -14
  76. package/dist/core-flow/Parallel.js.map +1 -1
  77. package/dist/core-flow/Sequence.js +29 -8
  78. package/dist/core-flow/Sequence.js.map +1 -1
  79. package/dist/core-flow/Workflow.js +34 -10
  80. package/dist/core-flow/Workflow.js.map +1 -1
  81. package/dist/doors/ag-ui.js +36 -0
  82. package/dist/doors/ag-ui.js.map +1 -0
  83. package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.d.ts +12 -0
  84. package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.js +20 -0
  85. package/dist/esm/adapters/mcp/agentcoreRuntime/errorType.js.map +1 -0
  86. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.d.ts +116 -0
  87. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js +260 -0
  88. package/dist/esm/adapters/mcp/agentcoreRuntime/invoke.js.map +1 -0
  89. package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts +49 -0
  90. package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.js +409 -0
  91. package/dist/esm/adapters/mcp/agentcoreRuntime/safeAnswer.js.map +1 -0
  92. package/dist/esm/adapters/mcp/agentcoreRuntime/session.d.ts +80 -0
  93. package/dist/esm/adapters/mcp/agentcoreRuntime/session.js +175 -0
  94. package/dist/esm/adapters/mcp/agentcoreRuntime/session.js.map +1 -0
  95. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +61 -0
  96. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js +112 -0
  97. package/dist/esm/adapters/mcp/agentcoreRuntime/sessionBusy.js.map +1 -0
  98. package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.d.ts +37 -0
  99. package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.js +215 -0
  100. package/dist/esm/adapters/mcp/agentcoreRuntime/strictJson.js.map +1 -0
  101. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.d.ts +176 -0
  102. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js +199 -0
  103. package/dist/esm/adapters/mcp/agentcoreRuntime/transport.js.map +1 -0
  104. package/dist/esm/adapters/memory/agentcore.d.ts +152 -7
  105. package/dist/esm/adapters/memory/agentcore.js +433 -19
  106. package/dist/esm/adapters/memory/agentcore.js.map +1 -1
  107. package/dist/esm/adapters/memory/memoryBank.d.ts +3 -2
  108. package/dist/esm/adapters/memory/memoryBank.js +16 -3
  109. package/dist/esm/adapters/memory/memoryBank.js.map +1 -1
  110. package/dist/esm/adapters/memory/pgVector.js +10 -4
  111. package/dist/esm/adapters/memory/pgVector.js.map +1 -1
  112. package/dist/esm/adapters/memory/redis.d.ts +8 -3
  113. package/dist/esm/adapters/memory/redis.js +11 -3
  114. package/dist/esm/adapters/memory/redis.js.map +1 -1
  115. package/dist/esm/adapters/memory/s3Vectors.js +8 -3
  116. package/dist/esm/adapters/memory/s3Vectors.js.map +1 -1
  117. package/dist/esm/adapters/memory/sqliteVector.js +10 -4
  118. package/dist/esm/adapters/memory/sqliteVector.js.map +1 -1
  119. package/dist/esm/ag-ui/adapter.d.ts +68 -0
  120. package/dist/esm/ag-ui/adapter.js +67 -0
  121. package/dist/esm/ag-ui/adapter.js.map +1 -0
  122. package/dist/esm/ag-ui/framing.d.ts +51 -0
  123. package/dist/esm/ag-ui/framing.js +62 -0
  124. package/dist/esm/ag-ui/framing.js.map +1 -0
  125. package/dist/esm/ag-ui/frontendTools.d.ts +37 -0
  126. package/dist/esm/ag-ui/frontendTools.js +64 -0
  127. package/dist/esm/ag-ui/frontendTools.js.map +1 -0
  128. package/dist/esm/ag-ui/ids.d.ts +43 -0
  129. package/dist/esm/ag-ui/ids.js +49 -0
  130. package/dist/esm/ag-ui/ids.js.map +1 -0
  131. package/dist/esm/ag-ui/index.d.ts +17 -0
  132. package/dist/esm/ag-ui/index.js +17 -0
  133. package/dist/esm/ag-ui/index.js.map +1 -0
  134. package/dist/esm/ag-ui/request.d.ts +72 -0
  135. package/dist/esm/ag-ui/request.js +350 -0
  136. package/dist/esm/ag-ui/request.js.map +1 -0
  137. package/dist/esm/ag-ui/serializer.d.ts +173 -0
  138. package/dist/esm/ag-ui/serializer.js +895 -0
  139. package/dist/esm/ag-ui/serializer.js.map +1 -0
  140. package/dist/esm/ag-ui/types.d.ts +305 -0
  141. package/dist/esm/ag-ui/types.js +19 -0
  142. package/dist/esm/ag-ui/types.js.map +1 -0
  143. package/dist/esm/core/Agent.d.ts +2 -0
  144. package/dist/esm/core/Agent.js +38 -5
  145. package/dist/esm/core/Agent.js.map +1 -1
  146. package/dist/esm/core/RunnerBase.js +17 -3
  147. package/dist/esm/core/RunnerBase.js.map +1 -1
  148. package/dist/esm/core/agent/buildAgentChart.js +4 -0
  149. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  150. package/dist/esm/core/agent/buildDynamicAgentChart.js +4 -0
  151. package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
  152. package/dist/esm/core/agent/callerIdentity.js +2 -1
  153. package/dist/esm/core/agent/callerIdentity.js.map +1 -1
  154. package/dist/esm/core/agent/stages/routeTurn.d.ts +1 -1
  155. package/dist/esm/core/agent/stages/routeTurn.js +3 -3
  156. package/dist/esm/core/agent/stages/routeTurn.js.map +1 -1
  157. package/dist/esm/core/agent/stages/seed.d.ts +11 -1
  158. package/dist/esm/core/agent/stages/seed.js +49 -8
  159. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  160. package/dist/esm/core/agent/stages/timeLayer.js +2 -2
  161. package/dist/esm/core/agent/stages/timeLayer.js.map +1 -1
  162. package/dist/esm/core/agent/stages/toolCalls.d.ts +11 -1
  163. package/dist/esm/core/agent/stages/toolCalls.js +26 -5
  164. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  165. package/dist/esm/core/agent/types.d.ts +16 -6
  166. package/dist/esm/core/memberRun.d.ts +132 -0
  167. package/dist/esm/core/memberRun.js +227 -0
  168. package/dist/esm/core/memberRun.js.map +1 -0
  169. package/dist/esm/core/slots/buildToolsSlot.d.ts +1 -1
  170. package/dist/esm/core/slots/buildToolsSlot.js +1 -1
  171. package/dist/esm/core/slots/buildToolsSlot.js.map +1 -1
  172. package/dist/esm/core-flow/Conditional.d.ts +8 -0
  173. package/dist/esm/core-flow/Conditional.js +29 -8
  174. package/dist/esm/core-flow/Conditional.js.map +1 -1
  175. package/dist/esm/core-flow/Graph.js +38 -13
  176. package/dist/esm/core-flow/Graph.js.map +1 -1
  177. package/dist/esm/core-flow/Loop.d.ts +8 -0
  178. package/dist/esm/core-flow/Loop.js +29 -9
  179. package/dist/esm/core-flow/Loop.js.map +1 -1
  180. package/dist/esm/core-flow/Parallel.d.ts +8 -0
  181. package/dist/esm/core-flow/Parallel.js +35 -14
  182. package/dist/esm/core-flow/Parallel.js.map +1 -1
  183. package/dist/esm/core-flow/Sequence.d.ts +8 -0
  184. package/dist/esm/core-flow/Sequence.js +29 -8
  185. package/dist/esm/core-flow/Sequence.js.map +1 -1
  186. package/dist/esm/core-flow/Workflow.js +34 -10
  187. package/dist/esm/core-flow/Workflow.js.map +1 -1
  188. package/dist/esm/doors/ag-ui.d.ts +19 -0
  189. package/dist/esm/doors/ag-ui.js +20 -0
  190. package/dist/esm/doors/ag-ui.js.map +1 -0
  191. package/dist/esm/hosting/envelope.js +5 -0
  192. package/dist/esm/hosting/envelope.js.map +1 -1
  193. package/dist/esm/hosting/httpHost.js +5 -78
  194. package/dist/esm/hosting/httpHost.js.map +1 -1
  195. package/dist/esm/hosting/index.d.ts +4 -1
  196. package/dist/esm/hosting/index.js +2 -0
  197. package/dist/esm/hosting/index.js.map +1 -1
  198. package/dist/esm/hosting/pendingAsk.d.ts +19 -0
  199. package/dist/esm/hosting/pendingAsk.js +38 -0
  200. package/dist/esm/hosting/pendingAsk.js.map +1 -0
  201. package/dist/esm/hosting/protocolAdapter.d.ts +229 -0
  202. package/dist/esm/hosting/protocolAdapter.js +23 -0
  203. package/dist/esm/hosting/protocolAdapter.js.map +1 -0
  204. package/dist/esm/hosting/refusalStatus.d.ts +30 -0
  205. package/dist/esm/hosting/refusalStatus.js +81 -0
  206. package/dist/esm/hosting/refusalStatus.js.map +1 -0
  207. package/dist/esm/hosting/standingAgent.js +1 -31
  208. package/dist/esm/hosting/standingAgent.js.map +1 -1
  209. package/dist/esm/hosting/stream.d.ts +39 -0
  210. package/dist/esm/hosting/stream.js +34 -2
  211. package/dist/esm/hosting/stream.js.map +1 -1
  212. package/dist/esm/hosting/streamHandler.d.ts +134 -0
  213. package/dist/esm/hosting/streamHandler.js +493 -0
  214. package/dist/esm/hosting/streamHandler.js.map +1 -0
  215. package/dist/esm/hosting/types.d.ts +15 -0
  216. package/dist/esm/hosting/types.js.map +1 -1
  217. package/dist/esm/hosting/verifiedThreads.d.ts +29 -0
  218. package/dist/esm/hosting/verifiedThreads.js +46 -0
  219. package/dist/esm/hosting/verifiedThreads.js.map +1 -0
  220. package/dist/esm/index.d.ts +1 -0
  221. package/dist/esm/index.js +3 -0
  222. package/dist/esm/index.js.map +1 -1
  223. package/dist/esm/lib/humanizeLLMError.d.ts +15 -0
  224. package/dist/esm/lib/humanizeLLMError.js +22 -7
  225. package/dist/esm/lib/humanizeLLMError.js.map +1 -1
  226. package/dist/esm/mcp/throttleRetry.d.ts +51 -0
  227. package/dist/esm/mcp/throttleRetry.js +37 -4
  228. package/dist/esm/mcp/throttleRetry.js.map +1 -1
  229. package/dist/esm/memory/define.js +45 -1
  230. package/dist/esm/memory/define.js.map +1 -1
  231. package/dist/esm/memory/define.types.d.ts +24 -0
  232. package/dist/esm/memory/define.types.js.map +1 -1
  233. package/dist/esm/memory/stages/formatDefault.js +3 -1
  234. package/dist/esm/memory/stages/formatDefault.js.map +1 -1
  235. package/dist/esm/memory/store/InMemoryStore.d.ts +8 -3
  236. package/dist/esm/memory/store/InMemoryStore.js +12 -3
  237. package/dist/esm/memory/store/InMemoryStore.js.map +1 -1
  238. package/dist/esm/memory/store/index.d.ts +1 -0
  239. package/dist/esm/memory/store/index.js +5 -0
  240. package/dist/esm/memory/store/index.js.map +1 -1
  241. package/dist/esm/memory/store/types.d.ts +38 -4
  242. package/dist/esm/memory/store/writeOptions.d.ts +118 -0
  243. package/dist/esm/memory/store/writeOptions.js +242 -0
  244. package/dist/esm/memory/store/writeOptions.js.map +1 -0
  245. package/dist/esm/memory-providers.d.ts +1 -1
  246. package/dist/esm/memory-providers.js +4 -1
  247. package/dist/esm/memory-providers.js.map +1 -1
  248. package/dist/esm/patterns/MapReduce.js +8 -2
  249. package/dist/esm/patterns/MapReduce.js.map +1 -1
  250. package/dist/esm/tool-providers/index.d.ts +5 -0
  251. package/dist/esm/tool-providers/index.js +6 -0
  252. package/dist/esm/tool-providers/index.js.map +1 -1
  253. package/dist/esm/trace-toolpack/selfExplain.d.ts +8 -0
  254. package/dist/esm/trace-toolpack/selfExplain.js +25 -2
  255. package/dist/esm/trace-toolpack/selfExplain.js.map +1 -1
  256. package/dist/hosting/envelope.js +5 -0
  257. package/dist/hosting/envelope.js.map +1 -1
  258. package/dist/hosting/httpHost.js +5 -78
  259. package/dist/hosting/httpHost.js.map +1 -1
  260. package/dist/hosting/index.js +9 -3
  261. package/dist/hosting/index.js.map +1 -1
  262. package/dist/hosting/pendingAsk.js +42 -0
  263. package/dist/hosting/pendingAsk.js.map +1 -0
  264. package/dist/hosting/protocolAdapter.js +24 -0
  265. package/dist/hosting/protocolAdapter.js.map +1 -0
  266. package/dist/hosting/refusalStatus.js +84 -0
  267. package/dist/hosting/refusalStatus.js.map +1 -0
  268. package/dist/hosting/standingAgent.js +2 -32
  269. package/dist/hosting/standingAgent.js.map +1 -1
  270. package/dist/hosting/stream.js +35 -3
  271. package/dist/hosting/stream.js.map +1 -1
  272. package/dist/hosting/streamHandler.js +497 -0
  273. package/dist/hosting/streamHandler.js.map +1 -0
  274. package/dist/hosting/types.js.map +1 -1
  275. package/dist/hosting/verifiedThreads.js +50 -0
  276. package/dist/hosting/verifiedThreads.js.map +1 -0
  277. package/dist/index.js +9 -3
  278. package/dist/index.js.map +1 -1
  279. package/dist/lib/humanizeLLMError.js +23 -8
  280. package/dist/lib/humanizeLLMError.js.map +1 -1
  281. package/dist/mcp/throttleRetry.js +41 -6
  282. package/dist/mcp/throttleRetry.js.map +1 -1
  283. package/dist/memory/define.js +45 -1
  284. package/dist/memory/define.js.map +1 -1
  285. package/dist/memory/define.types.js.map +1 -1
  286. package/dist/memory/stages/formatDefault.js +3 -1
  287. package/dist/memory/stages/formatDefault.js.map +1 -1
  288. package/dist/memory/store/InMemoryStore.js +12 -3
  289. package/dist/memory/store/InMemoryStore.js.map +1 -1
  290. package/dist/memory/store/index.js +11 -1
  291. package/dist/memory/store/index.js.map +1 -1
  292. package/dist/memory/store/writeOptions.js +250 -0
  293. package/dist/memory/store/writeOptions.js.map +1 -0
  294. package/dist/memory-providers.js +4 -1
  295. package/dist/memory-providers.js.map +1 -1
  296. package/dist/patterns/MapReduce.js +8 -2
  297. package/dist/patterns/MapReduce.js.map +1 -1
  298. package/dist/tool-providers/index.js +10 -1
  299. package/dist/tool-providers/index.js.map +1 -1
  300. package/dist/trace-toolpack/selfExplain.js +25 -2
  301. package/dist/trace-toolpack/selfExplain.js.map +1 -1
  302. package/dist/types/adapters/mcp/agentcoreRuntime/errorType.d.ts +13 -0
  303. package/dist/types/adapters/mcp/agentcoreRuntime/errorType.d.ts.map +1 -0
  304. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts +117 -0
  305. package/dist/types/adapters/mcp/agentcoreRuntime/invoke.d.ts.map +1 -0
  306. package/dist/types/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts +50 -0
  307. package/dist/types/adapters/mcp/agentcoreRuntime/safeAnswer.d.ts.map +1 -0
  308. package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts +81 -0
  309. package/dist/types/adapters/mcp/agentcoreRuntime/session.d.ts.map +1 -0
  310. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts +62 -0
  311. package/dist/types/adapters/mcp/agentcoreRuntime/sessionBusy.d.ts.map +1 -0
  312. package/dist/types/adapters/mcp/agentcoreRuntime/strictJson.d.ts +38 -0
  313. package/dist/types/adapters/mcp/agentcoreRuntime/strictJson.d.ts.map +1 -0
  314. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts +177 -0
  315. package/dist/types/adapters/mcp/agentcoreRuntime/transport.d.ts.map +1 -0
  316. package/dist/types/adapters/memory/agentcore.d.ts +152 -7
  317. package/dist/types/adapters/memory/agentcore.d.ts.map +1 -1
  318. package/dist/types/adapters/memory/memoryBank.d.ts +3 -2
  319. package/dist/types/adapters/memory/memoryBank.d.ts.map +1 -1
  320. package/dist/types/adapters/memory/pgVector.d.ts.map +1 -1
  321. package/dist/types/adapters/memory/redis.d.ts +8 -3
  322. package/dist/types/adapters/memory/redis.d.ts.map +1 -1
  323. package/dist/types/adapters/memory/s3Vectors.d.ts.map +1 -1
  324. package/dist/types/adapters/memory/sqliteVector.d.ts.map +1 -1
  325. package/dist/types/ag-ui/adapter.d.ts +69 -0
  326. package/dist/types/ag-ui/adapter.d.ts.map +1 -0
  327. package/dist/types/ag-ui/framing.d.ts +52 -0
  328. package/dist/types/ag-ui/framing.d.ts.map +1 -0
  329. package/dist/types/ag-ui/frontendTools.d.ts +38 -0
  330. package/dist/types/ag-ui/frontendTools.d.ts.map +1 -0
  331. package/dist/types/ag-ui/ids.d.ts +44 -0
  332. package/dist/types/ag-ui/ids.d.ts.map +1 -0
  333. package/dist/types/ag-ui/index.d.ts +18 -0
  334. package/dist/types/ag-ui/index.d.ts.map +1 -0
  335. package/dist/types/ag-ui/request.d.ts +73 -0
  336. package/dist/types/ag-ui/request.d.ts.map +1 -0
  337. package/dist/types/ag-ui/serializer.d.ts +174 -0
  338. package/dist/types/ag-ui/serializer.d.ts.map +1 -0
  339. package/dist/types/ag-ui/types.d.ts +306 -0
  340. package/dist/types/ag-ui/types.d.ts.map +1 -0
  341. package/dist/types/core/Agent.d.ts +2 -0
  342. package/dist/types/core/Agent.d.ts.map +1 -1
  343. package/dist/types/core/RunnerBase.d.ts.map +1 -1
  344. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  345. package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
  346. package/dist/types/core/agent/callerIdentity.d.ts.map +1 -1
  347. package/dist/types/core/agent/stages/routeTurn.d.ts +1 -1
  348. package/dist/types/core/agent/stages/routeTurn.d.ts.map +1 -1
  349. package/dist/types/core/agent/stages/seed.d.ts +11 -1
  350. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  351. package/dist/types/core/agent/stages/toolCalls.d.ts +11 -1
  352. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  353. package/dist/types/core/agent/types.d.ts +16 -6
  354. package/dist/types/core/agent/types.d.ts.map +1 -1
  355. package/dist/types/core/memberRun.d.ts +133 -0
  356. package/dist/types/core/memberRun.d.ts.map +1 -0
  357. package/dist/types/core/slots/buildToolsSlot.d.ts +1 -1
  358. package/dist/types/core/slots/buildToolsSlot.d.ts.map +1 -1
  359. package/dist/types/core-flow/Conditional.d.ts +8 -0
  360. package/dist/types/core-flow/Conditional.d.ts.map +1 -1
  361. package/dist/types/core-flow/Graph.d.ts.map +1 -1
  362. package/dist/types/core-flow/Loop.d.ts +8 -0
  363. package/dist/types/core-flow/Loop.d.ts.map +1 -1
  364. package/dist/types/core-flow/Parallel.d.ts +8 -0
  365. package/dist/types/core-flow/Parallel.d.ts.map +1 -1
  366. package/dist/types/core-flow/Sequence.d.ts +8 -0
  367. package/dist/types/core-flow/Sequence.d.ts.map +1 -1
  368. package/dist/types/core-flow/Workflow.d.ts.map +1 -1
  369. package/dist/types/doors/ag-ui.d.ts +20 -0
  370. package/dist/types/doors/ag-ui.d.ts.map +1 -0
  371. package/dist/types/hosting/httpHost.d.ts.map +1 -1
  372. package/dist/types/hosting/index.d.ts +4 -1
  373. package/dist/types/hosting/index.d.ts.map +1 -1
  374. package/dist/types/hosting/pendingAsk.d.ts +20 -0
  375. package/dist/types/hosting/pendingAsk.d.ts.map +1 -0
  376. package/dist/types/hosting/protocolAdapter.d.ts +230 -0
  377. package/dist/types/hosting/protocolAdapter.d.ts.map +1 -0
  378. package/dist/types/hosting/refusalStatus.d.ts +31 -0
  379. package/dist/types/hosting/refusalStatus.d.ts.map +1 -0
  380. package/dist/types/hosting/standingAgent.d.ts.map +1 -1
  381. package/dist/types/hosting/stream.d.ts +39 -0
  382. package/dist/types/hosting/stream.d.ts.map +1 -1
  383. package/dist/types/hosting/streamHandler.d.ts +135 -0
  384. package/dist/types/hosting/streamHandler.d.ts.map +1 -0
  385. package/dist/types/hosting/types.d.ts +15 -0
  386. package/dist/types/hosting/types.d.ts.map +1 -1
  387. package/dist/types/hosting/verifiedThreads.d.ts +30 -0
  388. package/dist/types/hosting/verifiedThreads.d.ts.map +1 -0
  389. package/dist/types/index.d.ts +1 -0
  390. package/dist/types/index.d.ts.map +1 -1
  391. package/dist/types/lib/humanizeLLMError.d.ts +15 -0
  392. package/dist/types/lib/humanizeLLMError.d.ts.map +1 -1
  393. package/dist/types/mcp/throttleRetry.d.ts +51 -0
  394. package/dist/types/mcp/throttleRetry.d.ts.map +1 -1
  395. package/dist/types/memory/define.d.ts.map +1 -1
  396. package/dist/types/memory/define.types.d.ts +24 -0
  397. package/dist/types/memory/define.types.d.ts.map +1 -1
  398. package/dist/types/memory/stages/formatDefault.d.ts.map +1 -1
  399. package/dist/types/memory/store/InMemoryStore.d.ts +8 -3
  400. package/dist/types/memory/store/InMemoryStore.d.ts.map +1 -1
  401. package/dist/types/memory/store/index.d.ts +1 -0
  402. package/dist/types/memory/store/index.d.ts.map +1 -1
  403. package/dist/types/memory/store/types.d.ts +38 -4
  404. package/dist/types/memory/store/types.d.ts.map +1 -1
  405. package/dist/types/memory/store/writeOptions.d.ts +119 -0
  406. package/dist/types/memory/store/writeOptions.d.ts.map +1 -0
  407. package/dist/types/memory-providers.d.ts +1 -1
  408. package/dist/types/memory-providers.d.ts.map +1 -1
  409. package/dist/types/patterns/MapReduce.d.ts.map +1 -1
  410. package/dist/types/tool-providers/index.d.ts +5 -0
  411. package/dist/types/tool-providers/index.d.ts.map +1 -1
  412. package/dist/types/trace-toolpack/selfExplain.d.ts +8 -0
  413. package/dist/types/trace-toolpack/selfExplain.d.ts.map +1 -1
  414. package/package.json +25 -1
@@ -0,0 +1,175 @@
1
+ /**
2
+ * session — the session strategies: which AgentCore Runtime session a request
3
+ * lands in.
4
+ *
5
+ * ── The facts they rest on ───────────────────────────────────────────────────
6
+ * From the AgentCore Runtime MCP protocol contract and the `InvokeAgentRuntime`
7
+ * API reference:
8
+ *
9
+ * - The runtime routes by `Mcp-Session-Id` and always returns one. A client
10
+ * "must capture the Mcp-Session-Id returned in the response and include it
11
+ * in all subsequent requests" for microVM affinity; without it "each request
12
+ * may be routed to a new microVM".
13
+ * - `InvokeAgentRuntime` also carries `runtimeSessionId`
14
+ * (`X-Amzn-Bedrock-AgentCore-Runtime-Session-Id`, 33–256 characters), and
15
+ * the AWS SDK models it as an idempotency token — it fills a FRESH random id
16
+ * on every call that leaves it unset.
17
+ *
18
+ * ── 'per-call' (the default) ─────────────────────────────────────────────────
19
+ * Every request in a session of its own: this strategy sends a FRESH runtime
20
+ * session id with every request and no `Mcp-Session-Id`, and the
21
+ * `Mcp-Session-Id` a response carries is not handed to the MCP client, so
22
+ * nothing can carry one call's session into the next. Isolation by
23
+ * construction: a client shared by every user of a process (tools built once at
24
+ * startup — the common shape) never puts two users in one microVM. The price is
25
+ * a cold start per call, and it needs a STATELESS server (`stateless_http=True`,
26
+ * the runtime's recommended default) — a stateful one sees every request as a
27
+ * stranger.
28
+ *
29
+ * ── 'reuse' ──────────────────────────────────────────────────────────────────
30
+ * One session per CONNECTION (per `mcpClient` built on the transport), and the
31
+ * TRANSPORT owns the key. A request with no `Mcp-Session-Id` (a client's
32
+ * `initialize`) opens a connection with a fresh runtime session id; the
33
+ * `Mcp-Session-Id` the server returns for it is stored WITH that connection,
34
+ * and the client is handed an opaque handle of the transport's own in its
35
+ * place. Every later request carrying the handle is sent in that connection's
36
+ * runtime session with the server's own id; a handle the transport does not
37
+ * know is answered 404 "Session not found" here, never sent.
38
+ *
39
+ * Why a handle and not the server's id: the server's ids are unique only as far
40
+ * as the server makes them. One that numbers sessions per process hands every
41
+ * fresh microVM the same first id, and a map keyed by it would send the second
42
+ * client into the first one's microVM. A handle is ours, random, and per
43
+ * connection, so two clients on one transport are two sessions whatever the
44
+ * server returns — while ONE client is still one session for whoever calls
45
+ * through it. Build a client per conversation; never share a 'reuse' client
46
+ * between users.
47
+ *
48
+ * At most {@link MAX_CONNECTIONS} connections are remembered, least recently
49
+ * used forgotten first; a client's `DELETE` (its `close()`) forgets its own.
50
+ *
51
+ * Pattern: Strategy. Role: outer ring, vendor fact. Holds no credential.
52
+ */
53
+ /** The runtime session header, as `InvokeAgentRuntime` binds `runtimeSessionId` to it. */
54
+ export const AGENTCORE_RUNTIME_SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
55
+ /** The MCP Streamable HTTP session header. */
56
+ export const MCP_SESSION_HEADER = 'Mcp-Session-Id';
57
+ /** How many connections a 'reuse' transport remembers before it forgets the least recently used. */
58
+ export const MAX_CONNECTIONS = 256;
59
+ /**
60
+ * A fresh runtime session id — `crypto.randomUUID()`, 36 characters, inside the
61
+ * 33–256 the API takes. Never injectable: freshness IS the isolation, and a
62
+ * source that repeated itself would put two requests (or two clients) in one
63
+ * session.
64
+ */
65
+ const newId = () => globalThis.crypto.randomUUID();
66
+ /**
67
+ * Build the strategy for one transport.
68
+ *
69
+ * @throws when `kind` is not one of the two strategies.
70
+ */
71
+ export function sessionStrategy(kind) {
72
+ if (kind === 'reuse')
73
+ return reuse();
74
+ if (kind === 'per-call')
75
+ return perCall();
76
+ throw new TypeError(`agentCoreRuntimeMcpTransport: \`session\` must be 'reuse' or 'per-call' — got ` +
77
+ `${JSON.stringify(kind)}. 'per-call' gives every request its own session (safe to share); ` +
78
+ `'reuse' keeps one runtime session per client (build one client per conversation).`);
79
+ }
80
+ function reuse() {
81
+ const connections = new Map();
82
+ const remember = (handle, connection) => {
83
+ connections.delete(handle);
84
+ connections.set(handle, connection); // most recently used last
85
+ while (connections.size > MAX_CONNECTIONS) {
86
+ const oldest = connections.keys().next().value;
87
+ if (oldest === undefined)
88
+ break;
89
+ connections.delete(oldest);
90
+ }
91
+ };
92
+ return {
93
+ request(headers, method) {
94
+ const handle = headers.get(MCP_SESSION_HEADER);
95
+ const known = handle === null ? undefined : connections.get(handle);
96
+ // A handle this transport did not issue, or has forgotten: fail closed.
97
+ if (handle !== null && known === undefined)
98
+ return { answer: sessionNotFound() };
99
+ const connection = known ?? { runtimeId: newId() };
100
+ if (handle !== null) {
101
+ if (method === 'DELETE')
102
+ connections.delete(handle);
103
+ else
104
+ remember(handle, connection);
105
+ }
106
+ // Set, not merged: these are the only session ids this request sends.
107
+ headers.set(AGENTCORE_RUNTIME_SESSION_HEADER, connection.runtimeId);
108
+ if (connection.serverSessionId !== undefined) {
109
+ headers.set(MCP_SESSION_HEADER, connection.serverSessionId);
110
+ }
111
+ else {
112
+ headers.delete(MCP_SESSION_HEADER);
113
+ }
114
+ return {
115
+ settle: (response) => {
116
+ const returned = response.headers.get(MCP_SESSION_HEADER);
117
+ if (returned === null)
118
+ return response;
119
+ if (handle === null) {
120
+ // A new connection: bound under a handle of our own, shown in the server's id's place.
121
+ const issued = newId();
122
+ remember(issued, { ...connection, serverSessionId: returned });
123
+ return withSessionHeader(response, issued);
124
+ }
125
+ if (method !== 'DELETE')
126
+ connection.serverSessionId = returned;
127
+ return withSessionHeader(response, handle);
128
+ },
129
+ };
130
+ },
131
+ };
132
+ }
133
+ function perCall() {
134
+ return {
135
+ request(headers) {
136
+ headers.delete(MCP_SESSION_HEADER);
137
+ // A fresh runtime session of our own for every request — as fresh as the
138
+ // SDK's own default, and set the same way on both auth paths.
139
+ headers.set(AGENTCORE_RUNTIME_SESSION_HEADER, newId());
140
+ return { settle: (response) => withSessionHeader(response, undefined) };
141
+ },
142
+ };
143
+ }
144
+ /**
145
+ * The response with its `Mcp-Session-Id` replaced by `value`, or removed when
146
+ * `value` is undefined. A fetched Response's headers are immutable, so the copy
147
+ * is rebuilt around the same body rather than edited.
148
+ */
149
+ function withSessionHeader(response, value) {
150
+ const current = response.headers.get(MCP_SESSION_HEADER);
151
+ if (current === (value ?? null))
152
+ return response;
153
+ const headers = new Headers(response.headers);
154
+ if (value === undefined)
155
+ headers.delete(MCP_SESSION_HEADER);
156
+ else
157
+ headers.set(MCP_SESSION_HEADER, value);
158
+ return new Response(response.body, {
159
+ status: response.status,
160
+ statusText: response.statusText,
161
+ headers,
162
+ });
163
+ }
164
+ /**
165
+ * The MCP Streamable HTTP answer to a session the server does not know: 404,
166
+ * after which a client starts a new session with `initialize`.
167
+ */
168
+ function sessionNotFound() {
169
+ return new Response(JSON.stringify({
170
+ jsonrpc: '2.0',
171
+ id: null,
172
+ error: { code: -32001, message: 'Session not found' },
173
+ }), { status: 404, headers: { 'content-type': 'application/json' } });
174
+ }
175
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../../../src/adapters/mcp/agentcoreRuntime/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,0FAA0F;AAC1F,MAAM,CAAC,MAAM,gCAAgC,GAAG,6CAA6C,CAAC;AAE9F,8CAA8C;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AA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R,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,mBAAmB,EAAE;KACtD,CAAC,EACF,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE,EAAE,CACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * sessionBusy — the retry strategy: AgentCore Runtime's "session operation in
3
+ * progress", recognised. One small function, on purpose.
4
+ *
5
+ * ── What the service says, in its own words ──────────────────────────────────
6
+ * The AgentCore Runtime MCP protocol contract maps the runtime's exceptions onto
7
+ * JSON-RPC errors, and exactly one of them is retryable by design:
8
+ *
9
+ * -32005 RetryableConflictException HTTP 200 "Session operation in progress, please retry"
10
+ *
11
+ * returned "when a second operation targets a session while the service is
12
+ * provisioning or tearing down that session. Because MCP returns HTTP 200 with
13
+ * the error in the JSON-RPC body, the caller must inspect the response body and
14
+ * retry with short exponential backoff — MCP clients do not auto-retry it."
15
+ *
16
+ * So no status code says it, and the MCP SDK will not wait for it: left alone,
17
+ * it reaches the model as a failed tool call, a moment after the session it was
18
+ * waiting for came up.
19
+ *
20
+ * ── Why asking again is safe ─────────────────────────────────────────────────
21
+ * The refusal is the PLATFORM's, about the session, made before the request
22
+ * reached the MCP server: nothing ran. That is the license a 429 holds, and the
23
+ * only one `retryingFetchWhen` accepts (see `mcp/throttleRetry.ts` ·
24
+ * `RetryDecision`).
25
+ *
26
+ * ── What it must NOT match ───────────────────────────────────────────────────
27
+ * `ConflictException` shares the code -32005 ("Resource conflict - Resource
28
+ * already exists") and is not retryable; the contract tells the two apart only
29
+ * by the message, so the message is part of the match. Anything else — another
30
+ * status, an SSE stream, a batch reply, a body that is not JSON — is delivered
31
+ * as it is.
32
+ *
33
+ * ── The API-layer form ───────────────────────────────────────────────────────
34
+ * `InvokeAgentRuntime`'s API reference gives the same exception as an HTTP 409,
35
+ * its type in the `x-amzn-errortype` header (the REST protocol's error-type
36
+ * header; the SigV4 strategy rebuilds exactly that from the SDK's exception,
37
+ * because the transport's SDK client has its own retry off). It is the same
38
+ * refusal, so it is the same decision — matched by the type, never by the 409
39
+ * alone.
40
+ *
41
+ * Pattern: Strategy (a `RetryDecision`). Role: outer ring, vendor fact.
42
+ */
43
+ import type { RetryVerdict } from '../../../mcp/throttleRetry.js';
44
+ /** The JSON-RPC error code the contract gives `RetryableConflictException`. */
45
+ export declare const SESSION_BUSY_CODE = -32005;
46
+ /**
47
+ * Is this response AgentCore Runtime's session-busy refusal — in either form:
48
+ * the MCP contract's HTTP 200 with JSON-RPC -32005, or the API's 409
49
+ * `RetryableConflictException`?
50
+ *
51
+ * Reads a CLONE of the body, so the response is delivered intact either way.
52
+ * Answers `{}` (wait the loop's own backoff, then send the same request again)
53
+ * or `undefined` (deliver it).
54
+ */
55
+ export declare function sessionBusy(response: Response): Promise<RetryVerdict | undefined>;
56
+ /**
57
+ * The match itself, over a parsed body: ONE JSON-RPC reply whose error carries
58
+ * the contract's code and message. A batch is never retried whole — some of
59
+ * its replies may be the record of work that ran.
60
+ */
61
+ export declare function isSessionBusyReply(body: unknown): boolean;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * sessionBusy — the retry strategy: AgentCore Runtime's "session operation in
3
+ * progress", recognised. One small function, on purpose.
4
+ *
5
+ * ── What the service says, in its own words ──────────────────────────────────
6
+ * The AgentCore Runtime MCP protocol contract maps the runtime's exceptions onto
7
+ * JSON-RPC errors, and exactly one of them is retryable by design:
8
+ *
9
+ * -32005 RetryableConflictException HTTP 200 "Session operation in progress, please retry"
10
+ *
11
+ * returned "when a second operation targets a session while the service is
12
+ * provisioning or tearing down that session. Because MCP returns HTTP 200 with
13
+ * the error in the JSON-RPC body, the caller must inspect the response body and
14
+ * retry with short exponential backoff — MCP clients do not auto-retry it."
15
+ *
16
+ * So no status code says it, and the MCP SDK will not wait for it: left alone,
17
+ * it reaches the model as a failed tool call, a moment after the session it was
18
+ * waiting for came up.
19
+ *
20
+ * ── Why asking again is safe ─────────────────────────────────────────────────
21
+ * The refusal is the PLATFORM's, about the session, made before the request
22
+ * reached the MCP server: nothing ran. That is the license a 429 holds, and the
23
+ * only one `retryingFetchWhen` accepts (see `mcp/throttleRetry.ts` ·
24
+ * `RetryDecision`).
25
+ *
26
+ * ── What it must NOT match ───────────────────────────────────────────────────
27
+ * `ConflictException` shares the code -32005 ("Resource conflict - Resource
28
+ * already exists") and is not retryable; the contract tells the two apart only
29
+ * by the message, so the message is part of the match. Anything else — another
30
+ * status, an SSE stream, a batch reply, a body that is not JSON — is delivered
31
+ * as it is.
32
+ *
33
+ * ── The API-layer form ───────────────────────────────────────────────────────
34
+ * `InvokeAgentRuntime`'s API reference gives the same exception as an HTTP 409,
35
+ * its type in the `x-amzn-errortype` header (the REST protocol's error-type
36
+ * header; the SigV4 strategy rebuilds exactly that from the SDK's exception,
37
+ * because the transport's SDK client has its own retry off). It is the same
38
+ * refusal, so it is the same decision — matched by the type, never by the 409
39
+ * alone.
40
+ *
41
+ * Pattern: Strategy (a `RetryDecision`). Role: outer ring, vendor fact.
42
+ */
43
+ import { awsErrorType } from './errorType.js';
44
+ /** The JSON-RPC error code the contract gives `RetryableConflictException`. */
45
+ export const SESSION_BUSY_CODE = -32005;
46
+ /** The exception's name, as the API layer and the SDK both spell it. */
47
+ const SESSION_BUSY_TYPE = 'RetryableConflictException';
48
+ /**
49
+ * How the contract's message reads. Matched case-insensitively and as a
50
+ * fragment, so a trailing "please retry" reworded does not stop the match;
51
+ * the code is still required, which is what keeps `ConflictException` out.
52
+ */
53
+ const SESSION_BUSY_MESSAGE = /session operation in progress/i;
54
+ /**
55
+ * Is this response AgentCore Runtime's session-busy refusal — in either form:
56
+ * the MCP contract's HTTP 200 with JSON-RPC -32005, or the API's 409
57
+ * `RetryableConflictException`?
58
+ *
59
+ * Reads a CLONE of the body, so the response is delivered intact either way.
60
+ * Answers `{}` (wait the loop's own backoff, then send the same request again)
61
+ * or `undefined` (deliver it).
62
+ */
63
+ export async function sessionBusy(response) {
64
+ if (response.status === 409) {
65
+ return awsErrorType(response.headers) === SESSION_BUSY_TYPE ? {} : undefined;
66
+ }
67
+ if (response.status !== 200)
68
+ return undefined;
69
+ if (!isJson(response.headers.get('content-type')))
70
+ return undefined;
71
+ let text;
72
+ try {
73
+ text = await response.clone().text();
74
+ }
75
+ catch {
76
+ return undefined;
77
+ }
78
+ // A cheap gate before parsing: a large tool result does not contain the
79
+ // code's digits often, and it is the common case.
80
+ if (!text.includes(String(SESSION_BUSY_CODE)))
81
+ return undefined;
82
+ let body;
83
+ try {
84
+ body = JSON.parse(text);
85
+ }
86
+ catch {
87
+ return undefined;
88
+ }
89
+ return isSessionBusyReply(body) ? {} : undefined;
90
+ }
91
+ /**
92
+ * The match itself, over a parsed body: ONE JSON-RPC reply whose error carries
93
+ * the contract's code and message. A batch is never retried whole — some of
94
+ * its replies may be the record of work that ran.
95
+ */
96
+ export function isSessionBusyReply(body) {
97
+ if (body === null || typeof body !== 'object' || Array.isArray(body))
98
+ return false;
99
+ const error = body.error;
100
+ if (error === null || typeof error !== 'object')
101
+ return false;
102
+ const { code, message } = error;
103
+ return (code === SESSION_BUSY_CODE && typeof message === 'string' && SESSION_BUSY_MESSAGE.test(message));
104
+ }
105
+ /** `application/json`, with or without parameters, in any case. */
106
+ function isJson(contentType) {
107
+ if (contentType === null)
108
+ return false;
109
+ const essence = contentType.split(';')[0]?.trim().toLowerCase();
110
+ return essence === 'application/json';
111
+ }
112
+ //# sourceMappingURL=sessionBusy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sessionBusy.js","sourceRoot":"","sources":["../../../../../src/adapters/mcp/agentcoreRuntime/sessionBusy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,+EAA+E;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KA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I,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACnF,MAAM,KAAK,GAAI,IAAqC,CAAC,KAAK,CAAC;IAC3D,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC9D,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAgE,CAAC;IAC3F,OAAO,CACL,IAAI,KAAK,iBAAiB,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,oBAAoB,CAAC,IAAI,CAAC,OAAO,CAAC,CAChG,CAAC;AACJ,CAAC;AAED,mEAAmE;AACnE,SAAS,MAAM,CAAC,WAA0B;IACxC,IAAI,WAAW,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IACvC,MAAM,OAAO,GAAG,WAAW,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAChE,OAAO,OAAO,KAAK,kBAAkB,CAAC;AACxC,CAAC"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * strictJson — ONE reading of a JSON text, with every ambiguity refused.
3
+ *
4
+ * `JSON.parse` resolves ambiguity silently: a duplicated key keeps its LAST
5
+ * value, while another reader may keep the first. A check that reads a body one
6
+ * way and a consumer that reads it another is a parser differential — a crafted
7
+ * answer passes the check and is used as something else. So the transport reads
8
+ * an answer once, here, refusing what two readers could disagree on, and hands
9
+ * the client the canonical re-serialization of exactly the value it checked.
10
+ *
11
+ * Refused, by name: a duplicated object key, trailing data after the value, a
12
+ * leading byte-order mark, nesting deeper than {@link MAX_DEPTH}, a number
13
+ * out of range (its re-serialization would be `null`), and anything that is
14
+ * not RFC 8259 JSON.
15
+ *
16
+ * Objects are built with own properties only (a `__proto__` key is data, never
17
+ * a prototype).
18
+ *
19
+ * Pattern: recursive-descent parser. Role: outer ring, the one reader.
20
+ */
21
+ /** Why a text was refused. */
22
+ export declare class AmbiguousJsonError extends Error {
23
+ readonly reason: string;
24
+ constructor(reason: string);
25
+ }
26
+ /** How deep a value may nest. */
27
+ export declare const MAX_DEPTH = 256;
28
+ /** A JSON value, as read. */
29
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
30
+ readonly [key: string]: JsonValue;
31
+ };
32
+ /**
33
+ * The one value `text` holds.
34
+ *
35
+ * @throws AmbiguousJsonError when the text is not exactly one unambiguous value.
36
+ */
37
+ export declare function parseStrictJson(text: string): JsonValue;
@@ -0,0 +1,215 @@
1
+ /**
2
+ * strictJson — ONE reading of a JSON text, with every ambiguity refused.
3
+ *
4
+ * `JSON.parse` resolves ambiguity silently: a duplicated key keeps its LAST
5
+ * value, while another reader may keep the first. A check that reads a body one
6
+ * way and a consumer that reads it another is a parser differential — a crafted
7
+ * answer passes the check and is used as something else. So the transport reads
8
+ * an answer once, here, refusing what two readers could disagree on, and hands
9
+ * the client the canonical re-serialization of exactly the value it checked.
10
+ *
11
+ * Refused, by name: a duplicated object key, trailing data after the value, a
12
+ * leading byte-order mark, nesting deeper than {@link MAX_DEPTH}, a number
13
+ * out of range (its re-serialization would be `null`), and anything that is
14
+ * not RFC 8259 JSON.
15
+ *
16
+ * Objects are built with own properties only (a `__proto__` key is data, never
17
+ * a prototype).
18
+ *
19
+ * Pattern: recursive-descent parser. Role: outer ring, the one reader.
20
+ */
21
+ /** Why a text was refused. */
22
+ export class AmbiguousJsonError extends Error {
23
+ reason;
24
+ constructor(reason) {
25
+ super(`ambiguous JSON: ${reason}`);
26
+ this.reason = reason;
27
+ this.name = 'AmbiguousJsonError';
28
+ }
29
+ }
30
+ /** How deep a value may nest. */
31
+ export const MAX_DEPTH = 256;
32
+ /**
33
+ * The one value `text` holds.
34
+ *
35
+ * @throws AmbiguousJsonError when the text is not exactly one unambiguous value.
36
+ */
37
+ export function parseStrictJson(text) {
38
+ if (text.charCodeAt(0) === 0xfeff)
39
+ throw new AmbiguousJsonError('a leading byte-order mark');
40
+ const reader = new Reader(text);
41
+ reader.space();
42
+ const value = reader.value(0);
43
+ reader.space();
44
+ if (!reader.done())
45
+ throw new AmbiguousJsonError('trailing data after the value');
46
+ return value;
47
+ }
48
+ const NUMBER = /-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/y;
49
+ /** Characters a string may hold as they are: not a quote, a backslash or a control character. */
50
+ // eslint-disable-next-line no-control-regex
51
+ const PLAIN_RUN = /[^"\\\u0000-\u001f]+/y;
52
+ class Reader {
53
+ text;
54
+ at = 0;
55
+ constructor(text) {
56
+ this.text = text;
57
+ }
58
+ done() {
59
+ return this.at >= this.text.length;
60
+ }
61
+ space() {
62
+ while (this.at < this.text.length) {
63
+ const c = this.text.charCodeAt(this.at);
64
+ if (c !== 0x20 && c !== 0x09 && c !== 0x0a && c !== 0x0d)
65
+ return;
66
+ this.at++;
67
+ }
68
+ }
69
+ value(depth) {
70
+ if (depth > MAX_DEPTH)
71
+ throw new AmbiguousJsonError('nesting too deep');
72
+ const c = this.text[this.at];
73
+ if (c === '{')
74
+ return this.object(depth);
75
+ if (c === '[')
76
+ return this.array(depth);
77
+ if (c === '"')
78
+ return this.string();
79
+ if (this.word('true'))
80
+ return true;
81
+ if (this.word('false'))
82
+ return false;
83
+ if (this.word('null'))
84
+ return null;
85
+ return this.number();
86
+ }
87
+ object(depth) {
88
+ this.at++; // {
89
+ const out = {};
90
+ const seen = new Set();
91
+ this.space();
92
+ if (this.text[this.at] === '}') {
93
+ this.at++;
94
+ return out;
95
+ }
96
+ for (;;) {
97
+ this.space();
98
+ if (this.text[this.at] !== '"')
99
+ throw new AmbiguousJsonError('an object key that is not a string');
100
+ const key = this.string();
101
+ // The key is not named: it is the answer's text, and a refusal repeats none.
102
+ if (seen.has(key))
103
+ throw new AmbiguousJsonError('a duplicated object key');
104
+ seen.add(key);
105
+ this.space();
106
+ this.expect(':');
107
+ this.space();
108
+ Object.defineProperty(out, key, {
109
+ value: this.value(depth + 1),
110
+ enumerable: true,
111
+ writable: true,
112
+ configurable: true,
113
+ });
114
+ this.space();
115
+ if (this.text[this.at] === ',') {
116
+ this.at++;
117
+ continue;
118
+ }
119
+ this.expect('}');
120
+ return out;
121
+ }
122
+ }
123
+ array(depth) {
124
+ this.at++; // [
125
+ const out = [];
126
+ this.space();
127
+ if (this.text[this.at] === ']') {
128
+ this.at++;
129
+ return out;
130
+ }
131
+ for (;;) {
132
+ this.space();
133
+ out.push(this.value(depth + 1));
134
+ this.space();
135
+ if (this.text[this.at] === ',') {
136
+ this.at++;
137
+ continue;
138
+ }
139
+ this.expect(']');
140
+ return out;
141
+ }
142
+ }
143
+ string() {
144
+ this.at++; // opening quote
145
+ let out = '';
146
+ for (;;) {
147
+ if (this.at >= this.text.length)
148
+ throw new AmbiguousJsonError('an unterminated string');
149
+ const c = this.text[this.at];
150
+ const code = c.charCodeAt(0);
151
+ if (c === '"') {
152
+ this.at++;
153
+ return out;
154
+ }
155
+ if (code < 0x20)
156
+ throw new AmbiguousJsonError('a control character inside a string');
157
+ if (c !== '\\') {
158
+ // A run of plain characters at once — a large string is read in slices.
159
+ PLAIN_RUN.lastIndex = this.at;
160
+ const run = PLAIN_RUN.exec(this.text)?.[0] ?? c;
161
+ out += run;
162
+ this.at += run.length;
163
+ continue;
164
+ }
165
+ const e = this.text[this.at + 1];
166
+ this.at += 2;
167
+ if (e === 'u') {
168
+ const hex = this.text.slice(this.at, this.at + 4);
169
+ if (!/^[0-9a-fA-F]{4}$/.test(hex))
170
+ throw new AmbiguousJsonError('a malformed \\u escape');
171
+ out += String.fromCharCode(parseInt(hex, 16));
172
+ this.at += 4;
173
+ continue;
174
+ }
175
+ const simple = ESCAPES[e ?? ''];
176
+ if (simple === undefined)
177
+ throw new AmbiguousJsonError('an unknown escape');
178
+ out += simple;
179
+ }
180
+ }
181
+ number() {
182
+ NUMBER.lastIndex = this.at;
183
+ const match = NUMBER.exec(this.text);
184
+ if (match === null || match[0] === '')
185
+ throw new AmbiguousJsonError('a value that is not JSON');
186
+ this.at += match[0].length;
187
+ const value = Number(match[0]);
188
+ // Re-serialized, a number out of range would become `null` — another value.
189
+ if (!Number.isFinite(value))
190
+ throw new AmbiguousJsonError('a number out of range');
191
+ return value;
192
+ }
193
+ word(word) {
194
+ if (!this.text.startsWith(word, this.at))
195
+ return false;
196
+ this.at += word.length;
197
+ return true;
198
+ }
199
+ expect(c) {
200
+ if (this.text[this.at] !== c)
201
+ throw new AmbiguousJsonError(`a missing '${c}'`);
202
+ this.at++;
203
+ }
204
+ }
205
+ const ESCAPES = {
206
+ '"': '"',
207
+ '\\': '\\',
208
+ '/': '/',
209
+ b: '\b',
210
+ f: '\f',
211
+ n: '\n',
212
+ r: '\r',
213
+ t: '\t',
214
+ };
215
+ //# sourceMappingURL=strictJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strictJson.js","sourceRoot":"","sources":["../../../../../src/adapters/mcp/agentcoreRuntime/strictJson.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,8BAA8B;AAC9B,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACtB;IAArB,YAAqB,MAAc;QACjC,KAAK,CAAC,mBAAmB,MAAM,EAAE,CAAC,CAAC;QADhB,WAAM,GAAN,MAAM,CAAQ;QAEjC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,iCAAiC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,CAAC;AAW7B;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,MAAM;QAAE,MAAM,IAAI,kBAAkB,CAAC,2BAA2B,CAAC,CAAC;IAC7F,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC;IAChC,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,MAAM,KAAK,GAAG,MAAM,CAA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