@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.
@@ -55563,17 +55563,12 @@ var FB = ({ className: e, ...t }) => /* @__PURE__ */ H("form", {
55563
55563
  });
55564
55564
  //#endregion
55565
55565
  //#region src/components/suggested-actions.tsx
55566
- function VB({ chatId: e, sendMessage: t }) {
55567
- let { getChatPath: n } = et(), r = [
55568
- "What are the advantages of using Next.js?",
55569
- "Write code to demonstrate Dijkstra's algorithm",
55570
- "Help me write an essay about Silicon Valley",
55571
- "What is the weather in San Francisco?"
55572
- ];
55573
- return /* @__PURE__ */ H("div", {
55566
+ function VB({ chatId: e, sendMessage: t, suggestedActions: n }) {
55567
+ let { getChatPath: r } = et(), i = n.map((e) => e.trim()).filter(Boolean);
55568
+ return i.length === 0 ? null : /* @__PURE__ */ H("div", {
55574
55569
  className: "grid w-full gap-2 sm:grid-cols-2",
55575
55570
  "data-testid": "suggested-actions",
55576
- children: r.map((r, i) => /* @__PURE__ */ H(yj.div, {
55571
+ children: i.map((n, i) => /* @__PURE__ */ H(yj.div, {
55577
55572
  animate: {
55578
55573
  opacity: 1,
55579
55574
  y: 0
@@ -55589,22 +55584,22 @@ function VB({ chatId: e, sendMessage: t }) {
55589
55584
  transition: { delay: .05 * i },
55590
55585
  children: /* @__PURE__ */ H(BB, {
55591
55586
  className: "h-auto w-full whitespace-normal p-3 text-left",
55592
- onClick: (r) => {
55593
- window.history.pushState({}, "", n(e)), t({
55587
+ onClick: (n) => {
55588
+ window.history.pushState({}, "", r(e)), t({
55594
55589
  role: "user",
55595
55590
  parts: [{
55596
55591
  type: "text",
55597
- text: r
55592
+ text: n
55598
55593
  }]
55599
55594
  });
55600
55595
  },
55601
- suggestion: r,
55602
- children: r
55596
+ suggestion: n,
55597
+ children: n
55603
55598
  })
55604
- }, r))
55599
+ }, `${i}-${n}`))
55605
55600
  });
55606
55601
  }
55607
- var HB = S(VB, (e, t) => e.chatId === t.chatId);
55602
+ var HB = S(VB, (e, t) => !(e.chatId !== t.chatId || !xe(e.suggestedActions, t.suggestedActions)));
55608
55603
  //#endregion
55609
55604
  //#region src/components/multimodal-input.tsx
55610
55605
  function UB(e, t) {
@@ -55643,37 +55638,37 @@ function XB(e, t) {
55643
55638
  let r = qB(t.scrollArea);
55644
55639
  r && (r.scrollTop = 0);
55645
55640
  }
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 }) {
55647
- let g = N(null), _ = N(null), [v, y] = P(GB), { width: b } = uM(), { getChatPath: x } = et();
55641
+ 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, suggestedActions: g }) {
55642
+ let _ = N(null), v = N(null), [y, b] = P(GB), { width: x } = uM(), { getChatPath: S } = et();
55648
55643
  E(() => {
55649
- YB(g.current, {
55650
- scrollArea: _.current,
55651
- setScrollAreaHeight: y
55644
+ YB(_.current, {
55645
+ scrollArea: v.current,
55646
+ setScrollAreaHeight: b
55652
55647
  });
55653
- }, [t, b]);
55654
- let S = N(!1);
55648
+ }, [t, x]);
55649
+ let w = N(!1);
55655
55650
  E(() => {
55656
- if (!S.current && b) {
55651
+ if (!w.current && x) {
55657
55652
  let e = setTimeout(() => {
55658
- g.current?.focus(), S.current = !0;
55653
+ _.current?.focus(), w.current = !0;
55659
55654
  }, 100);
55660
55655
  return () => clearTimeout(e);
55661
55656
  }
55662
- }, [b]);
55663
- let [w, T] = aM("input", "");
55657
+ }, [x]);
55658
+ let [T, D] = aM("input", "");
55664
55659
  E(() => {
55665
- g.current && n(g.current.value || w || "");
55666
- }, [w, n]), E(() => {
55667
- T(t);
55668
- }, [t, T]);
55669
- let D = (e) => {
55660
+ _.current && n(_.current.value || T || "");
55661
+ }, [T, n]), E(() => {
55662
+ D(t);
55663
+ }, [t, D]);
55664
+ let O = (e) => {
55670
55665
  n(e.target.value), YB(e.currentTarget, {
55671
- scrollArea: _.current,
55672
- setScrollAreaHeight: y
55666
+ scrollArea: v.current,
55667
+ setScrollAreaHeight: b
55673
55668
  });
55674
- }, O = N(null), [k, A] = P([]), j = C(() => {
55669
+ }, k = N(null), [A, j] = P([]), M = C(() => {
55675
55670
  let r = Vd();
55676
- window.history.pushState({}, "", Gd(x(e), r)), l({
55671
+ window.history.pushState({}, "", Gd(S(e), r)), l({
55677
55672
  role: "user",
55678
55673
  parts: [...a.map((e) => ({
55679
55674
  type: "file",
@@ -55684,21 +55679,21 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55684
55679
  type: "text",
55685
55680
  text: t
55686
55681
  }]
55687
- }), o([]), T(""), n(""), XB(g.current, {
55688
- scrollArea: _.current,
55689
- setScrollAreaHeight: y
55690
- }), b && b > 768 && g.current?.focus();
55682
+ }), o([]), D(""), n(""), XB(_.current, {
55683
+ scrollArea: v.current,
55684
+ setScrollAreaHeight: b
55685
+ }), x && x > 768 && _.current?.focus();
55691
55686
  }, [
55692
55687
  t,
55693
55688
  n,
55694
55689
  a,
55695
55690
  l,
55696
55691
  o,
55697
- T,
55698
- b,
55692
+ D,
55693
+ x,
55699
55694
  e,
55700
- x
55701
- ]), M = C(async (e) => {
55695
+ S
55696
+ ]), F = C(async (e) => {
55702
55697
  try {
55703
55698
  let t = Vd(), n = await fetch("/api/rb/file-uploads", {
55704
55699
  method: "POST",
@@ -55759,48 +55754,49 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55759
55754
  } catch {
55760
55755
  de.error("Failed to upload file, please try again!");
55761
55756
  }
55762
- }, []), F = C(async (e) => {
55757
+ }, []), I = C(async (e) => {
55763
55758
  let t = Array.from(e.target.files || []);
55764
- A(t.map((e) => e.name));
55759
+ j(t.map((e) => e.name));
55765
55760
  try {
55766
- let e = t.map((e) => M(e)), n = (await Promise.all(e)).filter((e) => e !== void 0);
55761
+ let e = t.map((e) => F(e)), n = (await Promise.all(e)).filter((e) => e !== void 0);
55767
55762
  o((e) => [...e, ...n]);
55768
55763
  } catch (e) {
55769
55764
  console.error("Error uploading files!", e);
55770
55765
  } finally {
55771
- A([]);
55766
+ j([]);
55772
55767
  }
55773
- }, [o, M]), I = C(async (e) => {
55768
+ }, [o, F]), L = C(async (e) => {
55774
55769
  let t = e.clipboardData?.items;
55775
55770
  if (!t) return;
55776
55771
  let n = Array.from(t).filter((e) => e.type.startsWith("image/"));
55777
55772
  if (n.length !== 0) {
55778
- e.preventDefault(), A((e) => [...e, "Pasted image"]);
55773
+ e.preventDefault(), j((e) => [...e, "Pasted image"]);
55779
55774
  try {
55780
- let e = n.map((e) => e.getAsFile()).filter((e) => e !== null).map((e) => M(e)), t = (await Promise.all(e)).filter((e) => e !== void 0 && e.url !== void 0 && e.contentType !== void 0);
55775
+ 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);
55781
55776
  o((e) => [...e, ...t]);
55782
55777
  } catch (e) {
55783
55778
  console.error("Error uploading pasted images:", e), de.error("Failed to upload pasted image(s)");
55784
55779
  } finally {
55785
- A([]);
55780
+ j([]);
55786
55781
  }
55787
55782
  }
55788
- }, [o, M]);
55783
+ }, [o, F]);
55789
55784
  return E(() => {
55790
- let e = g.current;
55791
- if (e) return e.addEventListener("paste", I), () => e.removeEventListener("paste", I);
55792
- }, [I]), /* @__PURE__ */ U("div", {
55785
+ let e = _.current;
55786
+ if (e) return e.addEventListener("paste", L), () => e.removeEventListener("paste", L);
55787
+ }, [L]), /* @__PURE__ */ U("div", {
55793
55788
  className: G("relative flex w-full flex-col gap-4", u),
55794
55789
  children: [
55795
- s.length === 0 && a.length === 0 && k.length === 0 && /* @__PURE__ */ H(HB, {
55790
+ s.length === 0 && a.length === 0 && A.length === 0 && g && g.length > 0 && /* @__PURE__ */ H(HB, {
55796
55791
  chatId: e,
55797
- sendMessage: l
55792
+ sendMessage: l,
55793
+ suggestedActions: g
55798
55794
  }),
55799
55795
  /* @__PURE__ */ H("input", {
55800
55796
  className: "-top-4 -left-4 pointer-events-none fixed size-0.5 opacity-0",
55801
55797
  multiple: !0,
55802
- onChange: F,
55803
- ref: O,
55798
+ onChange: I,
55799
+ ref: k,
55804
55800
  tabIndex: -1,
55805
55801
  type: "file"
55806
55802
  }),
@@ -55808,23 +55804,23 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55808
55804
  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",
55809
55805
  onSubmit: (e) => {
55810
55806
  if (e.preventDefault(), !(!t.trim() && a.length === 0)) {
55811
- if (k.length > 0) {
55807
+ if (A.length > 0) {
55812
55808
  de.error("Please wait for uploads to finish!");
55813
55809
  return;
55814
55810
  }
55815
- r === "ready" ? j() : de.error("Please wait for the model to finish its response!");
55811
+ r === "ready" ? M() : de.error("Please wait for the model to finish its response!");
55816
55812
  }
55817
55813
  },
55818
55814
  children: [
55819
- (a.length > 0 || k.length > 0) && /* @__PURE__ */ U("div", {
55815
+ (a.length > 0 || A.length > 0) && /* @__PURE__ */ U("div", {
55820
55816
  className: "flex flex-row items-end gap-2 overflow-x-scroll",
55821
55817
  "data-testid": "attachments-preview",
55822
55818
  children: [a.map((e) => /* @__PURE__ */ H(uL, {
55823
55819
  attachment: e,
55824
55820
  onRemove: () => {
55825
- o((t) => t.filter((t) => t.url !== e.url)), O.current && (O.current.value = "");
55821
+ o((t) => t.filter((t) => t.url !== e.url)), k.current && (k.current.value = "");
55826
55822
  }
55827
- }, e.url)), k.map((e) => /* @__PURE__ */ H(uL, {
55823
+ }, e.url)), A.map((e) => /* @__PURE__ */ H(uL, {
55828
55824
  attachment: {
55829
55825
  url: "",
55830
55826
  name: e,
@@ -55837,15 +55833,15 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55837
55833
  className: "flex flex-row items-start gap-1 sm:gap-2",
55838
55834
  children: /* @__PURE__ */ H(WR, {
55839
55835
  className: "grow rounded-md",
55840
- ref: _,
55841
- style: { height: v },
55836
+ ref: v,
55837
+ style: { height: y },
55842
55838
  children: /* @__PURE__ */ H(IB, {
55843
55839
  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",
55844
55840
  "data-testid": "multimodal-input",
55845
55841
  disableAutoResize: !0,
55846
- onChange: D,
55842
+ onChange: O,
55847
55843
  placeholder: "Send a message...",
55848
- ref: g,
55844
+ ref: _,
55849
55845
  rows: 1,
55850
55846
  value: t
55851
55847
  })
@@ -55857,12 +55853,12 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55857
55853
  className: "gap-0 sm:gap-0.5",
55858
55854
  children: [
55859
55855
  /* @__PURE__ */ H(eV, {
55860
- fileInputRef: O,
55856
+ fileInputRef: k,
55861
55857
  selectedModelId: d,
55862
55858
  status: r
55863
55859
  }),
55864
55860
  /* @__PURE__ */ H(nV, {
55865
- focusTargetRef: g,
55861
+ focusTargetRef: _,
55866
55862
  idScope: e,
55867
55863
  onModelChange: p,
55868
55864
  selectedModelId: d
@@ -55881,7 +55877,7 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55881
55877
  }) : /* @__PURE__ */ H(zB, {
55882
55878
  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",
55883
55879
  "data-testid": "send-button",
55884
- disabled: !t.trim() || k.length > 0,
55880
+ disabled: !t.trim() || A.length > 0,
55885
55881
  status: r,
55886
55882
  children: /* @__PURE__ */ H(K, { size: 14 })
55887
55883
  })]
@@ -55891,7 +55887,7 @@ function ZB({ chatId: e, input: t, setInput: n, status: r, stop: i, attachments:
55891
55887
  ]
55892
55888
  });
55893
55889
  }
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));
55890
+ 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 || !xe(e.suggestedActions, t.suggestedActions)));
55895
55891
  function $B({ fileInputRef: e, status: t, selectedModelId: n }) {
55896
55892
  let r = n.includes("reasoning") || n.includes("think");
55897
55893
  return /* @__PURE__ */ H(ef, {
@@ -56301,33 +56297,33 @@ var oV = S(aV), sV = ({ description: e, icon: t, selectedTool: n, setSelectedToo
56301
56297
  SM,
56302
56298
  HP
56303
56299
  ];
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 }) {
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);
56300
+ 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, suggestedActions: h }) {
56301
+ let { artifact: g, setArtifact: _, metadata: v, setMetadata: y } = Hy(), { data: b, isLoading: x, mutate: S } = cv(g.documentId !== "init" && g.status !== "streaming" ? `/api/rb/agents/document?id=${g.documentId}` : null, Kd), [w, T] = P("edit"), [D, O] = P(null), [k, A] = P(-1);
56306
56302
  E(() => {
56307
- if (y && y.length > 0) {
56308
- let e = y.at(-1);
56309
- e && (D(e), k(y.length - 1), g((t) => ({
56303
+ if (b && b.length > 0) {
56304
+ let e = b.at(-1);
56305
+ e && (O(e), A(b.length - 1), _((t) => ({
56310
56306
  ...t,
56311
56307
  content: e.content ?? ""
56312
56308
  })));
56313
56309
  }
56314
- }, [y, g]), E(() => {
56315
- x();
56316
- }, [x]);
56317
- let { mutate: A } = G_(), [j, M] = P(!1), N = C((e) => {
56318
- h && A(`/api/rb/agents/document?id=${h.documentId}`, async (t) => {
56310
+ }, [b, _]), E(() => {
56311
+ S();
56312
+ }, [S]);
56313
+ let { mutate: j } = G_(), [M, N] = P(!1), F = C((e) => {
56314
+ g && j(`/api/rb/agents/document?id=${g.documentId}`, async (t) => {
56319
56315
  if (!t) return [];
56320
56316
  let n = t.at(-1);
56321
- if (!n || !n.content) return M(!1), t;
56317
+ if (!n || !n.content) return N(!1), t;
56322
56318
  if (n.content !== e) {
56323
- await fetch(`/api/rb/agents/document?id=${h.documentId}`, {
56319
+ await fetch(`/api/rb/agents/document?id=${g.documentId}`, {
56324
56320
  method: "POST",
56325
56321
  body: JSON.stringify({
56326
- title: h.title,
56322
+ title: g.title,
56327
56323
  content: e,
56328
- kind: h.kind
56324
+ kind: g.kind
56329
56325
  })
56330
- }), M(!1);
56326
+ }), N(!1);
56331
56327
  let r = {
56332
56328
  ...n,
56333
56329
  content: e,
@@ -56337,30 +56333,30 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56337
56333
  }
56338
56334
  return t;
56339
56335
  }, { revalidate: !1 });
56340
- }, [h, A]), F = sM(N, 2e3), I = C((e, t) => {
56341
- T && e !== T.content && (M(!0), t ? F(e) : N(e));
56336
+ }, [g, j]), I = sM(F, 2e3), L = C((e, t) => {
56337
+ D && e !== D.content && (N(!0), t ? I(e) : F(e));
56342
56338
  }, [
56343
- T,
56344
- F,
56345
- N
56339
+ D,
56340
+ I,
56341
+ F
56346
56342
  ]);
56347
- function L(e) {
56348
- return !y || !y[e] ? "" : y[e].content ?? "";
56343
+ function R(e) {
56344
+ return !b || !b[e] ? "" : b[e].content ?? "";
56349
56345
  }
56350
- let R = (e) => {
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));
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);
56353
- if (!V) throw Error("Artifact definition not found!");
56346
+ let z = (e) => {
56347
+ b && (e === "latest" && (A(b.length - 1), T("edit")), e === "toggle" && T((e) => e === "edit" ? "diff" : "edit"), e === "prev" ? k > 0 && A((e) => e - 1) : e === "next" && k < b.length - 1 && A((e) => e + 1));
56348
+ }, [ee, B] = P(!1), te = b && b.length > 0 ? k === b.length - 1 : !0, V = dm(), ne = pV.find((e) => e.kind === g.kind);
56349
+ if (!ne) throw Error("Artifact definition not found!");
56354
56350
  return E(() => {
56355
- h.documentId !== "init" && V.initialize && V.initialize({
56356
- documentId: h.documentId,
56357
- setMetadata: v
56351
+ g.documentId !== "init" && ne.initialize && ne.initialize({
56352
+ documentId: g.documentId,
56353
+ setMetadata: y
56358
56354
  });
56359
56355
  }, [
56360
- h.documentId,
56361
- V,
56362
- v
56363
- ]), /* @__PURE__ */ H(Ek, { children: h.isVisible && /* @__PURE__ */ U(yj.div, {
56356
+ g.documentId,
56357
+ ne,
56358
+ y
56359
+ ]), /* @__PURE__ */ H(Ek, { children: g.isVisible && /* @__PURE__ */ U(yj.div, {
56364
56360
  animate: { opacity: 1 },
56365
56361
  className: "absolute inset-0 z-50 flex min-h-0 min-w-0 flex-row overflow-hidden bg-background",
56366
56362
  "data-testid": "artifact",
@@ -56369,7 +56365,7 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56369
56365
  transition: { delay: .4 }
56370
56366
  },
56371
56367
  initial: { opacity: 1 },
56372
- children: [!te && /* @__PURE__ */ U(yj.div, {
56368
+ children: [!V && /* @__PURE__ */ U(yj.div, {
56373
56369
  animate: {
56374
56370
  opacity: 1,
56375
56371
  x: 0,
@@ -56393,7 +56389,7 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56393
56389
  x: 10,
56394
56390
  scale: 1
56395
56391
  },
56396
- children: [/* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(yj.div, {
56392
+ children: [/* @__PURE__ */ H(Ek, { children: !te && /* @__PURE__ */ H(yj.div, {
56397
56393
  animate: { opacity: 1 },
56398
56394
  className: "absolute inset-0 z-50 bg-background/70",
56399
56395
  exit: { opacity: 0 },
@@ -56402,7 +56398,7 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56402
56398
  className: "flex h-full flex-col items-center justify-between",
56403
56399
  children: [/* @__PURE__ */ H(kL, {
56404
56400
  addToolApprovalResponse: e,
56405
- artifactStatus: h.status,
56401
+ artifactStatus: g.status,
56406
56402
  chatId: t,
56407
56403
  isReadonly: p,
56408
56404
  messages: l,
@@ -56424,7 +56420,8 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56424
56420
  setInput: r,
56425
56421
  setMessages: u,
56426
56422
  status: i,
56427
- stop: a
56423
+ stop: a,
56424
+ suggestedActions: h
56428
56425
  })
56429
56426
  })]
56430
56427
  })]
@@ -56453,7 +56450,7 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56453
56450
  damping: 30
56454
56451
  }
56455
56452
  },
56456
- initial: te ? {
56453
+ initial: V ? {
56457
56454
  opacity: 0,
56458
56455
  x: 0,
56459
56456
  y: 16,
@@ -56473,131 +56470,137 @@ function mV({ addToolApprovalResponse: e, chatId: t, input: n, setInput: r, stat
56473
56470
  className: "flex flex-col",
56474
56471
  children: [/* @__PURE__ */ H("div", {
56475
56472
  className: "font-medium",
56476
- children: h.title
56477
- }), j ? /* @__PURE__ */ H("div", {
56473
+ children: g.title
56474
+ }), M ? /* @__PURE__ */ H("div", {
56478
56475
  className: "text-muted-foreground text-sm",
56479
56476
  children: "Saving changes..."
56480
- }) : T ? /* @__PURE__ */ H("div", {
56477
+ }) : D ? /* @__PURE__ */ H("div", {
56481
56478
  className: "text-muted-foreground text-sm",
56482
- children: `Updated ${re(new Date(T.createdAt), /* @__PURE__ */ new Date(), { addSuffix: !0 })}`
56479
+ children: `Updated ${re(new Date(D.createdAt), /* @__PURE__ */ new Date(), { addSuffix: !0 })}`
56483
56480
  }) : /* @__PURE__ */ H("div", { className: "mt-2 h-3 w-32 animate-pulse rounded-md bg-muted-foreground/20" })]
56484
56481
  })]
56485
56482
  }), /* @__PURE__ */ H(zF, {
56486
- artifact: h,
56487
- currentVersionIndex: O,
56488
- handleVersionChange: R,
56489
- isCurrentVersion: B,
56490
- metadata: _,
56491
- mode: S,
56492
- setMetadata: v
56483
+ artifact: g,
56484
+ currentVersionIndex: k,
56485
+ handleVersionChange: z,
56486
+ isCurrentVersion: te,
56487
+ metadata: v,
56488
+ mode: w,
56489
+ setMetadata: y
56493
56490
  })]
56494
56491
  }),
56495
56492
  /* @__PURE__ */ U("div", {
56496
56493
  className: "h-full max-w-full! items-center overflow-y-scroll bg-background dark:bg-muted",
56497
- children: [/* @__PURE__ */ H(V.content, {
56498
- content: B ? h.content : L(O),
56499
- currentVersionIndex: O,
56500
- getDocumentContentById: L,
56501
- isCurrentVersion: B,
56494
+ children: [/* @__PURE__ */ H(ne.content, {
56495
+ content: te ? g.content : R(k),
56496
+ currentVersionIndex: k,
56497
+ getDocumentContentById: R,
56498
+ isCurrentVersion: te,
56502
56499
  isInline: !1,
56503
- isLoading: b && !h.content,
56504
- metadata: _,
56505
- mode: S,
56506
- onSaveContent: I,
56507
- setMetadata: v,
56508
- status: h.status,
56500
+ isLoading: x && !g.content,
56501
+ metadata: v,
56502
+ mode: w,
56503
+ onSaveContent: L,
56504
+ setMetadata: y,
56505
+ status: g.status,
56509
56506
  suggestions: [],
56510
- title: h.title
56511
- }), /* @__PURE__ */ H(Ek, { children: B && /* @__PURE__ */ H(dV, {
56512
- artifactKind: h.kind,
56513
- isToolbarVisible: z,
56507
+ title: g.title
56508
+ }), /* @__PURE__ */ H(Ek, { children: te && /* @__PURE__ */ H(dV, {
56509
+ artifactKind: g.kind,
56510
+ isToolbarVisible: ee,
56514
56511
  sendMessage: c,
56515
- setIsToolbarVisible: ee,
56512
+ setIsToolbarVisible: B,
56516
56513
  setMessages: u,
56517
56514
  status: i,
56518
56515
  stop: a
56519
56516
  }) })]
56520
56517
  }),
56521
- /* @__PURE__ */ H(Ek, { children: !B && /* @__PURE__ */ H(fV, {
56522
- currentVersionIndex: O,
56523
- documents: y,
56524
- handleVersionChange: R
56518
+ /* @__PURE__ */ H(Ek, { children: !te && /* @__PURE__ */ H(fV, {
56519
+ currentVersionIndex: k,
56520
+ documents: b,
56521
+ handleVersionChange: z
56525
56522
  }) })
56526
56523
  ]
56527
56524
  })]
56528
56525
  }) });
56529
56526
  }
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", {
56531
- className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56532
- children: [/* @__PURE__ */ H(yj.div, {
56533
- animate: {
56534
- opacity: 1,
56535
- y: 0
56536
- },
56537
- className: "font-semibold text-xl md:text-2xl",
56538
- exit: {
56539
- opacity: 0,
56540
- y: 10
56541
- },
56542
- initial: {
56543
- opacity: 0,
56544
- y: 10
56545
- },
56546
- transition: { delay: .5 },
56547
- children: "Hello there!"
56548
- }), /* @__PURE__ */ H(yj.div, {
56549
- animate: {
56550
- opacity: 1,
56551
- y: 0
56552
- },
56553
- className: "text-xl text-muted-foreground md:text-2xl",
56554
- exit: {
56555
- opacity: 0,
56556
- y: 10
56557
- },
56558
- initial: {
56559
- opacity: 0,
56560
- y: 10
56561
- },
56562
- transition: { delay: .6 },
56563
- children: "How can I help you today?"
56564
- })]
56565
- }, "overview");
56527
+ 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) || !xe(e.suggestedActions, t.suggestedActions))), gV = ({ title1: e, title2: t }) => {
56528
+ let n = e?.trim(), r = t?.trim();
56529
+ return !n && !r ? null : /* @__PURE__ */ U("div", {
56530
+ className: "mx-auto mt-4 flex size-full max-w-3xl flex-col justify-center px-4 md:mt-16 md:px-8",
56531
+ children: [n && /* @__PURE__ */ H(yj.div, {
56532
+ animate: {
56533
+ opacity: 1,
56534
+ y: 0
56535
+ },
56536
+ className: "font-semibold text-xl md:text-2xl",
56537
+ exit: {
56538
+ opacity: 0,
56539
+ y: 10
56540
+ },
56541
+ initial: {
56542
+ opacity: 0,
56543
+ y: 10
56544
+ },
56545
+ transition: { delay: .5 },
56546
+ children: n
56547
+ }), r && /* @__PURE__ */ H(yj.div, {
56548
+ animate: {
56549
+ opacity: 1,
56550
+ y: 0
56551
+ },
56552
+ className: "text-xl text-muted-foreground md:text-2xl",
56553
+ exit: {
56554
+ opacity: 0,
56555
+ y: 10
56556
+ },
56557
+ initial: {
56558
+ opacity: 0,
56559
+ y: 10
56560
+ },
56561
+ transition: { delay: .6 },
56562
+ children: r
56563
+ })]
56564
+ }, "overview");
56565
+ };
56566
56566
  //#endregion
56567
56567
  //#region src/components/messages.tsx
56568
- function _V({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c }) {
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 });
56568
+ function _V({ addToolApprovalResponse: e, chatId: t, status: n, votes: r, messages: i, setMessages: a, regenerate: o, isReadonly: s, selectedModelId: c, title1: l, title2: u }) {
56569
+ 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" ? xL(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 } = UF({ status: n });
56570
56570
  return ot(), /* @__PURE__ */ U("div", {
56571
56571
  className: "relative flex-1",
56572
56572
  children: [/* @__PURE__ */ H("div", {
56573
56573
  className: "absolute inset-0 touch-pan-y overflow-y-auto",
56574
- ref: m,
56574
+ ref: g,
56575
56575
  children: /* @__PURE__ */ U("div", {
56576
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",
56577
56577
  children: [
56578
- i.length === 0 && /* @__PURE__ */ H(gV, {}),
56579
- i.map((c, l) => p && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ H(TL, {
56578
+ i.length === 0 && /* @__PURE__ */ H(gV, {
56579
+ title1: l,
56580
+ title2: u
56581
+ }),
56582
+ i.map((c, l) => h && l === i.length - 1 && c.role === "assistant" ? null : /* @__PURE__ */ H(TL, {
56580
56583
  addToolApprovalResponse: e,
56581
56584
  chatId: t,
56582
56585
  isLoading: n === "streaming" && i.length - 1 === l,
56583
56586
  isReadonly: s,
56584
56587
  message: c,
56585
56588
  regenerate: o,
56586
- requiresScrollPadding: v && l === i.length - 1,
56589
+ requiresScrollPadding: b && l === i.length - 1,
56587
56590
  setMessages: a,
56588
56591
  vote: r ? r.find((e) => e.messageId === c.id) : void 0
56589
56592
  }, c.id)),
56590
- f && /* @__PURE__ */ H(EL, {}),
56593
+ m && /* @__PURE__ */ H(EL, {}),
56591
56594
  /* @__PURE__ */ H("div", {
56592
56595
  className: "min-h-[24px] min-w-[24px] shrink-0",
56593
- ref: h
56596
+ ref: _
56594
56597
  })
56595
56598
  ]
56596
56599
  })
56597
56600
  }), /* @__PURE__ */ H("button", {
56598
56601
  "aria-label": "Scroll to bottom",
56599
- 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"}`,
56600
- onClick: () => _("smooth"),
56602
+ 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"}`,
56603
+ onClick: () => y("smooth"),
56601
56604
  type: "button",
56602
56605
  children: /* @__PURE__ */ H(Ef, { className: "size-4" })
56603
56606
  })]
@@ -56607,16 +56610,16 @@ var vV = _V, yV = (e) => e?.parts?.some((e) => {
56607
56610
  let t = e.state;
56608
56611
  return t === "approval-responded" || t === "output-denied";
56609
56612
  }) ?? !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(_);
56613
+ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, autoResume: i, suggestedActions: a, title1: s, title2: u }) {
56614
+ let { setDataStream: d } = ot(), { getChatPath: f } = et(), p = o.has(n) ? n : c, m = SV(p), [h, g] = P(""), [_, v] = P(p), y = N(_), [b, x] = P(m), S = N(b);
56612
56615
  E(() => {
56613
- g.current = m;
56614
- }, [m]), E(() => {
56615
- h(u), v(SV(u));
56616
- }, [e, u]), E(() => {
56617
56616
  y.current = _;
56618
- }, [_]);
56619
- let { messages: b, setMessages: x, sendMessage: S, status: C, stop: w, regenerate: T, resumeStream: D, addToolApprovalResponse: O } = zy({
56617
+ }, [_]), E(() => {
56618
+ v(p), x(SV(p));
56619
+ }, [e, p]), E(() => {
56620
+ S.current = b;
56621
+ }, [b]);
56622
+ let { messages: C, setMessages: w, sendMessage: T, status: D, stop: O, regenerate: k, resumeStream: A, addToolApprovalResponse: j } = zy({
56620
56623
  id: e,
56621
56624
  messages: t,
56622
56625
  experimental_throttle: 100,
@@ -56626,7 +56629,7 @@ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56626
56629
  api: "/api/rb/agents/chat",
56627
56630
  fetch: qd,
56628
56631
  prepareSendMessagesRequest(e) {
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);
56632
+ let t = y.current, n = S.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);
56630
56633
  return {
56631
56634
  ...a ? { headers: a } : {},
56632
56635
  body: {
@@ -56647,7 +56650,7 @@ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56647
56650
  }
56648
56651
  }),
56649
56652
  onData: (e) => {
56650
- a((t) => t ? [...t, e] : []);
56653
+ d((t) => t ? [...t, e] : []);
56651
56654
  },
56652
56655
  onError: (e) => {
56653
56656
  if (e instanceof Nd) {
@@ -56660,7 +56663,7 @@ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56660
56663
  }
56661
56664
  de.error("Something went wrong. Please try again.");
56662
56665
  }
56663
- }), k = N(null), A = N("");
56666
+ }), M = N(null), F = N("");
56664
56667
  E(() => fe(bV(e), (t) => {
56665
56668
  if (!xV(t) || t.chatId !== e) return;
56666
56669
  let n = t.message;
@@ -56673,34 +56676,34 @@ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56673
56676
  parts: r,
56674
56677
  metadata: xV(n.metadata) ? n.metadata : { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56675
56678
  };
56676
- x((t) => {
56679
+ w((t) => {
56677
56680
  let n = t.findIndex((t) => t.id === e);
56678
56681
  return n === -1 ? [...t, i] : t.map((e, t) => t === n ? i : e);
56679
56682
  });
56680
56683
  }
56681
56684
  }
56682
56685
  if (t.done === !0) {
56683
- k.current = null, A.current = "";
56686
+ M.current = null, F.current = "";
56684
56687
  return;
56685
56688
  }
56686
56689
  let r = t.part;
56687
56690
  if (!xV(r)) return;
56688
56691
  if (r.type === "start" && typeof r.messageId == "string") {
56689
- k.current = r.messageId, A.current = "";
56692
+ M.current = r.messageId, F.current = "";
56690
56693
  return;
56691
56694
  }
56692
- if (typeof r.type == "string" && r.type.startsWith("data-") && a((e) => e ? [...e, r] : []), r.type !== "text-delta" || typeof r.delta != "string") return;
56693
- let i = k.current;
56695
+ if (typeof r.type == "string" && r.type.startsWith("data-") && d((e) => e ? [...e, r] : []), r.type !== "text-delta" || typeof r.delta != "string") return;
56696
+ let i = M.current;
56694
56697
  if (!i) return;
56695
- A.current += r.delta;
56696
- let o = A.current;
56697
- x((e) => {
56698
+ F.current += r.delta;
56699
+ let a = F.current;
56700
+ w((e) => {
56698
56701
  let t = e.findIndex((e) => e.id === i), n = {
56699
56702
  id: i,
56700
56703
  role: "assistant",
56701
56704
  parts: [{
56702
56705
  type: "text",
56703
- text: o
56706
+ text: a
56704
56707
  }],
56705
56708
  metadata: { createdAt: (/* @__PURE__ */ new Date()).toISOString() }
56706
56709
  };
@@ -56708,89 +56711,93 @@ function CV({ id: e, initialMessages: t, initialChatModel: n, isReadonly: r, aut
56708
56711
  });
56709
56712
  }), [
56710
56713
  e,
56711
- a,
56712
- x
56714
+ d,
56715
+ w
56713
56716
  ]);
56714
- let [j] = V(), M = j.get("query"), [F, I] = P(!1);
56717
+ let [I] = V(), L = I.get("query"), [R, z] = P(!1);
56715
56718
  E(() => {
56716
- if (M && !F) {
56717
- S({
56719
+ if (L && !R) {
56720
+ T({
56718
56721
  role: "user",
56719
56722
  parts: [{
56720
56723
  type: "text",
56721
- text: M
56724
+ text: L
56722
56725
  }]
56723
- }), I(!0);
56726
+ }), z(!0);
56724
56727
  let t = new URLSearchParams(window.location.search);
56725
56728
  t.delete("query");
56726
56729
  let n = t.toString();
56727
- window.history.replaceState({}, "", `${s(e)}${n ? `?${n}` : ""}`);
56730
+ window.history.replaceState({}, "", `${f(e)}${n ? `?${n}` : ""}`);
56728
56731
  }
56729
56732
  }, [
56730
- M,
56731
- S,
56732
- F,
56733
+ L,
56734
+ T,
56735
+ R,
56733
56736
  e,
56734
- s
56737
+ f
56735
56738
  ]);
56736
- let { data: L } = cv(b.length >= 2 ? `/api/rb/agents/vote?chatId=${e}` : null, Kd), [R, z] = P([]), ee = Vy((e) => e.isVisible);
56739
+ let { data: ee } = cv(C.length >= 2 ? `/api/rb/agents/vote?chatId=${e}` : null, Kd), [B, te] = P([]), ne = Vy((e) => e.isVisible);
56737
56740
  return Uy({
56738
56741
  autoResume: i,
56739
56742
  initialMessages: t,
56740
- resumeStream: D,
56741
- setMessages: x
56743
+ resumeStream: A,
56744
+ setMessages: w
56742
56745
  }), /* @__PURE__ */ U("div", {
56743
56746
  className: "relative flex h-full min-h-0 min-w-0 overflow-hidden bg-background",
56744
56747
  children: [/* @__PURE__ */ U("div", {
56745
56748
  className: "overscroll-behavior-contain flex h-full min-h-0 min-w-0 flex-1 touch-pan-y flex-col bg-background",
56746
56749
  children: [/* @__PURE__ */ H(vV, {
56747
- addToolApprovalResponse: O,
56750
+ addToolApprovalResponse: j,
56748
56751
  chatId: e,
56749
- isArtifactVisible: ee,
56752
+ isArtifactVisible: ne,
56750
56753
  isReadonly: r,
56751
- messages: b,
56752
- regenerate: T,
56753
- selectedModelId: u,
56754
- setMessages: x,
56755
- status: C,
56756
- votes: L
56754
+ messages: C,
56755
+ regenerate: k,
56756
+ selectedModelId: p,
56757
+ setMessages: w,
56758
+ status: D,
56759
+ title1: s,
56760
+ title2: u,
56761
+ votes: ee
56757
56762
  }), /* @__PURE__ */ H("div", {
56758
56763
  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",
56759
56764
  children: !r && /* @__PURE__ */ H(QB, {
56760
- attachments: R,
56765
+ attachments: B,
56761
56766
  chatId: e,
56762
- input: f,
56763
- messages: b,
56767
+ input: h,
56768
+ messages: C,
56764
56769
  onModelChange: (e) => {
56765
- h(e), v(SV(e));
56770
+ v(e), x(SV(e));
56766
56771
  },
56767
- onOpenAIReasoningEffortChange: v,
56768
- openaiReasoningEffort: _,
56769
- selectedModelId: m,
56770
- sendMessage: S,
56771
- setAttachments: z,
56772
- setInput: p,
56773
- setMessages: x,
56774
- status: C,
56775
- stop: w
56772
+ onOpenAIReasoningEffortChange: x,
56773
+ openaiReasoningEffort: b,
56774
+ selectedModelId: _,
56775
+ sendMessage: T,
56776
+ setAttachments: te,
56777
+ setInput: g,
56778
+ setMessages: w,
56779
+ status: D,
56780
+ stop: O,
56781
+ suggestedActions: a
56776
56782
  })
56777
56783
  })]
56778
56784
  }), /* @__PURE__ */ H(hV, {
56779
- addToolApprovalResponse: O,
56780
- attachments: R,
56785
+ addToolApprovalResponse: j,
56786
+ attachments: B,
56781
56787
  chatId: e,
56782
- input: f,
56788
+ input: h,
56783
56789
  isReadonly: r,
56784
- messages: b,
56785
- regenerate: T,
56786
- selectedModelId: m,
56787
- sendMessage: S,
56788
- setAttachments: z,
56789
- setInput: p,
56790
- setMessages: x,
56791
- status: C,
56792
- stop: w,
56793
- votes: L
56790
+ messages: C,
56791
+ regenerate: k,
56792
+ selectedModelId: _,
56793
+ sendMessage: T,
56794
+ setAttachments: te,
56795
+ setInput: g,
56796
+ setMessages: w,
56797
+ status: D,
56798
+ stop: O,
56799
+ suggestedActions: a,
56800
+ votes: ee
56794
56801
  })]
56795
56802
  });
56796
56803
  }