langgraph-ui-components 0.0.17 → 0.0.18
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.es100.js +20 -354
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +172 -127
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +231 -60
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +352 -34
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +134 -34
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +65 -161
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +30 -196
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +36 -13
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +162 -26
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +196 -27
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es110.js +13 -3156
- package/dist/index.es110.js.map +1 -1
- package/dist/index.es111.js +27 -34
- package/dist/index.es111.js.map +1 -1
- package/dist/index.es112.js +34 -5
- package/dist/index.es112.js.map +1 -1
- package/dist/index.es113.js +3145 -61
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +33 -33
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +5 -21
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +69 -64
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +37 -3
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es12.js +1 -1
- package/dist/index.es121.js +9 -9
- package/dist/index.es122.js +1 -1
- package/dist/index.es126.js +1 -1
- package/dist/index.es128.js +2 -2
- package/dist/index.es13.js +9 -3
- package/dist/index.es13.js.map +1 -1
- package/dist/index.es136.js +1 -1
- package/dist/index.es137.js +6 -6
- package/dist/index.es139.js +1 -1
- package/dist/index.es14.js +6 -6
- package/dist/index.es140.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 +10 -5
- 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 +7 -7
- 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 +1 -1
- package/dist/index.es184.js +1 -1
- package/dist/index.es185.js +1 -1
- package/dist/index.es186.js +1 -1
- package/dist/index.es187.js +1 -1
- package/dist/index.es191.js +2 -56
- package/dist/index.es191.js.map +1 -1
- package/dist/index.es192.js +2 -100
- package/dist/index.es192.js.map +1 -1
- package/dist/index.es193.js +2 -191
- package/dist/index.es193.js.map +1 -1
- package/dist/index.es194.js +2 -110
- package/dist/index.es194.js.map +1 -1
- package/dist/index.es195.js +2 -35
- package/dist/index.es195.js.map +1 -1
- package/dist/index.es196.js +2 -10
- package/dist/index.es196.js.map +1 -1
- package/dist/index.es197.js +2 -11
- package/dist/index.es197.js.map +1 -1
- package/dist/index.es198.js +2 -12
- package/dist/index.es198.js.map +1 -1
- package/dist/index.es199.js +2 -91
- package/dist/index.es199.js.map +1 -1
- package/dist/index.es2.js +96 -11
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +2 -2
- package/dist/index.es200.js +2 -275
- package/dist/index.es200.js.map +1 -1
- package/dist/index.es201.js +2 -2
- package/dist/index.es202.js +2 -164
- package/dist/index.es202.js.map +1 -1
- package/dist/index.es203.js +2 -51
- package/dist/index.es203.js.map +1 -1
- package/dist/index.es204.js +2 -40
- package/dist/index.es204.js.map +1 -1
- package/dist/index.es205.js +2 -35
- package/dist/index.es205.js.map +1 -1
- package/dist/index.es206.js +2 -40
- package/dist/index.es206.js.map +1 -1
- package/dist/index.es207.js +2 -24
- package/dist/index.es207.js.map +1 -1
- package/dist/index.es208.js +2 -591
- package/dist/index.es208.js.map +1 -1
- package/dist/index.es209.js +2 -125
- package/dist/index.es209.js.map +1 -1
- package/dist/index.es210.js +2 -164
- package/dist/index.es210.js.map +1 -1
- 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.es22.js +35 -119
- package/dist/index.es22.js.map +1 -1
- 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.es23.js +66 -36
- package/dist/index.es23.js.map +1 -1
- package/dist/index.es230.js +2 -2
- package/dist/index.es231.js +2 -2
- package/dist/index.es232.js +2 -2
- package/dist/index.es233.js +2 -2
- package/dist/index.es234.js +2 -2
- package/dist/index.es235.js +2 -2
- package/dist/index.es236.js +56 -2
- package/dist/index.es236.js.map +1 -1
- package/dist/index.es237.js +100 -2
- package/dist/index.es237.js.map +1 -1
- package/dist/index.es238.js +191 -2
- package/dist/index.es238.js.map +1 -1
- package/dist/index.es239.js +110 -2
- package/dist/index.es239.js.map +1 -1
- package/dist/index.es24.js +30 -64
- package/dist/index.es24.js.map +1 -1
- package/dist/index.es240.js +35 -2
- package/dist/index.es240.js.map +1 -1
- package/dist/index.es241.js +10 -2
- package/dist/index.es241.js.map +1 -1
- package/dist/index.es242.js +11 -2
- package/dist/index.es242.js.map +1 -1
- package/dist/index.es243.js +12 -2
- package/dist/index.es243.js.map +1 -1
- package/dist/index.es244.js +91 -2
- package/dist/index.es244.js.map +1 -1
- package/dist/index.es245.js +275 -2
- package/dist/index.es245.js.map +1 -1
- package/dist/index.es246.js +2 -2
- package/dist/index.es247.js +164 -2
- package/dist/index.es247.js.map +1 -1
- package/dist/index.es248.js +51 -2
- package/dist/index.es248.js.map +1 -1
- package/dist/index.es249.js +40 -2
- package/dist/index.es249.js.map +1 -1
- package/dist/index.es25.js +120 -29
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es250.js +35 -2
- package/dist/index.es250.js.map +1 -1
- package/dist/index.es251.js +40 -2
- package/dist/index.es251.js.map +1 -1
- package/dist/index.es252.js +24 -2
- package/dist/index.es252.js.map +1 -1
- package/dist/index.es253.js +591 -2
- package/dist/index.es253.js.map +1 -1
- package/dist/index.es254.js +125 -2
- package/dist/index.es254.js.map +1 -1
- package/dist/index.es255.js +164 -2
- package/dist/index.es255.js.map +1 -1
- package/dist/index.es256.js +2 -2
- package/dist/index.es26.js +102 -123
- package/dist/index.es26.js.map +1 -1
- package/dist/index.es267.js +1 -1
- package/dist/index.es27.js +66 -101
- package/dist/index.es27.js.map +1 -1
- package/dist/index.es28.js +139 -66
- package/dist/index.es28.js.map +1 -1
- package/dist/index.es29.js +295 -131
- package/dist/index.es29.js.map +1 -1
- package/dist/index.es30.js +114 -298
- package/dist/index.es30.js.map +1 -1
- package/dist/index.es305.js +1 -1
- package/dist/index.es307.js +1 -1
- package/dist/index.es319.js +1 -1
- package/dist/index.es32.js +7 -7
- package/dist/index.es33.js +1 -1
- package/dist/index.es339.js +2 -2
- package/dist/index.es36.js +4 -4
- package/dist/index.es37.js +289 -114
- package/dist/index.es37.js.map +1 -1
- package/dist/index.es38.js +44 -70
- package/dist/index.es38.js.map +1 -1
- package/dist/index.es39.js +145 -19
- package/dist/index.es39.js.map +1 -1
- package/dist/index.es40.js +5 -261
- package/dist/index.es40.js.map +1 -1
- package/dist/index.es41.js +247 -38
- package/dist/index.es41.js.map +1 -1
- package/dist/index.es42.js +110 -207
- package/dist/index.es42.js.map +1 -1
- package/dist/index.es43.js +68 -64
- package/dist/index.es43.js.map +1 -1
- package/dist/index.es44.js +17 -141
- package/dist/index.es44.js.map +1 -1
- package/dist/index.es45.js +251 -14
- package/dist/index.es45.js.map +1 -1
- package/dist/index.es46.js +36 -223
- package/dist/index.es46.js.map +1 -1
- package/dist/index.es47.js +213 -7
- package/dist/index.es47.js.map +1 -1
- package/dist/index.es48.js +55 -1180
- package/dist/index.es48.js.map +1 -1
- package/dist/index.es49.js +141 -6
- package/dist/index.es49.js.map +1 -1
- package/dist/index.es50.js +21 -144
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +230 -5
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +8 -292
- package/dist/index.es52.js.map +1 -1
- package/dist/index.es53.js +1190 -43
- package/dist/index.es53.js.map +1 -1
- package/dist/index.es54.js +7 -144
- package/dist/index.es54.js.map +1 -1
- package/dist/index.es55.js +136 -241
- package/dist/index.es55.js.map +1 -1
- package/dist/index.es59.js +1 -1
- package/dist/index.es6.js +21 -8
- package/dist/index.es6.js.map +1 -1
- package/dist/index.es60.js +1 -1
- package/dist/index.es61.js +1 -1
- package/dist/index.es62.js +7 -7
- package/dist/index.es67.js +3 -3
- package/dist/index.es69.js +2 -2
- package/dist/index.es70.js +1 -1
- package/dist/index.es71.js +1 -1
- package/dist/index.es72.js +1 -1
- package/dist/index.es77.js +7 -7
- package/dist/index.es78.js +17 -17
- package/dist/index.es82.js +1 -1
- package/dist/index.es83.js +4 -4
- package/dist/index.es84.js +20 -11
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +66 -38
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +3 -34
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +10 -230
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +39 -29
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +32 -73
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +200 -44
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +15 -37
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +71 -26
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +72 -39
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +48 -53
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +30 -13
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +40 -134
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +56 -20
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +11 -180
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +129 -233
- package/dist/index.es99.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.es41.js
CHANGED
|
@@ -1,47 +1,256 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
const sections = {
|
|
2
|
+
172351395: { name: "EBML", type: "Container" },
|
|
3
|
+
646: { name: "EBMLVersion", type: "Uint" },
|
|
4
|
+
759: { name: "EBMLReadVersion", type: "Uint" },
|
|
5
|
+
754: { name: "EBMLMaxIDLength", type: "Uint" },
|
|
6
|
+
755: { name: "EBMLMaxSizeLength", type: "Uint" },
|
|
7
|
+
642: { name: "DocType", type: "String" },
|
|
8
|
+
647: { name: "DocTypeVersion", type: "Uint" },
|
|
9
|
+
645: { name: "DocTypeReadVersion", type: "Uint" },
|
|
10
|
+
108: { name: "Void", type: "Binary" },
|
|
11
|
+
1161: { name: "Duration", type: "Float" },
|
|
12
|
+
139690087: { name: "Segment", type: "Container" },
|
|
13
|
+
88713574: { name: "Info", type: "Container" },
|
|
14
|
+
710577: { name: "TimecodeScale", type: "Uint" }
|
|
15
|
+
};
|
|
16
|
+
class WebmBase {
|
|
17
|
+
source;
|
|
18
|
+
data;
|
|
19
|
+
name;
|
|
20
|
+
type;
|
|
21
|
+
constructor(name = "Unknown", type = "Unknown") {
|
|
22
|
+
this.name = name;
|
|
23
|
+
this.type = type;
|
|
5
24
|
}
|
|
6
|
-
|
|
7
|
-
constructor(fields) {
|
|
8
|
-
super(fields);
|
|
25
|
+
updateBySource() {
|
|
9
26
|
}
|
|
10
|
-
|
|
11
|
-
|
|
27
|
+
setSource(source) {
|
|
28
|
+
this.source = source;
|
|
29
|
+
this.updateBySource();
|
|
12
30
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
updateByData() {
|
|
32
|
+
}
|
|
33
|
+
setData(data) {
|
|
34
|
+
this.data = data;
|
|
35
|
+
this.updateByData();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class WebmUint extends WebmBase {
|
|
39
|
+
constructor(name, type) {
|
|
40
|
+
super(name, type || "Uint");
|
|
41
|
+
}
|
|
42
|
+
updateBySource() {
|
|
43
|
+
this.data = "";
|
|
44
|
+
for (let i = 0; i < this.source.length; i++) {
|
|
45
|
+
const hex = this.source[i].toString(16);
|
|
46
|
+
this.data += padHex(hex);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
updateByData() {
|
|
50
|
+
const length = this.data.length / 2;
|
|
51
|
+
this.source = new Uint8Array(length);
|
|
52
|
+
for (let i = 0; i < length; i++) {
|
|
53
|
+
const hex = this.data.substr(i * 2, 2);
|
|
54
|
+
this.source[i] = parseInt(hex, 16);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
getValue() {
|
|
58
|
+
return parseInt(this.data, 16);
|
|
59
|
+
}
|
|
60
|
+
setValue(value) {
|
|
61
|
+
this.setData(padHex(value.toString(16)));
|
|
33
62
|
}
|
|
34
|
-
};
|
|
35
|
-
function isHumanMessage(x) {
|
|
36
|
-
return x.getType() === "human";
|
|
37
63
|
}
|
|
38
|
-
function
|
|
39
|
-
return
|
|
64
|
+
function padHex(hex) {
|
|
65
|
+
return hex.length % 2 === 1 ? "0" + hex : hex;
|
|
40
66
|
}
|
|
67
|
+
class WebmFloat extends WebmBase {
|
|
68
|
+
constructor(name, type) {
|
|
69
|
+
super(name, type || "Float");
|
|
70
|
+
}
|
|
71
|
+
getFloatArrayType() {
|
|
72
|
+
return this.source && this.source.length === 4 ? Float32Array : Float64Array;
|
|
73
|
+
}
|
|
74
|
+
updateBySource() {
|
|
75
|
+
const byteArray = this.source.slice().reverse();
|
|
76
|
+
const floatArrayType = this.getFloatArrayType();
|
|
77
|
+
const floatArray = new floatArrayType(byteArray.buffer);
|
|
78
|
+
this.data = floatArray[0];
|
|
79
|
+
}
|
|
80
|
+
updateByData() {
|
|
81
|
+
const floatArrayType = this.getFloatArrayType();
|
|
82
|
+
const floatArray = new floatArrayType([this.data]);
|
|
83
|
+
const byteArray = new Uint8Array(floatArray.buffer);
|
|
84
|
+
this.source = byteArray.slice().reverse();
|
|
85
|
+
}
|
|
86
|
+
getValue() {
|
|
87
|
+
return this.data;
|
|
88
|
+
}
|
|
89
|
+
setValue(value) {
|
|
90
|
+
this.setData(value);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
class WebmContainer extends WebmBase {
|
|
94
|
+
offset = 0;
|
|
95
|
+
data = [];
|
|
96
|
+
constructor(name, type) {
|
|
97
|
+
super(name, type || "Container");
|
|
98
|
+
}
|
|
99
|
+
readByte() {
|
|
100
|
+
return this.source[this.offset++];
|
|
101
|
+
}
|
|
102
|
+
readUint() {
|
|
103
|
+
const firstByte = this.readByte();
|
|
104
|
+
const bytes = 8 - firstByte.toString(2).length;
|
|
105
|
+
let value = firstByte - (1 << 7 - bytes);
|
|
106
|
+
for (let i = 0; i < bytes; i++) {
|
|
107
|
+
value *= 256;
|
|
108
|
+
value += this.readByte();
|
|
109
|
+
}
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
updateBySource() {
|
|
113
|
+
let end = void 0;
|
|
114
|
+
this.data = [];
|
|
115
|
+
for (this.offset = 0; this.offset < this.source.length; this.offset = end) {
|
|
116
|
+
const id = this.readUint();
|
|
117
|
+
const len = this.readUint();
|
|
118
|
+
end = Math.min(this.offset + len, this.source.length);
|
|
119
|
+
const data = this.source.slice(this.offset, end);
|
|
120
|
+
const info = sections[id] || { name: "Unknown", type: "Unknown" };
|
|
121
|
+
let ctr = WebmBase;
|
|
122
|
+
switch (info.type) {
|
|
123
|
+
case "Container":
|
|
124
|
+
ctr = WebmContainer;
|
|
125
|
+
break;
|
|
126
|
+
case "Uint":
|
|
127
|
+
ctr = WebmUint;
|
|
128
|
+
break;
|
|
129
|
+
case "Float":
|
|
130
|
+
ctr = WebmFloat;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
const section = new ctr(info.name, info.type);
|
|
134
|
+
section.setSource(data);
|
|
135
|
+
this.data.push({
|
|
136
|
+
id,
|
|
137
|
+
idHex: id.toString(16),
|
|
138
|
+
data: section
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
writeUint(x, draft = false) {
|
|
143
|
+
let bytes = 1, flag = 128;
|
|
144
|
+
while (x >= flag && bytes < 8) {
|
|
145
|
+
bytes++;
|
|
146
|
+
flag *= 128;
|
|
147
|
+
}
|
|
148
|
+
if (!draft) {
|
|
149
|
+
let value = flag + x;
|
|
150
|
+
for (let i = bytes - 1; i >= 0; i--) {
|
|
151
|
+
const c = value % 256;
|
|
152
|
+
this.source[this.offset + i] = c;
|
|
153
|
+
value = (value - c) / 256;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
this.offset += bytes;
|
|
157
|
+
}
|
|
158
|
+
writeSections(draft = false) {
|
|
159
|
+
this.offset = 0;
|
|
160
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
161
|
+
const section = this.data[i], content = section.data.source, contentLength = content.length;
|
|
162
|
+
this.writeUint(section.id, draft);
|
|
163
|
+
this.writeUint(contentLength, draft);
|
|
164
|
+
if (!draft) {
|
|
165
|
+
this.source.set(content, this.offset);
|
|
166
|
+
}
|
|
167
|
+
this.offset += contentLength;
|
|
168
|
+
}
|
|
169
|
+
return this.offset;
|
|
170
|
+
}
|
|
171
|
+
updateByData() {
|
|
172
|
+
const length = this.writeSections(true);
|
|
173
|
+
this.source = new Uint8Array(length);
|
|
174
|
+
this.writeSections();
|
|
175
|
+
}
|
|
176
|
+
getSectionById(id) {
|
|
177
|
+
for (let i = 0; i < this.data.length; i++) {
|
|
178
|
+
const section = this.data[i];
|
|
179
|
+
if (section.id === id) {
|
|
180
|
+
return section.data;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return void 0;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class WebmFile extends WebmContainer {
|
|
187
|
+
constructor(source) {
|
|
188
|
+
super("File", "File");
|
|
189
|
+
this.setSource(source);
|
|
190
|
+
}
|
|
191
|
+
fixDuration(duration) {
|
|
192
|
+
const segmentSection = this.getSectionById(139690087);
|
|
193
|
+
if (!segmentSection) {
|
|
194
|
+
return false;
|
|
195
|
+
}
|
|
196
|
+
const infoSection = segmentSection.getSectionById(88713574);
|
|
197
|
+
if (!infoSection) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
const timeScaleSection = infoSection.getSectionById(710577);
|
|
201
|
+
if (!timeScaleSection) {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
let durationSection = infoSection.getSectionById(1161);
|
|
205
|
+
if (durationSection) {
|
|
206
|
+
if (durationSection.getValue() <= 0) {
|
|
207
|
+
durationSection.setValue(duration);
|
|
208
|
+
} else {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
durationSection = new WebmFloat("Duration", "Float");
|
|
213
|
+
durationSection.setValue(duration);
|
|
214
|
+
infoSection.data.push({
|
|
215
|
+
id: 1161,
|
|
216
|
+
data: durationSection
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
timeScaleSection.setValue(1e6);
|
|
220
|
+
infoSection.updateByData();
|
|
221
|
+
segmentSection.updateByData();
|
|
222
|
+
this.updateByData();
|
|
223
|
+
return true;
|
|
224
|
+
}
|
|
225
|
+
toBlob(type = "video/webm") {
|
|
226
|
+
return new Blob([this.source.buffer], { type });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
const webmFixDuration = (blob, duration, type = "video/webm") => {
|
|
230
|
+
return new Promise((resolve, reject) => {
|
|
231
|
+
try {
|
|
232
|
+
const reader = new FileReader();
|
|
233
|
+
reader.addEventListener("loadend", () => {
|
|
234
|
+
try {
|
|
235
|
+
const result = reader.result;
|
|
236
|
+
const file = new WebmFile(new Uint8Array(result));
|
|
237
|
+
if (file.fixDuration(duration)) {
|
|
238
|
+
resolve(file.toBlob(type));
|
|
239
|
+
} else {
|
|
240
|
+
resolve(blob);
|
|
241
|
+
}
|
|
242
|
+
} catch (ex) {
|
|
243
|
+
reject(ex);
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
reader.addEventListener("error", () => reject());
|
|
247
|
+
reader.readAsArrayBuffer(blob);
|
|
248
|
+
} catch (ex) {
|
|
249
|
+
reject(ex);
|
|
250
|
+
}
|
|
251
|
+
});
|
|
252
|
+
};
|
|
41
253
|
export {
|
|
42
|
-
|
|
43
|
-
HumanMessageChunk,
|
|
44
|
-
isHumanMessage,
|
|
45
|
-
isHumanMessageChunk
|
|
254
|
+
webmFixDuration
|
|
46
255
|
};
|
|
47
256
|
//# sourceMappingURL=index.es41.js.map
|
package/dist/index.es41.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es41.js","sources":["../node_modules/.pnpm/@langchain+core@1.1.13_openai@6.16.0_zod@4.3.5_/node_modules/@langchain/core/dist/messages/human.js"],"sourcesContent":["import { BaseMessage, BaseMessageChunk, _mergeDicts, mergeContent } from \"./base.js\";\n\n//#region src/messages/human.ts\n/**\n* Represents a human message in a conversation.\n*/\nvar HumanMessage = class extends BaseMessage {\n\tstatic lc_name() {\n\t\treturn \"HumanMessage\";\n\t}\n\ttype = \"human\";\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t}\n\tstatic isInstance(obj) {\n\t\treturn super.isInstance(obj) && obj.type === \"human\";\n\t}\n};\n/**\n* Represents a chunk of a human message, which can be concatenated with\n* other human message chunks.\n*/\nvar HumanMessageChunk = class extends BaseMessageChunk {\n\tstatic lc_name() {\n\t\treturn \"HumanMessageChunk\";\n\t}\n\ttype = \"human\";\n\tconstructor(fields) {\n\t\tsuper(fields);\n\t}\n\tconcat(chunk) {\n\t\tconst Cls = this.constructor;\n\t\treturn new Cls({\n\t\t\tcontent: mergeContent(this.content, chunk.content),\n\t\t\tadditional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),\n\t\t\tresponse_metadata: _mergeDicts(this.response_metadata, chunk.response_metadata),\n\t\t\tid: this.id ?? chunk.id\n\t\t});\n\t}\n\tstatic isInstance(obj) {\n\t\treturn super.isInstance(obj) && obj.type === \"human\";\n\t}\n};\n/**\n* @deprecated Use {@link HumanMessage.isInstance} instead\n*/\nfunction isHumanMessage(x) {\n\treturn x.getType() === \"human\";\n}\n/**\n* @deprecated Use {@link HumanMessageChunk.isInstance} instead\n*/\nfunction isHumanMessageChunk(x) {\n\treturn x.getType() === \"human\";\n}\n\n//#endregion\nexport { HumanMessage, HumanMessageChunk, isHumanMessage, isHumanMessageChunk };\n//# sourceMappingURL=human.js.map"],"names":[],"mappings":";AAMG,IAAC,eAAe,cAAc,YAAY;AAAA,EAC5C,OAAO,UAAU;AAChB,WAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA,EACP,YAAY,QAAQ;AACnB,UAAM,MAAM;AAAA,EACb;AAAA,EACA,OAAO,WAAW,KAAK;AACtB,WAAO,MAAM,WAAW,GAAG,KAAK,IAAI,SAAS;AAAA,EAC9C;AACD;AAKG,IAAC,oBAAoB,cAAc,iBAAiB;AAAA,EACtD,OAAO,UAAU;AAChB,WAAO;AAAA,EACR;AAAA,EACA,OAAO;AAAA,EACP,YAAY,QAAQ;AACnB,UAAM,MAAM;AAAA,EACb;AAAA,EACA,OAAO,OAAO;AACb,UAAM,MAAM,KAAK;AACjB,WAAO,IAAI,IAAI;AAAA,MACd,SAAS,aAAa,KAAK,SAAS,MAAM,OAAO;AAAA,MACjD,mBAAmB,YAAY,KAAK,mBAAmB,MAAM,iBAAiB;AAAA,MAC9E,mBAAmB,YAAY,KAAK,mBAAmB,MAAM,iBAAiB;AAAA,MAC9E,IAAI,KAAK,MAAM,MAAM;AAAA,IACxB,CAAG;AAAA,EACF;AAAA,EACA,OAAO,WAAW,KAAK;AACtB,WAAO,MAAM,WAAW,GAAG,KAAK,IAAI,SAAS;AAAA,EAC9C;AACD;AAIA,SAAS,eAAe,GAAG;AAC1B,SAAO,EAAE,QAAO,MAAO;AACxB;AAIA,SAAS,oBAAoB,GAAG;AAC/B,SAAO,EAAE,QAAO,MAAO;AACxB;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"index.es41.js","sources":["../src/utils/BlobFix.ts"],"sourcesContent":["/*\n * There is a bug where `navigator.mediaDevices.getUserMedia` + `MediaRecorder`\n * creates WEBM files without duration metadata. See:\n * - https://bugs.chromium.org/p/chromium/issues/detail?id=642012\n * - https://stackoverflow.com/a/39971175/13989043\n *\n * This file contains a function that fixes the duration metadata of a WEBM file.\n * - Answer found: https://stackoverflow.com/a/75218309/13989043\n * - Code adapted from: https://github.com/mat-sz/webm-fix-duration\n * (forked from: https://github.com/yusitnikov/fix-webm-duration)\n */\n\ninterface Section {\n name: string;\n type: string;\n}\n\nconst sections: Record<number, Section> = {\n 0xa45dfa3: { name: \"EBML\", type: \"Container\" },\n 0x286: { name: \"EBMLVersion\", type: \"Uint\" },\n 0x2f7: { name: \"EBMLReadVersion\", type: \"Uint\" },\n 0x2f2: { name: \"EBMLMaxIDLength\", type: \"Uint\" },\n 0x2f3: { name: \"EBMLMaxSizeLength\", type: \"Uint\" },\n 0x282: { name: \"DocType\", type: \"String\" },\n 0x287: { name: \"DocTypeVersion\", type: \"Uint\" },\n 0x285: { name: \"DocTypeReadVersion\", type: \"Uint\" },\n 0x6c: { name: \"Void\", type: \"Binary\" },\n 0x489: { name: \"Duration\", type: \"Float\" },\n 0x8538067: { name: \"Segment\", type: \"Container\" },\n 0x549a966: { name: \"Info\", type: \"Container\" },\n 0xad7b1: { name: \"TimecodeScale\", type: \"Uint\" },\n};\n\nclass WebmBase<T> {\n source?: Uint8Array;\n data?: T;\n name: string;\n type: string;\n\n constructor(name = \"Unknown\", type = \"Unknown\") {\n this.name = name;\n this.type = type;\n }\n\n updateBySource() {}\n\n setSource(source: Uint8Array) {\n this.source = source;\n this.updateBySource();\n }\n\n updateByData() {}\n\n setData(data: T) {\n this.data = data;\n this.updateByData();\n }\n}\n\nclass WebmUint extends WebmBase<string> {\n constructor(name: string, type: string) {\n super(name, type || \"Uint\");\n }\n\n updateBySource() {\n this.data = \"\";\n for (let i = 0; i < this.source!.length; i++) {\n const hex = this.source![i].toString(16);\n this.data += padHex(hex);\n }\n }\n\n updateByData() {\n const length = this.data!.length / 2;\n this.source = new Uint8Array(length);\n for (let i = 0; i < length; i++) {\n const hex = this.data!.substr(i * 2, 2);\n this.source[i] = parseInt(hex, 16);\n }\n }\n\n getValue() {\n return parseInt(this.data!, 16);\n }\n\n setValue(value: number) {\n this.setData(padHex(value.toString(16)));\n }\n}\n\nfunction padHex(hex: string) {\n return hex.length % 2 === 1 ? \"0\" + hex : hex;\n}\n\nclass WebmFloat extends WebmBase<number> {\n constructor(name: string, type: string) {\n super(name, type || \"Float\");\n }\n\n getFloatArrayType() {\n return this.source && this.source.length === 4\n ? Float32Array\n : Float64Array;\n }\n \n updateBySource() {\n const byteArray = this.source!.slice().reverse();\n const floatArrayType = this.getFloatArrayType();\n const floatArray = new floatArrayType(byteArray.buffer as ArrayBuffer);\n this.data! = floatArray[0];\n }\n \n updateByData() {\n const floatArrayType = this.getFloatArrayType();\n const floatArray = new floatArrayType([this.data!]);\n const byteArray = new Uint8Array(floatArray.buffer as ArrayBuffer);\n this.source = byteArray.slice().reverse();\n }\n \n getValue() {\n return this.data;\n }\n \n setValue(value: number) {\n this.setData(value);\n }\n}\n\ninterface ContainerData {\n id: number;\n idHex?: string;\n data: WebmBase<any>;\n}\n\nclass WebmContainer extends WebmBase<ContainerData[]> {\n offset: number = 0;\n data: ContainerData[] = [];\n\n constructor(name: string, type: string) {\n super(name, type || \"Container\");\n }\n\n readByte() {\n return this.source![this.offset++];\n }\n \n readUint() {\n const firstByte = this.readByte();\n const bytes = 8 - firstByte.toString(2).length;\n let value = firstByte - (1 << (7 - bytes));\n for (let i = 0; i < bytes; i++) {\n value *= 256;\n value += this.readByte();\n }\n return value;\n }\n \n updateBySource() {\n let end: number | undefined = undefined;\n this.data = [];\n for (\n this.offset = 0;\n this.offset < this.source!.length;\n this.offset = end\n ) {\n const id = this.readUint();\n const len = this.readUint();\n end = Math.min(this.offset + len, this.source!.length);\n const data = this.source!.slice(this.offset, end);\n\n const info = sections[id] || { name: \"Unknown\", type: \"Unknown\" };\n let ctr: any = WebmBase;\n switch (info.type) {\n case \"Container\":\n ctr = WebmContainer;\n break;\n case \"Uint\":\n ctr = WebmUint;\n break;\n case \"Float\":\n ctr = WebmFloat;\n break;\n }\n const section = new ctr(info.name, info.type);\n section.setSource(data);\n this.data.push({\n id: id,\n idHex: id.toString(16),\n data: section,\n });\n }\n }\n \n writeUint(x: number, draft = false) {\n let bytes = 1, flag = 0x80;\n while (x >= flag && bytes < 8) {\n bytes++;\n flag *= 0x80;\n }\n\n if (!draft) {\n let value = flag + x;\n for (let i = bytes - 1; i >= 0; i--) {\n const c = value % 256;\n this.source![this.offset! + i] = c;\n value = (value - c) / 256;\n }\n }\n\n this.offset += bytes;\n }\n\n writeSections(draft = false) {\n this.offset = 0;\n for (let i = 0; i < this.data.length; i++) {\n const section = this.data[i],\n content = section.data.source,\n contentLength = content!.length;\n this.writeUint(section.id, draft);\n this.writeUint(contentLength, draft);\n if (!draft) {\n this.source!.set(content!, this.offset);\n }\n this.offset += contentLength;\n }\n return this.offset;\n }\n\n updateByData() {\n const length = this.writeSections(true);\n this.source = new Uint8Array(length);\n this.writeSections();\n }\n\n getSectionById(id: number) {\n for (let i = 0; i < this.data.length; i++) {\n const section = this.data[i];\n if (section.id === id) {\n return section.data;\n }\n }\n return undefined;\n }\n}\n\nclass WebmFile extends WebmContainer {\n constructor(source: Uint8Array) {\n super(\"File\", \"File\");\n this.setSource(source);\n }\n\n fixDuration(duration: number) {\n const segmentSection = this.getSectionById(0x8538067) as WebmContainer;\n if (!segmentSection) {\n return false;\n }\n\n const infoSection = segmentSection.getSectionById(0x549a966) as WebmContainer;\n if (!infoSection) {\n return false;\n }\n\n const timeScaleSection = infoSection.getSectionById(0xad7b1) as WebmFloat;\n if (!timeScaleSection) {\n return false;\n }\n\n let durationSection = infoSection.getSectionById(0x489) as WebmFloat;\n if (durationSection) {\n if (durationSection.getValue()! <= 0) {\n durationSection.setValue(duration);\n } else {\n return false;\n }\n } else {\n durationSection = new WebmFloat(\"Duration\", \"Float\");\n durationSection.setValue(duration);\n infoSection.data.push({\n id: 0x489,\n data: durationSection,\n });\n }\n\n timeScaleSection.setValue(1000000);\n infoSection.updateByData();\n segmentSection.updateByData();\n this.updateByData();\n\n return true;\n }\n\n toBlob(type = \"video/webm\") {\n return new Blob([this.source!.buffer as ArrayBuffer], { type });\n }\n}\n\nexport const webmFixDuration = (\n blob: Blob,\n duration: number,\n type = \"video/webm\",\n): Promise<Blob> => {\n return new Promise((resolve, reject) => {\n try {\n const reader = new FileReader();\n\n reader.addEventListener(\"loadend\", () => {\n try {\n const result = reader.result as ArrayBuffer;\n const file = new WebmFile(new Uint8Array(result));\n if (file.fixDuration(duration)) {\n resolve(file.toBlob(type));\n } else {\n resolve(blob);\n }\n } catch (ex) {\n reject(ex);\n }\n });\n\n reader.addEventListener(\"error\", () => reject());\n\n reader.readAsArrayBuffer(blob);\n } catch (ex) {\n reject(ex);\n }\n });\n};\n"],"names":[],"mappings":"AAiBA,MAAM,WAAoC;AAAA,EACtC,WAAW,EAAE,MAAM,QAAQ,MAAM,YAAA;AAAA,EACjC,KAAO,EAAE,MAAM,eAAe,MAAM,OAAA;AAAA,EACpC,KAAO,EAAE,MAAM,mBAAmB,MAAM,OAAA;AAAA,EACxC,KAAO,EAAE,MAAM,mBAAmB,MAAM,OAAA;AAAA,EACxC,KAAO,EAAE,MAAM,qBAAqB,MAAM,OAAA;AAAA,EAC1C,KAAO,EAAE,MAAM,WAAW,MAAM,SAAA;AAAA,EAChC,KAAO,EAAE,MAAM,kBAAkB,MAAM,OAAA;AAAA,EACvC,KAAO,EAAE,MAAM,sBAAsB,MAAM,OAAA;AAAA,EAC3C,KAAM,EAAE,MAAM,QAAQ,MAAM,SAAA;AAAA,EAC5B,MAAO,EAAE,MAAM,Y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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"pnpm install @langchain/openai`, etc."
|
|
35
|
-
].join(" "));
|
|
36
|
-
try {
|
|
37
|
-
if (!(rawToolCalls == null) && toolCalls === void 0) {
|
|
38
|
-
const [parsedToolCalls, invalidToolCalls] = defaultToolCallParser(rawToolCalls);
|
|
39
|
-
initParams.tool_calls = parsedToolCalls ?? [];
|
|
40
|
-
initParams.invalid_tool_calls = invalidToolCalls ?? [];
|
|
41
|
-
} else {
|
|
42
|
-
initParams.tool_calls = initParams.tool_calls ?? [];
|
|
43
|
-
initParams.invalid_tool_calls = initParams.invalid_tool_calls ?? [];
|
|
1
|
+
const CR = "\r".charCodeAt(0);
|
|
2
|
+
const LF = "\n".charCodeAt(0);
|
|
3
|
+
const NULL = "\0".charCodeAt(0);
|
|
4
|
+
const COLON = ":".charCodeAt(0);
|
|
5
|
+
const SPACE = " ".charCodeAt(0);
|
|
6
|
+
const TRAILING_NEWLINE = [CR, LF];
|
|
7
|
+
function BytesLineDecoder() {
|
|
8
|
+
let buffer = [];
|
|
9
|
+
let trailingCr = false;
|
|
10
|
+
return new TransformStream({
|
|
11
|
+
start() {
|
|
12
|
+
buffer = [];
|
|
13
|
+
trailingCr = false;
|
|
14
|
+
},
|
|
15
|
+
transform(chunk, controller) {
|
|
16
|
+
let text = chunk;
|
|
17
|
+
if (trailingCr) {
|
|
18
|
+
text = joinArrays([[CR], text]);
|
|
19
|
+
trailingCr = false;
|
|
20
|
+
}
|
|
21
|
+
if (text.length > 0 && text.at(-1) === CR) {
|
|
22
|
+
trailingCr = true;
|
|
23
|
+
text = text.subarray(0, -1);
|
|
24
|
+
}
|
|
25
|
+
if (!text.length) return;
|
|
26
|
+
const trailingNewline = TRAILING_NEWLINE.includes(text.at(-1));
|
|
27
|
+
const lastIdx = text.length - 1;
|
|
28
|
+
const { lines } = text.reduce((acc, cur, idx) => {
|
|
29
|
+
if (acc.from > idx) return acc;
|
|
30
|
+
if (cur === CR || cur === LF) {
|
|
31
|
+
acc.lines.push(text.subarray(acc.from, idx));
|
|
32
|
+
if (cur === CR && text[idx + 1] === LF) acc.from = idx + 2;
|
|
33
|
+
else acc.from = idx + 1;
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
35
|
+
if (idx === lastIdx && acc.from <= lastIdx) acc.lines.push(text.subarray(acc.from));
|
|
36
|
+
return acc;
|
|
37
|
+
}, {
|
|
38
|
+
lines: [],
|
|
39
|
+
from: 0
|
|
40
|
+
});
|
|
41
|
+
if (lines.length === 1 && !trailingNewline) {
|
|
42
|
+
buffer.push(lines[0]);
|
|
43
|
+
return;
|
|
48
44
|
}
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
if (buffer.length) {
|
|
46
|
+
buffer.push(lines[0]);
|
|
47
|
+
lines[0] = joinArrays(buffer);
|
|
48
|
+
buffer = [];
|
|
52
49
|
}
|
|
53
|
-
if (
|
|
54
|
-
if (
|
|
55
|
-
type: "tool_call",
|
|
56
|
-
id: toolCall.id,
|
|
57
|
-
name: toolCall.name,
|
|
58
|
-
args: toolCall.args
|
|
59
|
-
})));
|
|
60
|
-
const missingToolCalls = initParams.contentBlocks.filter((block) => block.type === "tool_call").filter((block) => !initParams.tool_calls?.some((toolCall) => toolCall.id === block.id && toolCall.name === block.name));
|
|
61
|
-
if (missingToolCalls.length > 0) initParams.tool_calls = missingToolCalls.map((block) => ({
|
|
62
|
-
type: "tool_call",
|
|
63
|
-
id: block.id,
|
|
64
|
-
name: block.name,
|
|
65
|
-
args: block.args
|
|
66
|
-
}));
|
|
50
|
+
if (!trailingNewline) {
|
|
51
|
+
if (lines.length) buffer = [lines.pop()];
|
|
67
52
|
}
|
|
53
|
+
for (const line of lines) controller.enqueue(line);
|
|
54
|
+
},
|
|
55
|
+
flush(controller) {
|
|
56
|
+
if (buffer.length) controller.enqueue(joinArrays(buffer));
|
|
68
57
|
}
|
|
69
|
-
|
|
70
|
-
if (typeof initParams !== "string") {
|
|
71
|
-
this.tool_calls = initParams.tool_calls ?? this.tool_calls;
|
|
72
|
-
this.invalid_tool_calls = initParams.invalid_tool_calls ?? this.invalid_tool_calls;
|
|
73
|
-
}
|
|
74
|
-
this.usage_metadata = initParams.usage_metadata;
|
|
75
|
-
}
|
|
76
|
-
static lc_name() {
|
|
77
|
-
return "AIMessage";
|
|
78
|
-
}
|
|
79
|
-
get contentBlocks() {
|
|
80
|
-
if (this.response_metadata && "output_version" in this.response_metadata && this.response_metadata.output_version === "v1") return this.content;
|
|
81
|
-
if (this.response_metadata && "model_provider" in this.response_metadata && typeof this.response_metadata.model_provider === "string") {
|
|
82
|
-
const translator = getTranslator(this.response_metadata.model_provider);
|
|
83
|
-
if (translator) return translator.translateContent(this);
|
|
84
|
-
}
|
|
85
|
-
const blocks = super.contentBlocks;
|
|
86
|
-
if (this.tool_calls) {
|
|
87
|
-
const missingToolCalls = this.tool_calls.filter((block) => !blocks.some((b) => b.id === block.id && b.name === block.name));
|
|
88
|
-
blocks.push(...missingToolCalls.map((block) => ({
|
|
89
|
-
type: "tool_call",
|
|
90
|
-
id: block.id,
|
|
91
|
-
name: block.name,
|
|
92
|
-
args: block.args
|
|
93
|
-
})));
|
|
94
|
-
}
|
|
95
|
-
return blocks;
|
|
96
|
-
}
|
|
97
|
-
get _printableFields() {
|
|
98
|
-
return {
|
|
99
|
-
...super._printableFields,
|
|
100
|
-
tool_calls: this.tool_calls,
|
|
101
|
-
invalid_tool_calls: this.invalid_tool_calls,
|
|
102
|
-
usage_metadata: this.usage_metadata
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
static isInstance(obj) {
|
|
106
|
-
return super.isInstance(obj) && obj.type === "ai";
|
|
107
|
-
}
|
|
108
|
-
};
|
|
109
|
-
function isAIMessage(x) {
|
|
110
|
-
return x._getType() === "ai";
|
|
111
|
-
}
|
|
112
|
-
function isAIMessageChunk(x) {
|
|
113
|
-
return x._getType() === "ai";
|
|
58
|
+
});
|
|
114
59
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
};
|
|
136
|
-
else {
|
|
137
|
-
const collapsed = collapseToolCallChunks(fields.tool_call_chunks ?? []);
|
|
138
|
-
initParams = {
|
|
139
|
-
...fields,
|
|
140
|
-
tool_call_chunks: collapsed.tool_call_chunks,
|
|
141
|
-
tool_calls: collapsed.tool_calls,
|
|
142
|
-
invalid_tool_calls: collapsed.invalid_tool_calls,
|
|
143
|
-
usage_metadata: fields.usage_metadata !== void 0 ? fields.usage_metadata : void 0
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
super(initParams);
|
|
147
|
-
this.tool_call_chunks = initParams.tool_call_chunks ?? this.tool_call_chunks;
|
|
148
|
-
this.tool_calls = initParams.tool_calls ?? this.tool_calls;
|
|
149
|
-
this.invalid_tool_calls = initParams.invalid_tool_calls ?? this.invalid_tool_calls;
|
|
150
|
-
this.usage_metadata = initParams.usage_metadata;
|
|
151
|
-
}
|
|
152
|
-
get lc_aliases() {
|
|
153
|
-
return {
|
|
154
|
-
...super.lc_aliases,
|
|
155
|
-
tool_calls: "tool_calls",
|
|
156
|
-
invalid_tool_calls: "invalid_tool_calls",
|
|
157
|
-
tool_call_chunks: "tool_call_chunks"
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
static lc_name() {
|
|
161
|
-
return "AIMessageChunk";
|
|
162
|
-
}
|
|
163
|
-
get contentBlocks() {
|
|
164
|
-
if (this.response_metadata && "output_version" in this.response_metadata && this.response_metadata.output_version === "v1") return this.content;
|
|
165
|
-
if (this.response_metadata && "model_provider" in this.response_metadata && typeof this.response_metadata.model_provider === "string") {
|
|
166
|
-
const translator = getTranslator(this.response_metadata.model_provider);
|
|
167
|
-
if (translator) return translator.translateContent(this);
|
|
168
|
-
}
|
|
169
|
-
const blocks = super.contentBlocks;
|
|
170
|
-
if (this.tool_calls) {
|
|
171
|
-
if (typeof this.content !== "string") {
|
|
172
|
-
const contentToolCalls = this.content.filter((block) => block.type === "tool_call").map((block) => block.id);
|
|
173
|
-
for (const toolCall of this.tool_calls) if (toolCall.id && !contentToolCalls.includes(toolCall.id)) blocks.push({
|
|
174
|
-
...toolCall,
|
|
175
|
-
type: "tool_call",
|
|
176
|
-
id: toolCall.id,
|
|
177
|
-
name: toolCall.name,
|
|
178
|
-
args: toolCall.args
|
|
179
|
-
});
|
|
60
|
+
function SSEDecoder() {
|
|
61
|
+
let event = "";
|
|
62
|
+
let data = [];
|
|
63
|
+
let lastEventId = "";
|
|
64
|
+
let retry = null;
|
|
65
|
+
const decoder = new TextDecoder();
|
|
66
|
+
return new TransformStream({
|
|
67
|
+
transform(chunk, controller) {
|
|
68
|
+
if (!chunk.length) {
|
|
69
|
+
if (!event && !data.length && !lastEventId && retry == null) return;
|
|
70
|
+
const sse = {
|
|
71
|
+
id: lastEventId || void 0,
|
|
72
|
+
event,
|
|
73
|
+
data: data.length ? decodeArraysToJson(decoder, data) : null
|
|
74
|
+
};
|
|
75
|
+
event = "";
|
|
76
|
+
data = [];
|
|
77
|
+
retry = null;
|
|
78
|
+
controller.enqueue(sse);
|
|
79
|
+
return;
|
|
180
80
|
}
|
|
81
|
+
if (chunk[0] === COLON) return;
|
|
82
|
+
const sepIdx = chunk.indexOf(COLON);
|
|
83
|
+
if (sepIdx === -1) return;
|
|
84
|
+
const fieldName = decoder.decode(chunk.subarray(0, sepIdx));
|
|
85
|
+
let value = chunk.subarray(sepIdx + 1);
|
|
86
|
+
if (value[0] === SPACE) value = value.subarray(1);
|
|
87
|
+
if (fieldName === "event") event = decoder.decode(value);
|
|
88
|
+
else if (fieldName === "data") data.push(value);
|
|
89
|
+
else if (fieldName === "id") {
|
|
90
|
+
if (value.indexOf(NULL) === -1) lastEventId = decoder.decode(value);
|
|
91
|
+
} else if (fieldName === "retry") {
|
|
92
|
+
const retryNum = Number.parseInt(decoder.decode(value), 10);
|
|
93
|
+
if (!Number.isNaN(retryNum)) retry = retryNum;
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
flush(controller) {
|
|
97
|
+
if (event) controller.enqueue({
|
|
98
|
+
id: lastEventId || void 0,
|
|
99
|
+
event,
|
|
100
|
+
data: data.length ? decodeArraysToJson(decoder, data) : null
|
|
101
|
+
});
|
|
181
102
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
concat(chunk) {
|
|
194
|
-
const combinedFields = {
|
|
195
|
-
content: mergeContent(this.content, chunk.content),
|
|
196
|
-
additional_kwargs: _mergeDicts(this.additional_kwargs, chunk.additional_kwargs),
|
|
197
|
-
response_metadata: mergeResponseMetadata(this.response_metadata, chunk.response_metadata),
|
|
198
|
-
tool_call_chunks: [],
|
|
199
|
-
id: this.id ?? chunk.id
|
|
200
|
-
};
|
|
201
|
-
if (this.tool_call_chunks !== void 0 || chunk.tool_call_chunks !== void 0) {
|
|
202
|
-
const rawToolCalls = _mergeLists(this.tool_call_chunks, chunk.tool_call_chunks);
|
|
203
|
-
if (rawToolCalls !== void 0 && rawToolCalls.length > 0) combinedFields.tool_call_chunks = rawToolCalls;
|
|
204
|
-
}
|
|
205
|
-
if (this.usage_metadata !== void 0 || chunk.usage_metadata !== void 0) combinedFields.usage_metadata = mergeUsageMetadata(this.usage_metadata, chunk.usage_metadata);
|
|
206
|
-
const Cls = this.constructor;
|
|
207
|
-
return new Cls(combinedFields);
|
|
208
|
-
}
|
|
209
|
-
static isInstance(obj) {
|
|
210
|
-
return super.isInstance(obj) && obj.type === "ai";
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function joinArrays(data) {
|
|
106
|
+
const totalLength = data.reduce((acc, curr) => acc + curr.length, 0);
|
|
107
|
+
const merged = new Uint8Array(totalLength);
|
|
108
|
+
let offset = 0;
|
|
109
|
+
for (const c of data) {
|
|
110
|
+
merged.set(c, offset);
|
|
111
|
+
offset += c.length;
|
|
211
112
|
}
|
|
212
|
-
|
|
113
|
+
return merged;
|
|
114
|
+
}
|
|
115
|
+
function decodeArraysToJson(decoder, data) {
|
|
116
|
+
return JSON.parse(decoder.decode(joinArrays(data)));
|
|
117
|
+
}
|
|
213
118
|
export {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
isAIMessage,
|
|
217
|
-
isAIMessageChunk
|
|
119
|
+
BytesLineDecoder,
|
|
120
|
+
SSEDecoder
|
|
218
121
|
};
|
|
219
122
|
//# sourceMappingURL=index.es42.js.map
|