ai 7.0.73 → 7.0.76
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 +23 -0
- package/dist/index.d.ts +115 -3
- package/dist/index.js +265 -77
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +1 -1
- package/docs/03-ai-sdk-core/60-telemetry.mdx +6 -4
- package/package.json +2 -2
- package/src/generate-text/stream-text.ts +78 -6
- package/src/generate-video/generate-video.ts +95 -53
- package/src/generate-video/get-video-status.ts +66 -0
- package/src/generate-video/index.ts +4 -0
- package/src/generate-video/start-video.ts +214 -0
- package/src/ui/chat.ts +2 -2
- package/src/ui/process-ui-message-stream.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
createIdGenerator as createIdGenerator9,
|
|
12
12
|
dynamicTool,
|
|
13
13
|
experimental_toolCaller,
|
|
14
|
-
generateId as
|
|
14
|
+
generateId as generateId3,
|
|
15
15
|
jsonSchema,
|
|
16
16
|
parseJsonEventStream as parseJsonEventStream3,
|
|
17
17
|
tool,
|
|
@@ -1143,7 +1143,7 @@ import {
|
|
|
1143
1143
|
} from "@ai-sdk/provider-utils";
|
|
1144
1144
|
|
|
1145
1145
|
// src/version.ts
|
|
1146
|
-
var VERSION = true ? "7.0.
|
|
1146
|
+
var VERSION = true ? "7.0.76" : "0.0.0-test";
|
|
1147
1147
|
|
|
1148
1148
|
// src/util/download/download.ts
|
|
1149
1149
|
var download = async ({
|
|
@@ -5270,7 +5270,7 @@ async function generateText({
|
|
|
5270
5270
|
experimental_include,
|
|
5271
5271
|
include = experimental_include,
|
|
5272
5272
|
_internal: {
|
|
5273
|
-
generateId:
|
|
5273
|
+
generateId: generateId4 = originalGenerateId,
|
|
5274
5274
|
generateCallId = originalGenerateCallId,
|
|
5275
5275
|
now: now2 = now
|
|
5276
5276
|
} = {},
|
|
@@ -5655,7 +5655,7 @@ async function generateText({
|
|
|
5655
5655
|
}
|
|
5656
5656
|
);
|
|
5657
5657
|
const responseData = {
|
|
5658
|
-
id: (_b3 = (_a26 = result.response) == null ? void 0 : _a26.id) != null ? _b3 :
|
|
5658
|
+
id: (_b3 = (_a26 = result.response) == null ? void 0 : _a26.id) != null ? _b3 : generateId4(),
|
|
5659
5659
|
timestamp: (_d3 = (_c3 = result.response) == null ? void 0 : _c3.timestamp) != null ? _d3 : /* @__PURE__ */ new Date(),
|
|
5660
5660
|
modelId: (_f2 = (_e2 = result.response) == null ? void 0 : _e2.modelId) != null ? _f2 : stepModel.modelId,
|
|
5661
5661
|
headers: (_g2 = result.response) == null ? void 0 : _g2.headers,
|
|
@@ -5763,7 +5763,7 @@ async function generateText({
|
|
|
5763
5763
|
if (toolApprovalStatus.type === "not-applicable") {
|
|
5764
5764
|
continue;
|
|
5765
5765
|
}
|
|
5766
|
-
const approvalId =
|
|
5766
|
+
const approvalId = generateId4();
|
|
5767
5767
|
const signature = await maybeSignApproval({
|
|
5768
5768
|
secret: experimental_toolApprovalSecret,
|
|
5769
5769
|
approvalId,
|
|
@@ -8096,7 +8096,7 @@ function executeToolsFromStream({
|
|
|
8096
8096
|
toolApproval,
|
|
8097
8097
|
runtimeContext,
|
|
8098
8098
|
toolApprovalSecret,
|
|
8099
|
-
generateId:
|
|
8099
|
+
generateId: generateId4,
|
|
8100
8100
|
onToolExecutionStart,
|
|
8101
8101
|
onToolExecutionEnd,
|
|
8102
8102
|
executeToolInTelemetryContext,
|
|
@@ -8131,7 +8131,7 @@ function executeToolsFromStream({
|
|
|
8131
8131
|
}
|
|
8132
8132
|
return;
|
|
8133
8133
|
}
|
|
8134
|
-
const approvalId =
|
|
8134
|
+
const approvalId = generateId4();
|
|
8135
8135
|
const signature = await maybeSignApproval({
|
|
8136
8136
|
secret: toolApprovalSecret,
|
|
8137
8137
|
approvalId,
|
|
@@ -8340,7 +8340,7 @@ async function streamLanguageModelCall({
|
|
|
8340
8340
|
toolsContext,
|
|
8341
8341
|
experimental_sandbox: sandbox,
|
|
8342
8342
|
_internal: {
|
|
8343
|
-
generateId:
|
|
8343
|
+
generateId: generateId4 = originalGenerateId2,
|
|
8344
8344
|
generateCallId = originalGenerateCallId2,
|
|
8345
8345
|
now: now2 = now
|
|
8346
8346
|
} = {},
|
|
@@ -8425,7 +8425,7 @@ async function streamLanguageModelCall({
|
|
|
8425
8425
|
callId: effectiveCallId,
|
|
8426
8426
|
provider: resolvedModel.provider,
|
|
8427
8427
|
modelId: resolvedModel.modelId,
|
|
8428
|
-
generateId:
|
|
8428
|
+
generateId: generateId4,
|
|
8429
8429
|
now: now2,
|
|
8430
8430
|
callStartTimestampMs,
|
|
8431
8431
|
onLanguageModelCallEnd
|
|
@@ -8446,7 +8446,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
|
|
|
8446
8446
|
callId,
|
|
8447
8447
|
provider,
|
|
8448
8448
|
modelId,
|
|
8449
|
-
generateId:
|
|
8449
|
+
generateId: generateId4,
|
|
8450
8450
|
now: now2,
|
|
8451
8451
|
callStartTimestampMs,
|
|
8452
8452
|
onLanguageModelCallEnd
|
|
@@ -8455,7 +8455,7 @@ function createLanguageModelV4StreamPartToLanguageModelStreamPartTransform({
|
|
|
8455
8455
|
const modelCallContent = [];
|
|
8456
8456
|
const textPartIndexes = /* @__PURE__ */ new Map();
|
|
8457
8457
|
const reasoningPartIndexes = /* @__PURE__ */ new Map();
|
|
8458
|
-
let responseId =
|
|
8458
|
+
let responseId = generateId4();
|
|
8459
8459
|
let responseModelId = modelId;
|
|
8460
8460
|
let timeToFirstOutputMs;
|
|
8461
8461
|
let previousOutputChunkTimestampMs;
|
|
@@ -8890,7 +8890,7 @@ function streamText({
|
|
|
8890
8890
|
include = experimental_include,
|
|
8891
8891
|
_internal: {
|
|
8892
8892
|
now: now2 = now,
|
|
8893
|
-
generateId:
|
|
8893
|
+
generateId: generateId4 = originalGenerateId3,
|
|
8894
8894
|
generateCallId = originalGenerateCallId3
|
|
8895
8895
|
} = {},
|
|
8896
8896
|
...settings
|
|
@@ -8964,7 +8964,7 @@ function streamText({
|
|
|
8964
8964
|
onToolExecutionStart: resolvedOnToolExecutionStart,
|
|
8965
8965
|
onToolExecutionEnd: resolvedOnToolExecutionEnd,
|
|
8966
8966
|
now: now2,
|
|
8967
|
-
generateId:
|
|
8967
|
+
generateId: generateId4,
|
|
8968
8968
|
generateCallId,
|
|
8969
8969
|
download: download2,
|
|
8970
8970
|
// assign default values to include:
|
|
@@ -9082,7 +9082,7 @@ var DefaultStreamTextResult = class {
|
|
|
9082
9082
|
providerOptions,
|
|
9083
9083
|
prepareStep,
|
|
9084
9084
|
now: now2,
|
|
9085
|
-
generateId:
|
|
9085
|
+
generateId: generateId4,
|
|
9086
9086
|
generateCallId,
|
|
9087
9087
|
timeout,
|
|
9088
9088
|
onChunk,
|
|
@@ -9129,6 +9129,25 @@ var DefaultStreamTextResult = class {
|
|
|
9129
9129
|
const initialResponseMessages = [];
|
|
9130
9130
|
let stepMessagesForNextStep;
|
|
9131
9131
|
let currentStepMessages = [];
|
|
9132
|
+
const createPartIdReserver = () => {
|
|
9133
|
+
const usedIds = /* @__PURE__ */ new Set();
|
|
9134
|
+
return (id) => {
|
|
9135
|
+
if (!usedIds.has(id)) {
|
|
9136
|
+
usedIds.add(id);
|
|
9137
|
+
return id;
|
|
9138
|
+
}
|
|
9139
|
+
const generatedId = generateId4();
|
|
9140
|
+
let uniqueId = generatedId;
|
|
9141
|
+
let suffix = 0;
|
|
9142
|
+
while (usedIds.has(uniqueId)) {
|
|
9143
|
+
uniqueId = `${generatedId}-${++suffix}`;
|
|
9144
|
+
}
|
|
9145
|
+
usedIds.add(uniqueId);
|
|
9146
|
+
return uniqueId;
|
|
9147
|
+
};
|
|
9148
|
+
};
|
|
9149
|
+
const reserveTextPartId = createPartIdReserver();
|
|
9150
|
+
const reserveReasoningPartId = createPartIdReserver();
|
|
9132
9151
|
const pendingDeferredToolCalls = /* @__PURE__ */ new Map();
|
|
9133
9152
|
let activeTextContent = createIdMap();
|
|
9134
9153
|
let activeReasoningContent = createIdMap();
|
|
@@ -9856,7 +9875,7 @@ var DefaultStreamTextResult = class {
|
|
|
9856
9875
|
toolApproval,
|
|
9857
9876
|
runtimeContext,
|
|
9858
9877
|
toolApprovalSecret: experimental_toolApprovalSecret,
|
|
9859
|
-
generateId:
|
|
9878
|
+
generateId: generateId4,
|
|
9860
9879
|
// the callbacks need to be passed down and handled by executeToolCall
|
|
9861
9880
|
// to guarantee that the onToolExecutionStart callback is invoked before the tool execute function
|
|
9862
9881
|
onToolExecutionStart: filterNullable2(
|
|
@@ -9898,15 +9917,17 @@ var DefaultStreamTextResult = class {
|
|
|
9898
9917
|
};
|
|
9899
9918
|
const toolExecutionMs = {};
|
|
9900
9919
|
let stepResponse = {
|
|
9901
|
-
id:
|
|
9920
|
+
id: generateId4(),
|
|
9902
9921
|
timestamp: /* @__PURE__ */ new Date(),
|
|
9903
9922
|
modelId: model.modelId
|
|
9904
9923
|
};
|
|
9924
|
+
const textPartIds = /* @__PURE__ */ new Map();
|
|
9925
|
+
const reasoningPartIds = /* @__PURE__ */ new Map();
|
|
9905
9926
|
self.addStream(
|
|
9906
9927
|
streamWithToolResults.pipeThrough(
|
|
9907
9928
|
new TransformStream({
|
|
9908
9929
|
async transform(chunk, controller) {
|
|
9909
|
-
var _a25, _b2, _c2;
|
|
9930
|
+
var _a25, _b2, _c2, _d2, _e2, _f2, _g2;
|
|
9910
9931
|
if (chunk.type === "model-call-start") {
|
|
9911
9932
|
warnings = chunk.warnings;
|
|
9912
9933
|
return;
|
|
@@ -9931,11 +9952,6 @@ var DefaultStreamTextResult = class {
|
|
|
9931
9952
|
case "file":
|
|
9932
9953
|
case "custom":
|
|
9933
9954
|
case "source":
|
|
9934
|
-
case "text-start":
|
|
9935
|
-
case "text-end":
|
|
9936
|
-
case "reasoning-start":
|
|
9937
|
-
case "reasoning-end":
|
|
9938
|
-
case "reasoning-delta":
|
|
9939
9955
|
case "reasoning-file":
|
|
9940
9956
|
case "tool-input-start":
|
|
9941
9957
|
case "tool-input-end":
|
|
@@ -9944,12 +9960,50 @@ var DefaultStreamTextResult = class {
|
|
|
9944
9960
|
controller.enqueue(chunk);
|
|
9945
9961
|
break;
|
|
9946
9962
|
}
|
|
9963
|
+
case "text-start": {
|
|
9964
|
+
const id = reserveTextPartId(chunk.id);
|
|
9965
|
+
textPartIds.set(chunk.id, id);
|
|
9966
|
+
controller.enqueue({ ...chunk, id });
|
|
9967
|
+
break;
|
|
9968
|
+
}
|
|
9947
9969
|
case "text-delta": {
|
|
9948
9970
|
if (chunk.text.length > 0 || chunk.providerMetadata != null) {
|
|
9949
|
-
controller.enqueue(
|
|
9971
|
+
controller.enqueue({
|
|
9972
|
+
...chunk,
|
|
9973
|
+
id: (_a25 = textPartIds.get(chunk.id)) != null ? _a25 : chunk.id
|
|
9974
|
+
});
|
|
9950
9975
|
}
|
|
9951
9976
|
break;
|
|
9952
9977
|
}
|
|
9978
|
+
case "text-end": {
|
|
9979
|
+
controller.enqueue({
|
|
9980
|
+
...chunk,
|
|
9981
|
+
id: (_b2 = textPartIds.get(chunk.id)) != null ? _b2 : chunk.id
|
|
9982
|
+
});
|
|
9983
|
+
textPartIds.delete(chunk.id);
|
|
9984
|
+
break;
|
|
9985
|
+
}
|
|
9986
|
+
case "reasoning-start": {
|
|
9987
|
+
const id = reserveReasoningPartId(chunk.id);
|
|
9988
|
+
reasoningPartIds.set(chunk.id, id);
|
|
9989
|
+
controller.enqueue({ ...chunk, id });
|
|
9990
|
+
break;
|
|
9991
|
+
}
|
|
9992
|
+
case "reasoning-delta": {
|
|
9993
|
+
controller.enqueue({
|
|
9994
|
+
...chunk,
|
|
9995
|
+
id: (_c2 = reasoningPartIds.get(chunk.id)) != null ? _c2 : chunk.id
|
|
9996
|
+
});
|
|
9997
|
+
break;
|
|
9998
|
+
}
|
|
9999
|
+
case "reasoning-end": {
|
|
10000
|
+
controller.enqueue({
|
|
10001
|
+
...chunk,
|
|
10002
|
+
id: (_d2 = reasoningPartIds.get(chunk.id)) != null ? _d2 : chunk.id
|
|
10003
|
+
});
|
|
10004
|
+
reasoningPartIds.delete(chunk.id);
|
|
10005
|
+
break;
|
|
10006
|
+
}
|
|
9953
10007
|
case "tool-call": {
|
|
9954
10008
|
controller.enqueue(chunk);
|
|
9955
10009
|
stepToolCalls.push(chunk);
|
|
@@ -9978,9 +10032,9 @@ var DefaultStreamTextResult = class {
|
|
|
9978
10032
|
}
|
|
9979
10033
|
case "model-call-response-metadata": {
|
|
9980
10034
|
stepResponse = {
|
|
9981
|
-
id: (
|
|
9982
|
-
timestamp: (
|
|
9983
|
-
modelId: (
|
|
10035
|
+
id: (_e2 = chunk.id) != null ? _e2 : stepResponse.id,
|
|
10036
|
+
timestamp: (_f2 = chunk.timestamp) != null ? _f2 : stepResponse.timestamp,
|
|
10037
|
+
modelId: (_g2 = chunk.modelId) != null ? _g2 : stepResponse.modelId
|
|
9984
10038
|
};
|
|
9985
10039
|
break;
|
|
9986
10040
|
}
|
|
@@ -10661,7 +10715,7 @@ function createUIMessageStream({
|
|
|
10661
10715
|
onStepFinish,
|
|
10662
10716
|
onEnd,
|
|
10663
10717
|
onFinish,
|
|
10664
|
-
generateId:
|
|
10718
|
+
generateId: generateId4 = generateIdFunc
|
|
10665
10719
|
}) {
|
|
10666
10720
|
let controller;
|
|
10667
10721
|
const ongoingStreamPromises = [];
|
|
@@ -10733,7 +10787,7 @@ function createUIMessageStream({
|
|
|
10733
10787
|
});
|
|
10734
10788
|
return handleUIMessageStreamFinish({
|
|
10735
10789
|
stream,
|
|
10736
|
-
messageId:
|
|
10790
|
+
messageId: generateId4(),
|
|
10737
10791
|
originalMessages,
|
|
10738
10792
|
onStepEnd: onStepEnd != null ? onStepEnd : onStepFinish,
|
|
10739
10793
|
onEnd: onEnd != null ? onEnd : onFinish,
|
|
@@ -13037,7 +13091,7 @@ async function generateObject(options) {
|
|
|
13037
13091
|
onStepFinish,
|
|
13038
13092
|
onFinish,
|
|
13039
13093
|
_internal: {
|
|
13040
|
-
generateId:
|
|
13094
|
+
generateId: generateId4 = originalGenerateId4,
|
|
13041
13095
|
currentDate = () => /* @__PURE__ */ new Date()
|
|
13042
13096
|
} = {},
|
|
13043
13097
|
...settings
|
|
@@ -13077,7 +13131,7 @@ async function generateObject(options) {
|
|
|
13077
13131
|
const resolvedOnStepStart = onStepStart != null ? onStepStart : experimental_onStepStart;
|
|
13078
13132
|
const resolvedOnStepEnd = onStepEnd != null ? onStepEnd : onStepFinish;
|
|
13079
13133
|
const jsonSchema2 = await outputStrategy.jsonSchema();
|
|
13080
|
-
const callId =
|
|
13134
|
+
const callId = generateId4();
|
|
13081
13135
|
await notify({
|
|
13082
13136
|
event: {
|
|
13083
13137
|
callId,
|
|
@@ -13146,7 +13200,7 @@ async function generateObject(options) {
|
|
|
13146
13200
|
})
|
|
13147
13201
|
);
|
|
13148
13202
|
const responseData = {
|
|
13149
|
-
id: (_b = (_a23 = generateResult.response) == null ? void 0 : _a23.id) != null ? _b :
|
|
13203
|
+
id: (_b = (_a23 = generateResult.response) == null ? void 0 : _a23.id) != null ? _b : generateId4(),
|
|
13150
13204
|
timestamp: (_d = (_c = generateResult.response) == null ? void 0 : _c.timestamp) != null ? _d : currentDate(),
|
|
13151
13205
|
modelId: (_f = (_e = generateResult.response) == null ? void 0 : _e.modelId) != null ? _f : model.modelId,
|
|
13152
13206
|
headers: (_g = generateResult.response) == null ? void 0 : _g.headers,
|
|
@@ -13432,7 +13486,7 @@ function streamObject(options) {
|
|
|
13432
13486
|
},
|
|
13433
13487
|
onFinish,
|
|
13434
13488
|
_internal: {
|
|
13435
|
-
generateId:
|
|
13489
|
+
generateId: generateId4 = originalGenerateId5,
|
|
13436
13490
|
currentDate = () => /* @__PURE__ */ new Date(),
|
|
13437
13491
|
now: now2 = now
|
|
13438
13492
|
} = {},
|
|
@@ -13479,7 +13533,7 @@ function streamObject(options) {
|
|
|
13479
13533
|
onError,
|
|
13480
13534
|
onFinish,
|
|
13481
13535
|
download: download2,
|
|
13482
|
-
generateId:
|
|
13536
|
+
generateId: generateId4,
|
|
13483
13537
|
currentDate,
|
|
13484
13538
|
now: now2
|
|
13485
13539
|
});
|
|
@@ -13508,7 +13562,7 @@ var DefaultStreamObjectResult = class {
|
|
|
13508
13562
|
onError,
|
|
13509
13563
|
onFinish,
|
|
13510
13564
|
download: download2,
|
|
13511
|
-
generateId:
|
|
13565
|
+
generateId: generateId4,
|
|
13512
13566
|
currentDate,
|
|
13513
13567
|
now: now2
|
|
13514
13568
|
}) {
|
|
@@ -13542,7 +13596,7 @@ var DefaultStreamObjectResult = class {
|
|
|
13542
13596
|
}
|
|
13543
13597
|
});
|
|
13544
13598
|
this.baseStream = stitchableStream.stream.pipeThrough(eventProcessor);
|
|
13545
|
-
const callId =
|
|
13599
|
+
const callId = generateId4();
|
|
13546
13600
|
(async () => {
|
|
13547
13601
|
const jsonSchema2 = await outputStrategy.jsonSchema();
|
|
13548
13602
|
await notify({
|
|
@@ -13640,7 +13694,7 @@ var DefaultStreamObjectResult = class {
|
|
|
13640
13694
|
let accumulatedText = "";
|
|
13641
13695
|
let textDelta = "";
|
|
13642
13696
|
let fullResponse = {
|
|
13643
|
-
id:
|
|
13697
|
+
id: generateId4(),
|
|
13644
13698
|
timestamp: currentDate(),
|
|
13645
13699
|
modelId: model.modelId
|
|
13646
13700
|
};
|
|
@@ -14326,7 +14380,7 @@ async function experimental_generateVideo({
|
|
|
14326
14380
|
poll,
|
|
14327
14381
|
webhook
|
|
14328
14382
|
}) {
|
|
14329
|
-
var _a23
|
|
14383
|
+
var _a23;
|
|
14330
14384
|
const model = resolveVideoModel(modelArg);
|
|
14331
14385
|
const headersWithUserAgent = withUserAgentSuffix10(
|
|
14332
14386
|
headers != null ? headers : {},
|
|
@@ -14336,34 +14390,14 @@ async function experimental_generateVideo({
|
|
|
14336
14390
|
maxRetries: maxRetriesArg,
|
|
14337
14391
|
abortSignal
|
|
14338
14392
|
});
|
|
14339
|
-
const {
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
});
|
|
14348
|
-
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
|
|
14349
|
-
const warnings = [];
|
|
14350
|
-
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
14351
|
-
warnings.push({
|
|
14352
|
-
type: "other",
|
|
14353
|
-
message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
|
|
14354
|
-
});
|
|
14355
|
-
}
|
|
14356
|
-
const firstFrameImage = (_a23 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
|
|
14357
|
-
(frame) => frame.frameType === "first_frame"
|
|
14358
|
-
)) == null ? void 0 : _a23.image;
|
|
14359
|
-
if (image != null && firstFrameImage != null) {
|
|
14360
|
-
warnings.push({
|
|
14361
|
-
type: "other",
|
|
14362
|
-
message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
|
|
14363
|
-
});
|
|
14364
|
-
}
|
|
14365
|
-
const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
|
|
14366
|
-
const maxVideosPerCallWithDefault = (_b = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _b : 1;
|
|
14393
|
+
const {
|
|
14394
|
+
prompt,
|
|
14395
|
+
resolvedImage,
|
|
14396
|
+
normalizedFrameImages,
|
|
14397
|
+
effectiveInputReferences,
|
|
14398
|
+
warnings
|
|
14399
|
+
} = normalizeVideoCallInputs({ promptArg, frameImages, inputReferences });
|
|
14400
|
+
const maxVideosPerCallWithDefault = (_a23 = maxVideosPerCall != null ? maxVideosPerCall : await invokeModelMaxVideosPerCall(model)) != null ? _a23 : 1;
|
|
14367
14401
|
const hasStartStatus = model.doStart != null && model.doStatus != null;
|
|
14368
14402
|
const useStartStatus = hasStartStatus && (poll != null || webhook != null || model.doGenerate == null);
|
|
14369
14403
|
if (model.doGenerate == null && !hasStartStatus) {
|
|
@@ -14646,6 +14680,47 @@ function normalizePrompt2(promptArg) {
|
|
|
14646
14680
|
image: promptArg.image != null ? normalizeImageData(promptArg.image) : void 0
|
|
14647
14681
|
};
|
|
14648
14682
|
}
|
|
14683
|
+
function normalizeVideoCallInputs({
|
|
14684
|
+
promptArg,
|
|
14685
|
+
frameImages,
|
|
14686
|
+
inputReferences
|
|
14687
|
+
}) {
|
|
14688
|
+
var _a23;
|
|
14689
|
+
const { prompt, image } = normalizePrompt2(promptArg);
|
|
14690
|
+
const normalizedFrameImages = frameImages == null ? void 0 : frameImages.flatMap((frame) => {
|
|
14691
|
+
const normalizedImage = normalizeImageData(frame.image);
|
|
14692
|
+
return normalizedImage != null ? [{ image: normalizedImage, frameType: frame.frameType }] : [];
|
|
14693
|
+
});
|
|
14694
|
+
const normalizedInputReferences = inputReferences == null ? void 0 : inputReferences.flatMap((reference) => {
|
|
14695
|
+
const normalized = normalizeReferenceData(reference);
|
|
14696
|
+
return normalized != null ? [normalized] : [];
|
|
14697
|
+
});
|
|
14698
|
+
const effectiveInputReferences = normalizedFrameImages != null && normalizedFrameImages.length > 0 ? void 0 : normalizedInputReferences;
|
|
14699
|
+
const warnings = [];
|
|
14700
|
+
if (normalizedFrameImages != null && normalizedFrameImages.length > 0 && normalizedInputReferences != null && normalizedInputReferences.length > 0) {
|
|
14701
|
+
warnings.push({
|
|
14702
|
+
type: "other",
|
|
14703
|
+
message: "inputReferences were ignored because frameImages were provided; frameImages and inputReferences cannot be combined."
|
|
14704
|
+
});
|
|
14705
|
+
}
|
|
14706
|
+
const firstFrameImage = (_a23 = normalizedFrameImages == null ? void 0 : normalizedFrameImages.find(
|
|
14707
|
+
(frame) => frame.frameType === "first_frame"
|
|
14708
|
+
)) == null ? void 0 : _a23.image;
|
|
14709
|
+
if (image != null && firstFrameImage != null) {
|
|
14710
|
+
warnings.push({
|
|
14711
|
+
type: "other",
|
|
14712
|
+
message: "prompt.image was ignored because a first_frame frameImage was provided; the first_frame frameImage takes precedence as the start image."
|
|
14713
|
+
});
|
|
14714
|
+
}
|
|
14715
|
+
const resolvedImage = firstFrameImage != null ? firstFrameImage : image;
|
|
14716
|
+
return {
|
|
14717
|
+
prompt,
|
|
14718
|
+
resolvedImage,
|
|
14719
|
+
normalizedFrameImages,
|
|
14720
|
+
effectiveInputReferences,
|
|
14721
|
+
warnings
|
|
14722
|
+
};
|
|
14723
|
+
}
|
|
14649
14724
|
function detectFileMediaType(data, restrictToImages) {
|
|
14650
14725
|
const detected = restrictToImages ? detectMediaType4({ data, topLevelType: "image" }) : detectMediaType4({ data });
|
|
14651
14726
|
return detected != null ? detected : "image/png";
|
|
@@ -14709,6 +14784,117 @@ async function invokeModelMaxVideosPerCall(model) {
|
|
|
14709
14784
|
return model.maxVideosPerCall;
|
|
14710
14785
|
}
|
|
14711
14786
|
|
|
14787
|
+
// src/generate-video/start-video.ts
|
|
14788
|
+
import {
|
|
14789
|
+
generateId as generateId2,
|
|
14790
|
+
withUserAgentSuffix as withUserAgentSuffix11
|
|
14791
|
+
} from "@ai-sdk/provider-utils";
|
|
14792
|
+
async function experimental_startVideo({
|
|
14793
|
+
model: modelArg,
|
|
14794
|
+
prompt: promptArg,
|
|
14795
|
+
n = 1,
|
|
14796
|
+
maxVideosPerCall,
|
|
14797
|
+
aspectRatio,
|
|
14798
|
+
resolution,
|
|
14799
|
+
duration,
|
|
14800
|
+
fps,
|
|
14801
|
+
seed,
|
|
14802
|
+
frameImages,
|
|
14803
|
+
inputReferences,
|
|
14804
|
+
generateAudio,
|
|
14805
|
+
providerOptions,
|
|
14806
|
+
maxRetries: maxRetriesArg,
|
|
14807
|
+
abortSignal,
|
|
14808
|
+
headers,
|
|
14809
|
+
webhookUrl
|
|
14810
|
+
}) {
|
|
14811
|
+
const model = resolveVideoModel(modelArg);
|
|
14812
|
+
if (model.doStart == null) {
|
|
14813
|
+
throw new Error(
|
|
14814
|
+
`Video model ${model.modelId} does not implement doStart. Use generateVideo for models without an asynchronous start/status flow.`
|
|
14815
|
+
);
|
|
14816
|
+
}
|
|
14817
|
+
if (!Number.isInteger(n) || n < 1) {
|
|
14818
|
+
throw new Error(
|
|
14819
|
+
`Invalid n: expected a positive integer, received ${JSON.stringify(n)}.`
|
|
14820
|
+
);
|
|
14821
|
+
}
|
|
14822
|
+
const knownMaxVideosPerCall = maxVideosPerCall != null ? maxVideosPerCall : typeof model.maxVideosPerCall === "function" ? await model.maxVideosPerCall({ modelId: model.modelId }) : model.maxVideosPerCall;
|
|
14823
|
+
if (knownMaxVideosPerCall != null && n > knownMaxVideosPerCall) {
|
|
14824
|
+
throw new Error(
|
|
14825
|
+
`Video model ${model.modelId} supports at most ${knownMaxVideosPerCall} video(s) per call, but ${n} were requested. Split the batch across multiple startVideo calls.`
|
|
14826
|
+
);
|
|
14827
|
+
}
|
|
14828
|
+
const {
|
|
14829
|
+
prompt,
|
|
14830
|
+
resolvedImage,
|
|
14831
|
+
normalizedFrameImages,
|
|
14832
|
+
effectiveInputReferences,
|
|
14833
|
+
warnings
|
|
14834
|
+
} = normalizeVideoCallInputs({ promptArg, frameImages, inputReferences });
|
|
14835
|
+
const { retry } = prepareRetries({
|
|
14836
|
+
maxRetries: maxRetriesArg,
|
|
14837
|
+
abortSignal
|
|
14838
|
+
});
|
|
14839
|
+
const callerIdempotencyKey = Object.entries(headers != null ? headers : {}).find(
|
|
14840
|
+
([key, value]) => key.toLowerCase() === "idempotency-key" && value !== void 0
|
|
14841
|
+
);
|
|
14842
|
+
const callOptions = {
|
|
14843
|
+
prompt,
|
|
14844
|
+
n,
|
|
14845
|
+
aspectRatio,
|
|
14846
|
+
resolution,
|
|
14847
|
+
duration,
|
|
14848
|
+
fps,
|
|
14849
|
+
seed,
|
|
14850
|
+
image: resolvedImage,
|
|
14851
|
+
frameImages: normalizedFrameImages,
|
|
14852
|
+
inputReferences: effectiveInputReferences,
|
|
14853
|
+
generateAudio,
|
|
14854
|
+
providerOptions: providerOptions != null ? providerOptions : {},
|
|
14855
|
+
headers: {
|
|
14856
|
+
...withUserAgentSuffix11(headers != null ? headers : {}, `ai/${VERSION}`),
|
|
14857
|
+
...callerIdempotencyKey ? {} : { "idempotency-key": `aisdk_vid_${generateId2()}` }
|
|
14858
|
+
},
|
|
14859
|
+
abortSignal,
|
|
14860
|
+
webhookUrl
|
|
14861
|
+
};
|
|
14862
|
+
const startResult = await retry(() => model.doStart(callOptions));
|
|
14863
|
+
return {
|
|
14864
|
+
operation: startResult.operation,
|
|
14865
|
+
warnings: [...warnings, ...startResult.warnings],
|
|
14866
|
+
providerMetadata: startResult.providerMetadata,
|
|
14867
|
+
response: startResult.response
|
|
14868
|
+
};
|
|
14869
|
+
}
|
|
14870
|
+
|
|
14871
|
+
// src/generate-video/get-video-status.ts
|
|
14872
|
+
import { withUserAgentSuffix as withUserAgentSuffix12 } from "@ai-sdk/provider-utils";
|
|
14873
|
+
async function experimental_getVideoStatus(modelArg, {
|
|
14874
|
+
operation,
|
|
14875
|
+
headers,
|
|
14876
|
+
abortSignal,
|
|
14877
|
+
maxRetries: maxRetriesArg
|
|
14878
|
+
}) {
|
|
14879
|
+
const model = resolveVideoModel(modelArg);
|
|
14880
|
+
if (model.doStatus == null) {
|
|
14881
|
+
throw new Error(
|
|
14882
|
+
`Video model ${model.modelId} does not implement doStatus.`
|
|
14883
|
+
);
|
|
14884
|
+
}
|
|
14885
|
+
const { retry } = prepareRetries({
|
|
14886
|
+
maxRetries: maxRetriesArg,
|
|
14887
|
+
abortSignal
|
|
14888
|
+
});
|
|
14889
|
+
return retry(
|
|
14890
|
+
() => model.doStatus({
|
|
14891
|
+
operation,
|
|
14892
|
+
headers: withUserAgentSuffix12(headers != null ? headers : {}, `ai/${VERSION}`),
|
|
14893
|
+
abortSignal
|
|
14894
|
+
})
|
|
14895
|
+
);
|
|
14896
|
+
}
|
|
14897
|
+
|
|
14712
14898
|
// src/middleware/default-embedding-settings-middleware.ts
|
|
14713
14899
|
function defaultEmbeddingSettingsMiddleware({
|
|
14714
14900
|
settings
|
|
@@ -16869,7 +17055,7 @@ var DefaultRerankResult = class {
|
|
|
16869
17055
|
// src/transcribe/transcribe.ts
|
|
16870
17056
|
import {
|
|
16871
17057
|
detectMediaType as detectMediaType5,
|
|
16872
|
-
withUserAgentSuffix as
|
|
17058
|
+
withUserAgentSuffix as withUserAgentSuffix13
|
|
16873
17059
|
} from "@ai-sdk/provider-utils";
|
|
16874
17060
|
var defaultDownload2 = createDownload();
|
|
16875
17061
|
async function transcribe({
|
|
@@ -16889,7 +17075,7 @@ async function transcribe({
|
|
|
16889
17075
|
maxRetries: maxRetriesArg,
|
|
16890
17076
|
abortSignal
|
|
16891
17077
|
});
|
|
16892
|
-
const headersWithUserAgent =
|
|
17078
|
+
const headersWithUserAgent = withUserAgentSuffix13(
|
|
16893
17079
|
headers != null ? headers : {},
|
|
16894
17080
|
`ai/${VERSION}`
|
|
16895
17081
|
);
|
|
@@ -16946,7 +17132,7 @@ import {
|
|
|
16946
17132
|
} from "@ai-sdk/provider";
|
|
16947
17133
|
import {
|
|
16948
17134
|
DelayedPromise as DelayedPromise3,
|
|
16949
|
-
withUserAgentSuffix as
|
|
17135
|
+
withUserAgentSuffix as withUserAgentSuffix14
|
|
16950
17136
|
} from "@ai-sdk/provider-utils";
|
|
16951
17137
|
function streamTranscribe({
|
|
16952
17138
|
model,
|
|
@@ -16970,7 +17156,7 @@ function streamTranscribe({
|
|
|
16970
17156
|
message: `The ${resolvedModel.provider} model "${resolvedModel.modelId}" does not support streaming transcription.` + (typeof model === "string" ? " String model IDs resolve through the global provider (AI Gateway by default). If that provider does not support streaming transcription, pass a provider model instance instead (e.g. openai.transcription('gpt-realtime-whisper')) or upgrade @ai-sdk/gateway to a version with streaming transcription support." : "")
|
|
16971
17157
|
});
|
|
16972
17158
|
}
|
|
16973
|
-
const headersWithUserAgent =
|
|
17159
|
+
const headersWithUserAgent = withUserAgentSuffix14(
|
|
16974
17160
|
headers != null ? headers : {},
|
|
16975
17161
|
`ai/${VERSION}`
|
|
16976
17162
|
);
|
|
@@ -17155,7 +17341,7 @@ var experimental_transcribe = transcribe;
|
|
|
17155
17341
|
// src/translate/stream-translate.ts
|
|
17156
17342
|
import {
|
|
17157
17343
|
DelayedPromise as DelayedPromise4,
|
|
17158
|
-
withUserAgentSuffix as
|
|
17344
|
+
withUserAgentSuffix as withUserAgentSuffix15
|
|
17159
17345
|
} from "@ai-sdk/provider-utils";
|
|
17160
17346
|
function streamTranslate({
|
|
17161
17347
|
model,
|
|
@@ -17172,7 +17358,7 @@ function streamTranslate({
|
|
|
17172
17358
|
}) {
|
|
17173
17359
|
const resolvedModel = resolveSpeechTranslationModel(model);
|
|
17174
17360
|
const doStream = resolvedModel.doStream.bind(resolvedModel);
|
|
17175
|
-
const headersWithUserAgent =
|
|
17361
|
+
const headersWithUserAgent = withUserAgentSuffix15(
|
|
17176
17362
|
headers != null ? headers : {},
|
|
17177
17363
|
`ai/${VERSION}`
|
|
17178
17364
|
);
|
|
@@ -17369,7 +17555,7 @@ function streamTranslate({
|
|
|
17369
17555
|
// src/ui/call-completion-api.ts
|
|
17370
17556
|
import {
|
|
17371
17557
|
parseJsonEventStream,
|
|
17372
|
-
withUserAgentSuffix as
|
|
17558
|
+
withUserAgentSuffix as withUserAgentSuffix16,
|
|
17373
17559
|
getRuntimeEnvironmentUserAgent as getRuntimeEnvironmentUserAgent2
|
|
17374
17560
|
} from "@ai-sdk/provider-utils";
|
|
17375
17561
|
|
|
@@ -17419,7 +17605,7 @@ async function callCompletionApi({
|
|
|
17419
17605
|
...body
|
|
17420
17606
|
}),
|
|
17421
17607
|
credentials,
|
|
17422
|
-
headers:
|
|
17608
|
+
headers: withUserAgentSuffix16(
|
|
17423
17609
|
{
|
|
17424
17610
|
"Content-Type": "application/json",
|
|
17425
17611
|
...headers
|
|
@@ -17687,8 +17873,8 @@ var DefaultChatTransport = class extends HttpChatTransport {
|
|
|
17687
17873
|
// src/ui/chat.ts
|
|
17688
17874
|
var AbstractChat = class {
|
|
17689
17875
|
constructor({
|
|
17690
|
-
generateId:
|
|
17691
|
-
id =
|
|
17876
|
+
generateId: generateId4 = generateIdFunc2,
|
|
17877
|
+
id = generateId4(),
|
|
17692
17878
|
transport = new DefaultChatTransport(),
|
|
17693
17879
|
messageMetadataSchema,
|
|
17694
17880
|
dataPartSchemas,
|
|
@@ -17890,7 +18076,7 @@ var AbstractChat = class {
|
|
|
17890
18076
|
};
|
|
17891
18077
|
this.id = id;
|
|
17892
18078
|
this.transport = transport;
|
|
17893
|
-
this.generateId =
|
|
18079
|
+
this.generateId = generateId4;
|
|
17894
18080
|
this.messageMetadataSchema = messageMetadataSchema;
|
|
17895
18081
|
this.dataPartSchemas = dataPartSchemas;
|
|
17896
18082
|
this.state = state;
|
|
@@ -18443,8 +18629,10 @@ export {
|
|
|
18443
18629
|
getBatchResults as experimental_getBatchResults,
|
|
18444
18630
|
getBatchStatus as experimental_getBatchStatus,
|
|
18445
18631
|
getRealtimeToolDefinitions as experimental_getRealtimeToolDefinitions,
|
|
18632
|
+
experimental_getVideoStatus,
|
|
18446
18633
|
resampleAudio as experimental_resampleAudio,
|
|
18447
18634
|
startTextBatch as experimental_startTextBatch,
|
|
18635
|
+
experimental_startVideo,
|
|
18448
18636
|
streamLanguageModelCall as experimental_streamLanguageModelCall,
|
|
18449
18637
|
streamTranscribe as experimental_streamTranscribe,
|
|
18450
18638
|
streamTranslate as experimental_streamTranslate,
|
|
@@ -18454,7 +18642,7 @@ export {
|
|
|
18454
18642
|
extractReasoningMiddleware,
|
|
18455
18643
|
fingerprintTools,
|
|
18456
18644
|
gateway2 as gateway,
|
|
18457
|
-
|
|
18645
|
+
generateId3 as generateId,
|
|
18458
18646
|
generateImage,
|
|
18459
18647
|
generateObject,
|
|
18460
18648
|
generateSpeech,
|