teodor-new-chat-ui 4.3.605 → 4.3.606

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.
@@ -29,16 +29,12 @@ export declare function createArtifactPreviewFromSource({ base64, url, formatHin
29
29
  export declare function createArtifactPreviewFromPlot(plot: PlotData): ArtifactPreview | null;
30
30
  export declare function getToolProgress(message: ChatMessage): unknown[];
31
31
  /**
32
- * Check if an assistant message contains ONLY tool_call parts (no text content).
33
- * These messages should be hidden from the main list and their tool execution
34
- * should be shown nested within the next assistant message with text.
32
+ * Check if an assistant message contains ONLY tool_calls (no meaningful text/media).
33
+ * These messages should be hidden and their logic hoisted into the next message.
35
34
  */
36
35
  export declare function isAssistantMessageWithOnlyToolCalls(message: ChatMessage): boolean;
37
36
  /**
38
37
  * Check if a message should be hidden from the main message list.
39
- * This includes:
40
- * - Tool messages (role: "tool")
41
- * - Assistant messages with only tool_call parts (no text)
42
38
  */
43
39
  export declare function shouldHideMessageFromList(message: ChatMessage): boolean;
44
40
  export type ToolExecutionEntry = {
package/dist/index.esm.js CHANGED
@@ -3618,10 +3618,10 @@ function uu(e) {
3618
3618
  return e.filter((t) => t.type === "text").map((t) => t.text).join("");
3619
3619
  }
3620
3620
  function ws(e) {
3621
- const t = e.content.find((s) => s.type === "tool_call"), n = e.additionalKwargs ?? {}, r = typeof (t == null ? void 0 : t.id) == "string" && t.id || typeof n.toolCallId == "string" && n.toolCallId || (e.id.startsWith("tool-") ? e.id.slice(5) : void 0);
3621
+ const n = (Array.isArray(e.content) ? e.content : Array.isArray(e.parts) ? e.parts : []).find((i) => i.type === "tool_call"), r = e.additionalKwargs ?? {}, o = typeof (n == null ? void 0 : n.id) == "string" && n.id || typeof r.toolCallId == "string" && r.toolCallId || (e.id.startsWith("tool-") ? e.id.slice(5) : void 0);
3622
3622
  return {
3623
- name: (typeof (t == null ? void 0 : t.name) == "string" && t.name || typeof n.toolName == "string" && n.toolName || e.name && String(e.name)) ?? void 0,
3624
- toolCallId: r ?? void 0
3623
+ name: (typeof (n == null ? void 0 : n.name) == "string" && n.name || typeof r.toolName == "string" && r.toolName || e.name && String(e.name)) ?? void 0,
3624
+ toolCallId: o ?? void 0
3625
3625
  };
3626
3626
  }
3627
3627
  function du(e) {
@@ -3668,62 +3668,69 @@ function ki(e) {
3668
3668
  return Array.isArray(t) ? t : [];
3669
3669
  }
3670
3670
  function fu(e) {
3671
- var o;
3672
- return e.role !== "assistant" || !(e.tool_calls && e.tool_calls.length > 0) ? !1 : !(((o = e.parts) == null ? void 0 : o.filter((s) => s.type === "text")) || []).some((s) => s.text && s.text.trim().length > 0);
3671
+ if (e.role !== "assistant") return !1;
3672
+ const t = Array.isArray(e.content) ? e.content : Array.isArray(e.parts) ? e.parts : [], n = t.some((s) => s.type === "text" && s.text && s.text.trim().length > 0), r = t.some((s) => s.type === "image" || s.type === "image_url" || s.type === "file"), o = !!e.artifact;
3673
+ return !n && !r && !o;
3673
3674
  }
3674
3675
  function Bg(e) {
3675
- return e.role === "tool" ? !0 : fu(e);
3676
+ return e.role === "tool" ? !0 : e.role === "assistant" ? fu(e) : !1;
3676
3677
  }
3677
3678
  function Hg(e, t) {
3678
- var s, i;
3679
- const n = [], r = e.findIndex((a) => a.id === t);
3679
+ const n = [], r = e.findIndex((s) => s.id === t);
3680
3680
  if (r === -1) return n;
3681
3681
  const o = /* @__PURE__ */ new Map();
3682
- for (let a = r - 1; a >= 0; a--) {
3683
- const c = e[a];
3684
- if (c.role === "assistant" && !fu(c))
3682
+ for (let s = r - 1; s >= 0; s--) {
3683
+ const i = e[s];
3684
+ if (i.role === "assistant" && !fu(i))
3685
3685
  break;
3686
- if (c.role === "assistant") {
3687
- const l = ((s = c.tool_calls) == null ? void 0 : s.filter((u) => u.type === "tool_call")) || [];
3688
- for (const u of l) {
3689
- const f = u;
3690
- f.id && f.name && o.set(f.id, {
3691
- name: f.name,
3692
- timestamp: c.createdAt
3686
+ if (i.role === "assistant") {
3687
+ const a = Array.isArray(i.content) ? i.content : Array.isArray(i.parts) ? i.parts : [];
3688
+ if (i.tool_calls)
3689
+ for (const l of i.tool_calls)
3690
+ l.id && l.name && o.set(l.id, {
3691
+ name: l.name,
3692
+ timestamp: i.createdAt
3693
+ });
3694
+ const c = a.filter((l) => l.type === "tool_call") || [];
3695
+ for (const l of c) {
3696
+ const u = l;
3697
+ u.id && u.name && o.set(u.id, {
3698
+ name: u.name,
3699
+ timestamp: i.createdAt
3693
3700
  });
3694
3701
  }
3695
3702
  }
3696
- if (c.role === "tool") {
3697
- const l = ws(c), u = l.toolCallId, f = l.name || c.name || "tool";
3698
- if (u && o.has(u)) {
3699
- const h = o.get(u);
3703
+ if (i.role === "tool") {
3704
+ const a = ws(i), c = a.toolCallId, l = a.name || i.name || "tool";
3705
+ if (c && o.has(c)) {
3706
+ const u = o.get(c);
3700
3707
  n.unshift({
3701
3708
  type: "tool.start",
3702
- toolName: h.name,
3703
- toolCallId: u,
3704
- content: `Starting ${h.name}...`,
3705
- timestamp: h.timestamp
3709
+ toolName: u.name,
3710
+ toolCallId: c,
3711
+ content: `Starting ${u.name}...`,
3712
+ timestamp: u.timestamp
3706
3713
  });
3707
- const p = uu(((i = c.parts) == null ? void 0 : i.filter((m) => m.type === "text")) || []);
3714
+ const f = Array.isArray(i.content) ? i.content : Array.isArray(i.parts) ? i.parts : [], h = uu(f.filter((p) => p.type === "text"));
3708
3715
  n.push({
3709
3716
  type: "tool.end",
3710
- toolName: f,
3711
- toolCallId: u,
3712
- content: p || `Finished ${f}`,
3713
- timestamp: c.createdAt,
3714
- output: p,
3715
- artifact: c.artifact
3716
- }), o.delete(u);
3717
+ toolName: l,
3718
+ toolCallId: c,
3719
+ content: h || `Finished ${l}`,
3720
+ timestamp: i.createdAt,
3721
+ output: h,
3722
+ artifact: i.artifact
3723
+ }), o.delete(c);
3717
3724
  }
3718
3725
  }
3719
3726
  }
3720
- for (const [a, c] of o.entries())
3727
+ for (const [s, i] of o.entries())
3721
3728
  n.unshift({
3722
3729
  type: "tool.start",
3723
- toolName: c.name,
3724
- toolCallId: a,
3725
- content: `Starting ${c.name}...`,
3726
- timestamp: c.timestamp
3730
+ toolName: i.name,
3731
+ toolCallId: s,
3732
+ content: `Starting ${i.name}...`,
3733
+ timestamp: i.timestamp
3727
3734
  });
3728
3735
  return n;
3729
3736
  }