@babelbeez/sdk 0.2.0 → 0.3.1
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/CHANGELOG.md +49 -0
- package/README.md +7 -0
- package/dist/babelbeez-sdk.d.ts +0 -10
- package/dist/babelbeez-sdk.js +993 -969
- package/dist/babelbeez-sdk.umd.cjs +6 -6
- package/package.json +3 -2
package/dist/babelbeez-sdk.js
CHANGED
|
@@ -3,8 +3,8 @@ var Vr = (n) => {
|
|
|
3
3
|
throw TypeError(n);
|
|
4
4
|
};
|
|
5
5
|
var So = (n, e, t) => e in n ? Io(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
6
|
-
var
|
|
7
|
-
var c = (n, e, t) => (Ms(n, e, "read from private field"), t ? t.call(n) : e.get(n)),
|
|
6
|
+
var S = (n, e, t) => So(n, typeof e != "symbol" ? e + "" : e, t), Ms = (n, e, t) => e.has(n) || Vr("Cannot " + t);
|
|
7
|
+
var c = (n, e, t) => (Ms(n, e, "read from private field"), t ? t.call(n) : e.get(n)), R = (n, e, t) => e.has(n) ? Vr("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), k = (n, e, t, s) => (Ms(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t), z = (n, e, t) => (Ms(n, e, "access private method"), t);
|
|
8
8
|
const Vs = {
|
|
9
9
|
version: "0.3.6"
|
|
10
10
|
};
|
|
@@ -79,22 +79,22 @@ class Hr {
|
|
|
79
79
|
if (u)
|
|
80
80
|
a.schema = u;
|
|
81
81
|
else {
|
|
82
|
-
const
|
|
82
|
+
const _ = {
|
|
83
83
|
...t,
|
|
84
84
|
schemaPath: [...t.schemaPath, e],
|
|
85
85
|
path: t.path
|
|
86
|
-
},
|
|
87
|
-
if (
|
|
88
|
-
a.ref =
|
|
86
|
+
}, T = e._zod.parent;
|
|
87
|
+
if (T)
|
|
88
|
+
a.ref = T, this.process(T, _), this.seen.get(T).isParent = !0;
|
|
89
89
|
else {
|
|
90
90
|
const y = a.schema;
|
|
91
91
|
switch (r.type) {
|
|
92
92
|
case "string": {
|
|
93
93
|
const h = y;
|
|
94
94
|
h.type = "string";
|
|
95
|
-
const { minimum:
|
|
96
|
-
if (typeof
|
|
97
|
-
const D = [...
|
|
95
|
+
const { minimum: v, maximum: b, format: N, patterns: x, contentEncoding: A } = e._zod.bag;
|
|
96
|
+
if (typeof v == "number" && (h.minLength = v), typeof b == "number" && (h.maxLength = b), N && (h.format = i[N] ?? N, h.format === "" && delete h.format), A && (h.contentEncoding = A), x && x.size > 0) {
|
|
97
|
+
const D = [...x];
|
|
98
98
|
D.length === 1 ? h.pattern = D[0].source : D.length > 1 && (a.schema.allOf = [
|
|
99
99
|
...D.map((U) => ({
|
|
100
100
|
...this.target === "draft-7" ? { type: "string" } : {},
|
|
@@ -105,8 +105,8 @@ class Hr {
|
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
case "number": {
|
|
108
|
-
const h = y, { minimum:
|
|
109
|
-
typeof
|
|
108
|
+
const h = y, { minimum: v, maximum: b, format: N, multipleOf: x, exclusiveMaximum: A, exclusiveMinimum: D } = e._zod.bag;
|
|
109
|
+
typeof N == "string" && N.includes("int") ? h.type = "integer" : h.type = "number", typeof D == "number" && (h.exclusiveMinimum = D), typeof v == "number" && (h.minimum = v, typeof D == "number" && (D >= v ? delete h.minimum : delete h.exclusiveMinimum)), typeof A == "number" && (h.exclusiveMaximum = A), typeof b == "number" && (h.maximum = b, typeof A == "number" && (A <= b ? delete h.maximum : delete h.exclusiveMaximum)), typeof x == "number" && (h.multipleOf = x);
|
|
110
110
|
break;
|
|
111
111
|
}
|
|
112
112
|
case "boolean": {
|
|
@@ -152,75 +152,75 @@ class Hr {
|
|
|
152
152
|
break;
|
|
153
153
|
}
|
|
154
154
|
case "array": {
|
|
155
|
-
const h = y, { minimum:
|
|
156
|
-
typeof
|
|
155
|
+
const h = y, { minimum: v, maximum: b } = e._zod.bag;
|
|
156
|
+
typeof v == "number" && (h.minItems = v), typeof b == "number" && (h.maxItems = b), h.type = "array", h.items = this.process(r.element, { ..._, path: [..._.path, "items"] });
|
|
157
157
|
break;
|
|
158
158
|
}
|
|
159
159
|
case "object": {
|
|
160
160
|
const h = y;
|
|
161
161
|
h.type = "object", h.properties = {};
|
|
162
|
-
const
|
|
163
|
-
for (const
|
|
164
|
-
h.properties[
|
|
165
|
-
...
|
|
166
|
-
path: [...
|
|
162
|
+
const v = r.shape;
|
|
163
|
+
for (const x in v)
|
|
164
|
+
h.properties[x] = this.process(v[x], {
|
|
165
|
+
..._,
|
|
166
|
+
path: [..._.path, "properties", x]
|
|
167
167
|
});
|
|
168
|
-
const
|
|
169
|
-
const A = r.shape[
|
|
168
|
+
const b = new Set(Object.keys(v)), N = new Set([...b].filter((x) => {
|
|
169
|
+
const A = r.shape[x]._zod;
|
|
170
170
|
return this.io === "input" ? A.optin === void 0 : A.optout === void 0;
|
|
171
171
|
}));
|
|
172
|
-
|
|
173
|
-
...
|
|
174
|
-
path: [...
|
|
172
|
+
N.size > 0 && (h.required = Array.from(N)), ((g = r.catchall) == null ? void 0 : g._zod.def.type) === "never" ? h.additionalProperties = !1 : r.catchall ? r.catchall && (h.additionalProperties = this.process(r.catchall, {
|
|
173
|
+
..._,
|
|
174
|
+
path: [..._.path, "additionalProperties"]
|
|
175
175
|
})) : this.io === "output" && (h.additionalProperties = !1);
|
|
176
176
|
break;
|
|
177
177
|
}
|
|
178
178
|
case "union": {
|
|
179
179
|
const h = y;
|
|
180
|
-
h.anyOf = r.options.map((
|
|
181
|
-
...
|
|
182
|
-
path: [...
|
|
180
|
+
h.anyOf = r.options.map((v, b) => this.process(v, {
|
|
181
|
+
..._,
|
|
182
|
+
path: [..._.path, "anyOf", b]
|
|
183
183
|
}));
|
|
184
184
|
break;
|
|
185
185
|
}
|
|
186
186
|
case "intersection": {
|
|
187
|
-
const h = y,
|
|
188
|
-
...
|
|
189
|
-
path: [...
|
|
190
|
-
}),
|
|
191
|
-
...
|
|
192
|
-
path: [...
|
|
193
|
-
}),
|
|
194
|
-
...
|
|
195
|
-
...
|
|
187
|
+
const h = y, v = this.process(r.left, {
|
|
188
|
+
..._,
|
|
189
|
+
path: [..._.path, "allOf", 0]
|
|
190
|
+
}), b = this.process(r.right, {
|
|
191
|
+
..._,
|
|
192
|
+
path: [..._.path, "allOf", 1]
|
|
193
|
+
}), N = (A) => "allOf" in A && Object.keys(A).length === 1, x = [
|
|
194
|
+
...N(v) ? v.allOf : [v],
|
|
195
|
+
...N(b) ? b.allOf : [b]
|
|
196
196
|
];
|
|
197
|
-
h.allOf =
|
|
197
|
+
h.allOf = x;
|
|
198
198
|
break;
|
|
199
199
|
}
|
|
200
200
|
case "tuple": {
|
|
201
201
|
const h = y;
|
|
202
202
|
h.type = "array";
|
|
203
|
-
const
|
|
204
|
-
if (this.target === "draft-2020-12" ? h.prefixItems =
|
|
205
|
-
const
|
|
206
|
-
...
|
|
207
|
-
path: [...
|
|
203
|
+
const v = r.items.map((x, A) => this.process(x, { ..._, path: [..._.path, "prefixItems", A] }));
|
|
204
|
+
if (this.target === "draft-2020-12" ? h.prefixItems = v : h.items = v, r.rest) {
|
|
205
|
+
const x = this.process(r.rest, {
|
|
206
|
+
..._,
|
|
207
|
+
path: [..._.path, "items"]
|
|
208
208
|
});
|
|
209
|
-
this.target === "draft-2020-12" ? h.items =
|
|
209
|
+
this.target === "draft-2020-12" ? h.items = x : h.additionalItems = x;
|
|
210
210
|
}
|
|
211
211
|
r.rest && (h.items = this.process(r.rest, {
|
|
212
|
-
...
|
|
213
|
-
path: [...
|
|
212
|
+
..._,
|
|
213
|
+
path: [..._.path, "items"]
|
|
214
214
|
}));
|
|
215
|
-
const { minimum:
|
|
216
|
-
typeof
|
|
215
|
+
const { minimum: b, maximum: N } = e._zod.bag;
|
|
216
|
+
typeof b == "number" && (h.minItems = b), typeof N == "number" && (h.maxItems = N);
|
|
217
217
|
break;
|
|
218
218
|
}
|
|
219
219
|
case "record": {
|
|
220
220
|
const h = y;
|
|
221
|
-
h.type = "object", h.propertyNames = this.process(r.keyType, { ...
|
|
222
|
-
...
|
|
223
|
-
path: [...
|
|
221
|
+
h.type = "object", h.propertyNames = this.process(r.keyType, { ..._, path: [..._.path, "propertyNames"] }), h.additionalProperties = this.process(r.valueType, {
|
|
222
|
+
..._,
|
|
223
|
+
path: [..._.path, "additionalProperties"]
|
|
224
224
|
});
|
|
225
225
|
break;
|
|
226
226
|
}
|
|
@@ -235,36 +235,36 @@ class Hr {
|
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
237
|
case "enum": {
|
|
238
|
-
const h = y,
|
|
239
|
-
|
|
238
|
+
const h = y, v = To(r.entries);
|
|
239
|
+
v.every((b) => typeof b == "number") && (h.type = "number"), v.every((b) => typeof b == "string") && (h.type = "string"), h.enum = v;
|
|
240
240
|
break;
|
|
241
241
|
}
|
|
242
242
|
case "literal": {
|
|
243
|
-
const h = y,
|
|
244
|
-
for (const
|
|
245
|
-
if (
|
|
243
|
+
const h = y, v = [];
|
|
244
|
+
for (const b of r.values)
|
|
245
|
+
if (b === void 0) {
|
|
246
246
|
if (this.unrepresentable === "throw")
|
|
247
247
|
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
248
|
-
} else if (typeof
|
|
248
|
+
} else if (typeof b == "bigint") {
|
|
249
249
|
if (this.unrepresentable === "throw")
|
|
250
250
|
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
251
|
-
|
|
251
|
+
v.push(Number(b));
|
|
252
252
|
} else
|
|
253
|
-
|
|
254
|
-
if (
|
|
255
|
-
const
|
|
256
|
-
h.type =
|
|
253
|
+
v.push(b);
|
|
254
|
+
if (v.length !== 0) if (v.length === 1) {
|
|
255
|
+
const b = v[0];
|
|
256
|
+
h.type = b === null ? "null" : typeof b, h.const = b;
|
|
257
257
|
} else
|
|
258
|
-
|
|
258
|
+
v.every((b) => typeof b == "number") && (h.type = "number"), v.every((b) => typeof b == "string") && (h.type = "string"), v.every((b) => typeof b == "boolean") && (h.type = "string"), v.every((b) => b === null) && (h.type = "null"), h.enum = v;
|
|
259
259
|
break;
|
|
260
260
|
}
|
|
261
261
|
case "file": {
|
|
262
|
-
const h = y,
|
|
262
|
+
const h = y, v = {
|
|
263
263
|
type: "string",
|
|
264
264
|
format: "binary",
|
|
265
265
|
contentEncoding: "binary"
|
|
266
|
-
}, { minimum:
|
|
267
|
-
|
|
266
|
+
}, { minimum: b, maximum: N, mime: x } = e._zod.bag;
|
|
267
|
+
b !== void 0 && (v.minLength = b), N !== void 0 && (v.maxLength = N), x ? x.length === 1 ? (v.contentMediaType = x[0], Object.assign(h, v)) : h.anyOf = x.map((A) => ({ ...v, contentMediaType: A })) : Object.assign(h, v);
|
|
268
268
|
break;
|
|
269
269
|
}
|
|
270
270
|
case "transform": {
|
|
@@ -273,12 +273,12 @@ class Hr {
|
|
|
273
273
|
break;
|
|
274
274
|
}
|
|
275
275
|
case "nullable": {
|
|
276
|
-
const h = this.process(r.innerType,
|
|
276
|
+
const h = this.process(r.innerType, _);
|
|
277
277
|
y.anyOf = [h, { type: "null" }];
|
|
278
278
|
break;
|
|
279
279
|
}
|
|
280
280
|
case "nonoptional": {
|
|
281
|
-
this.process(r.innerType,
|
|
281
|
+
this.process(r.innerType, _), a.ref = r.innerType;
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
case "success": {
|
|
@@ -287,15 +287,15 @@ class Hr {
|
|
|
287
287
|
break;
|
|
288
288
|
}
|
|
289
289
|
case "default": {
|
|
290
|
-
this.process(r.innerType,
|
|
290
|
+
this.process(r.innerType, _), a.ref = r.innerType, y.default = JSON.parse(JSON.stringify(r.defaultValue));
|
|
291
291
|
break;
|
|
292
292
|
}
|
|
293
293
|
case "prefault": {
|
|
294
|
-
this.process(r.innerType,
|
|
294
|
+
this.process(r.innerType, _), a.ref = r.innerType, this.io === "input" && (y._prefault = JSON.parse(JSON.stringify(r.defaultValue)));
|
|
295
295
|
break;
|
|
296
296
|
}
|
|
297
297
|
case "catch": {
|
|
298
|
-
this.process(r.innerType,
|
|
298
|
+
this.process(r.innerType, _), a.ref = r.innerType;
|
|
299
299
|
let h;
|
|
300
300
|
try {
|
|
301
301
|
h = r.catchValue(void 0);
|
|
@@ -311,33 +311,33 @@ class Hr {
|
|
|
311
311
|
break;
|
|
312
312
|
}
|
|
313
313
|
case "template_literal": {
|
|
314
|
-
const h = y,
|
|
315
|
-
if (!
|
|
314
|
+
const h = y, v = e._zod.pattern;
|
|
315
|
+
if (!v)
|
|
316
316
|
throw new Error("Pattern not found in template literal");
|
|
317
|
-
h.type = "string", h.pattern =
|
|
317
|
+
h.type = "string", h.pattern = v.source;
|
|
318
318
|
break;
|
|
319
319
|
}
|
|
320
320
|
case "pipe": {
|
|
321
321
|
const h = this.io === "input" ? r.in._zod.def.type === "transform" ? r.out : r.in : r.out;
|
|
322
|
-
this.process(h,
|
|
322
|
+
this.process(h, _), a.ref = h;
|
|
323
323
|
break;
|
|
324
324
|
}
|
|
325
325
|
case "readonly": {
|
|
326
|
-
this.process(r.innerType,
|
|
326
|
+
this.process(r.innerType, _), a.ref = r.innerType, y.readOnly = !0;
|
|
327
327
|
break;
|
|
328
328
|
}
|
|
329
329
|
// passthrough types
|
|
330
330
|
case "promise": {
|
|
331
|
-
this.process(r.innerType,
|
|
331
|
+
this.process(r.innerType, _), a.ref = r.innerType;
|
|
332
332
|
break;
|
|
333
333
|
}
|
|
334
334
|
case "optional": {
|
|
335
|
-
this.process(r.innerType,
|
|
335
|
+
this.process(r.innerType, _), a.ref = r.innerType;
|
|
336
336
|
break;
|
|
337
337
|
}
|
|
338
338
|
case "lazy": {
|
|
339
339
|
const h = e._zod.innerType;
|
|
340
|
-
this.process(h,
|
|
340
|
+
this.process(h, _), a.ref = h;
|
|
341
341
|
break;
|
|
342
342
|
}
|
|
343
343
|
case "custom": {
|
|
@@ -352,7 +352,7 @@ class Hr {
|
|
|
352
352
|
return l && Object.assign(a.schema, l), this.io === "input" && de(e) && (delete a.schema.examples, delete a.schema.default), this.io === "input" && a.schema._prefault && ((s = a.schema).default ?? (s.default = a.schema._prefault)), delete a.schema._prefault, this.seen.get(e).schema;
|
|
353
353
|
}
|
|
354
354
|
emit(e, t) {
|
|
355
|
-
var p, d, m, g,
|
|
355
|
+
var p, d, m, g, _, T;
|
|
356
356
|
const s = {
|
|
357
357
|
cycles: (t == null ? void 0 : t.cycles) ?? "ref",
|
|
358
358
|
reused: (t == null ? void 0 : t.reused) ?? "inline",
|
|
@@ -363,10 +363,10 @@ class Hr {
|
|
|
363
363
|
if (!r)
|
|
364
364
|
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
365
365
|
const i = (y) => {
|
|
366
|
-
var
|
|
366
|
+
var x;
|
|
367
367
|
const h = this.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
368
368
|
if (s.external) {
|
|
369
|
-
const A = (
|
|
369
|
+
const A = (x = s.external.registry.get(y[0])) == null ? void 0 : x.id, D = s.external.uri ?? ((G) => G);
|
|
370
370
|
if (A)
|
|
371
371
|
return { ref: D(A) };
|
|
372
372
|
const U = y[1].defId ?? y[1].schema.id ?? `schema${this.counter++}`;
|
|
@@ -374,17 +374,17 @@ class Hr {
|
|
|
374
374
|
}
|
|
375
375
|
if (y[1] === r)
|
|
376
376
|
return { ref: "#" };
|
|
377
|
-
const
|
|
378
|
-
return { defId:
|
|
377
|
+
const b = `#/${h}/`, N = y[1].schema.id ?? `__schema${this.counter++}`;
|
|
378
|
+
return { defId: N, ref: b + N };
|
|
379
379
|
}, o = (y) => {
|
|
380
380
|
if (y[1].schema.$ref)
|
|
381
381
|
return;
|
|
382
|
-
const h = y[1], { ref:
|
|
383
|
-
h.def = { ...h.schema },
|
|
384
|
-
const
|
|
385
|
-
for (const
|
|
386
|
-
delete
|
|
387
|
-
|
|
382
|
+
const h = y[1], { ref: v, defId: b } = i(y);
|
|
383
|
+
h.def = { ...h.schema }, b && (h.defId = b);
|
|
384
|
+
const N = h.schema;
|
|
385
|
+
for (const x in N)
|
|
386
|
+
delete N[x];
|
|
387
|
+
N.$ref = v;
|
|
388
388
|
};
|
|
389
389
|
if (s.cycles === "throw")
|
|
390
390
|
for (const y of this.seen.entries()) {
|
|
@@ -401,8 +401,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
401
401
|
continue;
|
|
402
402
|
}
|
|
403
403
|
if (s.external) {
|
|
404
|
-
const
|
|
405
|
-
if (e !== y[0] &&
|
|
404
|
+
const b = (d = s.external.registry.get(y[0])) == null ? void 0 : d.id;
|
|
405
|
+
if (e !== y[0] && b) {
|
|
406
406
|
o(y);
|
|
407
407
|
continue;
|
|
408
408
|
}
|
|
@@ -421,32 +421,32 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
|
|
|
421
421
|
}
|
|
422
422
|
}
|
|
423
423
|
const a = (y, h) => {
|
|
424
|
-
const
|
|
425
|
-
if (
|
|
424
|
+
const v = this.seen.get(y), b = v.def ?? v.schema, N = { ...b };
|
|
425
|
+
if (v.ref === null)
|
|
426
426
|
return;
|
|
427
|
-
const
|
|
428
|
-
if (
|
|
429
|
-
a(
|
|
430
|
-
const A = this.seen.get(
|
|
431
|
-
A.$ref && h.target === "draft-7" ? (
|
|
427
|
+
const x = v.ref;
|
|
428
|
+
if (v.ref = null, x) {
|
|
429
|
+
a(x, h);
|
|
430
|
+
const A = this.seen.get(x).schema;
|
|
431
|
+
A.$ref && h.target === "draft-7" ? (b.allOf = b.allOf ?? [], b.allOf.push(A)) : (Object.assign(b, A), Object.assign(b, N));
|
|
432
432
|
}
|
|
433
|
-
|
|
433
|
+
v.isParent || this.override({
|
|
434
434
|
zodSchema: y,
|
|
435
|
-
jsonSchema:
|
|
436
|
-
path:
|
|
435
|
+
jsonSchema: b,
|
|
436
|
+
path: v.path ?? []
|
|
437
437
|
});
|
|
438
438
|
};
|
|
439
439
|
for (const y of [...this.seen.entries()].reverse())
|
|
440
440
|
a(y[0], { target: this.target });
|
|
441
441
|
const u = {};
|
|
442
442
|
if (this.target === "draft-2020-12" ? u.$schema = "https://json-schema.org/draft/2020-12/schema" : this.target === "draft-7" ? u.$schema = "http://json-schema.org/draft-07/schema#" : console.warn(`Invalid target: ${this.target}`), (g = s.external) != null && g.uri) {
|
|
443
|
-
const y = (
|
|
443
|
+
const y = (_ = s.external.registry.get(e)) == null ? void 0 : _.id;
|
|
444
444
|
if (!y)
|
|
445
445
|
throw new Error("Schema is missing an `id` property");
|
|
446
446
|
u.$id = s.external.uri(y);
|
|
447
447
|
}
|
|
448
448
|
Object.assign(u, r.def);
|
|
449
|
-
const l = ((
|
|
449
|
+
const l = ((T = s.external) == null ? void 0 : T.defs) ?? {};
|
|
450
450
|
for (const y of this.seen.entries()) {
|
|
451
451
|
const h = y[1];
|
|
452
452
|
h.def && h.defId && (l[h.defId] = h.def);
|
|
@@ -1124,7 +1124,7 @@ class K {
|
|
|
1124
1124
|
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof t == "function" ? t(s, r) : t), !1));
|
|
1125
1125
|
}
|
|
1126
1126
|
_refinement(e) {
|
|
1127
|
-
return new
|
|
1127
|
+
return new Ft({
|
|
1128
1128
|
schema: this,
|
|
1129
1129
|
typeName: O.ZodEffects,
|
|
1130
1130
|
effect: { type: "refinement", refinement: e }
|
|
@@ -1144,7 +1144,7 @@ class K {
|
|
|
1144
1144
|
return tt.create(this, this._def);
|
|
1145
1145
|
}
|
|
1146
1146
|
nullable() {
|
|
1147
|
-
return
|
|
1147
|
+
return $t.create(this, this._def);
|
|
1148
1148
|
}
|
|
1149
1149
|
nullish() {
|
|
1150
1150
|
return this.nullable().optional();
|
|
@@ -1162,7 +1162,7 @@ class K {
|
|
|
1162
1162
|
return ls.create(this, e, this._def);
|
|
1163
1163
|
}
|
|
1164
1164
|
transform(e) {
|
|
1165
|
-
return new
|
|
1165
|
+
return new Ft({
|
|
1166
1166
|
...V(this._def),
|
|
1167
1167
|
schema: this,
|
|
1168
1168
|
typeName: O.ZodEffects,
|
|
@@ -2217,12 +2217,12 @@ je.create = (n, e) => new je({
|
|
|
2217
2217
|
typeName: O.ZodArray,
|
|
2218
2218
|
...V(e)
|
|
2219
2219
|
});
|
|
2220
|
-
function
|
|
2220
|
+
function zt(n) {
|
|
2221
2221
|
if (n instanceof ce) {
|
|
2222
2222
|
const e = {};
|
|
2223
2223
|
for (const t in n.shape) {
|
|
2224
2224
|
const s = n.shape[t];
|
|
2225
|
-
e[t] = tt.create(
|
|
2225
|
+
e[t] = tt.create(zt(s));
|
|
2226
2226
|
}
|
|
2227
2227
|
return new ce({
|
|
2228
2228
|
...n._def,
|
|
@@ -2230,8 +2230,8 @@ function Bt(n) {
|
|
|
2230
2230
|
});
|
|
2231
2231
|
} else return n instanceof je ? new je({
|
|
2232
2232
|
...n._def,
|
|
2233
|
-
type:
|
|
2234
|
-
}) : n instanceof tt ? tt.create(
|
|
2233
|
+
type: zt(n.element)
|
|
2234
|
+
}) : n instanceof tt ? tt.create(zt(n.unwrap())) : n instanceof $t ? $t.create(zt(n.unwrap())) : n instanceof Dt ? Dt.create(n.items.map((e) => zt(e))) : n;
|
|
2235
2235
|
}
|
|
2236
2236
|
class ce extends K {
|
|
2237
2237
|
constructor() {
|
|
@@ -2467,7 +2467,7 @@ class ce extends K {
|
|
|
2467
2467
|
* @deprecated
|
|
2468
2468
|
*/
|
|
2469
2469
|
deepPartial() {
|
|
2470
|
-
return
|
|
2470
|
+
return zt(this);
|
|
2471
2471
|
}
|
|
2472
2472
|
partial(e) {
|
|
2473
2473
|
const t = {};
|
|
@@ -2594,7 +2594,7 @@ cs.create = (n, e) => new cs({
|
|
|
2594
2594
|
typeName: O.ZodUnion,
|
|
2595
2595
|
...V(e)
|
|
2596
2596
|
});
|
|
2597
|
-
const Je = (n) => n instanceof ps ? Je(n.schema) : n instanceof
|
|
2597
|
+
const Je = (n) => n instanceof ps ? Je(n.schema) : n instanceof Ft ? Je(n.innerType()) : n instanceof fs ? [n.value] : n instanceof Mt ? n.options : n instanceof er ? X.objectValues(n.enum) : n instanceof ms ? Je(n._def.innerType) : n instanceof Ys ? [void 0] : n instanceof Xs ? [null] : n instanceof tt ? [void 0, ...Je(n.unwrap())] : n instanceof $t ? [null, ...Je(n.unwrap())] : n instanceof aa || n instanceof ys ? Je(n.unwrap()) : n instanceof gs ? Je(n._def.innerType) : [];
|
|
2598
2598
|
class Sr extends K {
|
|
2599
2599
|
_parse(e) {
|
|
2600
2600
|
const { ctx: t } = this._processInputParams(e);
|
|
@@ -2721,7 +2721,7 @@ ls.create = (n, e, t) => new ls({
|
|
|
2721
2721
|
typeName: O.ZodIntersection,
|
|
2722
2722
|
...V(t)
|
|
2723
2723
|
});
|
|
2724
|
-
class
|
|
2724
|
+
class Dt extends K {
|
|
2725
2725
|
_parse(e) {
|
|
2726
2726
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2727
2727
|
if (s.parsedType !== M.array)
|
|
@@ -2755,16 +2755,16 @@ class Mt extends K {
|
|
|
2755
2755
|
return this._def.items;
|
|
2756
2756
|
}
|
|
2757
2757
|
rest(e) {
|
|
2758
|
-
return new
|
|
2758
|
+
return new Dt({
|
|
2759
2759
|
...this._def,
|
|
2760
2760
|
rest: e
|
|
2761
2761
|
});
|
|
2762
2762
|
}
|
|
2763
2763
|
}
|
|
2764
|
-
|
|
2764
|
+
Dt.create = (n, e) => {
|
|
2765
2765
|
if (!Array.isArray(n))
|
|
2766
2766
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2767
|
-
return new
|
|
2767
|
+
return new Dt({
|
|
2768
2768
|
items: n,
|
|
2769
2769
|
typeName: O.ZodTuple,
|
|
2770
2770
|
rest: null,
|
|
@@ -2960,13 +2960,13 @@ fs.create = (n, e) => new fs({
|
|
|
2960
2960
|
...V(e)
|
|
2961
2961
|
});
|
|
2962
2962
|
function ia(n, e) {
|
|
2963
|
-
return new
|
|
2963
|
+
return new Mt({
|
|
2964
2964
|
values: n,
|
|
2965
2965
|
typeName: O.ZodEnum,
|
|
2966
2966
|
...V(e)
|
|
2967
2967
|
});
|
|
2968
2968
|
}
|
|
2969
|
-
class
|
|
2969
|
+
class Mt extends K {
|
|
2970
2970
|
_parse(e) {
|
|
2971
2971
|
if (typeof e.data != "string") {
|
|
2972
2972
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
@@ -3008,19 +3008,19 @@ class Ft extends K {
|
|
|
3008
3008
|
return e;
|
|
3009
3009
|
}
|
|
3010
3010
|
extract(e, t = this._def) {
|
|
3011
|
-
return
|
|
3011
|
+
return Mt.create(e, {
|
|
3012
3012
|
...this._def,
|
|
3013
3013
|
...t
|
|
3014
3014
|
});
|
|
3015
3015
|
}
|
|
3016
3016
|
exclude(e, t = this._def) {
|
|
3017
|
-
return
|
|
3017
|
+
return Mt.create(this.options.filter((s) => !e.includes(s)), {
|
|
3018
3018
|
...this._def,
|
|
3019
3019
|
...t
|
|
3020
3020
|
});
|
|
3021
3021
|
}
|
|
3022
3022
|
}
|
|
3023
|
-
|
|
3023
|
+
Mt.create = ia;
|
|
3024
3024
|
class er extends K {
|
|
3025
3025
|
_parse(e) {
|
|
3026
3026
|
const t = X.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
@@ -3075,7 +3075,7 @@ hs.create = (n, e) => new hs({
|
|
|
3075
3075
|
typeName: O.ZodPromise,
|
|
3076
3076
|
...V(e)
|
|
3077
3077
|
});
|
|
3078
|
-
class
|
|
3078
|
+
class Ft extends K {
|
|
3079
3079
|
innerType() {
|
|
3080
3080
|
return this._def.schema;
|
|
3081
3081
|
}
|
|
@@ -3155,13 +3155,13 @@ class $t extends K {
|
|
|
3155
3155
|
X.assertNever(r);
|
|
3156
3156
|
}
|
|
3157
3157
|
}
|
|
3158
|
-
|
|
3158
|
+
Ft.create = (n, e, t) => new Ft({
|
|
3159
3159
|
schema: n,
|
|
3160
3160
|
typeName: O.ZodEffects,
|
|
3161
3161
|
effect: e,
|
|
3162
3162
|
...V(t)
|
|
3163
3163
|
});
|
|
3164
|
-
|
|
3164
|
+
Ft.createWithPreprocess = (n, e, t) => new Ft({
|
|
3165
3165
|
schema: e,
|
|
3166
3166
|
effect: { type: "preprocess", transform: n },
|
|
3167
3167
|
typeName: O.ZodEffects,
|
|
@@ -3180,7 +3180,7 @@ tt.create = (n, e) => new tt({
|
|
|
3180
3180
|
typeName: O.ZodOptional,
|
|
3181
3181
|
...V(e)
|
|
3182
3182
|
});
|
|
3183
|
-
class
|
|
3183
|
+
class $t extends K {
|
|
3184
3184
|
_parse(e) {
|
|
3185
3185
|
return this._getType(e) === M.null ? Ce(null) : this._def.innerType._parse(e);
|
|
3186
3186
|
}
|
|
@@ -3188,7 +3188,7 @@ class jt extends K {
|
|
|
3188
3188
|
return this._def.innerType;
|
|
3189
3189
|
}
|
|
3190
3190
|
}
|
|
3191
|
-
|
|
3191
|
+
$t.create = (n, e) => new $t({
|
|
3192
3192
|
innerType: n,
|
|
3193
3193
|
typeName: O.ZodNullable,
|
|
3194
3194
|
...V(e)
|
|
@@ -3366,15 +3366,15 @@ var O;
|
|
|
3366
3366
|
})(O || (O = {}));
|
|
3367
3367
|
const oa = (n, e = {
|
|
3368
3368
|
message: `Input not instance of ${n.name}`
|
|
3369
|
-
}) => ru((t) => t instanceof n, e), f = et.create, E = ln.create,
|
|
3369
|
+
}) => ru((t) => t instanceof n, e), f = et.create, E = ln.create, Pt = Ks.create, W = Sn.create;
|
|
3370
3370
|
ft.create;
|
|
3371
|
-
const J = je.create,
|
|
3371
|
+
const J = je.create, w = ce.create, nt = cs.create, ye = Sr.create;
|
|
3372
3372
|
ls.create;
|
|
3373
|
-
|
|
3374
|
-
const se = ds.create, iu = ps.create, I = fs.create, le =
|
|
3373
|
+
Dt.create;
|
|
3374
|
+
const se = ds.create, iu = ps.create, I = fs.create, le = Mt.create;
|
|
3375
3375
|
hs.create;
|
|
3376
3376
|
tt.create;
|
|
3377
|
-
|
|
3377
|
+
$t.create;
|
|
3378
3378
|
function au() {
|
|
3379
3379
|
return {};
|
|
3380
3380
|
}
|
|
@@ -4343,7 +4343,7 @@ function Vu(n) {
|
|
|
4343
4343
|
class mt extends Error {
|
|
4344
4344
|
constructor(t, s) {
|
|
4345
4345
|
super(t);
|
|
4346
|
-
|
|
4346
|
+
S(this, "state");
|
|
4347
4347
|
this.state = s;
|
|
4348
4348
|
}
|
|
4349
4349
|
}
|
|
@@ -4358,28 +4358,28 @@ class ne extends mt {
|
|
|
4358
4358
|
class ci extends mt {
|
|
4359
4359
|
constructor(t, s, r) {
|
|
4360
4360
|
super(t, r);
|
|
4361
|
-
|
|
4361
|
+
S(this, "error");
|
|
4362
4362
|
this.error = s;
|
|
4363
4363
|
}
|
|
4364
4364
|
}
|
|
4365
4365
|
class Wu extends mt {
|
|
4366
4366
|
constructor(t, s, r) {
|
|
4367
4367
|
super(t, r);
|
|
4368
|
-
|
|
4368
|
+
S(this, "error");
|
|
4369
4369
|
this.error = s;
|
|
4370
4370
|
}
|
|
4371
4371
|
}
|
|
4372
4372
|
class li extends mt {
|
|
4373
4373
|
constructor(t, s, r) {
|
|
4374
4374
|
super(t, r);
|
|
4375
|
-
|
|
4375
|
+
S(this, "result");
|
|
4376
4376
|
this.result = s;
|
|
4377
4377
|
}
|
|
4378
4378
|
}
|
|
4379
4379
|
class nr extends mt {
|
|
4380
4380
|
constructor(t, s, r) {
|
|
4381
4381
|
super(t, r);
|
|
4382
|
-
|
|
4382
|
+
S(this, "result");
|
|
4383
4383
|
this.result = s;
|
|
4384
4384
|
}
|
|
4385
4385
|
}
|
|
@@ -4400,7 +4400,7 @@ function ks(n) {
|
|
|
4400
4400
|
const s = t.toLowerCase();
|
|
4401
4401
|
return s.startsWith("zod") ? s.slice(3) : s;
|
|
4402
4402
|
}
|
|
4403
|
-
function
|
|
4403
|
+
function jt(n) {
|
|
4404
4404
|
return pn(n) ? ks(n) === "object" : !1;
|
|
4405
4405
|
}
|
|
4406
4406
|
function Ku(n) {
|
|
@@ -4607,7 +4607,7 @@ function vs(n) {
|
|
|
4607
4607
|
}
|
|
4608
4608
|
function xr(n, e) {
|
|
4609
4609
|
const t = (s) => JSON.parse(s);
|
|
4610
|
-
if (
|
|
4610
|
+
if (jt(n)) {
|
|
4611
4611
|
const s = (i) => {
|
|
4612
4612
|
const o = _a(n);
|
|
4613
4613
|
if (o)
|
|
@@ -4645,7 +4645,7 @@ function xr(n, e) {
|
|
|
4645
4645
|
function pi(n) {
|
|
4646
4646
|
if (n === "text")
|
|
4647
4647
|
return "text";
|
|
4648
|
-
if (
|
|
4648
|
+
if (jt(n)) {
|
|
4649
4649
|
const e = (s, r) => {
|
|
4650
4650
|
const i = _a(n);
|
|
4651
4651
|
if (i)
|
|
@@ -4753,8 +4753,8 @@ function gc() {
|
|
|
4753
4753
|
return d >= s ? l(p, d, s, "day") : d >= t ? l(p, d, t, "hour") : d >= e ? l(p, d, e, "minute") : d >= n ? l(p, d, n, "second") : p + " ms";
|
|
4754
4754
|
}
|
|
4755
4755
|
function l(p, d, m, g) {
|
|
4756
|
-
var
|
|
4757
|
-
return Math.round(p / m) + " " + g + (
|
|
4756
|
+
var _ = d >= m * 1.5;
|
|
4757
|
+
return Math.round(p / m) + " " + g + (_ ? "s" : "");
|
|
4758
4758
|
}
|
|
4759
4759
|
return js;
|
|
4760
4760
|
}
|
|
@@ -4774,29 +4774,29 @@ function yc() {
|
|
|
4774
4774
|
}
|
|
4775
4775
|
s.selectColor = t;
|
|
4776
4776
|
function s(d) {
|
|
4777
|
-
let m, g = null,
|
|
4777
|
+
let m, g = null, _, T;
|
|
4778
4778
|
function y(...h) {
|
|
4779
4779
|
if (!y.enabled)
|
|
4780
4780
|
return;
|
|
4781
|
-
const
|
|
4782
|
-
|
|
4783
|
-
let
|
|
4781
|
+
const v = y, b = Number(/* @__PURE__ */ new Date()), N = b - (m || b);
|
|
4782
|
+
v.diff = N, v.prev = m, v.curr = b, m = b, h[0] = s.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O");
|
|
4783
|
+
let x = 0;
|
|
4784
4784
|
h[0] = h[0].replace(/%([a-zA-Z%])/g, (D, U) => {
|
|
4785
4785
|
if (D === "%%")
|
|
4786
4786
|
return "%";
|
|
4787
|
-
|
|
4787
|
+
x++;
|
|
4788
4788
|
const G = s.formatters[U];
|
|
4789
4789
|
if (typeof G == "function") {
|
|
4790
|
-
const L = h[
|
|
4791
|
-
D = G.call(
|
|
4790
|
+
const L = h[x];
|
|
4791
|
+
D = G.call(v, L), h.splice(x, 1), x--;
|
|
4792
4792
|
}
|
|
4793
4793
|
return D;
|
|
4794
|
-
}), s.formatArgs.call(
|
|
4794
|
+
}), s.formatArgs.call(v, h), (v.log || s.log).apply(v, h);
|
|
4795
4795
|
}
|
|
4796
4796
|
return y.namespace = d, y.useColors = s.useColors(), y.color = s.selectColor(d), y.extend = r, y.destroy = s.destroy, Object.defineProperty(y, "enabled", {
|
|
4797
4797
|
enumerable: !0,
|
|
4798
4798
|
configurable: !1,
|
|
4799
|
-
get: () => g !== null ? g : (
|
|
4799
|
+
get: () => g !== null ? g : (_ !== s.namespaces && (_ = s.namespaces, T = s.enabled(d)), T),
|
|
4800
4800
|
set: (h) => {
|
|
4801
4801
|
g = h;
|
|
4802
4802
|
}
|
|
@@ -4813,17 +4813,17 @@ function yc() {
|
|
|
4813
4813
|
g[0] === "-" ? s.skips.push(g.slice(1)) : s.names.push(g);
|
|
4814
4814
|
}
|
|
4815
4815
|
function o(d, m) {
|
|
4816
|
-
let g = 0,
|
|
4816
|
+
let g = 0, _ = 0, T = -1, y = 0;
|
|
4817
4817
|
for (; g < d.length; )
|
|
4818
|
-
if (
|
|
4819
|
-
m[
|
|
4820
|
-
else if (
|
|
4821
|
-
|
|
4818
|
+
if (_ < m.length && (m[_] === d[g] || m[_] === "*"))
|
|
4819
|
+
m[_] === "*" ? (T = _, y = g, _++) : (g++, _++);
|
|
4820
|
+
else if (T !== -1)
|
|
4821
|
+
_ = T + 1, y++, g = y;
|
|
4822
4822
|
else
|
|
4823
4823
|
return !1;
|
|
4824
|
-
for (;
|
|
4825
|
-
|
|
4826
|
-
return
|
|
4824
|
+
for (; _ < m.length && m[_] === "*"; )
|
|
4825
|
+
_++;
|
|
4826
|
+
return _ === m.length;
|
|
4827
4827
|
}
|
|
4828
4828
|
function a() {
|
|
4829
4829
|
const d = [
|
|
@@ -5136,27 +5136,27 @@ async function vi({ runContext: n }) {
|
|
|
5136
5136
|
function kc(n, e) {
|
|
5137
5137
|
return `An error occurred while running the tool. Please try again. Error: ${e instanceof Error ? e.toString() : String(e)}`;
|
|
5138
5138
|
}
|
|
5139
|
-
function
|
|
5139
|
+
function Gt(n) {
|
|
5140
5140
|
const e = n.name ? vs(n.name) : vs(n.execute.name), t = typeof n.errorFunction > "u" ? kc : n.errorFunction;
|
|
5141
5141
|
if (!e)
|
|
5142
5142
|
throw new Error("Tool name cannot be empty. Either name your function or provide a name in the options.");
|
|
5143
5143
|
const s = n.strict ?? !0;
|
|
5144
|
-
if (!s &&
|
|
5144
|
+
if (!s && jt(n.parameters))
|
|
5145
5145
|
throw new ne("Strict mode is required for Zod parameters");
|
|
5146
5146
|
const { parser: r, schema: i } = xr(n.parameters, e);
|
|
5147
5147
|
async function o(p, d, m) {
|
|
5148
|
-
const [g,
|
|
5148
|
+
const [g, _] = await Ir(() => r(d));
|
|
5149
5149
|
if (g !== null)
|
|
5150
5150
|
throw F.dontLogToolData ? F.debug(`Invalid JSON input for tool ${e}`) : F.debug(`Invalid JSON input for tool ${e}: ${d}`), new we("Invalid JSON input for tool");
|
|
5151
5151
|
F.dontLogToolData ? F.debug(`Invoking tool ${e}`) : F.debug(`Invoking tool ${e} with input ${d}`);
|
|
5152
|
-
const
|
|
5153
|
-
return F.dontLogToolData ? F.debug(`Tool ${e} completed`) : F.debug(`Tool ${e} returned: ${y}`),
|
|
5152
|
+
const T = await n.execute(_, p, m), y = ht(T);
|
|
5153
|
+
return F.dontLogToolData ? F.debug(`Tool ${e} completed`) : F.debug(`Tool ${e} returned: ${y}`), T;
|
|
5154
5154
|
}
|
|
5155
5155
|
async function a(p, d, m) {
|
|
5156
5156
|
return o(p, d, m).catch((g) => {
|
|
5157
5157
|
if (t) {
|
|
5158
|
-
const
|
|
5159
|
-
return
|
|
5158
|
+
const _ = An();
|
|
5159
|
+
return _ == null || _.setError({
|
|
5160
5160
|
message: "Error running tool (non-fatal)",
|
|
5161
5161
|
data: {
|
|
5162
5162
|
tool_name: e,
|
|
@@ -5182,14 +5182,14 @@ function wt(n) {
|
|
|
5182
5182
|
isEnabled: l
|
|
5183
5183
|
};
|
|
5184
5184
|
}
|
|
5185
|
-
|
|
5185
|
+
w({
|
|
5186
5186
|
name: f(),
|
|
5187
5187
|
description: f().optional(),
|
|
5188
|
-
inputSchema:
|
|
5188
|
+
inputSchema: w({
|
|
5189
5189
|
type: I("object"),
|
|
5190
5190
|
properties: se(f(), W()),
|
|
5191
5191
|
required: J(f()),
|
|
5192
|
-
additionalProperties:
|
|
5192
|
+
additionalProperties: Pt()
|
|
5193
5193
|
})
|
|
5194
5194
|
});
|
|
5195
5195
|
const Ls = {}, zs = {}, Ac = ({ server: n, agent: e }) => n.toolFilter && typeof n.toolFilter == "function" && e ? `${n.name}:${e.name}` : n.name;
|
|
@@ -5207,19 +5207,19 @@ async function Cc({ server: n, convertSchemasToStrict: e, runContext: t, agent:
|
|
|
5207
5207
|
if (t && s) {
|
|
5208
5208
|
const d = { runContext: t, agent: s, serverName: n.name }, m = [];
|
|
5209
5209
|
for (const g of u) {
|
|
5210
|
-
const
|
|
5211
|
-
if (
|
|
5212
|
-
if (typeof
|
|
5213
|
-
if (!await
|
|
5210
|
+
const _ = n.toolFilter;
|
|
5211
|
+
if (_)
|
|
5212
|
+
if (typeof _ == "function") {
|
|
5213
|
+
if (!await _(d, g)) {
|
|
5214
5214
|
F.debug(`MCP Tool (server: ${n.name}, tool: ${g.name}) is blocked by the callable filter.`);
|
|
5215
5215
|
continue;
|
|
5216
5216
|
}
|
|
5217
5217
|
} else {
|
|
5218
|
-
const
|
|
5219
|
-
if (
|
|
5220
|
-
const h =
|
|
5221
|
-
if (!h ||
|
|
5222
|
-
|
|
5218
|
+
const T = _.allowedToolNames ?? [], y = _.blockedToolNames ?? [];
|
|
5219
|
+
if (T.length > 0 || y.length > 0) {
|
|
5220
|
+
const h = T.length > 0 ? T.includes(g.name) : !0, v = y.length > 0 ? y.includes(g.name) : !1;
|
|
5221
|
+
if (!h || v) {
|
|
5222
|
+
v ? F.debug(`MCP Tool (server: ${n.name}, tool: ${g.name}) is blocked by the static filter.`) : h || F.debug(`MCP Tool (server: ${n.name}, tool: ${g.name}) is not allowed by the static filter.`);
|
|
5223
5223
|
continue;
|
|
5224
5224
|
}
|
|
5225
5225
|
}
|
|
@@ -5250,9 +5250,9 @@ async function Oc(n, e, t, s = !1) {
|
|
|
5250
5250
|
runContext: a,
|
|
5251
5251
|
agent: u,
|
|
5252
5252
|
generateMCPToolCacheKey: l
|
|
5253
|
-
}),
|
|
5254
|
-
if (
|
|
5255
|
-
throw new ne(`Duplicate tool names found across MCP servers: ${
|
|
5253
|
+
}), T = [...new Set(g.map((y) => y.name))].filter((y) => d.has(y));
|
|
5254
|
+
if (T.length > 0)
|
|
5255
|
+
throw new ne(`Duplicate tool names found across MCP servers: ${T.join(", ")}`);
|
|
5256
5256
|
for (const y of g)
|
|
5257
5257
|
d.add(y.name), p.push(y);
|
|
5258
5258
|
}
|
|
@@ -5265,8 +5265,8 @@ function bi(n, e, t) {
|
|
|
5265
5265
|
typeof p == "string" && p ? m = JSON.parse(p) : typeof p == "object" && p != null && (m = p);
|
|
5266
5266
|
const g = An();
|
|
5267
5267
|
g && (g.spanData.mcp_data = { server: e.name });
|
|
5268
|
-
const
|
|
5269
|
-
return
|
|
5268
|
+
const _ = await e.callTool(n.name, m);
|
|
5269
|
+
return _.length === 1 ? _[0] : _;
|
|
5270
5270
|
}
|
|
5271
5271
|
const r = {
|
|
5272
5272
|
...n.inputSchema,
|
|
@@ -5278,7 +5278,7 @@ function bi(n, e, t) {
|
|
|
5278
5278
|
if (t || r.additionalProperties === !0)
|
|
5279
5279
|
try {
|
|
5280
5280
|
const p = Ec(r);
|
|
5281
|
-
return
|
|
5281
|
+
return Gt({
|
|
5282
5282
|
name: n.name,
|
|
5283
5283
|
description: n.description || "",
|
|
5284
5284
|
parameters: p,
|
|
@@ -5292,7 +5292,7 @@ function bi(n, e, t) {
|
|
|
5292
5292
|
...r,
|
|
5293
5293
|
additionalProperties: !0
|
|
5294
5294
|
};
|
|
5295
|
-
return
|
|
5295
|
+
return Gt({
|
|
5296
5296
|
name: n.name,
|
|
5297
5297
|
description: n.description || "",
|
|
5298
5298
|
parameters: i,
|
|
@@ -5310,27 +5310,27 @@ function Ec(n) {
|
|
|
5310
5310
|
function Rc() {
|
|
5311
5311
|
return {};
|
|
5312
5312
|
}
|
|
5313
|
-
var Ht,
|
|
5313
|
+
var Ht, It;
|
|
5314
5314
|
class Cs {
|
|
5315
5315
|
constructor() {
|
|
5316
|
-
|
|
5317
|
-
|
|
5316
|
+
R(this, Ht, new EventTarget());
|
|
5317
|
+
R(this, It, /* @__PURE__ */ new Map());
|
|
5318
5318
|
}
|
|
5319
5319
|
on(e, t) {
|
|
5320
5320
|
const s = e;
|
|
5321
|
-
let r = c(this,
|
|
5322
|
-
r || (r = /* @__PURE__ */ new Map(), c(this,
|
|
5321
|
+
let r = c(this, It).get(s);
|
|
5322
|
+
r || (r = /* @__PURE__ */ new Map(), c(this, It).set(s, r));
|
|
5323
5323
|
let i = r.get(t);
|
|
5324
5324
|
i || (i = /* @__PURE__ */ new Set(), r.set(t, i));
|
|
5325
5325
|
const o = (a) => t(...a.detail ?? []);
|
|
5326
5326
|
return i.add(o), c(this, Ht).addEventListener(s, o), this;
|
|
5327
5327
|
}
|
|
5328
5328
|
off(e, t) {
|
|
5329
|
-
const s = e, r = c(this,
|
|
5329
|
+
const s = e, r = c(this, It).get(s), i = r == null ? void 0 : r.get(t);
|
|
5330
5330
|
if (i != null && i.size) {
|
|
5331
5331
|
for (const o of i)
|
|
5332
5332
|
c(this, Ht).removeEventListener(s, o);
|
|
5333
|
-
r == null || r.delete(t), (r == null ? void 0 : r.size) === 0 && c(this,
|
|
5333
|
+
r == null || r.delete(t), (r == null ? void 0 : r.size) === 0 && c(this, It).delete(s);
|
|
5334
5334
|
}
|
|
5335
5335
|
return this;
|
|
5336
5336
|
}
|
|
@@ -5345,7 +5345,7 @@ class Cs {
|
|
|
5345
5345
|
return this.on(e, s), this;
|
|
5346
5346
|
}
|
|
5347
5347
|
}
|
|
5348
|
-
Ht = new WeakMap(),
|
|
5348
|
+
Ht = new WeakMap(), It = new WeakMap();
|
|
5349
5349
|
const ka = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
|
|
5350
5350
|
const e = Math.random() * 16 | 0;
|
|
5351
5351
|
return (n === "x" ? e : e & 3 | 8).toString(16);
|
|
@@ -5359,7 +5359,7 @@ const ka = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID()
|
|
|
5359
5359
|
}, Pc = globalThis.ReadableStream, Dc = globalThis.TransformStream;
|
|
5360
5360
|
class Mc {
|
|
5361
5361
|
constructor() {
|
|
5362
|
-
|
|
5362
|
+
S(this, "context", null);
|
|
5363
5363
|
}
|
|
5364
5364
|
run(e, t) {
|
|
5365
5365
|
return this.context = e, t();
|
|
@@ -5400,13 +5400,13 @@ class Ar {
|
|
|
5400
5400
|
class jc extends Ar {
|
|
5401
5401
|
constructor() {
|
|
5402
5402
|
super(...arguments);
|
|
5403
|
-
|
|
5403
|
+
S(this, "eventEmitter", new Cs());
|
|
5404
5404
|
}
|
|
5405
5405
|
}
|
|
5406
5406
|
class Uc extends Ar {
|
|
5407
5407
|
constructor() {
|
|
5408
5408
|
super(...arguments);
|
|
5409
|
-
|
|
5409
|
+
S(this, "eventEmitter", new Cs());
|
|
5410
5410
|
}
|
|
5411
5411
|
}
|
|
5412
5412
|
const Lc = "OPENAI_DEFAULT_MODEL";
|
|
@@ -5444,15 +5444,15 @@ class Ea {
|
|
|
5444
5444
|
/**
|
|
5445
5445
|
* The name of the tool that represents the handoff.
|
|
5446
5446
|
*/
|
|
5447
|
-
|
|
5447
|
+
S(this, "toolName");
|
|
5448
5448
|
/**
|
|
5449
5449
|
* The description of the tool that represents the handoff.
|
|
5450
5450
|
*/
|
|
5451
|
-
|
|
5451
|
+
S(this, "toolDescription");
|
|
5452
5452
|
/**
|
|
5453
5453
|
* The JSON schema for the handoff input. Can be empty if the handoff does not take an input
|
|
5454
5454
|
*/
|
|
5455
|
-
|
|
5455
|
+
S(this, "inputJsonSchema", {
|
|
5456
5456
|
type: "object",
|
|
5457
5457
|
properties: {},
|
|
5458
5458
|
required: [],
|
|
@@ -5462,7 +5462,7 @@ class Ea {
|
|
|
5462
5462
|
* Whether the input JSON schema is in strict mode. We **strongly** recommend setting this to
|
|
5463
5463
|
* true, as it increases the likelihood of correct JSON input.
|
|
5464
5464
|
*/
|
|
5465
|
-
|
|
5465
|
+
S(this, "strictJsonSchema", !0);
|
|
5466
5466
|
/**
|
|
5467
5467
|
* The function that invokes the handoff. The parameters passed are:
|
|
5468
5468
|
* 1. The handoff run context
|
|
@@ -5470,11 +5470,11 @@ class Ea {
|
|
|
5470
5470
|
*
|
|
5471
5471
|
* Must return an agent
|
|
5472
5472
|
*/
|
|
5473
|
-
|
|
5473
|
+
S(this, "onInvokeHandoff");
|
|
5474
5474
|
/**
|
|
5475
5475
|
* The name of the agent that is being handed off to.
|
|
5476
5476
|
*/
|
|
5477
|
-
|
|
5477
|
+
S(this, "agentName");
|
|
5478
5478
|
/**
|
|
5479
5479
|
* A function that filters the inputs that are passed to the next agent. By default, the new agent
|
|
5480
5480
|
* sees the entire conversation history. In some cases, you may want to filter inputs e.g. to
|
|
@@ -5486,12 +5486,12 @@ class Ea {
|
|
|
5486
5486
|
* You are free to modify the input history or new items as you see fit. The next agent that runs
|
|
5487
5487
|
* will receive `handoffInputData.allItems
|
|
5488
5488
|
*/
|
|
5489
|
-
|
|
5489
|
+
S(this, "inputFilter");
|
|
5490
5490
|
/**
|
|
5491
5491
|
* The agent that is being handed off to.
|
|
5492
5492
|
*/
|
|
5493
|
-
|
|
5494
|
-
|
|
5493
|
+
S(this, "agent");
|
|
5494
|
+
S(this, "isEnabled", async () => !0);
|
|
5495
5495
|
this.agentName = e.name, this.onInvokeHandoff = t, this.toolName = Bc(e), this.toolDescription = Zc(e), this.agent = e;
|
|
5496
5496
|
}
|
|
5497
5497
|
/**
|
|
@@ -5567,27 +5567,27 @@ function Vc(n) {
|
|
|
5567
5567
|
const e = ar.get(n);
|
|
5568
5568
|
return e && ar.delete(n), e;
|
|
5569
5569
|
}
|
|
5570
|
-
const Hc =
|
|
5570
|
+
const Hc = w({ input: f() }), Jt = class Jt extends jc {
|
|
5571
5571
|
constructor(t) {
|
|
5572
5572
|
super();
|
|
5573
|
-
|
|
5574
|
-
|
|
5575
|
-
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5573
|
+
S(this, "name");
|
|
5574
|
+
S(this, "instructions");
|
|
5575
|
+
S(this, "prompt");
|
|
5576
|
+
S(this, "handoffDescription");
|
|
5577
|
+
S(this, "handoffs");
|
|
5578
|
+
S(this, "model");
|
|
5579
|
+
S(this, "modelSettings");
|
|
5580
|
+
S(this, "tools");
|
|
5581
|
+
S(this, "mcpServers");
|
|
5582
|
+
S(this, "inputGuardrails");
|
|
5583
|
+
S(this, "outputGuardrails");
|
|
5584
|
+
S(this, "outputType", "text");
|
|
5585
|
+
S(this, "toolUseBehavior");
|
|
5586
|
+
S(this, "resetToolChoice");
|
|
5587
|
+
S(this, "_toolsExplicitlyConfigured");
|
|
5588
5588
|
if (typeof t.name != "string" || t.name.trim() === "")
|
|
5589
5589
|
throw new ne("Agent must have a name.");
|
|
5590
|
-
if (this.name = t.name, this.instructions = t.instructions ??
|
|
5590
|
+
if (this.name = t.name, this.instructions = t.instructions ?? Jt.DEFAULT_MODEL_PLACEHOLDER, this.prompt = t.prompt, this.handoffDescription = t.handoffDescription ?? "", this.handoffs = t.handoffs ?? [], this.model = t.model ?? "", this.modelSettings = t.modelSettings ?? zc(), this.tools = t.tools ?? [], this._toolsExplicitlyConfigured = t.tools !== void 0, this.mcpServers = t.mcpServers ?? [], this.inputGuardrails = t.inputGuardrails ?? [], this.outputGuardrails = t.outputGuardrails ?? [], t.outputType && (this.outputType = t.outputType), this.toolUseBehavior = t.toolUseBehavior ?? "run_llm_again", this.resetToolChoice = t.resetToolChoice ?? !0, // The user sets a non-default model
|
|
5591
5591
|
t.model !== void 0 && // The default model is gpt-5
|
|
5592
5592
|
Aa() && // However, the specified model is not a gpt-5 model
|
|
5593
5593
|
(typeof t.model != "string" || !Os(t.model)) && // The model settings are not customized for the specified model
|
|
@@ -5602,7 +5602,7 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5602
5602
|
* Create an Agent with handoffs and automatically infer the union type for TOutput from the handoff agents' output types.
|
|
5603
5603
|
*/
|
|
5604
5604
|
static create(t) {
|
|
5605
|
-
return new
|
|
5605
|
+
return new Jt({
|
|
5606
5606
|
...t,
|
|
5607
5607
|
handoffs: t.handoffs,
|
|
5608
5608
|
outputType: t.outputType,
|
|
@@ -5615,7 +5615,7 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5615
5615
|
get outputSchemaName() {
|
|
5616
5616
|
if (this.outputType === "text")
|
|
5617
5617
|
return "text";
|
|
5618
|
-
if (
|
|
5618
|
+
if (jt(this.outputType))
|
|
5619
5619
|
return "ZodOutput";
|
|
5620
5620
|
if (typeof this.outputType == "object")
|
|
5621
5621
|
return this.outputType.name;
|
|
@@ -5632,7 +5632,7 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5632
5632
|
* @returns A new agent with the given changes.
|
|
5633
5633
|
*/
|
|
5634
5634
|
clone(t) {
|
|
5635
|
-
return new
|
|
5635
|
+
return new Jt({
|
|
5636
5636
|
...this,
|
|
5637
5637
|
...t
|
|
5638
5638
|
});
|
|
@@ -5650,56 +5650,56 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5650
5650
|
* @returns A tool that runs the agent and returns the output text.
|
|
5651
5651
|
*/
|
|
5652
5652
|
asTool(t) {
|
|
5653
|
-
const { toolName: s, toolDescription: r, customOutputExtractor: i, needsApproval: o, runConfig: a, runOptions: u, isEnabled: l, onStream: p } = t, d = /* @__PURE__ */ new Map(), m = async (
|
|
5654
|
-
const y = d.get(
|
|
5653
|
+
const { toolName: s, toolDescription: r, customOutputExtractor: i, needsApproval: o, runConfig: a, runOptions: u, isEnabled: l, onStream: p } = t, d = /* @__PURE__ */ new Map(), m = async (T) => {
|
|
5654
|
+
const y = d.get(T.event.type), h = d.get("*"), v = [
|
|
5655
5655
|
...p ? [p] : [],
|
|
5656
5656
|
...y ? Array.from(y) : [],
|
|
5657
5657
|
...h ? Array.from(h) : []
|
|
5658
5658
|
];
|
|
5659
|
-
await Promise.allSettled(
|
|
5660
|
-
},
|
|
5661
|
-
...
|
|
5659
|
+
await Promise.allSettled(v.map((b) => Promise.resolve().then(() => b(T))));
|
|
5660
|
+
}, _ = {
|
|
5661
|
+
...Gt({
|
|
5662
5662
|
name: s ?? vs(this.name),
|
|
5663
5663
|
description: r ?? "",
|
|
5664
5664
|
parameters: Hc,
|
|
5665
5665
|
strict: !0,
|
|
5666
5666
|
needsApproval: o,
|
|
5667
5667
|
isEnabled: l,
|
|
5668
|
-
execute: async (
|
|
5669
|
-
if (!Ku(
|
|
5668
|
+
execute: async (T, y, h) => {
|
|
5669
|
+
if (!Ku(T))
|
|
5670
5670
|
throw new we("Agent tool called with invalid input");
|
|
5671
|
-
const
|
|
5671
|
+
const v = new xd(a ?? {}), b = typeof p == "function" || d.size > 0, N = b ? await v.run(this, T.input, {
|
|
5672
5672
|
context: y,
|
|
5673
5673
|
...u ?? {},
|
|
5674
5674
|
stream: !0
|
|
5675
|
-
}) : await
|
|
5675
|
+
}) : await v.run(this, T.input, {
|
|
5676
5676
|
context: y,
|
|
5677
5677
|
...u ?? {}
|
|
5678
|
-
}),
|
|
5678
|
+
}), x = {
|
|
5679
5679
|
agent: this,
|
|
5680
5680
|
toolCall: h == null ? void 0 : h.toolCall
|
|
5681
5681
|
};
|
|
5682
|
-
if (
|
|
5683
|
-
const G =
|
|
5682
|
+
if (b) {
|
|
5683
|
+
const G = N;
|
|
5684
5684
|
for await (const L of G)
|
|
5685
5685
|
await m({
|
|
5686
5686
|
event: L,
|
|
5687
|
-
...
|
|
5687
|
+
...x
|
|
5688
5688
|
});
|
|
5689
5689
|
await G.completed;
|
|
5690
5690
|
}
|
|
5691
|
-
const A =
|
|
5691
|
+
const A = N, D = typeof this.toolUseBehavior == "object" && this.toolUseBehavior !== null && "stopAtToolNames" in this.toolUseBehavior;
|
|
5692
5692
|
typeof i != "function" && D && F.debug(`You're passing the agent (name: ${this.name}) with toolUseBehavior.stopAtToolNames configured as a tool to a different agent; this may not work as you expect. You may want to have a wrapper function tool to consistently return the final output.`);
|
|
5693
5693
|
const U = typeof i == "function" ? await i(A) : Jc(A.rawResponses[A.rawResponses.length - 1]);
|
|
5694
5694
|
return h != null && h.toolCall && Gc(h.toolCall, A), U;
|
|
5695
5695
|
}
|
|
5696
5696
|
}),
|
|
5697
|
-
on: (
|
|
5698
|
-
const h = d.get(
|
|
5699
|
-
return h.add(y), d.set(
|
|
5697
|
+
on: (T, y) => {
|
|
5698
|
+
const h = d.get(T) ?? /* @__PURE__ */ new Set();
|
|
5699
|
+
return h.add(y), d.set(T, h), _;
|
|
5700
5700
|
}
|
|
5701
5701
|
};
|
|
5702
|
-
return
|
|
5702
|
+
return _;
|
|
5703
5703
|
}
|
|
5704
5704
|
/**
|
|
5705
5705
|
* Returns the system prompt for the agent.
|
|
@@ -5774,7 +5774,7 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5774
5774
|
return t;
|
|
5775
5775
|
if (typeof this.outputType == "object") {
|
|
5776
5776
|
const s = JSON.parse(t);
|
|
5777
|
-
return
|
|
5777
|
+
return jt(this.outputType) ? this.outputType.parse(s) : s;
|
|
5778
5778
|
}
|
|
5779
5779
|
throw new Error(`Unknown output type: ${this.outputType}`);
|
|
5780
5780
|
}
|
|
@@ -5789,8 +5789,8 @@ const Hc = b({ input: f() }), Gt = class Gt extends jc {
|
|
|
5789
5789
|
};
|
|
5790
5790
|
}
|
|
5791
5791
|
};
|
|
5792
|
-
|
|
5793
|
-
let st =
|
|
5792
|
+
S(Jt, "DEFAULT_MODEL_PLACEHOLDER", "");
|
|
5793
|
+
let st = Jt;
|
|
5794
5794
|
function wi({ name: n, execute: e, runInParallel: t = !0 }) {
|
|
5795
5795
|
return {
|
|
5796
5796
|
type: "input",
|
|
@@ -5823,7 +5823,7 @@ function or({ name: n, execute: e }) {
|
|
|
5823
5823
|
function Wc() {
|
|
5824
5824
|
throw new Error("No default model provider set. Make sure to set a provider using setDefaultModelProvider before calling getDefaultModelProvider or pass an explicit provider.");
|
|
5825
5825
|
}
|
|
5826
|
-
const pe =
|
|
5826
|
+
const pe = w({
|
|
5827
5827
|
/**
|
|
5828
5828
|
* Additional optional provider specific data. Used for custom functionality or model provider
|
|
5829
5829
|
* specific fields.
|
|
@@ -5865,7 +5865,7 @@ const pe = b({
|
|
|
5865
5865
|
* The image input to the model. Could be provided inline (`image`), as a URL, or by reference to a
|
|
5866
5866
|
* previously uploaded OpenAI file.
|
|
5867
5867
|
*/
|
|
5868
|
-
image: f().or(
|
|
5868
|
+
image: f().or(w({ id: f().describe("OpenAI file ID") })).describe("Either base64 encoded image data, a data URL, or an object with a file ID.").optional(),
|
|
5869
5869
|
/**
|
|
5870
5870
|
* Controls the level of detail requested for image understanding tasks.
|
|
5871
5871
|
* Future models may add new values, therefore this accepts any string.
|
|
@@ -5876,7 +5876,7 @@ const pe = b({
|
|
|
5876
5876
|
/**
|
|
5877
5877
|
* The file input to the model. Could be raw data, a URL, or an OpenAI file ID.
|
|
5878
5878
|
*/
|
|
5879
|
-
file: f().describe("Either base64 encoded file data or a publicly accessible file URL").or(
|
|
5879
|
+
file: f().describe("Either base64 encoded file data or a publicly accessible file URL").or(w({ id: f().describe("OpenAI file ID") })).or(w({ url: f().describe("Publicly accessible file URL") })).describe("Contents of the file or an object with a file ID.").optional(),
|
|
5880
5880
|
/**
|
|
5881
5881
|
* Optional filename metadata when uploading file data inline.
|
|
5882
5882
|
*/
|
|
@@ -5886,7 +5886,7 @@ const pe = b({
|
|
|
5886
5886
|
/**
|
|
5887
5887
|
* The audio input to the model. Could be base64 encoded audio data or an object with a file ID.
|
|
5888
5888
|
*/
|
|
5889
|
-
audio: f().or(
|
|
5889
|
+
audio: f().or(w({
|
|
5890
5890
|
id: f()
|
|
5891
5891
|
})).describe("Base64 encoded audio data or file id"),
|
|
5892
5892
|
/**
|
|
@@ -5909,21 +5909,21 @@ const pe = b({
|
|
|
5909
5909
|
* The text output from the model.
|
|
5910
5910
|
*/
|
|
5911
5911
|
text: f()
|
|
5912
|
-
}), tl =
|
|
5912
|
+
}), tl = w({
|
|
5913
5913
|
data: nt([f(), oa(Uint8Array)]).describe("Base64 image data, or raw bytes that will be base64 encoded automatically."),
|
|
5914
5914
|
mediaType: f().optional()
|
|
5915
|
-
}), nl =
|
|
5915
|
+
}), nl = w({
|
|
5916
5916
|
url: f().describe("Publicly accessible URL pointing to the image content")
|
|
5917
|
-
}), sl =
|
|
5917
|
+
}), sl = w({
|
|
5918
5918
|
fileId: f().describe("OpenAI file ID referencing uploaded image content")
|
|
5919
|
-
}), rl = nt([tl, nl, sl]).describe("Inline image data or references to uploaded content."), il =
|
|
5919
|
+
}), rl = nt([tl, nl, sl]).describe("Inline image data or references to uploaded content."), il = w({
|
|
5920
5920
|
data: nt([f(), oa(Uint8Array)]).describe("Base64 encoded file data, or raw bytes that will be encoded automatically."),
|
|
5921
5921
|
mediaType: f().describe("IANA media type describing the file contents"),
|
|
5922
5922
|
filename: f().describe("Filename associated with the inline data")
|
|
5923
|
-
}), al =
|
|
5923
|
+
}), al = w({
|
|
5924
5924
|
url: f().describe("Publicly accessible URL for the file content"),
|
|
5925
5925
|
filename: f().optional()
|
|
5926
|
-
}), ol =
|
|
5926
|
+
}), ol = w({
|
|
5927
5927
|
id: f().describe("OpenAI file ID referencing uploaded content"),
|
|
5928
5928
|
filename: f().optional()
|
|
5929
5929
|
}), ul = nt([
|
|
@@ -5957,42 +5957,42 @@ const pe = b({
|
|
|
5957
5957
|
*/
|
|
5958
5958
|
data: f().describe("Base64 encoded image data or URL")
|
|
5959
5959
|
}), fl = ye("type", [
|
|
5960
|
-
|
|
5961
|
-
|
|
5960
|
+
w({ type: I("screenshot") }),
|
|
5961
|
+
w({
|
|
5962
5962
|
type: I("click"),
|
|
5963
5963
|
x: E(),
|
|
5964
5964
|
y: E(),
|
|
5965
5965
|
button: le(["left", "right", "wheel", "back", "forward"])
|
|
5966
5966
|
}),
|
|
5967
|
-
|
|
5967
|
+
w({
|
|
5968
5968
|
type: I("double_click"),
|
|
5969
5969
|
x: E(),
|
|
5970
5970
|
y: E()
|
|
5971
5971
|
}),
|
|
5972
|
-
|
|
5972
|
+
w({
|
|
5973
5973
|
type: I("scroll"),
|
|
5974
5974
|
x: E(),
|
|
5975
5975
|
y: E(),
|
|
5976
5976
|
scroll_x: E(),
|
|
5977
5977
|
scroll_y: E()
|
|
5978
5978
|
}),
|
|
5979
|
-
|
|
5979
|
+
w({
|
|
5980
5980
|
type: I("type"),
|
|
5981
5981
|
text: f()
|
|
5982
5982
|
}),
|
|
5983
|
-
|
|
5984
|
-
|
|
5983
|
+
w({ type: I("wait") }),
|
|
5984
|
+
w({
|
|
5985
5985
|
type: I("move"),
|
|
5986
5986
|
x: E(),
|
|
5987
5987
|
y: E()
|
|
5988
5988
|
}),
|
|
5989
|
-
|
|
5989
|
+
w({
|
|
5990
5990
|
type: I("keypress"),
|
|
5991
5991
|
keys: J(f())
|
|
5992
5992
|
}),
|
|
5993
|
-
|
|
5993
|
+
w({
|
|
5994
5994
|
type: I("drag"),
|
|
5995
|
-
path: J(
|
|
5995
|
+
path: J(w({ x: E(), y: E() }))
|
|
5996
5996
|
})
|
|
5997
5997
|
]), hl = ye("type", [
|
|
5998
5998
|
Yc,
|
|
@@ -6138,7 +6138,7 @@ const xn = Oe.extend({
|
|
|
6138
6138
|
* The output of the computer call.
|
|
6139
6139
|
*/
|
|
6140
6140
|
output: pl
|
|
6141
|
-
}), vl =
|
|
6141
|
+
}), vl = w({
|
|
6142
6142
|
commands: J(f()),
|
|
6143
6143
|
timeoutMs: E().int().min(0).optional(),
|
|
6144
6144
|
maxOutputLength: E().int().min(0).optional()
|
|
@@ -6148,12 +6148,12 @@ const xn = Oe.extend({
|
|
|
6148
6148
|
status: le(["in_progress", "completed", "incomplete"]).optional(),
|
|
6149
6149
|
action: vl
|
|
6150
6150
|
}), bl = ye("type", [
|
|
6151
|
-
|
|
6152
|
-
|
|
6151
|
+
w({ type: I("timeout") }),
|
|
6152
|
+
w({
|
|
6153
6153
|
type: I("exit"),
|
|
6154
6154
|
exitCode: E().int().nullable()
|
|
6155
6155
|
})
|
|
6156
|
-
]), wl =
|
|
6156
|
+
]), wl = w({
|
|
6157
6157
|
stdout: f(),
|
|
6158
6158
|
stderr: f(),
|
|
6159
6159
|
outcome: bl
|
|
@@ -6162,15 +6162,15 @@ const xn = Oe.extend({
|
|
|
6162
6162
|
callId: f(),
|
|
6163
6163
|
maxOutputLength: E().optional(),
|
|
6164
6164
|
output: J(wl)
|
|
6165
|
-
}), Il =
|
|
6165
|
+
}), Il = w({
|
|
6166
6166
|
type: I("create_file"),
|
|
6167
6167
|
path: f(),
|
|
6168
6168
|
diff: f()
|
|
6169
|
-
}), Sl =
|
|
6169
|
+
}), Sl = w({
|
|
6170
6170
|
type: I("update_file"),
|
|
6171
6171
|
path: f(),
|
|
6172
6172
|
diff: f()
|
|
6173
|
-
}), Tl =
|
|
6173
|
+
}), Tl = w({
|
|
6174
6174
|
type: I("delete_file"),
|
|
6175
6175
|
path: f()
|
|
6176
6176
|
}), xl = ye("type", [
|
|
@@ -6249,14 +6249,14 @@ const xn = Oe.extend({
|
|
|
6249
6249
|
Rr,
|
|
6250
6250
|
La,
|
|
6251
6251
|
za
|
|
6252
|
-
]), Cl =
|
|
6252
|
+
]), Cl = w({
|
|
6253
6253
|
inputTokens: E(),
|
|
6254
6254
|
outputTokens: E(),
|
|
6255
6255
|
totalTokens: E(),
|
|
6256
6256
|
inputTokensDetails: se(f(), E()).optional(),
|
|
6257
6257
|
outputTokensDetails: se(f(), E()).optional(),
|
|
6258
6258
|
endpoint: f().optional()
|
|
6259
|
-
}), Ol =
|
|
6259
|
+
}), Ol = w({
|
|
6260
6260
|
requests: E().optional(),
|
|
6261
6261
|
inputTokens: E(),
|
|
6262
6262
|
outputTokens: E(),
|
|
@@ -6312,27 +6312,27 @@ class mn {
|
|
|
6312
6312
|
/**
|
|
6313
6313
|
* The number of input tokens used for this request.
|
|
6314
6314
|
*/
|
|
6315
|
-
|
|
6315
|
+
S(this, "inputTokens");
|
|
6316
6316
|
/**
|
|
6317
6317
|
* The number of output tokens used for this request.
|
|
6318
6318
|
*/
|
|
6319
|
-
|
|
6319
|
+
S(this, "outputTokens");
|
|
6320
6320
|
/**
|
|
6321
6321
|
* The total number of tokens sent and received for this request.
|
|
6322
6322
|
*/
|
|
6323
|
-
|
|
6323
|
+
S(this, "totalTokens");
|
|
6324
6324
|
/**
|
|
6325
6325
|
* Details about the input tokens used for this request.
|
|
6326
6326
|
*/
|
|
6327
|
-
|
|
6327
|
+
S(this, "inputTokensDetails");
|
|
6328
6328
|
/**
|
|
6329
6329
|
* Details about the output tokens used for this request.
|
|
6330
6330
|
*/
|
|
6331
|
-
|
|
6331
|
+
S(this, "outputTokensDetails");
|
|
6332
6332
|
/**
|
|
6333
6333
|
* The endpoint that produced this usage entry (e.g., responses.create, responses.compact).
|
|
6334
6334
|
*/
|
|
6335
|
-
|
|
6335
|
+
S(this, "endpoint");
|
|
6336
6336
|
this.inputTokens = (e == null ? void 0 : e.inputTokens) ?? (e == null ? void 0 : e.input_tokens) ?? 0, this.outputTokens = (e == null ? void 0 : e.outputTokens) ?? (e == null ? void 0 : e.output_tokens) ?? 0, this.totalTokens = (e == null ? void 0 : e.totalTokens) ?? (e == null ? void 0 : e.total_tokens) ?? this.inputTokens + this.outputTokens;
|
|
6337
6337
|
const t = (e == null ? void 0 : e.inputTokensDetails) ?? (e == null ? void 0 : e.input_tokens_details);
|
|
6338
6338
|
this.inputTokensDetails = t || {};
|
|
@@ -6345,31 +6345,31 @@ class Qn {
|
|
|
6345
6345
|
/**
|
|
6346
6346
|
* The number of requests made to the LLM API.
|
|
6347
6347
|
*/
|
|
6348
|
-
|
|
6348
|
+
S(this, "requests");
|
|
6349
6349
|
/**
|
|
6350
6350
|
* The number of input tokens used across all requests.
|
|
6351
6351
|
*/
|
|
6352
|
-
|
|
6352
|
+
S(this, "inputTokens");
|
|
6353
6353
|
/**
|
|
6354
6354
|
* The number of output tokens used across all requests.
|
|
6355
6355
|
*/
|
|
6356
|
-
|
|
6356
|
+
S(this, "outputTokens");
|
|
6357
6357
|
/**
|
|
6358
6358
|
* The total number of tokens sent and received, across all requests.
|
|
6359
6359
|
*/
|
|
6360
|
-
|
|
6360
|
+
S(this, "totalTokens");
|
|
6361
6361
|
/**
|
|
6362
6362
|
* Details about the input tokens used across all requests.
|
|
6363
6363
|
*/
|
|
6364
|
-
|
|
6364
|
+
S(this, "inputTokensDetails", []);
|
|
6365
6365
|
/**
|
|
6366
6366
|
* Details about the output tokens used across all requests.
|
|
6367
6367
|
*/
|
|
6368
|
-
|
|
6368
|
+
S(this, "outputTokensDetails", []);
|
|
6369
6369
|
/**
|
|
6370
6370
|
* List of per-request usage entries for detailed cost calculations.
|
|
6371
6371
|
*/
|
|
6372
|
-
|
|
6372
|
+
S(this, "requestUsageEntries");
|
|
6373
6373
|
if (typeof e > "u")
|
|
6374
6374
|
this.requests = 0, this.inputTokens = 0, this.outputTokens = 0, this.totalTokens = 0, this.inputTokensDetails = [], this.outputTokensDetails = [], this.requestUsageEntries = void 0;
|
|
6375
6375
|
else {
|
|
@@ -6394,20 +6394,20 @@ class Qn {
|
|
|
6394
6394
|
}
|
|
6395
6395
|
}
|
|
6396
6396
|
var Se;
|
|
6397
|
-
class
|
|
6397
|
+
class Zt {
|
|
6398
6398
|
constructor(e = {}) {
|
|
6399
6399
|
/**
|
|
6400
6400
|
* The context object you passed to the `Runner.run()` method.
|
|
6401
6401
|
*/
|
|
6402
|
-
|
|
6402
|
+
S(this, "context");
|
|
6403
6403
|
/**
|
|
6404
6404
|
* The usage of the agent run so far. For streamed responses, the usage will be updated in real-time
|
|
6405
6405
|
*/
|
|
6406
|
-
|
|
6406
|
+
S(this, "usage");
|
|
6407
6407
|
/**
|
|
6408
6408
|
* A map of tool names to whether they have been approved.
|
|
6409
6409
|
*/
|
|
6410
|
-
|
|
6410
|
+
R(this, Se);
|
|
6411
6411
|
this.context = e, this.usage = new Qn(), k(this, Se, /* @__PURE__ */ new Map());
|
|
6412
6412
|
}
|
|
6413
6413
|
/**
|
|
@@ -6541,10 +6541,10 @@ function Dl(n) {
|
|
|
6541
6541
|
strictJsonSchema: n.strictJsonSchema
|
|
6542
6542
|
};
|
|
6543
6543
|
}
|
|
6544
|
-
class
|
|
6544
|
+
class Lt {
|
|
6545
6545
|
constructor() {
|
|
6546
|
-
|
|
6547
|
-
|
|
6546
|
+
S(this, "type", "base_item");
|
|
6547
|
+
S(this, "rawItem");
|
|
6548
6548
|
}
|
|
6549
6549
|
toJSON() {
|
|
6550
6550
|
return {
|
|
@@ -6553,12 +6553,12 @@ class zt {
|
|
|
6553
6553
|
};
|
|
6554
6554
|
}
|
|
6555
6555
|
}
|
|
6556
|
-
class Ps extends
|
|
6556
|
+
class Ps extends Lt {
|
|
6557
6557
|
constructor(t, s) {
|
|
6558
6558
|
super();
|
|
6559
|
-
|
|
6560
|
-
|
|
6561
|
-
|
|
6559
|
+
S(this, "rawItem");
|
|
6560
|
+
S(this, "agent");
|
|
6561
|
+
S(this, "type", "message_output_item");
|
|
6562
6562
|
this.rawItem = t, this.agent = s;
|
|
6563
6563
|
}
|
|
6564
6564
|
toJSON() {
|
|
@@ -6574,12 +6574,12 @@ class Ps extends zt {
|
|
|
6574
6574
|
return t;
|
|
6575
6575
|
}
|
|
6576
6576
|
}
|
|
6577
|
-
class Xe extends
|
|
6577
|
+
class Xe extends Lt {
|
|
6578
6578
|
constructor(t, s) {
|
|
6579
6579
|
super();
|
|
6580
|
-
|
|
6581
|
-
|
|
6582
|
-
|
|
6580
|
+
S(this, "rawItem");
|
|
6581
|
+
S(this, "agent");
|
|
6582
|
+
S(this, "type", "tool_call_item");
|
|
6583
6583
|
this.rawItem = t, this.agent = s;
|
|
6584
6584
|
}
|
|
6585
6585
|
toJSON() {
|
|
@@ -6589,13 +6589,13 @@ class Xe extends zt {
|
|
|
6589
6589
|
};
|
|
6590
6590
|
}
|
|
6591
6591
|
}
|
|
6592
|
-
class Be extends
|
|
6592
|
+
class Be extends Lt {
|
|
6593
6593
|
constructor(t, s, r) {
|
|
6594
6594
|
super();
|
|
6595
|
-
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6595
|
+
S(this, "rawItem");
|
|
6596
|
+
S(this, "agent");
|
|
6597
|
+
S(this, "output");
|
|
6598
|
+
S(this, "type", "tool_call_output_item");
|
|
6599
6599
|
this.rawItem = t, this.agent = s, this.output = r;
|
|
6600
6600
|
}
|
|
6601
6601
|
toJSON() {
|
|
@@ -6606,12 +6606,12 @@ class Be extends zt {
|
|
|
6606
6606
|
};
|
|
6607
6607
|
}
|
|
6608
6608
|
}
|
|
6609
|
-
class Pr extends
|
|
6609
|
+
class Pr extends Lt {
|
|
6610
6610
|
constructor(t, s) {
|
|
6611
6611
|
super();
|
|
6612
|
-
|
|
6613
|
-
|
|
6614
|
-
|
|
6612
|
+
S(this, "rawItem");
|
|
6613
|
+
S(this, "agent");
|
|
6614
|
+
S(this, "type", "reasoning_item");
|
|
6615
6615
|
this.rawItem = t, this.agent = s;
|
|
6616
6616
|
}
|
|
6617
6617
|
toJSON() {
|
|
@@ -6621,12 +6621,12 @@ class Pr extends zt {
|
|
|
6621
6621
|
};
|
|
6622
6622
|
}
|
|
6623
6623
|
}
|
|
6624
|
-
class Dr extends
|
|
6624
|
+
class Dr extends Lt {
|
|
6625
6625
|
constructor(t, s) {
|
|
6626
6626
|
super();
|
|
6627
|
-
|
|
6628
|
-
|
|
6629
|
-
|
|
6627
|
+
S(this, "rawItem");
|
|
6628
|
+
S(this, "agent");
|
|
6629
|
+
S(this, "type", "handoff_call_item");
|
|
6630
6630
|
this.rawItem = t, this.agent = s;
|
|
6631
6631
|
}
|
|
6632
6632
|
toJSON() {
|
|
@@ -6636,13 +6636,13 @@ class Dr extends zt {
|
|
|
6636
6636
|
};
|
|
6637
6637
|
}
|
|
6638
6638
|
}
|
|
6639
|
-
class Mr extends
|
|
6639
|
+
class Mr extends Lt {
|
|
6640
6640
|
constructor(t, s, r) {
|
|
6641
6641
|
super();
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6645
|
-
|
|
6642
|
+
S(this, "rawItem");
|
|
6643
|
+
S(this, "sourceAgent");
|
|
6644
|
+
S(this, "targetAgent");
|
|
6645
|
+
S(this, "type", "handoff_output_item");
|
|
6646
6646
|
this.rawItem = t, this.sourceAgent = s, this.targetAgent = r;
|
|
6647
6647
|
}
|
|
6648
6648
|
toJSON() {
|
|
@@ -6653,13 +6653,13 @@ class Mr extends zt {
|
|
|
6653
6653
|
};
|
|
6654
6654
|
}
|
|
6655
6655
|
}
|
|
6656
|
-
class _e extends
|
|
6656
|
+
class _e extends Lt {
|
|
6657
6657
|
constructor(t, s, r) {
|
|
6658
6658
|
super();
|
|
6659
|
-
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6659
|
+
S(this, "rawItem");
|
|
6660
|
+
S(this, "agent");
|
|
6661
|
+
S(this, "toolName");
|
|
6662
|
+
S(this, "type", "tool_approval_item");
|
|
6663
6663
|
this.rawItem = t, this.agent = s, this.toolName = r, this.toolName = r ?? t.name;
|
|
6664
6664
|
}
|
|
6665
6665
|
/**
|
|
@@ -6775,11 +6775,11 @@ class Bl {
|
|
|
6775
6775
|
* @param data The raw responses stream events from the LLM.
|
|
6776
6776
|
*/
|
|
6777
6777
|
constructor(e) {
|
|
6778
|
-
|
|
6778
|
+
S(this, "data");
|
|
6779
6779
|
/**
|
|
6780
6780
|
* The type of the event.
|
|
6781
6781
|
*/
|
|
6782
|
-
|
|
6782
|
+
S(this, "type", "raw_model_stream_event");
|
|
6783
6783
|
this.data = e;
|
|
6784
6784
|
}
|
|
6785
6785
|
}
|
|
@@ -6789,9 +6789,9 @@ class Zl {
|
|
|
6789
6789
|
* @param item The item that was created.
|
|
6790
6790
|
*/
|
|
6791
6791
|
constructor(e, t) {
|
|
6792
|
-
|
|
6793
|
-
|
|
6794
|
-
|
|
6792
|
+
S(this, "name");
|
|
6793
|
+
S(this, "item");
|
|
6794
|
+
S(this, "type", "run_item_stream_event");
|
|
6795
6795
|
this.name = e, this.item = t;
|
|
6796
6796
|
}
|
|
6797
6797
|
}
|
|
@@ -6800,8 +6800,8 @@ class ql {
|
|
|
6800
6800
|
* @param agent The new agent
|
|
6801
6801
|
*/
|
|
6802
6802
|
constructor(e) {
|
|
6803
|
-
|
|
6804
|
-
|
|
6803
|
+
S(this, "agent");
|
|
6804
|
+
S(this, "type", "agent_updated_stream_event");
|
|
6805
6805
|
this.agent = e;
|
|
6806
6806
|
}
|
|
6807
6807
|
}
|
|
@@ -6859,19 +6859,19 @@ function xi(n, e = 160) {
|
|
|
6859
6859
|
return t ? t.length <= e ? t : `${t.slice(0, e - 3)}...` : "Schema validation failed.";
|
|
6860
6860
|
}
|
|
6861
6861
|
function ki(n, e, t, s) {
|
|
6862
|
-
var
|
|
6863
|
-
const r = [], i = [], o = [], a = [], u = [], l = [], p = [], d = [], m = new Map(s.map((
|
|
6864
|
-
var
|
|
6865
|
-
return
|
|
6866
|
-
}).map((
|
|
6867
|
-
for (const
|
|
6868
|
-
if (
|
|
6869
|
-
|
|
6870
|
-
else if (
|
|
6871
|
-
r.push(new Xe(
|
|
6872
|
-
const
|
|
6873
|
-
if (d.push(
|
|
6874
|
-
const A =
|
|
6862
|
+
var v;
|
|
6863
|
+
const r = [], i = [], o = [], a = [], u = [], l = [], p = [], d = [], m = new Map(s.map((b) => [b.toolName, b])), g = new Map(t.filter((b) => b.type === "function").map((b) => [b.name, b])), _ = t.find((b) => b.type === "computer"), T = t.find((b) => b.type === "shell"), y = t.find((b) => b.type === "apply_patch"), h = new Map(t.filter((b) => {
|
|
6864
|
+
var N;
|
|
6865
|
+
return b.type === "hosted_tool" && ((N = b.providerData) == null ? void 0 : N.type) === "mcp";
|
|
6866
|
+
}).map((b) => b).map((b) => [b.providerData.server_label, b]));
|
|
6867
|
+
for (const b of n.output) {
|
|
6868
|
+
if (b.type === "message")
|
|
6869
|
+
b.role === "assistant" && r.push(new Ps(b, e));
|
|
6870
|
+
else if (b.type === "hosted_tool_call") {
|
|
6871
|
+
r.push(new Xe(b, e));
|
|
6872
|
+
const x = b.name;
|
|
6873
|
+
if (d.push(x), ((v = b.providerData) == null ? void 0 : v.type) === "mcp_approval_request" || b.name === "mcp_approval_request") {
|
|
6874
|
+
const A = b.providerData, D = A.server_label, U = h.get(D);
|
|
6875
6875
|
if (typeof U > "u") {
|
|
6876
6876
|
const L = `MCP server (${D}) not found in Agent (${e.name})`;
|
|
6877
6877
|
throw Qe({
|
|
@@ -6892,10 +6892,10 @@ function ki(n, e, t, s) {
|
|
|
6892
6892
|
mcpTool: U
|
|
6893
6893
|
}), U.providerData.on_approval || r.push(G);
|
|
6894
6894
|
}
|
|
6895
|
-
} else if (
|
|
6896
|
-
r.push(new Pr(
|
|
6897
|
-
else if (
|
|
6898
|
-
if (r.push(new Xe(
|
|
6895
|
+
} else if (b.type === "reasoning")
|
|
6896
|
+
r.push(new Pr(b, e));
|
|
6897
|
+
else if (b.type === "computer_call") {
|
|
6898
|
+
if (r.push(new Xe(b, e)), d.push("computer_use"), !_)
|
|
6899
6899
|
throw Qe({
|
|
6900
6900
|
message: "Model produced computer action without a computer tool.",
|
|
6901
6901
|
data: {
|
|
@@ -6903,11 +6903,11 @@ function ki(n, e, t, s) {
|
|
|
6903
6903
|
}
|
|
6904
6904
|
}), new we("Model produced computer action without a computer tool.");
|
|
6905
6905
|
a.push({
|
|
6906
|
-
toolCall:
|
|
6907
|
-
computer:
|
|
6906
|
+
toolCall: b,
|
|
6907
|
+
computer: _
|
|
6908
6908
|
});
|
|
6909
|
-
} else if (
|
|
6910
|
-
if (r.push(new Xe(
|
|
6909
|
+
} else if (b.type === "shell_call") {
|
|
6910
|
+
if (r.push(new Xe(b, e)), d.push("shell"), !T)
|
|
6911
6911
|
throw Qe({
|
|
6912
6912
|
message: "Model produced shell action without a shell tool.",
|
|
6913
6913
|
data: {
|
|
@@ -6915,11 +6915,11 @@ function ki(n, e, t, s) {
|
|
|
6915
6915
|
}
|
|
6916
6916
|
}), new we("Model produced shell action without a shell tool.");
|
|
6917
6917
|
u.push({
|
|
6918
|
-
toolCall:
|
|
6919
|
-
shell:
|
|
6918
|
+
toolCall: b,
|
|
6919
|
+
shell: T
|
|
6920
6920
|
});
|
|
6921
|
-
} else if (
|
|
6922
|
-
if (r.push(new Xe(
|
|
6921
|
+
} else if (b.type === "apply_patch_call") {
|
|
6922
|
+
if (r.push(new Xe(b, e)), d.push("apply_patch"), !y)
|
|
6923
6923
|
throw Qe({
|
|
6924
6924
|
message: "Model produced apply_patch action without an apply_patch tool.",
|
|
6925
6925
|
data: {
|
|
@@ -6927,32 +6927,32 @@ function ki(n, e, t, s) {
|
|
|
6927
6927
|
}
|
|
6928
6928
|
}), new we("Model produced apply_patch action without an apply_patch tool.");
|
|
6929
6929
|
l.push({
|
|
6930
|
-
toolCall:
|
|
6930
|
+
toolCall: b,
|
|
6931
6931
|
applyPatch: y
|
|
6932
6932
|
});
|
|
6933
6933
|
}
|
|
6934
|
-
if (
|
|
6934
|
+
if (b.type !== "function_call")
|
|
6935
6935
|
continue;
|
|
6936
|
-
d.push(
|
|
6937
|
-
const
|
|
6938
|
-
if (
|
|
6939
|
-
r.push(new Dr(
|
|
6940
|
-
toolCall:
|
|
6941
|
-
handoff:
|
|
6936
|
+
d.push(b.name);
|
|
6937
|
+
const N = m.get(b.name);
|
|
6938
|
+
if (N)
|
|
6939
|
+
r.push(new Dr(b, e)), i.push({
|
|
6940
|
+
toolCall: b,
|
|
6941
|
+
handoff: N
|
|
6942
6942
|
});
|
|
6943
6943
|
else {
|
|
6944
|
-
const
|
|
6945
|
-
if (!
|
|
6944
|
+
const x = g.get(b.name);
|
|
6945
|
+
if (!x)
|
|
6946
6946
|
throw Qe({
|
|
6947
|
-
message: `Tool ${
|
|
6947
|
+
message: `Tool ${b.name} not found in agent ${e.name}.`,
|
|
6948
6948
|
data: {
|
|
6949
|
-
tool_name:
|
|
6949
|
+
tool_name: b.name,
|
|
6950
6950
|
agent_name: e.name
|
|
6951
6951
|
}
|
|
6952
|
-
}), new we(`Tool ${
|
|
6953
|
-
r.push(new Xe(
|
|
6954
|
-
toolCall:
|
|
6955
|
-
tool:
|
|
6952
|
+
}), new we(`Tool ${b.name} not found in agent ${e.name}.`);
|
|
6953
|
+
r.push(new Xe(b, e)), o.push({
|
|
6954
|
+
toolCall: b,
|
|
6955
|
+
tool: x
|
|
6956
6956
|
});
|
|
6957
6957
|
}
|
|
6958
6958
|
}
|
|
@@ -6971,29 +6971,29 @@ function ki(n, e, t, s) {
|
|
|
6971
6971
|
};
|
|
6972
6972
|
}
|
|
6973
6973
|
const Hl = ye("type", [
|
|
6974
|
-
|
|
6974
|
+
w({
|
|
6975
6975
|
type: I("next_step_handoff"),
|
|
6976
6976
|
newAgent: W()
|
|
6977
6977
|
}),
|
|
6978
|
-
|
|
6978
|
+
w({
|
|
6979
6979
|
type: I("next_step_final_output"),
|
|
6980
6980
|
output: f()
|
|
6981
6981
|
}),
|
|
6982
|
-
|
|
6982
|
+
w({
|
|
6983
6983
|
type: I("next_step_run_again")
|
|
6984
6984
|
}),
|
|
6985
|
-
|
|
6985
|
+
w({
|
|
6986
6986
|
type: I("next_step_interruption"),
|
|
6987
6987
|
data: se(f(), W())
|
|
6988
6988
|
})
|
|
6989
6989
|
]);
|
|
6990
6990
|
class $e {
|
|
6991
6991
|
constructor(e, t, s, r, i) {
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
|
|
6992
|
+
S(this, "originalInput");
|
|
6993
|
+
S(this, "modelResponse");
|
|
6994
|
+
S(this, "preStepItems");
|
|
6995
|
+
S(this, "newStepItems");
|
|
6996
|
+
S(this, "nextStep");
|
|
6997
6997
|
this.originalInput = e, this.modelResponse = t, this.preStepItems = s, this.newStepItems = r, this.nextStep = i;
|
|
6998
6998
|
}
|
|
6999
6999
|
/**
|
|
@@ -7007,39 +7007,39 @@ function Wl(n, e, t) {
|
|
|
7007
7007
|
return n.resetToolChoice && e.hasUsedTools(n) ? { ...t, toolChoice: void 0 } : t;
|
|
7008
7008
|
}
|
|
7009
7009
|
async function Ai(n, e, t, s, r, i, o) {
|
|
7010
|
-
const a = t.filter((
|
|
7010
|
+
const a = t.filter((x) => x instanceof _e && "callId" in x.rawItem && x.rawItem.type === "function_call").map((x) => x.rawItem.callId), u = o.getInterruptions().filter(Gl);
|
|
7011
7011
|
if (u.length > 0) {
|
|
7012
|
-
const
|
|
7012
|
+
const x = /* @__PURE__ */ new Set();
|
|
7013
7013
|
for (const A of u) {
|
|
7014
7014
|
const D = Ti(A);
|
|
7015
|
-
D &&
|
|
7015
|
+
D && x.add(D);
|
|
7016
7016
|
}
|
|
7017
|
-
if (
|
|
7017
|
+
if (x.size > 0) {
|
|
7018
7018
|
let A = 0;
|
|
7019
7019
|
for (let D = t.length - 1; D >= 0; D--) {
|
|
7020
7020
|
const U = t[D];
|
|
7021
7021
|
if (!(U instanceof _e))
|
|
7022
7022
|
continue;
|
|
7023
7023
|
const G = Ti(U);
|
|
7024
|
-
if (G &&
|
|
7024
|
+
if (G && x.has(G) && (A++, x.delete(G), x.size === 0))
|
|
7025
7025
|
break;
|
|
7026
7026
|
}
|
|
7027
7027
|
A > 0 && (o._currentTurnPersistedItemCount = Math.max(0, o._currentTurnPersistedItemCount - A));
|
|
7028
7028
|
}
|
|
7029
7029
|
}
|
|
7030
|
-
const l = r.functions.filter((
|
|
7031
|
-
m.has(
|
|
7030
|
+
const l = r.functions.filter((x) => a.includes(x.toolCall.callId)), p = await Ja(n, l, i, o), d = r.computerActions.length > 0 ? await Va(n, r.computerActions, i, o._context) : [], m = new Set(t), g = [], _ = /* @__PURE__ */ new Set(), T = (x) => {
|
|
7031
|
+
m.has(x) || _.has(x) || (g.push(x), _.add(x));
|
|
7032
7032
|
};
|
|
7033
|
-
for (const
|
|
7034
|
-
|
|
7035
|
-
for (const
|
|
7036
|
-
|
|
7037
|
-
const y = r.mcpApprovalRequests.filter((
|
|
7033
|
+
for (const x of p)
|
|
7034
|
+
T(x.runItem);
|
|
7035
|
+
for (const x of d)
|
|
7036
|
+
T(x);
|
|
7037
|
+
const y = r.mcpApprovalRequests.filter((x) => {
|
|
7038
7038
|
var A;
|
|
7039
|
-
return
|
|
7040
|
-
}), h = /* @__PURE__ */ new Set(),
|
|
7041
|
-
for (const
|
|
7042
|
-
const A =
|
|
7039
|
+
return x.requestItem.type === "tool_approval_item" && x.requestItem.rawItem.type === "hosted_tool_call" && ((A = x.requestItem.rawItem.providerData) == null ? void 0 : A.type) === "mcp_approval_request";
|
|
7040
|
+
}), h = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set();
|
|
7041
|
+
for (const x of y) {
|
|
7042
|
+
const A = x.requestItem.rawItem;
|
|
7043
7043
|
if (A.type !== "hosted_tool_call")
|
|
7044
7044
|
continue;
|
|
7045
7045
|
const D = A.id, U = o._context.isToolApproved({
|
|
@@ -7057,45 +7057,45 @@ async function Ai(n, e, t, s, r, i, o) {
|
|
|
7057
7057
|
name: "mcp_approval_response",
|
|
7058
7058
|
providerData: G
|
|
7059
7059
|
}, n);
|
|
7060
|
-
|
|
7060
|
+
T(L);
|
|
7061
7061
|
} else
|
|
7062
|
-
h.add(
|
|
7062
|
+
h.add(x.requestItem), v.add(D), p.push({
|
|
7063
7063
|
type: "hosted_mcp_tool_approval",
|
|
7064
|
-
tool:
|
|
7065
|
-
runItem:
|
|
7066
|
-
}),
|
|
7064
|
+
tool: x.mcpTool,
|
|
7065
|
+
runItem: x.requestItem
|
|
7066
|
+
}), T(x.requestItem);
|
|
7067
7067
|
}
|
|
7068
|
-
const
|
|
7068
|
+
const b = t.filter((x) => {
|
|
7069
7069
|
var A;
|
|
7070
|
-
if (!(
|
|
7070
|
+
if (!(x instanceof _e))
|
|
7071
7071
|
return !0;
|
|
7072
|
-
if (
|
|
7073
|
-
if (h.has(
|
|
7072
|
+
if (x.rawItem.type === "hosted_tool_call" && ((A = x.rawItem.providerData) == null ? void 0 : A.type) === "mcp_approval_request") {
|
|
7073
|
+
if (h.has(x))
|
|
7074
7074
|
return !0;
|
|
7075
|
-
const D =
|
|
7076
|
-
return D ?
|
|
7075
|
+
const D = x.rawItem.id;
|
|
7076
|
+
return D ? v.has(D) : !1;
|
|
7077
7077
|
}
|
|
7078
7078
|
return !1;
|
|
7079
|
-
}),
|
|
7079
|
+
}), N = await qa({
|
|
7080
7080
|
agent: n,
|
|
7081
7081
|
runner: i,
|
|
7082
7082
|
state: o,
|
|
7083
7083
|
functionResults: p,
|
|
7084
7084
|
originalInput: e,
|
|
7085
7085
|
newResponse: s,
|
|
7086
|
-
preStepItems:
|
|
7086
|
+
preStepItems: b,
|
|
7087
7087
|
newItems: g
|
|
7088
7088
|
});
|
|
7089
|
-
return
|
|
7089
|
+
return N || new $e(e, s, b, g, { type: "next_step_run_again" });
|
|
7090
7090
|
}
|
|
7091
7091
|
async function Ci(n, e, t, s, r, i, o) {
|
|
7092
|
-
var
|
|
7092
|
+
var N, x, A, D, U, G;
|
|
7093
7093
|
const a = t, u = new Set(t), l = [], p = (L) => {
|
|
7094
7094
|
u.has(L) || (l.push(L), u.add(L));
|
|
7095
7095
|
};
|
|
7096
7096
|
for (const L of r.newItems)
|
|
7097
7097
|
p(L);
|
|
7098
|
-
const [d, m, g,
|
|
7098
|
+
const [d, m, g, _] = await Promise.all([
|
|
7099
7099
|
Ja(n, r.functions, i, o),
|
|
7100
7100
|
Va(n, r.computerActions, i, o._context),
|
|
7101
7101
|
ed(n, r.shellActions, i, o._context),
|
|
@@ -7107,7 +7107,7 @@ async function Ci(n, e, t, s, r, i, o) {
|
|
|
7107
7107
|
p(L);
|
|
7108
7108
|
for (const L of g)
|
|
7109
7109
|
p(L);
|
|
7110
|
-
for (const L of
|
|
7110
|
+
for (const L of _)
|
|
7111
7111
|
p(L);
|
|
7112
7112
|
if (r.mcpApprovalRequests.length > 0)
|
|
7113
7113
|
for (const L of r.mcpApprovalRequests) {
|
|
@@ -7142,7 +7142,7 @@ async function Ci(n, e, t, s, r, i, o) {
|
|
|
7142
7142
|
}
|
|
7143
7143
|
if (r.handoffs.length > 0)
|
|
7144
7144
|
return await nd(n, e, a, l, s, r.handoffs, i, o._context);
|
|
7145
|
-
const
|
|
7145
|
+
const T = await qa({
|
|
7146
7146
|
agent: n,
|
|
7147
7147
|
runner: i,
|
|
7148
7148
|
state: o,
|
|
@@ -7152,21 +7152,21 @@ async function Ci(n, e, t, s, r, i, o) {
|
|
|
7152
7152
|
preStepItems: a,
|
|
7153
7153
|
newItems: l
|
|
7154
7154
|
});
|
|
7155
|
-
if (
|
|
7156
|
-
return
|
|
7157
|
-
if ((((
|
|
7155
|
+
if (T)
|
|
7156
|
+
return T;
|
|
7157
|
+
if ((((N = r.functions) == null ? void 0 : N.length) ?? 0) > 0 || (((x = r.computerActions) == null ? void 0 : x.length) ?? 0) > 0 || (((A = r.shellActions) == null ? void 0 : A.length) ?? 0) > 0 || (((D = r.applyPatchActions) == null ? void 0 : D.length) ?? 0) > 0 || (((U = r.mcpApprovalRequests) == null ? void 0 : U.length) ?? 0) > 0 || (((G = r.handoffs) == null ? void 0 : G.length) ?? 0) > 0)
|
|
7158
7158
|
return new $e(e, s, a, l, { type: "next_step_run_again" });
|
|
7159
|
-
const h = l.filter((L) => L instanceof Ps),
|
|
7160
|
-
if (typeof
|
|
7159
|
+
const h = l.filter((L) => L instanceof Ps), v = h.length > 0 ? Na(h[h.length - 1].rawItem) : void 0;
|
|
7160
|
+
if (typeof v > "u")
|
|
7161
7161
|
return new $e(e, s, a, l, { type: "next_step_run_again" });
|
|
7162
7162
|
if (!d.some((L) => L.runItem instanceof _e)) {
|
|
7163
7163
|
if (n.outputType === "text")
|
|
7164
7164
|
return new $e(e, s, a, l, {
|
|
7165
7165
|
type: "next_step_final_output",
|
|
7166
|
-
output:
|
|
7166
|
+
output: v
|
|
7167
7167
|
});
|
|
7168
|
-
if (n.outputType !== "text" &&
|
|
7169
|
-
const { parser: L } = xr(n.outputType, "final_output"), [ue] = await Ir(() => L(
|
|
7168
|
+
if (n.outputType !== "text" && v) {
|
|
7169
|
+
const { parser: L } = xr(n.outputType, "final_output"), [ue] = await Ir(() => L(v));
|
|
7170
7170
|
if (ue) {
|
|
7171
7171
|
const Y = Vl(ue);
|
|
7172
7172
|
throw Qe({
|
|
@@ -7176,7 +7176,7 @@ async function Ci(n, e, t, s, r, i, o) {
|
|
|
7176
7176
|
}
|
|
7177
7177
|
}), new we(Y);
|
|
7178
7178
|
}
|
|
7179
|
-
return new $e(e, s, a, l, { type: "next_step_final_output", output:
|
|
7179
|
+
return new $e(e, s, a, l, { type: "next_step_final_output", output: v });
|
|
7180
7180
|
}
|
|
7181
7181
|
}
|
|
7182
7182
|
return new $e(e, s, a, l, { type: "next_step_run_again" });
|
|
@@ -7272,17 +7272,17 @@ function he(n) {
|
|
|
7272
7272
|
}
|
|
7273
7273
|
function ns(n, e) {
|
|
7274
7274
|
if (typeof n == "string")
|
|
7275
|
-
return e && !n.startsWith("data:") ?
|
|
7275
|
+
return e && !n.startsWith("data:") ? qt(n, e) : n;
|
|
7276
7276
|
const t = Ae(n);
|
|
7277
|
-
return
|
|
7277
|
+
return qt(t, e);
|
|
7278
7278
|
}
|
|
7279
|
-
function
|
|
7279
|
+
function qt(n, e) {
|
|
7280
7280
|
return e ? `data:${e};base64,${n}` : n;
|
|
7281
7281
|
}
|
|
7282
7282
|
async function Ja(n, e, t, s) {
|
|
7283
7283
|
async function r(i) {
|
|
7284
7284
|
let o = i.toolCall.arguments;
|
|
7285
|
-
if (i.tool.parameters && (
|
|
7285
|
+
if (i.tool.parameters && (jt(i.tool.parameters) ? o = i.tool.parameters.parse(o) : o = JSON.parse(o)), await i.tool.needsApproval(s._context, o, i.toolCall.callId)) {
|
|
7286
7286
|
const u = s._context.isToolApproved({
|
|
7287
7287
|
toolName: i.tool.name,
|
|
7288
7288
|
callId: i.toolCall.callId
|
|
@@ -7422,7 +7422,7 @@ async function ed(n, e, t, s, r = void 0) {
|
|
|
7422
7422
|
callId: l.callId
|
|
7423
7423
|
});
|
|
7424
7424
|
if (y === !1) {
|
|
7425
|
-
const h = "Tool execution was not approved.",
|
|
7425
|
+
const h = "Tool execution was not approved.", v = {
|
|
7426
7426
|
stdout: "",
|
|
7427
7427
|
stderr: h,
|
|
7428
7428
|
outcome: { type: "exit", exitCode: null }
|
|
@@ -7430,7 +7430,7 @@ async function ed(n, e, t, s, r = void 0) {
|
|
|
7430
7430
|
o.push(new Be({
|
|
7431
7431
|
type: "shell_call_output",
|
|
7432
7432
|
callId: l.callId,
|
|
7433
|
-
output: [
|
|
7433
|
+
output: [v]
|
|
7434
7434
|
}, n, h));
|
|
7435
7435
|
continue;
|
|
7436
7436
|
}
|
|
@@ -7444,10 +7444,10 @@ async function ed(n, e, t, s, r = void 0) {
|
|
|
7444
7444
|
}), typeof n.emit == "function" && n.emit("agent_tool_start", s, u, { toolCall: l });
|
|
7445
7445
|
let m;
|
|
7446
7446
|
const g = {};
|
|
7447
|
-
let
|
|
7447
|
+
let _;
|
|
7448
7448
|
try {
|
|
7449
7449
|
const y = await u.shell.run(l.action);
|
|
7450
|
-
m = y.output ?? [], y.providerData && Object.assign(g, y.providerData), typeof y.maxOutputLength == "number" && (
|
|
7450
|
+
m = y.output ?? [], y.providerData && Object.assign(g, y.providerData), typeof y.maxOutputLength == "number" && (_ = y.maxOutputLength);
|
|
7451
7451
|
} catch (y) {
|
|
7452
7452
|
m = [
|
|
7453
7453
|
{
|
|
@@ -7462,12 +7462,12 @@ async function ed(n, e, t, s, r = void 0) {
|
|
|
7462
7462
|
}), typeof n.emit == "function" && n.emit("agent_tool_end", s, u, JSON.stringify(m), {
|
|
7463
7463
|
toolCall: l
|
|
7464
7464
|
});
|
|
7465
|
-
const
|
|
7465
|
+
const T = {
|
|
7466
7466
|
type: "shell_call_output",
|
|
7467
7467
|
callId: l.callId,
|
|
7468
7468
|
output: m ?? []
|
|
7469
7469
|
};
|
|
7470
|
-
typeof
|
|
7470
|
+
typeof _ == "number" && (T.maxOutputLength = _), Object.keys(g).length > 0 && (T.providerData = g), o.push(new Be(T, n, T.output));
|
|
7471
7471
|
}
|
|
7472
7472
|
return o;
|
|
7473
7473
|
}
|
|
@@ -7480,11 +7480,11 @@ async function td(n, e, t, s, r = void 0) {
|
|
|
7480
7480
|
const y = await u.onApproval(s, p);
|
|
7481
7481
|
y.approve === !0 ? s.approveTool(p) : y.approve === !1 && s.rejectTool(p);
|
|
7482
7482
|
}
|
|
7483
|
-
const
|
|
7483
|
+
const T = s.isToolApproved({
|
|
7484
7484
|
toolName: u.name,
|
|
7485
7485
|
callId: l.callId
|
|
7486
7486
|
});
|
|
7487
|
-
if (
|
|
7487
|
+
if (T === !1) {
|
|
7488
7488
|
const y = "Tool execution was not approved.";
|
|
7489
7489
|
o.push(new Be({
|
|
7490
7490
|
type: "apply_patch_call_output",
|
|
@@ -7494,7 +7494,7 @@ async function td(n, e, t, s, r = void 0) {
|
|
|
7494
7494
|
}, n, y));
|
|
7495
7495
|
continue;
|
|
7496
7496
|
}
|
|
7497
|
-
if (
|
|
7497
|
+
if (T !== !0) {
|
|
7498
7498
|
o.push(p);
|
|
7499
7499
|
continue;
|
|
7500
7500
|
}
|
|
@@ -7506,35 +7506,35 @@ async function td(n, e, t, s, r = void 0) {
|
|
|
7506
7506
|
});
|
|
7507
7507
|
let m = "completed", g = "";
|
|
7508
7508
|
try {
|
|
7509
|
-
let
|
|
7509
|
+
let T;
|
|
7510
7510
|
switch (l.operation.type) {
|
|
7511
7511
|
case "create_file":
|
|
7512
|
-
|
|
7512
|
+
T = await u.editor.createFile(l.operation);
|
|
7513
7513
|
break;
|
|
7514
7514
|
case "update_file":
|
|
7515
|
-
|
|
7515
|
+
T = await u.editor.updateFile(l.operation);
|
|
7516
7516
|
break;
|
|
7517
7517
|
case "delete_file":
|
|
7518
|
-
|
|
7518
|
+
T = await u.editor.deleteFile(l.operation);
|
|
7519
7519
|
break;
|
|
7520
7520
|
default:
|
|
7521
7521
|
throw new Error("Unsupported apply_patch operation");
|
|
7522
7522
|
}
|
|
7523
|
-
|
|
7524
|
-
} catch (
|
|
7525
|
-
m = "failed", g = Ga(
|
|
7523
|
+
T && typeof T.status == "string" && (m = T.status), T && typeof T.output == "string" && (g = T.output);
|
|
7524
|
+
} catch (T) {
|
|
7525
|
+
m = "failed", g = Ga(T), i.error("Failed to execute apply_patch operation:", T);
|
|
7526
7526
|
}
|
|
7527
7527
|
t.emit("agent_tool_end", s, n, u, g, {
|
|
7528
7528
|
toolCall: l
|
|
7529
7529
|
}), typeof n.emit == "function" && n.emit("agent_tool_end", s, u, g, {
|
|
7530
7530
|
toolCall: l
|
|
7531
7531
|
});
|
|
7532
|
-
const
|
|
7532
|
+
const _ = {
|
|
7533
7533
|
type: "apply_patch_call_output",
|
|
7534
7534
|
callId: l.callId,
|
|
7535
7535
|
status: m
|
|
7536
7536
|
};
|
|
7537
|
-
g && (
|
|
7537
|
+
g && (_.output = g), o.push(new Be(_, n, g));
|
|
7538
7538
|
}
|
|
7539
7539
|
return o;
|
|
7540
7540
|
}
|
|
@@ -7581,7 +7581,7 @@ async function nd(n, e, t, s, r, i, o, a) {
|
|
|
7581
7581
|
return jl(async (l) => {
|
|
7582
7582
|
const p = u.handoff, d = await p.onInvokeHandoff(a, u.toolCall.arguments);
|
|
7583
7583
|
if (l.spanData.to_agent = d.name, i.length > 1) {
|
|
7584
|
-
const g = i.map((
|
|
7584
|
+
const g = i.map((_) => _.handoff.agentName);
|
|
7585
7585
|
l.setError({
|
|
7586
7586
|
message: "Multiple handoffs requested",
|
|
7587
7587
|
data: {
|
|
@@ -7603,8 +7603,8 @@ async function nd(n, e, t, s, r, i, o, a) {
|
|
|
7603
7603
|
preHandoffItems: [...t],
|
|
7604
7604
|
newItems: [...s],
|
|
7605
7605
|
runContext: a
|
|
7606
|
-
},
|
|
7607
|
-
e =
|
|
7606
|
+
}, _ = m(g);
|
|
7607
|
+
e = _.inputHistory, t = _.preHandoffItems, s = _.newItems;
|
|
7608
7608
|
}
|
|
7609
7609
|
return new $e(e, r, t, s, { type: "next_step_handoff", newAgent: d });
|
|
7610
7610
|
}, {
|
|
@@ -7694,7 +7694,7 @@ function Oi(n, e, t) {
|
|
|
7694
7694
|
var Wt;
|
|
7695
7695
|
class Ei {
|
|
7696
7696
|
constructor() {
|
|
7697
|
-
|
|
7697
|
+
R(this, Wt, /* @__PURE__ */ new Map());
|
|
7698
7698
|
}
|
|
7699
7699
|
addToolUse(e, t) {
|
|
7700
7700
|
c(this, Wt).set(e, t);
|
|
@@ -7848,34 +7848,34 @@ async function pd(n, e, t, s) {
|
|
|
7848
7848
|
const u = o.slice(), l = a.slice(), p = await t(o, a);
|
|
7849
7849
|
if (!Array.isArray(p))
|
|
7850
7850
|
throw new ne("Session input callback must return an array of AgentInputItem objects.");
|
|
7851
|
-
const d = Pi(u), m = Pi(l), g = Di(u),
|
|
7851
|
+
const d = Pi(u), m = Pi(l), g = Di(u), _ = Di(l), T = [];
|
|
7852
7852
|
for (const h of p) {
|
|
7853
|
-
const
|
|
7854
|
-
if (Mi(
|
|
7855
|
-
Fi(m,
|
|
7853
|
+
const v = $r(h);
|
|
7854
|
+
if (Mi(_, v, h)) {
|
|
7855
|
+
Fi(m, v), T.push(h);
|
|
7856
7856
|
continue;
|
|
7857
7857
|
}
|
|
7858
|
-
if (Mi(g,
|
|
7859
|
-
Fi(d,
|
|
7858
|
+
if (Mi(g, v, h)) {
|
|
7859
|
+
Fi(d, v);
|
|
7860
7860
|
continue;
|
|
7861
7861
|
}
|
|
7862
|
-
const
|
|
7863
|
-
if (
|
|
7864
|
-
d.set(
|
|
7862
|
+
const b = d.get(v) ?? 0;
|
|
7863
|
+
if (b > 0) {
|
|
7864
|
+
d.set(v, b - 1);
|
|
7865
7865
|
continue;
|
|
7866
7866
|
}
|
|
7867
|
-
const
|
|
7868
|
-
if (
|
|
7869
|
-
m.set(
|
|
7867
|
+
const N = m.get(v) ?? 0;
|
|
7868
|
+
if (N > 0) {
|
|
7869
|
+
m.set(v, N - 1), T.push(h);
|
|
7870
7870
|
continue;
|
|
7871
7871
|
}
|
|
7872
|
-
|
|
7872
|
+
T.push(h);
|
|
7873
7873
|
}
|
|
7874
7874
|
return {
|
|
7875
|
-
preparedInput: r ? p :
|
|
7875
|
+
preparedInput: r ? p : T.length > 0 ? T : i ? l : [],
|
|
7876
7876
|
// Respect callbacks that intentionally drop the latest inputs (e.g. to redact sensitive
|
|
7877
7877
|
// values) by persisting only the items they kept in the combined array.
|
|
7878
|
-
sessionItems:
|
|
7878
|
+
sessionItems: T
|
|
7879
7879
|
};
|
|
7880
7880
|
}
|
|
7881
7881
|
function fd(n) {
|
|
@@ -7947,10 +7947,10 @@ function hd(n) {
|
|
|
7947
7947
|
if (he(s.url))
|
|
7948
7948
|
t.image = s.url;
|
|
7949
7949
|
else if (he(s.data))
|
|
7950
|
-
t.image = r && !s.data.startsWith("data:") ?
|
|
7950
|
+
t.image = r && !s.data.startsWith("data:") ? qt(s.data, r) : s.data;
|
|
7951
7951
|
else if (s.data instanceof Uint8Array && s.data.length > 0) {
|
|
7952
7952
|
const i = Ae(s.data);
|
|
7953
|
-
t.image =
|
|
7953
|
+
t.image = qt(i, r);
|
|
7954
7954
|
} else {
|
|
7955
7955
|
const i = he(s.fileId) && s.fileId || he(s.id) && s.id || void 0;
|
|
7956
7956
|
i && (t.image = { id: i });
|
|
@@ -7967,10 +7967,10 @@ function hd(n) {
|
|
|
7967
7967
|
if ("data" in r && r.data) {
|
|
7968
7968
|
const i = r.mediaType ?? "text/plain";
|
|
7969
7969
|
if (typeof r.data == "string")
|
|
7970
|
-
t.file =
|
|
7970
|
+
t.file = qt(r.data, i);
|
|
7971
7971
|
else {
|
|
7972
7972
|
const o = Ae(r.data);
|
|
7973
|
-
t.file =
|
|
7973
|
+
t.file = qt(o, i);
|
|
7974
7974
|
}
|
|
7975
7975
|
} else if (typeof r.url == "string" && r.url.length > 0)
|
|
7976
7976
|
t.file = { url: r.url };
|
|
@@ -8039,30 +8039,30 @@ function md(n, e) {
|
|
|
8039
8039
|
data: Ae(Uint8Array.from(e.data))
|
|
8040
8040
|
} : e;
|
|
8041
8041
|
}
|
|
8042
|
-
const is = "1.0", gd = I(is), Me =
|
|
8042
|
+
const is = "1.0", gd = I(is), Me = w({
|
|
8043
8043
|
name: f()
|
|
8044
|
-
}), yd =
|
|
8044
|
+
}), yd = w({
|
|
8045
8045
|
object: I("trace.span"),
|
|
8046
8046
|
id: f(),
|
|
8047
8047
|
trace_id: f(),
|
|
8048
8048
|
parent_id: f().nullable(),
|
|
8049
8049
|
started_at: f().nullable(),
|
|
8050
8050
|
ended_at: f().nullable(),
|
|
8051
|
-
error:
|
|
8051
|
+
error: w({
|
|
8052
8052
|
message: f(),
|
|
8053
8053
|
data: se(f(), W()).optional()
|
|
8054
8054
|
}).nullable(),
|
|
8055
8055
|
span_data: se(f(), W())
|
|
8056
8056
|
}), Ya = yd.extend({
|
|
8057
8057
|
previous_span: iu(() => Ya).optional()
|
|
8058
|
-
}), _d =
|
|
8058
|
+
}), _d = w({
|
|
8059
8059
|
inputTokens: E(),
|
|
8060
8060
|
outputTokens: E(),
|
|
8061
8061
|
totalTokens: E(),
|
|
8062
8062
|
inputTokensDetails: se(f(), E()).optional(),
|
|
8063
8063
|
outputTokensDetails: se(f(), E()).optional(),
|
|
8064
8064
|
endpoint: f().optional()
|
|
8065
|
-
}), Xa =
|
|
8065
|
+
}), Xa = w({
|
|
8066
8066
|
requests: E(),
|
|
8067
8067
|
inputTokens: E(),
|
|
8068
8068
|
outputTokens: E(),
|
|
@@ -8070,83 +8070,83 @@ const is = "1.0", gd = I(is), Me = b({
|
|
|
8070
8070
|
inputTokensDetails: J(se(f(), E())).optional(),
|
|
8071
8071
|
outputTokensDetails: J(se(f(), E())).optional(),
|
|
8072
8072
|
requestUsageEntries: J(_d).optional()
|
|
8073
|
-
}), $i =
|
|
8073
|
+
}), $i = w({
|
|
8074
8074
|
usage: Xa,
|
|
8075
8075
|
output: J(Nr),
|
|
8076
8076
|
responseId: f().optional(),
|
|
8077
8077
|
providerData: se(f(), W()).optional()
|
|
8078
8078
|
}), Qa = ye("type", [
|
|
8079
|
-
|
|
8079
|
+
w({
|
|
8080
8080
|
type: I("message_output_item"),
|
|
8081
8081
|
rawItem: Es,
|
|
8082
8082
|
agent: Me
|
|
8083
8083
|
}),
|
|
8084
|
-
|
|
8084
|
+
w({
|
|
8085
8085
|
type: I("tool_call_item"),
|
|
8086
8086
|
rawItem: kl.or(xn),
|
|
8087
8087
|
agent: Me
|
|
8088
8088
|
}),
|
|
8089
|
-
|
|
8089
|
+
w({
|
|
8090
8090
|
type: I("tool_call_output_item"),
|
|
8091
8091
|
rawItem: ws,
|
|
8092
8092
|
agent: Me,
|
|
8093
8093
|
output: f()
|
|
8094
8094
|
}),
|
|
8095
|
-
|
|
8095
|
+
w({
|
|
8096
8096
|
type: I("reasoning_item"),
|
|
8097
8097
|
rawItem: Rr,
|
|
8098
8098
|
agent: Me
|
|
8099
8099
|
}),
|
|
8100
|
-
|
|
8100
|
+
w({
|
|
8101
8101
|
type: I("handoff_call_item"),
|
|
8102
8102
|
rawItem: kn,
|
|
8103
8103
|
agent: Me
|
|
8104
8104
|
}),
|
|
8105
|
-
|
|
8105
|
+
w({
|
|
8106
8106
|
type: I("handoff_output_item"),
|
|
8107
8107
|
rawItem: ws,
|
|
8108
8108
|
sourceAgent: Me,
|
|
8109
8109
|
targetAgent: Me
|
|
8110
8110
|
}),
|
|
8111
|
-
|
|
8111
|
+
w({
|
|
8112
8112
|
type: I("tool_approval_item"),
|
|
8113
8113
|
rawItem: kn.or(xn).or(Rs).or(Ns),
|
|
8114
8114
|
agent: Me,
|
|
8115
8115
|
toolName: f().optional()
|
|
8116
8116
|
})
|
|
8117
|
-
]), vd =
|
|
8117
|
+
]), vd = w({
|
|
8118
8118
|
object: I("trace"),
|
|
8119
8119
|
id: f(),
|
|
8120
8120
|
workflow_name: f(),
|
|
8121
8121
|
group_id: f().nullable(),
|
|
8122
8122
|
metadata: se(f(), W())
|
|
8123
|
-
}), bd =
|
|
8123
|
+
}), bd = w({
|
|
8124
8124
|
newItems: J(Qa),
|
|
8125
8125
|
toolsUsed: J(f()),
|
|
8126
|
-
handoffs: J(
|
|
8126
|
+
handoffs: J(w({
|
|
8127
8127
|
toolCall: W(),
|
|
8128
8128
|
handoff: W()
|
|
8129
8129
|
})),
|
|
8130
|
-
functions: J(
|
|
8130
|
+
functions: J(w({
|
|
8131
8131
|
toolCall: W(),
|
|
8132
8132
|
tool: W()
|
|
8133
8133
|
})),
|
|
8134
|
-
computerActions: J(
|
|
8134
|
+
computerActions: J(w({
|
|
8135
8135
|
toolCall: W(),
|
|
8136
8136
|
computer: W()
|
|
8137
8137
|
})),
|
|
8138
|
-
shellActions: J(
|
|
8138
|
+
shellActions: J(w({
|
|
8139
8139
|
toolCall: W(),
|
|
8140
8140
|
shell: W()
|
|
8141
8141
|
})).optional(),
|
|
8142
|
-
applyPatchActions: J(
|
|
8142
|
+
applyPatchActions: J(w({
|
|
8143
8143
|
toolCall: W(),
|
|
8144
8144
|
applyPatch: W()
|
|
8145
8145
|
})).optional(),
|
|
8146
|
-
mcpApprovalRequests: J(
|
|
8147
|
-
requestItem:
|
|
8146
|
+
mcpApprovalRequests: J(w({
|
|
8147
|
+
requestItem: w({
|
|
8148
8148
|
// protocol.HostedToolCallItem
|
|
8149
|
-
rawItem:
|
|
8149
|
+
rawItem: w({
|
|
8150
8150
|
type: I("hosted_tool_call"),
|
|
8151
8151
|
name: f(),
|
|
8152
8152
|
arguments: f().optional(),
|
|
@@ -8157,47 +8157,47 @@ const is = "1.0", gd = I(is), Me = b({
|
|
|
8157
8157
|
})
|
|
8158
8158
|
}),
|
|
8159
8159
|
// HostedMCPTool
|
|
8160
|
-
mcpTool:
|
|
8160
|
+
mcpTool: w({
|
|
8161
8161
|
type: I("hosted_tool"),
|
|
8162
8162
|
name: I("hosted_mcp"),
|
|
8163
8163
|
providerData: se(f(), W())
|
|
8164
8164
|
})
|
|
8165
8165
|
})).optional()
|
|
8166
|
-
}), eo =
|
|
8167
|
-
tripwireTriggered:
|
|
8166
|
+
}), eo = w({
|
|
8167
|
+
tripwireTriggered: Pt(),
|
|
8168
8168
|
outputInfo: W()
|
|
8169
|
-
}), wd =
|
|
8170
|
-
guardrail:
|
|
8169
|
+
}), wd = w({
|
|
8170
|
+
guardrail: w({
|
|
8171
8171
|
type: I("input"),
|
|
8172
8172
|
name: f()
|
|
8173
8173
|
}),
|
|
8174
8174
|
output: eo
|
|
8175
|
-
}), Id =
|
|
8176
|
-
guardrail:
|
|
8175
|
+
}), Id = w({
|
|
8176
|
+
guardrail: w({
|
|
8177
8177
|
type: I("output"),
|
|
8178
8178
|
name: f()
|
|
8179
8179
|
}),
|
|
8180
8180
|
agentOutput: W(),
|
|
8181
8181
|
agent: Me,
|
|
8182
8182
|
output: eo
|
|
8183
|
-
}), ji =
|
|
8183
|
+
}), ji = w({
|
|
8184
8184
|
$schemaVersion: gd,
|
|
8185
8185
|
currentTurn: E(),
|
|
8186
8186
|
currentAgent: Me,
|
|
8187
8187
|
originalInput: f().or(J(Al)),
|
|
8188
8188
|
modelResponses: J($i),
|
|
8189
|
-
context:
|
|
8189
|
+
context: w({
|
|
8190
8190
|
usage: Xa,
|
|
8191
|
-
approvals: se(f(),
|
|
8192
|
-
approved: J(f()).or(
|
|
8193
|
-
rejected: J(f()).or(
|
|
8191
|
+
approvals: se(f(), w({
|
|
8192
|
+
approved: J(f()).or(Pt()),
|
|
8193
|
+
rejected: J(f()).or(Pt())
|
|
8194
8194
|
})),
|
|
8195
8195
|
context: se(f(), W())
|
|
8196
8196
|
}),
|
|
8197
8197
|
toolUseTracker: se(f(), J(f())),
|
|
8198
8198
|
maxTurns: E(),
|
|
8199
8199
|
currentAgentSpan: Ya.nullable().optional(),
|
|
8200
|
-
noActiveAgentRun:
|
|
8200
|
+
noActiveAgentRun: Pt(),
|
|
8201
8201
|
inputGuardrailResults: J(wd),
|
|
8202
8202
|
outputGuardrailResults: J(Id),
|
|
8203
8203
|
currentStep: Hl.optional(),
|
|
@@ -8212,35 +8212,35 @@ class Ve {
|
|
|
8212
8212
|
/**
|
|
8213
8213
|
* Current turn number in the conversation.
|
|
8214
8214
|
*/
|
|
8215
|
-
|
|
8215
|
+
S(this, "_currentTurn", 0);
|
|
8216
8216
|
/**
|
|
8217
8217
|
* The agent currently handling the conversation.
|
|
8218
8218
|
*/
|
|
8219
|
-
|
|
8219
|
+
S(this, "_currentAgent");
|
|
8220
8220
|
/**
|
|
8221
8221
|
* Original user input prior to any processing.
|
|
8222
8222
|
*/
|
|
8223
|
-
|
|
8223
|
+
S(this, "_originalInput");
|
|
8224
8224
|
/**
|
|
8225
8225
|
* Responses from the model so far.
|
|
8226
8226
|
*/
|
|
8227
|
-
|
|
8227
|
+
S(this, "_modelResponses");
|
|
8228
8228
|
/**
|
|
8229
8229
|
* Active tracing span for the current agent if tracing is enabled.
|
|
8230
8230
|
*/
|
|
8231
|
-
|
|
8231
|
+
S(this, "_currentAgentSpan");
|
|
8232
8232
|
/**
|
|
8233
8233
|
* Run context tracking approvals, usage, and other metadata.
|
|
8234
8234
|
*/
|
|
8235
|
-
|
|
8235
|
+
S(this, "_context");
|
|
8236
8236
|
/**
|
|
8237
8237
|
* Tracks what tools each agent has used.
|
|
8238
8238
|
*/
|
|
8239
|
-
|
|
8239
|
+
S(this, "_toolUseTracker");
|
|
8240
8240
|
/**
|
|
8241
8241
|
* Items generated by the agent during the run.
|
|
8242
8242
|
*/
|
|
8243
|
-
|
|
8243
|
+
S(this, "_generatedItems");
|
|
8244
8244
|
/**
|
|
8245
8245
|
* Number of `_generatedItems` already flushed to session storage for the current turn.
|
|
8246
8246
|
*
|
|
@@ -8251,39 +8251,39 @@ class Ve {
|
|
|
8251
8251
|
* approval) and later resumed, we rewind the counter before continuing so the pending tool
|
|
8252
8252
|
* output still gets stored.
|
|
8253
8253
|
*/
|
|
8254
|
-
|
|
8254
|
+
S(this, "_currentTurnPersistedItemCount");
|
|
8255
8255
|
/**
|
|
8256
8256
|
* Maximum allowed turns before forcing termination.
|
|
8257
8257
|
*/
|
|
8258
|
-
|
|
8258
|
+
S(this, "_maxTurns");
|
|
8259
8259
|
/**
|
|
8260
8260
|
* Whether the run has an active agent step in progress.
|
|
8261
8261
|
*/
|
|
8262
|
-
|
|
8262
|
+
S(this, "_noActiveAgentRun", !0);
|
|
8263
8263
|
/**
|
|
8264
8264
|
* Last model response for the previous turn.
|
|
8265
8265
|
*/
|
|
8266
|
-
|
|
8266
|
+
S(this, "_lastTurnResponse");
|
|
8267
8267
|
/**
|
|
8268
8268
|
* Results from input guardrails applied to the run.
|
|
8269
8269
|
*/
|
|
8270
|
-
|
|
8270
|
+
S(this, "_inputGuardrailResults");
|
|
8271
8271
|
/**
|
|
8272
8272
|
* Results from output guardrails applied to the run.
|
|
8273
8273
|
*/
|
|
8274
|
-
|
|
8274
|
+
S(this, "_outputGuardrailResults");
|
|
8275
8275
|
/**
|
|
8276
8276
|
* Next step computed for the agent to take.
|
|
8277
8277
|
*/
|
|
8278
|
-
|
|
8278
|
+
S(this, "_currentStep");
|
|
8279
8279
|
/**
|
|
8280
8280
|
* Parsed model response after applying guardrails and tools.
|
|
8281
8281
|
*/
|
|
8282
|
-
|
|
8282
|
+
S(this, "_lastProcessedResponse");
|
|
8283
8283
|
/**
|
|
8284
8284
|
* Trace associated with this run if tracing is enabled.
|
|
8285
8285
|
*/
|
|
8286
|
-
|
|
8286
|
+
S(this, "_trace", null);
|
|
8287
8287
|
this._context = e, this._originalInput = structuredClone(t), this._modelResponses = [], this._currentAgentSpan = void 0, this._currentAgent = s, this._toolUseTracker = new Ei(), this._generatedItems = [], this._currentTurnPersistedItemCount = 0, this._maxTurns = r, this._inputGuardrailResults = [], this._outputGuardrailResults = [], this._trace = dn();
|
|
8288
8288
|
}
|
|
8289
8289
|
/**
|
|
@@ -8416,7 +8416,7 @@ class Ve {
|
|
|
8416
8416
|
* `toString` method.
|
|
8417
8417
|
*/
|
|
8418
8418
|
static async fromString(e, t) {
|
|
8419
|
-
var d, m, g,
|
|
8419
|
+
var d, m, g, _, T;
|
|
8420
8420
|
const [s, r] = await Ir(() => JSON.parse(t));
|
|
8421
8421
|
if (s)
|
|
8422
8422
|
throw new ne(`Failed to parse run state. ${s instanceof Error ? s.message : String(s)}`);
|
|
@@ -8425,7 +8425,7 @@ class Ve {
|
|
|
8425
8425
|
throw new ne("Run state is missing schema version");
|
|
8426
8426
|
if (i !== is)
|
|
8427
8427
|
throw new ne(`Run state schema version ${i} is not supported. Please use version ${is}`);
|
|
8428
|
-
const o = ji.parse(JSON.parse(t)), a = Sd(e), u = new
|
|
8428
|
+
const o = ji.parse(JSON.parse(t)), a = Sd(e), u = new Zt(o.context.context);
|
|
8429
8429
|
u._rebuildApprovals(o.context.approvals);
|
|
8430
8430
|
const l = a.get(o.currentAgent.name);
|
|
8431
8431
|
if (!l)
|
|
@@ -8440,14 +8440,14 @@ class Ve {
|
|
|
8440
8440
|
traceId: (d = o.trace) == null ? void 0 : d.id,
|
|
8441
8441
|
name: (m = o.trace) == null ? void 0 : m.workflow_name,
|
|
8442
8442
|
groupId: ((g = o.trace) == null ? void 0 : g.group_id) ?? void 0,
|
|
8443
|
-
metadata: (
|
|
8443
|
+
metadata: (_ = o.trace) == null ? void 0 : _.metadata
|
|
8444
8444
|
});
|
|
8445
8445
|
p._currentAgentSpan = to(y, o.currentAgentSpan), p._trace = y;
|
|
8446
8446
|
}
|
|
8447
8447
|
return p._noActiveAgentRun = o.noActiveAgentRun, p._inputGuardrailResults = o.inputGuardrailResults, p._outputGuardrailResults = o.outputGuardrailResults.map((y) => ({
|
|
8448
8448
|
...y,
|
|
8449
8449
|
agent: a.get(y.agent.name)
|
|
8450
|
-
})), p._currentStep = o.currentStep, p._originalInput = o.originalInput, p._modelResponses = o.modelResponses.map(Ui), p._lastTurnResponse = o.lastModelResponse ? Ui(o.lastModelResponse) : void 0, p._generatedItems = o.generatedItems.map((y) => no(y, a)), p._currentTurnPersistedItemCount = o.currentTurnPersistedItemCount ?? 0, p._lastProcessedResponse = o.lastProcessedResponse ? await Td(a, p._currentAgent, p._context, o.lastProcessedResponse) : void 0, ((
|
|
8450
|
+
})), p._currentStep = o.currentStep, p._originalInput = o.originalInput, p._modelResponses = o.modelResponses.map(Ui), p._lastTurnResponse = o.lastModelResponse ? Ui(o.lastModelResponse) : void 0, p._generatedItems = o.generatedItems.map((y) => no(y, a)), p._currentTurnPersistedItemCount = o.currentTurnPersistedItemCount ?? 0, p._lastProcessedResponse = o.lastProcessedResponse ? await Td(a, p._currentAgent, p._context, o.lastProcessedResponse) : void 0, ((T = o.currentStep) == null ? void 0 : T.type) === "next_step_handoff" && (p._currentStep = {
|
|
8451
8451
|
type: "next_step_handoff",
|
|
8452
8452
|
newAgent: a.get(o.currentStep.newAgent.name)
|
|
8453
8453
|
}), p;
|
|
@@ -8570,13 +8570,13 @@ class xd extends Uc {
|
|
|
8570
8570
|
*/
|
|
8571
8571
|
constructor(t = {}) {
|
|
8572
8572
|
super();
|
|
8573
|
-
|
|
8574
|
-
|
|
8573
|
+
R(this, ie);
|
|
8574
|
+
S(this, "config");
|
|
8575
8575
|
// --------------------------------------------------------------
|
|
8576
8576
|
// Internals
|
|
8577
8577
|
// --------------------------------------------------------------
|
|
8578
|
-
|
|
8579
|
-
|
|
8578
|
+
S(this, "inputGuardrailDefs");
|
|
8579
|
+
S(this, "outputGuardrailDefs");
|
|
8580
8580
|
this.config = {
|
|
8581
8581
|
modelProvider: t.modelProvider ?? Wc(),
|
|
8582
8582
|
model: t.model,
|
|
@@ -8603,16 +8603,16 @@ class xd extends Uc {
|
|
|
8603
8603
|
sessionInputCallback: o,
|
|
8604
8604
|
callModelInputFilter: a
|
|
8605
8605
|
}, p = !!l.conversationId || !!l.previousResponseId, d = l.session, m = s instanceof Ve;
|
|
8606
|
-
let g = d && m ? [] : void 0,
|
|
8607
|
-
const y = (
|
|
8608
|
-
const D =
|
|
8606
|
+
let g = d && m ? [] : void 0, _, T = d && m ? /* @__PURE__ */ new Map() : void 0;
|
|
8607
|
+
const y = (x, A) => {
|
|
8608
|
+
const D = T;
|
|
8609
8609
|
if (A !== void 0) {
|
|
8610
8610
|
if (!D) {
|
|
8611
|
-
|
|
8611
|
+
_ = A.map((Y) => structuredClone(Y));
|
|
8612
8612
|
return;
|
|
8613
8613
|
}
|
|
8614
8614
|
const G = [], L = /* @__PURE__ */ new WeakMap();
|
|
8615
|
-
for (const Y of
|
|
8615
|
+
for (const Y of x) {
|
|
8616
8616
|
if (!Y || typeof Y != "object")
|
|
8617
8617
|
continue;
|
|
8618
8618
|
const oe = (L.get(Y) ?? 0) + 1;
|
|
@@ -8629,86 +8629,86 @@ class xd extends Uc {
|
|
|
8629
8629
|
if (!oe)
|
|
8630
8630
|
continue;
|
|
8631
8631
|
let Ee = !1;
|
|
8632
|
-
const Pe =
|
|
8632
|
+
const Pe = x[Y];
|
|
8633
8633
|
if (Pe && typeof Pe == "object") {
|
|
8634
8634
|
const qr = (L.get(Pe) ?? 0) - 1;
|
|
8635
8635
|
if (L.set(Pe, qr), qr > 0)
|
|
8636
8636
|
continue;
|
|
8637
|
-
const Jr =
|
|
8637
|
+
const Jr = wt(Pe), Gr = D.get(Jr) ?? 0;
|
|
8638
8638
|
if (Gr > 0) {
|
|
8639
8639
|
D.set(Jr, Gr - 1), G.push(structuredClone(oe)), Ee = !0;
|
|
8640
8640
|
continue;
|
|
8641
8641
|
}
|
|
8642
8642
|
}
|
|
8643
|
-
const hn =
|
|
8643
|
+
const hn = wt(oe), es = D.get(hn) ?? 0;
|
|
8644
8644
|
if (es > 0) {
|
|
8645
8645
|
D.set(hn, es - 1), G.push(structuredClone(oe)), Ee = !0;
|
|
8646
8646
|
continue;
|
|
8647
8647
|
}
|
|
8648
|
-
!Pe && ue() && (G.push(structuredClone(oe)), Ee = !0), !Ee && !Pe &&
|
|
8648
|
+
!Pe && ue() && (G.push(structuredClone(oe)), Ee = !0), !Ee && !Pe && _ === void 0 && G.push(structuredClone(oe));
|
|
8649
8649
|
}
|
|
8650
|
-
(G.length > 0 ||
|
|
8650
|
+
(G.length > 0 || _ === void 0) && (_ = G);
|
|
8651
8651
|
return;
|
|
8652
8652
|
}
|
|
8653
8653
|
const U = [];
|
|
8654
8654
|
if (D)
|
|
8655
|
-
for (const G of
|
|
8655
|
+
for (const G of x) {
|
|
8656
8656
|
if (!G)
|
|
8657
8657
|
continue;
|
|
8658
|
-
const L =
|
|
8658
|
+
const L = wt(G), ue = D.get(L) ?? 0;
|
|
8659
8659
|
ue <= 0 || (D.set(L, ue - 1), U.push(structuredClone(G)));
|
|
8660
8660
|
}
|
|
8661
8661
|
else
|
|
8662
|
-
for (const G of
|
|
8662
|
+
for (const G of x)
|
|
8663
8663
|
G && U.push(structuredClone(G));
|
|
8664
|
-
U.length > 0 ?
|
|
8664
|
+
U.length > 0 ? _ = U : _ === void 0 && (_ = []);
|
|
8665
8665
|
}, h = () => {
|
|
8666
|
-
if (
|
|
8667
|
-
return
|
|
8666
|
+
if (_ !== void 0)
|
|
8667
|
+
return _;
|
|
8668
8668
|
if (!u)
|
|
8669
8669
|
return g;
|
|
8670
8670
|
};
|
|
8671
|
-
let
|
|
8672
|
-
if (!(
|
|
8673
|
-
if (d && Array.isArray(
|
|
8671
|
+
let v = s;
|
|
8672
|
+
if (!(v instanceof Ve)) {
|
|
8673
|
+
if (d && Array.isArray(v) && !o)
|
|
8674
8674
|
throw new ne("RunConfig.sessionInputCallback must be provided when using session history with list inputs.");
|
|
8675
|
-
const
|
|
8675
|
+
const x = await pd(v, d, o, {
|
|
8676
8676
|
// When the server tracks conversation state we only send the new turn inputs;
|
|
8677
8677
|
// previous messages are recovered via conversationId/previousResponseId.
|
|
8678
8678
|
includeHistoryInPreparedInput: !p,
|
|
8679
8679
|
preserveDroppedNewItems: p
|
|
8680
8680
|
});
|
|
8681
8681
|
if (p && d) {
|
|
8682
|
-
const A =
|
|
8683
|
-
A && A.length > 0 ?
|
|
8682
|
+
const A = x.sessionItems;
|
|
8683
|
+
A && A.length > 0 ? v = A : v = x.preparedInput;
|
|
8684
8684
|
} else
|
|
8685
|
-
|
|
8685
|
+
v = x.preparedInput;
|
|
8686
8686
|
if (d) {
|
|
8687
|
-
const A =
|
|
8688
|
-
g = A.map((D) => structuredClone(D)),
|
|
8687
|
+
const A = x.sessionItems ?? [];
|
|
8688
|
+
g = A.map((D) => structuredClone(D)), T = /* @__PURE__ */ new Map();
|
|
8689
8689
|
for (const D of A) {
|
|
8690
|
-
const U =
|
|
8691
|
-
|
|
8690
|
+
const U = wt(D);
|
|
8691
|
+
T.set(U, (T.get(U) ?? 0) + 1);
|
|
8692
8692
|
}
|
|
8693
8693
|
}
|
|
8694
8694
|
}
|
|
8695
|
-
let
|
|
8695
|
+
let b;
|
|
8696
8696
|
if (d && !p) {
|
|
8697
|
-
let
|
|
8698
|
-
|
|
8699
|
-
if (
|
|
8697
|
+
let x = !1;
|
|
8698
|
+
b = async () => {
|
|
8699
|
+
if (x)
|
|
8700
8700
|
return;
|
|
8701
8701
|
const A = h();
|
|
8702
|
-
!A || A.length === 0 || (
|
|
8702
|
+
!A || A.length === 0 || (x = !0, await dd(d, A));
|
|
8703
8703
|
};
|
|
8704
8704
|
}
|
|
8705
|
-
const
|
|
8705
|
+
const N = async () => {
|
|
8706
8706
|
if (l.stream)
|
|
8707
|
-
return await z(this, ie, ao).call(this, t,
|
|
8708
|
-
const
|
|
8709
|
-
return d && !p && await ld(d, h(),
|
|
8707
|
+
return await z(this, ie, ao).call(this, t, v, l, b, y);
|
|
8708
|
+
const x = await z(this, ie, ro).call(this, t, v, l, y);
|
|
8709
|
+
return d && !p && await ld(d, h(), x), x;
|
|
8710
8710
|
};
|
|
8711
|
-
return
|
|
8711
|
+
return v instanceof Ve && v._trace ? Nd(v._trace, async () => (v._currentAgentSpan && jr(v._currentAgentSpan), N())) : Pd(async () => N(), {
|
|
8712
8712
|
traceId: this.config.traceId,
|
|
8713
8713
|
name: this.config.workflowName,
|
|
8714
8714
|
groupId: this.config.groupId,
|
|
@@ -8730,7 +8730,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8730
8730
|
}, ro = async function(t, s, r, i) {
|
|
8731
8731
|
return mr(async () => {
|
|
8732
8732
|
var p, d, m;
|
|
8733
|
-
const o = s instanceof Ve, a = o ? s : new Ve(r.context instanceof
|
|
8733
|
+
const o = s instanceof Ve, a = o ? s : new Ve(r.context instanceof Zt ? r.context : new Zt(r.context), s, t, r.maxTurns ?? Li), u = r.conversationId || r.previousResponseId ? new Bi({
|
|
8734
8734
|
conversationId: r.conversationId,
|
|
8735
8735
|
previousResponseId: r.previousResponseId
|
|
8736
8736
|
}) : void 0;
|
|
@@ -8757,17 +8757,17 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8757
8757
|
l = !1, a._currentStep = g.nextStep;
|
|
8758
8758
|
}
|
|
8759
8759
|
if (a._currentStep.type === "next_step_run_again") {
|
|
8760
|
-
const g = await Zi(a),
|
|
8761
|
-
if (l = !1,
|
|
8760
|
+
const g = await Zi(a), _ = o && l;
|
|
8761
|
+
if (l = !1, _ || (a._currentTurn++, a._currentTurnPersistedItemCount = 0), a._currentTurn > a._maxTurns)
|
|
8762
8762
|
throw (p = a._currentAgentSpan) == null || p.setError({
|
|
8763
8763
|
message: "Max turns exceeded",
|
|
8764
8764
|
data: { max_turns: a._maxTurns }
|
|
8765
8765
|
}), new ui(`Max turns (${a._maxTurns}) exceeded`, a);
|
|
8766
8766
|
F.debug(`Running agent ${a._currentAgent.name} (turn ${a._currentTurn})`);
|
|
8767
|
-
let
|
|
8768
|
-
if (a._currentTurn === 1 && !
|
|
8769
|
-
const
|
|
8770
|
-
|
|
8767
|
+
let T;
|
|
8768
|
+
if (a._currentTurn === 1 && !_) {
|
|
8769
|
+
const N = z(this, ie, dr).call(this, a);
|
|
8770
|
+
N.blocking.length > 0 && await z(this, ie, yn).call(this, a, N.blocking), N.parallel.length > 0 && (T = z(this, ie, yn).call(this, a, N.parallel), T.catch(() => {
|
|
8771
8771
|
}));
|
|
8772
8772
|
}
|
|
8773
8773
|
const y = u ? u.prepareInput(a._originalInput, a._generatedItems) : Vt(a._originalInput, a._generatedItems);
|
|
@@ -8789,10 +8789,10 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8789
8789
|
tracing: zi(this.config.tracingDisabled, this.config.traceIncludeSensitiveData),
|
|
8790
8790
|
signal: r.signal
|
|
8791
8791
|
}), a._modelResponses.push(a._lastTurnResponse), a._context.usage.add(a._lastTurnResponse.usage), a._noActiveAgentRun = !1, u == null || u.trackServerItems(a._lastTurnResponse);
|
|
8792
|
-
const
|
|
8793
|
-
a._lastProcessedResponse =
|
|
8794
|
-
const
|
|
8795
|
-
a._toolUseTracker.addToolUse(a._currentAgent, a._lastProcessedResponse.toolsUsed), a._originalInput =
|
|
8792
|
+
const v = ki(a._lastTurnResponse, a._currentAgent, h.tools, h.handoffs);
|
|
8793
|
+
a._lastProcessedResponse = v;
|
|
8794
|
+
const b = await Ci(a._currentAgent, a._originalInput, a._generatedItems, a._lastTurnResponse, a._lastProcessedResponse, this, a);
|
|
8795
|
+
a._toolUseTracker.addToolUse(a._currentAgent, a._lastProcessedResponse.toolsUsed), a._originalInput = b.originalInput, a._generatedItems = b.generatedItems, b.nextStep.type === "next_step_run_again" && (a._currentTurnPersistedItemCount = 0), a._currentStep = b.nextStep, T && await T;
|
|
8796
8796
|
}
|
|
8797
8797
|
if (a._currentStep && a._currentStep.type === "next_step_final_output")
|
|
8798
8798
|
return await z(this, ie, pr).call(this, a, a._currentStep.output), this.emit("agent_end", a._context, a._currentAgent, a._currentStep.output), a._currentAgent.emit("agent_end", a._context, a._currentStep.output), new Bs(a);
|
|
@@ -8820,7 +8820,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8820
8820
|
}
|
|
8821
8821
|
});
|
|
8822
8822
|
}, io = async function(t, s, r, i, o) {
|
|
8823
|
-
var g,
|
|
8823
|
+
var g, _, T, y;
|
|
8824
8824
|
const a = !!s.conversationId || !!s.previousResponseId, u = a ? new Bi({
|
|
8825
8825
|
conversationId: s.conversationId,
|
|
8826
8826
|
previousResponseId: s.previousResponseId
|
|
@@ -8843,36 +8843,36 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8843
8843
|
}, t.state._currentStep.type === "next_step_interruption") {
|
|
8844
8844
|
if (F.debug("Continuing from interruption"), !t.state._lastTurnResponse || !t.state._lastProcessedResponse)
|
|
8845
8845
|
throw new ne("No model response found in previous state", t.state);
|
|
8846
|
-
const
|
|
8847
|
-
if (Oi(t,
|
|
8848
|
-
t.state._currentStep =
|
|
8846
|
+
const v = await Ai(t.state._currentAgent, t.state._originalInput, t.state._generatedItems, t.state._lastTurnResponse, t.state._lastProcessedResponse, this, t.state);
|
|
8847
|
+
if (Oi(t, v), t.state._toolUseTracker.addToolUse(t.state._currentAgent, t.state._lastProcessedResponse.toolsUsed), t.state._originalInput = v.originalInput, t.state._generatedItems = v.generatedItems, v.nextStep.type === "next_step_interruption") {
|
|
8848
|
+
t.state._currentStep = v.nextStep;
|
|
8849
8849
|
return;
|
|
8850
8850
|
}
|
|
8851
|
-
if (
|
|
8851
|
+
if (v.nextStep.type === "next_step_run_again") {
|
|
8852
8852
|
m = !0, t.state._currentStep = void 0;
|
|
8853
8853
|
continue;
|
|
8854
8854
|
}
|
|
8855
|
-
m = !1, t.state._currentStep =
|
|
8855
|
+
m = !1, t.state._currentStep = v.nextStep;
|
|
8856
8856
|
}
|
|
8857
8857
|
if (t.state._currentStep.type === "next_step_run_again") {
|
|
8858
|
-
const
|
|
8859
|
-
if (m = !1,
|
|
8858
|
+
const v = await Zi(t.state), b = r && m;
|
|
8859
|
+
if (m = !1, b || (t.state._currentTurn++, t.state._currentTurnPersistedItemCount = 0), t.state._currentTurn > t.state._maxTurns)
|
|
8860
8860
|
throw (g = t.state._currentAgentSpan) == null || g.setError({
|
|
8861
8861
|
message: "Max turns exceeded",
|
|
8862
8862
|
data: { max_turns: t.state._maxTurns }
|
|
8863
8863
|
}), new ui(`Max turns (${t.state._maxTurns}) exceeded`, t.state);
|
|
8864
8864
|
F.debug(`Running agent ${h.name} (turn ${t.state._currentTurn})`);
|
|
8865
|
-
let
|
|
8866
|
-
if (t.state._currentTurn === 1 && !
|
|
8865
|
+
let N, x;
|
|
8866
|
+
if (t.state._currentTurn === 1 && !b) {
|
|
8867
8867
|
const Y = z(this, ie, dr).call(this, t.state);
|
|
8868
|
-
Y.blocking.length > 0 && await z(this, ie, yn).call(this, t.state, Y.blocking), Y.parallel.length > 0 && (
|
|
8868
|
+
Y.blocking.length > 0 && await z(this, ie, yn).call(this, t.state, Y.blocking), Y.parallel.length > 0 && (x = z(this, ie, yn).call(this, t.state, Y.parallel).catch((Ee) => (N = Ee, [])));
|
|
8869
8869
|
}
|
|
8870
8870
|
const A = u ? u.prepareInput(t.input, t.newItems) : Vt(t.input, t.newItems);
|
|
8871
8871
|
t.state._noActiveAgentRun && (h.emit("agent_start", t.state._context, h, A), this.emit("agent_start", t.state._context, h, A));
|
|
8872
8872
|
let D;
|
|
8873
|
-
const U = await z(this, ie, fr).call(this, t.state, s,
|
|
8874
|
-
if (
|
|
8875
|
-
throw
|
|
8873
|
+
const U = await z(this, ie, fr).call(this, t.state, s, v, A, u, o);
|
|
8874
|
+
if (N)
|
|
8875
|
+
throw N;
|
|
8876
8876
|
l = !0, await d();
|
|
8877
8877
|
for await (const Y of U.model.getStreamedResponse({
|
|
8878
8878
|
systemInstructions: U.modelInput.instructions,
|
|
@@ -8890,8 +8890,8 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8890
8890
|
tracing: zi(this.config.tracingDisabled, this.config.traceIncludeSensitiveData),
|
|
8891
8891
|
signal: s.signal
|
|
8892
8892
|
})) {
|
|
8893
|
-
if (
|
|
8894
|
-
throw
|
|
8893
|
+
if (N)
|
|
8894
|
+
throw N;
|
|
8895
8895
|
if (Y.type === "response_done") {
|
|
8896
8896
|
const oe = Za.parse(Y);
|
|
8897
8897
|
D = {
|
|
@@ -8904,8 +8904,8 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8904
8904
|
return;
|
|
8905
8905
|
t._addItem(new Bl(Y));
|
|
8906
8906
|
}
|
|
8907
|
-
if (
|
|
8908
|
-
throw
|
|
8907
|
+
if (x && (await x, N))
|
|
8908
|
+
throw N;
|
|
8909
8909
|
if (t.state._noActiveAgentRun = !1, !D)
|
|
8910
8910
|
throw new we("Model did not produce a final response!", t.state);
|
|
8911
8911
|
t.state._lastTurnResponse = D, u == null || u.trackServerItems(D), t.state._modelResponses.push(t.state._lastTurnResponse);
|
|
@@ -8924,7 +8924,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8924
8924
|
} else if (t.state._currentStep.type === "next_step_interruption") {
|
|
8925
8925
|
await d(), a || await Ri(s.session, t);
|
|
8926
8926
|
return;
|
|
8927
|
-
} else t.state._currentStep.type === "next_step_handoff" ? (t.state._currentAgent = (
|
|
8927
|
+
} else t.state._currentStep.type === "next_step_handoff" ? (t.state._currentAgent = (_ = t.state._currentStep) == null ? void 0 : _.newAgent, t.state._currentAgentSpan && (t.state._currentAgentSpan.end(), _n()), t.state._currentAgentSpan = void 0, t._addItem(new ql(t.state._currentAgent)), t.state._noActiveAgentRun = !0, t.state._currentStep = {
|
|
8928
8928
|
type: "next_step_run_again"
|
|
8929
8929
|
}) : F.debug("Running next loop");
|
|
8930
8930
|
}
|
|
@@ -8934,7 +8934,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8934
8934
|
data: { error: String(h) }
|
|
8935
8935
|
}), h;
|
|
8936
8936
|
} finally {
|
|
8937
|
-
if (((
|
|
8937
|
+
if (((T = t.state._currentStep) == null ? void 0 : T.type) !== "next_step_interruption")
|
|
8938
8938
|
try {
|
|
8939
8939
|
await vi({ runContext: t.state._context });
|
|
8940
8940
|
} catch (h) {
|
|
@@ -8944,7 +8944,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
8944
8944
|
}
|
|
8945
8945
|
}, ao = async function(t, s, r, i, o) {
|
|
8946
8946
|
return r = r ?? {}, mr(async () => {
|
|
8947
|
-
const a = s instanceof Ve, u = a ? s : new Ve(r.context instanceof
|
|
8947
|
+
const a = s instanceof Ve, u = a ? s : new Ve(r.context instanceof Zt ? r.context : new Zt(r.context), s, t, r.maxTurns ?? Li), l = new uo({
|
|
8948
8948
|
signal: r.signal,
|
|
8949
8949
|
state: u
|
|
8950
8950
|
});
|
|
@@ -9016,9 +9016,9 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
9016
9016
|
...t._currentAgent.modelSettings
|
|
9017
9017
|
};
|
|
9018
9018
|
p = Cd(l, t._currentAgent.modelSettings, u, p), p = Wl(t._currentAgent, t._toolUseTracker, p);
|
|
9019
|
-
const d = await t._currentAgent.getSystemPrompt(t._context), m = await t._currentAgent.getPrompt(t._context), { modelInput: g, sourceItems:
|
|
9020
|
-
o == null || o.markInputAsSent(
|
|
9021
|
-
const h = (o == null ? void 0 : o.previousResponseId) ?? s.previousResponseId,
|
|
9019
|
+
const d = await t._currentAgent.getSystemPrompt(t._context), m = await t._currentAgent.getPrompt(t._context), { modelInput: g, sourceItems: _, persistedItems: T, filterApplied: y } = await Ad(t._currentAgent, s.callModelInputFilter, t._context, i, d);
|
|
9020
|
+
o == null || o.markInputAsSent(_), a == null || a(_, y ? T : void 0);
|
|
9021
|
+
const h = (o == null ? void 0 : o.previousResponseId) ?? s.previousResponseId, v = (o == null ? void 0 : o.conversationId) ?? s.conversationId;
|
|
9022
9022
|
return {
|
|
9023
9023
|
...r,
|
|
9024
9024
|
model: u,
|
|
@@ -9027,7 +9027,7 @@ ie = new WeakSet(), lr = function(t) {
|
|
|
9027
9027
|
modelInput: g,
|
|
9028
9028
|
prompt: m,
|
|
9029
9029
|
previousResponseId: h,
|
|
9030
|
-
conversationId:
|
|
9030
|
+
conversationId: v
|
|
9031
9031
|
};
|
|
9032
9032
|
};
|
|
9033
9033
|
function Vt(n, e) {
|
|
@@ -9042,17 +9042,17 @@ function zi(n, e) {
|
|
|
9042
9042
|
return n ? !1 : e ? !0 : "enabled_without_data";
|
|
9043
9043
|
}
|
|
9044
9044
|
async function Ad(n, e, t, s, r) {
|
|
9045
|
-
const i = (g,
|
|
9046
|
-
const y = structuredClone(
|
|
9047
|
-
return
|
|
9045
|
+
const i = (g, _) => g.map((T) => {
|
|
9046
|
+
const y = structuredClone(T);
|
|
9047
|
+
return _ && y && typeof y == "object" && _.set(y, T), y;
|
|
9048
9048
|
}), o = /* @__PURE__ */ new WeakMap(), a = Od(s), u = [];
|
|
9049
9049
|
for (const g of s)
|
|
9050
9050
|
g && typeof g == "object" && u.push(g);
|
|
9051
9051
|
const l = (g) => {
|
|
9052
9052
|
if (!g || typeof g != "object")
|
|
9053
9053
|
return;
|
|
9054
|
-
const
|
|
9055
|
-
|
|
9054
|
+
const _ = u.findIndex((T) => T === g);
|
|
9055
|
+
_ !== -1 && u.splice(_, 1);
|
|
9056
9056
|
}, p = () => {
|
|
9057
9057
|
const g = u.shift();
|
|
9058
9058
|
return g && qi(a, g), g;
|
|
@@ -9075,26 +9075,26 @@ async function Ad(n, e, t, s, r) {
|
|
|
9075
9075
|
});
|
|
9076
9076
|
if (!g || !Array.isArray(g.input))
|
|
9077
9077
|
throw new ne("callModelInputFilter must return a ModelInputData object with an input array.");
|
|
9078
|
-
const
|
|
9078
|
+
const _ = g.input.map((y) => {
|
|
9079
9079
|
if (!y || typeof y != "object")
|
|
9080
9080
|
return;
|
|
9081
9081
|
const h = o.get(y);
|
|
9082
9082
|
if (h)
|
|
9083
9083
|
return l(h), qi(a, h), h;
|
|
9084
|
-
const
|
|
9085
|
-
if (
|
|
9086
|
-
return l(
|
|
9087
|
-
const
|
|
9088
|
-
if (
|
|
9089
|
-
return
|
|
9090
|
-
}),
|
|
9084
|
+
const v = wt(y), b = Ed(a, v);
|
|
9085
|
+
if (b)
|
|
9086
|
+
return l(b), b;
|
|
9087
|
+
const N = p();
|
|
9088
|
+
if (N)
|
|
9089
|
+
return N;
|
|
9090
|
+
}), T = i(g.input);
|
|
9091
9091
|
return {
|
|
9092
9092
|
modelInput: {
|
|
9093
|
-
input:
|
|
9093
|
+
input: T,
|
|
9094
9094
|
instructions: typeof g.instructions > "u" ? r : g.instructions
|
|
9095
9095
|
},
|
|
9096
|
-
sourceItems:
|
|
9097
|
-
persistedItems:
|
|
9096
|
+
sourceItems: _,
|
|
9097
|
+
persistedItems: T.map((y) => structuredClone(y)),
|
|
9098
9098
|
filterApplied: !0
|
|
9099
9099
|
};
|
|
9100
9100
|
} catch (g) {
|
|
@@ -9109,18 +9109,18 @@ class Bi {
|
|
|
9109
9109
|
// Conversation ID:
|
|
9110
9110
|
// - https://platform.openai.com/docs/guides/conversation-state?api-mode=responses#using-the-conversations-api
|
|
9111
9111
|
// - https://platform.openai.com/docs/api-reference/conversations/create
|
|
9112
|
-
|
|
9112
|
+
S(this, "conversationId");
|
|
9113
9113
|
// Previous Response ID:
|
|
9114
9114
|
// https://platform.openai.com/docs/guides/conversation-state?api-mode=responses#passing-context-from-the-previous-response
|
|
9115
|
-
|
|
9115
|
+
S(this, "previousResponseId");
|
|
9116
9116
|
// Using this flag because WeakSet does not provide a way to check its size
|
|
9117
|
-
|
|
9117
|
+
S(this, "sentInitialInput", !1);
|
|
9118
9118
|
// The items already sent to the model; using WeakSet for memory efficiency
|
|
9119
|
-
|
|
9119
|
+
S(this, "sentItems", /* @__PURE__ */ new WeakSet());
|
|
9120
9120
|
// The items received from the server; using WeakSet for memory efficiency
|
|
9121
|
-
|
|
9121
|
+
S(this, "serverItems", /* @__PURE__ */ new WeakSet());
|
|
9122
9122
|
// Track initial input items that have not yet been sent so they can be retried on later turns.
|
|
9123
|
-
|
|
9123
|
+
S(this, "remainingInitialInput", null);
|
|
9124
9124
|
this.conversationId = e ?? void 0, this.previousResponseId = t ?? void 0;
|
|
9125
9125
|
}
|
|
9126
9126
|
/**
|
|
@@ -9225,13 +9225,13 @@ async function Zi(n) {
|
|
|
9225
9225
|
toolsExplicitlyProvided: n._currentAgent.hasExplicitToolConfig()
|
|
9226
9226
|
};
|
|
9227
9227
|
}
|
|
9228
|
-
function
|
|
9228
|
+
function wt(n) {
|
|
9229
9229
|
return JSON.stringify(n, Rd);
|
|
9230
9230
|
}
|
|
9231
9231
|
function Od(n) {
|
|
9232
9232
|
const e = /* @__PURE__ */ new Map();
|
|
9233
9233
|
for (const t of n) {
|
|
9234
|
-
const s =
|
|
9234
|
+
const s = wt(t), r = e.get(s);
|
|
9235
9235
|
r ? r.push(t) : e.set(s, [t]);
|
|
9236
9236
|
}
|
|
9237
9237
|
return e;
|
|
@@ -9244,7 +9244,7 @@ function Ed(n, e) {
|
|
|
9244
9244
|
return t.shift(), t.length === 0 && n.delete(e), s;
|
|
9245
9245
|
}
|
|
9246
9246
|
function qi(n, e) {
|
|
9247
|
-
const t =
|
|
9247
|
+
const t = wt(e), s = n.get(t);
|
|
9248
9248
|
if (!s || s.length === 0)
|
|
9249
9249
|
return;
|
|
9250
9250
|
const r = s.findIndex((i) => i === e);
|
|
@@ -9280,7 +9280,7 @@ function hr(n) {
|
|
|
9280
9280
|
}
|
|
9281
9281
|
class oo {
|
|
9282
9282
|
constructor(e) {
|
|
9283
|
-
|
|
9283
|
+
S(this, "state");
|
|
9284
9284
|
this.state = e;
|
|
9285
9285
|
}
|
|
9286
9286
|
/**
|
|
@@ -9371,42 +9371,42 @@ class Bs extends oo {
|
|
|
9371
9371
|
super(e);
|
|
9372
9372
|
}
|
|
9373
9373
|
}
|
|
9374
|
-
var En, at, Te, He, Kt, Yt, Rn,
|
|
9374
|
+
var En, at, Te, He, Kt, Yt, Rn, St, Nn;
|
|
9375
9375
|
class uo extends oo {
|
|
9376
9376
|
constructor(t = {}) {
|
|
9377
9377
|
super(t.state);
|
|
9378
9378
|
/**
|
|
9379
9379
|
* The current turn number
|
|
9380
9380
|
*/
|
|
9381
|
-
|
|
9381
|
+
S(this, "currentTurn", 0);
|
|
9382
9382
|
/**
|
|
9383
9383
|
* The maximum number of turns that can be run
|
|
9384
9384
|
*/
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9385
|
+
S(this, "maxTurns");
|
|
9386
|
+
R(this, En, null);
|
|
9387
|
+
R(this, at);
|
|
9388
|
+
R(this, Te);
|
|
9389
|
+
R(this, He);
|
|
9390
|
+
R(this, Kt);
|
|
9391
|
+
R(this, Yt);
|
|
9392
|
+
R(this, Rn);
|
|
9393
|
+
R(this, St, !1);
|
|
9394
|
+
R(this, Nn);
|
|
9395
9395
|
if (k(this, at, t.signal), k(this, He, new Pc({
|
|
9396
9396
|
start: (s) => {
|
|
9397
9397
|
k(this, Te, s);
|
|
9398
9398
|
},
|
|
9399
9399
|
cancel: () => {
|
|
9400
|
-
k(this,
|
|
9400
|
+
k(this, St, !0);
|
|
9401
9401
|
}
|
|
9402
9402
|
})), k(this, Kt, new Promise((s, r) => {
|
|
9403
9403
|
k(this, Yt, s), k(this, Rn, r);
|
|
9404
9404
|
})), c(this, at)) {
|
|
9405
9405
|
const s = () => {
|
|
9406
9406
|
var i, o;
|
|
9407
|
-
if (c(this,
|
|
9407
|
+
if (c(this, St))
|
|
9408
9408
|
return;
|
|
9409
|
-
k(this,
|
|
9409
|
+
k(this, St, !0);
|
|
9410
9410
|
const r = c(this, Te);
|
|
9411
9411
|
if (k(this, Te, void 0), c(this, He).locked) {
|
|
9412
9412
|
if (r)
|
|
@@ -9460,7 +9460,7 @@ class uo extends oo {
|
|
|
9460
9460
|
* Returns true if the stream has been cancelled.
|
|
9461
9461
|
*/
|
|
9462
9462
|
get cancelled() {
|
|
9463
|
-
return c(this,
|
|
9463
|
+
return c(this, St);
|
|
9464
9464
|
}
|
|
9465
9465
|
/**
|
|
9466
9466
|
* Returns the underlying readable stream.
|
|
@@ -9513,7 +9513,7 @@ class uo extends oo {
|
|
|
9513
9513
|
return c(this, Nn);
|
|
9514
9514
|
}
|
|
9515
9515
|
}
|
|
9516
|
-
En = new WeakMap(), at = new WeakMap(), Te = new WeakMap(), He = new WeakMap(), Kt = new WeakMap(), Yt = new WeakMap(), Rn = new WeakMap(),
|
|
9516
|
+
En = new WeakMap(), at = new WeakMap(), Te = new WeakMap(), He = new WeakMap(), Kt = new WeakMap(), Yt = new WeakMap(), Rn = new WeakMap(), St = new WeakMap(), Nn = new WeakMap();
|
|
9517
9517
|
let Ji;
|
|
9518
9518
|
function Ze() {
|
|
9519
9519
|
return Ji ?? (Ji = new Mc()), Ji;
|
|
@@ -9594,7 +9594,7 @@ class Md {
|
|
|
9594
9594
|
t.type === "trace" ? console.log(`[Exporter] Export trace traceId=${t.traceId} name=${t.name}${t.groupId ? ` groupId=${t.groupId}` : ""}`) : console.log(`[Exporter] Export span: ${JSON.stringify(t)}`);
|
|
9595
9595
|
}
|
|
9596
9596
|
}
|
|
9597
|
-
var Pn, Xt, Dn, Mn, Qt, ge, We, ot, ut, en, Ie, gr, yr,
|
|
9597
|
+
var Pn, Xt, Dn, Mn, Qt, ge, We, ot, ut, en, Ie, gr, yr, Bt;
|
|
9598
9598
|
class Fd {
|
|
9599
9599
|
constructor(e, {
|
|
9600
9600
|
maxQueueSize: t = 1e3,
|
|
@@ -9603,17 +9603,17 @@ class Fd {
|
|
|
9603
9603
|
// 5 seconds
|
|
9604
9604
|
exportTriggerRatio: i = 0.8
|
|
9605
9605
|
} = {}) {
|
|
9606
|
-
|
|
9607
|
-
|
|
9608
|
-
|
|
9609
|
-
|
|
9610
|
-
|
|
9611
|
-
|
|
9612
|
-
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9606
|
+
R(this, Ie);
|
|
9607
|
+
R(this, Pn);
|
|
9608
|
+
R(this, Xt);
|
|
9609
|
+
R(this, Dn);
|
|
9610
|
+
R(this, Mn);
|
|
9611
|
+
R(this, Qt);
|
|
9612
|
+
R(this, ge, []);
|
|
9613
|
+
R(this, We);
|
|
9614
|
+
R(this, ot, null);
|
|
9615
|
+
R(this, ut, !1);
|
|
9616
|
+
R(this, en, null);
|
|
9617
9617
|
k(this, Pn, t), k(this, Xt, s), k(this, Dn, r), k(this, Mn, t * i), k(this, Qt, e), k(this, We, $c), F.debug("Automatic trace export loop is not supported in this environment. You need to manually call `getGlobalTraceProvider().forceFlush()` to export traces.");
|
|
9618
9618
|
}
|
|
9619
9619
|
start() {
|
|
@@ -9635,8 +9635,8 @@ class Fd {
|
|
|
9635
9635
|
var s;
|
|
9636
9636
|
(s = c(this, en)) == null || s.abort();
|
|
9637
9637
|
}, e), F.debug("Shutting down gracefully"); c(this, ge).length > 0; ) {
|
|
9638
|
-
if (F.debug(`Waiting for buffer to empty. Items left: ${c(this, ge).length}`), c(this, ut) || await z(this, Ie,
|
|
9639
|
-
F.debug("Timeout reached, force flushing"), await z(this, Ie,
|
|
9638
|
+
if (F.debug(`Waiting for buffer to empty. Items left: ${c(this, ge).length}`), c(this, ut) || await z(this, Ie, Bt).call(this, !0), (t = c(this, en)) != null && t.signal.aborted) {
|
|
9639
|
+
F.debug("Timeout reached, force flushing"), await z(this, Ie, Bt).call(this, !0);
|
|
9640
9640
|
break;
|
|
9641
9641
|
}
|
|
9642
9642
|
await new Promise((s) => c(this, We).setTimeout(s, 500));
|
|
@@ -9644,7 +9644,7 @@ class Fd {
|
|
|
9644
9644
|
F.debug("Buffer empty. Exiting"), c(this, We) && c(this, ot) && c(this, We).clearTimeout(c(this, ot));
|
|
9645
9645
|
}
|
|
9646
9646
|
async forceFlush() {
|
|
9647
|
-
c(this, ge).length > 0 && await z(this, Ie,
|
|
9647
|
+
c(this, ge).length > 0 && await z(this, Ie, Bt).call(this, !0);
|
|
9648
9648
|
}
|
|
9649
9649
|
}
|
|
9650
9650
|
Pn = new WeakMap(), Xt = new WeakMap(), Dn = new WeakMap(), Mn = new WeakMap(), Qt = new WeakMap(), ge = new WeakMap(), We = new WeakMap(), ot = new WeakMap(), ut = new WeakMap(), en = new WeakMap(), Ie = new WeakSet(), gr = async function(e) {
|
|
@@ -9652,12 +9652,12 @@ Pn = new WeakMap(), Xt = new WeakMap(), Dn = new WeakMap(), Mn = new WeakMap(),
|
|
|
9652
9652
|
F.error("Dropping trace because buffer is full");
|
|
9653
9653
|
return;
|
|
9654
9654
|
}
|
|
9655
|
-
c(this, ge).push(e), c(this, ge).length > c(this, Mn) && await z(this, Ie,
|
|
9655
|
+
c(this, ge).push(e), c(this, ge).length > c(this, Mn) && await z(this, Ie, Bt).call(this);
|
|
9656
9656
|
}, yr = function() {
|
|
9657
9657
|
k(this, ot, c(this, We).setTimeout(async () => {
|
|
9658
|
-
await z(this, Ie,
|
|
9658
|
+
await z(this, Ie, Bt).call(this), z(this, Ie, yr).call(this);
|
|
9659
9659
|
}, c(this, Dn))), typeof c(this, ot).unref == "function" && c(this, ot).unref();
|
|
9660
|
-
},
|
|
9660
|
+
}, Bt = async function(e = !1) {
|
|
9661
9661
|
if (c(this, ge).length !== 0) {
|
|
9662
9662
|
if (F.debug(`Exporting batches. Force: ${e}. Buffer size: ${c(this, ge).length}`), e || c(this, ge).length < c(this, Xt)) {
|
|
9663
9663
|
const t = [...c(this, ge)];
|
|
@@ -9671,7 +9671,7 @@ Pn = new WeakMap(), Xt = new WeakMap(), Dn = new WeakMap(), Mn = new WeakMap(),
|
|
|
9671
9671
|
var xe;
|
|
9672
9672
|
class $d {
|
|
9673
9673
|
constructor() {
|
|
9674
|
-
|
|
9674
|
+
R(this, xe, []);
|
|
9675
9675
|
}
|
|
9676
9676
|
start() {
|
|
9677
9677
|
for (const e of c(this, xe))
|
|
@@ -9731,20 +9731,20 @@ function Ud() {
|
|
|
9731
9731
|
function Ld(n) {
|
|
9732
9732
|
return Object.fromEntries(Object.entries(n).filter(([e]) => !e.startsWith("_")));
|
|
9733
9733
|
}
|
|
9734
|
-
var Fn, $n, jn, Un,
|
|
9734
|
+
var Fn, $n, jn, Un, Tt, ct, lt, xt, Ln;
|
|
9735
9735
|
const Lr = class Lr {
|
|
9736
9736
|
constructor(e, t) {
|
|
9737
|
-
|
|
9738
|
-
|
|
9739
|
-
|
|
9740
|
-
|
|
9741
|
-
|
|
9742
|
-
|
|
9743
|
-
|
|
9744
|
-
|
|
9745
|
-
|
|
9746
|
-
|
|
9747
|
-
k(this, $n, e.traceId), k(this, jn, e.spanId ?? Ud()), k(this, Fn, e.data), k(this,
|
|
9737
|
+
S(this, "type", "trace.span");
|
|
9738
|
+
R(this, Fn);
|
|
9739
|
+
R(this, $n);
|
|
9740
|
+
R(this, jn);
|
|
9741
|
+
R(this, Un);
|
|
9742
|
+
R(this, Tt);
|
|
9743
|
+
R(this, ct);
|
|
9744
|
+
R(this, lt);
|
|
9745
|
+
R(this, xt);
|
|
9746
|
+
R(this, Ln);
|
|
9747
|
+
k(this, $n, e.traceId), k(this, jn, e.spanId ?? Ud()), k(this, Fn, e.data), k(this, Tt, t), k(this, Un, e.parentId ?? null), k(this, xt, e.error ?? null), k(this, ct, e.startedAt ?? null), k(this, lt, e.endedAt ?? null);
|
|
9748
9748
|
}
|
|
9749
9749
|
get traceId() {
|
|
9750
9750
|
return c(this, $n);
|
|
@@ -9769,20 +9769,20 @@ const Lr = class Lr {
|
|
|
9769
9769
|
F.warn("Span already started");
|
|
9770
9770
|
return;
|
|
9771
9771
|
}
|
|
9772
|
-
k(this, ct, Gi()), c(this,
|
|
9772
|
+
k(this, ct, Gi()), c(this, Tt).onSpanStart(this);
|
|
9773
9773
|
}
|
|
9774
9774
|
end() {
|
|
9775
9775
|
if (c(this, lt)) {
|
|
9776
9776
|
F.debug("Span already finished", this.spanData);
|
|
9777
9777
|
return;
|
|
9778
9778
|
}
|
|
9779
|
-
k(this, lt, Gi()), c(this,
|
|
9779
|
+
k(this, lt, Gi()), c(this, Tt).onSpanEnd(this);
|
|
9780
9780
|
}
|
|
9781
9781
|
setError(e) {
|
|
9782
|
-
k(this,
|
|
9782
|
+
k(this, xt, e);
|
|
9783
9783
|
}
|
|
9784
9784
|
get error() {
|
|
9785
|
-
return c(this,
|
|
9785
|
+
return c(this, xt);
|
|
9786
9786
|
}
|
|
9787
9787
|
get startedAt() {
|
|
9788
9788
|
return c(this, ct);
|
|
@@ -9799,8 +9799,8 @@ const Lr = class Lr {
|
|
|
9799
9799
|
data: this.spanData,
|
|
9800
9800
|
startedAt: c(this, ct) ?? void 0,
|
|
9801
9801
|
endedAt: c(this, lt) ?? void 0,
|
|
9802
|
-
error: c(this,
|
|
9803
|
-
}, c(this,
|
|
9802
|
+
error: c(this, xt) ?? void 0
|
|
9803
|
+
}, c(this, Tt));
|
|
9804
9804
|
return e.previousSpan = (t = this.previousSpan) == null ? void 0 : t.clone(), e;
|
|
9805
9805
|
}
|
|
9806
9806
|
toJSON() {
|
|
@@ -9816,7 +9816,7 @@ const Lr = class Lr {
|
|
|
9816
9816
|
};
|
|
9817
9817
|
}
|
|
9818
9818
|
};
|
|
9819
|
-
Fn = new WeakMap(), $n = new WeakMap(), jn = new WeakMap(), Un = new WeakMap(),
|
|
9819
|
+
Fn = new WeakMap(), $n = new WeakMap(), jn = new WeakMap(), Un = new WeakMap(), Tt = new WeakMap(), ct = new WeakMap(), lt = new WeakMap(), xt = new WeakMap(), Ln = new WeakMap();
|
|
9820
9820
|
let Cn = Lr;
|
|
9821
9821
|
class rt extends Cn {
|
|
9822
9822
|
constructor(e, t) {
|
|
@@ -9835,13 +9835,13 @@ class rt extends Cn {
|
|
|
9835
9835
|
var tn, Ke;
|
|
9836
9836
|
const zr = class zr {
|
|
9837
9837
|
constructor(e, t) {
|
|
9838
|
-
|
|
9839
|
-
|
|
9840
|
-
|
|
9841
|
-
|
|
9842
|
-
|
|
9843
|
-
|
|
9844
|
-
|
|
9838
|
+
S(this, "type", "trace");
|
|
9839
|
+
S(this, "traceId");
|
|
9840
|
+
S(this, "name");
|
|
9841
|
+
S(this, "groupId", null);
|
|
9842
|
+
S(this, "metadata");
|
|
9843
|
+
R(this, tn);
|
|
9844
|
+
R(this, Ke);
|
|
9845
9845
|
this.traceId = e.traceId ?? po(), this.name = e.name ?? "Agent workflow", this.groupId = e.groupId ?? null, this.metadata = e.metadata ?? {}, k(this, tn, t ?? lo()), k(this, Ke, e.started ?? !1);
|
|
9846
9846
|
}
|
|
9847
9847
|
async start() {
|
|
@@ -9883,13 +9883,13 @@ class Js extends On {
|
|
|
9883
9883
|
return null;
|
|
9884
9884
|
}
|
|
9885
9885
|
}
|
|
9886
|
-
var me,
|
|
9886
|
+
var me, kt, xs, fo;
|
|
9887
9887
|
class zd {
|
|
9888
9888
|
constructor() {
|
|
9889
|
-
|
|
9890
|
-
|
|
9891
|
-
|
|
9892
|
-
k(this, me, new $d()), k(this,
|
|
9889
|
+
R(this, xs);
|
|
9890
|
+
R(this, me);
|
|
9891
|
+
R(this, kt);
|
|
9892
|
+
k(this, me, new $d()), k(this, kt, ba.disabled), z(this, xs, fo).call(this);
|
|
9893
9893
|
}
|
|
9894
9894
|
/**
|
|
9895
9895
|
* Add a processor to the list of processors. Each processor will receive all traces/spans.
|
|
@@ -9919,19 +9919,19 @@ class zd {
|
|
|
9919
9919
|
return An();
|
|
9920
9920
|
}
|
|
9921
9921
|
setDisabled(e) {
|
|
9922
|
-
k(this,
|
|
9922
|
+
k(this, kt, e);
|
|
9923
9923
|
}
|
|
9924
9924
|
startExportLoop() {
|
|
9925
9925
|
c(this, me).start();
|
|
9926
9926
|
}
|
|
9927
9927
|
createTrace(e) {
|
|
9928
|
-
if (c(this,
|
|
9928
|
+
if (c(this, kt))
|
|
9929
9929
|
return F.debug("Tracing is disabled, Not creating trace %o", e), new Js();
|
|
9930
9930
|
const t = e.traceId ?? po(), s = e.name ?? "Agent workflow";
|
|
9931
9931
|
return F.debug("Creating trace %s with name %s", t, s), new On({ ...e, name: s, traceId: t }, c(this, me));
|
|
9932
9932
|
}
|
|
9933
9933
|
createSpan(e, t) {
|
|
9934
|
-
if (c(this,
|
|
9934
|
+
if (c(this, kt) || e.disabled)
|
|
9935
9935
|
return F.debug("Tracing is disabled, Not creating span %o", e), new rt(e.data, c(this, me));
|
|
9936
9936
|
let s, r;
|
|
9937
9937
|
if (t) {
|
|
@@ -9969,7 +9969,7 @@ class zd {
|
|
|
9969
9969
|
await c(this, me).forceFlush();
|
|
9970
9970
|
}
|
|
9971
9971
|
}
|
|
9972
|
-
me = new WeakMap(),
|
|
9972
|
+
me = new WeakMap(), kt = new WeakMap(), xs = new WeakSet(), /** Adds listeners to `process` to ensure `shutdown` occurs before exit. */
|
|
9973
9973
|
fo = function() {
|
|
9974
9974
|
if (typeof process < "u" && typeof process.on == "function") {
|
|
9975
9975
|
const e = async () => {
|
|
@@ -10138,7 +10138,7 @@ class Xd extends st {
|
|
|
10138
10138
|
* The voice intended to be used by the agent. If another agent already spoke during the
|
|
10139
10139
|
* RealtimeSession, changing the voice during a handoff will fail.
|
|
10140
10140
|
*/
|
|
10141
|
-
|
|
10141
|
+
S(this, "voice");
|
|
10142
10142
|
this.voice = t.voice;
|
|
10143
10143
|
}
|
|
10144
10144
|
}
|
|
@@ -10235,42 +10235,42 @@ function rs(n) {
|
|
|
10235
10235
|
const e = String(n);
|
|
10236
10236
|
return e === "pcm16" ? { type: "audio/pcm", rate: 24e3 } : e === "g711_ulaw" ? { type: "audio/pcmu" } : e === "g711_alaw" ? { type: "audio/pcma" } : { type: "audio/pcm", rate: 24e3 };
|
|
10237
10237
|
}
|
|
10238
|
-
|
|
10238
|
+
w({
|
|
10239
10239
|
itemId: f()
|
|
10240
10240
|
});
|
|
10241
10241
|
const Yi = ye("role", [
|
|
10242
|
-
|
|
10242
|
+
w({
|
|
10243
10243
|
itemId: f(),
|
|
10244
10244
|
previousItemId: f().nullable().optional(),
|
|
10245
10245
|
type: I("message"),
|
|
10246
10246
|
role: I("system"),
|
|
10247
|
-
content: J(
|
|
10247
|
+
content: J(w({ type: I("input_text"), text: f() }))
|
|
10248
10248
|
}),
|
|
10249
|
-
|
|
10249
|
+
w({
|
|
10250
10250
|
itemId: f(),
|
|
10251
10251
|
previousItemId: f().nullable().optional(),
|
|
10252
10252
|
type: I("message"),
|
|
10253
10253
|
role: I("user"),
|
|
10254
10254
|
status: le(["in_progress", "completed"]),
|
|
10255
|
-
content: J(
|
|
10255
|
+
content: J(w({ type: I("input_text"), text: f() }).or(w({
|
|
10256
10256
|
type: I("input_audio"),
|
|
10257
10257
|
audio: f().nullable().optional(),
|
|
10258
10258
|
transcript: f().nullable()
|
|
10259
10259
|
})))
|
|
10260
10260
|
}),
|
|
10261
|
-
|
|
10261
|
+
w({
|
|
10262
10262
|
itemId: f(),
|
|
10263
10263
|
previousItemId: f().nullable().optional(),
|
|
10264
10264
|
type: I("message"),
|
|
10265
10265
|
role: I("assistant"),
|
|
10266
10266
|
status: le(["in_progress", "completed", "incomplete"]),
|
|
10267
|
-
content: J(
|
|
10267
|
+
content: J(w({ type: I("output_text"), text: f() }).or(w({
|
|
10268
10268
|
type: I("output_audio"),
|
|
10269
10269
|
audio: f().nullable().optional(),
|
|
10270
10270
|
transcript: f().nullable().optional()
|
|
10271
10271
|
})))
|
|
10272
10272
|
})
|
|
10273
|
-
]), Xi =
|
|
10273
|
+
]), Xi = w({
|
|
10274
10274
|
itemId: f(),
|
|
10275
10275
|
previousItemId: f().nullable().optional(),
|
|
10276
10276
|
type: I("function_call"),
|
|
@@ -10278,7 +10278,7 @@ const Yi = ye("role", [
|
|
|
10278
10278
|
arguments: f(),
|
|
10279
10279
|
name: f(),
|
|
10280
10280
|
output: f().nullable()
|
|
10281
|
-
}), Qi =
|
|
10281
|
+
}), Qi = w({
|
|
10282
10282
|
itemId: f(),
|
|
10283
10283
|
previousItemId: f().nullable().optional(),
|
|
10284
10284
|
type: le(["mcp_call", "mcp_tool_call"]),
|
|
@@ -10286,14 +10286,14 @@ const Yi = ye("role", [
|
|
|
10286
10286
|
arguments: f(),
|
|
10287
10287
|
name: f(),
|
|
10288
10288
|
output: f().nullable()
|
|
10289
|
-
}), rp =
|
|
10289
|
+
}), rp = w({
|
|
10290
10290
|
itemId: f(),
|
|
10291
10291
|
type: I("mcp_approval_request"),
|
|
10292
10292
|
serverLabel: f(),
|
|
10293
10293
|
name: f(),
|
|
10294
10294
|
arguments: se(f(), W()),
|
|
10295
|
-
approved:
|
|
10296
|
-
}), ke = Ia("openai-agents:realtime"), mo =
|
|
10295
|
+
approved: Pt().optional().nullable()
|
|
10296
|
+
}), ke = Ia("openai-agents:realtime"), mo = w({
|
|
10297
10297
|
id: f().optional().nullable(),
|
|
10298
10298
|
conversation_id: f().optional().nullable(),
|
|
10299
10299
|
max_output_tokens: E().or(I("inf")).optional().nullable(),
|
|
@@ -10303,21 +10303,21 @@ const Yi = ye("role", [
|
|
|
10303
10303
|
object: I("realtime.response").optional().nullable(),
|
|
10304
10304
|
output: J(W()).optional().nullable(),
|
|
10305
10305
|
// GA grouping: audio.output.{format,voice}
|
|
10306
|
-
audio:
|
|
10307
|
-
output:
|
|
10306
|
+
audio: w({
|
|
10307
|
+
output: w({
|
|
10308
10308
|
format: W().optional().nullable(),
|
|
10309
10309
|
voice: f().optional().nullable()
|
|
10310
10310
|
}).optional().nullable()
|
|
10311
10311
|
}).optional().nullable(),
|
|
10312
10312
|
status: le(["completed", "incomplete", "failed", "cancelled", "in_progress"]).optional().nullable(),
|
|
10313
10313
|
status_details: se(f(), W()).optional().nullable(),
|
|
10314
|
-
usage:
|
|
10314
|
+
usage: w({
|
|
10315
10315
|
input_tokens: E().optional(),
|
|
10316
10316
|
input_token_details: se(f(), W()).optional().nullable(),
|
|
10317
10317
|
output_tokens: E().optional(),
|
|
10318
10318
|
output_token_details: se(f(), W()).optional().nullable()
|
|
10319
10319
|
}).optional().nullable()
|
|
10320
|
-
}), ip =
|
|
10320
|
+
}), ip = w({
|
|
10321
10321
|
id: f().optional(),
|
|
10322
10322
|
audio: f().nullable().optional(),
|
|
10323
10323
|
text: f().nullable().optional(),
|
|
@@ -10329,7 +10329,7 @@ const Yi = ye("role", [
|
|
|
10329
10329
|
I("output_text"),
|
|
10330
10330
|
I("output_audio")
|
|
10331
10331
|
])
|
|
10332
|
-
}), fn =
|
|
10332
|
+
}), fn = w({
|
|
10333
10333
|
id: f().optional(),
|
|
10334
10334
|
arguments: f().optional(),
|
|
10335
10335
|
call_id: f().optional(),
|
|
@@ -10349,151 +10349,151 @@ const Yi = ye("role", [
|
|
|
10349
10349
|
"mcp_approval_response"
|
|
10350
10350
|
]).optional(),
|
|
10351
10351
|
approval_request_id: f().nullable().optional(),
|
|
10352
|
-
approve:
|
|
10352
|
+
approve: Pt().nullable().optional(),
|
|
10353
10353
|
reason: f().nullable().optional(),
|
|
10354
10354
|
server_label: f().optional(),
|
|
10355
10355
|
error: W().nullable().optional(),
|
|
10356
|
-
tools: J(
|
|
10356
|
+
tools: J(w({
|
|
10357
10357
|
name: f(),
|
|
10358
10358
|
description: f(),
|
|
10359
10359
|
input_schema: se(W()).optional()
|
|
10360
10360
|
}).passthrough()).optional()
|
|
10361
|
-
}).passthrough(), ap =
|
|
10361
|
+
}).passthrough(), ap = w({
|
|
10362
10362
|
type: I("conversation.created"),
|
|
10363
10363
|
event_id: f(),
|
|
10364
|
-
conversation:
|
|
10364
|
+
conversation: w({
|
|
10365
10365
|
id: f().optional(),
|
|
10366
10366
|
object: I("realtime.conversation").optional()
|
|
10367
10367
|
})
|
|
10368
|
-
}), op =
|
|
10368
|
+
}), op = w({
|
|
10369
10369
|
type: I("conversation.item.added"),
|
|
10370
10370
|
event_id: f(),
|
|
10371
10371
|
item: fn,
|
|
10372
10372
|
previous_item_id: f().nullable().optional()
|
|
10373
|
-
}), up =
|
|
10373
|
+
}), up = w({
|
|
10374
10374
|
type: I("conversation.item.done"),
|
|
10375
10375
|
event_id: f(),
|
|
10376
10376
|
item: fn,
|
|
10377
10377
|
previous_item_id: f().nullable().optional()
|
|
10378
|
-
}), cp =
|
|
10378
|
+
}), cp = w({
|
|
10379
10379
|
type: I("conversation.item.deleted"),
|
|
10380
10380
|
event_id: f(),
|
|
10381
10381
|
item_id: f()
|
|
10382
|
-
}), lp =
|
|
10382
|
+
}), lp = w({
|
|
10383
10383
|
type: I("conversation.item.input_audio_transcription.completed"),
|
|
10384
10384
|
event_id: f(),
|
|
10385
10385
|
item_id: f(),
|
|
10386
10386
|
content_index: E(),
|
|
10387
10387
|
transcript: f(),
|
|
10388
10388
|
logprobs: J(W()).nullable().optional(),
|
|
10389
|
-
usage:
|
|
10389
|
+
usage: w({
|
|
10390
10390
|
type: I("tokens"),
|
|
10391
10391
|
total_tokens: E(),
|
|
10392
10392
|
input_tokens: E(),
|
|
10393
|
-
input_token_details:
|
|
10393
|
+
input_token_details: w({
|
|
10394
10394
|
text_tokens: E(),
|
|
10395
10395
|
audio_tokens: E()
|
|
10396
10396
|
}),
|
|
10397
10397
|
output_tokens: E()
|
|
10398
10398
|
}).optional()
|
|
10399
|
-
}), dp =
|
|
10399
|
+
}), dp = w({
|
|
10400
10400
|
type: I("conversation.item.input_audio_transcription.delta"),
|
|
10401
10401
|
event_id: f(),
|
|
10402
10402
|
item_id: f(),
|
|
10403
10403
|
content_index: E().optional(),
|
|
10404
10404
|
delta: f().optional(),
|
|
10405
10405
|
logprobs: J(W()).nullable().optional()
|
|
10406
|
-
}), pp =
|
|
10406
|
+
}), pp = w({
|
|
10407
10407
|
type: I("conversation.item.input_audio_transcription.failed"),
|
|
10408
10408
|
event_id: f(),
|
|
10409
10409
|
item_id: f(),
|
|
10410
10410
|
content_index: E(),
|
|
10411
|
-
error:
|
|
10411
|
+
error: w({
|
|
10412
10412
|
code: f().optional(),
|
|
10413
10413
|
message: f().optional(),
|
|
10414
10414
|
param: f().optional(),
|
|
10415
10415
|
type: f().optional()
|
|
10416
10416
|
})
|
|
10417
|
-
}), fp =
|
|
10417
|
+
}), fp = w({
|
|
10418
10418
|
type: I("conversation.item.retrieved"),
|
|
10419
10419
|
event_id: f(),
|
|
10420
10420
|
item: fn
|
|
10421
|
-
}), hp =
|
|
10421
|
+
}), hp = w({
|
|
10422
10422
|
type: I("conversation.item.truncated"),
|
|
10423
10423
|
event_id: f(),
|
|
10424
10424
|
item_id: f(),
|
|
10425
10425
|
audio_end_ms: E(),
|
|
10426
10426
|
content_index: E()
|
|
10427
|
-
}), mp =
|
|
10427
|
+
}), mp = w({
|
|
10428
10428
|
type: I("conversation.item.create"),
|
|
10429
10429
|
item: fn,
|
|
10430
10430
|
event_id: f().optional(),
|
|
10431
10431
|
previous_item_id: f().nullable().optional()
|
|
10432
|
-
}), gp =
|
|
10432
|
+
}), gp = w({
|
|
10433
10433
|
type: I("conversation.item.delete"),
|
|
10434
10434
|
item_id: f(),
|
|
10435
10435
|
event_id: f().optional()
|
|
10436
|
-
}), yp =
|
|
10436
|
+
}), yp = w({
|
|
10437
10437
|
type: I("conversation.item.retrieve"),
|
|
10438
10438
|
item_id: f(),
|
|
10439
10439
|
event_id: f().optional()
|
|
10440
|
-
}), _p =
|
|
10440
|
+
}), _p = w({
|
|
10441
10441
|
type: I("conversation.item.truncate"),
|
|
10442
10442
|
item_id: f(),
|
|
10443
10443
|
audio_end_ms: E(),
|
|
10444
10444
|
content_index: E(),
|
|
10445
10445
|
event_id: f().optional()
|
|
10446
|
-
}), vp =
|
|
10446
|
+
}), vp = w({
|
|
10447
10447
|
type: I("error"),
|
|
10448
10448
|
event_id: f().optional(),
|
|
10449
10449
|
error: W().optional()
|
|
10450
|
-
}), bp =
|
|
10450
|
+
}), bp = w({
|
|
10451
10451
|
type: I("input_audio_buffer.cleared"),
|
|
10452
10452
|
event_id: f()
|
|
10453
|
-
}), wp =
|
|
10453
|
+
}), wp = w({
|
|
10454
10454
|
type: I("input_audio_buffer.append"),
|
|
10455
10455
|
audio: f(),
|
|
10456
10456
|
event_id: f().optional()
|
|
10457
|
-
}), Ip =
|
|
10457
|
+
}), Ip = w({
|
|
10458
10458
|
type: I("input_audio_buffer.clear"),
|
|
10459
10459
|
event_id: f().optional()
|
|
10460
|
-
}), Sp =
|
|
10460
|
+
}), Sp = w({
|
|
10461
10461
|
type: I("input_audio_buffer.commit"),
|
|
10462
10462
|
event_id: f().optional()
|
|
10463
|
-
}), Tp =
|
|
10463
|
+
}), Tp = w({
|
|
10464
10464
|
type: I("input_audio_buffer.committed"),
|
|
10465
10465
|
event_id: f(),
|
|
10466
10466
|
item_id: f(),
|
|
10467
10467
|
previous_item_id: f().nullable().optional()
|
|
10468
|
-
}), xp =
|
|
10468
|
+
}), xp = w({
|
|
10469
10469
|
type: I("input_audio_buffer.speech_started"),
|
|
10470
10470
|
event_id: f(),
|
|
10471
10471
|
item_id: f(),
|
|
10472
10472
|
audio_start_ms: E()
|
|
10473
|
-
}), kp =
|
|
10473
|
+
}), kp = w({
|
|
10474
10474
|
type: I("input_audio_buffer.speech_stopped"),
|
|
10475
10475
|
event_id: f(),
|
|
10476
10476
|
item_id: f(),
|
|
10477
10477
|
audio_end_ms: E()
|
|
10478
|
-
}), Ap =
|
|
10478
|
+
}), Ap = w({
|
|
10479
10479
|
type: I("output_audio_buffer.started"),
|
|
10480
10480
|
event_id: f()
|
|
10481
|
-
}).passthrough(), Cp =
|
|
10481
|
+
}).passthrough(), Cp = w({
|
|
10482
10482
|
type: I("output_audio_buffer.stopped"),
|
|
10483
10483
|
event_id: f()
|
|
10484
|
-
}).passthrough(), Op =
|
|
10484
|
+
}).passthrough(), Op = w({
|
|
10485
10485
|
type: I("output_audio_buffer.cleared"),
|
|
10486
10486
|
event_id: f()
|
|
10487
|
-
}), Ep =
|
|
10487
|
+
}), Ep = w({
|
|
10488
10488
|
type: I("rate_limits.updated"),
|
|
10489
10489
|
event_id: f(),
|
|
10490
|
-
rate_limits: J(
|
|
10490
|
+
rate_limits: J(w({
|
|
10491
10491
|
limit: E().optional(),
|
|
10492
10492
|
name: le(["requests", "tokens"]).optional(),
|
|
10493
10493
|
remaining: E().optional(),
|
|
10494
10494
|
reset_seconds: E().optional()
|
|
10495
10495
|
}))
|
|
10496
|
-
}), Rp =
|
|
10496
|
+
}), Rp = w({
|
|
10497
10497
|
type: I("response.output_audio.delta"),
|
|
10498
10498
|
event_id: f(),
|
|
10499
10499
|
item_id: f(),
|
|
@@ -10501,14 +10501,14 @@ const Yi = ye("role", [
|
|
|
10501
10501
|
delta: f(),
|
|
10502
10502
|
output_index: E(),
|
|
10503
10503
|
response_id: f()
|
|
10504
|
-
}), Np =
|
|
10504
|
+
}), Np = w({
|
|
10505
10505
|
type: I("response.output_audio.done"),
|
|
10506
10506
|
event_id: f(),
|
|
10507
10507
|
item_id: f(),
|
|
10508
10508
|
content_index: E(),
|
|
10509
10509
|
output_index: E(),
|
|
10510
10510
|
response_id: f()
|
|
10511
|
-
}), Pp =
|
|
10511
|
+
}), Pp = w({
|
|
10512
10512
|
type: I("response.output_audio_transcript.delta"),
|
|
10513
10513
|
event_id: f(),
|
|
10514
10514
|
item_id: f(),
|
|
@@ -10516,7 +10516,7 @@ const Yi = ye("role", [
|
|
|
10516
10516
|
delta: f(),
|
|
10517
10517
|
output_index: E(),
|
|
10518
10518
|
response_id: f()
|
|
10519
|
-
}), Dp =
|
|
10519
|
+
}), Dp = w({
|
|
10520
10520
|
// GA may introduce response.output_audio_transcript.done
|
|
10521
10521
|
type: I("response.output_audio_transcript.done"),
|
|
10522
10522
|
event_id: f(),
|
|
@@ -10525,41 +10525,41 @@ const Yi = ye("role", [
|
|
|
10525
10525
|
transcript: f(),
|
|
10526
10526
|
output_index: E(),
|
|
10527
10527
|
response_id: f()
|
|
10528
|
-
}), Mp =
|
|
10528
|
+
}), Mp = w({
|
|
10529
10529
|
type: I("response.content_part.added"),
|
|
10530
10530
|
event_id: f(),
|
|
10531
10531
|
item_id: f(),
|
|
10532
10532
|
content_index: E(),
|
|
10533
10533
|
output_index: E(),
|
|
10534
10534
|
response_id: f(),
|
|
10535
|
-
part:
|
|
10535
|
+
part: w({
|
|
10536
10536
|
audio: f().optional(),
|
|
10537
10537
|
text: f().optional(),
|
|
10538
10538
|
transcript: f().optional(),
|
|
10539
10539
|
type: le(["text", "audio"]).optional()
|
|
10540
10540
|
})
|
|
10541
|
-
}), Fp =
|
|
10541
|
+
}), Fp = w({
|
|
10542
10542
|
type: I("response.content_part.done"),
|
|
10543
10543
|
event_id: f(),
|
|
10544
10544
|
item_id: f(),
|
|
10545
10545
|
content_index: E(),
|
|
10546
10546
|
output_index: E(),
|
|
10547
10547
|
response_id: f(),
|
|
10548
|
-
part:
|
|
10548
|
+
part: w({
|
|
10549
10549
|
audio: f().optional(),
|
|
10550
10550
|
text: f().optional(),
|
|
10551
10551
|
transcript: f().optional(),
|
|
10552
10552
|
type: le(["text", "audio"]).optional()
|
|
10553
10553
|
})
|
|
10554
|
-
}), $p =
|
|
10554
|
+
}), $p = w({
|
|
10555
10555
|
type: I("response.created"),
|
|
10556
10556
|
event_id: f(),
|
|
10557
10557
|
response: mo
|
|
10558
|
-
}), go =
|
|
10558
|
+
}), go = w({
|
|
10559
10559
|
type: I("response.done"),
|
|
10560
10560
|
event_id: f(),
|
|
10561
10561
|
response: mo
|
|
10562
|
-
}), jp =
|
|
10562
|
+
}), jp = w({
|
|
10563
10563
|
type: I("response.function_call_arguments.delta"),
|
|
10564
10564
|
event_id: f(),
|
|
10565
10565
|
item_id: f(),
|
|
@@ -10567,7 +10567,7 @@ const Yi = ye("role", [
|
|
|
10567
10567
|
delta: f(),
|
|
10568
10568
|
output_index: E(),
|
|
10569
10569
|
response_id: f()
|
|
10570
|
-
}), Up =
|
|
10570
|
+
}), Up = w({
|
|
10571
10571
|
type: I("response.function_call_arguments.done"),
|
|
10572
10572
|
event_id: f(),
|
|
10573
10573
|
item_id: f(),
|
|
@@ -10575,19 +10575,19 @@ const Yi = ye("role", [
|
|
|
10575
10575
|
arguments: f(),
|
|
10576
10576
|
output_index: E(),
|
|
10577
10577
|
response_id: f()
|
|
10578
|
-
}), Lp =
|
|
10578
|
+
}), Lp = w({
|
|
10579
10579
|
type: I("response.output_item.added"),
|
|
10580
10580
|
event_id: f(),
|
|
10581
10581
|
item: fn,
|
|
10582
10582
|
output_index: E(),
|
|
10583
10583
|
response_id: f()
|
|
10584
|
-
}), zp =
|
|
10584
|
+
}), zp = w({
|
|
10585
10585
|
type: I("response.output_item.done"),
|
|
10586
10586
|
event_id: f(),
|
|
10587
10587
|
item: fn,
|
|
10588
10588
|
output_index: E(),
|
|
10589
10589
|
response_id: f()
|
|
10590
|
-
}), Bp =
|
|
10590
|
+
}), Bp = w({
|
|
10591
10591
|
type: I("response.output_text.delta"),
|
|
10592
10592
|
event_id: f(),
|
|
10593
10593
|
item_id: f(),
|
|
@@ -10595,7 +10595,7 @@ const Yi = ye("role", [
|
|
|
10595
10595
|
delta: f(),
|
|
10596
10596
|
output_index: E(),
|
|
10597
10597
|
response_id: f()
|
|
10598
|
-
}), Zp =
|
|
10598
|
+
}), Zp = w({
|
|
10599
10599
|
// No rename specified for done; keep response.text.done
|
|
10600
10600
|
type: I("response.output_text.done"),
|
|
10601
10601
|
event_id: f(),
|
|
@@ -10604,35 +10604,35 @@ const Yi = ye("role", [
|
|
|
10604
10604
|
text: f(),
|
|
10605
10605
|
output_index: E(),
|
|
10606
10606
|
response_id: f()
|
|
10607
|
-
}), qp =
|
|
10607
|
+
}), qp = w({
|
|
10608
10608
|
type: I("session.created"),
|
|
10609
10609
|
event_id: f(),
|
|
10610
10610
|
session: W()
|
|
10611
|
-
}), Jp =
|
|
10611
|
+
}), Jp = w({
|
|
10612
10612
|
type: I("session.updated"),
|
|
10613
10613
|
event_id: f(),
|
|
10614
10614
|
session: W()
|
|
10615
|
-
}), Gp =
|
|
10615
|
+
}), Gp = w({
|
|
10616
10616
|
type: I("response.cancel"),
|
|
10617
10617
|
event_id: f().optional(),
|
|
10618
10618
|
response_id: f().optional()
|
|
10619
|
-
}), Vp =
|
|
10619
|
+
}), Vp = w({
|
|
10620
10620
|
type: I("response.create"),
|
|
10621
10621
|
event_id: f().optional(),
|
|
10622
10622
|
response: W().optional()
|
|
10623
|
-
}), Hp =
|
|
10623
|
+
}), Hp = w({
|
|
10624
10624
|
type: I("session.update"),
|
|
10625
10625
|
event_id: f().optional(),
|
|
10626
10626
|
session: W()
|
|
10627
|
-
}), Wp =
|
|
10627
|
+
}), Wp = w({
|
|
10628
10628
|
type: I("mcp_list_tools.in_progress"),
|
|
10629
10629
|
event_id: f().optional(),
|
|
10630
10630
|
item_id: f().optional()
|
|
10631
|
-
}), Kp =
|
|
10631
|
+
}), Kp = w({
|
|
10632
10632
|
type: I("mcp_list_tools.completed"),
|
|
10633
10633
|
event_id: f().optional(),
|
|
10634
10634
|
item_id: f().optional()
|
|
10635
|
-
}), Yp =
|
|
10635
|
+
}), Yp = w({
|
|
10636
10636
|
type: I("response.mcp_call_arguments.delta"),
|
|
10637
10637
|
event_id: f(),
|
|
10638
10638
|
response_id: f(),
|
|
@@ -10640,28 +10640,28 @@ const Yi = ye("role", [
|
|
|
10640
10640
|
output_index: E(),
|
|
10641
10641
|
delta: f(),
|
|
10642
10642
|
obfuscation: f()
|
|
10643
|
-
}), Xp =
|
|
10643
|
+
}), Xp = w({
|
|
10644
10644
|
type: I("response.mcp_call_arguments.done"),
|
|
10645
10645
|
event_id: f(),
|
|
10646
10646
|
response_id: f(),
|
|
10647
10647
|
item_id: f(),
|
|
10648
10648
|
output_index: E(),
|
|
10649
10649
|
arguments: f()
|
|
10650
|
-
}), Qp =
|
|
10650
|
+
}), Qp = w({
|
|
10651
10651
|
type: I("response.mcp_call.in_progress"),
|
|
10652
10652
|
event_id: f(),
|
|
10653
10653
|
output_index: E(),
|
|
10654
10654
|
item_id: f()
|
|
10655
|
-
}), ef =
|
|
10655
|
+
}), ef = w({
|
|
10656
10656
|
type: I("response.mcp_call.completed"),
|
|
10657
10657
|
event_id: f(),
|
|
10658
10658
|
output_index: E(),
|
|
10659
10659
|
item_id: f()
|
|
10660
|
-
}), tf =
|
|
10660
|
+
}), tf = w({
|
|
10661
10661
|
type: I("mcp_list_tools.failed"),
|
|
10662
10662
|
event_id: f().optional(),
|
|
10663
10663
|
item_id: f().optional()
|
|
10664
|
-
}), nf =
|
|
10664
|
+
}), nf = w({
|
|
10665
10665
|
type: f(),
|
|
10666
10666
|
event_id: f().optional().nullable()
|
|
10667
10667
|
}).passthrough(), sf = ye("type", [
|
|
@@ -10742,29 +10742,29 @@ const rf = "gpt-realtime", De = {
|
|
|
10742
10742
|
}
|
|
10743
10743
|
}
|
|
10744
10744
|
};
|
|
10745
|
-
var
|
|
10745
|
+
var At, zn, be, Bn;
|
|
10746
10746
|
const Br = class Br extends Ar {
|
|
10747
10747
|
constructor(t = {}) {
|
|
10748
10748
|
super();
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
|
|
10752
|
-
|
|
10753
|
-
|
|
10754
|
-
k(this,
|
|
10749
|
+
R(this, At);
|
|
10750
|
+
R(this, zn);
|
|
10751
|
+
R(this, be, null);
|
|
10752
|
+
R(this, Bn, null);
|
|
10753
|
+
S(this, "eventEmitter", new Cs());
|
|
10754
|
+
k(this, At, t.model ?? rf), k(this, zn, t.apiKey);
|
|
10755
10755
|
}
|
|
10756
10756
|
/**
|
|
10757
10757
|
* The current model that is being used by the transport layer.
|
|
10758
10758
|
*/
|
|
10759
10759
|
get currentModel() {
|
|
10760
|
-
return c(this,
|
|
10760
|
+
return c(this, At);
|
|
10761
10761
|
}
|
|
10762
10762
|
/**
|
|
10763
10763
|
* The current model that is being used by the transport layer.
|
|
10764
10764
|
* **Note**: The model cannot be changed mid conversation.
|
|
10765
10765
|
*/
|
|
10766
10766
|
set currentModel(t) {
|
|
10767
|
-
k(this,
|
|
10767
|
+
k(this, At, t);
|
|
10768
10768
|
}
|
|
10769
10769
|
/**
|
|
10770
10770
|
* Hook for subclasses to clean up transport-specific state when audio
|
|
@@ -10798,14 +10798,14 @@ const Br = class Br extends Ar {
|
|
|
10798
10798
|
ke.error("Error parsing response done event", d.error);
|
|
10799
10799
|
return;
|
|
10800
10800
|
}
|
|
10801
|
-
const m = ((i = d.data.response.usage) == null ? void 0 : i.input_tokens) ?? 0, g = ((o = d.data.response.usage) == null ? void 0 : o.output_tokens) ?? 0,
|
|
10801
|
+
const m = ((i = d.data.response.usage) == null ? void 0 : i.input_tokens) ?? 0, g = ((o = d.data.response.usage) == null ? void 0 : o.output_tokens) ?? 0, _ = m + g, T = new Qn({
|
|
10802
10802
|
inputTokens: m,
|
|
10803
10803
|
inputTokensDetails: ((a = d.data.response.usage) == null ? void 0 : a.input_token_details) ?? {},
|
|
10804
10804
|
outputTokens: g,
|
|
10805
10805
|
outputTokensDetails: ((u = d.data.response.usage) == null ? void 0 : u.output_token_details) ?? {},
|
|
10806
|
-
totalTokens:
|
|
10806
|
+
totalTokens: _
|
|
10807
10807
|
});
|
|
10808
|
-
this.emit("usage_update",
|
|
10808
|
+
this.emit("usage_update", T), this.emit("turn_done", {
|
|
10809
10809
|
type: "response_done",
|
|
10810
10810
|
response: {
|
|
10811
10811
|
id: d.data.response.id ?? "",
|
|
@@ -10815,7 +10815,7 @@ const Br = class Br extends Ar {
|
|
|
10815
10815
|
inputTokensDetails: ((l = d.data.response.usage) == null ? void 0 : l.input_token_details) ?? {},
|
|
10816
10816
|
outputTokens: g,
|
|
10817
10817
|
outputTokensDetails: ((p = d.data.response.usage) == null ? void 0 : p.output_token_details) ?? {},
|
|
10818
|
-
totalTokens:
|
|
10818
|
+
totalTokens: _
|
|
10819
10819
|
}
|
|
10820
10820
|
}
|
|
10821
10821
|
});
|
|
@@ -11011,21 +11011,21 @@ const Br = class Br extends Ar {
|
|
|
11011
11011
|
}, {}, { triggerResponse: s });
|
|
11012
11012
|
}
|
|
11013
11013
|
_getMergedSessionConfig(t) {
|
|
11014
|
-
var i, o, a, u, l, p, d, m, g,
|
|
11014
|
+
var i, o, a, u, l, p, d, m, g, _, T, y, h, v, b, N, x, A, D, U, G, L, ue, Y, oe, Ee, Pe, hn;
|
|
11015
11015
|
const s = sp(t), r = {
|
|
11016
11016
|
type: "realtime",
|
|
11017
11017
|
instructions: s.instructions,
|
|
11018
|
-
model: s.model ?? c(this,
|
|
11018
|
+
model: s.model ?? c(this, At),
|
|
11019
11019
|
output_modalities: s.outputModalities ?? De.outputModalities,
|
|
11020
11020
|
audio: {
|
|
11021
11021
|
input: {
|
|
11022
11022
|
format: ((o = (i = s.audio) == null ? void 0 : i.input) == null ? void 0 : o.format) ?? ((u = (a = De.audio) == null ? void 0 : a.input) == null ? void 0 : u.format),
|
|
11023
11023
|
noise_reduction: ((p = (l = s.audio) == null ? void 0 : l.input) == null ? void 0 : p.noiseReduction) ?? ((m = (d = De.audio) == null ? void 0 : d.input) == null ? void 0 : m.noiseReduction),
|
|
11024
|
-
transcription: ((
|
|
11025
|
-
turn_detection: Br.buildTurnDetectionConfig((
|
|
11024
|
+
transcription: ((_ = (g = s.audio) == null ? void 0 : g.input) == null ? void 0 : _.transcription) ?? ((y = (T = De.audio) == null ? void 0 : T.input) == null ? void 0 : y.transcription),
|
|
11025
|
+
turn_detection: Br.buildTurnDetectionConfig((v = (h = s.audio) == null ? void 0 : h.input) == null ? void 0 : v.turnDetection) ?? ((N = (b = De.audio) == null ? void 0 : b.input) == null ? void 0 : N.turnDetection)
|
|
11026
11026
|
},
|
|
11027
11027
|
output: {
|
|
11028
|
-
format: ((A = (
|
|
11028
|
+
format: ((A = (x = s.audio) == null ? void 0 : x.output) == null ? void 0 : A.format) ?? ((U = (D = De.audio) == null ? void 0 : D.output) == null ? void 0 : U.format),
|
|
11029
11029
|
voice: ((L = (G = s.audio) == null ? void 0 : G.output) == null ? void 0 : L.voice) ?? ((Y = (ue = De.audio) == null ? void 0 : ue.output) == null ? void 0 : Y.voice),
|
|
11030
11030
|
speed: ((Ee = (oe = s.audio) == null ? void 0 : oe.output) == null ? void 0 : Ee.speed) ?? ((hn = (Pe = De.audio) == null ? void 0 : Pe.output) == null ? void 0 : hn.speed)
|
|
11031
11031
|
}
|
|
@@ -11059,19 +11059,19 @@ const Br = class Br extends Ar {
|
|
|
11059
11059
|
static buildTurnDetectionConfig(t) {
|
|
11060
11060
|
if (typeof t > "u")
|
|
11061
11061
|
return;
|
|
11062
|
-
const { type: s, createResponse: r, create_response: i, eagerness: o, interruptResponse: a, interrupt_response: u, prefixPaddingMs: l, prefix_padding_ms: p, silenceDurationMs: d, silence_duration_ms: m, threshold: g, idleTimeoutMs:
|
|
11062
|
+
const { type: s, createResponse: r, create_response: i, eagerness: o, interruptResponse: a, interrupt_response: u, prefixPaddingMs: l, prefix_padding_ms: p, silenceDurationMs: d, silence_duration_ms: m, threshold: g, idleTimeoutMs: _, idle_timeout_ms: T, ...y } = t, h = {
|
|
11063
11063
|
type: s,
|
|
11064
11064
|
create_response: r || i,
|
|
11065
11065
|
eagerness: o,
|
|
11066
11066
|
interrupt_response: a || u,
|
|
11067
11067
|
prefix_padding_ms: l || p,
|
|
11068
11068
|
silence_duration_ms: d || m,
|
|
11069
|
-
idle_timeout_ms:
|
|
11069
|
+
idle_timeout_ms: _ || T,
|
|
11070
11070
|
threshold: g,
|
|
11071
11071
|
...y
|
|
11072
11072
|
};
|
|
11073
|
-
return Object.keys(h).forEach((
|
|
11074
|
-
h[
|
|
11073
|
+
return Object.keys(h).forEach((v) => {
|
|
11074
|
+
h[v] === void 0 && delete h[v];
|
|
11075
11075
|
}), Object.keys(h).length > 0 ? h : void 0;
|
|
11076
11076
|
}
|
|
11077
11077
|
/**
|
|
@@ -11241,7 +11241,7 @@ const Br = class Br extends Ar {
|
|
|
11241
11241
|
});
|
|
11242
11242
|
}
|
|
11243
11243
|
};
|
|
11244
|
-
|
|
11244
|
+
At = new WeakMap(), zn = new WeakMap(), be = new WeakMap(), Bn = new WeakMap();
|
|
11245
11245
|
let Ts = Br;
|
|
11246
11246
|
var Zn, te, qn, dt, Jn;
|
|
11247
11247
|
class af extends Ts {
|
|
@@ -11249,17 +11249,17 @@ class af extends Ts {
|
|
|
11249
11249
|
if (typeof RTCPeerConnection > "u")
|
|
11250
11250
|
throw new Error("WebRTC is not supported in this environment");
|
|
11251
11251
|
super(t);
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
11252
|
+
S(this, "options");
|
|
11253
|
+
R(this, Zn);
|
|
11254
|
+
R(this, te, {
|
|
11255
11255
|
status: "disconnected",
|
|
11256
11256
|
peerConnection: void 0,
|
|
11257
11257
|
dataChannel: void 0,
|
|
11258
11258
|
callId: void 0
|
|
11259
11259
|
});
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
|
|
11260
|
+
R(this, qn);
|
|
11261
|
+
R(this, dt, !1);
|
|
11262
|
+
R(this, Jn, !1);
|
|
11263
11263
|
this.options = t, k(this, Zn, t.baseUrl ?? "https://api.openai.com/v1/realtime/calls"), k(this, qn, t.useInsecureApiKey ?? !1);
|
|
11264
11264
|
}
|
|
11265
11265
|
/**
|
|
@@ -11313,8 +11313,8 @@ class af extends Ts {
|
|
|
11313
11313
|
model: this.currentModel
|
|
11314
11314
|
}, m = new URL(r);
|
|
11315
11315
|
let g = new RTCPeerConnection();
|
|
11316
|
-
const
|
|
11317
|
-
let
|
|
11316
|
+
const _ = g.createDataChannel("oai-events");
|
|
11317
|
+
let T;
|
|
11318
11318
|
const y = (A) => {
|
|
11319
11319
|
A.onconnectionstatechange = () => {
|
|
11320
11320
|
switch (A.connectionState) {
|
|
@@ -11329,18 +11329,18 @@ class af extends Ts {
|
|
|
11329
11329
|
y(g), k(this, te, {
|
|
11330
11330
|
status: "connecting",
|
|
11331
11331
|
peerConnection: g,
|
|
11332
|
-
dataChannel:
|
|
11333
|
-
callId:
|
|
11334
|
-
}), this.emit("connection_change", c(this, te).status),
|
|
11332
|
+
dataChannel: _,
|
|
11333
|
+
callId: T
|
|
11334
|
+
}), this.emit("connection_change", c(this, te).status), _.addEventListener("open", () => {
|
|
11335
11335
|
k(this, te, {
|
|
11336
11336
|
status: "connected",
|
|
11337
11337
|
peerConnection: g,
|
|
11338
|
-
dataChannel:
|
|
11339
|
-
callId:
|
|
11338
|
+
dataChannel: _,
|
|
11339
|
+
callId: T
|
|
11340
11340
|
}), this.updateSessionConfig(d), this.emit("connection_change", c(this, te).status), this._onOpen(), a();
|
|
11341
|
-
}),
|
|
11341
|
+
}), _.addEventListener("error", (A) => {
|
|
11342
11342
|
this.close(), this._onError(A), u(A);
|
|
11343
|
-
}),
|
|
11343
|
+
}), _.addEventListener("message", (A) => {
|
|
11344
11344
|
this._onMessage(A);
|
|
11345
11345
|
const { data: D, isGeneric: U } = Ur(A);
|
|
11346
11346
|
if (!(!D || U) && (D.type === "response.created" ? k(this, dt, !0) : D.type === "response.done" && k(this, dt, !1), D.type === "session.created")) {
|
|
@@ -11353,31 +11353,31 @@ class af extends Ts {
|
|
|
11353
11353
|
h.autoplay = !0, g.ontrack = (A) => {
|
|
11354
11354
|
h.srcObject = A.streams[0];
|
|
11355
11355
|
};
|
|
11356
|
-
const
|
|
11356
|
+
const v = this.options.mediaStream ?? await navigator.mediaDevices.getUserMedia({
|
|
11357
11357
|
audio: !0
|
|
11358
11358
|
});
|
|
11359
|
-
if (g.addTrack(
|
|
11359
|
+
if (g.addTrack(v.getAudioTracks()[0]), this.options.changePeerConnection) {
|
|
11360
11360
|
const A = g;
|
|
11361
11361
|
g = await this.options.changePeerConnection(g), A !== g && (A.onconnectionstatechange = null), y(g), k(this, te, { ...c(this, te), peerConnection: g });
|
|
11362
11362
|
}
|
|
11363
|
-
const
|
|
11364
|
-
if (await g.setLocalDescription(
|
|
11363
|
+
const b = await g.createOffer();
|
|
11364
|
+
if (await g.setLocalDescription(b), !b.sdp)
|
|
11365
11365
|
throw new Error("Failed to create offer");
|
|
11366
|
-
const
|
|
11366
|
+
const N = await fetch(m, {
|
|
11367
11367
|
method: "POST",
|
|
11368
|
-
body:
|
|
11368
|
+
body: b.sdp,
|
|
11369
11369
|
headers: {
|
|
11370
11370
|
"Content-Type": "application/sdp",
|
|
11371
11371
|
Authorization: `Bearer ${i}`,
|
|
11372
11372
|
"X-OpenAI-Agents-SDK": ho["X-OpenAI-Agents-SDK"]
|
|
11373
11373
|
}
|
|
11374
11374
|
});
|
|
11375
|
-
|
|
11376
|
-
const
|
|
11375
|
+
T = (p = (l = N.headers) == null ? void 0 : l.get("Location")) == null ? void 0 : p.split("/").pop(), k(this, te, { ...c(this, te), callId: T });
|
|
11376
|
+
const x = {
|
|
11377
11377
|
type: "answer",
|
|
11378
|
-
sdp: await
|
|
11378
|
+
sdp: await N.text()
|
|
11379
11379
|
};
|
|
11380
|
-
await g.setRemoteDescription(
|
|
11380
|
+
await g.setRemoteDescription(x);
|
|
11381
11381
|
} catch (d) {
|
|
11382
11382
|
this.close(), this._onError(d), u(d);
|
|
11383
11383
|
}
|
|
@@ -11438,21 +11438,21 @@ class af extends Ts {
|
|
|
11438
11438
|
}
|
|
11439
11439
|
Zn = new WeakMap(), te = new WeakMap(), qn = new WeakMap(), dt = new WeakMap(), Jn = new WeakMap();
|
|
11440
11440
|
const of = globalThis.WebSocket;
|
|
11441
|
-
var pt,
|
|
11441
|
+
var pt, Ct, Ot, fe, Gn, Ye, Et, Rt, nn, Vn, Ut, _r, yo;
|
|
11442
11442
|
class uf extends Ts {
|
|
11443
11443
|
constructor(t = {}) {
|
|
11444
11444
|
super(t);
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
|
|
11448
|
-
|
|
11449
|
-
|
|
11445
|
+
R(this, Ut);
|
|
11446
|
+
R(this, pt);
|
|
11447
|
+
R(this, Ct);
|
|
11448
|
+
R(this, Ot);
|
|
11449
|
+
R(this, fe, {
|
|
11450
11450
|
status: "disconnected",
|
|
11451
11451
|
websocket: void 0
|
|
11452
11452
|
});
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11453
|
+
R(this, Gn);
|
|
11454
|
+
R(this, Ye);
|
|
11455
|
+
R(this, Et);
|
|
11456
11456
|
/**
|
|
11457
11457
|
* Timestamp maintained by the transport layer to aid with the calculation of the elapsed time
|
|
11458
11458
|
* since the response started to compute the right interruption time.
|
|
@@ -11460,12 +11460,12 @@ class uf extends Ts {
|
|
|
11460
11460
|
* Mostly internal but might be used by extended transport layers for their interruption
|
|
11461
11461
|
* calculation.
|
|
11462
11462
|
*/
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
k(this,
|
|
11463
|
+
S(this, "_firstAudioTimestamp");
|
|
11464
|
+
S(this, "_audioLengthMs", 0);
|
|
11465
|
+
R(this, Rt, !1);
|
|
11466
|
+
R(this, nn);
|
|
11467
|
+
R(this, Vn);
|
|
11468
|
+
k(this, Ct, t.url), k(this, Ot, t.url), k(this, Gn, t.useInsecureApiKey ?? !1), k(this, nn, t.createWebSocket), k(this, Vn, t.skipOpenEventListeners ?? !1);
|
|
11469
11469
|
}
|
|
11470
11470
|
getCommonRequestHeaders() {
|
|
11471
11471
|
return ho;
|
|
@@ -11506,20 +11506,20 @@ class uf extends Ts {
|
|
|
11506
11506
|
this.emit("audio", t);
|
|
11507
11507
|
}
|
|
11508
11508
|
_afterAudioDoneEvent() {
|
|
11509
|
-
z(this,
|
|
11509
|
+
z(this, Ut, _r).call(this);
|
|
11510
11510
|
}
|
|
11511
11511
|
async connect(t) {
|
|
11512
11512
|
const s = t.model ?? this.currentModel;
|
|
11513
11513
|
this.currentModel = s, k(this, pt, await this._getApiKey(t));
|
|
11514
11514
|
const r = t.callId;
|
|
11515
11515
|
let i;
|
|
11516
|
-
t.url ? (i = t.url, k(this,
|
|
11516
|
+
t.url ? (i = t.url, k(this, Ot, t.url)) : r ? i = `wss://api.openai.com/v1/realtime?call_id=${r}` : c(this, Ot) ? i = c(this, Ot) : i = `wss://api.openai.com/v1/realtime?model=${this.currentModel}`, k(this, Ct, i);
|
|
11517
11517
|
const o = {
|
|
11518
11518
|
...t.initialSessionConfig || {},
|
|
11519
11519
|
model: this.currentModel
|
|
11520
11520
|
};
|
|
11521
11521
|
await new Promise((a, u) => {
|
|
11522
|
-
z(this,
|
|
11522
|
+
z(this, Ut, yo).call(this, a, u, o).catch(u);
|
|
11523
11523
|
}), await this.updateSessionConfig(o);
|
|
11524
11524
|
}
|
|
11525
11525
|
/**
|
|
@@ -11540,7 +11540,7 @@ class uf extends Ts {
|
|
|
11540
11540
|
*/
|
|
11541
11541
|
close() {
|
|
11542
11542
|
var t;
|
|
11543
|
-
(t = c(this, fe).websocket) == null || t.close(), k(this, Ye, void 0), this._firstAudioTimestamp = void 0, this._audioLengthMs = 0, k(this,
|
|
11543
|
+
(t = c(this, fe).websocket) == null || t.close(), k(this, Ye, void 0), this._firstAudioTimestamp = void 0, this._audioLengthMs = 0, k(this, Et, void 0);
|
|
11544
11544
|
}
|
|
11545
11545
|
/**
|
|
11546
11546
|
* Will throw an error as the WebSocket transport layer does not support muting.
|
|
@@ -11563,9 +11563,9 @@ class uf extends Ts {
|
|
|
11563
11563
|
* response that the model is currently generating.
|
|
11564
11564
|
*/
|
|
11565
11565
|
_cancelResponse() {
|
|
11566
|
-
c(this,
|
|
11566
|
+
c(this, Rt) && (this.sendEvent({
|
|
11567
11567
|
type: "response.cancel"
|
|
11568
|
-
}), k(this,
|
|
11568
|
+
}), k(this, Rt, !1));
|
|
11569
11569
|
}
|
|
11570
11570
|
/**
|
|
11571
11571
|
* Do NOT call this method directly. Call `interrupt()` instead for proper interruption handling.
|
|
@@ -11584,7 +11584,7 @@ class uf extends Ts {
|
|
|
11584
11584
|
this.emit("audio_interrupted"), this.sendEvent({
|
|
11585
11585
|
type: "conversation.item.truncate",
|
|
11586
11586
|
item_id: c(this, Ye),
|
|
11587
|
-
content_index: c(this,
|
|
11587
|
+
content_index: c(this, Et),
|
|
11588
11588
|
audio_end_ms: i
|
|
11589
11589
|
});
|
|
11590
11590
|
}
|
|
@@ -11600,11 +11600,11 @@ class uf extends Ts {
|
|
|
11600
11600
|
if (!c(this, Ye) || typeof this._firstAudioTimestamp != "number")
|
|
11601
11601
|
return;
|
|
11602
11602
|
const s = Date.now() - this._firstAudioTimestamp;
|
|
11603
|
-
s >= 0 && this._interrupt(s, t), z(this,
|
|
11603
|
+
s >= 0 && this._interrupt(s, t), z(this, Ut, _r).call(this);
|
|
11604
11604
|
}
|
|
11605
11605
|
}
|
|
11606
|
-
pt = new WeakMap(),
|
|
11607
|
-
k(this, Ye, void 0), this._firstAudioTimestamp = void 0, this._audioLengthMs = 0, k(this,
|
|
11606
|
+
pt = new WeakMap(), Ct = new WeakMap(), Ot = new WeakMap(), fe = new WeakMap(), Gn = new WeakMap(), Ye = new WeakMap(), Et = new WeakMap(), Rt = new WeakMap(), nn = new WeakMap(), Vn = new WeakMap(), Ut = new WeakSet(), _r = function() {
|
|
11607
|
+
k(this, Ye, void 0), this._firstAudioTimestamp = void 0, this._audioLengthMs = 0, k(this, Et, void 0);
|
|
11608
11608
|
}, yo = async function(t, s, r) {
|
|
11609
11609
|
if (c(this, fe).websocket) {
|
|
11610
11610
|
t();
|
|
@@ -11617,7 +11617,7 @@ pt = new WeakMap(), Ot = new WeakMap(), Et = new WeakMap(), fe = new WeakMap(),
|
|
|
11617
11617
|
let i = null;
|
|
11618
11618
|
if (c(this, nn))
|
|
11619
11619
|
i = await c(this, nn).call(this, {
|
|
11620
|
-
url: c(this,
|
|
11620
|
+
url: c(this, Ct),
|
|
11621
11621
|
apiKey: c(this, pt)
|
|
11622
11622
|
});
|
|
11623
11623
|
else {
|
|
@@ -11628,7 +11628,7 @@ pt = new WeakMap(), Ot = new WeakMap(), Et = new WeakMap(), fe = new WeakMap(),
|
|
|
11628
11628
|
// Version header
|
|
11629
11629
|
Kd
|
|
11630
11630
|
];
|
|
11631
|
-
i = new of(c(this,
|
|
11631
|
+
i = new of(c(this, Ct), a);
|
|
11632
11632
|
}
|
|
11633
11633
|
k(this, fe, {
|
|
11634
11634
|
status: "connecting",
|
|
@@ -11646,36 +11646,36 @@ pt = new WeakMap(), Ot = new WeakMap(), Et = new WeakMap(), fe = new WeakMap(),
|
|
|
11646
11646
|
websocket: void 0
|
|
11647
11647
|
}), this.emit("connection_change", c(this, fe).status), s(a);
|
|
11648
11648
|
}), i.addEventListener("message", (a) => {
|
|
11649
|
-
var p, d, m, g,
|
|
11649
|
+
var p, d, m, g, _, T, y;
|
|
11650
11650
|
this._onMessage(a);
|
|
11651
11651
|
const { data: u, isGeneric: l } = Ur(a);
|
|
11652
11652
|
if (!(!u || l)) {
|
|
11653
11653
|
if (u.type === "response.output_audio.delta") {
|
|
11654
|
-
k(this,
|
|
11655
|
-
const h = qd(u.delta),
|
|
11656
|
-
if (
|
|
11657
|
-
const
|
|
11658
|
-
if (
|
|
11654
|
+
k(this, Et, u.content_index), k(this, Ye, u.item_id), this._firstAudioTimestamp === void 0 && (this._firstAudioTimestamp = Date.now(), this._audioLengthMs = 0);
|
|
11655
|
+
const h = qd(u.delta), v = (m = (d = (p = this._rawSessionConfig) == null ? void 0 : p.audio) == null ? void 0 : d.output) == null ? void 0 : m.format;
|
|
11656
|
+
if (v && typeof v == "object") {
|
|
11657
|
+
const N = v.type;
|
|
11658
|
+
if (N === "audio/pcmu" || N === "audio/pcma")
|
|
11659
11659
|
this._audioLengthMs += h.byteLength / 8;
|
|
11660
|
-
else if (
|
|
11661
|
-
const
|
|
11662
|
-
this._audioLengthMs += h.byteLength / 2 /
|
|
11660
|
+
else if (N === "audio/pcm") {
|
|
11661
|
+
const x = v.rate ?? 24e3;
|
|
11662
|
+
this._audioLengthMs += h.byteLength / 2 / x * 1e3;
|
|
11663
11663
|
} else
|
|
11664
11664
|
this._audioLengthMs += h.byteLength / 24 / 2;
|
|
11665
|
-
} else typeof
|
|
11666
|
-
const
|
|
11665
|
+
} else typeof v == "string" ? v.startsWith("g711_") ? this._audioLengthMs += h.byteLength / 8 : this._audioLengthMs += h.byteLength / 24 / 2 : this._audioLengthMs += h.byteLength / 24 / 2;
|
|
11666
|
+
const b = {
|
|
11667
11667
|
type: "audio",
|
|
11668
11668
|
data: h,
|
|
11669
11669
|
responseId: u.response_id
|
|
11670
11670
|
};
|
|
11671
|
-
this._onAudio(
|
|
11671
|
+
this._onAudio(b);
|
|
11672
11672
|
} else if (u.type === "input_audio_buffer.speech_started") {
|
|
11673
|
-
const h = ((y = (
|
|
11673
|
+
const h = ((y = (T = (_ = (g = this._rawSessionConfig) == null ? void 0 : g.audio) == null ? void 0 : _.input) == null ? void 0 : T.turn_detection) == null ? void 0 : y.interrupt_response) ?? !1;
|
|
11674
11674
|
this.interrupt(!h);
|
|
11675
11675
|
} else if (u.type === "response.created")
|
|
11676
|
-
k(this,
|
|
11676
|
+
k(this, Rt, !0);
|
|
11677
11677
|
else if (u.type === "response.done")
|
|
11678
|
-
k(this,
|
|
11678
|
+
k(this, Rt, !1);
|
|
11679
11679
|
else if (u.type === "session.created") {
|
|
11680
11680
|
this._tracingConfig = u.session.tracing;
|
|
11681
11681
|
const h = typeof r.tracing > "u" ? "auto" : r.tracing;
|
|
@@ -11715,37 +11715,37 @@ function pf(n) {
|
|
|
11715
11715
|
function ff() {
|
|
11716
11716
|
return JSON.parse(JSON.stringify(De));
|
|
11717
11717
|
}
|
|
11718
|
-
var H, B, sn, Z, rn, an, Hn, ae, on, un, Fe, Wn,
|
|
11718
|
+
var H, B, sn, Z, rn, an, Hn, ae, on, un, Fe, Wn, Nt, Kn, Yn, re, vn, bn, _o, as, vo, br, bo, wr;
|
|
11719
11719
|
const Zr = class Zr extends Cs {
|
|
11720
11720
|
constructor(t, s = {}) {
|
|
11721
11721
|
super();
|
|
11722
|
-
|
|
11723
|
-
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
|
|
11731
|
-
|
|
11732
|
-
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
|
|
11722
|
+
R(this, re);
|
|
11723
|
+
S(this, "initialAgent");
|
|
11724
|
+
S(this, "options");
|
|
11725
|
+
R(this, H);
|
|
11726
|
+
R(this, B);
|
|
11727
|
+
R(this, sn);
|
|
11728
|
+
R(this, Z);
|
|
11729
|
+
R(this, rn, []);
|
|
11730
|
+
R(this, an);
|
|
11731
|
+
R(this, Hn, {});
|
|
11732
|
+
R(this, ae, []);
|
|
11733
|
+
R(this, on);
|
|
11734
|
+
R(this, un, {});
|
|
11735
|
+
R(this, Fe, !1);
|
|
11736
11736
|
// Tracks all MCP tools fetched per server label (from mcp_list_tools results).
|
|
11737
|
-
|
|
11737
|
+
R(this, Wn, /* @__PURE__ */ new Map());
|
|
11738
11738
|
// Tracks currently available MCP tools based on the active agent's configured server_labels.
|
|
11739
|
-
|
|
11739
|
+
R(this, Nt, []);
|
|
11740
11740
|
// Keeps track of the last full session config we sent (camelCase keys) so that
|
|
11741
11741
|
// subsequent updates (e.g. during agent handoffs) preserve properties that are
|
|
11742
11742
|
// not explicitly recalculated here (such as inputAudioFormat, outputAudioFormat,
|
|
11743
11743
|
// modalities, speed, toolChoice, turnDetection, etc.). Without this, updating
|
|
11744
11744
|
// the agent would drop audio format overrides (e.g. g711_ulaw) and revert to
|
|
11745
11745
|
// transport defaults causing issues for integrations like Twilio.
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
this.initialAgent = t, this.options = s, typeof s.transport > "u" && Hd() || s.transport === "webrtc" ? k(this, H, new af()) : s.transport === "websocket" || typeof s.transport > "u" ? k(this, H, new uf()) : k(this, H, s.transport), k(this, B, t), k(this, Z, new
|
|
11746
|
+
R(this, Kn, ff());
|
|
11747
|
+
R(this, Yn, !0);
|
|
11748
|
+
this.initialAgent = t, this.options = s, typeof s.transport > "u" && Hd() || s.transport === "webrtc" ? k(this, H, new af()) : s.transport === "websocket" || typeof s.transport > "u" ? k(this, H, new uf()) : k(this, H, s.transport), k(this, B, t), k(this, Z, new Zt({
|
|
11749
11749
|
...s.context ?? {},
|
|
11750
11750
|
history: c(this, ae)
|
|
11751
11751
|
})), k(this, rn, (s.outputGuardrails ?? []).map(ep)), k(this, an, Qd(s.outputGuardrailSettings ?? {})), k(this, on, s.historyStoreAudio ?? !1), k(this, Yn, s.automaticallyTriggerResponseForMcpToolCalls ?? !0);
|
|
@@ -11788,7 +11788,7 @@ const Zr = class Zr extends Cs {
|
|
|
11788
11788
|
return c(this, ae);
|
|
11789
11789
|
}
|
|
11790
11790
|
get availableMcpTools() {
|
|
11791
|
-
return c(this,
|
|
11791
|
+
return c(this, Nt);
|
|
11792
11792
|
}
|
|
11793
11793
|
/**
|
|
11794
11794
|
* Compute the initial session config that the current session will use when connecting.
|
|
@@ -11935,15 +11935,15 @@ const Zr = class Zr extends Cs {
|
|
|
11935
11935
|
throw new we(`Tool ${r ?? "unknown"} not found`);
|
|
11936
11936
|
}
|
|
11937
11937
|
};
|
|
11938
|
-
H = new WeakMap(), B = new WeakMap(), sn = new WeakMap(), Z = new WeakMap(), rn = new WeakMap(), an = new WeakMap(), Hn = new WeakMap(), ae = new WeakMap(), on = new WeakMap(), un = new WeakMap(), Fe = new WeakMap(), Wn = new WeakMap(),
|
|
11938
|
+
H = new WeakMap(), B = new WeakMap(), sn = new WeakMap(), Z = new WeakMap(), rn = new WeakMap(), an = new WeakMap(), Hn = new WeakMap(), ae = new WeakMap(), on = new WeakMap(), un = new WeakMap(), Fe = new WeakMap(), Wn = new WeakMap(), Nt = new WeakMap(), Kn = new WeakMap(), Yn = new WeakMap(), re = new WeakSet(), vn = async function(t) {
|
|
11939
11939
|
k(this, B, t);
|
|
11940
11940
|
const s = await c(this, B).getEnabledHandoffs(c(this, Z)), r = s.map((u) => u.getHandoffAsFunctionTool()), i = (await c(this, B).getAllTools(c(this, Z))).filter(df).map(pf), o = typeof c(this, B).tools < "u" || typeof c(this, B).mcpServers < "u", a = s.length > 0;
|
|
11941
11941
|
k(this, sn, o || a ? [...i, ...r] : void 0), z(this, re, wr).call(this);
|
|
11942
11942
|
}, bn = async function(t = {}) {
|
|
11943
11943
|
const s = t ?? {}, r = this.options.config ?? {}, i = await c(this, B).getSystemPrompt(c(this, Z)), o = (g) => {
|
|
11944
|
-
var
|
|
11945
|
-
const
|
|
11946
|
-
return (
|
|
11944
|
+
var T;
|
|
11945
|
+
const _ = g.audio;
|
|
11946
|
+
return (T = _ == null ? void 0 : _.output) == null ? void 0 : T.voice;
|
|
11947
11947
|
}, a = this.options.tracingDisabled ? null : this.options.workflowName ? {
|
|
11948
11948
|
workflow_name: this.options.workflowName
|
|
11949
11949
|
} : "auto";
|
|
@@ -11970,7 +11970,7 @@ H = new WeakMap(), B = new WeakMap(), sn = new WeakMap(), Z = new WeakMap(), rn
|
|
|
11970
11970
|
}, as = async function(t, s) {
|
|
11971
11971
|
c(this, Z).context.history = JSON.parse(JSON.stringify(c(this, ae)));
|
|
11972
11972
|
let r = t.arguments;
|
|
11973
|
-
if (s.parameters && (
|
|
11973
|
+
if (s.parameters && (jt(s.parameters) ? r = s.parameters.parse(r) : r = JSON.parse(r)), await s.needsApproval(c(this, Z), r, t.callId)) {
|
|
11974
11974
|
const u = this.context.isToolApproved({
|
|
11975
11975
|
toolName: s.name,
|
|
11976
11976
|
callId: t.callId
|
|
@@ -12149,8 +12149,8 @@ wr = function() {
|
|
|
12149
12149
|
for (const m of p)
|
|
12150
12150
|
d && !d.includes(m.name) || r.has(m.name) || r.set(m.name, m);
|
|
12151
12151
|
}
|
|
12152
|
-
const i = Array.from(r.values()), o = c(this,
|
|
12153
|
-
(o.length !== i.length || JSON.stringify(o.map((l) => l.name).sort()) !== JSON.stringify(i.map((l) => l.name).sort())) && (k(this,
|
|
12152
|
+
const i = Array.from(r.values()), o = c(this, Nt);
|
|
12153
|
+
(o.length !== i.length || JSON.stringify(o.map((l) => l.name).sort()) !== JSON.stringify(i.map((l) => l.name).sort())) && (k(this, Nt, i), this.emit("mcp_tools_changed", c(this, Nt)));
|
|
12154
12154
|
};
|
|
12155
12155
|
let vr = Zr;
|
|
12156
12156
|
class hf {
|
|
@@ -12237,7 +12237,7 @@ class wf extends hf {
|
|
|
12237
12237
|
throw new Error("BabelbeezClient: publicChatbotId is required.");
|
|
12238
12238
|
this.publicChatbotId = e.publicChatbotId;
|
|
12239
12239
|
const t = e.proxyInitializeUrl || _f;
|
|
12240
|
-
this.proxyInitializeUrl = t, this.apiBaseUrl = e.apiBaseUrl || new URL(t).origin, this.agent = null, this.session = null, this.currentSystemSettings = null, this.currentChatbotSettings = null, this.currentSessionId = null, this.currentRagSearchUrl = null, this.sessionStartTime = null, this.accumulatedUsage = null, this.hasEndConversationBeenHandled = !1, this.isTerminating = !1, this.
|
|
12240
|
+
this.proxyInitializeUrl = t, this.apiBaseUrl = e.apiBaseUrl || new URL(t).origin, this.agent = null, this.session = null, this.currentSystemSettings = null, this.currentChatbotSettings = null, this.currentSessionId = null, this.currentRagSearchUrl = null, this.sessionStartTime = null, this.accumulatedUsage = null, this.hasEndConversationBeenHandled = !1, this.isTerminating = !1, this.isUserSpeaking = !1, this.isAssistantSpeaking = !1, this.isHandoffFormOpen = !1, this.inactivityStage = 0, this.inactivityStage1TimeoutId = null, this.inactivityStage2TimeoutId = null, this.shouldScheduleStage2OnNextAssistantSilence = !1, this.pendingGoodbyeResolve = null, this.handoffPromiseResolve = null, this.currentHandoffSummaryText = null, this.heartbeatIntervalId = null, this.heartbeatFrequencySeconds = null, this._lastInitData = null, this._lastAssistantMessageId = null, this._lastAssistantTranscript = "", this._currentAssistantTranscript = "", this._currentUserTranscript = "";
|
|
12241
12241
|
}
|
|
12242
12242
|
// --- Public API ---
|
|
12243
12243
|
/**
|
|
@@ -12258,23 +12258,57 @@ class wf extends hf {
|
|
|
12258
12258
|
session_id: i,
|
|
12259
12259
|
heartbeat_frequency_seconds: o
|
|
12260
12260
|
} = e;
|
|
12261
|
-
this.currentSystemSettings = s, this.currentChatbotSettings = r, this.currentSessionId = i, this.heartbeatFrequencySeconds = o, this.currentRagSearchUrl = `${this.apiBaseUrl}/api/perform-rag-search`, $("DEBUG", "BabelbeezClient: using RAG search URL", this.currentRagSearchUrl), this._resetAccumulatedUsage(), this._resetInactivityState(), this.isUserSpeaking = !1, this.isAssistantSpeaking = !1, this.isTerminating = !1, this.hasEndConversationBeenHandled = !1
|
|
12261
|
+
this.currentSystemSettings = s, this.currentChatbotSettings = r, this.currentSessionId = i, this.heartbeatFrequencySeconds = o, this.currentRagSearchUrl = `${this.apiBaseUrl}/api/perform-rag-search`, $("DEBUG", "BabelbeezClient: using RAG search URL", this.currentRagSearchUrl), this._resetAccumulatedUsage(), this._resetInactivityState(), this.isUserSpeaking = !1, this.isAssistantSpeaking = !1, this.isTerminating = !1, this.hasEndConversationBeenHandled = !1;
|
|
12262
12262
|
try {
|
|
12263
12263
|
this.emit("buttonState", "loading"), this.agent = this._createVoiceAgent(), this.session = this._createVoiceSession(s, r), await this.session.connect({ apiKey: t }), this._attachTransportListeners(), this.sessionStartTime = Date.now(), this.emit("buttonState", "active"), this.emit("session:start", {
|
|
12264
12264
|
chatbotId: this.publicChatbotId,
|
|
12265
12265
|
// Expose the fresh chatbot configuration returned by /initialize-chat
|
|
12266
12266
|
config: this.currentChatbotSettings
|
|
12267
|
-
}), this._startHeartbeat()
|
|
12268
|
-
|
|
12269
|
-
|
|
12270
|
-
|
|
12271
|
-
|
|
12272
|
-
|
|
12273
|
-
|
|
12274
|
-
|
|
12275
|
-
|
|
12276
|
-
|
|
12277
|
-
|
|
12267
|
+
}), this._startHeartbeat(), this._resetInactivityState(), $("INFO", "BabelbeezClient: Realtime session connected."), setTimeout(() => {
|
|
12268
|
+
var u;
|
|
12269
|
+
const a = (u = this.currentChatbotSettings) == null ? void 0 : u.greetingInstructions;
|
|
12270
|
+
if (a)
|
|
12271
|
+
try {
|
|
12272
|
+
this.session && this.session.transport && this.session.transport.sendEvent({
|
|
12273
|
+
type: "response.create",
|
|
12274
|
+
response: {
|
|
12275
|
+
// Treat the greeting as an out-of-band response so it does
|
|
12276
|
+
// not write into the default conversation history.
|
|
12277
|
+
conversation: "none",
|
|
12278
|
+
// Use the Realtime protocol field. Request audio output,
|
|
12279
|
+
// which will also include a text transcript.
|
|
12280
|
+
output_modalities: ["audio"],
|
|
12281
|
+
// Keep the locale-wrapped greeting instructions for this
|
|
12282
|
+
// specific turn only.
|
|
12283
|
+
instructions: a,
|
|
12284
|
+
// Clear tools for this response so the model cannot turn the
|
|
12285
|
+
// greeting into a tool call.
|
|
12286
|
+
tools: [],
|
|
12287
|
+
// Provide a simple synthetic user message as input so the
|
|
12288
|
+
// model treats this like a normal turn, without exposing
|
|
12289
|
+
// the raw greetingInstructions as user text.
|
|
12290
|
+
input: [
|
|
12291
|
+
{
|
|
12292
|
+
type: "message",
|
|
12293
|
+
role: "user",
|
|
12294
|
+
content: [
|
|
12295
|
+
{
|
|
12296
|
+
type: "input_text",
|
|
12297
|
+
text: "The caller has just connected. Greet them now."
|
|
12298
|
+
}
|
|
12299
|
+
]
|
|
12300
|
+
}
|
|
12301
|
+
],
|
|
12302
|
+
// Keep metadata for debugging/inspection if needed.
|
|
12303
|
+
metadata: {
|
|
12304
|
+
source: "greeting"
|
|
12305
|
+
}
|
|
12306
|
+
}
|
|
12307
|
+
});
|
|
12308
|
+
} catch (l) {
|
|
12309
|
+
$("WARN", "BabelbeezClient: failed to trigger greeting response (post-connect).", l);
|
|
12310
|
+
}
|
|
12311
|
+
}, 0);
|
|
12278
12312
|
} catch (a) {
|
|
12279
12313
|
let u = `Connect Session failed: ${(a == null ? void 0 : a.message) || "Unknown error"}`, l = "connection_error", p = "CONNECTION_FAILED";
|
|
12280
12314
|
throw a && (a.name === "NotAllowedError" || a.name === "PermissionDeniedError") ? (u = "Microphone access denied. Please allow microphone access in your browser settings.", l = "microphone_permission_denied", p = "MIC_DENIED") : a && a.name === "NotFoundError" && (u = "No microphone found. Please ensure a microphone is connected and enabled.", l = "microphone_not_found", p = "MIC_NOT_FOUND"), $("ERROR", u, a), this.emit("buttonState", "error"), this.emit("error", {
|
|
@@ -12552,107 +12586,99 @@ class wf extends hf {
|
|
|
12552
12586
|
await Promise.race([s, i]), this.pendingGoodbyeResolve = null, this._setSessionMuted(!1, "goodbye"), await this._finalizeSession(e);
|
|
12553
12587
|
}
|
|
12554
12588
|
_createVoiceAgent() {
|
|
12555
|
-
var
|
|
12556
|
-
const e = (
|
|
12589
|
+
var u, l, p, d;
|
|
12590
|
+
const e = (u = this.currentSystemSettings) != null && u.system_prompt ? `${this.currentSystemSettings.system_prompt}
|
|
12557
12591
|
|
|
12558
|
-
${((
|
|
12592
|
+
${((l = this.currentChatbotSettings) == null ? void 0 : l.instructions) || ""}`.trim() : ((p = this.currentChatbotSettings) == null ? void 0 : p.instructions) || "", t = this, s = Gt({
|
|
12559
12593
|
name: "perform_rag_search",
|
|
12560
|
-
description: ((
|
|
12561
|
-
parameters:
|
|
12594
|
+
description: ((d = this.currentSystemSettings) == null ? void 0 : d.rag_search_description) || "Searches the knowledge base for relevant context.",
|
|
12595
|
+
parameters: w({
|
|
12562
12596
|
query: f()
|
|
12563
12597
|
}),
|
|
12564
|
-
async execute({ query:
|
|
12565
|
-
if ($("INFO", `Tool perform_rag_search called with query: "${
|
|
12598
|
+
async execute({ query: m }) {
|
|
12599
|
+
if ($("INFO", `Tool perform_rag_search called with query: "${m}"`), t._resetInactivityState(), !t.currentRagSearchUrl || !t.publicChatbotId)
|
|
12566
12600
|
return $(
|
|
12567
12601
|
"ERROR",
|
|
12568
12602
|
"RAG search URL or publicChatbotId not configured; returning fallback context."
|
|
12569
12603
|
), "Knowledge search is temporarily unavailable.";
|
|
12570
|
-
const
|
|
12604
|
+
const g = t.isAssistantSpeaking;
|
|
12571
12605
|
t.isAssistantSpeaking = !0, t.emit("buttonState", "rag-retrieval");
|
|
12572
12606
|
try {
|
|
12573
|
-
const
|
|
12607
|
+
const _ = await fetch(t.currentRagSearchUrl, {
|
|
12574
12608
|
method: "POST",
|
|
12575
12609
|
headers: { "Content-Type": "application/json" },
|
|
12576
|
-
body: JSON.stringify({ query:
|
|
12610
|
+
body: JSON.stringify({ query: m, public_chatbot_id: t.publicChatbotId })
|
|
12577
12611
|
});
|
|
12578
|
-
if (!
|
|
12579
|
-
let
|
|
12612
|
+
if (!_.ok) {
|
|
12613
|
+
let h = `RAG search failed: ${_.status} ${_.statusText}`;
|
|
12580
12614
|
try {
|
|
12581
|
-
const
|
|
12582
|
-
|
|
12615
|
+
const v = await _.json();
|
|
12616
|
+
v && v.detail && (h = v.detail);
|
|
12583
12617
|
} catch {
|
|
12584
12618
|
}
|
|
12585
|
-
return $("ERROR",
|
|
12619
|
+
return $("ERROR", h), "Knowledge search failed; please answer based on your existing knowledge.";
|
|
12586
12620
|
}
|
|
12587
|
-
const
|
|
12588
|
-
return $("INFO", `RAG search succeeded. Context length: ${
|
|
12589
|
-
} catch (
|
|
12590
|
-
return $("ERROR", "Network or unexpected error during RAG search.",
|
|
12621
|
+
const y = (await _.json()).context || "";
|
|
12622
|
+
return $("INFO", `RAG search succeeded. Context length: ${y.length}`), y || "No additional knowledge was found.";
|
|
12623
|
+
} catch (_) {
|
|
12624
|
+
return $("ERROR", "Network or unexpected error during RAG search.", _), "Knowledge search failed due to a network error.";
|
|
12591
12625
|
} finally {
|
|
12592
|
-
t.isAssistantSpeaking =
|
|
12626
|
+
t.isAssistantSpeaking = g, t.emit("buttonState", "active");
|
|
12593
12627
|
}
|
|
12594
12628
|
}
|
|
12595
|
-
}), r =
|
|
12629
|
+
}), r = Gt({
|
|
12596
12630
|
name: "request_human_handoff",
|
|
12597
12631
|
description: "Escalate to a human staff member via contact form. Provide a concise summary_text.",
|
|
12598
|
-
parameters:
|
|
12632
|
+
parameters: w({
|
|
12599
12633
|
summary_text: f(),
|
|
12600
12634
|
announcement: f()
|
|
12601
12635
|
}),
|
|
12602
|
-
async execute({ summary_text:
|
|
12603
|
-
var
|
|
12636
|
+
async execute({ summary_text: m, announcement: g }) {
|
|
12637
|
+
var h;
|
|
12604
12638
|
$("INFO", "Tool request_human_handoff called."), t._resetInactivityState();
|
|
12605
|
-
const
|
|
12639
|
+
const _ = g || "Please fill out the form so that I can connect you to a staff member to follow up";
|
|
12606
12640
|
try {
|
|
12607
|
-
t.session && await t.session.sendMessage(
|
|
12608
|
-
} catch (
|
|
12609
|
-
$("WARN", "Failed to send handoff announcement message.",
|
|
12641
|
+
t.session && await t.session.sendMessage(_);
|
|
12642
|
+
} catch (v) {
|
|
12643
|
+
$("WARN", "Failed to send handoff announcement message.", v);
|
|
12610
12644
|
}
|
|
12611
12645
|
t.isHandoffFormOpen = !0, t._setSessionMuted(!0, "handoff_form");
|
|
12612
|
-
let
|
|
12613
|
-
const
|
|
12614
|
-
if (
|
|
12615
|
-
const
|
|
12616
|
-
|
|
12646
|
+
let T = null;
|
|
12647
|
+
const y = (h = t.currentChatbotSettings) == null ? void 0 : h.handoff_whatsapp_number;
|
|
12648
|
+
if (y) {
|
|
12649
|
+
const v = String(y).replace(/\D+/g, "");
|
|
12650
|
+
v && (T = `https://wa.me/${v}?text=${encodeURIComponent(m || "Summary not available.")}`);
|
|
12617
12651
|
}
|
|
12618
|
-
return t.currentHandoffSummaryText =
|
|
12652
|
+
return t.currentHandoffSummaryText = m || "Summary not available.", t.emit("handoff:show", {
|
|
12619
12653
|
summaryText: t.currentHandoffSummaryText,
|
|
12620
|
-
waLink:
|
|
12621
|
-
}), await new Promise((
|
|
12622
|
-
t.handoffPromiseResolve =
|
|
12623
|
-
}).then((
|
|
12654
|
+
waLink: T
|
|
12655
|
+
}), await new Promise((v) => {
|
|
12656
|
+
t.handoffPromiseResolve = v;
|
|
12657
|
+
}).then((v) => v === "whatsapp_submitted" ? "User chose WhatsApp handoff." : v === "email_submitted" ? "Handoff request submitted successfully." : "Handoff flow completed or cancelled by the user.");
|
|
12624
12658
|
}
|
|
12625
|
-
}), i =
|
|
12659
|
+
}), i = Gt({
|
|
12626
12660
|
name: "end_conversation",
|
|
12627
12661
|
description: "End the conversation when the user clearly wants to stop. The model should call this tool instead of saying goodbye itself.",
|
|
12628
|
-
parameters:
|
|
12662
|
+
parameters: w({}),
|
|
12629
12663
|
async execute() {
|
|
12630
12664
|
return $("INFO", "Tool end_conversation called by AI."), t._resetInactivityState(), t.hasEndConversationBeenHandled ? ($("DEBUG", "end_conversation already handled; ignoring subsequent call."), "Conversation is already ending.") : (t.hasEndConversationBeenHandled = !0, (async () => {
|
|
12631
12665
|
try {
|
|
12632
12666
|
t.session && (await t.session.interrupt(), $("INFO", "Session interrupted by AI end_conversation before goodbye."));
|
|
12633
|
-
} catch (
|
|
12667
|
+
} catch (m) {
|
|
12634
12668
|
$(
|
|
12635
12669
|
"WARN",
|
|
12636
12670
|
"Error interrupting session during AI end_conversation; proceeding anyway.",
|
|
12637
|
-
|
|
12671
|
+
m
|
|
12638
12672
|
);
|
|
12639
12673
|
}
|
|
12640
12674
|
await t._playGoodbyeThenFinalize("ai_end_conversation_tool");
|
|
12641
12675
|
})(), "Conversation ended.");
|
|
12642
12676
|
}
|
|
12643
|
-
}), o =
|
|
12644
|
-
|
|
12645
|
-
description: "Silently update structured user information (e.g. email, name, appointment time).",
|
|
12646
|
-
parameters: b({}).passthrough(),
|
|
12647
|
-
// accept any key:value pairs
|
|
12648
|
-
async execute(S) {
|
|
12649
|
-
return $("INFO", "Tool update_session_entities called", S), t.sessionEntities = { ...t.sessionEntities, ...S }, t.emit("entities:updated", { entities: t.sessionEntities }), "Information updated.";
|
|
12650
|
-
}
|
|
12651
|
-
}), a = [s, r, i], u = (v = this.currentChatbotSettings) == null ? void 0 : v.monitored_entities;
|
|
12652
|
-
return Array.isArray(u) && u.length > 0 && a.push(o), new Xd({
|
|
12677
|
+
}), o = [s, r, i];
|
|
12678
|
+
return new Xd({
|
|
12653
12679
|
name: "Assistant",
|
|
12654
12680
|
instructions: e,
|
|
12655
|
-
tools:
|
|
12681
|
+
tools: o
|
|
12656
12682
|
});
|
|
12657
12683
|
}
|
|
12658
12684
|
_createVoiceSession(e, t) {
|
|
@@ -12705,7 +12731,7 @@ ${((d = this.currentChatbotSettings) == null ? void 0 : d.instructions) || ""}`.
|
|
|
12705
12731
|
}), this.session.transport && (this.session.transport.on("*", (e) => {
|
|
12706
12732
|
var t, s;
|
|
12707
12733
|
if (e) {
|
|
12708
|
-
if (e.type === "response.done" && ((t = e.response) != null && t.usage) && (this.accumulatedUsage = wo(this.accumulatedUsage, e.response.usage), $("DEBUG", "Accumulated token usage from response.done.", this.accumulatedUsage)), e.type === "input_audio_buffer.speech_started") {
|
|
12734
|
+
if (e.type && typeof e.type == "string" && e.type.startsWith("response."), e.type === "response.done" && ((t = e.response) != null && t.usage) && (this.accumulatedUsage = wo(this.accumulatedUsage, e.response.usage), $("DEBUG", "Accumulated token usage from response.done.", this.accumulatedUsage)), e.type === "input_audio_buffer.speech_started") {
|
|
12709
12735
|
this.isUserSpeaking = !0, this._currentUserTranscript = "", this._resetInactivityState();
|
|
12710
12736
|
return;
|
|
12711
12737
|
}
|
|
@@ -12826,8 +12852,7 @@ ${((d = this.currentChatbotSettings) == null ? void 0 : d.instructions) || ""}`.
|
|
|
12826
12852
|
heartbeatUrl: e
|
|
12827
12853
|
});
|
|
12828
12854
|
const t = {
|
|
12829
|
-
session_id: this.currentSessionId
|
|
12830
|
-
extracted_data: this.sessionEntities && Object.keys(this.sessionEntities).length ? this.sessionEntities : void 0
|
|
12855
|
+
session_id: this.currentSessionId
|
|
12831
12856
|
};
|
|
12832
12857
|
(await fetch(e, {
|
|
12833
12858
|
method: "POST",
|
|
@@ -12862,8 +12887,7 @@ ${((d = this.currentChatbotSettings) == null ? void 0 : d.instructions) || ""}`.
|
|
|
12862
12887
|
session_id: this.currentSessionId,
|
|
12863
12888
|
token_usage: s.usage || void 0,
|
|
12864
12889
|
raw_history: s.raw_history || void 0,
|
|
12865
|
-
client_reason: s.client_reason || void 0
|
|
12866
|
-
extracted_data: this.sessionEntities && Object.keys(this.sessionEntities).length ? this.sessionEntities : void 0
|
|
12890
|
+
client_reason: s.client_reason || void 0
|
|
12867
12891
|
};
|
|
12868
12892
|
$("DEBUG", "BabelbeezClient: Sending /end-chat beacon", {
|
|
12869
12893
|
...i,
|
|
@@ -12883,7 +12907,7 @@ ${((d = this.currentChatbotSettings) == null ? void 0 : d.instructions) || ""}`.
|
|
|
12883
12907
|
} catch (r) {
|
|
12884
12908
|
$("WARN", "BabelbeezClient: Error closing RealtimeSession.", r);
|
|
12885
12909
|
}
|
|
12886
|
-
this.session = null, this.agent = null, this.currentSystemSettings = null, this.currentChatbotSettings = null, this.currentSessionId = null, this.currentRagSearchUrl = null, this.sessionStartTime = null, this._resetInactivityState(), this.isUserSpeaking = !1, this.isAssistantSpeaking = !1, this._resetAccumulatedUsage(), this.hasEndConversationBeenHandled = !1, this.
|
|
12910
|
+
this.session = null, this.agent = null, this.currentSystemSettings = null, this.currentChatbotSettings = null, this.currentSessionId = null, this.currentRagSearchUrl = null, this.sessionStartTime = null, this._resetInactivityState(), this.isUserSpeaking = !1, this.isAssistantSpeaking = !1, this._resetAccumulatedUsage(), this.hasEndConversationBeenHandled = !1, this.isTerminating = !1;
|
|
12887
12911
|
}
|
|
12888
12912
|
}
|
|
12889
12913
|
export {
|