@8wave/ai-elements 0.125.0-beta.16 → 0.125.0-beta.17

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.
Files changed (103) hide show
  1. package/README.md +23 -0
  2. package/dist/_chunks/{PkFilePreview-8nVPKv8k.js → PkFilePreview-BIFkMsAC.js} +559 -718
  3. package/dist/_chunks/PkFilePreview-BIFkMsAC.js.map +1 -0
  4. package/dist/_chunks/{PkFilePreviewDialog-BHPcGlnF.js → PkFilePreviewDialog-NLk4gZMd.js} +8 -8
  5. package/dist/_chunks/{PkFilePreviewDialog-BHPcGlnF.js.map → PkFilePreviewDialog-NLk4gZMd.js.map} +1 -1
  6. package/dist/_chunks/PkSelectionActions-CUymhwsG.js +168 -0
  7. package/dist/_chunks/PkSelectionActions-CUymhwsG.js.map +1 -0
  8. package/dist/ai-elements.es.js +4548 -4153
  9. package/dist/ai-elements.es.js.map +1 -1
  10. package/dist-vue/PkChatbot.js +1 -1
  11. package/dist-vue/PkChatbotEmptyState.js +1 -1
  12. package/dist-vue/PkChatbotInput.js +1 -1
  13. package/dist-vue/PkChatbotMessages.js +1 -1
  14. package/dist-vue/PkChatbotStepPayload.js +1 -1
  15. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  16. package/dist-vue/PkChatbotSteps.js +1 -1
  17. package/dist-vue/PkChatbotViewChat.js +1 -1
  18. package/dist-vue/PkChatbotViewConversations.js +1 -1
  19. package/dist-vue/PkChatbotViewFiles.js +1 -1
  20. package/dist-vue/PkChatbotViewProfile.js +1 -1
  21. package/dist-vue/_chunks/{Agent-DmxsItHG.js → Agent-Cm1LrkYm.js} +162 -162
  22. package/dist-vue/_chunks/{Agent-DmxsItHG.js.map → Agent-Cm1LrkYm.js.map} +1 -1
  23. package/dist-vue/_chunks/{Document-CXfJxfu6.js → Document-DHBTrCuO.js} +10 -10
  24. package/dist-vue/_chunks/{Document-CXfJxfu6.js.map → Document-DHBTrCuO.js.map} +1 -1
  25. package/dist-vue/_chunks/{PkChatbot-Bpo22_yE.js → PkChatbot-BtUaZ-LR.js} +10 -9
  26. package/dist-vue/_chunks/PkChatbot-BtUaZ-LR.js.map +1 -0
  27. package/dist-vue/_chunks/{PkChatbotEmptyState-CQ_Qdkge.js → PkChatbotEmptyState-DJIkAskP.js} +2 -2
  28. package/dist-vue/_chunks/{PkChatbotEmptyState-CQ_Qdkge.js.map → PkChatbotEmptyState-DJIkAskP.js.map} +1 -1
  29. package/dist-vue/_chunks/{PkChatbotInput-BVu1b2Te.js → PkChatbotInput-DzqaW3EE.js} +2 -2
  30. package/dist-vue/_chunks/{PkChatbotInput-BVu1b2Te.js.map → PkChatbotInput-DzqaW3EE.js.map} +1 -1
  31. package/dist-vue/_chunks/{PkChatbotMessages-DftNL5ZQ.js → PkChatbotMessages-vkbq5p1X.js} +17 -17
  32. package/dist-vue/_chunks/{PkChatbotMessages-DftNL5ZQ.js.map → PkChatbotMessages-vkbq5p1X.js.map} +1 -1
  33. package/dist-vue/_chunks/{PkChatbotStepPayload-AiDZPbds.js → PkChatbotStepPayload-cuYclK_2.js} +2 -2
  34. package/dist-vue/_chunks/{PkChatbotStepPayload-AiDZPbds.js.map → PkChatbotStepPayload-cuYclK_2.js.map} +1 -1
  35. package/dist-vue/_chunks/{PkChatbotStepToolDetail-CALZDpfQ.js → PkChatbotStepToolDetail-Yd8cUQJP.js} +3 -3
  36. package/dist-vue/_chunks/{PkChatbotStepToolDetail-CALZDpfQ.js.map → PkChatbotStepToolDetail-Yd8cUQJP.js.map} +1 -1
  37. package/dist-vue/_chunks/{PkChatbotSteps-CY7pN2Gl.js → PkChatbotSteps-D5yz8lut.js} +5 -5
  38. package/dist-vue/_chunks/{PkChatbotSteps-CY7pN2Gl.js.map → PkChatbotSteps-D5yz8lut.js.map} +1 -1
  39. package/dist-vue/_chunks/{PkChatbotViewChat-Drp0At_n.js → PkChatbotViewChat-DCPRePrE.js} +7 -7
  40. package/dist-vue/_chunks/{PkChatbotViewChat-Drp0At_n.js.map → PkChatbotViewChat-DCPRePrE.js.map} +1 -1
  41. package/dist-vue/_chunks/{PkChatbotViewConversations-C0KqM_Wq.js → PkChatbotViewConversations-BBd3XMmM.js} +3 -3
  42. package/dist-vue/_chunks/{PkChatbotViewConversations-C0KqM_Wq.js.map → PkChatbotViewConversations-BBd3XMmM.js.map} +1 -1
  43. package/dist-vue/_chunks/{PkChatbotViewFiles-B9mYRoNK.js → PkChatbotViewFiles-BiQzDqJg.js} +3 -3
  44. package/dist-vue/_chunks/{PkChatbotViewFiles-B9mYRoNK.js.map → PkChatbotViewFiles-BiQzDqJg.js.map} +1 -1
  45. package/dist-vue/_chunks/{PkChatbotViewProfile-BfNE3d7F.js → PkChatbotViewProfile-7266UiRM.js} +2 -2
  46. package/dist-vue/_chunks/{PkChatbotViewProfile-BfNE3d7F.js.map → PkChatbotViewProfile-7266UiRM.js.map} +1 -1
  47. package/dist-vue/_chunks/{PkFilePreview-z7JcRtjP.js → PkFilePreview-DLo9nI2g.js} +426 -426
  48. package/dist-vue/_chunks/PkFilePreview-DLo9nI2g.js.map +1 -0
  49. package/dist-vue/_chunks/{PkFilePreviewDialog-zVon3aPY.js → PkFilePreviewDialog-CgDJQgIJ.js} +2 -2
  50. package/dist-vue/_chunks/{PkFilePreviewDialog-zVon3aPY.js.map → PkFilePreviewDialog-CgDJQgIJ.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkStreamingMarkdown-bJEDk-kM.js → PkStreamingMarkdown-C3UGCEXm.js} +3 -3
  52. package/dist-vue/_chunks/{PkStreamingMarkdown-bJEDk-kM.js.map → PkStreamingMarkdown-C3UGCEXm.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkToolChatFile-DqLGwJxp.js → PkToolChatFile-Dy0rGC29.js} +3 -3
  54. package/dist-vue/_chunks/{PkToolChatFile-DqLGwJxp.js.map → PkToolChatFile-Dy0rGC29.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkToolRequestGeolocation-BnV7A6SW.js → PkToolRequestGeolocation-p7Ip17F7.js} +2 -2
  56. package/dist-vue/_chunks/{PkToolRequestGeolocation-BnV7A6SW.js.map → PkToolRequestGeolocation-p7Ip17F7.js.map} +1 -1
  57. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-QCbQ7bnl.js → PkToolRequestOAuthConnection-CtXSzKzM.js} +2 -2
  58. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-QCbQ7bnl.js.map → PkToolRequestOAuthConnection-CtXSzKzM.js.map} +1 -1
  59. package/dist-vue/_chunks/{PkToolShowArtifact-DanzULWt.js → PkToolShowArtifact-B7udnhpb.js} +2 -2
  60. package/dist-vue/_chunks/{PkToolShowArtifact-DanzULWt.js.map → PkToolShowArtifact-B7udnhpb.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkToolShowContactForm-DzttQBG6.js → PkToolShowContactForm-0SEgxn2S.js} +2 -2
  62. package/dist-vue/_chunks/{PkToolShowContactForm-DzttQBG6.js.map → PkToolShowContactForm-0SEgxn2S.js.map} +1 -1
  63. package/dist-vue/_chunks/{PkToolShowDiagram-BNa89wcw.js → PkToolShowDiagram-BqHBhZgd.js} +2 -2
  64. package/dist-vue/_chunks/{PkToolShowDiagram-BNa89wcw.js.map → PkToolShowDiagram-BqHBhZgd.js.map} +1 -1
  65. package/dist-vue/_chunks/{PkToolShowForm-BXol1WE3.js → PkToolShowForm-C4n_3mFL.js} +4 -4
  66. package/dist-vue/_chunks/{PkToolShowForm-BXol1WE3.js.map → PkToolShowForm-C4n_3mFL.js.map} +1 -1
  67. package/dist-vue/_chunks/{PkToolShowImageGallery-Dmr5zXTj.js → PkToolShowImageGallery-DEpdtLns.js} +2 -2
  68. package/dist-vue/_chunks/{PkToolShowImageGallery-Dmr5zXTj.js.map → PkToolShowImageGallery-DEpdtLns.js.map} +1 -1
  69. package/dist-vue/_chunks/{PkToolShowProductList-C_uIUG_G.js → PkToolShowProductList-Bm2NLUGS.js} +2 -2
  70. package/dist-vue/_chunks/{PkToolShowProductList-C_uIUG_G.js.map → PkToolShowProductList-Bm2NLUGS.js.map} +1 -1
  71. package/dist-vue/_chunks/{PkToolShowSources-BHRNGn4s.js → PkToolShowSources-DwFqlit2.js} +3 -3
  72. package/dist-vue/_chunks/{PkToolShowSources-BHRNGn4s.js.map → PkToolShowSources-DwFqlit2.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DHCqxA1P.js → PkToolShowSuggestedReply-BRIzGNwx.js} +2 -2
  74. package/dist-vue/_chunks/{PkToolShowSuggestedReply-DHCqxA1P.js.map → PkToolShowSuggestedReply-BRIzGNwx.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolShowVideo-P4H5A7ke.js → PkToolShowVideo-BLEJ8tng.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolShowVideo-P4H5A7ke.js.map → PkToolShowVideo-BLEJ8tng.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolShowWebPages-BzNZHR7Q.js → PkToolShowWebPages-CeAXllAF.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolShowWebPages-BzNZHR7Q.js.map → PkToolShowWebPages-CeAXllAF.js.map} +1 -1
  79. package/dist-vue/_chunks/{createChatbotApiClient-CQjxHqLr.js → createChatbotApiClient-BPN6cLGF.js} +14 -14
  80. package/dist-vue/_chunks/{createChatbotApiClient-CQjxHqLr.js.map → createChatbotApiClient-BPN6cLGF.js.map} +1 -1
  81. package/dist-vue/_chunks/{useChatbotStore-CyZha9pf.js → useChatbotStore-C4xhJtrb.js} +1242 -1242
  82. package/dist-vue/_chunks/{useChatbotStore-CyZha9pf.js.map → useChatbotStore-C4xhJtrb.js.map} +1 -1
  83. package/dist-vue/_chunks/{utils-8lO2Gj-m.js → utils-RwaXl9-x.js} +4 -4
  84. package/dist-vue/_chunks/{utils-8lO2Gj-m.js.map → utils-RwaXl9-x.js.map} +1 -1
  85. package/dist-vue/api.js +1 -1
  86. package/dist-vue/apps/web-component/src/components/EmbeddedChatWidget.ce.d.ts +4 -4
  87. package/dist-vue/apps/web-component/src/composables/usePagePointer.d.ts +14 -9
  88. package/dist-vue/apps/web-component/src/composables/usePendingMessage.d.ts +29 -15
  89. package/dist-vue/apps/web-component/src/composables/useSelectionActions.d.ts +77 -0
  90. package/dist-vue/composables.js +34 -8
  91. package/dist-vue/composables.js.map +1 -1
  92. package/dist-vue/index.js +5401 -5321
  93. package/dist-vue/index.js.map +1 -1
  94. package/dist-vue/locales.js +22 -2
  95. package/dist-vue/packages/components/src/chat/PkAgentSelectionActionsSettings.d.ts +25 -0
  96. package/dist-vue/packages/components/src/chat/PkAgentSettingsPanel.d.ts +23 -3
  97. package/dist-vue/packages/components/src/chat/PkChatbot.d.ts +2 -1
  98. package/dist-vue/packages/components/src/chat/PkSelectionActions.d.ts +2 -12
  99. package/dist-vue/packages/components/src/chat/PkSelectionAnswerCard.d.ts +41 -0
  100. package/package.json +1 -1
  101. package/dist/_chunks/PkFilePreview-8nVPKv8k.js.map +0 -1
  102. package/dist-vue/_chunks/PkChatbot-Bpo22_yE.js.map +0 -1
  103. package/dist-vue/_chunks/PkFilePreview-z7JcRtjP.js.map +0 -1
@@ -1,15 +1,15 @@
1
1
  import { C as e, D as t, O as n, S as r, _ as i, a, g as o, h as s, i as c, l, m as u, o as d, p as f, r as p, s as m, u as h, v as g, w as _, x as v } from "./schemas-BO5QlXAp.js";
2
- import { $ as y, G as b, J as ee, K as te, V as ne, X as re, et as ie, tt as ae } from "./Agent-DmxsItHG.js";
3
- import { r as oe, t as se } from "./createChatbotApiClient-CQjxHqLr.js";
4
- import { n as ce } from "./src-nb8MU1sh.js";
5
- import { d as le, r as ue } from "./message-DuibQyHy.js";
6
- import { n as de, t as fe } from "./useSafeLocalStorage-Bn4SsL8C.js";
7
- import { computed as x, getCurrentScope as pe, isReadonly as me, nextTick as he, onScopeDispose as ge, reactive as _e, ref as S, shallowRef as C, toRefs as ve, toValue as ye, watch as w, watchEffect as be } from "vue";
8
- import { useI18n as xe } from "vue-i18n";
9
- import { useDocumentVisibility as Se, usePreferredDark as Ce } from "@vueuse/core";
10
- import { defineStore as we } from "pinia";
2
+ import { Q as ee, V as y, X as te, Y as ne, at as re, et as ie, it as ae, rt as oe } from "./Agent-Cm1LrkYm.js";
3
+ import { r as se, t as ce } from "./createChatbotApiClient-BPN6cLGF.js";
4
+ import { n as le } from "./src-nb8MU1sh.js";
5
+ import { d as ue, r as de } from "./message-DuibQyHy.js";
6
+ import { n as fe, t as pe } from "./useSafeLocalStorage-Bn4SsL8C.js";
7
+ import { computed as b, getCurrentScope as me, isReadonly as he, nextTick as ge, onScopeDispose as _e, reactive as ve, ref as x, shallowRef as S, toRefs as ye, toValue as be, watch as C, watchEffect as xe } from "vue";
8
+ import { useI18n as Se } from "vue-i18n";
9
+ import { useDocumentVisibility as Ce, usePreferredDark as we } from "@vueuse/core";
10
+ import { defineStore as Te } from "pinia";
11
11
  // ../../packages/utils/src/device-context.ts
12
- function Te() {
12
+ function Ee() {
13
13
  let e = navigator.connection, t = navigator.userAgentData;
14
14
  return {
15
15
  dateTime: (/* @__PURE__ */ new Date()).toISOString(),
@@ -39,7 +39,7 @@ function Te() {
39
39
  historyLength: window.history.length
40
40
  };
41
41
  }
42
- async function Ee(e) {
42
+ async function De(e) {
43
43
  if (!navigator.geolocation || !navigator.permissions) return null;
44
44
  try {
45
45
  if ((await navigator.permissions.query({ name: "geolocation" })).state !== "granted") return null;
@@ -57,16 +57,16 @@ async function Ee(e) {
57
57
  }
58
58
  }
59
59
  // ../../packages/composable/src/chatbot/hostTools.ts
60
- var De = "agentstudio:page-navigation", Oe = (e) => typeof e?.afterOutput == "function", ke = (e) => e.toolMetadata?.source === y, Ae = (e, t) => {
60
+ var Oe = "agentstudio:page-navigation", ke = (e) => typeof e?.afterOutput == "function", Ae = (e) => e.toolMetadata?.source === oe, je = (e, t) => {
61
61
  if (!t || !e?.length) return;
62
62
  let n = new Set(t.allowed), r = e.filter((e) => n.has(e.name) && !ee(e.name)).map(({ execute: e, confirmation: t, policy: n, ...r }) => r);
63
63
  return r.length > 0 ? r : void 0;
64
64
  };
65
- function je(e) {
65
+ function Me(e) {
66
66
  let t = 0, n = 0, r = (t) => {
67
67
  n = t, e.onPendingChange?.(n);
68
68
  }, i = Promise.resolve(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = (e) => {
69
- Oe(e) && e.abandon?.();
69
+ ke(e) && e.abandon?.();
70
70
  }, c = (e, t) => t.requireConfirmation.includes(e.name) || t.confirmDestructive && e.annotations?.destructiveHint === !0, l = (t, n) => e.addToolOutput({
71
71
  tool: t.toolName,
72
72
  toolCallId: t.toolCallId,
@@ -80,7 +80,7 @@ function je(e) {
80
80
  async function d(n, r) {
81
81
  let i = () => r === t, d = e.capability(), f = e.registry()?.find((e) => e.name === n.toolName), p = f?.policy?.timeoutMs ?? d?.timeoutMs;
82
82
  if (!f || p === void 0) {
83
- u(n, ie(n.readOnly));
83
+ u(n, ae(n.readOnly));
84
84
  return;
85
85
  }
86
86
  let m;
@@ -103,22 +103,22 @@ function je(e) {
103
103
  }
104
104
  let v = new AbortController();
105
105
  a.set(n.toolCallId, v), e.onActivity?.(n);
106
- let y = setTimeout(() => v.abort(/* @__PURE__ */ Error("timeout")), p), b;
106
+ let ee = setTimeout(() => v.abort(/* @__PURE__ */ Error("timeout")), p), y;
107
107
  try {
108
108
  let t = new Promise((e, t) => {
109
109
  v.signal.addEventListener("abort", () => t(v.signal.reason), { once: !0 });
110
110
  });
111
- b = Promise.resolve(f.execute(n.input, {
111
+ y = Promise.resolve(f.execute(n.input, {
112
112
  signal: v.signal,
113
113
  callId: n.toolCallId,
114
114
  messageId: n.messageId
115
115
  }));
116
- let r = await Promise.race([b, t]);
116
+ let r = await Promise.race([y, t]);
117
117
  if (!i()) {
118
118
  s(r);
119
119
  return;
120
120
  }
121
- if (Oe(r)) {
121
+ if (ke(r)) {
122
122
  l(n, r.result ?? null);
123
123
  let t = !1, a = () => {
124
124
  t || (t = !0, o.delete(a), r.abandon?.());
@@ -128,11 +128,11 @@ function je(e) {
128
128
  });
129
129
  } else l(n, r ?? null);
130
130
  } catch (e) {
131
- if (b?.then(s, () => void 0), !i()) return;
131
+ if (y?.then(s, () => void 0), !i()) return;
132
132
  let t = v.signal.aborted;
133
- u(n, t ? ie(n.readOnly) : e instanceof Error && e.message ? e.message : "The host app failed to run this call.");
133
+ u(n, t ? ae(n.readOnly) : e instanceof Error && e.message ? e.message : "The host app failed to run this call.");
134
134
  } finally {
135
- clearTimeout(y), a.delete(n.toolCallId), e.onActivity?.(void 0);
135
+ clearTimeout(ee), a.delete(n.toolCallId), e.onActivity?.(void 0);
136
136
  }
137
137
  }
138
138
  return {
@@ -151,65 +151,65 @@ function je(e) {
151
151
  };
152
152
  }
153
153
  // ../../node_modules/.pnpm/@ai-sdk+provider@4.0.34/node_modules/@ai-sdk/provider/dist/index.js
154
- var Me = "vercel.ai.error", Ne = Symbol.for(Me), T = class e extends Error {
154
+ var Ne = "vercel.ai.error", Pe = Symbol.for(Ne), w = class e extends Error {
155
155
  constructor({ name: e, message: t, cause: n }) {
156
- super(t), this[Ne] = !0, this.name = e, this.cause = n;
156
+ super(t), this[Pe] = !0, this.name = e, this.cause = n;
157
157
  }
158
158
  static isInstance(t) {
159
- return e.hasMarker(t, Me);
159
+ return e.hasMarker(t, Ne);
160
160
  }
161
161
  static hasMarker(e, t) {
162
162
  let n = Symbol.for(t);
163
163
  return typeof e == "object" && !!e && n in e && typeof e[n] == "boolean" && e[n] === !0;
164
164
  }
165
- }, Pe = "AI_APICallError", Fe = `vercel.ai.error.${Pe}`, Ie = Symbol.for(Fe), Le = class extends T {
165
+ }, Fe = "AI_APICallError", Ie = `vercel.ai.error.${Fe}`, Le = Symbol.for(Ie), Re = class extends w {
166
166
  constructor({ message: e, url: t, requestBodyValues: n, statusCode: r, responseHeaders: i, responseBody: a, cause: o, isRetryable: s = r != null && (r === 408 || r === 409 || r === 429 || r >= 500), data: c }) {
167
167
  super({
168
- name: Pe,
168
+ name: Fe,
169
169
  message: e,
170
170
  cause: o
171
- }), this[Ie] = !0, this.url = t, this.requestBodyValues = n, this.statusCode = r, this.responseHeaders = i, this.responseBody = a, this.isRetryable = s, this.data = c;
171
+ }), this[Le] = !0, this.url = t, this.requestBodyValues = n, this.statusCode = r, this.responseHeaders = i, this.responseBody = a, this.isRetryable = s, this.data = c;
172
172
  }
173
173
  static isInstance(e) {
174
- return T.hasMarker(e, Fe);
174
+ return w.hasMarker(e, Ie);
175
175
  }
176
- }, Re = "AI_EmptyResponseBodyError", ze = `vercel.ai.error.${Re}`, Be = Symbol.for(ze), Ve = class extends T {
176
+ }, ze = "AI_EmptyResponseBodyError", Be = `vercel.ai.error.${ze}`, Ve = Symbol.for(Be), He = class extends w {
177
177
  constructor({ message: e = "Empty response body" } = {}) {
178
178
  super({
179
- name: Re,
179
+ name: ze,
180
180
  message: e
181
- }), this[Be] = !0;
181
+ }), this[Ve] = !0;
182
182
  }
183
183
  static isInstance(e) {
184
- return T.hasMarker(e, ze);
184
+ return w.hasMarker(e, Be);
185
185
  }
186
186
  };
187
- function He(e) {
187
+ function Ue(e) {
188
188
  return e == null ? "unknown error" : typeof e == "string" ? e : e instanceof Error ? e.toString() : JSON.stringify(e);
189
189
  }
190
- var Ue = "AI_InvalidArgumentError", We = `vercel.ai.error.${Ue}`, E = Symbol.for(We), Ge = class extends T {
190
+ var We = "AI_InvalidArgumentError", Ge = `vercel.ai.error.${We}`, T = Symbol.for(Ge), Ke = class extends w {
191
191
  constructor({ message: e, cause: t, argument: n }) {
192
192
  super({
193
- name: Ue,
193
+ name: We,
194
194
  message: e,
195
195
  cause: t
196
- }), this[E] = !0, this.argument = n;
196
+ }), this[T] = !0, this.argument = n;
197
197
  }
198
198
  static isInstance(e) {
199
- return T.hasMarker(e, We);
199
+ return w.hasMarker(e, Ge);
200
200
  }
201
- }, Ke = "AI_JSONParseError", D = `vercel.ai.error.${Ke}`, qe = Symbol.for(D), O = class extends T {
201
+ }, qe = "AI_JSONParseError", E = `vercel.ai.error.${qe}`, Je = Symbol.for(E), D = class extends w {
202
202
  constructor({ text: e, cause: t }) {
203
203
  super({
204
- name: Ke,
205
- message: `JSON parsing failed: Text: ${e}.\nError message: ${He(t)}`,
204
+ name: qe,
205
+ message: `JSON parsing failed: Text: ${e}.\nError message: ${Ue(t)}`,
206
206
  cause: t
207
- }), this[qe] = !0, this.text = e;
207
+ }), this[Je] = !0, this.text = e;
208
208
  }
209
209
  static isInstance(e) {
210
- return T.hasMarker(e, D);
210
+ return w.hasMarker(e, E);
211
211
  }
212
- }, Je = "AI_TypeValidationError", Ye = `vercel.ai.error.${Je}`, Xe = Symbol.for(Ye), Ze = class e extends T {
212
+ }, Ye = "AI_TypeValidationError", Xe = `vercel.ai.error.${Ye}`, Ze = Symbol.for(Xe), Qe = class e extends w {
213
213
  constructor({ value: e, cause: t, context: n }) {
214
214
  let r = "Type validation failed";
215
215
  if (n?.field && (r += ` for ${n.field}`), n?.entityName || n?.entityId) {
@@ -218,13 +218,13 @@ var Ue = "AI_InvalidArgumentError", We = `vercel.ai.error.${Ue}`, E = Symbol.for
218
218
  n.entityName && e.push(n.entityName), n.entityId && e.push(`id: "${n.entityId}"`), r += e.join(", "), r += ")";
219
219
  }
220
220
  super({
221
- name: Je,
222
- message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${He(t)}`,
221
+ name: Ye,
222
+ message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${Ue(t)}`,
223
223
  cause: t
224
- }), this[Xe] = !0, this.value = e, this.context = n;
224
+ }), this[Ze] = !0, this.value = e, this.context = n;
225
225
  }
226
226
  static isInstance(e) {
227
- return T.hasMarker(e, Ye);
227
+ return w.hasMarker(e, Xe);
228
228
  }
229
229
  static wrap({ value: t, cause: n, context: r }) {
230
230
  return e.isInstance(n) && n.value === t && n.context?.field === r?.field && n.context?.entityName === r?.entityName && n.context?.entityId === r?.entityId ? n : new e({
@@ -233,25 +233,25 @@ var Ue = "AI_InvalidArgumentError", We = `vercel.ai.error.${Ue}`, E = Symbol.for
233
233
  context: r
234
234
  });
235
235
  }
236
- }, Qe = "AI_UnsupportedFunctionalityError", $e = `vercel.ai.error.${Qe}`, et = Symbol.for($e), tt = class extends T {
236
+ }, $e = "AI_UnsupportedFunctionalityError", et = `vercel.ai.error.${$e}`, tt = Symbol.for(et), nt = class extends w {
237
237
  constructor({ functionality: e, message: t = `'${e}' functionality not supported.` }) {
238
238
  super({
239
- name: Qe,
239
+ name: $e,
240
240
  message: t
241
- }), this[et] = !0, this.functionality = e;
241
+ }), this[tt] = !0, this.functionality = e;
242
242
  }
243
243
  static isInstance(e) {
244
- return T.hasMarker(e, $e);
244
+ return w.hasMarker(e, et);
245
245
  }
246
- }, nt = class extends Error {
246
+ }, rt = class extends Error {
247
247
  constructor(e, t) {
248
248
  super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
249
249
  }
250
- }, rt = 10, it = 13, k = 32;
251
- function at(e) {}
252
- function ot(e) {
250
+ }, it = 10, at = 13, O = 32;
251
+ function ot(e) {}
252
+ function st(e) {
253
253
  if (typeof e == "function") throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
254
- let { onEvent: t = at, onError: n = at, onRetry: r = at, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
254
+ let { onEvent: t = ot, onError: n = ot, onRetry: r = ot, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
255
255
  function m(e) {
256
256
  if (p) throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
257
257
  if (c && (c = !1, e.charCodeAt(0) === 239 && e.charCodeAt(1) === 187 && e.charCodeAt(2) === 191 && (e = e.slice(3))), o.length === 0) {
@@ -270,7 +270,7 @@ function ot(e) {
270
270
  n !== "" && (o.push(n), s = n.length), h();
271
271
  }
272
272
  function h() {
273
- a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new nt(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
273
+ a !== void 0 && (s + u.length <= a || (p = !0, o.length = 0, s = 0, l = void 0, u = "", d = 0, f = void 0, n(new rt(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
274
274
  }
275
275
  function g(e) {
276
276
  let n = 0;
@@ -286,9 +286,9 @@ function ot(e) {
286
286
  continue;
287
287
  }
288
288
  let i = e.charCodeAt(n);
289
- if (st(e, n, i)) {
290
- let i = e.charCodeAt(n + 5) === k ? n + 6 : n + 5, a = e.slice(i, r);
291
- if (d === 0 && e.charCodeAt(r + 1) === rt) {
289
+ if (ct(e, n, i)) {
290
+ let i = e.charCodeAt(n + 5) === O ? n + 6 : n + 5, a = e.slice(i, r);
291
+ if (d === 0 && e.charCodeAt(r + 1) === it) {
292
292
  t({
293
293
  id: l,
294
294
  event: f,
@@ -298,7 +298,7 @@ function ot(e) {
298
298
  }
299
299
  u = d === 0 ? a : `${u}
300
300
  ${a}`, d++;
301
- } else A(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === k ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
301
+ } else k(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === O ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
302
302
  n = r + 1, r = e.indexOf("\n", n);
303
303
  }
304
304
  return e.slice(n);
@@ -306,35 +306,35 @@ ${a}`, d++;
306
306
  for (; n < e.length;) {
307
307
  let t = e.indexOf("\r", n), r = e.indexOf("\n", n), i = -1;
308
308
  if (t !== -1 && r !== -1 ? i = t < r ? t : r : t === -1 ? r !== -1 && (i = r) : i = t === e.length - 1 ? -1 : t, i === -1) break;
309
- _(e, n, i), n = i + 1, e.charCodeAt(n - 1) === it && e.charCodeAt(n) === rt && n++;
309
+ _(e, n, i), n = i + 1, e.charCodeAt(n - 1) === at && e.charCodeAt(n) === it && n++;
310
310
  }
311
311
  return e.slice(n);
312
312
  }
313
313
  function _(e, t, n) {
314
314
  if (t === n) {
315
- y();
315
+ ee();
316
316
  return;
317
317
  }
318
318
  let r = e.charCodeAt(t);
319
- if (st(e, t, r)) {
320
- let r = e.charCodeAt(t + 5) === k ? t + 6 : t + 5, i = e.slice(r, n);
319
+ if (ct(e, t, r)) {
320
+ let r = e.charCodeAt(t + 5) === O ? t + 6 : t + 5, i = e.slice(r, n);
321
321
  u = d === 0 ? i : `${u}
322
322
  ${i}`, d++;
323
323
  return;
324
324
  }
325
- if (A(e, t, r)) {
326
- f = e.slice(e.charCodeAt(t + 6) === k ? t + 7 : t + 6, n) || void 0;
325
+ if (k(e, t, r)) {
326
+ f = e.slice(e.charCodeAt(t + 6) === O ? t + 7 : t + 6, n) || void 0;
327
327
  return;
328
328
  }
329
329
  if (r === 105 && e.charCodeAt(t + 1) === 100 && e.charCodeAt(t + 2) === 58) {
330
- let r = e.slice(e.charCodeAt(t + 3) === k ? t + 4 : t + 3, n);
330
+ let r = e.slice(e.charCodeAt(t + 3) === O ? t + 4 : t + 3, n);
331
331
  l = r.includes("\0") ? void 0 : r;
332
332
  return;
333
333
  }
334
334
  if (r === 58) {
335
335
  if (i) {
336
336
  let r = e.slice(t, n);
337
- i(r.slice(e.charCodeAt(t + 1) === k ? 2 : 1));
337
+ i(r.slice(e.charCodeAt(t + 1) === O ? 2 : 1));
338
338
  }
339
339
  return;
340
340
  }
@@ -343,7 +343,7 @@ ${i}`, d++;
343
343
  v(a, "", a);
344
344
  return;
345
345
  }
346
- let s = a.slice(0, o), c = a.charCodeAt(o + 1) === k ? 2 : 1;
346
+ let s = a.slice(0, o), c = a.charCodeAt(o + 1) === O ? 2 : 1;
347
347
  v(s, a.slice(o + c), a);
348
348
  }
349
349
  function v(e, t, i) {
@@ -359,13 +359,13 @@ ${t}`, d++;
359
359
  l = t.includes("\0") ? void 0 : t;
360
360
  break;
361
361
  case "retry":
362
- /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new nt(`Invalid \`retry\` value: "${t}"`, {
362
+ /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new rt(`Invalid \`retry\` value: "${t}"`, {
363
363
  type: "invalid-retry",
364
364
  value: t,
365
365
  line: i
366
366
  }));
367
367
  break;
368
- default: n(new nt(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
368
+ default: n(new rt(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
369
369
  type: "unknown-field",
370
370
  field: e,
371
371
  value: t,
@@ -373,14 +373,14 @@ ${t}`, d++;
373
373
  }));
374
374
  }
375
375
  }
376
- function y() {
376
+ function ee() {
377
377
  d > 0 && t({
378
378
  id: l,
379
379
  event: f,
380
380
  data: u
381
381
  }), l = void 0, u = "", d = 0, f = void 0;
382
382
  }
383
- function b(e = {}) {
383
+ function y(e = {}) {
384
384
  if (e.consume && o.length > 0) {
385
385
  let e = o.join("");
386
386
  _(e, 0, e.length);
@@ -389,22 +389,22 @@ ${t}`, d++;
389
389
  }
390
390
  return {
391
391
  feed: m,
392
- reset: b
392
+ reset: y
393
393
  };
394
394
  }
395
- function st(e, t, n) {
395
+ function ct(e, t, n) {
396
396
  return n === 100 && e.charCodeAt(t + 1) === 97 && e.charCodeAt(t + 2) === 116 && e.charCodeAt(t + 3) === 97 && e.charCodeAt(t + 4) === 58;
397
397
  }
398
- function A(e, t, n) {
398
+ function k(e, t, n) {
399
399
  return n === 101 && e.charCodeAt(t + 1) === 118 && e.charCodeAt(t + 2) === 101 && e.charCodeAt(t + 3) === 110 && e.charCodeAt(t + 4) === 116 && e.charCodeAt(t + 5) === 58;
400
400
  }
401
401
  // ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
402
- var ct = class extends TransformStream {
402
+ var lt = class extends TransformStream {
403
403
  constructor({ onError: e, onRetry: t, onComment: n, maxBufferSize: r } = {}) {
404
404
  let i;
405
405
  super({
406
406
  start(a) {
407
- i = ot({
407
+ i = st({
408
408
  onEvent: (e) => {
409
409
  a.enqueue(e);
410
410
  },
@@ -423,8 +423,8 @@ var ct = class extends TransformStream {
423
423
  }
424
424
  };
425
425
  new TextDecoder();
426
- var { btoa: lt, atob: ut } = globalThis;
427
- function j(e) {
426
+ var { btoa: ut, atob: dt } = globalThis;
427
+ function A(e) {
428
428
  if (e == null) return {};
429
429
  let t = {};
430
430
  if (e instanceof Headers) e.forEach((e, n) => {
@@ -436,28 +436,28 @@ function j(e) {
436
436
  }
437
437
  return t;
438
438
  }
439
- var M = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
439
+ var j = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", separator: r = "-" } = {}) => {
440
440
  let i = () => {
441
441
  let e = n.length, r = Array(t);
442
442
  for (let i = 0; i < t; i++) r[i] = n[Math.random() * e | 0];
443
443
  return r.join("");
444
444
  };
445
445
  if (e == null) return i;
446
- if (n.includes(r)) throw new Ge({
446
+ if (n.includes(r)) throw new Ke({
447
447
  argument: "separator",
448
448
  message: `The separator "${r}" must not be part of the alphabet "${n}".`
449
449
  });
450
450
  return () => `${e}${r}${i()}`;
451
- }, dt = M();
452
- function ft(e) {
451
+ }, ft = j();
452
+ function pt(e) {
453
453
  return globalThis.Buffer?.isBuffer(e) ?? !1;
454
454
  }
455
- var pt = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, mt = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
456
- function ht(e) {
455
+ var mt = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, ht = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
456
+ function gt(e) {
457
457
  let t = JSON.parse(e);
458
- return typeof t != "object" || !t || pt.test(e) === !1 && mt.test(e) === !1 ? t : gt(t);
458
+ return typeof t != "object" || !t || mt.test(e) === !1 && ht.test(e) === !1 ? t : _t(t);
459
459
  }
460
- function gt(e) {
460
+ function _t(e) {
461
461
  let t = [e];
462
462
  for (; t.length;) {
463
463
  let e = t;
@@ -472,35 +472,35 @@ function gt(e) {
472
472
  }
473
473
  return e;
474
474
  }
475
- function N(e) {
475
+ function M(e) {
476
476
  let { stackTraceLimit: t } = Error;
477
477
  try {
478
478
  Error.stackTraceLimit = 0;
479
479
  } catch {
480
- return ht(e);
480
+ return gt(e);
481
481
  }
482
482
  try {
483
- return ht(e);
483
+ return gt(e);
484
484
  } finally {
485
485
  Error.stackTraceLimit = t;
486
486
  }
487
487
  }
488
- function _t(e) {
488
+ function vt(e) {
489
489
  if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
490
490
  let { additionalProperties: t } = e;
491
- e.additionalProperties = t != null && typeof t != "boolean" && P(t);
491
+ e.additionalProperties = t != null && typeof t != "boolean" && N(t);
492
492
  let { properties: n } = e;
493
- if (n != null) for (let e of Object.keys(n)) n[e] = P(n[e]);
493
+ if (n != null) for (let e of Object.keys(n)) n[e] = N(n[e]);
494
494
  }
495
- e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(P) : P(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(P)), e.allOf != null && (e.allOf = e.allOf.map(P)), e.oneOf != null && (e.oneOf = e.oneOf.map(P));
495
+ e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(N) : N(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(N)), e.allOf != null && (e.allOf = e.allOf.map(N)), e.oneOf != null && (e.oneOf = e.oneOf.map(N));
496
496
  let { definitions: t } = e;
497
- if (t != null) for (let e of Object.keys(t)) t[e] = P(t[e]);
497
+ if (t != null) for (let e of Object.keys(t)) t[e] = N(t[e]);
498
498
  return e;
499
499
  }
500
- function P(e) {
501
- return typeof e == "boolean" ? e : _t(e);
500
+ function N(e) {
501
+ return typeof e == "boolean" ? e : vt(e);
502
502
  }
503
- var vt = Symbol("Let zodToJsonSchema decide on which parser to use"), yt = {
503
+ var yt = Symbol("Let zodToJsonSchema decide on which parser to use"), bt = {
504
504
  name: void 0,
505
505
  $refStrategy: "root",
506
506
  basePath: ["#"],
@@ -520,24 +520,24 @@ var vt = Symbol("Let zodToJsonSchema decide on which parser to use"), yt = {
520
520
  emailStrategy: "format:email",
521
521
  base64Strategy: "contentEncoding:base64",
522
522
  nameStrategy: "ref"
523
- }, bt = (e) => typeof e == "string" ? {
524
- ...yt,
523
+ }, xt = (e) => typeof e == "string" ? {
524
+ ...bt,
525
525
  name: e
526
526
  } : {
527
- ...yt,
527
+ ...bt,
528
528
  ...e
529
529
  };
530
- function F() {
530
+ function P() {
531
531
  return {};
532
532
  }
533
- function xt(e, t) {
533
+ function St(e, t) {
534
534
  let n = { type: "array" };
535
- return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = J(e.type._def, {
535
+ return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = q(e.type._def, {
536
536
  ...t,
537
537
  currentPath: [...t.currentPath, "items"]
538
538
  })), e.minLength && (n.minItems = e.minLength.value), e.maxLength && (n.maxItems = e.maxLength.value), e.exactLength && (n.minItems = e.exactLength.value, n.maxItems = e.exactLength.value), n;
539
539
  }
540
- function St(e) {
540
+ function Ct(e) {
541
541
  let t = {
542
542
  type: "integer",
543
543
  format: "int64"
@@ -554,16 +554,16 @@ function St(e) {
554
554
  }
555
555
  return t;
556
556
  }
557
- function Ct() {
557
+ function wt() {
558
558
  return { type: "boolean" };
559
559
  }
560
- function wt(e, t) {
561
- return J(e.type._def, t);
560
+ function Tt(e, t) {
561
+ return q(e.type._def, t);
562
562
  }
563
- var I = (e, t) => J(e.innerType._def, t);
564
- function Tt(e, t, n) {
563
+ var F = (e, t) => q(e.innerType._def, t);
564
+ function Et(e, t, n) {
565
565
  let r = n ?? t.dateStrategy;
566
- if (Array.isArray(r)) return { anyOf: r.map((n) => Tt(e, t, n)) };
566
+ if (Array.isArray(r)) return { anyOf: r.map((n) => Et(e, t, n)) };
567
567
  switch (r) {
568
568
  case "string":
569
569
  case "format:date-time": return {
@@ -574,10 +574,10 @@ function Tt(e, t, n) {
574
574
  type: "string",
575
575
  format: "date"
576
576
  };
577
- case "integer": return Et(e);
577
+ case "integer": return Dt(e);
578
578
  }
579
579
  }
580
- var Et = (e) => {
580
+ var Dt = (e) => {
581
581
  let t = {
582
582
  type: "integer",
583
583
  format: "unix-time"
@@ -590,31 +590,31 @@ var Et = (e) => {
590
590
  }
591
591
  return t;
592
592
  };
593
- function Dt(e, t) {
593
+ function Ot(e, t) {
594
594
  return {
595
- ...J(e.innerType._def, t),
595
+ ...q(e.innerType._def, t),
596
596
  default: e.defaultValue()
597
597
  };
598
598
  }
599
- function L(e, t) {
600
- return t.effectStrategy === "input" ? J(e.schema._def, t) : F();
599
+ function I(e, t) {
600
+ return t.effectStrategy === "input" ? q(e.schema._def, t) : P();
601
601
  }
602
- function R(e) {
602
+ function L(e) {
603
603
  return {
604
604
  type: "string",
605
605
  enum: Array.from(e.values)
606
606
  };
607
607
  }
608
- var Ot = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
608
+ var R = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
609
609
  function kt(e, t) {
610
- let n = [J(e.left._def, {
610
+ let n = [q(e.left._def, {
611
611
  ...t,
612
612
  currentPath: [
613
613
  ...t.currentPath,
614
614
  "allOf",
615
615
  "0"
616
616
  ]
617
- }), J(e.right._def, {
617
+ }), q(e.right._def, {
618
618
  ...t,
619
619
  currentPath: [
620
620
  ...t.currentPath,
@@ -623,7 +623,7 @@ function kt(e, t) {
623
623
  ]
624
624
  })].filter((e) => !!e), r = [];
625
625
  return n.forEach((e) => {
626
- if (Ot(e)) r.push(...e.allOf);
626
+ if (R(e)) r.push(...e.allOf);
627
627
  else {
628
628
  let t = e;
629
629
  if ("additionalProperties" in e && e.additionalProperties === !1) {
@@ -812,7 +812,7 @@ function Ft(e, t) {
812
812
  function It(e, t) {
813
813
  let n = {
814
814
  type: "object",
815
- additionalProperties: J(e.valueType._def, {
815
+ additionalProperties: q(e.valueType._def, {
816
816
  ...t,
817
817
  currentPath: [...t.currentPath, "additionalProperties"]
818
818
  }) ?? t.allowedAdditionalProperties
@@ -829,7 +829,7 @@ function It(e, t) {
829
829
  propertyNames: { enum: e.keyType._def.values }
830
830
  };
831
831
  if (e.keyType?._def.typeName === "ZodBranded" && e.keyType._def.type._def.typeName === "ZodString" && e.keyType._def.type._def.checks?.length) {
832
- let { type: r, ...i } = wt(e.keyType._def, t);
832
+ let { type: r, ...i } = Tt(e.keyType._def, t);
833
833
  return {
834
834
  ...n,
835
835
  propertyNames: i
@@ -843,7 +843,7 @@ function Lt(e, t) {
843
843
  maxItems: 125,
844
844
  items: {
845
845
  type: "array",
846
- items: [J(e.keyType._def, {
846
+ items: [q(e.keyType._def, {
847
847
  ...t,
848
848
  currentPath: [
849
849
  ...t.currentPath,
@@ -851,7 +851,7 @@ function Lt(e, t) {
851
851
  "items",
852
852
  "0"
853
853
  ]
854
- }) || F(), J(e.valueType._def, {
854
+ }) || P(), q(e.valueType._def, {
855
855
  ...t,
856
856
  currentPath: [
857
857
  ...t.currentPath,
@@ -859,7 +859,7 @@ function Lt(e, t) {
859
859
  "items",
860
860
  "1"
861
861
  ]
862
- }) || F()],
862
+ }) || P()],
863
863
  minItems: 2,
864
864
  maxItems: 2
865
865
  }
@@ -873,7 +873,7 @@ function U(e) {
873
873
  };
874
874
  }
875
875
  function Rt() {
876
- return { not: F() };
876
+ return { not: P() };
877
877
  }
878
878
  function zt() {
879
879
  return { type: "null" };
@@ -920,7 +920,7 @@ function Vt(e, t) {
920
920
  return Ht(e, t);
921
921
  }
922
922
  var Ht = (e, t) => {
923
- let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => J(e._def, {
923
+ let n = (e.options instanceof Map ? Array.from(e.options.values()) : e.options).map((e, n) => q(e._def, {
924
924
  ...t,
925
925
  currentPath: [
926
926
  ...t.currentPath,
@@ -930,7 +930,7 @@ var Ht = (e, t) => {
930
930
  })).filter((e) => !!e && (!t.strictUnions || typeof e == "object" && Object.keys(e).length > 0));
931
931
  return n.length ? { anyOf: n } : void 0;
932
932
  };
933
- function W(e, t) {
933
+ function Ut(e, t) {
934
934
  if ([
935
935
  "ZodString",
936
936
  "ZodNumber",
@@ -938,7 +938,7 @@ function W(e, t) {
938
938
  "ZodBoolean",
939
939
  "ZodNull"
940
940
  ].includes(e.innerType._def.typeName) && (!e.innerType._def.checks || !e.innerType._def.checks.length)) return { type: [Bt[e.innerType._def.typeName], "null"] };
941
- let n = J(e.innerType._def, {
941
+ let n = q(e.innerType._def, {
942
942
  ...t,
943
943
  currentPath: [
944
944
  ...t.currentPath,
@@ -948,7 +948,7 @@ function W(e, t) {
948
948
  });
949
949
  return n && { anyOf: [n, { type: "null" }] };
950
950
  }
951
- function Ut(e) {
951
+ function Wt(e) {
952
952
  let t = { type: "number" };
953
953
  if (!e.checks) return t;
954
954
  for (let n of e.checks) switch (n.kind) {
@@ -965,7 +965,7 @@ function Ut(e) {
965
965
  }
966
966
  return t;
967
967
  }
968
- function Wt(e, t) {
968
+ function Gt(e, t) {
969
969
  let n = {
970
970
  type: "object",
971
971
  properties: {}
@@ -973,7 +973,7 @@ function Wt(e, t) {
973
973
  for (let e in i) {
974
974
  let a = i[e];
975
975
  if (a === void 0 || a._def === void 0) continue;
976
- let o = Kt(a), s = J(a._def, {
976
+ let o = qt(a), s = q(a._def, {
977
977
  ...t,
978
978
  currentPath: [
979
979
  ...t.currentPath,
@@ -989,11 +989,11 @@ function Wt(e, t) {
989
989
  s !== void 0 && (n.properties[e] = s, o || r.push(e));
990
990
  }
991
991
  r.length && (n.required = r);
992
- let a = Gt(e, t);
992
+ let a = Kt(e, t);
993
993
  return a !== void 0 && (n.additionalProperties = a), n;
994
994
  }
995
- function Gt(e, t) {
996
- if (e.catchall._def.typeName !== "ZodNever") return J(e.catchall._def, {
995
+ function Kt(e, t) {
996
+ if (e.catchall._def.typeName !== "ZodNever") return q(e.catchall._def, {
997
997
  ...t,
998
998
  currentPath: [...t.currentPath, "additionalProperties"]
999
999
  });
@@ -1003,16 +1003,16 @@ function Gt(e, t) {
1003
1003
  case "strip": return t.removeAdditionalStrategy === "strict" ? t.allowedAdditionalProperties : t.rejectedAdditionalProperties;
1004
1004
  }
1005
1005
  }
1006
- function Kt(e) {
1006
+ function qt(e) {
1007
1007
  try {
1008
1008
  return e.isOptional();
1009
1009
  } catch {
1010
1010
  return !0;
1011
1011
  }
1012
1012
  }
1013
- var qt = (e, t) => {
1014
- if (t.currentPath.toString() === t.propertyPath?.toString()) return J(e.innerType._def, t);
1015
- let n = J(e.innerType._def, {
1013
+ var Jt = (e, t) => {
1014
+ if (t.currentPath.toString() === t.propertyPath?.toString()) return q(e.innerType._def, t);
1015
+ let n = q(e.innerType._def, {
1016
1016
  ...t,
1017
1017
  currentPath: [
1018
1018
  ...t.currentPath,
@@ -1020,11 +1020,11 @@ var qt = (e, t) => {
1020
1020
  "1"
1021
1021
  ]
1022
1022
  });
1023
- return n ? { anyOf: [{ not: F() }, n] } : F();
1024
- }, Jt = (e, t) => {
1025
- if (t.pipeStrategy === "input") return J(e.in._def, t);
1026
- if (t.pipeStrategy === "output") return J(e.out._def, t);
1027
- let n = J(e.in._def, {
1023
+ return n ? { anyOf: [{ not: P() }, n] } : P();
1024
+ }, Yt = (e, t) => {
1025
+ if (t.pipeStrategy === "input") return q(e.in._def, t);
1026
+ if (t.pipeStrategy === "output") return q(e.out._def, t);
1027
+ let n = q(e.in._def, {
1028
1028
  ...t,
1029
1029
  currentPath: [
1030
1030
  ...t.currentPath,
@@ -1032,7 +1032,7 @@ var qt = (e, t) => {
1032
1032
  "0"
1033
1033
  ]
1034
1034
  });
1035
- return { allOf: [n, J(e.out._def, {
1035
+ return { allOf: [n, q(e.out._def, {
1036
1036
  ...t,
1037
1037
  currentPath: [
1038
1038
  ...t.currentPath,
@@ -1041,25 +1041,25 @@ var qt = (e, t) => {
1041
1041
  ]
1042
1042
  })].filter((e) => e !== void 0) };
1043
1043
  };
1044
- function Yt(e, t) {
1045
- return J(e.type._def, t);
1046
- }
1047
1044
  function Xt(e, t) {
1045
+ return q(e.type._def, t);
1046
+ }
1047
+ function Zt(e, t) {
1048
1048
  let n = {
1049
1049
  type: "array",
1050
1050
  uniqueItems: !0,
1051
- items: J(e.valueType._def, {
1051
+ items: q(e.valueType._def, {
1052
1052
  ...t,
1053
1053
  currentPath: [...t.currentPath, "items"]
1054
1054
  })
1055
1055
  };
1056
1056
  return e.minSize && (n.minItems = e.minSize.value), e.maxSize && (n.maxItems = e.maxSize.value), n;
1057
1057
  }
1058
- function Zt(e, t) {
1058
+ function Qt(e, t) {
1059
1059
  return e.rest ? {
1060
1060
  type: "array",
1061
1061
  minItems: e.items.length,
1062
- items: e.items.map((e, n) => J(e._def, {
1062
+ items: e.items.map((e, n) => q(e._def, {
1063
1063
  ...t,
1064
1064
  currentPath: [
1065
1065
  ...t.currentPath,
@@ -1067,7 +1067,7 @@ function Zt(e, t) {
1067
1067
  `${n}`
1068
1068
  ]
1069
1069
  })).reduce((e, t) => t === void 0 ? e : [...e, t], []),
1070
- additionalItems: J(e.rest._def, {
1070
+ additionalItems: q(e.rest._def, {
1071
1071
  ...t,
1072
1072
  currentPath: [...t.currentPath, "additionalItems"]
1073
1073
  })
@@ -1075,7 +1075,7 @@ function Zt(e, t) {
1075
1075
  type: "array",
1076
1076
  minItems: e.items.length,
1077
1077
  maxItems: e.items.length,
1078
- items: e.items.map((e, n) => J(e._def, {
1078
+ items: e.items.map((e, n) => q(e._def, {
1079
1079
  ...t,
1080
1080
  currentPath: [
1081
1081
  ...t.currentPath,
@@ -1085,47 +1085,47 @@ function Zt(e, t) {
1085
1085
  })).reduce((e, t) => t === void 0 ? e : [...e, t], [])
1086
1086
  };
1087
1087
  }
1088
- function Qt() {
1089
- return { not: F() };
1090
- }
1091
1088
  function $t() {
1092
- return F();
1089
+ return { not: P() };
1090
+ }
1091
+ function en() {
1092
+ return P();
1093
1093
  }
1094
- var G = (e, t) => J(e.innerType._def, t), K = (e, t, n) => {
1094
+ var W = (e, t) => q(e.innerType._def, t), G = (e, t, n) => {
1095
1095
  switch (t) {
1096
1096
  case "ZodString": return Mt(e, n);
1097
- case "ZodNumber": return Ut(e);
1098
- case "ZodObject": return Wt(e, n);
1099
- case "ZodBigInt": return St(e);
1100
- case "ZodBoolean": return Ct();
1101
- case "ZodDate": return Tt(e, n);
1102
- case "ZodUndefined": return Qt();
1097
+ case "ZodNumber": return Wt(e);
1098
+ case "ZodObject": return Gt(e, n);
1099
+ case "ZodBigInt": return Ct(e);
1100
+ case "ZodBoolean": return wt();
1101
+ case "ZodDate": return Et(e, n);
1102
+ case "ZodUndefined": return $t();
1103
1103
  case "ZodNull": return zt();
1104
- case "ZodArray": return xt(e, n);
1104
+ case "ZodArray": return St(e, n);
1105
1105
  case "ZodUnion":
1106
1106
  case "ZodDiscriminatedUnion": return Vt(e, n);
1107
1107
  case "ZodIntersection": return kt(e, n);
1108
- case "ZodTuple": return Zt(e, n);
1108
+ case "ZodTuple": return Qt(e, n);
1109
1109
  case "ZodRecord": return It(e, n);
1110
1110
  case "ZodLiteral": return At(e);
1111
- case "ZodEnum": return R(e);
1111
+ case "ZodEnum": return L(e);
1112
1112
  case "ZodNativeEnum": return U(e);
1113
- case "ZodNullable": return W(e, n);
1114
- case "ZodOptional": return qt(e, n);
1113
+ case "ZodNullable": return Ut(e, n);
1114
+ case "ZodOptional": return Jt(e, n);
1115
1115
  case "ZodMap": return Lt(e, n);
1116
- case "ZodSet": return Xt(e, n);
1116
+ case "ZodSet": return Zt(e, n);
1117
1117
  case "ZodLazy": return () => e.getter()._def;
1118
- case "ZodPromise": return Yt(e, n);
1118
+ case "ZodPromise": return Xt(e, n);
1119
1119
  case "ZodNaN":
1120
1120
  case "ZodNever": return Rt();
1121
- case "ZodEffects": return L(e, n);
1122
- case "ZodAny": return F();
1123
- case "ZodUnknown": return $t();
1124
- case "ZodDefault": return Dt(e, n);
1125
- case "ZodBranded": return wt(e, n);
1126
- case "ZodReadonly": return G(e, n);
1127
- case "ZodCatch": return I(e, n);
1128
- case "ZodPipeline": return Jt(e, n);
1121
+ case "ZodEffects": return I(e, n);
1122
+ case "ZodAny": return P();
1123
+ case "ZodUnknown": return en();
1124
+ case "ZodDefault": return Ot(e, n);
1125
+ case "ZodBranded": return Tt(e, n);
1126
+ case "ZodReadonly": return W(e, n);
1127
+ case "ZodCatch": return F(e, n);
1128
+ case "ZodPipeline": return Yt(e, n);
1129
1129
  case "ZodFunction":
1130
1130
  case "ZodVoid":
1131
1131
  case "ZodSymbol": return;
@@ -1133,19 +1133,19 @@ var G = (e, t) => J(e.innerType._def, t), K = (e, t, n) => {
1133
1133
  /* c8 ignore next */
1134
1134
  return ((e) => void 0)(t);
1135
1135
  }
1136
- }, q = (e, t) => {
1136
+ }, K = (e, t) => {
1137
1137
  let n = 0;
1138
1138
  for (; n < e.length && n < t.length && e[n] === t[n]; n++);
1139
1139
  return [(e.length - n).toString(), ...t.slice(n)].join("/");
1140
1140
  };
1141
- function J(e, t, n = !1) {
1141
+ function q(e, t, n = !1) {
1142
1142
  let r = t.seen.get(e);
1143
1143
  if (t.override) {
1144
1144
  let i = t.override?.(e, t, r, n);
1145
- if (i !== vt) return i;
1145
+ if (i !== yt) return i;
1146
1146
  }
1147
1147
  if (r && !n) {
1148
- let e = en(r, t);
1148
+ let e = tn(r, t);
1149
1149
  if (e !== void 0) return e;
1150
1150
  }
1151
1151
  let i = {
@@ -1154,22 +1154,22 @@ function J(e, t, n = !1) {
1154
1154
  jsonSchema: void 0
1155
1155
  };
1156
1156
  t.seen.set(e, i);
1157
- let a = K(e, e.typeName, t), o = typeof a == "function" ? J(a(), t) : a;
1158
- if (o && tn(e, t, o), t.postProcess) {
1157
+ let a = G(e, e.typeName, t), o = typeof a == "function" ? q(a(), t) : a;
1158
+ if (o && nn(e, t, o), t.postProcess) {
1159
1159
  let n = t.postProcess(o, e, t);
1160
1160
  return i.jsonSchema = o, n;
1161
1161
  }
1162
1162
  return i.jsonSchema = o, o;
1163
1163
  }
1164
- var en = (e, t) => {
1164
+ var tn = (e, t) => {
1165
1165
  switch (t.$refStrategy) {
1166
1166
  case "root": return { $ref: e.path.join("/") };
1167
- case "relative": return { $ref: q(t.currentPath, e.path) };
1167
+ case "relative": return { $ref: K(t.currentPath, e.path) };
1168
1168
  case "none":
1169
- case "seen": return e.path.length < t.currentPath.length && e.path.every((e, n) => t.currentPath[n] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), F()) : t.$refStrategy === "seen" ? F() : void 0;
1169
+ case "seen": return e.path.length < t.currentPath.length && e.path.every((e, n) => t.currentPath[n] === e) ? (console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`), P()) : t.$refStrategy === "seen" ? P() : void 0;
1170
1170
  }
1171
- }, tn = (e, t, n) => (e.description && (n.description = e.description), n), nn = (e) => {
1172
- let t = bt(e), n = t.name === void 0 ? t.basePath : [
1171
+ }, nn = (e, t, n) => (e.description && (n.description = e.description), n), rn = (e) => {
1172
+ let t = xt(e), n = t.name === void 0 ? t.basePath : [
1173
1173
  ...t.basePath,
1174
1174
  t.definitionPath,
1175
1175
  t.name
@@ -1188,25 +1188,25 @@ var en = (e, t) => {
1188
1188
  jsonSchema: void 0
1189
1189
  }]))
1190
1190
  };
1191
- }, rn = (e, t) => {
1192
- let n = nn(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
1191
+ }, an = (e, t) => {
1192
+ let n = rn(t), r = typeof t == "object" && t.definitions ? Object.entries(t.definitions).reduce((e, [t, r]) => ({
1193
1193
  ...e,
1194
- [t]: J(r._def, {
1194
+ [t]: q(r._def, {
1195
1195
  ...n,
1196
1196
  currentPath: [
1197
1197
  ...n.basePath,
1198
1198
  n.definitionPath,
1199
1199
  t
1200
1200
  ]
1201
- }, !0) ?? F()
1202
- }), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = J(e._def, i === void 0 ? n : {
1201
+ }, !0) ?? P()
1202
+ }), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = q(e._def, i === void 0 ? n : {
1203
1203
  ...n,
1204
1204
  currentPath: [
1205
1205
  ...n.basePath,
1206
1206
  n.definitionPath,
1207
1207
  i
1208
1208
  ]
1209
- }, !1) ?? F(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1209
+ }, !1) ?? P(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1210
1210
  o !== void 0 && (a.title = o);
1211
1211
  let s = i === void 0 ? r ? {
1212
1212
  ...a,
@@ -1223,14 +1223,14 @@ var en = (e, t) => {
1223
1223
  }
1224
1224
  };
1225
1225
  return s.$schema = "http://json-schema.org/draft-07/schema#", s;
1226
- }, an = Symbol.for("vercel.ai.schema");
1227
- function on(e) {
1226
+ }, on = Symbol.for("vercel.ai.schema");
1227
+ function sn(e) {
1228
1228
  let t;
1229
1229
  return () => (t ??= e(), t);
1230
1230
  }
1231
- function sn(e, { validate: t } = {}) {
1231
+ function cn(e, { validate: t } = {}) {
1232
1232
  return {
1233
- [an]: !0,
1233
+ [on]: !0,
1234
1234
  _type: void 0,
1235
1235
  get jsonSchema() {
1236
1236
  return typeof e == "function" && (e = e()), e;
@@ -1238,20 +1238,20 @@ function sn(e, { validate: t } = {}) {
1238
1238
  validate: t
1239
1239
  };
1240
1240
  }
1241
- function cn(e) {
1242
- return typeof e == "object" && !!e && an in e && e[an] === !0 && "jsonSchema" in e && "validate" in e;
1243
- }
1244
1241
  function ln(e) {
1245
- return e == null ? sn({
1242
+ return typeof e == "object" && !!e && on in e && e[on] === !0 && "jsonSchema" in e && "validate" in e;
1243
+ }
1244
+ function un(e) {
1245
+ return e == null ? cn({
1246
1246
  type: "object",
1247
1247
  properties: {},
1248
1248
  additionalProperties: !1
1249
- }) : cn(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? hn(e) : un(e) : e();
1249
+ }) : ln(e) ? e : "~standard" in e ? e["~standard"].vendor === "zod" ? gn(e) : dn(e) : e();
1250
1250
  }
1251
- function un(e) {
1252
- return sn(() => {
1253
- if (!dn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1254
- return _t(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1251
+ function dn(e) {
1252
+ return cn(() => {
1253
+ if (!fn(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1254
+ return vt(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1255
1255
  }, { validate: async (t) => {
1256
1256
  let n = await e["~standard"].validate(t);
1257
1257
  return "value" in n ? {
@@ -1259,19 +1259,19 @@ function un(e) {
1259
1259
  value: n.value
1260
1260
  } : {
1261
1261
  success: !1,
1262
- error: new Ze({
1262
+ error: new Qe({
1263
1263
  value: t,
1264
1264
  cause: n.issues
1265
1265
  })
1266
1266
  };
1267
1267
  } });
1268
1268
  }
1269
- function dn(e) {
1269
+ function fn(e) {
1270
1270
  return e["~standard"].jsonSchema != null;
1271
1271
  }
1272
- function fn(e, t) {
1272
+ function pn(e, t) {
1273
1273
  let n = t?.useReferences ?? !1;
1274
- return sn(() => rn(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1274
+ return cn(() => an(e, { $refStrategy: n ? "root" : "none" }), { validate: async (t) => {
1275
1275
  let n = await e.safeParseAsync(t);
1276
1276
  return n.success ? {
1277
1277
  success: !0,
@@ -1282,9 +1282,9 @@ function fn(e, t) {
1282
1282
  };
1283
1283
  } });
1284
1284
  }
1285
- function pn(e, r) {
1285
+ function mn(e, r) {
1286
1286
  let i = r?.useReferences ?? !1;
1287
- return sn(() => _t(n(e, {
1287
+ return cn(() => vt(n(e, {
1288
1288
  target: "draft-7",
1289
1289
  io: "input",
1290
1290
  reused: i ? "ref" : "inline"
@@ -1299,27 +1299,27 @@ function pn(e, r) {
1299
1299
  };
1300
1300
  } });
1301
1301
  }
1302
- function mn(e) {
1302
+ function hn(e) {
1303
1303
  return "_zod" in e;
1304
1304
  }
1305
- function hn(e, t) {
1306
- return mn(e) ? pn(e, t) : fn(e, t);
1305
+ function gn(e, t) {
1306
+ return hn(e) ? mn(e, t) : pn(e, t);
1307
1307
  }
1308
- async function gn({ value: e, schema: t, context: n }) {
1309
- let r = await _n({
1308
+ async function _n({ value: e, schema: t, context: n }) {
1309
+ let r = await vn({
1310
1310
  value: e,
1311
1311
  schema: t,
1312
1312
  context: n
1313
1313
  });
1314
- if (!r.success) throw Ze.wrap({
1314
+ if (!r.success) throw Qe.wrap({
1315
1315
  value: e,
1316
1316
  cause: r.error,
1317
1317
  context: n
1318
1318
  });
1319
1319
  return r.value;
1320
1320
  }
1321
- async function _n({ value: e, schema: t, context: n }) {
1322
- let r = ln(t);
1321
+ async function vn({ value: e, schema: t, context: n }) {
1322
+ let r = un(t);
1323
1323
  try {
1324
1324
  if (r.validate == null) return {
1325
1325
  success: !0,
@@ -1333,7 +1333,7 @@ async function _n({ value: e, schema: t, context: n }) {
1333
1333
  rawValue: e
1334
1334
  } : {
1335
1335
  success: !1,
1336
- error: Ze.wrap({
1336
+ error: Qe.wrap({
1337
1337
  value: e,
1338
1338
  cause: t.error,
1339
1339
  context: n
@@ -1343,7 +1343,7 @@ async function _n({ value: e, schema: t, context: n }) {
1343
1343
  } catch (t) {
1344
1344
  return {
1345
1345
  success: !1,
1346
- error: Ze.wrap({
1346
+ error: Qe.wrap({
1347
1347
  value: e,
1348
1348
  cause: t,
1349
1349
  context: n
@@ -1352,21 +1352,21 @@ async function _n({ value: e, schema: t, context: n }) {
1352
1352
  };
1353
1353
  }
1354
1354
  }
1355
- async function vn({ text: e, schema: t }) {
1355
+ async function yn({ text: e, schema: t }) {
1356
1356
  try {
1357
- let n = N(e);
1357
+ let n = M(e);
1358
1358
  return t == null ? {
1359
1359
  success: !0,
1360
1360
  value: n,
1361
1361
  rawValue: n
1362
- } : await _n({
1362
+ } : await vn({
1363
1363
  value: n,
1364
1364
  schema: t
1365
1365
  });
1366
1366
  } catch (t) {
1367
1367
  return {
1368
1368
  success: !1,
1369
- error: O.isInstance(t) ? t : new O({
1369
+ error: D.isInstance(t) ? t : new D({
1370
1370
  text: e,
1371
1371
  cause: t
1372
1372
  }),
@@ -1374,41 +1374,41 @@ async function vn({ text: e, schema: t }) {
1374
1374
  };
1375
1375
  }
1376
1376
  }
1377
- function yn({ stream: e, schema: t }) {
1378
- return e.pipeThrough(new TextDecoderStream()).pipeThrough(new ct()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1379
- e !== "[DONE]" && n.enqueue(await vn({
1377
+ function bn({ stream: e, schema: t }) {
1378
+ return e.pipeThrough(new TextDecoderStream()).pipeThrough(new lt()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1379
+ e !== "[DONE]" && n.enqueue(await yn({
1380
1380
  text: e,
1381
1381
  schema: t
1382
1382
  }));
1383
1383
  } }));
1384
1384
  }
1385
- async function bn(e) {
1385
+ async function xn(e) {
1386
1386
  return typeof e == "function" && (e = e()), e;
1387
1387
  }
1388
1388
  new TextDecoder();
1389
1389
  // ../../node_modules/.pnpm/ai@7.0.154_zod@4.6.7/node_modules/ai/dist/index.js
1390
- var Y = "AI_InvalidArgumentError", xn = `vercel.ai.error.${Y}`, Sn = Symbol.for(xn), Cn = class extends T {
1390
+ var J = "AI_InvalidArgumentError", Sn = `vercel.ai.error.${J}`, Cn = Symbol.for(Sn), wn = class extends w {
1391
1391
  constructor({ parameter: e, value: t, message: n }) {
1392
1392
  super({
1393
- name: Y,
1393
+ name: J,
1394
1394
  message: `Invalid argument for parameter ${e}: ${n}`
1395
- }), this[Sn] = !0, this.parameter = e, this.value = t;
1395
+ }), this[Cn] = !0, this.parameter = e, this.value = t;
1396
1396
  }
1397
1397
  static isInstance(e) {
1398
- return T.hasMarker(e, xn);
1398
+ return w.hasMarker(e, Sn);
1399
1399
  }
1400
- }, wn = "AI_UIMessageStreamError", Tn = `vercel.ai.error.${wn}`, En = Symbol.for(Tn), Dn = class extends T {
1400
+ }, Tn = "AI_UIMessageStreamError", En = `vercel.ai.error.${Tn}`, Dn = Symbol.for(En), On = class extends w {
1401
1401
  constructor({ chunkType: e, chunkId: t, message: n }) {
1402
1402
  super({
1403
- name: wn,
1403
+ name: Tn,
1404
1404
  message: n
1405
- }), this[En] = !0, this.chunkType = e, this.chunkId = t;
1405
+ }), this[Dn] = !0, this.chunkType = e, this.chunkId = t;
1406
1406
  }
1407
1407
  static isInstance(e) {
1408
- return T.hasMarker(e, Tn);
1408
+ return w.hasMarker(e, En);
1409
1409
  }
1410
1410
  };
1411
- function On(e, t) {
1411
+ function kn(e, t) {
1412
1412
  if (e === void 0 && t === void 0) return;
1413
1413
  if (e === void 0) return t;
1414
1414
  if (t === void 0) return e;
@@ -1417,11 +1417,11 @@ function On(e, t) {
1417
1417
  let i = t[r];
1418
1418
  if (i === void 0) continue;
1419
1419
  let a = r in e ? e[r] : void 0, o = typeof i == "object" && !!i && !Array.isArray(i) && !(i instanceof Date) && !(i instanceof RegExp), s = typeof a == "object" && !!a && !Array.isArray(a) && !(a instanceof Date) && !(a instanceof RegExp);
1420
- n[r] = o && s ? On(a, i) : i;
1420
+ n[r] = o && s ? kn(a, i) : i;
1421
1421
  }
1422
1422
  return n;
1423
1423
  }
1424
- var X = {
1424
+ var Y = {
1425
1425
  array: d,
1426
1426
  boolean: m,
1427
1427
  custom: l,
@@ -1439,236 +1439,236 @@ var X = {
1439
1439
  string: r,
1440
1440
  union: e,
1441
1441
  unknown: _
1442
- }, kn = X.lazy(() => X.union([
1443
- X.null(),
1444
- X.string(),
1445
- X.number(),
1446
- X.boolean(),
1447
- X.record(X.string(), kn.optional()),
1448
- X.array(kn)
1449
- ])), Z = X.record(X.string(), X.record(X.string(), kn.optional())), An = X.union([
1450
- X.string(),
1451
- X.instanceof(Uint8Array),
1452
- X.instanceof(ArrayBuffer),
1453
- X.custom(ft, { message: "Must be a Buffer" })
1454
- ]), jn = X.record(X.string(), X.string()), Mn = X.object({
1455
- type: X.literal("text"),
1456
- text: X.string(),
1457
- providerOptions: Z.optional()
1458
- }), Nn = X.object({
1459
- type: X.literal("image"),
1460
- image: X.union([
1461
- An,
1462
- X.instanceof(URL),
1463
- jn
1442
+ }, An = Y.lazy(() => Y.union([
1443
+ Y.null(),
1444
+ Y.string(),
1445
+ Y.number(),
1446
+ Y.boolean(),
1447
+ Y.record(Y.string(), An.optional()),
1448
+ Y.array(An)
1449
+ ])), X = Y.record(Y.string(), Y.record(Y.string(), An.optional())), jn = Y.union([
1450
+ Y.string(),
1451
+ Y.instanceof(Uint8Array),
1452
+ Y.instanceof(ArrayBuffer),
1453
+ Y.custom(pt, { message: "Must be a Buffer" })
1454
+ ]), Mn = Y.record(Y.string(), Y.string()), Nn = Y.object({
1455
+ type: Y.literal("text"),
1456
+ text: Y.string(),
1457
+ providerOptions: X.optional()
1458
+ }), Pn = Y.object({
1459
+ type: Y.literal("image"),
1460
+ image: Y.union([
1461
+ jn,
1462
+ Y.instanceof(URL),
1463
+ Mn
1464
1464
  ]),
1465
- mediaType: X.string().optional(),
1466
- providerOptions: Z.optional()
1467
- }), Pn = X.discriminatedUnion("type", [
1468
- X.object({
1469
- type: X.literal("data"),
1470
- data: An
1465
+ mediaType: Y.string().optional(),
1466
+ providerOptions: X.optional()
1467
+ }), Fn = Y.discriminatedUnion("type", [
1468
+ Y.object({
1469
+ type: Y.literal("data"),
1470
+ data: jn
1471
1471
  }),
1472
- X.object({
1473
- type: X.literal("url"),
1474
- url: X.instanceof(URL)
1472
+ Y.object({
1473
+ type: Y.literal("url"),
1474
+ url: Y.instanceof(URL)
1475
1475
  }),
1476
- X.object({
1477
- type: X.literal("reference"),
1478
- reference: jn
1476
+ Y.object({
1477
+ type: Y.literal("reference"),
1478
+ reference: Mn
1479
1479
  }),
1480
- X.object({
1481
- type: X.literal("text"),
1482
- text: X.string()
1480
+ Y.object({
1481
+ type: Y.literal("text"),
1482
+ text: Y.string()
1483
1483
  })
1484
- ]), Fn = X.discriminatedUnion("type", [X.object({
1485
- type: X.literal("data"),
1486
- data: An
1487
- }), X.object({
1488
- type: X.literal("url"),
1489
- url: X.instanceof(URL)
1490
- })]), In = X.object({
1491
- type: X.literal("file"),
1492
- data: X.union([
1493
- Pn,
1494
- An,
1495
- X.instanceof(URL),
1496
- jn
1497
- ]),
1498
- filename: X.string().optional(),
1499
- mediaType: X.string(),
1500
- providerOptions: Z.optional()
1501
- }), Ln = X.object({
1502
- type: X.literal("reasoning"),
1503
- text: X.string(),
1504
- providerOptions: Z.optional()
1505
- }), Rn = X.object({
1506
- type: X.literal("custom"),
1507
- kind: X.string().transform((e) => e),
1508
- providerOptions: Z.optional()
1509
- }), zn = X.object({
1510
- type: X.literal("reasoning-file"),
1511
- data: X.union([
1484
+ ]), In = Y.discriminatedUnion("type", [Y.object({
1485
+ type: Y.literal("data"),
1486
+ data: jn
1487
+ }), Y.object({
1488
+ type: Y.literal("url"),
1489
+ url: Y.instanceof(URL)
1490
+ })]), Ln = Y.object({
1491
+ type: Y.literal("file"),
1492
+ data: Y.union([
1512
1493
  Fn,
1513
- An,
1514
- X.instanceof(URL)
1494
+ jn,
1495
+ Y.instanceof(URL),
1496
+ Mn
1497
+ ]),
1498
+ filename: Y.string().optional(),
1499
+ mediaType: Y.string(),
1500
+ providerOptions: X.optional()
1501
+ }), Rn = Y.object({
1502
+ type: Y.literal("reasoning"),
1503
+ text: Y.string(),
1504
+ providerOptions: X.optional()
1505
+ }), zn = Y.object({
1506
+ type: Y.literal("custom"),
1507
+ kind: Y.string().transform((e) => e),
1508
+ providerOptions: X.optional()
1509
+ }), Bn = Y.object({
1510
+ type: Y.literal("reasoning-file"),
1511
+ data: Y.union([
1512
+ In,
1513
+ jn,
1514
+ Y.instanceof(URL)
1515
1515
  ]),
1516
- mediaType: X.string(),
1517
- providerOptions: Z.optional()
1518
- }), Bn = X.object({
1519
- type: X.literal("tool-call"),
1520
- toolCallId: X.string(),
1521
- toolName: X.string(),
1522
- input: X.unknown(),
1523
- providerOptions: Z.optional(),
1524
- providerExecuted: X.boolean().optional()
1525
- }), Vn = X.discriminatedUnion("type", [
1526
- X.object({
1527
- type: X.literal("text"),
1528
- value: X.string(),
1529
- providerOptions: Z.optional()
1516
+ mediaType: Y.string(),
1517
+ providerOptions: X.optional()
1518
+ }), Vn = Y.object({
1519
+ type: Y.literal("tool-call"),
1520
+ toolCallId: Y.string(),
1521
+ toolName: Y.string(),
1522
+ input: Y.unknown(),
1523
+ providerOptions: X.optional(),
1524
+ providerExecuted: Y.boolean().optional()
1525
+ }), Hn = Y.discriminatedUnion("type", [
1526
+ Y.object({
1527
+ type: Y.literal("text"),
1528
+ value: Y.string(),
1529
+ providerOptions: X.optional()
1530
1530
  }),
1531
- X.object({
1532
- type: X.literal("json"),
1533
- value: kn,
1534
- providerOptions: Z.optional()
1531
+ Y.object({
1532
+ type: Y.literal("json"),
1533
+ value: An,
1534
+ providerOptions: X.optional()
1535
1535
  }),
1536
- X.object({
1537
- type: X.literal("execution-denied"),
1538
- reason: X.string().optional(),
1539
- providerOptions: Z.optional()
1536
+ Y.object({
1537
+ type: Y.literal("execution-denied"),
1538
+ reason: Y.string().optional(),
1539
+ providerOptions: X.optional()
1540
1540
  }),
1541
- X.object({
1542
- type: X.literal("error-text"),
1543
- value: X.string(),
1544
- providerOptions: Z.optional()
1541
+ Y.object({
1542
+ type: Y.literal("error-text"),
1543
+ value: Y.string(),
1544
+ providerOptions: X.optional()
1545
1545
  }),
1546
- X.object({
1547
- type: X.literal("error-json"),
1548
- value: kn,
1549
- providerOptions: Z.optional()
1546
+ Y.object({
1547
+ type: Y.literal("error-json"),
1548
+ value: An,
1549
+ providerOptions: X.optional()
1550
1550
  }),
1551
- X.object({
1552
- type: X.literal("content"),
1553
- value: X.array(X.union([
1554
- X.object({
1555
- type: X.literal("text"),
1556
- text: X.string(),
1557
- providerOptions: Z.optional()
1551
+ Y.object({
1552
+ type: Y.literal("content"),
1553
+ value: Y.array(Y.union([
1554
+ Y.object({
1555
+ type: Y.literal("text"),
1556
+ text: Y.string(),
1557
+ providerOptions: X.optional()
1558
1558
  }),
1559
- X.object({
1560
- type: X.literal("file"),
1561
- data: Pn,
1562
- mediaType: X.string(),
1563
- filename: X.string().optional(),
1564
- providerOptions: Z.optional()
1559
+ Y.object({
1560
+ type: Y.literal("file"),
1561
+ data: Fn,
1562
+ mediaType: Y.string(),
1563
+ filename: Y.string().optional(),
1564
+ providerOptions: X.optional()
1565
1565
  }),
1566
- X.object({
1567
- type: X.literal("file-data"),
1568
- data: X.string(),
1569
- mediaType: X.string(),
1570
- filename: X.string().optional(),
1571
- providerOptions: Z.optional()
1566
+ Y.object({
1567
+ type: Y.literal("file-data"),
1568
+ data: Y.string(),
1569
+ mediaType: Y.string(),
1570
+ filename: Y.string().optional(),
1571
+ providerOptions: X.optional()
1572
1572
  }),
1573
- X.object({
1574
- type: X.literal("file-url"),
1575
- url: X.string(),
1576
- mediaType: X.string().optional(),
1577
- providerOptions: Z.optional()
1573
+ Y.object({
1574
+ type: Y.literal("file-url"),
1575
+ url: Y.string(),
1576
+ mediaType: Y.string().optional(),
1577
+ providerOptions: X.optional()
1578
1578
  }),
1579
- X.object({
1580
- type: X.literal("file-id"),
1581
- fileId: X.union([X.string(), X.record(X.string(), X.string())]),
1582
- providerOptions: Z.optional()
1579
+ Y.object({
1580
+ type: Y.literal("file-id"),
1581
+ fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
1582
+ providerOptions: X.optional()
1583
1583
  }),
1584
- X.object({
1585
- type: X.literal("file-reference"),
1586
- providerReference: X.record(X.string(), X.string()),
1587
- providerOptions: Z.optional()
1584
+ Y.object({
1585
+ type: Y.literal("file-reference"),
1586
+ providerReference: Y.record(Y.string(), Y.string()),
1587
+ providerOptions: X.optional()
1588
1588
  }),
1589
- X.object({
1590
- type: X.literal("image-data"),
1591
- data: X.string(),
1592
- mediaType: X.string(),
1593
- providerOptions: Z.optional()
1589
+ Y.object({
1590
+ type: Y.literal("image-data"),
1591
+ data: Y.string(),
1592
+ mediaType: Y.string(),
1593
+ providerOptions: X.optional()
1594
1594
  }),
1595
- X.object({
1596
- type: X.literal("image-url"),
1597
- url: X.string(),
1598
- providerOptions: Z.optional()
1595
+ Y.object({
1596
+ type: Y.literal("image-url"),
1597
+ url: Y.string(),
1598
+ providerOptions: X.optional()
1599
1599
  }),
1600
- X.object({
1601
- type: X.literal("image-file-id"),
1602
- fileId: X.union([X.string(), X.record(X.string(), X.string())]),
1603
- providerOptions: Z.optional()
1600
+ Y.object({
1601
+ type: Y.literal("image-file-id"),
1602
+ fileId: Y.union([Y.string(), Y.record(Y.string(), Y.string())]),
1603
+ providerOptions: X.optional()
1604
1604
  }),
1605
- X.object({
1606
- type: X.literal("image-file-reference"),
1607
- providerReference: X.record(X.string(), X.string()),
1608
- providerOptions: Z.optional()
1605
+ Y.object({
1606
+ type: Y.literal("image-file-reference"),
1607
+ providerReference: Y.record(Y.string(), Y.string()),
1608
+ providerOptions: X.optional()
1609
1609
  }),
1610
- X.object({
1611
- type: X.literal("custom"),
1612
- providerOptions: Z.optional()
1610
+ Y.object({
1611
+ type: Y.literal("custom"),
1612
+ providerOptions: X.optional()
1613
1613
  })
1614
1614
  ]))
1615
1615
  })
1616
- ]), Q = X.object({
1617
- type: X.literal("tool-result"),
1618
- toolCallId: X.string(),
1619
- toolName: X.string(),
1620
- output: Vn,
1621
- providerOptions: Z.optional()
1622
- }), Hn = X.object({
1623
- type: X.literal("tool-approval-request"),
1624
- approvalId: X.string(),
1625
- toolCallId: X.string(),
1626
- reason: X.string().optional(),
1627
- isAutomatic: X.boolean().optional(),
1628
- signature: X.string().optional(),
1629
- inputSchemaInput: X.unknown().optional()
1630
- }), Un = X.object({
1631
- type: X.literal("tool-approval-response"),
1632
- approvalId: X.string(),
1633
- approved: X.boolean(),
1634
- reason: X.string().optional()
1635
- }), Wn = X.object({
1636
- role: X.literal("system"),
1637
- content: X.string(),
1638
- providerOptions: Z.optional()
1639
- }), Gn = X.object({
1640
- role: X.literal("user"),
1641
- content: X.union([X.string(), X.array(X.union([
1642
- Mn,
1616
+ ]), Z = Y.object({
1617
+ type: Y.literal("tool-result"),
1618
+ toolCallId: Y.string(),
1619
+ toolName: Y.string(),
1620
+ output: Hn,
1621
+ providerOptions: X.optional()
1622
+ }), Un = Y.object({
1623
+ type: Y.literal("tool-approval-request"),
1624
+ approvalId: Y.string(),
1625
+ toolCallId: Y.string(),
1626
+ reason: Y.string().optional(),
1627
+ isAutomatic: Y.boolean().optional(),
1628
+ signature: Y.string().optional(),
1629
+ inputSchemaInput: Y.unknown().optional()
1630
+ }), Wn = Y.object({
1631
+ type: Y.literal("tool-approval-response"),
1632
+ approvalId: Y.string(),
1633
+ approved: Y.boolean(),
1634
+ reason: Y.string().optional()
1635
+ }), Gn = Y.object({
1636
+ role: Y.literal("system"),
1637
+ content: Y.string(),
1638
+ providerOptions: X.optional()
1639
+ }), Kn = Y.object({
1640
+ role: Y.literal("user"),
1641
+ content: Y.union([Y.string(), Y.array(Y.union([
1643
1642
  Nn,
1644
- In
1643
+ Pn,
1644
+ Ln
1645
1645
  ]))]),
1646
- providerOptions: Z.optional()
1647
- }), Kn = X.object({
1648
- role: X.literal("assistant"),
1649
- content: X.union([X.string(), X.array(X.union([
1650
- Mn,
1651
- Rn,
1652
- In,
1653
- Ln,
1646
+ providerOptions: X.optional()
1647
+ }), qn = Y.object({
1648
+ role: Y.literal("assistant"),
1649
+ content: Y.union([Y.string(), Y.array(Y.union([
1650
+ Nn,
1654
1651
  zn,
1652
+ Ln,
1653
+ Rn,
1655
1654
  Bn,
1656
- Q,
1657
- Hn
1655
+ Vn,
1656
+ Z,
1657
+ Un
1658
1658
  ]))]),
1659
- providerOptions: Z.optional()
1660
- }), qn = X.object({
1661
- role: X.literal("tool"),
1662
- content: X.array(X.union([Q, Un])),
1663
- providerOptions: Z.optional()
1659
+ providerOptions: X.optional()
1660
+ }), Jn = Y.object({
1661
+ role: Y.literal("tool"),
1662
+ content: Y.array(Y.union([Z, Wn])),
1663
+ providerOptions: X.optional()
1664
1664
  });
1665
- X.union([
1666
- Wn,
1665
+ Y.union([
1667
1666
  Gn,
1668
1667
  Kn,
1669
- qn
1668
+ qn,
1669
+ Jn
1670
1670
  ]);
1671
- function Jn(e) {
1671
+ function Yn(e) {
1672
1672
  let t = ["ROOT"], n = -1, r = null, i = 0;
1673
1673
  function a(e) {
1674
1674
  return e >= "0" && e <= "9" || e >= "A" && e <= "F" || e >= "a" && e <= "f";
@@ -1850,16 +1850,16 @@ function Jn(e) {
1850
1850
  }
1851
1851
  return l;
1852
1852
  }
1853
- async function Yn(e) {
1853
+ async function Xn(e) {
1854
1854
  if (e === void 0) return {
1855
1855
  value: void 0,
1856
1856
  state: "undefined-input"
1857
1857
  };
1858
- let t = await vn({ text: e });
1858
+ let t = await yn({ text: e });
1859
1859
  return t.success ? {
1860
1860
  value: t.value,
1861
1861
  state: "successful-parse"
1862
- } : (t = await vn({ text: Jn(e) }), t.success ? {
1862
+ } : (t = await yn({ text: Yn(e) }), t.success ? {
1863
1863
  value: t.value,
1864
1864
  state: "repaired-parse"
1865
1865
  } : {
@@ -1867,203 +1867,203 @@ async function Yn(e) {
1867
1867
  state: "failed-parse"
1868
1868
  });
1869
1869
  }
1870
- M({
1870
+ j({
1871
1871
  prefix: "steer",
1872
1872
  size: 24
1873
- }), new TextEncoder(), new TextEncoder(), M({
1873
+ }), new TextEncoder(), new TextEncoder(), j({
1874
1874
  prefix: "aitxt",
1875
1875
  size: 24
1876
- }), M({
1876
+ }), j({
1877
1877
  prefix: "call",
1878
1878
  size: 24
1879
1879
  }), TransformStream;
1880
- var Xn = X.object({
1881
- source: X.discriminatedUnion("sourceType", [X.object({
1882
- type: X.literal("source"),
1883
- sourceType: X.literal("url"),
1884
- id: X.string(),
1885
- url: X.string(),
1886
- title: X.string().optional(),
1887
- providerMetadata: Z.optional()
1888
- }), X.object({
1889
- type: X.literal("source"),
1890
- sourceType: X.literal("document"),
1891
- id: X.string(),
1892
- mediaType: X.string(),
1893
- title: X.string(),
1894
- filename: X.string().optional(),
1895
- providerMetadata: Z.optional()
1880
+ var Zn = Y.object({
1881
+ source: Y.discriminatedUnion("sourceType", [Y.object({
1882
+ type: Y.literal("source"),
1883
+ sourceType: Y.literal("url"),
1884
+ id: Y.string(),
1885
+ url: Y.string(),
1886
+ title: Y.string().optional(),
1887
+ providerMetadata: X.optional()
1888
+ }), Y.object({
1889
+ type: Y.literal("source"),
1890
+ sourceType: Y.literal("document"),
1891
+ id: Y.string(),
1892
+ mediaType: Y.string(),
1893
+ title: Y.string(),
1894
+ filename: Y.string().optional(),
1895
+ providerMetadata: X.optional()
1896
1896
  })]),
1897
- startIndex: X.number().int().nonnegative().optional(),
1898
- endIndex: X.number().int().nonnegative().optional(),
1899
- citedText: X.string().optional()
1900
- }), Zn = X.record(X.string(), kn.optional()), Qn = on(() => hn(X.union([
1901
- X.looseObject({
1902
- type: X.literal("text-start"),
1903
- id: X.string(),
1904
- providerMetadata: Z.optional()
1897
+ startIndex: Y.number().int().nonnegative().optional(),
1898
+ endIndex: Y.number().int().nonnegative().optional(),
1899
+ citedText: Y.string().optional()
1900
+ }), Qn = Y.record(Y.string(), An.optional()), $n = sn(() => gn(Y.union([
1901
+ Y.looseObject({
1902
+ type: Y.literal("text-start"),
1903
+ id: Y.string(),
1904
+ providerMetadata: X.optional()
1905
1905
  }),
1906
- X.looseObject({
1907
- type: X.literal("text-delta"),
1908
- id: X.string(),
1909
- delta: X.string(),
1910
- providerMetadata: Z.optional()
1906
+ Y.looseObject({
1907
+ type: Y.literal("text-delta"),
1908
+ id: Y.string(),
1909
+ delta: Y.string(),
1910
+ providerMetadata: X.optional()
1911
1911
  }),
1912
- X.looseObject({
1913
- type: X.literal("text-end"),
1914
- id: X.string(),
1915
- citations: X.array(Xn).optional(),
1916
- providerMetadata: Z.optional()
1912
+ Y.looseObject({
1913
+ type: Y.literal("text-end"),
1914
+ id: Y.string(),
1915
+ citations: Y.array(Zn).optional(),
1916
+ providerMetadata: X.optional()
1917
1917
  }),
1918
- X.looseObject({
1919
- type: X.literal("error"),
1920
- errorText: X.string()
1918
+ Y.looseObject({
1919
+ type: Y.literal("error"),
1920
+ errorText: Y.string()
1921
1921
  }),
1922
- X.looseObject({
1923
- type: X.literal("tool-input-start"),
1924
- toolCallId: X.string(),
1925
- toolName: X.string(),
1926
- inputEncoding: X.enum(["json", "text"]).optional(),
1927
- providerExecuted: X.boolean().optional(),
1928
- providerMetadata: Z.optional(),
1929
- toolMetadata: Zn.optional(),
1930
- dynamic: X.boolean().optional(),
1931
- title: X.string().optional()
1922
+ Y.looseObject({
1923
+ type: Y.literal("tool-input-start"),
1924
+ toolCallId: Y.string(),
1925
+ toolName: Y.string(),
1926
+ inputEncoding: Y.enum(["json", "text"]).optional(),
1927
+ providerExecuted: Y.boolean().optional(),
1928
+ providerMetadata: X.optional(),
1929
+ toolMetadata: Qn.optional(),
1930
+ dynamic: Y.boolean().optional(),
1931
+ title: Y.string().optional()
1932
1932
  }),
1933
- X.looseObject({
1934
- type: X.literal("tool-input-delta"),
1935
- toolCallId: X.string(),
1936
- inputTextDelta: X.string()
1933
+ Y.looseObject({
1934
+ type: Y.literal("tool-input-delta"),
1935
+ toolCallId: Y.string(),
1936
+ inputTextDelta: Y.string()
1937
1937
  }),
1938
- X.looseObject({
1939
- type: X.literal("tool-input-available"),
1940
- toolCallId: X.string(),
1941
- toolName: X.string(),
1942
- input: X.unknown(),
1943
- providerExecuted: X.boolean().optional(),
1944
- providerMetadata: Z.optional(),
1945
- toolMetadata: Zn.optional(),
1946
- dynamic: X.boolean().optional(),
1947
- title: X.string().optional()
1938
+ Y.looseObject({
1939
+ type: Y.literal("tool-input-available"),
1940
+ toolCallId: Y.string(),
1941
+ toolName: Y.string(),
1942
+ input: Y.unknown(),
1943
+ providerExecuted: Y.boolean().optional(),
1944
+ providerMetadata: X.optional(),
1945
+ toolMetadata: Qn.optional(),
1946
+ dynamic: Y.boolean().optional(),
1947
+ title: Y.string().optional()
1948
1948
  }),
1949
- X.looseObject({
1950
- type: X.literal("tool-input-error"),
1951
- toolCallId: X.string(),
1952
- toolName: X.string(),
1953
- input: X.unknown(),
1954
- providerExecuted: X.boolean().optional(),
1955
- providerMetadata: Z.optional(),
1956
- toolMetadata: Zn.optional(),
1957
- dynamic: X.boolean().optional(),
1958
- errorText: X.string(),
1959
- title: X.string().optional()
1949
+ Y.looseObject({
1950
+ type: Y.literal("tool-input-error"),
1951
+ toolCallId: Y.string(),
1952
+ toolName: Y.string(),
1953
+ input: Y.unknown(),
1954
+ providerExecuted: Y.boolean().optional(),
1955
+ providerMetadata: X.optional(),
1956
+ toolMetadata: Qn.optional(),
1957
+ dynamic: Y.boolean().optional(),
1958
+ errorText: Y.string(),
1959
+ title: Y.string().optional()
1960
1960
  }),
1961
- X.looseObject({
1962
- type: X.literal("tool-approval-request"),
1963
- approvalId: X.string(),
1964
- toolCallId: X.string(),
1965
- approvalDescriptor: X.unknown().optional(),
1966
- inputSchemaInput: X.unknown().optional(),
1967
- reason: X.string().optional(),
1968
- isAutomatic: X.boolean().optional(),
1969
- signature: X.string().optional()
1961
+ Y.looseObject({
1962
+ type: Y.literal("tool-approval-request"),
1963
+ approvalId: Y.string(),
1964
+ toolCallId: Y.string(),
1965
+ approvalDescriptor: Y.unknown().optional(),
1966
+ inputSchemaInput: Y.unknown().optional(),
1967
+ reason: Y.string().optional(),
1968
+ isAutomatic: Y.boolean().optional(),
1969
+ signature: Y.string().optional()
1970
1970
  }),
1971
- X.looseObject({
1972
- type: X.literal("tool-approval-response"),
1973
- approvalId: X.string(),
1974
- approved: X.boolean(),
1975
- reason: X.string().optional(),
1976
- providerExecuted: X.boolean().optional(),
1977
- providerMetadata: Z.optional()
1971
+ Y.looseObject({
1972
+ type: Y.literal("tool-approval-response"),
1973
+ approvalId: Y.string(),
1974
+ approved: Y.boolean(),
1975
+ reason: Y.string().optional(),
1976
+ providerExecuted: Y.boolean().optional(),
1977
+ providerMetadata: X.optional()
1978
1978
  }),
1979
- X.looseObject({
1980
- type: X.literal("tool-output-available"),
1981
- toolCallId: X.string(),
1982
- output: X.unknown(),
1983
- providerExecuted: X.boolean().optional(),
1984
- providerMetadata: Z.optional(),
1985
- toolMetadata: Zn.optional(),
1986
- dynamic: X.boolean().optional(),
1987
- preliminary: X.boolean().optional()
1979
+ Y.looseObject({
1980
+ type: Y.literal("tool-output-available"),
1981
+ toolCallId: Y.string(),
1982
+ output: Y.unknown(),
1983
+ providerExecuted: Y.boolean().optional(),
1984
+ providerMetadata: X.optional(),
1985
+ toolMetadata: Qn.optional(),
1986
+ dynamic: Y.boolean().optional(),
1987
+ preliminary: Y.boolean().optional()
1988
1988
  }),
1989
- X.looseObject({
1990
- type: X.literal("tool-output-error"),
1991
- toolCallId: X.string(),
1992
- errorText: X.string(),
1993
- providerExecuted: X.boolean().optional(),
1994
- providerMetadata: Z.optional(),
1995
- toolMetadata: Zn.optional(),
1996
- dynamic: X.boolean().optional()
1989
+ Y.looseObject({
1990
+ type: Y.literal("tool-output-error"),
1991
+ toolCallId: Y.string(),
1992
+ errorText: Y.string(),
1993
+ providerExecuted: Y.boolean().optional(),
1994
+ providerMetadata: X.optional(),
1995
+ toolMetadata: Qn.optional(),
1996
+ dynamic: Y.boolean().optional()
1997
1997
  }),
1998
- X.looseObject({
1999
- type: X.literal("tool-output-denied"),
2000
- toolCallId: X.string()
1998
+ Y.looseObject({
1999
+ type: Y.literal("tool-output-denied"),
2000
+ toolCallId: Y.string()
2001
2001
  }),
2002
- X.looseObject({
2003
- type: X.literal("reasoning-start"),
2004
- id: X.string(),
2005
- providerMetadata: Z.optional()
2002
+ Y.looseObject({
2003
+ type: Y.literal("reasoning-start"),
2004
+ id: Y.string(),
2005
+ providerMetadata: X.optional()
2006
2006
  }),
2007
- X.looseObject({
2008
- type: X.literal("reasoning-delta"),
2009
- id: X.string(),
2010
- delta: X.string(),
2011
- providerMetadata: Z.optional()
2007
+ Y.looseObject({
2008
+ type: Y.literal("reasoning-delta"),
2009
+ id: Y.string(),
2010
+ delta: Y.string(),
2011
+ providerMetadata: X.optional()
2012
2012
  }),
2013
- X.looseObject({
2014
- type: X.literal("reasoning-end"),
2015
- id: X.string(),
2016
- providerMetadata: Z.optional()
2013
+ Y.looseObject({
2014
+ type: Y.literal("reasoning-end"),
2015
+ id: Y.string(),
2016
+ providerMetadata: X.optional()
2017
2017
  }),
2018
- X.looseObject({
2019
- type: X.literal("custom"),
2020
- kind: X.string().transform((e) => e),
2021
- providerMetadata: Z.optional()
2018
+ Y.looseObject({
2019
+ type: Y.literal("custom"),
2020
+ kind: Y.string().transform((e) => e),
2021
+ providerMetadata: X.optional()
2022
2022
  }),
2023
- X.looseObject({
2024
- type: X.literal("source-url"),
2025
- sourceId: X.string(),
2026
- url: X.string(),
2027
- title: X.string().optional(),
2028
- providerMetadata: Z.optional()
2023
+ Y.looseObject({
2024
+ type: Y.literal("source-url"),
2025
+ sourceId: Y.string(),
2026
+ url: Y.string(),
2027
+ title: Y.string().optional(),
2028
+ providerMetadata: X.optional()
2029
2029
  }),
2030
- X.looseObject({
2031
- type: X.literal("source-document"),
2032
- sourceId: X.string(),
2033
- mediaType: X.string(),
2034
- title: X.string(),
2035
- filename: X.string().optional(),
2036
- providerMetadata: Z.optional()
2030
+ Y.looseObject({
2031
+ type: Y.literal("source-document"),
2032
+ sourceId: Y.string(),
2033
+ mediaType: Y.string(),
2034
+ title: Y.string(),
2035
+ filename: Y.string().optional(),
2036
+ providerMetadata: X.optional()
2037
2037
  }),
2038
- X.looseObject({
2039
- type: X.literal("file"),
2040
- url: X.string(),
2041
- mediaType: X.string(),
2042
- providerMetadata: Z.optional()
2038
+ Y.looseObject({
2039
+ type: Y.literal("file"),
2040
+ url: Y.string(),
2041
+ mediaType: Y.string(),
2042
+ providerMetadata: X.optional()
2043
2043
  }),
2044
- X.looseObject({
2045
- type: X.literal("reasoning-file"),
2046
- url: X.string(),
2047
- mediaType: X.string(),
2048
- providerMetadata: Z.optional()
2044
+ Y.looseObject({
2045
+ type: Y.literal("reasoning-file"),
2046
+ url: Y.string(),
2047
+ mediaType: Y.string(),
2048
+ providerMetadata: X.optional()
2049
2049
  }),
2050
- X.looseObject({
2051
- type: X.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
2052
- id: X.string().optional(),
2053
- data: X.unknown(),
2054
- transient: X.boolean().optional()
2050
+ Y.looseObject({
2051
+ type: Y.custom((e) => typeof e == "string" && e.startsWith("data-"), { message: "Type must start with \"data-\"" }),
2052
+ id: Y.string().optional(),
2053
+ data: Y.unknown(),
2054
+ transient: Y.boolean().optional()
2055
2055
  }),
2056
- X.looseObject({ type: X.literal("start-step") }),
2057
- X.looseObject({ type: X.literal("finish-step") }),
2058
- X.looseObject({ type: X.literal("reset-step") }),
2059
- X.looseObject({
2060
- type: X.literal("start"),
2061
- messageId: X.string().optional(),
2062
- messageMetadata: X.unknown().optional()
2056
+ Y.looseObject({ type: Y.literal("start-step") }),
2057
+ Y.looseObject({ type: Y.literal("finish-step") }),
2058
+ Y.looseObject({ type: Y.literal("reset-step") }),
2059
+ Y.looseObject({
2060
+ type: Y.literal("start"),
2061
+ messageId: Y.string().optional(),
2062
+ messageMetadata: Y.unknown().optional()
2063
2063
  }),
2064
- X.looseObject({
2065
- type: X.literal("finish"),
2066
- finishReason: X.enum([
2064
+ Y.looseObject({
2065
+ type: Y.literal("finish"),
2066
+ finishReason: Y.enum([
2067
2067
  "stop",
2068
2068
  "length",
2069
2069
  "content-filter",
@@ -2072,50 +2072,50 @@ var Xn = X.object({
2072
2072
  "interrupted",
2073
2073
  "other"
2074
2074
  ]).optional(),
2075
- messageMetadata: X.unknown().optional()
2075
+ messageMetadata: Y.unknown().optional()
2076
2076
  }),
2077
- X.looseObject({
2078
- type: X.literal("abort"),
2079
- reason: X.string().optional()
2077
+ Y.looseObject({
2078
+ type: Y.literal("abort"),
2079
+ reason: Y.string().optional()
2080
2080
  }),
2081
- X.looseObject({
2082
- type: X.literal("message-metadata"),
2083
- messageMetadata: X.unknown()
2081
+ Y.looseObject({
2082
+ type: Y.literal("message-metadata"),
2083
+ messageMetadata: Y.unknown()
2084
2084
  })
2085
2085
  ])));
2086
- function $n(e) {
2086
+ function er(e) {
2087
2087
  return e.type.startsWith("data-");
2088
2088
  }
2089
- function er() {
2089
+ function tr() {
2090
2090
  return Object.create(null);
2091
2091
  }
2092
- function tr(e) {
2092
+ function nr(e) {
2093
2093
  return e.type.startsWith("tool-");
2094
2094
  }
2095
- function nr(e) {
2095
+ function rr(e) {
2096
2096
  return e.type === "dynamic-tool";
2097
2097
  }
2098
- function $(e) {
2099
- return tr(e) || nr(e);
2098
+ function Q(e) {
2099
+ return nr(e) || rr(e);
2100
2100
  }
2101
- function rr(e) {
2101
+ function ir(e) {
2102
2102
  return e.type.split("-").slice(1).join("-");
2103
2103
  }
2104
- function ir({ lastMessage: e, messageId: t }) {
2104
+ function ar({ lastMessage: e, messageId: t }) {
2105
2105
  let n = e?.role === "assistant" ? e : {
2106
2106
  id: t,
2107
2107
  metadata: void 0,
2108
2108
  role: "assistant",
2109
2109
  parts: []
2110
- }, r = er(), i = n.parts.findLastIndex((e) => e.type === "step-start"), a = 0;
2110
+ }, r = tr(), i = n.parts.findLastIndex((e) => e.type === "step-start"), a = 0;
2111
2111
  for (let e of n.parts.slice(i + 1)) {
2112
- if (!$(e)) continue;
2112
+ if (!Q(e)) continue;
2113
2113
  let t = a;
2114
- tr(e) && a++, e.state === "input-streaming" && (r[e.toolCallId] = {
2114
+ nr(e) && a++, e.state === "input-streaming" && (r[e.toolCallId] = {
2115
2115
  text: e.rawInput ?? "",
2116
2116
  inputEncoding: e.inputEncoding,
2117
2117
  index: t,
2118
- toolName: e.type === "dynamic-tool" ? e.toolName : rr(e),
2118
+ toolName: e.type === "dynamic-tool" ? e.toolName : ir(e),
2119
2119
  dynamic: e.type === "dynamic-tool",
2120
2120
  title: e.title,
2121
2121
  toolMetadata: e.toolMetadata
@@ -2123,12 +2123,12 @@ function ir({ lastMessage: e, messageId: t }) {
2123
2123
  }
2124
2124
  return {
2125
2125
  message: n,
2126
- activeTextParts: er(),
2127
- activeReasoningParts: er(),
2126
+ activeTextParts: tr(),
2127
+ activeReasoningParts: tr(),
2128
2128
  partialToolCalls: r
2129
2129
  };
2130
2130
  }
2131
- function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o, resetStateOnMessageIdChange: s = !1, resetStateOnFirstMessageStart: c = !1 }) {
2131
+ function or({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdateMessageJob: r, onError: i, onToolCall: a, onData: o, resetStateOnMessageIdChange: s = !1, resetStateOnFirstMessageStart: c = !1 }) {
2132
2132
  let l = !0;
2133
2133
  return e.pipeThrough(new TransformStream({ async transform(e, u) {
2134
2134
  await r(async ({ state: r, write: d }) => {
@@ -2138,7 +2138,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2138
2138
  return e.slice(t + 1);
2139
2139
  }
2140
2140
  function p() {
2141
- return f().filter($);
2141
+ return f().filter(Q);
2142
2142
  }
2143
2143
  function m(e) {
2144
2144
  let t = p().find((t) => t.toolCallId === e);
@@ -2146,13 +2146,13 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2146
2146
  let n = r.message.parts;
2147
2147
  for (let r = n.length - 1; r >= 0; r--) {
2148
2148
  let i = n[r];
2149
- if ($(i) && i.toolCallId === e) {
2149
+ if (Q(i) && i.toolCallId === e) {
2150
2150
  t = i;
2151
2151
  break;
2152
2152
  }
2153
2153
  }
2154
2154
  }
2155
- if (t == null) throw new Dn({
2155
+ if (t == null) throw new On({
2156
2156
  chunkType: "tool-invocation",
2157
2157
  chunkId: e,
2158
2158
  message: `No tool invocation found for tool call ID "${e}".`
@@ -2160,8 +2160,8 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2160
2160
  return t;
2161
2161
  }
2162
2162
  function h(e) {
2163
- let t = r.message.parts.filter($).find((t) => t.approval?.id === e);
2164
- if (t == null) throw new Dn({
2163
+ let t = r.message.parts.filter(Q).find((t) => t.approval?.id === e);
2164
+ if (t == null) throw new On({
2165
2165
  chunkType: "tool-approval-response",
2166
2166
  chunkId: e,
2167
2167
  message: `No tool invocation found for approval ID "${e}".`
@@ -2169,7 +2169,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2169
2169
  return t;
2170
2170
  }
2171
2171
  function g(e, t) {
2172
- let n = t ?? f().find((t) => tr(t) && t.toolCallId === e.toolCallId), i = e, a = n;
2172
+ let n = t ?? f().find((t) => nr(t) && t.toolCallId === e.toolCallId), i = e, a = n;
2173
2173
  if (n != null) {
2174
2174
  n.state = e.state, a.type = `tool-${e.toolName}`, a.input = i.input, a.output = i.output, a.errorText = i.errorText, a.rawInput = i.rawInput, i.inputEncoding == null ? delete a.inputEncoding : a.inputEncoding = i.inputEncoding, a.preliminary = i.preliminary, e.title !== void 0 && (a.title = e.title), e.toolMetadata !== void 0 && (a.toolMetadata = e.toolMetadata), a.providerExecuted = i.providerExecuted ?? n.providerExecuted;
2175
2175
  let t = i.providerMetadata;
@@ -2226,8 +2226,8 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2226
2226
  }
2227
2227
  async function v(e) {
2228
2228
  if (e != null) {
2229
- let n = r.message.metadata == null ? e : On(r.message.metadata, e);
2230
- t != null && await gn({
2229
+ let n = r.message.metadata == null ? e : kn(r.message.metadata, e);
2230
+ t != null && await _n({
2231
2231
  value: n,
2232
2232
  schema: t,
2233
2233
  context: {
@@ -2250,7 +2250,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2250
2250
  }
2251
2251
  case "text-delta": {
2252
2252
  let t = r.activeTextParts[e.id];
2253
- if (t == null) throw new Dn({
2253
+ if (t == null) throw new On({
2254
2254
  chunkType: "text-delta",
2255
2255
  chunkId: e.id,
2256
2256
  message: `Received text-delta for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-delta" chunks.`
@@ -2260,7 +2260,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2260
2260
  }
2261
2261
  case "text-end": {
2262
2262
  let t = r.activeTextParts[e.id];
2263
- if (t == null) throw new Dn({
2263
+ if (t == null) throw new On({
2264
2264
  chunkType: "text-end",
2265
2265
  chunkId: e.id,
2266
2266
  message: `Received text-end for missing text part with ID "${e.id}". Ensure a "text-start" chunk is sent before any "text-end" chunks.`
@@ -2290,7 +2290,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2290
2290
  }
2291
2291
  case "reasoning-delta": {
2292
2292
  let t = r.activeReasoningParts[e.id];
2293
- if (t == null) throw new Dn({
2293
+ if (t == null) throw new On({
2294
2294
  chunkType: "reasoning-delta",
2295
2295
  chunkId: e.id,
2296
2296
  message: `Received reasoning-delta for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-delta" chunks.`
@@ -2300,7 +2300,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2300
2300
  }
2301
2301
  case "reasoning-end": {
2302
2302
  let t = r.activeReasoningParts[e.id];
2303
- if (t == null) throw new Dn({
2303
+ if (t == null) throw new On({
2304
2304
  chunkType: "reasoning-end",
2305
2305
  chunkId: e.id,
2306
2306
  message: `Received reasoning-end for missing reasoning part with ID "${e.id}". Ensure a "reasoning-start" chunk is sent before any "reasoning-end" chunks.`
@@ -2337,7 +2337,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2337
2337
  }), d();
2338
2338
  break;
2339
2339
  case "tool-input-start": {
2340
- let t = f().filter(tr);
2340
+ let t = f().filter(nr);
2341
2341
  r.partialToolCalls[e.toolCallId] = {
2342
2342
  text: "",
2343
2343
  inputEncoding: e.inputEncoding,
@@ -2371,13 +2371,13 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2371
2371
  }
2372
2372
  case "tool-input-delta": {
2373
2373
  let t = r.partialToolCalls[e.toolCallId];
2374
- if (t == null) throw new Dn({
2374
+ if (t == null) throw new On({
2375
2375
  chunkType: "tool-input-delta",
2376
2376
  chunkId: e.toolCallId,
2377
2377
  message: `Received tool-input-delta for missing tool call with ID "${e.toolCallId}". Ensure a "tool-input-start" chunk is sent before any "tool-input-delta" chunks.`
2378
2378
  });
2379
2379
  t.text += e.inputTextDelta;
2380
- let n = t.inputEncoding === "text" ? t.text : (await Yn(t.text)).value;
2380
+ let n = t.inputEncoding === "text" ? t.text : (await Xn(t.text)).value;
2381
2381
  t.dynamic ? _({
2382
2382
  toolCallId: e.toolCallId,
2383
2383
  toolName: t.toolName,
@@ -2421,7 +2421,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2421
2421
  }), d(), a && !e.providerExecuted && await a({ toolCall: e });
2422
2422
  break;
2423
2423
  case "tool-input-error": {
2424
- let t = f().filter($).find((t) => t.toolCallId === e.toolCallId);
2424
+ let t = f().filter(Q).find((t) => t.toolCallId === e.toolCallId);
2425
2425
  (t == null ? e.dynamic : t.type === "dynamic-tool") ? _({
2426
2426
  toolCallId: e.toolCallId,
2427
2427
  toolName: e.toolName,
@@ -2485,7 +2485,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2485
2485
  toolMetadata: e.toolMetadata ?? t.toolMetadata
2486
2486
  }, t) : g({
2487
2487
  toolCallId: e.toolCallId,
2488
- toolName: rr(t),
2488
+ toolName: ir(t),
2489
2489
  state: "output-available",
2490
2490
  input: t.input,
2491
2491
  output: e.output,
@@ -2511,7 +2511,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2511
2511
  toolMetadata: e.toolMetadata ?? t.toolMetadata
2512
2512
  }, t) : g({
2513
2513
  toolCallId: e.toolCallId,
2514
- toolName: rr(t),
2514
+ toolName: ir(t),
2515
2515
  state: "output-error",
2516
2516
  input: t.input,
2517
2517
  rawInput: t.rawInput,
@@ -2529,12 +2529,12 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2529
2529
  case "finish-step": break;
2530
2530
  case "reset-step": {
2531
2531
  let e = f();
2532
- r.activeTextParts = er(), r.activeReasoningParts = er(), r.partialToolCalls = er(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), d());
2532
+ r.activeTextParts = tr(), r.activeReasoningParts = tr(), r.partialToolCalls = tr(), e.length > 0 && (r.message.parts.splice(r.message.parts.length - e.length, e.length), d());
2533
2533
  break;
2534
2534
  }
2535
2535
  case "start": {
2536
2536
  let t = c && l || s && e.messageId != null && e.messageId !== r.message.id;
2537
- l = !1, t && Object.assign(r, ir({
2537
+ l = !1, t && Object.assign(r, ar({
2538
2538
  lastMessage: void 0,
2539
2539
  messageId: e.messageId ?? r.message.id
2540
2540
  }), { finishReason: void 0 }), e.messageId != null && (r.message.id = e.messageId), await v(e.messageMetadata), (t || e.messageId != null || e.messageMetadata != null) && d({ updateStatus: !1 });
@@ -2549,10 +2549,10 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2549
2549
  case "error":
2550
2550
  i?.(Error(e.errorText));
2551
2551
  break;
2552
- default: if ($n(e)) {
2552
+ default: if (er(e)) {
2553
2553
  if (n?.[e.type] != null) {
2554
2554
  let t = r.message.parts.findIndex((t) => "id" in t && "data" in t && t.id === e.id && t.type === e.type), i = t >= 0 ? t : r.message.parts.length;
2555
- await gn({
2555
+ await _n({
2556
2556
  value: e.data,
2557
2557
  schema: n[e.type],
2558
2558
  context: {
@@ -2575,7 +2575,7 @@ function ar({ stream: e, messageMetadataSchema: t, dataPartSchemas: n, runUpdate
2575
2575
  });
2576
2576
  } }));
2577
2577
  }
2578
- async function or({ stream: e, onError: t, abortSignal: n }) {
2578
+ async function sr({ stream: e, onError: t, abortSignal: n }) {
2579
2579
  let r = e.getReader(), i = () => {
2580
2580
  r.cancel().catch(() => {});
2581
2581
  };
@@ -2591,7 +2591,7 @@ async function or({ stream: e, onError: t, abortSignal: n }) {
2591
2591
  n?.removeEventListener("abort", i), r.releaseLock();
2592
2592
  }
2593
2593
  }
2594
- function sr() {
2594
+ function cr() {
2595
2595
  let e, t;
2596
2596
  return {
2597
2597
  promise: new Promise((n, r) => {
@@ -2601,32 +2601,32 @@ function sr() {
2601
2601
  reject: t
2602
2602
  };
2603
2603
  }
2604
- M({
2604
+ j({
2605
2605
  prefix: "aitxt",
2606
2606
  size: 24
2607
- }), M({
2607
+ }), j({
2608
2608
  prefix: "call",
2609
2609
  size: 24
2610
- }), M({
2610
+ }), j({
2611
2611
  prefix: "aitxt",
2612
2612
  size: 24
2613
- }), M({
2613
+ }), j({
2614
2614
  prefix: "call",
2615
2615
  size: 24
2616
- }), X.record(X.string(), kn.optional()), X.record(X.string(), X.string()), M({
2616
+ }), Y.record(Y.string(), An.optional()), Y.record(Y.string(), Y.string()), j({
2617
2617
  prefix: "call",
2618
2618
  size: 24
2619
- }), M({
2619
+ }), j({
2620
2620
  prefix: "call",
2621
2621
  size: 24
2622
- }), new TextEncoder(), M({
2622
+ }), new TextEncoder(), j({
2623
2623
  prefix: "call",
2624
2624
  size: 24
2625
- }), M({
2625
+ }), j({
2626
2626
  prefix: "aiobj",
2627
2627
  size: 24
2628
2628
  });
2629
- var { atob: cr } = globalThis, lr = class {
2629
+ var { atob: lr } = globalThis, ur = class {
2630
2630
  constructor() {
2631
2631
  this.queue = [], this.isProcessing = !1, this.idleWaiters = [];
2632
2632
  }
@@ -2658,15 +2658,15 @@ var { atob: cr } = globalThis, lr = class {
2658
2658
  });
2659
2659
  }
2660
2660
  };
2661
- M({
2661
+ j({
2662
2662
  prefix: "aiobj",
2663
2663
  size: 24
2664
- }), M({
2664
+ }), j({
2665
2665
  prefix: "call",
2666
2666
  size: 24
2667
- }), X.object({
2668
- token: X.string().refine((e) => e.trim().length > 0),
2669
- url: X.string().refine((e) => {
2667
+ }), Y.object({
2668
+ token: Y.string().refine((e) => e.trim().length > 0),
2669
+ url: Y.string().refine((e) => {
2670
2670
  try {
2671
2671
  let t = new URL(e);
2672
2672
  return (t.protocol === "ws:" || t.protocol === "wss:") && t.hostname !== "";
@@ -2674,26 +2674,26 @@ M({
2674
2674
  return !1;
2675
2675
  }
2676
2676
  }),
2677
- expiresAt: X.number().positive().max(2 ** 53 - 1).optional(),
2678
- tools: X.array(X.object({
2679
- type: X.literal("function"),
2680
- name: X.string().min(1),
2681
- description: X.string().optional(),
2682
- parameters: X.record(X.string(), X.unknown())
2677
+ expiresAt: Y.number().positive().max(2 ** 53 - 1).optional(),
2678
+ tools: Y.array(Y.object({
2679
+ type: Y.literal("function"),
2680
+ name: Y.string().min(1),
2681
+ description: Y.string().optional(),
2682
+ parameters: Y.record(Y.string(), Y.unknown())
2683
2683
  })).optional()
2684
- }), M({
2684
+ }), j({
2685
2685
  prefix: "call",
2686
2686
  size: 24
2687
- }), M({
2687
+ }), j({
2688
2688
  prefix: "call",
2689
2689
  size: 24
2690
- }), M({
2690
+ }), j({
2691
2691
  prefix: "call",
2692
2692
  size: 24
2693
2693
  });
2694
- async function ur({ response: e, url: t, fallbackMessage: n }) {
2694
+ async function dr({ response: e, url: t, fallbackMessage: n }) {
2695
2695
  let r = await e.text();
2696
- return new Le({
2696
+ return new Re({
2697
2697
  message: r || n,
2698
2698
  url: t,
2699
2699
  requestBodyValues: void 0,
@@ -2701,9 +2701,9 @@ async function ur({ response: e, url: t, fallbackMessage: n }) {
2701
2701
  responseBody: r
2702
2702
  });
2703
2703
  }
2704
- async function dr(e) {
2704
+ async function fr(e) {
2705
2705
  if (e == null) return [];
2706
- if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new tt({
2706
+ if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new nt({
2707
2707
  functionality: "FileList",
2708
2708
  message: "FileList is not supported in the current environment"
2709
2709
  });
@@ -2722,18 +2722,18 @@ async function dr(e) {
2722
2722
  };
2723
2723
  }));
2724
2724
  }
2725
- function fr(e, t) {
2725
+ function pr(e, t) {
2726
2726
  let n = e.search(/[?#]/), r = n === -1 ? e : e.slice(0, n), i = n === -1 ? "" : e.slice(n);
2727
2727
  return `${r.endsWith("/") && t.startsWith("/") ? r.slice(0, -1) : r}${t}${i}`;
2728
2728
  }
2729
- var pr = class {
2729
+ var mr = class {
2730
2730
  constructor({ api: e = "/api/chat", credentials: t, headers: n, body: r, fetch: i, prepareSendMessagesRequest: a, prepareReconnectToStreamRequest: o }) {
2731
2731
  this.api = e, this.credentials = t, this.headers = n, this.body = r, this.fetch = i, this.prepareSendMessagesRequest = a, this.prepareReconnectToStreamRequest = o;
2732
2732
  }
2733
2733
  async sendMessages({ abortSignal: e, ...t }) {
2734
- let n = await bn(this.body), r = await bn(this.headers), i = await bn(this.credentials), a = {
2735
- ...j(r),
2736
- ...j(t.headers)
2734
+ let n = await xn(this.body), r = await xn(this.headers), i = await xn(this.credentials), a = {
2735
+ ...A(r),
2736
+ ...A(t.headers)
2737
2737
  }, o = await this.prepareSendMessagesRequest?.({
2738
2738
  api: this.api,
2739
2739
  id: t.chatId,
@@ -2747,7 +2747,7 @@ var pr = class {
2747
2747
  requestMetadata: t.metadata,
2748
2748
  trigger: t.trigger,
2749
2749
  messageId: t.messageId
2750
- }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : j(o.headers), l = o?.body === void 0 ? {
2750
+ }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : A(o.headers), l = o?.body === void 0 ? {
2751
2751
  ...n,
2752
2752
  ...t.body,
2753
2753
  id: t.chatId,
@@ -2764,18 +2764,18 @@ var pr = class {
2764
2764
  credentials: u,
2765
2765
  signal: e
2766
2766
  });
2767
- if (!d.ok) throw await ur({
2767
+ if (!d.ok) throw await dr({
2768
2768
  response: d,
2769
2769
  url: s,
2770
2770
  fallbackMessage: "Failed to fetch the chat response."
2771
2771
  });
2772
- if (!d.body) throw new Ve({ message: "The response body is empty." });
2772
+ if (!d.body) throw new He({ message: "The response body is empty." });
2773
2773
  return this.processResponseStream(d.body);
2774
2774
  }
2775
2775
  async reconnectToStream(e) {
2776
- let t = await bn(this.body), n = await bn(this.headers), r = await bn(this.credentials), i = {
2777
- ...j(n),
2778
- ...j(e.headers)
2776
+ let t = await xn(this.body), n = await xn(this.headers), r = await xn(this.credentials), i = {
2777
+ ...A(n),
2778
+ ...A(e.headers)
2779
2779
  }, a = await this.prepareReconnectToStreamRequest?.({
2780
2780
  api: this.api,
2781
2781
  id: e.chatId,
@@ -2788,54 +2788,54 @@ var pr = class {
2788
2788
  requestMetadata: e.metadata
2789
2789
  }), o = a?.api;
2790
2790
  if (o == null) {
2791
- if (e.chatId === "." || e.chatId === "..") throw new Cn({
2791
+ if (e.chatId === "." || e.chatId === "..") throw new wn({
2792
2792
  parameter: "chatId",
2793
2793
  value: e.chatId,
2794
2794
  message: "Chat IDs must not be \".\" or \"..\" when using the default reconnect URL."
2795
2795
  });
2796
- o = fr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2796
+ o = pr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2797
2797
  }
2798
- let s = a?.headers === void 0 ? i : j(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2798
+ let s = a?.headers === void 0 ? i : A(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2799
2799
  method: "GET",
2800
2800
  headers: s,
2801
2801
  credentials: c,
2802
2802
  signal: e.abortSignal
2803
2803
  });
2804
2804
  if (l.status === 204) return null;
2805
- if (!l.ok) throw await ur({
2805
+ if (!l.ok) throw await dr({
2806
2806
  response: l,
2807
2807
  url: o,
2808
2808
  fallbackMessage: "Failed to fetch the chat response."
2809
2809
  });
2810
- if (!l.body) throw new Ve({ message: "The response body is empty." });
2810
+ if (!l.body) throw new He({ message: "The response body is empty." });
2811
2811
  return this.processResponseStream(l.body);
2812
2812
  }
2813
- }, mr = class extends pr {
2813
+ }, hr = class extends mr {
2814
2814
  constructor({ resumeStreamIsReplay: e = !0, ...t } = {}) {
2815
2815
  super(t), this.resumeStreamIsReplay = e;
2816
2816
  }
2817
2817
  processResponseStream(e) {
2818
- return yn({
2818
+ return bn({
2819
2819
  stream: e,
2820
- schema: Qn
2820
+ schema: $n
2821
2821
  }).pipeThrough(new TransformStream({ async transform(e, t) {
2822
2822
  if (!e.success) throw e.error;
2823
2823
  t.enqueue(e.value);
2824
2824
  } }));
2825
2825
  }
2826
- }, hr = class {
2826
+ }, gr = class {
2827
2827
  get id() {
2828
2828
  return this._id ??= this.generateId();
2829
2829
  }
2830
- constructor({ generateId: e = dt, id: t, transport: n = new mr(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
2831
- this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new lr(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (e, t) => {
2830
+ constructor({ generateId: e = ft, id: t, transport: n = new hr(), messageMetadataSchema: r, dataPartSchemas: i, state: a, onError: o, onToolCall: s, onFinish: c, onData: l, sendAutomaticallyWhen: u }) {
2831
+ this.pendingMessagePreparations = /* @__PURE__ */ new Set(), this.interruptedMessageIds = /* @__PURE__ */ new Set(), this.activeResponse = void 0, this.activeResumeRequest = void 0, this.resumableStreamState = void 0, this.jobExecutor = new ur(), this.activeStopCount = 0, this.stopGeneration = 0, this.sendMessage = async (e, t) => {
2832
2832
  if (e == null) {
2833
2833
  let e = this.pendingApprovalMessageId;
2834
2834
  if (e == null) {
2835
2835
  e = this.lastMessage?.id;
2836
2836
  for (let t = this.state.messages.length - 1; t >= 0; t--) {
2837
2837
  let n = this.state.messages[t];
2838
- if (n.role === "assistant" && n.parts.some((e) => $(e) && e.state === "approval-responded")) {
2838
+ if (n.role === "assistant" && n.parts.some((e) => Q(e) && e.state === "approval-responded")) {
2839
2839
  e = n.id;
2840
2840
  break;
2841
2841
  }
@@ -2855,7 +2855,7 @@ var pr = class {
2855
2855
  this.pendingMessagePreparations.add(t);
2856
2856
  let r;
2857
2857
  try {
2858
- r = Array.isArray(e.files) ? e.files : await dr(e.files);
2858
+ r = Array.isArray(e.files) ? e.files : await fr(e.files);
2859
2859
  } finally {
2860
2860
  this.pendingMessagePreparations.delete(t);
2861
2861
  }
@@ -2867,12 +2867,12 @@ var pr = class {
2867
2867
  } else n = e;
2868
2868
  if (e.messageId != null) {
2869
2869
  let t = this.state.messages.findIndex((t) => t.id === e.messageId);
2870
- if (t === -1) throw new Cn({
2870
+ if (t === -1) throw new wn({
2871
2871
  parameter: "message.messageId",
2872
2872
  value: e.messageId,
2873
2873
  message: `message with id ${e.messageId} not found`
2874
2874
  });
2875
- if (this.state.messages[t].role !== "user") throw new Cn({
2875
+ if (this.state.messages[t].role !== "user") throw new wn({
2876
2876
  parameter: "message.messageId",
2877
2877
  value: e.messageId,
2878
2878
  message: `message with id ${e.messageId} is not a user message`
@@ -2896,7 +2896,7 @@ var pr = class {
2896
2896
  });
2897
2897
  }, this.regenerate = async ({ messageId: e, ...t } = {}) => {
2898
2898
  let n = e == null ? this.state.messages.length - 1 : this.state.messages.findIndex((t) => t.id === e);
2899
- if (n === -1) throw new Cn({
2899
+ if (n === -1) throw new wn({
2900
2900
  parameter: "messageId",
2901
2901
  value: e,
2902
2902
  message: `message ${e} not found`
@@ -2917,7 +2917,7 @@ var pr = class {
2917
2917
  }, this.clearError = () => {
2918
2918
  this.status === "error" && (this.state.error = void 0, this.setStatus({ status: "ready" }));
2919
2919
  }, this.addToolApprovalResponse = async ({ id: e, approved: t, reason: n, options: r }) => this.jobExecutor.run(async () => {
2920
- let i = this.state.messages, a = (r) => $(r) && r.state === "approval-requested" && r.approval.id === e ? {
2920
+ let i = this.state.messages, a = (r) => Q(r) && r.state === "approval-requested" && r.approval.id === e ? {
2921
2921
  ...r,
2922
2922
  state: "approval-responded",
2923
2923
  approval: {
@@ -2926,7 +2926,7 @@ var pr = class {
2926
2926
  approved: t,
2927
2927
  reason: n
2928
2928
  }
2929
- } : r, o = i.findIndex((t) => t.parts.some((t) => $(t) && t.state === "approval-requested" && t.approval.id === e));
2929
+ } : r, o = i.findIndex((t) => t.parts.some((t) => Q(t) && t.state === "approval-requested" && t.approval.id === e));
2930
2930
  if (o !== -1) {
2931
2931
  let e = i[o];
2932
2932
  this.state.replaceMessage(o, {
@@ -2947,7 +2947,7 @@ var pr = class {
2947
2947
  }
2948
2948
  }), this.addToolOutput = async ({ state: e, toolCallId: t, output: n, errorText: r, options: i }) => this.jobExecutor.run(async () => {
2949
2949
  let a = this.state.messages, o = (i) => {
2950
- if (!$(i) || i.toolCallId !== t) return i;
2950
+ if (!Q(i) || i.toolCallId !== t) return i;
2951
2951
  let { approval: a, ...o } = i, s = a?.approved === !0 ? { approval: {
2952
2952
  ...a,
2953
2953
  approved: a.approved
@@ -2967,7 +2967,7 @@ var pr = class {
2967
2967
  output: n,
2968
2968
  errorText: void 0
2969
2969
  };
2970
- }, s = a.findIndex((e) => e.parts.some((e) => $(e) && e.toolCallId === t));
2970
+ }, s = a.findIndex((e) => e.parts.some((e) => Q(e) && e.toolCallId === t));
2971
2971
  if (s !== -1) {
2972
2972
  let e = a[s];
2973
2973
  this.state.replaceMessage(s, {
@@ -3031,7 +3031,7 @@ var pr = class {
3031
3031
  }), r && this.status === "error" && this.pendingApprovalMessageId == null && (this.pendingApprovalMessageId = this.state.messages[t]?.id ?? e);
3032
3032
  }
3033
3033
  async makeRequest(e) {
3034
- let t = sr();
3034
+ let t = cr();
3035
3035
  try {
3036
3036
  await this.makeRequestImpl({
3037
3037
  ...e,
@@ -3084,17 +3084,17 @@ var pr = class {
3084
3084
  status: "submitted",
3085
3085
  error: void 0
3086
3086
  });
3087
- let d = this.lastMessage, f = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, p = f === -1 ? d : this.state.messages[f], m = p?.id, h = e === "resume-stream" && p?.role === "assistant" && p.parts.some((e) => $(e) && (e.state === "input-streaming" || e.state === "input-available" && e.providerExecuted || e.state === "approval-responded")) ? this.state.snapshot(p) : void 0, g = f !== -1 && f < this.state.messages.length - 1 && p?.role === "assistant", _ = !1, v = !1, y = !1, b;
3087
+ let d = this.lastMessage, f = e === "submit-message" && i != null ? this.state.messages.findIndex((e) => e.id === i) : this.state.messages.length - 1, p = f === -1 ? d : this.state.messages[f], m = p?.id, h = e === "resume-stream" && p?.role === "assistant" && p.parts.some((e) => Q(e) && (e.state === "input-streaming" || e.state === "input-available" && e.providerExecuted || e.state === "approval-responded")) ? this.state.snapshot(p) : void 0, g = f !== -1 && f < this.state.messages.length - 1 && p?.role === "assistant", _ = !1, v = !1, ee = !1, y;
3088
3088
  try {
3089
3089
  let s = {
3090
- state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : ir({
3090
+ state: e === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : ar({
3091
3091
  lastMessage: e === "resume-stream" ? h : e === "regenerate-message" ? void 0 : this.state.snapshot(p),
3092
3092
  messageId: this.generateId()
3093
3093
  }),
3094
3094
  abortController: o,
3095
3095
  completionPromise: a
3096
3096
  };
3097
- b = s, s.abortController.signal.addEventListener("abort", () => {
3097
+ y = s, s.abortController.signal.addEventListener("abort", () => {
3098
3098
  _ = !0;
3099
3099
  }), this.activeResponse = s;
3100
3100
  let l;
@@ -3107,8 +3107,8 @@ var pr = class {
3107
3107
  body: r,
3108
3108
  trigger: e,
3109
3109
  messageId: i
3110
- }), await or({
3111
- stream: ar({
3110
+ }), await sr({
3111
+ stream: or({
3112
3112
  stream: l,
3113
3113
  resetStateOnMessageIdChange: e === "resume-stream",
3114
3114
  resetStateOnFirstMessageStart: e === "resume-stream" && this.transport.resumeStreamIsReplay,
@@ -3140,34 +3140,34 @@ var pr = class {
3140
3140
  }), _) return c() && (this.setStatus({ status: "ready" }), this.resumableStreamState === s.state && (this.resumableStreamState = void 0)), null;
3141
3141
  c() && (this.setStatus({ status: "ready" }), this.resumableStreamState === s.state && (this.resumableStreamState = void 0));
3142
3142
  } catch (e) {
3143
- if (_ || e.name === "AbortError") return _ = !0, c() && (this.setStatus({ status: "ready" }), this.resumableStreamState === b?.state && (this.resumableStreamState = void 0)), null;
3143
+ if (_ || e.name === "AbortError") return _ = !0, c() && (this.setStatus({ status: "ready" }), this.resumableStreamState === y?.state && (this.resumableStreamState = void 0)), null;
3144
3144
  if (!c()) return null;
3145
- if (y = !0, e instanceof TypeError) {
3145
+ if (ee = !0, e instanceof TypeError) {
3146
3146
  let t = e.message.toLowerCase();
3147
3147
  v = t.includes("fetch") || t.includes("network") || t === "load failed";
3148
3148
  }
3149
- v ? this.resumableStreamState = b?.state : this.resumableStreamState === b?.state && (this.resumableStreamState = void 0), this.onError && e instanceof Error && this.onError(e), this.setStatus({
3149
+ v ? this.resumableStreamState = y?.state : this.resumableStreamState === y?.state && (this.resumableStreamState = void 0), this.onError && e instanceof Error && this.onError(e), this.setStatus({
3150
3150
  status: "error",
3151
3151
  error: e
3152
3152
  });
3153
3153
  } finally {
3154
3154
  try {
3155
- if (b) {
3156
- let { message: e, finishReason: t } = b.state;
3157
- t === "interrupted" ? this.interruptedMessageIds.add(e.id) : !_ && !y && this.interruptedMessageIds.delete(e.id), this.onFinish?.({
3158
- message: b.state.message,
3155
+ if (y) {
3156
+ let { message: e, finishReason: t } = y.state;
3157
+ t === "interrupted" ? this.interruptedMessageIds.add(e.id) : !_ && !ee && this.interruptedMessageIds.delete(e.id), this.onFinish?.({
3158
+ message: y.state.message,
3159
3159
  messages: this.state.messages,
3160
3160
  isAbort: _,
3161
3161
  isDisconnect: v,
3162
- isError: y,
3163
- finishReason: b.state.finishReason
3162
+ isError: ee,
3163
+ finishReason: y.state.finishReason
3164
3164
  });
3165
3165
  }
3166
3166
  } finally {
3167
- this.activeResponse === b && (this.activeResponse = void 0), l();
3167
+ this.activeResponse === y && (this.activeResponse = void 0), l();
3168
3168
  }
3169
3169
  }
3170
- !_ && !y && b?.state.finishReason !== "interrupted" && await this.runAutomaticRequest(() => this.makeRequest({
3170
+ !_ && !ee && y?.state.finishReason !== "interrupted" && await this.runAutomaticRequest(() => this.makeRequest({
3171
3171
  trigger: "submit-message",
3172
3172
  messageId: this.lastMessage?.id,
3173
3173
  metadata: t,
@@ -3176,37 +3176,37 @@ var pr = class {
3176
3176
  }));
3177
3177
  }
3178
3178
  };
3179
- function gr({ messages: e }) {
3179
+ function _r({ messages: e }) {
3180
3180
  let t = e[e.length - 1];
3181
3181
  if (!t || t.role !== "assistant") return !1;
3182
- let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter($);
3182
+ let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter(Q);
3183
3183
  return r.filter((e) => e.state === "approval-responded").length > 0 && r.every((e) => e.state === "output-available" && e.preliminary !== !0 || e.state === "output-error" || e.state === "output-denied" || e.state === "approval-responded");
3184
3184
  }
3185
3185
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/lib/hash.js
3186
- var _r = /* @__PURE__ */ new WeakMap(), vr = 0;
3187
- function yr(e) {
3186
+ var vr = /* @__PURE__ */ new WeakMap(), yr = 0;
3187
+ function br(e) {
3188
3188
  if (!e.length) return "";
3189
3189
  for (var t = "arg", n = 0; n < e.length; ++n) {
3190
3190
  var r = void 0;
3191
- e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : _r.has(e[n]) ? r = _r.get(e[n]) : (r = vr, _r.set(e[n], vr++)), t += "@" + r;
3191
+ e[n] === null || typeof e[n] != "object" && typeof e[n] != "function" ? r = typeof e[n] == "string" ? "\"" + e[n] + "\"" : String(e[n]) : vr.has(e[n]) ? r = vr.get(e[n]) : (r = yr, vr.set(e[n], yr++)), t += "@" + r;
3192
3192
  }
3193
3193
  return t;
3194
3194
  }
3195
3195
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/cache/index.js
3196
- function br(e) {
3196
+ function xr(e) {
3197
3197
  if (typeof e == "function") try {
3198
3198
  e = e();
3199
3199
  } catch {
3200
3200
  e = "";
3201
3201
  }
3202
- return e = Array.isArray(e) ? yr(e) : String(e || ""), e;
3202
+ return e = Array.isArray(e) ? br(e) : String(e || ""), e;
3203
3203
  }
3204
- var xr = function() {
3204
+ var Sr = function() {
3205
3205
  function e(e) {
3206
3206
  e === void 0 && (e = 0), this.items = /* @__PURE__ */ new Map(), this.ttl = e;
3207
3207
  }
3208
3208
  return e.prototype.serializeKey = function(e) {
3209
- return br(e);
3209
+ return xr(e);
3210
3210
  }, e.prototype.get = function(e) {
3211
3211
  var t = this.serializeKey(e);
3212
3212
  return this.items.get(t);
@@ -3227,25 +3227,25 @@ var xr = function() {
3227
3227
  }, e;
3228
3228
  }();
3229
3229
  // ../../node_modules/.pnpm/swrv@1.2.0_vue@3.5.44_typescript@6.0.3_/node_modules/swrv/esm/lib/web-preset.js
3230
- function Sr() {
3230
+ function Cr() {
3231
3231
  return navigator.onLine === void 0 || navigator.onLine;
3232
3232
  }
3233
- function Cr() {
3233
+ function wr() {
3234
3234
  return typeof document < "u" && document.visibilityState !== void 0 ? document.visibilityState !== "hidden" : !0;
3235
3235
  }
3236
- var wr = {
3237
- isOnline: Sr,
3238
- isDocumentVisible: Cr,
3236
+ var Tr = {
3237
+ isOnline: Cr,
3238
+ isDocumentVisible: wr,
3239
3239
  fetcher: function(e) {
3240
3240
  return fetch(e).then(function(e) {
3241
3241
  return e.json();
3242
3242
  });
3243
3243
  }
3244
- }, Tr = function() {
3245
- return Tr = Object.assign || function(e) {
3244
+ }, $ = function() {
3245
+ return $ = Object.assign || function(e) {
3246
3246
  for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
3247
3247
  return e;
3248
- }, Tr.apply(this, arguments);
3248
+ }, $.apply(this, arguments);
3249
3249
  }, Er = function(e, t, n, r) {
3250
3250
  function i(e) {
3251
3251
  return e instanceof n ? e : new n(function(t) {
@@ -3364,7 +3364,7 @@ var wr = {
3364
3364
  }, kr = function(e, t, n) {
3365
3365
  if (n || arguments.length === 2) for (var r = 0, i = t.length, a; r < i; r++) (a || !(r in t)) && (a ||= Array.prototype.slice.call(t, 0, r), a[r] = t[r]);
3366
3366
  return e.concat(a || Array.prototype.slice.call(t));
3367
- }, Ar = new xr(), jr = new xr(), Mr = new xr(), Nr = {
3367
+ }, Ar = new Sr(), jr = new Sr(), Mr = new Sr(), Nr = {
3368
3368
  cache: Ar,
3369
3369
  refreshInterval: 0,
3370
3370
  ttl: 0,
@@ -3375,9 +3375,9 @@ var wr = {
3375
3375
  shouldRetryOnError: !0,
3376
3376
  errorRetryInterval: 5e3,
3377
3377
  errorRetryCount: 5,
3378
- fetcher: wr.fetcher,
3379
- isOnline: wr.isOnline,
3380
- isDocumentVisible: wr.isDocumentVisible
3378
+ fetcher: Tr.fetcher,
3379
+ isOnline: Tr.isOnline,
3380
+ isDocumentVisible: Tr.isDocumentVisible
3381
3381
  };
3382
3382
  function Pr(e, t, n) {
3383
3383
  var r = jr.get(e);
@@ -3437,14 +3437,14 @@ var Lr = function(e, t, n, r) {
3437
3437
  };
3438
3438
  function Rr() {
3439
3439
  for (var e = this, t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n];
3440
- var r, i, a = Tr({}, Nr), o = !1, s = !1;
3441
- if (!pe()) return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
3440
+ var r, i, a = $({}, Nr), o = !1, s = !1;
3441
+ if (!me()) return console.error("useSWRV must be called inside setup() or an active effectScope()."), null;
3442
3442
  var c = typeof window > "u" || typeof document > "u";
3443
- t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = Tr(Tr({}, a), t[2]));
3444
- var l = c ? a.serverTTL : a.ttl, u = typeof r == "function" ? r : S(r);
3443
+ t.length >= 1 && (r = t[0]), t.length >= 2 && (i = t[1]), t.length > 2 && (a = $($({}, a), t[2]));
3444
+ var l = c ? a.serverTTL : a.ttl, u = typeof r == "function" ? r : x(r);
3445
3445
  i === void 0 && (i = a.fetcher);
3446
3446
  var d = null;
3447
- d ||= _e({
3447
+ d ||= ve({
3448
3448
  data: void 0,
3449
3449
  error: void 0,
3450
3450
  isValidating: !0,
@@ -3514,7 +3514,7 @@ function Rr() {
3514
3514
  };
3515
3515
  a.refreshInterval && (m = setTimeout(h, a.refreshInterval)), a.revalidateOnFocus && (document.addEventListener("visibilitychange", p, !1), window.addEventListener("focus", p, !1));
3516
3516
  }
3517
- ge(function() {
3517
+ _e(function() {
3518
3518
  o = !0, m &&= (clearTimeout(m), null), !c && a.revalidateOnFocus && (document.removeEventListener("visibilitychange", p, !1), window.removeEventListener("focus", p, !1));
3519
3519
  var e = jr.get(u.value);
3520
3520
  e && (e.data = e.data.filter(function(e) {
@@ -3522,12 +3522,12 @@ function Rr() {
3522
3522
  }));
3523
3523
  });
3524
3524
  try {
3525
- w(u, function(e) {
3526
- me(u) || (u.value = e), d.key = e, d.isValidating = !!e, Pr(u.value, d, l), !c && !s && u.value && f(), s = !1;
3525
+ C(u, function(e) {
3526
+ he(u) || (u.value = e), d.key = e, d.isValidating = !!e, Pr(u.value, d, l), !c && !s && u.value && f(), s = !1;
3527
3527
  }, { immediate: !0 });
3528
3528
  } catch {}
3529
- return Tr(Tr({}, ve(d)), { mutate: function(e, t) {
3530
- return f(e, Tr(Tr({}, t), { forceRevalidate: !0 }));
3529
+ return $($({}, ye(d)), { mutate: function(e, t) {
3530
+ return f(e, $($({}, t), { forceRevalidate: !0 }));
3531
3531
  } });
3532
3532
  }
3533
3533
  function zr(e) {
@@ -3605,7 +3605,7 @@ var Ur = class {
3605
3605
  this.isPublishing = !1;
3606
3606
  }
3607
3607
  }
3608
- }, Wr = class extends hr {
3608
+ }, Wr = class extends gr {
3609
3609
  constructor({ state: e, ...t }) {
3610
3610
  super({
3611
3611
  ...t,
@@ -3614,10 +3614,10 @@ var Ur = class {
3614
3614
  }
3615
3615
  };
3616
3616
  function Gr(e) {
3617
- let t = C([]), n = C("ready"), r = C(), i = C(), a;
3618
- return w(t, (e) => {
3617
+ let t = S([]), n = S("ready"), r = S(), i = S(), a;
3618
+ return C(t, (e) => {
3619
3619
  a != null && !a.isPublishing && a.setMessagesFromConsumer(e);
3620
- }, { flush: "sync" }), w(() => ye(e), (e) => {
3620
+ }, { flush: "sync" }), C(() => be(e), (e) => {
3621
3621
  a?.dispose();
3622
3622
  let { throttle: o, ...s } = e ?? {}, c = new Ur({
3623
3623
  initialMessages: s.messages ?? [],
@@ -3630,10 +3630,10 @@ function Gr(e) {
3630
3630
  ...s,
3631
3631
  state: c
3632
3632
  });
3633
- }, { immediate: !0 }), pe() != null && ge(() => {
3633
+ }, { immediate: !0 }), me() != null && _e(() => {
3634
3634
  a?.dispose();
3635
3635
  }), {
3636
- id: x(() => i.value.id),
3636
+ id: b(() => i.value.id),
3637
3637
  status: n,
3638
3638
  messages: t,
3639
3639
  error: r,
@@ -3660,47 +3660,47 @@ var Kr = "voice-", qr = 300, Jr = (e) => e?.role === "assistant" && e.parts.some
3660
3660
  }, $r = 12e4, ei = 1e3, ti = 5e3, ni = 100, ri = 3e4, ii = 5e3, ai = 250, oi = 1e3, si = "\n\n", ci = (e) => {
3661
3661
  let t = e.type ?? "";
3662
3662
  return t === "dynamic-tool" ? e.toolName ?? "" : t.startsWith("tool-") ? t.slice(5) : "";
3663
- }, li = (e) => e?.role === "assistant" && e.parts.some((e) => ne(ci(e)) && !e.providerExecuted && !oe.has(e.state ?? "")), ui = ({ messages: e }) => {
3663
+ }, li = (e) => e?.role === "assistant" && e.parts.some((e) => y(ci(e)) && !e.providerExecuted && !se.has(e.state ?? "")), ui = ({ messages: e }) => {
3664
3664
  let t = e[e.length - 1];
3665
3665
  if (!t || t.role !== "assistant") return !1;
3666
- let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && (ne(ci(e)) || ae(e)));
3667
- return r.length > 0 && r.every((e) => oe.has(e.state ?? ""));
3666
+ let n = t.parts.reduce((e, t, n) => t.type === "step-start" ? n : e, -1), r = t.parts.slice(n + 1).filter((e) => !e.providerExecuted && (y(ci(e)) || re(e)));
3667
+ return r.length > 0 && r.every((e) => se.has(e.state ?? ""));
3668
3668
  };
3669
3669
  function di(e) {
3670
- return we(`chatbot-${e}`, () => {
3671
- let { t, te: n, locale: r } = xe({ useScope: "global" }), i = S(""), a = S(), o = S(e), s = S(), c = S(), l = S(), u = S(), d = S(), f = S(), p = S(), m = S(), h = S(), g = S(), _ = S(), v = S(), y = S(), ne = S(), ie = S(), oe = S(), pe = C(), me = S(0), ve = S(0), ye = S(), we = S(), Oe = S(), Me = C(), Ne = C(), T = S(), Pe = S(), Fe = C(), Ie = S(!1), Le = S({}), Re = S({}), ze = S(!1), Be = S(0), Ve = S(), He = S(!1), Ue = Ce(), We = x(() => {
3670
+ return Te(`chatbot-${e}`, () => {
3671
+ let { t, te: n, locale: r } = Se({ useScope: "global" }), i = x(""), a = x(), o = x(e), s = x(), c = x(), l = x(), u = x(), d = x(), f = x(), p = x(), m = x(), h = x(), g = x(), _ = x(), v = x(), y = x(), ae = x(), oe = x(), se = x(), me = S(), he = x(0), ye = x(0), be = x(), Te = x(), ke = x(), Ne = S(), Pe = S(), w = x(), Fe = x(), Ie = S(), Le = x(!1), Re = x({}), ze = x({}), Be = x(!1), Ve = x(0), He = x(), Ue = x(!1), We = we(), Ge = b(() => {
3672
3672
  let e = u.value?.theme;
3673
- return e && e !== "auto" || (e = Ve.value), e ? e === "dark" : Ue.value;
3674
- }), E = x(() => c.value === "reasoning"), Ge = x(() => E.value ? g.value?.filter((e) => ![
3673
+ return e && e !== "auto" || (e = He.value), e ? e === "dark" : We.value;
3674
+ }), T = b(() => c.value === "reasoning"), Ke = b(() => T.value ? g.value?.filter((e) => ![
3675
3675
  "upvote",
3676
3676
  "downvote",
3677
3677
  "feedback"
3678
- ].includes(e)) : g.value), Ke = fe(x(() => `${o.value}-chatId`), null);
3679
- be(() => {
3680
- Ke.value ||= dt();
3678
+ ].includes(e)) : g.value), qe = pe(b(() => `${o.value}-chatId`), null);
3679
+ xe(() => {
3680
+ qe.value ||= ft();
3681
3681
  });
3682
- let D = x({
3683
- get: () => Ke.value,
3682
+ let E = b({
3683
+ get: () => qe.value,
3684
3684
  set: (e) => {
3685
- Ke.value = e;
3685
+ qe.value = e;
3686
3686
  }
3687
- }), qe = de(x(() => `${o.value}-pageAccessOff`), !1), O = x(() => qe.value ? [] : Me.value ?? []), Je = () => qe.value ? [] : Ne.value?.() ?? [], Ye = x(() => !!(ye.value && Me.value?.length)), Xe = fe(x(() => `${o.value}-${l.value ?? "anonymous"}-confirmations`), "manual"), Ze = x(() => we.value?.allowAutomatic === !0), Qe = x(() => Ze.value && Xe.value === "automatic" ? "automatic" : "manual");
3688
- function $e(e) {
3689
- Xe.value = e;
3687
+ }), Je = fe(b(() => `${o.value}-pageAccessOff`), !1), D = b(() => Je.value ? [] : Ne.value ?? []), Ye = () => Je.value ? [] : Pe.value?.() ?? [], Xe = b(() => !!(be.value && Ne.value?.length)), Ze = pe(b(() => `${o.value}-${l.value ?? "anonymous"}-confirmations`), "manual"), Qe = b(() => Te.value?.allowAutomatic === !0), $e = b(() => Qe.value && Ze.value === "automatic" ? "automatic" : "manual");
3688
+ function et(e) {
3689
+ Ze.value = e;
3690
3690
  }
3691
- let et = x(() => !!Fe.value && ye.value?.pointer === !0 && O.value.length > 0);
3692
- w(et, (e) => {
3693
- e || (Pe.value = void 0);
3691
+ let tt = b(() => !!Ie.value && be.value?.pointer === !0 && D.value.length > 0);
3692
+ C(tt, (e) => {
3693
+ e || (Fe.value = void 0);
3694
3694
  });
3695
- let tt = fe(x(() => `${o.value}-pageNotice`), null), nt = x(() => {
3696
- let e = ye.value?.level;
3697
- return e && e !== te.Off && O.value.length && !re(tt.value ?? void 0, e) ? e : void 0;
3695
+ let nt = pe(b(() => `${o.value}-pageNotice`), null), rt = b(() => {
3696
+ let e = be.value?.level;
3697
+ return e && e !== te.Off && D.value.length && !ie(nt.value ?? void 0, e) ? e : void 0;
3698
3698
  });
3699
- function rt() {
3700
- tt.value = ye.value?.level ?? null;
3699
+ function it() {
3700
+ nt.value = be.value?.level ?? null;
3701
3701
  }
3702
- let it = S(), k = S(!1), at = x(() => it.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3703
- function ot(e) {
3702
+ let at = x(), O = x(!1), ot = b(() => at.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3703
+ function st(e) {
3704
3704
  try {
3705
3705
  let t = JSON.parse(e.message);
3706
3706
  return t.status === 404 || t.type?.includes("entity-not-found");
@@ -3708,99 +3708,99 @@ function di(e) {
3708
3708
  return !1;
3709
3709
  }
3710
3710
  }
3711
- function st(e) {
3712
- if (ot(e)) {
3713
- let e = B.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? ue(t) : void 0;
3714
- D.value = dt(), it.value = void 0, he(() => {
3711
+ function ct(e) {
3712
+ if (st(e)) {
3713
+ let e = B.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? de(t) : void 0;
3714
+ E.value = ft(), at.value = void 0, ge(() => {
3715
3715
  B.value.clearError(), n && B.value.sendMessage({ text: n });
3716
3716
  });
3717
- } else ce.error(e), it.value = e, at.value && (k.value = !0);
3717
+ } else le.error(e), at.value = e, ot.value && (O.value = !0);
3718
3718
  }
3719
- let A = x(() => se({
3719
+ let k = b(() => ce({
3720
3720
  baseUrl: i.value,
3721
3721
  basePath: a.value,
3722
3722
  headers: () => p.value
3723
- })), ct = S(null), lt = () => ({
3724
- ...Te(),
3725
- ...ct.value ?? {}
3726
- }), ut = () => {
3727
- let e = Be.value;
3723
+ })), lt = x(null), ut = () => ({
3724
+ ...Ee(),
3725
+ ...lt.value ?? {}
3726
+ }), dt = () => {
3727
+ let e = Ve.value;
3728
3728
  return new Promise((t) => {
3729
3729
  let n = setTimeout(() => {
3730
3730
  r(), t(!1);
3731
- }, 3e4), r = w(() => [Be.value, B.value.status], ([i, a]) => {
3731
+ }, 3e4), r = C(() => [Ve.value, B.value.status], ([i, a]) => {
3732
3732
  i > e && a === "streaming" && (clearTimeout(n), r(), t(!0));
3733
3733
  });
3734
3734
  });
3735
- }, j = C(), M = (e, t) => new Promise((n) => {
3736
- j.value?.answer(!1), j.value = {
3735
+ }, A = S(), j = (e, t) => new Promise((n) => {
3736
+ A.value?.answer(!1), A.value = {
3737
3737
  toolCallId: e.toolCallId,
3738
3738
  question: t?.question,
3739
3739
  details: t?.details,
3740
3740
  unchanged: t?.unchanged,
3741
3741
  answer: (e) => {
3742
- j.value = void 0, n(e);
3742
+ A.value = void 0, n(e);
3743
3743
  }
3744
3744
  };
3745
3745
  });
3746
- function ft(e) {
3747
- j.value?.answer(e);
3746
+ function pt(e) {
3747
+ A.value?.answer(e);
3748
3748
  }
3749
- let pt = (e, t) => {
3750
- t.details?.some((e) => e.before !== void 0) && (Re.value = {
3751
- ...Re.value,
3749
+ let mt = (e, t) => {
3750
+ t.details?.some((e) => e.before !== void 0) && (ze.value = {
3751
+ ...ze.value,
3752
3752
  [e.toolCallId]: {
3753
3753
  details: t.details,
3754
3754
  unchanged: t.unchanged
3755
3755
  }
3756
3756
  });
3757
- }, mt = ({ forms: e }) => ye.value && O.value.length ? {
3757
+ }, ht = ({ forms: e }) => be.value && D.value.length ? {
3758
3758
  version: 1,
3759
- features: [...b],
3760
- forms: e ? Je().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3759
+ features: [...ne],
3760
+ forms: e ? Ye().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3761
3761
  name: e,
3762
3762
  description: t,
3763
3763
  inputSchema: n,
3764
3764
  annotations: r
3765
3765
  })) : []
3766
- } : void 0, ht = (e) => {
3766
+ } : void 0, gt = (e) => {
3767
3767
  if (e?.provider !== "page") {
3768
- T.value = void 0;
3768
+ w.value = void 0;
3769
3769
  return;
3770
3770
  }
3771
- let t = [...O.value, ...Je()].find((t) => t.name === e.toolName), n;
3771
+ let t = [...D.value, ...Ye()].find((t) => t.name === e.toolName), n;
3772
3772
  try {
3773
3773
  n = t?.describe?.(e.input);
3774
3774
  } catch {
3775
3775
  n = void 0;
3776
3776
  }
3777
- n && (Le.value = {
3778
- ...Le.value,
3777
+ n && (Re.value = {
3778
+ ...Re.value,
3779
3779
  [e.toolCallId]: n
3780
- }), e.readOnly ? T.value = void 0 : (T.value = { title: n ?? t?.annotations?.title ?? e.toolName }, ze.value = !0);
3781
- }, gt = je({
3780
+ }), e.readOnly ? w.value = void 0 : (w.value = { title: n ?? t?.annotations?.title ?? e.toolName }, Be.value = !0);
3781
+ }, _t = Me({
3782
3782
  registry: () => [
3783
- ...(pe.value ?? []).filter((e) => !ee(e.name)),
3784
- ...O.value,
3785
- ...Je()
3783
+ ...(me.value ?? []).filter((e) => !ee(e.name)),
3784
+ ...D.value,
3785
+ ...Ye()
3786
3786
  ],
3787
- capability: () => oe.value,
3787
+ capability: () => se.value,
3788
3788
  addToolOutput: (e) => void B.value.addToolOutput(e),
3789
- confirm: M,
3790
- waitForResume: ut,
3789
+ confirm: j,
3790
+ waitForResume: dt,
3791
3791
  onPendingChange: (e) => {
3792
- me.value = e;
3792
+ he.value = e;
3793
3793
  },
3794
- onActivity: ht,
3795
- mode: () => Qe.value,
3796
- onSkip: pt
3797
- }), N = /* @__PURE__ */ new Map(), _t = 0, P = (e, t) => {
3798
- let n = N.get(e);
3799
- N.delete(e), n?.(JSON.stringify(t));
3800
- }, vt = je({
3801
- registry: () => O.value,
3802
- capability: () => oe.value,
3803
- addToolOutput: (e) => P(e.toolCallId, "output" in e ? e.output : {
3794
+ onActivity: gt,
3795
+ mode: () => $e.value,
3796
+ onSkip: mt
3797
+ }), M = /* @__PURE__ */ new Map(), vt = 0, N = (e, t) => {
3798
+ let n = M.get(e);
3799
+ M.delete(e), n?.(JSON.stringify(t));
3800
+ }, yt = Me({
3801
+ registry: () => D.value,
3802
+ capability: () => se.value,
3803
+ addToolOutput: (e) => N(e.toolCallId, "output" in e ? e.output : {
3804
3804
  content: [{
3805
3805
  type: "text",
3806
3806
  text: e.errorText
@@ -3808,29 +3808,29 @@ function di(e) {
3808
3808
  isError: !0
3809
3809
  }),
3810
3810
  confirm: async (e, t) => {
3811
- for (; j.value;) await new Promise((e) => {
3812
- let t = w(j, (n) => {
3811
+ for (; A.value;) await new Promise((e) => {
3812
+ let t = C(A, (n) => {
3813
3813
  n || (t(), e());
3814
3814
  });
3815
3815
  });
3816
- return N.has(e.toolCallId) ? M(e, t) : !1;
3816
+ return M.has(e.toolCallId) ? j(e, t) : !1;
3817
3817
  },
3818
3818
  waitForResume: () => new Promise((e) => setTimeout(() => e(!0), qr)),
3819
3819
  onPendingChange: (e) => {
3820
- ve.value = e;
3820
+ ye.value = e;
3821
3821
  },
3822
- onActivity: ht,
3823
- mode: () => yt
3824
- }), yt = "manual";
3825
- function bt() {
3826
- yt = Qe.value;
3827
- let e = mt({ forms: !1 });
3822
+ onActivity: gt,
3823
+ mode: () => bt
3824
+ }), bt = "manual";
3825
+ function xt() {
3826
+ bt = $e.value;
3827
+ let e = ht({ forms: !1 });
3828
3828
  if (e) return {
3829
3829
  declaration: e,
3830
- clientTools: Object.fromEntries(O.value.map((e) => [e.name, (t) => new Promise((n) => {
3831
- _t += 1;
3832
- let r = `page-call-${_t}`;
3833
- N.set(r, n), vt.enqueue({
3830
+ clientTools: Object.fromEntries(D.value.map((e) => [e.name, (t) => new Promise((n) => {
3831
+ vt += 1;
3832
+ let r = `page-call-${vt}`;
3833
+ M.set(r, n), yt.enqueue({
3834
3834
  toolCallId: r,
3835
3835
  toolName: e.name,
3836
3836
  input: t ?? {},
@@ -3841,9 +3841,9 @@ function di(e) {
3841
3841
  })]))
3842
3842
  };
3843
3843
  }
3844
- function F() {
3845
- vt.cancelAll(), j.value && N.has(j.value.toolCallId) && j.value.answer(!1);
3846
- for (let e of [...N.keys()]) P(e, {
3844
+ function P() {
3845
+ yt.cancelAll(), A.value && M.has(A.value.toolCallId) && A.value.answer(!1);
3846
+ for (let e of [...M.keys()]) N(e, {
3847
3847
  content: [{
3848
3848
  type: "text",
3849
3849
  text: "Stopped by the user."
@@ -3851,34 +3851,34 @@ function di(e) {
3851
3851
  isError: !0
3852
3852
  });
3853
3853
  }
3854
- async function xt() {
3855
- St(), F(), T.value = void 0, ze.value = !1, q.value = "", await B.value.stop();
3854
+ async function St() {
3855
+ Ct(), P(), w.value = void 0, Be.value = !1, K.value = "", await B.value.stop();
3856
3856
  }
3857
- function St() {
3858
- gt.cancelAll(), j.value && !N.has(j.value.toolCallId) && j.value.answer(!1);
3857
+ function Ct() {
3858
+ _t.cancelAll(), A.value && !M.has(A.value.toolCallId) && A.value.answer(!1);
3859
3859
  }
3860
- async function Ct(e) {
3861
- qe.value = e, e && await xt();
3860
+ async function wt(e) {
3861
+ Je.value = e, e && await St();
3862
3862
  }
3863
- w(D, () => St(), { flush: "sync" });
3864
- let wt = !1, I, Tt = S(), Et, Dt = S([]), L = S([]), R = S([]), Ot = S({}), kt = /* @__PURE__ */ new Map(), At = /* @__PURE__ */ new Set();
3863
+ C(E, () => Ct(), { flush: "sync" });
3864
+ let Tt = !1, F, Et = x(), Dt, Ot = x([]), I = x([]), L = x([]), R = x({}), kt = /* @__PURE__ */ new Map(), At = /* @__PURE__ */ new Set();
3865
3865
  function jt(e, t, n) {
3866
- L.value.includes(e) || (L.value = [...L.value, e]), kt.set(e, Date.now()), n ? At.add(e) : At.delete(e), t && (Ot.value = {
3867
- ...Ot.value,
3866
+ I.value.includes(e) || (I.value = [...I.value, e]), kt.set(e, Date.now()), n ? At.add(e) : At.delete(e), t && (R.value = {
3867
+ ...R.value,
3868
3868
  [e]: t
3869
- }), Q || Wn();
3869
+ }), Z || Gn();
3870
3870
  }
3871
3871
  function z(e) {
3872
- Ot.value = Object.fromEntries(Object.entries(Ot.value).filter(([t]) => t !== e));
3872
+ R.value = Object.fromEntries(Object.entries(R.value).filter(([t]) => t !== e));
3873
3873
  }
3874
3874
  function Mt(e) {
3875
- kt.delete(e), L.value = L.value.filter((t) => t !== e), R.value = R.value.filter((t) => t !== e), z(e);
3875
+ kt.delete(e), I.value = I.value.filter((t) => t !== e), L.value = L.value.filter((t) => t !== e), z(e);
3876
3876
  }
3877
3877
  let Nt = Gr(() => ({
3878
- id: D.value,
3879
- transport: new mr({
3880
- api: A.value.getChatEndpoint(o.value, E.value ? "reasoning" : "chat"),
3881
- prepareReconnectToStreamRequest: ({ id: e }) => ({ api: A.value.getChatStreamEndpoint(o.value, e) }),
3878
+ id: E.value,
3879
+ transport: new hr({
3880
+ api: k.value.getChatEndpoint(o.value, T.value ? "reasoning" : "chat"),
3881
+ prepareReconnectToStreamRequest: ({ id: e }) => ({ api: k.value.getChatStreamEndpoint(o.value, e) }),
3882
3882
  prepareSendMessagesRequest: ({ messages: e, id: t }) => ({ body: {
3883
3883
  id: t,
3884
3884
  messages: [e[e.length - 1]],
@@ -3893,26 +3893,26 @@ function di(e) {
3893
3893
  reasoning: d.value?.reasoning,
3894
3894
  webSearch: f.value?.webSearch,
3895
3895
  smoothStream: u.value?.smoothStream,
3896
- deviceContext: lt(),
3897
- externalContext: ie.value,
3896
+ deviceContext: ut(),
3897
+ externalContext: oe.value,
3898
3898
  disabledTools: f.value?.disabled,
3899
3899
  fallbackModels: y.value,
3900
- gatewayOptions: ne.value,
3901
- hostTools: Ae(pe.value, oe.value),
3902
- pageTools: mt({ forms: !0 }),
3903
- ...Qe.value === "automatic" && { confirmations: "automatic" }
3900
+ gatewayOptions: ae.value,
3901
+ hostTools: je(me.value, se.value),
3902
+ pageTools: ht({ forms: !0 }),
3903
+ ...$e.value === "automatic" && { confirmations: "automatic" }
3904
3904
  } }),
3905
3905
  credentials: "include",
3906
3906
  headers: () => p.value ?? {}
3907
3907
  }),
3908
- sendAutomaticallyWhen: (e) => ui(e) || gr(e),
3908
+ sendAutomaticallyWhen: (e) => ui(e) || _r(e),
3909
3909
  onError: (e) => {
3910
- wt ? ce.warn(e) : st(e);
3910
+ Tt ? le.warn(e) : ct(e);
3911
3911
  },
3912
3912
  onToolCall: ({ toolCall: e }) => {
3913
- if (!ke(e) || wt) return;
3913
+ if (!Ae(e) || Tt) return;
3914
3914
  let t = e;
3915
- gt.enqueue({
3915
+ _t.enqueue({
3916
3916
  toolCallId: t.toolCallId,
3917
3917
  toolName: t.toolName,
3918
3918
  input: t.input,
@@ -3922,31 +3922,31 @@ function di(e) {
3922
3922
  });
3923
3923
  },
3924
3924
  onData: (e) => {
3925
- e.type === "data-turnStream" ? Et = e.data.streamId : e.type === "data-audioTranscripts" && (B.value.messages = le(B.value.messages, e.data));
3925
+ e.type === "data-turnStream" ? Dt = e.data.streamId : e.type === "data-audioTranscripts" && (B.value.messages = ue(B.value.messages, e.data));
3926
3926
  },
3927
3927
  onFinish: () => {
3928
- let e = D.value;
3929
- !E.value && !U.value.some((t) => t.id === e) && un(o.value);
3928
+ let e = E.value;
3929
+ !T.value && !U.value.some((t) => t.id === e) && dn(o.value);
3930
3930
  }
3931
- })), B = x(() => _e(Nt)), Pt = () => B.value.messages[B.value.messages.length - 1];
3932
- w(D, (e, t) => {
3933
- if (t && !E.value && (Y() || I?.chatId === t)) {
3931
+ })), B = b(() => ve(Nt)), Pt = () => B.value.messages[B.value.messages.length - 1];
3932
+ C(E, (e, t) => {
3933
+ if (t && !T.value && (J() || F?.chatId === t)) {
3934
3934
  let e = B.value.messages.filter((e) => e.role === "user"), n = e[e.length - 1];
3935
- jt(t, n ? ue(n) ?? "" : "", B.value.status === "streaming" || I?.chatId === t);
3935
+ jt(t, n ? de(n) ?? "" : "", B.value.status === "streaming" || F?.chatId === t);
3936
3936
  }
3937
- Mt(e), Et = void 0, clearTimeout(Rn), Ln.value = !1, B.value.stop();
3937
+ Mt(e), Dt = void 0, clearTimeout(zn), Rn.value = !1, B.value.stop();
3938
3938
  }, { flush: "sync" });
3939
- let V = x(() => {
3939
+ let V = b(() => {
3940
3940
  let e = u.value?.initialMessage;
3941
3941
  return e?.[r.value] ? e[r.value] : n("message.defaultAgentWelcome") ? t("message.defaultAgentWelcome") : "";
3942
- }), H = dt(), Ft = x(() => ({
3942
+ }), H = ft(), Ft = b(() => ({
3943
3943
  id: H,
3944
3944
  role: "assistant",
3945
3945
  parts: [{
3946
3946
  type: "text",
3947
3947
  text: V.value
3948
3948
  }]
3949
- })), It = x(() => {
3949
+ })), It = b(() => {
3950
3950
  let e = (e) => e.map((e) => e.role !== "user" || !e.parts.some((e) => e.type === "file") ? e : {
3951
3951
  ...e,
3952
3952
  parts: e.parts.map((e) => {
@@ -3956,50 +3956,50 @@ function di(e) {
3956
3956
  let e = t.url.slice(13);
3957
3957
  return {
3958
3958
  ...t,
3959
- url: A.value.getMediaUrl(o.value, D.value, e)
3959
+ url: k.value.getMediaUrl(o.value, E.value, e)
3960
3960
  };
3961
3961
  }
3962
3962
  return t.url.startsWith("blob:") ? t : {
3963
3963
  ...t,
3964
- url: A.value.appendAuthToken(t.url)
3964
+ url: k.value.appendAuthToken(t.url)
3965
3965
  };
3966
3966
  })
3967
- }), t = B.value.id === D.value ? B.value.messages : [];
3968
- return E.value ? e(t) : !He.value && t[0]?.role !== "assistant" ? [Ft.value, ...e(t)] : e(t);
3969
- }), Lt = x(() => {
3967
+ }), t = B.value.id === E.value ? B.value.messages : [];
3968
+ return T.value ? e(t) : !Ue.value && t[0]?.role !== "assistant" ? [Ft.value, ...e(t)] : e(t);
3969
+ }), Lt = b(() => {
3970
3970
  let e = u.value?.messagePlaceholder;
3971
3971
  return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
3972
- }), U = S([]), Rt = S(!1), zt = S(1), Bt = S(!1), Vt = S(!1), Ht, W = S([]), Ut = S(!1), Wt = S("chat"), Gt = S(0), Kt = S([]), qt = S(), Jt = S(!1), Yt = S(!1), Xt = S(), Zt = S(!1), Qt = S(!1), $t = S(), G = S(""), K = S([]), q = S(""), J = C(), en = S(0), tn = de(x(() => `${o.value}-queue`), {}), nn = x(() => tn.value[D.value] ?? []), rn = x(() => !E.value);
3973
- function an(e, t) {
3974
- let n = Object.fromEntries(Object.entries(tn.value).filter(([t]) => t !== e));
3975
- tn.value = t.length > 0 ? {
3972
+ }), U = x([]), Rt = x(!1), zt = x(1), Bt = x(!1), Vt = x(!1), Ht, Ut = x([]), Wt = x(!1), Gt = x("chat"), Kt = x(0), qt = x([]), Jt = x(), Yt = x(!1), Xt = x(!1), Zt = x(), Qt = x(!1), $t = x(!1), en = x(), W = x(""), G = x([]), K = x(""), q = S(), tn = x(0), nn = fe(b(() => `${o.value}-queue`), {}), rn = b(() => nn.value[E.value] ?? []), an = b(() => !T.value);
3973
+ function on(e, t) {
3974
+ let n = Object.fromEntries(Object.entries(nn.value).filter(([t]) => t !== e));
3975
+ nn.value = t.length > 0 ? {
3976
3976
  ...n,
3977
3977
  [e]: t
3978
3978
  } : n;
3979
3979
  }
3980
- function on(e) {
3981
- let t = (tn.value[e] ?? []).join(si);
3982
- return an(e, []), t;
3983
- }
3984
3980
  function sn(e) {
3985
- e && (G.value = G.value ? `${G.value}${si}${e}` : e);
3981
+ let t = (nn.value[e] ?? []).join(si);
3982
+ return on(e, []), t;
3986
3983
  }
3987
3984
  function cn(e) {
3988
- an(D.value, nn.value.filter((t, n) => n !== e));
3985
+ e && (W.value = W.value ? `${W.value}${si}${e}` : e);
3989
3986
  }
3990
3987
  function ln(e) {
3991
- let t = nn.value[e];
3992
- cn(e), sn(t ?? "");
3988
+ on(E.value, rn.value.filter((t, n) => n !== e));
3989
+ }
3990
+ function un(e) {
3991
+ let t = rn.value[e];
3992
+ ln(e), cn(t ?? "");
3993
3993
  }
3994
- async function un(e) {
3995
- if (E.value) U.value = [];
3994
+ async function dn(e) {
3995
+ if (T.value) U.value = [];
3996
3996
  else {
3997
3997
  Rt.value = !0;
3998
3998
  try {
3999
- let t = await A.value.getConversations(e, l.value), n = new Set(t.map((e) => e.id)), r = L.value.filter((e) => !n.has(e) && Ot.value[e]).map((t) => ({
3999
+ let t = await k.value.getConversations(e, l.value), n = new Set(t.map((e) => e.id)), r = I.value.filter((e) => !n.has(e) && R.value[e]).map((t) => ({
4000
4000
  id: t,
4001
4001
  agentId: e,
4002
- title: Ot.value[t],
4002
+ title: R.value[t],
4003
4003
  summary: null,
4004
4004
  messages: [],
4005
4005
  lastMessageAt: /* @__PURE__ */ new Date()
@@ -4017,15 +4017,15 @@ function di(e) {
4017
4017
  } finally {
4018
4018
  Rt.value = !1;
4019
4019
  }
4020
- Gn([.../* @__PURE__ */ new Set([...Bn(), ...U.value.map((e) => e.id)])]);
4020
+ Kn([.../* @__PURE__ */ new Set([...Vn(), ...U.value.map((e) => e.id)])]);
4021
4021
  }
4022
4022
  }
4023
- async function dn() {
4024
- if (!Bt.value || Vt.value || E.value) return;
4023
+ async function fn() {
4024
+ if (!Bt.value || Vt.value || T.value) return;
4025
4025
  Vt.value = !0;
4026
4026
  let e = Ht;
4027
4027
  try {
4028
- let t = zt.value + 1, n = await A.value.getConversations(o.value, l.value, { page: t });
4028
+ let t = zt.value + 1, n = await k.value.getConversations(o.value, l.value, { page: t });
4029
4029
  if (e !== Ht) return;
4030
4030
  let r = new Set(U.value.map((e) => e.id));
4031
4031
  U.value = [...U.value, ...n.filter((e) => !r.has(e.id))], zt.value = t, Bt.value = n.length >= 100;
@@ -4033,60 +4033,60 @@ function di(e) {
4033
4033
  Vt.value = !1;
4034
4034
  }
4035
4035
  }
4036
- async function fn(e) {
4037
- return E.value ? [] : A.value.getConversations(o.value, l.value, { search: e });
4036
+ async function pn(e) {
4037
+ return T.value ? [] : k.value.getConversations(o.value, l.value, { search: e });
4038
4038
  }
4039
- async function pn() {
4040
- let e = D.value;
4041
- if (!e) W.value = [];
4039
+ async function mn() {
4040
+ let e = E.value;
4041
+ if (!e) Ut.value = [];
4042
4042
  else {
4043
- Ut.value = !0;
4043
+ Wt.value = !0;
4044
4044
  try {
4045
- W.value = await A.value.getChatFiles(e);
4045
+ Ut.value = await k.value.getChatFiles(e);
4046
4046
  } catch {
4047
- W.value = [];
4047
+ Ut.value = [];
4048
4048
  } finally {
4049
- Ut.value = !1;
4049
+ Wt.value = !1;
4050
4050
  }
4051
4051
  }
4052
4052
  }
4053
- function mn(e, t = !1) {
4054
- return A.value.getChatFileDownloadUrl(e, t);
4053
+ function hn(e, t = !1) {
4054
+ return k.value.getChatFileDownloadUrl(e, t);
4055
4055
  }
4056
- function hn(e) {
4057
- return A.value.getChatFilePreviewUrl(e);
4056
+ function gn(e) {
4057
+ return k.value.getChatFilePreviewUrl(e);
4058
4058
  }
4059
- async function gn(e) {
4060
- await A.value.deleteChatFile(e);
4061
- let t = W.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
4062
- W.value = W.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
4059
+ async function _n(e) {
4060
+ await k.value.deleteChatFile(e);
4061
+ let t = Ut.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
4062
+ Ut.value = Ut.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
4063
4063
  }
4064
- async function _n(e, t) {
4065
- if (!E.value) try {
4066
- let n = await A.value.getChat(e, t);
4067
- if (t !== D.value || B.value.status !== "ready" || B.value.messages.length > 0) return;
4068
- n && (B.value.messages = n.messages, k.value = n.blocked ?? !1, vn(e, t, n.turnInProgress === !0));
4064
+ async function vn(e, t) {
4065
+ if (!T.value) try {
4066
+ let n = await k.value.getChat(e, t);
4067
+ if (t !== E.value || B.value.status !== "ready" || B.value.messages.length > 0) return;
4068
+ n && (B.value.messages = n.messages, O.value = n.blocked ?? !1, yn(e, t, n.turnInProgress === !0));
4069
4069
  } catch {}
4070
4070
  }
4071
- async function vn(e, t, n) {
4072
- n && (await yn(t), t !== D.value || Y()) || (await bn(e, t), t === D.value && await wn());
4071
+ async function yn(e, t, n) {
4072
+ n && (await bn(t), t !== E.value || J()) || (await xn(e, t), t === E.value && await Tn());
4073
4073
  }
4074
- async function yn(e) {
4074
+ async function bn(e) {
4075
4075
  let t = { chatId: e };
4076
- I = t, Tt.value = e;
4077
- let n = () => I === t && e === D.value, r = Date.now() + $r;
4076
+ F = t, Et.value = e;
4077
+ let n = () => F === t && e === E.value, r = Date.now() + $r;
4078
4078
  try {
4079
- for (; n() && !Y() && Date.now() < r;) {
4080
- wt = !0;
4079
+ for (; n() && !J() && Date.now() < r;) {
4080
+ Tt = !0;
4081
4081
  try {
4082
4082
  await B.value.resumeStream();
4083
4083
  } finally {
4084
- wt = !1;
4084
+ Tt = !1;
4085
4085
  }
4086
4086
  if (!n()) return;
4087
4087
  B.value.clearError();
4088
- let t = await A.value.getChat(o.value, e).catch(() => null);
4089
- if (!t || !n() || Y()) return;
4088
+ let t = await k.value.getChat(o.value, e).catch(() => null);
4089
+ if (!t || !n() || J()) return;
4090
4090
  if (!t.turnInProgress) {
4091
4091
  B.value.messages = t.messages;
4092
4092
  return;
@@ -4094,22 +4094,22 @@ function di(e) {
4094
4094
  await new Promise((e) => setTimeout(e, ei));
4095
4095
  }
4096
4096
  } finally {
4097
- I === t && (I = void 0, Tt.value = void 0);
4097
+ F === t && (F = void 0, Et.value = void 0);
4098
4098
  }
4099
4099
  }
4100
- async function bn(e, t) {
4100
+ async function xn(e, t) {
4101
4101
  let n;
4102
4102
  try {
4103
- n = Number(sessionStorage.getItem(De)), sessionStorage.removeItem(De);
4103
+ n = Number(sessionStorage.getItem(Oe)), sessionStorage.removeItem(Oe);
4104
4104
  } catch {
4105
4105
  return;
4106
4106
  }
4107
- if (!(!n || Date.now() - n > 6e4 || qe.value)) for (let n = 0; n < 12; n++) {
4107
+ if (!(!n || Date.now() - n > 6e4 || Je.value)) for (let n = 0; n < 12; n++) {
4108
4108
  let n = B.value.messages[B.value.messages.length - 1];
4109
4109
  if (n?.role === "assistant") {
4110
- let e = n.parts.filter((e) => ae(e) && e.state === "input-available"), t = e.filter((e) => e.toolMetadata?.provider === "page" && e.toolMetadata.readOnly === !0);
4110
+ let e = n.parts.filter((e) => re(e) && e.state === "input-available"), t = e.filter((e) => e.toolMetadata?.provider === "page" && e.toolMetadata.readOnly === !0);
4111
4111
  if (e.length > 0) {
4112
- if (t.length === e.length && !qe.value) for (let e of t) gt.enqueue({
4112
+ if (t.length === e.length && !Je.value) for (let e of t) _t.enqueue({
4113
4113
  toolCallId: e.toolCallId,
4114
4114
  toolName: e.toolName,
4115
4115
  input: e.input,
@@ -4121,99 +4121,99 @@ function di(e) {
4121
4121
  }
4122
4122
  if (n.parts[n.parts.length - 1]?.type === "text") return;
4123
4123
  }
4124
- if (await new Promise((e) => setTimeout(e, 1500)), t !== D.value || B.value.status !== "ready") return;
4124
+ if (await new Promise((e) => setTimeout(e, 1500)), t !== E.value || B.value.status !== "ready") return;
4125
4125
  try {
4126
- let n = await A.value.getChat(e, t);
4127
- n && t === D.value && (B.value.messages = n.messages);
4126
+ let n = await k.value.getChat(e, t);
4127
+ n && t === E.value && (B.value.messages = n.messages);
4128
4128
  } catch {
4129
4129
  return;
4130
4130
  }
4131
4131
  }
4132
4132
  }
4133
- let Y = () => {
4133
+ let J = () => {
4134
4134
  let e = B.value.status;
4135
4135
  return e === "submitted" || e === "streaming";
4136
- }, xn = () => Y() || I?.chatId === D.value || me.value > 0, Sn = () => {
4136
+ }, Sn = () => J() || F?.chatId === E.value || he.value > 0, Cn = () => {
4137
4137
  let e = Pt();
4138
- return j.value !== void 0 || Jr(e) || li(e);
4139
- }, Cn = /* @__PURE__ */ new Set();
4140
- async function wn() {
4141
- let e = D.value;
4142
- if (!(Cn.has(e) || nn.value.length === 0 || xn() || it.value)) {
4143
- if (Sn()) sn(on(e));
4138
+ return A.value !== void 0 || Jr(e) || li(e);
4139
+ }, wn = /* @__PURE__ */ new Set();
4140
+ async function Tn() {
4141
+ let e = E.value;
4142
+ if (!(wn.has(e) || rn.value.length === 0 || Sn() || at.value)) {
4143
+ if (Cn()) cn(sn(e));
4144
4144
  else {
4145
- Cn.add(e);
4145
+ wn.add(e);
4146
4146
  try {
4147
4147
  let t = Date.now() + ii;
4148
- for (; Date.now() < t && (await Promise.race([A.value.getRunningTurns(o.value, [e]).catch(() => []), new Promise((t) => setTimeout(() => t([e]), oi))])).includes(e);) await new Promise((e) => setTimeout(e, ai));
4149
- if (e !== D.value || xn()) return;
4150
- let n = on(e);
4151
- n && Nn(n);
4148
+ for (; Date.now() < t && (await Promise.race([k.value.getRunningTurns(o.value, [e]).catch(() => []), new Promise((t) => setTimeout(() => t([e]), oi))])).includes(e);) await new Promise((e) => setTimeout(e, ai));
4149
+ if (e !== E.value || Sn()) return;
4150
+ let n = sn(e);
4151
+ n && Pn(n);
4152
4152
  } finally {
4153
- Cn.delete(e);
4153
+ wn.delete(e);
4154
4154
  }
4155
4155
  }
4156
4156
  }
4157
4157
  }
4158
- let Tn = 0, En = 0;
4159
- async function Dn() {
4160
- if (E.value || Y()) return "indeterminate";
4161
- let e = D.value, t = Tn += 1;
4158
+ let En = 0, Dn = 0;
4159
+ async function On() {
4160
+ if (T.value || J()) return "indeterminate";
4161
+ let e = E.value, t = En += 1;
4162
4162
  try {
4163
- let n = await A.value.getChat(o.value, e);
4164
- if (!n || e !== D.value || Y() || t <= En) return "indeterminate";
4165
- En = t;
4163
+ let n = await k.value.getChat(o.value, e);
4164
+ if (!n || e !== E.value || J() || t <= Dn) return "indeterminate";
4165
+ Dn = t;
4166
4166
  let r = n.messages, i = Qr(r, B.value.messages);
4167
- return B.value.messages = [...r, ...i], k.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
4167
+ return B.value.messages = [...r, ...i], O.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
4168
4168
  } catch {}
4169
4169
  return "indeterminate";
4170
4170
  }
4171
- function On(e) {
4171
+ function kn(e) {
4172
4172
  B.value.messages = [...B.value.messages, e];
4173
4173
  }
4174
- async function X(e) {
4174
+ async function Y(e) {
4175
4175
  try {
4176
- Kt.value = await A.value.getMessageFeedbacks(e);
4176
+ qt.value = await k.value.getMessageFeedbacks(e);
4177
4177
  } catch {
4178
- Kt.value = [];
4178
+ qt.value = [];
4179
4179
  }
4180
4180
  }
4181
- function kn(e) {
4182
- let t = Kt.value.findIndex((t) => t.messageId === e.messageId);
4183
- t >= 0 ? Kt.value[t] = e : Kt.value.push(e);
4181
+ function An(e) {
4182
+ let t = qt.value.findIndex((t) => t.messageId === e.messageId);
4183
+ t >= 0 ? qt.value[t] = e : qt.value.push(e);
4184
4184
  }
4185
- function Z(e) {
4186
- let t = It.value, n = t.findIndex((t) => t.id === e.id), r = ue(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4185
+ function X(e) {
4186
+ let t = It.value, n = t.findIndex((t) => t.id === e.id), r = de(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4187
4187
  return {
4188
- userQuestion: ue(i ?? e) ?? "",
4188
+ userQuestion: de(i ?? e) ?? "",
4189
4189
  assistantMessage: r
4190
4190
  };
4191
4191
  }
4192
- async function An(e, t) {
4192
+ async function jn(e, t) {
4193
4193
  await Promise.all([
4194
- _n(e, t),
4195
- un(e),
4196
- X(t)
4197
- ]), ct.value || Ee((e, t) => A.value.reverseGeocode(e, t, r.value)).then((e) => {
4198
- e && (ct.value = e);
4194
+ vn(e, t),
4195
+ dn(e),
4196
+ Y(t)
4197
+ ]), lt.value || De((e, t) => k.value.reverseGeocode(e, t, r.value)).then((e) => {
4198
+ e && (lt.value = e);
4199
4199
  });
4200
4200
  }
4201
- async function jn() {
4202
- let e = G.value.trim(), t = K.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4201
+ async function Mn() {
4202
+ let e = W.value.trim(), t = G.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4203
4203
  type: "file",
4204
4204
  mediaType: e.mediaSource.mimeType,
4205
4205
  url: e.localUrl,
4206
4206
  filename: e.mediaSource.name,
4207
4207
  providerMetadata: { "8bot": { media: e.mediaSource } }
4208
- })), n = et.value ? Pe.value : void 0;
4209
- !E.value && xn() ? e && t.length === 0 && !n && (an(D.value, [...nn.value, e]), G.value = "") : (E.value && It.value.length > 0 && await Xn(), Nn(e, t, n && { pagePointer: n }), G.value = "", Pe.value = void 0, Yn());
4208
+ })), n = tt.value ? Fe.value : void 0;
4209
+ !T.value && Sn() ? e && t.length === 0 && !n && (on(E.value, [...rn.value, e]), W.value = "") : (T.value && It.value.length > 0 && await Zn(), Pn(e, t, n && { pagePointer: n }), W.value = "", Fe.value = void 0, Xn());
4210
4210
  }
4211
- function Mn(e, t) {
4211
+ function Nn(e, t) {
4212
4212
  let n = e.trim();
4213
- return !n || k.value || xn() || B.value.status !== "ready" ? !1 : (Nn(n, [], t, { rollback: !1 }), !0);
4213
+ return !n || O.value || Sn() || B.value.status !== "ready" ? !1 : (Pn(n, [], t, { rollback: !1 }), !0);
4214
4214
  }
4215
- function Nn(e, t = [], n, { rollback: r = !0 } = {}) {
4216
- St(), q.value = r ? e : "", J.value = r && n && "pagePointer" in n ? n.pagePointer : void 0, en.value = B.value.messages.length;
4215
+ function Pn(e, t = [], n, { rollback: r = !0 } = {}) {
4216
+ Ct(), K.value = r ? e : "", q.value = r && n && "pagePointer" in n ? n.pagePointer : void 0, tn.value = B.value.messages.length;
4217
4217
  let i = B.value.sendMessage;
4218
4218
  i({
4219
4219
  text: e,
@@ -4221,132 +4221,132 @@ function di(e) {
4221
4221
  ...n && { metadata: n }
4222
4222
  });
4223
4223
  }
4224
- function Pn(e) {
4224
+ function Fn(e) {
4225
4225
  let t = e.trim();
4226
4226
  if (!t) return;
4227
4227
  if (B.value.status !== "ready") {
4228
- ce.warn("[useChatbotStore] sendMessage called before chat is ready. Listen for the \"ready\" event on the widget element.");
4228
+ le.warn("[useChatbotStore] sendMessage called before chat is ready. Listen for the \"ready\" event on the widget element.");
4229
4229
  return;
4230
4230
  }
4231
4231
  let n = B.value.sendMessage;
4232
- St(), n({ text: t });
4232
+ Ct(), n({ text: t });
4233
4233
  }
4234
- async function Fn() {
4235
- let e = B.value.messages.slice(en.value).some((e) => e.parts.some(ae)), t = q.value, n = J.value, r = t.length > 0 && !e, i = D.value, a = en.value, s = I?.chatId === i, c = Et, l = on(i), u = (e = "") => {
4236
- G.value = [
4234
+ async function In() {
4235
+ let e = B.value.messages.slice(tn.value).some((e) => e.parts.some(re)), t = K.value, n = q.value, r = t.length > 0 && !e, i = E.value, a = tn.value, s = F?.chatId === i, c = Dt, l = sn(i), u = (e = "") => {
4236
+ W.value = [
4237
4237
  e,
4238
4238
  l,
4239
- G.value
4239
+ W.value
4240
4240
  ].filter(Boolean).join(si);
4241
- }, d = () => i === D.value && !Y() && en.value === a ? !1 : (l && an(i, [l, ...tn.value[i] ?? []]), !0);
4242
- I = void 0, Tt.value = void 0, St(), await B.value.stop();
4243
- let f = E.value || e && !s || await A.value.stopChatTurn(o.value, i, c).catch(() => !0);
4241
+ }, d = () => i === E.value && !J() && tn.value === a ? !1 : (l && on(i, [l, ...nn.value[i] ?? []]), !0);
4242
+ F = void 0, Et.value = void 0, Ct(), await B.value.stop();
4243
+ let f = T.value || e && !s || await k.value.stopChatTurn(o.value, i, c).catch(() => !0);
4244
4244
  if (!d()) {
4245
4245
  if (s || !f) {
4246
- if (await Dn(), d()) return;
4247
- if (s || B.value.messages.length > en.value) {
4248
- q.value = "", u();
4246
+ if (await On(), d()) return;
4247
+ if (s || B.value.messages.length > tn.value) {
4248
+ K.value = "", u();
4249
4249
  return;
4250
4250
  }
4251
4251
  }
4252
- r ? (u(t), Pe.value ??= n, B.value.messages = B.value.messages.slice(0, en.value), q.value = "") : u();
4252
+ r ? (u(t), Fe.value ??= n, B.value.messages = B.value.messages.slice(0, tn.value), K.value = "") : u();
4253
4253
  }
4254
4254
  }
4255
- w(() => B.value.messages, (e) => {
4256
- let t = j.value?.toolCallId;
4257
- t && !N.has(t) && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && St();
4258
- }), w(() => B.value.status, (e) => {
4259
- e === "submitted" && (Be.value++, Et = void 0);
4255
+ C(() => B.value.messages, (e) => {
4256
+ let t = A.value?.toolCallId;
4257
+ t && !M.has(t) && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && Ct();
4258
+ }), C(() => B.value.status, (e) => {
4259
+ e === "submitted" && (Ve.value++, Dt = void 0);
4260
4260
  });
4261
- let In;
4262
- w(() => [
4261
+ let Ln;
4262
+ C(() => [
4263
4263
  B.value.status,
4264
- me.value,
4265
- ve.value
4264
+ he.value,
4265
+ ye.value
4266
4266
  ], ([e, t, n]) => {
4267
- clearTimeout(In), e === "ready" && t === 0 && n === 0 && (In = setTimeout(() => {
4268
- ze.value = !1;
4267
+ clearTimeout(Ln), e === "ready" && t === 0 && n === 0 && (Ln = setTimeout(() => {
4268
+ Be.value = !1;
4269
4269
  }, 1500));
4270
4270
  });
4271
- let Ln = S(!1), Rn;
4272
- w(() => !j.value && !Jr(Pt()) && (Y() || me.value > 0), (e) => {
4273
- clearTimeout(Rn), e ? Ln.value = !0 : Rn = setTimeout(() => {
4274
- Ln.value = !1;
4271
+ let Rn = x(!1), zn;
4272
+ C(() => !A.value && !Jr(Pt()) && (J() || he.value > 0), (e) => {
4273
+ clearTimeout(zn), e ? Rn.value = !0 : zn = setTimeout(() => {
4274
+ Rn.value = !1;
4275
4275
  }, 400);
4276
4276
  }, { immediate: !0 });
4277
- let zn = x(() => {
4278
- let e = Dt.value.filter((e) => e !== D.value);
4279
- return Ln.value || Tt.value === D.value ? [...e, D.value] : e;
4280
- }), Bn = () => [.../* @__PURE__ */ new Set([...Dt.value, ...L.value])], Vn = Se(), Q, Hn = 0, Un = 0;
4281
- function Wn() {
4282
- clearTimeout(Q), Q = void 0, Bn().length !== 0 && Vn.value === "visible" && (Q = setTimeout(() => {
4283
- Q = void 0, Gn(Bn());
4277
+ let Bn = b(() => {
4278
+ let e = Ot.value.filter((e) => e !== E.value);
4279
+ return Rn.value || Et.value === E.value ? [...e, E.value] : e;
4280
+ }), Vn = () => [.../* @__PURE__ */ new Set([...Ot.value, ...I.value])], Hn = Ce(), Z, Un = 0, Wn = 0;
4281
+ function Gn() {
4282
+ clearTimeout(Z), Z = void 0, Vn().length !== 0 && Hn.value === "visible" && (Z = setTimeout(() => {
4283
+ Z = void 0, Kn(Vn());
4284
4284
  }, ti));
4285
4285
  }
4286
- async function Gn(e) {
4286
+ async function Kn(e) {
4287
4287
  let t = e.slice(0, ni);
4288
- if (E.value || t.length === 0) {
4289
- Wn();
4288
+ if (T.value || t.length === 0) {
4289
+ Gn();
4290
4290
  return;
4291
4291
  }
4292
- let n = Hn += 1, r;
4292
+ let n = Un += 1, r;
4293
4293
  try {
4294
- r = await A.value.getRunningTurns(o.value, t);
4294
+ r = await k.value.getRunningTurns(o.value, t);
4295
4295
  } catch {
4296
- Wn();
4296
+ Gn();
4297
4297
  return;
4298
4298
  }
4299
- if (n <= Un) return;
4300
- Un = n;
4299
+ if (n <= Wn) return;
4300
+ Wn = n;
4301
4301
  for (let e of r) At.add(e);
4302
- let i = new Set(t), a = Bn().filter((e) => i.has(e) && !r.includes(e)), s = (e) => L.value.includes(e) && !At.has(e), c = a.filter((e) => s(e) && Date.now() - (kt.get(e) ?? 0) > ri), l = a.filter((e) => !s(e));
4303
- Dt.value = [...Dt.value.filter((e) => !i.has(e)), ...r];
4304
- let u = l.filter((e) => L.value.includes(e));
4305
- (u.length > 0 || c.length > 0) && (L.value = L.value.filter((e) => !u.includes(e) && !c.includes(e)), R.value = [...R.value, ...u.filter((e) => e !== D.value && !R.value.includes(e))]), l.length > 0 && un(o.value), Wn();
4302
+ let i = new Set(t), a = Vn().filter((e) => i.has(e) && !r.includes(e)), s = (e) => I.value.includes(e) && !At.has(e), c = a.filter((e) => s(e) && Date.now() - (kt.get(e) ?? 0) > ri), l = a.filter((e) => !s(e));
4303
+ Ot.value = [...Ot.value.filter((e) => !i.has(e)), ...r];
4304
+ let u = l.filter((e) => I.value.includes(e));
4305
+ (u.length > 0 || c.length > 0) && (I.value = I.value.filter((e) => !u.includes(e) && !c.includes(e)), L.value = [...L.value, ...u.filter((e) => e !== E.value && !L.value.includes(e))]), l.length > 0 && dn(o.value), Gn();
4306
4306
  }
4307
- w(Vn, (e) => {
4308
- e === "visible" ? Gn(Bn()) : (clearTimeout(Q), Q = void 0);
4309
- }), ge(() => clearTimeout(Q));
4310
- let Kn = x(() => R.value.map((e) => ({
4307
+ C(Hn, (e) => {
4308
+ e === "visible" ? Kn(Vn()) : (clearTimeout(Z), Z = void 0);
4309
+ }), _e(() => clearTimeout(Z));
4310
+ let qn = b(() => L.value.map((e) => ({
4311
4311
  chatId: e,
4312
- title: U.value.find((t) => t.id === e)?.title || Ot.value[e] || void 0
4312
+ title: U.value.find((t) => t.id === e)?.title || R.value[e] || void 0
4313
4313
  })));
4314
- function qn(e) {
4315
- Mt(e), D.value = e, _r("chat");
4316
- }
4317
4314
  function Jn(e) {
4318
- R.value = R.value.filter((t) => t !== e), z(e);
4315
+ Mt(e), E.value = e, vr("chat");
4316
+ }
4317
+ function Yn(e) {
4318
+ L.value = L.value.filter((t) => t !== e), z(e);
4319
4319
  }
4320
- w(() => [B.value.status, B.value.id], ([e, t], [n, r]) => {
4320
+ C(() => [B.value.status, B.value.id], ([e, t], [n, r]) => {
4321
4321
  if (t === r) {
4322
- if (e === "error") I?.chatId !== D.value && sn(on(D.value));
4322
+ if (e === "error") F?.chatId !== E.value && cn(sn(E.value));
4323
4323
  else if (e === "ready" && (n === "streaming" || n === "submitted")) {
4324
- if (Sn()) {
4325
- sn(on(D.value));
4324
+ if (Cn()) {
4325
+ cn(sn(E.value));
4326
4326
  return;
4327
4327
  }
4328
- wn();
4328
+ Tn();
4329
4329
  }
4330
4330
  }
4331
- }), w(me, (e) => {
4332
- e === 0 && B.value.status === "ready" && wn();
4333
- }), w(() => B.value.status, (e) => {
4334
- e === "ready" && q.value.length > 0 && (q.value = "");
4331
+ }), C(he, (e) => {
4332
+ e === 0 && B.value.status === "ready" && Tn();
4333
+ }), C(() => B.value.status, (e) => {
4334
+ e === "ready" && K.value.length > 0 && (K.value = "");
4335
4335
  });
4336
- function Yn(e = !1) {
4337
- for (let t of K.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4338
- K.value = [], ir.value = null;
4336
+ function Xn(e = !1) {
4337
+ for (let t of G.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4338
+ G.value = [], ar.value = null;
4339
4339
  }
4340
- async function Xn() {
4341
- return q.value = "", Le.value = {}, Re.value = {}, D.value = dt(), await he(), B.value.clearError(), it.value = void 0, k.value = !1, Yn(!0), _r("chat"), D.value;
4340
+ async function Zn() {
4341
+ return K.value = "", Re.value = {}, ze.value = {}, E.value = ft(), await ge(), B.value.clearError(), at.value = void 0, O.value = !1, Xn(!0), vr("chat"), E.value;
4342
4342
  }
4343
- async function Zn(e) {
4344
- B.value.status !== "ready" && (q.value = "", await Fn()), St(), await B.value.regenerate(e);
4343
+ async function Qn(e) {
4344
+ B.value.status !== "ready" && (K.value = "", await In()), Ct(), await B.value.regenerate(e);
4345
4345
  }
4346
- function Qn(e) {
4346
+ function $n(e) {
4347
4347
  if (e.tool === "requestGeolocation") {
4348
4348
  let t = e.output;
4349
- "latitude" in t && (ct.value = {
4349
+ "latitude" in t && (lt.value = {
4350
4350
  geolocationLatitude: t.latitude,
4351
4351
  geolocationLongitude: t.longitude,
4352
4352
  geolocationAccuracy: t.accuracy,
@@ -4355,129 +4355,129 @@ function di(e) {
4355
4355
  }
4356
4356
  B.value.addToolOutput(e);
4357
4357
  }
4358
- function $n(e) {
4358
+ function er(e) {
4359
4359
  B.value.addToolApprovalResponse(e);
4360
4360
  }
4361
- let er = x(() => B.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), tr = x(() => _.value?.maxFilesPerMessage ?? 5), nr = x(() => _.value?.maxFilesPerChat ?? 20), $ = x(() => Math.max(0, Math.min(tr.value - K.value.length, nr.value - er.value - K.value.length))), rr = x(() => $.value <= 0), ir = S(null), ar = () => {
4362
- ir.value = null;
4361
+ let tr = b(() => B.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), nr = b(() => _.value?.maxFilesPerMessage ?? 5), rr = b(() => _.value?.maxFilesPerChat ?? 20), Q = b(() => Math.max(0, Math.min(nr.value - G.value.length, rr.value - tr.value - G.value.length))), ir = b(() => Q.value <= 0), ar = x(null), or = () => {
4362
+ ar.value = null;
4363
4363
  };
4364
- w(rr, (e) => {
4365
- e || (ir.value = null);
4364
+ C(ir, (e) => {
4365
+ e || (ar.value = null);
4366
4366
  });
4367
- async function or(e) {
4368
- if (rr.value) {
4369
- ir.value = nr.value - er.value - K.value.length <= tr.value - K.value.length ? {
4367
+ async function sr(e) {
4368
+ if (ir.value) {
4369
+ ar.value = rr.value - tr.value - G.value.length <= nr.value - G.value.length ? {
4370
4370
  reason: "per-chat",
4371
- max: nr.value
4371
+ max: rr.value
4372
4372
  } : {
4373
4373
  reason: "per-message",
4374
- max: tr.value
4374
+ max: nr.value
4375
4375
  };
4376
4376
  return;
4377
4377
  }
4378
- let t = dt(), n = {
4378
+ let t = ft(), n = {
4379
4379
  id: t,
4380
4380
  file: e,
4381
4381
  localUrl: URL.createObjectURL(e),
4382
4382
  state: "uploading"
4383
4383
  };
4384
- K.value = [...K.value, n];
4384
+ G.value = [...G.value, n];
4385
4385
  try {
4386
- let n = await A.value.uploadMedia(o.value, D.value, e);
4387
- K.value = K.value.map((e) => e.id === t ? {
4386
+ let n = await k.value.uploadMedia(o.value, E.value, e);
4387
+ G.value = G.value.map((e) => e.id === t ? {
4388
4388
  ...e,
4389
4389
  state: "done",
4390
4390
  mediaSource: n
4391
4391
  } : e);
4392
4392
  } catch (e) {
4393
4393
  let n = e instanceof Error ? e.message : "Upload failed";
4394
- K.value = K.value.map((e) => e.id === t ? {
4394
+ G.value = G.value.map((e) => e.id === t ? {
4395
4395
  ...e,
4396
4396
  state: "error",
4397
4397
  error: n
4398
4398
  } : e);
4399
4399
  }
4400
4400
  }
4401
- async function sr(e, t) {
4402
- let { userQuestion: n, assistantMessage: r } = Z(e);
4403
- kn(await A.value.submitMessageFeedback({
4401
+ async function cr(e, t) {
4402
+ let { userQuestion: n, assistantMessage: r } = X(e);
4403
+ An(await k.value.submitMessageFeedback({
4404
4404
  messageId: e.id,
4405
- chatId: D.value,
4405
+ chatId: E.value,
4406
4406
  agentId: o.value,
4407
4407
  vote: t,
4408
4408
  userQuestion: n,
4409
4409
  assistantMessage: r
4410
4410
  }));
4411
4411
  }
4412
- async function cr(e) {
4413
- await sr(e, "upvote");
4414
- }
4415
4412
  async function lr(e) {
4416
- await sr(e, "downvote");
4413
+ await cr(e, "upvote");
4417
4414
  }
4418
- function ur(e) {
4419
- Yt.value = !1, Xt.value = void 0, qt.value = e;
4415
+ async function ur(e) {
4416
+ await cr(e, "downvote");
4420
4417
  }
4421
- async function dr(e) {
4422
- if (qt.value) try {
4423
- Jt.value = !0, Yt.value = !1, Xt.value = void 0;
4424
- let { userQuestion: t, assistantMessage: n } = Z(qt.value);
4425
- kn(await A.value.submitMessageFeedback({
4426
- messageId: qt.value.id,
4427
- chatId: D.value,
4418
+ function dr(e) {
4419
+ Xt.value = !1, Zt.value = void 0, Jt.value = e;
4420
+ }
4421
+ async function fr(e) {
4422
+ if (Jt.value) try {
4423
+ Yt.value = !0, Xt.value = !1, Zt.value = void 0;
4424
+ let { userQuestion: t, assistantMessage: n } = X(Jt.value);
4425
+ An(await k.value.submitMessageFeedback({
4426
+ messageId: Jt.value.id,
4427
+ chatId: E.value,
4428
4428
  agentId: o.value,
4429
4429
  userQuestion: t,
4430
4430
  assistantMessage: n,
4431
4431
  comment: e
4432
- })), Yt.value = !0, await X(D.value);
4432
+ })), Xt.value = !0, await Y(E.value);
4433
4433
  } catch {
4434
- Xt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4434
+ Zt.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4435
4435
  } finally {
4436
- Jt.value = !1;
4436
+ Yt.value = !1;
4437
4437
  }
4438
4438
  }
4439
- async function fr(e) {
4439
+ async function pr(e) {
4440
4440
  try {
4441
- Qt.value = !0, Zt.value = !1, $t.value = void 0, await A.value.submitLead({
4441
+ $t.value = !0, Qt.value = !1, en.value = void 0, await k.value.submitLead({
4442
4442
  agentId: o.value,
4443
- chatId: D.value,
4443
+ chatId: E.value,
4444
4444
  ...e
4445
- }), Zt.value = !0;
4445
+ }), Qt.value = !0;
4446
4446
  } catch {
4447
- $t.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4447
+ en.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4448
4448
  } finally {
4449
- Qt.value = !1;
4449
+ $t.value = !1;
4450
4450
  }
4451
4451
  }
4452
- async function pr(e, t) {
4453
- let n = await A.value.updateChatTitle(o.value, e, t);
4452
+ async function mr(e, t) {
4453
+ let n = await k.value.updateChatTitle(o.value, e, t);
4454
4454
  U.value = U.value.map((t) => t.id === e ? {
4455
4455
  ...t,
4456
4456
  title: n.title
4457
4457
  } : t);
4458
4458
  }
4459
- async function hr(e) {
4460
- await A.value.deleteChat(o.value, e), U.value = U.value.filter((t) => t.id !== e), D.value === e && await Xn();
4459
+ async function gr(e) {
4460
+ await k.value.deleteChat(o.value, e), U.value = U.value.filter((t) => t.id !== e), E.value === e && await Zn();
4461
4461
  }
4462
- function _r(e) {
4463
- Wt.value = e;
4462
+ function vr(e) {
4463
+ Gt.value = e;
4464
4464
  }
4465
- function vr() {
4466
- _r("chat"), Gt.value++;
4465
+ function yr() {
4466
+ vr("chat"), Kt.value++;
4467
4467
  }
4468
- let yr;
4469
- function br(e) {
4470
- let t = () => A.value.getChat(o.value, e).then((e) => e !== null);
4468
+ let br;
4469
+ function xr(e) {
4470
+ let t = () => k.value.getChat(o.value, e).then((e) => e !== null);
4471
4471
  return t().catch(() => t().catch(() => !1));
4472
4472
  }
4473
- return w(l, async (e) => {
4474
- if (!e || e === yr) return;
4475
- let t = yr;
4476
- if (yr = e, t === void 0) return;
4477
- let n = D.value, r = !E.value && await br(n);
4478
- l.value === e && D.value === n && (r ? un(o.value) : (U.value = [], Kt.value = [], W.value = [], Dt.value = [], L.value = [], R.value = [], Ot.value = {}, await Xn(), G.value = ""));
4473
+ return C(l, async (e) => {
4474
+ if (!e || e === br) return;
4475
+ let t = br;
4476
+ if (br = e, t === void 0) return;
4477
+ let n = E.value, r = !T.value && await xr(n);
4478
+ l.value === e && E.value === n && (r ? dn(o.value) : (U.value = [], qt.value = [], Ut.value = [], Ot.value = [], I.value = [], L.value = [], R.value = {}, await Zn(), W.value = ""));
4479
4479
  }), {
4480
- apiClient: A,
4480
+ apiClient: k,
4481
4481
  baseUrl: i,
4482
4482
  basePath: a,
4483
4483
  agentId: o,
@@ -4491,113 +4491,113 @@ function di(e) {
4491
4491
  revisedAnswers: m,
4492
4492
  model: h,
4493
4493
  actionsInput: g,
4494
- actions: Ge,
4494
+ actions: Ke,
4495
4495
  agentFileUpload: _,
4496
4496
  agentVoice: v,
4497
4497
  fallbackModels: y,
4498
- gatewayOptions: ne,
4499
- externalContext: ie,
4500
- agentHostTools: oe,
4501
- hostToolRegistry: pe,
4502
- hostToolsPending: me,
4503
- agentPageAccess: ye,
4504
- pageToolRegistry: Me,
4505
- pageFormsProvider: Ne,
4506
- pageAction: T,
4507
- hostStepTitles: Le,
4508
- hostStepChanges: Re,
4509
- pageControlActive: ze,
4510
- isWorking: Ln,
4511
- stopHostActions: xt,
4512
- voicePageTools: bt,
4513
- cancelVoicePageCalls: F,
4514
- pageNoticeLevel: nt,
4515
- closePageNotice: rt,
4516
- hostConfirmation: j,
4517
- respondHostConfirmation: ft,
4518
- pageAccessAvailable: Ye,
4519
- pageAccessOff: qe,
4520
- setPageAccessOff: Ct,
4521
- agentConfirmations: we,
4522
- agentSelectionActions: Oe,
4523
- sendSelection: Mn,
4524
- confirmationsAvailable: Ze,
4525
- confirmationMode: Qe,
4526
- setConfirmationMode: $e,
4527
- pagePointer: Pe,
4528
- pagePointerStart: Fe,
4529
- pagePointing: Ie,
4530
- pagePointerAvailable: et,
4531
- systemTheme: Ve,
4532
- hideWelcomeMessage: He,
4533
- isDark: We,
4498
+ gatewayOptions: ae,
4499
+ externalContext: oe,
4500
+ agentHostTools: se,
4501
+ hostToolRegistry: me,
4502
+ hostToolsPending: he,
4503
+ agentPageAccess: be,
4504
+ pageToolRegistry: Ne,
4505
+ pageFormsProvider: Pe,
4506
+ pageAction: w,
4507
+ hostStepTitles: Re,
4508
+ hostStepChanges: ze,
4509
+ pageControlActive: Be,
4510
+ isWorking: Rn,
4511
+ stopHostActions: St,
4512
+ voicePageTools: xt,
4513
+ cancelVoicePageCalls: P,
4514
+ pageNoticeLevel: rt,
4515
+ closePageNotice: it,
4516
+ hostConfirmation: A,
4517
+ respondHostConfirmation: pt,
4518
+ pageAccessAvailable: Xe,
4519
+ pageAccessOff: Je,
4520
+ setPageAccessOff: wt,
4521
+ agentConfirmations: Te,
4522
+ agentSelectionActions: ke,
4523
+ sendSelection: Nn,
4524
+ confirmationsAvailable: Qe,
4525
+ confirmationMode: $e,
4526
+ setConfirmationMode: et,
4527
+ pagePointer: Fe,
4528
+ pagePointerStart: Ie,
4529
+ pagePointing: Le,
4530
+ pagePointerAvailable: tt,
4531
+ systemTheme: He,
4532
+ hideWelcomeMessage: Ue,
4533
+ isDark: Ge,
4534
4534
  chat: B,
4535
4535
  messages: It,
4536
4536
  conversations: U,
4537
4537
  isLoadingConversations: Rt,
4538
4538
  hasMoreConversations: Bt,
4539
4539
  isLoadingMoreConversations: Vt,
4540
- chatFiles: W,
4541
- isLoadingChatFiles: Ut,
4542
- input: G,
4543
- pendingAttachments: K,
4544
- isAttachmentLimitReached: rr,
4545
- fileLimitError: ir,
4546
- localChatId: D,
4547
- isConversationBlocked: k,
4540
+ chatFiles: Ut,
4541
+ isLoadingChatFiles: Wt,
4542
+ input: W,
4543
+ pendingAttachments: G,
4544
+ isAttachmentLimitReached: ir,
4545
+ fileLimitError: ar,
4546
+ localChatId: E,
4547
+ isConversationBlocked: O,
4548
4548
  inputMessagePlaceholder: Lt,
4549
- chatError: it,
4550
- runningChatIds: zn,
4551
- backgroundAnswers: Kn,
4552
- openBackgroundAnswer: qn,
4553
- dismissBackgroundAnswer: Jn,
4554
- canQueue: rn,
4555
- queuedMessages: nn,
4556
- removeQueuedMessage: cn,
4557
- editQueuedMessage: ln,
4558
- activeView: Wt,
4559
- inputFocusRequest: Gt,
4560
- messageFeedbacks: Kt,
4561
- feedbackDialogMessage: qt,
4562
- isFeedbackSubmitting: Jt,
4563
- isFeedbackSubmitted: Yt,
4564
- feedbackSubmitError: Xt,
4565
- isLeadSubmitted: Zt,
4566
- isLoadingSubmitLead: Qt,
4567
- submitLeadError: $t,
4568
- buildDeviceContext: lt,
4569
- initialize: An,
4570
- loadConversations: un,
4571
- loadMoreConversations: dn,
4572
- searchConversations: fn,
4573
- loadChatFiles: pn,
4574
- refreshMessages: Dn,
4575
- appendMessage: On,
4576
- getChatFileUrl: mn,
4577
- getChatFilePreviewUrl: hn,
4578
- deleteChatFile: gn,
4579
- handleSubmit: jn,
4580
- sendMessage: Pn,
4581
- stopGeneration: Fn,
4582
- startNewChat: Xn,
4583
- regenerate: Zn,
4584
- addToolOutput: Qn,
4585
- addToolApprovalResponse: $n,
4586
- handleFileSelect: or,
4587
- clearFileLimitError: ar,
4588
- clearPendingAttachments: Yn,
4589
- onUpvote: cr,
4590
- onDownvote: lr,
4591
- onFeedback: ur,
4592
- onFeedbackSubmit: dr,
4593
- onLeadSubmit: fr,
4594
- navigate: _r,
4595
- focusInput: vr,
4596
- renameChatTitle: pr,
4597
- deleteChat: hr
4549
+ chatError: at,
4550
+ runningChatIds: Bn,
4551
+ backgroundAnswers: qn,
4552
+ openBackgroundAnswer: Jn,
4553
+ dismissBackgroundAnswer: Yn,
4554
+ canQueue: an,
4555
+ queuedMessages: rn,
4556
+ removeQueuedMessage: ln,
4557
+ editQueuedMessage: un,
4558
+ activeView: Gt,
4559
+ inputFocusRequest: Kt,
4560
+ messageFeedbacks: qt,
4561
+ feedbackDialogMessage: Jt,
4562
+ isFeedbackSubmitting: Yt,
4563
+ isFeedbackSubmitted: Xt,
4564
+ feedbackSubmitError: Zt,
4565
+ isLeadSubmitted: Qt,
4566
+ isLoadingSubmitLead: $t,
4567
+ submitLeadError: en,
4568
+ buildDeviceContext: ut,
4569
+ initialize: jn,
4570
+ loadConversations: dn,
4571
+ loadMoreConversations: fn,
4572
+ searchConversations: pn,
4573
+ loadChatFiles: mn,
4574
+ refreshMessages: On,
4575
+ appendMessage: kn,
4576
+ getChatFileUrl: hn,
4577
+ getChatFilePreviewUrl: gn,
4578
+ deleteChatFile: _n,
4579
+ handleSubmit: Mn,
4580
+ sendMessage: Fn,
4581
+ stopGeneration: In,
4582
+ startNewChat: Zn,
4583
+ regenerate: Qn,
4584
+ addToolOutput: $n,
4585
+ addToolApprovalResponse: er,
4586
+ handleFileSelect: sr,
4587
+ clearFileLimitError: or,
4588
+ clearPendingAttachments: Xn,
4589
+ onUpvote: lr,
4590
+ onDownvote: ur,
4591
+ onFeedback: dr,
4592
+ onFeedbackSubmit: fr,
4593
+ onLeadSubmit: pr,
4594
+ navigate: vr,
4595
+ focusInput: yr,
4596
+ renameChatTitle: mr,
4597
+ deleteChat: gr
4598
4598
  };
4599
4599
  })();
4600
4600
  }
4601
- export { dt as a, mr as i, di as n, Gr as r, Kr as t };
4601
+ export { ft as a, hr as i, di as n, Gr as r, Kr as t };
4602
4602
 
4603
- //# sourceMappingURL=useChatbotStore-CyZha9pf.js.map
4603
+ //# sourceMappingURL=useChatbotStore-C4xhJtrb.js.map