ai 7.0.118 → 7.0.119
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.js +57 -26
- package/dist/index.js.map +1 -1
- package/dist/internal/index.js +3 -1
- package/dist/internal/index.js.map +1 -1
- package/dist/test/index.d.ts +5 -1
- package/dist/test/index.js +4 -0
- package/dist/test/index.js.map +1 -1
- package/docs/03-ai-sdk-core/35-image-generation.mdx +38 -0
- package/docs/03-ai-sdk-core/36-transcription.mdx +1 -0
- package/docs/03-ai-sdk-harnesses/02-harness-agent.mdx +51 -9
- package/docs/07-reference/01-ai-sdk-core/61-wrap-image-model.mdx +16 -1
- package/package.json +12 -12
- package/src/middleware/wrap-image-model.ts +13 -0
- package/src/telemetry/tracing-channel-publisher.ts +1 -0
- package/src/test/mock-image-model-v4.ts +8 -0
- package/src/ui/process-ui-message-stream.ts +1 -6
- package/src/util/write-to-server-response.ts +41 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# ai
|
|
2
2
|
|
|
3
|
+
## 7.0.119
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 33e94ba: fix(ai): cancel response streams when clients disconnect
|
|
8
|
+
- 34d869e: fix(ai): prevent unhandled stream completion rejections in non-Node runtimes
|
|
9
|
+
- def4df8: fix(ai): store static tool input errors in the current input field
|
|
10
|
+
- 525efc5: feat(provider): advertise image model file and mask input support
|
|
11
|
+
|
|
12
|
+
Use confirmed model IDs for capability declarations so unrecognized model names
|
|
13
|
+
remain unknown. Include Together AI FLUX.2 Pro and Flex single-image editing, and
|
|
14
|
+
allow asynchronous capability lookups and middleware overrides to resolve to
|
|
15
|
+
unknown.
|
|
16
|
+
|
|
17
|
+
Advertise QuiverAI Arrow 2 and Arrow 2 Telos file-input support, and mark Together
|
|
18
|
+
AI Gemini image inputs unsupported by the current single-image request mapping.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [e3605f6]
|
|
21
|
+
- Updated dependencies [525efc5]
|
|
22
|
+
- @ai-sdk/provider-utils@5.0.50
|
|
23
|
+
- @ai-sdk/provider@4.0.19
|
|
24
|
+
- @ai-sdk/gateway@4.0.97
|
|
25
|
+
|
|
3
26
|
## 7.0.118
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -1328,7 +1328,7 @@ import {
|
|
|
1328
1328
|
} from "@ai-sdk/provider-utils";
|
|
1329
1329
|
|
|
1330
1330
|
// src/version.ts
|
|
1331
|
-
var VERSION = true ? "7.0.
|
|
1331
|
+
var VERSION = true ? "7.0.119" : "0.0.0-test";
|
|
1332
1332
|
|
|
1333
1333
|
// src/util/download/download.ts
|
|
1334
1334
|
var download = async ({
|
|
@@ -5056,6 +5056,8 @@ function openTelemetryChannelSpanContext({
|
|
|
5056
5056
|
completion
|
|
5057
5057
|
}) {
|
|
5058
5058
|
if (!isNodeRuntime()) {
|
|
5059
|
+
Promise.resolve(completion).catch(() => {
|
|
5060
|
+
});
|
|
5059
5061
|
return void 0;
|
|
5060
5062
|
}
|
|
5061
5063
|
const diagnosticsChannel = loadBuiltinModule(
|
|
@@ -7053,11 +7055,26 @@ function writeToServerResponse({
|
|
|
7053
7055
|
response.writeHead(statusCode);
|
|
7054
7056
|
}
|
|
7055
7057
|
const reader = stream.getReader();
|
|
7058
|
+
let clientDisconnected = false;
|
|
7059
|
+
let onDisconnect;
|
|
7060
|
+
const handleClose = () => {
|
|
7061
|
+
if (response.writableFinished) {
|
|
7062
|
+
return;
|
|
7063
|
+
}
|
|
7064
|
+
clientDisconnected = true;
|
|
7065
|
+
onDisconnect?.();
|
|
7066
|
+
reader.cancel(new Error("Client disconnected.")).catch(() => {
|
|
7067
|
+
});
|
|
7068
|
+
};
|
|
7069
|
+
response.once("close", handleClose);
|
|
7070
|
+
if (response.destroyed) {
|
|
7071
|
+
handleClose();
|
|
7072
|
+
}
|
|
7056
7073
|
const read = async () => {
|
|
7057
7074
|
try {
|
|
7058
7075
|
while (true) {
|
|
7059
7076
|
const { done, value } = await reader.read();
|
|
7060
|
-
if (done) break;
|
|
7077
|
+
if (done || clientDisconnected || response.destroyed) break;
|
|
7061
7078
|
const canContinue = response.write(value);
|
|
7062
7079
|
const flush = response.flush;
|
|
7063
7080
|
if (typeof flush === "function") {
|
|
@@ -7065,12 +7082,20 @@ function writeToServerResponse({
|
|
|
7065
7082
|
}
|
|
7066
7083
|
if (!canContinue) {
|
|
7067
7084
|
await new Promise((resolve3) => {
|
|
7085
|
+
onDisconnect = resolve3;
|
|
7068
7086
|
response.once("drain", resolve3);
|
|
7069
7087
|
});
|
|
7088
|
+
onDisconnect = void 0;
|
|
7070
7089
|
}
|
|
7071
7090
|
}
|
|
7072
7091
|
} finally {
|
|
7073
|
-
response.
|
|
7092
|
+
response.off("close", handleClose);
|
|
7093
|
+
if (clientDisconnected || response.destroyed) {
|
|
7094
|
+
reader.cancel().catch(() => {
|
|
7095
|
+
});
|
|
7096
|
+
} else {
|
|
7097
|
+
response.end();
|
|
7098
|
+
}
|
|
7074
7099
|
}
|
|
7075
7100
|
};
|
|
7076
7101
|
return read();
|
|
@@ -7446,25 +7471,6 @@ function getToolName(part) {
|
|
|
7446
7471
|
}
|
|
7447
7472
|
var getToolOrDynamicToolName = getToolName;
|
|
7448
7473
|
|
|
7449
|
-
// src/ui/warn-if-ui-message-has-deprecated-raw-input.ts
|
|
7450
|
-
var rawInputDeprecationWarning = {
|
|
7451
|
-
type: "deprecated",
|
|
7452
|
-
setting: "rawInput in output-error UI message parts",
|
|
7453
|
-
message: 'Use the "input" field instead. The "rawInput" field will be removed in the next major version.'
|
|
7454
|
-
};
|
|
7455
|
-
function warnIfUIMessageHasDeprecatedRawInput(messages) {
|
|
7456
|
-
const hasDeprecatedRawInput = messages.some(
|
|
7457
|
-
(message) => message.parts.some(
|
|
7458
|
-
(part) => part != null && typeof part === "object" && "type" in part && typeof part.type === "string" && (part.type === "dynamic-tool" || part.type.startsWith("tool-")) && "state" in part && part.state === "output-error" && Object.prototype.hasOwnProperty.call(part, "rawInput") && "rawInput" in part && part.rawInput !== void 0
|
|
7459
|
-
)
|
|
7460
|
-
);
|
|
7461
|
-
if (hasDeprecatedRawInput) {
|
|
7462
|
-
logWarnings({
|
|
7463
|
-
warnings: [rawInputDeprecationWarning]
|
|
7464
|
-
});
|
|
7465
|
-
}
|
|
7466
|
-
}
|
|
7467
|
-
|
|
7468
7474
|
// src/ui/process-ui-message-stream.ts
|
|
7469
7475
|
function createStreamingUIMessageState({
|
|
7470
7476
|
lastMessage,
|
|
@@ -7905,14 +7911,12 @@ function processUIMessageStream({
|
|
|
7905
7911
|
toolCallId: chunk.toolCallId,
|
|
7906
7912
|
toolName: chunk.toolName,
|
|
7907
7913
|
state: "output-error",
|
|
7908
|
-
input:
|
|
7909
|
-
rawInput: chunk.input,
|
|
7914
|
+
input: chunk.input,
|
|
7910
7915
|
errorText: chunk.errorText,
|
|
7911
7916
|
providerExecuted: chunk.providerExecuted,
|
|
7912
7917
|
providerMetadata: chunk.providerMetadata,
|
|
7913
7918
|
toolMetadata: chunk.toolMetadata
|
|
7914
7919
|
});
|
|
7915
|
-
warnIfUIMessageHasDeprecatedRawInput([state.message]);
|
|
7916
7920
|
}
|
|
7917
7921
|
write();
|
|
7918
7922
|
break;
|
|
@@ -12219,6 +12223,27 @@ function readUIMessageStream({
|
|
|
12219
12223
|
import {
|
|
12220
12224
|
isNonNullable
|
|
12221
12225
|
} from "@ai-sdk/provider-utils";
|
|
12226
|
+
|
|
12227
|
+
// src/ui/warn-if-ui-message-has-deprecated-raw-input.ts
|
|
12228
|
+
var rawInputDeprecationWarning = {
|
|
12229
|
+
type: "deprecated",
|
|
12230
|
+
setting: "rawInput in output-error UI message parts",
|
|
12231
|
+
message: 'Use the "input" field instead. The "rawInput" field will be removed in the next major version.'
|
|
12232
|
+
};
|
|
12233
|
+
function warnIfUIMessageHasDeprecatedRawInput(messages) {
|
|
12234
|
+
const hasDeprecatedRawInput = messages.some(
|
|
12235
|
+
(message) => message.parts.some(
|
|
12236
|
+
(part) => part != null && typeof part === "object" && "type" in part && typeof part.type === "string" && (part.type === "dynamic-tool" || part.type.startsWith("tool-")) && "state" in part && part.state === "output-error" && Object.prototype.hasOwnProperty.call(part, "rawInput") && "rawInput" in part && part.rawInput !== void 0
|
|
12237
|
+
)
|
|
12238
|
+
);
|
|
12239
|
+
if (hasDeprecatedRawInput) {
|
|
12240
|
+
logWarnings({
|
|
12241
|
+
warnings: [rawInputDeprecationWarning]
|
|
12242
|
+
});
|
|
12243
|
+
}
|
|
12244
|
+
}
|
|
12245
|
+
|
|
12246
|
+
// src/ui/convert-to-model-messages.ts
|
|
12222
12247
|
async function convertToModelMessages(messages, options) {
|
|
12223
12248
|
const modelMessages = [];
|
|
12224
12249
|
warnIfUIMessageHasDeprecatedRawInput(messages);
|
|
@@ -17874,7 +17899,9 @@ var doWrap3 = ({
|
|
|
17874
17899
|
wrapGenerate,
|
|
17875
17900
|
overrideProvider,
|
|
17876
17901
|
overrideModelId,
|
|
17877
|
-
overrideMaxImagesPerCall
|
|
17902
|
+
overrideMaxImagesPerCall,
|
|
17903
|
+
overrideSupportsFileInputs,
|
|
17904
|
+
overrideSupportsMaskInputs
|
|
17878
17905
|
},
|
|
17879
17906
|
modelId,
|
|
17880
17907
|
providerId
|
|
@@ -17884,11 +17911,15 @@ var doWrap3 = ({
|
|
|
17884
17911
|
}
|
|
17885
17912
|
const maxImagesPerCallRaw = overrideMaxImagesPerCall?.({ model }) ?? model.maxImagesPerCall;
|
|
17886
17913
|
const maxImagesPerCall = maxImagesPerCallRaw instanceof Function ? maxImagesPerCallRaw.bind(model) : maxImagesPerCallRaw;
|
|
17914
|
+
const supportsFileInputs = overrideSupportsFileInputs !== void 0 ? overrideSupportsFileInputs({ model }) : model.supportsFileInputs;
|
|
17915
|
+
const supportsMaskInputs = overrideSupportsMaskInputs !== void 0 ? overrideSupportsMaskInputs({ model }) : model.supportsMaskInputs;
|
|
17887
17916
|
return {
|
|
17888
17917
|
specificationVersion: "v4",
|
|
17889
17918
|
provider: providerId ?? overrideProvider?.({ model }) ?? model.provider,
|
|
17890
17919
|
modelId: modelId ?? overrideModelId?.({ model }) ?? model.modelId,
|
|
17891
17920
|
maxImagesPerCall,
|
|
17921
|
+
supportsFileInputs,
|
|
17922
|
+
supportsMaskInputs,
|
|
17892
17923
|
async doGenerate(params) {
|
|
17893
17924
|
const transformedParams = await doTransform({ params });
|
|
17894
17925
|
const doGenerate = async () => await model.doGenerate(transformedParams);
|