ai 5.0.0-canary.11 → 5.0.0-canary.13
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 +21 -0
- package/dist/index.d.mts +38 -215
- package/dist/index.d.ts +38 -215
- package/dist/index.js +185 -494
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +175 -484
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +196 -32
- package/dist/internal/index.d.ts +196 -32
- package/dist/internal/index.js +468 -33
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +463 -33
- package/dist/internal/index.mjs.map +1 -1
- package/internal.d.ts +1 -0
- package/mcp-stdio.d.ts +1 -0
- package/package.json +7 -4
- package/test.d.ts +1 -0
package/dist/internal/index.mjs
CHANGED
@@ -275,23 +275,11 @@ function convertToCoreMessages(messages, options) {
|
|
275
275
|
break;
|
276
276
|
}
|
277
277
|
case "reasoning": {
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
text: detail.text,
|
284
|
-
signature: detail.signature
|
285
|
-
});
|
286
|
-
break;
|
287
|
-
case "redacted":
|
288
|
-
content2.push({
|
289
|
-
type: "redacted-reasoning",
|
290
|
-
data: detail.data
|
291
|
-
});
|
292
|
-
break;
|
293
|
-
}
|
294
|
-
}
|
278
|
+
content2.push({
|
279
|
+
type: "reasoning",
|
280
|
+
text: part.reasoning,
|
281
|
+
providerOptions: part.providerMetadata
|
282
|
+
});
|
295
283
|
break;
|
296
284
|
}
|
297
285
|
case "tool-invocation":
|
@@ -561,11 +549,6 @@ var reasoningPartSchema = z5.object({
|
|
561
549
|
text: z5.string(),
|
562
550
|
providerOptions: providerMetadataSchema.optional()
|
563
551
|
});
|
564
|
-
var redactedReasoningPartSchema = z5.object({
|
565
|
-
type: z5.literal("redacted-reasoning"),
|
566
|
-
data: z5.string(),
|
567
|
-
providerOptions: providerMetadataSchema.optional()
|
568
|
-
});
|
569
552
|
var toolCallPartSchema = z5.object({
|
570
553
|
type: z5.literal("tool-call"),
|
571
554
|
toolCallId: z5.string(),
|
@@ -606,7 +589,6 @@ var coreAssistantMessageSchema = z6.object({
|
|
606
589
|
textPartSchema,
|
607
590
|
filePartSchema,
|
608
591
|
reasoningPartSchema,
|
609
|
-
redactedReasoningPartSchema,
|
610
592
|
toolCallPartSchema
|
611
593
|
])
|
612
594
|
)
|
@@ -626,7 +608,7 @@ var coreMessageSchema = z6.union([
|
|
626
608
|
]);
|
627
609
|
|
628
610
|
// core/prompt/standardize-prompt.ts
|
629
|
-
function standardizePrompt({
|
611
|
+
async function standardizePrompt({
|
630
612
|
prompt,
|
631
613
|
tools
|
632
614
|
}) {
|
@@ -683,7 +665,7 @@ function standardizePrompt({
|
|
683
665
|
message: "messages must not be empty"
|
684
666
|
});
|
685
667
|
}
|
686
|
-
const validationResult = safeValidateTypes({
|
668
|
+
const validationResult = await safeValidateTypes({
|
687
669
|
value: messages,
|
688
670
|
schema: z7.array(coreMessageSchema)
|
689
671
|
});
|
@@ -706,6 +688,262 @@ function standardizePrompt({
|
|
706
688
|
// core/util/index.ts
|
707
689
|
import { generateId } from "@ai-sdk/provider-utils";
|
708
690
|
|
691
|
+
// core/util/data-stream-parts.ts
|
692
|
+
var textStreamPart = {
|
693
|
+
code: "0",
|
694
|
+
name: "text",
|
695
|
+
parse: (value) => {
|
696
|
+
if (typeof value !== "string") {
|
697
|
+
throw new Error('"text" parts expect a string value.');
|
698
|
+
}
|
699
|
+
return { type: "text", value };
|
700
|
+
}
|
701
|
+
};
|
702
|
+
var dataStreamPart = {
|
703
|
+
code: "2",
|
704
|
+
name: "data",
|
705
|
+
parse: (value) => {
|
706
|
+
if (!Array.isArray(value)) {
|
707
|
+
throw new Error('"data" parts expect an array value.');
|
708
|
+
}
|
709
|
+
return { type: "data", value };
|
710
|
+
}
|
711
|
+
};
|
712
|
+
var errorStreamPart = {
|
713
|
+
code: "3",
|
714
|
+
name: "error",
|
715
|
+
parse: (value) => {
|
716
|
+
if (typeof value !== "string") {
|
717
|
+
throw new Error('"error" parts expect a string value.');
|
718
|
+
}
|
719
|
+
return { type: "error", value };
|
720
|
+
}
|
721
|
+
};
|
722
|
+
var messageAnnotationsStreamPart = {
|
723
|
+
code: "8",
|
724
|
+
name: "message_annotations",
|
725
|
+
parse: (value) => {
|
726
|
+
if (!Array.isArray(value)) {
|
727
|
+
throw new Error('"message_annotations" parts expect an array value.');
|
728
|
+
}
|
729
|
+
return { type: "message_annotations", value };
|
730
|
+
}
|
731
|
+
};
|
732
|
+
var toolCallStreamPart = {
|
733
|
+
code: "9",
|
734
|
+
name: "tool_call",
|
735
|
+
parse: (value) => {
|
736
|
+
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string" || !("args" in value) || typeof value.args !== "object") {
|
737
|
+
throw new Error(
|
738
|
+
'"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.'
|
739
|
+
);
|
740
|
+
}
|
741
|
+
return {
|
742
|
+
type: "tool_call",
|
743
|
+
value
|
744
|
+
};
|
745
|
+
}
|
746
|
+
};
|
747
|
+
var toolResultStreamPart = {
|
748
|
+
code: "a",
|
749
|
+
name: "tool_result",
|
750
|
+
parse: (value) => {
|
751
|
+
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("result" in value)) {
|
752
|
+
throw new Error(
|
753
|
+
'"tool_result" parts expect an object with a "toolCallId" and a "result" property.'
|
754
|
+
);
|
755
|
+
}
|
756
|
+
return {
|
757
|
+
type: "tool_result",
|
758
|
+
value
|
759
|
+
};
|
760
|
+
}
|
761
|
+
};
|
762
|
+
var toolCallStreamingStartStreamPart = {
|
763
|
+
code: "b",
|
764
|
+
name: "tool_call_streaming_start",
|
765
|
+
parse: (value) => {
|
766
|
+
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("toolName" in value) || typeof value.toolName !== "string") {
|
767
|
+
throw new Error(
|
768
|
+
'"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.'
|
769
|
+
);
|
770
|
+
}
|
771
|
+
return {
|
772
|
+
type: "tool_call_streaming_start",
|
773
|
+
value
|
774
|
+
};
|
775
|
+
}
|
776
|
+
};
|
777
|
+
var toolCallDeltaStreamPart = {
|
778
|
+
code: "c",
|
779
|
+
name: "tool_call_delta",
|
780
|
+
parse: (value) => {
|
781
|
+
if (value == null || typeof value !== "object" || !("toolCallId" in value) || typeof value.toolCallId !== "string" || !("argsTextDelta" in value) || typeof value.argsTextDelta !== "string") {
|
782
|
+
throw new Error(
|
783
|
+
'"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.'
|
784
|
+
);
|
785
|
+
}
|
786
|
+
return {
|
787
|
+
type: "tool_call_delta",
|
788
|
+
value
|
789
|
+
};
|
790
|
+
}
|
791
|
+
};
|
792
|
+
var finishMessageStreamPart = {
|
793
|
+
code: "d",
|
794
|
+
name: "finish_message",
|
795
|
+
parse: (value) => {
|
796
|
+
if (value == null || typeof value !== "object" || !("finishReason" in value) || typeof value.finishReason !== "string") {
|
797
|
+
throw new Error(
|
798
|
+
'"finish_message" parts expect an object with a "finishReason" property.'
|
799
|
+
);
|
800
|
+
}
|
801
|
+
const result = {
|
802
|
+
finishReason: value.finishReason
|
803
|
+
};
|
804
|
+
if ("usage" in value && value.usage != null && typeof value.usage === "object" && "promptTokens" in value.usage && "completionTokens" in value.usage) {
|
805
|
+
result.usage = {
|
806
|
+
promptTokens: typeof value.usage.promptTokens === "number" ? value.usage.promptTokens : Number.NaN,
|
807
|
+
completionTokens: typeof value.usage.completionTokens === "number" ? value.usage.completionTokens : Number.NaN
|
808
|
+
};
|
809
|
+
}
|
810
|
+
return {
|
811
|
+
type: "finish_message",
|
812
|
+
value: result
|
813
|
+
};
|
814
|
+
}
|
815
|
+
};
|
816
|
+
var finishStepStreamPart = {
|
817
|
+
code: "e",
|
818
|
+
name: "finish_step",
|
819
|
+
parse: (value) => {
|
820
|
+
if (value == null || typeof value !== "object" || !("finishReason" in value) || typeof value.finishReason !== "string") {
|
821
|
+
throw new Error(
|
822
|
+
'"finish_step" parts expect an object with a "finishReason" property.'
|
823
|
+
);
|
824
|
+
}
|
825
|
+
const result = {
|
826
|
+
finishReason: value.finishReason,
|
827
|
+
isContinued: false
|
828
|
+
};
|
829
|
+
if ("usage" in value && value.usage != null && typeof value.usage === "object" && "promptTokens" in value.usage && "completionTokens" in value.usage) {
|
830
|
+
result.usage = {
|
831
|
+
promptTokens: typeof value.usage.promptTokens === "number" ? value.usage.promptTokens : Number.NaN,
|
832
|
+
completionTokens: typeof value.usage.completionTokens === "number" ? value.usage.completionTokens : Number.NaN
|
833
|
+
};
|
834
|
+
}
|
835
|
+
if ("isContinued" in value && typeof value.isContinued === "boolean") {
|
836
|
+
result.isContinued = value.isContinued;
|
837
|
+
}
|
838
|
+
return {
|
839
|
+
type: "finish_step",
|
840
|
+
value: result
|
841
|
+
};
|
842
|
+
}
|
843
|
+
};
|
844
|
+
var startStepStreamPart = {
|
845
|
+
code: "f",
|
846
|
+
name: "start_step",
|
847
|
+
parse: (value) => {
|
848
|
+
if (value == null || typeof value !== "object" || !("messageId" in value) || typeof value.messageId !== "string") {
|
849
|
+
throw new Error(
|
850
|
+
'"start_step" parts expect an object with an "id" property.'
|
851
|
+
);
|
852
|
+
}
|
853
|
+
return {
|
854
|
+
type: "start_step",
|
855
|
+
value: {
|
856
|
+
messageId: value.messageId
|
857
|
+
}
|
858
|
+
};
|
859
|
+
}
|
860
|
+
};
|
861
|
+
var reasoningStreamPart = {
|
862
|
+
code: "g",
|
863
|
+
name: "reasoning",
|
864
|
+
parse: (value) => {
|
865
|
+
if (value == null || typeof value !== "object" || !("text" in value) || typeof value.text !== "string" || "providerMetadata" in value && typeof value.providerMetadata !== "object") {
|
866
|
+
throw new Error(
|
867
|
+
'"reasoning" parts expect an object with a "text" property.'
|
868
|
+
);
|
869
|
+
}
|
870
|
+
return {
|
871
|
+
type: "reasoning",
|
872
|
+
value: {
|
873
|
+
text: value.text,
|
874
|
+
providerMetadata: value.providerMetadata
|
875
|
+
}
|
876
|
+
};
|
877
|
+
}
|
878
|
+
};
|
879
|
+
var sourcePart = {
|
880
|
+
code: "h",
|
881
|
+
name: "source",
|
882
|
+
parse: (value) => {
|
883
|
+
if (value == null || typeof value !== "object") {
|
884
|
+
throw new Error('"source" parts expect a Source object.');
|
885
|
+
}
|
886
|
+
return {
|
887
|
+
type: "source",
|
888
|
+
value
|
889
|
+
};
|
890
|
+
}
|
891
|
+
};
|
892
|
+
var fileStreamPart = {
|
893
|
+
code: "k",
|
894
|
+
name: "file",
|
895
|
+
parse: (value) => {
|
896
|
+
if (value == null || typeof value !== "object" || !("data" in value) || typeof value.data !== "string" || !("mimeType" in value) || typeof value.mimeType !== "string") {
|
897
|
+
throw new Error(
|
898
|
+
'"file" parts expect an object with a "data" and "mimeType" property.'
|
899
|
+
);
|
900
|
+
}
|
901
|
+
return { type: "file", value };
|
902
|
+
}
|
903
|
+
};
|
904
|
+
var reasoningPartFinishStreamPart = {
|
905
|
+
code: "l",
|
906
|
+
name: "reasoning_part_finish",
|
907
|
+
parse: () => {
|
908
|
+
return {
|
909
|
+
type: "reasoning_part_finish",
|
910
|
+
value: {}
|
911
|
+
};
|
912
|
+
}
|
913
|
+
};
|
914
|
+
var dataStreamParts = [
|
915
|
+
textStreamPart,
|
916
|
+
dataStreamPart,
|
917
|
+
errorStreamPart,
|
918
|
+
messageAnnotationsStreamPart,
|
919
|
+
toolCallStreamPart,
|
920
|
+
toolResultStreamPart,
|
921
|
+
toolCallStreamingStartStreamPart,
|
922
|
+
toolCallDeltaStreamPart,
|
923
|
+
finishMessageStreamPart,
|
924
|
+
finishStepStreamPart,
|
925
|
+
startStepStreamPart,
|
926
|
+
reasoningStreamPart,
|
927
|
+
sourcePart,
|
928
|
+
reasoningPartFinishStreamPart,
|
929
|
+
fileStreamPart
|
930
|
+
];
|
931
|
+
var dataStreamPartsByCode = Object.fromEntries(
|
932
|
+
dataStreamParts.map((part) => [part.code, part])
|
933
|
+
);
|
934
|
+
var DataStreamStringPrefixes = Object.fromEntries(
|
935
|
+
dataStreamParts.map((part) => [part.name, part.code])
|
936
|
+
);
|
937
|
+
var validCodes = dataStreamParts.map((part) => part.code);
|
938
|
+
function formatDataStreamPart(type, value) {
|
939
|
+
const streamPart = dataStreamParts.find((part) => part.name === type);
|
940
|
+
if (!streamPart) {
|
941
|
+
throw new Error(`Invalid stream part type: ${type}`);
|
942
|
+
}
|
943
|
+
return `${streamPart.code}:${JSON.stringify(value)}
|
944
|
+
`;
|
945
|
+
}
|
946
|
+
|
709
947
|
// core/util/schema.ts
|
710
948
|
import { validatorSymbol } from "@ai-sdk/provider-utils";
|
711
949
|
|
@@ -1278,14 +1516,6 @@ function convertToLanguageModelMessage(message, downloadedAssets) {
|
|
1278
1516
|
return {
|
1279
1517
|
type: "reasoning",
|
1280
1518
|
text: part.text,
|
1281
|
-
signature: part.signature,
|
1282
|
-
providerOptions
|
1283
|
-
};
|
1284
|
-
}
|
1285
|
-
case "redacted-reasoning": {
|
1286
|
-
return {
|
1287
|
-
type: "redacted-reasoning",
|
1288
|
-
data: part.data,
|
1289
1519
|
providerOptions
|
1290
1520
|
};
|
1291
1521
|
}
|
@@ -1436,13 +1666,213 @@ function calculateLanguageModelUsage({
|
|
1436
1666
|
};
|
1437
1667
|
}
|
1438
1668
|
|
1669
|
+
// core/util/prepare-response-headers.ts
|
1670
|
+
function prepareResponseHeaders(headers, {
|
1671
|
+
contentType,
|
1672
|
+
dataStreamVersion
|
1673
|
+
}) {
|
1674
|
+
const responseHeaders = new Headers(headers != null ? headers : {});
|
1675
|
+
if (!responseHeaders.has("Content-Type")) {
|
1676
|
+
responseHeaders.set("Content-Type", contentType);
|
1677
|
+
}
|
1678
|
+
if (dataStreamVersion !== void 0) {
|
1679
|
+
responseHeaders.set("X-Vercel-AI-Data-Stream", dataStreamVersion);
|
1680
|
+
}
|
1681
|
+
return responseHeaders;
|
1682
|
+
}
|
1683
|
+
|
1684
|
+
// core/util/merge-streams.ts
|
1685
|
+
function mergeStreams(stream1, stream2) {
|
1686
|
+
const reader1 = stream1.getReader();
|
1687
|
+
const reader2 = stream2.getReader();
|
1688
|
+
let lastRead1 = void 0;
|
1689
|
+
let lastRead2 = void 0;
|
1690
|
+
let stream1Done = false;
|
1691
|
+
let stream2Done = false;
|
1692
|
+
async function readStream1(controller) {
|
1693
|
+
try {
|
1694
|
+
if (lastRead1 == null) {
|
1695
|
+
lastRead1 = reader1.read();
|
1696
|
+
}
|
1697
|
+
const result = await lastRead1;
|
1698
|
+
lastRead1 = void 0;
|
1699
|
+
if (!result.done) {
|
1700
|
+
controller.enqueue(result.value);
|
1701
|
+
} else {
|
1702
|
+
controller.close();
|
1703
|
+
}
|
1704
|
+
} catch (error) {
|
1705
|
+
controller.error(error);
|
1706
|
+
}
|
1707
|
+
}
|
1708
|
+
async function readStream2(controller) {
|
1709
|
+
try {
|
1710
|
+
if (lastRead2 == null) {
|
1711
|
+
lastRead2 = reader2.read();
|
1712
|
+
}
|
1713
|
+
const result = await lastRead2;
|
1714
|
+
lastRead2 = void 0;
|
1715
|
+
if (!result.done) {
|
1716
|
+
controller.enqueue(result.value);
|
1717
|
+
} else {
|
1718
|
+
controller.close();
|
1719
|
+
}
|
1720
|
+
} catch (error) {
|
1721
|
+
controller.error(error);
|
1722
|
+
}
|
1723
|
+
}
|
1724
|
+
return new ReadableStream({
|
1725
|
+
async pull(controller) {
|
1726
|
+
try {
|
1727
|
+
if (stream1Done) {
|
1728
|
+
await readStream2(controller);
|
1729
|
+
return;
|
1730
|
+
}
|
1731
|
+
if (stream2Done) {
|
1732
|
+
await readStream1(controller);
|
1733
|
+
return;
|
1734
|
+
}
|
1735
|
+
if (lastRead1 == null) {
|
1736
|
+
lastRead1 = reader1.read();
|
1737
|
+
}
|
1738
|
+
if (lastRead2 == null) {
|
1739
|
+
lastRead2 = reader2.read();
|
1740
|
+
}
|
1741
|
+
const { result, reader } = await Promise.race([
|
1742
|
+
lastRead1.then((result2) => ({ result: result2, reader: reader1 })),
|
1743
|
+
lastRead2.then((result2) => ({ result: result2, reader: reader2 }))
|
1744
|
+
]);
|
1745
|
+
if (!result.done) {
|
1746
|
+
controller.enqueue(result.value);
|
1747
|
+
}
|
1748
|
+
if (reader === reader1) {
|
1749
|
+
lastRead1 = void 0;
|
1750
|
+
if (result.done) {
|
1751
|
+
await readStream2(controller);
|
1752
|
+
stream1Done = true;
|
1753
|
+
}
|
1754
|
+
} else {
|
1755
|
+
lastRead2 = void 0;
|
1756
|
+
if (result.done) {
|
1757
|
+
stream2Done = true;
|
1758
|
+
await readStream1(controller);
|
1759
|
+
}
|
1760
|
+
}
|
1761
|
+
} catch (error) {
|
1762
|
+
controller.error(error);
|
1763
|
+
}
|
1764
|
+
},
|
1765
|
+
cancel() {
|
1766
|
+
reader1.cancel();
|
1767
|
+
reader2.cancel();
|
1768
|
+
}
|
1769
|
+
});
|
1770
|
+
}
|
1771
|
+
|
1772
|
+
// streams/stream-callbacks.ts
|
1773
|
+
function createCallbacksTransformer(callbacks = {}) {
|
1774
|
+
const textEncoder = new TextEncoder();
|
1775
|
+
let aggregatedResponse = "";
|
1776
|
+
return new TransformStream({
|
1777
|
+
async start() {
|
1778
|
+
if (callbacks.onStart)
|
1779
|
+
await callbacks.onStart();
|
1780
|
+
},
|
1781
|
+
async transform(message, controller) {
|
1782
|
+
controller.enqueue(textEncoder.encode(message));
|
1783
|
+
aggregatedResponse += message;
|
1784
|
+
if (callbacks.onToken)
|
1785
|
+
await callbacks.onToken(message);
|
1786
|
+
if (callbacks.onText && typeof message === "string") {
|
1787
|
+
await callbacks.onText(message);
|
1788
|
+
}
|
1789
|
+
},
|
1790
|
+
async flush() {
|
1791
|
+
if (callbacks.onCompletion) {
|
1792
|
+
await callbacks.onCompletion(aggregatedResponse);
|
1793
|
+
}
|
1794
|
+
if (callbacks.onFinal) {
|
1795
|
+
await callbacks.onFinal(aggregatedResponse);
|
1796
|
+
}
|
1797
|
+
}
|
1798
|
+
});
|
1799
|
+
}
|
1800
|
+
|
1439
1801
|
// util/constants.ts
|
1440
1802
|
var HANGING_STREAM_WARNING_TIME_MS = 15 * 1e3;
|
1803
|
+
|
1804
|
+
// streams/stream-data.ts
|
1805
|
+
var StreamData = class {
|
1806
|
+
constructor() {
|
1807
|
+
this.encoder = new TextEncoder();
|
1808
|
+
this.controller = null;
|
1809
|
+
this.isClosed = false;
|
1810
|
+
this.warningTimeout = null;
|
1811
|
+
const self = this;
|
1812
|
+
this.stream = new ReadableStream({
|
1813
|
+
start: async (controller) => {
|
1814
|
+
self.controller = controller;
|
1815
|
+
if (process.env.NODE_ENV === "development") {
|
1816
|
+
self.warningTimeout = setTimeout(() => {
|
1817
|
+
console.warn(
|
1818
|
+
"The data stream is hanging. Did you forget to close it with `data.close()`?"
|
1819
|
+
);
|
1820
|
+
}, HANGING_STREAM_WARNING_TIME_MS);
|
1821
|
+
}
|
1822
|
+
},
|
1823
|
+
pull: (controller) => {
|
1824
|
+
},
|
1825
|
+
cancel: (reason) => {
|
1826
|
+
this.isClosed = true;
|
1827
|
+
}
|
1828
|
+
});
|
1829
|
+
}
|
1830
|
+
async close() {
|
1831
|
+
if (this.isClosed) {
|
1832
|
+
throw new Error("Data Stream has already been closed.");
|
1833
|
+
}
|
1834
|
+
if (!this.controller) {
|
1835
|
+
throw new Error("Stream controller is not initialized.");
|
1836
|
+
}
|
1837
|
+
this.controller.close();
|
1838
|
+
this.isClosed = true;
|
1839
|
+
if (this.warningTimeout) {
|
1840
|
+
clearTimeout(this.warningTimeout);
|
1841
|
+
}
|
1842
|
+
}
|
1843
|
+
append(value) {
|
1844
|
+
if (this.isClosed) {
|
1845
|
+
throw new Error("Data Stream has already been closed.");
|
1846
|
+
}
|
1847
|
+
if (!this.controller) {
|
1848
|
+
throw new Error("Stream controller is not initialized.");
|
1849
|
+
}
|
1850
|
+
this.controller.enqueue(
|
1851
|
+
this.encoder.encode(formatDataStreamPart("data", [value]))
|
1852
|
+
);
|
1853
|
+
}
|
1854
|
+
appendMessageAnnotation(value) {
|
1855
|
+
if (this.isClosed) {
|
1856
|
+
throw new Error("Data Stream has already been closed.");
|
1857
|
+
}
|
1858
|
+
if (!this.controller) {
|
1859
|
+
throw new Error("Stream controller is not initialized.");
|
1860
|
+
}
|
1861
|
+
this.controller.enqueue(
|
1862
|
+
this.encoder.encode(formatDataStreamPart("message_annotations", [value]))
|
1863
|
+
);
|
1864
|
+
}
|
1865
|
+
};
|
1441
1866
|
export {
|
1442
1867
|
HANGING_STREAM_WARNING_TIME_MS,
|
1868
|
+
StreamData,
|
1443
1869
|
calculateLanguageModelUsage,
|
1444
1870
|
convertToLanguageModelPrompt,
|
1871
|
+
createCallbacksTransformer,
|
1872
|
+
formatDataStreamPart,
|
1873
|
+
mergeStreams,
|
1445
1874
|
prepareCallSettings,
|
1875
|
+
prepareResponseHeaders,
|
1446
1876
|
prepareRetries,
|
1447
1877
|
prepareToolsAndToolChoice,
|
1448
1878
|
standardizePrompt
|