@yourgpt/copilot-sdk 1.2.2 → 1.2.3
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/{chunk-DLM5KOFK.cjs → chunk-2IPWAEIC.cjs} +34 -7
- package/dist/chunk-2IPWAEIC.cjs.map +1 -0
- package/dist/{chunk-34LUNTCZ.js → chunk-XPV4Y2CT.js} +34 -7
- package/dist/chunk-XPV4Y2CT.js.map +1 -0
- package/dist/react/index.cjs +37 -37
- package/dist/react/index.d.cts +14 -1
- package/dist/react/index.d.ts +14 -1
- package/dist/react/index.js +1 -1
- package/dist/ui/index.cjs +4 -4
- package/dist/ui/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-34LUNTCZ.js.map +0 -1
- package/dist/chunk-DLM5KOFK.cjs.map +0 -1
|
@@ -84,6 +84,12 @@ var SimpleChatState = class {
|
|
|
84
84
|
const lastIndex = this._messages.length - 1;
|
|
85
85
|
this.replaceMessage(lastIndex, updater(this._messages[lastIndex]));
|
|
86
86
|
}
|
|
87
|
+
updateMessageById(id, updater) {
|
|
88
|
+
const index = this._messages.findIndex((m) => m.id === id);
|
|
89
|
+
if (index === -1) return false;
|
|
90
|
+
this.replaceMessage(index, updater(this._messages[index]));
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
87
93
|
setMessages(messages) {
|
|
88
94
|
this._messages = messages;
|
|
89
95
|
this.notify();
|
|
@@ -790,7 +796,7 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
790
796
|
}
|
|
791
797
|
this.streamState = processStreamChunk(chunk, this.streamState);
|
|
792
798
|
const updatedMessage = streamStateToMessage(this.streamState);
|
|
793
|
-
this.state.
|
|
799
|
+
this.state.updateMessageById(this.streamState.messageId, () => updatedMessage);
|
|
794
800
|
if (chunk.type === "message:delta") {
|
|
795
801
|
this.callbacks.onMessageDelta?.(assistantMessage.id, chunk.content);
|
|
796
802
|
}
|
|
@@ -806,7 +812,7 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt,
|
|
|
806
812
|
}
|
|
807
813
|
this.debug("handleStreamResponse", `Processed ${chunkCount} chunks`);
|
|
808
814
|
const finalMessage = streamStateToMessage(this.streamState);
|
|
809
|
-
this.state.
|
|
815
|
+
this.state.updateMessageById(this.streamState.messageId, () => finalMessage);
|
|
810
816
|
this.state.status = "ready";
|
|
811
817
|
if (!finalMessage.content && (!finalMessage.toolCalls || finalMessage.toolCalls.length === 0)) {
|
|
812
818
|
this.debug("warning", "Empty response - no content and no tool calls");
|
|
@@ -1159,6 +1165,14 @@ var AbstractAgentLoop = class {
|
|
|
1159
1165
|
this.clearToolExecutions();
|
|
1160
1166
|
this.pendingApprovals.clear();
|
|
1161
1167
|
}
|
|
1168
|
+
/**
|
|
1169
|
+
* Reset iteration counter only (allows continuing after max iterations)
|
|
1170
|
+
* Called when user sends a new message
|
|
1171
|
+
*/
|
|
1172
|
+
resetIterations() {
|
|
1173
|
+
this.setIteration(0);
|
|
1174
|
+
this._maxIterationsReached = false;
|
|
1175
|
+
}
|
|
1162
1176
|
/**
|
|
1163
1177
|
* Update configuration
|
|
1164
1178
|
*/
|
|
@@ -1267,11 +1281,12 @@ var ChatWithTools = class {
|
|
|
1267
1281
|
await this.chat.continueWithToolResults(toolResults);
|
|
1268
1282
|
} else if (this.agentLoop.maxIterationsReached && toolCallInfos.length > 0) {
|
|
1269
1283
|
this.debug("Max iterations reached, adding blocked tool results");
|
|
1284
|
+
const errorMessage = this.config.maxIterationsMessage || "Tool execution paused: iteration limit reached. User can say 'continue' to resume.";
|
|
1270
1285
|
const blockedResults = toolCallInfos.map((tc) => ({
|
|
1271
1286
|
toolCallId: tc.id,
|
|
1272
1287
|
result: {
|
|
1273
1288
|
success: false,
|
|
1274
|
-
error:
|
|
1289
|
+
error: errorMessage
|
|
1275
1290
|
}
|
|
1276
1291
|
}));
|
|
1277
1292
|
await this.chat.continueWithToolResults(blockedResults);
|
|
@@ -1322,6 +1337,7 @@ var ChatWithTools = class {
|
|
|
1322
1337
|
* Send a message
|
|
1323
1338
|
*/
|
|
1324
1339
|
async sendMessage(content, attachments) {
|
|
1340
|
+
this.agentLoop.resetIterations();
|
|
1325
1341
|
await this.chat.sendMessage(content, attachments);
|
|
1326
1342
|
}
|
|
1327
1343
|
/**
|
|
@@ -1513,6 +1529,15 @@ var ReactChatState = class {
|
|
|
1513
1529
|
];
|
|
1514
1530
|
this.notify();
|
|
1515
1531
|
}
|
|
1532
|
+
updateMessageById(id, updater) {
|
|
1533
|
+
const index = this._messages.findIndex((m) => m.id === id);
|
|
1534
|
+
if (index === -1) return false;
|
|
1535
|
+
this._messages = this._messages.map(
|
|
1536
|
+
(m, i) => i === index ? updater(m) : m
|
|
1537
|
+
);
|
|
1538
|
+
this.notify();
|
|
1539
|
+
return true;
|
|
1540
|
+
}
|
|
1516
1541
|
setMessages(messages) {
|
|
1517
1542
|
this._messages = messages;
|
|
1518
1543
|
this.notify();
|
|
@@ -1650,7 +1675,8 @@ function CopilotProvider({
|
|
|
1650
1675
|
onError,
|
|
1651
1676
|
streaming,
|
|
1652
1677
|
debug = false,
|
|
1653
|
-
maxIterations
|
|
1678
|
+
maxIterations,
|
|
1679
|
+
maxIterationsMessage
|
|
1654
1680
|
}) {
|
|
1655
1681
|
const debugLog = react.useCallback(
|
|
1656
1682
|
(...args) => {
|
|
@@ -1687,7 +1713,8 @@ function CopilotProvider({
|
|
|
1687
1713
|
initialMessages: uiInitialMessages,
|
|
1688
1714
|
streaming,
|
|
1689
1715
|
debug,
|
|
1690
|
-
maxIterations
|
|
1716
|
+
maxIterations,
|
|
1717
|
+
maxIterationsMessage
|
|
1691
1718
|
},
|
|
1692
1719
|
{
|
|
1693
1720
|
onToolExecutionsChange: (executions) => {
|
|
@@ -3635,5 +3662,5 @@ exports.useToolExecutor = useToolExecutor;
|
|
|
3635
3662
|
exports.useToolWithSchema = useToolWithSchema;
|
|
3636
3663
|
exports.useTools = useTools;
|
|
3637
3664
|
exports.useToolsWithSchema = useToolsWithSchema;
|
|
3638
|
-
//# sourceMappingURL=chunk-
|
|
3639
|
-
//# sourceMappingURL=chunk-
|
|
3665
|
+
//# sourceMappingURL=chunk-2IPWAEIC.cjs.map
|
|
3666
|
+
//# sourceMappingURL=chunk-2IPWAEIC.cjs.map
|