@aigne/anthropic 0.11.0 → 0.11.2

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.2](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.1...anthropic-v0.11.2) (2025-08-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **cli:** log only once in loadAIGNE ([#357](https://github.com/AIGNE-io/aigne-framework/issues/357)) ([6e6d968](https://github.com/AIGNE-io/aigne-framework/commit/6e6d96814fbc87f210522ae16daf94c1f84f311a))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/core bumped to 1.50.0
16
+ * devDependencies
17
+ * @aigne/test-utils bumped to 0.5.28
18
+
19
+ ## [0.11.1](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.0...anthropic-v0.11.1) (2025-08-12)
20
+
21
+
22
+ ### Dependencies
23
+
24
+ * The following workspace dependencies were updated
25
+ * dependencies
26
+ * @aigne/core bumped to 1.49.1
27
+ * devDependencies
28
+ * @aigne/test-utils bumped to 0.5.27
29
+
3
30
  ## [0.11.0](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.10.13...anthropic-v0.11.0) (2025-08-12)
4
31
 
5
32
 
@@ -106,6 +106,10 @@ export declare class AnthropicChatModel extends ChatModel {
106
106
  protected _client?: Anthropic;
107
107
  get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
+ getCredential(): {
110
+ apiKey: string | undefined;
111
+ model: string;
112
+ };
109
113
  private getMaxTokens;
110
114
  /**
111
115
  * Process the input using Claude's chat model
@@ -63,7 +63,7 @@ class AnthropicChatModel extends core_1.ChatModel {
63
63
  */
64
64
  _client;
65
65
  get client() {
66
- const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
66
+ const { apiKey } = this.getCredential();
67
67
  if (!apiKey)
68
68
  throw new Error("AnthropicChatModel requires an API key. Please provide it via `options.apiKey`, or set the `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` environment variable");
69
69
  this._client ??= new sdk_1.default({
@@ -76,6 +76,13 @@ class AnthropicChatModel extends core_1.ChatModel {
76
76
  get modelOptions() {
77
77
  return this.options?.modelOptions;
78
78
  }
79
+ getCredential() {
80
+ const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
81
+ return {
82
+ apiKey,
83
+ model: this.options?.model || CHAT_MODEL_CLAUDE_DEFAULT_MODEL,
84
+ };
85
+ }
79
86
  getMaxTokens(model) {
80
87
  const matchers = [
81
88
  [/claude-opus-4-/, 32000],
@@ -101,7 +108,7 @@ class AnthropicChatModel extends core_1.ChatModel {
101
108
  }
102
109
  ajv = new ajv_1.Ajv();
103
110
  async _process(input) {
104
- const model = this.options?.model || CHAT_MODEL_CLAUDE_DEFAULT_MODEL;
111
+ const { model } = this.getCredential();
105
112
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
106
113
  this.modelOptions?.parallelToolCalls === false;
107
114
  const body = {
@@ -106,6 +106,10 @@ export declare class AnthropicChatModel extends ChatModel {
106
106
  protected _client?: Anthropic;
107
107
  get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
+ getCredential(): {
110
+ apiKey: string | undefined;
111
+ model: string;
112
+ };
109
113
  private getMaxTokens;
110
114
  /**
111
115
  * Process the input using Claude's chat model
@@ -106,6 +106,10 @@ export declare class AnthropicChatModel extends ChatModel {
106
106
  protected _client?: Anthropic;
107
107
  get client(): Anthropic;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
+ getCredential(): {
110
+ apiKey: string | undefined;
111
+ model: string;
112
+ };
109
113
  private getMaxTokens;
110
114
  /**
111
115
  * Process the input using Claude's chat model
@@ -57,7 +57,7 @@ export class AnthropicChatModel extends ChatModel {
57
57
  */
58
58
  _client;
59
59
  get client() {
60
- const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
60
+ const { apiKey } = this.getCredential();
61
61
  if (!apiKey)
62
62
  throw new Error("AnthropicChatModel requires an API key. Please provide it via `options.apiKey`, or set the `ANTHROPIC_API_KEY` or `CLAUDE_API_KEY` environment variable");
63
63
  this._client ??= new Anthropic({
@@ -70,6 +70,13 @@ export class AnthropicChatModel extends ChatModel {
70
70
  get modelOptions() {
71
71
  return this.options?.modelOptions;
72
72
  }
73
+ getCredential() {
74
+ const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
75
+ return {
76
+ apiKey,
77
+ model: this.options?.model || CHAT_MODEL_CLAUDE_DEFAULT_MODEL,
78
+ };
79
+ }
73
80
  getMaxTokens(model) {
74
81
  const matchers = [
75
82
  [/claude-opus-4-/, 32000],
@@ -95,7 +102,7 @@ export class AnthropicChatModel extends ChatModel {
95
102
  }
96
103
  ajv = new Ajv();
97
104
  async _process(input) {
98
- const model = this.options?.model || CHAT_MODEL_CLAUDE_DEFAULT_MODEL;
105
+ const { model } = this.getCredential();
99
106
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
100
107
  this.modelOptions?.parallelToolCalls === false;
101
108
  const body = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/anthropic",
3
- "version": "0.11.0",
3
+ "version": "0.11.2",
4
4
  "description": "AIGNE Anthropic SDK for integrating with Claude AI models",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -38,7 +38,7 @@
38
38
  "@anthropic-ai/sdk": "^0.56.0",
39
39
  "ajv": "^8.17.1",
40
40
  "zod": "^3.25.67",
41
- "@aigne/core": "^1.49.0"
41
+ "@aigne/core": "^1.50.0"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/bun": "^1.2.18",
@@ -46,7 +46,7 @@
46
46
  "npm-run-all": "^4.1.5",
47
47
  "rimraf": "^6.0.1",
48
48
  "typescript": "^5.8.3",
49
- "@aigne/test-utils": "^0.5.26"
49
+ "@aigne/test-utils": "^0.5.28"
50
50
  },
51
51
  "scripts": {
52
52
  "lint": "tsc --noEmit",