New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ai-sdk/anthropic

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ai-sdk/anthropic - npm Package Compare versions

Comparing version 0.0.48 to 0.0.49

CHANGELOG.md

40

./dist/index.js

@@ -59,3 +59,3 @@ "use strict";

}) {
var _a, _b, _c;
var _a, _b, _c, _d;
const blocks = groupIntoBlocks(prompt);

@@ -96,5 +96,5 @@ let system = void 0;

case "user": {
for (let i2 = 0; i2 < content.length; i2++) {
const part = content[i2];
const isLastPart = i2 === content.length - 1;
for (let j = 0; j < content.length; j++) {
const part = content[j];
const isLastPart = j === content.length - 1;
const cacheControl = (_a = getCacheControl(part.providerMetadata)) != null ? _a : isLastPart ? getCacheControl(message.providerMetadata) : void 0;

@@ -157,5 +157,8 @@ switch (part.type) {

const anthropicContent = [];
for (const { content } of block.messages) {
for (const message of block.messages) {
const { content } = message;
for (let j = 0; j < content.length; j++) {
const part = content[j];
const isLastPart = j === content.length - 1;
const cacheControl = (_d = getCacheControl(part.providerMetadata)) != null ? _d : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
switch (part.type) {

@@ -171,4 +174,3 @@ case "text": {

),
cache_control: void 0
// not used in assistant messages
cache_control: cacheControl
});

@@ -182,3 +184,4 @@ break;

name: part.toolName,
input: part.args
input: part.args,
cache_control: cacheControl
});

@@ -376,3 +379,3 @@ break;

async doGenerate(options) {
var _a, _b;
var _a, _b, _c, _d;
const { args, warnings } = await this.getArgs(options);

@@ -421,7 +424,11 @@ const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

rawResponse: { headers: responseHeaders },
response: {
id: (_a = response.id) != null ? _a : void 0,
modelId: (_b = response.model) != null ? _b : void 0
},
warnings,
providerMetadata: this.settings.cacheControl === true ? {
anthropic: {
cacheCreationInputTokens: (_a = response.usage.cache_creation_input_tokens) != null ? _a : null,
cacheReadInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : null
cacheCreationInputTokens: (_c = response.usage.cache_creation_input_tokens) != null ? _c : null,
cacheReadInputTokens: (_d = response.usage.cache_read_input_tokens) != null ? _d : null
}

@@ -457,3 +464,3 @@ } : void 0

transform(chunk, controller) {
var _a, _b;
var _a, _b, _c, _d;
if (!chunk.success) {

@@ -545,2 +552,7 @@ controller.enqueue({ type: "error", error: chunk.error });

}
controller.enqueue({
type: "response-metadata",
id: (_c = value.message.id) != null ? _c : void 0,
modelId: (_d = value.message.model) != null ? _d : void 0
});
return;

@@ -582,2 +594,4 @@ }

type: import_zod2.z.literal("message"),
id: import_zod2.z.string().nullish(),
model: import_zod2.z.string().nullish(),
content: import_zod2.z.array(

@@ -609,2 +623,4 @@ import_zod2.z.discriminatedUnion("type", [

message: import_zod2.z.object({
id: import_zod2.z.string().nullish(),
model: import_zod2.z.string().nullish(),
usage: import_zod2.z.object({

@@ -611,0 +627,0 @@ input_tokens: import_zod2.z.number(),

@@ -59,3 +59,3 @@ "use strict";

}) {
var _a, _b, _c;
var _a, _b, _c, _d;
const blocks = groupIntoBlocks(prompt);

@@ -96,5 +96,5 @@ let system = void 0;

case "user": {
for (let i2 = 0; i2 < content.length; i2++) {
const part = content[i2];
const isLastPart = i2 === content.length - 1;
for (let j = 0; j < content.length; j++) {
const part = content[j];
const isLastPart = j === content.length - 1;
const cacheControl = (_a = getCacheControl(part.providerMetadata)) != null ? _a : isLastPart ? getCacheControl(message.providerMetadata) : void 0;

@@ -157,5 +157,8 @@ switch (part.type) {

const anthropicContent = [];
for (const { content } of block.messages) {
for (const message of block.messages) {
const { content } = message;
for (let j = 0; j < content.length; j++) {
const part = content[j];
const isLastPart = j === content.length - 1;
const cacheControl = (_d = getCacheControl(part.providerMetadata)) != null ? _d : isLastPart ? getCacheControl(message.providerMetadata) : void 0;
switch (part.type) {

@@ -171,4 +174,3 @@ case "text": {

),
cache_control: void 0
// not used in assistant messages
cache_control: cacheControl
});

@@ -182,3 +184,4 @@ break;

name: part.toolName,
input: part.args
input: part.args,
cache_control: cacheControl
});

@@ -376,3 +379,3 @@ break;

async doGenerate(options) {
var _a, _b;
var _a, _b, _c, _d;
const { args, warnings } = await this.getArgs(options);

@@ -421,7 +424,11 @@ const { responseHeaders, value: response } = await (0, import_provider_utils3.postJsonToApi)({

rawResponse: { headers: responseHeaders },
response: {
id: (_a = response.id) != null ? _a : void 0,
modelId: (_b = response.model) != null ? _b : void 0
},
warnings,
providerMetadata: this.settings.cacheControl === true ? {
anthropic: {
cacheCreationInputTokens: (_a = response.usage.cache_creation_input_tokens) != null ? _a : null,
cacheReadInputTokens: (_b = response.usage.cache_read_input_tokens) != null ? _b : null
cacheCreationInputTokens: (_c = response.usage.cache_creation_input_tokens) != null ? _c : null,
cacheReadInputTokens: (_d = response.usage.cache_read_input_tokens) != null ? _d : null
}

@@ -457,3 +464,3 @@ } : void 0

transform(chunk, controller) {
var _a, _b;
var _a, _b, _c, _d;
if (!chunk.success) {

@@ -545,2 +552,7 @@ controller.enqueue({ type: "error", error: chunk.error });

}
controller.enqueue({
type: "response-metadata",
id: (_c = value.message.id) != null ? _c : void 0,
modelId: (_d = value.message.model) != null ? _d : void 0
});
return;

@@ -582,2 +594,4 @@ }

type: import_zod2.z.literal("message"),
id: import_zod2.z.string().nullish(),
model: import_zod2.z.string().nullish(),
content: import_zod2.z.array(

@@ -609,2 +623,4 @@ import_zod2.z.discriminatedUnion("type", [

message: import_zod2.z.object({
id: import_zod2.z.string().nullish(),
model: import_zod2.z.string().nullish(),
usage: import_zod2.z.object({

@@ -611,0 +627,0 @@ input_tokens: import_zod2.z.number(),

{
"name": "@ai-sdk/anthropic",
"version": "0.0.48",
"version": "0.0.49",
"license": "Apache-2.0",

@@ -10,3 +10,4 @@ "sideEffects": false,

"files": [
"dist/**/*"
"dist/**/*",
"CHANGELOG.md"
],

@@ -22,4 +23,4 @@ "exports": {

"dependencies": {
"@ai-sdk/provider": "0.0.22",
"@ai-sdk/provider-utils": "1.0.17"
"@ai-sdk/provider": "0.0.23",
"@ai-sdk/provider-utils": "1.0.18"
},

@@ -26,0 +27,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc