teodor-new-chat-ui 4.0.2 → 4.0.4

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.
package/dist/index.esm.js CHANGED
@@ -2840,28 +2840,39 @@ function pl(e, t) {
2840
2840
  return e;
2841
2841
  }
2842
2842
  if (t.type === "tool_start") {
2843
- const r = `tool-${t.id}`, o = { type: "tool_call", id: t.id, name: t.name, args: t.args };
2844
- if (e.messages.find((a) => a.id === r))
2843
+ const r = t.id ?? t.call_id, o = t.name ?? t.tool;
2844
+ if (!r)
2845
+ return e;
2846
+ const s = `tool-${r}`, i = { type: "tool_call", id: r, name: o, args: t.args };
2847
+ if (e.messages.find((u) => u.id === s))
2845
2848
  return {
2846
2849
  ...e,
2847
- toolIndex: { ...e.toolIndex, [t.id]: r }
2850
+ toolIndex: { ...e.toolIndex, [r]: s }
2848
2851
  };
2849
- const i = {
2850
- id: r,
2852
+ const c = {
2853
+ id: s,
2851
2854
  role: "tool",
2852
- name: t.name,
2855
+ name: o,
2853
2856
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
2854
- content: [o]
2857
+ content: [i]
2855
2858
  };
2856
2859
  return {
2857
2860
  ...e,
2858
- messages: [...e.messages, i],
2859
- toolIndex: { ...e.toolIndex, [t.id]: r }
2861
+ messages: [...e.messages, c],
2862
+ toolIndex: { ...e.toolIndex, [r]: s }
2860
2863
  };
2861
2864
  }
2862
2865
  if (t.type === "tool_result") {
2863
- const r = e.toolIndex[t.id] ?? `tool-${t.id}`, o = { type: "tool_result", toolCallId: t.id, output: t.output, error: t.error }, s = e.messages.find((c) => c.id === r), i = { id: r, role: "tool", content: [o], createdAt: (/* @__PURE__ */ new Date()).toISOString() }, a = s ? Hs(e.messages, r, [o]) : [...e.messages, i];
2864
- return { ...e, messages: a };
2866
+ const r = t.id ?? t.call_id;
2867
+ if (!r)
2868
+ return e;
2869
+ const o = e.toolIndex[r] ?? `tool-${r}`, s = {
2870
+ type: "tool_result",
2871
+ toolCallId: r,
2872
+ output: t.output,
2873
+ error: t.error
2874
+ }, i = e.messages.find((u) => u.id === o), a = { id: o, role: "tool", content: [s], createdAt: (/* @__PURE__ */ new Date()).toISOString() }, c = i ? Hs(e.messages, o, [s]) : [...e.messages, a];
2875
+ return { ...e, messages: c };
2865
2876
  }
2866
2877
  if (t.type === "checkpoint") {
2867
2878
  const r = t.checkpointNs ?? e.lastCheckpointNs ?? null, o = Wg(e.messages, t.checkpointId, r);