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.js
CHANGED
@@ -812,8 +812,137 @@ var SerialJobExecutor = class {
|
|
812
812
|
}
|
813
813
|
};
|
814
814
|
|
815
|
+
// src/ui/convert-file-list-to-file-ui-parts.ts
|
816
|
+
async function convertFileListToFileUIParts(files) {
|
817
|
+
if (files == null) {
|
818
|
+
return [];
|
819
|
+
}
|
820
|
+
if (!globalThis.FileList || !(files instanceof globalThis.FileList)) {
|
821
|
+
throw new Error("FileList is not supported in the current environment");
|
822
|
+
}
|
823
|
+
return Promise.all(
|
824
|
+
Array.from(files).map(async (file) => {
|
825
|
+
const { name: name17, type } = file;
|
826
|
+
const dataUrl = await new Promise((resolve, reject) => {
|
827
|
+
const reader = new FileReader();
|
828
|
+
reader.onload = (readerEvent) => {
|
829
|
+
var _a17;
|
830
|
+
resolve((_a17 = readerEvent.target) == null ? void 0 : _a17.result);
|
831
|
+
};
|
832
|
+
reader.onerror = (error) => reject(error);
|
833
|
+
reader.readAsDataURL(file);
|
834
|
+
});
|
835
|
+
return {
|
836
|
+
type: "file",
|
837
|
+
mediaType: type,
|
838
|
+
filename: name17,
|
839
|
+
url: dataUrl
|
840
|
+
};
|
841
|
+
})
|
842
|
+
);
|
843
|
+
}
|
844
|
+
|
845
|
+
// src/ui/default-chat-transport.ts
|
846
|
+
var import_provider_utils2 = require("@ai-sdk/provider-utils");
|
847
|
+
var getOriginalFetch2 = () => fetch;
|
848
|
+
async function fetchUIMessageStream({
|
849
|
+
api,
|
850
|
+
body,
|
851
|
+
credentials,
|
852
|
+
headers,
|
853
|
+
abortSignal,
|
854
|
+
fetch: fetch2 = getOriginalFetch2(),
|
855
|
+
requestType = "generate"
|
856
|
+
}) {
|
857
|
+
var _a17;
|
858
|
+
const response = requestType === "resume" ? await fetch2(`${api}?id=${body.id}`, {
|
859
|
+
method: "GET",
|
860
|
+
headers: {
|
861
|
+
"Content-Type": "application/json",
|
862
|
+
...headers
|
863
|
+
},
|
864
|
+
signal: abortSignal,
|
865
|
+
credentials
|
866
|
+
}) : await fetch2(api, {
|
867
|
+
method: "POST",
|
868
|
+
body: JSON.stringify(body),
|
869
|
+
headers: {
|
870
|
+
"Content-Type": "application/json",
|
871
|
+
...headers
|
872
|
+
},
|
873
|
+
signal: abortSignal,
|
874
|
+
credentials
|
875
|
+
});
|
876
|
+
if (!response.ok) {
|
877
|
+
throw new Error(
|
878
|
+
(_a17 = await response.text()) != null ? _a17 : "Failed to fetch the chat response."
|
879
|
+
);
|
880
|
+
}
|
881
|
+
if (!response.body) {
|
882
|
+
throw new Error("The response body is empty.");
|
883
|
+
}
|
884
|
+
return (0, import_provider_utils2.parseJsonEventStream)({
|
885
|
+
stream: response.body,
|
886
|
+
schema: uiMessageStreamPartSchema
|
887
|
+
}).pipeThrough(
|
888
|
+
new TransformStream({
|
889
|
+
async transform(part, controller) {
|
890
|
+
if (!part.success) {
|
891
|
+
throw part.error;
|
892
|
+
}
|
893
|
+
controller.enqueue(part.value);
|
894
|
+
}
|
895
|
+
})
|
896
|
+
);
|
897
|
+
}
|
898
|
+
var DefaultChatTransport = class {
|
899
|
+
constructor({
|
900
|
+
api = "/api/chat",
|
901
|
+
credentials,
|
902
|
+
headers,
|
903
|
+
body,
|
904
|
+
fetch: fetch2,
|
905
|
+
prepareRequest
|
906
|
+
} = {}) {
|
907
|
+
this.api = api;
|
908
|
+
this.credentials = credentials;
|
909
|
+
this.headers = headers;
|
910
|
+
this.body = body;
|
911
|
+
this.fetch = fetch2;
|
912
|
+
this.prepareRequest = prepareRequest;
|
913
|
+
}
|
914
|
+
submitMessages({
|
915
|
+
chatId,
|
916
|
+
messages,
|
917
|
+
abortSignal,
|
918
|
+
metadata,
|
919
|
+
headers,
|
920
|
+
body,
|
921
|
+
requestType
|
922
|
+
}) {
|
923
|
+
var _a17, _b;
|
924
|
+
const preparedRequest = (_a17 = this.prepareRequest) == null ? void 0 : _a17.call(this, {
|
925
|
+
id: chatId,
|
926
|
+
messages,
|
927
|
+
body: { ...this.body, ...body },
|
928
|
+
headers: { ...this.headers, ...headers },
|
929
|
+
credentials: this.credentials,
|
930
|
+
requestMetadata: metadata
|
931
|
+
});
|
932
|
+
return fetchUIMessageStream({
|
933
|
+
api: this.api,
|
934
|
+
body: (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : { ...this.body, ...body, id: chatId, messages },
|
935
|
+
headers: (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...headers },
|
936
|
+
credentials: (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : this.credentials,
|
937
|
+
abortSignal,
|
938
|
+
fetch: this.fetch,
|
939
|
+
requestType
|
940
|
+
});
|
941
|
+
}
|
942
|
+
};
|
943
|
+
|
815
944
|
// src/ui/process-ui-message-stream.ts
|
816
|
-
var
|
945
|
+
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
817
946
|
|
818
947
|
// src/util/merge-objects.ts
|
819
948
|
function mergeObjects(base, overrides) {
|
@@ -849,7 +978,7 @@ function mergeObjects(base, overrides) {
|
|
849
978
|
}
|
850
979
|
|
851
980
|
// src/util/parse-partial-json.ts
|
852
|
-
var
|
981
|
+
var import_provider_utils3 = require("@ai-sdk/provider-utils");
|
853
982
|
|
854
983
|
// src/util/fix-json.ts
|
855
984
|
function fixJson(input) {
|
@@ -1174,11 +1303,11 @@ async function parsePartialJson(jsonText) {
|
|
1174
1303
|
if (jsonText === void 0) {
|
1175
1304
|
return { value: void 0, state: "undefined-input" };
|
1176
1305
|
}
|
1177
|
-
let result = await (0,
|
1306
|
+
let result = await (0, import_provider_utils3.safeParseJSON)({ text: jsonText });
|
1178
1307
|
if (result.success) {
|
1179
1308
|
return { value: result.value, state: "successful-parse" };
|
1180
1309
|
}
|
1181
|
-
result = await (0,
|
1310
|
+
result = await (0, import_provider_utils3.safeParseJSON)({ text: fixJson(jsonText) });
|
1182
1311
|
if (result.success) {
|
1183
1312
|
return { value: result.value, state: "repaired-parse" };
|
1184
1313
|
}
|
@@ -1239,7 +1368,7 @@ function processUIMessageStream({
|
|
1239
1368
|
if (metadata != null) {
|
1240
1369
|
const mergedMetadata = state.message.metadata != null ? mergeObjects(state.message.metadata, metadata) : metadata;
|
1241
1370
|
if (messageMetadataSchema != null) {
|
1242
|
-
await (0,
|
1371
|
+
await (0, import_provider_utils4.validateTypes)({
|
1243
1372
|
value: mergedMetadata,
|
1244
1373
|
schema: messageMetadataSchema
|
1245
1374
|
});
|
@@ -1494,135 +1623,6 @@ function isAssistantMessageWithCompletedToolCalls(message) {
|
|
1494
1623
|
return lastStepToolInvocations.length > 0 && lastStepToolInvocations.every((part) => "result" in part.toolInvocation);
|
1495
1624
|
}
|
1496
1625
|
|
1497
|
-
// src/ui/default-chat-transport.ts
|
1498
|
-
var import_provider_utils4 = require("@ai-sdk/provider-utils");
|
1499
|
-
var getOriginalFetch2 = () => fetch;
|
1500
|
-
async function fetchUIMessageStream({
|
1501
|
-
api,
|
1502
|
-
body,
|
1503
|
-
credentials,
|
1504
|
-
headers,
|
1505
|
-
abortSignal,
|
1506
|
-
fetch: fetch2 = getOriginalFetch2(),
|
1507
|
-
requestType = "generate"
|
1508
|
-
}) {
|
1509
|
-
var _a17;
|
1510
|
-
const response = requestType === "resume" ? await fetch2(`${api}?id=${body.id}`, {
|
1511
|
-
method: "GET",
|
1512
|
-
headers: {
|
1513
|
-
"Content-Type": "application/json",
|
1514
|
-
...headers
|
1515
|
-
},
|
1516
|
-
signal: abortSignal,
|
1517
|
-
credentials
|
1518
|
-
}) : await fetch2(api, {
|
1519
|
-
method: "POST",
|
1520
|
-
body: JSON.stringify(body),
|
1521
|
-
headers: {
|
1522
|
-
"Content-Type": "application/json",
|
1523
|
-
...headers
|
1524
|
-
},
|
1525
|
-
signal: abortSignal,
|
1526
|
-
credentials
|
1527
|
-
});
|
1528
|
-
if (!response.ok) {
|
1529
|
-
throw new Error(
|
1530
|
-
(_a17 = await response.text()) != null ? _a17 : "Failed to fetch the chat response."
|
1531
|
-
);
|
1532
|
-
}
|
1533
|
-
if (!response.body) {
|
1534
|
-
throw new Error("The response body is empty.");
|
1535
|
-
}
|
1536
|
-
return (0, import_provider_utils4.parseJsonEventStream)({
|
1537
|
-
stream: response.body,
|
1538
|
-
schema: uiMessageStreamPartSchema
|
1539
|
-
}).pipeThrough(
|
1540
|
-
new TransformStream({
|
1541
|
-
async transform(part, controller) {
|
1542
|
-
if (!part.success) {
|
1543
|
-
throw part.error;
|
1544
|
-
}
|
1545
|
-
controller.enqueue(part.value);
|
1546
|
-
}
|
1547
|
-
})
|
1548
|
-
);
|
1549
|
-
}
|
1550
|
-
var DefaultChatTransport = class {
|
1551
|
-
constructor({
|
1552
|
-
api = "/api/chat",
|
1553
|
-
credentials,
|
1554
|
-
headers,
|
1555
|
-
body,
|
1556
|
-
fetch: fetch2,
|
1557
|
-
prepareRequest
|
1558
|
-
} = {}) {
|
1559
|
-
this.api = api;
|
1560
|
-
this.credentials = credentials;
|
1561
|
-
this.headers = headers;
|
1562
|
-
this.body = body;
|
1563
|
-
this.fetch = fetch2;
|
1564
|
-
this.prepareRequest = prepareRequest;
|
1565
|
-
}
|
1566
|
-
submitMessages({
|
1567
|
-
chatId,
|
1568
|
-
messages,
|
1569
|
-
abortSignal,
|
1570
|
-
metadata,
|
1571
|
-
headers,
|
1572
|
-
body,
|
1573
|
-
requestType
|
1574
|
-
}) {
|
1575
|
-
var _a17, _b;
|
1576
|
-
const preparedRequest = (_a17 = this.prepareRequest) == null ? void 0 : _a17.call(this, {
|
1577
|
-
id: chatId,
|
1578
|
-
messages,
|
1579
|
-
body: { ...this.body, ...body },
|
1580
|
-
headers: { ...this.headers, ...headers },
|
1581
|
-
credentials: this.credentials,
|
1582
|
-
requestMetadata: metadata
|
1583
|
-
});
|
1584
|
-
return fetchUIMessageStream({
|
1585
|
-
api: this.api,
|
1586
|
-
body: (preparedRequest == null ? void 0 : preparedRequest.body) !== void 0 ? preparedRequest.body : { ...this.body, ...body, id: chatId, messages },
|
1587
|
-
headers: (preparedRequest == null ? void 0 : preparedRequest.headers) !== void 0 ? preparedRequest.headers : { ...this.headers, ...headers },
|
1588
|
-
credentials: (_b = preparedRequest == null ? void 0 : preparedRequest.credentials) != null ? _b : this.credentials,
|
1589
|
-
abortSignal,
|
1590
|
-
fetch: this.fetch,
|
1591
|
-
requestType
|
1592
|
-
});
|
1593
|
-
}
|
1594
|
-
};
|
1595
|
-
|
1596
|
-
// src/ui/convert-file-list-to-file-ui-parts.ts
|
1597
|
-
async function convertFileListToFileUIParts(files) {
|
1598
|
-
if (files == null) {
|
1599
|
-
return [];
|
1600
|
-
}
|
1601
|
-
if (!globalThis.FileList || !(files instanceof globalThis.FileList)) {
|
1602
|
-
throw new Error("FileList is not supported in the current environment");
|
1603
|
-
}
|
1604
|
-
return Promise.all(
|
1605
|
-
Array.from(files).map(async (file) => {
|
1606
|
-
const { name: name17, type } = file;
|
1607
|
-
const dataUrl = await new Promise((resolve, reject) => {
|
1608
|
-
const reader = new FileReader();
|
1609
|
-
reader.onload = (readerEvent) => {
|
1610
|
-
var _a17;
|
1611
|
-
resolve((_a17 = readerEvent.target) == null ? void 0 : _a17.result);
|
1612
|
-
};
|
1613
|
-
reader.onerror = (error) => reject(error);
|
1614
|
-
reader.readAsDataURL(file);
|
1615
|
-
});
|
1616
|
-
return {
|
1617
|
-
type: "file",
|
1618
|
-
mediaType: type,
|
1619
|
-
filename: name17,
|
1620
|
-
url: dataUrl
|
1621
|
-
};
|
1622
|
-
})
|
1623
|
-
);
|
1624
|
-
}
|
1625
|
-
|
1626
1626
|
// src/ui/chat.ts
|
1627
1627
|
var AbstractChat = class {
|
1628
1628
|
constructor({
|
@@ -1637,7 +1637,6 @@ var AbstractChat = class {
|
|
1637
1637
|
onToolCall,
|
1638
1638
|
onFinish
|
1639
1639
|
}) {
|
1640
|
-
this.subscribers = /* @__PURE__ */ new Set();
|
1641
1640
|
this.activeResponse = void 0;
|
1642
1641
|
this.jobExecutor = new SerialJobExecutor();
|
1643
1642
|
this.removeAssistantResponse = () => {
|
@@ -1649,7 +1648,6 @@ var AbstractChat = class {
|
|
1649
1648
|
throw new Error("Last message is not an assistant message");
|
1650
1649
|
}
|
1651
1650
|
this.state.popMessage();
|
1652
|
-
this.emit({ type: "messages-changed" });
|
1653
1651
|
};
|
1654
1652
|
/**
|
1655
1653
|
* Append a user message to the chat list. This triggers the API call to fetch
|
@@ -1674,7 +1672,6 @@ var AbstractChat = class {
|
|
1674
1672
|
id: (_a17 = uiMessage.id) != null ? _a17 : this.generateId(),
|
1675
1673
|
role: (_b = uiMessage.role) != null ? _b : "user"
|
1676
1674
|
});
|
1677
|
-
this.emit({ type: "messages-changed" });
|
1678
1675
|
await this.triggerRequest({ requestType: "generate", ...options });
|
1679
1676
|
};
|
1680
1677
|
/**
|
@@ -1686,7 +1683,6 @@ var AbstractChat = class {
|
|
1686
1683
|
}
|
1687
1684
|
if (this.lastMessage.role === "assistant") {
|
1688
1685
|
this.state.popMessage();
|
1689
|
-
this.emit({ type: "messages-changed" });
|
1690
1686
|
}
|
1691
1687
|
await this.triggerRequest({ requestType: "generate", ...options });
|
1692
1688
|
};
|
@@ -1760,7 +1756,6 @@ var AbstractChat = class {
|
|
1760
1756
|
return;
|
1761
1757
|
this.state.status = status;
|
1762
1758
|
this.state.error = error;
|
1763
|
-
this.emit({ type: "status-changed" });
|
1764
1759
|
}
|
1765
1760
|
get error() {
|
1766
1761
|
return this.state.error;
|
@@ -1771,18 +1766,8 @@ var AbstractChat = class {
|
|
1771
1766
|
get lastMessage() {
|
1772
1767
|
return this.state.messages[this.state.messages.length - 1];
|
1773
1768
|
}
|
1774
|
-
subscribe(subscriber) {
|
1775
|
-
this.subscribers.add(subscriber);
|
1776
|
-
return () => this.subscribers.delete(subscriber);
|
1777
|
-
}
|
1778
1769
|
set messages(messages) {
|
1779
1770
|
this.state.messages = messages;
|
1780
|
-
this.emit({ type: "messages-changed" });
|
1781
|
-
}
|
1782
|
-
emit(event) {
|
1783
|
-
for (const subscriber of this.subscribers) {
|
1784
|
-
subscriber.onChange(event);
|
1785
|
-
}
|
1786
1771
|
}
|
1787
1772
|
async triggerRequest({
|
1788
1773
|
requestType,
|
@@ -1830,9 +1815,6 @@ var AbstractChat = class {
|
|
1830
1815
|
} else {
|
1831
1816
|
this.state.pushMessage(activeResponse.state.message);
|
1832
1817
|
}
|
1833
|
-
this.emit({
|
1834
|
-
type: "messages-changed"
|
1835
|
-
});
|
1836
1818
|
}
|
1837
1819
|
})
|
1838
1820
|
)
|
@@ -2235,7 +2217,10 @@ function createUIMessageStream({
|
|
2235
2217
|
safeEnqueue(value);
|
2236
2218
|
}
|
2237
2219
|
})().catch((error) => {
|
2238
|
-
safeEnqueue({
|
2220
|
+
safeEnqueue({
|
2221
|
+
type: "error",
|
2222
|
+
errorText: onError(error)
|
2223
|
+
});
|
2239
2224
|
})
|
2240
2225
|
);
|
2241
2226
|
},
|
@@ -2245,12 +2230,18 @@ function createUIMessageStream({
|
|
2245
2230
|
if (result) {
|
2246
2231
|
ongoingStreamPromises.push(
|
2247
2232
|
result.catch((error) => {
|
2248
|
-
safeEnqueue({
|
2233
|
+
safeEnqueue({
|
2234
|
+
type: "error",
|
2235
|
+
errorText: onError(error)
|
2236
|
+
});
|
2249
2237
|
})
|
2250
2238
|
);
|
2251
2239
|
}
|
2252
2240
|
} catch (error) {
|
2253
|
-
safeEnqueue({
|
2241
|
+
safeEnqueue({
|
2242
|
+
type: "error",
|
2243
|
+
errorText: onError(error)
|
2244
|
+
});
|
2254
2245
|
}
|
2255
2246
|
const waitForStreams = new Promise(async (resolve) => {
|
2256
2247
|
while (ongoingStreamPromises.length > 0) {
|
@@ -2272,16 +2263,6 @@ function createUIMessageStream({
|
|
2272
2263
|
});
|
2273
2264
|
}
|
2274
2265
|
|
2275
|
-
// src/ui-message-stream/ui-message-stream-headers.ts
|
2276
|
-
var uiMessageStreamHeaders = {
|
2277
|
-
"content-type": "text/event-stream",
|
2278
|
-
"cache-control": "no-cache",
|
2279
|
-
connection: "keep-alive",
|
2280
|
-
"x-vercel-ai-ui-message-stream": "v1",
|
2281
|
-
"x-accel-buffering": "no"
|
2282
|
-
// disable nginx buffering
|
2283
|
-
};
|
2284
|
-
|
2285
2266
|
// src/ui-message-stream/json-to-sse-transform-stream.ts
|
2286
2267
|
var JsonToSseTransformStream = class extends TransformStream {
|
2287
2268
|
constructor() {
|
@@ -2298,6 +2279,16 @@ var JsonToSseTransformStream = class extends TransformStream {
|
|
2298
2279
|
}
|
2299
2280
|
};
|
2300
2281
|
|
2282
|
+
// src/ui-message-stream/ui-message-stream-headers.ts
|
2283
|
+
var uiMessageStreamHeaders = {
|
2284
|
+
"content-type": "text/event-stream",
|
2285
|
+
"cache-control": "no-cache",
|
2286
|
+
connection: "keep-alive",
|
2287
|
+
"x-vercel-ai-ui-message-stream": "v1",
|
2288
|
+
"x-accel-buffering": "no"
|
2289
|
+
// disable nginx buffering
|
2290
|
+
};
|
2291
|
+
|
2301
2292
|
// src/ui-message-stream/create-ui-message-stream-response.ts
|
2302
2293
|
function createUIMessageStreamResponse({
|
2303
2294
|
status,
|
@@ -4939,7 +4930,8 @@ var DefaultStreamObjectResult = class {
|
|
4939
4930
|
}),
|
4940
4931
|
providerOptions,
|
4941
4932
|
abortSignal,
|
4942
|
-
headers
|
4933
|
+
headers,
|
4934
|
+
includeRawChunks: false
|
4943
4935
|
};
|
4944
4936
|
const transformer = {
|
4945
4937
|
transform: (chunk, controller) => {
|
@@ -6289,7 +6281,6 @@ var import_provider_utils21 = require("@ai-sdk/provider-utils");
|
|
6289
6281
|
function runToolsTransformation({
|
6290
6282
|
tools,
|
6291
6283
|
generatorStream,
|
6292
|
-
toolCallStreaming,
|
6293
6284
|
tracer,
|
6294
6285
|
telemetry,
|
6295
6286
|
system,
|
@@ -6330,6 +6321,10 @@ function runToolsTransformation({
|
|
6330
6321
|
controller.enqueue(chunk);
|
6331
6322
|
break;
|
6332
6323
|
}
|
6324
|
+
case "raw": {
|
6325
|
+
controller.enqueue(chunk);
|
6326
|
+
break;
|
6327
|
+
}
|
6333
6328
|
case "file": {
|
6334
6329
|
controller.enqueue({
|
6335
6330
|
type: "file",
|
@@ -6341,22 +6336,20 @@ function runToolsTransformation({
|
|
6341
6336
|
break;
|
6342
6337
|
}
|
6343
6338
|
case "tool-call-delta": {
|
6344
|
-
if (
|
6345
|
-
if (!activeToolCalls[chunk.toolCallId]) {
|
6346
|
-
controller.enqueue({
|
6347
|
-
type: "tool-call-streaming-start",
|
6348
|
-
toolCallId: chunk.toolCallId,
|
6349
|
-
toolName: chunk.toolName
|
6350
|
-
});
|
6351
|
-
activeToolCalls[chunk.toolCallId] = true;
|
6352
|
-
}
|
6339
|
+
if (!activeToolCalls[chunk.toolCallId]) {
|
6353
6340
|
controller.enqueue({
|
6354
|
-
type: "tool-call-
|
6341
|
+
type: "tool-call-streaming-start",
|
6355
6342
|
toolCallId: chunk.toolCallId,
|
6356
|
-
toolName: chunk.toolName
|
6357
|
-
argsTextDelta: chunk.argsTextDelta
|
6343
|
+
toolName: chunk.toolName
|
6358
6344
|
});
|
6345
|
+
activeToolCalls[chunk.toolCallId] = true;
|
6359
6346
|
}
|
6347
|
+
controller.enqueue({
|
6348
|
+
type: "tool-call-delta",
|
6349
|
+
toolCallId: chunk.toolCallId,
|
6350
|
+
toolName: chunk.toolName,
|
6351
|
+
argsTextDelta: chunk.argsTextDelta
|
6352
|
+
});
|
6360
6353
|
break;
|
6361
6354
|
}
|
6362
6355
|
case "tool-call": {
|
@@ -6507,12 +6500,11 @@ function streamText({
|
|
6507
6500
|
experimental_telemetry: telemetry,
|
6508
6501
|
prepareStep,
|
6509
6502
|
providerOptions,
|
6510
|
-
experimental_toolCallStreaming = false,
|
6511
|
-
toolCallStreaming = experimental_toolCallStreaming,
|
6512
6503
|
experimental_activeTools,
|
6513
6504
|
activeTools = experimental_activeTools,
|
6514
6505
|
experimental_repairToolCall: repairToolCall,
|
6515
6506
|
experimental_transform: transform,
|
6507
|
+
includeRawChunks = false,
|
6516
6508
|
onChunk,
|
6517
6509
|
onError = ({ error }) => {
|
6518
6510
|
console.error(error);
|
@@ -6538,7 +6530,6 @@ function streamText({
|
|
6538
6530
|
messages,
|
6539
6531
|
tools,
|
6540
6532
|
toolChoice,
|
6541
|
-
toolCallStreaming,
|
6542
6533
|
transforms: asArray(transform),
|
6543
6534
|
activeTools,
|
6544
6535
|
repairToolCall,
|
@@ -6546,6 +6537,7 @@ function streamText({
|
|
6546
6537
|
output,
|
6547
6538
|
providerOptions,
|
6548
6539
|
prepareStep,
|
6540
|
+
includeRawChunks,
|
6549
6541
|
onChunk,
|
6550
6542
|
onError,
|
6551
6543
|
onFinish,
|
@@ -6616,7 +6608,6 @@ var DefaultStreamTextResult = class {
|
|
6616
6608
|
messages,
|
6617
6609
|
tools,
|
6618
6610
|
toolChoice,
|
6619
|
-
toolCallStreaming,
|
6620
6611
|
transforms,
|
6621
6612
|
activeTools,
|
6622
6613
|
repairToolCall,
|
@@ -6624,6 +6615,7 @@ var DefaultStreamTextResult = class {
|
|
6624
6615
|
output,
|
6625
6616
|
providerOptions,
|
6626
6617
|
prepareStep,
|
6618
|
+
includeRawChunks,
|
6627
6619
|
now: now2,
|
6628
6620
|
currentDate,
|
6629
6621
|
generateId: generateId3,
|
@@ -6636,6 +6628,7 @@ var DefaultStreamTextResult = class {
|
|
6636
6628
|
this._finishReason = new DelayedPromise();
|
6637
6629
|
this._steps = new DelayedPromise();
|
6638
6630
|
this.output = output;
|
6631
|
+
this.includeRawChunks = includeRawChunks;
|
6639
6632
|
this.generateId = generateId3;
|
6640
6633
|
let stepFinish;
|
6641
6634
|
let activeReasoningPart = void 0;
|
@@ -6843,6 +6836,7 @@ var DefaultStreamTextResult = class {
|
|
6843
6836
|
usage
|
6844
6837
|
}) {
|
6845
6838
|
var _a17, _b, _c, _d;
|
6839
|
+
const includeRawChunks2 = self.includeRawChunks;
|
6846
6840
|
stepFinish = new DelayedPromise();
|
6847
6841
|
const initialPrompt = await standardizePrompt({
|
6848
6842
|
system,
|
@@ -6929,7 +6923,8 @@ var DefaultStreamTextResult = class {
|
|
6929
6923
|
prompt: promptMessages,
|
6930
6924
|
providerOptions,
|
6931
6925
|
abortSignal,
|
6932
|
-
headers
|
6926
|
+
headers,
|
6927
|
+
includeRawChunks: includeRawChunks2
|
6933
6928
|
})
|
6934
6929
|
};
|
6935
6930
|
}
|
@@ -6938,7 +6933,6 @@ var DefaultStreamTextResult = class {
|
|
6938
6933
|
const streamWithToolResults = runToolsTransformation({
|
6939
6934
|
tools,
|
6940
6935
|
generatorStream: stream2,
|
6941
|
-
toolCallStreaming,
|
6942
6936
|
tracer,
|
6943
6937
|
telemetry,
|
6944
6938
|
system,
|
@@ -7098,6 +7092,10 @@ var DefaultStreamTextResult = class {
|
|
7098
7092
|
stepFinishReason = "error";
|
7099
7093
|
break;
|
7100
7094
|
}
|
7095
|
+
case "raw": {
|
7096
|
+
controller.enqueue(chunk);
|
7097
|
+
break;
|
7098
|
+
}
|
7101
7099
|
default: {
|
7102
7100
|
const exhaustiveCheck = chunkType;
|
7103
7101
|
throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);
|
@@ -7467,6 +7465,9 @@ var DefaultStreamTextResult = class {
|
|
7467
7465
|
}
|
7468
7466
|
break;
|
7469
7467
|
}
|
7468
|
+
case "raw": {
|
7469
|
+
break;
|
7470
|
+
}
|
7470
7471
|
default: {
|
7471
7472
|
const exhaustiveCheck = partType;
|
7472
7473
|
throw new Error(`Unknown chunk type: ${exhaustiveCheck}`);
|