@rulvar/anthropic 1.15.0 → 1.16.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/dist/index.d.ts CHANGED
@@ -91,7 +91,13 @@ interface AnthropicAdapterOptions {
91
91
  * autoretries are disabled (max_retries 0): the core owns retries and
92
92
  * wall-clock. With no auth option at all, the underlying SDK resolves
93
93
  * credentials itself: `ANTHROPIC_API_KEY`, then bearer
94
- * `ANTHROPIC_AUTH_TOKEN`, then its config-file credential chain.
94
+ * `ANTHROPIC_AUTH_TOKEN`, then its config-file credential chain. When
95
+ * `sdkOptions` carries structured auth (`credentials`, `config`, or
96
+ * `profile`) and no `apiKey`/`authToken` is set anywhere, ambient
97
+ * environment credentials are suppressed (explicit `apiKey: null,
98
+ * authToken: null` are passed to the SDK), so the configured provider
99
+ * is the one that authenticates; the SDK itself would otherwise let an
100
+ * environment `ANTHROPIC_API_KEY` win over the provider.
95
101
  */
96
102
  declare function anthropic(options?: AnthropicAdapterOptions): ProviderAdapter;
97
103
  //#endregion
package/dist/index.js CHANGED
@@ -675,8 +675,13 @@ function resolveAnthropicClient(options) {
675
675
  const sdkOptions = options.sdkOptions ?? {};
676
676
  if (options.apiKey !== void 0 && sdkOptions.apiKey !== void 0) throw new ConfigError("anthropic(): 'apiKey' and 'sdkOptions.apiKey' are both set; pick one place");
677
677
  if (options.baseURL !== void 0 && sdkOptions.baseURL !== void 0) throw new ConfigError("anthropic(): 'baseURL' and 'sdkOptions.baseURL' are both set; pick one place");
678
+ const suppressAmbientEnv = (sdkOptions.credentials != null || sdkOptions.config != null || sdkOptions.profile != null) && options.apiKey === void 0 && sdkOptions.apiKey === void 0 && sdkOptions.authToken === void 0;
678
679
  return new Anthropic({
679
680
  ...sdkOptions,
681
+ ...suppressAmbientEnv ? {
682
+ apiKey: null,
683
+ authToken: null
684
+ } : {},
680
685
  ...options.apiKey === void 0 ? {} : { apiKey: options.apiKey },
681
686
  ...options.baseURL === void 0 ? {} : { baseURL: options.baseURL },
682
687
  maxRetries: 0
@@ -687,7 +692,13 @@ function resolveAnthropicClient(options) {
687
692
  * autoretries are disabled (max_retries 0): the core owns retries and
688
693
  * wall-clock. With no auth option at all, the underlying SDK resolves
689
694
  * credentials itself: `ANTHROPIC_API_KEY`, then bearer
690
- * `ANTHROPIC_AUTH_TOKEN`, then its config-file credential chain.
695
+ * `ANTHROPIC_AUTH_TOKEN`, then its config-file credential chain. When
696
+ * `sdkOptions` carries structured auth (`credentials`, `config`, or
697
+ * `profile`) and no `apiKey`/`authToken` is set anywhere, ambient
698
+ * environment credentials are suppressed (explicit `apiKey: null,
699
+ * authToken: null` are passed to the SDK), so the configured provider
700
+ * is the one that authenticates; the SDK itself would otherwise let an
701
+ * environment `ANTHROPIC_API_KEY` win over the provider.
691
702
  */
692
703
  function anthropic(options = {}) {
693
704
  const client = resolveAnthropicClient(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rulvar/anthropic",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Rulvar first-class provider adapter over @anthropic-ai/sdk.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -23,13 +23,13 @@
23
23
  },
24
24
  "dependencies": {
25
25
  "@anthropic-ai/sdk": "^0.110.0",
26
- "@rulvar/core": "1.15.0"
26
+ "@rulvar/core": "1.16.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/node": "^22.20.0",
30
30
  "tsdown": "^0.22.3",
31
31
  "typescript": "~6.0.3",
32
- "@rulvar/testing": "1.15.0"
32
+ "@rulvar/testing": "1.16.0"
33
33
  },
34
34
  "repository": {
35
35
  "type": "git",