@rpcbase/agents-sdk 0.2.0 → 0.3.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 (82) 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/ai-elements/model-selector.d.ts.map +1 -1
  20. package/dist/components/chat.d.ts.map +1 -1
  21. package/dist/components/multimodal-input.d.ts.map +1 -1
  22. package/dist/components/sidebar-history.d.ts.map +1 -1
  23. package/dist/components/ui/dialog.d.ts +4 -1
  24. package/dist/components/ui/dialog.d.ts.map +1 -1
  25. package/dist/{data-stream-handler-DMKVEvOY.js → data-stream-handler-CTBOlLdZ.js} +109 -95
  26. package/dist/{data-stream-handler-6o0tw3-M.js → data-stream-handler-LGFXl3Kj.js} +116 -102
  27. package/dist/{handler-BcbiHqzs.js → handler-5D9tLMpX.js} +418 -274
  28. package/dist/{handler-CwGQ3dV4.js → handler-B6kVyUoS.js} +1 -1
  29. package/dist/{handler-B3iF4jS4.js → handler-BKT8Hl0a.js} +1 -1
  30. package/dist/{handler-CzKTKfwA.js → handler-BLG0AYVC.js} +1 -1
  31. package/dist/handler-BQZNf9EG.js +21 -0
  32. package/dist/{handler-Bb3YEDwz.js → handler-BUvspcpX.js} +1 -1
  33. package/dist/handler-BdCGoVUM.js +21 -0
  34. package/dist/{handler-CZ-GUuYr.js → handler-BeWk8pDD.js} +1 -1
  35. package/dist/handler-BgY0anAs.js +19 -0
  36. package/dist/{handler-BU60I9Tt.js → handler-BqHuBA6Q.js} +1 -1
  37. package/dist/{handler-C2MJfgeU.js → handler-CEk1hut1.js} +1 -1
  38. package/dist/{handler-DRk4qlh0.js → handler-CGV7uuUA.js} +1 -1
  39. package/dist/{handler-DBFa5_B9.js → handler-CKmHOFMG.js} +1 -1
  40. package/dist/{handler-ImeP5Thm.js → handler-ClWOGjB_.js} +455 -311
  41. package/dist/{handler-Dmw-3E9n.js → handler-PkV1nrcU.js} +1 -1
  42. package/dist/handler-dVlpopfq.js +21 -0
  43. package/dist/handler-klwfX3CY.js +21 -0
  44. package/dist/handler-mbDBRYl8.js +19 -0
  45. package/dist/index.browser.js +1 -1
  46. package/dist/index.js +1 -1
  47. package/dist/lib/ai/openai-reasoning.d.ts +1 -1
  48. package/dist/lib/ai/openai-reasoning.d.ts.map +1 -1
  49. package/dist/lib/db/schema.d.ts +29 -0
  50. package/dist/lib/db/schema.d.ts.map +1 -1
  51. package/dist/loaders/chatLoader.d.ts +1 -0
  52. package/dist/loaders/chatLoader.d.ts.map +1 -1
  53. package/dist/models/RBAgentsChatThread.d.ts +3 -0
  54. package/dist/models/RBAgentsChatThread.d.ts.map +1 -1
  55. package/dist/models/RBAgentsUsageEvent.d.ts +45 -0
  56. package/dist/models/RBAgentsUsageEvent.d.ts.map +1 -0
  57. package/dist/models/index.browser.d.ts +4 -0
  58. package/dist/models/index.browser.d.ts.map +1 -1
  59. package/dist/models/index.d.ts +34 -0
  60. package/dist/models/index.d.ts.map +1 -1
  61. package/dist/models.browser.js +35 -3
  62. package/dist/models.js +204 -4
  63. package/dist/{openai-reasoning-ARz6ZvZ_.js → openai-reasoning-CLjhz1V1.js} +1 -1
  64. package/dist/{openai-reasoning-jbPa-xup.js → openai-reasoning-kFq60GX9.js} +1 -1
  65. package/dist/pages/ChatPage.d.ts.map +1 -1
  66. package/dist/routes.browser.js +12 -11
  67. package/dist/routes.js +12 -11
  68. package/dist/runtime.d.ts +2 -2
  69. package/dist/runtime.d.ts.map +1 -1
  70. package/dist/runtime.js +1 -1
  71. package/dist/tailwind-source.js +1 -1
  72. package/package.json +1 -1
  73. package/dist/handler-B4PUL3Fm.js +0 -21
  74. package/dist/handler-DAjf6ro0.js +0 -19
  75. package/dist/handler-DN-H4zmz.js +0 -19
  76. package/dist/handler-Df8dOV-8.js +0 -21
  77. /package/dist/{handler-CxfBBYhN.js → handler-BdEE0--D.js} +0 -0
  78. /package/dist/{handler-CzHg9puj.js → handler-BdXUC9Rg.js} +0 -0
  79. /package/dist/{handler-_UsjVWVA.js → handler-D74Wi6e9.js} +0 -0
  80. /package/dist/{handler-Ct7ZyGSn.js → handler-D752oOcY.js} +0 -0
  81. /package/dist/{handler-CSLr0jTM.js → handler-hV65_Dui.js} +0 -0
  82. /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-100 transition-opacity duration-150 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
@@ -52945,15 +52948,15 @@ var PL = p.forwardRef(({ asChild: e = !1, children: t, ...n }, r) => /* @__PURE_
52945
52948
  children: t
52946
52949
  }));
52947
52950
  PL.displayName = "DialogClose";
52948
- var FL = p.forwardRef(({ className: e, children: t, ...n }, r) => {
52949
- let { resolvedTheme: i, theme: a } = sf();
52950
- return /* @__PURE__ */ U(jL, { children: [/* @__PURE__ */ H(ML, {}), /* @__PURE__ */ U(dd, {
52951
- 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),
52953
- "data-agents-sdk-resolved-theme": i,
52954
- "data-agents-sdk-theme": a,
52955
- ...n,
52956
- children: [t, /* @__PURE__ */ U(Ju, {
52951
+ var FL = p.forwardRef(({ backdropClassName: e, className: t, children: n, ...r }, i) => {
52952
+ let { resolvedTheme: a, theme: o } = sf();
52953
+ return /* @__PURE__ */ U(jL, { children: [/* @__PURE__ */ H(ML, { className: e }), /* @__PURE__ */ U(dd, {
52954
+ ref: i,
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 shadow-lg duration-200 data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-closed:fill-mode-forwards data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 sm:rounded-lg", t),
52956
+ "data-agents-sdk-resolved-theme": a,
52957
+ "data-agents-sdk-theme": o,
52958
+ ...r,
52959
+ children: [n, /* @__PURE__ */ U(Ju, {
52957
52960
  className: "absolute right-4 top-4 cursor-pointer rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-disabled:pointer-events-none",
52958
52961
  children: [/* @__PURE__ */ H(Hf, { className: "h-4 w-4" }), /* @__PURE__ */ H("span", {
52959
52962
  className: "sr-only",
@@ -53214,6 +53217,7 @@ QL.displayName = "CommandShortcut";
53214
53217
  //#endregion
53215
53218
  //#region src/components/ai-elements/model-selector.tsx
53216
53219
  var $L = (e) => /* @__PURE__ */ H(AL, { ...e }), eR = (e) => /* @__PURE__ */ H(NL, { ...e }), tR = ({ className: e, children: t, title: n = "Model Selector", ...r }) => /* @__PURE__ */ U(FL, {
53220
+ backdropClassName: "!bg-transparent",
53217
53221
  className: G("p-0", e),
53218
53222
  ...r,
53219
53223
  children: [/* @__PURE__ */ H(RL, {
@@ -55607,35 +55611,43 @@ var HB = S(VB, (e, t) => e.chatId === t.chatId);
55607
55611
  function UB(e, t) {
55608
55612
  document.cookie = `${e}=${encodeURIComponent(t)}; path=/; max-age=31536000`;
55609
55613
  }
55610
- var WB = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_") || "default", GB = 40, KB = 232;
55614
+ var WB = (e) => e.replace(/[^a-zA-Z0-9_-]/g, "_") || "default", GB = 40, KB = 9;
55611
55615
  function qB(e) {
55612
55616
  let t = e?.firstElementChild;
55613
55617
  return t instanceof HTMLElement ? t : null;
55614
55618
  }
55615
- function JB(e, t) {
55619
+ function JB(e) {
55620
+ 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;
55621
+ return {
55622
+ minHeight: Math.max(a + o + s, GB),
55623
+ maxHeight: a * KB + o + s
55624
+ };
55625
+ }
55626
+ function YB(e, t) {
55616
55627
  if (!e) return;
55617
55628
  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;
55629
+ let { minHeight: n, maxHeight: r } = JB(e), i = e.scrollHeight, a = Math.max(i, n), o = Math.min(a, r), s = qB(t.scrollArea);
55630
+ if (e.style.height = `${a}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight((e) => e === o ? e : o), s) {
55631
+ if (a <= r) {
55632
+ s.scrollTop = 0;
55622
55633
  return;
55623
55634
  }
55624
55635
  e.selectionEnd >= e.value.length && requestAnimationFrame(() => {
55625
- a.scrollTop = a.scrollHeight;
55636
+ s.scrollTop = s.scrollHeight;
55626
55637
  });
55627
55638
  }
55628
55639
  }
55629
- function YB(e, t) {
55640
+ function XB(e, t) {
55630
55641
  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);
55642
+ let { minHeight: n } = JB(e);
55643
+ e.style.height = `${n}px`, e.style.overflowY = "hidden", t.setScrollAreaHeight(n);
55644
+ let r = qB(t.scrollArea);
55645
+ r && (r.scrollTop = 0);
55634
55646
  }
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 }) {
55647
+ 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
55648
  let g = N(null), _ = N(null), [v, y] = P(GB), { width: b } = uM(), { getChatPath: x } = et();
55637
55649
  E(() => {
55638
- JB(g.current, {
55650
+ YB(g.current, {
55639
55651
  scrollArea: _.current,
55640
55652
  setScrollAreaHeight: y
55641
55653
  });
@@ -55656,7 +55668,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55656
55668
  T(t);
55657
55669
  }, [t, T]);
55658
55670
  let D = (e) => {
55659
- n(e.target.value), JB(e.currentTarget, {
55671
+ n(e.target.value), YB(e.currentTarget, {
55660
55672
  scrollArea: _.current,
55661
55673
  setScrollAreaHeight: y
55662
55674
  });
@@ -55673,7 +55685,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55673
55685
  type: "text",
55674
55686
  text: t
55675
55687
  }]
55676
- }), o([]), T(""), n(""), YB(g.current, {
55688
+ }), o([]), T(""), n(""), XB(g.current, {
55677
55689
  scrollArea: _.current,
55678
55690
  setScrollAreaHeight: y
55679
55691
  }), b && b > 768 && g.current?.focus();
@@ -55845,18 +55857,18 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55845
55857
  children: [/* @__PURE__ */ U(RB, {
55846
55858
  className: "gap-0 sm:gap-0.5",
55847
55859
  children: [
55848
- /* @__PURE__ */ H($B, {
55860
+ /* @__PURE__ */ H(eV, {
55849
55861
  fileInputRef: O,
55850
55862
  selectedModelId: d,
55851
55863
  status: r
55852
55864
  }),
55853
- /* @__PURE__ */ H(tV, {
55865
+ /* @__PURE__ */ H(nV, {
55854
55866
  focusTargetRef: g,
55855
55867
  idScope: e,
55856
55868
  onModelChange: p,
55857
55869
  selectedModelId: d
55858
55870
  }),
55859
- /* @__PURE__ */ H(rV, {
55871
+ /* @__PURE__ */ H(iV, {
55860
55872
  disabled: r !== "ready",
55861
55873
  idScope: e,
55862
55874
  onChange: h,
@@ -55864,7 +55876,7 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55864
55876
  value: m
55865
55877
  })
55866
55878
  ]
55867
- }), r === "submitted" || r === "streaming" ? /* @__PURE__ */ H(aV, {
55879
+ }), r === "submitted" || r === "streaming" ? /* @__PURE__ */ H(oV, {
55868
55880
  setMessages: c,
55869
55881
  stop: i
55870
55882
  }) : /* @__PURE__ */ H(zB, {
@@ -55880,8 +55892,8 @@ function XB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55880
55892
  ]
55881
55893
  });
55882
55894
  }
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 }) {
55895
+ 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));
55896
+ function $B({ fileInputRef: e, status: t, selectedModelId: n }) {
55885
55897
  let r = n.includes("reasoning") || n.includes("think");
55886
55898
  return /* @__PURE__ */ H(ef, {
55887
55899
  className: "aspect-square h-8 rounded-lg p-1 transition-colors hover:bg-accent",
@@ -55900,8 +55912,8 @@ function QB({ fileInputRef: e, status: t, selectedModelId: n }) {
55900
55912
  })
55901
55913
  });
55902
55914
  }
55903
- var $B = S(QB);
55904
- function eV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange: r }) {
55915
+ var eV = S($B);
55916
+ function tV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange: r }) {
55905
55917
  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
55918
  anthropic: "Anthropic",
55907
55919
  openai: "OpenAI",
@@ -55945,20 +55957,21 @@ function eV({ focusTargetRef: e, idScope: t, selectedModelId: n, onModelChange:
55945
55957
  })]
55946
55958
  });
55947
55959
  }
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);
55960
+ var nV = S(tV), rV = (e, t) => t.includes(e);
55961
+ function iV({ idScope: e, selectedModelId: t, value: n, onChange: r, disabled: i }) {
55962
+ 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
55963
  return E(() => {
55952
- !a || !r || s === n || r(s);
55964
+ !a || !r || rV(n, o) || r(c ?? "default");
55953
55965
  }, [
55966
+ o,
55967
+ c,
55954
55968
  r,
55955
- s,
55956
55969
  a,
55957
55970
  n
55958
- ]), !a || !r ? null : /* @__PURE__ */ U(yB, {
55971
+ ]), !a || !r || f === "default" ? null : /* @__PURE__ */ U(yB, {
55959
55972
  disabled: i,
55960
55973
  onValueChange: (e) => r(e),
55961
- value: s,
55974
+ value: f,
55962
55975
  children: [/* @__PURE__ */ H(xB, {
55963
55976
  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
55977
  id: `agents-sdk-reasoning-effort-${WB(e)}`,
@@ -55969,16 +55982,13 @@ function rV({ idScope: e, selectedModelId: t, value: n, onChange: r, disabled: i
55969
55982
  children: /* @__PURE__ */ H(bB, { placeholder: "Reasoning" })
55970
55983
  })]
55971
55984
  })
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, {
55985
+ }), /* @__PURE__ */ H(wB, { children: o.map((e) => /* @__PURE__ */ H(EB, {
55976
55986
  value: e,
55977
55987
  children: /* @__PURE__ */ H("span", { children: `Reasoning: ${e}` })
55978
- }, e))] })]
55988
+ }, e)) })]
55979
55989
  });
55980
55990
  }
55981
- function iV({ stop: e, setMessages: t }) {
55991
+ function aV({ stop: e, setMessages: t }) {
55982
55992
  return /* @__PURE__ */ H(ef, {
55983
55993
  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
55994
  "data-testid": "stop-button",
@@ -55988,7 +55998,7 @@ function iV({ stop: e, setMessages: t }) {
55988
55998
  children: /* @__PURE__ */ H(dt, { size: 14 })
55989
55999
  });
55990
56000
  }
55991
- var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedTool: r, isToolbarVisible: i, setIsToolbarVisible: a, isAnimating: o, sendMessage: s, onClick: c }) => {
56001
+ var oV = S(aV), sV = ({ description: e, icon: t, selectedTool: n, setSelectedTool: r, isToolbarVisible: i, setIsToolbarVisible: a, isAnimating: o, sendMessage: s, onClick: c }) => {
55992
56002
  let [l, u] = P(!1);
55993
56003
  E(() => {
55994
56004
  n !== e && u(!1);
@@ -56046,14 +56056,14 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56046
56056
  children: e
56047
56057
  })]
56048
56058
  });
56049
- }, sV = [...[
56059
+ }, cV = [...[
56050
56060
  ,
56051
56061
  ,
56052
56062
  ,
56053
56063
  ,
56054
56064
  ,
56055
56065
  ,
56056
- ]].map((e) => Ze(5)), cV = ({ setSelectedTool: e, sendMessage: t, isAnimating: n }) => {
56066
+ ]].map((e) => Ze(5)), lV = ({ setSelectedTool: e, sendMessage: t, isAnimating: n }) => {
56057
56067
  let r = [
56058
56068
  "Elementary",
56059
56069
  "Middle School",
@@ -56069,7 +56079,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56069
56079
  return () => e();
56070
56080
  }, [a]), /* @__PURE__ */ U("div", {
56071
56081
  className: "relative flex flex-col items-center justify-end",
56072
- children: [sV.map((e) => /* @__PURE__ */ H(yj.div, {
56082
+ children: [cV.map((e) => /* @__PURE__ */ H(yj.div, {
56073
56083
  animate: { opacity: 1 },
56074
56084
  className: "flex size-[40px] flex-row items-center justify-center",
56075
56085
  exit: { opacity: 0 },
@@ -56121,7 +56131,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56121
56131
  })]
56122
56132
  }) })]
56123
56133
  });
56124
- }, lV = ({ isToolbarVisible: e, selectedTool: t, setSelectedTool: n, sendMessage: r, isAnimating: i, setIsToolbarVisible: a, tools: o }) => {
56134
+ }, uV = ({ isToolbarVisible: e, selectedTool: t, setSelectedTool: n, sendMessage: r, isAnimating: i, setIsToolbarVisible: a, tools: o }) => {
56125
56135
  let [s, ...c] = o;
56126
56136
  return /* @__PURE__ */ U(yj.div, {
56127
56137
  animate: {
@@ -56137,7 +56147,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56137
56147
  opacity: 0,
56138
56148
  scale: .95
56139
56149
  },
56140
- children: [/* @__PURE__ */ H(Ek, { children: e && c.map((e) => /* @__PURE__ */ H(oV, {
56150
+ children: [/* @__PURE__ */ H(Ek, { children: e && c.map((e) => /* @__PURE__ */ H(sV, {
56141
56151
  description: e.description,
56142
56152
  icon: e.icon,
56143
56153
  isAnimating: i,
@@ -56145,7 +56155,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56145
56155
  selectedTool: t,
56146
56156
  sendMessage: r,
56147
56157
  setSelectedTool: n
56148
- }, e.description)) }), /* @__PURE__ */ H(oV, {
56158
+ }, e.description)) }), /* @__PURE__ */ H(sV, {
56149
56159
  description: s.description,
56150
56160
  icon: s.icon,
56151
56161
  isAnimating: i,
@@ -56157,7 +56167,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56157
56167
  setSelectedTool: n
56158
56168
  })]
56159
56169
  });
56160
- }, uV = S(({ isToolbarVisible: e, setIsToolbarVisible: t, sendMessage: n, status: r, stop: i, setMessages: a, artifactKind: o }) => {
56170
+ }, dV = S(({ isToolbarVisible: e, setIsToolbarVisible: t, sendMessage: n, status: r, stop: i, setMessages: a, artifactKind: o }) => {
56161
56171
  let s = N(null), c = N(null), [l, u] = P(null), [d, f] = P(!1);
56162
56172
  cM(s, () => {
56163
56173
  t(!1), u(null);
@@ -56174,7 +56184,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56174
56184
  }, []), E(() => {
56175
56185
  r === "streaming" && t(!1);
56176
56186
  }, [r, t]);
56177
- let h = fV.find((e) => e.kind === o);
56187
+ let h = pV.find((e) => e.kind === o);
56178
56188
  if (!h) throw Error("Artifact definition not found!");
56179
56189
  let g = h.toolbar;
56180
56190
  return g.length === 0 ? null : /* @__PURE__ */ H(om, {
@@ -56236,11 +56246,11 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56236
56246
  i(), a((e) => e);
56237
56247
  },
56238
56248
  children: /* @__PURE__ */ H(dt, {})
56239
- }, "stop-icon") : l === "adjust-reading-level" ? /* @__PURE__ */ H(cV, {
56249
+ }, "stop-icon") : l === "adjust-reading-level" ? /* @__PURE__ */ H(lV, {
56240
56250
  isAnimating: d,
56241
56251
  sendMessage: n,
56242
56252
  setSelectedTool: u
56243
- }, "reading-level-selector") : /* @__PURE__ */ H(lV, {
56253
+ }, "reading-level-selector") : /* @__PURE__ */ H(uV, {
56244
56254
  isAnimating: d,
56245
56255
  isToolbarVisible: e,
56246
56256
  selectedTool: l,
@@ -56251,7 +56261,7 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56251
56261
  }, "tools")
56252
56262
  })
56253
56263
  });
56254
- }, (e, t) => !(e.status !== t.status || e.isToolbarVisible !== t.isToolbarVisible || e.artifactKind !== t.artifactKind)), dV = ({ handleVersionChange: e, documents: t, currentVersionIndex: n }) => {
56264
+ }, (e, t) => !(e.status !== t.status || e.isToolbarVisible !== t.isToolbarVisible || e.artifactKind !== t.artifactKind)), fV = ({ handleVersionChange: e, documents: t, currentVersionIndex: n }) => {
56255
56265
  let { artifact: r } = Hy(), { width: i } = uM(), a = i < 768, { mutate: o } = G_(), [s, c] = P(!1);
56256
56266
  if (t) return /* @__PURE__ */ U(yj.div, {
56257
56267
  animate: { y: 0 },
@@ -56286,13 +56296,13 @@ var aV = S(iV), oV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56286
56296
  })]
56287
56297
  })]
56288
56298
  });
56289
- }, fV = [
56299
+ }, pV = [
56290
56300
  LF,
56291
56301
  bM,
56292
56302
  SM,
56293
56303
  HP
56294
56304
  ];
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 }) {
56305
+ 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
56306
  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
56307
  E(() => {
56298
56308
  if (y && y.length > 0) {
@@ -56340,7 +56350,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56340
56350
  }
56341
56351
  let R = (e) => {
56342
56352
  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);
56353
+ }, [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
56354
  if (!V) throw Error("Artifact definition not found!");
56345
56355
  return E(() => {
56346
56356
  h.documentId !== "init" && V.initialize && V.initialize({
@@ -56403,7 +56413,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56403
56413
  votes: f
56404
56414
  }), /* @__PURE__ */ H("div", {
56405
56415
  className: "relative flex w-full flex-row items-end gap-2 px-4 pb-4",
56406
- children: /* @__PURE__ */ H(ZB, {
56416
+ children: /* @__PURE__ */ H(QB, {
56407
56417
  attachments: o,
56408
56418
  chatId: t,
56409
56419
  className: "bg-background dark:bg-muted",
@@ -56499,7 +56509,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56499
56509
  status: h.status,
56500
56510
  suggestions: [],
56501
56511
  title: h.title
56502
- }), /* @__PURE__ */ H(Ek, { children: B && /* @__PURE__ */ H(uV, {
56512
+ }), /* @__PURE__ */ H(Ek, { children: B && /* @__PURE__ */ H(dV, {
56503
56513
  artifactKind: h.kind,
56504
56514
  isToolbarVisible: z,
56505
56515
  sendMessage: c,
@@ -56509,7 +56519,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56509
56519
  stop: a
56510
56520
  }) })]
56511
56521
  }),
56512
- /* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(dV, {
56522
+ /* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(fV, {
56513
56523
  currentVersionIndex: O,
56514
56524
  documents: y,
56515
56525
  handleVersionChange: R
@@ -56518,7 +56528,7 @@ function pV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56518
56528
  })]
56519
56529
  }) });
56520
56530
  }
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", {
56531
+ 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
56532
  className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56523
56533
  children: [/* @__PURE__ */ H(yj.div, {
56524
56534
  animate: {
@@ -56556,7 +56566,7 @@ var mV = S(pV, (e, t) => !(e.status !== t.status || !xe(e.votes, t.votes) || e.i
56556
56566
  }, "overview");
56557
56567
  //#endregion
56558
56568
  //#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 }) {
56569
+ function _V({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c }) {
56560
56570
  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
56571
  return ot(), /* @__PURE__ */ U("div", {
56562
56572
  className: "relative flex-1",
@@ -56566,7 +56576,7 @@ function gV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messag
56566
56576
  children: /* @__PURE__ */ U("div", {
56567
56577
  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
56578
  children: [
56569
- i.length === 0 && /* @__PURE__ */ H(hV, {}),
56579
+ i.length === 0 && /* @__PURE__ */ H(gV, {}),
56570
56580
  i.map((c, l) => p && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ H(TL, {
56571
56581
  addToolApprovalResponse: e,
56572
56582
  chatId: t,
@@ -56594,15 +56604,17 @@ function gV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messag
56594
56604
  })]
56595
56605
  });
56596
56606
  }
56597
- var _V = gV, vV = (e) => e?.parts?.some((e) => {
56607
+ var vV = _V, yV = (e) => e?.parts?.some((e) => {
56598
56608
  let t = e.state;
56599
56609
  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(_);
56610
+ }) ?? !1, bV = (e) => `agents-sdk:chat:${e}:stream`, xV = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), SV = (e) => u(e) ?? "default";
56611
+ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, autoResume: i }) {
56612
+ 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
56613
  E(() => {
56604
56614
  g.current = m;
56605
56615
  }, [m]), E(() => {
56616
+ h(u), v(SV(u));
56617
+ }, [e, u]), E(() => {
56606
56618
  y.current = _;
56607
56619
  }, [_]);
56608
56620
  let { messages: b, setMessages: x, sendMessage: S, status: C, stop: w, regenerate: T, resumeStream: D, addToolApprovalResponse: O } = zy({
@@ -56615,15 +56627,15 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56615
56627
  api: "/api/rb/agents/chat",
56616
56628
  fetch: qd,
56617
56629
  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);
56630
+ 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
56631
  return {
56620
- ...r ? { headers: r } : {},
56632
+ ...a ? { headers: a } : {},
56621
56633
  body: {
56622
56634
  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,
56635
+ ...o ? { messages: e.messages } : { message: r },
56636
+ selectedChatModel: t,
56637
+ ...l(t) && n !== "default" ? {
56638
+ openaiReasoningEffort: n,
56627
56639
  openaiReasoningSummary: "detailed"
56628
56640
  } : {},
56629
56641
  ...e.body
@@ -56650,17 +56662,17 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56650
56662
  de.error("Something went wrong. Please try again.");
56651
56663
  }
56652
56664
  }), k = N(null), A = N("");
56653
- E(() => fe(yV(e), (t) => {
56654
- if (!bV(t) || t.chatId !== e) return;
56665
+ E(() => fe(bV(e), (t) => {
56666
+ if (!xV(t) || t.chatId !== e) return;
56655
56667
  let n = t.message;
56656
- if (bV(n)) {
56668
+ if (xV(n)) {
56657
56669
  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
56670
  if (e && t && r) {
56659
56671
  let i = {
56660
56672
  id: e,
56661
56673
  role: t,
56662
56674
  parts: r,
56663
- metadata: bV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56675
+ metadata: xV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56664
56676
  };
56665
56677
  x((t) => {
56666
56678
  let n = t.findIndex((t) => t.id === e);
@@ -56673,7 +56685,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56673
56685
  return;
56674
56686
  }
56675
56687
  let r = t.part;
56676
- if (!bV(r)) return;
56688
+ if (!xV(r)) return;
56677
56689
  if (r.type === "start" && typeof r.messageId == "string") {
56678
56690
  k.current = r.messageId, A.current = "";
56679
56691
  return;
@@ -56732,7 +56744,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56732
56744
  className: "relative flex h-full min-h-0 min-w-0 overflow-hidden bg-background",
56733
56745
  children: [/* @__PURE__ */ U("div", {
56734
56746
  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, {
56747
+ children: [/* @__PURE__ */ H(vV, {
56736
56748
  addToolApprovalResponse: O,
56737
56749
  chatId: e,
56738
56750
  isArtifactVisible: ee,
@@ -56745,12 +56757,14 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56745
56757
  votes: L
56746
56758
  }), /* @__PURE__ */ H("div", {
56747
56759
  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, {
56760
+ children: !r && /* @__PURE__ */ H(QB, {
56749
56761
  attachments: R,
56750
56762
  chatId: e,
56751
- input: d,
56763
+ input: f,
56752
56764
  messages: b,
56753
- onModelChange: h,
56765
+ onModelChange: (e) => {
56766
+ h(e), v(SV(e));
56767
+ },
56754
56768
  onOpenAIReasoningEffortChange: v,
56755
56769
  openaiReasoningEffort: _,
56756
56770
  selectedModelId: m,
@@ -56762,11 +56776,11 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56762
56776
  stop: w
56763
56777
  })
56764
56778
  })]
56765
- }), /* @__PURE__ */ H(mV, {
56779
+ }), /* @__PURE__ */ H(hV, {
56766
56780
  addToolApprovalResponse: O,
56767
56781
  attachments: R,
56768
56782
  chatId: e,
56769
- input: d,
56783
+ input: f,
56770
56784
  isReadonly: r,
56771
56785
  messages: b,
56772
56786
  regenerate: T,
@@ -56783,7 +56797,7 @@ function xV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56783
56797
  }
56784
56798
  //#endregion
56785
56799
  //#region src/components/data-stream-handler.tsx
56786
- function SV() {
56800
+ function wV() {
56787
56801
  let { dataStream: e, setDataStream: t } = ot(), { artifact: n, setArtifact: r, setMetadata: i } = Hy();
56788
56802
  return E(() => {
56789
56803
  if (!e?.length) return;
@@ -56791,7 +56805,7 @@ function SV() {
56791
56805
  t([]);
56792
56806
  for (let e of a) {
56793
56807
  if (e.type === "data-chat-title") continue;
56794
- let t = fV.find((e) => e.kind === n.kind);
56808
+ let t = pV.find((e) => e.kind === n.kind);
56795
56809
  t?.onStreamPart && t.onStreamPart({
56796
56810
  streamPart: e,
56797
56811
  setArtifact: r,
@@ -56839,4 +56853,4 @@ function SV() {
56839
56853
  ]), null;
56840
56854
  }
56841
56855
  //#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 };
56856
+ 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 };