@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.
@@ -1622,18 +1622,23 @@ var AbstractChat = class {
1622
1622
  "resolveUnresolvedToolCalls",
1623
1623
  `Adding ${unresolvedIds.length} missing tool results`
1624
1624
  );
1625
+ const visibleMsgs = this.state.messages;
1626
+ let errorChainParentId = visibleMsgs.length > 0 ? visibleMsgs[visibleMsgs.length - 1].id : void 0;
1625
1627
  for (const toolCallId of unresolvedIds) {
1628
+ const toolMessageId = generateMessageId();
1626
1629
  const toolMessage = {
1627
- id: generateMessageId(),
1630
+ id: toolMessageId,
1628
1631
  role: "tool",
1629
1632
  content: JSON.stringify({
1630
1633
  success: false,
1631
1634
  error: "Tool execution was interrupted. Please try again."
1632
1635
  }),
1633
1636
  toolCallId,
1634
- createdAt: /* @__PURE__ */ new Date()
1637
+ createdAt: /* @__PURE__ */ new Date(),
1638
+ ...errorChainParentId !== void 0 ? { parentId: errorChainParentId } : {}
1635
1639
  };
1636
1640
  this.state.pushMessage(toolMessage);
1641
+ errorChainParentId = toolMessageId;
1637
1642
  }
1638
1643
  this.callbacks.onMessagesChange?.(this._allMessages());
1639
1644
  }
@@ -1649,6 +1654,8 @@ var AbstractChat = class {
1649
1654
  this.debug("continueWithToolResults", toolResults);
1650
1655
  try {
1651
1656
  const attachmentsToAdd = [];
1657
+ const visibleMessages = this.state.messages;
1658
+ let chainParentId = visibleMessages.length > 0 ? visibleMessages[visibleMessages.length - 1].id : void 0;
1652
1659
  for (const { toolCallId, result } of toolResults) {
1653
1660
  const typedResult = result;
1654
1661
  let messageContent;
@@ -1665,14 +1672,17 @@ var AbstractChat = class {
1665
1672
  } else {
1666
1673
  messageContent = typeof result === "string" ? result : JSON.stringify(result);
1667
1674
  }
1675
+ const toolMessageId = generateMessageId();
1668
1676
  const toolMessage = {
1669
- id: generateMessageId(),
1677
+ id: toolMessageId,
1670
1678
  role: "tool",
1671
1679
  content: messageContent,
1672
1680
  toolCallId,
1673
- createdAt: /* @__PURE__ */ new Date()
1681
+ createdAt: /* @__PURE__ */ new Date(),
1682
+ ...chainParentId !== void 0 ? { parentId: chainParentId } : {}
1674
1683
  };
1675
1684
  this.state.pushMessage(toolMessage);
1685
+ chainParentId = toolMessageId;
1676
1686
  }
1677
1687
  if (attachmentsToAdd.length > 0) {
1678
1688
  this.debug(
@@ -1684,7 +1694,8 @@ var AbstractChat = class {
1684
1694
  role: "user",
1685
1695
  content: "Here's my screen:",
1686
1696
  attachments: attachmentsToAdd,
1687
- createdAt: /* @__PURE__ */ new Date()
1697
+ createdAt: /* @__PURE__ */ new Date(),
1698
+ ...chainParentId !== void 0 ? { parentId: chainParentId } : {}
1688
1699
  };
1689
1700
  this.state.pushMessage(userMessage);
1690
1701
  }
@@ -7408,5 +7419,5 @@ function defineSkill(def) {
7408
7419
  }
7409
7420
 
7410
7421
  export { AbstractAgentLoop, AbstractChat, CopilotProvider, MessageHistoryContext, MessageTree, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, SkillProvider, createMessageIntentHandler, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, createToolIntentHandler, defaultMessageHistoryConfig, defineSkill, formatKnowledgeResultsForAI, initialAgentLoopState, isCompactionMarker, keepToolPairsAtomic, searchKnowledgeBase, toDisplayMessage, toLLMMessage, toLLMMessages, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useContextStats, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useMCPClient, useMCPTools, useMCPUIIntents, useMessageHistory, useMessageHistoryContext, useSkill, useSkillStatus, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema };
7411
- //# sourceMappingURL=chunk-6BMQZIS3.js.map
7412
- //# sourceMappingURL=chunk-6BMQZIS3.js.map
7422
+ //# sourceMappingURL=chunk-5Q72LZ5H.js.map
7423
+ //# sourceMappingURL=chunk-5Q72LZ5H.js.map