langgraph-ui-components 0.0.11-testing → 0.0.12
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 +2 -3
- package/dist/index.es10.js +6 -25
- package/dist/index.es10.js.map +1 -1
- package/dist/index.es100.js +156 -127
- package/dist/index.es100.js.map +1 -1
- package/dist/index.es101.js +195 -62
- package/dist/index.es101.js.map +1 -1
- package/dist/index.es102.js +14 -37
- package/dist/index.es102.js.map +1 -1
- package/dist/index.es103.js +27 -34
- package/dist/index.es103.js.map +1 -1
- package/dist/index.es104.js +25 -157
- package/dist/index.es104.js.map +1 -1
- package/dist/index.es105.js +3130 -176
- package/dist/index.es105.js.map +1 -1
- package/dist/index.es106.js +36 -13
- package/dist/index.es106.js.map +1 -1
- package/dist/index.es107.js +5 -30
- package/dist/index.es107.js.map +1 -1
- package/dist/index.es108.js +69 -30
- package/dist/index.es108.js.map +1 -1
- package/dist/index.es109.js +28 -3148
- package/dist/index.es109.js.map +1 -1
- package/dist/index.es11.js +6 -1
- package/dist/index.es11.js.map +1 -1
- package/dist/index.es113.js +5 -16
- package/dist/index.es113.js.map +1 -1
- package/dist/index.es114.js +2 -7
- package/dist/index.es114.js.map +1 -1
- package/dist/index.es115.js +13 -2
- package/dist/index.es115.js.map +1 -1
- package/dist/index.es116.js +499 -9
- package/dist/index.es116.js.map +1 -1
- package/dist/index.es117.js +5 -501
- package/dist/index.es117.js.map +1 -1
- package/dist/index.es118.js +2 -7
- package/dist/index.es118.js.map +1 -1
- package/dist/index.es119.js +148 -2
- package/dist/index.es119.js.map +1 -1
- package/dist/index.es120.js +878 -118
- package/dist/index.es120.js.map +1 -1
- package/dist/index.es121.js +251 -877
- package/dist/index.es121.js.map +1 -1
- package/dist/index.es122.js +3 -281
- package/dist/index.es122.js.map +1 -1
- package/dist/index.es123.js +445 -3
- package/dist/index.es123.js.map +1 -1
- package/dist/index.es124.js +38 -436
- package/dist/index.es124.js.map +1 -1
- package/dist/index.es125.js +22 -46
- package/dist/index.es125.js.map +1 -1
- package/dist/index.es126.js +78 -21
- package/dist/index.es126.js.map +1 -1
- package/dist/index.es127.js +126 -76
- package/dist/index.es127.js.map +1 -1
- package/dist/index.es128.js +45 -125
- package/dist/index.es128.js.map +1 -1
- package/dist/index.es129.js +9 -48
- package/dist/index.es129.js.map +1 -1
- package/dist/index.es13.js +6 -6
- package/dist/index.es130.js +45 -10
- package/dist/index.es130.js.map +1 -1
- package/dist/index.es131.js +97 -43
- package/dist/index.es131.js.map +1 -1
- package/dist/index.es132.js +48 -94
- package/dist/index.es132.js.map +1 -1
- package/dist/index.es133.js +14 -51
- package/dist/index.es133.js.map +1 -1
- package/dist/index.es15.js +59 -31
- package/dist/index.es15.js.map +1 -1
- package/dist/index.es16.js +4 -4
- package/dist/index.es16.js.map +1 -1
- package/dist/index.es183.js +13 -162
- package/dist/index.es183.js.map +1 -1
- package/dist/index.es184.js +89 -2
- package/dist/index.es184.js.map +1 -1
- package/dist/index.es185.js +2 -15
- package/dist/index.es185.js.map +1 -1
- package/dist/index.es186.js +54 -87
- package/dist/index.es186.js.map +1 -1
- package/dist/index.es187.js +100 -2
- package/dist/index.es187.js.map +1 -1
- package/dist/index.es188.js +185 -50
- package/dist/index.es188.js.map +1 -1
- package/dist/index.es189.js +96 -86
- package/dist/index.es189.js.map +1 -1
- package/dist/index.es190.js +31 -187
- package/dist/index.es190.js.map +1 -1
- package/dist/index.es191.js +9 -109
- package/dist/index.es191.js.map +1 -1
- package/dist/index.es192.js +11 -35
- package/dist/index.es192.js.map +1 -1
- package/dist/index.es193.js +12 -10
- package/dist/index.es193.js.map +1 -1
- package/dist/index.es194.js +90 -10
- package/dist/index.es194.js.map +1 -1
- package/dist/index.es195.js +274 -11
- package/dist/index.es195.js.map +1 -1
- package/dist/index.es196.js +2 -91
- package/dist/index.es196.js.map +1 -1
- package/dist/index.es197.js +150 -261
- package/dist/index.es197.js.map +1 -1
- package/dist/index.es198.js +51 -2
- package/dist/index.es198.js.map +1 -1
- package/dist/index.es199.js +34 -158
- package/dist/index.es199.js.map +1 -1
- package/dist/index.es2.js +84 -46
- package/dist/index.es2.js.map +1 -1
- package/dist/index.es20.js +2 -2
- package/dist/index.es200.js +34 -50
- package/dist/index.es200.js.map +1 -1
- package/dist/index.es201.js +32 -32
- package/dist/index.es201.js.map +1 -1
- package/dist/index.es202.js +23 -34
- package/dist/index.es202.js.map +1 -1
- package/dist/index.es203.js +583 -32
- package/dist/index.es203.js.map +1 -1
- package/dist/index.es204.js +121 -20
- package/dist/index.es204.js.map +1 -1
- package/dist/index.es205.js +158 -585
- package/dist/index.es205.js.map +1 -1
- package/dist/index.es206.js +2 -125
- package/dist/index.es206.js.map +1 -1
- package/dist/index.es22.js +15 -119
- package/dist/index.es22.js.map +1 -1
- package/dist/index.es23.js +37 -17
- package/dist/index.es23.js.map +1 -1
- package/dist/index.es24.js +27 -34
- package/dist/index.es24.js.map +1 -1
- package/dist/index.es25.js +145 -28
- package/dist/index.es25.js.map +1 -1
- package/dist/index.es252.js +2 -2
- package/dist/index.es253.js +1 -1
- package/dist/index.es258.js +1 -1
- package/dist/index.es26.js +100 -144
- package/dist/index.es26.js.map +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.es27.js +66 -101
- package/dist/index.es27.js.map +1 -1
- package/dist/index.es277.js +147 -2
- package/dist/index.es277.js.map +1 -1
- package/dist/index.es278.js +167 -126
- package/dist/index.es278.js.map +1 -1
- package/dist/index.es279.js +2 -188
- package/dist/index.es279.js.map +1 -1
- package/dist/index.es28.js +121 -68
- package/dist/index.es28.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 +10 -42
- 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.es314.js +1 -1
- package/dist/index.es334.js +2 -2
- package/dist/index.es4.js +1 -2
- package/dist/index.es4.js.map +1 -1
- package/dist/index.es43.js +5 -5
- package/dist/index.es45.js +1 -1
- package/dist/index.es49.js +3 -3
- package/dist/index.es5.js.map +1 -1
- package/dist/index.es50.js +208 -5
- package/dist/index.es50.js.map +1 -1
- package/dist/index.es51.js +5 -208
- package/dist/index.es51.js.map +1 -1
- package/dist/index.es52.js +3 -3
- package/dist/index.es61.js +1 -1
- package/dist/index.es62.js +2 -2
- package/dist/index.es64.js +142 -5
- package/dist/index.es64.js.map +1 -1
- package/dist/index.es65.js +285 -148
- package/dist/index.es65.js.map +1 -1
- package/dist/index.es66.js +62 -668
- package/dist/index.es66.js.map +1 -1
- package/dist/index.es67.js +201 -131
- package/dist/index.es67.js.map +1 -1
- package/dist/index.es68.js +29 -295
- package/dist/index.es68.js.map +1 -1
- package/dist/index.es69.js +8 -65
- package/dist/index.es69.js.map +1 -1
- package/dist/index.es7.js +1 -2
- package/dist/index.es7.js.map +1 -1
- package/dist/index.es70.js +9 -210
- package/dist/index.es70.js.map +1 -1
- package/dist/index.es71.js +181 -28
- package/dist/index.es71.js.map +1 -1
- package/dist/index.es72.js +23 -8
- package/dist/index.es72.js.map +1 -1
- package/dist/index.es73.js +1397 -9
- package/dist/index.es73.js.map +1 -1
- package/dist/index.es74.js +9 -187
- package/dist/index.es74.js.map +1 -1
- package/dist/index.es75.js +8 -24
- package/dist/index.es75.js.map +1 -1
- package/dist/index.es76.js +5 -1399
- package/dist/index.es76.js.map +1 -1
- package/dist/index.es77.js +163 -9
- package/dist/index.es77.js.map +1 -1
- package/dist/index.es78.js +672 -8
- package/dist/index.es78.js.map +1 -1
- package/dist/index.es79.js +11 -36
- package/dist/index.es79.js.map +1 -1
- package/dist/index.es80.js +40 -5
- package/dist/index.es80.js.map +1 -1
- package/dist/index.es81.js +32 -71
- package/dist/index.es81.js.map +1 -1
- package/dist/index.es82.js +225 -30
- package/dist/index.es82.js.map +1 -1
- package/dist/index.es83.js +29 -11
- package/dist/index.es83.js.map +1 -1
- package/dist/index.es84.js +72 -37
- package/dist/index.es84.js.map +1 -1
- package/dist/index.es85.js +74 -32
- package/dist/index.es85.js.map +1 -1
- package/dist/index.es86.js +46 -226
- package/dist/index.es86.js.map +1 -1
- package/dist/index.es87.js +6 -6
- package/dist/index.es87.js.map +1 -1
- package/dist/index.es88.js +39 -71
- package/dist/index.es88.js.map +1 -1
- package/dist/index.es89.js +54 -73
- package/dist/index.es89.js.map +1 -1
- package/dist/index.es90.js +13 -52
- package/dist/index.es90.js.map +1 -1
- package/dist/index.es91.js +135 -28
- package/dist/index.es91.js.map +1 -1
- package/dist/index.es92.js +20 -42
- package/dist/index.es92.js.map +1 -1
- package/dist/index.es93.js +175 -50
- package/dist/index.es93.js.map +1 -1
- package/dist/index.es94.js +239 -11
- package/dist/index.es94.js.map +1 -1
- package/dist/index.es95.js +348 -130
- package/dist/index.es95.js.map +1 -1
- package/dist/index.es96.js +134 -18
- package/dist/index.es96.js.map +1 -1
- package/dist/index.es97.js +61 -173
- package/dist/index.es97.js.map +1 -1
- package/dist/index.es98.js +30 -234
- package/dist/index.es98.js.map +1 -1
- package/dist/index.es99.js +26 -344
- package/dist/index.es99.js.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.es121.js
CHANGED
|
@@ -1,909 +1,283 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
function
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
function getMicrosecondPrecisionDatestring(epoch, executionOrder = 1) {
|
|
21
|
-
const paddedOrder = executionOrder.toFixed(0).slice(0, 3).padStart(3, "0");
|
|
22
|
-
return `${new Date(epoch).toISOString().slice(0, -1)}${paddedOrder}Z`;
|
|
23
|
-
}
|
|
24
|
-
function convertToDottedOrderFormat(epoch, runId, executionOrder = 1) {
|
|
25
|
-
const microsecondPrecisionDatestring = getMicrosecondPrecisionDatestring(epoch, executionOrder);
|
|
26
|
-
return {
|
|
27
|
-
dottedOrder: stripNonAlphanumeric(microsecondPrecisionDatestring) + runId,
|
|
28
|
-
microsecondPrecisionDatestring
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
const HEADER_SAFE_REPLICA_FIELDS = /* @__PURE__ */ new Set([
|
|
32
|
-
"projectName",
|
|
33
|
-
"updates",
|
|
34
|
-
"reroot"
|
|
35
|
-
]);
|
|
36
|
-
function filterReplicaForHeaders(replica) {
|
|
37
|
-
const filtered = {};
|
|
38
|
-
for (const key of Object.keys(replica)) {
|
|
39
|
-
if (HEADER_SAFE_REPLICA_FIELDS.has(key)) {
|
|
40
|
-
filtered[key] = replica[key];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return filtered;
|
|
44
|
-
}
|
|
45
|
-
class Baggage {
|
|
46
|
-
constructor(metadata, tags, project_name, replicas) {
|
|
47
|
-
Object.defineProperty(this, "metadata", {
|
|
48
|
-
enumerable: true,
|
|
49
|
-
configurable: true,
|
|
50
|
-
writable: true,
|
|
51
|
-
value: void 0
|
|
52
|
-
});
|
|
53
|
-
Object.defineProperty(this, "tags", {
|
|
54
|
-
enumerable: true,
|
|
55
|
-
configurable: true,
|
|
56
|
-
writable: true,
|
|
57
|
-
value: void 0
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(this, "project_name", {
|
|
60
|
-
enumerable: true,
|
|
61
|
-
configurable: true,
|
|
62
|
-
writable: true,
|
|
63
|
-
value: void 0
|
|
64
|
-
});
|
|
65
|
-
Object.defineProperty(this, "replicas", {
|
|
66
|
-
enumerable: true,
|
|
67
|
-
configurable: true,
|
|
68
|
-
writable: true,
|
|
69
|
-
value: void 0
|
|
70
|
-
});
|
|
71
|
-
this.metadata = metadata;
|
|
72
|
-
this.tags = tags;
|
|
73
|
-
this.project_name = project_name;
|
|
74
|
-
this.replicas = replicas;
|
|
75
|
-
}
|
|
76
|
-
static fromHeader(value) {
|
|
77
|
-
const items = value.split(",");
|
|
78
|
-
let metadata = {};
|
|
79
|
-
let tags = [];
|
|
80
|
-
let project_name;
|
|
81
|
-
let replicas;
|
|
82
|
-
for (const item of items) {
|
|
83
|
-
const [key, uriValue] = item.split("=");
|
|
84
|
-
const value2 = decodeURIComponent(uriValue);
|
|
85
|
-
if (key === "langsmith-metadata") {
|
|
86
|
-
metadata = JSON.parse(value2);
|
|
87
|
-
} else if (key === "langsmith-tags") {
|
|
88
|
-
tags = value2.split(",");
|
|
89
|
-
} else if (key === "langsmith-project") {
|
|
90
|
-
project_name = value2;
|
|
91
|
-
} else if (key === "langsmith-replicas") {
|
|
92
|
-
const parsed = JSON.parse(value2);
|
|
93
|
-
replicas = parsed.map((replica) => {
|
|
94
|
-
if (Array.isArray(replica)) {
|
|
95
|
-
return replica;
|
|
96
|
-
}
|
|
97
|
-
return filterReplicaForHeaders(replica);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return new Baggage(metadata, tags, project_name, replicas);
|
|
102
|
-
}
|
|
103
|
-
toHeader() {
|
|
104
|
-
const items = [];
|
|
105
|
-
if (this.metadata && Object.keys(this.metadata).length > 0) {
|
|
106
|
-
items.push(`langsmith-metadata=${encodeURIComponent(JSON.stringify(this.metadata))}`);
|
|
107
|
-
}
|
|
108
|
-
if (this.tags && this.tags.length > 0) {
|
|
109
|
-
items.push(`langsmith-tags=${encodeURIComponent(this.tags.join(","))}`);
|
|
110
|
-
}
|
|
111
|
-
if (this.project_name) {
|
|
112
|
-
items.push(`langsmith-project=${encodeURIComponent(this.project_name)}`);
|
|
113
|
-
}
|
|
114
|
-
return items.join(",");
|
|
115
|
-
}
|
|
1
|
+
import { __export } from "./index.es55.js";
|
|
2
|
+
import { _deepClone, PatchError, unescapePathComponent, isInteger, hasUndefined } from "./index.es194.js";
|
|
3
|
+
var core_exports = {};
|
|
4
|
+
__export(core_exports, {
|
|
5
|
+
JsonPatchError: () => JsonPatchError,
|
|
6
|
+
_areEquals: () => _areEquals,
|
|
7
|
+
applyOperation: () => applyOperation,
|
|
8
|
+
applyPatch: () => applyPatch,
|
|
9
|
+
applyReducer: () => applyReducer,
|
|
10
|
+
deepClone: () => deepClone,
|
|
11
|
+
getValueByPointer: () => getValueByPointer,
|
|
12
|
+
validate: () => validate,
|
|
13
|
+
validator: () => validator
|
|
14
|
+
});
|
|
15
|
+
const JsonPatchError = PatchError;
|
|
16
|
+
const deepClone = _deepClone;
|
|
17
|
+
function isDangerousKey(key) {
|
|
18
|
+
return Object.getOwnPropertyNames(Object.prototype).includes(key);
|
|
116
19
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
writable: true,
|
|
153
|
-
value: void 0
|
|
154
|
-
});
|
|
155
|
-
Object.defineProperty(this, "child_runs", {
|
|
156
|
-
enumerable: true,
|
|
157
|
-
configurable: true,
|
|
158
|
-
writable: true,
|
|
159
|
-
value: void 0
|
|
160
|
-
});
|
|
161
|
-
Object.defineProperty(this, "start_time", {
|
|
162
|
-
enumerable: true,
|
|
163
|
-
configurable: true,
|
|
164
|
-
writable: true,
|
|
165
|
-
value: void 0
|
|
166
|
-
});
|
|
167
|
-
Object.defineProperty(this, "end_time", {
|
|
168
|
-
enumerable: true,
|
|
169
|
-
configurable: true,
|
|
170
|
-
writable: true,
|
|
171
|
-
value: void 0
|
|
172
|
-
});
|
|
173
|
-
Object.defineProperty(this, "extra", {
|
|
174
|
-
enumerable: true,
|
|
175
|
-
configurable: true,
|
|
176
|
-
writable: true,
|
|
177
|
-
value: void 0
|
|
178
|
-
});
|
|
179
|
-
Object.defineProperty(this, "tags", {
|
|
180
|
-
enumerable: true,
|
|
181
|
-
configurable: true,
|
|
182
|
-
writable: true,
|
|
183
|
-
value: void 0
|
|
184
|
-
});
|
|
185
|
-
Object.defineProperty(this, "error", {
|
|
186
|
-
enumerable: true,
|
|
187
|
-
configurable: true,
|
|
188
|
-
writable: true,
|
|
189
|
-
value: void 0
|
|
190
|
-
});
|
|
191
|
-
Object.defineProperty(this, "serialized", {
|
|
192
|
-
enumerable: true,
|
|
193
|
-
configurable: true,
|
|
194
|
-
writable: true,
|
|
195
|
-
value: void 0
|
|
196
|
-
});
|
|
197
|
-
Object.defineProperty(this, "inputs", {
|
|
198
|
-
enumerable: true,
|
|
199
|
-
configurable: true,
|
|
200
|
-
writable: true,
|
|
201
|
-
value: void 0
|
|
202
|
-
});
|
|
203
|
-
Object.defineProperty(this, "outputs", {
|
|
204
|
-
enumerable: true,
|
|
205
|
-
configurable: true,
|
|
206
|
-
writable: true,
|
|
207
|
-
value: void 0
|
|
208
|
-
});
|
|
209
|
-
Object.defineProperty(this, "reference_example_id", {
|
|
210
|
-
enumerable: true,
|
|
211
|
-
configurable: true,
|
|
212
|
-
writable: true,
|
|
213
|
-
value: void 0
|
|
214
|
-
});
|
|
215
|
-
Object.defineProperty(this, "client", {
|
|
216
|
-
enumerable: true,
|
|
217
|
-
configurable: true,
|
|
218
|
-
writable: true,
|
|
219
|
-
value: void 0
|
|
220
|
-
});
|
|
221
|
-
Object.defineProperty(this, "events", {
|
|
222
|
-
enumerable: true,
|
|
223
|
-
configurable: true,
|
|
224
|
-
writable: true,
|
|
225
|
-
value: void 0
|
|
226
|
-
});
|
|
227
|
-
Object.defineProperty(this, "trace_id", {
|
|
228
|
-
enumerable: true,
|
|
229
|
-
configurable: true,
|
|
230
|
-
writable: true,
|
|
231
|
-
value: void 0
|
|
232
|
-
});
|
|
233
|
-
Object.defineProperty(this, "dotted_order", {
|
|
234
|
-
enumerable: true,
|
|
235
|
-
configurable: true,
|
|
236
|
-
writable: true,
|
|
237
|
-
value: void 0
|
|
238
|
-
});
|
|
239
|
-
Object.defineProperty(this, "tracingEnabled", {
|
|
240
|
-
enumerable: true,
|
|
241
|
-
configurable: true,
|
|
242
|
-
writable: true,
|
|
243
|
-
value: void 0
|
|
244
|
-
});
|
|
245
|
-
Object.defineProperty(this, "execution_order", {
|
|
246
|
-
enumerable: true,
|
|
247
|
-
configurable: true,
|
|
248
|
-
writable: true,
|
|
249
|
-
value: void 0
|
|
250
|
-
});
|
|
251
|
-
Object.defineProperty(this, "child_execution_order", {
|
|
252
|
-
enumerable: true,
|
|
253
|
-
configurable: true,
|
|
254
|
-
writable: true,
|
|
255
|
-
value: void 0
|
|
256
|
-
});
|
|
257
|
-
Object.defineProperty(this, "attachments", {
|
|
258
|
-
enumerable: true,
|
|
259
|
-
configurable: true,
|
|
260
|
-
writable: true,
|
|
261
|
-
value: void 0
|
|
262
|
-
});
|
|
263
|
-
Object.defineProperty(this, "replicas", {
|
|
264
|
-
enumerable: true,
|
|
265
|
-
configurable: true,
|
|
266
|
-
writable: true,
|
|
267
|
-
value: void 0
|
|
268
|
-
});
|
|
269
|
-
Object.defineProperty(this, "distributedParentId", {
|
|
270
|
-
enumerable: true,
|
|
271
|
-
configurable: true,
|
|
272
|
-
writable: true,
|
|
273
|
-
value: void 0
|
|
274
|
-
});
|
|
275
|
-
Object.defineProperty(this, "_serialized_start_time", {
|
|
276
|
-
enumerable: true,
|
|
277
|
-
configurable: true,
|
|
278
|
-
writable: true,
|
|
279
|
-
value: void 0
|
|
280
|
-
});
|
|
281
|
-
Object.defineProperty(this, "_awaitInputsOnPost", {
|
|
282
|
-
enumerable: true,
|
|
283
|
-
configurable: true,
|
|
284
|
-
writable: true,
|
|
285
|
-
value: void 0
|
|
20
|
+
const objOps = {
|
|
21
|
+
add: function(obj, key, document) {
|
|
22
|
+
if (isDangerousKey(key)) throw new TypeError("JSON-Patch: modifying `__proto__`, `constructor`, or `prototype` prop is banned for security reasons");
|
|
23
|
+
obj[key] = this.value;
|
|
24
|
+
return { newDocument: document };
|
|
25
|
+
},
|
|
26
|
+
remove: function(obj, key, document) {
|
|
27
|
+
if (isDangerousKey(key)) throw new TypeError("JSON-Patch: modifying `__proto__`, `constructor`, or `prototype` prop is banned for security reasons");
|
|
28
|
+
var removed = obj[key];
|
|
29
|
+
delete obj[key];
|
|
30
|
+
return {
|
|
31
|
+
newDocument: document,
|
|
32
|
+
removed
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
replace: function(obj, key, document) {
|
|
36
|
+
if (isDangerousKey(key)) throw new TypeError("JSON-Patch: modifying `__proto__`, `constructor`, or `prototype` prop is banned for security reasons");
|
|
37
|
+
var removed = obj[key];
|
|
38
|
+
obj[key] = this.value;
|
|
39
|
+
return {
|
|
40
|
+
newDocument: document,
|
|
41
|
+
removed
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
move: function(obj, key, document) {
|
|
45
|
+
let removed = getValueByPointer(document, this.path);
|
|
46
|
+
if (removed) removed = _deepClone(removed);
|
|
47
|
+
const originalValue = applyOperation(document, {
|
|
48
|
+
op: "remove",
|
|
49
|
+
path: this.from
|
|
50
|
+
}).removed;
|
|
51
|
+
applyOperation(document, {
|
|
52
|
+
op: "add",
|
|
53
|
+
path: this.path,
|
|
54
|
+
value: originalValue
|
|
286
55
|
});
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}
|
|
291
|
-
const defaultConfig = RunTree.getDefaultConfig();
|
|
292
|
-
const { metadata, ...config } = originalConfig;
|
|
293
|
-
const client = config.client ?? RunTree.getSharedClient();
|
|
294
|
-
const dedupedMetadata = {
|
|
295
|
-
...metadata,
|
|
296
|
-
...config?.extra?.metadata
|
|
56
|
+
return {
|
|
57
|
+
newDocument: document,
|
|
58
|
+
removed
|
|
297
59
|
};
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
if (this.parent_run) {
|
|
313
|
-
this.trace_id = this.parent_run.trace_id ?? this.id;
|
|
314
|
-
} else {
|
|
315
|
-
this.trace_id = this.id;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
this.replicas = _ensureWriteReplicas(this.replicas);
|
|
319
|
-
if (!this.dotted_order) {
|
|
320
|
-
const { dottedOrder } = convertToDottedOrderFormat(this.start_time, this.id, this.execution_order);
|
|
321
|
-
if (this.parent_run) {
|
|
322
|
-
this.dotted_order = this.parent_run.dotted_order + "." + dottedOrder;
|
|
323
|
-
} else {
|
|
324
|
-
this.dotted_order = dottedOrder;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
set metadata(metadata) {
|
|
329
|
-
this.extra = {
|
|
330
|
-
...this.extra,
|
|
331
|
-
metadata: {
|
|
332
|
-
...this.extra?.metadata,
|
|
333
|
-
...metadata
|
|
334
|
-
}
|
|
60
|
+
},
|
|
61
|
+
copy: function(obj, key, document) {
|
|
62
|
+
const valueToCopy = getValueByPointer(document, this.from);
|
|
63
|
+
applyOperation(document, {
|
|
64
|
+
op: "add",
|
|
65
|
+
path: this.path,
|
|
66
|
+
value: _deepClone(valueToCopy)
|
|
67
|
+
});
|
|
68
|
+
return { newDocument: document };
|
|
69
|
+
},
|
|
70
|
+
test: function(obj, key, document) {
|
|
71
|
+
return {
|
|
72
|
+
newDocument: document,
|
|
73
|
+
test: _areEquals(obj[key], this.value)
|
|
335
74
|
};
|
|
75
|
+
},
|
|
76
|
+
_get: function(obj, key, document) {
|
|
77
|
+
this.value = obj[key];
|
|
78
|
+
return { newDocument: document };
|
|
336
79
|
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
80
|
+
};
|
|
81
|
+
var arrOps = {
|
|
82
|
+
add: function(arr, i, document) {
|
|
83
|
+
if (isInteger(i)) arr.splice(i, 0, this.value);
|
|
84
|
+
else arr[i] = this.value;
|
|
342
85
|
return {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
child_runs: [],
|
|
346
|
-
api_url: getEnvironmentVariable("LANGCHAIN_ENDPOINT") ?? "http://localhost:1984",
|
|
347
|
-
api_key: getEnvironmentVariable("LANGCHAIN_API_KEY"),
|
|
348
|
-
caller_options: {},
|
|
349
|
-
start_time,
|
|
350
|
-
serialized: {},
|
|
351
|
-
inputs: {},
|
|
352
|
-
extra: {}
|
|
86
|
+
newDocument: document,
|
|
87
|
+
index: i
|
|
353
88
|
};
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
RunTree.sharedClient = new Client();
|
|
358
|
-
}
|
|
359
|
-
return RunTree.sharedClient;
|
|
360
|
-
}
|
|
361
|
-
createChild(config) {
|
|
362
|
-
const child_execution_order = this.child_execution_order + 1;
|
|
363
|
-
const inheritedReplicas = this.replicas?.map((replica) => {
|
|
364
|
-
const { reroot, ...rest } = replica;
|
|
365
|
-
return rest;
|
|
366
|
-
});
|
|
367
|
-
const childReplicas = config.replicas ?? inheritedReplicas;
|
|
368
|
-
const child = new RunTree({
|
|
369
|
-
...config,
|
|
370
|
-
parent_run: this,
|
|
371
|
-
project_name: this.project_name,
|
|
372
|
-
replicas: childReplicas,
|
|
373
|
-
client: this.client,
|
|
374
|
-
tracingEnabled: this.tracingEnabled,
|
|
375
|
-
execution_order: child_execution_order,
|
|
376
|
-
child_execution_order
|
|
377
|
-
});
|
|
378
|
-
if (_LC_CONTEXT_VARIABLES_KEY in this) {
|
|
379
|
-
child[_LC_CONTEXT_VARIABLES_KEY] = this[_LC_CONTEXT_VARIABLES_KEY];
|
|
380
|
-
}
|
|
381
|
-
const LC_CHILD = /* @__PURE__ */ Symbol.for("lc:child_config");
|
|
382
|
-
const presentConfig = config.extra?.[LC_CHILD] ?? this.extra[LC_CHILD];
|
|
383
|
-
if (isRunnableConfigLike(presentConfig)) {
|
|
384
|
-
const newConfig = { ...presentConfig };
|
|
385
|
-
const callbacks = isCallbackManagerLike(newConfig.callbacks) ? newConfig.callbacks.copy?.() : void 0;
|
|
386
|
-
if (callbacks) {
|
|
387
|
-
Object.assign(callbacks, { _parentRunId: child.id });
|
|
388
|
-
callbacks.handlers?.find(isLangChainTracerLike)?.updateFromRunTree?.(child);
|
|
389
|
-
newConfig.callbacks = callbacks;
|
|
390
|
-
}
|
|
391
|
-
child.extra[LC_CHILD] = newConfig;
|
|
392
|
-
}
|
|
393
|
-
const visited = /* @__PURE__ */ new Set();
|
|
394
|
-
let current = this;
|
|
395
|
-
while (current != null && !visited.has(current.id)) {
|
|
396
|
-
visited.add(current.id);
|
|
397
|
-
current.child_execution_order = Math.max(current.child_execution_order, child_execution_order);
|
|
398
|
-
current = current.parent_run;
|
|
399
|
-
}
|
|
400
|
-
this.child_runs.push(child);
|
|
401
|
-
return child;
|
|
402
|
-
}
|
|
403
|
-
async end(outputs, error, endTime = Date.now(), metadata) {
|
|
404
|
-
this.outputs = this.outputs ?? outputs;
|
|
405
|
-
this.error = this.error ?? error;
|
|
406
|
-
this.end_time = this.end_time ?? endTime;
|
|
407
|
-
if (metadata && Object.keys(metadata).length > 0) {
|
|
408
|
-
this.extra = this.extra ? { ...this.extra, metadata: { ...this.extra.metadata, ...metadata } } : { metadata };
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
_convertToCreate(run, runtimeEnv, excludeChildRuns = true) {
|
|
412
|
-
const runExtra = run.extra ?? {};
|
|
413
|
-
if (runExtra?.runtime?.library === void 0) {
|
|
414
|
-
if (!runExtra.runtime) {
|
|
415
|
-
runExtra.runtime = {};
|
|
416
|
-
}
|
|
417
|
-
if (runtimeEnv) {
|
|
418
|
-
for (const [k, v] of Object.entries(runtimeEnv)) {
|
|
419
|
-
if (!runExtra.runtime[k]) {
|
|
420
|
-
runExtra.runtime[k] = v;
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
let child_runs;
|
|
426
|
-
let parent_run_id;
|
|
427
|
-
if (!excludeChildRuns) {
|
|
428
|
-
child_runs = run.child_runs.map((child_run) => this._convertToCreate(child_run, runtimeEnv, excludeChildRuns));
|
|
429
|
-
parent_run_id = void 0;
|
|
430
|
-
} else {
|
|
431
|
-
parent_run_id = run.parent_run?.id ?? run.parent_run_id;
|
|
432
|
-
child_runs = [];
|
|
433
|
-
}
|
|
89
|
+
},
|
|
90
|
+
remove: function(arr, i, document) {
|
|
91
|
+
var removedList = arr.splice(i, 1);
|
|
434
92
|
return {
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
start_time: run._serialized_start_time ?? run.start_time,
|
|
438
|
-
end_time: run.end_time,
|
|
439
|
-
run_type: run.run_type,
|
|
440
|
-
reference_example_id: run.reference_example_id,
|
|
441
|
-
extra: runExtra,
|
|
442
|
-
serialized: run.serialized,
|
|
443
|
-
error: run.error,
|
|
444
|
-
inputs: run.inputs,
|
|
445
|
-
outputs: run.outputs,
|
|
446
|
-
session_name: run.project_name,
|
|
447
|
-
child_runs,
|
|
448
|
-
parent_run_id,
|
|
449
|
-
trace_id: run.trace_id,
|
|
450
|
-
dotted_order: run.dotted_order,
|
|
451
|
-
tags: run.tags,
|
|
452
|
-
attachments: run.attachments,
|
|
453
|
-
events: run.events
|
|
93
|
+
newDocument: document,
|
|
94
|
+
removed: removedList[0]
|
|
454
95
|
};
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
let startIdx = null;
|
|
460
|
-
for (let idx = 0; idx < segs.length; idx++) {
|
|
461
|
-
const segId = segs[idx].slice(-36);
|
|
462
|
-
if (segId === parentId) {
|
|
463
|
-
startIdx = idx;
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
if (startIdx !== null) {
|
|
468
|
-
const trimmedSegs = segs.slice(startIdx + 1);
|
|
469
|
-
run.dotted_order = trimmedSegs.join(".");
|
|
470
|
-
if (trimmedSegs.length > 0) {
|
|
471
|
-
run.trace_id = trimmedSegs[0].slice(-36);
|
|
472
|
-
} else {
|
|
473
|
-
run.trace_id = run.id;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
if (run.parent_run_id === parentId) {
|
|
478
|
-
run.parent_run_id = void 0;
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
_setReplicaTraceRoot(replicaKey, traceRootId) {
|
|
482
|
-
const replicaTraceRoots = getContextVar(this, _REPLICA_TRACE_ROOTS_KEY) ?? {};
|
|
483
|
-
replicaTraceRoots[replicaKey] = traceRootId;
|
|
484
|
-
setContextVar(this, _REPLICA_TRACE_ROOTS_KEY, replicaTraceRoots);
|
|
485
|
-
for (const child of this.child_runs) {
|
|
486
|
-
child._setReplicaTraceRoot(replicaKey, traceRootId);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
_remapForProject(params) {
|
|
490
|
-
const { projectName, runtimeEnv, excludeChildRuns = true, reroot = false, distributedParentId, apiUrl, apiKey, workspaceId } = params;
|
|
491
|
-
const baseRun = this._convertToCreate(this, runtimeEnv, excludeChildRuns);
|
|
492
|
-
if (projectName === this.project_name) {
|
|
493
|
-
return {
|
|
494
|
-
...baseRun,
|
|
495
|
-
session_name: projectName
|
|
496
|
-
};
|
|
497
|
-
}
|
|
498
|
-
if (reroot) {
|
|
499
|
-
if (distributedParentId) {
|
|
500
|
-
this._sliceParentId(distributedParentId, baseRun);
|
|
501
|
-
} else {
|
|
502
|
-
baseRun.parent_run_id = void 0;
|
|
503
|
-
if (baseRun.dotted_order) {
|
|
504
|
-
const segs = baseRun.dotted_order.split(".");
|
|
505
|
-
if (segs.length > 0) {
|
|
506
|
-
baseRun.dotted_order = segs[segs.length - 1];
|
|
507
|
-
baseRun.trace_id = baseRun.id;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
const replicaKey = getReplicaKey({
|
|
512
|
-
projectName,
|
|
513
|
-
apiUrl,
|
|
514
|
-
apiKey,
|
|
515
|
-
workspaceId
|
|
516
|
-
});
|
|
517
|
-
this._setReplicaTraceRoot(replicaKey, baseRun.id);
|
|
518
|
-
}
|
|
519
|
-
let ancestorRerootedTraceId;
|
|
520
|
-
if (!reroot) {
|
|
521
|
-
const replicaTraceRoots = getContextVar(this, _REPLICA_TRACE_ROOTS_KEY) ?? {};
|
|
522
|
-
const replicaKey = getReplicaKey({
|
|
523
|
-
projectName,
|
|
524
|
-
apiUrl,
|
|
525
|
-
apiKey,
|
|
526
|
-
workspaceId
|
|
527
|
-
});
|
|
528
|
-
ancestorRerootedTraceId = replicaTraceRoots[replicaKey];
|
|
529
|
-
if (ancestorRerootedTraceId) {
|
|
530
|
-
baseRun.trace_id = ancestorRerootedTraceId;
|
|
531
|
-
if (baseRun.dotted_order) {
|
|
532
|
-
const segs = baseRun.dotted_order.split(".");
|
|
533
|
-
let rootIdx = null;
|
|
534
|
-
for (let idx = 0; idx < segs.length; idx++) {
|
|
535
|
-
const segId = segs[idx].slice(-36);
|
|
536
|
-
if (segId === ancestorRerootedTraceId) {
|
|
537
|
-
rootIdx = idx;
|
|
538
|
-
break;
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
if (rootIdx !== null) {
|
|
542
|
-
const trimmedSegs = segs.slice(rootIdx);
|
|
543
|
-
baseRun.dotted_order = trimmedSegs.join(".");
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
const oldId = baseRun.id;
|
|
549
|
-
const newId = v5(`${oldId}:${projectName}`, UUID_NAMESPACE_DNS);
|
|
550
|
-
let newTraceId;
|
|
551
|
-
if (baseRun.trace_id) {
|
|
552
|
-
newTraceId = v5(`${baseRun.trace_id}:${projectName}`, UUID_NAMESPACE_DNS);
|
|
553
|
-
} else {
|
|
554
|
-
newTraceId = newId;
|
|
555
|
-
}
|
|
556
|
-
let newParentId;
|
|
557
|
-
if (baseRun.parent_run_id) {
|
|
558
|
-
newParentId = v5(`${baseRun.parent_run_id}:${projectName}`, UUID_NAMESPACE_DNS);
|
|
559
|
-
}
|
|
560
|
-
let newDottedOrder;
|
|
561
|
-
if (baseRun.dotted_order) {
|
|
562
|
-
const segs = baseRun.dotted_order.split(".");
|
|
563
|
-
const remappedSegs = segs.map((seg) => {
|
|
564
|
-
const segId = seg.slice(-36);
|
|
565
|
-
const remappedId = v5(`${segId}:${projectName}`, UUID_NAMESPACE_DNS);
|
|
566
|
-
return seg.slice(0, -36) + remappedId;
|
|
567
|
-
});
|
|
568
|
-
newDottedOrder = remappedSegs.join(".");
|
|
569
|
-
}
|
|
96
|
+
},
|
|
97
|
+
replace: function(arr, i, document) {
|
|
98
|
+
var removed = arr[i];
|
|
99
|
+
arr[i] = this.value;
|
|
570
100
|
return {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
trace_id: newTraceId,
|
|
574
|
-
parent_run_id: newParentId,
|
|
575
|
-
dotted_order: newDottedOrder,
|
|
576
|
-
session_name: projectName
|
|
101
|
+
newDocument: document,
|
|
102
|
+
removed
|
|
577
103
|
};
|
|
578
|
-
}
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
if (
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
events: runData.events,
|
|
645
|
-
tags: runData.tags,
|
|
646
|
-
extra: runData.extra,
|
|
647
|
-
attachments: this.attachments,
|
|
648
|
-
...updates
|
|
649
|
-
};
|
|
650
|
-
if (!options?.excludeInputs) {
|
|
651
|
-
updatePayload.inputs = runData.inputs;
|
|
104
|
+
},
|
|
105
|
+
move: objOps.move,
|
|
106
|
+
copy: objOps.copy,
|
|
107
|
+
test: objOps.test,
|
|
108
|
+
_get: objOps._get
|
|
109
|
+
};
|
|
110
|
+
function getValueByPointer(document, pointer) {
|
|
111
|
+
if (pointer == "") return document;
|
|
112
|
+
var getOriginalDestination = {
|
|
113
|
+
op: "_get",
|
|
114
|
+
path: pointer
|
|
115
|
+
};
|
|
116
|
+
applyOperation(document, getOriginalDestination);
|
|
117
|
+
return getOriginalDestination.value;
|
|
118
|
+
}
|
|
119
|
+
function applyOperation(document, operation, validateOperation = false, mutateDocument = true, banPrototypeModifications = true, index = 0) {
|
|
120
|
+
if (validateOperation) if (typeof validateOperation == "function") validateOperation(operation, 0, document, operation.path);
|
|
121
|
+
else validator(operation, 0);
|
|
122
|
+
if (operation.path === "") {
|
|
123
|
+
let returnValue = { newDocument: document };
|
|
124
|
+
if (operation.op === "add") {
|
|
125
|
+
returnValue.newDocument = operation.value;
|
|
126
|
+
return returnValue;
|
|
127
|
+
} else if (operation.op === "replace") {
|
|
128
|
+
returnValue.newDocument = operation.value;
|
|
129
|
+
returnValue.removed = document;
|
|
130
|
+
return returnValue;
|
|
131
|
+
} else if (operation.op === "move" || operation.op === "copy") {
|
|
132
|
+
returnValue.newDocument = getValueByPointer(document, operation.from);
|
|
133
|
+
if (operation.op === "move") returnValue.removed = document;
|
|
134
|
+
return returnValue;
|
|
135
|
+
} else if (operation.op === "test") {
|
|
136
|
+
returnValue.test = _areEquals(document, operation.value);
|
|
137
|
+
if (returnValue.test === false) throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
138
|
+
returnValue.newDocument = document;
|
|
139
|
+
return returnValue;
|
|
140
|
+
} else if (operation.op === "remove") {
|
|
141
|
+
returnValue.removed = document;
|
|
142
|
+
returnValue.newDocument = null;
|
|
143
|
+
return returnValue;
|
|
144
|
+
} else if (operation.op === "_get") {
|
|
145
|
+
operation.value = document;
|
|
146
|
+
return returnValue;
|
|
147
|
+
} else if (validateOperation) throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
148
|
+
else return returnValue;
|
|
149
|
+
} else {
|
|
150
|
+
if (!mutateDocument) document = _deepClone(document);
|
|
151
|
+
const path = operation.path || "";
|
|
152
|
+
const keys = path.split("/");
|
|
153
|
+
let obj = document;
|
|
154
|
+
let t = 1;
|
|
155
|
+
let len = keys.length;
|
|
156
|
+
let existingPathFragment = void 0;
|
|
157
|
+
let key;
|
|
158
|
+
let validateFunction;
|
|
159
|
+
if (typeof validateOperation == "function") validateFunction = validateOperation;
|
|
160
|
+
else validateFunction = validator;
|
|
161
|
+
while (true) {
|
|
162
|
+
key = keys[t];
|
|
163
|
+
if (key && key.indexOf("~") != -1) key = unescapePathComponent(key);
|
|
164
|
+
if (banPrototypeModifications && (key == "__proto__" || key == "prototype" && t > 0 && keys[t - 1] == "constructor")) throw new TypeError("JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README");
|
|
165
|
+
if (validateOperation) {
|
|
166
|
+
if (existingPathFragment === void 0) {
|
|
167
|
+
if (obj[key] === void 0) existingPathFragment = keys.slice(0, t).join("/");
|
|
168
|
+
else if (t == len - 1) existingPathFragment = operation.path;
|
|
169
|
+
if (existingPathFragment !== void 0) validateFunction(operation, 0, document, existingPathFragment);
|
|
652
170
|
}
|
|
653
|
-
await this.client.updateRun(runData.id, updatePayload, {
|
|
654
|
-
apiKey,
|
|
655
|
-
apiUrl,
|
|
656
|
-
workspaceId
|
|
657
|
-
});
|
|
658
171
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
reference_example_id: this.reference_example_id,
|
|
670
|
-
extra: this.extra,
|
|
671
|
-
events: this.events,
|
|
672
|
-
dotted_order: this.dotted_order,
|
|
673
|
-
trace_id: this.trace_id,
|
|
674
|
-
tags: this.tags,
|
|
675
|
-
attachments: this.attachments,
|
|
676
|
-
session_name: this.project_name
|
|
677
|
-
};
|
|
678
|
-
if (!options?.excludeInputs) {
|
|
679
|
-
runUpdate.inputs = this.inputs;
|
|
172
|
+
t++;
|
|
173
|
+
if (Array.isArray(obj)) {
|
|
174
|
+
if (key === "-") key = obj.length;
|
|
175
|
+
else if (validateOperation && !isInteger(key)) throw new JsonPatchError("Expected an unsigned base-10 integer value, making the new referenced value the array element with the zero-based index", "OPERATION_PATH_ILLEGAL_ARRAY_INDEX", index, operation, document);
|
|
176
|
+
else if (isInteger(key)) key = ~~key;
|
|
177
|
+
if (t >= len) {
|
|
178
|
+
if (validateOperation && operation.op === "add" && key > obj.length) throw new JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array", "OPERATION_VALUE_OUT_OF_BOUNDS", index, operation, document);
|
|
179
|
+
const returnValue = arrOps[operation.op].call(operation, obj, key, document);
|
|
180
|
+
if (returnValue.test === false) throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
181
|
+
return returnValue;
|
|
680
182
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
183
|
+
} else if (t >= len) {
|
|
184
|
+
const returnValue = objOps[operation.op].call(operation, obj, key, document);
|
|
185
|
+
if (returnValue.test === false) throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
186
|
+
return returnValue;
|
|
684
187
|
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
}
|
|
688
|
-
toJSON() {
|
|
689
|
-
return this._convertToCreate(this, void 0, false);
|
|
690
|
-
}
|
|
691
|
-
/**
|
|
692
|
-
* Add an event to the run tree.
|
|
693
|
-
* @param event - A single event or string to add
|
|
694
|
-
*/
|
|
695
|
-
addEvent(event) {
|
|
696
|
-
if (!this.events) {
|
|
697
|
-
this.events = [];
|
|
698
|
-
}
|
|
699
|
-
if (typeof event === "string") {
|
|
700
|
-
this.events.push({
|
|
701
|
-
name: "event",
|
|
702
|
-
time: (/* @__PURE__ */ new Date()).toISOString(),
|
|
703
|
-
message: event
|
|
704
|
-
});
|
|
705
|
-
} else {
|
|
706
|
-
this.events.push({
|
|
707
|
-
...event,
|
|
708
|
-
time: event.time ?? (/* @__PURE__ */ new Date()).toISOString()
|
|
709
|
-
});
|
|
188
|
+
obj = obj[key];
|
|
189
|
+
if (validateOperation && t < len && (!obj || typeof obj !== "object")) throw new JsonPatchError("Cannot perform operation at the desired path", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
710
190
|
}
|
|
711
191
|
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
let client;
|
|
717
|
-
let tracingEnabled = isTracingEnabled();
|
|
718
|
-
if (callbackManager) {
|
|
719
|
-
const parentRunId = callbackManager?.getParentRunId?.() ?? "";
|
|
720
|
-
const langChainTracer = callbackManager?.handlers?.find((handler) => handler?.name == "langchain_tracer");
|
|
721
|
-
parentRun = langChainTracer?.getRun?.(parentRunId);
|
|
722
|
-
projectName = langChainTracer?.projectName;
|
|
723
|
-
client = langChainTracer?.client;
|
|
724
|
-
tracingEnabled = tracingEnabled || !!langChainTracer;
|
|
725
|
-
}
|
|
726
|
-
if (!parentRun) {
|
|
727
|
-
return new RunTree({
|
|
728
|
-
...props,
|
|
729
|
-
client,
|
|
730
|
-
tracingEnabled,
|
|
731
|
-
project_name: projectName
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
const parentRunTree = new RunTree({
|
|
735
|
-
name: parentRun.name,
|
|
736
|
-
id: parentRun.id,
|
|
737
|
-
trace_id: parentRun.trace_id,
|
|
738
|
-
dotted_order: parentRun.dotted_order,
|
|
739
|
-
client,
|
|
740
|
-
tracingEnabled,
|
|
741
|
-
project_name: projectName,
|
|
742
|
-
tags: [
|
|
743
|
-
...new Set((parentRun?.tags ?? []).concat(parentConfig?.tags ?? []))
|
|
744
|
-
],
|
|
745
|
-
extra: {
|
|
746
|
-
metadata: {
|
|
747
|
-
...parentRun?.extra?.metadata,
|
|
748
|
-
...parentConfig?.metadata
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
});
|
|
752
|
-
return parentRunTree.createChild(props);
|
|
753
|
-
}
|
|
754
|
-
static fromDottedOrder(dottedOrder) {
|
|
755
|
-
return this.fromHeaders({ "langsmith-trace": dottedOrder });
|
|
756
|
-
}
|
|
757
|
-
static fromHeaders(headers, inheritArgs) {
|
|
758
|
-
const rawHeaders = "get" in headers && typeof headers.get === "function" ? {
|
|
759
|
-
"langsmith-trace": headers.get("langsmith-trace"),
|
|
760
|
-
baggage: headers.get("baggage")
|
|
761
|
-
} : headers;
|
|
762
|
-
const headerTrace = rawHeaders["langsmith-trace"];
|
|
763
|
-
if (!headerTrace || typeof headerTrace !== "string")
|
|
764
|
-
return void 0;
|
|
765
|
-
const parentDottedOrder = headerTrace.trim();
|
|
766
|
-
const parsedDottedOrder = parentDottedOrder.split(".").map((part) => {
|
|
767
|
-
const [strTime, uuid] = part.split("Z");
|
|
768
|
-
return { strTime, time: Date.parse(strTime + "Z"), uuid };
|
|
769
|
-
});
|
|
770
|
-
const traceId = parsedDottedOrder[0].uuid;
|
|
771
|
-
const config = {
|
|
772
|
-
...inheritArgs,
|
|
773
|
-
name: inheritArgs?.["name"] ?? "parent",
|
|
774
|
-
run_type: inheritArgs?.["run_type"] ?? "chain",
|
|
775
|
-
start_time: inheritArgs?.["start_time"] ?? Date.now(),
|
|
776
|
-
id: parsedDottedOrder.at(-1)?.uuid,
|
|
777
|
-
trace_id: traceId,
|
|
778
|
-
dotted_order: parentDottedOrder
|
|
779
|
-
};
|
|
780
|
-
if (rawHeaders["baggage"] && typeof rawHeaders["baggage"] === "string") {
|
|
781
|
-
const baggage = Baggage.fromHeader(rawHeaders["baggage"]);
|
|
782
|
-
config.metadata = baggage.metadata;
|
|
783
|
-
config.tags = baggage.tags;
|
|
784
|
-
config.project_name = baggage.project_name;
|
|
785
|
-
config.replicas = baggage.replicas;
|
|
786
|
-
}
|
|
787
|
-
const runTree = new RunTree(config);
|
|
788
|
-
runTree.distributedParentId = runTree.id;
|
|
789
|
-
return runTree;
|
|
192
|
+
}
|
|
193
|
+
function applyPatch(document, patch, validateOperation, mutateDocument = true, banPrototypeModifications = true) {
|
|
194
|
+
if (validateOperation) {
|
|
195
|
+
if (!Array.isArray(patch)) throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
790
196
|
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
if (headers) {
|
|
797
|
-
for (const [key, value] of Object.entries(result)) {
|
|
798
|
-
headers.set(key, value);
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
return result;
|
|
197
|
+
if (!mutateDocument) document = _deepClone(document);
|
|
198
|
+
const results = new Array(patch.length);
|
|
199
|
+
for (let i = 0, length = patch.length; i < length; i++) {
|
|
200
|
+
results[i] = applyOperation(document, patch[i], validateOperation, true, banPrototypeModifications, i);
|
|
201
|
+
document = results[i].newDocument;
|
|
802
202
|
}
|
|
203
|
+
results.newDocument = document;
|
|
204
|
+
return results;
|
|
803
205
|
}
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
value: null
|
|
809
|
-
});
|
|
810
|
-
function isRunTree(x) {
|
|
811
|
-
return x != null && typeof x.createChild === "function" && typeof x.postRun === "function";
|
|
812
|
-
}
|
|
813
|
-
function isLangChainTracerLike(x) {
|
|
814
|
-
return typeof x === "object" && x != null && typeof x.name === "string" && x.name === "langchain_tracer";
|
|
815
|
-
}
|
|
816
|
-
function containsLangChainTracerLike(x) {
|
|
817
|
-
return Array.isArray(x) && x.some((callback) => isLangChainTracerLike(callback));
|
|
206
|
+
function applyReducer(document, operation, index) {
|
|
207
|
+
const operationResult = applyOperation(document, operation);
|
|
208
|
+
if (operationResult.test === false) throw new JsonPatchError("Test operation failed", "TEST_OPERATION_FAILED", index, operation, document);
|
|
209
|
+
return operationResult.newDocument;
|
|
818
210
|
}
|
|
819
|
-
function
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
(
|
|
827
|
-
|
|
211
|
+
function validator(operation, index, document, existingPathFragment) {
|
|
212
|
+
if (typeof operation !== "object" || operation === null || Array.isArray(operation)) throw new JsonPatchError("Operation is not an object", "OPERATION_NOT_AN_OBJECT", index, operation, document);
|
|
213
|
+
else if (!objOps[operation.op]) throw new JsonPatchError("Operation `op` property is not one of operations defined in RFC-6902", "OPERATION_OP_INVALID", index, operation, document);
|
|
214
|
+
else if (typeof operation.path !== "string") throw new JsonPatchError("Operation `path` property is not a string", "OPERATION_PATH_INVALID", index, operation, document);
|
|
215
|
+
else if (operation.path.indexOf("/") !== 0 && operation.path.length > 0) throw new JsonPatchError('Operation `path` property must start with "/"', "OPERATION_PATH_INVALID", index, operation, document);
|
|
216
|
+
else if ((operation.op === "move" || operation.op === "copy") && typeof operation.from !== "string") throw new JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)", "OPERATION_FROM_REQUIRED", index, operation, document);
|
|
217
|
+
else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && operation.value === void 0) throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_REQUIRED", index, operation, document);
|
|
218
|
+
else if ((operation.op === "add" || operation.op === "replace" || operation.op === "test") && hasUndefined(operation.value)) throw new JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)", "OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED", index, operation, document);
|
|
219
|
+
else if (document) {
|
|
220
|
+
if (operation.op == "add") {
|
|
221
|
+
var pathLen = operation.path.split("/").length;
|
|
222
|
+
var existingPathLen = existingPathFragment.split("/").length;
|
|
223
|
+
if (pathLen !== existingPathLen + 1 && pathLen !== existingPathLen) throw new JsonPatchError("Cannot perform an `add` operation at the desired path", "OPERATION_PATH_CANNOT_ADD", index, operation, document);
|
|
224
|
+
} else if (operation.op === "replace" || operation.op === "remove" || operation.op === "_get") {
|
|
225
|
+
if (operation.path !== existingPathFragment) throw new JsonPatchError("Cannot perform the operation at a path that does not exist", "OPERATION_PATH_UNRESOLVABLE", index, operation, document);
|
|
226
|
+
} else if (operation.op === "move" || operation.op === "copy") {
|
|
227
|
+
var existingValue = {
|
|
228
|
+
op: "_get",
|
|
229
|
+
path: operation.from,
|
|
230
|
+
value: void 0
|
|
231
|
+
};
|
|
232
|
+
var error = validate([existingValue], document);
|
|
233
|
+
if (error && error.name === "OPERATION_PATH_UNRESOLVABLE") throw new JsonPatchError("Cannot perform the operation from a path that does not exist", "OPERATION_FROM_UNRESOLVABLE", index, operation, document);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
828
236
|
}
|
|
829
|
-
function
|
|
830
|
-
const envVar = getEnvironmentVariable("LANGSMITH_RUNS_ENDPOINTS");
|
|
831
|
-
if (!envVar)
|
|
832
|
-
return [];
|
|
237
|
+
function validate(sequence, document, externalValidator) {
|
|
833
238
|
try {
|
|
834
|
-
|
|
835
|
-
if (
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
console.warn(`Invalid item type in LANGSMITH_RUNS_ENDPOINTS: expected object, got ${typeof item}`);
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
if (typeof item.api_url !== "string") {
|
|
843
|
-
console.warn(`Invalid api_url type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof item.api_url}`);
|
|
844
|
-
continue;
|
|
845
|
-
}
|
|
846
|
-
if (typeof item.api_key !== "string") {
|
|
847
|
-
console.warn(`Invalid api_key type in LANGSMITH_RUNS_ENDPOINTS: expected string, got ${typeof item.api_key}`);
|
|
848
|
-
continue;
|
|
849
|
-
}
|
|
850
|
-
replicas.push({
|
|
851
|
-
apiUrl: item.api_url.replace(/\/$/, ""),
|
|
852
|
-
apiKey: item.api_key
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
return replicas;
|
|
856
|
-
} else if (typeof parsed === "object" && parsed !== null) {
|
|
857
|
-
_checkEndpointEnvUnset(parsed);
|
|
858
|
-
const replicas = [];
|
|
859
|
-
for (const [url, key] of Object.entries(parsed)) {
|
|
860
|
-
const cleanUrl = url.replace(/\/$/, "");
|
|
861
|
-
if (typeof key === "string") {
|
|
862
|
-
replicas.push({
|
|
863
|
-
apiUrl: cleanUrl,
|
|
864
|
-
apiKey: key
|
|
865
|
-
});
|
|
866
|
-
} else {
|
|
867
|
-
console.warn(`Invalid value type in LANGSMITH_RUNS_ENDPOINTS for URL ${url}: expected string, got ${typeof key}`);
|
|
868
|
-
continue;
|
|
869
|
-
}
|
|
870
|
-
}
|
|
871
|
-
return replicas;
|
|
872
|
-
} else {
|
|
873
|
-
console.warn(`Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey, got ${typeof parsed}`);
|
|
874
|
-
return [];
|
|
239
|
+
if (!Array.isArray(sequence)) throw new JsonPatchError("Patch sequence must be an array", "SEQUENCE_NOT_AN_ARRAY");
|
|
240
|
+
if (document) applyPatch(_deepClone(document), _deepClone(sequence), externalValidator || true);
|
|
241
|
+
else {
|
|
242
|
+
externalValidator = externalValidator || validator;
|
|
243
|
+
for (var i = 0; i < sequence.length; i++) externalValidator(sequence[i], i, document, void 0);
|
|
875
244
|
}
|
|
876
245
|
} catch (e) {
|
|
877
|
-
if (
|
|
878
|
-
|
|
879
|
-
}
|
|
880
|
-
console.warn("Invalid LANGSMITH_RUNS_ENDPOINTS – must be valid JSON array of objects with api_url and api_key properties, or object mapping url->apiKey");
|
|
881
|
-
return [];
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
function _ensureWriteReplicas(replicas) {
|
|
885
|
-
if (replicas) {
|
|
886
|
-
return replicas.map((replica) => {
|
|
887
|
-
if (Array.isArray(replica)) {
|
|
888
|
-
return {
|
|
889
|
-
projectName: replica[0],
|
|
890
|
-
updates: replica[1]
|
|
891
|
-
};
|
|
892
|
-
}
|
|
893
|
-
return replica;
|
|
894
|
-
});
|
|
246
|
+
if (e instanceof JsonPatchError) return e;
|
|
247
|
+
else throw e;
|
|
895
248
|
}
|
|
896
|
-
return _getWriteReplicasFromEnv();
|
|
897
249
|
}
|
|
898
|
-
function
|
|
899
|
-
if (
|
|
900
|
-
|
|
250
|
+
function _areEquals(a, b) {
|
|
251
|
+
if (a === b) return true;
|
|
252
|
+
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
253
|
+
var arrA = Array.isArray(a), arrB = Array.isArray(b), i, length, key;
|
|
254
|
+
if (arrA && arrB) {
|
|
255
|
+
length = a.length;
|
|
256
|
+
if (length != b.length) return false;
|
|
257
|
+
for (i = length; i-- !== 0; ) if (!_areEquals(a[i], b[i])) return false;
|
|
258
|
+
return true;
|
|
259
|
+
}
|
|
260
|
+
if (arrA != arrB) return false;
|
|
261
|
+
var keys = Object.keys(a);
|
|
262
|
+
length = keys.length;
|
|
263
|
+
if (length !== Object.keys(b).length) return false;
|
|
264
|
+
for (i = length; i-- !== 0; ) if (!b.hasOwnProperty(keys[i])) return false;
|
|
265
|
+
for (i = length; i-- !== 0; ) {
|
|
266
|
+
key = keys[i];
|
|
267
|
+
if (!_areEquals(a[key], b[key])) return false;
|
|
268
|
+
}
|
|
269
|
+
return true;
|
|
901
270
|
}
|
|
271
|
+
return a !== a && b !== b;
|
|
902
272
|
}
|
|
903
273
|
export {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
274
|
+
_areEquals,
|
|
275
|
+
applyOperation,
|
|
276
|
+
applyPatch,
|
|
277
|
+
applyReducer,
|
|
278
|
+
core_exports,
|
|
279
|
+
getValueByPointer,
|
|
280
|
+
validate,
|
|
281
|
+
validator
|
|
908
282
|
};
|
|
909
283
|
//# sourceMappingURL=index.es121.js.map
|