@ai-sdk/anthropic 4.0.0-beta.19 → 4.0.0-beta.21
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 +18 -0
- package/dist/index.d.mts +12 -4
- package/dist/index.d.ts +12 -4
- package/dist/index.js +152 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -8
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.js +16 -6
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +18 -7
- package/dist/internal/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/anthropic-messages-language-model.ts +8 -1
- package/src/anthropic-messages-options.ts +12 -5
- package/src/anthropic-provider.ts +17 -0
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +136 -0
package/dist/index.mjs
CHANGED
|
@@ -134,7 +134,8 @@ import {
|
|
|
134
134
|
mapReasoningToProviderEffort,
|
|
135
135
|
parseProviderOptions as parseProviderOptions3,
|
|
136
136
|
postJsonToApi,
|
|
137
|
-
resolve
|
|
137
|
+
resolve,
|
|
138
|
+
resolveProviderReference as resolveProviderReference2
|
|
138
139
|
} from "@ai-sdk/provider-utils";
|
|
139
140
|
|
|
140
141
|
// src/anthropic-messages-api.ts
|
|
@@ -986,11 +987,18 @@ var anthropicLanguageModelOptions = z4.object({
|
|
|
986
987
|
container: z4.object({
|
|
987
988
|
id: z4.string().optional(),
|
|
988
989
|
skills: z4.array(
|
|
989
|
-
z4.
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
990
|
+
z4.discriminatedUnion("type", [
|
|
991
|
+
z4.object({
|
|
992
|
+
type: z4.literal("anthropic"),
|
|
993
|
+
skillId: z4.string(),
|
|
994
|
+
version: z4.string().optional()
|
|
995
|
+
}),
|
|
996
|
+
z4.object({
|
|
997
|
+
type: z4.literal("custom"),
|
|
998
|
+
providerReference: z4.record(z4.string(), z4.string()),
|
|
999
|
+
version: z4.string().optional()
|
|
1000
|
+
})
|
|
1001
|
+
])
|
|
994
1002
|
).optional()
|
|
995
1003
|
}).optional(),
|
|
996
1004
|
/**
|
|
@@ -3214,7 +3222,10 @@ var AnthropicMessagesLanguageModel = class {
|
|
|
3214
3222
|
id: anthropicOptions.container.id,
|
|
3215
3223
|
skills: anthropicOptions.container.skills.map((skill) => ({
|
|
3216
3224
|
type: skill.type,
|
|
3217
|
-
skill_id: skill.
|
|
3225
|
+
skill_id: skill.type === "custom" ? resolveProviderReference2({
|
|
3226
|
+
reference: skill.providerReference,
|
|
3227
|
+
provider: "anthropic"
|
|
3228
|
+
}) : skill.skillId,
|
|
3218
3229
|
version: skill.version
|
|
3219
3230
|
}))
|
|
3220
3231
|
}
|
|
@@ -5327,8 +5338,137 @@ var anthropicTools = {
|
|
|
5327
5338
|
toolSearchBm25_20251119
|
|
5328
5339
|
};
|
|
5329
5340
|
|
|
5341
|
+
// src/skills/anthropic-skills.ts
|
|
5342
|
+
import {
|
|
5343
|
+
combineHeaders as combineHeaders3,
|
|
5344
|
+
convertBase64ToUint8Array as convertBase64ToUint8Array3,
|
|
5345
|
+
createJsonResponseHandler as createJsonResponseHandler3,
|
|
5346
|
+
getFromApi,
|
|
5347
|
+
postFormDataToApi as postFormDataToApi2,
|
|
5348
|
+
resolve as resolve2
|
|
5349
|
+
} from "@ai-sdk/provider-utils";
|
|
5350
|
+
|
|
5351
|
+
// src/skills/anthropic-skills-api.ts
|
|
5352
|
+
import { lazySchema as lazySchema23, zodSchema as zodSchema23 } from "@ai-sdk/provider-utils";
|
|
5353
|
+
import { z as z24 } from "zod/v4";
|
|
5354
|
+
var anthropicSkillResponseSchema = lazySchema23(
|
|
5355
|
+
() => zodSchema23(
|
|
5356
|
+
z24.object({
|
|
5357
|
+
id: z24.string(),
|
|
5358
|
+
display_title: z24.string().nullish(),
|
|
5359
|
+
name: z24.string().nullish(),
|
|
5360
|
+
description: z24.string().nullish(),
|
|
5361
|
+
latest_version: z24.string().nullish(),
|
|
5362
|
+
source: z24.string(),
|
|
5363
|
+
created_at: z24.string(),
|
|
5364
|
+
updated_at: z24.string()
|
|
5365
|
+
})
|
|
5366
|
+
)
|
|
5367
|
+
);
|
|
5368
|
+
var anthropicSkillVersionListResponseSchema = lazySchema23(
|
|
5369
|
+
() => zodSchema23(
|
|
5370
|
+
z24.object({
|
|
5371
|
+
data: z24.array(
|
|
5372
|
+
z24.object({
|
|
5373
|
+
version: z24.string()
|
|
5374
|
+
})
|
|
5375
|
+
)
|
|
5376
|
+
})
|
|
5377
|
+
)
|
|
5378
|
+
);
|
|
5379
|
+
var anthropicSkillVersionResponseSchema = lazySchema23(
|
|
5380
|
+
() => zodSchema23(
|
|
5381
|
+
z24.object({
|
|
5382
|
+
type: z24.string(),
|
|
5383
|
+
skill_id: z24.string(),
|
|
5384
|
+
name: z24.string().nullish(),
|
|
5385
|
+
description: z24.string().nullish()
|
|
5386
|
+
})
|
|
5387
|
+
)
|
|
5388
|
+
);
|
|
5389
|
+
|
|
5390
|
+
// src/skills/anthropic-skills.ts
|
|
5391
|
+
var AnthropicSkills = class {
|
|
5392
|
+
constructor(config) {
|
|
5393
|
+
this.config = config;
|
|
5394
|
+
this.specificationVersion = "v4";
|
|
5395
|
+
}
|
|
5396
|
+
get provider() {
|
|
5397
|
+
return this.config.provider;
|
|
5398
|
+
}
|
|
5399
|
+
async getHeaders() {
|
|
5400
|
+
return combineHeaders3(await resolve2(this.config.headers), {
|
|
5401
|
+
"anthropic-beta": "skills-2025-10-02"
|
|
5402
|
+
});
|
|
5403
|
+
}
|
|
5404
|
+
async fetchVersionMetadata({
|
|
5405
|
+
skillId,
|
|
5406
|
+
version,
|
|
5407
|
+
headers
|
|
5408
|
+
}) {
|
|
5409
|
+
const { value: versionResponse } = await getFromApi({
|
|
5410
|
+
url: `${this.config.baseURL}/skills/${skillId}/versions/${version}`,
|
|
5411
|
+
headers,
|
|
5412
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5413
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5414
|
+
anthropicSkillVersionResponseSchema
|
|
5415
|
+
),
|
|
5416
|
+
fetch: this.config.fetch
|
|
5417
|
+
});
|
|
5418
|
+
return {
|
|
5419
|
+
...versionResponse.name != null ? { name: versionResponse.name } : {},
|
|
5420
|
+
...versionResponse.description != null ? { description: versionResponse.description } : {}
|
|
5421
|
+
};
|
|
5422
|
+
}
|
|
5423
|
+
async upload(params) {
|
|
5424
|
+
var _a, _b;
|
|
5425
|
+
const warnings = [];
|
|
5426
|
+
const formData = new FormData();
|
|
5427
|
+
if (params.displayTitle != null) {
|
|
5428
|
+
formData.append("display_title", params.displayTitle);
|
|
5429
|
+
}
|
|
5430
|
+
for (const file of params.files) {
|
|
5431
|
+
const content = typeof file.content === "string" ? convertBase64ToUint8Array3(file.content) : file.content;
|
|
5432
|
+
formData.append("files[]", new Blob([content]), file.path);
|
|
5433
|
+
}
|
|
5434
|
+
const headers = await this.getHeaders();
|
|
5435
|
+
const { value: response } = await postFormDataToApi2({
|
|
5436
|
+
url: `${this.config.baseURL}/skills`,
|
|
5437
|
+
headers,
|
|
5438
|
+
formData,
|
|
5439
|
+
failedResponseHandler: anthropicFailedResponseHandler,
|
|
5440
|
+
successfulResponseHandler: createJsonResponseHandler3(
|
|
5441
|
+
anthropicSkillResponseSchema
|
|
5442
|
+
),
|
|
5443
|
+
fetch: this.config.fetch
|
|
5444
|
+
});
|
|
5445
|
+
const versionMetadata = response.latest_version != null ? await this.fetchVersionMetadata({
|
|
5446
|
+
skillId: response.id,
|
|
5447
|
+
version: response.latest_version,
|
|
5448
|
+
headers
|
|
5449
|
+
}) : {};
|
|
5450
|
+
const name = (_a = versionMetadata.name) != null ? _a : response.name;
|
|
5451
|
+
const description = (_b = versionMetadata.description) != null ? _b : response.description;
|
|
5452
|
+
return {
|
|
5453
|
+
providerReference: { anthropic: response.id },
|
|
5454
|
+
...response.display_title != null ? { displayTitle: response.display_title } : {},
|
|
5455
|
+
...name != null ? { name } : {},
|
|
5456
|
+
...description != null ? { description } : {},
|
|
5457
|
+
...response.latest_version != null ? { latestVersion: response.latest_version } : {},
|
|
5458
|
+
providerMetadata: {
|
|
5459
|
+
anthropic: {
|
|
5460
|
+
...response.source != null ? { source: response.source } : {},
|
|
5461
|
+
...response.created_at != null ? { createdAt: response.created_at } : {},
|
|
5462
|
+
...response.updated_at != null ? { updatedAt: response.updated_at } : {}
|
|
5463
|
+
}
|
|
5464
|
+
},
|
|
5465
|
+
warnings
|
|
5466
|
+
};
|
|
5467
|
+
}
|
|
5468
|
+
};
|
|
5469
|
+
|
|
5330
5470
|
// src/version.ts
|
|
5331
|
-
var VERSION = true ? "4.0.0-beta.
|
|
5471
|
+
var VERSION = true ? "4.0.0-beta.21" : "0.0.0-test";
|
|
5332
5472
|
|
|
5333
5473
|
// src/anthropic-provider.ts
|
|
5334
5474
|
function createAnthropic(options = {}) {
|
|
@@ -5377,6 +5517,12 @@ function createAnthropic(options = {}) {
|
|
|
5377
5517
|
})
|
|
5378
5518
|
});
|
|
5379
5519
|
};
|
|
5520
|
+
const createSkills = () => new AnthropicSkills({
|
|
5521
|
+
provider: `${providerName.replace(".messages", "")}.skills`,
|
|
5522
|
+
baseURL,
|
|
5523
|
+
headers: getHeaders,
|
|
5524
|
+
fetch: options.fetch
|
|
5525
|
+
});
|
|
5380
5526
|
const provider = function(modelId) {
|
|
5381
5527
|
if (new.target) {
|
|
5382
5528
|
throw new Error(
|
|
@@ -5402,6 +5548,7 @@ function createAnthropic(options = {}) {
|
|
|
5402
5548
|
headers: getHeaders,
|
|
5403
5549
|
fetch: options.fetch
|
|
5404
5550
|
});
|
|
5551
|
+
provider.skills = createSkills;
|
|
5405
5552
|
provider.tools = anthropicTools;
|
|
5406
5553
|
return provider;
|
|
5407
5554
|
}
|