ai 6.0.89 → 6.0.90
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/CHANGELOG.md +6 -0
- package/dist/index.js +23 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +23 -12
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/package.json +1 -1
- package/src/ui/chat.ts +28 -13
package/dist/internal/index.js
CHANGED
|
@@ -153,7 +153,7 @@ var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
|
|
153
153
|
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
|
154
154
|
|
|
155
155
|
// src/version.ts
|
|
156
|
-
var VERSION = true ? "6.0.
|
|
156
|
+
var VERSION = true ? "6.0.90" : "0.0.0-test";
|
|
157
157
|
|
|
158
158
|
// src/util/download/download.ts
|
|
159
159
|
var download = async ({
|
package/dist/internal/index.mjs
CHANGED
package/package.json
CHANGED
package/src/ui/chat.ts
CHANGED
|
@@ -582,6 +582,33 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
582
582
|
trigger: 'submit-message' | 'resume-stream' | 'regenerate-message';
|
|
583
583
|
messageId?: string;
|
|
584
584
|
} & ChatRequestOptions) {
|
|
585
|
+
// For resume-stream, check if there's an active stream before
|
|
586
|
+
// changing status. This avoids a brief flash of 'submitted' status
|
|
587
|
+
// when there is no stream to resume (e.g. on page load).
|
|
588
|
+
let resumeStream: ReadableStream<UIMessageChunk> | undefined;
|
|
589
|
+
if (trigger === 'resume-stream') {
|
|
590
|
+
try {
|
|
591
|
+
const reconnect = await this.transport.reconnectToStream({
|
|
592
|
+
chatId: this.id,
|
|
593
|
+
metadata,
|
|
594
|
+
headers,
|
|
595
|
+
body,
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
if (reconnect == null) {
|
|
599
|
+
return; // no active stream found, so we do not resume
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
resumeStream = reconnect;
|
|
603
|
+
} catch (err) {
|
|
604
|
+
if (this.onError && err instanceof Error) {
|
|
605
|
+
this.onError(err);
|
|
606
|
+
}
|
|
607
|
+
this.setStatus({ status: 'error', error: err as Error });
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
585
612
|
this.setStatus({ status: 'submitted', error: undefined });
|
|
586
613
|
|
|
587
614
|
const lastMessage = this.lastMessage;
|
|
@@ -608,19 +635,7 @@ export abstract class AbstractChat<UI_MESSAGE extends UIMessage> {
|
|
|
608
635
|
let stream: ReadableStream<UIMessageChunk>;
|
|
609
636
|
|
|
610
637
|
if (trigger === 'resume-stream') {
|
|
611
|
-
|
|
612
|
-
chatId: this.id,
|
|
613
|
-
metadata,
|
|
614
|
-
headers,
|
|
615
|
-
body,
|
|
616
|
-
});
|
|
617
|
-
|
|
618
|
-
if (reconnect == null) {
|
|
619
|
-
this.setStatus({ status: 'ready' });
|
|
620
|
-
return; // no active stream found, so we do not resume
|
|
621
|
-
}
|
|
622
|
-
|
|
623
|
-
stream = reconnect;
|
|
638
|
+
stream = resumeStream!;
|
|
624
639
|
} else {
|
|
625
640
|
stream = await this.transport.sendMessages({
|
|
626
641
|
chatId: this.id,
|