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.
- package/dist/index.es.js +3 -2
- package/dist/index.es10.js +25 -6
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es100.js +131 -64
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +65 -32
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +34 -34
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +35 -164
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +156 -193
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +202 -13
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +13 -29
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +25 -29
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +24 -3147
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +3151 -31
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es110.js +21 -5
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +64 -69
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +3 -37
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +16 -5
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +7 -2
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +2 -13
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +9 -499
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +501 -5
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +7 -2
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +2 -148
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es120.js +118 -878
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +877 -251
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +281 -3
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +3 -445
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +437 -39
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +46 -22
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +21 -78
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +76 -126
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +125 -45
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +48 -9
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es130.js +10 -45
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +43 -97
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +94 -48
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +51 -14
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es134.js +1 -1
- package/dist/index.es135.js +1 -1
- package/dist/index.es138.js +1 -1
- package/dist/index.es139.js +1 -1
- package/dist/index.es140.js +1 -1
- package/dist/index.es141.js +1 -1
- package/dist/index.es142.js +1 -1
- package/dist/index.es143.js +1 -1
- package/dist/index.es144.js +1 -1
- package/dist/index.es145.js +1 -1
- package/dist/index.es146.js +1 -1
- package/dist/index.es147.js +1 -1
- package/dist/index.es148.js +1 -1
- package/dist/index.es149.js +1 -1
- package/dist/index.es150.js +1 -1
- package/dist/index.es151.js +1 -1
- package/dist/index.es152.js +1 -1
- package/dist/index.es153.js +1 -1
- package/dist/index.es154.js +1 -1
- package/dist/index.es155.js +1 -1
- package/dist/index.es156.js +1 -1
- package/dist/index.es157.js +1 -1
- package/dist/index.es158.js +1 -1
- package/dist/index.es159.js +1 -1
- package/dist/index.es16.js +3 -3
- package/dist/index.es16.js.map +1 -1
- package/dist/index.es160.js +1 -1
- package/dist/index.es161.js +1 -1
- package/dist/index.es162.js +1 -1
- package/dist/index.es163.js +1 -1
- package/dist/index.es164.js +1 -1
- package/dist/index.es165.js +1 -1
- package/dist/index.es166.js +1 -1
- package/dist/index.es167.js +1 -1
- package/dist/index.es168.js +1 -1
- package/dist/index.es169.js +1 -1
- package/dist/index.es170.js +1 -1
- package/dist/index.es171.js +1 -1
- package/dist/index.es172.js +1 -1
- package/dist/index.es173.js +1 -1
- package/dist/index.es174.js +1 -1
- package/dist/index.es175.js +1 -1
- package/dist/index.es176.js +1 -1
- package/dist/index.es177.js +1 -1
- package/dist/index.es178.js +1 -1
- package/dist/index.es179.js +1 -1
- package/dist/index.es18.js +15 -15
- package/dist/index.es180.js +1 -1
- package/dist/index.es181.js +1 -1
- package/dist/index.es182.js +1 -1
- package/dist/index.es183.js +162 -13
- package/dist/index.es183.js.map +1 -1
- package/dist/index.es184.js +2 -89
- package/dist/index.es184.js.map +1 -1
- package/dist/index.es185.js +15 -2
- package/dist/index.es185.js.map +1 -1
- package/dist/index.es186.js +89 -2
- package/dist/index.es186.js.map +1 -1
- package/dist/index.es187.js +2 -2
- package/dist/index.es188.js +56 -2
- package/dist/index.es188.js.map +1 -1
- package/dist/index.es189.js +100 -2
- package/dist/index.es189.js.map +1 -1
- package/dist/index.es190.js +191 -2
- package/dist/index.es190.js.map +1 -1
- package/dist/index.es191.js +110 -2
- package/dist/index.es191.js.map +1 -1
- package/dist/index.es192.js +35 -2
- package/dist/index.es192.js.map +1 -1
- package/dist/index.es193.js +10 -2
- package/dist/index.es193.js.map +1 -1
- package/dist/index.es194.js +11 -2
- package/dist/index.es194.js.map +1 -1
- package/dist/index.es195.js +12 -2
- package/dist/index.es195.js.map +1 -1
- package/dist/index.es196.js +91 -2
- package/dist/index.es196.js.map +1 -1
- package/dist/index.es197.js +275 -2
- package/dist/index.es197.js.map +1 -1
- package/dist/index.es198.js +2 -2
- package/dist/index.es199.js +164 -2
- package/dist/index.es199.js.map +1 -1
- package/dist/index.es200.js +51 -2
- package/dist/index.es200.js.map +1 -1
- package/dist/index.es201.js +40 -2
- package/dist/index.es201.js.map +1 -1
- package/dist/index.es202.js +35 -2
- package/dist/index.es202.js.map +1 -1
- package/dist/index.es203.js +40 -2
- package/dist/index.es203.js.map +1 -1
- package/dist/index.es204.js +24 -2
- package/dist/index.es204.js.map +1 -1
- package/dist/index.es205.js +591 -2
- package/dist/index.es205.js.map +1 -1
- package/dist/index.es206.js +125 -2
- package/dist/index.es206.js.map +1 -1
- package/dist/index.es207.js +2 -2
- package/dist/index.es208.js +2 -2
- package/dist/index.es209.js +2 -2
- package/dist/index.es210.js +2 -2
- package/dist/index.es211.js +2 -2
- package/dist/index.es212.js +2 -2
- package/dist/index.es213.js +2 -2
- package/dist/index.es214.js +2 -2
- package/dist/index.es215.js +2 -2
- package/dist/index.es216.js +2 -2
- package/dist/index.es217.js +2 -2
- package/dist/index.es218.js +2 -2
- package/dist/index.es219.js +2 -2
- package/dist/index.es220.js +2 -2
- package/dist/index.es221.js +2 -2
- package/dist/index.es222.js +2 -2
- package/dist/index.es223.js +2 -2
- package/dist/index.es224.js +2 -2
- package/dist/index.es225.js +2 -2
- package/dist/index.es226.js +2 -2
- package/dist/index.es227.js +2 -2
- package/dist/index.es228.js +2 -2
- package/dist/index.es229.js +2 -2
- package/dist/index.es230.js +2 -2
- package/dist/index.es231.js +2 -56
- package/dist/index.es231.js.map +1 -1
- package/dist/index.es232.js +2 -100
- package/dist/index.es232.js.map +1 -1
- package/dist/index.es233.js +2 -191
- package/dist/index.es233.js.map +1 -1
- package/dist/index.es234.js +2 -110
- package/dist/index.es234.js.map +1 -1
- package/dist/index.es235.js +2 -35
- package/dist/index.es235.js.map +1 -1
- package/dist/index.es236.js +2 -10
- package/dist/index.es236.js.map +1 -1
- package/dist/index.es237.js +2 -11
- package/dist/index.es237.js.map +1 -1
- package/dist/index.es238.js +2 -12
- package/dist/index.es238.js.map +1 -1
- package/dist/index.es239.js +2 -91
- package/dist/index.es239.js.map +1 -1
- package/dist/index.es24.js +1 -1
- package/dist/index.es240.js +2 -275
- package/dist/index.es240.js.map +1 -1
- package/dist/index.es241.js +2 -2
- package/dist/index.es242.js +2 -164
- package/dist/index.es242.js.map +1 -1
- package/dist/index.es243.js +2 -51
- package/dist/index.es243.js.map +1 -1
- package/dist/index.es244.js +2 -40
- package/dist/index.es244.js.map +1 -1
- package/dist/index.es245.js +2 -35
- package/dist/index.es245.js.map +1 -1
- package/dist/index.es246.js +2 -40
- package/dist/index.es246.js.map +1 -1
- package/dist/index.es247.js +2 -24
- package/dist/index.es247.js.map +1 -1
- package/dist/index.es248.js +2 -591
- package/dist/index.es248.js.map +1 -1
- package/dist/index.es249.js +2 -125
- package/dist/index.es249.js.map +1 -1
- package/dist/index.es25.js +3 -1
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es250.js +2 -164
- package/dist/index.es250.js.map +1 -1
- package/dist/index.es251.js +2 -2
- package/dist/index.es252.js +2 -2
- package/dist/index.es253.js +1 -1
- package/dist/index.es258.js +1 -1
- package/dist/index.es260.js +2 -2
- package/dist/index.es262.js +2 -2
- package/dist/index.es265.js +1 -1
- package/dist/index.es267.js +1 -1
- package/dist/index.es277.js +2 -147
- package/dist/index.es277.js.map +1 -1
- package/dist/index.es278.js +126 -167
- package/dist/index.es278.js.map +1 -1
- package/dist/index.es279.js +188 -2
- package/dist/index.es279.js.map +1 -1
- package/dist/index.es280.js +1 -1
- package/dist/index.es283.js +1 -1
- package/dist/index.es288.js +1 -1
- package/dist/index.es29.js +1 -1
- package/dist/index.es3.js +24 -9
- package/dist/index.es3.js.map +1 -1
- package/dist/index.es300.js +1 -1
- package/dist/index.es302.js +1 -1
- package/dist/index.es31.js +7 -7
- package/dist/index.es314.js +1 -1
- package/dist/index.es32.js +1 -1
- package/dist/index.es334.js +2 -2
- package/dist/index.es35.js +4 -4
- package/dist/index.es36.js +1185 -111
- package/dist/index.es36.js.map +1 -1
- package/dist/index.es37.js +7 -71
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +9 -18
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +136 -250
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es4.js +2 -1
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es40.js +116 -41
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +64 -208
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +17 -66
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +236 -117
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +38 -19
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +202 -217
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +65 -7
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +131 -1181
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es48.js +25 -8
- package/dist/index.es48.js.map +1 -1
- package/dist/index.es49.js +218 -135
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es50.js +5 -208
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +208 -5
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +90 -7
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +6 -92
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +14 -3
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +8 -36
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es56.js +83 -61
- package/dist/index.es56.js.map +1 -1
- package/dist/index.es57.js +3 -37
- package/dist/index.es57.js.map +1 -1
- package/dist/index.es58.js +34 -304
- package/dist/index.es58.js.map +1 -1
- package/dist/index.es59.js +72 -9
- package/dist/index.es59.js.map +1 -1
- package/dist/index.es60.js +32 -85
- package/dist/index.es60.js.map +1 -1
- package/dist/index.es61.js +304 -6
- package/dist/index.es61.js.map +1 -1
- package/dist/index.es62.js +9 -15
- package/dist/index.es62.js.map +1 -1
- package/dist/index.es63.js +3 -3
- package/dist/index.es64.js +5 -142
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +148 -285
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +668 -62
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +131 -201
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +295 -29
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +65 -8
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es7.js +2 -1
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es70.js +210 -9
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +28 -181
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +8 -23
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +9 -1397
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +187 -9
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +24 -8
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +1399 -5
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +9 -163
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +8 -672
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +36 -20
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +5 -68
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +73 -3
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +36 -11
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +10 -38
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +34 -28
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +28 -226
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +228 -26
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +26 -71
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +41 -42
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +71 -47
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +37 -15
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +6 -19
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +40 -54
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +56 -12
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +13 -137
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +135 -19
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +18 -179
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +163 -222
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +187 -301
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +348 -130
- package/dist/index.es99.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -6,7 +6,7 @@ import { ThreadProvider, useThread } from "./index.es6.js";
|
|
|
6
6
|
import { StreamProvider, useStreamContext } from "./index.es7.js";
|
|
7
7
|
import { FileProvider, useFileProvider } from "./index.es8.js";
|
|
8
8
|
import { CustomComponentProvider, useCustomComponents } from "./index.es9.js";
|
|
9
|
-
import {
|
|
9
|
+
import { ToolsProvider, useTools } from "./index.es10.js";
|
|
10
10
|
import { useChatSuggestions } from "./index.es11.js";
|
|
11
11
|
export {
|
|
12
12
|
Chat,
|
|
@@ -17,12 +17,13 @@ export {
|
|
|
17
17
|
default2 as Sidebar,
|
|
18
18
|
StreamProvider,
|
|
19
19
|
ThreadProvider,
|
|
20
|
+
ToolsProvider,
|
|
20
21
|
useChatRuntime,
|
|
21
22
|
useChatSuggestions,
|
|
22
23
|
useCustomComponents,
|
|
23
24
|
useFileProvider,
|
|
24
25
|
useStreamContext,
|
|
25
26
|
useThread,
|
|
26
|
-
|
|
27
|
+
useTools
|
|
27
28
|
};
|
|
28
29
|
//# sourceMappingURL=index.es.js.map
|
package/dist/index.es10.js
CHANGED
|
@@ -1,20 +1,39 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Plus, Search } from "lucide-react";
|
|
3
|
-
import { useState } from "react";
|
|
4
|
-
|
|
3
|
+
import { createContext, useState, useContext } from "react";
|
|
4
|
+
const ToolsContext = createContext(void 0);
|
|
5
|
+
function ToolsProvider({ children }) {
|
|
5
6
|
const defaultTools = [
|
|
6
7
|
{ label: "New chat", alt: "Start New Chat", onClick: () => {
|
|
7
8
|
}, icon: /* @__PURE__ */ jsx(Plus, {}) },
|
|
8
9
|
{ label: "Search", alt: "Search the threads", onClick: () => {
|
|
9
10
|
}, icon: /* @__PURE__ */ jsx(Search, {}) }
|
|
10
11
|
];
|
|
11
|
-
const [
|
|
12
|
+
const [tools, setTools] = useState(defaultTools);
|
|
12
13
|
const addTool = (newTool) => {
|
|
13
|
-
setTools((prevTools) =>
|
|
14
|
+
setTools((prevTools) => {
|
|
15
|
+
const exists = prevTools.some((tool) => tool.label === newTool.label);
|
|
16
|
+
if (exists) {
|
|
17
|
+
console.warn(`Tool with label "${newTool.label}" already exists`);
|
|
18
|
+
return prevTools;
|
|
19
|
+
}
|
|
20
|
+
return [...prevTools, newTool];
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const removeTool = (label) => {
|
|
24
|
+
setTools((prevTools) => prevTools.filter((tool) => tool.label !== label));
|
|
14
25
|
};
|
|
15
|
-
return {
|
|
26
|
+
return /* @__PURE__ */ jsx(ToolsContext.Provider, { value: { tools, addTool, removeTool }, children });
|
|
27
|
+
}
|
|
28
|
+
function useTools() {
|
|
29
|
+
const context = useContext(ToolsContext);
|
|
30
|
+
if (context === void 0) {
|
|
31
|
+
throw new Error("useTools must be used within a ToolsProvider");
|
|
32
|
+
}
|
|
33
|
+
return context;
|
|
16
34
|
}
|
|
17
35
|
export {
|
|
18
|
-
|
|
36
|
+
ToolsProvider,
|
|
37
|
+
useTools
|
|
19
38
|
};
|
|
20
39
|
//# sourceMappingURL=index.es10.js.map
|
package/dist/index.es10.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es10.js","sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.es10.js","sources":["../src/providers/ToolsProvider.tsx"],"sourcesContent":["import type { CustomTool } from '@/types/CustomTools';\nimport { Plus, Search } from 'lucide-react';\nimport { createContext, useContext, useState, type ReactNode } from 'react';\n\ninterface ToolsContextType {\n tools: CustomTool[];\n addTool: (newTool: CustomTool) => void;\n removeTool: (label: string) => void;\n}\n\nconst ToolsContext = createContext<ToolsContextType | undefined>(undefined);\n\nexport function ToolsProvider({ children }: { children: ReactNode }) {\n const defaultTools: CustomTool[] = [\n { label: 'New chat', alt: 'Start New Chat', onClick: () => { }, icon: <Plus /> },\n { label: 'Search', alt: 'Search the threads', onClick: () => { }, icon: <Search /> },\n ];\n \n const [tools, setTools] = useState<CustomTool[]>(defaultTools);\n\n const addTool = (newTool: CustomTool) => {\n setTools((prevTools) => {\n // Prevent duplicates based on label\n const exists = prevTools.some(tool => tool.label === newTool.label);\n if (exists) {\n console.warn(`Tool with label \"${newTool.label}\" already exists`);\n return prevTools;\n }\n return [...prevTools, newTool];\n });\n };\n\n const removeTool = (label: string) => {\n setTools((prevTools) => prevTools.filter(tool => tool.label !== label));\n };\n\n return (\n <ToolsContext.Provider value={{ tools, addTool, removeTool }}>\n {children}\n </ToolsContext.Provider>\n );\n}\n\nexport function useTools() {\n const context = useContext(ToolsContext);\n if (context === undefined) {\n throw new Error('useTools must be used within a ToolsProvider');\n }\n return context;\n}\n"],"names":[],"mappings":";;;AAUA,MAAM,eAAe,cAA4C,MAAS;AAEnE,SAAS,cAAc,EAAE,YAAqC;AACjE,QAAM,eAA6B;AAAA,IAC/B,EAAE,OAAO,YAAY,KAAK,kBAAkB,SAAS,MAAM;AAAA,IAAE,GAAG,MAAM,oBAAC,MAAA,CAAA,CAAK,EAAA;AAAA,IAC5E,EAAE,OAAO,UAAU,KAAK,sBAAsB,SAAS,MAAM;AAAA,IAAE,GAAG,MAAM,oBAAC,QAAA,CAAA,CAAO,EAAA;AAAA,EAAG;AAGvF,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,YAAY;AAE7D,QAAM,UAAU,CAAC,YAAwB;AACrC,aAAS,CAAC,cAAc;AAEpB,YAAM,SAAS,UAAU,KAAK,UAAQ,KAAK,UAAU,QAAQ,KAAK;AAClE,UAAI,QAAQ;AACR,gBAAQ,KAAK,oBAAoB,QAAQ,KAAK,kBAAkB;AAChE,eAAO;AAAA,MACX;AACA,aAAO,CAAC,GAAG,WAAW,OAAO;AAAA,IACjC,CAAC;AAAA,EACL;AAEA,QAAM,aAAa,CAAC,UAAkB;AAClC,aAAS,CAAC,cAAc,UAAU,OAAO,UAAQ,KAAK,UAAU,KAAK,CAAC;AAAA,EAC1E;AAEA,SACI,oBAAC,aAAa,UAAb,EAAsB,OAAO,EAAE,OAAO,SAAS,cAC3C,UACL;AAER;AAEO,SAAS,WAAW;AACvB,QAAM,UAAU,WAAW,YAAY;AACvC,MAAI,YAAY,QAAW;AACvB,UAAM,IAAI,MAAM,8CAA8C;AAAA,EAClE;AACA,SAAO;AACX;"}
|
package/dist/index.es100.js
CHANGED
|
@@ -1,73 +1,140 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
throw err;
|
|
1
|
+
import { isNetworkError } from "./index.es126.js";
|
|
2
|
+
function validateRetries(retries) {
|
|
3
|
+
if (typeof retries === "number") {
|
|
4
|
+
if (retries < 0) throw new TypeError("Expected `retries` to be a non-negative number.");
|
|
5
|
+
if (Number.isNaN(retries)) throw new TypeError("Expected `retries` to be a valid number or Infinity, got NaN.");
|
|
6
|
+
} else if (retries !== void 0) throw new TypeError("Expected `retries` to be a number or Infinity.");
|
|
7
|
+
}
|
|
8
|
+
function validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {
|
|
9
|
+
if (value === void 0) return;
|
|
10
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw new TypeError(`Expected \`${name}\` to be a number${allowInfinity ? " or Infinity" : ""}.`);
|
|
11
|
+
if (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \`${name}\` to be a finite number.`);
|
|
12
|
+
if (value < min) throw new TypeError(`Expected \`${name}\` to be ≥ ${min}.`);
|
|
13
|
+
}
|
|
14
|
+
var AbortError = class extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super();
|
|
17
|
+
if (message instanceof Error) {
|
|
18
|
+
this.originalError = message;
|
|
19
|
+
({ message } = message);
|
|
20
|
+
} else {
|
|
21
|
+
this.originalError = new Error(message);
|
|
22
|
+
this.originalError.stack = this.stack;
|
|
23
|
+
}
|
|
24
|
+
this.name = "AbortError";
|
|
25
|
+
this.message = message;
|
|
27
26
|
}
|
|
28
27
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
function calculateDelay(retriesConsumed, options) {
|
|
29
|
+
const attempt = Math.max(1, retriesConsumed + 1);
|
|
30
|
+
const random = options.randomize ? Math.random() + 1 : 1;
|
|
31
|
+
let timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));
|
|
32
|
+
timeout = Math.min(timeout, options.maxTimeout);
|
|
33
|
+
return timeout;
|
|
34
|
+
}
|
|
35
|
+
function calculateRemainingTime(start, max) {
|
|
36
|
+
if (!Number.isFinite(max)) return max;
|
|
37
|
+
return max - (performance.now() - start);
|
|
38
|
+
}
|
|
39
|
+
async function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {
|
|
40
|
+
const normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: "${error}". You should only throw errors.`);
|
|
41
|
+
if (normalizedError instanceof AbortError) throw normalizedError.originalError;
|
|
42
|
+
const retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;
|
|
43
|
+
const maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;
|
|
44
|
+
const context = Object.freeze({
|
|
45
|
+
error: normalizedError,
|
|
46
|
+
attemptNumber,
|
|
47
|
+
retriesLeft,
|
|
48
|
+
retriesConsumed
|
|
49
|
+
});
|
|
50
|
+
await options.onFailedAttempt(context);
|
|
51
|
+
if (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError;
|
|
52
|
+
const consumeRetry = await options.shouldConsumeRetry(context);
|
|
53
|
+
const remainingTime = calculateRemainingTime(startTime, maxRetryTime);
|
|
54
|
+
if (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError;
|
|
55
|
+
if (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {
|
|
56
|
+
if (consumeRetry) throw normalizedError;
|
|
57
|
+
options.signal?.throwIfAborted();
|
|
58
|
+
return false;
|
|
40
59
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}), {
|
|
46
|
-
onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),
|
|
47
|
-
retries: this.maxRetries,
|
|
48
|
-
randomize: true
|
|
49
|
-
}), { throwOnTimeout: true });
|
|
60
|
+
if (!await options.shouldRetry(context)) throw normalizedError;
|
|
61
|
+
if (!consumeRetry) {
|
|
62
|
+
options.signal?.throwIfAborted();
|
|
63
|
+
return false;
|
|
50
64
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
const delayTime = calculateDelay(retriesConsumed, options);
|
|
66
|
+
const finalDelay = Math.min(delayTime, remainingTime);
|
|
67
|
+
if (finalDelay > 0) await new Promise((resolve, reject) => {
|
|
68
|
+
const onAbort = () => {
|
|
69
|
+
clearTimeout(timeoutToken);
|
|
70
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
71
|
+
reject(options.signal.reason);
|
|
72
|
+
};
|
|
73
|
+
const timeoutToken = setTimeout(() => {
|
|
74
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
75
|
+
resolve();
|
|
76
|
+
}, finalDelay);
|
|
77
|
+
if (options.unref) timeoutToken.unref?.();
|
|
78
|
+
options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
79
|
+
});
|
|
80
|
+
options.signal?.throwIfAborted();
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
async function pRetry(input, options = {}) {
|
|
84
|
+
options = { ...options };
|
|
85
|
+
validateRetries(options.retries);
|
|
86
|
+
if (Object.hasOwn(options, "forever")) throw new Error("The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.");
|
|
87
|
+
options.retries ??= 10;
|
|
88
|
+
options.factor ??= 2;
|
|
89
|
+
options.minTimeout ??= 1e3;
|
|
90
|
+
options.maxTimeout ??= Number.POSITIVE_INFINITY;
|
|
91
|
+
options.maxRetryTime ??= Number.POSITIVE_INFINITY;
|
|
92
|
+
options.randomize ??= false;
|
|
93
|
+
options.onFailedAttempt ??= () => {
|
|
94
|
+
};
|
|
95
|
+
options.shouldRetry ??= () => true;
|
|
96
|
+
options.shouldConsumeRetry ??= () => true;
|
|
97
|
+
validateNumberOption("factor", options.factor, {
|
|
98
|
+
min: 0,
|
|
99
|
+
allowInfinity: false
|
|
100
|
+
});
|
|
101
|
+
validateNumberOption("minTimeout", options.minTimeout, {
|
|
102
|
+
min: 0,
|
|
103
|
+
allowInfinity: false
|
|
104
|
+
});
|
|
105
|
+
validateNumberOption("maxTimeout", options.maxTimeout, {
|
|
106
|
+
min: 0,
|
|
107
|
+
allowInfinity: true
|
|
108
|
+
});
|
|
109
|
+
validateNumberOption("maxRetryTime", options.maxRetryTime, {
|
|
110
|
+
min: 0,
|
|
111
|
+
allowInfinity: true
|
|
112
|
+
});
|
|
113
|
+
if (!(options.factor > 0)) options.factor = 1;
|
|
114
|
+
options.signal?.throwIfAborted();
|
|
115
|
+
let attemptNumber = 0;
|
|
116
|
+
let retriesConsumed = 0;
|
|
117
|
+
const startTime = performance.now();
|
|
118
|
+
while (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {
|
|
119
|
+
attemptNumber++;
|
|
120
|
+
try {
|
|
121
|
+
options.signal?.throwIfAborted();
|
|
122
|
+
const result = await input(attemptNumber);
|
|
123
|
+
options.signal?.throwIfAborted();
|
|
124
|
+
return result;
|
|
125
|
+
} catch (error) {
|
|
126
|
+
if (await onAttemptFailure({
|
|
127
|
+
error,
|
|
128
|
+
attemptNumber,
|
|
129
|
+
retriesConsumed,
|
|
130
|
+
startTime,
|
|
131
|
+
options
|
|
132
|
+
})) retriesConsumed++;
|
|
62
133
|
}
|
|
63
|
-
return this.call(callable, ...args);
|
|
64
|
-
}
|
|
65
|
-
fetch(...args) {
|
|
66
|
-
return this.call(() => fetch(...args).then((res) => res.ok ? res : Promise.reject(res)));
|
|
67
134
|
}
|
|
68
|
-
|
|
135
|
+
throw new Error("Retry attempts exhausted without throwing an error.");
|
|
136
|
+
}
|
|
69
137
|
export {
|
|
70
|
-
|
|
71
|
-
async_caller_exports
|
|
138
|
+
pRetry
|
|
72
139
|
};
|
|
73
140
|
//# sourceMappingURL=index.es100.js.map
|
package/dist/index.es100.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es100.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/
|
|
1
|
+
{"version":3,"file":"index.es100.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/p-retry/index.js"],"sourcesContent":["import { isNetworkError } from \"../is-network-error/index.js\";\n\n//#region src/utils/p-retry/index.js\nfunction validateRetries(retries) {\n\tif (typeof retries === \"number\") {\n\t\tif (retries < 0) throw new TypeError(\"Expected `retries` to be a non-negative number.\");\n\t\tif (Number.isNaN(retries)) throw new TypeError(\"Expected `retries` to be a valid number or Infinity, got NaN.\");\n\t} else if (retries !== void 0) throw new TypeError(\"Expected `retries` to be a number or Infinity.\");\n}\nfunction validateNumberOption(name, value, { min = 0, allowInfinity = false } = {}) {\n\tif (value === void 0) return;\n\tif (typeof value !== \"number\" || Number.isNaN(value)) throw new TypeError(`Expected \\`${name}\\` to be a number${allowInfinity ? \" or Infinity\" : \"\"}.`);\n\tif (!allowInfinity && !Number.isFinite(value)) throw new TypeError(`Expected \\`${name}\\` to be a finite number.`);\n\tif (value < min) throw new TypeError(`Expected \\`${name}\\` to be \\u2265 ${min}.`);\n}\nvar AbortError = class extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\t\tif (message instanceof Error) {\n\t\t\tthis.originalError = message;\n\t\t\t({message} = message);\n\t\t} else {\n\t\t\tthis.originalError = new Error(message);\n\t\t\tthis.originalError.stack = this.stack;\n\t\t}\n\t\tthis.name = \"AbortError\";\n\t\tthis.message = message;\n\t}\n};\nfunction calculateDelay(retriesConsumed, options) {\n\tconst attempt = Math.max(1, retriesConsumed + 1);\n\tconst random = options.randomize ? Math.random() + 1 : 1;\n\tlet timeout = Math.round(random * options.minTimeout * options.factor ** (attempt - 1));\n\ttimeout = Math.min(timeout, options.maxTimeout);\n\treturn timeout;\n}\nfunction calculateRemainingTime(start, max) {\n\tif (!Number.isFinite(max)) return max;\n\treturn max - (performance.now() - start);\n}\nasync function onAttemptFailure({ error, attemptNumber, retriesConsumed, startTime, options }) {\n\tconst normalizedError = error instanceof Error ? error : /* @__PURE__ */ new TypeError(`Non-error was thrown: \"${error}\". You should only throw errors.`);\n\tif (normalizedError instanceof AbortError) throw normalizedError.originalError;\n\tconst retriesLeft = Number.isFinite(options.retries) ? Math.max(0, options.retries - retriesConsumed) : options.retries;\n\tconst maxRetryTime = options.maxRetryTime ?? Number.POSITIVE_INFINITY;\n\tconst context = Object.freeze({\n\t\terror: normalizedError,\n\t\tattemptNumber,\n\t\tretriesLeft,\n\t\tretriesConsumed\n\t});\n\tawait options.onFailedAttempt(context);\n\tif (calculateRemainingTime(startTime, maxRetryTime) <= 0) throw normalizedError;\n\tconst consumeRetry = await options.shouldConsumeRetry(context);\n\tconst remainingTime = calculateRemainingTime(startTime, maxRetryTime);\n\tif (remainingTime <= 0 || retriesLeft <= 0) throw normalizedError;\n\tif (normalizedError instanceof TypeError && !isNetworkError(normalizedError)) {\n\t\tif (consumeRetry) throw normalizedError;\n\t\toptions.signal?.throwIfAborted();\n\t\treturn false;\n\t}\n\tif (!await options.shouldRetry(context)) throw normalizedError;\n\tif (!consumeRetry) {\n\t\toptions.signal?.throwIfAborted();\n\t\treturn false;\n\t}\n\tconst delayTime = calculateDelay(retriesConsumed, options);\n\tconst finalDelay = Math.min(delayTime, remainingTime);\n\tif (finalDelay > 0) await new Promise((resolve, reject) => {\n\t\tconst onAbort = () => {\n\t\t\tclearTimeout(timeoutToken);\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\treject(options.signal.reason);\n\t\t};\n\t\tconst timeoutToken = setTimeout(() => {\n\t\t\toptions.signal?.removeEventListener(\"abort\", onAbort);\n\t\t\tresolve();\n\t\t}, finalDelay);\n\t\tif (options.unref) timeoutToken.unref?.();\n\t\toptions.signal?.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\toptions.signal?.throwIfAborted();\n\treturn true;\n}\nasync function pRetry(input, options = {}) {\n\toptions = { ...options };\n\tvalidateRetries(options.retries);\n\tif (Object.hasOwn(options, \"forever\")) throw new Error(\"The `forever` option is no longer supported. For many use-cases, you can set `retries: Infinity` instead.\");\n\toptions.retries ??= 10;\n\toptions.factor ??= 2;\n\toptions.minTimeout ??= 1e3;\n\toptions.maxTimeout ??= Number.POSITIVE_INFINITY;\n\toptions.maxRetryTime ??= Number.POSITIVE_INFINITY;\n\toptions.randomize ??= false;\n\toptions.onFailedAttempt ??= () => {};\n\toptions.shouldRetry ??= () => true;\n\toptions.shouldConsumeRetry ??= () => true;\n\tvalidateNumberOption(\"factor\", options.factor, {\n\t\tmin: 0,\n\t\tallowInfinity: false\n\t});\n\tvalidateNumberOption(\"minTimeout\", options.minTimeout, {\n\t\tmin: 0,\n\t\tallowInfinity: false\n\t});\n\tvalidateNumberOption(\"maxTimeout\", options.maxTimeout, {\n\t\tmin: 0,\n\t\tallowInfinity: true\n\t});\n\tvalidateNumberOption(\"maxRetryTime\", options.maxRetryTime, {\n\t\tmin: 0,\n\t\tallowInfinity: true\n\t});\n\tif (!(options.factor > 0)) options.factor = 1;\n\toptions.signal?.throwIfAborted();\n\tlet attemptNumber = 0;\n\tlet retriesConsumed = 0;\n\tconst startTime = performance.now();\n\twhile (Number.isFinite(options.retries) ? retriesConsumed <= options.retries : true) {\n\t\tattemptNumber++;\n\t\ttry {\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\tconst result = await input(attemptNumber);\n\t\t\toptions.signal?.throwIfAborted();\n\t\t\treturn result;\n\t\t} catch (error) {\n\t\t\tif (await onAttemptFailure({\n\t\t\t\terror,\n\t\t\t\tattemptNumber,\n\t\t\t\tretriesConsumed,\n\t\t\t\tstartTime,\n\t\t\t\toptions\n\t\t\t})) retriesConsumed++;\n\t\t}\n\t}\n\tthrow new Error(\"Retry attempts exhausted without throwing an error.\");\n}\n\n//#endregion\nexport { pRetry };\n//# sourceMappingURL=index.js.map"],"names":[],"mappings":";AAGA,SAAS,gBAAgB,SAAS;AACjC,MAAI,OAAO,YAAY,UAAU;AAChC,QAAI,UAAU,EAAG,OAAM,IAAI,UAAU,iDAAiD;AACtF,QAAI,OAAO,MAAM,OAAO,EAAG,OAAM,IAAI,UAAU,+DAA+D;AAAA,EAC/G,WAAW,YAAY,OAAQ,OAAM,IAAI,UAAU,gDAAgD;AACpG;AACA,SAA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,CAAI,EAAG;AAAA,IACL;AAAA,EACD;AACA,QAAM,IAAI,MAAM,qDAAqD;AACtE;","x_google_ignoreList":[0]}
|
package/dist/index.es101.js
CHANGED
|
@@ -1,40 +1,73 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { __export } from "./index.es55.js";
|
|
2
|
+
import { getAbortSignalError } from "./index.es96.js";
|
|
3
|
+
import { pRetry } from "./index.es100.js";
|
|
4
|
+
import PQueueMod from "./index.es118.js";
|
|
5
|
+
var async_caller_exports = {};
|
|
6
|
+
__export(async_caller_exports, { AsyncCaller: () => AsyncCaller });
|
|
7
|
+
const STATUS_NO_RETRY = [
|
|
8
|
+
400,
|
|
9
|
+
401,
|
|
10
|
+
402,
|
|
11
|
+
403,
|
|
12
|
+
404,
|
|
13
|
+
405,
|
|
14
|
+
406,
|
|
15
|
+
407,
|
|
16
|
+
409
|
|
17
|
+
];
|
|
18
|
+
const defaultFailedAttemptHandler = (error) => {
|
|
19
|
+
if (error.message.startsWith("Cancel") || error.message.startsWith("AbortError") || error.name === "AbortError") throw error;
|
|
20
|
+
if (error?.code === "ECONNABORTED") throw error;
|
|
21
|
+
const status = error?.response?.status ?? error?.status;
|
|
22
|
+
if (status && STATUS_NO_RETRY.includes(+status)) throw error;
|
|
23
|
+
if (error?.error?.code === "insufficient_quota") {
|
|
24
|
+
const err = new Error(error?.message);
|
|
25
|
+
err.name = "InsufficientQuotaError";
|
|
26
|
+
throw err;
|
|
16
27
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
};
|
|
29
|
+
var AsyncCaller = class {
|
|
30
|
+
maxConcurrency;
|
|
31
|
+
maxRetries;
|
|
32
|
+
onFailedAttempt;
|
|
33
|
+
queue;
|
|
34
|
+
constructor(params) {
|
|
35
|
+
this.maxConcurrency = params.maxConcurrency ?? Infinity;
|
|
36
|
+
this.maxRetries = params.maxRetries ?? 6;
|
|
37
|
+
this.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;
|
|
38
|
+
const PQueue = "default" in PQueueMod ? PQueueMod.default : PQueueMod;
|
|
39
|
+
this.queue = new PQueue({ concurrency: this.maxConcurrency });
|
|
40
|
+
}
|
|
41
|
+
async call(callable, ...args) {
|
|
42
|
+
return this.queue.add(() => pRetry(() => callable(...args).catch((error) => {
|
|
43
|
+
if (error instanceof Error) throw error;
|
|
44
|
+
else throw new Error(error);
|
|
45
|
+
}), {
|
|
46
|
+
onFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),
|
|
47
|
+
retries: this.maxRetries,
|
|
48
|
+
randomize: true
|
|
49
|
+
}), { throwOnTimeout: true });
|
|
24
50
|
}
|
|
25
|
-
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
callWithOptions(options, callable, ...args) {
|
|
52
|
+
if (options.signal) {
|
|
53
|
+
let listener;
|
|
54
|
+
return Promise.race([this.call(callable, ...args), new Promise((_, reject) => {
|
|
55
|
+
listener = () => {
|
|
56
|
+
reject(getAbortSignalError(options.signal));
|
|
57
|
+
};
|
|
58
|
+
options.signal?.addEventListener("abort", listener);
|
|
59
|
+
})]).finally(() => {
|
|
60
|
+
if (options.signal && listener) options.signal.removeEventListener("abort", listener);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return this.call(callable, ...args);
|
|
29
64
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!run.error) {
|
|
33
|
-
if (this.argOnEnd) await this.argOnEnd(run, this.config);
|
|
34
|
-
} else if (this.argOnError) await this.argOnError(run, this.config);
|
|
65
|
+
fetch(...args) {
|
|
66
|
+
return this.call(() => fetch(...args).then((res) => res.ok ? res : Promise.reject(res)));
|
|
35
67
|
}
|
|
36
68
|
};
|
|
37
69
|
export {
|
|
38
|
-
|
|
70
|
+
AsyncCaller,
|
|
71
|
+
async_caller_exports
|
|
39
72
|
};
|
|
40
73
|
//# sourceMappingURL=index.es101.js.map
|
package/dist/index.es101.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es101.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es101.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/utils/async_caller.js"],"sourcesContent":["import { __export } from \"../_virtual/rolldown_runtime.js\";\nimport { getAbortSignalError } from \"./signal.js\";\nimport { pRetry } from \"./p-retry/index.js\";\nimport PQueueMod from \"p-queue\";\n\n//#region src/utils/async_caller.ts\nvar async_caller_exports = {};\n__export(async_caller_exports, { AsyncCaller: () => AsyncCaller });\nconst STATUS_NO_RETRY = [\n\t400,\n\t401,\n\t402,\n\t403,\n\t404,\n\t405,\n\t406,\n\t407,\n\t409\n];\nconst defaultFailedAttemptHandler = (error) => {\n\tif (error.message.startsWith(\"Cancel\") || error.message.startsWith(\"AbortError\") || error.name === \"AbortError\") throw error;\n\tif (error?.code === \"ECONNABORTED\") throw error;\n\tconst status = error?.response?.status ?? error?.status;\n\tif (status && STATUS_NO_RETRY.includes(+status)) throw error;\n\tif (error?.error?.code === \"insufficient_quota\") {\n\t\tconst err = new Error(error?.message);\n\t\terr.name = \"InsufficientQuotaError\";\n\t\tthrow err;\n\t}\n};\n/**\n* A class that can be used to make async calls with concurrency and retry logic.\n*\n* This is useful for making calls to any kind of \"expensive\" external resource,\n* be it because it's rate-limited, subject to network issues, etc.\n*\n* Concurrent calls are limited by the `maxConcurrency` parameter, which defaults\n* to `Infinity`. This means that by default, all calls will be made in parallel.\n*\n* Retries are limited by the `maxRetries` parameter, which defaults to 6. This\n* means that by default, each call will be retried up to 6 times, with an\n* exponential backoff between each attempt.\n*/\nvar AsyncCaller = class {\n\tmaxConcurrency;\n\tmaxRetries;\n\tonFailedAttempt;\n\tqueue;\n\tconstructor(params) {\n\t\tthis.maxConcurrency = params.maxConcurrency ?? Infinity;\n\t\tthis.maxRetries = params.maxRetries ?? 6;\n\t\tthis.onFailedAttempt = params.onFailedAttempt ?? defaultFailedAttemptHandler;\n\t\tconst PQueue = \"default\" in PQueueMod ? PQueueMod.default : PQueueMod;\n\t\tthis.queue = new PQueue({ concurrency: this.maxConcurrency });\n\t}\n\tasync call(callable, ...args) {\n\t\treturn this.queue.add(() => pRetry(() => callable(...args).catch((error) => {\n\t\t\tif (error instanceof Error) throw error;\n\t\t\telse throw new Error(error);\n\t\t}), {\n\t\t\tonFailedAttempt: ({ error }) => this.onFailedAttempt?.(error),\n\t\t\tretries: this.maxRetries,\n\t\t\trandomize: true\n\t\t}), { throwOnTimeout: true });\n\t}\n\tcallWithOptions(options, callable, ...args) {\n\t\tif (options.signal) {\n\t\t\tlet listener;\n\t\t\treturn Promise.race([this.call(callable, ...args), new Promise((_, reject) => {\n\t\t\t\tlistener = () => {\n\t\t\t\t\treject(getAbortSignalError(options.signal));\n\t\t\t\t};\n\t\t\t\toptions.signal?.addEventListener(\"abort\", listener);\n\t\t\t})]).finally(() => {\n\t\t\t\tif (options.signal && listener) options.signal.removeEventListener(\"abort\", listener);\n\t\t\t});\n\t\t}\n\t\treturn this.call(callable, ...args);\n\t}\n\tfetch(...args) {\n\t\treturn this.call(() => fetch(...args).then((res) => res.ok ? res : Promise.reject(res)));\n\t}\n};\n\n//#endregion\nexport { AsyncCaller, async_caller_exports };\n//# sourceMappingURL=async_caller.js.map"],"names":[],"mappings":";;;;AAMG,IAAC,uBAAuB,CAAA;AAC3B,SAAS,sBAAsB,EAAE,aAAa,MAAM,YAAW,CAAE;AACjE,MAAM,kBAAkB;AAAA,EACvB;A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Q,QAAQ;AACnB,UAAI;AACJ,aAAO,QAAQ,KAAK,CAAC,KAAK,KAAK,UAAU,GAAG,IAAI,GAAG,IAAI,QAAQ,CAAC,GAAG,WAAW;AAC7E,mBAAW,MAAM;AAChB,iBAAO,oBAAoB,QAAQ,MAAM,CAAC;AAAA,QAC3C;AACA,gBAAQ,QAAQ,iBAAiB,SAAS,QAAQ;AAAA,MACnD,CAAC,CAAC,CAAC,EAAE,QAAQ,MAAM;AAClB,YAAI,QAAQ,UAAU,SAAU,SAAQ,OAAO,oBAAoB,SAAS,QAAQ;AAAA,MACrF,CAAC;AAAA,IACF;AACA,WAAO,KAAK,KAAK,UAAU,GAAG,IAAI;AAAA,EACnC;AAAA,EACA,SAAS,MAAM;AACd,WAAO,KAAK,KAAK,MAAM,MAAM,GAAG,IAAI,EAAE,KAAK,CAAC,QAAQ,IAAI,KAAK,MAAM,QAAQ,OAAO,GAAG,CAAC,CAAC;AAAA,EACxF;AACD;","x_google_ignoreList":[0]}
|
package/dist/index.es102.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
16
|
-
this.excludeTypes = fields.excludeTypes;
|
|
17
|
-
this.excludeTags = fields.excludeTags;
|
|
1
|
+
import { BaseTracer } from "./index.es124.js";
|
|
2
|
+
var RootListenersTracer = class extends BaseTracer {
|
|
3
|
+
name = "RootListenersTracer";
|
|
4
|
+
/** The Run's ID. Type UUID */
|
|
5
|
+
rootId;
|
|
6
|
+
config;
|
|
7
|
+
argOnStart;
|
|
8
|
+
argOnEnd;
|
|
9
|
+
argOnError;
|
|
10
|
+
constructor({ config, onStart, onEnd, onError }) {
|
|
11
|
+
super({ _awaitHandler: true });
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.argOnStart = onStart;
|
|
14
|
+
this.argOnEnd = onEnd;
|
|
15
|
+
this.argOnError = onError;
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return
|
|
17
|
+
/**
|
|
18
|
+
* This is a legacy method only called once for an entire run tree
|
|
19
|
+
* therefore not useful here
|
|
20
|
+
* @param {Run} _ Not used
|
|
21
|
+
*/
|
|
22
|
+
persistRun(_) {
|
|
23
|
+
return Promise.resolve();
|
|
24
|
+
}
|
|
25
|
+
async onRunCreate(run) {
|
|
26
|
+
if (this.rootId) return;
|
|
27
|
+
this.rootId = run.id;
|
|
28
|
+
if (this.argOnStart) await this.argOnStart(run, this.config);
|
|
29
|
+
}
|
|
30
|
+
async onRunUpdate(run) {
|
|
31
|
+
if (run.id !== this.rootId) return;
|
|
32
|
+
if (!run.error) {
|
|
33
|
+
if (this.argOnEnd) await this.argOnEnd(run, this.config);
|
|
34
|
+
} else if (this.argOnError) await this.argOnError(run, this.config);
|
|
29
35
|
}
|
|
30
|
-
};
|
|
31
|
-
const toBase64Url = (str) => {
|
|
32
|
-
const encoded = btoa(str);
|
|
33
|
-
return encoded.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
34
36
|
};
|
|
35
37
|
export {
|
|
36
|
-
|
|
37
|
-
isRunnableInterface,
|
|
38
|
-
toBase64Url
|
|
38
|
+
RootListenersTracer
|
|
39
39
|
};
|
|
40
40
|
//# sourceMappingURL=index.es102.js.map
|
package/dist/index.es102.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es102.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/
|
|
1
|
+
{"version":3,"file":"index.es102.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/tracers/root_listener.js"],"sourcesContent":["import { BaseTracer } from \"./base.js\";\n\n//#region src/tracers/root_listener.ts\nvar RootListenersTracer = class extends BaseTracer {\n\tname = \"RootListenersTracer\";\n\t/** The Run's ID. Type UUID */\n\trootId;\n\tconfig;\n\targOnStart;\n\targOnEnd;\n\targOnError;\n\tconstructor({ config, onStart, onEnd, onError }) {\n\t\tsuper({ _awaitHandler: true });\n\t\tthis.config = config;\n\t\tthis.argOnStart = onStart;\n\t\tthis.argOnEnd = onEnd;\n\t\tthis.argOnError = onError;\n\t}\n\t/**\n\t* This is a legacy method only called once for an entire run tree\n\t* therefore not useful here\n\t* @param {Run} _ Not used\n\t*/\n\tpersistRun(_) {\n\t\treturn Promise.resolve();\n\t}\n\tasync onRunCreate(run) {\n\t\tif (this.rootId) return;\n\t\tthis.rootId = run.id;\n\t\tif (this.argOnStart) await this.argOnStart(run, this.config);\n\t}\n\tasync onRunUpdate(run) {\n\t\tif (run.id !== this.rootId) return;\n\t\tif (!run.error) {\n\t\t\tif (this.argOnEnd) await this.argOnEnd(run, this.config);\n\t\t} else if (this.argOnError) await this.argOnError(run, this.config);\n\t}\n};\n\n//#endregion\nexport { RootListenersTracer };\n//# sourceMappingURL=root_listener.js.map"],"names":[],"mappings":";AAGG,IAAC,sBAAsB,cAAc,WAAW;AAAA,EAClD,OAAO;AAAA;AAAA,EAEP;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,EAAE,QAAQ,SAAS,OAAO,QAAO,GAAI;AAChD,UAAM,EAAE,eAAe,MAAM;AAC7B,SAAK,SAAS;AACd,SAAK,aAAa;AAClB,SAAK,WAAW;AAChB,SAAK,aAAa;AAAA,EACnB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,WAAW,GAAG;AACb,WAAO,QAAQ,QAAO;AAAA,EACvB;AAAA,EACA,MAAM,YAAY,KAAK;AACtB,QAAI,KAAK,OAAQ;AACjB,SAAK,SAAS,IAAI;AAClB,QAAI,KAAK,WAAY,OAAM,KAAK,WAAW,KAAK,KAAK,MAAM;AAAA,EAC5D;AAAA,EACA,MAAM,YAAY,KAAK;AACtB,QAAI,IAAI,OAAO,KAAK,OAAQ;AAC5B,QAAI,CAAC,IAAI,OAAO;AACf,UAAI,KAAK,SAAU,OAAM,KAAK,SAAS,KAAK,KAAK,MAAM;AAAA,IACxD,WAAW,KAAK,WAAY,OAAM,KAAK,WAAW,KAAK,KAAK,MAAM;AAAA,EACnE;AACD;","x_google_ignoreList":[0]}
|