@babelbeez/sdk 0.1.2 → 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.
@@ -92,8 +92,8 @@ class Hr {
92
92
  case "string": {
93
93
  const h = y;
94
94
  h.type = "string";
95
- const { minimum: w, maximum: v, format: N, patterns: x, contentEncoding: A } = e._zod.bag;
96
- if (typeof w == "number" && (h.minLength = w), typeof v == "number" && (h.maxLength = v), N && (h.format = i[N] ?? N, h.format === "" && delete h.format), A && (h.contentEncoding = A), x && x.size > 0) {
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
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) => ({
@@ -105,8 +105,8 @@ class Hr {
105
105
  break;
106
106
  }
107
107
  case "number": {
108
- const h = y, { minimum: w, maximum: v, 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 w == "number" && (h.minimum = w, typeof D == "number" && (D >= w ? delete h.minimum : delete h.exclusiveMinimum)), typeof A == "number" && (h.exclusiveMaximum = A), typeof v == "number" && (h.maximum = v, typeof A == "number" && (A <= v ? delete h.maximum : delete h.exclusiveMaximum)), typeof x == "number" && (h.multipleOf = x);
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,20 +152,20 @@ class Hr {
152
152
  break;
153
153
  }
154
154
  case "array": {
155
- const h = y, { minimum: w, maximum: v } = e._zod.bag;
156
- typeof w == "number" && (h.minItems = w), typeof v == "number" && (h.maxItems = v), h.type = "array", h.items = this.process(r.element, { ..._, path: [..._.path, "items"] });
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 w = r.shape;
163
- for (const x in w)
164
- h.properties[x] = this.process(w[x], {
162
+ const v = r.shape;
163
+ for (const x in v)
164
+ h.properties[x] = this.process(v[x], {
165
165
  ..._,
166
166
  path: [..._.path, "properties", x]
167
167
  });
168
- const v = new Set(Object.keys(w)), N = new Set([...v].filter((x) => {
168
+ const b = new Set(Object.keys(v)), N = new Set([...b].filter((x) => {
169
169
  const A = r.shape[x]._zod;
170
170
  return this.io === "input" ? A.optin === void 0 : A.optout === void 0;
171
171
  }));
@@ -177,22 +177,22 @@ class Hr {
177
177
  }
178
178
  case "union": {
179
179
  const h = y;
180
- h.anyOf = r.options.map((w, v) => this.process(w, {
180
+ h.anyOf = r.options.map((v, b) => this.process(v, {
181
181
  ..._,
182
- path: [..._.path, "anyOf", v]
182
+ path: [..._.path, "anyOf", b]
183
183
  }));
184
184
  break;
185
185
  }
186
186
  case "intersection": {
187
- const h = y, w = this.process(r.left, {
187
+ const h = y, v = this.process(r.left, {
188
188
  ..._,
189
189
  path: [..._.path, "allOf", 0]
190
- }), v = this.process(r.right, {
190
+ }), b = this.process(r.right, {
191
191
  ..._,
192
192
  path: [..._.path, "allOf", 1]
193
193
  }), N = (A) => "allOf" in A && Object.keys(A).length === 1, x = [
194
- ...N(w) ? w.allOf : [w],
195
- ...N(v) ? v.allOf : [v]
194
+ ...N(v) ? v.allOf : [v],
195
+ ...N(b) ? b.allOf : [b]
196
196
  ];
197
197
  h.allOf = x;
198
198
  break;
@@ -200,8 +200,8 @@ class Hr {
200
200
  case "tuple": {
201
201
  const h = y;
202
202
  h.type = "array";
203
- const w = r.items.map((x, A) => this.process(x, { ..._, path: [..._.path, "prefixItems", A] }));
204
- if (this.target === "draft-2020-12" ? h.prefixItems = w : h.items = w, r.rest) {
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
205
  const x = this.process(r.rest, {
206
206
  ..._,
207
207
  path: [..._.path, "items"]
@@ -212,8 +212,8 @@ class Hr {
212
212
  ..._,
213
213
  path: [..._.path, "items"]
214
214
  }));
215
- const { minimum: v, maximum: N } = e._zod.bag;
216
- typeof v == "number" && (h.minItems = v), typeof N == "number" && (h.maxItems = N);
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": {
@@ -235,36 +235,36 @@ class Hr {
235
235
  break;
236
236
  }
237
237
  case "enum": {
238
- const h = y, w = To(r.entries);
239
- w.every((v) => typeof v == "number") && (h.type = "number"), w.every((v) => typeof v == "string") && (h.type = "string"), h.enum = w;
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, w = [];
244
- for (const v of r.values)
245
- if (v === void 0) {
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 v == "bigint") {
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
- w.push(Number(v));
251
+ v.push(Number(b));
252
252
  } else
253
- w.push(v);
254
- if (w.length !== 0) if (w.length === 1) {
255
- const v = w[0];
256
- h.type = v === null ? "null" : typeof v, h.const = v;
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
- w.every((v) => typeof v == "number") && (h.type = "number"), w.every((v) => typeof v == "string") && (h.type = "string"), w.every((v) => typeof v == "boolean") && (h.type = "string"), w.every((v) => v === null) && (h.type = "null"), h.enum = w;
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, w = {
262
+ const h = y, v = {
263
263
  type: "string",
264
264
  format: "binary",
265
265
  contentEncoding: "binary"
266
- }, { minimum: v, maximum: N, mime: x } = e._zod.bag;
267
- v !== void 0 && (w.minLength = v), N !== void 0 && (w.maxLength = N), x ? x.length === 1 ? (w.contentMediaType = x[0], Object.assign(h, w)) : h.anyOf = x.map((A) => ({ ...w, contentMediaType: A })) : Object.assign(h, w);
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": {
@@ -311,10 +311,10 @@ class Hr {
311
311
  break;
312
312
  }
313
313
  case "template_literal": {
314
- const h = y, w = e._zod.pattern;
315
- if (!w)
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 = w.source;
317
+ h.type = "string", h.pattern = v.source;
318
318
  break;
319
319
  }
320
320
  case "pipe": {
@@ -374,17 +374,17 @@ class Hr {
374
374
  }
375
375
  if (y[1] === r)
376
376
  return { ref: "#" };
377
- const v = `#/${h}/`, N = y[1].schema.id ?? `__schema${this.counter++}`;
378
- return { defId: N, ref: v + N };
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: w, defId: v } = i(y);
383
- h.def = { ...h.schema }, v && (h.defId = v);
382
+ const h = y[1], { ref: v, defId: b } = i(y);
383
+ h.def = { ...h.schema }, b && (h.defId = b);
384
384
  const N = h.schema;
385
385
  for (const x in N)
386
386
  delete N[x];
387
- N.$ref = w;
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 v = (d = s.external.registry.get(y[0])) == null ? void 0 : d.id;
405
- if (e !== y[0] && v) {
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,19 +421,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
421
421
  }
422
422
  }
423
423
  const a = (y, h) => {
424
- const w = this.seen.get(y), v = w.def ?? w.schema, N = { ...v };
425
- if (w.ref === null)
424
+ const v = this.seen.get(y), b = v.def ?? v.schema, N = { ...b };
425
+ if (v.ref === null)
426
426
  return;
427
- const x = w.ref;
428
- if (w.ref = null, x) {
427
+ const x = v.ref;
428
+ if (v.ref = null, x) {
429
429
  a(x, h);
430
430
  const A = this.seen.get(x).schema;
431
- A.$ref && h.target === "draft-7" ? (v.allOf = v.allOf ?? [], v.allOf.push(A)) : (Object.assign(v, A), Object.assign(v, N));
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
- w.isParent || this.override({
433
+ v.isParent || this.override({
434
434
  zodSchema: y,
435
- jsonSchema: v,
436
- path: w.path ?? []
435
+ jsonSchema: b,
436
+ path: v.path ?? []
437
437
  });
438
438
  };
439
439
  for (const y of [...this.seen.entries()].reverse())
@@ -3368,7 +3368,7 @@ const oa = (n, e = {
3368
3368
  message: `Input not instance of ${n.name}`
3369
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, b = ce.create, nt = cs.create, ye = Sr.create;
3371
+ const J = je.create, w = ce.create, nt = cs.create, ye = Sr.create;
3372
3372
  ls.create;
3373
3373
  Dt.create;
3374
3374
  const se = ds.create, iu = ps.create, I = fs.create, le = Mt.create;
@@ -4778,8 +4778,8 @@ function yc() {
4778
4778
  function y(...h) {
4779
4779
  if (!y.enabled)
4780
4780
  return;
4781
- const w = y, v = Number(/* @__PURE__ */ new Date()), N = v - (m || v);
4782
- w.diff = N, w.prev = m, w.curr = v, m = v, h[0] = s.coerce(h[0]), typeof h[0] != "string" && h.unshift("%O");
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
4783
  let x = 0;
4784
4784
  h[0] = h[0].replace(/%([a-zA-Z%])/g, (D, U) => {
4785
4785
  if (D === "%%")
@@ -4788,10 +4788,10 @@ function yc() {
4788
4788
  const G = s.formatters[U];
4789
4789
  if (typeof G == "function") {
4790
4790
  const L = h[x];
4791
- D = G.call(w, L), h.splice(x, 1), x--;
4791
+ D = G.call(v, L), h.splice(x, 1), x--;
4792
4792
  }
4793
4793
  return D;
4794
- }), s.formatArgs.call(w, h), (w.log || s.log).apply(w, h);
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,
@@ -5182,10 +5182,10 @@ function Gt(n) {
5182
5182
  isEnabled: l
5183
5183
  };
5184
5184
  }
5185
- b({
5185
+ w({
5186
5186
  name: f(),
5187
5187
  description: f().optional(),
5188
- inputSchema: b({
5188
+ inputSchema: w({
5189
5189
  type: I("object"),
5190
5190
  properties: se(f(), W()),
5191
5191
  required: J(f()),
@@ -5217,9 +5217,9 @@ async function Cc({ server: n, convertSchemasToStrict: e, runContext: t, agent:
5217
5217
  } else {
5218
5218
  const T = _.allowedToolNames ?? [], y = _.blockedToolNames ?? [];
5219
5219
  if (T.length > 0 || y.length > 0) {
5220
- const h = T.length > 0 ? T.includes(g.name) : !0, w = y.length > 0 ? y.includes(g.name) : !1;
5221
- if (!h || w) {
5222
- w ? 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.`);
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
  }
@@ -5567,7 +5567,7 @@ function Vc(n) {
5567
5567
  const e = ar.get(n);
5568
5568
  return e && ar.delete(n), e;
5569
5569
  }
5570
- const Hc = b({ input: f() }), Jt = class Jt extends jc {
5570
+ const Hc = w({ input: f() }), Jt = class Jt extends jc {
5571
5571
  constructor(t) {
5572
5572
  super();
5573
5573
  S(this, "name");
@@ -5651,12 +5651,12 @@ const Hc = b({ input: f() }), Jt = class Jt extends jc {
5651
5651
  */
5652
5652
  asTool(t) {
5653
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("*"), w = [
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(w.map((v) => Promise.resolve().then(() => v(T))));
5659
+ await Promise.allSettled(v.map((b) => Promise.resolve().then(() => b(T))));
5660
5660
  }, _ = {
5661
5661
  ...Gt({
5662
5662
  name: s ?? vs(this.name),
@@ -5668,18 +5668,18 @@ const Hc = b({ input: f() }), Jt = class Jt extends jc {
5668
5668
  execute: async (T, y, h) => {
5669
5669
  if (!Ku(T))
5670
5670
  throw new we("Agent tool called with invalid input");
5671
- const w = new xd(a ?? {}), v = typeof p == "function" || d.size > 0, N = v ? await w.run(this, T.input, {
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 w.run(this, T.input, {
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 (v) {
5682
+ if (b) {
5683
5683
  const G = N;
5684
5684
  for await (const L of G)
5685
5685
  await m({
@@ -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 = b({
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(b({ id: f().describe("OpenAI file ID") })).describe("Either base64 encoded image data, a data URL, or an object with a file ID.").optional(),
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(b({ id: f().describe("OpenAI file ID") })).or(b({ url: f().describe("Publicly accessible file URL") })).describe("Contents of the file or an object with a file ID.").optional(),
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(b({
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 = b({
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 = b({
5915
+ }), nl = w({
5916
5916
  url: f().describe("Publicly accessible URL pointing to the image content")
5917
- }), sl = b({
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 = b({
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 = b({
5923
+ }), al = w({
5924
5924
  url: f().describe("Publicly accessible URL for the file content"),
5925
5925
  filename: f().optional()
5926
- }), ol = b({
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
- b({ type: I("screenshot") }),
5961
- b({
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
- b({
5967
+ w({
5968
5968
  type: I("double_click"),
5969
5969
  x: E(),
5970
5970
  y: E()
5971
5971
  }),
5972
- b({
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
- b({
5979
+ w({
5980
5980
  type: I("type"),
5981
5981
  text: f()
5982
5982
  }),
5983
- b({ type: I("wait") }),
5984
- b({
5983
+ w({ type: I("wait") }),
5984
+ w({
5985
5985
  type: I("move"),
5986
5986
  x: E(),
5987
5987
  y: E()
5988
5988
  }),
5989
- b({
5989
+ w({
5990
5990
  type: I("keypress"),
5991
5991
  keys: J(f())
5992
5992
  }),
5993
- b({
5993
+ w({
5994
5994
  type: I("drag"),
5995
- path: J(b({ x: E(), y: E() }))
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 = b({
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
- b({ type: I("timeout") }),
6152
- b({
6151
+ w({ type: I("timeout") }),
6152
+ w({
6153
6153
  type: I("exit"),
6154
6154
  exitCode: E().int().nullable()
6155
6155
  })
6156
- ]), wl = b({
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 = b({
6165
+ }), Il = w({
6166
6166
  type: I("create_file"),
6167
6167
  path: f(),
6168
6168
  diff: f()
6169
- }), Sl = b({
6169
+ }), Sl = w({
6170
6170
  type: I("update_file"),
6171
6171
  path: f(),
6172
6172
  diff: f()
6173
- }), Tl = b({
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 = b({
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 = b({
6259
+ }), Ol = w({
6260
6260
  requests: E().optional(),
6261
6261
  inputTokens: E(),
6262
6262
  outputTokens: E(),
@@ -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 w;
6863
- const r = [], i = [], o = [], a = [], u = [], l = [], p = [], d = [], m = new Map(s.map((v) => [v.toolName, v])), g = new Map(t.filter((v) => v.type === "function").map((v) => [v.name, v])), _ = t.find((v) => v.type === "computer"), T = t.find((v) => v.type === "shell"), y = t.find((v) => v.type === "apply_patch"), h = new Map(t.filter((v) => {
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
6864
  var N;
6865
- return v.type === "hosted_tool" && ((N = v.providerData) == null ? void 0 : N.type) === "mcp";
6866
- }).map((v) => v).map((v) => [v.providerData.server_label, v]));
6867
- for (const v of n.output) {
6868
- if (v.type === "message")
6869
- v.role === "assistant" && r.push(new Ps(v, e));
6870
- else if (v.type === "hosted_tool_call") {
6871
- r.push(new Xe(v, e));
6872
- const x = v.name;
6873
- if (d.push(x), ((w = v.providerData) == null ? void 0 : w.type) === "mcp_approval_request" || v.name === "mcp_approval_request") {
6874
- const A = v.providerData, D = A.server_label, U = h.get(D);
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 (v.type === "reasoning")
6896
- r.push(new Pr(v, e));
6897
- else if (v.type === "computer_call") {
6898
- if (r.push(new Xe(v, e)), d.push("computer_use"), !_)
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: v,
6906
+ toolCall: b,
6907
6907
  computer: _
6908
6908
  });
6909
- } else if (v.type === "shell_call") {
6910
- if (r.push(new Xe(v, e)), d.push("shell"), !T)
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: v,
6918
+ toolCall: b,
6919
6919
  shell: T
6920
6920
  });
6921
- } else if (v.type === "apply_patch_call") {
6922
- if (r.push(new Xe(v, e)), d.push("apply_patch"), !y)
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,31 +6927,31 @@ 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: v,
6930
+ toolCall: b,
6931
6931
  applyPatch: y
6932
6932
  });
6933
6933
  }
6934
- if (v.type !== "function_call")
6934
+ if (b.type !== "function_call")
6935
6935
  continue;
6936
- d.push(v.name);
6937
- const N = m.get(v.name);
6936
+ d.push(b.name);
6937
+ const N = m.get(b.name);
6938
6938
  if (N)
6939
- r.push(new Dr(v, e)), i.push({
6940
- toolCall: v,
6939
+ r.push(new Dr(b, e)), i.push({
6940
+ toolCall: b,
6941
6941
  handoff: N
6942
6942
  });
6943
6943
  else {
6944
- const x = g.get(v.name);
6944
+ const x = g.get(b.name);
6945
6945
  if (!x)
6946
6946
  throw Qe({
6947
- message: `Tool ${v.name} not found in agent ${e.name}.`,
6947
+ message: `Tool ${b.name} not found in agent ${e.name}.`,
6948
6948
  data: {
6949
- tool_name: v.name,
6949
+ tool_name: b.name,
6950
6950
  agent_name: e.name
6951
6951
  }
6952
- }), new we(`Tool ${v.name} not found in agent ${e.name}.`);
6953
- r.push(new Xe(v, e)), o.push({
6954
- toolCall: v,
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
6955
  tool: x
6956
6956
  });
6957
6957
  }
@@ -6971,18 +6971,18 @@ function ki(n, e, t, s) {
6971
6971
  };
6972
6972
  }
6973
6973
  const Hl = ye("type", [
6974
- b({
6974
+ w({
6975
6975
  type: I("next_step_handoff"),
6976
6976
  newAgent: W()
6977
6977
  }),
6978
- b({
6978
+ w({
6979
6979
  type: I("next_step_final_output"),
6980
6980
  output: f()
6981
6981
  }),
6982
- b({
6982
+ w({
6983
6983
  type: I("next_step_run_again")
6984
6984
  }),
6985
- b({
6985
+ w({
6986
6986
  type: I("next_step_interruption"),
6987
6987
  data: se(f(), W())
6988
6988
  })
@@ -7037,7 +7037,7 @@ async function Ai(n, e, t, s, r, i, o) {
7037
7037
  const y = r.mcpApprovalRequests.filter((x) => {
7038
7038
  var A;
7039
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(), w = /* @__PURE__ */ new Set();
7040
+ }), h = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set();
7041
7041
  for (const x of y) {
7042
7042
  const A = x.requestItem.rawItem;
7043
7043
  if (A.type !== "hosted_tool_call")
@@ -7059,13 +7059,13 @@ async function Ai(n, e, t, s, r, i, o) {
7059
7059
  }, n);
7060
7060
  T(L);
7061
7061
  } else
7062
- h.add(x.requestItem), w.add(D), p.push({
7062
+ h.add(x.requestItem), v.add(D), p.push({
7063
7063
  type: "hosted_mcp_tool_approval",
7064
7064
  tool: x.mcpTool,
7065
7065
  runItem: x.requestItem
7066
7066
  }), T(x.requestItem);
7067
7067
  }
7068
- const v = t.filter((x) => {
7068
+ const b = t.filter((x) => {
7069
7069
  var A;
7070
7070
  if (!(x instanceof _e))
7071
7071
  return !0;
@@ -7073,7 +7073,7 @@ async function Ai(n, e, t, s, r, i, o) {
7073
7073
  if (h.has(x))
7074
7074
  return !0;
7075
7075
  const D = x.rawItem.id;
7076
- return D ? w.has(D) : !1;
7076
+ return D ? v.has(D) : !1;
7077
7077
  }
7078
7078
  return !1;
7079
7079
  }), N = await qa({
@@ -7083,10 +7083,10 @@ async function Ai(n, e, t, s, r, i, o) {
7083
7083
  functionResults: p,
7084
7084
  originalInput: e,
7085
7085
  newResponse: s,
7086
- preStepItems: v,
7086
+ preStepItems: b,
7087
7087
  newItems: g
7088
7088
  });
7089
- return N || new $e(e, s, v, g, { type: "next_step_run_again" });
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
7092
  var N, x, A, D, U, G;
@@ -7156,17 +7156,17 @@ async function Ci(n, e, t, s, r, i, o) {
7156
7156
  return T;
7157
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), w = h.length > 0 ? Na(h[h.length - 1].rawItem) : void 0;
7160
- if (typeof w > "u")
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: w
7166
+ output: v
7167
7167
  });
7168
- if (n.outputType !== "text" && w) {
7169
- const { parser: L } = xr(n.outputType, "final_output"), [ue] = await Ir(() => L(w));
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: w });
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" });
@@ -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.", w = {
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: [w]
7433
+ output: [v]
7434
7434
  }, n, h));
7435
7435
  continue;
7436
7436
  }
@@ -7850,23 +7850,23 @@ async function pd(n, e, t, s) {
7850
7850
  throw new ne("Session input callback must return an array of AgentInputItem objects.");
7851
7851
  const d = Pi(u), m = Pi(l), g = Di(u), _ = Di(l), T = [];
7852
7852
  for (const h of p) {
7853
- const w = $r(h);
7854
- if (Mi(_, w, h)) {
7855
- Fi(m, w), T.push(h);
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, w, h)) {
7859
- Fi(d, w);
7858
+ if (Mi(g, v, h)) {
7859
+ Fi(d, v);
7860
7860
  continue;
7861
7861
  }
7862
- const v = d.get(w) ?? 0;
7863
- if (v > 0) {
7864
- d.set(w, v - 1);
7862
+ const b = d.get(v) ?? 0;
7863
+ if (b > 0) {
7864
+ d.set(v, b - 1);
7865
7865
  continue;
7866
7866
  }
7867
- const N = m.get(w) ?? 0;
7867
+ const N = m.get(v) ?? 0;
7868
7868
  if (N > 0) {
7869
- m.set(w, N - 1), T.push(h);
7869
+ m.set(v, N - 1), T.push(h);
7870
7870
  continue;
7871
7871
  }
7872
7872
  T.push(h);
@@ -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 = b({
8042
+ const is = "1.0", gd = I(is), Me = w({
8043
8043
  name: f()
8044
- }), yd = b({
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: b({
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 = b({
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 = b({
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 = b({
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
- b({
8079
+ w({
8080
8080
  type: I("message_output_item"),
8081
8081
  rawItem: Es,
8082
8082
  agent: Me
8083
8083
  }),
8084
- b({
8084
+ w({
8085
8085
  type: I("tool_call_item"),
8086
8086
  rawItem: kl.or(xn),
8087
8087
  agent: Me
8088
8088
  }),
8089
- b({
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
- b({
8095
+ w({
8096
8096
  type: I("reasoning_item"),
8097
8097
  rawItem: Rr,
8098
8098
  agent: Me
8099
8099
  }),
8100
- b({
8100
+ w({
8101
8101
  type: I("handoff_call_item"),
8102
8102
  rawItem: kn,
8103
8103
  agent: Me
8104
8104
  }),
8105
- b({
8105
+ w({
8106
8106
  type: I("handoff_output_item"),
8107
8107
  rawItem: ws,
8108
8108
  sourceAgent: Me,
8109
8109
  targetAgent: Me
8110
8110
  }),
8111
- b({
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 = b({
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 = b({
8123
+ }), bd = w({
8124
8124
  newItems: J(Qa),
8125
8125
  toolsUsed: J(f()),
8126
- handoffs: J(b({
8126
+ handoffs: J(w({
8127
8127
  toolCall: W(),
8128
8128
  handoff: W()
8129
8129
  })),
8130
- functions: J(b({
8130
+ functions: J(w({
8131
8131
  toolCall: W(),
8132
8132
  tool: W()
8133
8133
  })),
8134
- computerActions: J(b({
8134
+ computerActions: J(w({
8135
8135
  toolCall: W(),
8136
8136
  computer: W()
8137
8137
  })),
8138
- shellActions: J(b({
8138
+ shellActions: J(w({
8139
8139
  toolCall: W(),
8140
8140
  shell: W()
8141
8141
  })).optional(),
8142
- applyPatchActions: J(b({
8142
+ applyPatchActions: J(w({
8143
8143
  toolCall: W(),
8144
8144
  applyPatch: W()
8145
8145
  })).optional(),
8146
- mcpApprovalRequests: J(b({
8147
- requestItem: b({
8146
+ mcpApprovalRequests: J(w({
8147
+ requestItem: w({
8148
8148
  // protocol.HostedToolCallItem
8149
- rawItem: b({
8149
+ rawItem: w({
8150
8150
  type: I("hosted_tool_call"),
8151
8151
  name: f(),
8152
8152
  arguments: f().optional(),
@@ -8157,38 +8157,38 @@ const is = "1.0", gd = I(is), Me = b({
8157
8157
  })
8158
8158
  }),
8159
8159
  // HostedMCPTool
8160
- mcpTool: b({
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 = b({
8166
+ }), eo = w({
8167
8167
  tripwireTriggered: Pt(),
8168
8168
  outputInfo: W()
8169
- }), wd = b({
8170
- guardrail: b({
8169
+ }), wd = w({
8170
+ guardrail: w({
8171
8171
  type: I("input"),
8172
8172
  name: f()
8173
8173
  }),
8174
8174
  output: eo
8175
- }), Id = b({
8176
- guardrail: b({
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 = b({
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: b({
8189
+ context: w({
8190
8190
  usage: Xa,
8191
- approvals: se(f(), b({
8191
+ approvals: se(f(), w({
8192
8192
  approved: J(f()).or(Pt()),
8193
8193
  rejected: J(f()).or(Pt())
8194
8194
  })),
@@ -8668,11 +8668,11 @@ class xd extends Uc {
8668
8668
  if (!u)
8669
8669
  return g;
8670
8670
  };
8671
- let w = s;
8672
- if (!(w instanceof Ve)) {
8673
- if (d && Array.isArray(w) && !o)
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 x = await pd(w, d, o, {
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,
@@ -8680,9 +8680,9 @@ class xd extends Uc {
8680
8680
  });
8681
8681
  if (p && d) {
8682
8682
  const A = x.sessionItems;
8683
- A && A.length > 0 ? w = A : w = x.preparedInput;
8683
+ A && A.length > 0 ? v = A : v = x.preparedInput;
8684
8684
  } else
8685
- w = x.preparedInput;
8685
+ v = x.preparedInput;
8686
8686
  if (d) {
8687
8687
  const A = x.sessionItems ?? [];
8688
8688
  g = A.map((D) => structuredClone(D)), T = /* @__PURE__ */ new Map();
@@ -8692,10 +8692,10 @@ class xd extends Uc {
8692
8692
  }
8693
8693
  }
8694
8694
  }
8695
- let v;
8695
+ let b;
8696
8696
  if (d && !p) {
8697
8697
  let x = !1;
8698
- v = async () => {
8698
+ b = async () => {
8699
8699
  if (x)
8700
8700
  return;
8701
8701
  const A = h();
@@ -8704,11 +8704,11 @@ class xd extends Uc {
8704
8704
  }
8705
8705
  const N = async () => {
8706
8706
  if (l.stream)
8707
- return await z(this, ie, ao).call(this, t, w, l, v, y);
8708
- const x = await z(this, ie, ro).call(this, t, w, l, y);
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
8709
  return d && !p && await ld(d, h(), x), x;
8710
8710
  };
8711
- return w instanceof Ve && w._trace ? Nd(w._trace, async () => (w._currentAgentSpan && jr(w._currentAgentSpan), N())) : Pd(async () => N(), {
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,
@@ -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 w = ki(a._lastTurnResponse, a._currentAgent, h.tools, h.handoffs);
8793
- a._lastProcessedResponse = w;
8794
- const v = 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 = v.originalInput, a._generatedItems = v.generatedItems, v.nextStep.type === "next_step_run_again" && (a._currentTurnPersistedItemCount = 0), a._currentStep = v.nextStep, T && await T;
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);
@@ -8843,34 +8843,34 @@ 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 w = await Ai(t.state._currentAgent, t.state._originalInput, t.state._generatedItems, t.state._lastTurnResponse, t.state._lastProcessedResponse, this, t.state);
8847
- if (Oi(t, w), t.state._toolUseTracker.addToolUse(t.state._currentAgent, t.state._lastProcessedResponse.toolsUsed), t.state._originalInput = w.originalInput, t.state._generatedItems = w.generatedItems, w.nextStep.type === "next_step_interruption") {
8848
- t.state._currentStep = w.nextStep;
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 (w.nextStep.type === "next_step_run_again") {
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 = w.nextStep;
8855
+ m = !1, t.state._currentStep = v.nextStep;
8856
8856
  }
8857
8857
  if (t.state._currentStep.type === "next_step_run_again") {
8858
- const w = await Zi(t.state), v = r && m;
8859
- if (m = !1, v || (t.state._currentTurn++, t.state._currentTurnPersistedItemCount = 0), t.state._currentTurn > t.state._maxTurns)
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
8865
  let N, x;
8866
- if (t.state._currentTurn === 1 && !v) {
8866
+ if (t.state._currentTurn === 1 && !b) {
8867
8867
  const Y = z(this, ie, dr).call(this, t.state);
8868
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, w, A, u, o);
8873
+ const U = await z(this, ie, fr).call(this, t.state, s, v, A, u, o);
8874
8874
  if (N)
8875
8875
  throw N;
8876
8876
  l = !0, await d();
@@ -9018,7 +9018,7 @@ ie = new WeakSet(), lr = function(t) {
9018
9018
  p = Cd(l, t._currentAgent.modelSettings, u, p), p = Wl(t._currentAgent, t._toolUseTracker, p);
9019
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
9020
  o == null || o.markInputAsSent(_), a == null || a(_, y ? T : void 0);
9021
- const h = (o == null ? void 0 : o.previousResponseId) ?? s.previousResponseId, w = (o == null ? void 0 : o.conversationId) ?? s.conversationId;
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: w
9030
+ conversationId: v
9031
9031
  };
9032
9032
  };
9033
9033
  function Vt(n, e) {
@@ -9081,9 +9081,9 @@ async function Ad(n, e, t, s, r) {
9081
9081
  const h = o.get(y);
9082
9082
  if (h)
9083
9083
  return l(h), qi(a, h), h;
9084
- const w = wt(y), v = Ed(a, w);
9085
- if (v)
9086
- return l(v), v;
9084
+ const v = wt(y), b = Ed(a, v);
9085
+ if (b)
9086
+ return l(b), b;
9087
9087
  const N = p();
9088
9088
  if (N)
9089
9089
  return N;
@@ -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
- b({
10238
+ w({
10239
10239
  itemId: f()
10240
10240
  });
10241
10241
  const Yi = ye("role", [
10242
- b({
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(b({ type: I("input_text"), text: f() }))
10247
+ content: J(w({ type: I("input_text"), text: f() }))
10248
10248
  }),
10249
- b({
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(b({ type: I("input_text"), text: f() }).or(b({
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
- b({
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(b({ type: I("output_text"), text: f() }).or(b({
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 = b({
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 = b({
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 = b({
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
10295
  approved: Pt().optional().nullable()
10296
- }), ke = Ia("openai-agents:realtime"), mo = b({
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: b({
10307
- output: b({
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: b({
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 = b({
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 = b({
10332
+ }), fn = w({
10333
10333
  id: f().optional(),
10334
10334
  arguments: f().optional(),
10335
10335
  call_id: f().optional(),
@@ -10353,147 +10353,147 @@ const Yi = ye("role", [
10353
10353
  reason: f().nullable().optional(),
10354
10354
  server_label: f().optional(),
10355
10355
  error: W().nullable().optional(),
10356
- tools: J(b({
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 = b({
10361
+ }).passthrough(), ap = w({
10362
10362
  type: I("conversation.created"),
10363
10363
  event_id: f(),
10364
- conversation: b({
10364
+ conversation: w({
10365
10365
  id: f().optional(),
10366
10366
  object: I("realtime.conversation").optional()
10367
10367
  })
10368
- }), op = b({
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 = b({
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 = b({
10378
+ }), cp = w({
10379
10379
  type: I("conversation.item.deleted"),
10380
10380
  event_id: f(),
10381
10381
  item_id: f()
10382
- }), lp = b({
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: b({
10389
+ usage: w({
10390
10390
  type: I("tokens"),
10391
10391
  total_tokens: E(),
10392
10392
  input_tokens: E(),
10393
- input_token_details: b({
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 = b({
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 = b({
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: b({
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 = b({
10417
+ }), fp = w({
10418
10418
  type: I("conversation.item.retrieved"),
10419
10419
  event_id: f(),
10420
10420
  item: fn
10421
- }), hp = b({
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 = b({
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 = b({
10432
+ }), gp = w({
10433
10433
  type: I("conversation.item.delete"),
10434
10434
  item_id: f(),
10435
10435
  event_id: f().optional()
10436
- }), yp = b({
10436
+ }), yp = w({
10437
10437
  type: I("conversation.item.retrieve"),
10438
10438
  item_id: f(),
10439
10439
  event_id: f().optional()
10440
- }), _p = b({
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 = b({
10446
+ }), vp = w({
10447
10447
  type: I("error"),
10448
10448
  event_id: f().optional(),
10449
10449
  error: W().optional()
10450
- }), bp = b({
10450
+ }), bp = w({
10451
10451
  type: I("input_audio_buffer.cleared"),
10452
10452
  event_id: f()
10453
- }), wp = b({
10453
+ }), wp = w({
10454
10454
  type: I("input_audio_buffer.append"),
10455
10455
  audio: f(),
10456
10456
  event_id: f().optional()
10457
- }), Ip = b({
10457
+ }), Ip = w({
10458
10458
  type: I("input_audio_buffer.clear"),
10459
10459
  event_id: f().optional()
10460
- }), Sp = b({
10460
+ }), Sp = w({
10461
10461
  type: I("input_audio_buffer.commit"),
10462
10462
  event_id: f().optional()
10463
- }), Tp = b({
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 = b({
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 = b({
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 = b({
10478
+ }), Ap = w({
10479
10479
  type: I("output_audio_buffer.started"),
10480
10480
  event_id: f()
10481
- }).passthrough(), Cp = b({
10481
+ }).passthrough(), Cp = w({
10482
10482
  type: I("output_audio_buffer.stopped"),
10483
10483
  event_id: f()
10484
- }).passthrough(), Op = b({
10484
+ }).passthrough(), Op = w({
10485
10485
  type: I("output_audio_buffer.cleared"),
10486
10486
  event_id: f()
10487
- }), Ep = b({
10487
+ }), Ep = w({
10488
10488
  type: I("rate_limits.updated"),
10489
10489
  event_id: f(),
10490
- rate_limits: J(b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
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: b({
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 = b({
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: b({
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 = b({
10554
+ }), $p = w({
10555
10555
  type: I("response.created"),
10556
10556
  event_id: f(),
10557
10557
  response: mo
10558
- }), go = b({
10558
+ }), go = w({
10559
10559
  type: I("response.done"),
10560
10560
  event_id: f(),
10561
10561
  response: mo
10562
- }), jp = b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
10607
+ }), qp = w({
10608
10608
  type: I("session.created"),
10609
10609
  event_id: f(),
10610
10610
  session: W()
10611
- }), Jp = b({
10611
+ }), Jp = w({
10612
10612
  type: I("session.updated"),
10613
10613
  event_id: f(),
10614
10614
  session: W()
10615
- }), Gp = b({
10615
+ }), Gp = w({
10616
10616
  type: I("response.cancel"),
10617
10617
  event_id: f().optional(),
10618
10618
  response_id: f().optional()
10619
- }), Vp = b({
10619
+ }), Vp = w({
10620
10620
  type: I("response.create"),
10621
10621
  event_id: f().optional(),
10622
10622
  response: W().optional()
10623
- }), Hp = b({
10623
+ }), Hp = w({
10624
10624
  type: I("session.update"),
10625
10625
  event_id: f().optional(),
10626
10626
  session: W()
10627
- }), Wp = b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
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 = b({
10664
+ }), nf = w({
10665
10665
  type: f(),
10666
10666
  event_id: f().optional().nullable()
10667
10667
  }).passthrough(), sf = ye("type", [
@@ -11011,7 +11011,7 @@ 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, _, T, y, h, w, v, N, x, A, D, U, G, L, ue, Y, oe, Ee, Pe, hn;
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,
@@ -11022,7 +11022,7 @@ const Br = class Br extends Ar {
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
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((w = (h = s.audio) == null ? void 0 : h.input) == null ? void 0 : w.turnDetection) ?? ((N = (v = De.audio) == null ? void 0 : v.input) == null ? void 0 : N.turnDetection)
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
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),
@@ -11070,8 +11070,8 @@ const Br = class Br extends Ar {
11070
11070
  threshold: g,
11071
11071
  ...y
11072
11072
  };
11073
- return Object.keys(h).forEach((w) => {
11074
- h[w] === void 0 && delete h[w];
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
  /**
@@ -11353,19 +11353,19 @@ class af extends Ts {
11353
11353
  h.autoplay = !0, g.ontrack = (A) => {
11354
11354
  h.srcObject = A.streams[0];
11355
11355
  };
11356
- const w = this.options.mediaStream ?? await navigator.mediaDevices.getUserMedia({
11356
+ const v = this.options.mediaStream ?? await navigator.mediaDevices.getUserMedia({
11357
11357
  audio: !0
11358
11358
  });
11359
- if (g.addTrack(w.getAudioTracks()[0]), this.options.changePeerConnection) {
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 v = await g.createOffer();
11364
- if (await g.setLocalDescription(v), !v.sdp)
11363
+ const b = await g.createOffer();
11364
+ if (await g.setLocalDescription(b), !b.sdp)
11365
11365
  throw new Error("Failed to create offer");
11366
11366
  const N = await fetch(m, {
11367
11367
  method: "POST",
11368
- body: v.sdp,
11368
+ body: b.sdp,
11369
11369
  headers: {
11370
11370
  "Content-Type": "application/sdp",
11371
11371
  Authorization: `Bearer ${i}`,
@@ -11652,23 +11652,23 @@ pt = new WeakMap(), Ct = new WeakMap(), Ot = new WeakMap(), fe = new WeakMap(),
11652
11652
  if (!(!u || l)) {
11653
11653
  if (u.type === "response.output_audio.delta") {
11654
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), w = (m = (d = (p = this._rawSessionConfig) == null ? void 0 : p.audio) == null ? void 0 : d.output) == null ? void 0 : m.format;
11656
- if (w && typeof w == "object") {
11657
- const N = w.type;
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
11658
  if (N === "audio/pcmu" || N === "audio/pcma")
11659
11659
  this._audioLengthMs += h.byteLength / 8;
11660
11660
  else if (N === "audio/pcm") {
11661
- const x = w.rate ?? 24e3;
11661
+ const x = v.rate ?? 24e3;
11662
11662
  this._audioLengthMs += h.byteLength / 2 / x * 1e3;
11663
11663
  } else
11664
11664
  this._audioLengthMs += h.byteLength / 24 / 2;
11665
- } else typeof w == "string" ? w.startsWith("g711_") ? this._audioLengthMs += h.byteLength / 8 : this._audioLengthMs += h.byteLength / 24 / 2 : this._audioLengthMs += h.byteLength / 24 / 2;
11666
- const v = {
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(v);
11671
+ this._onAudio(b);
11672
11672
  } else if (u.type === "input_audio_buffer.speech_started") {
11673
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);
@@ -12264,17 +12264,51 @@ class wf extends hf {
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
- const a = r == null ? void 0 : r.greetingInstructions;
12269
- if (a)
12270
- try {
12271
- this._setSessionMuted(!0, "greeting"), await this.session.sendMessage(a);
12272
- } catch (u) {
12273
- $("WARN", "BabelbeezClient: failed to send greeting instructions.", u);
12274
- } finally {
12275
- this.isTerminating || this._setSessionMuted(!1, "greeting");
12276
- }
12277
- this._resetInactivityState(), $("INFO", "BabelbeezClient: Realtime session connected.");
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,99 +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 a, u, l, p;
12556
- const e = (a = this.currentSystemSettings) != null && a.system_prompt ? `${this.currentSystemSettings.system_prompt}
12589
+ var u, l, p, d;
12590
+ const e = (u = this.currentSystemSettings) != null && u.system_prompt ? `${this.currentSystemSettings.system_prompt}
12557
12591
 
12558
- ${((u = this.currentChatbotSettings) == null ? void 0 : u.instructions) || ""}`.trim() : ((l = this.currentChatbotSettings) == null ? void 0 : l.instructions) || "", t = this, s = Gt({
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: ((p = this.currentSystemSettings) == null ? void 0 : p.rag_search_description) || "Searches the knowledge base for relevant context.",
12561
- parameters: b({
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: d }) {
12565
- if ($("INFO", `Tool perform_rag_search called with query: "${d}"`), t._resetInactivityState(), !t.currentRagSearchUrl || !t.publicChatbotId)
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 m = t.isAssistantSpeaking;
12604
+ const g = t.isAssistantSpeaking;
12571
12605
  t.isAssistantSpeaking = !0, t.emit("buttonState", "rag-retrieval");
12572
12606
  try {
12573
- const g = await fetch(t.currentRagSearchUrl, {
12607
+ const _ = await fetch(t.currentRagSearchUrl, {
12574
12608
  method: "POST",
12575
12609
  headers: { "Content-Type": "application/json" },
12576
- body: JSON.stringify({ query: d, public_chatbot_id: t.publicChatbotId })
12610
+ body: JSON.stringify({ query: m, public_chatbot_id: t.publicChatbotId })
12577
12611
  });
12578
- if (!g.ok) {
12579
- let y = `RAG search failed: ${g.status} ${g.statusText}`;
12612
+ if (!_.ok) {
12613
+ let h = `RAG search failed: ${_.status} ${_.statusText}`;
12580
12614
  try {
12581
- const h = await g.json();
12582
- h && h.detail && (y = h.detail);
12615
+ const v = await _.json();
12616
+ v && v.detail && (h = v.detail);
12583
12617
  } catch {
12584
12618
  }
12585
- return $("ERROR", y), "Knowledge search failed; please answer based on your existing knowledge.";
12619
+ return $("ERROR", h), "Knowledge search failed; please answer based on your existing knowledge.";
12586
12620
  }
12587
- const T = (await g.json()).context || "";
12588
- return $("INFO", `RAG search succeeded. Context length: ${T.length}`), T || "No additional knowledge was found.";
12589
- } catch (g) {
12590
- return $("ERROR", "Network or unexpected error during RAG search.", g), "Knowledge search failed due to a network error.";
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 = m, t.emit("buttonState", "active");
12626
+ t.isAssistantSpeaking = g, t.emit("buttonState", "active");
12593
12627
  }
12594
12628
  }
12595
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: b({
12632
+ parameters: w({
12599
12633
  summary_text: f(),
12600
12634
  announcement: f()
12601
12635
  }),
12602
- async execute({ summary_text: d, announcement: m }) {
12603
- var y;
12636
+ async execute({ summary_text: m, announcement: g }) {
12637
+ var h;
12604
12638
  $("INFO", "Tool request_human_handoff called."), t._resetInactivityState();
12605
- const g = m || "Please fill out the form so that I can connect you to a staff member to follow up";
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(g);
12608
- } catch (h) {
12609
- $("WARN", "Failed to send handoff announcement message.", h);
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 _ = null;
12613
- const T = (y = t.currentChatbotSettings) == null ? void 0 : y.handoff_whatsapp_number;
12614
- if (T) {
12615
- const h = String(T).replace(/\D+/g, "");
12616
- h && (_ = `https://wa.me/${h}?text=${encodeURIComponent(d || "Summary not available.")}`);
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 = d || "Summary not available.", t.emit("handoff:show", {
12652
+ return t.currentHandoffSummaryText = m || "Summary not available.", t.emit("handoff:show", {
12619
12653
  summaryText: t.currentHandoffSummaryText,
12620
- waLink: _
12621
- }), await new Promise((h) => {
12622
- t.handoffPromiseResolve = h;
12623
- }).then((h) => h === "whatsapp_submitted" ? "User chose WhatsApp handoff." : h === "email_submitted" ? "Handoff request submitted successfully." : "Handoff flow completed or cancelled by the user.");
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
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: b({}),
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 (d) {
12667
+ } catch (m) {
12634
12668
  $(
12635
12669
  "WARN",
12636
12670
  "Error interrupting session during AI end_conversation; proceeding anyway.",
12637
- d
12671
+ m
12638
12672
  );
12639
12673
  }
12640
12674
  await t._playGoodbyeThenFinalize("ai_end_conversation_tool");
12641
12675
  })(), "Conversation ended.");
12642
12676
  }
12643
- });
12677
+ }), o = [s, r, i];
12644
12678
  return new Xd({
12645
12679
  name: "Assistant",
12646
12680
  instructions: e,
12647
- tools: [s, r, i]
12681
+ tools: o
12648
12682
  });
12649
12683
  }
12650
12684
  _createVoiceSession(e, t) {
@@ -12697,7 +12731,7 @@ ${((u = this.currentChatbotSettings) == null ? void 0 : u.instructions) || ""}`.
12697
12731
  }), this.session.transport && (this.session.transport.on("*", (e) => {
12698
12732
  var t, s;
12699
12733
  if (e) {
12700
- 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") {
12701
12735
  this.isUserSpeaking = !0, this._currentUserTranscript = "", this._resetInactivityState();
12702
12736
  return;
12703
12737
  }
@@ -12816,10 +12850,14 @@ ${((u = this.currentChatbotSettings) == null ? void 0 : u.instructions) || ""}`.
12816
12850
  $("DEBUG", "BabelbeezClient: Sending heartbeat", {
12817
12851
  session_id: this.currentSessionId,
12818
12852
  heartbeatUrl: e
12819
- }), (await fetch(e, {
12853
+ });
12854
+ const t = {
12855
+ session_id: this.currentSessionId
12856
+ };
12857
+ (await fetch(e, {
12820
12858
  method: "POST",
12821
12859
  headers: { "Content-Type": "application/json" },
12822
- body: JSON.stringify({ session_id: this.currentSessionId })
12860
+ body: JSON.stringify(t)
12823
12861
  })).ok;
12824
12862
  } catch (e) {
12825
12863
  $("ERROR", "BabelbeezClient: Error sending heartbeat.", e);