@copilotkit/web-inspector 1.63.3-canary.rc-1 → 1.64.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.
package/dist/index.cjs CHANGED
@@ -1767,7 +1767,7 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1767
1767
  if (msg.toolCalls?.length) for (const tc of msg.toolCalls) {
1768
1768
  let args = {};
1769
1769
  if (typeof tc.args === "string") try {
1770
- args = JSON.parse(tc.args);
1770
+ args = this.parseToolCallContent(tc.args);
1771
1771
  } catch (err) {
1772
1772
  console.error("[CopilotKit Inspector] Failed to parse tool-call arguments", {
1773
1773
  toolCallId: tc.id,
@@ -1807,7 +1807,7 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1807
1807
  else if (msg.role === "tool" && msg.toolCallId) {
1808
1808
  const tc = toolCallMap.get(msg.toolCallId);
1809
1809
  if (tc) try {
1810
- tc.result = JSON.parse(msg.content ?? "{}");
1810
+ tc.result = this.parseToolCallContent(msg.content);
1811
1811
  } catch (err) {
1812
1812
  console.error("[CopilotKit Inspector] Failed to parse tool-call result content", {
1813
1813
  toolCallId: msg.toolCallId,
@@ -1822,6 +1822,11 @@ var CpkThreadInspector = class CpkThreadInspector extends lit.LitElement {
1822
1822
  }
1823
1823
  return items;
1824
1824
  }
1825
+ parseToolCallContent(content) {
1826
+ const normalizedContent = content?.trim();
1827
+ if (!normalizedContent) return {};
1828
+ return JSON.parse(normalizedContent);
1829
+ }
1825
1830
  mapApiEvents(events) {
1826
1831
  return events.map((event, index) => {
1827
1832
  const { type, timestamp, payload, ...rest } = event;