langgraph-ui-components 0.0.4 → 0.0.7

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 (520) hide show
  1. package/dist/index.es10.js +31 -16
  2. package/dist/index.es10.js.map +1 -1
  3. package/dist/index.es100.js +143 -3134
  4. package/dist/index.es100.js.map +1 -1
  5. package/dist/index.es101.js +202 -36
  6. package/dist/index.es101.js.map +1 -1
  7. package/dist/index.es102.js +14 -5
  8. package/dist/index.es102.js.map +1 -1
  9. package/dist/index.es103.js +27 -70
  10. package/dist/index.es103.js.map +1 -1
  11. package/dist/index.es104.js +28 -31
  12. package/dist/index.es104.js.map +1 -1
  13. package/dist/index.es105.js +3157 -5
  14. package/dist/index.es105.js.map +1 -1
  15. package/dist/index.es106.js +18 -2
  16. package/dist/index.es106.js.map +1 -1
  17. package/dist/index.es107.js +5 -11
  18. package/dist/index.es107.js.map +1 -1
  19. package/dist/index.es108.js +2 -503
  20. package/dist/index.es108.js.map +1 -1
  21. package/dist/index.es109.js +11 -5
  22. package/dist/index.es109.js.map +1 -1
  23. package/dist/index.es11.js +166 -123
  24. package/dist/index.es11.js.map +1 -1
  25. package/dist/index.es110.js +503 -2
  26. package/dist/index.es110.js.map +1 -1
  27. package/dist/index.es111.js +5 -146
  28. package/dist/index.es111.js.map +1 -1
  29. package/dist/index.es112.js +2 -908
  30. package/dist/index.es112.js.map +1 -1
  31. package/dist/index.es113.js +128 -262
  32. package/dist/index.es113.js.map +1 -1
  33. package/dist/index.es114.js +907 -3
  34. package/dist/index.es114.js.map +1 -1
  35. package/dist/index.es115.js +262 -426
  36. package/dist/index.es115.js.map +1 -1
  37. package/dist/index.es116.js +3 -47
  38. package/dist/index.es116.js.map +1 -1
  39. package/dist/index.es117.js +443 -21
  40. package/dist/index.es117.js.map +1 -1
  41. package/dist/index.es118.js +42 -75
  42. package/dist/index.es118.js.map +1 -1
  43. package/dist/index.es119.js +22 -129
  44. package/dist/index.es119.js.map +1 -1
  45. package/dist/index.es12.js +13 -103
  46. package/dist/index.es12.js.map +1 -1
  47. package/dist/index.es120.js +74 -44
  48. package/dist/index.es120.js.map +1 -1
  49. package/dist/index.es121.js +129 -10
  50. package/dist/index.es121.js.map +1 -1
  51. package/dist/index.es122.js +47 -43
  52. package/dist/index.es122.js.map +1 -1
  53. package/dist/index.es123.js +9 -98
  54. package/dist/index.es123.js.map +1 -1
  55. package/dist/index.es124.js +43 -51
  56. package/dist/index.es124.js.map +1 -1
  57. package/dist/index.es125.js +96 -13
  58. package/dist/index.es125.js.map +1 -1
  59. package/dist/index.es126.js +52 -14
  60. package/dist/index.es126.js.map +1 -1
  61. package/dist/index.es127.js +156 -81
  62. package/dist/index.es127.js.map +1 -1
  63. package/dist/index.es128.js +2 -2
  64. package/dist/index.es129.js +14 -55
  65. package/dist/index.es129.js.map +1 -1
  66. package/dist/index.es13.js +126 -32
  67. package/dist/index.es13.js.map +1 -1
  68. package/dist/index.es130.js +87 -98
  69. package/dist/index.es130.js.map +1 -1
  70. package/dist/index.es131.js +2 -191
  71. package/dist/index.es131.js.map +1 -1
  72. package/dist/index.es132.js +54 -108
  73. package/dist/index.es132.js.map +1 -1
  74. package/dist/index.es133.js +98 -33
  75. package/dist/index.es133.js.map +1 -1
  76. package/dist/index.es134.js +191 -10
  77. package/dist/index.es134.js.map +1 -1
  78. package/dist/index.es135.js +109 -10
  79. package/dist/index.es135.js.map +1 -1
  80. package/dist/index.es136.js +35 -12
  81. package/dist/index.es136.js.map +1 -1
  82. package/dist/index.es137.js +10 -91
  83. package/dist/index.es137.js.map +1 -1
  84. package/dist/index.es138.js +11 -275
  85. package/dist/index.es138.js.map +1 -1
  86. package/dist/index.es139.js +12 -2
  87. package/dist/index.es139.js.map +1 -1
  88. package/dist/index.es140.js +88 -161
  89. package/dist/index.es140.js.map +1 -1
  90. package/dist/index.es141.js +270 -46
  91. package/dist/index.es141.js.map +1 -1
  92. package/dist/index.es142.js +2 -40
  93. package/dist/index.es142.js.map +1 -1
  94. package/dist/index.es143.js +164 -35
  95. package/dist/index.es143.js.map +1 -1
  96. package/dist/index.es144.js +45 -34
  97. package/dist/index.es144.js.map +1 -1
  98. package/dist/index.es145.js +37 -21
  99. package/dist/index.es145.js.map +1 -1
  100. package/dist/index.es146.js +32 -588
  101. package/dist/index.es146.js.map +1 -1
  102. package/dist/index.es147.js +32 -117
  103. package/dist/index.es147.js.map +1 -1
  104. package/dist/index.es148.js +22 -162
  105. package/dist/index.es148.js.map +1 -1
  106. package/dist/index.es149.js +591 -2
  107. package/dist/index.es149.js.map +1 -1
  108. package/dist/index.es15.js +15 -15
  109. package/dist/index.es150.js +125 -2
  110. package/dist/index.es150.js.map +1 -1
  111. package/dist/index.es151.js +2 -2
  112. package/dist/index.es152.js +2 -22
  113. package/dist/index.es152.js.map +1 -1
  114. package/dist/index.es153.js +22 -2
  115. package/dist/index.es153.js.map +1 -1
  116. package/dist/index.es154.js +2 -25
  117. package/dist/index.es154.js.map +1 -1
  118. package/dist/index.es155.js +25 -8
  119. package/dist/index.es155.js.map +1 -1
  120. package/dist/index.es156.js +4 -5
  121. package/dist/index.es156.js.map +1 -1
  122. package/dist/index.es157.js +7 -12
  123. package/dist/index.es157.js.map +1 -1
  124. package/dist/index.es158.js +5 -6
  125. package/dist/index.es158.js.map +1 -1
  126. package/dist/index.es159.js +12 -63
  127. package/dist/index.es159.js.map +1 -1
  128. package/dist/index.es160.js +5 -21
  129. package/dist/index.es160.js.map +1 -1
  130. package/dist/index.es161.js +24 -5
  131. package/dist/index.es161.js.map +1 -1
  132. package/dist/index.es162.js +11 -348
  133. package/dist/index.es162.js.map +1 -1
  134. package/dist/index.es163.js +52 -23
  135. package/dist/index.es163.js.map +1 -1
  136. package/dist/index.es164.js +63 -11
  137. package/dist/index.es164.js.map +1 -1
  138. package/dist/index.es165.js +21 -53
  139. package/dist/index.es165.js.map +1 -1
  140. package/dist/index.es166.js +6 -7
  141. package/dist/index.es166.js.map +1 -1
  142. package/dist/index.es167.js +342 -96
  143. package/dist/index.es167.js.map +1 -1
  144. package/dist/index.es168.js +6 -118
  145. package/dist/index.es168.js.map +1 -1
  146. package/dist/index.es169.js +98 -131
  147. package/dist/index.es169.js.map +1 -1
  148. package/dist/index.es17.js +2 -2
  149. package/dist/index.es170.js +108 -104
  150. package/dist/index.es170.js.map +1 -1
  151. package/dist/index.es171.js +136 -6
  152. package/dist/index.es171.js.map +1 -1
  153. package/dist/index.es172.js +114 -3
  154. package/dist/index.es172.js.map +1 -1
  155. package/dist/index.es173.js +6 -2
  156. package/dist/index.es173.js.map +1 -1
  157. package/dist/index.es174.js +2 -3737
  158. package/dist/index.es174.js.map +1 -1
  159. package/dist/index.es175.js +3682 -287
  160. package/dist/index.es175.js.map +1 -1
  161. package/dist/index.es176.js +321 -88
  162. package/dist/index.es176.js.map +1 -1
  163. package/dist/index.es177.js +95 -119
  164. package/dist/index.es177.js.map +1 -1
  165. package/dist/index.es178.js +131 -13
  166. package/dist/index.es178.js.map +1 -1
  167. package/dist/index.es179.js +13 -150
  168. package/dist/index.es179.js.map +1 -1
  169. package/dist/index.es180.js +150 -13
  170. package/dist/index.es180.js.map +1 -1
  171. package/dist/index.es181.js +13 -6
  172. package/dist/index.es181.js.map +1 -1
  173. package/dist/index.es182.js +6 -19
  174. package/dist/index.es182.js.map +1 -1
  175. package/dist/index.es183.js +17 -86
  176. package/dist/index.es183.js.map +1 -1
  177. package/dist/index.es184.js +69 -222
  178. package/dist/index.es184.js.map +1 -1
  179. package/dist/index.es185.js +242 -23
  180. package/dist/index.es185.js.map +1 -1
  181. package/dist/index.es186.js +23 -5
  182. package/dist/index.es186.js.map +1 -1
  183. package/dist/index.es187.js +6 -4
  184. package/dist/index.es187.js.map +1 -1
  185. package/dist/index.es188.js +4 -18
  186. package/dist/index.es188.js.map +1 -1
  187. package/dist/index.es189.js +16 -6
  188. package/dist/index.es189.js.map +1 -1
  189. package/dist/index.es19.js +119 -15
  190. package/dist/index.es19.js.map +1 -1
  191. package/dist/index.es190.js +7 -141
  192. package/dist/index.es190.js.map +1 -1
  193. package/dist/index.es191.js +142 -2
  194. package/dist/index.es191.js.map +1 -1
  195. package/dist/index.es192.js +2 -32
  196. package/dist/index.es192.js.map +1 -1
  197. package/dist/index.es193.js +31 -5
  198. package/dist/index.es193.js.map +1 -1
  199. package/dist/index.es194.js +5 -105
  200. package/dist/index.es194.js.map +1 -1
  201. package/dist/index.es195.js +106 -13
  202. package/dist/index.es195.js.map +1 -1
  203. package/dist/index.es196.js +12 -17
  204. package/dist/index.es196.js.map +1 -1
  205. package/dist/index.es197.js +15 -28
  206. package/dist/index.es197.js.map +1 -1
  207. package/dist/index.es198.js +30 -3
  208. package/dist/index.es198.js.map +1 -1
  209. package/dist/index.es199.js +3 -4
  210. package/dist/index.es199.js.map +1 -1
  211. package/dist/index.es2.js +24 -16
  212. package/dist/index.es2.js.map +1 -1
  213. package/dist/index.es20.js +17 -68
  214. package/dist/index.es20.js.map +1 -1
  215. package/dist/index.es200.js +5 -5
  216. package/dist/index.es200.js.map +1 -1
  217. package/dist/index.es201.js +4 -36
  218. package/dist/index.es201.js.map +1 -1
  219. package/dist/index.es202.js +36 -7
  220. package/dist/index.es202.js.map +1 -1
  221. package/dist/index.es203.js +7 -5
  222. package/dist/index.es203.js.map +1 -1
  223. package/dist/index.es204.js +5 -6
  224. package/dist/index.es204.js.map +1 -1
  225. package/dist/index.es205.js +6 -41
  226. package/dist/index.es205.js.map +1 -1
  227. package/dist/index.es206.js +41 -12
  228. package/dist/index.es206.js.map +1 -1
  229. package/dist/index.es207.js +11 -240
  230. package/dist/index.es207.js.map +1 -1
  231. package/dist/index.es208.js +239 -48
  232. package/dist/index.es208.js.map +1 -1
  233. package/dist/index.es209.js +49 -33
  234. package/dist/index.es209.js.map +1 -1
  235. package/dist/index.es21.js +3 -3
  236. package/dist/index.es21.js.map +1 -1
  237. package/dist/index.es210.js +32 -10
  238. package/dist/index.es210.js.map +1 -1
  239. package/dist/index.es211.js +12 -7
  240. package/dist/index.es211.js.map +1 -1
  241. package/dist/index.es212.js +7 -6
  242. package/dist/index.es212.js.map +1 -1
  243. package/dist/index.es213.js +6 -64
  244. package/dist/index.es213.js.map +1 -1
  245. package/dist/index.es214.js +60 -36
  246. package/dist/index.es214.js.map +1 -1
  247. package/dist/index.es215.js +39 -30
  248. package/dist/index.es215.js.map +1 -1
  249. package/dist/index.es216.js +30 -60
  250. package/dist/index.es216.js.map +1 -1
  251. package/dist/index.es217.js +60 -13
  252. package/dist/index.es217.js.map +1 -1
  253. package/dist/index.es218.js +9 -17
  254. package/dist/index.es218.js.map +1 -1
  255. package/dist/index.es219.js +23 -5
  256. package/dist/index.es219.js.map +1 -1
  257. package/dist/index.es22.js +1 -1
  258. package/dist/index.es220.js +4 -16
  259. package/dist/index.es220.js.map +1 -1
  260. package/dist/index.es221.js +14 -30
  261. package/dist/index.es221.js.map +1 -1
  262. package/dist/index.es222.js +32 -4
  263. package/dist/index.es222.js.map +1 -1
  264. package/dist/index.es223.js +4 -4
  265. package/dist/index.es223.js.map +1 -1
  266. package/dist/index.es224.js +5 -5
  267. package/dist/index.es224.js.map +1 -1
  268. package/dist/index.es225.js +5 -8
  269. package/dist/index.es225.js.map +1 -1
  270. package/dist/index.es226.js +6 -90
  271. package/dist/index.es226.js.map +1 -1
  272. package/dist/index.es227.js +90 -16
  273. package/dist/index.es227.js.map +1 -1
  274. package/dist/index.es228.js +17 -761
  275. package/dist/index.es228.js.map +1 -1
  276. package/dist/index.es229.js +762 -66
  277. package/dist/index.es229.js.map +1 -1
  278. package/dist/index.es230.js +66 -174
  279. package/dist/index.es230.js.map +1 -1
  280. package/dist/index.es231.js +169 -33
  281. package/dist/index.es231.js.map +1 -1
  282. package/dist/index.es232.js +37 -136
  283. package/dist/index.es232.js.map +1 -1
  284. package/dist/index.es233.js +136 -92
  285. package/dist/index.es233.js.map +1 -1
  286. package/dist/index.es234.js +92 -32
  287. package/dist/index.es234.js.map +1 -1
  288. package/dist/index.es235.js +32 -284
  289. package/dist/index.es235.js.map +1 -1
  290. package/dist/index.es236.js +284 -25
  291. package/dist/index.es236.js.map +1 -1
  292. package/dist/index.es237.js +22 -20
  293. package/dist/index.es237.js.map +1 -1
  294. package/dist/index.es238.js +22 -13
  295. package/dist/index.es238.js.map +1 -1
  296. package/dist/index.es239.js +12 -12
  297. package/dist/index.es239.js.map +1 -1
  298. package/dist/index.es24.js +103 -305
  299. package/dist/index.es24.js.map +1 -1
  300. package/dist/index.es240.js +13 -24
  301. package/dist/index.es240.js.map +1 -1
  302. package/dist/index.es241.js +22 -42
  303. package/dist/index.es241.js.map +1 -1
  304. package/dist/index.es242.js +45 -11
  305. package/dist/index.es242.js.map +1 -1
  306. package/dist/index.es243.js +10 -10
  307. package/dist/index.es243.js.map +1 -1
  308. package/dist/index.es244.js +10 -10
  309. package/dist/index.es244.js.map +1 -1
  310. package/dist/index.es245.js +11 -14
  311. package/dist/index.es245.js.map +1 -1
  312. package/dist/index.es246.js +14 -11
  313. package/dist/index.es246.js.map +1 -1
  314. package/dist/index.es247.js +11 -11
  315. package/dist/index.es247.js.map +1 -1
  316. package/dist/index.es248.js +10 -10
  317. package/dist/index.es248.js.map +1 -1
  318. package/dist/index.es249.js +11 -15
  319. package/dist/index.es249.js.map +1 -1
  320. package/dist/index.es25.js +68 -121
  321. package/dist/index.es25.js.map +1 -1
  322. package/dist/index.es250.js +15 -11
  323. package/dist/index.es250.js.map +1 -1
  324. package/dist/index.es251.js +10 -10
  325. package/dist/index.es251.js.map +1 -1
  326. package/dist/index.es252.js +11 -11
  327. package/dist/index.es252.js.map +1 -1
  328. package/dist/index.es253.js +10 -10
  329. package/dist/index.es253.js.map +1 -1
  330. package/dist/index.es254.js +10 -10
  331. package/dist/index.es254.js.map +1 -1
  332. package/dist/index.es255.js +10 -10
  333. package/dist/index.es255.js.map +1 -1
  334. package/dist/index.es256.js +10 -10
  335. package/dist/index.es256.js.map +1 -1
  336. package/dist/index.es257.js +10 -10
  337. package/dist/index.es257.js.map +1 -1
  338. package/dist/index.es258.js +11 -56
  339. package/dist/index.es258.js.map +1 -1
  340. package/dist/index.es259.js +53 -46
  341. package/dist/index.es259.js.map +1 -1
  342. package/dist/index.es26.js +305 -5
  343. package/dist/index.es26.js.map +1 -1
  344. package/dist/index.es260.js +42 -112
  345. package/dist/index.es260.js.map +1 -1
  346. package/dist/index.es261.js +87 -352
  347. package/dist/index.es261.js.map +1 -1
  348. package/dist/index.es262.js +381 -15
  349. package/dist/index.es262.js.map +1 -1
  350. package/dist/index.es263.js +17 -10
  351. package/dist/index.es263.js.map +1 -1
  352. package/dist/index.es264.js +10 -30
  353. package/dist/index.es264.js.map +1 -1
  354. package/dist/index.es265.js +17 -17
  355. package/dist/index.es265.js.map +1 -1
  356. package/dist/index.es266.js +25 -56
  357. package/dist/index.es266.js.map +1 -1
  358. package/dist/index.es267.js +59 -14
  359. package/dist/index.es267.js.map +1 -1
  360. package/dist/index.es268.js +14 -74
  361. package/dist/index.es268.js.map +1 -1
  362. package/dist/index.es269.js +77 -11
  363. package/dist/index.es269.js.map +1 -1
  364. package/dist/index.es270.js +10 -10
  365. package/dist/index.es270.js.map +1 -1
  366. package/dist/index.es271.js +11 -15
  367. package/dist/index.es271.js.map +1 -1
  368. package/dist/index.es272.js +14 -51
  369. package/dist/index.es272.js.map +1 -1
  370. package/dist/index.es273.js +44 -158
  371. package/dist/index.es273.js.map +1 -1
  372. package/dist/index.es274.js +167 -2
  373. package/dist/index.es274.js.map +1 -1
  374. package/dist/index.es275.js +2 -11
  375. package/dist/index.es275.js.map +1 -1
  376. package/dist/index.es276.js +9 -18
  377. package/dist/index.es276.js.map +1 -1
  378. package/dist/index.es277.js +17 -36
  379. package/dist/index.es277.js.map +1 -1
  380. package/dist/index.es278.js +42 -0
  381. package/dist/index.es278.js.map +1 -0
  382. package/dist/index.es28.js +7 -7
  383. package/dist/index.es29.js +1 -1
  384. package/dist/index.es32.js +4 -4
  385. package/dist/index.es33.js +1191 -13
  386. package/dist/index.es33.js.map +1 -1
  387. package/dist/index.es34.js +6 -117
  388. package/dist/index.es34.js.map +1 -1
  389. package/dist/index.es35.js +8 -70
  390. package/dist/index.es35.js.map +1 -1
  391. package/dist/index.es36.js +148 -19
  392. package/dist/index.es36.js.map +1 -1
  393. package/dist/index.es37.js +112 -255
  394. package/dist/index.es37.js.map +1 -1
  395. package/dist/index.es38.js +68 -40
  396. package/dist/index.es38.js.map +1 -1
  397. package/dist/index.es39.js +17 -214
  398. package/dist/index.es39.js.map +1 -1
  399. package/dist/index.es40.js +247 -53
  400. package/dist/index.es40.js.map +1 -1
  401. package/dist/index.es41.js +24 -123
  402. package/dist/index.es41.js.map +1 -1
  403. package/dist/index.es42.js +205 -14
  404. package/dist/index.es42.js.map +1 -1
  405. package/dist/index.es43.js +58 -221
  406. package/dist/index.es43.js.map +1 -1
  407. package/dist/index.es44.js +140 -7
  408. package/dist/index.es44.js.map +1 -1
  409. package/dist/index.es45.js +17 -1185
  410. package/dist/index.es45.js.map +1 -1
  411. package/dist/index.es46.js +229 -6
  412. package/dist/index.es46.js.map +1 -1
  413. package/dist/index.es47.js +15 -146
  414. package/dist/index.es47.js.map +1 -1
  415. package/dist/index.es48.js +6 -8
  416. package/dist/index.es48.js.map +1 -1
  417. package/dist/index.es49.js +84 -87
  418. package/dist/index.es49.js.map +1 -1
  419. package/dist/index.es50.js +7 -3
  420. package/dist/index.es50.js.map +1 -1
  421. package/dist/index.es51.js +14 -35
  422. package/dist/index.es51.js.map +1 -1
  423. package/dist/index.es52.js +7 -71
  424. package/dist/index.es52.js.map +1 -1
  425. package/dist/index.es53.js +89 -33
  426. package/dist/index.es53.js.map +1 -1
  427. package/dist/index.es54.js +3 -305
  428. package/dist/index.es54.js.map +1 -1
  429. package/dist/index.es55.js +36 -9
  430. package/dist/index.es55.js.map +1 -1
  431. package/dist/index.es56.js +64 -83
  432. package/dist/index.es56.js.map +1 -1
  433. package/dist/index.es57.js +36 -6
  434. package/dist/index.es57.js.map +1 -1
  435. package/dist/index.es58.js +303 -12
  436. package/dist/index.es58.js.map +1 -1
  437. package/dist/index.es59.js +9 -143
  438. package/dist/index.es59.js.map +1 -1
  439. package/dist/index.es60.js +5 -299
  440. package/dist/index.es60.js.map +1 -1
  441. package/dist/index.es61.js +158 -61
  442. package/dist/index.es61.js.map +1 -1
  443. package/dist/index.es62.js +658 -199
  444. package/dist/index.es62.js.map +1 -1
  445. package/dist/index.es63.js +138 -29
  446. package/dist/index.es63.js.map +1 -1
  447. package/dist/index.es64.js +299 -8
  448. package/dist/index.es64.js.map +1 -1
  449. package/dist/index.es65.js +65 -11
  450. package/dist/index.es65.js.map +1 -1
  451. package/dist/index.es66.js +201 -175
  452. package/dist/index.es66.js.map +1 -1
  453. package/dist/index.es67.js +33 -23
  454. package/dist/index.es67.js.map +1 -1
  455. package/dist/index.es68.js +8 -1399
  456. package/dist/index.es68.js.map +1 -1
  457. package/dist/index.es69.js +12 -9
  458. package/dist/index.es69.js.map +1 -1
  459. package/dist/index.es70.js +187 -8
  460. package/dist/index.es70.js.map +1 -1
  461. package/dist/index.es71.js +24 -6
  462. package/dist/index.es71.js.map +1 -1
  463. package/dist/index.es72.js +1384 -147
  464. package/dist/index.es72.js.map +1 -1
  465. package/dist/index.es73.js +9 -672
  466. package/dist/index.es73.js.map +1 -1
  467. package/dist/index.es74.js +8 -12
  468. package/dist/index.es74.js.map +1 -1
  469. package/dist/index.es75.js +35 -38
  470. package/dist/index.es75.js.map +1 -1
  471. package/dist/index.es76.js +5 -34
  472. package/dist/index.es76.js.map +1 -1
  473. package/dist/index.es77.js +64 -223
  474. package/dist/index.es77.js.map +1 -1
  475. package/dist/index.es78.js +36 -29
  476. package/dist/index.es78.js.map +1 -1
  477. package/dist/index.es79.js +11 -74
  478. package/dist/index.es79.js.map +1 -1
  479. package/dist/index.es80.js +37 -73
  480. package/dist/index.es80.js.map +1 -1
  481. package/dist/index.es81.js +32 -50
  482. package/dist/index.es81.js.map +1 -1
  483. package/dist/index.es82.js +228 -26
  484. package/dist/index.es82.js.map +1 -1
  485. package/dist/index.es83.js +6 -19
  486. package/dist/index.es83.js.map +1 -1
  487. package/dist/index.es84.js +72 -54
  488. package/dist/index.es84.js.map +1 -1
  489. package/dist/index.es85.js +76 -13
  490. package/dist/index.es85.js.map +1 -1
  491. package/dist/index.es86.js +47 -132
  492. package/dist/index.es86.js.map +1 -1
  493. package/dist/index.es87.js +29 -20
  494. package/dist/index.es87.js.map +1 -1
  495. package/dist/index.es88.js +37 -176
  496. package/dist/index.es88.js.map +1 -1
  497. package/dist/index.es89.js +49 -233
  498. package/dist/index.es89.js.map +1 -1
  499. package/dist/index.es90.js +13 -355
  500. package/dist/index.es90.js.map +1 -1
  501. package/dist/index.es91.js +128 -128
  502. package/dist/index.es91.js.map +1 -1
  503. package/dist/index.es92.js +21 -70
  504. package/dist/index.es92.js.map +1 -1
  505. package/dist/index.es93.js +179 -34
  506. package/dist/index.es93.js.map +1 -1
  507. package/dist/index.es94.js +230 -26
  508. package/dist/index.es94.js.map +1 -1
  509. package/dist/index.es95.js +346 -157
  510. package/dist/index.es95.js.map +1 -1
  511. package/dist/index.es96.js +129 -195
  512. package/dist/index.es96.js.map +1 -1
  513. package/dist/index.es97.js +70 -14
  514. package/dist/index.es97.js.map +1 -1
  515. package/dist/index.es98.js +35 -28
  516. package/dist/index.es98.js.map +1 -1
  517. package/dist/index.es99.js +34 -31
  518. package/dist/index.es99.js.map +1 -1
  519. package/dist/styles.css +1 -1
  520. package/package.json +8 -11
@@ -1,216 +1,675 @@
1
- import { _isObject, _isArray, _isString, _isContentBlock, iife } from "./index.es76.js";
2
- import { isOpenAIDataBlock, convertToV1FromOpenAIDataBlock } from "./index.es61.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;
17
- }
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
1
+ import EventEmitter from "./index.es76.js";
2
+ import pTimeout from "./index.es77.js";
3
+ import { TimeoutError } from "./index.es77.js";
4
+ import PriorityQueue from "./index.es78.js";
5
+ class PQueue extends EventEmitter {
6
+ #carryoverIntervalCount;
7
+ #isIntervalIgnored;
8
+ #intervalCount = 0;
9
+ #intervalCap;
10
+ #rateLimitedInInterval = false;
11
+ #rateLimitFlushScheduled = false;
12
+ #interval;
13
+ #intervalEnd = 0;
14
+ #lastExecutionTime = 0;
15
+ #intervalId;
16
+ #timeoutId;
17
+ #strict;
18
+ // Circular buffer implementation for better performance
19
+ #strictTicks = [];
20
+ #strictTicksStartIndex = 0;
21
+ #queue;
22
+ #queueClass;
23
+ #pending = 0;
24
+ // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194
25
+ #concurrency;
26
+ #isPaused;
27
+ // Use to assign a unique identifier to a promise function, if not explicitly specified
28
+ #idAssigner = 1n;
29
+ // Track currently running tasks for debugging
30
+ #runningTasks = /* @__PURE__ */ new Map();
31
+ /**
32
+ Get or set the default timeout for all tasks. Can be changed at runtime.
33
+
34
+ Operations will throw a `TimeoutError` if they don't complete within the specified time.
35
+
36
+ The timeout begins when the operation is dequeued and starts execution, not while it's waiting in the queue.
37
+
38
+ @example
39
+ ```
40
+ const queue = new PQueue({timeout: 5000});
41
+
42
+ // Change timeout for all future tasks
43
+ queue.timeout = 10000;
44
+ ```
45
+ */
46
+ timeout;
47
+ constructor(options) {
48
+ super();
49
+ options = {
50
+ carryoverIntervalCount: false,
51
+ intervalCap: Number.POSITIVE_INFINITY,
52
+ interval: 0,
53
+ concurrency: Number.POSITIVE_INFINITY,
54
+ autoStart: true,
55
+ queueClass: PriorityQueue,
56
+ strict: false,
57
+ ...options
48
58
  };
59
+ if (!(typeof options.intervalCap === "number" && options.intervalCap >= 1)) {
60
+ throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${options.intervalCap?.toString() ?? ""}\` (${typeof options.intervalCap})`);
61
+ }
62
+ if (options.interval === void 0 || !(Number.isFinite(options.interval) && options.interval >= 0)) {
63
+ throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${options.interval?.toString() ?? ""}\` (${typeof options.interval})`);
64
+ }
65
+ if (options.strict && options.interval === 0) {
66
+ throw new TypeError("The `strict` option requires a non-zero `interval`");
67
+ }
68
+ if (options.strict && options.intervalCap === Number.POSITIVE_INFINITY) {
69
+ throw new TypeError("The `strict` option requires a finite `intervalCap`");
70
+ }
71
+ this.#carryoverIntervalCount = options.carryoverIntervalCount ?? options.carryoverConcurrencyCount ?? false;
72
+ this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;
73
+ this.#intervalCap = options.intervalCap;
74
+ this.#interval = options.interval;
75
+ this.#strict = options.strict;
76
+ this.#queue = new options.queueClass();
77
+ this.#queueClass = options.queueClass;
78
+ this.concurrency = options.concurrency;
79
+ if (options.timeout !== void 0 && !(Number.isFinite(options.timeout) && options.timeout > 0)) {
80
+ throw new TypeError(`Expected \`timeout\` to be a positive finite number, got \`${options.timeout}\` (${typeof options.timeout})`);
81
+ }
82
+ this.timeout = options.timeout;
83
+ this.#isPaused = options.autoStart === false;
84
+ this.#setupRateLimitTracking();
49
85
  }
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
- };
86
+ #cleanupStrictTicks(now) {
87
+ while (this.#strictTicksStartIndex < this.#strictTicks.length) {
88
+ const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
89
+ if (oldestTick !== void 0 && now - oldestTick >= this.#interval) {
90
+ this.#strictTicksStartIndex++;
91
+ } else {
92
+ break;
93
+ }
94
+ }
95
+ const shouldCompact = this.#strictTicksStartIndex > 100 && this.#strictTicksStartIndex > this.#strictTicks.length / 2 || this.#strictTicksStartIndex === this.#strictTicks.length;
96
+ if (shouldCompact) {
97
+ this.#strictTicks = this.#strictTicks.slice(this.#strictTicksStartIndex);
98
+ this.#strictTicksStartIndex = 0;
99
+ }
59
100
  }
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
- };
101
+ // Helper methods for interval consumption
102
+ #consumeIntervalSlot(now) {
103
+ if (this.#strict) {
104
+ this.#strictTicks.push(now);
105
+ } else {
106
+ this.#intervalCount++;
73
107
  }
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
- };
108
+ }
109
+ #rollbackIntervalSlot() {
110
+ if (this.#strict) {
111
+ if (this.#strictTicks.length > this.#strictTicksStartIndex) {
112
+ this.#strictTicks.pop();
113
+ }
114
+ } else if (this.#intervalCount > 0) {
115
+ this.#intervalCount--;
116
+ }
117
+ }
118
+ #getActiveTicksCount() {
119
+ return this.#strictTicks.length - this.#strictTicksStartIndex;
120
+ }
121
+ get #doesIntervalAllowAnother() {
122
+ if (this.#isIntervalIgnored) {
123
+ return true;
124
+ }
125
+ if (this.#strict) {
126
+ return this.#getActiveTicksCount() < this.#intervalCap;
127
+ }
128
+ return this.#intervalCount < this.#intervalCap;
129
+ }
130
+ get #doesConcurrentAllowAnother() {
131
+ return this.#pending < this.#concurrency;
132
+ }
133
+ #next() {
134
+ this.#pending--;
135
+ if (this.#pending === 0) {
136
+ this.emit("pendingZero");
137
+ }
138
+ this.#tryToStartAnother();
139
+ this.emit("next");
140
+ }
141
+ #onResumeInterval() {
142
+ this.#timeoutId = void 0;
143
+ this.#onInterval();
144
+ this.#initializeIntervalIfNeeded();
145
+ }
146
+ #isIntervalPausedAt(now) {
147
+ if (this.#strict) {
148
+ this.#cleanupStrictTicks(now);
149
+ const activeTicksCount = this.#getActiveTicksCount();
150
+ if (activeTicksCount >= this.#intervalCap) {
151
+ const oldestTick = this.#strictTicks[this.#strictTicksStartIndex];
152
+ const delay = this.#interval - (now - oldestTick);
153
+ this.#createIntervalTimeout(delay);
154
+ return true;
155
+ }
156
+ return false;
157
+ }
158
+ if (this.#intervalId === void 0) {
159
+ const delay = this.#intervalEnd - now;
160
+ if (delay < 0) {
161
+ if (this.#lastExecutionTime > 0) {
162
+ const timeSinceLastExecution = now - this.#lastExecutionTime;
163
+ if (timeSinceLastExecution < this.#interval) {
164
+ this.#createIntervalTimeout(this.#interval - timeSinceLastExecution);
165
+ return true;
166
+ }
167
+ }
168
+ this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
169
+ } else {
170
+ this.#createIntervalTimeout(delay);
171
+ return true;
172
+ }
173
+ }
174
+ return false;
175
+ }
176
+ #createIntervalTimeout(delay) {
177
+ if (this.#timeoutId !== void 0) {
178
+ return;
179
+ }
180
+ this.#timeoutId = setTimeout(() => {
181
+ this.#onResumeInterval();
182
+ }, delay);
183
+ }
184
+ #clearIntervalTimer() {
185
+ if (this.#intervalId) {
186
+ clearInterval(this.#intervalId);
187
+ this.#intervalId = void 0;
188
+ }
189
+ }
190
+ #clearTimeoutTimer() {
191
+ if (this.#timeoutId) {
192
+ clearTimeout(this.#timeoutId);
193
+ this.#timeoutId = void 0;
194
+ }
195
+ }
196
+ #tryToStartAnother() {
197
+ if (this.#queue.size === 0) {
198
+ this.#clearIntervalTimer();
199
+ this.emit("empty");
200
+ if (this.#pending === 0) {
201
+ this.#clearTimeoutTimer();
202
+ if (this.#strict && this.#strictTicksStartIndex > 0) {
203
+ const now = Date.now();
204
+ this.#cleanupStrictTicks(now);
205
+ }
206
+ this.emit("idle");
207
+ }
208
+ return false;
209
+ }
210
+ let taskStarted = false;
211
+ if (!this.#isPaused) {
212
+ const now = Date.now();
213
+ const canInitializeInterval = !this.#isIntervalPausedAt(now);
214
+ if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {
215
+ const job = this.#queue.dequeue();
216
+ if (!this.#isIntervalIgnored) {
217
+ this.#consumeIntervalSlot(now);
218
+ this.#scheduleRateLimitUpdate();
219
+ }
220
+ this.emit("active");
221
+ job();
222
+ if (canInitializeInterval) {
223
+ this.#initializeIntervalIfNeeded();
224
+ }
225
+ taskStarted = true;
226
+ }
227
+ }
228
+ return taskStarted;
229
+ }
230
+ #initializeIntervalIfNeeded() {
231
+ if (this.#isIntervalIgnored || this.#intervalId !== void 0) {
232
+ return;
91
233
  }
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
234
+ if (this.#strict) {
235
+ return;
236
+ }
237
+ this.#intervalId = setInterval(() => {
238
+ this.#onInterval();
239
+ }, this.#interval);
240
+ this.#intervalEnd = Date.now() + this.#interval;
241
+ }
242
+ #onInterval() {
243
+ if (!this.#strict) {
244
+ if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {
245
+ this.#clearIntervalTimer();
246
+ }
247
+ this.#intervalCount = this.#carryoverIntervalCount ? this.#pending : 0;
248
+ }
249
+ this.#processQueue();
250
+ this.#scheduleRateLimitUpdate();
251
+ }
252
+ /**
253
+ Executes all queued functions until it reaches the limit.
254
+ */
255
+ #processQueue() {
256
+ while (this.#tryToStartAnother()) {
257
+ }
258
+ }
259
+ get concurrency() {
260
+ return this.#concurrency;
261
+ }
262
+ set concurrency(newConcurrency) {
263
+ if (!(typeof newConcurrency === "number" && newConcurrency >= 1)) {
264
+ throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${newConcurrency}\` (${typeof newConcurrency})`);
265
+ }
266
+ this.#concurrency = newConcurrency;
267
+ this.#processQueue();
268
+ }
269
+ /**
270
+ Updates the priority of a promise function by its id, affecting its execution order. Requires a defined concurrency limit to take effect.
271
+
272
+ For example, this can be used to prioritize a promise function to run earlier.
273
+
274
+ ```js
275
+ import PQueue from 'p-queue';
276
+
277
+ const queue = new PQueue({concurrency: 1});
278
+
279
+ queue.add(async () => '🦄', {priority: 1});
280
+ queue.add(async () => '🦀', {priority: 0, id: '🦀'});
281
+ queue.add(async () => '🦄', {priority: 1});
282
+ queue.add(async () => '🦄', {priority: 1});
283
+
284
+ queue.setPriority('🦀', 2);
285
+ ```
286
+
287
+ In this case, the promise function with `id: '🦀'` runs second.
288
+
289
+ You can also deprioritize a promise function to delay its execution:
290
+
291
+ ```js
292
+ import PQueue from 'p-queue';
293
+
294
+ const queue = new PQueue({concurrency: 1});
295
+
296
+ queue.add(async () => '🦄', {priority: 1});
297
+ queue.add(async () => '🦀', {priority: 1, id: '🦀'});
298
+ queue.add(async () => '🦄');
299
+ queue.add(async () => '🦄', {priority: 0});
300
+
301
+ queue.setPriority('🦀', -1);
302
+ ```
303
+ Here, the promise function with `id: '🦀'` executes last.
304
+ */
305
+ setPriority(id, priority) {
306
+ if (typeof priority !== "number" || !Number.isFinite(priority)) {
307
+ throw new TypeError(`Expected \`priority\` to be a finite number, got \`${priority}\` (${typeof priority})`);
308
+ }
309
+ this.#queue.setPriority(id, priority);
310
+ }
311
+ async add(function_, options = {}) {
312
+ options = {
313
+ timeout: this.timeout,
314
+ ...options,
315
+ // Assign unique ID if not provided
316
+ id: options.id ?? (this.#idAssigner++).toString()
97
317
  };
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;
318
+ return new Promise((resolve, reject) => {
319
+ const taskSymbol = /* @__PURE__ */ Symbol(`task-${options.id}`);
320
+ this.#queue.enqueue(async () => {
321
+ this.#pending++;
322
+ this.#runningTasks.set(taskSymbol, {
323
+ id: options.id,
324
+ priority: options.priority ?? 0,
325
+ // Match priority-queue default
326
+ startTime: Date.now(),
327
+ timeout: options.timeout
328
+ });
329
+ let eventListener;
330
+ try {
331
+ try {
332
+ options.signal?.throwIfAborted();
333
+ } catch (error) {
334
+ this.#rollbackIntervalConsumption();
335
+ this.#runningTasks.delete(taskSymbol);
336
+ throw error;
337
+ }
338
+ this.#lastExecutionTime = Date.now();
339
+ let operation = function_({ signal: options.signal });
340
+ if (options.timeout) {
341
+ operation = pTimeout(Promise.resolve(operation), {
342
+ milliseconds: options.timeout,
343
+ message: `Task timed out after ${options.timeout}ms (queue has ${this.#pending} running, ${this.#queue.size} waiting)`
344
+ });
150
345
  }
346
+ if (options.signal) {
347
+ const { signal } = options;
348
+ operation = Promise.race([operation, new Promise((_resolve, reject2) => {
349
+ eventListener = () => {
350
+ reject2(signal.reason);
351
+ };
352
+ signal.addEventListener("abort", eventListener, { once: true });
353
+ })]);
354
+ }
355
+ const result = await operation;
356
+ resolve(result);
357
+ this.emit("completed", result);
358
+ } catch (error) {
359
+ reject(error);
360
+ this.emit("error", error);
361
+ } finally {
362
+ if (eventListener) {
363
+ options.signal?.removeEventListener("abort", eventListener);
364
+ }
365
+ this.#runningTasks.delete(taskSymbol);
366
+ queueMicrotask(() => {
367
+ this.#next();
368
+ });
151
369
  }
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;
370
+ }, options);
371
+ this.emit("add");
372
+ this.#tryToStartAnother();
373
+ });
374
+ }
375
+ async addAll(functions, options) {
376
+ return Promise.all(functions.map(async (function_) => this.add(function_, options)));
377
+ }
378
+ /**
379
+ Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)
380
+ */
381
+ start() {
382
+ if (!this.#isPaused) {
383
+ return this;
384
+ }
385
+ this.#isPaused = false;
386
+ this.#processQueue();
387
+ return this;
388
+ }
389
+ /**
390
+ Put queue execution on hold.
391
+ */
392
+ pause() {
393
+ this.#isPaused = true;
394
+ }
395
+ /**
396
+ Clear the queue.
397
+ */
398
+ clear() {
399
+ this.#queue = new this.#queueClass();
400
+ this.#clearIntervalTimer();
401
+ this.#updateRateLimitState();
402
+ this.emit("empty");
403
+ if (this.#pending === 0) {
404
+ this.#clearTimeoutTimer();
405
+ this.emit("idle");
406
+ }
407
+ this.emit("next");
408
+ }
409
+ /**
410
+ Can be called multiple times. Useful if you for example add additional items at a later time.
411
+
412
+ @returns A promise that settles when the queue becomes empty.
413
+ */
414
+ async onEmpty() {
415
+ if (this.#queue.size === 0) {
416
+ return;
417
+ }
418
+ await this.#onEvent("empty");
419
+ }
420
+ /**
421
+ @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.
422
+
423
+ If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.
424
+
425
+ Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.
426
+ */
427
+ async onSizeLessThan(limit) {
428
+ if (this.#queue.size < limit) {
429
+ return;
430
+ }
431
+ await this.#onEvent("next", () => this.#queue.size < limit);
432
+ }
433
+ /**
434
+ The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.
435
+
436
+ @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.
437
+ */
438
+ async onIdle() {
439
+ if (this.#pending === 0 && this.#queue.size === 0) {
440
+ return;
441
+ }
442
+ await this.#onEvent("idle");
443
+ }
444
+ /**
445
+ The difference with `.onIdle` is that `.onPendingZero` only waits for currently running tasks to finish, ignoring queued tasks.
446
+
447
+ @returns A promise that settles when all currently running tasks have completed; `queue.pending === 0`.
448
+ */
449
+ async onPendingZero() {
450
+ if (this.#pending === 0) {
451
+ return;
452
+ }
453
+ await this.#onEvent("pendingZero");
454
+ }
455
+ /**
456
+ @returns A promise that settles when the queue becomes rate-limited due to intervalCap.
457
+ */
458
+ async onRateLimit() {
459
+ if (this.isRateLimited) {
460
+ return;
461
+ }
462
+ await this.#onEvent("rateLimit");
463
+ }
464
+ /**
465
+ @returns A promise that settles when the queue is no longer rate-limited.
466
+ */
467
+ async onRateLimitCleared() {
468
+ if (!this.isRateLimited) {
469
+ return;
470
+ }
471
+ await this.#onEvent("rateLimitCleared");
472
+ }
473
+ /**
474
+ @returns A promise that rejects when any task in the queue errors.
475
+
476
+ Use with `Promise.race([queue.onError(), queue.onIdle()])` to fail fast on the first error while still resolving normally when the queue goes idle.
477
+
478
+ Important: The promise returned by `add()` still rejects. You must handle each `add()` promise (for example, `.catch(() => {})`) to avoid unhandled rejections.
479
+
480
+ @example
481
+ ```
482
+ import PQueue from 'p-queue';
483
+
484
+ const queue = new PQueue({concurrency: 2});
485
+
486
+ queue.add(() => fetchData(1)).catch(() => {});
487
+ queue.add(() => fetchData(2)).catch(() => {});
488
+ queue.add(() => fetchData(3)).catch(() => {});
489
+
490
+ // Stop processing on first error
491
+ try {
492
+ await Promise.race([
493
+ queue.onError(),
494
+ queue.onIdle()
495
+ ]);
496
+ } catch (error) {
497
+ queue.pause(); // Stop processing remaining tasks
498
+ console.error('Queue failed:', error);
181
499
  }
182
- if (_isObject(toolOutput)) yield {
183
- type: "non_standard",
184
- value: toolOutput
500
+ ```
501
+ */
502
+ // eslint-disable-next-line @typescript-eslint/promise-function-async
503
+ onError() {
504
+ return new Promise((_resolve, reject) => {
505
+ const handleError = (error) => {
506
+ this.off("error", handleError);
507
+ reject(error);
508
+ };
509
+ this.on("error", handleError);
510
+ });
511
+ }
512
+ async #onEvent(event, filter) {
513
+ return new Promise((resolve) => {
514
+ const listener = () => {
515
+ if (filter && !filter()) {
516
+ return;
517
+ }
518
+ this.off(event, listener);
519
+ resolve();
185
520
  };
521
+ this.on(event, listener);
522
+ });
523
+ }
524
+ /**
525
+ Size of the queue, the number of queued items waiting to run.
526
+ */
527
+ get size() {
528
+ return this.#queue.size;
529
+ }
530
+ /**
531
+ Size of the queue, filtered by the given options.
532
+
533
+ For example, this can be used to find the number of items remaining in the queue with a specific priority level.
534
+ */
535
+ sizeBy(options) {
536
+ return this.#queue.filter(options).length;
537
+ }
538
+ /**
539
+ Number of running items (no longer in the queue).
540
+ */
541
+ get pending() {
542
+ return this.#pending;
543
+ }
544
+ /**
545
+ Whether the queue is currently paused.
546
+ */
547
+ get isPaused() {
548
+ return this.#isPaused;
549
+ }
550
+ #setupRateLimitTracking() {
551
+ if (this.#isIntervalIgnored) {
552
+ return;
186
553
  }
554
+ this.on("add", () => {
555
+ if (this.#queue.size > 0) {
556
+ this.#scheduleRateLimitUpdate();
557
+ }
558
+ });
559
+ this.on("next", () => {
560
+ this.#scheduleRateLimitUpdate();
561
+ });
187
562
  }
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
- };
563
+ #scheduleRateLimitUpdate() {
564
+ if (this.#isIntervalIgnored || this.#rateLimitFlushScheduled) {
565
+ return;
566
+ }
567
+ this.#rateLimitFlushScheduled = true;
568
+ queueMicrotask(() => {
569
+ this.#rateLimitFlushScheduled = false;
570
+ this.#updateRateLimitState();
571
+ });
199
572
  }
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);
573
+ #rollbackIntervalConsumption() {
574
+ if (this.#isIntervalIgnored) {
575
+ return;
576
+ }
577
+ this.#rollbackIntervalSlot();
578
+ this.#scheduleRateLimitUpdate();
210
579
  }
211
- };
580
+ #updateRateLimitState() {
581
+ const previous = this.#rateLimitedInInterval;
582
+ if (this.#isIntervalIgnored || this.#queue.size === 0) {
583
+ if (previous) {
584
+ this.#rateLimitedInInterval = false;
585
+ this.emit("rateLimitCleared");
586
+ }
587
+ return;
588
+ }
589
+ let count;
590
+ if (this.#strict) {
591
+ const now = Date.now();
592
+ this.#cleanupStrictTicks(now);
593
+ count = this.#getActiveTicksCount();
594
+ } else {
595
+ count = this.#intervalCount;
596
+ }
597
+ const shouldBeRateLimited = count >= this.#intervalCap;
598
+ if (shouldBeRateLimited !== previous) {
599
+ this.#rateLimitedInInterval = shouldBeRateLimited;
600
+ this.emit(shouldBeRateLimited ? "rateLimit" : "rateLimitCleared");
601
+ }
602
+ }
603
+ /**
604
+ Whether the queue is currently rate-limited due to intervalCap.
605
+ */
606
+ get isRateLimited() {
607
+ return this.#rateLimitedInInterval;
608
+ }
609
+ /**
610
+ Whether the queue is saturated. Returns `true` when:
611
+ - All concurrency slots are occupied and tasks are waiting, OR
612
+ - The queue is rate-limited and tasks are waiting
613
+
614
+ Useful for detecting backpressure and potential hanging tasks.
615
+
616
+ ```js
617
+ import PQueue from 'p-queue';
618
+
619
+ const queue = new PQueue({concurrency: 2});
620
+
621
+ // Backpressure handling
622
+ if (queue.isSaturated) {
623
+ console.log('Queue is saturated, waiting for capacity...');
624
+ await queue.onSizeLessThan(queue.concurrency);
625
+ }
626
+
627
+ // Monitoring for stuck tasks
628
+ setInterval(() => {
629
+ if (queue.isSaturated) {
630
+ console.warn(`Queue saturated: ${queue.pending} running, ${queue.size} waiting`);
631
+ }
632
+ }, 60000);
633
+ ```
634
+ */
635
+ get isSaturated() {
636
+ return this.#pending === this.#concurrency && this.#queue.size > 0 || this.isRateLimited && this.#queue.size > 0;
637
+ }
638
+ /**
639
+ The tasks currently being executed. Each task includes its `id`, `priority`, `startTime`, and `timeout` (if set).
640
+
641
+ Returns an array of task info objects.
642
+
643
+ ```js
644
+ import PQueue from 'p-queue';
645
+
646
+ const queue = new PQueue({concurrency: 2});
647
+
648
+ // Add tasks with IDs for better debugging
649
+ queue.add(() => fetchUser(123), {id: 'user-123'});
650
+ queue.add(() => fetchPosts(456), {id: 'posts-456', priority: 1});
651
+
652
+ // Check what's running
653
+ console.log(queue.runningTasks);
654
+ // => [{
655
+ // id: 'user-123',
656
+ // priority: 0,
657
+ // startTime: 1759253001716,
658
+ // timeout: undefined
659
+ // }, {
660
+ // id: 'posts-456',
661
+ // priority: 1,
662
+ // startTime: 1759253001916,
663
+ // timeout: undefined
664
+ // }]
665
+ ```
666
+ */
667
+ get runningTasks() {
668
+ return [...this.#runningTasks.values()].map((task) => ({ ...task }));
669
+ }
670
+ }
212
671
  export {
213
- ChatOpenAITranslator,
214
- convertToV1FromChatCompletionsInput
672
+ TimeoutError,
673
+ PQueue as default
215
674
  };
216
675
  //# sourceMappingURL=index.es62.js.map