@ank1015/agents-provider-anthropic-spec 0.1.0

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 ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ All notable changes to `@ank1015/agents-provider-anthropic-spec` will be documented in this file.
4
+
5
+ ## 0.1.0 - Initial Release
6
+
7
+ - Added direct-value API key secret references to the provider config schema.
8
+ - Added the `anthropic` provider identifier and config schema.
9
+ - Added Anthropic native message and provider option type augmentation for `@ank1015/agents-contracts`.
10
+ - Added a static Anthropic model catalog with literal model-id narrowing.
11
+ - Added `getAnthropicModel` for catalog lookup.
12
+ - Added grouped package exports for `config` and `models`.
13
+ - Added unit and type-contract coverage for config validation, catalog shape, lookup behavior, and model-id narrowing.
package/README.md ADDED
@@ -0,0 +1,105 @@
1
+ # @ank1015/agents-provider-anthropic-spec
2
+
3
+ Static Anthropic provider metadata for the `@ank1015/agents` packages.
4
+
5
+ This package contains no live Anthropic client. It provides provider identity, config types, provider-specific type augmentation, and a static model catalog that other packages can consume without depending on the Anthropic runtime adapter.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ pnpm add @ank1015/agents-provider-anthropic-spec
11
+ ```
12
+
13
+ ## What This Package Provides
14
+
15
+ - `ANTHROPIC_PROVIDER` provider id.
16
+ - `anthropicProviderConfigSchema` for provider config validation.
17
+ - `AnthropicProviderOptions` based on Anthropic Messages API request options.
18
+ - `AnthropicNativeMessage` based on Anthropic SDK message responses.
19
+ - `ANTHROPIC_MODELS` static model catalog.
20
+ - `AnthropicModelId` literal union derived from the catalog.
21
+ - Contract augmentation for `@ank1015/agents-contracts`.
22
+
23
+ ## Import Paths
24
+
25
+ ```ts
26
+ import {
27
+ ANTHROPIC_MODELS,
28
+ ANTHROPIC_PROVIDER,
29
+ getAnthropicModel,
30
+ } from '@ank1015/agents-provider-anthropic-spec';
31
+
32
+ import { anthropicProviderConfigSchema } from '@ank1015/agents-provider-anthropic-spec/config';
33
+ import type { AnthropicModelId } from '@ank1015/agents-provider-anthropic-spec/models';
34
+ ```
35
+
36
+ ## Provider Config
37
+
38
+ Anthropic provider config uses a secret reference for the API key. Environment references keep keys out of config:
39
+
40
+ ```ts
41
+ import {
42
+ ANTHROPIC_PROVIDER,
43
+ anthropicProviderConfigSchema,
44
+ } from '@ank1015/agents-provider-anthropic-spec';
45
+
46
+ const config = anthropicProviderConfigSchema.parse({
47
+ provider: ANTHROPIC_PROVIDER,
48
+ apiKey: {
49
+ type: 'env',
50
+ name: 'ANTHROPIC_API_KEY',
51
+ },
52
+ });
53
+ ```
54
+
55
+ The live adapter resolves the referenced environment variable when it creates the Anthropic SDK client. Callers that already have a key from another secret source can pass a direct value reference:
56
+
57
+ ```ts
58
+ const config = anthropicProviderConfigSchema.parse({
59
+ provider: ANTHROPIC_PROVIDER,
60
+ apiKey: {
61
+ type: 'value',
62
+ value: anthropicKey,
63
+ },
64
+ });
65
+ ```
66
+
67
+ ## Model Catalog
68
+
69
+ `ANTHROPIC_MODELS` is a static snapshot used for model lookup, UI metadata, defaults, and compile-time model-id narrowing:
70
+
71
+ ```ts
72
+ import {
73
+ ANTHROPIC_MODELS,
74
+ getAnthropicModel,
75
+ } from '@ank1015/agents-provider-anthropic-spec';
76
+
77
+ const model = getAnthropicModel('claude-sonnet-4-6');
78
+ ```
79
+
80
+ The catalog currently includes:
81
+
82
+ - `claude-opus-4-8`
83
+ - `claude-sonnet-4-6`
84
+ - `claude-haiku-4-5`
85
+
86
+ Static model metadata can age as providers release or retire models. Treat pricing, context windows, and max-token metadata as package-versioned snapshot data.
87
+
88
+ ## Type Augmentation
89
+
90
+ Importing this package augments `@ank1015/agents-contracts` so Anthropic requests can narrow provider-specific fields:
91
+
92
+ ```ts
93
+ import type { LLMRequest } from '@ank1015/agents-contracts';
94
+ import type { AnthropicProvider } from '@ank1015/agents-provider-anthropic-spec';
95
+
96
+ const request: LLMRequest<AnthropicProvider> = {
97
+ provider: 'anthropic',
98
+ modelId: 'claude-sonnet-4-6',
99
+ messages: [],
100
+ };
101
+ ```
102
+
103
+ ## Versioning
104
+
105
+ This package is currently `0.1.0`. Until `1.0.0`, model metadata and provider option types may evolve as the surrounding agent runtime settles.
@@ -0,0 +1,39 @@
1
+ import type { Message, MessageCreateParamsBase } from '@anthropic-ai/sdk/resources/messages.js';
2
+ import { z } from 'zod';
3
+ export declare const ANTHROPIC_PROVIDER: "anthropic";
4
+ export type AnthropicProvider = typeof ANTHROPIC_PROVIDER;
5
+ export type AnthropicNativeMessage = Message;
6
+ export declare const anthropicProviderConfigSchema: z.ZodObject<{
7
+ baseUrl: z.ZodOptional<z.ZodString>;
8
+ headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
+ provider: z.ZodLiteral<"anthropic">;
10
+ apiKey: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
+ type: z.ZodLiteral<"env">;
12
+ name: z.ZodString;
13
+ }, z.core.$strict>, z.ZodObject<{
14
+ type: z.ZodLiteral<"value">;
15
+ value: z.ZodString;
16
+ }, z.core.$strict>], "type">;
17
+ }, z.core.$strict>;
18
+ export type AnthropicProviderConfig = z.infer<typeof anthropicProviderConfigSchema>;
19
+ /**
20
+ * Per-call Anthropic request options.
21
+ * Model, messages, streaming, system prompt, and tools are owned by the generic LLM layer.
22
+ * `max_tokens` is required by the Anthropic API but absent from the generic request, so it
23
+ * stays here as an optional override; the adapter defaults it to the model's `maxTokens`.
24
+ */
25
+ export type AnthropicProviderOptions = Omit<MessageCreateParamsBase, 'model' | 'messages' | 'stream' | 'system' | 'tools' | 'max_tokens'> & {
26
+ max_tokens?: number;
27
+ };
28
+ declare module '@ank1015/agents-contracts' {
29
+ interface ProviderNativeMessageMap {
30
+ anthropic: AnthropicNativeMessage;
31
+ }
32
+ interface ProviderOptionsMap {
33
+ anthropic: AnthropicProviderOptions;
34
+ }
35
+ interface ProviderConfigMap {
36
+ anthropic: AnthropicProviderConfig;
37
+ }
38
+ }
39
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,uBAAuB,EACxB,MAAM,yCAAyC,CAAC;AACjD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,eAAO,MAAM,kBAAkB,EAAG,WAAoB,CAAC;AAEvD,MAAM,MAAM,iBAAiB,GAAG,OAAO,kBAAkB,CAAC;AAE1D,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC;AAE7C,eAAO,MAAM,6BAA6B;;;;;;;;;;;kBAK/B,CAAC;AAEZ,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAC;AAEpF;;;;;GAKG;AACH,MAAM,MAAM,wBAAwB,GAAG,IAAI,CACzC,uBAAuB,EACvB,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CACpE,GAAG;IACF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,OAAO,QAAQ,2BAA2B,CAAC;IACzC,UAAU,wBAAwB;QAChC,SAAS,EAAE,sBAAsB,CAAC;KACnC;IAED,UAAU,kBAAkB;QAC1B,SAAS,EAAE,wBAAwB,CAAC;KACrC;IAED,UAAU,iBAAiB;QACzB,SAAS,EAAE,uBAAuB,CAAC;KACpC;CACF"}
package/dist/config.js ADDED
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ import { baseProviderConfigSchema, secretRefSchema, } from '@ank1015/agents-contracts';
3
+ export const ANTHROPIC_PROVIDER = 'anthropic';
4
+ export const anthropicProviderConfigSchema = baseProviderConfigSchema
5
+ .extend({
6
+ provider: z.literal(ANTHROPIC_PROVIDER),
7
+ apiKey: secretRefSchema,
8
+ })
9
+ .strict();
10
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,wBAAwB,EACxB,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAEnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAoB,CAAC;AAMvD,MAAM,CAAC,MAAM,6BAA6B,GAAG,wBAAwB;KAClE,MAAM,CAAC;IACN,QAAQ,EAAE,CAAC,CAAC,OAAO,CAAC,kBAAkB,CAAC;IACvC,MAAM,EAAE,eAAe;CACxB,CAAC;KACD,MAAM,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './models.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from './config.js';
2
+ export * from './models.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,56 @@
1
+ export declare const ANTHROPIC_MODEL_AVATAR = "https://avatars.githubusercontent.com/u/81847?s=64&v=4";
2
+ export declare const ANTHROPIC_MODELS: readonly [{
3
+ readonly id: "claude-opus-4-8";
4
+ readonly name: "Claude Opus 4.8";
5
+ readonly avatar: "https://avatars.githubusercontent.com/u/81847?s=64&v=4";
6
+ readonly provider: "anthropic";
7
+ readonly reasoning: true;
8
+ readonly input: ["text", "image"];
9
+ readonly cost: {
10
+ readonly input: 5;
11
+ readonly output: 25;
12
+ readonly cacheRead: 0.5;
13
+ readonly cacheWrite: 6.25;
14
+ };
15
+ readonly contextWindow: 1000000;
16
+ readonly maxTokens: 128000;
17
+ }, {
18
+ readonly id: "claude-sonnet-4-6";
19
+ readonly name: "Claude Sonnet 4.6";
20
+ readonly avatar: "https://avatars.githubusercontent.com/u/81847?s=64&v=4";
21
+ readonly provider: "anthropic";
22
+ readonly reasoning: true;
23
+ readonly input: ["text", "image"];
24
+ readonly cost: {
25
+ readonly input: 3;
26
+ readonly output: 15;
27
+ readonly cacheRead: 0.3;
28
+ readonly cacheWrite: 3.75;
29
+ };
30
+ readonly contextWindow: 1000000;
31
+ readonly maxTokens: 64000;
32
+ }, {
33
+ readonly id: "claude-haiku-4-5";
34
+ readonly name: "Claude Haiku 4.5";
35
+ readonly avatar: "https://avatars.githubusercontent.com/u/81847?s=64&v=4";
36
+ readonly provider: "anthropic";
37
+ readonly reasoning: true;
38
+ readonly input: ["text", "image"];
39
+ readonly cost: {
40
+ readonly input: 1;
41
+ readonly output: 5;
42
+ readonly cacheRead: 0.1;
43
+ readonly cacheWrite: 1.25;
44
+ };
45
+ readonly contextWindow: 200000;
46
+ readonly maxTokens: 64000;
47
+ }];
48
+ export type AnthropicModel = (typeof ANTHROPIC_MODELS)[number];
49
+ export type AnthropicModelId = AnthropicModel['id'];
50
+ export declare function getAnthropicModel(id: string): AnthropicModel | undefined;
51
+ declare module '@ank1015/agents-contracts' {
52
+ interface ProviderModelIdMap {
53
+ anthropic: AnthropicModelId;
54
+ }
55
+ }
56
+ //# sourceMappingURL=models.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,2DAA2D,CAAC;AAE/F,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiD2B,CAAC;AAEzD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,MAAM,MAAM,gBAAgB,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;AAMpD,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAExE;AAED,OAAO,QAAQ,2BAA2B,CAAC;IACzC,UAAU,kBAAkB;QAC1B,SAAS,EAAE,gBAAgB,CAAC;KAC7B;CACF"}
package/dist/models.js ADDED
@@ -0,0 +1,56 @@
1
+ import { ANTHROPIC_PROVIDER } from './config.js';
2
+ export const ANTHROPIC_MODEL_AVATAR = 'https://avatars.githubusercontent.com/u/81847?s=64&v=4';
3
+ export const ANTHROPIC_MODELS = [
4
+ {
5
+ id: 'claude-opus-4-8',
6
+ name: 'Claude Opus 4.8',
7
+ avatar: ANTHROPIC_MODEL_AVATAR,
8
+ provider: ANTHROPIC_PROVIDER,
9
+ reasoning: true,
10
+ input: ['text', 'image'],
11
+ cost: {
12
+ input: 5,
13
+ output: 25,
14
+ cacheRead: 0.5,
15
+ cacheWrite: 6.25,
16
+ },
17
+ contextWindow: 1000000,
18
+ maxTokens: 128000,
19
+ },
20
+ {
21
+ id: 'claude-sonnet-4-6',
22
+ name: 'Claude Sonnet 4.6',
23
+ avatar: ANTHROPIC_MODEL_AVATAR,
24
+ provider: ANTHROPIC_PROVIDER,
25
+ reasoning: true,
26
+ input: ['text', 'image'],
27
+ cost: {
28
+ input: 3,
29
+ output: 15,
30
+ cacheRead: 0.3,
31
+ cacheWrite: 3.75,
32
+ },
33
+ contextWindow: 1000000,
34
+ maxTokens: 64000,
35
+ },
36
+ {
37
+ id: 'claude-haiku-4-5',
38
+ name: 'Claude Haiku 4.5',
39
+ avatar: ANTHROPIC_MODEL_AVATAR,
40
+ provider: ANTHROPIC_PROVIDER,
41
+ reasoning: true,
42
+ input: ['text', 'image'],
43
+ cost: {
44
+ input: 1,
45
+ output: 5,
46
+ cacheRead: 0.1,
47
+ cacheWrite: 1.25,
48
+ },
49
+ contextWindow: 200000,
50
+ maxTokens: 64000,
51
+ },
52
+ ];
53
+ export function getAnthropicModel(id) {
54
+ return ANTHROPIC_MODELS.find((model) => model.id === id);
55
+ }
56
+ //# sourceMappingURL=models.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,CAAC,MAAM,sBAAsB,GAAG,wDAAwD,CAAC;AAE/F,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B;QACE,EAAE,EAAE,iBAAiB;QACrB,IAAI,EAAE,iBAAiB;QACvB,MAAM,EAAE,sBAAsB;QAC9B,QAAQ,EAAE,kBAAkB;QAC5B,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QACxB,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,IAAI;SACjB;QACD,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,MAAM;KAClB;IACD;QACE,EAAE,EAAE,mBAAmB;QACvB,IAAI,EAAE,mBAAmB;QACzB,MAAM,EAAE,sBAAsB;QAC9B,QAAQ,EAAE,kBAAkB;QAC5B,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QACxB,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,EAAE;YACV,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,IAAI;SACjB;QACD,aAAa,EAAE,OAAO;QACtB,SAAS,EAAE,KAAK;KACjB;IACD;QACE,EAAE,EAAE,kBAAkB;QACtB,IAAI,EAAE,kBAAkB;QACxB,MAAM,EAAE,sBAAsB;QAC9B,QAAQ,EAAE,kBAAkB;QAC5B,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,CAAC,MAAM,EAAE,OAAO,CAAC;QACxB,IAAI,EAAE;YACJ,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,SAAS,EAAE,GAAG;YACd,UAAU,EAAE,IAAI;SACjB;QACD,aAAa,EAAE,MAAM;QACrB,SAAS,EAAE,KAAK;KACjB;CACqD,CAAC;AAUzD,MAAM,UAAU,iBAAiB,CAAC,EAAU;IAC1C,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;AAC3D,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@ank1015/agents-provider-anthropic-spec",
3
+ "version": "0.1.0",
4
+ "description": "Anthropic provider static spec (model catalog, config + per-call option types) for @ank1015/agents.",
5
+ "keywords": [
6
+ "agents",
7
+ "anthropic",
8
+ "claude",
9
+ "llm",
10
+ "typescript"
11
+ ],
12
+ "license": "UNLICENSED",
13
+ "type": "module",
14
+ "sideEffects": false,
15
+ "main": "./dist/index.js",
16
+ "types": "./dist/index.d.ts",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/ank1015/agent.git",
20
+ "directory": "packages/provider-anthropic-spec"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/ank1015/agent/issues"
24
+ },
25
+ "homepage": "https://github.com/ank1015/agent#readme",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js"
30
+ },
31
+ "./config": {
32
+ "types": "./dist/config.d.ts",
33
+ "import": "./dist/config.js"
34
+ },
35
+ "./models": {
36
+ "types": "./dist/models.d.ts",
37
+ "import": "./dist/models.js"
38
+ }
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "files": [
44
+ "dist",
45
+ "README.md",
46
+ "CHANGELOG.md"
47
+ ],
48
+ "scripts": {
49
+ "prepack": "tsc -b",
50
+ "build": "tsc -b",
51
+ "check": "tsc -b --pretty false",
52
+ "test": "vitest run && tsc --noEmit --strict --skipLibCheck --module NodeNext --moduleResolution NodeNext --target ES2022 --ignoreConfig tests/*.test.ts",
53
+ "clean": "rm -rf dist ../../.tsbuildinfo/provider-anthropic-spec.tsbuildinfo"
54
+ },
55
+ "dependencies": {
56
+ "@ank1015/agents-contracts": "^0.1.1",
57
+ "@anthropic-ai/sdk": "^0.104.2",
58
+ "zod": "^4.4.3"
59
+ },
60
+ "devDependencies": {
61
+ "vitest": "^4.1.9"
62
+ }
63
+ }