@yourgpt/copilot-sdk 2.1.5-alpha.0 → 2.1.5-alpha.1

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.
@@ -1647,18 +1647,23 @@ var AbstractChat = class {
1647
1647
  "resolveUnresolvedToolCalls",
1648
1648
  `Adding ${unresolvedIds.length} missing tool results`
1649
1649
  );
1650
+ const visibleMsgs = this.state.messages;
1651
+ let errorChainParentId = visibleMsgs.length > 0 ? visibleMsgs[visibleMsgs.length - 1].id : void 0;
1650
1652
  for (const toolCallId of unresolvedIds) {
1653
+ const toolMessageId = generateMessageId();
1651
1654
  const toolMessage = {
1652
- id: generateMessageId(),
1655
+ id: toolMessageId,
1653
1656
  role: "tool",
1654
1657
  content: JSON.stringify({
1655
1658
  success: false,
1656
1659
  error: "Tool execution was interrupted. Please try again."
1657
1660
  }),
1658
1661
  toolCallId,
1659
- createdAt: /* @__PURE__ */ new Date()
1662
+ createdAt: /* @__PURE__ */ new Date(),
1663
+ ...errorChainParentId !== void 0 ? { parentId: errorChainParentId } : {}
1660
1664
  };
1661
1665
  this.state.pushMessage(toolMessage);
1666
+ errorChainParentId = toolMessageId;
1662
1667
  }
1663
1668
  this.callbacks.onMessagesChange?.(this._allMessages());
1664
1669
  }
@@ -1674,6 +1679,8 @@ var AbstractChat = class {
1674
1679
  this.debug("continueWithToolResults", toolResults);
1675
1680
  try {
1676
1681
  const attachmentsToAdd = [];
1682
+ const visibleMessages = this.state.messages;
1683
+ let chainParentId = visibleMessages.length > 0 ? visibleMessages[visibleMessages.length - 1].id : void 0;
1677
1684
  for (const { toolCallId, result } of toolResults) {
1678
1685
  const typedResult = result;
1679
1686
  let messageContent;
@@ -1690,14 +1697,17 @@ var AbstractChat = class {
1690
1697
  } else {
1691
1698
  messageContent = typeof result === "string" ? result : JSON.stringify(result);
1692
1699
  }
1700
+ const toolMessageId = generateMessageId();
1693
1701
  const toolMessage = {
1694
- id: generateMessageId(),
1702
+ id: toolMessageId,
1695
1703
  role: "tool",
1696
1704
  content: messageContent,
1697
1705
  toolCallId,
1698
- createdAt: /* @__PURE__ */ new Date()
1706
+ createdAt: /* @__PURE__ */ new Date(),
1707
+ ...chainParentId !== void 0 ? { parentId: chainParentId } : {}
1699
1708
  };
1700
1709
  this.state.pushMessage(toolMessage);
1710
+ chainParentId = toolMessageId;
1701
1711
  }
1702
1712
  if (attachmentsToAdd.length > 0) {
1703
1713
  this.debug(
@@ -1709,7 +1719,8 @@ var AbstractChat = class {
1709
1719
  role: "user",
1710
1720
  content: "Here's my screen:",
1711
1721
  attachments: attachmentsToAdd,
1712
- createdAt: /* @__PURE__ */ new Date()
1722
+ createdAt: /* @__PURE__ */ new Date(),
1723
+ ...chainParentId !== void 0 ? { parentId: chainParentId } : {}
1713
1724
  };
1714
1725
  this.state.pushMessage(userMessage);
1715
1726
  }
@@ -7488,5 +7499,5 @@ exports.useToolExecutor = useToolExecutor;
7488
7499
  exports.useToolWithSchema = useToolWithSchema;
7489
7500
  exports.useTools = useTools;
7490
7501
  exports.useToolsWithSchema = useToolsWithSchema;
7491
- //# sourceMappingURL=chunk-76RE7AJE.cjs.map
7492
- //# sourceMappingURL=chunk-76RE7AJE.cjs.map
7502
+ //# sourceMappingURL=chunk-IXWNDR7H.cjs.map
7503
+ //# sourceMappingURL=chunk-IXWNDR7H.cjs.map