@aigne/anthropic 0.11.2 → 0.11.3

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,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.11.3](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.2...anthropic-v0.11.3) (2025-08-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **core:** make getCredential async for aigne-hub mount point retrieval ([#372](https://github.com/AIGNE-io/aigne-framework/issues/372)) ([34ce7a6](https://github.com/AIGNE-io/aigne-framework/commit/34ce7a645fa83994d3dfe0f29ca70098cfecac9c))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @aigne/core bumped to 1.50.1
16
+ * devDependencies
17
+ * @aigne/test-utils bumped to 0.5.29
18
+
3
19
  ## [0.11.2](https://github.com/AIGNE-io/aigne-framework/compare/anthropic-v0.11.1...anthropic-v0.11.2) (2025-08-14)
4
20
 
5
21
 
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- get client(): Anthropic;
107
+ client(): Promise<Anthropic>;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): {
109
+ getCredential(): Promise<{
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- };
112
+ }>;
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -62,8 +62,8 @@ class AnthropicChatModel extends core_1.ChatModel {
62
62
  * @hidden
63
63
  */
64
64
  _client;
65
- get client() {
66
- const { apiKey } = this.getCredential();
65
+ async client() {
66
+ const { apiKey } = await 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,7 +76,7 @@ class AnthropicChatModel extends core_1.ChatModel {
76
76
  get modelOptions() {
77
77
  return this.options?.modelOptions;
78
78
  }
79
- getCredential() {
79
+ async getCredential() {
80
80
  const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
81
81
  return {
82
82
  apiKey,
@@ -108,7 +108,7 @@ class AnthropicChatModel extends core_1.ChatModel {
108
108
  }
109
109
  ajv = new ajv_1.Ajv();
110
110
  async _process(input) {
111
- const { model } = this.getCredential();
111
+ const { model } = await this.getCredential();
112
112
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
113
113
  this.modelOptions?.parallelToolCalls === false;
114
114
  const body = {
@@ -125,7 +125,8 @@ class AnthropicChatModel extends core_1.ChatModel {
125
125
  if (!input.tools?.length && input.responseFormat?.type === "json_schema") {
126
126
  return this.requestStructuredOutput(body, input.responseFormat);
127
127
  }
128
- const stream = this.client.messages.stream({
128
+ const client = await this.client();
129
+ const stream = client.messages.stream({
129
130
  ...body,
130
131
  stream: true,
131
132
  });
@@ -230,7 +231,8 @@ class AnthropicChatModel extends core_1.ChatModel {
230
231
  if (responseFormat?.type !== "json_schema") {
231
232
  throw new Error("Expected json_schema response format");
232
233
  }
233
- const result = await this.client.messages.create({
234
+ const client = await this.client();
235
+ const result = await client.messages.create({
234
236
  ...body,
235
237
  tools: [
236
238
  {
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- get client(): Anthropic;
107
+ client(): Promise<Anthropic>;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): {
109
+ getCredential(): Promise<{
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- };
112
+ }>;
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -104,12 +104,12 @@ export declare class AnthropicChatModel extends ChatModel {
104
104
  * @hidden
105
105
  */
106
106
  protected _client?: Anthropic;
107
- get client(): Anthropic;
107
+ client(): Promise<Anthropic>;
108
108
  get modelOptions(): ChatModelOptions | undefined;
109
- getCredential(): {
109
+ getCredential(): Promise<{
110
110
  apiKey: string | undefined;
111
111
  model: string;
112
- };
112
+ }>;
113
113
  private getMaxTokens;
114
114
  /**
115
115
  * Process the input using Claude's chat model
@@ -56,8 +56,8 @@ export class AnthropicChatModel extends ChatModel {
56
56
  * @hidden
57
57
  */
58
58
  _client;
59
- get client() {
60
- const { apiKey } = this.getCredential();
59
+ async client() {
60
+ const { apiKey } = await 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,7 +70,7 @@ export class AnthropicChatModel extends ChatModel {
70
70
  get modelOptions() {
71
71
  return this.options?.modelOptions;
72
72
  }
73
- getCredential() {
73
+ async getCredential() {
74
74
  const apiKey = this.options?.apiKey || process.env[this.apiKeyEnvName] || process.env.CLAUDE_API_KEY;
75
75
  return {
76
76
  apiKey,
@@ -102,7 +102,7 @@ export class AnthropicChatModel extends ChatModel {
102
102
  }
103
103
  ajv = new Ajv();
104
104
  async _process(input) {
105
- const { model } = this.getCredential();
105
+ const { model } = await this.getCredential();
106
106
  const disableParallelToolUse = input.modelOptions?.parallelToolCalls === false ||
107
107
  this.modelOptions?.parallelToolCalls === false;
108
108
  const body = {
@@ -119,7 +119,8 @@ export class AnthropicChatModel extends ChatModel {
119
119
  if (!input.tools?.length && input.responseFormat?.type === "json_schema") {
120
120
  return this.requestStructuredOutput(body, input.responseFormat);
121
121
  }
122
- const stream = this.client.messages.stream({
122
+ const client = await this.client();
123
+ const stream = client.messages.stream({
123
124
  ...body,
124
125
  stream: true,
125
126
  });
@@ -224,7 +225,8 @@ export class AnthropicChatModel extends ChatModel {
224
225
  if (responseFormat?.type !== "json_schema") {
225
226
  throw new Error("Expected json_schema response format");
226
227
  }
227
- const result = await this.client.messages.create({
228
+ const client = await this.client();
229
+ const result = await client.messages.create({
228
230
  ...body,
229
231
  tools: [
230
232
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aigne/anthropic",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
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.50.0"
41
+ "@aigne/core": "^1.50.1"
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.28"
49
+ "@aigne/test-utils": "^0.5.29"
50
50
  },
51
51
  "scripts": {
52
52
  "lint": "tsc --noEmit",