@rpcbase/agents-sdk 0.2.0 → 0.4.0

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 (79) hide show
  1. package/dist/agents-sdk.css +1 -1
  2. package/dist/api/chat/handler.d.ts.map +1 -1
  3. package/dist/api/chat/messages/handler.d.ts.map +1 -1
  4. package/dist/api/chat/messages/trailing/handler.d.ts.map +1 -1
  5. package/dist/api/chat/runtimeConfig.d.ts +11 -0
  6. package/dist/api/chat/runtimeConfig.d.ts.map +1 -1
  7. package/dist/api/chatDb.d.ts +35 -1
  8. package/dist/api/chatDb.d.ts.map +1 -1
  9. package/dist/api/chatStore.d.ts +11 -2
  10. package/dist/api/chatStore.d.ts.map +1 -1
  11. package/dist/api/session/current/handler.d.ts +4 -0
  12. package/dist/api/session/current/handler.d.ts.map +1 -0
  13. package/dist/api/session/current/index.d.ts +11 -0
  14. package/dist/api/session/current/index.d.ts.map +1 -0
  15. package/dist/{chatDb-CpCFaAxK.js → chatDb-CcAjAGX7.js} +76 -61
  16. package/dist/{chatDb-hVHCr0j0.js → chatDb-DfmUbQT2.js} +76 -61
  17. package/dist/client-routes.browser.js +9 -8
  18. package/dist/client-routes.js +9 -8
  19. package/dist/components/chat.d.ts.map +1 -1
  20. package/dist/components/multimodal-input.d.ts.map +1 -1
  21. package/dist/components/sidebar-history.d.ts.map +1 -1
  22. package/dist/{data-stream-handler-DMKVEvOY.js → data-stream-handler-D9R15ZTc.js} +100 -87
  23. package/dist/{data-stream-handler-6o0tw3-M.js → data-stream-handler-eapMI8kQ.js} +107 -94
  24. package/dist/{handler-CwGQ3dV4.js → handler-B6kVyUoS.js} +1 -1
  25. package/dist/{handler-B3iF4jS4.js → handler-BKT8Hl0a.js} +1 -1
  26. package/dist/{handler-CzKTKfwA.js → handler-BLG0AYVC.js} +1 -1
  27. package/dist/handler-BQZNf9EG.js +21 -0
  28. package/dist/{handler-Bb3YEDwz.js → handler-BUvspcpX.js} +1 -1
  29. package/dist/handler-BdCGoVUM.js +21 -0
  30. package/dist/{handler-CZ-GUuYr.js → handler-BeWk8pDD.js} +1 -1
  31. package/dist/{handler-BcbiHqzs.js → handler-BgRhcxRI.js} +418 -274
  32. package/dist/handler-BgY0anAs.js +19 -0
  33. package/dist/{handler-BU60I9Tt.js → handler-BqHuBA6Q.js} +1 -1
  34. package/dist/{handler-C2MJfgeU.js → handler-CEk1hut1.js} +1 -1
  35. package/dist/{handler-DRk4qlh0.js → handler-CGV7uuUA.js} +1 -1
  36. package/dist/{handler-DBFa5_B9.js → handler-CKmHOFMG.js} +1 -1
  37. package/dist/{handler-ImeP5Thm.js → handler-ClWOGjB_.js} +455 -311
  38. package/dist/{handler-Dmw-3E9n.js → handler-PkV1nrcU.js} +1 -1
  39. package/dist/handler-dVlpopfq.js +21 -0
  40. package/dist/handler-klwfX3CY.js +21 -0
  41. package/dist/handler-mbDBRYl8.js +19 -0
  42. package/dist/index.browser.js +1 -1
  43. package/dist/index.js +1 -1
  44. package/dist/lib/ai/openai-reasoning.d.ts +1 -1
  45. package/dist/lib/ai/openai-reasoning.d.ts.map +1 -1
  46. package/dist/lib/db/schema.d.ts +29 -0
  47. package/dist/lib/db/schema.d.ts.map +1 -1
  48. package/dist/loaders/chatLoader.d.ts +1 -0
  49. package/dist/loaders/chatLoader.d.ts.map +1 -1
  50. package/dist/models/RBAgentsChatThread.d.ts +3 -0
  51. package/dist/models/RBAgentsChatThread.d.ts.map +1 -1
  52. package/dist/models/RBAgentsUsageEvent.d.ts +45 -0
  53. package/dist/models/RBAgentsUsageEvent.d.ts.map +1 -0
  54. package/dist/models/index.browser.d.ts +4 -0
  55. package/dist/models/index.browser.d.ts.map +1 -1
  56. package/dist/models/index.d.ts +34 -0
  57. package/dist/models/index.d.ts.map +1 -1
  58. package/dist/models.browser.js +35 -3
  59. package/dist/models.js +204 -4
  60. package/dist/{openai-reasoning-ARz6ZvZ_.js → openai-reasoning-CLjhz1V1.js} +1 -1
  61. package/dist/{openai-reasoning-jbPa-xup.js → openai-reasoning-kFq60GX9.js} +1 -1
  62. package/dist/pages/ChatPage.d.ts.map +1 -1
  63. package/dist/routes.browser.js +12 -11
  64. package/dist/routes.js +12 -11
  65. package/dist/runtime.d.ts +2 -2
  66. package/dist/runtime.d.ts.map +1 -1
  67. package/dist/runtime.js +1 -1
  68. package/dist/tailwind-source.js +1 -1
  69. package/package.json +1 -1
  70. package/dist/handler-B4PUL3Fm.js +0 -21
  71. package/dist/handler-DAjf6ro0.js +0 -19
  72. package/dist/handler-DN-H4zmz.js +0 -19
  73. package/dist/handler-Df8dOV-8.js +0 -21
  74. /package/dist/{handler-CxfBBYhN.js → handler-BdEE0--D.js} +0 -0
  75. /package/dist/{handler-CzHg9puj.js → handler-BdXUC9Rg.js} +0 -0
  76. /package/dist/{handler-_UsjVWVA.js → handler-D74Wi6e9.js} +0 -0
  77. /package/dist/{handler-Ct7ZyGSn.js → handler-D752oOcY.js} +0 -0
  78. /package/dist/{handler-CSLr0jTM.js → handler-hV65_Dui.js} +0 -0
  79. /package/dist/{handler-oJ8qxBLd.js → handler-jpHBMoww.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { l as e, o as t, r as n, s as r, u as i } from "./chunk-BO2N2NFS-DAcOISTD.js";
2
2
  import { i as a, n as o, r as s, t as c } from "./models-DUt7W9lV.js";
3
- import { i as l, n as u, r as d, t as f } from "./openai-reasoning-ARz6ZvZ_.js";
3
+ import { i as l, n as u, r as d, t as f } from "./openai-reasoning-kFq60GX9.js";
4
4
  import * as p from "react";
5
5
  import m, { Children as h, Component as g, Fragment as _, createContext as v, createElement as y, forwardRef as b, isValidElement as x, memo as S, useCallback as C, useContext as w, useDebugValue as T, useEffect as E, useEffectEvent as D, useId as O, useImperativeHandle as k, useInsertionEffect as A, useLayoutEffect as j, useMemo as M, useRef as N, useState as P, useSyncExternalStore as F, useSyncExternalStore as I } from "react";
6
6
  import { Link as L, Outlet as R, useLocation as z, useNavigate as ee, useRevalidator as B, useRouteLoaderData as te, useSearchParams as V } from "@rpcbase/router";
@@ -40130,7 +40130,10 @@ function kg() {
40130
40130
  });
40131
40131
  }
40132
40132
  function Ag(e = "") {
40133
- let t = e.trim(), n = pe("RBAgentsChatThread", { userId: t }, {
40133
+ let t = e.trim(), n = pe("RBAgentsChatThread", {
40134
+ userId: t,
40135
+ deletedAt: null
40136
+ }, {
40134
40137
  ...Dg,
40135
40138
  enabled: !!t
40136
40139
  }), [r, i] = P(null), [a, o] = P(!1);
@@ -40277,7 +40280,7 @@ function Mg({ historyState: e, onActiveChatTitleChange: t }) {
40277
40280
  })] }) }) }), /* @__PURE__ */ H(cf, {
40278
40281
  onOpenChange: S,
40279
40282
  open: x,
40280
- children: /* @__PURE__ */ U(ff, { children: [/* @__PURE__ */ U(pf, { children: [/* @__PURE__ */ H(hf, { children: "Are you absolutely sure?" }), /* @__PURE__ */ H(gf, { children: "This action cannot be undone. This will permanently delete your chat and remove it from our servers." })] }), /* @__PURE__ */ U(mf, { children: [/* @__PURE__ */ H(vf, { children: "Cancel" }), /* @__PURE__ */ H(_f, {
40283
+ children: /* @__PURE__ */ U(ff, { children: [/* @__PURE__ */ U(pf, { children: [/* @__PURE__ */ H(hf, { children: "Are you absolutely sure?" }), /* @__PURE__ */ H(gf, { children: "This action cannot be undone. This will hide the chat from your history." })] }), /* @__PURE__ */ U(mf, { children: [/* @__PURE__ */ H(vf, { children: "Cancel" }), /* @__PURE__ */ H(_f, {
40281
40284
  onClick: w,
40282
40285
  children: "Continue"
40283
40286
  })] })] })
@@ -50834,7 +50837,7 @@ var LF = new _M({
50834
50837
  //#endregion
50835
50838
  //#region src/components/artifact-actions.tsx
50836
50839
  function RF({ artifact: e, handleVersionChange: t, currentVersionIndex: n, isCurrentVersion: r, mode: i, metadata: a, setMetadata: o }) {
50837
- let [s, c] = P(!1), l = fV.find((t) => t.kind === e.kind);
50840
+ let [s, c] = P(!1), l = pV.find((t) => t.kind === e.kind);
50838
50841
  if (!l) throw Error("Artifact definition not found!");
50839
50842
  let u = {
50840
50843
  content: e.content,
@@ -52924,7 +52927,7 @@ var kL = S(DL, OL), AL = Kf, jL = md, ML = p.forwardRef(({ className: e, ...t },
52924
52927
  let { resolvedTheme: r, theme: i } = sf();
52925
52928
  return /* @__PURE__ */ H(zu, {
52926
52929
  ref: n,
52927
- className: G("agents-sdk fixed inset-0 z-50 bg-foreground/50 data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0", e),
52930
+ className: G("agents-sdk fixed inset-0 z-50 bg-foreground/50 opacity-0 transition-opacity duration-150 data-open:opacity-100 data-closed:opacity-0 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0", e),
52928
52931
  "data-agents-sdk-resolved-theme": r,
52929
52932
  "data-agents-sdk-theme": i,
52930
52933
  ...t
@@ -52949,7 +52952,7 @@ var FL = p.forwardRef(({ className: e, children: t, ...n }, r) => {
52949
52952
  let { resolvedTheme: i, theme: a } = sf();
52950
52953
  return /* @__PURE__ */ U(jL, { children: [/* @__PURE__ */ H(ML, {}), /* @__PURE__ */ U(dd, {
52951
52954
  ref: r,
52952
- className: G("agents-sdk fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 sm:rounded-lg", e),
52955
+ className: G("agents-sdk fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 opacity-0 shadow-lg transition-opacity duration-200 data-open:opacity-100 data-closed:opacity-0 data-[ending-style]:opacity-0 data-[starting-style]:opacity-0 sm:rounded-lg", e),
52953
52956
  "data-agents-sdk-resolved-theme": i,
52954
52957
  "data-agents-sdk-theme": a,
52955
52958
  ...n,
@@ -55607,35 +55610,43 @@ var HB = S(VB, (e, t) => e.chatId === t.chatId);
55607
55610
  function UB(e, t) {
55608
55611
  document.cookie = `${e}=${encodeURIComponent(t)}; path=/; max-age=31536000`;
55609
55612
  }
55610
- var WB = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_") || "default", GB = 40, KB = 232;
55613
+ var WB = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_") || "default", GB = 40, KB = 9;
55611
55614
  function qB(e) {
55612
55615
  let t = e?.firstElementChild;
55613
55616
  return t instanceof HTMLElement ? t : null;
55614
55617
  }
55615
- function JB(e, t) {
55618
+ function JB(e) {
55619
+ let t = window.getComputedStyle(e), n = Number.parseFloat(t.lineHeight), r = Number.parseFloat(t.paddingTop), i = Number.parseFloat(t.paddingBottom), a = Number.isFinite(n) ? n : 24, o = Number.isFinite(r) ? r : 0, s = Number.isFinite(i) ? i : 0;
55620
+ return {
55621
+ minHeight: Math.max(a + o + s, GB),
55622
+ maxHeight: a * KB + o + s
55623
+ };
55624
+ }
55625
+ function YB(e, t) {
55616
55626
  if (!e) return;
55617
55627
  e.style.height = "auto";
55618
- let n = e.scrollHeight, r = Math.max(n, GB), i = Math.min(r, KB), a = qB(t.scrollArea);
55619
- if (e.style.height = `${r}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight((e) => e === i ? e : i), a) {
55620
- if (r <= KB) {
55621
- a.scrollTop = 0;
55628
+ let { minHeight: n, maxHeight: r } = JB(e), i = e.scrollHeight, a = Math.max(i, n), o = Math.min(a, r), s = qB(t.scrollArea);
55629
+ if (e.style.height = `${a}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight((e) => e === o ? e : o), s) {
55630
+ if (a <= r) {
55631
+ s.scrollTop = 0;
55622
55632
  return;
55623
55633
  }
55624
55634
  e.selectionEnd >= e.value.length && requestAnimationFrame(() => {
55625
- a.scrollTop = a.scrollHeight;
55635
+ s.scrollTop = s.scrollHeight;
55626
55636
  });
55627
55637
  }
55628
55638
  }
55629
- function YB(e, t) {
55639
+ function XB(e, t) {
55630
55640
  if (!e) return;
55631
- e.style.height = `${GB}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight(GB);
55632
- let n = qB(t.scrollArea);
55633
- n && (n.scrollTop = 0);
55641
+ let { minHeight: n } = JB(e);
55642
+ e.style.height = `${n}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight(n);
55643
+ let r = qB(t.scrollArea);
55644
+ r && (r.scrollTop = 0);
55634
55645
  }
55635
- function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments: a, setAttachments: o, messages: s, setMessages: c, sendMessage: l, className: u, selectedModelId: d, onModelChange: p, openaiReasoningEffort: m = f, onOpenAIReasoningEffortChange: h }) {
55646
+ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments: a, setAttachments: o, messages: s, setMessages: c, sendMessage: l, className: u, selectedModelId: d, onModelChange: p, openaiReasoningEffort: m = f, onOpenAIReasoningEffortChange: h }) {
55636
55647
  let g = N(null), _ = N(null), [v, y] = P(GB), { width: b } = uM(), { getChatPath: x } = et();
55637
55648
  E(() => {
55638
- JB(g.current, {
55649
+ YB(g.current, {
55639
55650
  scrollArea: _.current,
55640
55651
  setScrollAreaHeight: y
55641
55652
  });
@@ -55656,7 +55667,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55656
55667
  T(t);
55657
55668
  }, [t, T]);
55658
55669
  let D = (e) => {
55659
- n(e.target.value), JB(e.currentTarget, {
55670
+ n(e.target.value), YB(e.currentTarget, {
55660
55671
  scrollArea: _.current,
55661
55672
  setScrollAreaHeight: y
55662
55673
  });
@@ -55673,7 +55684,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55673
55684
  type: "text",
55674
55685
  text: t
55675
55686
  }]
55676
- }), o([]), T(""), n(""), YB(g.current, {
55687
+ }), o([]), T(""), n(""), XB(g.current, {
55677
55688
  scrollArea: _.current,
55678
55689
  setScrollAreaHeight: y
55679
55690
  }), b && b > 768 && g.current?.focus();
@@ -55845,18 +55856,18 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55845
55856
  children: [/* @__PURE__ */ U(RB, {
55846
55857
  className: "gap-0 sm:gap-0.5",
55847
55858
  children: [
55848
- /* @__PURE__ */ H($B, {
55859
+ /* @__PURE__ */ H(eV, {
55849
55860
  fileInputRef: O,
55850
55861
  selectedModelId: d,
55851
55862
  status: r
55852
55863
  }),
55853
- /* @__PURE__ */ H(tV, {
55864
+ /* @__PURE__ */ H(nV, {
55854
55865
  focusTargetRef: g,
55855
55866
  idScope: e,
55856
55867
  onModelChange: p,
55857
55868
  selectedModelId: d
55858
55869
  }),
55859
- /* @__PURE__ */ H(rV, {
55870
+ /* @__PURE__ */ H(iV, {
55860
55871
  disabled: r !== "ready",
55861
55872
  idScope: e,
55862
55873
  onChange: h,
@@ -55864,7 +55875,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55864
55875
  value: m
55865
55876
  })
55866
55877
  ]
55867
- }), r === "submitted" || r === "streaming" ? /* @__PURE__ */ H(aV, {
55878
+ }), r === "submitted" || r === "streaming" ? /* @__PURE__ */ H(oV, {
55868
55879
  setMessages: c,
55869
55880
  stop: i
55870
55881
  }) : /* @__PURE__ */ H(zB, {
@@ -55880,8 +55891,8 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55880
55891
  ]
55881
55892
  });
55882
55893
  }
55883
- var ZB = S(XB, (e, t) => !(e.input !== t.input || e.status !== t.status || !xe(e.attachments, t.attachments) || e.selectedModelId !== t.selectedModelId || e.openaiReasoningEffort !== t.openaiReasoningEffort));
55884
- function QB({ fileInputRef: e, status: t, selectedModelId: n }) {
55894
+ var QB = S(ZB, (e, t) => !(e.input !== t.input || e.status !== t.status || !xe(e.attachments, t.attachments) || e.selectedModelId !== t.selectedModelId || e.openaiReasoningEffort !== t.openaiReasoningEffort));
55895
+ function $B({ fileInputRef: e, status: t, selectedModelId: n }) {
55885
55896
  let r = n.includes("reasoning") || n.includes("think");
55886
55897
  return /* @__PURE__ */ H(ef, {
55887
55898
  className: "aspect-square h-8 rounded-lg p-1 transition-colors hover:bg-accent",
@@ -55900,8 +55911,8 @@ function QB({ fileInputRef: e, status: t, selectedModelId: n }) {
55900
55911
  })
55901
55912
  });
55902
55913
  }
55903
- var $B = S(QB);
55904
- function eV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange: r }) {
55914
+ var eV = S($B);
55915
+ function tV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange: r }) {
55905
55916
  let [i, o] = P(!1), c = N(!1), l = WB(t), u = s.find((e) => e.id === n) ?? s.find((e) => e.id === "openai/gpt-5.4-mini") ?? s[0], [d] = u.id.split("/"), f = {
55906
55917
  anthropic: "Anthropic",
55907
55918
  openai: "OpenAI",
@@ -55945,20 +55956,21 @@ function eV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange:
55945
55956
  })]
55946
55957
  });
55947
55958
  }
55948
- var tV = S(eV), nV = (e, t) => t.includes(e);
55949
- function rV({ idScope: e, selectedModelId: t, value: n, onChange: r, disabled: i }) {
55950
- let a = l(t), o = d(t), s = n === "default" || nV(n, o) ? n : f, c = u(t);
55959
+ var nV = S(tV), rV = (e, t) => t.includes(e);
55960
+ function iV({ idScope: e, selectedModelId: t, value: n, onChange: r, disabled: i }) {
55961
+ let a = l(t), o = d(t), s = u(t), c = s && rV(s, o) ? s : o[0], f = rV(n, o) ? n : c ?? "default";
55951
55962
  return E(() => {
55952
- !a || !r || s === n || r(s);
55963
+ !a || !r || rV(n, o) || r(c ?? "default");
55953
55964
  }, [
55965
+ o,
55966
+ c,
55954
55967
  r,
55955
- s,
55956
55968
  a,
55957
55969
  n
55958
- ]), !a || !r ? null : /* @__PURE__ */ U(yB, {
55970
+ ]), !a || !r || f === "default" ? null : /* @__PURE__ */ U(yB, {
55959
55971
  disabled: i,
55960
55972
  onValueChange: (e) => r(e),
55961
- value: s,
55973
+ value: f,
55962
55974
  children: [/* @__PURE__ */ H(xB, {
55963
55975
  className: "h-8 w-[180px] gap-1 border-0 bg-transparent px-2 text-xs hover:bg-accent focus:ring-0 focus:ring-offset-0",
55964
55976
  id: `agents-sdk-reasoning-effort-${WB(e)}`,
@@ -55969,16 +55981,13 @@ function rV({ idScope: e, selectedModelId: t, value: n, onChange: r, disabled: i
55969
55981
  children: /* @__PURE__ */ H(bB, { placeholder: "Reasoning" })
55970
55982
  })]
55971
55983
  })
55972
- }), /* @__PURE__ */ U(wB, { children: [/* @__PURE__ */ H(EB, {
55973
- value: f,
55974
- children: /* @__PURE__ */ H("span", { children: c ? `Reasoning: Default (${c})` : "Reasoning: Default" })
55975
- }), o.map((e) => /* @__PURE__ */ H(EB, {
55984
+ }), /* @__PURE__ */ H(wB, { children: o.map((e) => /* @__PURE__ */ H(EB, {
55976
55985
  value: e,
55977
55986
  children: /* @__PURE__ */ H("span", { children: `Reasoning: ${e}` })
55978
- }, e))] })]
55987
+ }, e)) })]
55979
55988
  });
55980
55989
  }
55981
- function iV({ stop: e, setMessages: t }) {
55990
+ function aV({ stop: e, setMessages: t }) {
55982
55991
  return /* @__PURE__ */ H(ef, {
55983
55992
  className: "size-8 rounded-full bg-primary p-1 text-primary-foreground transition-colors duration-200 hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground",
55984
55993
  "data-testid": "stop-button",
@@ -55988,7 +55997,7 @@ function iV({ stop: e, setMessages: t }) {
55988
55997
  children: /* @__PURE__ */ H(dt, { size: 14 })
55989
55998
  });
55990
55999
  }
55991
- var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedTool: r, isToolbarVisible: i, setIsToolbarVisible: a, isAnimating: o, sendMessage: s, onClick: c }) => {
56000
+ var oV = S(aV), sV = ({ description: e, icon: t, selectedTool: n, setSelectedTool: r, isToolbarVisible: i, setIsToolbarVisible: a, isAnimating: o, sendMessage: s, onClick: c }) => {
55992
56001
  let [l, u] = P(!1);
55993
56002
  E(() => {
55994
56003
  n !== e && u(!1);
@@ -56046,14 +56055,14 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56046
56055
  children: e
56047
56056
  })]
56048
56057
  });
56049
- }, sV = [...[
56058
+ }, cV = [...[
56050
56059
  ,
56051
56060
  ,
56052
56061
  ,
56053
56062
  ,
56054
56063
  ,
56055
56064
  ,
56056
- ]].map((e) => Ze(5)), cV = ({ setSelectedTool: e, sendMessage: t, isAnimating: n }) => {
56065
+ ]].map((e) => Ze(5)), lV = ({ setSelectedTool: e, sendMessage: t, isAnimating: n }) => {
56057
56066
  let r = [
56058
56067
  "Elementary",
56059
56068
  "Middle School",
@@ -56069,7 +56078,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56069
56078
  return () => e();
56070
56079
  }, [a]), /* @__PURE__ */ U("div", {
56071
56080
  className: "relative flex flex-col items-center justify-end",
56072
- children: [sV.map((e) => /* @__PURE__ */ H(yj.div, {
56081
+ children: [cV.map((e) => /* @__PURE__ */ H(yj.div, {
56073
56082
  animate: { opacity: 1 },
56074
56083
  className: "flex size-[40px] flex-row items-center justify-center",
56075
56084
  exit: { opacity: 0 },
@@ -56121,7 +56130,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56121
56130
  })]
56122
56131
  }) })]
56123
56132
  });
56124
- }, lV = ({ isToolbarVisible: e, selectedTool: t, setSelectedTool: n, sendMessage: r, isAnimating: i, setIsToolbarVisible: a, tools: o }) => {
56133
+ }, uV = ({ isToolbarVisible: e, selectedTool: t, setSelectedTool: n, sendMessage: r, isAnimating: i, setIsToolbarVisible: a, tools: o }) => {
56125
56134
  let [s, ...c] = o;
56126
56135
  return /* @__PURE__ */ U(yj.div, {
56127
56136
  animate: {
@@ -56137,7 +56146,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56137
56146
  opacity: 0,
56138
56147
  scale: .95
56139
56148
  },
56140
- children: [/* @__PURE__ */ H(Ek, { children: e && c.map((e) => /* @__PURE__ */ H(oV, {
56149
+ children: [/* @__PURE__ */ H(Ek, { children: e && c.map((e) => /* @__PURE__ */ H(sV, {
56141
56150
  description: e.description,
56142
56151
  icon: e.icon,
56143
56152
  isAnimating: i,
@@ -56145,7 +56154,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56145
56154
  selectedTool: t,
56146
56155
  sendMessage: r,
56147
56156
  setSelectedTool: n
56148
- }, e.description)) }), /* @__PURE__ */ H(oV, {
56157
+ }, e.description)) }), /* @__PURE__ */ H(sV, {
56149
56158
  description: s.description,
56150
56159
  icon: s.icon,
56151
56160
  isAnimating: i,
@@ -56157,7 +56166,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56157
56166
  setSelectedTool: n
56158
56167
  })]
56159
56168
  });
56160
- }, uV = S(({ isToolbarVisible: e, setIsToolbarVisible: t, sendMessage: n, status: r, stop: i, setMessages: a, artifactKind: o }) => {
56169
+ }, dV = S(({ isToolbarVisible: e, setIsToolbarVisible: t, sendMessage: n, status: r, stop: i, setMessages: a, artifactKind: o }) => {
56161
56170
  let s = N(null), c = N(null), [l, u] = P(null), [d, f] = P(!1);
56162
56171
  cM(s, () => {
56163
56172
  t(!1), u(null);
@@ -56174,7 +56183,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56174
56183
  }, []), E(() => {
56175
56184
  r === "streaming" && t(!1);
56176
56185
  }, [r, t]);
56177
- let h = fV.find((e) => e.kind === o);
56186
+ let h = pV.find((e) => e.kind === o);
56178
56187
  if (!h) throw Error("Artifact definition not found!");
56179
56188
  let g = h.toolbar;
56180
56189
  return g.length === 0 ? null : /* @__PURE__ */ H(om, {
@@ -56236,11 +56245,11 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56236
56245
  i(), a((e) => e);
56237
56246
  },
56238
56247
  children: /* @__PURE__ */ H(dt, {})
56239
- }, "stop-icon") : l === "adjust-reading-level" ? /* @__PURE__ */ H(cV, {
56248
+ }, "stop-icon") : l === "adjust-reading-level" ? /* @__PURE__ */ H(lV, {
56240
56249
  isAnimating: d,
56241
56250
  sendMessage: n,
56242
56251
  setSelectedTool: u
56243
- }, "reading-level-selector") : /* @__PURE__ */ H(lV, {
56252
+ }, "reading-level-selector") : /* @__PURE__ */ H(uV, {
56244
56253
  isAnimating: d,
56245
56254
  isToolbarVisible: e,
56246
56255
  selectedTool: l,
@@ -56251,7 +56260,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56251
56260
  }, "tools")
56252
56261
  })
56253
56262
  });
56254
- }, (e, t) => !(e.status !== t.status || e.isToolbarVisible !== t.isToolbarVisible || e.artifactKind !== t.artifactKind)), dV = ({ handleVersionChange: e, documents: t, currentVersionIndex: n }) => {
56263
+ }, (e, t) => !(e.status !== t.status || e.isToolbarVisible !== t.isToolbarVisible || e.artifactKind !== t.artifactKind)), fV = ({ handleVersionChange: e, documents: t, currentVersionIndex: n }) => {
56255
56264
  let { artifact: r } = Hy(), { width: i } = uM(), a = i < 768, { mutate: o } = G_(), [s, c] = P(!1);
56256
56265
  if (t) return /* @__PURE__ */ U(yj.div, {
56257
56266
  animate: { y: 0 },
@@ -56286,13 +56295,13 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56286
56295
  })]
56287
56296
  })]
56288
56297
  });
56289
- }, fV = [
56298
+ }, pV = [
56290
56299
  LF,
56291
56300
  bM,
56292
56301
  SM,
56293
56302
  HP
56294
56303
  ];
56295
- function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, status: i, stop: a, attachments: o, setAttachments: s, sendMessage: c, messages: l, setMessages: u, regenerate: d, votes: f, isReadonly: p, selectedModelId: m }) {
56304
+ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, status: i, stop: a, attachments: o, setAttachments: s, sendMessage: c, messages: l, setMessages: u, regenerate: d, votes: f, isReadonly: p, selectedModelId: m }) {
56296
56305
  let { artifact: h, setArtifact: g, metadata: _, setMetadata: v } = Hy(), { data: y, isLoading: b, mutate: x } = cv(h.documentId !== "init" && h.status !== "streaming" ? `/api/rb/agents/document?id=${h.documentId}` : null, Kd), [S, w] = P("edit"), [T, D] = P(null), [O, k] = P(-1);
56297
56306
  E(() => {
56298
56307
  if (y && y.length > 0) {
@@ -56340,7 +56349,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56340
56349
  }
56341
56350
  let R = (e) => {
56342
56351
  y && (e === "latest" && (k(y.length - 1), w("edit")), e === "toggle" && w((e) => e === "edit" ? "diff" : "edit"), e === "prev" ? O > 0 && k((e) => e - 1) : e === "next" && O < y.length - 1 && k((e) => e + 1));
56343
- }, [z, ee] = P(!1), B = y && y.length > 0 ? O === y.length - 1 : !0, te = dm(), V = fV.find((e) => e.kind === h.kind);
56352
+ }, [z, ee] = P(!1), B = y && y.length > 0 ? O === y.length - 1 : !0, te = dm(), V = pV.find((e) => e.kind === h.kind);
56344
56353
  if (!V) throw Error("Artifact definition not found!");
56345
56354
  return E(() => {
56346
56355
  h.documentId !== "init" && V.initialize && V.initialize({
@@ -56403,7 +56412,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56403
56412
  votes: f
56404
56413
  }), /* @__PURE__ */ H("div", {
56405
56414
  className: "relative flex w-full flex-row items-end gap-2 px-4 pb-4",
56406
- children: /* @__PURE__ */ H(ZB, {
56415
+ children: /* @__PURE__ */ H(QB, {
56407
56416
  attachments: o,
56408
56417
  chatId: t,
56409
56418
  className: "bg-background dark:bg-muted",
@@ -56499,7 +56508,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56499
56508
  status: h.status,
56500
56509
  suggestions: [],
56501
56510
  title: h.title
56502
- }), /* @__PURE__ */ H(Ek, { children: B && /* @__PURE__ */ H(uV, {
56511
+ }), /* @__PURE__ */ H(Ek, { children: B && /* @__PURE__ */ H(dV, {
56503
56512
  artifactKind: h.kind,
56504
56513
  isToolbarVisible: z,
56505
56514
  sendMessage: c,
@@ -56509,7 +56518,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56509
56518
  stop: a
56510
56519
  }) })]
56511
56520
  }),
56512
- /* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(dV, {
56521
+ /* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(fV, {
56513
56522
  currentVersionIndex: O,
56514
56523
  documents: y,
56515
56524
  handleVersionChange: R
@@ -56518,7 +56527,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56518
56527
  })]
56519
56528
  }) });
56520
56529
  }
56521
- var mV = S(pV, (e, t) => !(e.status !== t.status || !xe(e.votes, t.votes) || e.input !== t.input || !xe(e.messages, t.messages.length))), hV = () => /* @__PURE__ */ U("div", {
56530
+ var hV = S(mV, (e, t) => !(e.status !== t.status || !xe(e.votes, t.votes) || e.input !== t.input || !xe(e.messages, t.messages.length))), gV = () => /* @__PURE__ */ U("div", {
56522
56531
  className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56523
56532
  children: [/* @__PURE__ */ H(yj.div, {
56524
56533
  animate: {
@@ -56556,7 +56565,7 @@ var mV = S(pV, (e, t) => !(e.status !== t.status || !xe(e.votes, t.votes) || e.i
56556
56565
  }, "overview");
56557
56566
  //#endregion
56558
56567
  //#region src/components/messages.tsx
56559
- function gV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c }) {
56568
+ function _V({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c }) {
56560
56569
  let l = i.at(-1), u = (e) => e === "dynamic-tool" || e.startsWith("tool-"), d = l?.role === "assistant" && (l.parts?.some((e) => e.type === "text" ? !!e.text?.trim() : e.type === "reasoning" ? xL(e) : !!u(e.type)) ?? !1), f = n === "submitted" || n === "streaming" && l?.role === "assistant" && !d, p = n === "streaming" && l?.role === "assistant" && !d, { containerRef: m, endRef: h, isAtBottom: g, scrollToBottom: _, hasSentMessage: v } = UF({ status: n });
56561
56570
  return ot(), /* @__PURE__ */ U("div", {
56562
56571
  className: "relative flex-1",
@@ -56566,7 +56575,7 @@ function gV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messag
56566
56575
  children: /* @__PURE__ */ U("div", {
56567
56576
  className: "mx-auto flex min-w-0 max-w-4xl flex-col gap-4 px-2 pt-[60px] pb-4 md:gap-6 md:px-4",
56568
56577
  children: [
56569
- i.length === 0 && /* @__PURE__ */ H(hV, {}),
56578
+ i.length === 0 && /* @__PURE__ */ H(gV, {}),
56570
56579
  i.map((c, l) => p && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ H(TL, {
56571
56580
  addToolApprovalResponse: e,
56572
56581
  chatId: t,
@@ -56594,15 +56603,17 @@ function gV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messag
56594
56603
  })]
56595
56604
  });
56596
56605
  }
56597
- var _V = gV, vV = (e) => e?.parts?.some((e) => {
56606
+ var vV = _V, yV = (e) => e?.parts?.some((e) => {
56598
56607
  let t = e.state;
56599
56608
  return t === "approval-responded" || t === "output-denied";
56600
- }) ?? !1, yV = (e) => `agents-sdk:chat:${e}:stream`, bV = (e) => !!(e && typeof e == "object" && !Array.isArray(e));
56601
- function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, autoResume: i }) {
56602
- let { setDataStream: a } = ot(), { getChatPath: s } = et(), u = o.has(n) ? n : c, [d, p] = P(""), [m, h] = P(u), g = N(m), [_, v] = P(f), y = N(_);
56609
+ }) ?? !1, bV = (e) => `agents-sdk:chat:${e}:stream`, xV = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), SV = (e) => u(e) ?? "default";
56610
+ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, autoResume: i }) {
56611
+ let { setDataStream: a } = ot(), { getChatPath: s } = et(), u = o.has(n) ? n : c, d = SV(u), [f, p] = P(""), [m, h] = P(u), g = N(m), [_, v] = P(d), y = N(_);
56603
56612
  E(() => {
56604
56613
  g.current = m;
56605
56614
  }, [m]), E(() => {
56615
+ h(u), v(SV(u));
56616
+ }, [e, u]), E(() => {
56606
56617
  y.current = _;
56607
56618
  }, [_]);
56608
56619
  let { messages: b, setMessages: x, sendMessage: S, status: C, stop: w, regenerate: T, resumeStream: D, addToolApprovalResponse: O } = zy({
@@ -56615,15 +56626,15 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56615
56626
  api: "/api/rb/agents/chat",
56616
56627
  fetch: qd,
56617
56628
  prepareSendMessagesRequest(e) {
56618
- let t = e.messages.at(-1), n = e.messages.at(-2), r = Ud(e.headers, Vd()), i = t?.role !== "user" || t?.role === "user" && vV(n);
56629
+ let t = g.current, n = y.current, r = e.messages.at(-1), i = e.messages.at(-2), a = Ud(e.headers, Vd()), o = r?.role !== "user" || r?.role === "user" && yV(i);
56619
56630
  return {
56620
- ...r ? { headers: r } : {},
56631
+ ...a ? { headers: a } : {},
56621
56632
  body: {
56622
56633
  id: e.id,
56623
- ...i ? { messages: e.messages } : { message: t },
56624
- selectedChatModel: g.current,
56625
- ...l(g.current) && y.current !== "default" ? {
56626
- openaiReasoningEffort: y.current,
56634
+ ...o ? { messages: e.messages } : { message: r },
56635
+ selectedChatModel: t,
56636
+ ...l(t) && n !== "default" ? {
56637
+ openaiReasoningEffort: n,
56627
56638
  openaiReasoningSummary: "detailed"
56628
56639
  } : {},
56629
56640
  ...e.body
@@ -56650,17 +56661,17 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56650
56661
  de.error("Something went wrong. Please try again.");
56651
56662
  }
56652
56663
  }), k = N(null), A = N("");
56653
- E(() => fe(yV(e), (t) => {
56654
- if (!bV(t) || t.chatId !== e) return;
56664
+ E(() => fe(bV(e), (t) => {
56665
+ if (!xV(t) || t.chatId !== e) return;
56655
56666
  let n = t.message;
56656
- if (bV(n)) {
56667
+ if (xV(n)) {
56657
56668
  let e = typeof n.id == "string" ? n.id : null, t = typeof n.role == "string" ? n.role : null, r = Array.isArray(n.parts) ? n.parts : null;
56658
56669
  if (e && t && r) {
56659
56670
  let i = {
56660
56671
  id: e,
56661
56672
  role: t,
56662
56673
  parts: r,
56663
- metadata: bV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56674
+ metadata: xV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56664
56675
  };
56665
56676
  x((t) => {
56666
56677
  let n = t.findIndex((t) => t.id === e);
@@ -56673,7 +56684,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56673
56684
  return;
56674
56685
  }
56675
56686
  let r = t.part;
56676
- if (!bV(r)) return;
56687
+ if (!xV(r)) return;
56677
56688
  if (r.type === "start" && typeof r.messageId == "string") {
56678
56689
  k.current = r.messageId, A.current = "";
56679
56690
  return;
@@ -56732,7 +56743,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56732
56743
  className: "relative flex h-full min-h-0 min-w-0 overflow-hidden bg-background",
56733
56744
  children: [/* @__PURE__ */ U("div", {
56734
56745
  className: "overscroll-behavior-contain flex h-full min-h-0 min-w-0 flex-1 touch-pan-y flex-col bg-background",
56735
- children: [/* @__PURE__ */ H(_V, {
56746
+ children: [/* @__PURE__ */ H(vV, {
56736
56747
  addToolApprovalResponse: O,
56737
56748
  chatId: e,
56738
56749
  isArtifactVisible: ee,
@@ -56745,12 +56756,14 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56745
56756
  votes: L
56746
56757
  }), /* @__PURE__ */ H("div", {
56747
56758
  className: "sticky bottom-0 z-1 mx-auto flex w-full max-w-4xl gap-2 border-t-0 bg-background px-2 pb-3 md:px-4 md:pb-4",
56748
- children: !r && /* @__PURE__ */ H(ZB, {
56759
+ children: !r && /* @__PURE__ */ H(QB, {
56749
56760
  attachments: R,
56750
56761
  chatId: e,
56751
- input: d,
56762
+ input: f,
56752
56763
  messages: b,
56753
- onModelChange: h,
56764
+ onModelChange: (e) => {
56765
+ h(e), v(SV(e));
56766
+ },
56754
56767
  onOpenAIReasoningEffortChange: v,
56755
56768
  openaiReasoningEffort: _,
56756
56769
  selectedModelId: m,
@@ -56762,11 +56775,11 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56762
56775
  stop: w
56763
56776
  })
56764
56777
  })]
56765
- }), /* @__PURE__ */ H(mV, {
56778
+ }), /* @__PURE__ */ H(hV, {
56766
56779
  addToolApprovalResponse: O,
56767
56780
  attachments: R,
56768
56781
  chatId: e,
56769
- input: d,
56782
+ input: f,
56770
56783
  isReadonly: r,
56771
56784
  messages: b,
56772
56785
  regenerate: T,
@@ -56783,7 +56796,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56783
56796
  }
56784
56797
  //#endregion
56785
56798
  //#region src/components/data-stream-handler.tsx
56786
- function SV() {
56799
+ function wV() {
56787
56800
  let { dataStream: e, setDataStream: t } = ot(), { artifact: n, setArtifact: r, setMetadata: i } = Hy();
56788
56801
  return E(() => {
56789
56802
  if (!e?.length) return;
@@ -56791,7 +56804,7 @@ function SV() {
56791
56804
  t([]);
56792
56805
  for (let e of a) {
56793
56806
  if (e.type === "data-chat-title") continue;
56794
- let t = fV.find((e) => e.kind === n.kind);
56807
+ let t = pV.find((e) => e.kind === n.kind);
56795
56808
  t?.onStreamPart && t.onStreamPart({
56796
56809
  streamPart: e,
56797
56810
  setArtifact: r,
@@ -56839,4 +56852,4 @@ function SV() {
56839
56852
  ]), null;
56840
56853
  }
56841
56854
  //#endregion
56842
- export { jg as a, Hd as c, $e as d, nt as f, et as h, Rg as i, Bd as l, rt as m, xV as n, Zd as o, tt as p, Fg as r, Vd as s, SV as t, at as u };
56855
+ export { jg as a, Hd as c, $e as d, nt as f, et as h, Rg as i, Bd as l, rt as m, CV as n, Zd as o, tt as p, Fg as r, Vd as s, wV as t, at as u };