ai 7.0.100 → 7.0.102
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 +36 -0
- package/dist/index.d.ts +82 -20
- package/dist/index.js +2017 -330
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +12 -5
- package/dist/internal/index.js.map +1 -1
- package/docs/03-agents/07-workflow-agent.mdx +1 -1
- package/docs/03-ai-sdk-core/36-realtime.mdx +41 -18
- package/docs/04-ai-sdk-ui/21-transport.mdx +1 -1
- package/docs/07-reference/02-ai-sdk-ui/05-use-realtime.mdx +364 -48
- package/docs/07-reference/04-ai-sdk-workflow/02-workflow-chat-transport.mdx +4 -4
- package/docs/07-reference/05-ai-sdk-errors/index.mdx +131 -36
- package/package.json +12 -12
- package/src/generate-text/execute-tools-from-stream.ts +7 -0
- package/src/generate-text/stream-text.ts +3 -1
- package/src/prompt/create-tool-model-output.ts +16 -5
- package/src/realtime/__fixtures__/fake-live-websocket.ts +71 -0
- package/src/realtime/__fixtures__/fake-realtime.ts +36 -0
- package/src/realtime/__fixtures__/fake-webrtc.ts +133 -0
- package/src/realtime/browser-realtime-audio.ts +107 -10
- package/src/realtime/browser-realtime-live-websocket.ts +247 -0
- package/src/realtime/browser-realtime-transport.ts +235 -69
- package/src/realtime/browser-realtime-webrtc.ts +582 -0
- package/src/realtime/encode-realtime-frame.ts +33 -0
- package/src/realtime/index.ts +1 -0
- package/src/realtime/realtime-attempt.ts +45 -0
- package/src/realtime/realtime-command-tracker.ts +81 -0
- package/src/realtime/realtime-event-channel.ts +170 -0
- package/src/realtime/realtime-event-reducer.ts +3 -0
- package/src/realtime/realtime-session-state.ts +65 -0
- package/src/realtime/realtime-session.ts +768 -218
- package/src/realtime/realtime-types.ts +1 -1
- package/src/realtime/validate-realtime-setup.ts +37 -0
package/dist/internal/index.js
CHANGED
|
@@ -91,7 +91,7 @@ import {
|
|
|
91
91
|
} from "@ai-sdk/provider-utils";
|
|
92
92
|
|
|
93
93
|
// src/version.ts
|
|
94
|
-
var VERSION = true ? "7.0.
|
|
94
|
+
var VERSION = true ? "7.0.102" : "0.0.0-test";
|
|
95
95
|
|
|
96
96
|
// src/util/download/download.ts
|
|
97
97
|
var download = async ({
|
|
@@ -1061,6 +1061,9 @@ function getMediaTypeFromUrl(url, fallbackMediaType = "application/octet-stream"
|
|
|
1061
1061
|
|
|
1062
1062
|
// src/prompt/create-tool-model-output.ts
|
|
1063
1063
|
import { getErrorMessage } from "@ai-sdk/provider";
|
|
1064
|
+
import {
|
|
1065
|
+
parseJSON
|
|
1066
|
+
} from "@ai-sdk/provider-utils";
|
|
1064
1067
|
async function createToolModelOutput({
|
|
1065
1068
|
toolCallId,
|
|
1066
1069
|
input,
|
|
@@ -1071,15 +1074,19 @@ async function createToolModelOutput({
|
|
|
1071
1074
|
if (errorMode === "text") {
|
|
1072
1075
|
return { type: "error-text", value: getErrorMessage(output) };
|
|
1073
1076
|
} else if (errorMode === "json") {
|
|
1074
|
-
return { type: "error-json", value: toJSONValue(output) };
|
|
1077
|
+
return { type: "error-json", value: await toJSONValue(output) };
|
|
1075
1078
|
}
|
|
1076
1079
|
if (tool == null ? void 0 : tool.toModelOutput) {
|
|
1077
1080
|
return await tool.toModelOutput({ toolCallId, input, output });
|
|
1078
1081
|
}
|
|
1079
|
-
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: toJSONValue(output) };
|
|
1082
|
+
return typeof output === "string" ? { type: "text", value: output } : { type: "json", value: await toJSONValue(output) };
|
|
1080
1083
|
}
|
|
1081
|
-
function toJSONValue(value) {
|
|
1082
|
-
|
|
1084
|
+
async function toJSONValue(value) {
|
|
1085
|
+
if (value === void 0) {
|
|
1086
|
+
return null;
|
|
1087
|
+
}
|
|
1088
|
+
const serialized = JSON.stringify(value);
|
|
1089
|
+
return serialized === void 0 ? null : await parseJSON({ text: serialized });
|
|
1083
1090
|
}
|
|
1084
1091
|
|
|
1085
1092
|
// src/prompt/prepare-tool-choice.ts
|