langgraph-ui-components 0.0.10 → 0.0.11-testing

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 (393) hide show
  1. package/dist/index.es.js +3 -2
  2. package/dist/index.es10.js +25 -6
  3. package/dist/index.es10.js.map +1 -1
  4. package/dist/index.es100.js +131 -64
  5. package/dist/index.es100.js.map +1 -1
  6. package/dist/index.es101.js +65 -32
  7. package/dist/index.es101.js.map +1 -1
  8. package/dist/index.es102.js +34 -34
  9. package/dist/index.es102.js.map +1 -1
  10. package/dist/index.es103.js +35 -164
  11. package/dist/index.es103.js.map +1 -1
  12. package/dist/index.es104.js +156 -193
  13. package/dist/index.es104.js.map +1 -1
  14. package/dist/index.es105.js +202 -13
  15. package/dist/index.es105.js.map +1 -1
  16. package/dist/index.es106.js +13 -29
  17. package/dist/index.es106.js.map +1 -1
  18. package/dist/index.es107.js +25 -29
  19. package/dist/index.es107.js.map +1 -1
  20. package/dist/index.es108.js +24 -3147
  21. package/dist/index.es108.js.map +1 -1
  22. package/dist/index.es109.js +3151 -31
  23. package/dist/index.es109.js.map +1 -1
  24. package/dist/index.es110.js +21 -5
  25. package/dist/index.es110.js.map +1 -1
  26. package/dist/index.es111.js +64 -69
  27. package/dist/index.es111.js.map +1 -1
  28. package/dist/index.es112.js +3 -37
  29. package/dist/index.es112.js.map +1 -1
  30. package/dist/index.es113.js +16 -5
  31. package/dist/index.es113.js.map +1 -1
  32. package/dist/index.es114.js +7 -2
  33. package/dist/index.es114.js.map +1 -1
  34. package/dist/index.es115.js +2 -13
  35. package/dist/index.es115.js.map +1 -1
  36. package/dist/index.es116.js +9 -499
  37. package/dist/index.es116.js.map +1 -1
  38. package/dist/index.es117.js +501 -5
  39. package/dist/index.es117.js.map +1 -1
  40. package/dist/index.es118.js +7 -2
  41. package/dist/index.es118.js.map +1 -1
  42. package/dist/index.es119.js +2 -148
  43. package/dist/index.es119.js.map +1 -1
  44. package/dist/index.es120.js +118 -878
  45. package/dist/index.es120.js.map +1 -1
  46. package/dist/index.es121.js +877 -251
  47. package/dist/index.es121.js.map +1 -1
  48. package/dist/index.es122.js +281 -3
  49. package/dist/index.es122.js.map +1 -1
  50. package/dist/index.es123.js +3 -445
  51. package/dist/index.es123.js.map +1 -1
  52. package/dist/index.es124.js +437 -39
  53. package/dist/index.es124.js.map +1 -1
  54. package/dist/index.es125.js +46 -22
  55. package/dist/index.es125.js.map +1 -1
  56. package/dist/index.es126.js +21 -78
  57. package/dist/index.es126.js.map +1 -1
  58. package/dist/index.es127.js +76 -126
  59. package/dist/index.es127.js.map +1 -1
  60. package/dist/index.es128.js +125 -45
  61. package/dist/index.es128.js.map +1 -1
  62. package/dist/index.es129.js +48 -9
  63. package/dist/index.es129.js.map +1 -1
  64. package/dist/index.es130.js +10 -45
  65. package/dist/index.es130.js.map +1 -1
  66. package/dist/index.es131.js +43 -97
  67. package/dist/index.es131.js.map +1 -1
  68. package/dist/index.es132.js +94 -48
  69. package/dist/index.es132.js.map +1 -1
  70. package/dist/index.es133.js +51 -14
  71. package/dist/index.es133.js.map +1 -1
  72. package/dist/index.es134.js +1 -1
  73. package/dist/index.es135.js +1 -1
  74. package/dist/index.es138.js +1 -1
  75. package/dist/index.es139.js +1 -1
  76. package/dist/index.es140.js +1 -1
  77. package/dist/index.es141.js +1 -1
  78. package/dist/index.es142.js +1 -1
  79. package/dist/index.es143.js +1 -1
  80. package/dist/index.es144.js +1 -1
  81. package/dist/index.es145.js +1 -1
  82. package/dist/index.es146.js +1 -1
  83. package/dist/index.es147.js +1 -1
  84. package/dist/index.es148.js +1 -1
  85. package/dist/index.es149.js +1 -1
  86. package/dist/index.es150.js +1 -1
  87. package/dist/index.es151.js +1 -1
  88. package/dist/index.es152.js +1 -1
  89. package/dist/index.es153.js +1 -1
  90. package/dist/index.es154.js +1 -1
  91. package/dist/index.es155.js +1 -1
  92. package/dist/index.es156.js +1 -1
  93. package/dist/index.es157.js +1 -1
  94. package/dist/index.es158.js +1 -1
  95. package/dist/index.es159.js +1 -1
  96. package/dist/index.es16.js +3 -3
  97. package/dist/index.es16.js.map +1 -1
  98. package/dist/index.es160.js +1 -1
  99. package/dist/index.es161.js +1 -1
  100. package/dist/index.es162.js +1 -1
  101. package/dist/index.es163.js +1 -1
  102. package/dist/index.es164.js +1 -1
  103. package/dist/index.es165.js +1 -1
  104. package/dist/index.es166.js +1 -1
  105. package/dist/index.es167.js +1 -1
  106. package/dist/index.es168.js +1 -1
  107. package/dist/index.es169.js +1 -1
  108. package/dist/index.es170.js +1 -1
  109. package/dist/index.es171.js +1 -1
  110. package/dist/index.es172.js +1 -1
  111. package/dist/index.es173.js +1 -1
  112. package/dist/index.es174.js +1 -1
  113. package/dist/index.es175.js +1 -1
  114. package/dist/index.es176.js +1 -1
  115. package/dist/index.es177.js +1 -1
  116. package/dist/index.es178.js +1 -1
  117. package/dist/index.es179.js +1 -1
  118. package/dist/index.es18.js +15 -15
  119. package/dist/index.es180.js +1 -1
  120. package/dist/index.es181.js +1 -1
  121. package/dist/index.es182.js +1 -1
  122. package/dist/index.es183.js +162 -13
  123. package/dist/index.es183.js.map +1 -1
  124. package/dist/index.es184.js +2 -89
  125. package/dist/index.es184.js.map +1 -1
  126. package/dist/index.es185.js +15 -2
  127. package/dist/index.es185.js.map +1 -1
  128. package/dist/index.es186.js +89 -2
  129. package/dist/index.es186.js.map +1 -1
  130. package/dist/index.es187.js +2 -2
  131. package/dist/index.es188.js +56 -2
  132. package/dist/index.es188.js.map +1 -1
  133. package/dist/index.es189.js +100 -2
  134. package/dist/index.es189.js.map +1 -1
  135. package/dist/index.es190.js +191 -2
  136. package/dist/index.es190.js.map +1 -1
  137. package/dist/index.es191.js +110 -2
  138. package/dist/index.es191.js.map +1 -1
  139. package/dist/index.es192.js +35 -2
  140. package/dist/index.es192.js.map +1 -1
  141. package/dist/index.es193.js +10 -2
  142. package/dist/index.es193.js.map +1 -1
  143. package/dist/index.es194.js +11 -2
  144. package/dist/index.es194.js.map +1 -1
  145. package/dist/index.es195.js +12 -2
  146. package/dist/index.es195.js.map +1 -1
  147. package/dist/index.es196.js +91 -2
  148. package/dist/index.es196.js.map +1 -1
  149. package/dist/index.es197.js +275 -2
  150. package/dist/index.es197.js.map +1 -1
  151. package/dist/index.es198.js +2 -2
  152. package/dist/index.es199.js +164 -2
  153. package/dist/index.es199.js.map +1 -1
  154. package/dist/index.es200.js +51 -2
  155. package/dist/index.es200.js.map +1 -1
  156. package/dist/index.es201.js +40 -2
  157. package/dist/index.es201.js.map +1 -1
  158. package/dist/index.es202.js +35 -2
  159. package/dist/index.es202.js.map +1 -1
  160. package/dist/index.es203.js +40 -2
  161. package/dist/index.es203.js.map +1 -1
  162. package/dist/index.es204.js +24 -2
  163. package/dist/index.es204.js.map +1 -1
  164. package/dist/index.es205.js +591 -2
  165. package/dist/index.es205.js.map +1 -1
  166. package/dist/index.es206.js +125 -2
  167. package/dist/index.es206.js.map +1 -1
  168. package/dist/index.es207.js +2 -2
  169. package/dist/index.es208.js +2 -2
  170. package/dist/index.es209.js +2 -2
  171. package/dist/index.es210.js +2 -2
  172. package/dist/index.es211.js +2 -2
  173. package/dist/index.es212.js +2 -2
  174. package/dist/index.es213.js +2 -2
  175. package/dist/index.es214.js +2 -2
  176. package/dist/index.es215.js +2 -2
  177. package/dist/index.es216.js +2 -2
  178. package/dist/index.es217.js +2 -2
  179. package/dist/index.es218.js +2 -2
  180. package/dist/index.es219.js +2 -2
  181. package/dist/index.es220.js +2 -2
  182. package/dist/index.es221.js +2 -2
  183. package/dist/index.es222.js +2 -2
  184. package/dist/index.es223.js +2 -2
  185. package/dist/index.es224.js +2 -2
  186. package/dist/index.es225.js +2 -2
  187. package/dist/index.es226.js +2 -2
  188. package/dist/index.es227.js +2 -2
  189. package/dist/index.es228.js +2 -2
  190. package/dist/index.es229.js +2 -2
  191. package/dist/index.es230.js +2 -2
  192. package/dist/index.es231.js +2 -56
  193. package/dist/index.es231.js.map +1 -1
  194. package/dist/index.es232.js +2 -100
  195. package/dist/index.es232.js.map +1 -1
  196. package/dist/index.es233.js +2 -191
  197. package/dist/index.es233.js.map +1 -1
  198. package/dist/index.es234.js +2 -110
  199. package/dist/index.es234.js.map +1 -1
  200. package/dist/index.es235.js +2 -35
  201. package/dist/index.es235.js.map +1 -1
  202. package/dist/index.es236.js +2 -10
  203. package/dist/index.es236.js.map +1 -1
  204. package/dist/index.es237.js +2 -11
  205. package/dist/index.es237.js.map +1 -1
  206. package/dist/index.es238.js +2 -12
  207. package/dist/index.es238.js.map +1 -1
  208. package/dist/index.es239.js +2 -91
  209. package/dist/index.es239.js.map +1 -1
  210. package/dist/index.es24.js +1 -1
  211. package/dist/index.es240.js +2 -275
  212. package/dist/index.es240.js.map +1 -1
  213. package/dist/index.es241.js +2 -2
  214. package/dist/index.es242.js +2 -164
  215. package/dist/index.es242.js.map +1 -1
  216. package/dist/index.es243.js +2 -51
  217. package/dist/index.es243.js.map +1 -1
  218. package/dist/index.es244.js +2 -40
  219. package/dist/index.es244.js.map +1 -1
  220. package/dist/index.es245.js +2 -35
  221. package/dist/index.es245.js.map +1 -1
  222. package/dist/index.es246.js +2 -40
  223. package/dist/index.es246.js.map +1 -1
  224. package/dist/index.es247.js +2 -24
  225. package/dist/index.es247.js.map +1 -1
  226. package/dist/index.es248.js +2 -591
  227. package/dist/index.es248.js.map +1 -1
  228. package/dist/index.es249.js +2 -125
  229. package/dist/index.es249.js.map +1 -1
  230. package/dist/index.es25.js +3 -1
  231. package/dist/index.es25.js.map +1 -1
  232. package/dist/index.es250.js +2 -164
  233. package/dist/index.es250.js.map +1 -1
  234. package/dist/index.es251.js +2 -2
  235. package/dist/index.es252.js +2 -2
  236. package/dist/index.es253.js +1 -1
  237. package/dist/index.es258.js +1 -1
  238. package/dist/index.es260.js +2 -2
  239. package/dist/index.es262.js +2 -2
  240. package/dist/index.es265.js +1 -1
  241. package/dist/index.es267.js +1 -1
  242. package/dist/index.es277.js +2 -147
  243. package/dist/index.es277.js.map +1 -1
  244. package/dist/index.es278.js +126 -167
  245. package/dist/index.es278.js.map +1 -1
  246. package/dist/index.es279.js +188 -2
  247. package/dist/index.es279.js.map +1 -1
  248. package/dist/index.es280.js +1 -1
  249. package/dist/index.es283.js +1 -1
  250. package/dist/index.es288.js +1 -1
  251. package/dist/index.es29.js +1 -1
  252. package/dist/index.es3.js +24 -9
  253. package/dist/index.es3.js.map +1 -1
  254. package/dist/index.es300.js +1 -1
  255. package/dist/index.es302.js +1 -1
  256. package/dist/index.es31.js +7 -7
  257. package/dist/index.es314.js +1 -1
  258. package/dist/index.es32.js +1 -1
  259. package/dist/index.es334.js +2 -2
  260. package/dist/index.es35.js +4 -4
  261. package/dist/index.es36.js +1185 -111
  262. package/dist/index.es36.js.map +1 -1
  263. package/dist/index.es37.js +7 -71
  264. package/dist/index.es37.js.map +1 -1
  265. package/dist/index.es38.js +9 -18
  266. package/dist/index.es38.js.map +1 -1
  267. package/dist/index.es39.js +136 -250
  268. package/dist/index.es39.js.map +1 -1
  269. package/dist/index.es4.js +2 -1
  270. package/dist/index.es4.js.map +1 -1
  271. package/dist/index.es40.js +116 -41
  272. package/dist/index.es40.js.map +1 -1
  273. package/dist/index.es41.js +64 -208
  274. package/dist/index.es41.js.map +1 -1
  275. package/dist/index.es42.js +17 -66
  276. package/dist/index.es42.js.map +1 -1
  277. package/dist/index.es43.js +236 -117
  278. package/dist/index.es43.js.map +1 -1
  279. package/dist/index.es44.js +38 -19
  280. package/dist/index.es44.js.map +1 -1
  281. package/dist/index.es45.js +202 -217
  282. package/dist/index.es45.js.map +1 -1
  283. package/dist/index.es46.js +65 -7
  284. package/dist/index.es46.js.map +1 -1
  285. package/dist/index.es47.js +131 -1181
  286. package/dist/index.es47.js.map +1 -1
  287. package/dist/index.es48.js +25 -8
  288. package/dist/index.es48.js.map +1 -1
  289. package/dist/index.es49.js +218 -135
  290. package/dist/index.es49.js.map +1 -1
  291. package/dist/index.es5.js.map +1 -1
  292. package/dist/index.es50.js +5 -208
  293. package/dist/index.es50.js.map +1 -1
  294. package/dist/index.es51.js +208 -5
  295. package/dist/index.es51.js.map +1 -1
  296. package/dist/index.es52.js +90 -7
  297. package/dist/index.es52.js.map +1 -1
  298. package/dist/index.es53.js +6 -92
  299. package/dist/index.es53.js.map +1 -1
  300. package/dist/index.es54.js +14 -3
  301. package/dist/index.es54.js.map +1 -1
  302. package/dist/index.es55.js +8 -36
  303. package/dist/index.es55.js.map +1 -1
  304. package/dist/index.es56.js +83 -61
  305. package/dist/index.es56.js.map +1 -1
  306. package/dist/index.es57.js +3 -37
  307. package/dist/index.es57.js.map +1 -1
  308. package/dist/index.es58.js +34 -304
  309. package/dist/index.es58.js.map +1 -1
  310. package/dist/index.es59.js +72 -9
  311. package/dist/index.es59.js.map +1 -1
  312. package/dist/index.es60.js +32 -85
  313. package/dist/index.es60.js.map +1 -1
  314. package/dist/index.es61.js +304 -6
  315. package/dist/index.es61.js.map +1 -1
  316. package/dist/index.es62.js +9 -15
  317. package/dist/index.es62.js.map +1 -1
  318. package/dist/index.es63.js +3 -3
  319. package/dist/index.es64.js +5 -142
  320. package/dist/index.es64.js.map +1 -1
  321. package/dist/index.es65.js +148 -285
  322. package/dist/index.es65.js.map +1 -1
  323. package/dist/index.es66.js +668 -62
  324. package/dist/index.es66.js.map +1 -1
  325. package/dist/index.es67.js +131 -201
  326. package/dist/index.es67.js.map +1 -1
  327. package/dist/index.es68.js +295 -29
  328. package/dist/index.es68.js.map +1 -1
  329. package/dist/index.es69.js +65 -8
  330. package/dist/index.es69.js.map +1 -1
  331. package/dist/index.es7.js +2 -1
  332. package/dist/index.es7.js.map +1 -1
  333. package/dist/index.es70.js +210 -9
  334. package/dist/index.es70.js.map +1 -1
  335. package/dist/index.es71.js +28 -181
  336. package/dist/index.es71.js.map +1 -1
  337. package/dist/index.es72.js +8 -23
  338. package/dist/index.es72.js.map +1 -1
  339. package/dist/index.es73.js +9 -1397
  340. package/dist/index.es73.js.map +1 -1
  341. package/dist/index.es74.js +187 -9
  342. package/dist/index.es74.js.map +1 -1
  343. package/dist/index.es75.js +24 -8
  344. package/dist/index.es75.js.map +1 -1
  345. package/dist/index.es76.js +1399 -5
  346. package/dist/index.es76.js.map +1 -1
  347. package/dist/index.es77.js +9 -163
  348. package/dist/index.es77.js.map +1 -1
  349. package/dist/index.es78.js +8 -672
  350. package/dist/index.es78.js.map +1 -1
  351. package/dist/index.es79.js +36 -20
  352. package/dist/index.es79.js.map +1 -1
  353. package/dist/index.es80.js +5 -68
  354. package/dist/index.es80.js.map +1 -1
  355. package/dist/index.es81.js +73 -3
  356. package/dist/index.es81.js.map +1 -1
  357. package/dist/index.es82.js +36 -11
  358. package/dist/index.es82.js.map +1 -1
  359. package/dist/index.es83.js +10 -38
  360. package/dist/index.es83.js.map +1 -1
  361. package/dist/index.es84.js +34 -28
  362. package/dist/index.es84.js.map +1 -1
  363. package/dist/index.es85.js +28 -226
  364. package/dist/index.es85.js.map +1 -1
  365. package/dist/index.es86.js +228 -26
  366. package/dist/index.es86.js.map +1 -1
  367. package/dist/index.es87.js +26 -71
  368. package/dist/index.es87.js.map +1 -1
  369. package/dist/index.es88.js +41 -42
  370. package/dist/index.es88.js.map +1 -1
  371. package/dist/index.es89.js +71 -47
  372. package/dist/index.es89.js.map +1 -1
  373. package/dist/index.es90.js +37 -15
  374. package/dist/index.es90.js.map +1 -1
  375. package/dist/index.es91.js +6 -19
  376. package/dist/index.es91.js.map +1 -1
  377. package/dist/index.es92.js +40 -54
  378. package/dist/index.es92.js.map +1 -1
  379. package/dist/index.es93.js +56 -12
  380. package/dist/index.es93.js.map +1 -1
  381. package/dist/index.es94.js +13 -137
  382. package/dist/index.es94.js.map +1 -1
  383. package/dist/index.es95.js +135 -19
  384. package/dist/index.es95.js.map +1 -1
  385. package/dist/index.es96.js +18 -179
  386. package/dist/index.es96.js.map +1 -1
  387. package/dist/index.es97.js +163 -222
  388. package/dist/index.es97.js.map +1 -1
  389. package/dist/index.es98.js +187 -301
  390. package/dist/index.es98.js.map +1 -1
  391. package/dist/index.es99.js +348 -130
  392. package/dist/index.es99.js.map +1 -1
  393. package/package.json +1 -1
@@ -1,15 +1,216 @@
1
- function _isToolCall(toolCall) {
2
- return !!(toolCall && typeof toolCall === "object" && "type" in toolCall && toolCall.type === "tool_call");
1
+ import { _isObject, _isArray, _isString, _isContentBlock, iife } from "./index.es85.js";
2
+ import { isOpenAIDataBlock, convertToV1FromOpenAIDataBlock } from "./index.es69.js";
3
+ function convertToV1FromChatCompletions(message) {
4
+ const blocks = [];
5
+ if (typeof message.content === "string") blocks.push({
6
+ type: "text",
7
+ text: message.content
8
+ });
9
+ else blocks.push(...convertToV1FromChatCompletionsInput(message.content));
10
+ for (const toolCall of message.tool_calls ?? []) blocks.push({
11
+ type: "tool_call",
12
+ id: toolCall.id,
13
+ name: toolCall.name,
14
+ args: toolCall.args
15
+ });
16
+ return blocks;
3
17
  }
4
- var ToolInputParsingException = class extends Error {
5
- output;
6
- constructor(message, output) {
7
- super(message);
8
- this.output = output;
18
+ function convertToV1FromChatCompletionsChunk(message) {
19
+ const blocks = [];
20
+ if (typeof message.content === "string") blocks.push({
21
+ type: "text",
22
+ text: message.content
23
+ });
24
+ else blocks.push(...convertToV1FromChatCompletionsInput(message.content));
25
+ for (const toolCall of message.tool_calls ?? []) blocks.push({
26
+ type: "tool_call",
27
+ id: toolCall.id,
28
+ name: toolCall.name,
29
+ args: toolCall.args
30
+ });
31
+ return blocks;
32
+ }
33
+ function convertToV1FromChatCompletionsInput(blocks) {
34
+ const convertedBlocks = [];
35
+ for (const block of blocks) if (isOpenAIDataBlock(block)) convertedBlocks.push(convertToV1FromOpenAIDataBlock(block));
36
+ else convertedBlocks.push(block);
37
+ return convertedBlocks;
38
+ }
39
+ function convertResponsesAnnotation(annotation) {
40
+ if (annotation.type === "url_citation") {
41
+ const { url, title, start_index, end_index } = annotation;
42
+ return {
43
+ type: "citation",
44
+ url,
45
+ title,
46
+ startIndex: start_index,
47
+ endIndex: end_index
48
+ };
49
+ }
50
+ if (annotation.type === "file_citation") {
51
+ const { file_id, filename, index } = annotation;
52
+ return {
53
+ type: "citation",
54
+ title: filename,
55
+ startIndex: index,
56
+ endIndex: index,
57
+ fileId: file_id
58
+ };
59
+ }
60
+ return annotation;
61
+ }
62
+ function convertToV1FromResponses(message) {
63
+ function* iterateContent() {
64
+ if (_isObject(message.additional_kwargs?.reasoning) && _isArray(message.additional_kwargs.reasoning.summary)) {
65
+ const summary = message.additional_kwargs.reasoning.summary.reduce((acc, item) => {
66
+ if (_isObject(item) && _isString(item.text)) return `${acc}${item.text}`;
67
+ return acc;
68
+ }, "");
69
+ yield {
70
+ type: "reasoning",
71
+ reasoning: summary
72
+ };
73
+ }
74
+ const content = typeof message.content === "string" ? [{
75
+ type: "text",
76
+ text: message.content
77
+ }] : message.content;
78
+ for (const block of content) if (_isContentBlock(block, "text")) {
79
+ const { text, annotations, ...rest } = block;
80
+ if (Array.isArray(annotations)) yield {
81
+ ...rest,
82
+ type: "text",
83
+ text: String(text),
84
+ annotations: annotations.map(convertResponsesAnnotation)
85
+ };
86
+ else yield {
87
+ ...rest,
88
+ type: "text",
89
+ text: String(text)
90
+ };
91
+ }
92
+ for (const toolCall of message.tool_calls ?? []) yield {
93
+ type: "tool_call",
94
+ id: toolCall.id,
95
+ name: toolCall.name,
96
+ args: toolCall.args
97
+ };
98
+ if (_isObject(message.additional_kwargs) && _isArray(message.additional_kwargs.tool_outputs)) for (const toolOutput of message.additional_kwargs.tool_outputs) {
99
+ if (_isContentBlock(toolOutput, "web_search_call")) {
100
+ yield {
101
+ id: toolOutput.id,
102
+ type: "server_tool_call",
103
+ name: "web_search",
104
+ args: { query: toolOutput.query }
105
+ };
106
+ continue;
107
+ } else if (_isContentBlock(toolOutput, "file_search_call")) {
108
+ yield {
109
+ id: toolOutput.id,
110
+ type: "server_tool_call",
111
+ name: "file_search",
112
+ args: { query: toolOutput.query }
113
+ };
114
+ continue;
115
+ } else if (_isContentBlock(toolOutput, "computer_call")) {
116
+ yield {
117
+ type: "non_standard",
118
+ value: toolOutput
119
+ };
120
+ continue;
121
+ } else if (_isContentBlock(toolOutput, "code_interpreter_call")) {
122
+ if (_isString(toolOutput.code)) yield {
123
+ id: toolOutput.id,
124
+ type: "server_tool_call",
125
+ name: "code_interpreter",
126
+ args: { code: toolOutput.code }
127
+ };
128
+ if (_isArray(toolOutput.outputs)) {
129
+ const returnCode = iife(() => {
130
+ if (toolOutput.status === "in_progress") return void 0;
131
+ if (toolOutput.status === "completed") return 0;
132
+ if (toolOutput.status === "incomplete") return 127;
133
+ if (toolOutput.status === "interpreting") return void 0;
134
+ if (toolOutput.status === "failed") return 1;
135
+ return void 0;
136
+ });
137
+ for (const output of toolOutput.outputs) if (_isContentBlock(output, "logs")) {
138
+ yield {
139
+ type: "server_tool_call_result",
140
+ toolCallId: toolOutput.id ?? "",
141
+ status: "success",
142
+ output: {
143
+ type: "code_interpreter_output",
144
+ returnCode: returnCode ?? 0,
145
+ stderr: [0, void 0].includes(returnCode) ? void 0 : String(output.logs),
146
+ stdout: [0, void 0].includes(returnCode) ? String(output.logs) : void 0
147
+ }
148
+ };
149
+ continue;
150
+ }
151
+ }
152
+ continue;
153
+ } else if (_isContentBlock(toolOutput, "mcp_call")) {
154
+ yield {
155
+ id: toolOutput.id,
156
+ type: "server_tool_call",
157
+ name: "mcp_call",
158
+ args: toolOutput.input
159
+ };
160
+ continue;
161
+ } else if (_isContentBlock(toolOutput, "mcp_list_tools")) {
162
+ yield {
163
+ id: toolOutput.id,
164
+ type: "server_tool_call",
165
+ name: "mcp_list_tools",
166
+ args: toolOutput.input
167
+ };
168
+ continue;
169
+ } else if (_isContentBlock(toolOutput, "mcp_approval_request")) {
170
+ yield {
171
+ type: "non_standard",
172
+ value: toolOutput
173
+ };
174
+ continue;
175
+ } else if (_isContentBlock(toolOutput, "image_generation_call")) {
176
+ yield {
177
+ type: "non_standard",
178
+ value: toolOutput
179
+ };
180
+ continue;
181
+ }
182
+ if (_isObject(toolOutput)) yield {
183
+ type: "non_standard",
184
+ value: toolOutput
185
+ };
186
+ }
187
+ }
188
+ return Array.from(iterateContent());
189
+ }
190
+ function convertToV1FromResponsesChunk(message) {
191
+ function* iterateContent() {
192
+ yield* convertToV1FromResponses(message);
193
+ for (const toolCallChunk of message.tool_call_chunks ?? []) yield {
194
+ type: "tool_call_chunk",
195
+ id: toolCallChunk.id,
196
+ name: toolCallChunk.name,
197
+ args: toolCallChunk.args
198
+ };
199
+ }
200
+ return Array.from(iterateContent());
201
+ }
202
+ const ChatOpenAITranslator = {
203
+ translateContent: (message) => {
204
+ if (typeof message.content === "string") return convertToV1FromChatCompletions(message);
205
+ return convertToV1FromResponses(message);
206
+ },
207
+ translateContentChunk: (message) => {
208
+ if (typeof message.content === "string") return convertToV1FromChatCompletionsChunk(message);
209
+ return convertToV1FromResponsesChunk(message);
9
210
  }
10
211
  };
11
212
  export {
12
- ToolInputParsingException,
13
- _isToolCall
213
+ ChatOpenAITranslator,
214
+ convertToV1FromChatCompletionsInput
14
215
  };
15
216
  //# sourceMappingURL=index.es70.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es70.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tools/utils.js"],"sourcesContent":["//#region src/tools/utils.ts\nfunction _isToolCall(toolCall) {\n\treturn !!(toolCall && typeof toolCall === \"object\" && \"type\" in toolCall && toolCall.type === \"tool_call\");\n}\nfunction _configHasToolCallId(config) {\n\treturn !!(config && typeof config === \"object\" && \"toolCall\" in config && config.toolCall != null && typeof config.toolCall === \"object\" && \"id\" in config.toolCall && typeof config.toolCall.id === \"string\");\n}\n/**\n* Custom error class used to handle exceptions related to tool input parsing.\n* It extends the built-in `Error` class and adds an optional `output`\n* property that can hold the output that caused the exception.\n*/\nvar ToolInputParsingException = class extends Error {\n\toutput;\n\tconstructor(message, output) {\n\t\tsuper(message);\n\t\tthis.output = output;\n\t}\n};\n\n//#endregion\nexport { ToolInputParsingException, _configHasToolCallId, _isToolCall };\n//# sourceMappingURL=utils.js.map"],"names":[],"mappings":"AACA,SAAS,YAAY,UAAU;AAC9B,SAAO,CAAC,EAAE,YAAY,OAAO,aAAa,YAAY,UAAU,YAAY,SAAS,SAAS;AAC/F;AASG,IAAC,4BAA4B,cAAc,MAAM;AAAA,EACnD;AAAA,EACA,YAAY,SAAS,QAAQ;AAC5B,UAAM,OAAO;AACb,SAAK,SAAS;AAAA,EACf;AACD;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es70.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/messages/block_translators/openai.js"],"sourcesContent":["import { _isArray, _isContentBlock, _isObject, _isString, iife } from \"./utils.js\";\nimport { convertToV1FromOpenAIDataBlock, isOpenAIDataBlock } from \"./data.js\";\n\n//#region src/messages/block_translators/openai.ts\n/**\n* Converts a ChatOpenAICompletions message to an array of v1 standard content blocks.\n*\n* This function processes an AI message from ChatOpenAICompletions API format\n* and converts it to the standardized v1 content block format. It handles both\n* string content and structured content blocks, as well as tool calls.\n*\n* @param message - The AI message containing ChatOpenAICompletions formatted content\n* @returns Array of content blocks in v1 standard format\n*\n* @example\n* ```typescript\n* const message = new AIMessage(\"Hello world\");\n* const standardBlocks = convertToV1FromChatCompletions(message);\n* // Returns: [{ type: \"text\", text: \"Hello world\" }]\n* ```\n*\n* @example\n* ```typescript\n* const message = new AIMessage([\n* { type: \"text\", text: \"Hello\" },\n* { type: \"image_url\", image_url: { url: \"https://example.com/image.png\" } }\n* ]);\n* message.tool_calls = [\n* { id: \"call_123\", name: \"calculator\", args: { a: 1, b: 2 } }\n* ];\n*\n* const standardBlocks = convertToV1FromChatCompletions(message);\n* // Returns:\n* // [\n* // { type: \"text\", text: \"Hello\" },\n* // { type: \"image\", url: \"https://example.com/image.png\" },\n* // { type: \"tool_call\", id: \"call_123\", name: \"calculator\", args: { a: 1, b: 2 } }\n* // ]\n* ```\n*/\nfunction convertToV1FromChatCompletions(message) {\n\tconst blocks = [];\n\tif (typeof message.content === \"string\") blocks.push({\n\t\ttype: \"text\",\n\t\ttext: message.content\n\t});\n\telse blocks.push(...convertToV1FromChatCompletionsInput(message.content));\n\tfor (const toolCall of message.tool_calls ?? []) blocks.push({\n\t\ttype: \"tool_call\",\n\t\tid: toolCall.id,\n\t\tname: toolCall.name,\n\t\targs: toolCall.args\n\t});\n\treturn blocks;\n}\n/**\n* Converts a ChatOpenAICompletions message chunk to an array of v1 standard content blocks.\n*\n* This function processes an AI message chunk from OpenAI's chat completions API and converts\n* it to the standardized v1 content block format. It handles both string and array content,\n* as well as tool calls that may be present in the chunk.\n*\n* @param message - The AI message chunk containing OpenAI-formatted content blocks\n* @returns Array of content blocks in v1 standard format\n*\n* @example\n* ```typescript\n* const chunk = new AIMessage(\"Hello\");\n* const standardBlocks = convertToV1FromChatCompletionsChunk(chunk);\n* // Returns: [{ type: \"text\", text: \"Hello\" }]\n* ```\n*\n* @example\n* ```typescript\n* const chunk = new AIMessage([\n* { type: \"text\", text: \"Processing...\" }\n* ]);\n* chunk.tool_calls = [\n* { id: \"call_456\", name: \"search\", args: { query: \"test\" } }\n* ];\n*\n* const standardBlocks = convertToV1FromChatCompletionsChunk(chunk);\n* // Returns:\n* // [\n* // { type: \"text\", text: \"Processing...\" },\n* // { type: \"tool_call\", id: \"call_456\", name: \"search\", args: { query: \"test\" } }\n* // ]\n* ```\n*/\nfunction convertToV1FromChatCompletionsChunk(message) {\n\tconst blocks = [];\n\tif (typeof message.content === \"string\") blocks.push({\n\t\ttype: \"text\",\n\t\ttext: message.content\n\t});\n\telse blocks.push(...convertToV1FromChatCompletionsInput(message.content));\n\tfor (const toolCall of message.tool_calls ?? []) blocks.push({\n\t\ttype: \"tool_call\",\n\t\tid: toolCall.id,\n\t\tname: toolCall.name,\n\t\targs: toolCall.args\n\t});\n\treturn blocks;\n}\n/**\n* Converts an array of ChatOpenAICompletions content blocks to v1 standard content blocks.\n*\n* This function processes content blocks from OpenAI's Chat Completions API format\n* and converts them to the standardized v1 content block format. It handles both\n* OpenAI-specific data blocks (which require conversion) and standard blocks\n* (which are passed through with type assertion).\n*\n* @param blocks - Array of content blocks in ChatOpenAICompletions format\n* @returns Array of content blocks in v1 standard format\n*\n* @example\n* ```typescript\n* const openaiBlocks = [\n* { type: \"text\", text: \"Hello world\" },\n* { type: \"image_url\", image_url: { url: \"https://example.com/image.png\" } }\n* ];\n*\n* const standardBlocks = convertToV1FromChatCompletionsInput(openaiBlocks);\n* // Returns:\n* // [\n* // { type: \"text\", text: \"Hello world\" },\n* // { type: \"image\", url: \"https://example.com/image.png\" }\n* // ]\n* ```\n*/\nfunction convertToV1FromChatCompletionsInput(blocks) {\n\tconst convertedBlocks = [];\n\tfor (const block of blocks) if (isOpenAIDataBlock(block)) convertedBlocks.push(convertToV1FromOpenAIDataBlock(block));\n\telse convertedBlocks.push(block);\n\treturn convertedBlocks;\n}\nfunction convertResponsesAnnotation(annotation) {\n\tif (annotation.type === \"url_citation\") {\n\t\tconst { url, title, start_index, end_index } = annotation;\n\t\treturn {\n\t\t\ttype: \"citation\",\n\t\t\turl,\n\t\t\ttitle,\n\t\t\tstartIndex: start_index,\n\t\t\tendIndex: end_index\n\t\t};\n\t}\n\tif (annotation.type === \"file_citation\") {\n\t\tconst { file_id, filename, index } = annotation;\n\t\treturn {\n\t\t\ttype: \"citation\",\n\t\t\ttitle: filename,\n\t\t\tstartIndex: index,\n\t\t\tendIndex: index,\n\t\t\tfileId: file_id\n\t\t};\n\t}\n\treturn annotation;\n}\n/**\n* Converts a ChatOpenAIResponses message to an array of v1 standard content blocks.\n*\n* This function processes an AI message containing OpenAI Responses-specific content blocks\n* and converts them to the standardized v1 content block format. It handles reasoning summaries,\n* text content with annotations, tool calls, and various tool outputs including code interpreter,\n* web search, file search, computer calls, and MCP-related blocks.\n*\n* @param message - The AI message containing OpenAI Responses-formatted content blocks\n* @returns Array of content blocks in v1 standard format\n*\n* @example\n* ```typescript\n* const message = new AIMessage({\n* content: [{ type: \"text\", text: \"Hello world\", annotations: [] }],\n* tool_calls: [{ id: \"123\", name: \"calculator\", args: { a: 1, b: 2 } }],\n* additional_kwargs: {\n* reasoning: { summary: [{ text: \"Let me calculate this...\" }] },\n* tool_outputs: [\n* {\n* type: \"code_interpreter_call\",\n* code: \"print('hello')\",\n* outputs: [{ type: \"logs\", logs: \"hello\" }]\n* }\n* ]\n* }\n* });\n*\n* const standardBlocks = convertToV1FromResponses(message);\n* // Returns:\n* // [\n* // { type: \"reasoning\", reasoning: \"Let me calculate this...\" },\n* // { type: \"text\", text: \"Hello world\", annotations: [] },\n* // { type: \"tool_call\", id: \"123\", name: \"calculator\", args: { a: 1, b: 2 } },\n* // { type: \"code_interpreter_call\", code: \"print('hello')\" },\n* // { type: \"code_interpreter_result\", output: [{ type: \"code_interpreter_output\", returnCode: 0, stdout: \"hello\" }] }\n* // ]\n* ```\n*/\nfunction convertToV1FromResponses(message) {\n\tfunction* iterateContent() {\n\t\tif (_isObject(message.additional_kwargs?.reasoning) && _isArray(message.additional_kwargs.reasoning.summary)) {\n\t\t\tconst summary = message.additional_kwargs.reasoning.summary.reduce((acc, item) => {\n\t\t\t\tif (_isObject(item) && _isString(item.text)) return `${acc}${item.text}`;\n\t\t\t\treturn acc;\n\t\t\t}, \"\");\n\t\t\tyield {\n\t\t\t\ttype: \"reasoning\",\n\t\t\t\treasoning: summary\n\t\t\t};\n\t\t}\n\t\tconst content = typeof message.content === \"string\" ? [{\n\t\t\ttype: \"text\",\n\t\t\ttext: message.content\n\t\t}] : message.content;\n\t\tfor (const block of content) if (_isContentBlock(block, \"text\")) {\n\t\t\tconst { text, annotations,...rest } = block;\n\t\t\tif (Array.isArray(annotations)) yield {\n\t\t\t\t...rest,\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: String(text),\n\t\t\t\tannotations: annotations.map(convertResponsesAnnotation)\n\t\t\t};\n\t\t\telse yield {\n\t\t\t\t...rest,\n\t\t\t\ttype: \"text\",\n\t\t\t\ttext: String(text)\n\t\t\t};\n\t\t}\n\t\tfor (const toolCall of message.tool_calls ?? []) yield {\n\t\t\ttype: \"tool_call\",\n\t\t\tid: toolCall.id,\n\t\t\tname: toolCall.name,\n\t\t\targs: toolCall.args\n\t\t};\n\t\tif (_isObject(message.additional_kwargs) && _isArray(message.additional_kwargs.tool_outputs)) for (const toolOutput of message.additional_kwargs.tool_outputs) {\n\t\t\tif (_isContentBlock(toolOutput, \"web_search_call\")) {\n\t\t\t\tyield {\n\t\t\t\t\tid: toolOutput.id,\n\t\t\t\t\ttype: \"server_tool_call\",\n\t\t\t\t\tname: \"web_search\",\n\t\t\t\t\targs: { query: toolOutput.query }\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"file_search_call\")) {\n\t\t\t\tyield {\n\t\t\t\t\tid: toolOutput.id,\n\t\t\t\t\ttype: \"server_tool_call\",\n\t\t\t\t\tname: \"file_search\",\n\t\t\t\t\targs: { query: toolOutput.query }\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"computer_call\")) {\n\t\t\t\tyield {\n\t\t\t\t\ttype: \"non_standard\",\n\t\t\t\t\tvalue: toolOutput\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"code_interpreter_call\")) {\n\t\t\t\tif (_isString(toolOutput.code)) yield {\n\t\t\t\t\tid: toolOutput.id,\n\t\t\t\t\ttype: \"server_tool_call\",\n\t\t\t\t\tname: \"code_interpreter\",\n\t\t\t\t\targs: { code: toolOutput.code }\n\t\t\t\t};\n\t\t\t\tif (_isArray(toolOutput.outputs)) {\n\t\t\t\t\tconst returnCode = iife(() => {\n\t\t\t\t\t\tif (toolOutput.status === \"in_progress\") return void 0;\n\t\t\t\t\t\tif (toolOutput.status === \"completed\") return 0;\n\t\t\t\t\t\tif (toolOutput.status === \"incomplete\") return 127;\n\t\t\t\t\t\tif (toolOutput.status === \"interpreting\") return void 0;\n\t\t\t\t\t\tif (toolOutput.status === \"failed\") return 1;\n\t\t\t\t\t\treturn void 0;\n\t\t\t\t\t});\n\t\t\t\t\tfor (const output of toolOutput.outputs) if (_isContentBlock(output, \"logs\")) {\n\t\t\t\t\t\tyield {\n\t\t\t\t\t\t\ttype: \"server_tool_call_result\",\n\t\t\t\t\t\t\ttoolCallId: toolOutput.id ?? \"\",\n\t\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\t\toutput: {\n\t\t\t\t\t\t\t\ttype: \"code_interpreter_output\",\n\t\t\t\t\t\t\t\treturnCode: returnCode ?? 0,\n\t\t\t\t\t\t\t\tstderr: [0, void 0].includes(returnCode) ? void 0 : String(output.logs),\n\t\t\t\t\t\t\t\tstdout: [0, void 0].includes(returnCode) ? String(output.logs) : void 0\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"mcp_call\")) {\n\t\t\t\tyield {\n\t\t\t\t\tid: toolOutput.id,\n\t\t\t\t\ttype: \"server_tool_call\",\n\t\t\t\t\tname: \"mcp_call\",\n\t\t\t\t\targs: toolOutput.input\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"mcp_list_tools\")) {\n\t\t\t\tyield {\n\t\t\t\t\tid: toolOutput.id,\n\t\t\t\t\ttype: \"server_tool_call\",\n\t\t\t\t\tname: \"mcp_list_tools\",\n\t\t\t\t\targs: toolOutput.input\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"mcp_approval_request\")) {\n\t\t\t\tyield {\n\t\t\t\t\ttype: \"non_standard\",\n\t\t\t\t\tvalue: toolOutput\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t} else if (_isContentBlock(toolOutput, \"image_generation_call\")) {\n\t\t\t\tyield {\n\t\t\t\t\ttype: \"non_standard\",\n\t\t\t\t\tvalue: toolOutput\n\t\t\t\t};\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (_isObject(toolOutput)) yield {\n\t\t\t\ttype: \"non_standard\",\n\t\t\t\tvalue: toolOutput\n\t\t\t};\n\t\t}\n\t}\n\treturn Array.from(iterateContent());\n}\n/**\n* Converts a ChatOpenAIResponses message chunk to an array of v1 standard content blocks.\n*\n* This function processes an AI message chunk containing OpenAI-specific content blocks\n* and converts them to the standardized v1 content block format. It handles both the\n* regular message content and tool call chunks that are specific to streaming responses.\n*\n* @param message - The AI message chunk containing OpenAI-formatted content blocks\n* @returns Array of content blocks in v1 standard format\n*\n* @example\n* ```typescript\n* const messageChunk = new AIMessageChunk({\n* content: [{ type: \"text\", text: \"Hello\" }],\n* tool_call_chunks: [\n* { id: \"call_123\", name: \"calculator\", args: '{\"a\": 1' }\n* ]\n* });\n*\n* const standardBlocks = convertToV1FromResponsesChunk(messageChunk);\n* // Returns:\n* // [\n* // { type: \"text\", text: \"Hello\" },\n* // { type: \"tool_call_chunk\", id: \"call_123\", name: \"calculator\", args: '{\"a\": 1' }\n* // ]\n* ```\n*/\nfunction convertToV1FromResponsesChunk(message) {\n\tfunction* iterateContent() {\n\t\tyield* convertToV1FromResponses(message);\n\t\tfor (const toolCallChunk of message.tool_call_chunks ?? []) yield {\n\t\t\ttype: \"tool_call_chunk\",\n\t\t\tid: toolCallChunk.id,\n\t\t\tname: toolCallChunk.name,\n\t\t\targs: toolCallChunk.args\n\t\t};\n\t}\n\treturn Array.from(iterateContent());\n}\nconst ChatOpenAITranslator = {\n\ttranslateContent: (message) => {\n\t\tif (typeof message.content === \"string\") return convertToV1FromChatCompletions(message);\n\t\treturn convertToV1FromResponses(message);\n\t},\n\ttranslateContentChunk: (message) => {\n\t\tif (typeof message.content === \"string\") return convertToV1FromChatCompletionsChunk(message);\n\t\treturn convertToV1FromResponsesChunk(message);\n\t}\n};\n\n//#endregion\nexport { ChatOpenAITranslator, convertToV1FromChatCompletionsInput };\n//# sourceMappingURL=openai.js.map"],"names":[],"mappings":";;AAwCA,SAAS,+BAA+B,SAAS;AAChD,QAAM,SAAS,CAAA;AACf,MAAI,OAAO,QAAQ,YAAY,SAAU,QAAO,KAAK;AAAA,IACpD,MAAM;AAAA,IACN,MAAM,QAAQ;AAAA,EAChB,CAAE;AAAA,MACI,QAAO,KAAK,GAAG,oCAAoC,QAAQ,OAAO,CAAC;AACxE,aAAW,YAAY,QAAQ,cAAc,CAAA,EAAI,QAAO,KAAK;AAAA,IAC5D,MAAM;AAAA,IACN,IAAI,SAAS;AAAA,IACb,MAAM,SAAS;AAAA,IACf,MAAM,SAAS;AAAA,EACjB,CAAE;AACD,SAAO;AACR;AAmCA,SAAS,oCAAoC,SAAS;AACrD,QAAM,SAAS,CAAA;AACf,MAAI,OAAO,QAAQ,YAAY,SAAU,QAAO,KAAK;AAAA,IACpD,MAAM;AAAA,IACN,MAAM,QAAQ;AAAA,EAChB,CAAE;AAAA,MACI,QAAO,KAAK,GAAG,oCAAoC,QAAQ,OAAO,CAAC;AACxE,aAAW,YAAY,QAAQ,cAAc,CAAA,EAAI,QAAO,KAAK;AAAA,IAC5D,MAAM;AAAA,IACN,IAAI,SAAS;AAAA,IACb,MAAM,SAAS;AAAA,IACf,MAAM,SAAS;AAAA,EACjB,CAAE;AACD,SAAO;AACR;AA2BA,SAAS,oCAAoC,QAAQ;AACpD,QAAM,kBAAkB,CAAA;AACxB,aAAW,SAAS,OAAQ,KAAI,kBAAkB,KAAK,EAAG,iBAAgB,KAAK,+BAA+B,KAAK,CAAC;AAAA,MAC/G,iBAAgB,KAAK,KAAK;AAC/B,SAAO;AACR;AACA,SAAS,2BAA2B,YAAY;AAC/C,MAAI,WAAW,SAAS,gBAAgB;AACvC,UAAM,EAAE,KAAK,OAAO,aAAa,UAAS,IAAK;AAC/C,WAAO;AAAA,MACN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AAAA,IACvB;AAAA,EACC;AACA,SAAO,MAAM,KAAK,gBAAgB;AACnC;AACK,MAAC,uBAAuB;AAAA,EAC5B,kBAAkB,CAAC,YAAY;AAC9B,QAAI,OAAO,QAAQ,YAAY,SAAU,QAAO,+BAA+B,OAAO;AACtF,WAAO,yBAAyB,OAAO;AAAA,EACxC;AAAA,EACA,uBAAuB,CAAC,YAAY;AACnC,QAAI,OAAO,QAAQ,YAAY,SAAU,QAAO,oCAAoC,OAAO;AAC3F,WAAO,8BAA8B,OAAO;AAAA,EAC7C;AACD;","x_google_ignoreList":[0]}
@@ -1,190 +1,37 @@
1
- function strictParsePartialJson(s) {
2
- try {
3
- return JSON.parse(s);
4
- } catch {
5
- }
6
- const buffer = s.trim();
7
- if (buffer.length === 0) throw new Error("Unexpected end of JSON input");
8
- let pos = 0;
9
- function skipWhitespace() {
10
- while (pos < buffer.length && /\s/.test(buffer[pos])) pos += 1;
11
- }
12
- function parseString() {
13
- if (buffer[pos] !== '"') throw new Error(`Expected '"' at position ${pos}, got '${buffer[pos]}'`);
14
- pos += 1;
15
- let result = "";
16
- let escaped = false;
17
- while (pos < buffer.length) {
18
- const char = buffer[pos];
19
- if (escaped) {
20
- if (char === "n") result += "\n";
21
- else if (char === "t") result += " ";
22
- else if (char === "r") result += "\r";
23
- else if (char === "\\") result += "\\";
24
- else if (char === '"') result += '"';
25
- else if (char === "b") result += "\b";
26
- else if (char === "f") result += "\f";
27
- else if (char === "/") result += "/";
28
- else if (char === "u") {
29
- const hex = buffer.substring(pos + 1, pos + 5);
30
- if (/^[0-9A-Fa-f]{0,4}$/.test(hex)) {
31
- if (hex.length === 4) result += String.fromCharCode(Number.parseInt(hex, 16));
32
- else result += `u${hex}`;
33
- pos += hex.length;
34
- } else throw new Error(`Invalid unicode escape sequence '\\u${hex}' at position ${pos}`);
35
- } else throw new Error(`Invalid escape sequence '\\${char}' at position ${pos}`);
36
- escaped = false;
37
- } else if (char === "\\") escaped = true;
38
- else if (char === '"') {
39
- pos += 1;
40
- return result;
41
- } else result += char;
42
- pos += 1;
43
- }
44
- if (escaped) result += "\\";
45
- return result;
46
- }
47
- function parseNumber() {
48
- const start = pos;
49
- let numStr = "";
50
- if (buffer[pos] === "-") {
51
- numStr += "-";
52
- pos += 1;
53
- }
54
- if (pos < buffer.length && buffer[pos] === "0") {
55
- numStr += "0";
56
- pos += 1;
57
- if (buffer[pos] >= "0" && buffer[pos] <= "9") throw new Error(`Invalid number at position ${start}`);
58
- }
59
- if (pos < buffer.length && buffer[pos] >= "1" && buffer[pos] <= "9") while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
60
- numStr += buffer[pos];
61
- pos += 1;
62
- }
63
- if (pos < buffer.length && buffer[pos] === ".") {
64
- numStr += ".";
65
- pos += 1;
66
- while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
67
- numStr += buffer[pos];
68
- pos += 1;
69
- }
70
- }
71
- if (pos < buffer.length && (buffer[pos] === "e" || buffer[pos] === "E")) {
72
- numStr += buffer[pos];
73
- pos += 1;
74
- if (pos < buffer.length && (buffer[pos] === "+" || buffer[pos] === "-")) {
75
- numStr += buffer[pos];
76
- pos += 1;
77
- }
78
- while (pos < buffer.length && buffer[pos] >= "0" && buffer[pos] <= "9") {
79
- numStr += buffer[pos];
80
- pos += 1;
81
- }
82
- }
83
- if (numStr === "-") return -0;
84
- const num = Number.parseFloat(numStr);
85
- if (Number.isNaN(num)) {
86
- pos = start;
87
- throw new Error(`Invalid number '${numStr}' at position ${start}`);
88
- }
89
- return num;
90
- }
91
- function parseValue() {
92
- skipWhitespace();
93
- if (pos >= buffer.length) throw new Error(`Unexpected end of input at position ${pos}`);
94
- const char = buffer[pos];
95
- if (char === "{") return parseObject();
96
- if (char === "[") return parseArray();
97
- if (char === '"') return parseString();
98
- if ("null".startsWith(buffer.substring(pos, pos + 4))) {
99
- pos += Math.min(4, buffer.length - pos);
100
- return null;
101
- }
102
- if ("true".startsWith(buffer.substring(pos, pos + 4))) {
103
- pos += Math.min(4, buffer.length - pos);
104
- return true;
105
- }
106
- if ("false".startsWith(buffer.substring(pos, pos + 5))) {
107
- pos += Math.min(5, buffer.length - pos);
108
- return false;
109
- }
110
- if (char === "-" || char >= "0" && char <= "9") return parseNumber();
111
- throw new Error(`Unexpected character '${char}' at position ${pos}`);
112
- }
113
- function parseArray() {
114
- if (buffer[pos] !== "[") throw new Error(`Expected '[' at position ${pos}, got '${buffer[pos]}'`);
115
- const arr = [];
116
- pos += 1;
117
- skipWhitespace();
118
- if (pos >= buffer.length) return arr;
119
- if (buffer[pos] === "]") {
120
- pos += 1;
121
- return arr;
122
- }
123
- while (pos < buffer.length) {
124
- skipWhitespace();
125
- if (pos >= buffer.length) return arr;
126
- arr.push(parseValue());
127
- skipWhitespace();
128
- if (pos >= buffer.length) return arr;
129
- if (buffer[pos] === "]") {
130
- pos += 1;
131
- return arr;
132
- } else if (buffer[pos] === ",") {
133
- pos += 1;
134
- continue;
1
+ function convertToFormattedString(message, format = "pretty") {
2
+ if (format === "pretty") return convertToPrettyString(message);
3
+ return JSON.stringify(message);
4
+ }
5
+ function convertToPrettyString(message) {
6
+ const lines = [];
7
+ const title = ` ${message.type.charAt(0).toUpperCase() + message.type.slice(1)} Message `;
8
+ const sepLen = Math.floor((80 - title.length) / 2);
9
+ const sep = "=".repeat(sepLen);
10
+ const secondSep = title.length % 2 === 0 ? sep : `${sep}=`;
11
+ lines.push(`${sep}${title}${secondSep}`);
12
+ if (message.type === "ai") {
13
+ const aiMessage = message;
14
+ if (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {
15
+ lines.push("Tool Calls:");
16
+ for (const tc of aiMessage.tool_calls) {
17
+ lines.push(` ${tc.name} (${tc.id})`);
18
+ lines.push(` Call ID: ${tc.id}`);
19
+ lines.push(" Args:");
20
+ for (const [key, value] of Object.entries(tc.args)) lines.push(` ${key}: ${typeof value === "object" ? JSON.stringify(value) : value}`);
135
21
  }
136
- throw new Error(`Expected ',' or ']' at position ${pos}, got '${buffer[pos]}'`);
137
22
  }
138
- return arr;
139
23
  }
140
- function parseObject() {
141
- if (buffer[pos] !== "{") throw new Error(`Expected '{' at position ${pos}, got '${buffer[pos]}'`);
142
- const obj = {};
143
- pos += 1;
144
- skipWhitespace();
145
- if (pos >= buffer.length) return obj;
146
- if (buffer[pos] === "}") {
147
- pos += 1;
148
- return obj;
149
- }
150
- while (pos < buffer.length) {
151
- skipWhitespace();
152
- if (pos >= buffer.length) return obj;
153
- const key = parseString();
154
- skipWhitespace();
155
- if (pos >= buffer.length) return obj;
156
- if (buffer[pos] !== ":") throw new Error(`Expected ':' at position ${pos}, got '${buffer[pos]}'`);
157
- pos += 1;
158
- skipWhitespace();
159
- if (pos >= buffer.length) return obj;
160
- obj[key] = parseValue();
161
- skipWhitespace();
162
- if (pos >= buffer.length) return obj;
163
- if (buffer[pos] === "}") {
164
- pos += 1;
165
- return obj;
166
- } else if (buffer[pos] === ",") {
167
- pos += 1;
168
- continue;
169
- }
170
- throw new Error(`Expected ',' or '}' at position ${pos}, got '${buffer[pos]}'`);
171
- }
172
- return obj;
24
+ if (message.type === "tool") {
25
+ const toolMessage = message;
26
+ if (toolMessage.name) lines.push(`Name: ${toolMessage.name}`);
173
27
  }
174
- const value = parseValue();
175
- skipWhitespace();
176
- if (pos < buffer.length) throw new Error(`Unexpected character '${buffer[pos]}' at position ${pos}`);
177
- return value;
178
- }
179
- function parsePartialJson(s) {
180
- try {
181
- if (typeof s === "undefined") return null;
182
- return strictParsePartialJson(s);
183
- } catch {
184
- return null;
28
+ if (typeof message.content === "string" && message.content.trim()) {
29
+ if (lines.length > 1) lines.push("");
30
+ lines.push(message.content);
185
31
  }
32
+ return lines.join("\n");
186
33
  }
187
34
  export {
188
- parsePartialJson
35
+ convertToFormattedString
189
36
  };
190
37
  //# sourceMappingURL=index.es71.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es71.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/json.js"],"sourcesContent":["//#region src/utils/json.ts\nfunction parseJsonMarkdown(s, parser = parsePartialJson) {\n\ts = s.trim();\n\tconst firstFenceIndex = s.indexOf(\"```\");\n\tif (firstFenceIndex === -1) return parser(s);\n\tlet contentAfterFence = s.substring(firstFenceIndex + 3);\n\tif (contentAfterFence.startsWith(\"json\\n\")) contentAfterFence = contentAfterFence.substring(5);\n\telse if (contentAfterFence.startsWith(\"json\")) contentAfterFence = contentAfterFence.substring(4);\n\telse if (contentAfterFence.startsWith(\"\\n\")) contentAfterFence = contentAfterFence.substring(1);\n\tconst closingFenceIndex = contentAfterFence.indexOf(\"```\");\n\tlet finalContent = contentAfterFence;\n\tif (closingFenceIndex !== -1) finalContent = contentAfterFence.substring(0, closingFenceIndex);\n\treturn parser(finalContent.trim());\n}\n/**\n* Recursive descent partial JSON parser.\n* @param s - The string to parse.\n* @returns The parsed value.\n* @throws Error if the input is a malformed JSON string.\n*/\nfunction strictParsePartialJson(s) {\n\ttry {\n\t\treturn JSON.parse(s);\n\t} catch {}\n\tconst buffer = s.trim();\n\tif (buffer.length === 0) throw new Error(\"Unexpected end of JSON input\");\n\tlet pos = 0;\n\tfunction skipWhitespace() {\n\t\twhile (pos < buffer.length && /\\s/.test(buffer[pos])) pos += 1;\n\t}\n\tfunction parseString() {\n\t\tif (buffer[pos] !== \"\\\"\") throw new Error(`Expected '\"' at position ${pos}, got '${buffer[pos]}'`);\n\t\tpos += 1;\n\t\tlet result = \"\";\n\t\tlet escaped = false;\n\t\twhile (pos < buffer.length) {\n\t\t\tconst char = buffer[pos];\n\t\t\tif (escaped) {\n\t\t\t\tif (char === \"n\") result += \"\\n\";\n\t\t\t\telse if (char === \"t\") result += \"\t\";\n\t\t\t\telse if (char === \"r\") result += \"\\r\";\n\t\t\t\telse if (char === \"\\\\\") result += \"\\\\\";\n\t\t\t\telse if (char === \"\\\"\") result += \"\\\"\";\n\t\t\t\telse if (char === \"b\") result += \"\\b\";\n\t\t\t\telse if (char === \"f\") result += \"\\f\";\n\t\t\t\telse if (char === \"/\") result += \"/\";\n\t\t\t\telse if (char === \"u\") {\n\t\t\t\t\tconst hex = buffer.substring(pos + 1, pos + 5);\n\t\t\t\t\tif (/^[0-9A-Fa-f]{0,4}$/.test(hex)) {\n\t\t\t\t\t\tif (hex.length === 4) result += String.fromCharCode(Number.parseInt(hex, 16));\n\t\t\t\t\t\telse result += `u${hex}`;\n\t\t\t\t\t\tpos += hex.length;\n\t\t\t\t\t} else throw new Error(`Invalid unicode escape sequence '\\\\u${hex}' at position ${pos}`);\n\t\t\t\t} else throw new Error(`Invalid escape sequence '\\\\${char}' at position ${pos}`);\n\t\t\t\tescaped = false;\n\t\t\t} else if (char === \"\\\\\") escaped = true;\n\t\t\telse if (char === \"\\\"\") {\n\t\t\t\tpos += 1;\n\t\t\t\treturn result;\n\t\t\t} else result += char;\n\t\t\tpos += 1;\n\t\t}\n\t\tif (escaped) result += \"\\\\\";\n\t\treturn result;\n\t}\n\tfunction parseNumber() {\n\t\tconst start = pos;\n\t\tlet numStr = \"\";\n\t\tif (buffer[pos] === \"-\") {\n\t\t\tnumStr += \"-\";\n\t\t\tpos += 1;\n\t\t}\n\t\tif (pos < buffer.length && buffer[pos] === \"0\") {\n\t\t\tnumStr += \"0\";\n\t\t\tpos += 1;\n\t\t\tif (buffer[pos] >= \"0\" && buffer[pos] <= \"9\") throw new Error(`Invalid number at position ${start}`);\n\t\t}\n\t\tif (pos < buffer.length && buffer[pos] >= \"1\" && buffer[pos] <= \"9\") while (pos < buffer.length && buffer[pos] >= \"0\" && buffer[pos] <= \"9\") {\n\t\t\tnumStr += buffer[pos];\n\t\t\tpos += 1;\n\t\t}\n\t\tif (pos < buffer.length && buffer[pos] === \".\") {\n\t\t\tnumStr += \".\";\n\t\t\tpos += 1;\n\t\t\twhile (pos < buffer.length && buffer[pos] >= \"0\" && buffer[pos] <= \"9\") {\n\t\t\t\tnumStr += buffer[pos];\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t}\n\t\tif (pos < buffer.length && (buffer[pos] === \"e\" || buffer[pos] === \"E\")) {\n\t\t\tnumStr += buffer[pos];\n\t\t\tpos += 1;\n\t\t\tif (pos < buffer.length && (buffer[pos] === \"+\" || buffer[pos] === \"-\")) {\n\t\t\t\tnumStr += buffer[pos];\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t\twhile (pos < buffer.length && buffer[pos] >= \"0\" && buffer[pos] <= \"9\") {\n\t\t\t\tnumStr += buffer[pos];\n\t\t\t\tpos += 1;\n\t\t\t}\n\t\t}\n\t\tif (numStr === \"-\") return -0;\n\t\tconst num = Number.parseFloat(numStr);\n\t\tif (Number.isNaN(num)) {\n\t\t\tpos = start;\n\t\t\tthrow new Error(`Invalid number '${numStr}' at position ${start}`);\n\t\t}\n\t\treturn num;\n\t}\n\tfunction parseValue() {\n\t\tskipWhitespace();\n\t\tif (pos >= buffer.length) throw new Error(`Unexpected end of input at position ${pos}`);\n\t\tconst char = buffer[pos];\n\t\tif (char === \"{\") return parseObject();\n\t\tif (char === \"[\") return parseArray();\n\t\tif (char === \"\\\"\") return parseString();\n\t\tif (\"null\".startsWith(buffer.substring(pos, pos + 4))) {\n\t\t\tpos += Math.min(4, buffer.length - pos);\n\t\t\treturn null;\n\t\t}\n\t\tif (\"true\".startsWith(buffer.substring(pos, pos + 4))) {\n\t\t\tpos += Math.min(4, buffer.length - pos);\n\t\t\treturn true;\n\t\t}\n\t\tif (\"false\".startsWith(buffer.substring(pos, pos + 5))) {\n\t\t\tpos += Math.min(5, buffer.length - pos);\n\t\t\treturn false;\n\t\t}\n\t\tif (char === \"-\" || char >= \"0\" && char <= \"9\") return parseNumber();\n\t\tthrow new Error(`Unexpected character '${char}' at position ${pos}`);\n\t}\n\tfunction parseArray() {\n\t\tif (buffer[pos] !== \"[\") throw new Error(`Expected '[' at position ${pos}, got '${buffer[pos]}'`);\n\t\tconst arr = [];\n\t\tpos += 1;\n\t\tskipWhitespace();\n\t\tif (pos >= buffer.length) return arr;\n\t\tif (buffer[pos] === \"]\") {\n\t\t\tpos += 1;\n\t\t\treturn arr;\n\t\t}\n\t\twhile (pos < buffer.length) {\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return arr;\n\t\t\tarr.push(parseValue());\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return arr;\n\t\t\tif (buffer[pos] === \"]\") {\n\t\t\t\tpos += 1;\n\t\t\t\treturn arr;\n\t\t\t} else if (buffer[pos] === \",\") {\n\t\t\t\tpos += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Expected ',' or ']' at position ${pos}, got '${buffer[pos]}'`);\n\t\t}\n\t\treturn arr;\n\t}\n\tfunction parseObject() {\n\t\tif (buffer[pos] !== \"{\") throw new Error(`Expected '{' at position ${pos}, got '${buffer[pos]}'`);\n\t\tconst obj = {};\n\t\tpos += 1;\n\t\tskipWhitespace();\n\t\tif (pos >= buffer.length) return obj;\n\t\tif (buffer[pos] === \"}\") {\n\t\t\tpos += 1;\n\t\t\treturn obj;\n\t\t}\n\t\twhile (pos < buffer.length) {\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return obj;\n\t\t\tconst key = parseString();\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return obj;\n\t\t\tif (buffer[pos] !== \":\") throw new Error(`Expected ':' at position ${pos}, got '${buffer[pos]}'`);\n\t\t\tpos += 1;\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return obj;\n\t\t\tobj[key] = parseValue();\n\t\t\tskipWhitespace();\n\t\t\tif (pos >= buffer.length) return obj;\n\t\t\tif (buffer[pos] === \"}\") {\n\t\t\t\tpos += 1;\n\t\t\t\treturn obj;\n\t\t\t} else if (buffer[pos] === \",\") {\n\t\t\t\tpos += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tthrow new Error(`Expected ',' or '}' at position ${pos}, got '${buffer[pos]}'`);\n\t\t}\n\t\treturn obj;\n\t}\n\tconst value = parseValue();\n\tskipWhitespace();\n\tif (pos < buffer.length) throw new Error(`Unexpected character '${buffer[pos]}' at position ${pos}`);\n\treturn value;\n}\nfunction parsePartialJson(s) {\n\ttry {\n\t\tif (typeof s === \"undefined\") return null;\n\t\treturn strictParsePartialJson(s);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n//#endregion\nexport { parseJsonMarkdown, parsePartialJson };\n//# sourceMappingURL=json.js.map"],"names":[],"mappings":"AAoBA,SAAS,uBAAuB,GAAG;AAClC,MAAI;AACH,WAAO,KAAK,MAAM,CAAC;AAAA,EACpB,QAAQ;AAAA,EAAC;AACT,QAAM,SAAS,EAAE,KAAI;AACrB,MAAI,OAAO,WAAW,EAAG,OAAM,IAAI,MAAM,8BAA8B;AACvE,MAAI,MAAM;AACV,WAAS,iBAAiB;AACzB,WAAO,MAAM,OAAO,UAAU,KAAK,KAAK,OAAO,GAAG,CAAC,EAAG,QAAO;AAAA,EAC9D;AACA,WAAS,cAAc;AACtB,QAAI,OAAO,GAAG,MAAM,IAAM,OAAM,IAAI,MAAM,4BAA4B,GAAG,UAAU,OAAO,GAAG,CAAC,GAAG;AACjG,WAAO;AACP,QAAI,SAAS;AACb,QAAI,UAAU;AACd,WAAO,MAAM,OAAO,QAAQ;AAC3B,YAAM,OAAO,OAAO,GAAG;AACvB,UAAI,SAAS;AACZ,YAAI,SAAS,IAAK,WAAU;AAAA,iBACnB,SAAS,IAAK,WAAU;AAAA,iBACxB,SAAS,IAAK,WAAU;AAAA,iBACxB,SAAS,KAAM,WAAU;AAAA,iBACzB,SAAS,IAAM,WAAU;AAAA,iBACzB,SAAS,IAAK,WAAU;AAAA,iBACxB,SAAS,IAAK,WAAU;AAAA,iBACxB,SAAS,IAAK,WAAU;AAAA,iBACxB,SAAS,KAAK;AACtB,gBAAM,MAAM,OAAO,UAAU,MAAM,GAAG,MAAM,CAAC;AAC7C,cAAI,qBAAqB,KAAK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B,GAAG,UAAU,OAAO,GAAG,CAAC,GAAG;AAChG,aAAO;AACP,qBAAc;AACd,UAAI,OAAO,OAAO,OAAQ,QAAO;AACjC,UAAI,GAAG,IAAI,WAAU;AACrB,qBAAc;AACd,UAAI,OAAO,OAAO,OAAQ,QAAO;AACjC,UAAI,OAAO,GAAG,MAAM,KAAK;AACxB,eAAO;AACP,eAAO;AAAA,MACR,WAAW,OAAO,GAAG,MAAM,KAAK;AAC/B,eAAO;AACP;AAAA,MACD;AACA,YAAM,IAAI,MAAM,mCAAmC,GAAG,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,IAC/E;AACA,WAAO;AAAA,EACR;AACA,QAAM,QAAQ,WAAU;AACxB,iBAAc;AACd,MAAI,MAAM,OAAO,OAAQ,OAAM,IAAI,MAAM,yBAAyB,OAAO,GAAG,CAAC,iBAAiB,GAAG,EAAE;AACnG,SAAO;AACR;AACA,SAAS,iBAAiB,GAAG;AAC5B,MAAI;AACH,QAAI,OAAO,MAAM,YAAa,QAAO;AACrC,WAAO,uBAAuB,CAAC;AAAA,EAChC,QAAQ;AACP,WAAO;AAAA,EACR;AACD;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es71.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/messages/format.js"],"sourcesContent":["//#region src/messages/format.ts\nfunction convertToFormattedString(message, format = \"pretty\") {\n\tif (format === \"pretty\") return convertToPrettyString(message);\n\treturn JSON.stringify(message);\n}\nfunction convertToPrettyString(message) {\n\tconst lines = [];\n\tconst title = ` ${message.type.charAt(0).toUpperCase() + message.type.slice(1)} Message `;\n\tconst sepLen = Math.floor((80 - title.length) / 2);\n\tconst sep = \"=\".repeat(sepLen);\n\tconst secondSep = title.length % 2 === 0 ? sep : `${sep}=`;\n\tlines.push(`${sep}${title}${secondSep}`);\n\tif (message.type === \"ai\") {\n\t\tconst aiMessage = message;\n\t\tif (aiMessage.tool_calls && aiMessage.tool_calls.length > 0) {\n\t\t\tlines.push(\"Tool Calls:\");\n\t\t\tfor (const tc of aiMessage.tool_calls) {\n\t\t\t\tlines.push(` ${tc.name} (${tc.id})`);\n\t\t\t\tlines.push(` Call ID: ${tc.id}`);\n\t\t\t\tlines.push(\" Args:\");\n\t\t\t\tfor (const [key, value] of Object.entries(tc.args)) lines.push(` ${key}: ${typeof value === \"object\" ? JSON.stringify(value) : value}`);\n\t\t\t}\n\t\t}\n\t}\n\tif (message.type === \"tool\") {\n\t\tconst toolMessage = message;\n\t\tif (toolMessage.name) lines.push(`Name: ${toolMessage.name}`);\n\t}\n\tif (typeof message.content === \"string\" && message.content.trim()) {\n\t\tif (lines.length > 1) lines.push(\"\");\n\t\tlines.push(message.content);\n\t}\n\treturn lines.join(\"\\n\");\n}\n\n//#endregion\nexport { convertToFormattedString };\n//# sourceMappingURL=format.js.map"],"names":[],"mappings":"AACA,SAAS,yBAAyB,SAAS,SAAS,UAAU;AAC7D,MAAI,WAAW,SAAU,QAAO,sBAAsB,OAAO;AAC7D,SAAO,KAAK,UAAU,OAAO;AAC9B;AACA,SAAS,sBAAsB,SAAS;AACvC,QAAM,QAAQ,CAAA;AACd,QAAM,QAAQ,IAAI,QAAQ,KAAK,OAAO,CAAC,EAAE,YAAW,IAAK,QAAQ,KAAK,MAAM,CAAC,CAAC;AAC9E,QAAM,SAAS,KAAK,OAAO,KAAK,MAAM,UAAU,CAAC;AACjD,QAAM,MAAM,IAAI,OAAO,MAAM;AAC7B,QAAM,YAAY,MAAM,SAAS,MAAM,IAAI,MAAM,GAAG,GAAG;AACvD,QAAM,KAAK,GAAG,GAAG,GAAG,KAAK,GAAG,SAAS,EAAE;AACvC,MAAI,QAAQ,SAAS,MAAM;AAC1B,UAAM,YAAY;AAClB,QAAI,UAAU,cAAc,UAAU,WAAW,SAAS,GAAG;AAC5D,YAAM,KAAK,aAAa;AACxB,iBAAW,MAAM,UAAU,YAAY;AACtC,cAAM,KAAK,KAAK,GAAG,IAAI,KAAK,GAAG,EAAE,GAAG;AACpC,cAAM,KAAK,aAAa,GAAG,EAAE,EAAE;AAC/B,cAAM,KAAK,SAAS;AACpB,mBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,IAAI,EAAG,OAAM,KAAK,OAAO,GAAG,KAAK,OAAO,UAAU,WAAW,KAAK,UAAU,KAAK,IAAI,KAAK,EAAE;AAAA,MAC1I;AAAA,IACD;AAAA,EACD;AACA,MAAI,QAAQ,SAAS,QAAQ;AAC5B,UAAM,cAAc;AACpB,QAAI,YAAY,KAAM,OAAM,KAAK,SAAS,YAAY,IAAI,EAAE;AAAA,EAC7D;AACA,MAAI,OAAO,QAAQ,YAAY,YAAY,QAAQ,QAAQ,QAAQ;AAClE,QAAI,MAAM,SAAS,EAAG,OAAM,KAAK,EAAE;AACnC,UAAM,KAAK,QAAQ,OAAO;AAAA,EAC3B;AACA,SAAO,MAAM,KAAK,IAAI;AACvB;","x_google_ignoreList":[0]}
@@ -1,27 +1,12 @@
1
- import { ChatAnthropicTranslator } from "./index.es65.js";
2
- import { ChatOpenAITranslator } from "./index.es67.js";
3
- import { ChatBedrockConverseTranslator } from "./index.es85.js";
4
- import { ChatDeepSeekTranslator } from "./index.es86.js";
5
- import { ChatGoogleGenAITranslator } from "./index.es87.js";
6
- import { ChatVertexTranslator } from "./index.es88.js";
7
- import { ChatGroqTranslator } from "./index.es89.js";
8
- import { ChatOllamaTranslator } from "./index.es90.js";
9
- import { ChatXAITranslator } from "./index.es91.js";
10
- globalThis.lc_block_translators_registry ??= /* @__PURE__ */ new Map([
11
- ["anthropic", ChatAnthropicTranslator],
12
- ["bedrock-converse", ChatBedrockConverseTranslator],
13
- ["deepseek", ChatDeepSeekTranslator],
14
- ["google-genai", ChatGoogleGenAITranslator],
15
- ["google-vertexai", ChatVertexTranslator],
16
- ["groq", ChatGroqTranslator],
17
- ["ollama", ChatOllamaTranslator],
18
- ["openai", ChatOpenAITranslator],
19
- ["xai", ChatXAITranslator]
20
- ]);
21
- function getTranslator(modelProvider) {
22
- return globalThis.lc_block_translators_registry.get(modelProvider);
1
+ function addLangChainErrorFields(error, lc_error_code) {
2
+ error.lc_error_code = lc_error_code;
3
+ error.message = `${error.message}
4
+
5
+ Troubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/
6
+ `;
7
+ return error;
23
8
  }
24
9
  export {
25
- getTranslator
10
+ addLangChainErrorFields
26
11
  };
27
12
  //# sourceMappingURL=index.es72.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.es72.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/messages/block_translators/index.js"],"sourcesContent":["import { ChatAnthropicTranslator } from \"./anthropic.js\";\nimport { ChatOpenAITranslator } from \"./openai.js\";\nimport { ChatBedrockConverseTranslator } from \"./bedrock_converse.js\";\nimport { ChatDeepSeekTranslator } from \"./deepseek.js\";\nimport { ChatGoogleGenAITranslator } from \"./google_genai.js\";\nimport { ChatVertexTranslator } from \"./google_vertexai.js\";\nimport { ChatGroqTranslator } from \"./groq.js\";\nimport { ChatOllamaTranslator } from \"./ollama.js\";\nimport { ChatXAITranslator } from \"./xai.js\";\n\n//#region src/messages/block_translators/index.ts\nglobalThis.lc_block_translators_registry ??= new Map([\n\t[\"anthropic\", ChatAnthropicTranslator],\n\t[\"bedrock-converse\", ChatBedrockConverseTranslator],\n\t[\"deepseek\", ChatDeepSeekTranslator],\n\t[\"google-genai\", ChatGoogleGenAITranslator],\n\t[\"google-vertexai\", ChatVertexTranslator],\n\t[\"groq\", ChatGroqTranslator],\n\t[\"ollama\", ChatOllamaTranslator],\n\t[\"openai\", ChatOpenAITranslator],\n\t[\"xai\", ChatXAITranslator]\n]);\nfunction getTranslator(modelProvider) {\n\treturn globalThis.lc_block_translators_registry.get(modelProvider);\n}\n\n//#endregion\nexport { getTranslator };\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";;;;;;;;;AAWA,WAAW,kCAAkC,oBAAI,IAAI;AAAA,EACpD,CAAC,aAAa,uBAAuB;AAAA,EACrC,CAAC,oBAAoB,6BAA6B;AAAA,EAClD,CAAC,YAAY,sBAAsB;AAAA,EACnC,CAAC,gBAAgB,yBAAyB;AAAA,EAC1C,CAAC,mBAAmB,oBAAoB;AAAA,EACxC,CAAC,QAAQ,kBAAkB;AAAA,EAC3B,CAAC,UAAU,oBAAoB;AAAA,EAC/B,CAAC,UAAU,oBAAoB;AAAA,EAC/B,CAAC,OAAO,iBAAiB;AAC1B,CAAC;AACD,SAAS,cAAc,eAAe;AACrC,SAAO,WAAW,8BAA8B,IAAI,aAAa;AAClE;","x_google_ignoreList":[0]}
1
+ {"version":3,"file":"index.es72.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/errors/index.js"],"sourcesContent":["//#region src/errors/index.ts\nfunction addLangChainErrorFields(error, lc_error_code) {\n\terror.lc_error_code = lc_error_code;\n\terror.message = `${error.message}\\n\\nTroubleshooting URL: https://docs.langchain.com/oss/javascript/langchain/errors/${lc_error_code}/\\n`;\n\treturn error;\n}\n\n//#endregion\nexport { addLangChainErrorFields };\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":"AACA,SAAS,wBAAwB,OAAO,eAAe;AACtD,QAAM,gBAAgB;AACtB,QAAM,UAAU,GAAG,MAAM,OAAO;AAAA;AAAA,kFAAuF,aAAa;AAAA;AACpI,SAAO;AACR;","x_google_ignoreList":[0]}