@ai-sdk/anthropic 4.0.85 → 4.0.87
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 +26 -0
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/dist/internal/index.d.ts.map +1 -1
- package/dist/internal/index.js +50 -1
- package/dist/internal/index.js.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-language-model.ts +64 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
# @ai-sdk/anthropic
|
|
2
2
|
|
|
3
|
+
## 4.0.87
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [8202f5b]
|
|
8
|
+
- Updated dependencies [85d84a1]
|
|
9
|
+
- @ai-sdk/provider-utils@5.0.67
|
|
10
|
+
- @ai-sdk/provider@4.0.33
|
|
11
|
+
|
|
12
|
+
## 4.0.86
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
|
|
17
|
+
|
|
18
|
+
This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
|
|
19
|
+
|
|
20
|
+
**Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
|
|
21
|
+
|
|
22
|
+
Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
|
|
23
|
+
|
|
24
|
+
- aac6026: fix(anthropic): preserve empty-stream rejection for interrupted responses
|
|
25
|
+
- Updated dependencies [10026d1]
|
|
26
|
+
- @ai-sdk/provider@4.0.32
|
|
27
|
+
- @ai-sdk/provider-utils@5.0.66
|
|
28
|
+
|
|
3
29
|
## 4.0.85
|
|
4
30
|
|
|
5
31
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -4503,7 +4503,7 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
4503
4503
|
let hasInvalidMessageSequence = false;
|
|
4504
4504
|
let blockType = void 0;
|
|
4505
4505
|
const generateId = this.generateId;
|
|
4506
|
-
const
|
|
4506
|
+
const transformedStream = response.pipeThrough(new TransformStream({
|
|
4507
4507
|
start(controller) {
|
|
4508
4508
|
controller.enqueue({
|
|
4509
4509
|
type: "stream-start",
|
|
@@ -5223,6 +5223,55 @@ var AnthropicLanguageModel = class AnthropicLanguageModel {
|
|
|
5223
5223
|
default: throw new Error(`Unsupported chunk type: ${value}`);
|
|
5224
5224
|
}
|
|
5225
5225
|
}
|
|
5226
|
+
}));
|
|
5227
|
+
let hasOutput = false;
|
|
5228
|
+
let hasStreamError = false;
|
|
5229
|
+
let lastFinish;
|
|
5230
|
+
const [streamForFirstChunk, streamForConsumer] = transformedStream.pipeThrough(new TransformStream({
|
|
5231
|
+
transform(chunk, controller) {
|
|
5232
|
+
switch (chunk.type) {
|
|
5233
|
+
case "response-metadata":
|
|
5234
|
+
hasOutput = false;
|
|
5235
|
+
break;
|
|
5236
|
+
case "finish":
|
|
5237
|
+
hasOutput = false;
|
|
5238
|
+
lastFinish = chunk;
|
|
5239
|
+
break;
|
|
5240
|
+
case "error":
|
|
5241
|
+
hasStreamError = true;
|
|
5242
|
+
break;
|
|
5243
|
+
case "text-delta":
|
|
5244
|
+
case "reasoning-delta":
|
|
5245
|
+
case "tool-input-delta":
|
|
5246
|
+
hasOutput ||= chunk.delta.length > 0;
|
|
5247
|
+
break;
|
|
5248
|
+
case "tool-call": hasOutput = true;
|
|
5249
|
+
}
|
|
5250
|
+
controller.enqueue(chunk);
|
|
5251
|
+
},
|
|
5252
|
+
flush(controller) {
|
|
5253
|
+
if (hasOutput && !hasStreamError) controller.enqueue({
|
|
5254
|
+
type: "finish",
|
|
5255
|
+
finishReason: {
|
|
5256
|
+
unified: "interrupted",
|
|
5257
|
+
raw: void 0
|
|
5258
|
+
},
|
|
5259
|
+
usage: lastFinish?.usage ?? {
|
|
5260
|
+
inputTokens: {
|
|
5261
|
+
total: void 0,
|
|
5262
|
+
noCache: void 0,
|
|
5263
|
+
cacheRead: void 0,
|
|
5264
|
+
cacheWrite: void 0
|
|
5265
|
+
},
|
|
5266
|
+
outputTokens: {
|
|
5267
|
+
total: void 0,
|
|
5268
|
+
text: void 0,
|
|
5269
|
+
reasoning: void 0
|
|
5270
|
+
}
|
|
5271
|
+
},
|
|
5272
|
+
...lastFinish?.providerMetadata != null ? { providerMetadata: lastFinish.providerMetadata } : {}
|
|
5273
|
+
});
|
|
5274
|
+
}
|
|
5226
5275
|
})).tee();
|
|
5227
5276
|
const firstChunkReader = streamForFirstChunk.getReader();
|
|
5228
5277
|
try {
|
|
@@ -6970,7 +7019,7 @@ var AnthropicSkills = class {
|
|
|
6970
7019
|
};
|
|
6971
7020
|
//#endregion
|
|
6972
7021
|
//#region src/version.ts
|
|
6973
|
-
const VERSION = "4.0.
|
|
7022
|
+
const VERSION = "4.0.87";
|
|
6974
7023
|
//#endregion
|
|
6975
7024
|
//#region src/anthropic-provider.ts
|
|
6976
7025
|
const ANTHROPIC_API_URL = "https://api.anthropic.com";
|