ai 5.0.0-alpha.11 → 5.0.0-alpha.12
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 +14 -0
- package/dist/index.d.mts +1909 -1908
- package/dist/index.d.ts +1909 -1908
- package/dist/index.js +186 -185
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +183 -182
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
@@ -729,6 +729,137 @@ var SerialJobExecutor = class {
|
|
729
729
|
}
|
730
730
|
};
|
731
731
|
|
732
|
+
// src/ui/convert-file-list-to-file-ui-parts.ts
|
733
|
+
async function convertFileListToFileUIParts(files) {
|
734
|
+
if (files == null) {
|
735
|
+
return [];
|
736
|
+
}
|
737
|
+
if (!globalThis.FileList || !(files instanceof globalThis.FileList)) {
|
738
|
+
throw new Error("FileList is not supported in the current environment");
|
739
|
+
}
|
740
|
+
return Promise.all(
|
741
|
+
Array.from(files).map(async (file) => {
|
742
|
+
const { name: name17, type } = file;
|
743
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
744
|
+
const reader = new FileReader();
|
745
|
+
reader.onload = (readerEvent) => {
|
746
|
+
var _a17;
|
747
|
+
resolve((_a17 = readerEvent.target) == null ? void 0 : _a17.result);
|
748
|
+
};
|
749
|
+
reader.onerror = (error) => reject(error);
|
750
|
+
reader.readAsDataURL(file);
|
751
|
+
});
|
752
|
+
return {
|
753
|
+
type: "file",
|
754
|
+
mediaType: type,
|
755
|
+
filename: name17,
|
756
|
+
url: dataUrl
|
757
|
+
};
|
758
|
+
})
|
759
|
+
);
|
760
|
+
}
|
761
|
+
|
762
|
+
// src/ui/default-chat-transport.ts
|
763
|
+
import {
|
764
|
+
parseJsonEventStream as parseJsonEventStream2
|
765
|
+
} from "@ai-sdk/provider-utils";
|
766
|
+
var getOriginalFetch2 = () => fetch;
|
767
|
+
async function fetchUIMessageStream({
|
768
|
+
api,
|
769
|
+
body,
|
770
|
+
credentials,
|
771
|
+
headers,
|
772
|
+
abortSignal,
|
773
|
+
fetch: fetch2 = getOriginalFetch2(),
|
774
|
+
requestType = "generate"
|
775
|
+
}) {
|
776
|
+
var _a17;
|
777
|
+
const response = requestType === "resume" ? await fetch2(`${api}?id=${body.id}`, {
|
778
|
+
method: "GET",
|
779
|
+
headers: {
|
780
|
+
"Content-Type": "application/json",
|
781
|
+
...headers
|
782
|
+
},
|
783
|
+
signal: abortSignal,
|
784
|
+
credentials
|
785
|
+
}) : await fetch2(api, {
|
786
|
+
method: "POST",
|
787
|
+
body: JSON.stringify(body),
|
788
|
+
headers: {
|
789
|
+
"Content-Type": "application/json",
|
790
|
+
...headers
|
791
|
+
},
|
792
|
+
signal: abortSignal,
|
793
|
+
credentials
|
794
|
+
});
|
795
|
+
if (!response.ok) {
|
796
|
+
throw new Error(
|
797
|
+
(_a17 = await response.text()) != null ? _a17 : "Failed to fetch the chat response."
|
798
|
+
);
|
799
|
+
}
|
800
|
+
if (!response.body) {
|
801
|
+
throw new Error("The response body is empty.");
|
802
|
+
}
|
803
|
+
return parseJsonEventStream2({
|
804
|
+
stream: response.body,
|
805
|
+
schema: uiMessageStreamPartSchema
|
806
|
+
}).pipeThrough(
|
807
|
+
new TransformStream({
|
808
|
+
async transform(part, controller) {
|
809
|
+
if (!part.success) {
|
810
|
+
throw part.error;
|
811
|
+
}
|
812
|
+
controller.enqueue(part.value);
|
813
|
+
}
|
814
|
+
})
|
815
|
+
);
|
816
|
+
}
|
817
|
+
var DefaultChatTransport = class {
|
818
|
+
constructor({
|
819
|
+
api = "/api/chat",
|
820
|
+
credentials,
|
821
|
+
headers,
|
822
|
+
body,
|
823
|
+
fetch: fetch2,
|
824
|
+
prepareRequest
|
825
|
+
} = {}) {
|
826
|
+
this.api = api;
|
827
|
+
this.credentials = credentials;
|
828
|
+
this.headers = headers;
|
829
|
+
this.body = body;
|
830
|
+
this.fetch = fetch2;
|
831
|
+
this.prepareRequest = prepareRequest;
|
832
|
+
}
|
833
|
+
submitMessages({
|
834
|
+
chatId,
|
835
|
+
messages,
|
836
|
+
abortSignal,
|
837
|
+
metadata,
|
838
|
+
headers,
|
839
|
+
body,
|
840
|
+
requestType
|
841
|
+
}) {
|
842
|
+
var _a17, _b;
|
843
|
+
const preparedRequest = (_a17 = this.prepareRequest) == null ? void 0 : _a17.call(this, {
|
844
|
+
id: chatId,
|
845
|
+
messages,
|
846
|
+
body: { ...this.body, ...body },
|
847
|
+
headers: { ...this.headers, ...headers },
|
848
|
+
credentials: this.credentials,
|
849
|
+
requestMetadata: metadata
|
850
|
+
});
|
851
|
+
return fetchUIMessageStream({
|
852
|
+
api: this.api,
|
853
|
+
body: (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : { ...this.body, ...body, id: chatId, messages },
|
854
|
+
headers: (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...headers },
|
855
|
+
credentials: (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : this.credentials,
|
856
|
+
abortSignal,
|
857
|
+
fetch: this.fetch,
|
858
|
+
requestType
|
859
|
+
});
|
860
|
+
}
|
861
|
+
};
|
862
|
+
|
732
863
|
// src/ui/process-ui-message-stream.ts
|
733
864
|
import {
|
734
865
|
validateTypes
|
@@ -1413,137 +1544,6 @@ function isAssistantMessageWithCompletedToolCalls(message) {
|
|
1413
1544
|
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => "result" in part.toolInvocation);
|
1414
1545
|
}
|
1415
1546
|
|
1416
|
-
// src/ui/default-chat-transport.ts
|
1417
|
-
import {
|
1418
|
-
parseJsonEventStream as parseJsonEventStream2
|
1419
|
-
} from "@ai-sdk/provider-utils";
|
1420
|
-
var getOriginalFetch2 = () => fetch;
|
1421
|
-
async function fetchUIMessageStream({
|
1422
|
-
api,
|
1423
|
-
body,
|
1424
|
-
credentials,
|
1425
|
-
headers,
|
1426
|
-
abortSignal,
|
1427
|
-
fetch: fetch2 = getOriginalFetch2(),
|
1428
|
-
requestType = "generate"
|
1429
|
-
}) {
|
1430
|
-
var _a17;
|
1431
|
-
const response = requestType === "resume" ? await fetch2(`${api}?id=${body.id}`, {
|
1432
|
-
method: "GET",
|
1433
|
-
headers: {
|
1434
|
-
"Content-Type": "application/json",
|
1435
|
-
...headers
|
1436
|
-
},
|
1437
|
-
signal: abortSignal,
|
1438
|
-
credentials
|
1439
|
-
}) : await fetch2(api, {
|
1440
|
-
method: "POST",
|
1441
|
-
body: JSON.stringify(body),
|
1442
|
-
headers: {
|
1443
|
-
"Content-Type": "application/json",
|
1444
|
-
...headers
|
1445
|
-
},
|
1446
|
-
signal: abortSignal,
|
1447
|
-
credentials
|
1448
|
-
});
|
1449
|
-
if (!response.ok) {
|
1450
|
-
throw new Error(
|
1451
|
-
(_a17 = await response.text()) != null ? _a17 : "Failed to fetch the chat response."
|
1452
|
-
);
|
1453
|
-
}
|
1454
|
-
if (!response.body) {
|
1455
|
-
throw new Error("The response body is empty.");
|
1456
|
-
}
|
1457
|
-
return parseJsonEventStream2({
|
1458
|
-
stream: response.body,
|
1459
|
-
schema: uiMessageStreamPartSchema
|
1460
|
-
}).pipeThrough(
|
1461
|
-
new TransformStream({
|
1462
|
-
async transform(part, controller) {
|
1463
|
-
if (!part.success) {
|
1464
|
-
throw part.error;
|
1465
|
-
}
|
1466
|
-
controller.enqueue(part.value);
|
1467
|
-
}
|
1468
|
-
})
|
1469
|
-
);
|
1470
|
-
}
|
1471
|
-
var DefaultChatTransport = class {
|
1472
|
-
constructor({
|
1473
|
-
api = "/api/chat",
|
1474
|
-
credentials,
|
1475
|
-
headers,
|
1476
|
-
body,
|
1477
|
-
fetch: fetch2,
|
1478
|
-
prepareRequest
|
1479
|
-
} = {}) {
|
1480
|
-
this.api = api;
|
1481
|
-
this.credentials = credentials;
|
1482
|
-
this.headers = headers;
|
1483
|
-
this.body = body;
|
1484
|
-
this.fetch = fetch2;
|
1485
|
-
this.prepareRequest = prepareRequest;
|
1486
|
-
}
|
1487
|
-
submitMessages({
|
1488
|
-
chatId,
|
1489
|
-
messages,
|
1490
|
-
abortSignal,
|
1491
|
-
metadata,
|
1492
|
-
headers,
|
1493
|
-
body,
|
1494
|
-
requestType
|
1495
|
-
}) {
|
1496
|
-
var _a17, _b;
|
1497
|
-
const preparedRequest = (_a17 = this.prepareRequest) == null ? void 0 : _a17.call(this, {
|
1498
|
-
id: chatId,
|
1499
|
-
messages,
|
1500
|
-
body: { ...this.body, ...body },
|
1501
|
-
headers: { ...this.headers, ...headers },
|
1502
|
-
credentials: this.credentials,
|
1503
|
-
requestMetadata: metadata
|
1504
|
-
});
|
1505
|
-
return fetchUIMessageStream({
|
1506
|
-
api: this.api,
|
1507
|
-
body: (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : { ...this.body, ...body, id: chatId, messages },
|
1508
|
-
headers: (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...headers },
|
1509
|
-
credentials: (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : this.credentials,
|
1510
|
-
abortSignal,
|
1511
|
-
fetch: this.fetch,
|
1512
|
-
requestType
|
1513
|
-
});
|
1514
|
-
}
|
1515
|
-
};
|
1516
|
-
|
1517
|
-
// src/ui/convert-file-list-to-file-ui-parts.ts
|
1518
|
-
async function convertFileListToFileUIParts(files) {
|
1519
|
-
if (files == null) {
|
1520
|
-
return [];
|
1521
|
-
}
|
1522
|
-
if (!globalThis.FileList || !(files instanceof globalThis.FileList)) {
|
1523
|
-
throw new Error("FileList is not supported in the current environment");
|
1524
|
-
}
|
1525
|
-
return Promise.all(
|
1526
|
-
Array.from(files).map(async (file) => {
|
1527
|
-
const { name: name17, type } = file;
|
1528
|
-
const dataUrl = await new Promise((resolve, reject) => {
|
1529
|
-
const reader = new FileReader();
|
1530
|
-
reader.onload = (readerEvent) => {
|
1531
|
-
var _a17;
|
1532
|
-
resolve((_a17 = readerEvent.target) == null ? void 0 : _a17.result);
|
1533
|
-
};
|
1534
|
-
reader.onerror = (error) => reject(error);
|
1535
|
-
reader.readAsDataURL(file);
|
1536
|
-
});
|
1537
|
-
return {
|
1538
|
-
type: "file",
|
1539
|
-
mediaType: type,
|
1540
|
-
filename: name17,
|
1541
|
-
url: dataUrl
|
1542
|
-
};
|
1543
|
-
})
|
1544
|
-
);
|
1545
|
-
}
|
1546
|
-
|
1547
1547
|
// src/ui/chat.ts
|
1548
1548
|
var AbstractChat = class {
|
1549
1549
|
constructor({
|
@@ -1558,7 +1558,6 @@ var AbstractChat = class {
|
|
1558
1558
|
onToolCall,
|
1559
1559
|
onFinish
|
1560
1560
|
}) {
|
1561
|
-
this.subscribers = /* @__PURE__ */ new Set();
|
1562
1561
|
this.activeResponse = void 0;
|
1563
1562
|
this.jobExecutor = new SerialJobExecutor();
|
1564
1563
|
this.removeAssistantResponse = () => {
|
@@ -1570,7 +1569,6 @@ var AbstractChat = class {
|
|
1570
1569
|
throw new Error("Last message is not an assistant message");
|
1571
1570
|
}
|
1572
1571
|
this.state.popMessage();
|
1573
|
-
this.emit({ type: "messages-changed" });
|
1574
1572
|
};
|
1575
1573
|
/**
|
1576
1574
|
* Append a user message to the chat list. This triggers the API call to fetch
|
@@ -1595,7 +1593,6 @@ var AbstractChat = class {
|
|
1595
1593
|
id: (_a17 = uiMessage.id) != null ? _a17 : this.generateId(),
|
1596
1594
|
role: (_b = uiMessage.role) != null ? _b : "user"
|
1597
1595
|
});
|
1598
|
-
this.emit({ type: "messages-changed" });
|
1599
1596
|
await this.triggerRequest({ requestType: "generate", ...options });
|
1600
1597
|
};
|
1601
1598
|
/**
|
@@ -1607,7 +1604,6 @@ var AbstractChat = class {
|
|
1607
1604
|
}
|
1608
1605
|
if (this.lastMessage.role === "assistant") {
|
1609
1606
|
this.state.popMessage();
|
1610
|
-
this.emit({ type: "messages-changed" });
|
1611
1607
|
}
|
1612
1608
|
await this.triggerRequest({ requestType: "generate", ...options });
|
1613
1609
|
};
|
@@ -1681,7 +1677,6 @@ var AbstractChat = class {
|
|
1681
1677
|
return;
|
1682
1678
|
this.state.status = status;
|
1683
1679
|
this.state.error = error;
|
1684
|
-
this.emit({ type: "status-changed" });
|
1685
1680
|
}
|
1686
1681
|
get error() {
|
1687
1682
|
return this.state.error;
|
@@ -1692,18 +1687,8 @@ var AbstractChat = class {
|
|
1692
1687
|
get lastMessage() {
|
1693
1688
|
return this.state.messages[this.state.messages.length - 1];
|
1694
1689
|
}
|
1695
|
-
subscribe(subscriber) {
|
1696
|
-
this.subscribers.add(subscriber);
|
1697
|
-
return () => this.subscribers.delete(subscriber);
|
1698
|
-
}
|
1699
1690
|
set messages(messages) {
|
1700
1691
|
this.state.messages = messages;
|
1701
|
-
this.emit({ type: "messages-changed" });
|
1702
|
-
}
|
1703
|
-
emit(event) {
|
1704
|
-
for (const subscriber of this.subscribers) {
|
1705
|
-
subscriber.onChange(event);
|
1706
|
-
}
|
1707
1692
|
}
|
1708
1693
|
async triggerRequest({
|
1709
1694
|
requestType,
|
@@ -1751,9 +1736,6 @@ var AbstractChat = class {
|
|
1751
1736
|
} else {
|
1752
1737
|
this.state.pushMessage(activeResponse.state.message);
|
1753
1738
|
}
|
1754
|
-
this.emit({
|
1755
|
-
type: "messages-changed"
|
1756
|
-
});
|
1757
1739
|
}
|
1758
1740
|
})
|
1759
1741
|
)
|
@@ -2156,7 +2138,10 @@ function createUIMessageStream({
|
|
2156
2138
|
safeEnqueue(value);
|
2157
2139
|
}
|
2158
2140
|
})().catch((error) => {
|
2159
|
-
safeEnqueue({
|
2141
|
+
safeEnqueue({
|
2142
|
+
type: "error",
|
2143
|
+
errorText: onError(error)
|
2144
|
+
});
|
2160
2145
|
})
|
2161
2146
|
);
|
2162
2147
|
},
|
@@ -2166,12 +2151,18 @@ function createUIMessageStream({
|
|
2166
2151
|
if (result) {
|
2167
2152
|
ongoingStreamPromises.push(
|
2168
2153
|
result.catch((error) => {
|
2169
|
-
safeEnqueue({
|
2154
|
+
safeEnqueue({
|
2155
|
+
type: "error",
|
2156
|
+
errorText: onError(error)
|
2157
|
+
});
|
2170
2158
|
})
|
2171
2159
|
);
|
2172
2160
|
}
|
2173
2161
|
} catch (error) {
|
2174
|
-
safeEnqueue({
|
2162
|
+
safeEnqueue({
|
2163
|
+
type: "error",
|
2164
|
+
errorText: onError(error)
|
2165
|
+
});
|
2175
2166
|
}
|
2176
2167
|
const waitForStreams = new Promise(async (resolve) => {
|
2177
2168
|
while (ongoingStreamPromises.length > 0) {
|
@@ -2193,16 +2184,6 @@ function createUIMessageStream({
|
|
2193
2184
|
});
|
2194
2185
|
}
|
2195
2186
|
|
2196
|
-
// src/ui-message-stream/ui-message-stream-headers.ts
|
2197
|
-
var uiMessageStreamHeaders = {
|
2198
|
-
"content-type": "text/event-stream",
|
2199
|
-
"cache-control": "no-cache",
|
2200
|
-
connection: "keep-alive",
|
2201
|
-
"x-vercel-ai-ui-message-stream": "v1",
|
2202
|
-
"x-accel-buffering": "no"
|
2203
|
-
// disable nginx buffering
|
2204
|
-
};
|
2205
|
-
|
2206
2187
|
// src/ui-message-stream/json-to-sse-transform-stream.ts
|
2207
2188
|
var JsonToSseTransformStream = class extends TransformStream {
|
2208
2189
|
constructor() {
|
@@ -2219,6 +2200,16 @@ var JsonToSseTransformStream = class extends TransformStream {
|
|
2219
2200
|
}
|
2220
2201
|
};
|
2221
2202
|
|
2203
|
+
// src/ui-message-stream/ui-message-stream-headers.ts
|
2204
|
+
var uiMessageStreamHeaders = {
|
2205
|
+
"content-type": "text/event-stream",
|
2206
|
+
"cache-control": "no-cache",
|
2207
|
+
connection: "keep-alive",
|
2208
|
+
"x-vercel-ai-ui-message-stream": "v1",
|
2209
|
+
"x-accel-buffering": "no"
|
2210
|
+
// disable nginx buffering
|
2211
|
+
};
|
2212
|
+
|
2222
2213
|
// src/ui-message-stream/create-ui-message-stream-response.ts
|
2223
2214
|
function createUIMessageStreamResponse({
|
2224
2215
|
status,
|
@@ -4885,7 +4876,8 @@ var DefaultStreamObjectResult = class {
|
|
4885
4876
|
}),
|
4886
4877
|
providerOptions,
|
4887
4878
|
abortSignal,
|
4888
|
-
headers
|
4879
|
+
headers,
|
4880
|
+
includeRawChunks: false
|
4889
4881
|
};
|
4890
4882
|
const transformer = {
|
4891
4883
|
transform: (chunk, controller) => {
|
@@ -6243,7 +6235,6 @@ import { generateId } from "@ai-sdk/provider-utils";
|
|
6243
6235
|
function runToolsTransformation({
|
6244
6236
|
tools,
|
6245
6237
|
generatorStream,
|
6246
|
-
toolCallStreaming,
|
6247
6238
|
tracer,
|
6248
6239
|
telemetry,
|
6249
6240
|
system,
|
@@ -6284,6 +6275,10 @@ function runToolsTransformation({
|
|
6284
6275
|
controller.enqueue(chunk);
|
6285
6276
|
break;
|
6286
6277
|
}
|
6278
|
+
case "raw": {
|
6279
|
+
controller.enqueue(chunk);
|
6280
|
+
break;
|
6281
|
+
}
|
6287
6282
|
case "file": {
|
6288
6283
|
controller.enqueue({
|
6289
6284
|
type: "file",
|
@@ -6295,22 +6290,20 @@ function runToolsTransformation({
|
|
6295
6290
|
break;
|
6296
6291
|
}
|
6297
6292
|
case "tool-call-delta": {
|
6298
|
-
if (
|
6299
|
-
if (!activeToolCalls[chunk.toolCallId]) {
|
6300
|
-
controller.enqueue({
|
6301
|
-
type: "tool-call-streaming-start",
|
6302
|
-
toolCallId: chunk.toolCallId,
|
6303
|
-
toolName: chunk.toolName
|
6304
|
-
});
|
6305
|
-
activeToolCalls[chunk.toolCallId] = true;
|
6306
|
-
}
|
6293
|
+
if (!activeToolCalls[chunk.toolCallId]) {
|
6307
6294
|
controller.enqueue({
|
6308
|
-
type: "tool-call-
|
6295
|
+
type: "tool-call-streaming-start",
|
6309
6296
|
toolCallId: chunk.toolCallId,
|
6310
|
-
toolName: chunk.toolName
|
6311
|
-
argsTextDelta: chunk.argsTextDelta
|
6297
|
+
toolName: chunk.toolName
|
6312
6298
|
});
|
6299
|
+
activeToolCalls[chunk.toolCallId] = true;
|
6313
6300
|
}
|
6301
|
+
controller.enqueue({
|
6302
|
+
type: "tool-call-delta",
|
6303
|
+
toolCallId: chunk.toolCallId,
|
6304
|
+
toolName: chunk.toolName,
|
6305
|
+
argsTextDelta: chunk.argsTextDelta
|
6306
|
+
});
|
6314
6307
|
break;
|
6315
6308
|
}
|
6316
6309
|
case "tool-call": {
|
@@ -6461,12 +6454,11 @@ function streamText({
|
|
6461
6454
|
experimental_telemetry: telemetry,
|
6462
6455
|
prepareStep,
|
6463
6456
|
providerOptions,
|
6464
|
-
experimental_toolCallStreaming = false,
|
6465
|
-
toolCallStreaming = experimental_toolCallStreaming,
|
6466
6457
|
experimental_activeTools,
|
6467
6458
|
activeTools = experimental_activeTools,
|
6468
6459
|
experimental_repairToolCall: repairToolCall,
|
6469
6460
|
experimental_transform: transform,
|
6461
|
+
includeRawChunks = false,
|
6470
6462
|
onChunk,
|
6471
6463
|
onError = ({ error }) => {
|
6472
6464
|
console.error(error);
|
@@ -6492,7 +6484,6 @@ function streamText({
|
|
6492
6484
|
messages,
|
6493
6485
|
tools,
|
6494
6486
|
toolChoice,
|
6495
|
-
toolCallStreaming,
|
6496
6487
|
transforms: asArray(transform),
|
6497
6488
|
activeTools,
|
6498
6489
|
repairToolCall,
|
@@ -6500,6 +6491,7 @@ function streamText({
|
|
6500
6491
|
output,
|
6501
6492
|
providerOptions,
|
6502
6493
|
prepareStep,
|
6494
|
+
includeRawChunks,
|
6503
6495
|
onChunk,
|
6504
6496
|
onError,
|
6505
6497
|
onFinish,
|
@@ -6570,7 +6562,6 @@ var DefaultStreamTextResult = class {
|
|
6570
6562
|
messages,
|
6571
6563
|
tools,
|
6572
6564
|
toolChoice,
|
6573
|
-
toolCallStreaming,
|
6574
6565
|
transforms,
|
6575
6566
|
activeTools,
|
6576
6567
|
repairToolCall,
|
@@ -6578,6 +6569,7 @@ var DefaultStreamTextResult = class {
|
|
6578
6569
|
output,
|
6579
6570
|
providerOptions,
|
6580
6571
|
prepareStep,
|
6572
|
+
includeRawChunks,
|
6581
6573
|
now: now2,
|
6582
6574
|
currentDate,
|
6583
6575
|
generateId: generateId3,
|
@@ -6590,6 +6582,7 @@ var DefaultStreamTextResult = class {
|
|
6590
6582
|
this._finishReason = new DelayedPromise();
|
6591
6583
|
this._steps = new DelayedPromise();
|
6592
6584
|
this.output = output;
|
6585
|
+
this.includeRawChunks = includeRawChunks;
|
6593
6586
|
this.generateId = generateId3;
|
6594
6587
|
let stepFinish;
|
6595
6588
|
let activeReasoningPart = void 0;
|
@@ -6797,6 +6790,7 @@ var DefaultStreamTextResult = class {
|
|
6797
6790
|
usage
|
6798
6791
|
}) {
|
6799
6792
|
var _a17, _b, _c, _d;
|
6793
|
+
const includeRawChunks2 = self.includeRawChunks;
|
6800
6794
|
stepFinish = new DelayedPromise();
|
6801
6795
|
const initialPrompt = await standardizePrompt({
|
6802
6796
|
system,
|
@@ -6883,7 +6877,8 @@ var DefaultStreamTextResult = class {
|
|
6883
6877
|
prompt: promptMessages,
|
6884
6878
|
providerOptions,
|
6885
6879
|
abortSignal,
|
6886
|
-
headers
|
6880
|
+
headers,
|
6881
|
+
includeRawChunks: includeRawChunks2
|
6887
6882
|
})
|
6888
6883
|
};
|
6889
6884
|
}
|
@@ -6892,7 +6887,6 @@ var DefaultStreamTextResult = class {
|
|
6892
6887
|
const streamWithToolResults = runToolsTransformation({
|
6893
6888
|
tools,
|
6894
6889
|
generatorStream: stream2,
|
6895
|
-
toolCallStreaming,
|
6896
6890
|
tracer,
|
6897
6891
|
telemetry,
|
6898
6892
|
system,
|
@@ -7052,6 +7046,10 @@ var DefaultStreamTextResult = class {
|
|
7052
7046
|
stepFinishReason = "error";
|
7053
7047
|
break;
|
7054
7048
|
}
|
7049
|
+
case "raw": {
|
7050
|
+
controller.enqueue(chunk);
|
7051
|
+
break;
|
7052
|
+
}
|
7055
7053
|
default: {
|
7056
7054
|
const exhaustiveCheck = chunkType;
|
7057
7055
|
throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);
|
@@ -7421,6 +7419,9 @@ var DefaultStreamTextResult = class {
|
|
7421
7419
|
}
|
7422
7420
|
break;
|
7423
7421
|
}
|
7422
|
+
case "raw": {
|
7423
|
+
break;
|
7424
|
+
}
|
7424
7425
|
default: {
|
7425
7426
|
const exhaustiveCheck = partType;
|
7426
7427
|
throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);
|