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,43 @@
1
+ /**
2
+ * ids — every id the AG-UI adapter mints, from ONE grammar.
3
+ *
4
+ * <run>/<kind>/<n>/<address>
5
+ *
6
+ * run the AG-UI `runId`, through `encodeIdentityField` — `%` and `/`
7
+ * escaped, so it holds no `/`;
8
+ * kind one of {@link AgUiIdKind} — no `/`;
9
+ * n a decimal ordinal — no `/`;
10
+ * address the agentfootprint `runtimeStageId` of the event that opened the
11
+ * entity (`call-llm#18`, `step-p/x/tool-calls#97`) — any string.
12
+ *
13
+ * INJECTIVE by construction: the first three `/` end the three segments that
14
+ * cannot hold one, so two different (run, kind, n, address) tuples never spell
15
+ * the same id. `test/ag-ui/ids.test.ts` pins it with a property test.
16
+ *
17
+ * WHY THE ADDRESS, NOT THE PROVIDER'S ID. A model's tool-call id is not unique
18
+ * in a run: a provider may reuse it across iterations, and two parallel branches
19
+ * routinely mint the same one (`call_1`, `c1`). An AG-UI client finds a tool
20
+ * call by its id across the WHOLE conversation, so a reused id would land a new
21
+ * call's arguments on an old message. And under a redaction policy the record
22
+ * serves every id as the placeholder. The address — the stage execution that
23
+ * produced the entity, unique within a run — is unique, survives redaction (it
24
+ * is the record's own key, never a value a policy selects) and lines up with the
25
+ * recording; the run segment makes it unique across the thread. The provider's
26
+ * id, as the record serves it, rides `metadata.agentfootprint.toolCallId`.
27
+ */
28
+ /** The kinds of entity the adapter mints ids for. */
29
+ export type AgUiIdKind = 'text' | 'reasoning' | 'tool' | 'result' | 'agent' | 'interrupt';
30
+ /** One run's minter: ordinals counted per (kind, address), ids spelled by {@link agUiId}. */
31
+ export interface AgUiIdMinter {
32
+ /** The next id of `kind` at `address` — `n` counts up from 0 per (kind, address). */
33
+ next(kind: AgUiIdKind, address: string): {
34
+ readonly id: string;
35
+ readonly n: number;
36
+ };
37
+ /** The id of `kind` at `address` with a KNOWN ordinal — a tool result reuses its call's. */
38
+ at(kind: AgUiIdKind, n: number, address: string): string;
39
+ }
40
+ /** Spell one id. Exported for the property test; the minter is the only caller. */
41
+ export declare function agUiId(runId: string, kind: AgUiIdKind, n: number, address: string): string;
42
+ /** A minter for the AG-UI run `runId`. Refuses an empty run id: it would mint `_` ids. */
43
+ export declare function agUiIdMinter(runId: string): AgUiIdMinter;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * ids — every id the AG-UI adapter mints, from ONE grammar.
3
+ *
4
+ * <run>/<kind>/<n>/<address>
5
+ *
6
+ * run the AG-UI `runId`, through `encodeIdentityField` — `%` and `/`
7
+ * escaped, so it holds no `/`;
8
+ * kind one of {@link AgUiIdKind} — no `/`;
9
+ * n a decimal ordinal — no `/`;
10
+ * address the agentfootprint `runtimeStageId` of the event that opened the
11
+ * entity (`call-llm#18`, `step-p/x/tool-calls#97`) — any string.
12
+ *
13
+ * INJECTIVE by construction: the first three `/` end the three segments that
14
+ * cannot hold one, so two different (run, kind, n, address) tuples never spell
15
+ * the same id. `test/ag-ui/ids.test.ts` pins it with a property test.
16
+ *
17
+ * WHY THE ADDRESS, NOT THE PROVIDER'S ID. A model's tool-call id is not unique
18
+ * in a run: a provider may reuse it across iterations, and two parallel branches
19
+ * routinely mint the same one (`call_1`, `c1`). An AG-UI client finds a tool
20
+ * call by its id across the WHOLE conversation, so a reused id would land a new
21
+ * call's arguments on an old message. And under a redaction policy the record
22
+ * serves every id as the placeholder. The address — the stage execution that
23
+ * produced the entity, unique within a run — is unique, survives redaction (it
24
+ * is the record's own key, never a value a policy selects) and lines up with the
25
+ * recording; the run segment makes it unique across the thread. The provider's
26
+ * id, as the record serves it, rides `metadata.agentfootprint.toolCallId`.
27
+ */
28
+ import { encodeIdentityField } from '../memory/identity/encode.js';
29
+ /** Spell one id. Exported for the property test; the minter is the only caller. */
30
+ export function agUiId(runId, kind, n, address) {
31
+ return `${encodeIdentityField(runId)}/${kind}/${n}/${address}`;
32
+ }
33
+ /** A minter for the AG-UI run `runId`. Refuses an empty run id: it would mint `_` ids. */
34
+ export function agUiIdMinter(runId) {
35
+ if (typeof runId !== 'string' || runId.length === 0) {
36
+ throw new TypeError('AG-UI: `runId` must be a non-empty string — every id the run mints is under it.');
37
+ }
38
+ const counts = new Map();
39
+ return {
40
+ next(kind, address) {
41
+ const key = `${kind}\u0000${address}`;
42
+ const n = counts.get(key) ?? 0;
43
+ counts.set(key, n + 1);
44
+ return { id: agUiId(runId, kind, n, address), n };
45
+ },
46
+ at: (kind, n, address) => agUiId(runId, kind, n, address),
47
+ };
48
+ }
49
+ //# sourceMappingURL=ids.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ids.js","sourceRoot":"","sources":["../../../src/ag-ui/ids.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAanE,mFAAmF;AACnF,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,IAAgB,EAAE,CAAS,EAAE,OAAe;IAChF,OAAO,GAAG,mBAAmB,CAAC,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;AACjE,CAAC;AAED,0FAA0F;AAC1F,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CACjB,iFAAiF,CAClF,CAAC;IACJ,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAC;IACzC,OAAO;QACL,IAAI,CAAC,IAAI,EAAE,OAAO;YAChB,MAAM,GAAG,GAAG,GAAG,IAAI,SAAS,OAAO,EAAE,CAAC;YACtC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC/B,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YACvB,OAAO,EAAE,EAAE,EAAE,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,EAAE,CAAC;QACpD,CAAC;QACD,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,CAAC;KAC1D,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ag-ui — the AG-UI protocol adapter over agentfootprint's event stream.
3
+ *
4
+ * `agUi()` is the adapter a host takes (`streamHandler` on
5
+ * `agentfootprint/hosting`): it reads an untrusted `RunAgentInput`, plans the
6
+ * turn against what the server holds, and translates the run.
7
+ * `agUiSerializer` turns one run's served events into AG-UI events; `agUiSse`
8
+ * frames them for the wire with the official `@ag-ui/encoder`. Published
9
+ * through the `agentfootprint/ag-ui` door. The fixed sentences and the id
10
+ * grammar stay internal — tests import them by module path.
11
+ */
12
+ export { agUiSerializer, AG_UI_CUSTOM_EVENTS, type AgUiCustomContext, type AgUiCustomProjection, type AgUiSerializerOptions, type AgUiTranslation, } from './serializer.js';
13
+ export { agUiSse, type AgUiEncoderModule, type AgUiSseOptions } from './framing.js';
14
+ export { agUi, type AgUiOptions } from './adapter.js';
15
+ export type { AgUiFrontendTool } from './frontendTools.js';
16
+ export { AG_UI_MAX_ID_LENGTH, readAgUiRunInput, type AgUiValidator } from './request.js';
17
+ export { AG_UI_PROTOCOL_VERSION, type AgUiAddress, type AgUiEvent, type AgUiEventType, type AgUiInterrupt, type AgUiMessage, type AgUiMetadata, type AgUiResumeEntry, type AgUiRunInput, type AgUiRunOutcome, type AgUiSuspendedCall, type AgUiSuspendedScope, type AgUiSuspension, } from './types.js';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * ag-ui — the AG-UI protocol adapter over agentfootprint's event stream.
3
+ *
4
+ * `agUi()` is the adapter a host takes (`streamHandler` on
5
+ * `agentfootprint/hosting`): it reads an untrusted `RunAgentInput`, plans the
6
+ * turn against what the server holds, and translates the run.
7
+ * `agUiSerializer` turns one run's served events into AG-UI events; `agUiSse`
8
+ * frames them for the wire with the official `@ag-ui/encoder`. Published
9
+ * through the `agentfootprint/ag-ui` door. The fixed sentences and the id
10
+ * grammar stay internal — tests import them by module path.
11
+ */
12
+ export { agUiSerializer, AG_UI_CUSTOM_EVENTS, } from './serializer.js';
13
+ export { agUiSse } from './framing.js';
14
+ export { agUi } from './adapter.js';
15
+ export { AG_UI_MAX_ID_LENGTH, readAgUiRunInput } from './request.js';
16
+ export { AG_UI_PROTOCOL_VERSION, } from './types.js';
17
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/ag-ui/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,cAAc,EACd,mBAAmB,GAKpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,OAAO,EAA+C,MAAM,cAAc,CAAC;AACpF,OAAO,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAsB,MAAM,cAAc,CAAC;AACzF,OAAO,EACL,sBAAsB,GAavB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * request — an AG-UI request (`RunAgentInput`) read as UNTRUSTED browser input,
3
+ * and the one turn it may ask for.
4
+ *
5
+ * Two steps, each refusing by NAME (a `WireRequestRefusal`: its own status and
6
+ * code; the field named, the value never quoted back):
7
+ *
8
+ * readAgUiRunInput the body's SHAPE, field by field, and the ids' FORMAT
9
+ * and length — nothing here is trusted, nothing the
10
+ * server holds is read;
11
+ * planAgUiTurn the turn, from the request AND what the server holds
12
+ * for the bound conversation.
13
+ *
14
+ * WHAT A REQUEST MAY DECIDE, and what it may not:
15
+ * - the newest USER message is the run's message. Nothing else the browser
16
+ * sends is ever conversation: its assistant and tool messages are its own
17
+ * copy of what the server said, and the server's copy is the one kept
18
+ * (`sessions`, or the agent's memory under the bound session). A system or
19
+ * developer message is refused — the agent's instructions are its own;
20
+ * - an ANSWER is taken only for the pause the server is keeping, matched to
21
+ * the ids that pause handed out (`AgUiSuspension`): a resume entry naming
22
+ * its interrupt, or the tool message answering the frontend tool call it is
23
+ * waiting on. Any other tool result is refused — never folded in;
24
+ * - a frontend tool runs only when the app allow-listed its NAME — with the
25
+ * app's own description and schema, never the page's (a description the
26
+ * model reads is an instruction) — and only on a host that keeps the paused
27
+ * run until the page answers;
28
+ * - `state` and `context` reach the agent only through the app's validators;
29
+ * without one, a request carrying either is refused;
30
+ * - identity, credentials and redaction never come from a request: the host
31
+ * binds the thread to the caller the app authenticates (`ThreadBinder`).
32
+ * `forwardedProps` is never read.
33
+ */
34
+ import type { HeldConversation, PlanFacts, ProtocolPlan, ThreadBinding } from '../hosting/protocolAdapter.js';
35
+ import type { Tool } from '../tools/tools.js';
36
+ import type { AgUiRunInput, AgUiSuspension } from './types.js';
37
+ /** The longest thread or run id read — longer is refused, never truncated. */
38
+ export declare const AG_UI_MAX_ID_LENGTH = 128;
39
+ /**
40
+ * Read one AG-UI request body — its shape and its ids — refusing what the
41
+ * protocol does not allow by the field's NAME, never by its value.
42
+ *
43
+ * @throws WireRequestRefusal (400, `ERR_INVALID_RUN_INPUT`)
44
+ */
45
+ export declare function readAgUiRunInput(body: unknown): AgUiRunInput;
46
+ /** What a page's `state` or `context` is checked by before the agent may see it. */
47
+ export type AgUiValidator = (value: unknown, at: {
48
+ /** The conversation the request was bound to — whose state this claims to be. */
49
+ readonly thread?: ThreadBinding;
50
+ readonly headers: Readonly<Record<string, string>>;
51
+ }) => unknown;
52
+ /** The rules one adapter plans by — built from `agUi()`'s options. */
53
+ export interface AgUiTurnRules {
54
+ /** The frontend tools the app allow-listed, by name: each builds the tool the agent is given. */
55
+ readonly frontendTools: ReadonlyMap<string, () => Tool>;
56
+ readonly accept: {
57
+ readonly state?: AgUiValidator;
58
+ readonly context?: AgUiValidator;
59
+ };
60
+ }
61
+ /**
62
+ * Plan one turn: the request (read by {@link readAgUiRunInput}) against what
63
+ * the server holds for its bound conversation.
64
+ *
65
+ * @throws WireRequestRefusal — by name, for everything a page may not decide.
66
+ */
67
+ export declare function planAgUiTurn(input: AgUiRunInput, held: HeldConversation, facts: PlanFacts, rules: AgUiTurnRules): ProtocolPlan;
68
+ /**
69
+ * A stored suspension record, checked — the store holds bytes; a record that
70
+ * is not one this adapter wrote is `undefined`, and nothing is matched to it.
71
+ */
72
+ export declare function readAgUiSuspension(value: unknown): AgUiSuspension | undefined;
@@ -0,0 +1,350 @@
1
+ /**
2
+ * request — an AG-UI request (`RunAgentInput`) read as UNTRUSTED browser input,
3
+ * and the one turn it may ask for.
4
+ *
5
+ * Two steps, each refusing by NAME (a `WireRequestRefusal`: its own status and
6
+ * code; the field named, the value never quoted back):
7
+ *
8
+ * readAgUiRunInput the body's SHAPE, field by field, and the ids' FORMAT
9
+ * and length — nothing here is trusted, nothing the
10
+ * server holds is read;
11
+ * planAgUiTurn the turn, from the request AND what the server holds
12
+ * for the bound conversation.
13
+ *
14
+ * WHAT A REQUEST MAY DECIDE, and what it may not:
15
+ * - the newest USER message is the run's message. Nothing else the browser
16
+ * sends is ever conversation: its assistant and tool messages are its own
17
+ * copy of what the server said, and the server's copy is the one kept
18
+ * (`sessions`, or the agent's memory under the bound session). A system or
19
+ * developer message is refused — the agent's instructions are its own;
20
+ * - an ANSWER is taken only for the pause the server is keeping, matched to
21
+ * the ids that pause handed out (`AgUiSuspension`): a resume entry naming
22
+ * its interrupt, or the tool message answering the frontend tool call it is
23
+ * waiting on. Any other tool result is refused — never folded in;
24
+ * - a frontend tool runs only when the app allow-listed its NAME — with the
25
+ * app's own description and schema, never the page's (a description the
26
+ * model reads is an instruction) — and only on a host that keeps the paused
27
+ * run until the page answers;
28
+ * - `state` and `context` reach the agent only through the app's validators;
29
+ * without one, a request carrying either is refused;
30
+ * - identity, credentials and redaction never come from a request: the host
31
+ * binds the thread to the caller the app authenticates (`ThreadBinder`).
32
+ * `forwardedProps` is never read.
33
+ */
34
+ import { WireRequestRefusal } from '../hosting/errors.js';
35
+ /** The longest thread or run id read — longer is refused, never truncated. */
36
+ export const AG_UI_MAX_ID_LENGTH = 128;
37
+ /**
38
+ * The thread and run id alphabet: letters, digits and `._:-`, starting with a
39
+ * letter or digit — every id an AG-UI SDK mints (a UUID, a ULID) and nothing
40
+ * that could carry markup, a path or a control character into a log line.
41
+ */
42
+ const ID_FORMAT = /^[A-Za-z0-9][A-Za-z0-9._:-]*$/;
43
+ /** The longest message, tool-call or interrupt id read. */
44
+ const MAX_ITEM_ID_LENGTH = 400;
45
+ /** A tool name the page may declare — the provider-portable alphabet. */
46
+ const TOOL_NAME = /^[A-Za-z0-9_-]{1,64}$/;
47
+ const ROLES = new Set([
48
+ 'user',
49
+ 'assistant',
50
+ 'tool',
51
+ 'system',
52
+ 'developer',
53
+ 'reasoning',
54
+ 'activity',
55
+ ]);
56
+ /** A refusal of the request's shape — names the field, never its value. */
57
+ const malformed = (what) => new WireRequestRefusal('ERR_INVALID_RUN_INPUT', `AG-UI: ${what}`, 400);
58
+ /** A refusal of what this agent does not accept from a page — its own code. */
59
+ const refused = (code, what, status = 400) => new WireRequestRefusal(code, `AG-UI: ${what}`, status);
60
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
61
+ /** A thread or run id: present, bounded, and in the id alphabet. */
62
+ function runId(value, field) {
63
+ if (typeof value !== 'string' || value.length === 0)
64
+ throw malformed(`\`${field}\` must be a non-empty string.`);
65
+ if (value.length > AG_UI_MAX_ID_LENGTH)
66
+ throw malformed(`\`${field}\` is longer than ${AG_UI_MAX_ID_LENGTH} characters.`);
67
+ if (!ID_FORMAT.test(value))
68
+ throw malformed(`\`${field}\` must be letters, digits and . _ : - only, starting with a letter or digit.`);
69
+ return value;
70
+ }
71
+ /** A message, call or interrupt id: present and bounded. */
72
+ function itemId(value, field) {
73
+ if (typeof value !== 'string' || value.length === 0)
74
+ throw malformed(`\`${field}\` must be a non-empty string.`);
75
+ if (value.length > MAX_ITEM_ID_LENGTH)
76
+ throw malformed(`\`${field}\` is longer than ${MAX_ITEM_ID_LENGTH} characters.`);
77
+ return value;
78
+ }
79
+ function list(value, field) {
80
+ if (value === undefined || value === null)
81
+ return [];
82
+ if (!Array.isArray(value))
83
+ throw malformed(`\`${field}\` must be an array.`);
84
+ return value;
85
+ }
86
+ function content(value, at, optional = false) {
87
+ if (value === undefined && optional)
88
+ return;
89
+ if (typeof value === 'string')
90
+ return;
91
+ if (!Array.isArray(value))
92
+ throw malformed(`\`${at}.content\` must be a string or a list of parts.`);
93
+ for (const part of value) {
94
+ if (!isRecord(part) || typeof part.type !== 'string')
95
+ throw malformed(`every part of \`${at}.content\` must have a \`type\`.`);
96
+ if (part.type === 'text' && typeof part.text !== 'string')
97
+ throw malformed(`a text part of \`${at}.content\` must carry \`text\`.`);
98
+ }
99
+ }
100
+ function message(value, i) {
101
+ const at = `messages[${i}]`;
102
+ if (!isRecord(value))
103
+ throw malformed(`\`${at}\` must be an object.`);
104
+ itemId(value.id, `${at}.id`);
105
+ if (typeof value.role !== 'string' || !ROLES.has(value.role))
106
+ throw malformed(`\`${at}.role\` is not an AG-UI role.`);
107
+ switch (value.role) {
108
+ case 'user':
109
+ case 'tool':
110
+ content(value.content, at);
111
+ if (value.role === 'tool')
112
+ itemId(value.toolCallId, `${at}.toolCallId`);
113
+ break;
114
+ case 'assistant':
115
+ content(value.content, at, true);
116
+ list(value.toolCalls, `${at}.toolCalls`).forEach((call, j) => {
117
+ const where = `${at}.toolCalls[${j}]`;
118
+ if (!isRecord(call) || !isRecord(call.function))
119
+ throw malformed(`\`${where}\` must be a function call.`);
120
+ itemId(call.id, `${where}.id`);
121
+ if (typeof call.function.name !== 'string' || typeof call.function.arguments !== 'string')
122
+ throw malformed(`\`${where}.function\` must carry \`name\` and \`arguments\` strings.`);
123
+ });
124
+ break;
125
+ default:
126
+ break;
127
+ }
128
+ return value;
129
+ }
130
+ /**
131
+ * Read one AG-UI request body — its shape and its ids — refusing what the
132
+ * protocol does not allow by the field's NAME, never by its value.
133
+ *
134
+ * @throws WireRequestRefusal (400, `ERR_INVALID_RUN_INPUT`)
135
+ */
136
+ export function readAgUiRunInput(body) {
137
+ if (!isRecord(body))
138
+ throw malformed('the body must be a RunAgentInput object.');
139
+ runId(body.threadId, 'threadId');
140
+ runId(body.runId, 'runId');
141
+ if (body.parentRunId !== undefined)
142
+ runId(body.parentRunId, 'parentRunId');
143
+ if (!Array.isArray(body.messages))
144
+ throw malformed('`messages` must be an array.');
145
+ const messages = body.messages.map(message);
146
+ const tools = list(body.tools, 'tools');
147
+ const named = new Set();
148
+ tools.forEach((tool, i) => {
149
+ if (!isRecord(tool) || typeof tool.name !== 'string' || !TOOL_NAME.test(tool.name))
150
+ throw malformed(`\`tools[${i}].name\` must be a tool name (letters, digits, _ and -).`);
151
+ if (named.has(tool.name))
152
+ throw malformed(`\`tools[${i}].name\` repeats a tool already declared.`);
153
+ named.add(tool.name);
154
+ });
155
+ const context = list(body.context, 'context');
156
+ context.forEach((entry, i) => {
157
+ if (!isRecord(entry) ||
158
+ typeof entry.description !== 'string' ||
159
+ typeof entry.value !== 'string')
160
+ throw malformed(`\`context[${i}]\` must carry \`description\` and \`value\` strings.`);
161
+ });
162
+ const resume = list(body.resume, 'resume');
163
+ resume.forEach((entry, i) => {
164
+ if (!isRecord(entry))
165
+ throw malformed(`\`resume[${i}]\` must be an object.`);
166
+ itemId(entry.interruptId, `resume[${i}].interruptId`);
167
+ if (entry.status !== 'resolved' && entry.status !== 'cancelled')
168
+ throw malformed(`\`resume[${i}].status\` must be 'resolved' or 'cancelled'.`);
169
+ });
170
+ return {
171
+ ...body,
172
+ messages,
173
+ tools: tools,
174
+ context: context,
175
+ ...(resume.length > 0 && { resume: resume }),
176
+ };
177
+ }
178
+ /**
179
+ * Plan one turn: the request (read by {@link readAgUiRunInput}) against what
180
+ * the server holds for its bound conversation.
181
+ *
182
+ * @throws WireRequestRefusal — by name, for everything a page may not decide.
183
+ */
184
+ export function planAgUiTurn(input, held, facts, rules) {
185
+ input.messages.forEach((m, i) => {
186
+ if (m.role === 'system' || m.role === 'developer')
187
+ throw refused('ERR_INSTRUCTIONS_NOT_CARRIED', `messages[${i}] is a ${m.role} message. The agent's instructions are its own; a page ` +
188
+ `cannot send them.`);
189
+ });
190
+ const tools = toolsOf(input, facts, rules);
191
+ const accepted = {};
192
+ const state = validated('state', input.state, rules.accept.state, facts);
193
+ if (state !== undefined)
194
+ accepted.state = state;
195
+ const context = validated('context', input.context.length === 0 ? undefined : input.context, rules.accept.context, facts);
196
+ if (context !== undefined)
197
+ accepted.context = context;
198
+ return {
199
+ turn: turnOf(input, held, facts),
200
+ ...(tools.length > 0 && { tools }),
201
+ ...(Object.keys(accepted).length > 0 && { accepted }),
202
+ };
203
+ }
204
+ /** The frontend tools this request enables: allow-listed by name AND declared by the page. */
205
+ function toolsOf(input, facts, rules) {
206
+ const tools = [];
207
+ input.tools.forEach((declared, i) => {
208
+ const build = rules.frontendTools.get(declared.name);
209
+ if (build === undefined)
210
+ throw refused('ERR_TOOL_NOT_ALLOWED', `tools[${i}] names a tool this agent does not let the page run. A frontend tool runs ` +
211
+ `only when the app allow-lists it: agUi({ frontendTools }).`);
212
+ tools.push(build());
213
+ });
214
+ if (tools.length > 0 && !facts.keepsPauses)
215
+ throw refused('ERR_CLIENT_TOOLS_NOT_CARRIED', `the page offers frontend tools, and their results arrive in the page's NEXT request — ` +
216
+ `this host keeps no paused run to continue. Serve it with threads and sessions.`);
217
+ return tools;
218
+ }
219
+ /** A page value the app's validator accepted, or `undefined` for an empty one. */
220
+ function validated(name, value, validator, facts) {
221
+ if (isEmpty(value))
222
+ return undefined;
223
+ const upper = name.toUpperCase();
224
+ if (validator === undefined)
225
+ throw refused(`ERR_${upper}_NOT_CARRIED`, `the request carries \`${name}\`, and this agent accepts none from a page. To accept it, ` +
226
+ `validate it: agUi({ accept: { ${name} } }).`);
227
+ try {
228
+ return validator(value, {
229
+ ...(facts.thread !== undefined && { thread: facts.thread }),
230
+ headers: facts.headers,
231
+ });
232
+ }
233
+ catch (err) {
234
+ if (err instanceof WireRequestRefusal)
235
+ throw err;
236
+ // Never the validator's message: it may describe the value it refused.
237
+ throw refused(`ERR_${upper}_REFUSED`, `the app's validator refused \`${name}\`.`);
238
+ }
239
+ }
240
+ const isEmpty = (value) => value === undefined ||
241
+ value === null ||
242
+ (Array.isArray(value) && value.length === 0) ||
243
+ (isRecord(value) && Object.keys(value).length === 0);
244
+ /** The turn the request asks for, against what the server holds. */
245
+ function turnOf(input, held, facts) {
246
+ const resume = input.resume ?? [];
247
+ const last = input.messages[input.messages.length - 1];
248
+ const awaiting = held.awaiting;
249
+ if (awaiting === undefined) {
250
+ if (resume.length > 0)
251
+ throw refused('ERR_NO_PENDING_ASK', facts.keepsPauses
252
+ ? 'the request answers an interrupt, and this thread is waiting on none.'
253
+ : 'the request answers an interrupt, and this host keeps no paused run to continue.', 409);
254
+ if (last?.role === 'tool')
255
+ throw refused('ERR_UNKNOWN_TOOL_CALL', `messages[${input.messages.length - 1}] answers a tool call this thread is not ` +
256
+ `waiting on. A tool result is taken only for a frontend tool the run is paused on.`);
257
+ return { kind: 'message', message: newestMessage(input, facts) };
258
+ }
259
+ const suspension = readAgUiSuspension(awaiting.suspension);
260
+ if (suspension === undefined)
261
+ throw refused('ERR_AWAITING_DECISION', 'this thread is waiting on an answer another door asked for; answer it there.', 409);
262
+ const call = suspension.call;
263
+ if (call?.client === true)
264
+ return { kind: 'answer', answer: clientResult(input, call) };
265
+ if (resume.length === 0)
266
+ throw refused('ERR_AWAITING_DECISION', 'this thread is waiting on the answer to its interrupt; send it in `resume`.', 409);
267
+ const known = resume.findIndex((entry) => entry.interruptId !== suspension.interruptId);
268
+ if (known >= 0 || resume.length !== 1)
269
+ throw refused('ERR_UNKNOWN_INTERRUPT', `resume[${Math.max(known, 0)}] does not answer the interrupt this thread is waiting on.`);
270
+ const entry = resume[0];
271
+ if (entry.status === 'cancelled')
272
+ throw refused('ERR_CANCEL_NOT_CARRIED', 'the request cancels the interrupt, and this agent continues a paused run only with an ' +
273
+ 'answer. Answer it — a decline is an answer.');
274
+ return { kind: 'answer', answer: entry.payload };
275
+ }
276
+ /** The page's result for the frontend tool call the run is paused on — the newest message. */
277
+ function clientResult(input, call) {
278
+ const at = input.messages.length - 1;
279
+ const last = input.messages[at];
280
+ if (last?.role === 'tool' && last.toolCallId === call.toolCallId)
281
+ return textOf(last.content, at);
282
+ if (last?.role === 'tool')
283
+ throw refused('ERR_UNKNOWN_TOOL_CALL', `messages[${at}] answers a tool call this thread is not waiting on.`);
284
+ throw refused('ERR_AWAITING_DECISION', 'this thread is waiting on the result of a tool the page runs; send it as the newest ' +
285
+ 'message, a `tool` message for that call.', 409);
286
+ }
287
+ /** The newest message — the person's — as the run's message. */
288
+ function newestMessage(input, facts) {
289
+ const at = input.messages.length - 1;
290
+ const last = input.messages[at];
291
+ if (last === undefined || last.role !== 'user')
292
+ throw refused('ERR_NO_USER_TURN', 'the newest message must be the person’s (`role: user`) — it is what the agent answers.');
293
+ if (!facts.keepsConversation && at > 0)
294
+ throw refused('ERR_CONVERSATION_NOT_KEPT', 'the request continues a conversation, and this host keeps none: the page’s copy is ' +
295
+ 'never taken as what was said. Serve it with threads (and sessions, or an agent ' +
296
+ 'with memory) to continue one.');
297
+ const text = textOf(last.content, at);
298
+ if (text.trim().length === 0)
299
+ throw refused('ERR_NO_USER_TURN', `messages[${at}] says nothing.`);
300
+ return text;
301
+ }
302
+ /** A message body as text — a media part refused by name, never dropped. */
303
+ function textOf(value, at) {
304
+ if (value === undefined)
305
+ return '';
306
+ if (typeof value === 'string')
307
+ return value;
308
+ let out = '';
309
+ for (const part of value) {
310
+ if (part.type !== 'text')
311
+ throw refused('ERR_MEDIA_NOT_CARRIED', `messages[${at}] carries a ${part.type} part; this agent is given text only.`);
312
+ out += part.text;
313
+ }
314
+ return out;
315
+ }
316
+ const isText = (value) => typeof value === 'string';
317
+ const texts = (value) => Array.isArray(value) && value.every(isText);
318
+ /**
319
+ * A stored suspension record, checked — the store holds bytes; a record that
320
+ * is not one this adapter wrote is `undefined`, and nothing is matched to it.
321
+ */
322
+ export function readAgUiSuspension(value) {
323
+ if (!isRecord(value) || value.version !== 1 || !isText(value.runId))
324
+ return undefined;
325
+ if (value.interruptId !== undefined && !isText(value.interruptId))
326
+ return undefined;
327
+ if (typeof value.rootAgent !== 'boolean' || !Array.isArray(value.scopes))
328
+ return undefined;
329
+ const call = value.call;
330
+ if (call !== undefined &&
331
+ (!isRecord(call) ||
332
+ !isText(call.toolCallId) ||
333
+ typeof call.client !== 'boolean' ||
334
+ !texts(call.mount)))
335
+ return undefined;
336
+ for (const scope of value.scopes) {
337
+ if (!isRecord(scope) || !texts(scope.mount) || !texts(scope.steps))
338
+ return undefined;
339
+ if (!Array.isArray(scope.calls))
340
+ return undefined;
341
+ for (const open of scope.calls)
342
+ if (!isRecord(open) || !isText(open.toolCallId) || typeof open.client !== 'boolean')
343
+ return undefined;
344
+ for (const field of ['subagentRunId', 'name', 'parentSubagentRunId', 'messageId'])
345
+ if (scope[field] !== undefined && !isText(scope[field]))
346
+ return undefined;
347
+ }
348
+ return value;
349
+ }
350
+ //#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