@yourgpt/copilot-sdk 1.2.4 → 1.2.5

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.
@@ -788,14 +788,16 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
788
788
  this.debug("handleStreamResponse", `Processed ${chunkCount} chunks`);
789
789
  const finalMessage = streamStateToMessage(this.streamState);
790
790
  this.state.updateMessageById(this.streamState.messageId, () => finalMessage);
791
- this.state.status = "ready";
792
791
  if (!finalMessage.content && (!finalMessage.toolCalls || finalMessage.toolCalls.length === 0)) {
793
792
  this.debug("warning", "Empty response - no content and no tool calls");
794
793
  }
795
794
  this.callbacks.onMessageFinish?.(finalMessage);
796
- this.callbacks.onStatusChange?.("ready");
797
795
  this.callbacks.onMessagesChange?.(this.state.messages);
798
- this.callbacks.onFinish?.(this.state.messages);
796
+ if (!toolCallsEmitted) {
797
+ this.state.status = "ready";
798
+ this.callbacks.onStatusChange?.("ready");
799
+ this.callbacks.onFinish?.(this.state.messages);
800
+ }
799
801
  this.emit("done", {});
800
802
  this.streamState = null;
801
803
  }
@@ -813,15 +815,15 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
813
815
  };
814
816
  this.state.pushMessage(message);
815
817
  }
816
- this.state.status = "ready";
817
- this.callbacks.onStatusChange?.("ready");
818
818
  this.callbacks.onMessagesChange?.(this.state.messages);
819
- this.callbacks.onFinish?.(this.state.messages);
820
- if (response.requiresAction && this.state.messages.length > 0) {
819
+ const hasToolCalls = response.requiresAction && this.state.messages.length > 0 && this.state.messages[this.state.messages.length - 1]?.toolCalls?.length;
820
+ if (hasToolCalls) {
821
821
  const lastMessage = this.state.messages[this.state.messages.length - 1];
822
- if (lastMessage?.toolCalls?.length) {
823
- this.emit("toolCalls", { toolCalls: lastMessage.toolCalls });
824
- }
822
+ this.emit("toolCalls", { toolCalls: lastMessage.toolCalls });
823
+ } else {
824
+ this.state.status = "ready";
825
+ this.callbacks.onStatusChange?.("ready");
826
+ this.callbacks.onFinish?.(this.state.messages);
825
827
  }
826
828
  this.emit("done", {});
827
829
  }
@@ -3602,5 +3604,5 @@ function useChat(config) {
3602
3604
  }
3603
3605
 
3604
3606
  export { AbstractAgentLoop, AbstractChat, CopilotProvider, ReactChat, ReactChatState, ReactThreadManager, ReactThreadManagerState, createPermissionStorage, createReactChat, createReactChatState, createReactThreadManager, createReactThreadManagerState, createSessionPermissionCache, formatKnowledgeResultsForAI, initialAgentLoopState, searchKnowledgeBase, useAIAction, useAIActions, useAIContext, useAIContexts, useAITools, useAgent, useCapabilities, useChat, useCopilot, useDevLogger, useFeatureSupport, useKnowledgeBase, useSuggestions, useSupportedMediaTypes, useThreadManager, useTool, useToolExecutor, useToolWithSchema, useTools, useToolsWithSchema };
3605
- //# sourceMappingURL=chunk-CVZ7LT5B.js.map
3606
- //# sourceMappingURL=chunk-CVZ7LT5B.js.map
3607
+ //# sourceMappingURL=chunk-6NJKNYYW.js.map
3608
+ //# sourceMappingURL=chunk-6NJKNYYW.js.map