@rpcbase/agents-sdk 0.4.0 → 0.5.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.
@@ -55583,17 +55583,12 @@ var UB = ({ className: e, ...t }) => /* @__PURE__ */ B("form", {
55583
55583
  });
55584
55584
  //#endregion
55585
55585
  //#region src/components/suggested-actions.tsx
55586
- function YB({ chatId: e, sendMessage: t }) {
55587
- let { getChatPath: n } = lt(), r = [
55588
- "What are the advantages of using Next.js?",
55589
- "Write code to demonstrate Dijkstra's algorithm",
55590
- "Help me write an essay about Silicon Valley",
55591
- "What is the weather in San Francisco?"
55592
- ];
55593
- return /* @__PURE__ */ B("div", {
55586
+ function YB({ chatId: e, sendMessage: t, suggestedActions: n }) {
55587
+ let { getChatPath: r } = lt(), i = n.map((e) => e.trim()).filter(Boolean);
55588
+ return i.length === 0 ? null : /* @__PURE__ */ B("div", {
55594
55589
  className: "grid w-full gap-2 sm:grid-cols-2",
55595
55590
  "data-testid": "suggested-actions",
55596
- children: r.map((r, i) => /* @__PURE__ */ B(Dj.div, {
55591
+ children: i.map((n, i) => /* @__PURE__ */ B(Dj.div, {
55597
55592
  animate: {
55598
55593
  opacity: 1,
55599
55594
  y: 0
@@ -55609,22 +55604,22 @@ function YB({ chatId: e, sendMessage: t }) {
55609
55604
  transition: { delay: .05 * i },
55610
55605
  children: /* @__PURE__ */ B(JB, {
55611
55606
  className: "h-auto w-full whitespace-normal p-3 text-left",
55612
- onClick: (r) => {
55613
- window.history.pushState({}, "", n(e)), t({
55607
+ onClick: (n) => {
55608
+ window.history.pushState({}, "", r(e)), t({
55614
55609
  role: "user",
55615
55610
  parts: [{
55616
55611
  type: "text",
55617
- text: r
55612
+ text: n
55618
55613
  }]
55619
55614
  });
55620
55615
  },
55621
- suggestion: r,
55622
- children: r
55616
+ suggestion: n,
55617
+ children: n
55623
55618
  })
55624
- }, r))
55619
+ }, `${i}-${n}`))
55625
55620
  });
55626
55621
  }
55627
- var XB = _(YB, (e, t) => e.chatId === t.chatId);
55622
+ var XB = _(YB, (e, t) => !(e.chatId !== t.chatId || !_e(e.suggestedActions, t.suggestedActions)));
55628
55623
  //#endregion
55629
55624
  //#region src/components/multimodal-input.tsx
55630
55625
  function ZB(e, t) {
@@ -55663,37 +55658,37 @@ function iV(e, t) {
55663
55658
  let r = tV(t.scrollArea);
55664
55659
  r && (r.scrollTop = 0);
55665
55660
  }
55666
- function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments: a, setAttachments: o, messages: c, setMessages: l, sendMessage: u, className: d, selectedModelId: f, onModelChange: p, openaiReasoningEffort: m = s, onOpenAIReasoningEffortChange: h }) {
55667
- let g = O(null), _ = O(null), [y, b] = k($B), { width: S } = vM(), { getChatPath: C } = lt();
55661
+ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments: a, setAttachments: o, messages: c, setMessages: l, sendMessage: u, className: d, selectedModelId: f, onModelChange: p, openaiReasoningEffort: m = s, onOpenAIReasoningEffortChange: h, suggestedActions: g }) {
55662
+ let _ = O(null), y = O(null), [b, S] = k($B), { width: C } = vM(), { getChatPath: w } = lt();
55668
55663
  x(() => {
55669
- rV(g.current, {
55670
- scrollArea: _.current,
55671
- setScrollAreaHeight: b
55664
+ rV(_.current, {
55665
+ scrollArea: y.current,
55666
+ setScrollAreaHeight: S
55672
55667
  });
55673
- }, [t, S]);
55674
- let w = O(!1);
55668
+ }, [t, C]);
55669
+ let T = O(!1);
55675
55670
  x(() => {
55676
- if (!w.current && S) {
55671
+ if (!T.current && C) {
55677
55672
  let e = setTimeout(() => {
55678
- g.current?.focus(), w.current = !0;
55673
+ _.current?.focus(), T.current = !0;
55679
55674
  }, 100);
55680
55675
  return () => clearTimeout(e);
55681
55676
  }
55682
- }, [S]);
55683
- let [T, E] = pM("input", "");
55677
+ }, [C]);
55678
+ let [E, D] = pM("input", "");
55684
55679
  x(() => {
55685
- g.current && n(g.current.value || T || "");
55686
- }, [T, n]), x(() => {
55687
- E(t);
55688
- }, [t, E]);
55689
- let D = (e) => {
55680
+ _.current && n(_.current.value || E || "");
55681
+ }, [E, n]), x(() => {
55682
+ D(t);
55683
+ }, [t, D]);
55684
+ let A = (e) => {
55690
55685
  n(e.target.value), rV(e.currentTarget, {
55691
- scrollArea: _.current,
55692
- setScrollAreaHeight: b
55686
+ scrollArea: y.current,
55687
+ setScrollAreaHeight: S
55693
55688
  });
55694
- }, A = O(null), [j, M] = k([]), N = v(() => {
55689
+ }, j = O(null), [M, N] = k([]), P = v(() => {
55695
55690
  let r = Yd();
55696
- window.history.pushState({}, "", $d(C(e), r)), u({
55691
+ window.history.pushState({}, "", $d(w(e), r)), u({
55697
55692
  role: "user",
55698
55693
  parts: [...a.map((e) => ({
55699
55694
  type: "file",
@@ -55704,21 +55699,21 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55704
55699
  type: "text",
55705
55700
  text: t
55706
55701
  }]
55707
- }), o([]), E(""), n(""), iV(g.current, {
55708
- scrollArea: _.current,
55709
- setScrollAreaHeight: b
55710
- }), S && S > 768 && g.current?.focus();
55702
+ }), o([]), D(""), n(""), iV(_.current, {
55703
+ scrollArea: y.current,
55704
+ setScrollAreaHeight: S
55705
+ }), C && C > 768 && _.current?.focus();
55711
55706
  }, [
55712
55707
  t,
55713
55708
  n,
55714
55709
  a,
55715
55710
  u,
55716
55711
  o,
55717
- E,
55718
- S,
55712
+ D,
55713
+ C,
55719
55714
  e,
55720
- C
55721
- ]), P = v(async (e) => {
55715
+ w
55716
+ ]), F = v(async (e) => {
55722
55717
  try {
55723
55718
  let t = Yd(), n = await fetch("/api/rb/file-uploads", {
55724
55719
  method: "POST",
@@ -55779,48 +55774,49 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55779
55774
  } catch {
55780
55775
  se.error("Failed to upload file, please try again!");
55781
55776
  }
55782
- }, []), F = v(async (e) => {
55777
+ }, []), I = v(async (e) => {
55783
55778
  let t = Array.from(e.target.files || []);
55784
- M(t.map((e) => e.name));
55779
+ N(t.map((e) => e.name));
55785
55780
  try {
55786
- let e = t.map((e) => P(e)), n = (await Promise.all(e)).filter((e) => e !== void 0);
55781
+ let e = t.map((e) => F(e)), n = (await Promise.all(e)).filter((e) => e !== void 0);
55787
55782
  o((e) => [...e, ...n]);
55788
55783
  } catch (e) {
55789
55784
  console.error("Error uploading files!", e);
55790
55785
  } finally {
55791
- M([]);
55786
+ N([]);
55792
55787
  }
55793
- }, [o, P]), I = v(async (e) => {
55788
+ }, [o, F]), L = v(async (e) => {
55794
55789
  let t = e.clipboardData?.items;
55795
55790
  if (!t) return;
55796
55791
  let n = Array.from(t).filter((e) => e.type.startsWith("image/"));
55797
55792
  if (n.length !== 0) {
55798
- e.preventDefault(), M((e) => [...e, "Pasted image"]);
55793
+ e.preventDefault(), N((e) => [...e, "Pasted image"]);
55799
55794
  try {
55800
- let e = n.map((e) => e.getAsFile()).filter((e) => e !== null).map((e) => P(e)), t = (await Promise.all(e)).filter((e) => e !== void 0 && e.url !== void 0 && e.contentType !== void 0);
55795
+ let e = n.map((e) => e.getAsFile()).filter((e) => e !== null).map((e) => F(e)), t = (await Promise.all(e)).filter((e) => e !== void 0 && e.url !== void 0 && e.contentType !== void 0);
55801
55796
  o((e) => [...e, ...t]);
55802
55797
  } catch (e) {
55803
55798
  console.error("Error uploading pasted images:", e), se.error("Failed to upload pasted image(s)");
55804
55799
  } finally {
55805
- M([]);
55800
+ N([]);
55806
55801
  }
55807
55802
  }
55808
- }, [o, P]);
55803
+ }, [o, F]);
55809
55804
  return x(() => {
55810
- let e = g.current;
55811
- if (e) return e.addEventListener("paste", I), () => e.removeEventListener("paste", I);
55812
- }, [I]), /* @__PURE__ */ V("div", {
55805
+ let e = _.current;
55806
+ if (e) return e.addEventListener("paste", L), () => e.removeEventListener("paste", L);
55807
+ }, [L]), /* @__PURE__ */ V("div", {
55813
55808
  className: W("relative flex w-full flex-col gap-4", d),
55814
55809
  children: [
55815
- c.length === 0 && a.length === 0 && j.length === 0 && /* @__PURE__ */ B(XB, {
55810
+ c.length === 0 && a.length === 0 && M.length === 0 && g && g.length > 0 && /* @__PURE__ */ B(XB, {
55816
55811
  chatId: e,
55817
- sendMessage: u
55812
+ sendMessage: u,
55813
+ suggestedActions: g
55818
55814
  }),
55819
55815
  /* @__PURE__ */ B("input", {
55820
55816
  className: "-top-4 -left-4 pointer-events-none fixed size-0.5 opacity-0",
55821
55817
  multiple: !0,
55822
- onChange: F,
55823
- ref: A,
55818
+ onChange: I,
55819
+ ref: j,
55824
55820
  tabIndex: -1,
55825
55821
  type: "file"
55826
55822
  }),
@@ -55828,23 +55824,23 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55828
55824
  className: "rounded-xl border border-border bg-background p-3 shadow-xs transition-all duration-200 focus-within:border-border hover:border-muted-foreground/50",
55829
55825
  onSubmit: (e) => {
55830
55826
  if (e.preventDefault(), !(!t.trim() && a.length === 0)) {
55831
- if (j.length > 0) {
55827
+ if (M.length > 0) {
55832
55828
  se.error("Please wait for uploads to finish!");
55833
55829
  return;
55834
55830
  }
55835
- r === "ready" ? N() : se.error("Please wait for the model to finish its response!");
55831
+ r === "ready" ? P() : se.error("Please wait for the model to finish its response!");
55836
55832
  }
55837
55833
  },
55838
55834
  children: [
55839
- (a.length > 0 || j.length > 0) && /* @__PURE__ */ V("div", {
55835
+ (a.length > 0 || M.length > 0) && /* @__PURE__ */ V("div", {
55840
55836
  className: "flex flex-row items-end gap-2 overflow-x-scroll",
55841
55837
  "data-testid": "attachments-preview",
55842
55838
  children: [a.map((e) => /* @__PURE__ */ B(vL, {
55843
55839
  attachment: e,
55844
55840
  onRemove: () => {
55845
- o((t) => t.filter((t) => t.url !== e.url)), A.current && (A.current.value = "");
55841
+ o((t) => t.filter((t) => t.url !== e.url)), j.current && (j.current.value = "");
55846
55842
  }
55847
- }, e.url)), j.map((e) => /* @__PURE__ */ B(vL, {
55843
+ }, e.url)), M.map((e) => /* @__PURE__ */ B(vL, {
55848
55844
  attachment: {
55849
55845
  url: "",
55850
55846
  name: e,
@@ -55857,15 +55853,15 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55857
55853
  className: "flex flex-row items-start gap-1 sm:gap-2",
55858
55854
  children: /* @__PURE__ */ B(QR, {
55859
55855
  className: "grow rounded-md",
55860
- ref: _,
55861
- style: { height: y },
55856
+ ref: y,
55857
+ style: { height: b },
55862
55858
  children: /* @__PURE__ */ B(WB, {
55863
55859
  className: "min-h-10 w-full resize-none overflow-y-hidden border-0! border-none! bg-transparent p-2 text-base outline-none ring-0 placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-0 focus-visible:ring-offset-0",
55864
55860
  "data-testid": "multimodal-input",
55865
55861
  disableAutoResize: !0,
55866
- onChange: D,
55862
+ onChange: A,
55867
55863
  placeholder: "Send a message...",
55868
- ref: g,
55864
+ ref: _,
55869
55865
  rows: 1,
55870
55866
  value: t
55871
55867
  })
@@ -55877,12 +55873,12 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55877
55873
  className: "gap-0 sm:gap-0.5",
55878
55874
  children: [
55879
55875
  /* @__PURE__ */ B(cV, {
55880
- fileInputRef: A,
55876
+ fileInputRef: j,
55881
55877
  selectedModelId: f,
55882
55878
  status: r
55883
55879
  }),
55884
55880
  /* @__PURE__ */ B(uV, {
55885
- focusTargetRef: g,
55881
+ focusTargetRef: _,
55886
55882
  idScope: e,
55887
55883
  onModelChange: p,
55888
55884
  selectedModelId: f
@@ -55901,7 +55897,7 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55901
55897
  }) : /* @__PURE__ */ B(qB, {
55902
55898
  className: "size-8 rounded-full bg-primary text-primary-foreground transition-colors duration-200 hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground",
55903
55899
  "data-testid": "send-button",
55904
- disabled: !t.trim() || j.length > 0,
55900
+ disabled: !t.trim() || M.length > 0,
55905
55901
  status: r,
55906
55902
  children: /* @__PURE__ */ B(yt, { size: 14 })
55907
55903
  })]
@@ -55911,7 +55907,7 @@ function aV({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55911
55907
  ]
55912
55908
  });
55913
55909
  }
55914
- var oV = _(aV, (e, t) => !(e.input !== t.input || e.status !== t.status || !_e(e.attachments, t.attachments) || e.selectedModelId !== t.selectedModelId || e.openaiReasoningEffort !== t.openaiReasoningEffort));
55910
+ var oV = _(aV, (e, t) => !(e.input !== t.input || e.status !== t.status || !_e(e.attachments, t.attachments) || e.selectedModelId !== t.selectedModelId || e.openaiReasoningEffort !== t.openaiReasoningEffort || !_e(e.suggestedActions, t.suggestedActions)));
55915
55911
  function sV({ fileInputRef: e, status: t, selectedModelId: n }) {
55916
55912
  let r = n.includes("reasoning") || n.includes("think");
55917
55913
  return /* @__PURE__ */ B(lf, {
@@ -56321,33 +56317,33 @@ var mV = _(pV), hV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56321
56317
  AM,
56322
56318
  XP
56323
56319
  ];
56324
- function SV({ 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 }) {
56325
- let { artifact: h, setArtifact: g, metadata: _, setMetadata: y } = Xy(), { data: b, isLoading: S, mutate: C } = gv(h.documentId !== "init" && h.status !== "streaming" ? `/api/rb/agents/document?id=${h.documentId}` : null, ef), [w, T] = k("edit"), [E, D] = k(null), [O, A] = k(-1);
56320
+ function SV({ 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, suggestedActions: h }) {
56321
+ let { artifact: g, setArtifact: _, metadata: y, setMetadata: b } = Xy(), { data: S, isLoading: C, mutate: w } = gv(g.documentId !== "init" && g.status !== "streaming" ? `/api/rb/agents/document?id=${g.documentId}` : null, ef), [T, E] = k("edit"), [D, O] = k(null), [A, j] = k(-1);
56326
56322
  x(() => {
56327
- if (b && b.length > 0) {
56328
- let e = b.at(-1);
56329
- e && (D(e), A(b.length - 1), g((t) => ({
56323
+ if (S && S.length > 0) {
56324
+ let e = S.at(-1);
56325
+ e && (O(e), j(S.length - 1), _((t) => ({
56330
56326
  ...t,
56331
56327
  content: e.content ?? ""
56332
56328
  })));
56333
56329
  }
56334
- }, [b, g]), x(() => {
56335
- C();
56336
- }, [C]);
56337
- let { mutate: j } = $_(), [M, N] = k(!1), P = v((e) => {
56338
- h && j(`/api/rb/agents/document?id=${h.documentId}`, async (t) => {
56330
+ }, [S, _]), x(() => {
56331
+ w();
56332
+ }, [w]);
56333
+ let { mutate: M } = $_(), [N, P] = k(!1), F = v((e) => {
56334
+ g && M(`/api/rb/agents/document?id=${g.documentId}`, async (t) => {
56339
56335
  if (!t) return [];
56340
56336
  let n = t.at(-1);
56341
- if (!n || !n.content) return N(!1), t;
56337
+ if (!n || !n.content) return P(!1), t;
56342
56338
  if (n.content !== e) {
56343
- await fetch(`/api/rb/agents/document?id=${h.documentId}`, {
56339
+ await fetch(`/api/rb/agents/document?id=${g.documentId}`, {
56344
56340
  method: "POST",
56345
56341
  body: JSON.stringify({
56346
- title: h.title,
56342
+ title: g.title,
56347
56343
  content: e,
56348
- kind: h.kind
56344
+ kind: g.kind
56349
56345
  })
56350
- }), N(!1);
56346
+ }), P(!1);
56351
56347
  let r = {
56352
56348
  ...n,
56353
56349
  content: e,
@@ -56357,30 +56353,30 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56357
56353
  }
56358
56354
  return t;
56359
56355
  }, { revalidate: !1 });
56360
- }, [h, j]), F = hM(P, 2e3), I = v((e, t) => {
56361
- E && e !== E.content && (N(!0), t ? F(e) : P(e));
56356
+ }, [g, M]), I = hM(F, 2e3), L = v((e, t) => {
56357
+ D && e !== D.content && (P(!0), t ? I(e) : F(e));
56362
56358
  }, [
56363
- E,
56364
- F,
56365
- P
56359
+ D,
56360
+ I,
56361
+ F
56366
56362
  ]);
56367
- function L(e) {
56368
- return !b || !b[e] ? "" : b[e].content ?? "";
56363
+ function R(e) {
56364
+ return !S || !S[e] ? "" : S[e].content ?? "";
56369
56365
  }
56370
- let R = (e) => {
56371
- b && (e === "latest" && (A(b.length - 1), T("edit")), e === "toggle" && T((e) => e === "edit" ? "diff" : "edit"), e === "prev" ? O > 0 && A((e) => e - 1) : e === "next" && O < b.length - 1 && A((e) => e + 1));
56372
- }, [z, ee] = k(!1), te = b && b.length > 0 ? O === b.length - 1 : !0, ne = ym(), re = xV.find((e) => e.kind === h.kind);
56373
- if (!re) throw Error("Artifact definition not found!");
56366
+ let z = (e) => {
56367
+ S && (e === "latest" && (j(S.length - 1), E("edit")), e === "toggle" && E((e) => e === "edit" ? "diff" : "edit"), e === "prev" ? A > 0 && j((e) => e - 1) : e === "next" && A < S.length - 1 && j((e) => e + 1));
56368
+ }, [ee, te] = k(!1), ne = S && S.length > 0 ? A === S.length - 1 : !0, re = ym(), U = xV.find((e) => e.kind === g.kind);
56369
+ if (!U) throw Error("Artifact definition not found!");
56374
56370
  return x(() => {
56375
- h.documentId !== "init" && re.initialize && re.initialize({
56376
- documentId: h.documentId,
56377
- setMetadata: y
56371
+ g.documentId !== "init" && U.initialize && U.initialize({
56372
+ documentId: g.documentId,
56373
+ setMetadata: b
56378
56374
  });
56379
56375
  }, [
56380
- h.documentId,
56381
- re,
56382
- y
56383
- ]), /* @__PURE__ */ B(Pk, { children: h.isVisible && /* @__PURE__ */ V(Dj.div, {
56376
+ g.documentId,
56377
+ U,
56378
+ b
56379
+ ]), /* @__PURE__ */ B(Pk, { children: g.isVisible && /* @__PURE__ */ V(Dj.div, {
56384
56380
  animate: { opacity: 1 },
56385
56381
  className: "absolute inset-0 z-50 flex min-h-0 min-w-0 flex-row overflow-hidden bg-background",
56386
56382
  "data-testid": "artifact",
@@ -56389,7 +56385,7 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56389
56385
  transition: { delay: .4 }
56390
56386
  },
56391
56387
  initial: { opacity: 1 },
56392
- children: [!ne && /* @__PURE__ */ V(Dj.div, {
56388
+ children: [!re && /* @__PURE__ */ V(Dj.div, {
56393
56389
  animate: {
56394
56390
  opacity: 1,
56395
56391
  x: 0,
@@ -56413,7 +56409,7 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56413
56409
  x: 10,
56414
56410
  scale: 1
56415
56411
  },
56416
- children: [/* @__PURE__ */ B(Pk, { children: !te && /* @__PURE__ */ B(Dj.div, {
56412
+ children: [/* @__PURE__ */ B(Pk, { children: !ne && /* @__PURE__ */ B(Dj.div, {
56417
56413
  animate: { opacity: 1 },
56418
56414
  className: "absolute inset-0 z-50 bg-background/70",
56419
56415
  exit: { opacity: 0 },
@@ -56422,7 +56418,7 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56422
56418
  className: "flex h-full flex-col items-center justify-between",
56423
56419
  children: [/* @__PURE__ */ B(LL, {
56424
56420
  addToolApprovalResponse: e,
56425
- artifactStatus: h.status,
56421
+ artifactStatus: g.status,
56426
56422
  chatId: t,
56427
56423
  isReadonly: p,
56428
56424
  messages: l,
@@ -56444,7 +56440,8 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56444
56440
  setInput: r,
56445
56441
  setMessages: u,
56446
56442
  status: i,
56447
- stop: a
56443
+ stop: a,
56444
+ suggestedActions: h
56448
56445
  })
56449
56446
  })]
56450
56447
  })]
@@ -56473,7 +56470,7 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56473
56470
  damping: 30
56474
56471
  }
56475
56472
  },
56476
- initial: ne ? {
56473
+ initial: re ? {
56477
56474
  opacity: 0,
56478
56475
  x: 0,
56479
56476
  y: 16,
@@ -56493,131 +56490,137 @@ function SV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56493
56490
  className: "flex flex-col",
56494
56491
  children: [/* @__PURE__ */ B("div", {
56495
56492
  className: "font-medium",
56496
- children: h.title
56497
- }), M ? /* @__PURE__ */ B("div", {
56493
+ children: g.title
56494
+ }), N ? /* @__PURE__ */ B("div", {
56498
56495
  className: "text-muted-foreground text-sm",
56499
56496
  children: "Saving changes..."
56500
- }) : E ? /* @__PURE__ */ B("div", {
56497
+ }) : D ? /* @__PURE__ */ B("div", {
56501
56498
  className: "text-muted-foreground text-sm",
56502
- children: `Updated ${H(new Date(E.createdAt), /* @__PURE__ */ new Date(), { addSuffix: !0 })}`
56499
+ children: `Updated ${H(new Date(D.createdAt), /* @__PURE__ */ new Date(), { addSuffix: !0 })}`
56503
56500
  }) : /* @__PURE__ */ B("div", { className: "mt-2 h-3 w-32 animate-pulse rounded-md bg-muted-foreground/20" })]
56504
56501
  })]
56505
56502
  }), /* @__PURE__ */ B(qF, {
56506
- artifact: h,
56507
- currentVersionIndex: O,
56508
- handleVersionChange: R,
56509
- isCurrentVersion: te,
56510
- metadata: _,
56511
- mode: w,
56512
- setMetadata: y
56503
+ artifact: g,
56504
+ currentVersionIndex: A,
56505
+ handleVersionChange: z,
56506
+ isCurrentVersion: ne,
56507
+ metadata: y,
56508
+ mode: T,
56509
+ setMetadata: b
56513
56510
  })]
56514
56511
  }),
56515
56512
  /* @__PURE__ */ V("div", {
56516
56513
  className: "h-full max-w-full! items-center overflow-y-scroll bg-background dark:bg-muted",
56517
- children: [/* @__PURE__ */ B(re.content, {
56518
- content: te ? h.content : L(O),
56519
- currentVersionIndex: O,
56520
- getDocumentContentById: L,
56521
- isCurrentVersion: te,
56514
+ children: [/* @__PURE__ */ B(U.content, {
56515
+ content: ne ? g.content : R(A),
56516
+ currentVersionIndex: A,
56517
+ getDocumentContentById: R,
56518
+ isCurrentVersion: ne,
56522
56519
  isInline: !1,
56523
- isLoading: S && !h.content,
56524
- metadata: _,
56525
- mode: w,
56526
- onSaveContent: I,
56527
- setMetadata: y,
56528
- status: h.status,
56520
+ isLoading: C && !g.content,
56521
+ metadata: y,
56522
+ mode: T,
56523
+ onSaveContent: L,
56524
+ setMetadata: b,
56525
+ status: g.status,
56529
56526
  suggestions: [],
56530
- title: h.title
56531
- }), /* @__PURE__ */ B(Pk, { children: te && /* @__PURE__ */ B(yV, {
56532
- artifactKind: h.kind,
56533
- isToolbarVisible: z,
56527
+ title: g.title
56528
+ }), /* @__PURE__ */ B(Pk, { children: ne && /* @__PURE__ */ B(yV, {
56529
+ artifactKind: g.kind,
56530
+ isToolbarVisible: ee,
56534
56531
  sendMessage: c,
56535
- setIsToolbarVisible: ee,
56532
+ setIsToolbarVisible: te,
56536
56533
  setMessages: u,
56537
56534
  status: i,
56538
56535
  stop: a
56539
56536
  }) })]
56540
56537
  }),
56541
- /* @__PURE__ */ B(Pk, { children: !te && /* @__PURE__ */ B(bV, {
56542
- currentVersionIndex: O,
56543
- documents: b,
56544
- handleVersionChange: R
56538
+ /* @__PURE__ */ B(Pk, { children: !ne && /* @__PURE__ */ B(bV, {
56539
+ currentVersionIndex: A,
56540
+ documents: S,
56541
+ handleVersionChange: z
56545
56542
  }) })
56546
56543
  ]
56547
56544
  })]
56548
56545
  }) });
56549
56546
  }
56550
- var CV = _(SV, (e, t) => !(e.status !== t.status || !_e(e.votes, t.votes) || e.input !== t.input || !_e(e.messages, t.messages.length))), wV = () => /* @__PURE__ */ V("div", {
56551
- className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56552
- children: [/* @__PURE__ */ B(Dj.div, {
56553
- animate: {
56554
- opacity: 1,
56555
- y: 0
56556
- },
56557
- className: "font-semibold text-xl md:text-2xl",
56558
- exit: {
56559
- opacity: 0,
56560
- y: 10
56561
- },
56562
- initial: {
56563
- opacity: 0,
56564
- y: 10
56565
- },
56566
- transition: { delay: .5 },
56567
- children: "Hello there!"
56568
- }), /* @__PURE__ */ B(Dj.div, {
56569
- animate: {
56570
- opacity: 1,
56571
- y: 0
56572
- },
56573
- className: "text-xl text-muted-foreground md:text-2xl",
56574
- exit: {
56575
- opacity: 0,
56576
- y: 10
56577
- },
56578
- initial: {
56579
- opacity: 0,
56580
- y: 10
56581
- },
56582
- transition: { delay: .6 },
56583
- children: "How can I help you today?"
56584
- })]
56585
- }, "overview");
56547
+ var CV = _(SV, (e, t) => !(e.status !== t.status || !_e(e.votes, t.votes) || e.input !== t.input || !_e(e.messages, t.messages.length) || !_e(e.suggestedActions, t.suggestedActions))), wV = ({ title1: e, title2: t }) => {
56548
+ let n = e?.trim(), r = t?.trim();
56549
+ return !n && !r ? null : /* @__PURE__ */ V("div", {
56550
+ className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56551
+ children: [n && /* @__PURE__ */ B(Dj.div, {
56552
+ animate: {
56553
+ opacity: 1,
56554
+ y: 0
56555
+ },
56556
+ className: "font-semibold text-xl md:text-2xl",
56557
+ exit: {
56558
+ opacity: 0,
56559
+ y: 10
56560
+ },
56561
+ initial: {
56562
+ opacity: 0,
56563
+ y: 10
56564
+ },
56565
+ transition: { delay: .5 },
56566
+ children: n
56567
+ }), r && /* @__PURE__ */ B(Dj.div, {
56568
+ animate: {
56569
+ opacity: 1,
56570
+ y: 0
56571
+ },
56572
+ className: "text-xl text-muted-foreground md:text-2xl",
56573
+ exit: {
56574
+ opacity: 0,
56575
+ y: 10
56576
+ },
56577
+ initial: {
56578
+ opacity: 0,
56579
+ y: 10
56580
+ },
56581
+ transition: { delay: .6 },
56582
+ children: r
56583
+ })]
56584
+ }, "overview");
56585
+ };
56586
56586
  //#endregion
56587
56587
  //#region src/components/messages.tsx
56588
- function TV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c }) {
56589
- 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" ? kL(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 } = ZF({ status: n });
56588
+ function TV({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c, title1: l, title2: u }) {
56589
+ let d = i.at(-1), f = (e) => e === "dynamic-tool" || e.startsWith("tool-"), p = d?.role === "assistant" && (d.parts?.some((e) => e.type === "text" ? !!e.text?.trim() : e.type === "reasoning" ? kL(e) : !!f(e.type)) ?? !1), m = n === "submitted" || n === "streaming" && d?.role === "assistant" && !p, h = n === "streaming" && d?.role === "assistant" && !p, { containerRef: g, endRef: _, isAtBottom: v, scrollToBottom: y, hasSentMessage: b } = ZF({ status: n });
56590
56590
  return mt(), /* @__PURE__ */ V("div", {
56591
56591
  className: "relative flex-1",
56592
56592
  children: [/* @__PURE__ */ B("div", {
56593
56593
  className: "absolute inset-0 touch-pan-y overflow-y-auto",
56594
- ref: m,
56594
+ ref: g,
56595
56595
  children: /* @__PURE__ */ V("div", {
56596
56596
  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",
56597
56597
  children: [
56598
- i.length === 0 && /* @__PURE__ */ B(wV, {}),
56599
- i.map((c, l) => p && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ B(NL, {
56598
+ i.length === 0 && /* @__PURE__ */ B(wV, {
56599
+ title1: l,
56600
+ title2: u
56601
+ }),
56602
+ i.map((c, l) => h && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ B(NL, {
56600
56603
  addToolApprovalResponse: e,
56601
56604
  chatId: t,
56602
56605
  isLoading: n === "streaming" && i.length - 1 === l,
56603
56606
  isReadonly: s,
56604
56607
  message: c,
56605
56608
  regenerate: o,
56606
- requiresScrollPadding: v && l === i.length - 1,
56609
+ requiresScrollPadding: b && l === i.length - 1,
56607
56610
  setMessages: a,
56608
56611
  vote: r ? r.find((e) => e.messageId === c.id) : void 0
56609
56612
  }, c.id)),
56610
- f && /* @__PURE__ */ B(PL, {}),
56613
+ m && /* @__PURE__ */ B(PL, {}),
56611
56614
  /* @__PURE__ */ B("div", {
56612
56615
  className: "min-h-[24px] min-w-[24px] shrink-0",
56613
- ref: h
56616
+ ref: _
56614
56617
  })
56615
56618
  ]
56616
56619
  })
56617
56620
  }), /* @__PURE__ */ B("button", {
56618
56621
  "aria-label": "Scroll to bottom",
56619
- className: `-translate-x-1/2 absolute bottom-4 left-1/2 z-10 rounded-full border bg-background p-2 shadow-lg transition-all hover:bg-muted ${g ? "pointer-events-none scale-0 opacity-0" : "pointer-events-auto scale-100 opacity-100"}`,
56620
- onClick: () => _("smooth"),
56622
+ className: `-translate-x-1/2 absolute bottom-4 left-1/2 z-10 rounded-full border bg-background p-2 shadow-lg transition-all hover:bg-muted ${v ? "pointer-events-none scale-0 opacity-0" : "pointer-events-auto scale-100 opacity-100"}`,
56623
+ onClick: () => y("smooth"),
56621
56624
  type: "button",
56622
56625
  children: /* @__PURE__ */ B(Pf, { className: "size-4" })
56623
56626
  })]
@@ -56627,16 +56630,16 @@ var EV = TV, DV = (e) => e?.parts?.some((e) => {
56627
56630
  let t = e.state;
56628
56631
  return t === "approval-responded" || t === "output-denied";
56629
56632
  }) ?? !1, OV = (e) => `agents-sdk:chat:${e}:stream`, kV = (e) => !!(e && typeof e == "object" && !Array.isArray(e)), AV = (e) => a(e) ?? "default";
56630
- function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, autoResume: s }) {
56631
- let { setDataStream: c } = mt(), { getChatPath: l } = lt(), u = t.has(a) ? a : r, d = AV(u), [f, p] = k(""), [m, h] = k(u), g = O(m), [_, v] = k(d), y = O(_);
56633
+ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, autoResume: s, suggestedActions: c, title1: l, title2: u }) {
56634
+ let { setDataStream: d } = mt(), { getChatPath: f } = lt(), p = t.has(a) ? a : r, m = AV(p), [h, g] = k(""), [_, v] = k(p), y = O(_), [b, S] = k(m), C = O(b);
56632
56635
  x(() => {
56633
- g.current = m;
56634
- }, [m]), x(() => {
56635
- h(u), v(AV(u));
56636
- }, [e, u]), x(() => {
56637
56636
  y.current = _;
56638
- }, [_]);
56639
- let { messages: b, setMessages: S, sendMessage: C, status: w, stop: T, regenerate: E, resumeStream: D, addToolApprovalResponse: A } = qy({
56637
+ }, [_]), x(() => {
56638
+ v(p), S(AV(p));
56639
+ }, [e, p]), x(() => {
56640
+ C.current = b;
56641
+ }, [b]);
56642
+ let { messages: w, setMessages: T, sendMessage: E, status: D, stop: A, regenerate: j, resumeStream: M, addToolApprovalResponse: N } = qy({
56640
56643
  id: e,
56641
56644
  messages: n,
56642
56645
  experimental_throttle: 100,
@@ -56646,7 +56649,7 @@ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, aut
56646
56649
  api: "/api/rb/agents/chat",
56647
56650
  fetch: tf,
56648
56651
  prepareSendMessagesRequest(e) {
56649
- let t = g.current, n = y.current, r = e.messages.at(-1), a = e.messages.at(-2), o = Zd(e.headers, Yd()), s = r?.role !== "user" || r?.role === "user" && DV(a);
56652
+ let t = y.current, n = C.current, r = e.messages.at(-1), a = e.messages.at(-2), o = Zd(e.headers, Yd()), s = r?.role !== "user" || r?.role === "user" && DV(a);
56650
56653
  return {
56651
56654
  ...o ? { headers: o } : {},
56652
56655
  body: {
@@ -56667,7 +56670,7 @@ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, aut
56667
56670
  }
56668
56671
  }),
56669
56672
  onData: (e) => {
56670
- c((t) => t ? [...t, e] : []);
56673
+ d((t) => t ? [...t, e] : []);
56671
56674
  },
56672
56675
  onError: (e) => {
56673
56676
  if (e instanceof Vd) {
@@ -56680,7 +56683,7 @@ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, aut
56680
56683
  }
56681
56684
  se.error("Something went wrong. Please try again.");
56682
56685
  }
56683
- }), j = O(null), M = O("");
56686
+ }), P = O(null), F = O("");
56684
56687
  x(() => ce(OV(e), (t) => {
56685
56688
  if (!kV(t) || t.chatId !== e) return;
56686
56689
  let n = t.message;
@@ -56693,28 +56696,28 @@ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, aut
56693
56696
  parts: r,
56694
56697
  metadata: kV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56695
56698
  };
56696
- S((t) => {
56699
+ T((t) => {
56697
56700
  let n = t.findIndex((t) => t.id === e);
56698
56701
  return n === -1 ? [...t, i] : t.map((e, t) => t === n ? i : e);
56699
56702
  });
56700
56703
  }
56701
56704
  }
56702
56705
  if (t.done === !0) {
56703
- j.current = null, M.current = "";
56706
+ P.current = null, F.current = "";
56704
56707
  return;
56705
56708
  }
56706
56709
  let r = t.part;
56707
56710
  if (!kV(r)) return;
56708
56711
  if (r.type === "start" && typeof r.messageId == "string") {
56709
- j.current = r.messageId, M.current = "";
56712
+ P.current = r.messageId, F.current = "";
56710
56713
  return;
56711
56714
  }
56712
- if (typeof r.type == "string" && r.type.startsWith("data-") && c((e) => e ? [...e, r] : []), r.type !== "text-delta" || typeof r.delta != "string") return;
56713
- let i = j.current;
56715
+ if (typeof r.type == "string" && r.type.startsWith("data-") && d((e) => e ? [...e, r] : []), r.type !== "text-delta" || typeof r.delta != "string") return;
56716
+ let i = P.current;
56714
56717
  if (!i) return;
56715
- M.current += r.delta;
56716
- let a = M.current;
56717
- S((e) => {
56718
+ F.current += r.delta;
56719
+ let a = F.current;
56720
+ T((e) => {
56718
56721
  let t = e.findIndex((e) => e.id === i), n = {
56719
56722
  id: i,
56720
56723
  role: "assistant",
@@ -56728,89 +56731,93 @@ function jV({ id: e, initialMessages: n, initialChatModel: a, isReadonly: o, aut
56728
56731
  });
56729
56732
  }), [
56730
56733
  e,
56731
- c,
56732
- S
56734
+ d,
56735
+ T
56733
56736
  ]);
56734
- let [N] = R(), P = N.get("query"), [F, I] = k(!1);
56737
+ let [I] = R(), L = I.get("query"), [z, ee] = k(!1);
56735
56738
  x(() => {
56736
- if (P && !F) {
56737
- C({
56739
+ if (L && !z) {
56740
+ E({
56738
56741
  role: "user",
56739
56742
  parts: [{
56740
56743
  type: "text",
56741
- text: P
56744
+ text: L
56742
56745
  }]
56743
- }), I(!0);
56746
+ }), ee(!0);
56744
56747
  let t = new URLSearchParams(window.location.search);
56745
56748
  t.delete("query");
56746
56749
  let n = t.toString();
56747
- window.history.replaceState({}, "", `${l(e)}${n ? `?${n}` : ""}`);
56750
+ window.history.replaceState({}, "", `${f(e)}${n ? `?${n}` : ""}`);
56748
56751
  }
56749
56752
  }, [
56750
- P,
56751
- C,
56752
- F,
56753
+ L,
56754
+ E,
56755
+ z,
56753
56756
  e,
56754
- l
56757
+ f
56755
56758
  ]);
56756
- let { data: L } = gv(b.length >= 2 ? `/api/rb/agents/vote?chatId=${e}` : null, ef), [z, ee] = k([]), H = Yy((e) => e.isVisible);
56759
+ let { data: H } = gv(w.length >= 2 ? `/api/rb/agents/vote?chatId=${e}` : null, ef), [te, ne] = k([]), re = Yy((e) => e.isVisible);
56757
56760
  return Zy({
56758
56761
  autoResume: s,
56759
56762
  initialMessages: n,
56760
- resumeStream: D,
56761
- setMessages: S
56763
+ resumeStream: M,
56764
+ setMessages: T
56762
56765
  }), /* @__PURE__ */ V("div", {
56763
56766
  className: "relative flex h-full min-h-0 min-w-0 overflow-hidden bg-background",
56764
56767
  children: [/* @__PURE__ */ V("div", {
56765
56768
  className: "overscroll-behavior-contain flex h-full min-h-0 min-w-0 flex-1 touch-pan-y flex-col bg-background",
56766
56769
  children: [/* @__PURE__ */ B(EV, {
56767
- addToolApprovalResponse: A,
56770
+ addToolApprovalResponse: N,
56768
56771
  chatId: e,
56769
- isArtifactVisible: H,
56772
+ isArtifactVisible: re,
56770
56773
  isReadonly: o,
56771
- messages: b,
56772
- regenerate: E,
56773
- selectedModelId: u,
56774
- setMessages: S,
56775
- status: w,
56776
- votes: L
56774
+ messages: w,
56775
+ regenerate: j,
56776
+ selectedModelId: p,
56777
+ setMessages: T,
56778
+ status: D,
56779
+ title1: l,
56780
+ title2: u,
56781
+ votes: H
56777
56782
  }), /* @__PURE__ */ B("div", {
56778
56783
  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",
56779
56784
  children: !o && /* @__PURE__ */ B(oV, {
56780
- attachments: z,
56785
+ attachments: te,
56781
56786
  chatId: e,
56782
- input: f,
56783
- messages: b,
56787
+ input: h,
56788
+ messages: w,
56784
56789
  onModelChange: (e) => {
56785
- h(e), v(AV(e));
56790
+ v(e), S(AV(e));
56786
56791
  },
56787
- onOpenAIReasoningEffortChange: v,
56788
- openaiReasoningEffort: _,
56789
- selectedModelId: m,
56790
- sendMessage: C,
56791
- setAttachments: ee,
56792
- setInput: p,
56793
- setMessages: S,
56794
- status: w,
56795
- stop: T
56792
+ onOpenAIReasoningEffortChange: S,
56793
+ openaiReasoningEffort: b,
56794
+ selectedModelId: _,
56795
+ sendMessage: E,
56796
+ setAttachments: ne,
56797
+ setInput: g,
56798
+ setMessages: T,
56799
+ status: D,
56800
+ stop: A,
56801
+ suggestedActions: c
56796
56802
  })
56797
56803
  })]
56798
56804
  }), /* @__PURE__ */ B(CV, {
56799
- addToolApprovalResponse: A,
56800
- attachments: z,
56805
+ addToolApprovalResponse: N,
56806
+ attachments: te,
56801
56807
  chatId: e,
56802
- input: f,
56808
+ input: h,
56803
56809
  isReadonly: o,
56804
- messages: b,
56805
- regenerate: E,
56806
- selectedModelId: m,
56807
- sendMessage: C,
56808
- setAttachments: ee,
56809
- setInput: p,
56810
- setMessages: S,
56811
- status: w,
56812
- stop: T,
56813
- votes: L
56810
+ messages: w,
56811
+ regenerate: j,
56812
+ selectedModelId: _,
56813
+ sendMessage: E,
56814
+ setAttachments: ne,
56815
+ setInput: g,
56816
+ setMessages: T,
56817
+ status: D,
56818
+ stop: A,
56819
+ suggestedActions: c,
56820
+ votes: H
56814
56821
  })]
56815
56822
  });
56816
56823
  }