@langchain/langgraph-sdk 1.8.9 → 1.9.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 (444) hide show
  1. package/README.md +90 -43
  2. package/dist/client/assistants/index.cjs +180 -0
  3. package/dist/client/assistants/index.cjs.map +1 -0
  4. package/dist/client/assistants/index.d.cts +155 -0
  5. package/dist/client/assistants/index.d.cts.map +1 -0
  6. package/dist/client/assistants/index.d.ts +155 -0
  7. package/dist/client/assistants/index.d.ts.map +1 -0
  8. package/dist/client/assistants/index.js +180 -0
  9. package/dist/client/assistants/index.js.map +1 -0
  10. package/dist/client/base.cjs +190 -0
  11. package/dist/client/base.cjs.map +1 -0
  12. package/dist/client/base.d.cts +84 -0
  13. package/dist/client/base.d.cts.map +1 -0
  14. package/dist/client/base.d.ts +84 -0
  15. package/dist/client/base.d.ts.map +1 -0
  16. package/dist/client/base.js +188 -0
  17. package/dist/client/base.js.map +1 -0
  18. package/dist/client/crons/index.cjs +159 -0
  19. package/dist/client/crons/index.cjs.map +1 -0
  20. package/dist/client/crons/index.d.cts +71 -0
  21. package/dist/client/crons/index.d.cts.map +1 -0
  22. package/dist/client/crons/index.d.ts +71 -0
  23. package/dist/client/crons/index.d.ts.map +1 -0
  24. package/dist/client/crons/index.js +159 -0
  25. package/dist/client/crons/index.js.map +1 -0
  26. package/dist/client/index.cjs +84 -0
  27. package/dist/client/index.cjs.map +1 -0
  28. package/dist/client/index.d.cts +63 -0
  29. package/dist/client/index.d.cts.map +1 -0
  30. package/dist/client/index.d.ts +63 -0
  31. package/dist/client/index.d.ts.map +1 -0
  32. package/dist/client/index.js +83 -0
  33. package/dist/client/index.js.map +1 -0
  34. package/dist/client/runs/index.cjs +275 -0
  35. package/dist/client/runs/index.cjs.map +1 -0
  36. package/dist/client/runs/index.d.cts +123 -0
  37. package/dist/client/runs/index.d.cts.map +1 -0
  38. package/dist/client/runs/index.d.ts +123 -0
  39. package/dist/client/runs/index.d.ts.map +1 -0
  40. package/dist/client/runs/index.js +275 -0
  41. package/dist/client/runs/index.js.map +1 -0
  42. package/dist/client/store/index.cjs +128 -0
  43. package/dist/client/store/index.cjs.map +1 -0
  44. package/dist/client/store/index.d.cts +75 -0
  45. package/dist/client/store/index.d.cts.map +1 -0
  46. package/dist/client/store/index.d.ts +75 -0
  47. package/dist/client/store/index.d.ts.map +1 -0
  48. package/dist/client/store/index.js +128 -0
  49. package/dist/client/store/index.js.map +1 -0
  50. package/dist/client/stream/error.cjs +18 -0
  51. package/dist/client/stream/error.cjs.map +1 -0
  52. package/dist/client/stream/error.d.cts +14 -0
  53. package/dist/client/stream/error.d.cts.map +1 -0
  54. package/dist/client/stream/error.d.ts +14 -0
  55. package/dist/client/stream/error.d.ts.map +1 -0
  56. package/dist/client/stream/error.js +18 -0
  57. package/dist/client/stream/error.js.map +1 -0
  58. package/dist/client/stream/handles/index.cjs +3 -0
  59. package/dist/client/stream/handles/index.d.ts +3 -0
  60. package/dist/client/stream/handles/index.js +4 -0
  61. package/dist/client/stream/handles/subagents.cjs +263 -0
  62. package/dist/client/stream/handles/subagents.cjs.map +1 -0
  63. package/dist/client/stream/handles/subagents.d.cts +45 -0
  64. package/dist/client/stream/handles/subagents.d.cts.map +1 -0
  65. package/dist/client/stream/handles/subagents.d.ts +45 -0
  66. package/dist/client/stream/handles/subagents.d.ts.map +1 -0
  67. package/dist/client/stream/handles/subagents.js +262 -0
  68. package/dist/client/stream/handles/subagents.js.map +1 -0
  69. package/dist/client/stream/handles/subgraphs.cjs +352 -0
  70. package/dist/client/stream/handles/subgraphs.cjs.map +1 -0
  71. package/dist/client/stream/handles/subgraphs.d.cts +82 -0
  72. package/dist/client/stream/handles/subgraphs.d.cts.map +1 -0
  73. package/dist/client/stream/handles/subgraphs.d.ts +82 -0
  74. package/dist/client/stream/handles/subgraphs.d.ts.map +1 -0
  75. package/dist/client/stream/handles/subgraphs.js +351 -0
  76. package/dist/client/stream/handles/subgraphs.js.map +1 -0
  77. package/dist/client/stream/handles/tools.cjs +92 -0
  78. package/dist/client/stream/handles/tools.cjs.map +1 -0
  79. package/dist/client/stream/handles/tools.d.cts +26 -0
  80. package/dist/client/stream/handles/tools.d.cts.map +1 -0
  81. package/dist/client/stream/handles/tools.d.ts +26 -0
  82. package/dist/client/stream/handles/tools.d.ts.map +1 -0
  83. package/dist/client/stream/handles/tools.js +92 -0
  84. package/dist/client/stream/handles/tools.js.map +1 -0
  85. package/dist/client/stream/index.cjs +1368 -0
  86. package/dist/client/stream/index.cjs.map +1 -0
  87. package/dist/client/stream/index.d.cts +238 -0
  88. package/dist/client/stream/index.d.cts.map +1 -0
  89. package/dist/client/stream/index.d.ts +238 -0
  90. package/dist/client/stream/index.d.ts.map +1 -0
  91. package/dist/client/stream/index.js +1367 -0
  92. package/dist/client/stream/index.js.map +1 -0
  93. package/dist/client/stream/media.cjs +506 -0
  94. package/dist/client/stream/media.cjs.map +1 -0
  95. package/dist/client/stream/media.d.cts +164 -0
  96. package/dist/client/stream/media.d.cts.map +1 -0
  97. package/dist/client/stream/media.d.ts +164 -0
  98. package/dist/client/stream/media.d.ts.map +1 -0
  99. package/dist/client/stream/media.js +505 -0
  100. package/dist/client/stream/media.js.map +1 -0
  101. package/dist/client/stream/messages.cjs +635 -0
  102. package/dist/client/stream/messages.cjs.map +1 -0
  103. package/dist/client/stream/messages.d.cts +139 -0
  104. package/dist/client/stream/messages.d.cts.map +1 -0
  105. package/dist/client/stream/messages.d.ts +139 -0
  106. package/dist/client/stream/messages.d.ts.map +1 -0
  107. package/dist/client/stream/messages.js +631 -0
  108. package/dist/client/stream/messages.js.map +1 -0
  109. package/dist/client/stream/multi-cursor-buffer.cjs +55 -0
  110. package/dist/client/stream/multi-cursor-buffer.cjs.map +1 -0
  111. package/dist/client/stream/multi-cursor-buffer.js +55 -0
  112. package/dist/client/stream/multi-cursor-buffer.js.map +1 -0
  113. package/dist/client/stream/subscription.cjs +85 -0
  114. package/dist/client/stream/subscription.cjs.map +1 -0
  115. package/dist/client/stream/subscription.d.cts +22 -0
  116. package/dist/client/stream/subscription.d.cts.map +1 -0
  117. package/dist/client/stream/subscription.d.ts +22 -0
  118. package/dist/client/stream/subscription.d.ts.map +1 -0
  119. package/dist/client/stream/subscription.js +84 -0
  120. package/dist/client/stream/subscription.js.map +1 -0
  121. package/dist/client/stream/transport/agent-server.cjs +45 -0
  122. package/dist/client/stream/transport/agent-server.cjs.map +1 -0
  123. package/dist/client/stream/transport/agent-server.d.cts +39 -0
  124. package/dist/client/stream/transport/agent-server.d.cts.map +1 -0
  125. package/dist/client/stream/transport/agent-server.d.ts +39 -0
  126. package/dist/client/stream/transport/agent-server.d.ts.map +1 -0
  127. package/dist/client/stream/transport/agent-server.js +45 -0
  128. package/dist/client/stream/transport/agent-server.js.map +1 -0
  129. package/dist/client/stream/transport/constants.cjs +10 -0
  130. package/dist/client/stream/transport/constants.cjs.map +1 -0
  131. package/dist/client/stream/transport/constants.js +10 -0
  132. package/dist/client/stream/transport/constants.js.map +1 -0
  133. package/dist/client/stream/transport/decoder.cjs +115 -0
  134. package/dist/client/stream/transport/decoder.cjs.map +1 -0
  135. package/dist/client/stream/transport/decoder.js +114 -0
  136. package/dist/client/stream/transport/decoder.js.map +1 -0
  137. package/dist/client/stream/transport/http.cjs +183 -0
  138. package/dist/client/stream/transport/http.cjs.map +1 -0
  139. package/dist/client/stream/transport/http.d.cts +45 -0
  140. package/dist/client/stream/transport/http.d.cts.map +1 -0
  141. package/dist/client/stream/transport/http.d.ts +45 -0
  142. package/dist/client/stream/transport/http.d.ts.map +1 -0
  143. package/dist/client/stream/transport/http.js +183 -0
  144. package/dist/client/stream/transport/http.js.map +1 -0
  145. package/dist/client/stream/transport/index.cjs +3 -0
  146. package/dist/client/stream/transport/index.js +4 -0
  147. package/dist/client/stream/transport/queue.cjs +55 -0
  148. package/dist/client/stream/transport/queue.cjs.map +1 -0
  149. package/dist/client/stream/transport/queue.js +55 -0
  150. package/dist/client/stream/transport/queue.js.map +1 -0
  151. package/dist/client/stream/transport/stream.cjs +79 -0
  152. package/dist/client/stream/transport/stream.cjs.map +1 -0
  153. package/dist/client/stream/transport/stream.js +79 -0
  154. package/dist/client/stream/transport/stream.js.map +1 -0
  155. package/dist/client/stream/transport/types.d.cts +29 -0
  156. package/dist/client/stream/transport/types.d.cts.map +1 -0
  157. package/dist/client/stream/transport/types.d.ts +29 -0
  158. package/dist/client/stream/transport/types.d.ts.map +1 -0
  159. package/dist/client/stream/transport/utils.cjs +45 -0
  160. package/dist/client/stream/transport/utils.cjs.map +1 -0
  161. package/dist/client/stream/transport/utils.js +39 -0
  162. package/dist/client/stream/transport/utils.js.map +1 -0
  163. package/dist/client/stream/transport/websocket.cjs +155 -0
  164. package/dist/client/stream/transport/websocket.cjs.map +1 -0
  165. package/dist/client/stream/transport/websocket.d.cts +36 -0
  166. package/dist/client/stream/transport/websocket.d.cts.map +1 -0
  167. package/dist/client/stream/transport/websocket.d.ts +36 -0
  168. package/dist/client/stream/transport/websocket.d.ts.map +1 -0
  169. package/dist/client/stream/transport/websocket.js +155 -0
  170. package/dist/client/stream/transport/websocket.js.map +1 -0
  171. package/dist/client/stream/transport.d.cts +104 -0
  172. package/dist/client/stream/transport.d.cts.map +1 -0
  173. package/dist/client/stream/transport.d.ts +104 -0
  174. package/dist/client/stream/transport.d.ts.map +1 -0
  175. package/dist/client/stream/types.d.cts +208 -0
  176. package/dist/client/stream/types.d.cts.map +1 -0
  177. package/dist/client/stream/types.d.ts +208 -0
  178. package/dist/client/stream/types.d.ts.map +1 -0
  179. package/dist/client/threads/index.cjs +271 -0
  180. package/dist/client/threads/index.cjs.map +1 -0
  181. package/dist/client/threads/index.d.cts +235 -0
  182. package/dist/client/threads/index.d.cts.map +1 -0
  183. package/dist/client/threads/index.d.ts +235 -0
  184. package/dist/client/threads/index.d.ts.map +1 -0
  185. package/dist/client/threads/index.js +270 -0
  186. package/dist/client/threads/index.js.map +1 -0
  187. package/dist/client/ui-internal/index.cjs +29 -0
  188. package/dist/client/ui-internal/index.cjs.map +1 -0
  189. package/dist/client/ui-internal/index.d.cts +11 -0
  190. package/dist/client/ui-internal/index.d.cts.map +1 -0
  191. package/dist/client/ui-internal/index.d.ts +11 -0
  192. package/dist/client/ui-internal/index.d.ts.map +1 -0
  193. package/dist/client/ui-internal/index.js +29 -0
  194. package/dist/client/ui-internal/index.js.map +1 -0
  195. package/dist/client.cjs +35 -1308
  196. package/dist/client.d.cts +19 -857
  197. package/dist/client.d.ts +19 -857
  198. package/dist/client.js +16 -1301
  199. package/dist/index.cjs +25 -4
  200. package/dist/index.d.cts +15 -3
  201. package/dist/index.d.ts +15 -3
  202. package/dist/index.js +14 -3
  203. package/dist/react/stream.cjs.map +1 -1
  204. package/dist/react/stream.custom.cjs +1 -1
  205. package/dist/react/stream.custom.js +1 -1
  206. package/dist/react/stream.d.cts +2 -1
  207. package/dist/react/stream.d.cts.map +1 -1
  208. package/dist/react/stream.d.ts +2 -1
  209. package/dist/react/stream.d.ts.map +1 -1
  210. package/dist/react/stream.js.map +1 -1
  211. package/dist/react/stream.lgp.cjs +8 -6
  212. package/dist/react/stream.lgp.cjs.map +1 -1
  213. package/dist/react/stream.lgp.js +6 -4
  214. package/dist/react/stream.lgp.js.map +1 -1
  215. package/dist/react/types.d.cts +1 -1
  216. package/dist/react/types.d.ts +1 -1
  217. package/dist/react/types.d.ts.map +1 -1
  218. package/dist/react-ui/server/server.cjs +1 -1
  219. package/dist/react-ui/server/server.cjs.map +1 -1
  220. package/dist/react-ui/server/server.js +1 -1
  221. package/dist/react-ui/server/server.js.map +1 -1
  222. package/dist/react-ui/types.cjs.map +1 -1
  223. package/dist/react-ui/types.d.cts +1 -1
  224. package/dist/react-ui/types.d.cts.map +1 -1
  225. package/dist/react-ui/types.d.ts +1 -1
  226. package/dist/react-ui/types.d.ts.map +1 -1
  227. package/dist/react-ui/types.js.map +1 -1
  228. package/dist/stream/assembled-to-message.cjs +121 -0
  229. package/dist/stream/assembled-to-message.cjs.map +1 -0
  230. package/dist/stream/assembled-to-message.d.cts +35 -0
  231. package/dist/stream/assembled-to-message.d.cts.map +1 -0
  232. package/dist/stream/assembled-to-message.d.ts +35 -0
  233. package/dist/stream/assembled-to-message.d.ts.map +1 -0
  234. package/dist/stream/assembled-to-message.js +119 -0
  235. package/dist/stream/assembled-to-message.js.map +1 -0
  236. package/dist/stream/channel-registry.cjs +224 -0
  237. package/dist/stream/channel-registry.cjs.map +1 -0
  238. package/dist/stream/channel-registry.d.cts +102 -0
  239. package/dist/stream/channel-registry.d.cts.map +1 -0
  240. package/dist/stream/channel-registry.d.ts +102 -0
  241. package/dist/stream/channel-registry.d.ts.map +1 -0
  242. package/dist/stream/channel-registry.js +224 -0
  243. package/dist/stream/channel-registry.js.map +1 -0
  244. package/dist/stream/constants.cjs +11 -0
  245. package/dist/stream/constants.cjs.map +1 -0
  246. package/dist/stream/constants.d.cts +10 -0
  247. package/dist/stream/constants.d.cts.map +1 -0
  248. package/dist/stream/constants.d.ts +10 -0
  249. package/dist/stream/constants.d.ts.map +1 -0
  250. package/dist/stream/constants.js +11 -0
  251. package/dist/stream/constants.js.map +1 -0
  252. package/dist/stream/controller.cjs +933 -0
  253. package/dist/stream/controller.cjs.map +1 -0
  254. package/dist/stream/controller.d.cts +135 -0
  255. package/dist/stream/controller.d.cts.map +1 -0
  256. package/dist/stream/controller.d.ts +135 -0
  257. package/dist/stream/controller.d.ts.map +1 -0
  258. package/dist/stream/controller.js +910 -0
  259. package/dist/stream/controller.js.map +1 -0
  260. package/dist/stream/discovery/index.d.ts +2 -0
  261. package/dist/stream/discovery/subagents.cjs +235 -0
  262. package/dist/stream/discovery/subagents.cjs.map +1 -0
  263. package/dist/stream/discovery/subagents.d.cts +18 -0
  264. package/dist/stream/discovery/subagents.d.cts.map +1 -0
  265. package/dist/stream/discovery/subagents.d.ts +18 -0
  266. package/dist/stream/discovery/subagents.d.ts.map +1 -0
  267. package/dist/stream/discovery/subagents.js +235 -0
  268. package/dist/stream/discovery/subagents.js.map +1 -0
  269. package/dist/stream/discovery/subgraphs.cjs +153 -0
  270. package/dist/stream/discovery/subgraphs.cjs.map +1 -0
  271. package/dist/stream/discovery/subgraphs.d.cts +19 -0
  272. package/dist/stream/discovery/subgraphs.d.cts.map +1 -0
  273. package/dist/stream/discovery/subgraphs.d.ts +19 -0
  274. package/dist/stream/discovery/subgraphs.d.ts.map +1 -0
  275. package/dist/stream/discovery/subgraphs.js +153 -0
  276. package/dist/stream/discovery/subgraphs.js.map +1 -0
  277. package/dist/stream/index.cjs +36 -0
  278. package/dist/stream/index.d.cts +25 -0
  279. package/dist/stream/index.d.ts +25 -0
  280. package/dist/stream/index.js +16 -0
  281. package/dist/stream/lifecycle-loading-tracker.cjs +83 -0
  282. package/dist/stream/lifecycle-loading-tracker.cjs.map +1 -0
  283. package/dist/stream/lifecycle-loading-tracker.js +83 -0
  284. package/dist/stream/lifecycle-loading-tracker.js.map +1 -0
  285. package/dist/stream/message-metadata-tracker.cjs +165 -0
  286. package/dist/stream/message-metadata-tracker.cjs.map +1 -0
  287. package/dist/stream/message-metadata-tracker.d.cts +24 -0
  288. package/dist/stream/message-metadata-tracker.d.cts.map +1 -0
  289. package/dist/stream/message-metadata-tracker.d.ts +24 -0
  290. package/dist/stream/message-metadata-tracker.d.ts.map +1 -0
  291. package/dist/stream/message-metadata-tracker.js +165 -0
  292. package/dist/stream/message-metadata-tracker.js.map +1 -0
  293. package/dist/stream/message-reconciliation.cjs +118 -0
  294. package/dist/stream/message-reconciliation.cjs.map +1 -0
  295. package/dist/stream/message-reconciliation.js +115 -0
  296. package/dist/stream/message-reconciliation.js.map +1 -0
  297. package/dist/stream/namespace.cjs +54 -0
  298. package/dist/stream/namespace.cjs.map +1 -0
  299. package/dist/stream/namespace.js +49 -0
  300. package/dist/stream/namespace.js.map +1 -0
  301. package/dist/stream/projections/channel.cjs +53 -0
  302. package/dist/stream/projections/channel.cjs.map +1 -0
  303. package/dist/stream/projections/channel.d.cts +22 -0
  304. package/dist/stream/projections/channel.d.cts.map +1 -0
  305. package/dist/stream/projections/channel.d.ts +22 -0
  306. package/dist/stream/projections/channel.d.ts.map +1 -0
  307. package/dist/stream/projections/channel.js +53 -0
  308. package/dist/stream/projections/channel.js.map +1 -0
  309. package/dist/stream/projections/extension.cjs +29 -0
  310. package/dist/stream/projections/extension.cjs.map +1 -0
  311. package/dist/stream/projections/extension.d.cts +7 -0
  312. package/dist/stream/projections/extension.d.cts.map +1 -0
  313. package/dist/stream/projections/extension.d.ts +7 -0
  314. package/dist/stream/projections/extension.d.ts.map +1 -0
  315. package/dist/stream/projections/extension.js +29 -0
  316. package/dist/stream/projections/extension.js.map +1 -0
  317. package/dist/stream/projections/index.cjs +6 -0
  318. package/dist/stream/projections/index.d.ts +6 -0
  319. package/dist/stream/projections/index.js +7 -0
  320. package/dist/stream/projections/media.cjs +81 -0
  321. package/dist/stream/projections/media.cjs.map +1 -0
  322. package/dist/stream/projections/media.d.cts +18 -0
  323. package/dist/stream/projections/media.d.cts.map +1 -0
  324. package/dist/stream/projections/media.d.ts +18 -0
  325. package/dist/stream/projections/media.d.ts.map +1 -0
  326. package/dist/stream/projections/media.js +78 -0
  327. package/dist/stream/projections/media.js.map +1 -0
  328. package/dist/stream/projections/messages.cjs +121 -0
  329. package/dist/stream/projections/messages.cjs.map +1 -0
  330. package/dist/stream/projections/messages.d.cts +8 -0
  331. package/dist/stream/projections/messages.d.cts.map +1 -0
  332. package/dist/stream/projections/messages.d.ts +8 -0
  333. package/dist/stream/projections/messages.d.ts.map +1 -0
  334. package/dist/stream/projections/messages.js +121 -0
  335. package/dist/stream/projections/messages.js.map +1 -0
  336. package/dist/stream/projections/runtime.cjs +44 -0
  337. package/dist/stream/projections/runtime.cjs.map +1 -0
  338. package/dist/stream/projections/runtime.js +44 -0
  339. package/dist/stream/projections/runtime.js.map +1 -0
  340. package/dist/stream/projections/tool-calls.cjs +50 -0
  341. package/dist/stream/projections/tool-calls.cjs.map +1 -0
  342. package/dist/stream/projections/tool-calls.d.cts +8 -0
  343. package/dist/stream/projections/tool-calls.d.cts.map +1 -0
  344. package/dist/stream/projections/tool-calls.d.ts +8 -0
  345. package/dist/stream/projections/tool-calls.d.ts.map +1 -0
  346. package/dist/stream/projections/tool-calls.js +50 -0
  347. package/dist/stream/projections/tool-calls.js.map +1 -0
  348. package/dist/stream/projections/values.cjs +52 -0
  349. package/dist/stream/projections/values.cjs.map +1 -0
  350. package/dist/stream/projections/values.d.cts +7 -0
  351. package/dist/stream/projections/values.d.cts.map +1 -0
  352. package/dist/stream/projections/values.d.ts +6 -0
  353. package/dist/stream/projections/values.d.ts.map +1 -0
  354. package/dist/stream/projections/values.js +52 -0
  355. package/dist/stream/projections/values.js.map +1 -0
  356. package/dist/stream/root-message-projection.cjs +256 -0
  357. package/dist/stream/root-message-projection.cjs.map +1 -0
  358. package/dist/stream/root-message-projection.js +256 -0
  359. package/dist/stream/root-message-projection.js.map +1 -0
  360. package/dist/stream/store.cjs +32 -0
  361. package/dist/stream/store.cjs.map +1 -0
  362. package/dist/stream/store.d.cts +37 -0
  363. package/dist/stream/store.d.cts.map +1 -0
  364. package/dist/stream/store.d.ts +37 -0
  365. package/dist/stream/store.d.ts.map +1 -0
  366. package/dist/stream/store.js +32 -0
  367. package/dist/stream/store.js.map +1 -0
  368. package/dist/stream/submit-coordinator.cjs +399 -0
  369. package/dist/stream/submit-coordinator.cjs.map +1 -0
  370. package/dist/stream/submit-coordinator.d.cts +27 -0
  371. package/dist/stream/submit-coordinator.d.cts.map +1 -0
  372. package/dist/stream/submit-coordinator.d.ts +27 -0
  373. package/dist/stream/submit-coordinator.d.ts.map +1 -0
  374. package/dist/stream/submit-coordinator.js +397 -0
  375. package/dist/stream/submit-coordinator.js.map +1 -0
  376. package/dist/stream/tool-calls.cjs +15 -0
  377. package/dist/stream/tool-calls.cjs.map +1 -0
  378. package/dist/stream/tool-calls.js +15 -0
  379. package/dist/stream/tool-calls.js.map +1 -0
  380. package/dist/stream/types-inference.d.cts +43 -0
  381. package/dist/stream/types-inference.d.cts.map +1 -0
  382. package/dist/stream/types-inference.d.ts +43 -0
  383. package/dist/stream/types-inference.d.ts.map +1 -0
  384. package/dist/stream/types.d.cts +354 -0
  385. package/dist/stream/types.d.cts.map +1 -0
  386. package/dist/stream/types.d.ts +354 -0
  387. package/dist/stream/types.d.ts.map +1 -0
  388. package/dist/types.d.cts +2 -1
  389. package/dist/types.d.cts.map +1 -1
  390. package/dist/types.d.ts +2 -1
  391. package/dist/types.d.ts.map +1 -1
  392. package/dist/ui/index.cjs +1 -1
  393. package/dist/ui/index.d.cts +3 -3
  394. package/dist/ui/index.d.ts +3 -3
  395. package/dist/ui/index.js +1 -1
  396. package/dist/ui/manager.cjs +2 -2
  397. package/dist/ui/manager.cjs.map +1 -1
  398. package/dist/ui/manager.d.cts +1 -0
  399. package/dist/ui/manager.d.cts.map +1 -1
  400. package/dist/ui/manager.d.ts +1 -0
  401. package/dist/ui/manager.d.ts.map +1 -1
  402. package/dist/ui/manager.js +2 -2
  403. package/dist/ui/manager.js.map +1 -1
  404. package/dist/ui/messages.cjs +50 -7
  405. package/dist/ui/messages.cjs.map +1 -1
  406. package/dist/ui/messages.d.cts.map +1 -1
  407. package/dist/ui/messages.d.ts.map +1 -1
  408. package/dist/ui/messages.js +51 -9
  409. package/dist/ui/messages.js.map +1 -1
  410. package/dist/ui/orchestrator-custom.cjs +1 -1
  411. package/dist/ui/orchestrator-custom.js +1 -1
  412. package/dist/ui/orchestrator.cjs +4 -3
  413. package/dist/ui/orchestrator.cjs.map +1 -1
  414. package/dist/ui/orchestrator.d.cts +1 -1
  415. package/dist/ui/orchestrator.d.cts.map +1 -1
  416. package/dist/ui/orchestrator.d.ts +1 -1
  417. package/dist/ui/orchestrator.d.ts.map +1 -1
  418. package/dist/ui/orchestrator.js +4 -3
  419. package/dist/ui/orchestrator.js.map +1 -1
  420. package/dist/ui/stream/agent.d.cts +1 -1
  421. package/dist/ui/stream/agent.d.cts.map +1 -1
  422. package/dist/ui/stream/agent.d.ts +1 -1
  423. package/dist/ui/stream/agent.d.ts.map +1 -1
  424. package/dist/ui/stream/base.d.cts +7 -6
  425. package/dist/ui/stream/base.d.cts.map +1 -1
  426. package/dist/ui/stream/base.d.ts +7 -6
  427. package/dist/ui/stream/base.d.ts.map +1 -1
  428. package/dist/ui/stream/deep-agent.d.cts +1 -1
  429. package/dist/ui/stream/deep-agent.d.cts.map +1 -1
  430. package/dist/ui/stream/deep-agent.d.ts +1 -1
  431. package/dist/ui/stream/deep-agent.d.ts.map +1 -1
  432. package/dist/ui/stream/index.d.cts +4 -4
  433. package/dist/ui/stream/index.d.cts.map +1 -1
  434. package/dist/ui/stream/index.d.ts +4 -4
  435. package/dist/ui/stream/index.d.ts.map +1 -1
  436. package/dist/ui/types.d.cts +3 -2
  437. package/dist/ui/types.d.cts.map +1 -1
  438. package/dist/ui/types.d.ts +2 -1
  439. package/dist/ui/types.d.ts.map +1 -1
  440. package/package.json +18 -8
  441. package/dist/client.cjs.map +0 -1
  442. package/dist/client.d.cts.map +0 -1
  443. package/dist/client.d.ts.map +0 -1
  444. package/dist/client.js.map +0 -1
package/dist/client.cjs CHANGED
@@ -1,1309 +1,36 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_async_caller = require("./utils/async_caller.cjs");
3
- const require_env = require("./utils/env.cjs");
4
- const require_signals = require("./utils/signals.cjs");
5
- const require_sse = require("./utils/sse.cjs");
6
- const require_stream = require("./utils/stream.cjs");
7
- //#region src/client.ts
8
- function* iterateHeaders(headers) {
9
- let iter;
10
- let shouldClear = false;
11
- if (headers instanceof Headers) {
12
- const entries = [];
13
- headers.forEach((value, name) => {
14
- entries.push([name, value]);
15
- });
16
- iter = entries;
17
- } else if (Array.isArray(headers)) iter = headers;
18
- else {
19
- shouldClear = true;
20
- iter = Object.entries(headers ?? {});
21
- }
22
- for (const item of iter) {
23
- const name = item[0];
24
- if (typeof name !== "string") throw new TypeError(`Expected header name to be a string, got ${typeof name}`);
25
- const values = Array.isArray(item[1]) ? item[1] : [item[1]];
26
- let didClear = false;
27
- for (const value of values) {
28
- if (value === void 0) continue;
29
- if (shouldClear && !didClear) {
30
- didClear = true;
31
- yield [name, null];
32
- }
33
- yield [name, value];
34
- }
35
- }
36
- }
37
- function mergeHeaders(...headerObjects) {
38
- const outputHeaders = new Headers();
39
- for (const headers of headerObjects) {
40
- if (!headers) continue;
41
- for (const [name, value] of iterateHeaders(headers)) if (value === null) outputHeaders.delete(name);
42
- else outputHeaders.append(name, value);
43
- }
44
- const headerEntries = [];
45
- outputHeaders.forEach((value, name) => {
46
- headerEntries.push([name, value]);
47
- });
48
- return Object.fromEntries(headerEntries);
49
- }
50
- /**
51
- * Get the API key from the environment.
52
- * Precedence:
53
- * 1. explicit argument (if string)
54
- * 2. LANGGRAPH_API_KEY
55
- * 3. LANGSMITH_API_KEY
56
- * 4. LANGCHAIN_API_KEY
57
- *
58
- * @param apiKey - API key provided as an argument. If null, skips environment lookup. If undefined, tries environment.
59
- * @returns The API key if found, otherwise undefined
60
- */
61
- function getApiKey(apiKey) {
62
- if (apiKey === null) return;
63
- if (apiKey) return apiKey;
64
- for (const prefix of [
65
- "LANGGRAPH",
66
- "LANGSMITH",
67
- "LANGCHAIN"
68
- ]) {
69
- const envKey = require_env.getEnvironmentVariable(`${prefix}_API_KEY`);
70
- if (envKey) return envKey.trim().replace(/^["']|["']$/g, "");
71
- }
72
- }
73
- const REGEX_RUN_METADATA = /(\/threads\/(?<thread_id>.+))?\/runs\/(?<run_id>.+)/;
74
- function getRunMetadataFromResponse(response) {
75
- const contentLocation = response.headers.get("Content-Location");
76
- if (!contentLocation) return void 0;
77
- const match = REGEX_RUN_METADATA.exec(contentLocation);
78
- if (!match?.groups?.run_id) return void 0;
79
- return {
80
- run_id: match.groups.run_id,
81
- thread_id: match.groups.thread_id || void 0
82
- };
83
- }
84
- var BaseClient = class {
85
- asyncCaller;
86
- timeoutMs;
87
- apiUrl;
88
- defaultHeaders;
89
- onRequest;
90
- constructor(config) {
91
- const callerOptions = {
92
- maxRetries: 4,
93
- maxConcurrency: 4,
94
- ...config?.callerOptions
95
- };
96
- let defaultApiUrl = "http://localhost:8123";
97
- if (!config?.apiUrl && typeof globalThis === "object" && globalThis != null) {
98
- const fetchSmb = Symbol.for("langgraph_api:fetch");
99
- const urlSmb = Symbol.for("langgraph_api:url");
100
- const global = globalThis;
101
- if (global[fetchSmb]) callerOptions.fetch ??= global[fetchSmb];
102
- if (global[urlSmb]) defaultApiUrl = global[urlSmb];
103
- }
104
- this.asyncCaller = new require_async_caller.AsyncCaller(callerOptions);
105
- this.timeoutMs = config?.timeoutMs;
106
- this.apiUrl = config?.apiUrl?.replace(/\/$/, "") || defaultApiUrl;
107
- this.defaultHeaders = config?.defaultHeaders || {};
108
- this.onRequest = config?.onRequest;
109
- const apiKey = getApiKey(config?.apiKey);
110
- if (apiKey) this.defaultHeaders["x-api-key"] = apiKey;
111
- }
112
- prepareFetchOptions(path, options) {
113
- const mutatedOptions = {
114
- ...options,
115
- headers: mergeHeaders(this.defaultHeaders, options?.headers)
116
- };
117
- if (mutatedOptions.json) {
118
- mutatedOptions.body = JSON.stringify(mutatedOptions.json);
119
- mutatedOptions.headers = mergeHeaders(mutatedOptions.headers, { "content-type": "application/json" });
120
- delete mutatedOptions.json;
121
- }
122
- if (mutatedOptions.withResponse) delete mutatedOptions.withResponse;
123
- let timeoutSignal = null;
124
- if (typeof options?.timeoutMs !== "undefined") {
125
- if (options.timeoutMs != null) timeoutSignal = AbortSignal.timeout(options.timeoutMs);
126
- } else if (this.timeoutMs != null) timeoutSignal = AbortSignal.timeout(this.timeoutMs);
127
- mutatedOptions.signal = require_signals.mergeSignals(timeoutSignal, mutatedOptions.signal);
128
- const targetUrl = new URL(`${this.apiUrl}${path}`);
129
- if (mutatedOptions.params) {
130
- for (const [key, value] of Object.entries(mutatedOptions.params)) {
131
- if (value == null) continue;
132
- const strValue = typeof value === "string" || typeof value === "number" ? value.toString() : JSON.stringify(value);
133
- targetUrl.searchParams.append(key, strValue);
134
- }
135
- delete mutatedOptions.params;
136
- }
137
- return [targetUrl, mutatedOptions];
138
- }
139
- async fetch(path, options) {
140
- const [url, init] = this.prepareFetchOptions(path, options);
141
- let finalInit = init;
142
- if (this.onRequest) finalInit = await this.onRequest(url, init);
143
- const response = await this.asyncCaller.fetch(url.toString(), finalInit);
144
- const body = (() => {
145
- if (response.status === 202 || response.status === 204) return;
146
- return response.json();
147
- })();
148
- if (options?.withResponse) return [await body, response];
149
- return body;
150
- }
151
- /**
152
- * Protected helper for streaming with automatic retry logic.
153
- * Handles both initial requests and reconnections with SSE.
154
- */
155
- async *streamWithRetry(config) {
156
- const makeRequest = async (reconnectParams) => {
157
- const requestEndpoint = reconnectParams?.reconnectPath || config.endpoint;
158
- const isReconnect = !!reconnectParams?.reconnectPath;
159
- const method = isReconnect ? "GET" : config.method || "GET";
160
- const requestHeaders = isReconnect && reconnectParams?.lastEventId ? {
161
- ...config.headers,
162
- "Last-Event-ID": reconnectParams.lastEventId
163
- } : config.headers;
164
- let [url, init] = this.prepareFetchOptions(requestEndpoint, {
165
- method,
166
- timeoutMs: null,
167
- signal: config.signal,
168
- headers: requestHeaders,
169
- params: config.params,
170
- json: isReconnect ? void 0 : config.json
171
- });
172
- if (this.onRequest != null) init = await this.onRequest(url, init);
173
- const response = await this.asyncCaller.fetch(url.toString(), init);
174
- if (!response.body) throw new Error("Expected response body from stream endpoint");
175
- if (!isReconnect && config.onInitialResponse) await config.onInitialResponse(response);
176
- return {
177
- response,
178
- stream: response.body.pipeThrough(require_sse.BytesLineDecoder()).pipeThrough(require_sse.SSEDecoder())
179
- };
180
- };
181
- yield* require_stream.streamWithRetry(makeRequest, {
182
- maxRetries: config.maxRetries ?? 5,
183
- signal: config.signal,
184
- onReconnect: config.onReconnect
185
- });
186
- }
187
- };
188
- var CronsClient = class extends BaseClient {
189
- /**
190
- *
191
- * @param threadId The ID of the thread.
192
- * @param assistantId Assistant ID to use for this cron job.
193
- * @param payload Payload for creating a cron job.
194
- * @returns The created background run.
195
- */
196
- async createForThread(threadId, assistantId, payload) {
197
- const json = {
198
- schedule: payload?.schedule,
199
- input: payload?.input,
200
- config: payload?.config,
201
- context: payload?.context,
202
- metadata: payload?.metadata,
203
- assistant_id: assistantId,
204
- interrupt_before: payload?.interruptBefore,
205
- interrupt_after: payload?.interruptAfter,
206
- webhook: payload?.webhook,
207
- multitask_strategy: payload?.multitaskStrategy,
208
- checkpoint_during: payload?.checkpointDuring,
209
- durability: payload?.durability,
210
- enabled: payload?.enabled,
211
- timezone: payload?.timezone,
212
- stream_mode: payload?.streamMode,
213
- stream_subgraphs: payload?.streamSubgraphs,
214
- stream_resumable: payload?.streamResumable,
215
- end_time: payload?.endTime,
216
- on_run_completed: payload?.onRunCompleted
217
- };
218
- return this.fetch(`/threads/${threadId}/runs/crons`, {
219
- method: "POST",
220
- json,
221
- signal: payload?.signal
222
- });
223
- }
224
- /**
225
- *
226
- * @param assistantId Assistant ID to use for this cron job.
227
- * @param payload Payload for creating a cron job.
228
- * @returns
229
- */
230
- async create(assistantId, payload) {
231
- const json = {
232
- schedule: payload?.schedule,
233
- input: payload?.input,
234
- config: payload?.config,
235
- context: payload?.context,
236
- metadata: payload?.metadata,
237
- assistant_id: assistantId,
238
- interrupt_before: payload?.interruptBefore,
239
- interrupt_after: payload?.interruptAfter,
240
- webhook: payload?.webhook,
241
- on_run_completed: payload?.onRunCompleted,
242
- multitask_strategy: payload?.multitaskStrategy,
243
- checkpoint_during: payload?.checkpointDuring,
244
- durability: payload?.durability,
245
- enabled: payload?.enabled,
246
- timezone: payload?.timezone,
247
- stream_mode: payload?.streamMode,
248
- stream_subgraphs: payload?.streamSubgraphs,
249
- stream_resumable: payload?.streamResumable,
250
- end_time: payload?.endTime
251
- };
252
- return this.fetch(`/runs/crons`, {
253
- method: "POST",
254
- json,
255
- signal: payload?.signal
256
- });
257
- }
258
- /**
259
- * Update a cron job by ID.
260
- *
261
- * @param cronId The cron ID to update.
262
- * @param payload Payload for updating a cron job.
263
- * @returns The updated cron job.
264
- * ```
265
- */
266
- async update(cronId, payload) {
267
- const json = {};
268
- if (payload?.schedule !== void 0) json.schedule = payload.schedule;
269
- if (payload?.timezone !== void 0) json.timezone = payload.timezone;
270
- if (payload?.endTime !== void 0) json.end_time = payload.endTime;
271
- if (payload?.input !== void 0) json.input = payload.input;
272
- if (payload?.metadata !== void 0) json.metadata = payload.metadata;
273
- if (payload?.config !== void 0) json.config = payload.config;
274
- if (payload?.context !== void 0) json.context = payload.context;
275
- if (payload?.webhook !== void 0) json.webhook = payload.webhook;
276
- if (payload?.interruptBefore !== void 0) json.interrupt_before = payload.interruptBefore;
277
- if (payload?.interruptAfter !== void 0) json.interrupt_after = payload.interruptAfter;
278
- if (payload?.onRunCompleted !== void 0) json.on_run_completed = payload.onRunCompleted;
279
- if (payload?.enabled !== void 0) json.enabled = payload.enabled;
280
- if (payload?.streamMode !== void 0) json.stream_mode = payload.streamMode;
281
- if (payload?.streamSubgraphs !== void 0) json.stream_subgraphs = payload.streamSubgraphs;
282
- if (payload?.streamResumable !== void 0) json.stream_resumable = payload.streamResumable;
283
- if (payload?.durability !== void 0) json.durability = payload.durability;
284
- return this.fetch(`/runs/crons/${cronId}`, {
285
- method: "PATCH",
286
- json,
287
- signal: payload?.signal
288
- });
289
- }
290
- /**
291
- * Delete a cron job by ID.
292
- *
293
- * @param cronId Cron ID of Cron job to delete.
294
- * @param options Optional parameters for the request.
295
- */
296
- async delete(cronId, options) {
297
- await this.fetch(`/runs/crons/${cronId}`, {
298
- method: "DELETE",
299
- signal: options?.signal
300
- });
301
- }
302
- /**
303
- *
304
- * @param query Query options.
305
- * @returns List of crons.
306
- */
307
- async search(query) {
308
- return this.fetch("/runs/crons/search", {
309
- method: "POST",
310
- json: {
311
- assistant_id: query?.assistantId ?? void 0,
312
- thread_id: query?.threadId ?? void 0,
313
- enabled: query?.enabled ?? void 0,
314
- limit: query?.limit ?? 10,
315
- offset: query?.offset ?? 0,
316
- sort_by: query?.sortBy ?? void 0,
317
- sort_order: query?.sortOrder ?? void 0,
318
- select: query?.select ?? void 0
319
- },
320
- signal: query?.signal
321
- });
322
- }
323
- /**
324
- * Count cron jobs matching filters.
325
- *
326
- * @param query.assistantId Assistant ID to filter by.
327
- * @param query.threadId Thread ID to filter by.
328
- * @returns Number of cron jobs matching the criteria.
329
- */
330
- async count(query) {
331
- return this.fetch(`/runs/crons/count`, {
332
- method: "POST",
333
- json: {
334
- assistant_id: query?.assistantId ?? void 0,
335
- thread_id: query?.threadId ?? void 0
336
- },
337
- signal: query?.signal
338
- });
339
- }
340
- };
341
- var AssistantsClient = class extends BaseClient {
342
- /**
343
- * Get an assistant by ID.
344
- *
345
- * @param assistantId The ID of the assistant.
346
- * @returns Assistant
347
- */
348
- async get(assistantId, options) {
349
- return this.fetch(`/assistants/${assistantId}`, { signal: options?.signal });
350
- }
351
- /**
352
- * Get the JSON representation of the graph assigned to a runnable
353
- * @param assistantId The ID of the assistant.
354
- * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be included.
355
- * @returns Serialized graph
356
- */
357
- async getGraph(assistantId, options) {
358
- return this.fetch(`/assistants/${assistantId}/graph`, {
359
- params: { xray: options?.xray },
360
- signal: options?.signal
361
- });
362
- }
363
- /**
364
- * Get the state and config schema of the graph assigned to a runnable
365
- * @param assistantId The ID of the assistant.
366
- * @returns Graph schema
367
- */
368
- async getSchemas(assistantId, options) {
369
- return this.fetch(`/assistants/${assistantId}/schemas`, { signal: options?.signal });
370
- }
371
- /**
372
- * Get the schemas of an assistant by ID.
373
- *
374
- * @param assistantId The ID of the assistant to get the schema of.
375
- * @param options Additional options for getting subgraphs, such as namespace or recursion extraction.
376
- * @returns The subgraphs of the assistant.
377
- */
378
- async getSubgraphs(assistantId, options) {
379
- if (options?.namespace) return this.fetch(`/assistants/${assistantId}/subgraphs/${options.namespace}`, {
380
- params: { recurse: options?.recurse },
381
- signal: options?.signal
382
- });
383
- return this.fetch(`/assistants/${assistantId}/subgraphs`, {
384
- params: { recurse: options?.recurse },
385
- signal: options?.signal
386
- });
387
- }
388
- /**
389
- * Create a new assistant.
390
- * @param payload Payload for creating an assistant.
391
- * @returns The created assistant.
392
- */
393
- async create(payload) {
394
- return this.fetch("/assistants", {
395
- method: "POST",
396
- json: {
397
- graph_id: payload.graphId,
398
- config: payload.config,
399
- context: payload.context,
400
- metadata: payload.metadata,
401
- assistant_id: payload.assistantId,
402
- if_exists: payload.ifExists,
403
- name: payload.name,
404
- description: payload.description
405
- },
406
- signal: payload.signal
407
- });
408
- }
409
- /**
410
- * Update an assistant.
411
- * @param assistantId ID of the assistant.
412
- * @param payload Payload for updating the assistant.
413
- * @returns The updated assistant.
414
- */
415
- async update(assistantId, payload) {
416
- return this.fetch(`/assistants/${assistantId}`, {
417
- method: "PATCH",
418
- json: {
419
- graph_id: payload.graphId,
420
- config: payload.config,
421
- context: payload.context,
422
- metadata: payload.metadata,
423
- name: payload.name,
424
- description: payload.description
425
- },
426
- signal: payload.signal
427
- });
428
- }
429
- /**
430
- * Delete an assistant.
431
- *
432
- * @param assistantId ID of the assistant.
433
- * @param deleteThreads If true, delete all threads with `metadata.assistant_id` equal to `assistantId`. Defaults to false.
434
- */
435
- async delete(assistantId, options) {
436
- return this.fetch(`/assistants/${assistantId}?delete_threads=${options?.deleteThreads ?? false}`, {
437
- method: "DELETE",
438
- signal: options?.signal
439
- });
440
- }
441
- async search(query) {
442
- const json = {
443
- graph_id: query?.graphId ?? void 0,
444
- name: query?.name ?? void 0,
445
- metadata: query?.metadata ?? void 0,
446
- limit: query?.limit ?? 10,
447
- offset: query?.offset ?? 0,
448
- sort_by: query?.sortBy ?? void 0,
449
- sort_order: query?.sortOrder ?? void 0,
450
- select: query?.select ?? void 0
451
- };
452
- const [assistants, response] = await this.fetch("/assistants/search", {
453
- method: "POST",
454
- json,
455
- withResponse: true,
456
- signal: query?.signal
457
- });
458
- if (query?.includePagination) return {
459
- assistants,
460
- next: response.headers.get("X-Pagination-Next")
461
- };
462
- return assistants;
463
- }
464
- /**
465
- * Count assistants matching filters.
466
- *
467
- * @param query.metadata Metadata to filter by. Exact match for each key/value.
468
- * @param query.graphId Optional graph id to filter by.
469
- * @param query.name Optional name to filter by.
470
- * @returns Number of assistants matching the criteria.
471
- */
472
- async count(query) {
473
- return this.fetch(`/assistants/count`, {
474
- method: "POST",
475
- json: {
476
- metadata: query?.metadata ?? void 0,
477
- graph_id: query?.graphId ?? void 0,
478
- name: query?.name ?? void 0
479
- },
480
- signal: query?.signal
481
- });
482
- }
483
- /**
484
- * List all versions of an assistant.
485
- *
486
- * @param assistantId ID of the assistant.
487
- * @returns List of assistant versions.
488
- */
489
- async getVersions(assistantId, payload) {
490
- return this.fetch(`/assistants/${assistantId}/versions`, {
491
- method: "POST",
492
- json: {
493
- metadata: payload?.metadata ?? void 0,
494
- limit: payload?.limit ?? 10,
495
- offset: payload?.offset ?? 0
496
- },
497
- signal: payload?.signal
498
- });
499
- }
500
- /**
501
- * Change the version of an assistant.
502
- *
503
- * @param assistantId ID of the assistant.
504
- * @param version The version to change to.
505
- * @returns The updated assistant.
506
- */
507
- async setLatest(assistantId, version, options) {
508
- return this.fetch(`/assistants/${assistantId}/latest`, {
509
- method: "POST",
510
- json: { version },
511
- signal: options?.signal
512
- });
513
- }
514
- };
515
- var ThreadsClient = class extends BaseClient {
516
- /**
517
- * Get a thread by ID.
518
- *
519
- * @param threadId ID of the thread.
520
- * @returns The thread.
521
- */
522
- async get(threadId, options) {
523
- return this.fetch(`/threads/${threadId}`, {
524
- params: { include: options?.include ?? void 0 },
525
- signal: options?.signal
526
- });
527
- }
528
- /**
529
- * Create a new thread.
530
- *
531
- * @param payload Payload for creating a thread.
532
- * @returns The created thread.
533
- */
534
- async create(payload) {
535
- const ttlPayload = typeof payload?.ttl === "number" ? {
536
- ttl: payload.ttl,
537
- strategy: "delete"
538
- } : payload?.ttl;
539
- return this.fetch(`/threads`, {
540
- method: "POST",
541
- json: {
542
- metadata: {
543
- ...payload?.metadata,
544
- graph_id: payload?.graphId
545
- },
546
- thread_id: payload?.threadId,
547
- if_exists: payload?.ifExists,
548
- supersteps: payload?.supersteps?.map((s) => ({ updates: s.updates.map((u) => ({
549
- values: u.values,
550
- command: u.command,
551
- as_node: u.asNode
552
- })) })),
553
- ttl: ttlPayload
554
- },
555
- signal: payload?.signal
556
- });
557
- }
558
- /**
559
- * Copy an existing thread
560
- * @param threadId ID of the thread to be copied
561
- * @returns Newly copied thread
562
- */
563
- async copy(threadId, options) {
564
- return this.fetch(`/threads/${threadId}/copy`, {
565
- method: "POST",
566
- signal: options?.signal
567
- });
568
- }
569
- /**
570
- * Update a thread.
571
- *
572
- * @param threadId ID of the thread.
573
- * @param payload Payload for updating the thread.
574
- * @returns The updated thread.
575
- */
576
- async update(threadId, payload) {
577
- const ttlPayload = typeof payload?.ttl === "number" ? {
578
- ttl: payload.ttl,
579
- strategy: "delete"
580
- } : payload?.ttl;
581
- return this.fetch(`/threads/${threadId}`, {
582
- method: "PATCH",
583
- json: {
584
- metadata: payload?.metadata,
585
- ttl: ttlPayload
586
- },
587
- signal: payload?.signal
588
- });
589
- }
590
- /**
591
- * Delete a thread.
592
- *
593
- * @param threadId ID of the thread.
594
- */
595
- async delete(threadId, options) {
596
- return this.fetch(`/threads/${threadId}`, {
597
- method: "DELETE",
598
- signal: options?.signal
599
- });
600
- }
601
- /**
602
- * Prune threads by ID. The 'delete' strategy removes threads entirely.
603
- * The 'keep_latest' strategy prunes old checkpoints but keeps threads
604
- * and their latest state.
605
- *
606
- * @param threadIds List of thread IDs to prune.
607
- * @param options Additional options for pruning.
608
- * @param options.strategy The prune strategy. Defaults to 'delete'.
609
- * @param options.signal Signal to abort the request.
610
- * @returns An object containing `pruned_count`.
611
- */
612
- async prune(threadIds, options) {
613
- return this.fetch("/threads/prune", {
614
- method: "POST",
615
- json: {
616
- thread_ids: threadIds,
617
- strategy: options?.strategy ?? "delete"
618
- },
619
- signal: options?.signal
620
- });
621
- }
622
- /**
623
- * List threads
624
- *
625
- * @param query Query options
626
- * @returns List of threads
627
- */
628
- async search(query) {
629
- return this.fetch("/threads/search", {
630
- method: "POST",
631
- json: {
632
- metadata: query?.metadata ?? void 0,
633
- ids: query?.ids ?? void 0,
634
- limit: query?.limit ?? 10,
635
- offset: query?.offset ?? 0,
636
- status: query?.status,
637
- sort_by: query?.sortBy,
638
- sort_order: query?.sortOrder,
639
- select: query?.select ?? void 0,
640
- values: query?.values ?? void 0,
641
- extract: query?.extract ?? void 0
642
- },
643
- signal: query?.signal
644
- });
645
- }
646
- /**
647
- * Count threads matching filters.
648
- *
649
- * @param query.metadata Thread metadata to filter on.
650
- * @param query.values State values to filter on.
651
- * @param query.status Thread status to filter on.
652
- * @returns Number of threads matching the criteria.
653
- */
654
- async count(query) {
655
- return this.fetch(`/threads/count`, {
656
- method: "POST",
657
- json: {
658
- metadata: query?.metadata ?? void 0,
659
- values: query?.values ?? void 0,
660
- status: query?.status ?? void 0
661
- },
662
- signal: query?.signal
663
- });
664
- }
665
- /**
666
- * Get state for a thread.
667
- *
668
- * @param threadId ID of the thread.
669
- * @returns Thread state.
670
- */
671
- async getState(threadId, checkpoint, options) {
672
- if (checkpoint != null) {
673
- if (typeof checkpoint !== "string") return this.fetch(`/threads/${threadId}/state/checkpoint`, {
674
- method: "POST",
675
- json: {
676
- checkpoint,
677
- subgraphs: options?.subgraphs
678
- },
679
- signal: options?.signal
680
- });
681
- return this.fetch(`/threads/${threadId}/state/${checkpoint}`, {
682
- params: { subgraphs: options?.subgraphs },
683
- signal: options?.signal
684
- });
685
- }
686
- return this.fetch(`/threads/${threadId}/state`, {
687
- params: { subgraphs: options?.subgraphs },
688
- signal: options?.signal
689
- });
690
- }
691
- /**
692
- * Add state to a thread.
693
- *
694
- * @param threadId The ID of the thread.
695
- * @returns
696
- */
697
- async updateState(threadId, options) {
698
- return this.fetch(`/threads/${threadId}/state`, {
699
- method: "POST",
700
- json: {
701
- values: options.values,
702
- checkpoint: options.checkpoint,
703
- checkpoint_id: options.checkpointId,
704
- as_node: options?.asNode
705
- },
706
- signal: options?.signal
707
- });
708
- }
709
- /**
710
- * Patch the metadata of a thread.
711
- *
712
- * @param threadIdOrConfig Thread ID or config to patch the state of.
713
- * @param metadata Metadata to patch the state with.
714
- */
715
- async patchState(threadIdOrConfig, metadata, options) {
716
- let threadId;
717
- if (typeof threadIdOrConfig !== "string") {
718
- if (typeof threadIdOrConfig.configurable?.thread_id !== "string") throw new Error("Thread ID is required when updating state with a config.");
719
- threadId = threadIdOrConfig.configurable.thread_id;
720
- } else threadId = threadIdOrConfig;
721
- return this.fetch(`/threads/${threadId}/state`, {
722
- method: "PATCH",
723
- json: { metadata },
724
- signal: options?.signal
725
- });
726
- }
727
- /**
728
- * Get all past states for a thread.
729
- *
730
- * @param threadId ID of the thread.
731
- * @param options Additional options.
732
- * @returns List of thread states.
733
- */
734
- async getHistory(threadId, options) {
735
- return this.fetch(`/threads/${threadId}/history`, {
736
- method: "POST",
737
- json: {
738
- limit: options?.limit ?? 10,
739
- before: options?.before,
740
- metadata: options?.metadata,
741
- checkpoint: options?.checkpoint
742
- },
743
- signal: options?.signal
744
- });
745
- }
746
- async *joinStream(threadId, options) {
747
- yield* this.streamWithRetry({
748
- endpoint: `/threads/${threadId}/stream`,
749
- method: "GET",
750
- signal: options?.signal,
751
- headers: options?.lastEventId ? { "Last-Event-ID": options.lastEventId } : void 0,
752
- params: options?.streamMode ? { stream_mode: options.streamMode } : void 0
753
- });
754
- }
755
- };
756
- var RunsClient = class extends BaseClient {
757
- /**
758
- * Create a run and stream the results.
759
- *
760
- * @param threadId The ID of the thread.
761
- * @param assistantId Assistant ID to use for this run.
762
- * @param payload Payload for creating a run.
763
- */
764
- async *stream(threadId, assistantId, payload) {
765
- const json = {
766
- input: payload?.input,
767
- command: payload?.command,
768
- config: payload?.config,
769
- context: payload?.context,
770
- metadata: payload?.metadata,
771
- stream_mode: payload?.streamMode,
772
- stream_subgraphs: payload?.streamSubgraphs,
773
- stream_resumable: payload?.streamResumable,
774
- feedback_keys: payload?.feedbackKeys,
775
- assistant_id: assistantId,
776
- interrupt_before: payload?.interruptBefore,
777
- interrupt_after: payload?.interruptAfter,
778
- checkpoint: payload?.checkpoint,
779
- webhook: payload?.webhook,
780
- multitask_strategy: payload?.multitaskStrategy,
781
- on_completion: payload?.onCompletion,
782
- on_disconnect: payload?.onDisconnect,
783
- after_seconds: payload?.afterSeconds,
784
- if_not_exists: payload?.ifNotExists,
785
- checkpoint_during: payload?.checkpointDuring,
786
- durability: payload?.durability
787
- };
788
- yield* this.streamWithRetry({
789
- endpoint: threadId == null ? `/runs/stream` : `/threads/${threadId}/runs/stream`,
790
- method: "POST",
791
- json,
792
- signal: payload?.signal,
793
- onInitialResponse: (response) => {
794
- const runMetadata = getRunMetadataFromResponse(response);
795
- if (runMetadata) payload?.onRunCreated?.(runMetadata);
796
- }
797
- });
798
- }
799
- /**
800
- * Create a run.
801
- *
802
- * @param threadId The ID of the thread.
803
- * @param assistantId Assistant ID to use for this run.
804
- * @param payload Payload for creating a run.
805
- * @returns The created run.
806
- */
807
- async create(threadId, assistantId, payload) {
808
- const json = {
809
- input: payload?.input,
810
- command: payload?.command,
811
- config: payload?.config,
812
- context: payload?.context,
813
- metadata: payload?.metadata,
814
- stream_mode: payload?.streamMode,
815
- stream_subgraphs: payload?.streamSubgraphs,
816
- stream_resumable: payload?.streamResumable,
817
- feedback_keys: payload?.feedbackKeys,
818
- assistant_id: assistantId,
819
- interrupt_before: payload?.interruptBefore,
820
- interrupt_after: payload?.interruptAfter,
821
- webhook: payload?.webhook,
822
- checkpoint: payload?.checkpoint,
823
- checkpoint_id: payload?.checkpointId,
824
- multitask_strategy: payload?.multitaskStrategy,
825
- after_seconds: payload?.afterSeconds,
826
- if_not_exists: payload?.ifNotExists,
827
- checkpoint_during: payload?.checkpointDuring,
828
- durability: payload?.durability,
829
- on_completion: payload?.onCompletion,
830
- langsmith_tracer: payload?._langsmithTracer ? {
831
- project_name: payload?._langsmithTracer?.projectName,
832
- example_id: payload?._langsmithTracer?.exampleId
833
- } : void 0
834
- };
835
- const endpoint = threadId === null ? "/runs" : `/threads/${threadId}/runs`;
836
- const [run, response] = await this.fetch(endpoint, {
837
- method: "POST",
838
- json,
839
- signal: payload?.signal,
840
- withResponse: true
841
- });
842
- const runMetadata = getRunMetadataFromResponse(response);
843
- if (runMetadata) payload?.onRunCreated?.(runMetadata);
844
- return run;
845
- }
846
- /**
847
- * Create a batch of stateless background runs.
848
- *
849
- * @param payloads An array of payloads for creating runs.
850
- * @returns An array of created runs.
851
- */
852
- async createBatch(payloads, options) {
853
- const filteredPayloads = payloads.map((payload) => ({
854
- ...payload,
855
- assistant_id: payload.assistantId
856
- })).map((payload) => {
857
- return Object.fromEntries(Object.entries(payload).filter(([_, v]) => v !== void 0));
858
- });
859
- return this.fetch("/runs/batch", {
860
- method: "POST",
861
- json: filteredPayloads,
862
- signal: options?.signal
863
- });
864
- }
865
- /**
866
- * Create a run and wait for it to complete.
867
- *
868
- * @param threadId The ID of the thread.
869
- * @param assistantId Assistant ID to use for this run.
870
- * @param payload Payload for creating a run.
871
- * @returns The last values chunk of the thread.
872
- */
873
- async wait(threadId, assistantId, payload) {
874
- const json = {
875
- input: payload?.input,
876
- command: payload?.command,
877
- config: payload?.config,
878
- context: payload?.context,
879
- metadata: payload?.metadata,
880
- assistant_id: assistantId,
881
- interrupt_before: payload?.interruptBefore,
882
- interrupt_after: payload?.interruptAfter,
883
- checkpoint: payload?.checkpoint,
884
- checkpoint_id: payload?.checkpointId,
885
- webhook: payload?.webhook,
886
- multitask_strategy: payload?.multitaskStrategy,
887
- on_completion: payload?.onCompletion,
888
- on_disconnect: payload?.onDisconnect,
889
- after_seconds: payload?.afterSeconds,
890
- if_not_exists: payload?.ifNotExists,
891
- checkpoint_during: payload?.checkpointDuring,
892
- durability: payload?.durability,
893
- langsmith_tracer: payload?._langsmithTracer ? {
894
- project_name: payload?._langsmithTracer?.projectName,
895
- example_id: payload?._langsmithTracer?.exampleId
896
- } : void 0
897
- };
898
- const endpoint = threadId == null ? `/runs/wait` : `/threads/${threadId}/runs/wait`;
899
- const [run, response] = await this.fetch(endpoint, {
900
- method: "POST",
901
- json,
902
- timeoutMs: null,
903
- signal: payload?.signal,
904
- withResponse: true
905
- });
906
- const runMetadata = getRunMetadataFromResponse(response);
907
- if (runMetadata) payload?.onRunCreated?.(runMetadata);
908
- if ((payload?.raiseError !== void 0 ? payload.raiseError : true) && "__error__" in run && typeof run.__error__ === "object" && run.__error__ && "error" in run.__error__ && "message" in run.__error__) throw new Error(`${run.__error__?.error}: ${run.__error__?.message}`);
909
- return run;
910
- }
911
- /**
912
- * List all runs for a thread.
913
- *
914
- * @param threadId The ID of the thread.
915
- * @param options Filtering and pagination options.
916
- * @returns List of runs.
917
- */
918
- async list(threadId, options) {
919
- return this.fetch(`/threads/${threadId}/runs`, {
920
- params: {
921
- limit: options?.limit ?? 10,
922
- offset: options?.offset ?? 0,
923
- status: options?.status ?? void 0,
924
- select: options?.select ?? void 0
925
- },
926
- signal: options?.signal
927
- });
928
- }
929
- /**
930
- * Get a run by ID.
931
- *
932
- * @param threadId The ID of the thread.
933
- * @param runId The ID of the run.
934
- * @returns The run.
935
- */
936
- async get(threadId, runId, options) {
937
- return this.fetch(`/threads/${threadId}/runs/${runId}`, { signal: options?.signal });
938
- }
939
- /**
940
- * Cancel a run.
941
- *
942
- * @param threadId The ID of the thread.
943
- * @param runId The ID of the run.
944
- * @param wait Whether to block when canceling
945
- * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
946
- * @returns
947
- */
948
- async cancel(threadId, runId, wait = false, action = "interrupt", options = {}) {
949
- return this.fetch(`/threads/${threadId}/runs/${runId}/cancel`, {
950
- method: "POST",
951
- params: {
952
- wait: wait ? "1" : "0",
953
- action
954
- },
955
- signal: options?.signal
956
- });
957
- }
958
- /**
959
- * Cancel one or more runs. Can cancel runs by thread ID and run IDs, or by status filter.
960
- *
961
- * @param options Options for cancelling runs.
962
- * @param options.threadId The ID of the thread containing runs to cancel.
963
- * @param options.runIds List of run IDs to cancel.
964
- * @param options.status Filter runs by status to cancel. Must be one of 'pending', 'running', or 'all'.
965
- * @param options.action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`.
966
- * @param options.signal AbortSignal for cancelling the request.
967
- * @returns
968
- */
969
- async cancelMany(options) {
970
- return this.fetch(`/runs/cancel`, {
971
- method: "POST",
972
- json: {
973
- thread_id: options.threadId,
974
- run_ids: options.runIds,
975
- status: options.status
976
- },
977
- params: { action: options.action },
978
- signal: options.signal
979
- });
980
- }
981
- /**
982
- * Block until a run is done.
983
- *
984
- * @param threadId The ID of the thread.
985
- * @param runId The ID of the run.
986
- * @returns
987
- */
988
- async join(threadId, runId, options) {
989
- return this.fetch(`/threads/${threadId}/runs/${runId}/join`, {
990
- timeoutMs: null,
991
- params: { cancel_on_disconnect: options?.cancelOnDisconnect ? "1" : "0" },
992
- signal: options?.signal
993
- });
994
- }
995
- /**
996
- * Stream output from a run in real-time, until the run is done.
997
- *
998
- * @param threadId The ID of the thread. Can be set to `null` | `undefined` for stateless runs.
999
- * @param runId The ID of the run.
1000
- * @param options Additional options for controlling the stream behavior:
1001
- * - signal: An AbortSignal that can be used to cancel the stream request
1002
- * - lastEventId: The ID of the last event received. Can be used to reconnect to a stream without losing events.
1003
- * - cancelOnDisconnect: When true, automatically cancels the run if the client disconnects from the stream
1004
- * - streamMode: Controls what types of events to receive from the stream (can be a single mode or array of modes)
1005
- * Must be a subset of the stream modes passed when creating the run. Background runs default to having the union of all
1006
- * stream modes enabled.
1007
- * @returns An async generator yielding stream parts.
1008
- */
1009
- async *joinStream(threadId, runId, options) {
1010
- const opts = typeof options === "object" && options != null && options instanceof AbortSignal ? { signal: options } : options;
1011
- yield* this.streamWithRetry({
1012
- endpoint: threadId != null ? `/threads/${threadId}/runs/${runId}/stream` : `/runs/${runId}/stream`,
1013
- method: "GET",
1014
- signal: opts?.signal,
1015
- headers: opts?.lastEventId ? { "Last-Event-ID": opts.lastEventId } : void 0,
1016
- params: {
1017
- cancel_on_disconnect: opts?.cancelOnDisconnect ? "1" : "0",
1018
- stream_mode: opts?.streamMode
1019
- }
1020
- });
1021
- }
1022
- /**
1023
- * Delete a run.
1024
- *
1025
- * @param threadId The ID of the thread.
1026
- * @param runId The ID of the run.
1027
- * @returns
1028
- */
1029
- async delete(threadId, runId, options) {
1030
- return this.fetch(`/threads/${threadId}/runs/${runId}`, {
1031
- method: "DELETE",
1032
- signal: options?.signal
1033
- });
1034
- }
1035
- };
1036
- var StoreClient = class extends BaseClient {
1037
- /**
1038
- * Store or update an item.
1039
- *
1040
- * @param namespace A list of strings representing the namespace path.
1041
- * @param key The unique identifier for the item within the namespace.
1042
- * @param value A dictionary containing the item's data.
1043
- * @param options.index Controls search indexing - null (use defaults), false (disable), or list of field paths to index.
1044
- * @param options.ttl Optional time-to-live in minutes for the item, or null for no expiration.
1045
- * @returns Promise<void>
1046
- *
1047
- * @example
1048
- * ```typescript
1049
- * await client.store.putItem(
1050
- * ["documents", "user123"],
1051
- * "item456",
1052
- * { title: "My Document", content: "Hello World" },
1053
- * { ttl: 60 } // expires in 60 minutes
1054
- * );
1055
- * ```
1056
- */
1057
- async putItem(namespace, key, value, options) {
1058
- namespace.forEach((label) => {
1059
- if (label.includes(".")) throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
1060
- });
1061
- const payload = {
1062
- namespace,
1063
- key,
1064
- value,
1065
- index: options?.index,
1066
- ttl: options?.ttl
1067
- };
1068
- return this.fetch("/store/items", {
1069
- method: "PUT",
1070
- json: payload,
1071
- signal: options?.signal
1072
- });
1073
- }
1074
- /**
1075
- * Retrieve a single item.
1076
- *
1077
- * @param namespace A list of strings representing the namespace path.
1078
- * @param key The unique identifier for the item.
1079
- * @param options.refreshTtl Whether to refresh the TTL on this read operation. If null, uses the store's default behavior.
1080
- * @returns Promise<Item>
1081
- *
1082
- * @example
1083
- * ```typescript
1084
- * const item = await client.store.getItem(
1085
- * ["documents", "user123"],
1086
- * "item456",
1087
- * { refreshTtl: true }
1088
- * );
1089
- * console.log(item);
1090
- * // {
1091
- * // namespace: ["documents", "user123"],
1092
- * // key: "item456",
1093
- * // value: { title: "My Document", content: "Hello World" },
1094
- * // createdAt: "2024-07-30T12:00:00Z",
1095
- * // updatedAt: "2024-07-30T12:00:00Z"
1096
- * // }
1097
- * ```
1098
- */
1099
- async getItem(namespace, key, options) {
1100
- namespace.forEach((label) => {
1101
- if (label.includes(".")) throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
1102
- });
1103
- const params = {
1104
- namespace: namespace.join("."),
1105
- key
1106
- };
1107
- if (options?.refreshTtl !== void 0) params.refresh_ttl = options.refreshTtl;
1108
- const response = await this.fetch("/store/items", {
1109
- params,
1110
- signal: options?.signal
1111
- });
1112
- return response ? {
1113
- ...response,
1114
- createdAt: response.created_at,
1115
- updatedAt: response.updated_at
1116
- } : null;
1117
- }
1118
- /**
1119
- * Delete an item.
1120
- *
1121
- * @param namespace A list of strings representing the namespace path.
1122
- * @param key The unique identifier for the item.
1123
- * @returns Promise<void>
1124
- */
1125
- async deleteItem(namespace, key, options) {
1126
- namespace.forEach((label) => {
1127
- if (label.includes(".")) throw new Error(`Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`);
1128
- });
1129
- return this.fetch("/store/items", {
1130
- method: "DELETE",
1131
- json: {
1132
- namespace,
1133
- key
1134
- },
1135
- signal: options?.signal
1136
- });
1137
- }
1138
- /**
1139
- * Search for items within a namespace prefix.
1140
- *
1141
- * @param namespacePrefix List of strings representing the namespace prefix.
1142
- * @param options.filter Optional dictionary of key-value pairs to filter results.
1143
- * @param options.limit Maximum number of items to return (default is 10).
1144
- * @param options.offset Number of items to skip before returning results (default is 0).
1145
- * @param options.query Optional search query.
1146
- * @param options.refreshTtl Whether to refresh the TTL on items returned by this search. If null, uses the store's default behavior.
1147
- * @returns Promise<SearchItemsResponse>
1148
- *
1149
- * @example
1150
- * ```typescript
1151
- * const results = await client.store.searchItems(
1152
- * ["documents"],
1153
- * {
1154
- * filter: { author: "John Doe" },
1155
- * limit: 5,
1156
- * refreshTtl: true
1157
- * }
1158
- * );
1159
- * console.log(results);
1160
- * // {
1161
- * // items: [
1162
- * // {
1163
- * // namespace: ["documents", "user123"],
1164
- * // key: "item789",
1165
- * // value: { title: "Another Document", author: "John Doe" },
1166
- * // createdAt: "2024-07-30T12:00:00Z",
1167
- * // updatedAt: "2024-07-30T12:00:00Z"
1168
- * // },
1169
- * // // ... additional items ...
1170
- * // ]
1171
- * // }
1172
- * ```
1173
- */
1174
- async searchItems(namespacePrefix, options) {
1175
- const payload = {
1176
- namespace_prefix: namespacePrefix,
1177
- filter: options?.filter,
1178
- limit: options?.limit ?? 10,
1179
- offset: options?.offset ?? 0,
1180
- query: options?.query,
1181
- refresh_ttl: options?.refreshTtl
1182
- };
1183
- return { items: (await this.fetch("/store/items/search", {
1184
- method: "POST",
1185
- json: payload,
1186
- signal: options?.signal
1187
- })).items.map((item) => ({
1188
- ...item,
1189
- createdAt: item.created_at,
1190
- updatedAt: item.updated_at
1191
- })) };
1192
- }
1193
- /**
1194
- * List namespaces with optional match conditions.
1195
- *
1196
- * @param options.prefix Optional list of strings representing the prefix to filter namespaces.
1197
- * @param options.suffix Optional list of strings representing the suffix to filter namespaces.
1198
- * @param options.maxDepth Optional integer specifying the maximum depth of namespaces to return.
1199
- * @param options.limit Maximum number of namespaces to return (default is 100).
1200
- * @param options.offset Number of namespaces to skip before returning results (default is 0).
1201
- * @returns Promise<ListNamespaceResponse>
1202
- */
1203
- async listNamespaces(options) {
1204
- const payload = {
1205
- prefix: options?.prefix,
1206
- suffix: options?.suffix,
1207
- max_depth: options?.maxDepth,
1208
- limit: options?.limit ?? 100,
1209
- offset: options?.offset ?? 0
1210
- };
1211
- return this.fetch("/store/namespaces", {
1212
- method: "POST",
1213
- json: payload,
1214
- signal: options?.signal
1215
- });
1216
- }
1217
- };
1218
- var UiClient = class UiClient extends BaseClient {
1219
- static promiseCache = {};
1220
- static getOrCached(key, fn) {
1221
- if (UiClient.promiseCache[key] != null) return UiClient.promiseCache[key];
1222
- const promise = fn();
1223
- UiClient.promiseCache[key] = promise;
1224
- return promise;
1225
- }
1226
- async getComponent(assistantId, agentName) {
1227
- return UiClient.getOrCached(`${this.apiUrl}-${assistantId}-${agentName}`, async () => {
1228
- let [url, init] = this.prepareFetchOptions(`/ui/${assistantId}`, {
1229
- headers: {
1230
- Accept: "text/html",
1231
- "Content-Type": "application/json"
1232
- },
1233
- method: "POST",
1234
- json: { name: agentName }
1235
- });
1236
- if (this.onRequest != null) init = await this.onRequest(url, init);
1237
- return (await this.asyncCaller.fetch(url.toString(), init)).text();
1238
- });
1239
- }
1240
- };
1241
- var Client = class {
1242
- /**
1243
- * The client for interacting with assistants.
1244
- */
1245
- assistants;
1246
- /**
1247
- * The client for interacting with threads.
1248
- */
1249
- threads;
1250
- /**
1251
- * The client for interacting with runs.
1252
- */
1253
- runs;
1254
- /**
1255
- * The client for interacting with cron runs.
1256
- */
1257
- crons;
1258
- /**
1259
- * The client for interacting with the KV store.
1260
- */
1261
- store;
1262
- /**
1263
- * The client for interacting with the UI.
1264
- * @internal Used by LoadExternalComponent and the API might change in the future.
1265
- */
1266
- "~ui";
1267
- /**
1268
- * @internal Used to obtain a stable key representing the client.
1269
- */
1270
- "~configHash";
1271
- constructor(config) {
1272
- this["~configHash"] = JSON.stringify({
1273
- apiUrl: config?.apiUrl,
1274
- apiKey: config?.apiKey,
1275
- timeoutMs: config?.timeoutMs,
1276
- defaultHeaders: config?.defaultHeaders,
1277
- maxConcurrency: config?.callerOptions?.maxConcurrency,
1278
- maxRetries: config?.callerOptions?.maxRetries,
1279
- callbacks: {
1280
- onFailedResponseHook: config?.callerOptions?.onFailedResponseHook != null,
1281
- onRequest: config?.onRequest != null,
1282
- fetch: config?.callerOptions?.fetch != null
1283
- }
1284
- });
1285
- this.assistants = new AssistantsClient(config);
1286
- this.threads = new ThreadsClient(config);
1287
- this.runs = new RunsClient(config);
1288
- this.crons = new CronsClient(config);
1289
- this.store = new StoreClient(config);
1290
- this["~ui"] = new UiClient(config);
1291
- }
1292
- };
1293
- /**
1294
- * @internal Used to obtain a stable key representing the client.
1295
- */
1296
- function getClientConfigHash(client) {
1297
- return client["~configHash"];
1298
- }
1299
- //#endregion
1300
- exports.AssistantsClient = AssistantsClient;
1301
- exports.Client = Client;
1302
- exports.CronsClient = CronsClient;
1303
- exports.RunsClient = RunsClient;
1304
- exports.StoreClient = StoreClient;
1305
- exports.ThreadsClient = ThreadsClient;
1306
- exports.getApiKey = getApiKey;
1307
- exports.getClientConfigHash = getClientConfigHash;
1308
-
1309
- //# sourceMappingURL=client.cjs.map
2
+ const require_base = require("./client/base.cjs");
3
+ const require_index = require("./client/assistants/index.cjs");
4
+ const require_subscription = require("./client/stream/subscription.cjs");
5
+ const require_messages = require("./client/stream/messages.cjs");
6
+ const require_media = require("./client/stream/media.cjs");
7
+ const require_error = require("./client/stream/error.cjs");
8
+ const require_index$1 = require("./client/stream/index.cjs");
9
+ const require_http = require("./client/stream/transport/http.cjs");
10
+ const require_websocket = require("./client/stream/transport/websocket.cjs");
11
+ const require_index$2 = require("./client/threads/index.cjs");
12
+ const require_index$3 = require("./client/runs/index.cjs");
13
+ const require_index$4 = require("./client/crons/index.cjs");
14
+ const require_index$5 = require("./client/store/index.cjs");
15
+ const require_agent_server = require("./client/stream/transport/agent-server.cjs");
16
+ const require_index$6 = require("./client/index.cjs");
17
+ exports.AssistantsClient = require_index.AssistantsClient;
18
+ exports.BaseClient = require_base.BaseClient;
19
+ exports.Client = require_index$6.Client;
20
+ exports.CronsClient = require_index$4.CronsClient;
21
+ exports.HttpAgentServerAdapter = require_agent_server.HttpAgentServerAdapter;
22
+ exports.MediaAssembler = require_media.MediaAssembler;
23
+ exports.MediaAssemblyError = require_media.MediaAssemblyError;
24
+ exports.MessageAssembler = require_messages.MessageAssembler;
25
+ exports.ProtocolError = require_error.ProtocolError;
26
+ exports.ProtocolSseTransportAdapter = require_http.ProtocolSseTransportAdapter;
27
+ exports.ProtocolWebSocketTransportAdapter = require_websocket.ProtocolWebSocketTransportAdapter;
28
+ exports.RunsClient = require_index$3.RunsClient;
29
+ exports.StoreClient = require_index$5.StoreClient;
30
+ exports.SubscriptionHandle = require_index$1.SubscriptionHandle;
31
+ exports.ThreadStream = require_index$1.ThreadStream;
32
+ exports.ThreadsClient = require_index$2.ThreadsClient;
33
+ exports.getApiKey = require_base.getApiKey;
34
+ exports.getClientConfigHash = require_index$6.getClientConfigHash;
35
+ exports.inferChannel = require_subscription.inferChannel;
36
+ exports.matchesSubscription = require_subscription.matchesSubscription;