@8wave/ai-elements 0.121.0-beta.39 → 0.121.0-beta.40

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 (142) hide show
  1. package/README.md +67 -15
  2. package/dist/_chunks/{Agent-C3m0UmlL.js → Agent-BuPgJIt4.js} +203 -202
  3. package/dist/_chunks/Agent-BuPgJIt4.js.map +1 -0
  4. package/dist/_chunks/{PkStreamingMarkdown--PCkA4Fg.js → PkStreamingMarkdown-D2aqCD0I.js} +953 -927
  5. package/dist/_chunks/PkStreamingMarkdown-D2aqCD0I.js.map +1 -0
  6. package/dist/_chunks/{PkToolEditSpreadsheet-DAMWWIVt.js → PkToolEditSpreadsheet-83ZdmGeA.js} +2 -2
  7. package/dist/_chunks/{PkToolEditSpreadsheet-DAMWWIVt.js.map → PkToolEditSpreadsheet-83ZdmGeA.js.map} +1 -1
  8. package/dist/_chunks/{PkToolRequestGeolocation-BgsvQb7Q.js → PkToolRequestGeolocation-1cOmCG8P.js} +2 -2
  9. package/dist/_chunks/{PkToolRequestGeolocation-BgsvQb7Q.js.map → PkToolRequestGeolocation-1cOmCG8P.js.map} +1 -1
  10. package/dist/_chunks/{PkToolRequestOAuthConnection-DtuZw7yk.js → PkToolRequestOAuthConnection-CCu3FCyo.js} +2 -2
  11. package/dist/_chunks/{PkToolRequestOAuthConnection-DtuZw7yk.js.map → PkToolRequestOAuthConnection-CCu3FCyo.js.map} +1 -1
  12. package/dist/_chunks/{PkToolShowArtifact-B163OvqY.js → PkToolShowArtifact-CiYkZkpe.js} +2 -2
  13. package/dist/_chunks/{PkToolShowArtifact-B163OvqY.js.map → PkToolShowArtifact-CiYkZkpe.js.map} +1 -1
  14. package/dist/_chunks/{PkToolShowContactForm-C_ptr7Xs.js → PkToolShowContactForm-D7TEzrYe.js} +2 -2
  15. package/dist/_chunks/{PkToolShowContactForm-C_ptr7Xs.js.map → PkToolShowContactForm-D7TEzrYe.js.map} +1 -1
  16. package/dist/_chunks/{PkToolShowForm-fburTpQm.js → PkToolShowForm-CSh4Q6sl.js} +5 -5
  17. package/dist/_chunks/{PkToolShowForm-fburTpQm.js.map → PkToolShowForm-CSh4Q6sl.js.map} +1 -1
  18. package/dist/_chunks/{PkToolShowImageGallery-ChauJukk.js → PkToolShowImageGallery-CQEaEfYE.js} +2 -2
  19. package/dist/_chunks/{PkToolShowImageGallery-ChauJukk.js.map → PkToolShowImageGallery-CQEaEfYE.js.map} +1 -1
  20. package/dist/_chunks/{PkToolShowProductList-B_XZezYw.js → PkToolShowProductList-BCmULLct.js} +2 -2
  21. package/dist/_chunks/{PkToolShowProductList-B_XZezYw.js.map → PkToolShowProductList-BCmULLct.js.map} +1 -1
  22. package/dist/_chunks/{PkToolShowSources-CS4nEuL0.js → PkToolShowSources-R9KWsfTQ.js} +3 -3
  23. package/dist/_chunks/{PkToolShowSources-CS4nEuL0.js.map → PkToolShowSources-R9KWsfTQ.js.map} +1 -1
  24. package/dist/_chunks/{PkToolShowSuggestedReply-BIe56XdA.js → PkToolShowSuggestedReply-DYZz9aV2.js} +2 -2
  25. package/dist/_chunks/{PkToolShowSuggestedReply-BIe56XdA.js.map → PkToolShowSuggestedReply-DYZz9aV2.js.map} +1 -1
  26. package/dist/_chunks/{PkToolShowVideo-DzU1XJqv.js → PkToolShowVideo-C_9SZtZM.js} +2 -2
  27. package/dist/_chunks/{PkToolShowVideo-DzU1XJqv.js.map → PkToolShowVideo-C_9SZtZM.js.map} +1 -1
  28. package/dist/_chunks/{PkToolShowWebPages-BlKe8Arf.js → PkToolShowWebPages-DwRYfle9.js} +2 -2
  29. package/dist/_chunks/{PkToolShowWebPages-BlKe8Arf.js.map → PkToolShowWebPages-DwRYfle9.js.map} +1 -1
  30. package/dist/_chunks/{chatImagePolicy-ChSkpiw6.js → chatImagePolicy-CQYTWTkP.js} +2 -2
  31. package/dist/_chunks/{chatImagePolicy-ChSkpiw6.js.map → chatImagePolicy-CQYTWTkP.js.map} +1 -1
  32. package/dist/_chunks/{markdown-D3iMlF6T.js → markdown-Br9ROCBT.js} +2 -2
  33. package/dist/_chunks/{markdown-D3iMlF6T.js.map → markdown-Br9ROCBT.js.map} +1 -1
  34. package/dist/ai-elements.es.js +4378 -3756
  35. package/dist/ai-elements.es.js.map +1 -1
  36. package/dist-vue/PkChatbot.js +1 -1
  37. package/dist-vue/PkChatbotEmptyState.js +1 -1
  38. package/dist-vue/PkChatbotInput.js +1 -1
  39. package/dist-vue/PkChatbotMessages.js +1 -1
  40. package/dist-vue/PkChatbotStepPayload.js +1 -1
  41. package/dist-vue/PkChatbotStepToolDetail.js +1 -1
  42. package/dist-vue/PkChatbotSteps.js +1 -1
  43. package/dist-vue/PkChatbotViewChat.js +1 -1
  44. package/dist-vue/PkChatbotViewConversations.js +1 -1
  45. package/dist-vue/PkChatbotViewFiles.js +1 -1
  46. package/dist-vue/PkChatbotViewProfile.js +1 -1
  47. package/dist-vue/_chunks/{Agent-3IHYHv05.js → Agent-DZb775Ak.js} +193 -192
  48. package/dist-vue/_chunks/Agent-DZb775Ak.js.map +1 -0
  49. package/dist-vue/_chunks/{Document-B0A_y6N5.js → Document-E72l_VU6.js} +2 -2
  50. package/dist-vue/_chunks/{Document-B0A_y6N5.js.map → Document-E72l_VU6.js.map} +1 -1
  51. package/dist-vue/_chunks/{PkChatbot-Bu76hH4F.js → PkChatbot-DIqduIwr.js} +9 -9
  52. package/dist-vue/_chunks/{PkChatbot-Bu76hH4F.js.map → PkChatbot-DIqduIwr.js.map} +1 -1
  53. package/dist-vue/_chunks/{PkChatbotEmptyState-ilPJoYjk.js → PkChatbotEmptyState-Dh7ETVnf.js} +2 -2
  54. package/dist-vue/_chunks/{PkChatbotEmptyState-ilPJoYjk.js.map → PkChatbotEmptyState-Dh7ETVnf.js.map} +1 -1
  55. package/dist-vue/_chunks/{PkChatbotInput-CY0YRGkG.js → PkChatbotInput-BJHtmPR-.js} +2 -2
  56. package/dist-vue/_chunks/{PkChatbotInput-CY0YRGkG.js.map → PkChatbotInput-BJHtmPR-.js.map} +1 -1
  57. package/dist-vue/_chunks/PkChatbotMessages-DMSActW1.js +968 -0
  58. package/dist-vue/_chunks/PkChatbotMessages-DMSActW1.js.map +1 -0
  59. package/dist-vue/_chunks/{PkChatbotStepPayload-CiEcIlzW.js → PkChatbotStepPayload-CXdsUMrw.js} +2 -2
  60. package/dist-vue/_chunks/{PkChatbotStepPayload-CiEcIlzW.js.map → PkChatbotStepPayload-CXdsUMrw.js.map} +1 -1
  61. package/dist-vue/_chunks/{PkChatbotStepToolDetail-VqLkuWi7.js → PkChatbotStepToolDetail-DbpXR7jh.js} +16 -16
  62. package/dist-vue/_chunks/{PkChatbotStepToolDetail-VqLkuWi7.js.map → PkChatbotStepToolDetail-DbpXR7jh.js.map} +1 -1
  63. package/dist-vue/_chunks/PkChatbotSteps-QFFZ0DjH.js +189 -0
  64. package/dist-vue/_chunks/PkChatbotSteps-QFFZ0DjH.js.map +1 -0
  65. package/dist-vue/_chunks/{PkChatbotViewChat-t-XkwFbe.js → PkChatbotViewChat-BI_PtT72.js} +300 -298
  66. package/dist-vue/_chunks/PkChatbotViewChat-BI_PtT72.js.map +1 -0
  67. package/dist-vue/_chunks/{PkChatbotViewConversations-CgRMohUQ.js → PkChatbotViewConversations-Bg4jSO9a.js} +3 -3
  68. package/dist-vue/_chunks/{PkChatbotViewConversations-CgRMohUQ.js.map → PkChatbotViewConversations-Bg4jSO9a.js.map} +1 -1
  69. package/dist-vue/_chunks/{PkChatbotViewFiles-DkeysDGW.js → PkChatbotViewFiles-Cwm-JQMF.js} +3 -3
  70. package/dist-vue/_chunks/{PkChatbotViewFiles-DkeysDGW.js.map → PkChatbotViewFiles-Cwm-JQMF.js.map} +1 -1
  71. package/dist-vue/_chunks/{PkChatbotViewProfile-kgqu10ED.js → PkChatbotViewProfile-C_GElIM3.js} +2 -2
  72. package/dist-vue/_chunks/{PkChatbotViewProfile-kgqu10ED.js.map → PkChatbotViewProfile-C_GElIM3.js.map} +1 -1
  73. package/dist-vue/_chunks/{PkStreamingMarkdown-CDlpb5w0.js → PkStreamingMarkdown-DwDs-cGP.js} +3 -3
  74. package/dist-vue/_chunks/{PkStreamingMarkdown-CDlpb5w0.js.map → PkStreamingMarkdown-DwDs-cGP.js.map} +1 -1
  75. package/dist-vue/_chunks/{PkToolEditSpreadsheet-D0EPgCmp.js → PkToolEditSpreadsheet-B61LtERY.js} +2 -2
  76. package/dist-vue/_chunks/{PkToolEditSpreadsheet-D0EPgCmp.js.map → PkToolEditSpreadsheet-B61LtERY.js.map} +1 -1
  77. package/dist-vue/_chunks/{PkToolRequestGeolocation-DZnJd1od.js → PkToolRequestGeolocation-DC8hSH0j.js} +2 -2
  78. package/dist-vue/_chunks/{PkToolRequestGeolocation-DZnJd1od.js.map → PkToolRequestGeolocation-DC8hSH0j.js.map} +1 -1
  79. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-C8MGtBlh.js → PkToolRequestOAuthConnection-BH_-drvw.js} +2 -2
  80. package/dist-vue/_chunks/{PkToolRequestOAuthConnection-C8MGtBlh.js.map → PkToolRequestOAuthConnection-BH_-drvw.js.map} +1 -1
  81. package/dist-vue/_chunks/{PkToolShowArtifact-CtXB1-vJ.js → PkToolShowArtifact-CjVN96wJ.js} +2 -2
  82. package/dist-vue/_chunks/{PkToolShowArtifact-CtXB1-vJ.js.map → PkToolShowArtifact-CjVN96wJ.js.map} +1 -1
  83. package/dist-vue/_chunks/{PkToolShowContactForm-DlZdfcNw.js → PkToolShowContactForm-CmBLigw8.js} +2 -2
  84. package/dist-vue/_chunks/{PkToolShowContactForm-DlZdfcNw.js.map → PkToolShowContactForm-CmBLigw8.js.map} +1 -1
  85. package/dist-vue/_chunks/{PkToolShowDiagram-BUUjmUpE.js → PkToolShowDiagram-dKUU5_6F.js} +2 -2
  86. package/dist-vue/_chunks/{PkToolShowDiagram-BUUjmUpE.js.map → PkToolShowDiagram-dKUU5_6F.js.map} +1 -1
  87. package/dist-vue/_chunks/{PkToolShowForm-DxiiMSCC.js → PkToolShowForm-B6ESvq-5.js} +4 -4
  88. package/dist-vue/_chunks/{PkToolShowForm-DxiiMSCC.js.map → PkToolShowForm-B6ESvq-5.js.map} +1 -1
  89. package/dist-vue/_chunks/{PkToolShowImageGallery-D01aM-9U.js → PkToolShowImageGallery-Daq0IwTH.js} +2 -2
  90. package/dist-vue/_chunks/{PkToolShowImageGallery-D01aM-9U.js.map → PkToolShowImageGallery-Daq0IwTH.js.map} +1 -1
  91. package/dist-vue/_chunks/{PkToolShowProductList-BRMF3WJf.js → PkToolShowProductList-Bc3Gzyxy.js} +2 -2
  92. package/dist-vue/_chunks/{PkToolShowProductList-BRMF3WJf.js.map → PkToolShowProductList-Bc3Gzyxy.js.map} +1 -1
  93. package/dist-vue/_chunks/{PkToolShowSources-C0_MwX7m.js → PkToolShowSources-BDvRbenn.js} +3 -3
  94. package/dist-vue/_chunks/{PkToolShowSources-C0_MwX7m.js.map → PkToolShowSources-BDvRbenn.js.map} +1 -1
  95. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BcjKYwbk.js → PkToolShowSuggestedReply-Cd6VkzvJ.js} +2 -2
  96. package/dist-vue/_chunks/{PkToolShowSuggestedReply-BcjKYwbk.js.map → PkToolShowSuggestedReply-Cd6VkzvJ.js.map} +1 -1
  97. package/dist-vue/_chunks/{PkToolShowVideo-CjjoQH7j.js → PkToolShowVideo-Bo1gsD97.js} +2 -2
  98. package/dist-vue/_chunks/{PkToolShowVideo-CjjoQH7j.js.map → PkToolShowVideo-Bo1gsD97.js.map} +1 -1
  99. package/dist-vue/_chunks/{PkToolShowWebPages-B5reGh4g.js → PkToolShowWebPages-DI3sZiqh.js} +2 -2
  100. package/dist-vue/_chunks/{PkToolShowWebPages-B5reGh4g.js.map → PkToolShowWebPages-DI3sZiqh.js.map} +1 -1
  101. package/dist-vue/_chunks/{createChatbotApiClient-DcLpptlt.js → createChatbotApiClient-DUz4dwzY.js} +12 -12
  102. package/dist-vue/_chunks/{createChatbotApiClient-DcLpptlt.js.map → createChatbotApiClient-DUz4dwzY.js.map} +1 -1
  103. package/dist-vue/_chunks/{useChatbotStore-BliRphuB.js → useChatbotStore-D7LcpA-6.js} +481 -455
  104. package/dist-vue/_chunks/useChatbotStore-D7LcpA-6.js.map +1 -0
  105. package/dist-vue/_chunks/{utils-C7-KrzRE.js → utils-EPX3V3VI.js} +112 -86
  106. package/dist-vue/_chunks/utils-EPX3V3VI.js.map +1 -0
  107. package/dist-vue/api.js +1 -1
  108. package/dist-vue/apps/web-component/src/components/EmbeddedChatWidget.ce.d.ts +2 -0
  109. package/dist-vue/apps/web-component/src/components/FloatingChatWidget.ce.d.ts +2 -0
  110. package/dist-vue/apps/web-component/src/composables/usePageTools.d.ts +1 -0
  111. package/dist-vue/apps/web-component/src/lib.d.ts +10 -0
  112. package/dist-vue/apps/web-component/src/pageTools/actions.d.ts +2 -0
  113. package/dist-vue/apps/web-component/src/pageTools/announcements.d.ts +9 -0
  114. package/dist-vue/apps/web-component/src/pageTools/index.d.ts +12 -1
  115. package/dist-vue/apps/web-component/src/pageTools/navigation.d.ts +40 -8
  116. package/dist-vue/apps/web-component/src/pageTools/snapshot.d.ts +60 -0
  117. package/dist-vue/composables.js +34 -8
  118. package/dist-vue/composables.js.map +1 -1
  119. package/dist-vue/index.js +145 -125
  120. package/dist-vue/index.js.map +1 -1
  121. package/dist-vue/locales.js +28 -2
  122. package/dist-vue/packages/components/src/PkEditorPrompt.d.ts +6 -0
  123. package/dist-vue/packages/components/src/chat/PkChatbotMessages.d.ts +4 -0
  124. package/dist-vue/packages/components/src/chat/PkHostCallConfirmCard.d.ts +7 -1
  125. package/dist-vue/packages/components/src/chat/PkHostCallConfirmDialog.d.ts +4 -0
  126. package/dist-vue/packages/components/src/chat/PkPageControlBar.d.ts +5 -1
  127. package/dist-vue/packages/components/src/chat/utils.d.ts +11 -1
  128. package/dist-vue/packages/composable/src/chatbot/hostTools.d.ts +37 -8
  129. package/dist-vue/packages/composable/src/chatbot/useChatbotStore.d.ts +8 -2
  130. package/dist-vue/packages/models/src/schema/PageAccess.d.ts +9 -0
  131. package/dist-vue/style.css +1 -1
  132. package/package.json +1 -1
  133. package/dist/_chunks/Agent-C3m0UmlL.js.map +0 -1
  134. package/dist/_chunks/PkStreamingMarkdown--PCkA4Fg.js.map +0 -1
  135. package/dist-vue/_chunks/Agent-3IHYHv05.js.map +0 -1
  136. package/dist-vue/_chunks/PkChatbotMessages-BfKqJ8n_.js +0 -954
  137. package/dist-vue/_chunks/PkChatbotMessages-BfKqJ8n_.js.map +0 -1
  138. package/dist-vue/_chunks/PkChatbotSteps-CoDtEaL7.js +0 -189
  139. package/dist-vue/_chunks/PkChatbotSteps-CoDtEaL7.js.map +0 -1
  140. package/dist-vue/_chunks/PkChatbotViewChat-t-XkwFbe.js.map +0 -1
  141. package/dist-vue/_chunks/useChatbotStore-BliRphuB.js.map +0 -1
  142. package/dist-vue/_chunks/utils-C7-KrzRE.js.map +0 -1
@@ -1,6 +1,6 @@
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-Bu1lick6.js";
2
- import { G as ee, J as y, L as te, U as ne, V as re, X as ie, Y as ae, q as oe } from "./Agent-3IHYHv05.js";
3
- import { r as se, t as ce } from "./createChatbotApiClient-DcLpptlt.js";
2
+ import { H as ee, K as y, L as te, V as ne, W as re, X as ie, Y as ae, Z as oe } from "./Agent-DZb775Ak.js";
3
+ import { r as se, t as ce } from "./createChatbotApiClient-DUz4dwzY.js";
4
4
  import { n as le } from "./src-BZRiAJsH.js";
5
5
  import { d as ue, r as de } from "./message-DZvfzt9j.js";
6
6
  import { n as fe, t as pe } from "./useSafeLocalStorage-C1BlCeKw.js";
@@ -58,78 +58,93 @@ async function Ee(e) {
58
58
  }
59
59
  //#endregion
60
60
  //#region ../../packages/composable/src/chatbot/hostTools.ts
61
- var De = "agentstudio:page-navigation", Oe = (e) => typeof e?.afterOutput == "function", ke = (e) => e.toolMetadata?.source === y, Ae = (e, t) => {
61
+ var De = "agentstudio:page-navigation", Oe = (e) => typeof e?.afterOutput == "function", ke = (e) => e.toolMetadata?.source === ae, Ae = (e, t) => {
62
62
  if (!t || !e?.length) return;
63
- let n = new Set(t.allowed), r = e.filter((e) => n.has(e.name) && !ne(e.name)).map(({ execute: e, confirmation: t, policy: n, ...r }) => r);
63
+ let n = new Set(t.allowed), r = e.filter((e) => n.has(e.name) && !re(e.name)).map(({ execute: e, confirmation: t, policy: n, ...r }) => r);
64
64
  return r.length > 0 ? r : void 0;
65
65
  };
66
66
  function je(e) {
67
67
  let t = 0, n = 0, r = (t) => {
68
68
  n = t, e.onPendingChange?.(n);
69
- }, i = Promise.resolve(), a = /* @__PURE__ */ new Map(), o = (e, t) => t.requireConfirmation.includes(e.name) || t.confirmDestructive && e.annotations?.destructiveHint === !0, s = (t, n) => e.addToolOutput({
69
+ }, i = Promise.resolve(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set(), s = (e) => {
70
+ Oe(e) && e.abandon?.();
71
+ }, c = (e, t) => t.requireConfirmation.includes(e.name) || t.confirmDestructive && e.annotations?.destructiveHint === !0, l = (t, n) => e.addToolOutput({
70
72
  tool: t.toolName,
71
73
  toolCallId: t.toolCallId,
72
74
  output: n
73
- }), c = (t, n) => e.addToolOutput({
75
+ }), u = (t, n) => e.addToolOutput({
74
76
  tool: t.toolName,
75
77
  toolCallId: t.toolCallId,
76
78
  state: "output-error",
77
79
  errorText: n
78
80
  });
79
- async function l(n, r) {
80
- let i = () => r === t, l = e.capability(), u = e.registry()?.find((e) => e.name === n.toolName), d = u?.policy?.timeoutMs ?? l?.timeoutMs;
81
- if (!u || d === void 0) {
82
- c(n, ae(n.readOnly));
81
+ async function d(n, r) {
82
+ let i = () => r === t, d = e.capability(), f = e.registry()?.find((e) => e.name === n.toolName), p = f?.policy?.timeoutMs ?? d?.timeoutMs;
83
+ if (!f || p === void 0) {
84
+ u(n, ie(n.readOnly));
83
85
  return;
84
86
  }
85
- let f;
87
+ let m;
86
88
  try {
87
- f = u.confirmation?.(n.input);
89
+ let e = f.confirmation?.(n.input);
90
+ m = typeof e == "string" ? { question: e } : typeof e?.question == "string" ? e : void 0;
88
91
  } catch {
89
- c(n, "The host app could not prepare this call.");
92
+ u(n, "The host app could not prepare this call.");
90
93
  return;
91
94
  }
92
- let p = l !== void 0 && o(u, l);
93
- if (u.policy && u.confirmation ? f !== void 0 : f !== void 0 || p) {
94
- let t = await e.confirm(n, f);
95
+ let h = d !== void 0 && c(f, d);
96
+ if (f.policy && f.confirmation ? m !== void 0 : m !== void 0 || h) {
97
+ let t = await e.confirm(n, m);
95
98
  if (!i()) return;
96
99
  if (!t) {
97
- c(n, oe);
100
+ u(n, m?.refusal ?? "The user refused this call. Do not repeat it unless the user asks.");
98
101
  return;
99
102
  }
100
103
  }
101
- let m = new AbortController();
102
- a.set(n.toolCallId, m), e.onActivity?.(n);
103
- let h = setTimeout(() => m.abort(/* @__PURE__ */ Error("timeout")), d);
104
+ let g = new AbortController();
105
+ a.set(n.toolCallId, g), e.onActivity?.(n);
106
+ let _ = setTimeout(() => g.abort(/* @__PURE__ */ Error("timeout")), p), v;
104
107
  try {
105
108
  let t = new Promise((e, t) => {
106
- m.signal.addEventListener("abort", () => t(m.signal.reason), { once: !0 });
107
- }), r = await Promise.race([u.execute(n.input, {
108
- signal: m.signal,
109
+ g.signal.addEventListener("abort", () => t(g.signal.reason), { once: !0 });
110
+ });
111
+ v = Promise.resolve(f.execute(n.input, {
112
+ signal: g.signal,
109
113
  callId: n.toolCallId,
110
114
  messageId: n.messageId
111
- }), t]);
112
- if (!i()) return;
113
- Oe(r) ? (s(n, r.result ?? null), e.waitForResume().then((e) => {
114
- e && i() && r.afterOutput();
115
- })) : s(n, r ?? null);
115
+ }));
116
+ let r = await Promise.race([v, t]);
117
+ if (!i()) {
118
+ s(r);
119
+ return;
120
+ }
121
+ if (Oe(r)) {
122
+ l(n, r.result ?? null);
123
+ let t = !1, a = () => {
124
+ t || (t = !0, o.delete(a), r.abandon?.());
125
+ };
126
+ o.add(a), e.waitForResume().then((e) => {
127
+ t || (e && i() ? (t = !0, o.delete(a), r.afterOutput()) : a());
128
+ });
129
+ } else l(n, r ?? null);
116
130
  } catch (e) {
117
- if (!i()) return;
118
- let t = m.signal.aborted;
119
- c(n, t ? ae(n.readOnly) : e instanceof Error && e.message ? e.message : "The host app failed to run this call.");
131
+ if (v?.then(s, () => void 0), !i()) return;
132
+ let t = g.signal.aborted;
133
+ u(n, t ? ie(n.readOnly) : e instanceof Error && e.message ? e.message : "The host app failed to run this call.");
120
134
  } finally {
121
- clearTimeout(h), a.delete(n.toolCallId), e.onActivity?.(void 0);
135
+ clearTimeout(_), a.delete(n.toolCallId), e.onActivity?.(void 0);
122
136
  }
123
137
  }
124
138
  return {
125
139
  enqueue(e) {
126
140
  let a = t;
127
- r(n + 1), i = i.then(() => a === t ? l(e, a) : void 0).catch(() => void 0).then(() => {
141
+ r(n + 1), i = i.then(() => a === t ? d(e, a) : void 0).catch(() => void 0).then(() => {
128
142
  a === t && r(n - 1);
129
143
  });
130
144
  },
131
145
  cancelAll() {
132
146
  t++, r(0);
147
+ for (let e of [...o]) e();
133
148
  for (let e of a.values()) e.abort(/* @__PURE__ */ Error("cancelled"));
134
149
  a.clear();
135
150
  }
@@ -148,26 +163,26 @@ var Me = "vercel.ai.error", Ne = Symbol.for(Me), w = class e extends Error {
148
163
  let n = Symbol.for(t);
149
164
  return typeof e == "object" && !!e && n in e && typeof e[n] == "boolean" && e[n] === !0;
150
165
  }
151
- }, Pe = "AI_APICallError", T = `vercel.ai.error.${Pe}`, Fe = Symbol.for(T), Ie = class extends w {
166
+ }, Pe = "AI_APICallError", Fe = `vercel.ai.error.${Pe}`, Ie = Symbol.for(Fe), T = class extends w {
152
167
  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 }) {
153
168
  super({
154
169
  name: Pe,
155
170
  message: e,
156
171
  cause: o
157
- }), this[Fe] = !0, this.url = t, this.requestBodyValues = n, this.statusCode = r, this.responseHeaders = i, this.responseBody = a, this.isRetryable = s, this.data = c;
172
+ }), this[Ie] = !0, this.url = t, this.requestBodyValues = n, this.statusCode = r, this.responseHeaders = i, this.responseBody = a, this.isRetryable = s, this.data = c;
158
173
  }
159
174
  static isInstance(e) {
160
- return w.hasMarker(e, T);
175
+ return w.hasMarker(e, Fe);
161
176
  }
162
- }, E = "AI_EmptyResponseBodyError", D = `vercel.ai.error.${E}`, Le = Symbol.for(D), Re = class extends w {
177
+ }, Le = "AI_EmptyResponseBodyError", Re = `vercel.ai.error.${Le}`, E = Symbol.for(Re), D = class extends w {
163
178
  constructor({ message: e = "Empty response body" } = {}) {
164
179
  super({
165
- name: E,
180
+ name: Le,
166
181
  message: e
167
- }), this[Le] = !0;
182
+ }), this[E] = !0;
168
183
  }
169
184
  static isInstance(e) {
170
- return w.hasMarker(e, D);
185
+ return w.hasMarker(e, Re);
171
186
  }
172
187
  };
173
188
  function ze(e) {
@@ -184,18 +199,18 @@ var Be = "AI_InvalidArgumentError", Ve = `vercel.ai.error.${Be}`, He = Symbol.fo
184
199
  static isInstance(e) {
185
200
  return w.hasMarker(e, Ve);
186
201
  }
187
- }, We = "AI_JSONParseError", Ge = `vercel.ai.error.${We}`, Ke = Symbol.for(Ge), qe = class extends w {
202
+ }, We = "AI_JSONParseError", O = `vercel.ai.error.${We}`, Ge = Symbol.for(O), Ke = class extends w {
188
203
  constructor({ text: e, cause: t }) {
189
204
  super({
190
205
  name: We,
191
206
  message: `JSON parsing failed: Text: ${e}.\nError message: ${ze(t)}`,
192
207
  cause: t
193
- }), this[Ke] = !0, this.text = e;
208
+ }), this[Ge] = !0, this.text = e;
194
209
  }
195
210
  static isInstance(e) {
196
- return w.hasMarker(e, Ge);
211
+ return w.hasMarker(e, O);
197
212
  }
198
- }, O = "AI_TypeValidationError", Je = `vercel.ai.error.${O}`, Ye = Symbol.for(Je), Xe = class e extends w {
213
+ }, qe = "AI_TypeValidationError", Je = `vercel.ai.error.${qe}`, k = Symbol.for(Je), A = class e extends w {
199
214
  constructor({ value: e, cause: t, context: n }) {
200
215
  let r = "Type validation failed";
201
216
  if (n?.field && (r += ` for ${n.field}`), n?.entityName || n?.entityId) {
@@ -204,10 +219,10 @@ var Be = "AI_InvalidArgumentError", Ve = `vercel.ai.error.${Be}`, He = Symbol.fo
204
219
  n.entityName && e.push(n.entityName), n.entityId && e.push(`id: "${n.entityId}"`), r += e.join(", "), r += ")";
205
220
  }
206
221
  super({
207
- name: O,
222
+ name: qe,
208
223
  message: `${r}: Value: ${JSON.stringify(e)}.\nError message: ${ze(t)}`,
209
224
  cause: t
210
- }), this[Ye] = !0, this.value = e, this.context = n;
225
+ }), this[k] = !0, this.value = e, this.context = n;
211
226
  }
212
227
  static isInstance(e) {
213
228
  return w.hasMarker(e, Je);
@@ -219,25 +234,25 @@ var Be = "AI_InvalidArgumentError", Ve = `vercel.ai.error.${Be}`, He = Symbol.fo
219
234
  context: r
220
235
  });
221
236
  }
222
- }, k = "AI_UnsupportedFunctionalityError", Ze = `vercel.ai.error.${k}`, Qe = Symbol.for(Ze), $e = class extends w {
237
+ }, Ye = "AI_UnsupportedFunctionalityError", Xe = `vercel.ai.error.${Ye}`, j = Symbol.for(Xe), Ze = class extends w {
223
238
  constructor({ functionality: e, message: t = `'${e}' functionality not supported.` }) {
224
239
  super({
225
- name: k,
240
+ name: Ye,
226
241
  message: t
227
- }), this[Qe] = !0, this.functionality = e;
242
+ }), this[j] = !0, this.functionality = e;
228
243
  }
229
244
  static isInstance(e) {
230
- return w.hasMarker(e, Ze);
245
+ return w.hasMarker(e, Xe);
231
246
  }
232
- }, et = class extends Error {
247
+ }, Qe = class extends Error {
233
248
  constructor(e, t) {
234
249
  super(e), this.name = "ParseError", this.type = t.type, this.field = t.field, this.value = t.value, this.line = t.line;
235
250
  }
236
- }, A = 10, tt = 13, j = 32;
237
- function M(e) {}
251
+ }, $e = 10, et = 13, M = 32;
252
+ function tt(e) {}
238
253
  function nt(e) {
239
254
  if (typeof e == "function") throw TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");
240
- let { onEvent: t = M, onError: n = M, onRetry: r = M, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
255
+ let { onEvent: t = tt, onError: n = tt, onRetry: r = tt, onComment: i, maxBufferSize: a } = e, o = [], s = 0, c = !0, l, u = "", d = 0, f, p = !1;
241
256
  function m(e) {
242
257
  if (p) throw Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");
243
258
  if (c && (c = !1, e.charCodeAt(0) === 239 && e.charCodeAt(1) === 187 && e.charCodeAt(2) === 191 && (e = e.slice(3))), o.length === 0) {
@@ -256,7 +271,7 @@ function nt(e) {
256
271
  n !== "" && (o.push(n), s = n.length), h();
257
272
  }
258
273
  function h() {
259
- 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 et(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
274
+ 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 Qe(`Buffered data exceeded max buffer size of ${a} characters`, { type: "max-buffer-size-exceeded" }))));
260
275
  }
261
276
  function g(e) {
262
277
  let n = 0;
@@ -273,8 +288,8 @@ function nt(e) {
273
288
  }
274
289
  let i = e.charCodeAt(n);
275
290
  if (N(e, n, i)) {
276
- let i = e.charCodeAt(n + 5) === j ? n + 6 : n + 5, a = e.slice(i, r);
277
- if (d === 0 && e.charCodeAt(r + 1) === A) {
291
+ let i = e.charCodeAt(n + 5) === M ? n + 6 : n + 5, a = e.slice(i, r);
292
+ if (d === 0 && e.charCodeAt(r + 1) === $e) {
278
293
  t({
279
294
  id: l,
280
295
  event: f,
@@ -284,7 +299,7 @@ function nt(e) {
284
299
  }
285
300
  u = d === 0 ? a : `${u}
286
301
  ${a}`, d++;
287
- } else rt(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === j ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
302
+ } else rt(e, n, i) ? f = e.slice(e.charCodeAt(n + 6) === M ? n + 7 : n + 6, r) || void 0 : _(e, n, r);
288
303
  n = r + 1, r = e.indexOf("\n", n);
289
304
  }
290
305
  return e.slice(n);
@@ -292,7 +307,7 @@ ${a}`, d++;
292
307
  for (; n < e.length;) {
293
308
  let t = e.indexOf("\r", n), r = e.indexOf("\n", n), i = -1;
294
309
  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;
295
- _(e, n, i), n = i + 1, e.charCodeAt(n - 1) === tt && e.charCodeAt(n) === A && n++;
310
+ _(e, n, i), n = i + 1, e.charCodeAt(n - 1) === et && e.charCodeAt(n) === $e && n++;
296
311
  }
297
312
  return e.slice(n);
298
313
  }
@@ -303,24 +318,24 @@ ${a}`, d++;
303
318
  }
304
319
  let r = e.charCodeAt(t);
305
320
  if (N(e, t, r)) {
306
- let r = e.charCodeAt(t + 5) === j ? t + 6 : t + 5, i = e.slice(r, n);
321
+ let r = e.charCodeAt(t + 5) === M ? t + 6 : t + 5, i = e.slice(r, n);
307
322
  u = d === 0 ? i : `${u}
308
323
  ${i}`, d++;
309
324
  return;
310
325
  }
311
326
  if (rt(e, t, r)) {
312
- f = e.slice(e.charCodeAt(t + 6) === j ? t + 7 : t + 6, n) || void 0;
327
+ f = e.slice(e.charCodeAt(t + 6) === M ? t + 7 : t + 6, n) || void 0;
313
328
  return;
314
329
  }
315
330
  if (r === 105 && e.charCodeAt(t + 1) === 100 && e.charCodeAt(t + 2) === 58) {
316
- let r = e.slice(e.charCodeAt(t + 3) === j ? t + 4 : t + 3, n);
331
+ let r = e.slice(e.charCodeAt(t + 3) === M ? t + 4 : t + 3, n);
317
332
  l = r.includes("\0") ? void 0 : r;
318
333
  return;
319
334
  }
320
335
  if (r === 58) {
321
336
  if (i) {
322
337
  let r = e.slice(t, n);
323
- i(r.slice(e.charCodeAt(t + 1) === j ? 2 : 1));
338
+ i(r.slice(e.charCodeAt(t + 1) === M ? 2 : 1));
324
339
  }
325
340
  return;
326
341
  }
@@ -329,7 +344,7 @@ ${i}`, d++;
329
344
  v(a, "", a);
330
345
  return;
331
346
  }
332
- let s = a.slice(0, o), c = a.charCodeAt(o + 1) === j ? 2 : 1;
347
+ let s = a.slice(0, o), c = a.charCodeAt(o + 1) === M ? 2 : 1;
333
348
  v(s, a.slice(o + c), a);
334
349
  }
335
350
  function v(e, t, i) {
@@ -345,13 +360,13 @@ ${t}`, d++;
345
360
  l = t.includes("\0") ? void 0 : t;
346
361
  break;
347
362
  case "retry":
348
- /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new et(`Invalid \`retry\` value: "${t}"`, {
363
+ /^\d+$/.test(t) ? r(parseInt(t, 10)) : n(new Qe(`Invalid \`retry\` value: "${t}"`, {
349
364
  type: "invalid-retry",
350
365
  value: t,
351
366
  line: i
352
367
  }));
353
368
  break;
354
- default: n(new et(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
369
+ default: n(new Qe(`Unknown field "${e.length > 20 ? `${e.slice(0, 20)}\u2026` : e}"`, {
355
370
  type: "unknown-field",
356
371
  field: e,
357
372
  value: t,
@@ -386,7 +401,7 @@ function rt(e, t, n) {
386
401
  }
387
402
  //#endregion
388
403
  //#region ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
389
- var it = class extends TransformStream {
404
+ var P = class extends TransformStream {
390
405
  constructor({ onError: e, onRetry: t, onComment: n, maxBufferSize: r } = {}) {
391
406
  let i;
392
407
  super({
@@ -410,8 +425,8 @@ var it = class extends TransformStream {
410
425
  }
411
426
  };
412
427
  new TextDecoder();
413
- var { btoa: at, atob: ot } = globalThis;
414
- function P(e) {
428
+ var { btoa: it, atob: at } = globalThis;
429
+ function ot(e) {
415
430
  if (e == null) return {};
416
431
  let t = {};
417
432
  if (e instanceof Headers) e.forEach((e, n) => {
@@ -436,15 +451,15 @@ var F = ({ prefix: e, size: t = 16, alphabet: n = "0123456789ABCDEFGHIJKLMNOPQRS
436
451
  });
437
452
  return () => `${e}${r}${i()}`;
438
453
  }, st = F();
439
- function I(e) {
454
+ function ct(e) {
440
455
  return globalThis.Buffer?.isBuffer(e) ?? !1;
441
456
  }
442
- var ct = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, L = /"(?: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*:/;
443
- function lt(e) {
457
+ var lt = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/, I = /"(?: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*:/;
458
+ function ut(e) {
444
459
  let t = JSON.parse(e);
445
- return typeof t != "object" || !t || ct.test(e) === !1 && L.test(e) === !1 ? t : ut(t);
460
+ return typeof t != "object" || !t || lt.test(e) === !1 && I.test(e) === !1 ? t : L(t);
446
461
  }
447
- function ut(e) {
462
+ function L(e) {
448
463
  let t = [e];
449
464
  for (; t.length;) {
450
465
  let e = t;
@@ -459,35 +474,35 @@ function ut(e) {
459
474
  }
460
475
  return e;
461
476
  }
462
- function R(e) {
477
+ function dt(e) {
463
478
  let { stackTraceLimit: t } = Error;
464
479
  try {
465
480
  Error.stackTraceLimit = 0;
466
481
  } catch {
467
- return lt(e);
482
+ return ut(e);
468
483
  }
469
484
  try {
470
- return lt(e);
485
+ return ut(e);
471
486
  } finally {
472
487
  Error.stackTraceLimit = t;
473
488
  }
474
489
  }
475
- function z(e) {
490
+ function ft(e) {
476
491
  if (e.type === "object" || Array.isArray(e.type) && e.type.includes("object")) {
477
492
  let { additionalProperties: t } = e;
478
- e.additionalProperties = t != null && typeof t != "boolean" && B(t);
493
+ e.additionalProperties = t != null && typeof t != "boolean" && R(t);
479
494
  let { properties: n } = e;
480
- if (n != null) for (let e of Object.keys(n)) n[e] = B(n[e]);
495
+ if (n != null) for (let e of Object.keys(n)) n[e] = R(n[e]);
481
496
  }
482
- e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(B) : B(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(B)), e.allOf != null && (e.allOf = e.allOf.map(B)), e.oneOf != null && (e.oneOf = e.oneOf.map(B));
497
+ e.items != null && (e.items = Array.isArray(e.items) ? e.items.map(R) : R(e.items)), e.anyOf != null && (e.anyOf = e.anyOf.map(R)), e.allOf != null && (e.allOf = e.allOf.map(R)), e.oneOf != null && (e.oneOf = e.oneOf.map(R));
483
498
  let { definitions: t } = e;
484
- if (t != null) for (let e of Object.keys(t)) t[e] = B(t[e]);
499
+ if (t != null) for (let e of Object.keys(t)) t[e] = R(t[e]);
485
500
  return e;
486
501
  }
487
- function B(e) {
488
- return typeof e == "boolean" ? e : z(e);
502
+ function R(e) {
503
+ return typeof e == "boolean" ? e : ft(e);
489
504
  }
490
- var dt = Symbol("Let zodToJsonSchema decide on which parser to use"), ft = {
505
+ var pt = Symbol("Let zodToJsonSchema decide on which parser to use"), mt = {
491
506
  name: void 0,
492
507
  $refStrategy: "root",
493
508
  basePath: ["#"],
@@ -507,24 +522,24 @@ var dt = Symbol("Let zodToJsonSchema decide on which parser to use"), ft = {
507
522
  emailStrategy: "format:email",
508
523
  base64Strategy: "contentEncoding:base64",
509
524
  nameStrategy: "ref"
510
- }, pt = (e) => typeof e == "string" ? {
511
- ...ft,
525
+ }, ht = (e) => typeof e == "string" ? {
526
+ ...mt,
512
527
  name: e
513
528
  } : {
514
- ...ft,
529
+ ...mt,
515
530
  ...e
516
531
  };
517
- function V() {
532
+ function z() {
518
533
  return {};
519
534
  }
520
- function mt(e, t) {
535
+ function gt(e, t) {
521
536
  let n = { type: "array" };
522
537
  return e.type?._def && e.type?._def?.typeName !== "ZodAny" && (n.items = J(e.type._def, {
523
538
  ...t,
524
539
  currentPath: [...t.currentPath, "items"]
525
540
  })), 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;
526
541
  }
527
- function ht(e) {
542
+ function _t(e) {
528
543
  let t = {
529
544
  type: "integer",
530
545
  format: "int64"
@@ -541,16 +556,16 @@ function ht(e) {
541
556
  }
542
557
  return t;
543
558
  }
544
- function H() {
559
+ function vt() {
545
560
  return { type: "boolean" };
546
561
  }
547
- function U(e, t) {
562
+ function B(e, t) {
548
563
  return J(e.type._def, t);
549
564
  }
550
- var W = (e, t) => J(e.innerType._def, t);
551
- function gt(e, t, n) {
565
+ var V = (e, t) => J(e.innerType._def, t);
566
+ function H(e, t, n) {
552
567
  let r = n ?? t.dateStrategy;
553
- if (Array.isArray(r)) return { anyOf: r.map((n) => gt(e, t, n)) };
568
+ if (Array.isArray(r)) return { anyOf: r.map((n) => H(e, t, n)) };
554
569
  switch (r) {
555
570
  case "string":
556
571
  case "format:date-time": return {
@@ -561,10 +576,10 @@ function gt(e, t, n) {
561
576
  type: "string",
562
577
  format: "date"
563
578
  };
564
- case "integer": return _t(e);
579
+ case "integer": return U(e);
565
580
  }
566
581
  }
567
- var _t = (e) => {
582
+ var U = (e) => {
568
583
  let t = {
569
584
  type: "integer",
570
585
  format: "unix-time"
@@ -577,23 +592,23 @@ var _t = (e) => {
577
592
  }
578
593
  return t;
579
594
  };
580
- function vt(e, t) {
595
+ function yt(e, t) {
581
596
  return {
582
597
  ...J(e.innerType._def, t),
583
598
  default: e.defaultValue()
584
599
  };
585
600
  }
586
- function yt(e, t) {
587
- return t.effectStrategy === "input" ? J(e.schema._def, t) : V();
601
+ function bt(e, t) {
602
+ return t.effectStrategy === "input" ? J(e.schema._def, t) : z();
588
603
  }
589
- function bt(e) {
604
+ function xt(e) {
590
605
  return {
591
606
  type: "string",
592
607
  enum: Array.from(e.values)
593
608
  };
594
609
  }
595
- var xt = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
596
- function St(e, t) {
610
+ var St = (e) => "type" in e && e.type === "string" ? !1 : "allOf" in e;
611
+ function Ct(e, t) {
597
612
  let n = [J(e.left._def, {
598
613
  ...t,
599
614
  currentPath: [
@@ -610,7 +625,7 @@ function St(e, t) {
610
625
  ]
611
626
  })].filter((e) => !!e), r = [];
612
627
  return n.forEach((e) => {
613
- if (xt(e)) r.push(...e.allOf);
628
+ if (St(e)) r.push(...e.allOf);
614
629
  else {
615
630
  let t = e;
616
631
  if ("additionalProperties" in e && e.additionalProperties === !1) {
@@ -621,19 +636,19 @@ function St(e, t) {
621
636
  }
622
637
  }), r.length ? { allOf: r } : void 0;
623
638
  }
624
- function Ct(e) {
639
+ function wt(e) {
625
640
  let t = typeof e.value;
626
641
  return t !== "bigint" && t !== "number" && t !== "boolean" && t !== "string" ? { type: Array.isArray(e.value) ? "array" : "object" } : {
627
642
  type: t === "bigint" ? "integer" : t,
628
643
  const: e.value
629
644
  };
630
645
  }
631
- var wt = void 0, G = {
646
+ var Tt = void 0, W = {
632
647
  cuid: /^[cC][^\s-]{8,}$/,
633
648
  cuid2: /^[0-9a-z]+$/,
634
649
  ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
635
650
  email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
636
- emoji: () => (wt === void 0 && (wt = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), wt),
651
+ emoji: () => (Tt === void 0 && (Tt = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u")), Tt),
637
652
  uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
638
653
  ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
639
654
  ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
@@ -644,7 +659,7 @@ var wt = void 0, G = {
644
659
  nanoid: /^[a-zA-Z0-9_-]{21}$/,
645
660
  jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
646
661
  };
647
- function Tt(e, t) {
662
+ function Et(e, t) {
648
663
  let n = { type: "string" };
649
664
  if (e.checks) for (let r of e.checks) switch (r.kind) {
650
665
  case "min":
@@ -661,7 +676,7 @@ function Tt(e, t) {
661
676
  case "format:idn-email":
662
677
  K(n, "idn-email", r.message, t);
663
678
  break;
664
- case "pattern:zod": q(n, G.email, r.message, t);
679
+ case "pattern:zod": q(n, W.email, r.message, t);
665
680
  }
666
681
  break;
667
682
  case "url":
@@ -674,16 +689,16 @@ function Tt(e, t) {
674
689
  q(n, r.regex, r.message, t);
675
690
  break;
676
691
  case "cuid":
677
- q(n, G.cuid, r.message, t);
692
+ q(n, W.cuid, r.message, t);
678
693
  break;
679
694
  case "cuid2":
680
- q(n, G.cuid2, r.message, t);
695
+ q(n, W.cuid2, r.message, t);
681
696
  break;
682
697
  case "startsWith":
683
- q(n, RegExp(`^${Et(r.value, t)}`), r.message, t);
698
+ q(n, RegExp(`^${G(r.value, t)}`), r.message, t);
684
699
  break;
685
700
  case "endsWith":
686
- q(n, RegExp(`${Et(r.value, t)}$`), r.message, t);
701
+ q(n, RegExp(`${G(r.value, t)}$`), r.message, t);
687
702
  break;
688
703
  case "datetime":
689
704
  K(n, "date-time", r.message, t);
@@ -701,25 +716,25 @@ function Tt(e, t) {
701
716
  n.minLength = typeof n.minLength == "number" ? Math.max(n.minLength, r.value) : r.value, n.maxLength = typeof n.maxLength == "number" ? Math.min(n.maxLength, r.value) : r.value;
702
717
  break;
703
718
  case "includes":
704
- q(n, RegExp(Et(r.value, t)), r.message, t);
719
+ q(n, RegExp(G(r.value, t)), r.message, t);
705
720
  break;
706
721
  case "ip":
707
722
  r.version !== "v6" && K(n, "ipv4", r.message, t), r.version !== "v4" && K(n, "ipv6", r.message, t);
708
723
  break;
709
724
  case "base64url":
710
- q(n, G.base64url, r.message, t);
725
+ q(n, W.base64url, r.message, t);
711
726
  break;
712
727
  case "jwt":
713
- q(n, G.jwt, r.message, t);
728
+ q(n, W.jwt, r.message, t);
714
729
  break;
715
730
  case "cidr":
716
- r.version !== "v6" && q(n, G.ipv4Cidr, r.message, t), r.version !== "v4" && q(n, G.ipv6Cidr, r.message, t);
731
+ r.version !== "v6" && q(n, W.ipv4Cidr, r.message, t), r.version !== "v4" && q(n, W.ipv6Cidr, r.message, t);
717
732
  break;
718
733
  case "emoji":
719
- q(n, G.emoji(), r.message, t);
734
+ q(n, W.emoji(), r.message, t);
720
735
  break;
721
736
  case "ulid":
722
- q(n, G.ulid, r.message, t);
737
+ q(n, W.ulid, r.message, t);
723
738
  break;
724
739
  case "base64":
725
740
  switch (t.base64Strategy) {
@@ -729,14 +744,14 @@ function Tt(e, t) {
729
744
  case "contentEncoding:base64":
730
745
  n.contentEncoding = "base64";
731
746
  break;
732
- case "pattern:zod": q(n, G.base64, r.message, t);
747
+ case "pattern:zod": q(n, W.base64, r.message, t);
733
748
  }
734
749
  break;
735
- case "nanoid": q(n, G.nanoid, r.message, t);
750
+ case "nanoid": q(n, W.nanoid, r.message, t);
736
751
  }
737
752
  return n;
738
753
  }
739
- function Et(e, t) {
754
+ function G(e, t) {
740
755
  return t.patternStrategy === "escape" ? Ot(e) : e;
741
756
  }
742
757
  var Dt = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
@@ -805,7 +820,7 @@ function At(e, t) {
805
820
  }) ?? t.allowedAdditionalProperties
806
821
  };
807
822
  if (e.keyType?._def.typeName === "ZodString" && e.keyType._def.checks?.length) {
808
- let { type: r, ...i } = Tt(e.keyType._def, t);
823
+ let { type: r, ...i } = Et(e.keyType._def, t);
809
824
  return {
810
825
  ...n,
811
826
  propertyNames: i
@@ -816,7 +831,7 @@ function At(e, t) {
816
831
  propertyNames: { enum: e.keyType._def.values }
817
832
  };
818
833
  if (e.keyType?._def.typeName === "ZodBranded" && e.keyType._def.type._def.typeName === "ZodString" && e.keyType._def.type._def.checks?.length) {
819
- let { type: r, ...i } = U(e.keyType._def, t);
834
+ let { type: r, ...i } = B(e.keyType._def, t);
820
835
  return {
821
836
  ...n,
822
837
  propertyNames: i
@@ -838,7 +853,7 @@ function jt(e, t) {
838
853
  "items",
839
854
  "0"
840
855
  ]
841
- }) || V(), J(e.valueType._def, {
856
+ }) || z(), J(e.valueType._def, {
842
857
  ...t,
843
858
  currentPath: [
844
859
  ...t.currentPath,
@@ -846,7 +861,7 @@ function jt(e, t) {
846
861
  "items",
847
862
  "1"
848
863
  ]
849
- }) || V()],
864
+ }) || z()],
850
865
  minItems: 2,
851
866
  maxItems: 2
852
867
  }
@@ -860,7 +875,7 @@ function Mt(e) {
860
875
  };
861
876
  }
862
877
  function Nt() {
863
- return { not: V() };
878
+ return { not: z() };
864
879
  }
865
880
  function Pt() {
866
881
  return { type: "null" };
@@ -1007,7 +1022,7 @@ var Ut = (e, t) => {
1007
1022
  "1"
1008
1023
  ]
1009
1024
  });
1010
- return n ? { anyOf: [{ not: V() }, n] } : V();
1025
+ return n ? { anyOf: [{ not: z() }, n] } : z();
1011
1026
  }, Wt = (e, t) => {
1012
1027
  if (t.pipeStrategy === "input") return J(e.in._def, t);
1013
1028
  if (t.pipeStrategy === "output") return J(e.out._def, t);
@@ -1073,29 +1088,29 @@ function qt(e, t) {
1073
1088
  };
1074
1089
  }
1075
1090
  function Jt() {
1076
- return { not: V() };
1091
+ return { not: z() };
1077
1092
  }
1078
1093
  function Yt() {
1079
- return V();
1094
+ return z();
1080
1095
  }
1081
1096
  var Xt = (e, t) => J(e.innerType._def, t), Zt = (e, t, n) => {
1082
1097
  switch (t) {
1083
- case "ZodString": return Tt(e, n);
1098
+ case "ZodString": return Et(e, n);
1084
1099
  case "ZodNumber": return zt(e);
1085
1100
  case "ZodObject": return Bt(e, n);
1086
- case "ZodBigInt": return ht(e);
1087
- case "ZodBoolean": return H();
1088
- case "ZodDate": return gt(e, n);
1101
+ case "ZodBigInt": return _t(e);
1102
+ case "ZodBoolean": return vt();
1103
+ case "ZodDate": return H(e, n);
1089
1104
  case "ZodUndefined": return Jt();
1090
1105
  case "ZodNull": return Pt();
1091
- case "ZodArray": return mt(e, n);
1106
+ case "ZodArray": return gt(e, n);
1092
1107
  case "ZodUnion":
1093
1108
  case "ZodDiscriminatedUnion": return It(e, n);
1094
- case "ZodIntersection": return St(e, n);
1109
+ case "ZodIntersection": return Ct(e, n);
1095
1110
  case "ZodTuple": return qt(e, n);
1096
1111
  case "ZodRecord": return At(e, n);
1097
- case "ZodLiteral": return Ct(e);
1098
- case "ZodEnum": return bt(e);
1112
+ case "ZodLiteral": return wt(e);
1113
+ case "ZodEnum": return xt(e);
1099
1114
  case "ZodNativeEnum": return Mt(e);
1100
1115
  case "ZodNullable": return Rt(e, n);
1101
1116
  case "ZodOptional": return Ut(e, n);
@@ -1105,13 +1120,13 @@ var Xt = (e, t) => J(e.innerType._def, t), Zt = (e, t, n) => {
1105
1120
  case "ZodPromise": return Gt(e, n);
1106
1121
  case "ZodNaN":
1107
1122
  case "ZodNever": return Nt();
1108
- case "ZodEffects": return yt(e, n);
1109
- case "ZodAny": return V();
1123
+ case "ZodEffects": return bt(e, n);
1124
+ case "ZodAny": return z();
1110
1125
  case "ZodUnknown": return Yt();
1111
- case "ZodDefault": return vt(e, n);
1112
- case "ZodBranded": return U(e, n);
1126
+ case "ZodDefault": return yt(e, n);
1127
+ case "ZodBranded": return B(e, n);
1113
1128
  case "ZodReadonly": return Xt(e, n);
1114
- case "ZodCatch": return W(e, n);
1129
+ case "ZodCatch": return V(e, n);
1115
1130
  case "ZodPipeline": return Wt(e, n);
1116
1131
  case "ZodFunction":
1117
1132
  case "ZodVoid":
@@ -1129,7 +1144,7 @@ function J(e, t, n = !1) {
1129
1144
  let r = t.seen.get(e);
1130
1145
  if (t.override) {
1131
1146
  let i = t.override?.(e, t, r, n);
1132
- if (i !== dt) return i;
1147
+ if (i !== pt) return i;
1133
1148
  }
1134
1149
  if (r && !n) {
1135
1150
  let e = $t(r, t);
@@ -1153,10 +1168,10 @@ var $t = (e, t) => {
1153
1168
  case "root": return { $ref: e.path.join("/") };
1154
1169
  case "relative": return { $ref: Qt(t.currentPath, e.path) };
1155
1170
  case "none":
1156
- 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`), V()) : t.$refStrategy === "seen" ? V() : void 0;
1171
+ 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`), z()) : t.$refStrategy === "seen" ? z() : void 0;
1157
1172
  }
1158
1173
  }, en = (e, t, n) => (e.description && (n.description = e.description), n), tn = (e) => {
1159
- let t = pt(e), n = t.name === void 0 ? t.basePath : [
1174
+ let t = ht(e), n = t.name === void 0 ? t.basePath : [
1160
1175
  ...t.basePath,
1161
1176
  t.definitionPath,
1162
1177
  t.name
@@ -1185,7 +1200,7 @@ var $t = (e, t) => {
1185
1200
  n.definitionPath,
1186
1201
  t
1187
1202
  ]
1188
- }, !0) ?? V()
1203
+ }, !0) ?? z()
1189
1204
  }), {}) : void 0, i = typeof t == "string" ? t : t?.nameStrategy === "title" ? void 0 : t?.name, a = J(e._def, i === void 0 ? n : {
1190
1205
  ...n,
1191
1206
  currentPath: [
@@ -1193,7 +1208,7 @@ var $t = (e, t) => {
1193
1208
  n.definitionPath,
1194
1209
  i
1195
1210
  ]
1196
- }, !1) ?? V(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1211
+ }, !1) ?? z(), o = typeof t == "object" && t.name !== void 0 && t.nameStrategy === "title" ? t.name : void 0;
1197
1212
  o !== void 0 && (a.title = o);
1198
1213
  let s = i === void 0 ? r ? {
1199
1214
  ...a,
@@ -1238,7 +1253,7 @@ function cn(e) {
1238
1253
  function ln(e) {
1239
1254
  return on(() => {
1240
1255
  if (!un(e)) throw Error(`Standard schema vendor '${e["~standard"].vendor}' does not support JSON Schema conversion.`);
1241
- return z(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1256
+ return ft(e["~standard"].jsonSchema.input({ target: "draft-07" }));
1242
1257
  }, { validate: async (t) => {
1243
1258
  let n = await e["~standard"].validate(t);
1244
1259
  return "value" in n ? {
@@ -1246,7 +1261,7 @@ function ln(e) {
1246
1261
  value: n.value
1247
1262
  } : {
1248
1263
  success: !1,
1249
- error: new Xe({
1264
+ error: new A({
1250
1265
  value: t,
1251
1266
  cause: n.issues
1252
1267
  })
@@ -1271,7 +1286,7 @@ function dn(e, t) {
1271
1286
  }
1272
1287
  function fn(e, r) {
1273
1288
  let i = r?.useReferences ?? !1;
1274
- return on(() => z(n(e, {
1289
+ return on(() => ft(n(e, {
1275
1290
  target: "draft-7",
1276
1291
  io: "input",
1277
1292
  reused: i ? "ref" : "inline"
@@ -1298,7 +1313,7 @@ async function hn({ value: e, schema: t, context: n }) {
1298
1313
  schema: t,
1299
1314
  context: n
1300
1315
  });
1301
- if (!r.success) throw Xe.wrap({
1316
+ if (!r.success) throw A.wrap({
1302
1317
  value: e,
1303
1318
  cause: r.error,
1304
1319
  context: n
@@ -1320,7 +1335,7 @@ async function gn({ value: e, schema: t, context: n }) {
1320
1335
  rawValue: e
1321
1336
  } : {
1322
1337
  success: !1,
1323
- error: Xe.wrap({
1338
+ error: A.wrap({
1324
1339
  value: e,
1325
1340
  cause: t.error,
1326
1341
  context: n
@@ -1330,7 +1345,7 @@ async function gn({ value: e, schema: t, context: n }) {
1330
1345
  } catch (t) {
1331
1346
  return {
1332
1347
  success: !1,
1333
- error: Xe.wrap({
1348
+ error: A.wrap({
1334
1349
  value: e,
1335
1350
  cause: t,
1336
1351
  context: n
@@ -1341,7 +1356,7 @@ async function gn({ value: e, schema: t, context: n }) {
1341
1356
  }
1342
1357
  async function _n({ text: e, schema: t }) {
1343
1358
  try {
1344
- let n = R(e);
1359
+ let n = dt(e);
1345
1360
  return t == null ? {
1346
1361
  success: !0,
1347
1362
  value: n,
@@ -1353,7 +1368,7 @@ async function _n({ text: e, schema: t }) {
1353
1368
  } catch (t) {
1354
1369
  return {
1355
1370
  success: !1,
1356
- error: qe.isInstance(t) ? t : new qe({
1371
+ error: Ke.isInstance(t) ? t : new Ke({
1357
1372
  text: e,
1358
1373
  cause: t
1359
1374
  }),
@@ -1362,7 +1377,7 @@ async function _n({ text: e, schema: t }) {
1362
1377
  }
1363
1378
  }
1364
1379
  function vn({ stream: e, schema: t }) {
1365
- return e.pipeThrough(new TextDecoderStream()).pipeThrough(new it()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1380
+ return e.pipeThrough(new TextDecoderStream()).pipeThrough(new P()).pipeThrough(new TransformStream({ async transform({ data: e }, n) {
1366
1381
  e !== "[DONE]" && n.enqueue(await _n({
1367
1382
  text: e,
1368
1383
  schema: t
@@ -1438,7 +1453,7 @@ var Y = {
1438
1453
  Y.string(),
1439
1454
  Y.instanceof(Uint8Array),
1440
1455
  Y.instanceof(ArrayBuffer),
1441
- Y.custom(I, { message: "Must be a Buffer" })
1456
+ Y.custom(ct, { message: "Must be a Buffer" })
1442
1457
  ]), An = Y.record(Y.string(), Y.string()), jn = Y.object({
1443
1458
  type: Y.literal("text"),
1444
1459
  text: Y.string(),
@@ -2668,7 +2683,7 @@ F({
2668
2683
  });
2669
2684
  async function ur({ response: e, url: t, fallbackMessage: n }) {
2670
2685
  let r = await e.text();
2671
- return new Ie({
2686
+ return new T({
2672
2687
  message: r || n,
2673
2688
  url: t,
2674
2689
  requestBodyValues: void 0,
@@ -2678,7 +2693,7 @@ async function ur({ response: e, url: t, fallbackMessage: n }) {
2678
2693
  }
2679
2694
  async function dr(e) {
2680
2695
  if (e == null) return [];
2681
- if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new $e({
2696
+ if (!globalThis.FileList || !(e instanceof globalThis.FileList)) throw new Ze({
2682
2697
  functionality: "FileList",
2683
2698
  message: "FileList is not supported in the current environment"
2684
2699
  });
@@ -2707,8 +2722,8 @@ var pr = class {
2707
2722
  }
2708
2723
  async sendMessages({ abortSignal: e, ...t }) {
2709
2724
  let n = await yn(this.body), r = await yn(this.headers), i = await yn(this.credentials), a = {
2710
- ...P(r),
2711
- ...P(t.headers)
2725
+ ...ot(r),
2726
+ ...ot(t.headers)
2712
2727
  }, o = await this.prepareSendMessagesRequest?.({
2713
2728
  api: this.api,
2714
2729
  id: t.chatId,
@@ -2722,7 +2737,7 @@ var pr = class {
2722
2737
  requestMetadata: t.metadata,
2723
2738
  trigger: t.trigger,
2724
2739
  messageId: t.messageId
2725
- }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : P(o.headers), l = o?.body === void 0 ? {
2740
+ }), s = o?.api ?? this.api, c = o?.headers === void 0 ? a : ot(o.headers), l = o?.body === void 0 ? {
2726
2741
  ...n,
2727
2742
  ...t.body,
2728
2743
  id: t.chatId,
@@ -2744,13 +2759,13 @@ var pr = class {
2744
2759
  url: s,
2745
2760
  fallbackMessage: "Failed to fetch the chat response."
2746
2761
  });
2747
- if (!d.body) throw new Re({ message: "The response body is empty." });
2762
+ if (!d.body) throw new D({ message: "The response body is empty." });
2748
2763
  return this.processResponseStream(d.body);
2749
2764
  }
2750
2765
  async reconnectToStream(e) {
2751
2766
  let t = await yn(this.body), n = await yn(this.headers), r = await yn(this.credentials), i = {
2752
- ...P(n),
2753
- ...P(e.headers)
2767
+ ...ot(n),
2768
+ ...ot(e.headers)
2754
2769
  }, a = await this.prepareReconnectToStreamRequest?.({
2755
2770
  api: this.api,
2756
2771
  id: e.chatId,
@@ -2770,7 +2785,7 @@ var pr = class {
2770
2785
  });
2771
2786
  o = fr(this.api, `/${encodeURIComponent(e.chatId)}/stream`);
2772
2787
  }
2773
- let s = a?.headers === void 0 ? i : P(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2788
+ let s = a?.headers === void 0 ? i : ot(a.headers), c = a?.credentials ?? r, l = await (this.fetch ?? globalThis.fetch)(o, {
2774
2789
  method: "GET",
2775
2790
  headers: s,
2776
2791
  credentials: c,
@@ -2782,7 +2797,7 @@ var pr = class {
2782
2797
  url: o,
2783
2798
  fallbackMessage: "Failed to fetch the chat response."
2784
2799
  });
2785
- if (!l.body) throw new Re({ message: "The response body is empty." });
2800
+ if (!l.body) throw new D({ message: "The response body is empty." });
2786
2801
  return this.processResponseStream(l.body);
2787
2802
  }
2788
2803
  }, mr = class extends pr {
@@ -3638,36 +3653,36 @@ var Gr = "voice-", Kr = (e) => e?.role === "assistant" && e.parts.some((e) => e.
3638
3653
  }, ei = ({ messages: e }) => {
3639
3654
  let t = e[e.length - 1];
3640
3655
  if (!t || t.role !== "assistant") return !1;
3641
- 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 && (te($r(e)) || ie(e)));
3656
+ 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 && (te($r(e)) || oe(e)));
3642
3657
  return r.length > 0 && r.every((e) => se.has(e.state ?? ""));
3643
3658
  };
3644
3659
  function ti(e) {
3645
3660
  return we(`chatbot-${e}`, () => {
3646
- 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(), te = x(), ae = x(), oe = x(), se = S(), me = x(0), he = x(), _e = S(), ye = S(), be = x(), we = x(!1), Oe = x(0), Me = x(), Ne = x(!1), w = Ce(), Pe = b(() => {
3661
+ 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(), te = x(), ie = x(), ae = x(), se = x(), me = S(), he = x(0), _e = x(), ye = S(), be = S(), we = x(), Oe = x({}), Me = x(!1), Ne = x(0), w = x(), Pe = x(!1), Fe = Ce(), Ie = b(() => {
3647
3662
  let e = u.value?.theme;
3648
- return (!e || e === "auto") && (e = Me.value), e ? e === "dark" : w.value;
3649
- }), T = b(() => c.value === "reasoning"), Fe = b(() => T.value ? g.value?.filter((e) => ![
3663
+ return (!e || e === "auto") && (e = w.value), e ? e === "dark" : Fe.value;
3664
+ }), T = b(() => c.value === "reasoning"), Le = b(() => T.value ? g.value?.filter((e) => ![
3650
3665
  "upvote",
3651
3666
  "downvote",
3652
3667
  "feedback"
3653
- ].includes(e)) : g.value), Ie = pe(b(() => `${o.value}-chatId`), null);
3668
+ ].includes(e)) : g.value), Re = pe(b(() => `${o.value}-chatId`), null);
3654
3669
  xe(() => {
3655
- Ie.value ||= st();
3670
+ Re.value ||= st();
3656
3671
  });
3657
3672
  let E = b({
3658
- get: () => Ie.value,
3673
+ get: () => Re.value,
3659
3674
  set: (e) => {
3660
- Ie.value = e;
3675
+ Re.value = e;
3661
3676
  }
3662
- }), D = fe(b(() => `${o.value}-pageAccessOff`), !1), Le = b(() => D.value ? [] : _e.value ?? []), Re = () => D.value ? [] : ye.value?.() ?? [], ze = b(() => !!(he.value && _e.value?.length)), Be = pe(b(() => `${o.value}-pageNotice`), null), Ve = b(() => {
3663
- let e = he.value?.level;
3664
- return e && e !== re.Off && Le.value.length && !ee(Be.value ?? void 0, e) ? e : void 0;
3677
+ }), D = fe(b(() => `${o.value}-pageAccessOff`), !1), ze = b(() => D.value ? [] : ye.value ?? []), Be = () => D.value ? [] : be.value?.() ?? [], Ve = b(() => !!(_e.value && ye.value?.length)), He = pe(b(() => `${o.value}-pageNotice`), null), Ue = b(() => {
3678
+ let e = _e.value?.level;
3679
+ return e && e !== ee.Off && ze.value.length && !y(He.value ?? void 0, e) ? e : void 0;
3665
3680
  });
3666
- function He() {
3667
- Be.value = he.value?.level ?? null;
3681
+ function We() {
3682
+ He.value = _e.value?.level ?? null;
3668
3683
  }
3669
- let Ue = x(), We = x(!1), Ge = b(() => Ue.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3670
- function Ke(e) {
3684
+ let O = x(), Ge = x(!1), Ke = b(() => O.value?.message?.toLowerCase().includes("conversation-blocked") ?? !1);
3685
+ function qe(e) {
3671
3686
  try {
3672
3687
  let t = JSON.parse(e.message);
3673
3688
  return t.status === 404 || t.type?.includes("entity-not-found");
@@ -3675,79 +3690,88 @@ function ti(e) {
3675
3690
  return !1;
3676
3691
  }
3677
3692
  }
3678
- function qe(e) {
3679
- if (Ke(e)) {
3680
- let e = N.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? de(t) : void 0;
3681
- E.value = st(), Ue.value = void 0, ge(() => {
3682
- N.value.clearError(), n && N.value.sendMessage({ text: n });
3693
+ function Je(e) {
3694
+ if (qe(e)) {
3695
+ let e = P.value.messages.filter((e) => e.role === "user"), t = e[e.length - 1], n = t ? de(t) : void 0;
3696
+ E.value = st(), O.value = void 0, ge(() => {
3697
+ P.value.clearError(), n && P.value.sendMessage({ text: n });
3683
3698
  });
3684
- } else le.error(e), Ue.value = e, Ge.value && (We.value = !0);
3699
+ } else le.error(e), O.value = e, Ke.value && (Ge.value = !0);
3685
3700
  }
3686
- let O = b(() => ce({
3701
+ let k = b(() => ce({
3687
3702
  baseUrl: i.value,
3688
3703
  basePath: a.value,
3689
3704
  headers: () => p.value
3690
- })), Je = x(null), Ye = () => ({
3705
+ })), A = x(null), Ye = () => ({
3691
3706
  ...Te(),
3692
- ...Je.value ?? {}
3707
+ ...A.value ?? {}
3693
3708
  }), Xe = () => {
3694
- let e = Oe.value;
3709
+ let e = Ne.value;
3695
3710
  return new Promise((t) => {
3696
3711
  let n = setTimeout(() => {
3697
3712
  r(), t(!1);
3698
- }, 3e4), r = C(() => [Oe.value, N.value.status], ([i, a]) => {
3713
+ }, 3e4), r = C(() => [Ne.value, P.value.status], ([i, a]) => {
3699
3714
  i > e && a === "streaming" && (clearTimeout(n), r(), t(!0));
3700
3715
  });
3701
3716
  });
3702
- }, k = S(), Ze = (e, t) => new Promise((n) => {
3703
- k.value?.answer(!1), k.value = {
3717
+ }, j = S(), Ze = (e, t) => new Promise((n) => {
3718
+ j.value?.answer(!1), j.value = {
3704
3719
  toolCallId: e.toolCallId,
3705
- question: t,
3720
+ question: t?.question,
3721
+ details: t?.details,
3706
3722
  answer: (e) => {
3707
- k.value = void 0, n(e);
3723
+ j.value = void 0, n(e);
3708
3724
  }
3709
3725
  };
3710
3726
  });
3711
3727
  function Qe(e) {
3712
- k.value?.answer(e);
3728
+ j.value?.answer(e);
3713
3729
  }
3714
3730
  let $e = je({
3715
3731
  registry: () => [
3716
- ...(se.value ?? []).filter((e) => !ne(e.name)),
3717
- ...Le.value,
3718
- ...Re()
3732
+ ...(me.value ?? []).filter((e) => !re(e.name)),
3733
+ ...ze.value,
3734
+ ...Be()
3719
3735
  ],
3720
- capability: () => oe.value,
3721
- addToolOutput: (e) => void N.value.addToolOutput(e),
3736
+ capability: () => se.value,
3737
+ addToolOutput: (e) => void P.value.addToolOutput(e),
3722
3738
  confirm: Ze,
3723
3739
  waitForResume: Xe,
3724
3740
  onPendingChange: (e) => {
3725
- me.value = e;
3741
+ he.value = e;
3726
3742
  },
3727
3743
  onActivity: (e) => {
3728
- if (e?.provider !== "page" || e.readOnly) {
3729
- be.value = void 0;
3744
+ if (e?.provider !== "page") {
3745
+ we.value = void 0;
3730
3746
  return;
3731
3747
  }
3732
- let t = [...Le.value, ...Re()].find((t) => t.name === e.toolName);
3733
- be.value = { title: t?.annotations?.title ?? e.toolName }, we.value = !0;
3748
+ let t = [...ze.value, ...Be()].find((t) => t.name === e.toolName), n;
3749
+ try {
3750
+ n = t?.describe?.(e.input);
3751
+ } catch {
3752
+ n = void 0;
3753
+ }
3754
+ n && (Oe.value = {
3755
+ ...Oe.value,
3756
+ [e.toolCallId]: n
3757
+ }), e.readOnly ? we.value = void 0 : (we.value = { title: n ?? t?.annotations?.title ?? e.toolName }, Me.value = !0);
3734
3758
  }
3735
3759
  });
3736
3760
  async function et() {
3737
- A(), be.value = void 0, we.value = !1, U.value = "", await N.value.stop();
3761
+ M(), we.value = void 0, Me.value = !1, H.value = "", await P.value.stop();
3738
3762
  }
3739
- function A() {
3740
- $e.cancelAll(), k.value?.answer(!1);
3763
+ function M() {
3764
+ $e.cancelAll(), j.value?.answer(!1);
3741
3765
  }
3742
3766
  async function tt(e) {
3743
3767
  D.value = e, e && await et();
3744
3768
  }
3745
- C(E, () => A(), { flush: "sync" });
3746
- let j = !1, M, nt = Wr(() => ({
3769
+ C(E, () => M(), { flush: "sync" });
3770
+ let nt = !1, N, rt = Wr(() => ({
3747
3771
  id: E.value,
3748
3772
  transport: new mr({
3749
- api: O.value.getChatEndpoint(o.value, T.value ? "reasoning" : "chat"),
3750
- prepareReconnectToStreamRequest: ({ id: e }) => ({ api: O.value.getChatStreamEndpoint(o.value, e) }),
3773
+ api: k.value.getChatEndpoint(o.value, T.value ? "reasoning" : "chat"),
3774
+ prepareReconnectToStreamRequest: ({ id: e }) => ({ api: k.value.getChatStreamEndpoint(o.value, e) }),
3751
3775
  prepareSendMessagesRequest: ({ messages: e, id: t }) => ({ body: {
3752
3776
  id: t,
3753
3777
  messages: [e[e.length - 1]],
@@ -3765,12 +3789,13 @@ function ti(e) {
3765
3789
  deviceContext: Ye(),
3766
3790
  externalContext: ae.value,
3767
3791
  disabledTools: f.value?.disabled,
3768
- fallbackModels: y.value,
3769
- gatewayOptions: te.value,
3770
- hostTools: Ae(se.value, oe.value),
3771
- pageTools: he.value && Le.value.length ? {
3792
+ fallbackModels: te.value,
3793
+ gatewayOptions: ie.value,
3794
+ hostTools: Ae(me.value, se.value),
3795
+ pageTools: _e.value && ze.value.length ? {
3772
3796
  version: 1,
3773
- forms: Re().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3797
+ features: [...ne],
3798
+ forms: Be().map(({ name: e, description: t, inputSchema: n, annotations: r }) => ({
3774
3799
  name: e,
3775
3800
  description: t,
3776
3801
  inputSchema: n,
@@ -3783,42 +3808,42 @@ function ti(e) {
3783
3808
  }),
3784
3809
  sendAutomaticallyWhen: (e) => ei(e) || gr(e),
3785
3810
  onError: (e) => {
3786
- j ? le.warn(e) : qe(e);
3811
+ nt ? le.warn(e) : Je(e);
3787
3812
  },
3788
3813
  onToolCall: ({ toolCall: e }) => {
3789
- if (!ke(e) || j) return;
3814
+ if (!ke(e) || nt) return;
3790
3815
  let t = e;
3791
3816
  $e.enqueue({
3792
3817
  toolCallId: t.toolCallId,
3793
3818
  toolName: t.toolName,
3794
3819
  input: t.input,
3795
- messageId: rt()?.id ?? "",
3820
+ messageId: it()?.id ?? "",
3796
3821
  readOnly: t.toolMetadata?.readOnly === !0,
3797
3822
  provider: t.toolMetadata?.provider === "page" ? "page" : "app"
3798
3823
  });
3799
3824
  },
3800
3825
  onData: (e) => {
3801
- e.type === "data-audioTranscripts" && (N.value.messages = ue(N.value.messages, e.data));
3826
+ e.type === "data-audioTranscripts" && (P.value.messages = ue(P.value.messages, e.data));
3802
3827
  },
3803
3828
  onFinish: () => {
3804
3829
  let e = E.value;
3805
- !T.value && !I.value.some((t) => t.id === e) && gt(o.value);
3830
+ !T.value && !I.value.some((t) => t.id === e) && yt(o.value);
3806
3831
  }
3807
- })), N = b(() => ve(nt)), rt = () => N.value.messages[N.value.messages.length - 1];
3832
+ })), P = b(() => ve(rt)), it = () => P.value.messages[P.value.messages.length - 1];
3808
3833
  C(E, () => {
3809
- N.value.stop();
3834
+ P.value.stop();
3810
3835
  }, { flush: "sync" });
3811
- let it = b(() => {
3836
+ let at = b(() => {
3812
3837
  let e = u.value?.initialMessage;
3813
3838
  return e?.[r.value] ? e[r.value] : n("message.defaultAgentWelcome") ? t("message.defaultAgentWelcome") : "";
3814
- }), at = st(), ot = b(() => ({
3815
- id: at,
3839
+ }), ot = st(), F = b(() => ({
3840
+ id: ot,
3816
3841
  role: "assistant",
3817
3842
  parts: [{
3818
3843
  type: "text",
3819
- text: it.value
3844
+ text: at.value
3820
3845
  }]
3821
- })), P = b(() => {
3846
+ })), ct = b(() => {
3822
3847
  let e = (e) => e.map((e) => e.role !== "user" || !e.parts.some((e) => e.type === "file") ? e : {
3823
3848
  ...e,
3824
3849
  parts: e.parts.map((e) => {
@@ -3828,95 +3853,95 @@ function ti(e) {
3828
3853
  let e = t.url.slice(13);
3829
3854
  return {
3830
3855
  ...t,
3831
- url: O.value.getMediaUrl(o.value, E.value, e)
3856
+ url: k.value.getMediaUrl(o.value, E.value, e)
3832
3857
  };
3833
3858
  }
3834
3859
  return t.url.startsWith("blob:") ? t : {
3835
3860
  ...t,
3836
- url: O.value.appendAuthToken(t.url)
3861
+ url: k.value.appendAuthToken(t.url)
3837
3862
  };
3838
3863
  })
3839
- }), t = N.value.id === E.value ? N.value.messages : [];
3840
- return T.value ? e(t) : !Ne.value && t[0]?.role !== "assistant" ? [ot.value, ...e(t)] : e(t);
3841
- }), F = b(() => {
3864
+ }), t = P.value.id === E.value ? P.value.messages : [];
3865
+ return T.value ? e(t) : !Pe.value && t[0]?.role !== "assistant" ? [F.value, ...e(t)] : e(t);
3866
+ }), lt = b(() => {
3842
3867
  let e = u.value?.messagePlaceholder;
3843
3868
  return e?.[r.value] ? e[r.value] : n("placeholder.askAnything") ? t("placeholder.askAnything") : "";
3844
- }), I = x([]), ct = x(!1), L = x([]), lt = x(!1), ut = x("chat"), R = x([]), z = x(), B = x(!1), dt = x(!1), ft = x(), pt = x(!1), V = x(!1), mt = x(), ht = x(""), H = x([]), U = x(""), W = x(0);
3845
- async function gt(e) {
3869
+ }), I = x([]), ut = x(!1), L = x([]), dt = x(!1), ft = x("chat"), R = x([]), pt = x(), mt = x(!1), ht = x(!1), z = x(), gt = x(!1), _t = x(!1), vt = x(), B = x(""), V = x([]), H = x(""), U = x(0);
3870
+ async function yt(e) {
3846
3871
  if (T.value) I.value = [];
3847
3872
  else {
3848
- ct.value = !0;
3873
+ ut.value = !0;
3849
3874
  try {
3850
- I.value = await O.value.getConversations(e, l.value);
3875
+ I.value = await k.value.getConversations(e, l.value);
3851
3876
  } catch {
3852
3877
  I.value = [];
3853
3878
  } finally {
3854
- ct.value = !1;
3879
+ ut.value = !1;
3855
3880
  }
3856
3881
  }
3857
3882
  }
3858
- async function _t() {
3883
+ async function bt() {
3859
3884
  let e = E.value;
3860
3885
  if (!e) L.value = [];
3861
3886
  else {
3862
- lt.value = !0;
3887
+ dt.value = !0;
3863
3888
  try {
3864
- L.value = await O.value.getChatFiles(e);
3889
+ L.value = await k.value.getChatFiles(e);
3865
3890
  } catch {
3866
3891
  L.value = [];
3867
3892
  } finally {
3868
- lt.value = !1;
3893
+ dt.value = !1;
3869
3894
  }
3870
3895
  }
3871
3896
  }
3872
- function vt(e, t = !1) {
3873
- return O.value.getChatFileDownloadUrl(e, t);
3897
+ function xt(e, t = !1) {
3898
+ return k.value.getChatFileDownloadUrl(e, t);
3874
3899
  }
3875
- function yt(e) {
3876
- return O.value.getChatFilePreviewUrl(e);
3900
+ function St(e) {
3901
+ return k.value.getChatFilePreviewUrl(e);
3877
3902
  }
3878
- async function bt(e) {
3879
- await O.value.deleteChatFile(e);
3903
+ async function Ct(e) {
3904
+ await k.value.deleteChatFile(e);
3880
3905
  let t = L.value.find((t) => t.documentId === e), n = t?.kind === "spreadsheet" ? t.sourceAttachmentId ?? t.documentId : void 0;
3881
3906
  L.value = L.value.filter((t) => t.documentId !== e && (!n || t.documentId !== n && t.sourceAttachmentId !== n));
3882
3907
  }
3883
- async function xt(e, t) {
3908
+ async function wt(e, t) {
3884
3909
  if (!T.value) try {
3885
- let n = await O.value.getChat(e, t);
3886
- if (t !== E.value || N.value.status !== "ready" || N.value.messages.length > 0) return;
3887
- n && (N.value.messages = n.messages, We.value = n.blocked ?? !1, St(e, t, n.turnInProgress === !0));
3910
+ let n = await k.value.getChat(e, t);
3911
+ if (t !== E.value || P.value.status !== "ready" || P.value.messages.length > 0) return;
3912
+ n && (P.value.messages = n.messages, Ge.value = n.blocked ?? !1, Tt(e, t, n.turnInProgress === !0));
3888
3913
  } catch {}
3889
3914
  }
3890
- async function St(e, t, n) {
3891
- n && (await Ct(t), t !== E.value || G()) || await wt(e, t);
3915
+ async function Tt(e, t, n) {
3916
+ n && (await W(t), t !== E.value || G()) || await Et(e, t);
3892
3917
  }
3893
- async function Ct(e) {
3918
+ async function W(e) {
3894
3919
  let t = { chatId: e };
3895
- M = t;
3896
- let n = () => M === t && e === E.value, r = Date.now() + Zr;
3920
+ N = t;
3921
+ let n = () => N === t && e === E.value, r = Date.now() + Zr;
3897
3922
  try {
3898
3923
  for (; n() && !G() && Date.now() < r;) {
3899
- j = !0;
3924
+ nt = !0;
3900
3925
  try {
3901
- await N.value.resumeStream();
3926
+ await P.value.resumeStream();
3902
3927
  } finally {
3903
- j = !1;
3928
+ nt = !1;
3904
3929
  }
3905
3930
  if (!n()) return;
3906
- N.value.clearError();
3907
- let t = await O.value.getChat(o.value, e).catch(() => null);
3931
+ P.value.clearError();
3932
+ let t = await k.value.getChat(o.value, e).catch(() => null);
3908
3933
  if (!t || !n() || G()) return;
3909
3934
  if (!t.turnInProgress) {
3910
- N.value.messages = t.messages;
3935
+ P.value.messages = t.messages;
3911
3936
  return;
3912
3937
  }
3913
3938
  await new Promise((e) => setTimeout(e, Qr));
3914
3939
  }
3915
3940
  } finally {
3916
- M === t && (M = void 0);
3941
+ N === t && (N = void 0);
3917
3942
  }
3918
3943
  }
3919
- async function wt(e, t) {
3944
+ async function Et(e, t) {
3920
3945
  let n;
3921
3946
  try {
3922
3947
  n = Number(sessionStorage.getItem(De)), sessionStorage.removeItem(De);
@@ -3924,9 +3949,9 @@ function ti(e) {
3924
3949
  return;
3925
3950
  }
3926
3951
  if (!(!n || Date.now() - n > 6e4 || D.value)) for (let n = 0; n < 12; n++) {
3927
- let n = N.value.messages[N.value.messages.length - 1];
3952
+ let n = P.value.messages[P.value.messages.length - 1];
3928
3953
  if (n?.role === "assistant") {
3929
- let e = n.parts.filter((e) => ie(e) && e.state === "input-available"), t = e.filter((e) => e.toolMetadata?.provider === "page" && e.toolMetadata.readOnly === !0);
3954
+ let e = n.parts.filter((e) => oe(e) && e.state === "input-available"), t = e.filter((e) => e.toolMetadata?.provider === "page" && e.toolMetadata.readOnly === !0);
3930
3955
  if (e.length > 0) {
3931
3956
  if (t.length === e.length && !D.value) for (let e of t) $e.enqueue({
3932
3957
  toolCallId: e.toolCallId,
@@ -3940,151 +3965,151 @@ function ti(e) {
3940
3965
  }
3941
3966
  if (n.parts[n.parts.length - 1]?.type === "text") return;
3942
3967
  }
3943
- if (await new Promise((e) => setTimeout(e, 1500)), t !== E.value || N.value.status !== "ready") return;
3968
+ if (await new Promise((e) => setTimeout(e, 1500)), t !== E.value || P.value.status !== "ready") return;
3944
3969
  try {
3945
- let n = await O.value.getChat(e, t);
3946
- n && t === E.value && (N.value.messages = n.messages);
3970
+ let n = await k.value.getChat(e, t);
3971
+ n && t === E.value && (P.value.messages = n.messages);
3947
3972
  } catch {
3948
3973
  return;
3949
3974
  }
3950
3975
  }
3951
3976
  }
3952
3977
  let G = () => {
3953
- let e = N.value.status;
3978
+ let e = P.value.status;
3954
3979
  return e === "submitted" || e === "streaming";
3955
- }, Tt = 0, Et = 0;
3956
- async function Dt() {
3980
+ }, Dt = 0, Ot = 0;
3981
+ async function K() {
3957
3982
  if (T.value || G()) return "indeterminate";
3958
- let e = E.value, t = Tt += 1;
3983
+ let e = E.value, t = Dt += 1;
3959
3984
  try {
3960
- let n = await O.value.getChat(o.value, e);
3961
- if (!n || e !== E.value || G() || t <= Et) return "indeterminate";
3962
- Et = t;
3963
- let r = n.messages, i = Xr(r, N.value.messages);
3964
- return N.value.messages = [...r, ...i], We.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
3985
+ let n = await k.value.getChat(o.value, e);
3986
+ if (!n || e !== E.value || G() || t <= Ot) return "indeterminate";
3987
+ Ot = t;
3988
+ let r = n.messages, i = Xr(r, P.value.messages);
3989
+ return P.value.messages = [...r, ...i], Ge.value = n.blocked ?? !1, i.length > 0 ? "pending" : "caught-up";
3965
3990
  } catch {}
3966
3991
  return "indeterminate";
3967
3992
  }
3968
- function Ot(e) {
3969
- N.value.messages = [...N.value.messages, e];
3993
+ function q(e) {
3994
+ P.value.messages = [...P.value.messages, e];
3970
3995
  }
3971
- async function K(e) {
3996
+ async function kt(e) {
3972
3997
  try {
3973
- R.value = await O.value.getMessageFeedbacks(e);
3998
+ R.value = await k.value.getMessageFeedbacks(e);
3974
3999
  } catch {
3975
4000
  R.value = [];
3976
4001
  }
3977
4002
  }
3978
- function q(e) {
4003
+ function At(e) {
3979
4004
  let t = R.value.findIndex((t) => t.messageId === e.messageId);
3980
4005
  t >= 0 ? R.value[t] = e : R.value.push(e);
3981
4006
  }
3982
- function kt(e) {
3983
- let t = P.value, n = t.findIndex((t) => t.id === e.id), r = de(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
4007
+ function jt(e) {
4008
+ let t = ct.value, n = t.findIndex((t) => t.id === e.id), r = de(e) ?? "", i = t.slice(0, n).reverse().find((e) => e.role === "user");
3984
4009
  return {
3985
4010
  userQuestion: de(i ?? e) ?? "",
3986
4011
  assistantMessage: r
3987
4012
  };
3988
4013
  }
3989
- async function At(e, t) {
4014
+ async function Mt(e, t) {
3990
4015
  await Promise.all([
3991
- xt(e, t),
3992
- gt(e),
3993
- K(t)
3994
- ]), Je.value || Ee((e, t) => O.value.reverseGeocode(e, t, r.value)).then((e) => {
3995
- e && (Je.value = e);
4016
+ wt(e, t),
4017
+ yt(e),
4018
+ kt(t)
4019
+ ]), A.value || Ee((e, t) => k.value.reverseGeocode(e, t, r.value)).then((e) => {
4020
+ e && (A.value = e);
3996
4021
  });
3997
4022
  }
3998
- async function jt() {
3999
- let e = ht.value.trim(), t = H.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4023
+ async function Nt() {
4024
+ let e = B.value.trim(), t = V.value.filter((e) => e.state === "done" && e.mediaSource !== void 0).map((e) => ({
4000
4025
  type: "file",
4001
4026
  mediaType: e.mediaSource.mimeType,
4002
4027
  url: e.localUrl,
4003
4028
  filename: e.mediaSource.name,
4004
4029
  providerMetadata: { "8bot": { media: e.mediaSource } }
4005
4030
  }));
4006
- T.value && P.value.length > 0 && await Rt(), A(), U.value = e, W.value = N.value.messages.length;
4007
- let n = N.value.sendMessage;
4031
+ T.value && ct.value.length > 0 && await Bt(), M(), H.value = e, U.value = P.value.messages.length;
4032
+ let n = P.value.sendMessage;
4008
4033
  n({
4009
4034
  text: e,
4010
4035
  files: t.length > 0 ? t : void 0
4011
- }), ht.value = "", Lt();
4036
+ }), B.value = "", zt();
4012
4037
  }
4013
- function Mt(e) {
4038
+ function Pt(e) {
4014
4039
  let t = e.trim();
4015
4040
  if (!t) return;
4016
- if (N.value.status !== "ready") {
4041
+ if (P.value.status !== "ready") {
4017
4042
  le.warn("[useChatbotStore] sendMessage called before chat is ready. Listen for the \"ready\" event on the widget element.");
4018
4043
  return;
4019
4044
  }
4020
- let n = N.value.sendMessage;
4021
- A(), n({ text: t });
4045
+ let n = P.value.sendMessage;
4046
+ M(), n({ text: t });
4022
4047
  }
4023
- async function Nt() {
4024
- let e = N.value.messages.slice(W.value).some((e) => e.parts.some(ie)), t = U.value, n = t.length > 0 && !e, r = E.value, i = W.value, a = M?.chatId === r;
4025
- M = void 0, A(), await N.value.stop();
4026
- let s = T.value || e && !a || await O.value.stopChatTurn(o.value, r).catch(() => !0);
4027
- r !== E.value || G() || W.value !== i || ((a || !s) && (await Dt(), a || N.value.messages.length > W.value) ? U.value = "" : n && (ht.value = t, N.value.messages = N.value.messages.slice(0, W.value), U.value = ""));
4048
+ async function Ft() {
4049
+ let e = P.value.messages.slice(U.value).some((e) => e.parts.some(oe)), t = H.value, n = t.length > 0 && !e, r = E.value, i = U.value, a = N?.chatId === r;
4050
+ N = void 0, M(), await P.value.stop();
4051
+ let s = T.value || e && !a || await k.value.stopChatTurn(o.value, r).catch(() => !0);
4052
+ r !== E.value || G() || U.value !== i || ((a || !s) && (await K(), a || P.value.messages.length > U.value) ? H.value = "" : n && (B.value = t, P.value.messages = P.value.messages.slice(0, U.value), H.value = ""));
4028
4053
  }
4029
- C(() => N.value.messages, (e) => {
4030
- let t = k.value?.toolCallId;
4031
- t && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && A();
4032
- }), C(() => N.value.status, (e) => {
4033
- e === "submitted" && Oe.value++;
4054
+ C(() => P.value.messages, (e) => {
4055
+ let t = j.value?.toolCallId;
4056
+ t && !e.some((e) => e.parts.some((e) => e.toolCallId === t)) && M();
4057
+ }), C(() => P.value.status, (e) => {
4058
+ e === "submitted" && Ne.value++;
4034
4059
  });
4035
- let Pt;
4036
- C(() => [N.value.status, me.value], ([e, t]) => {
4037
- clearTimeout(Pt), e === "ready" && t === 0 && (Pt = setTimeout(() => {
4038
- we.value = !1;
4060
+ let It;
4061
+ C(() => [P.value.status, he.value], ([e, t]) => {
4062
+ clearTimeout(It), e === "ready" && t === 0 && (It = setTimeout(() => {
4063
+ Me.value = !1;
4039
4064
  }, 1500));
4040
4065
  });
4041
- let Ft = x(!1), It;
4042
- C(() => !k.value && !Kr(rt()) && (G() || me.value > 0), (e) => {
4043
- clearTimeout(It), e ? Ft.value = !0 : It = setTimeout(() => {
4044
- Ft.value = !1;
4066
+ let Lt = x(!1), Rt;
4067
+ C(() => !j.value && !Kr(it()) && (G() || he.value > 0), (e) => {
4068
+ clearTimeout(Rt), e ? Lt.value = !0 : Rt = setTimeout(() => {
4069
+ Lt.value = !1;
4045
4070
  }, 400);
4046
- }, { immediate: !0 }), C(() => N.value.status, (e) => {
4047
- e === "ready" && U.value.length > 0 && (U.value = "");
4071
+ }, { immediate: !0 }), C(() => P.value.status, (e) => {
4072
+ e === "ready" && H.value.length > 0 && (H.value = "");
4048
4073
  });
4049
- function Lt(e = !1) {
4050
- for (let t of H.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4051
- H.value = [], qt.value = null;
4074
+ function zt(e = !1) {
4075
+ for (let t of V.value) (e || t.state !== "done") && URL.revokeObjectURL(t.localUrl);
4076
+ V.value = [], Yt.value = null;
4052
4077
  }
4053
- async function Rt() {
4054
- return U.value = "", E.value = st(), await ge(), N.value.clearError(), Ue.value = void 0, We.value = !1, Lt(!0), rn("chat"), E.value;
4078
+ async function Bt() {
4079
+ return H.value = "", Oe.value = {}, E.value = st(), await ge(), P.value.clearError(), O.value = void 0, Ge.value = !1, zt(!0), on("chat"), E.value;
4055
4080
  }
4056
- async function zt(e) {
4057
- N.value.status !== "ready" && (U.value = "", await Nt()), A(), await N.value.regenerate(e);
4081
+ async function Vt(e) {
4082
+ P.value.status !== "ready" && (H.value = "", await Ft()), M(), await P.value.regenerate(e);
4058
4083
  }
4059
- function Bt(e) {
4084
+ function Ht(e) {
4060
4085
  if (e.tool === "requestGeolocation") {
4061
4086
  let t = e.output;
4062
- "latitude" in t && (Je.value = {
4087
+ "latitude" in t && (A.value = {
4063
4088
  geolocationLatitude: t.latitude,
4064
4089
  geolocationLongitude: t.longitude,
4065
4090
  geolocationAccuracy: t.accuracy,
4066
4091
  geolocationCity: t.city
4067
4092
  });
4068
4093
  }
4069
- N.value.addToolOutput(e);
4094
+ P.value.addToolOutput(e);
4070
4095
  }
4071
- function Vt(e) {
4072
- N.value.addToolApprovalResponse(e);
4096
+ function Ut(e) {
4097
+ P.value.addToolApprovalResponse(e);
4073
4098
  }
4074
- let Ht = b(() => N.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), Ut = b(() => _.value?.maxFilesPerMessage ?? 5), Wt = b(() => _.value?.maxFilesPerChat ?? 20), Gt = b(() => Math.max(0, Math.min(Ut.value - H.value.length, Wt.value - Ht.value - H.value.length))), Kt = b(() => Gt.value <= 0), qt = x(null), Jt = () => {
4075
- qt.value = null;
4099
+ let Wt = b(() => P.value.messages.reduce((e, t) => e + t.parts.filter((e) => e.type === "file").length, 0)), Gt = b(() => _.value?.maxFilesPerMessage ?? 5), Kt = b(() => _.value?.maxFilesPerChat ?? 20), qt = b(() => Math.max(0, Math.min(Gt.value - V.value.length, Kt.value - Wt.value - V.value.length))), Jt = b(() => qt.value <= 0), Yt = x(null), Xt = () => {
4100
+ Yt.value = null;
4076
4101
  };
4077
- C(Kt, (e) => {
4078
- e || (qt.value = null);
4102
+ C(Jt, (e) => {
4103
+ e || (Yt.value = null);
4079
4104
  });
4080
- async function Yt(e) {
4081
- if (Kt.value) {
4082
- qt.value = Wt.value - Ht.value - H.value.length <= Ut.value - H.value.length ? {
4105
+ async function Zt(e) {
4106
+ if (Jt.value) {
4107
+ Yt.value = Kt.value - Wt.value - V.value.length <= Gt.value - V.value.length ? {
4083
4108
  reason: "per-chat",
4084
- max: Wt.value
4109
+ max: Kt.value
4085
4110
  } : {
4086
4111
  reason: "per-message",
4087
- max: Ut.value
4112
+ max: Gt.value
4088
4113
  };
4089
4114
  return;
4090
4115
  }
@@ -4094,26 +4119,26 @@ function ti(e) {
4094
4119
  localUrl: URL.createObjectURL(e),
4095
4120
  state: "uploading"
4096
4121
  };
4097
- H.value = [...H.value, n];
4122
+ V.value = [...V.value, n];
4098
4123
  try {
4099
- let n = await O.value.uploadMedia(o.value, E.value, e);
4100
- H.value = H.value.map((e) => e.id === t ? {
4124
+ let n = await k.value.uploadMedia(o.value, E.value, e);
4125
+ V.value = V.value.map((e) => e.id === t ? {
4101
4126
  ...e,
4102
4127
  state: "done",
4103
4128
  mediaSource: n
4104
4129
  } : e);
4105
4130
  } catch (e) {
4106
4131
  let n = e instanceof Error ? e.message : "Upload failed";
4107
- H.value = H.value.map((e) => e.id === t ? {
4132
+ V.value = V.value.map((e) => e.id === t ? {
4108
4133
  ...e,
4109
4134
  state: "error",
4110
4135
  error: n
4111
4136
  } : e);
4112
4137
  }
4113
4138
  }
4114
- async function Xt(e, t) {
4115
- let { userQuestion: n, assistantMessage: r } = kt(e);
4116
- q(await O.value.submitMessageFeedback({
4139
+ async function Qt(e, t) {
4140
+ let { userQuestion: n, assistantMessage: r } = jt(e);
4141
+ At(await k.value.submitMessageFeedback({
4117
4142
  messageId: e.id,
4118
4143
  chatId: E.value,
4119
4144
  agentId: o.value,
@@ -4122,72 +4147,72 @@ function ti(e) {
4122
4147
  assistantMessage: r
4123
4148
  }));
4124
4149
  }
4125
- async function Zt(e) {
4126
- await Xt(e, "upvote");
4150
+ async function J(e) {
4151
+ await Qt(e, "upvote");
4127
4152
  }
4128
- async function Qt(e) {
4129
- await Xt(e, "downvote");
4153
+ async function $t(e) {
4154
+ await Qt(e, "downvote");
4130
4155
  }
4131
- function J(e) {
4132
- dt.value = !1, ft.value = void 0, z.value = e;
4156
+ function en(e) {
4157
+ ht.value = !1, z.value = void 0, pt.value = e;
4133
4158
  }
4134
- async function $t(e) {
4135
- if (z.value) try {
4136
- B.value = !0, dt.value = !1, ft.value = void 0;
4137
- let { userQuestion: t, assistantMessage: n } = kt(z.value);
4138
- q(await O.value.submitMessageFeedback({
4139
- messageId: z.value.id,
4159
+ async function tn(e) {
4160
+ if (pt.value) try {
4161
+ mt.value = !0, ht.value = !1, z.value = void 0;
4162
+ let { userQuestion: t, assistantMessage: n } = jt(pt.value);
4163
+ At(await k.value.submitMessageFeedback({
4164
+ messageId: pt.value.id,
4140
4165
  chatId: E.value,
4141
4166
  agentId: o.value,
4142
4167
  userQuestion: t,
4143
4168
  assistantMessage: n,
4144
4169
  comment: e
4145
- })), dt.value = !0, await K(E.value);
4170
+ })), ht.value = !0, await kt(E.value);
4146
4171
  } catch {
4147
- ft.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4172
+ z.value = n("message.feedbackSubmitError") ? t("message.feedbackSubmitError") : "Failed to submit feedback";
4148
4173
  } finally {
4149
- B.value = !1;
4174
+ mt.value = !1;
4150
4175
  }
4151
4176
  }
4152
- async function en(e) {
4177
+ async function nn(e) {
4153
4178
  try {
4154
- V.value = !0, pt.value = !1, mt.value = void 0, await O.value.submitLead({
4179
+ _t.value = !0, gt.value = !1, vt.value = void 0, await k.value.submitLead({
4155
4180
  agentId: o.value,
4156
4181
  chatId: E.value,
4157
4182
  ...e
4158
- }), pt.value = !0;
4183
+ }), gt.value = !0;
4159
4184
  } catch {
4160
- mt.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4185
+ vt.value = n("message.leadSubmitError") ? t("message.leadSubmitError") : "Failed to submit lead";
4161
4186
  } finally {
4162
- V.value = !1;
4187
+ _t.value = !1;
4163
4188
  }
4164
4189
  }
4165
- async function tn(e, t) {
4166
- let n = await O.value.updateChatTitle(o.value, e, t);
4190
+ async function rn(e, t) {
4191
+ let n = await k.value.updateChatTitle(o.value, e, t);
4167
4192
  I.value = I.value.map((t) => t.id === e ? {
4168
4193
  ...t,
4169
4194
  title: n.title
4170
4195
  } : t);
4171
4196
  }
4172
- async function nn(e) {
4173
- await O.value.deleteChat(o.value, e), I.value = I.value.filter((t) => t.id !== e), E.value === e && await Rt();
4174
- }
4175
- function rn(e) {
4176
- ut.value = e;
4197
+ async function an(e) {
4198
+ await k.value.deleteChat(o.value, e), I.value = I.value.filter((t) => t.id !== e), E.value === e && await Bt();
4177
4199
  }
4178
- let an;
4179
4200
  function on(e) {
4180
- let t = () => O.value.getChat(o.value, e).then((e) => e !== null);
4201
+ ft.value = e;
4202
+ }
4203
+ let sn;
4204
+ function cn(e) {
4205
+ let t = () => k.value.getChat(o.value, e).then((e) => e !== null);
4181
4206
  return t().catch(() => t().catch(() => !1));
4182
4207
  }
4183
4208
  return C(l, async (e) => {
4184
- if (!e || e === an) return;
4185
- let t = an;
4186
- if (an = e, t === void 0) return;
4187
- let n = E.value, r = !T.value && await on(n);
4188
- l.value === e && E.value === n && (r ? gt(o.value) : (I.value = [], R.value = [], L.value = [], await Rt(), ht.value = ""));
4209
+ if (!e || e === sn) return;
4210
+ let t = sn;
4211
+ if (sn = e, t === void 0) return;
4212
+ let n = E.value, r = !T.value && await cn(n);
4213
+ l.value === e && E.value === n && (r ? yt(o.value) : (I.value = [], R.value = [], L.value = [], await Bt(), B.value = ""));
4189
4214
  }), {
4190
- apiClient: O,
4215
+ apiClient: k,
4191
4216
  baseUrl: i,
4192
4217
  basePath: a,
4193
4218
  agentId: o,
@@ -4201,86 +4226,87 @@ function ti(e) {
4201
4226
  revisedAnswers: m,
4202
4227
  model: h,
4203
4228
  actionsInput: g,
4204
- actions: Fe,
4229
+ actions: Le,
4205
4230
  agentFileUpload: _,
4206
4231
  agentVoice: v,
4207
- fallbackModels: y,
4208
- gatewayOptions: te,
4232
+ fallbackModels: te,
4233
+ gatewayOptions: ie,
4209
4234
  externalContext: ae,
4210
- agentHostTools: oe,
4211
- hostToolRegistry: se,
4212
- hostToolsPending: me,
4213
- agentPageAccess: he,
4214
- pageToolRegistry: _e,
4215
- pageFormsProvider: ye,
4216
- pageAction: be,
4217
- pageControlActive: we,
4218
- isWorking: Ft,
4235
+ agentHostTools: se,
4236
+ hostToolRegistry: me,
4237
+ hostToolsPending: he,
4238
+ agentPageAccess: _e,
4239
+ pageToolRegistry: ye,
4240
+ pageFormsProvider: be,
4241
+ pageAction: we,
4242
+ hostStepTitles: Oe,
4243
+ pageControlActive: Me,
4244
+ isWorking: Lt,
4219
4245
  stopHostActions: et,
4220
- pageNoticeLevel: Ve,
4221
- closePageNotice: He,
4222
- hostConfirmation: k,
4246
+ pageNoticeLevel: Ue,
4247
+ closePageNotice: We,
4248
+ hostConfirmation: j,
4223
4249
  respondHostConfirmation: Qe,
4224
- pageAccessAvailable: ze,
4250
+ pageAccessAvailable: Ve,
4225
4251
  pageAccessOff: D,
4226
4252
  setPageAccessOff: tt,
4227
- systemTheme: Me,
4228
- hideWelcomeMessage: Ne,
4229
- isDark: Pe,
4230
- chat: N,
4231
- messages: P,
4253
+ systemTheme: w,
4254
+ hideWelcomeMessage: Pe,
4255
+ isDark: Ie,
4256
+ chat: P,
4257
+ messages: ct,
4232
4258
  conversations: I,
4233
- isLoadingConversations: ct,
4259
+ isLoadingConversations: ut,
4234
4260
  chatFiles: L,
4235
- isLoadingChatFiles: lt,
4236
- input: ht,
4237
- pendingAttachments: H,
4238
- isAttachmentLimitReached: Kt,
4239
- fileLimitError: qt,
4261
+ isLoadingChatFiles: dt,
4262
+ input: B,
4263
+ pendingAttachments: V,
4264
+ isAttachmentLimitReached: Jt,
4265
+ fileLimitError: Yt,
4240
4266
  localChatId: E,
4241
- isConversationBlocked: We,
4242
- inputMessagePlaceholder: F,
4243
- chatError: Ue,
4244
- activeView: ut,
4267
+ isConversationBlocked: Ge,
4268
+ inputMessagePlaceholder: lt,
4269
+ chatError: O,
4270
+ activeView: ft,
4245
4271
  messageFeedbacks: R,
4246
- feedbackDialogMessage: z,
4247
- isFeedbackSubmitting: B,
4248
- isFeedbackSubmitted: dt,
4249
- feedbackSubmitError: ft,
4250
- isLeadSubmitted: pt,
4251
- isLoadingSubmitLead: V,
4252
- submitLeadError: mt,
4272
+ feedbackDialogMessage: pt,
4273
+ isFeedbackSubmitting: mt,
4274
+ isFeedbackSubmitted: ht,
4275
+ feedbackSubmitError: z,
4276
+ isLeadSubmitted: gt,
4277
+ isLoadingSubmitLead: _t,
4278
+ submitLeadError: vt,
4253
4279
  buildDeviceContext: Ye,
4254
- initialize: At,
4255
- loadConversations: gt,
4256
- loadChatFiles: _t,
4257
- refreshMessages: Dt,
4258
- appendMessage: Ot,
4259
- getChatFileUrl: vt,
4260
- getChatFilePreviewUrl: yt,
4261
- deleteChatFile: bt,
4262
- handleSubmit: jt,
4263
- sendMessage: Mt,
4264
- stopGeneration: Nt,
4265
- startNewChat: Rt,
4266
- regenerate: zt,
4267
- addToolOutput: Bt,
4268
- addToolApprovalResponse: Vt,
4269
- handleFileSelect: Yt,
4270
- clearFileLimitError: Jt,
4271
- clearPendingAttachments: Lt,
4272
- onUpvote: Zt,
4273
- onDownvote: Qt,
4274
- onFeedback: J,
4275
- onFeedbackSubmit: $t,
4276
- onLeadSubmit: en,
4277
- navigate: rn,
4278
- renameChatTitle: tn,
4279
- deleteChat: nn
4280
+ initialize: Mt,
4281
+ loadConversations: yt,
4282
+ loadChatFiles: bt,
4283
+ refreshMessages: K,
4284
+ appendMessage: q,
4285
+ getChatFileUrl: xt,
4286
+ getChatFilePreviewUrl: St,
4287
+ deleteChatFile: Ct,
4288
+ handleSubmit: Nt,
4289
+ sendMessage: Pt,
4290
+ stopGeneration: Ft,
4291
+ startNewChat: Bt,
4292
+ regenerate: Vt,
4293
+ addToolOutput: Ht,
4294
+ addToolApprovalResponse: Ut,
4295
+ handleFileSelect: Zt,
4296
+ clearFileLimitError: Xt,
4297
+ clearPendingAttachments: zt,
4298
+ onUpvote: J,
4299
+ onDownvote: $t,
4300
+ onFeedback: en,
4301
+ onFeedbackSubmit: tn,
4302
+ onLeadSubmit: nn,
4303
+ navigate: on,
4304
+ renameChatTitle: rn,
4305
+ deleteChat: an
4280
4306
  };
4281
4307
  })();
4282
4308
  }
4283
4309
  //#endregion
4284
4310
  export { st as a, mr as i, ti as n, Wr as r, Gr as t };
4285
4311
 
4286
- //# sourceMappingURL=useChatbotStore-BliRphuB.js.map
4312
+ //# sourceMappingURL=useChatbotStore-D7LcpA-6.js.map