@yourgpt/copilot-sdk 2.1.5-alpha.7 → 2.1.5-alpha.8
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-UZHGMDOK.js → chunk-FDZVDGNR.js} +32 -5
- package/dist/chunk-FDZVDGNR.js.map +1 -0
- package/dist/{chunk-NPBOKT63.cjs → chunk-JV2L3WZS.cjs} +32 -5
- package/dist/chunk-JV2L3WZS.cjs.map +1 -0
- package/dist/{chunk-M66XAHSW.cjs → chunk-KLSKP6AZ.cjs} +16 -16
- package/dist/{chunk-M66XAHSW.cjs.map → chunk-KLSKP6AZ.cjs.map} +1 -1
- package/dist/{chunk-YHW6JZEF.js → chunk-KYVWKMUT.js} +3 -3
- package/dist/{chunk-YHW6JZEF.js.map → chunk-KYVWKMUT.js.map} +1 -1
- package/dist/experimental/index.cjs +2 -2
- package/dist/experimental/index.js +1 -1
- package/dist/react/index.cjs +62 -62
- package/dist/react/index.d.cts +15 -0
- package/dist/react/index.d.ts +15 -0
- package/dist/react/index.js +2 -2
- package/dist/styles.css +26 -0
- package/dist/ui/index.cjs +89 -20
- package/dist/ui/index.cjs.map +1 -1
- package/dist/ui/index.d.cts +3 -1
- package/dist/ui/index.d.ts +3 -1
- package/dist/ui/index.js +86 -17
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-NPBOKT63.cjs.map +0 -1
- package/dist/chunk-UZHGMDOK.js.map +0 -1
|
@@ -305,8 +305,16 @@ var HttpTransport = class {
|
|
|
305
305
|
signal: this.abortController.signal
|
|
306
306
|
});
|
|
307
307
|
if (!response.ok) {
|
|
308
|
-
|
|
309
|
-
|
|
308
|
+
let errorMessage = `HTTP ${response.status}`;
|
|
309
|
+
try {
|
|
310
|
+
const errorBody = await response.json();
|
|
311
|
+
const custom = this.config.parseError?.(response.status, errorBody);
|
|
312
|
+
errorMessage = custom ?? errorBody?.message ?? errorBody?.error ?? JSON.stringify(errorBody);
|
|
313
|
+
} catch {
|
|
314
|
+
const text = await response.text();
|
|
315
|
+
if (text) errorMessage = text;
|
|
316
|
+
}
|
|
317
|
+
throw new Error(errorMessage);
|
|
310
318
|
}
|
|
311
319
|
const contentType = response.headers.get("content-type") || "";
|
|
312
320
|
if (contentType.includes("application/json")) {
|
|
@@ -1491,6 +1499,11 @@ var AbstractChat = class {
|
|
|
1491
1499
|
this.eventHandlers = /* @__PURE__ */ new Map();
|
|
1492
1500
|
// Current streaming state
|
|
1493
1501
|
this.streamState = null;
|
|
1502
|
+
// ID of the pending assistant placeholder pushed before a request.
|
|
1503
|
+
// Used by handleError() to pop (remove) the placeholder on failure so it
|
|
1504
|
+
// doesn't stay frozen. Error is surfaced via state.error only — never written
|
|
1505
|
+
// into message history.
|
|
1506
|
+
this._activePlaceholderMessageId = void 0;
|
|
1494
1507
|
/**
|
|
1495
1508
|
* Inline skills from the client (sent on every request for server to merge)
|
|
1496
1509
|
*/
|
|
@@ -1523,7 +1536,8 @@ var AbstractChat = class {
|
|
|
1523
1536
|
url: init.runtimeUrl,
|
|
1524
1537
|
headers: init.headers,
|
|
1525
1538
|
body: init.body,
|
|
1526
|
-
streaming: init.streaming ?? true
|
|
1539
|
+
streaming: init.streaming ?? true,
|
|
1540
|
+
parseError: init.parseError
|
|
1527
1541
|
});
|
|
1528
1542
|
this.callbacks = init.callbacks ?? {};
|
|
1529
1543
|
this.optimizer = new ChatContextOptimizer(init.optimization);
|
|
@@ -1603,6 +1617,7 @@ var AbstractChat = class {
|
|
|
1603
1617
|
});
|
|
1604
1618
|
this.state.pushMessage(preMsg);
|
|
1605
1619
|
preCreatedMessageId = preMsg.id;
|
|
1620
|
+
this._activePlaceholderMessageId = preMsg.id;
|
|
1606
1621
|
}
|
|
1607
1622
|
this.callbacks.onMessagesChange?.(this._allMessages());
|
|
1608
1623
|
this.callbacks.onStatusChange?.("submitted");
|
|
@@ -1736,6 +1751,7 @@ var AbstractChat = class {
|
|
|
1736
1751
|
this.state.pushMessage(userMessage);
|
|
1737
1752
|
}
|
|
1738
1753
|
this.state.status = "submitted";
|
|
1754
|
+
this.state.error = void 0;
|
|
1739
1755
|
this.callbacks.onMessagesChange?.(this._allMessages());
|
|
1740
1756
|
this.callbacks.onStatusChange?.("submitted");
|
|
1741
1757
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
@@ -1898,6 +1914,7 @@ var AbstractChat = class {
|
|
|
1898
1914
|
this.state.pushMessage(preMsg);
|
|
1899
1915
|
this.callbacks.onMessagesChange?.(this._allMessages());
|
|
1900
1916
|
preCreatedMessageId = preMsg.id;
|
|
1917
|
+
this._activePlaceholderMessageId = preMsg.id;
|
|
1901
1918
|
}
|
|
1902
1919
|
const response = await this.transport.send(request);
|
|
1903
1920
|
if (this.isAsyncIterable(response)) {
|
|
@@ -1914,6 +1931,7 @@ var AbstractChat = class {
|
|
|
1914
1931
|
this.state.setCurrentLeaf(intendedLeafId);
|
|
1915
1932
|
}
|
|
1916
1933
|
}
|
|
1934
|
+
this._activePlaceholderMessageId = void 0;
|
|
1917
1935
|
this.handleJsonResponse(response);
|
|
1918
1936
|
}
|
|
1919
1937
|
}
|
|
@@ -2552,6 +2570,7 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt;
|
|
|
2552
2570
|
}
|
|
2553
2571
|
}
|
|
2554
2572
|
this.callbacks.onMessagesChange?.(this._allMessages());
|
|
2573
|
+
this._activePlaceholderMessageId = void 0;
|
|
2555
2574
|
this.debugGroupEnd();
|
|
2556
2575
|
this.debug("stream end", {
|
|
2557
2576
|
toolCallsEmitted,
|
|
@@ -2632,6 +2651,11 @@ ${this.dynamicContext}`.trim() : this.config.systemPrompt;
|
|
|
2632
2651
|
*/
|
|
2633
2652
|
handleError(error) {
|
|
2634
2653
|
this.debug("error", error);
|
|
2654
|
+
if (this._activePlaceholderMessageId) {
|
|
2655
|
+
this.state.popMessage();
|
|
2656
|
+
this._activePlaceholderMessageId = void 0;
|
|
2657
|
+
this.callbacks.onMessagesChange?.(this._allMessages());
|
|
2658
|
+
}
|
|
2635
2659
|
this.state.error = error;
|
|
2636
2660
|
this.state.status = "error";
|
|
2637
2661
|
this.callbacks.onError?.(error);
|
|
@@ -3505,6 +3529,7 @@ var ChatWithTools = class {
|
|
|
3505
3529
|
initialMessages: config.initialMessages,
|
|
3506
3530
|
state: config.state,
|
|
3507
3531
|
transport: config.transport,
|
|
3532
|
+
parseError: config.parseError,
|
|
3508
3533
|
callbacks: {
|
|
3509
3534
|
onMessagesChange: callbacks.onMessagesChange,
|
|
3510
3535
|
onStatusChange: callbacks.onStatusChange,
|
|
@@ -5378,6 +5403,7 @@ function CopilotProvider(props) {
|
|
|
5378
5403
|
initialMessages,
|
|
5379
5404
|
onMessagesChange,
|
|
5380
5405
|
onError,
|
|
5406
|
+
parseError,
|
|
5381
5407
|
streaming,
|
|
5382
5408
|
headers,
|
|
5383
5409
|
body,
|
|
@@ -5443,6 +5469,7 @@ function CopilotProvider(props) {
|
|
|
5443
5469
|
streaming,
|
|
5444
5470
|
headers,
|
|
5445
5471
|
body,
|
|
5472
|
+
parseError,
|
|
5446
5473
|
debug,
|
|
5447
5474
|
maxIterations,
|
|
5448
5475
|
maxIterationsMessage,
|
|
@@ -5942,5 +5969,5 @@ exports.useMessageHistoryContext = useMessageHistoryContext;
|
|
|
5942
5969
|
exports.useSkillContext = useSkillContext;
|
|
5943
5970
|
exports.useTool = useTool;
|
|
5944
5971
|
exports.useTools = useTools;
|
|
5945
|
-
//# sourceMappingURL=chunk-
|
|
5946
|
-
//# sourceMappingURL=chunk-
|
|
5972
|
+
//# sourceMappingURL=chunk-JV2L3WZS.cjs.map
|
|
5973
|
+
//# sourceMappingURL=chunk-JV2L3WZS.cjs.map
|