ai 6.0.294 → 6.0.296
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 +16 -0
- package/dist/index.d.mts +7 -6
- package/dist/index.d.ts +7 -6
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +46 -13
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +1 -1
- package/dist/internal/index.mjs +1 -1
- package/docs/02-foundations/02-providers-and-models.mdx +1 -0
- package/docs/07-reference/01-ai-sdk-core/17-create-agent-ui-stream.mdx +3 -3
- package/docs/07-reference/01-ai-sdk-core/18-create-agent-ui-stream-response.mdx +2 -2
- package/docs/07-reference/01-ai-sdk-core/18-pipe-agent-ui-stream-to-response.mdx +3 -3
- package/package.json +2 -2
- package/src/agent/create-agent-ui-stream-response.ts +2 -2
- package/src/agent/create-agent-ui-stream.ts +5 -3
- package/src/agent/pipe-agent-ui-stream-to-response.ts +2 -2
- package/src/generate-text/smooth-stream.ts +24 -9
- package/src/ui/chat.ts +36 -7
- package/src/ui/process-ui-message-stream.ts +8 -4
package/dist/index.mjs
CHANGED
|
@@ -1224,7 +1224,7 @@ import {
|
|
|
1224
1224
|
} from "@ai-sdk/provider-utils";
|
|
1225
1225
|
|
|
1226
1226
|
// src/version.ts
|
|
1227
|
-
var VERSION = true ? "6.0.
|
|
1227
|
+
var VERSION = true ? "6.0.296" : "0.0.0-test";
|
|
1228
1228
|
|
|
1229
1229
|
// src/util/download/download.ts
|
|
1230
1230
|
var download = async ({
|
|
@@ -5950,7 +5950,7 @@ function processUIMessageStream({
|
|
|
5950
5950
|
new TransformStream({
|
|
5951
5951
|
async transform(chunk, controller) {
|
|
5952
5952
|
await runUpdateMessageJob(async ({ state, write }) => {
|
|
5953
|
-
var _a23, _b, _c, _d;
|
|
5953
|
+
var _a23, _b, _c, _d, _e, _f, _g, _h;
|
|
5954
5954
|
function getCurrentStepParts() {
|
|
5955
5955
|
const parts = state.message.parts;
|
|
5956
5956
|
let currentStepStartIndex = parts.length - 1;
|
|
@@ -6384,7 +6384,7 @@ function processUIMessageStream({
|
|
|
6384
6384
|
providerExecuted: chunk.providerExecuted,
|
|
6385
6385
|
providerMetadata: chunk.providerMetadata,
|
|
6386
6386
|
title: toolInvocation.title,
|
|
6387
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
6387
|
+
toolMetadata: (_e = chunk.toolMetadata) != null ? _e : toolInvocation.toolMetadata
|
|
6388
6388
|
},
|
|
6389
6389
|
toolInvocation
|
|
6390
6390
|
);
|
|
@@ -6400,7 +6400,7 @@ function processUIMessageStream({
|
|
|
6400
6400
|
preliminary: chunk.preliminary,
|
|
6401
6401
|
providerMetadata: chunk.providerMetadata,
|
|
6402
6402
|
title: toolInvocation.title,
|
|
6403
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
6403
|
+
toolMetadata: (_f = chunk.toolMetadata) != null ? _f : toolInvocation.toolMetadata
|
|
6404
6404
|
},
|
|
6405
6405
|
toolInvocation
|
|
6406
6406
|
);
|
|
@@ -6421,7 +6421,7 @@ function processUIMessageStream({
|
|
|
6421
6421
|
providerExecuted: chunk.providerExecuted,
|
|
6422
6422
|
providerMetadata: chunk.providerMetadata,
|
|
6423
6423
|
title: toolInvocation.title,
|
|
6424
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
6424
|
+
toolMetadata: (_g = chunk.toolMetadata) != null ? _g : toolInvocation.toolMetadata
|
|
6425
6425
|
},
|
|
6426
6426
|
toolInvocation
|
|
6427
6427
|
);
|
|
@@ -6437,7 +6437,7 @@ function processUIMessageStream({
|
|
|
6437
6437
|
providerExecuted: chunk.providerExecuted,
|
|
6438
6438
|
providerMetadata: chunk.providerMetadata,
|
|
6439
6439
|
title: toolInvocation.title,
|
|
6440
|
-
toolMetadata: toolInvocation.toolMetadata
|
|
6440
|
+
toolMetadata: (_h = chunk.toolMetadata) != null ? _h : toolInvocation.toolMetadata
|
|
6441
6441
|
},
|
|
6442
6442
|
toolInvocation
|
|
6443
6443
|
);
|
|
@@ -10272,8 +10272,9 @@ async function createAgentUIStream({
|
|
|
10272
10272
|
...uiMessageStreamOptions
|
|
10273
10273
|
}) {
|
|
10274
10274
|
var _a23;
|
|
10275
|
+
const inputMessages = uiMessages != null ? uiMessages : uiMessageStreamOptions.originalMessages;
|
|
10275
10276
|
const validatedMessages = await validateUIMessagesForAgent({
|
|
10276
|
-
messages:
|
|
10277
|
+
messages: inputMessages,
|
|
10277
10278
|
tools: agent.tools
|
|
10278
10279
|
});
|
|
10279
10280
|
const modelMessages = await convertToModelMessages(validatedMessages, {
|
|
@@ -12704,21 +12705,32 @@ function smoothStream({
|
|
|
12704
12705
|
controller.enqueue(chunk);
|
|
12705
12706
|
return;
|
|
12706
12707
|
}
|
|
12707
|
-
if (
|
|
12708
|
+
if (chunk.text.length === 0 && chunk.providerMetadata != null) {
|
|
12709
|
+
flushBuffer(controller);
|
|
12710
|
+
controller.enqueue(chunk);
|
|
12711
|
+
return;
|
|
12712
|
+
}
|
|
12713
|
+
if (buffer.length > 0 && (chunk.type !== type || chunk.id !== id || providerMetadata != null || chunk.providerMetadata != null)) {
|
|
12708
12714
|
flushBuffer(controller);
|
|
12709
12715
|
}
|
|
12710
12716
|
buffer += chunk.text;
|
|
12711
12717
|
id = chunk.id;
|
|
12712
12718
|
type = chunk.type;
|
|
12713
|
-
|
|
12714
|
-
providerMetadata = chunk.providerMetadata;
|
|
12715
|
-
}
|
|
12719
|
+
providerMetadata = chunk.providerMetadata;
|
|
12716
12720
|
let match;
|
|
12717
12721
|
while ((match = detectChunk(buffer)) != null) {
|
|
12718
|
-
controller.enqueue({
|
|
12722
|
+
controller.enqueue({
|
|
12723
|
+
type,
|
|
12724
|
+
text: match,
|
|
12725
|
+
id,
|
|
12726
|
+
...providerMetadata != null ? { providerMetadata } : {}
|
|
12727
|
+
});
|
|
12719
12728
|
buffer = buffer.slice(match.length);
|
|
12720
12729
|
await delay(isDocumentHidden() ? null : delayInMs);
|
|
12721
12730
|
}
|
|
12731
|
+
if (buffer.length === 0) {
|
|
12732
|
+
providerMetadata = void 0;
|
|
12733
|
+
}
|
|
12722
12734
|
}
|
|
12723
12735
|
});
|
|
12724
12736
|
};
|
|
@@ -14440,6 +14452,7 @@ var AbstractChat = class {
|
|
|
14440
14452
|
}) {
|
|
14441
14453
|
this.activeResponse = void 0;
|
|
14442
14454
|
this.activeResumeRequest = void 0;
|
|
14455
|
+
this.resumableStreamState = void 0;
|
|
14443
14456
|
this.jobExecutor = new SerialJobExecutor();
|
|
14444
14457
|
/**
|
|
14445
14458
|
* Appends or replaces a user message to the chat list. This triggers the API call to fetch
|
|
@@ -14719,6 +14732,9 @@ var AbstractChat = class {
|
|
|
14719
14732
|
messageId
|
|
14720
14733
|
}) {
|
|
14721
14734
|
var _a23, _b, _c;
|
|
14735
|
+
if (trigger !== "resume-stream") {
|
|
14736
|
+
this.resumableStreamState = void 0;
|
|
14737
|
+
}
|
|
14722
14738
|
const abortController = new AbortController();
|
|
14723
14739
|
const activeResumeRequest = trigger === "resume-stream" ? { abortController } : void 0;
|
|
14724
14740
|
if (activeResumeRequest) {
|
|
@@ -14746,12 +14762,14 @@ var AbstractChat = class {
|
|
|
14746
14762
|
}));
|
|
14747
14763
|
if (isCurrentRequest()) {
|
|
14748
14764
|
this.setStatus({ status: "ready" });
|
|
14765
|
+
this.resumableStreamState = void 0;
|
|
14749
14766
|
}
|
|
14750
14767
|
clearActiveResumeRequest();
|
|
14751
14768
|
return;
|
|
14752
14769
|
}
|
|
14753
14770
|
if (reconnect == null) {
|
|
14754
14771
|
this.setStatus({ status: "ready" });
|
|
14772
|
+
this.resumableStreamState = void 0;
|
|
14755
14773
|
clearActiveResumeRequest();
|
|
14756
14774
|
return;
|
|
14757
14775
|
}
|
|
@@ -14760,6 +14778,7 @@ var AbstractChat = class {
|
|
|
14760
14778
|
if (abortController.signal.aborted || err.name === "AbortError") {
|
|
14761
14779
|
if (isCurrentRequest()) {
|
|
14762
14780
|
this.setStatus({ status: "ready" });
|
|
14781
|
+
this.resumableStreamState = void 0;
|
|
14763
14782
|
}
|
|
14764
14783
|
clearActiveResumeRequest();
|
|
14765
14784
|
return;
|
|
@@ -14786,7 +14805,7 @@ var AbstractChat = class {
|
|
|
14786
14805
|
let activeResponse;
|
|
14787
14806
|
try {
|
|
14788
14807
|
const response = {
|
|
14789
|
-
state: createStreamingUIMessageState({
|
|
14808
|
+
state: trigger === "resume-stream" && this.resumableStreamState != null ? this.resumableStreamState : createStreamingUIMessageState({
|
|
14790
14809
|
lastMessage: trigger === "resume-stream" || trigger === "regenerate-message" ? void 0 : this.state.snapshot(responseMessage),
|
|
14791
14810
|
messageId: this.generateId()
|
|
14792
14811
|
}),
|
|
@@ -14865,17 +14884,26 @@ var AbstractChat = class {
|
|
|
14865
14884
|
if (isAbort) {
|
|
14866
14885
|
if (isCurrentRequest()) {
|
|
14867
14886
|
this.setStatus({ status: "ready" });
|
|
14887
|
+
if (this.resumableStreamState === response.state) {
|
|
14888
|
+
this.resumableStreamState = void 0;
|
|
14889
|
+
}
|
|
14868
14890
|
}
|
|
14869
14891
|
return null;
|
|
14870
14892
|
}
|
|
14871
14893
|
if (isCurrentRequest()) {
|
|
14872
14894
|
this.setStatus({ status: "ready" });
|
|
14895
|
+
if (this.resumableStreamState === response.state) {
|
|
14896
|
+
this.resumableStreamState = void 0;
|
|
14897
|
+
}
|
|
14873
14898
|
}
|
|
14874
14899
|
} catch (err) {
|
|
14875
14900
|
if (isAbort || err.name === "AbortError") {
|
|
14876
14901
|
isAbort = true;
|
|
14877
14902
|
if (isCurrentRequest()) {
|
|
14878
14903
|
this.setStatus({ status: "ready" });
|
|
14904
|
+
if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) {
|
|
14905
|
+
this.resumableStreamState = void 0;
|
|
14906
|
+
}
|
|
14879
14907
|
}
|
|
14880
14908
|
return null;
|
|
14881
14909
|
}
|
|
@@ -14886,6 +14914,11 @@ var AbstractChat = class {
|
|
|
14886
14914
|
if (err instanceof TypeError && (err.message.toLowerCase().includes("fetch") || err.message.toLowerCase().includes("network"))) {
|
|
14887
14915
|
isDisconnect = true;
|
|
14888
14916
|
}
|
|
14917
|
+
if (isDisconnect) {
|
|
14918
|
+
this.resumableStreamState = activeResponse == null ? void 0 : activeResponse.state;
|
|
14919
|
+
} else if (this.resumableStreamState === (activeResponse == null ? void 0 : activeResponse.state)) {
|
|
14920
|
+
this.resumableStreamState = void 0;
|
|
14921
|
+
}
|
|
14889
14922
|
if (this.onError && err instanceof Error) {
|
|
14890
14923
|
this.onError(err);
|
|
14891
14924
|
}
|