@anthropic-ai/aws-sdk 0.2.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/.github/logo.svg +3 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE +8 -0
- package/README.md +0 -0
- package/client.d.mts +109 -0
- package/client.d.mts.map +1 -0
- package/client.d.ts +109 -0
- package/client.d.ts.map +1 -0
- package/client.js +158 -0
- package/client.js.map +1 -0
- package/client.mjs +120 -0
- package/client.mjs.map +1 -0
- package/core/auth.d.mts +15 -0
- package/core/auth.d.mts.map +1 -0
- package/core/auth.d.ts +15 -0
- package/core/auth.d.ts.map +1 -0
- package/core/auth.js +113 -0
- package/core/auth.js.map +1 -0
- package/core/auth.mjs +73 -0
- package/core/auth.mjs.map +1 -0
- package/core/error.d.mts +2 -0
- package/core/error.d.mts.map +1 -0
- package/core/error.d.ts +2 -0
- package/core/error.d.ts.map +1 -0
- package/core/error.js +18 -0
- package/core/error.js.map +1 -0
- package/core/error.mjs +2 -0
- package/core/error.mjs.map +1 -0
- package/core/pagination.d.mts +2 -0
- package/core/pagination.d.mts.map +1 -0
- package/core/pagination.d.ts +2 -0
- package/core/pagination.d.ts.map +1 -0
- package/core/pagination.js +18 -0
- package/core/pagination.js.map +1 -0
- package/core/pagination.mjs +2 -0
- package/core/pagination.mjs.map +1 -0
- package/core/streaming.d.mts +2 -0
- package/core/streaming.d.mts.map +1 -0
- package/core/streaming.d.ts +2 -0
- package/core/streaming.d.ts.map +1 -0
- package/core/streaming.js +18 -0
- package/core/streaming.js.map +1 -0
- package/core/streaming.mjs +2 -0
- package/core/streaming.mjs.map +1 -0
- package/index.d.mts +4 -0
- package/index.d.mts.map +1 -0
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -0
- package/index.js +25 -0
- package/index.js.map +1 -0
- package/index.mjs +3 -0
- package/index.mjs.map +1 -0
- package/internal/builtin-types.d.mts +73 -0
- package/internal/builtin-types.d.mts.map +1 -0
- package/internal/builtin-types.d.ts +73 -0
- package/internal/builtin-types.d.ts.map +1 -0
- package/internal/builtin-types.js +4 -0
- package/internal/builtin-types.js.map +1 -0
- package/internal/builtin-types.mjs +3 -0
- package/internal/builtin-types.mjs.map +1 -0
- package/internal/constants.d.mts +5 -0
- package/internal/constants.d.mts.map +1 -0
- package/internal/constants.d.ts +5 -0
- package/internal/constants.d.ts.map +1 -0
- package/internal/constants.js +18 -0
- package/internal/constants.js.map +1 -0
- package/internal/constants.mjs +15 -0
- package/internal/constants.mjs.map +1 -0
- package/internal/decoders/jsonl.d.mts +10 -0
- package/internal/decoders/jsonl.d.mts.map +1 -0
- package/internal/decoders/jsonl.d.ts +10 -0
- package/internal/decoders/jsonl.d.ts.map +1 -0
- package/internal/decoders/jsonl.js +39 -0
- package/internal/decoders/jsonl.js.map +1 -0
- package/internal/decoders/jsonl.mjs +35 -0
- package/internal/decoders/jsonl.mjs.map +1 -0
- package/internal/decoders/line.d.mts +17 -0
- package/internal/decoders/line.d.mts.map +1 -0
- package/internal/decoders/line.d.ts +17 -0
- package/internal/decoders/line.d.ts.map +1 -0
- package/internal/decoders/line.js +123 -0
- package/internal/decoders/line.js.map +1 -0
- package/internal/decoders/line.mjs +118 -0
- package/internal/decoders/line.mjs.map +1 -0
- package/internal/errors.d.mts +3 -0
- package/internal/errors.d.mts.map +1 -0
- package/internal/errors.d.ts +3 -0
- package/internal/errors.d.ts.map +1 -0
- package/internal/errors.js +41 -0
- package/internal/errors.js.map +1 -0
- package/internal/errors.mjs +36 -0
- package/internal/errors.mjs.map +1 -0
- package/internal/headers.d.mts +22 -0
- package/internal/headers.d.mts.map +1 -0
- package/internal/headers.d.ts +22 -0
- package/internal/headers.d.ts.map +1 -0
- package/internal/headers.js +79 -0
- package/internal/headers.js.map +1 -0
- package/internal/headers.mjs +74 -0
- package/internal/headers.mjs.map +1 -0
- package/internal/parse.d.mts +17 -0
- package/internal/parse.d.mts.map +1 -0
- package/internal/parse.d.ts +17 -0
- package/internal/parse.d.ts.map +1 -0
- package/internal/parse.js +60 -0
- package/internal/parse.js.map +1 -0
- package/internal/parse.mjs +56 -0
- package/internal/parse.mjs.map +1 -0
- package/internal/request-options.d.mts +77 -0
- package/internal/request-options.d.mts.map +1 -0
- package/internal/request-options.d.ts +77 -0
- package/internal/request-options.d.ts.map +1 -0
- package/internal/request-options.js +14 -0
- package/internal/request-options.js.map +1 -0
- package/internal/request-options.mjs +10 -0
- package/internal/request-options.mjs.map +1 -0
- package/internal/shim-types.d.mts +17 -0
- package/internal/shim-types.d.mts.map +1 -0
- package/internal/shim-types.d.ts +17 -0
- package/internal/shim-types.d.ts.map +1 -0
- package/internal/shim-types.js +4 -0
- package/internal/shim-types.js.map +1 -0
- package/internal/shim-types.mjs +3 -0
- package/internal/shim-types.mjs.map +1 -0
- package/internal/shims.d.mts +20 -0
- package/internal/shims.d.mts.map +1 -0
- package/internal/shims.d.ts +20 -0
- package/internal/shims.d.ts.map +1 -0
- package/internal/shims.js +92 -0
- package/internal/shims.js.map +1 -0
- package/internal/shims.mjs +85 -0
- package/internal/shims.mjs.map +1 -0
- package/internal/stream-utils.d.mts +8 -0
- package/internal/stream-utils.d.mts.map +1 -0
- package/internal/stream-utils.d.ts +8 -0
- package/internal/stream-utils.d.ts.map +1 -0
- package/internal/stream-utils.js +38 -0
- package/internal/stream-utils.js.map +1 -0
- package/internal/stream-utils.mjs +35 -0
- package/internal/stream-utils.mjs.map +1 -0
- package/internal/to-file.d.mts +45 -0
- package/internal/to-file.d.mts.map +1 -0
- package/internal/to-file.d.ts +45 -0
- package/internal/to-file.d.ts.map +1 -0
- package/internal/to-file.js +96 -0
- package/internal/to-file.js.map +1 -0
- package/internal/to-file.mjs +93 -0
- package/internal/to-file.mjs.map +1 -0
- package/internal/types.d.mts +69 -0
- package/internal/types.d.mts.map +1 -0
- package/internal/types.d.ts +69 -0
- package/internal/types.d.ts.map +1 -0
- package/internal/types.js +4 -0
- package/internal/types.js.map +1 -0
- package/internal/types.mjs +3 -0
- package/internal/types.mjs.map +1 -0
- package/internal/uploads.d.mts +42 -0
- package/internal/uploads.d.mts.map +1 -0
- package/internal/uploads.d.ts +42 -0
- package/internal/uploads.d.ts.map +1 -0
- package/internal/uploads.js +145 -0
- package/internal/uploads.js.map +1 -0
- package/internal/uploads.mjs +135 -0
- package/internal/uploads.mjs.map +1 -0
- package/internal/utils/base64.d.mts +3 -0
- package/internal/utils/base64.d.mts.map +1 -0
- package/internal/utils/base64.d.ts +3 -0
- package/internal/utils/base64.d.ts.map +1 -0
- package/internal/utils/base64.js +38 -0
- package/internal/utils/base64.js.map +1 -0
- package/internal/utils/base64.mjs +33 -0
- package/internal/utils/base64.mjs.map +1 -0
- package/internal/utils/bytes.d.mts +4 -0
- package/internal/utils/bytes.d.mts.map +1 -0
- package/internal/utils/bytes.d.ts +4 -0
- package/internal/utils/bytes.d.ts.map +1 -0
- package/internal/utils/bytes.js +31 -0
- package/internal/utils/bytes.js.map +1 -0
- package/internal/utils/bytes.mjs +26 -0
- package/internal/utils/bytes.mjs.map +1 -0
- package/internal/utils/env.d.mts +9 -0
- package/internal/utils/env.d.mts.map +1 -0
- package/internal/utils/env.d.ts +9 -0
- package/internal/utils/env.d.ts.map +1 -0
- package/internal/utils/env.js +22 -0
- package/internal/utils/env.js.map +1 -0
- package/internal/utils/env.mjs +18 -0
- package/internal/utils/env.mjs.map +1 -0
- package/internal/utils/log.d.mts +37 -0
- package/internal/utils/log.d.mts.map +1 -0
- package/internal/utils/log.d.ts +37 -0
- package/internal/utils/log.d.ts.map +1 -0
- package/internal/utils/log.js +86 -0
- package/internal/utils/log.js.map +1 -0
- package/internal/utils/log.mjs +80 -0
- package/internal/utils/log.mjs.map +1 -0
- package/internal/utils/path.d.mts +15 -0
- package/internal/utils/path.d.mts.map +1 -0
- package/internal/utils/path.d.ts +15 -0
- package/internal/utils/path.d.ts.map +1 -0
- package/internal/utils/path.js +79 -0
- package/internal/utils/path.js.map +1 -0
- package/internal/utils/path.mjs +74 -0
- package/internal/utils/path.mjs.map +1 -0
- package/internal/utils/query.d.mts +5 -0
- package/internal/utils/query.d.mts.map +1 -0
- package/internal/utils/query.d.ts +5 -0
- package/internal/utils/query.d.ts.map +1 -0
- package/internal/utils/query.js +23 -0
- package/internal/utils/query.js.map +1 -0
- package/internal/utils/query.mjs +20 -0
- package/internal/utils/query.mjs.map +1 -0
- package/internal/utils/sleep.d.mts +2 -0
- package/internal/utils/sleep.d.mts.map +1 -0
- package/internal/utils/sleep.d.ts +2 -0
- package/internal/utils/sleep.d.ts.map +1 -0
- package/internal/utils/sleep.js +7 -0
- package/internal/utils/sleep.js.map +1 -0
- package/internal/utils/sleep.mjs +3 -0
- package/internal/utils/sleep.mjs.map +1 -0
- package/internal/utils/uuid.d.mts +5 -0
- package/internal/utils/uuid.d.mts.map +1 -0
- package/internal/utils/uuid.d.ts +5 -0
- package/internal/utils/uuid.d.ts.map +1 -0
- package/internal/utils/uuid.js +19 -0
- package/internal/utils/uuid.js.map +1 -0
- package/internal/utils/uuid.mjs +15 -0
- package/internal/utils/uuid.mjs.map +1 -0
- package/internal/utils/values.d.mts +19 -0
- package/internal/utils/values.d.mts.map +1 -0
- package/internal/utils/values.d.ts +19 -0
- package/internal/utils/values.d.ts.map +1 -0
- package/internal/utils/values.js +119 -0
- package/internal/utils/values.js.map +1 -0
- package/internal/utils/values.mjs +100 -0
- package/internal/utils/values.mjs.map +1 -0
- package/internal/utils.d.mts +8 -0
- package/internal/utils.d.mts.map +1 -0
- package/internal/utils.d.ts +8 -0
- package/internal/utils.d.ts.map +1 -0
- package/internal/utils.js +25 -0
- package/internal/utils.js.map +1 -0
- package/internal/utils.mjs +9 -0
- package/internal/utils.mjs.map +1 -0
- package/package.json +87 -0
- package/src/client.ts +239 -0
- package/src/core/auth.ts +101 -0
- package/src/core/error.ts +1 -0
- package/src/core/pagination.ts +1 -0
- package/src/core/streaming.ts +1 -0
- package/src/index.ts +4 -0
- package/src/internal/README.md +3 -0
- package/src/internal/builtin-types.ts +93 -0
- package/src/internal/constants.ts +15 -0
- package/src/internal/decoders/jsonl.ts +48 -0
- package/src/internal/decoders/line.ts +135 -0
- package/src/internal/detect-platform.ts +196 -0
- package/src/internal/errors.ts +33 -0
- package/src/internal/headers.ts +99 -0
- package/src/internal/parse.ts +90 -0
- package/src/internal/request-options.ts +93 -0
- package/src/internal/shim-types.ts +26 -0
- package/src/internal/shims.ts +107 -0
- package/src/internal/stream-utils.ts +32 -0
- package/src/internal/to-file.ts +159 -0
- package/src/internal/types.ts +95 -0
- package/src/internal/uploads.ts +204 -0
- package/src/internal/utils/base64.ts +40 -0
- package/src/internal/utils/bytes.ts +32 -0
- package/src/internal/utils/env.ts +18 -0
- package/src/internal/utils/log.ts +127 -0
- package/src/internal/utils/path.ts +88 -0
- package/src/internal/utils/query.ts +23 -0
- package/src/internal/utils/sleep.ts +3 -0
- package/src/internal/utils/uuid.ts +17 -0
- package/src/internal/utils/values.ts +112 -0
- package/src/internal/utils.ts +9 -0
- package/src/tsconfig.json +11 -0
package/.github/logo.svg
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
<svg width="248" height="248" viewBox="0 0 248 248" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
+
<path d="M52.4285 162.873L98.7844 136.879L99.5485 134.602L98.7844 133.334H96.4921L88.7237 132.862L62.2346 132.153L39.3113 131.207L17.0249 130.026L11.4214 128.844L6.2 121.873L6.7094 118.447L11.4214 115.257L18.171 115.847L33.0711 116.911L55.485 118.447L71.6586 119.392L95.728 121.873H99.5485L100.058 120.337L98.7844 119.392L97.7656 118.447L74.5877 102.732L49.4995 86.1905L36.3823 76.62L29.3779 71.7757L25.8121 67.2858L24.2839 57.3608L30.6515 50.2716L39.3113 50.8623L41.4763 51.4531L50.2636 58.1879L68.9842 72.7209L93.4357 90.6804L97.0015 93.6343L98.4374 92.6652L98.6571 91.9801L97.0015 89.2625L83.757 65.2772L69.621 40.8192L63.2534 30.6579L61.5978 24.632C60.9565 22.1032 60.579 20.0111 60.579 17.4246L67.8381 7.49965L71.9133 6.19995L81.7193 7.49965L85.7946 11.0443L91.9074 24.9865L101.714 46.8451L116.996 76.62L121.453 85.4816L123.873 93.6343L124.764 96.1155H126.292V94.6976L127.566 77.9197L129.858 57.3608L132.15 30.8942L132.915 23.4505L136.608 14.4708L143.994 9.62643L149.725 12.344L154.437 19.0788L153.8 23.4505L150.998 41.6463L145.522 70.1215L141.957 89.2625H143.994L146.414 86.7813L156.093 74.0206L172.266 53.698L179.398 45.6635L187.803 36.802L193.152 32.5484H203.34L210.726 43.6549L207.415 55.1159L196.972 68.3492L188.312 79.5739L175.896 96.2095L168.191 109.585L168.882 110.689L170.738 110.53L198.755 104.504L213.91 101.787L231.994 98.7149L240.144 102.496L241.036 106.395L237.852 114.311L218.495 119.037L195.826 123.645L162.07 131.592L161.696 131.893L162.137 132.547L177.36 133.925L183.855 134.279H199.774L229.447 136.524L237.215 141.605L241.8 147.867L241.036 152.711L229.065 158.737L213.019 154.956L175.45 145.977L162.587 142.787H160.805V143.85L171.502 154.366L191.242 172.089L215.82 195.011L217.094 200.682L213.91 205.172L210.599 204.699L188.949 188.394L180.544 181.069L161.696 165.118H160.422V166.772L164.752 173.152L187.803 207.771L188.949 218.405L187.294 221.832L181.308 223.959L174.813 222.777L161.187 203.754L147.305 182.486L136.098 163.345L134.745 164.2L128.075 235.42L125.019 239.082L117.887 241.8L111.902 237.31L108.718 229.984L111.902 215.452L115.722 196.547L118.779 181.541L121.58 162.873L123.291 156.636L123.14 156.219L121.773 156.449L107.699 175.752L86.304 204.699L69.3663 222.777L65.291 224.431L58.2867 220.768L58.9235 214.27L62.8713 208.48L86.304 178.705L100.44 160.155L109.551 149.507L109.462 147.967L108.959 147.924L46.6977 188.512L35.6182 189.93L30.7788 185.44L31.4156 178.115L33.7079 175.752L52.4285 162.873Z" fill="#D97757"/>
|
|
3
|
+
</svg>
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.2.0 (2026-04-01)
|
|
4
|
+
|
|
5
|
+
Full Changelog: [aws-sdk-v0.1.0...aws-sdk-v0.2.0](https://github.com/anthropics/anthropic-sdk-typescript/compare/aws-sdk-v0.1.0...aws-sdk-v0.2.0)
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
* prepare aws package ([#782](https://github.com/anthropics/anthropic-sdk-typescript/issues/782)) ([f351d4d](https://github.com/anthropics/anthropic-sdk-typescript/commit/f351d4dfeb57b48bcb126686dc608493813262da))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Chores
|
|
13
|
+
|
|
14
|
+
* **internal:** version bump ([eb97e85](https://github.com/anthropics/anthropic-sdk-typescript/commit/eb97e8577279fb150582297d2a0924a297185c3c))
|
|
15
|
+
* **internal:** version bump ([8ebaf61](https://github.com/anthropics/anthropic-sdk-typescript/commit/8ebaf616d2e5c6aebc153f19a403dde41ab5a9f1))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Copyright 2023 Anthropic, PBC.
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
8
|
+
|
package/README.md
ADDED
|
File without changes
|
package/client.d.mts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { NullableHeaders } from "./internal/headers.mjs";
|
|
2
|
+
import { Anthropic, ClientOptions } from '@anthropic-ai/sdk/client';
|
|
3
|
+
export { BaseAnthropic } from '@anthropic-ai/sdk/client';
|
|
4
|
+
import { AwsCredentialIdentityProvider } from '@smithy/types';
|
|
5
|
+
import { FinalRequestOptions } from "./internal/request-options.mjs";
|
|
6
|
+
import { FinalizedRequestInit } from "./internal/types.mjs";
|
|
7
|
+
export interface AwsClientOptions extends ClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* AWS region for the API gateway.
|
|
10
|
+
*
|
|
11
|
+
* Resolved by precedence: `awsRegion` arg > `AWS_REGION` env var > `AWS_DEFAULT_REGION` env var.
|
|
12
|
+
*/
|
|
13
|
+
awsRegion?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* API key for x-api-key authentication.
|
|
16
|
+
*
|
|
17
|
+
* Takes precedence over AWS credential options. If neither `apiKey` nor
|
|
18
|
+
* AWS credentials are provided, falls back to the `ANTHROPIC_AWS_API_KEY`
|
|
19
|
+
* environment variable, then to the default AWS credential chain.
|
|
20
|
+
*/
|
|
21
|
+
apiKey?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* AWS access key ID for SigV4 authentication.
|
|
24
|
+
*
|
|
25
|
+
* Must be provided together with `awsSecretAccessKey`.
|
|
26
|
+
*/
|
|
27
|
+
awsAccessKey?: string | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* AWS secret access key for SigV4 authentication.
|
|
30
|
+
*
|
|
31
|
+
* Must be provided together with `awsAccessKey`.
|
|
32
|
+
*/
|
|
33
|
+
awsSecretAccessKey?: string | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* AWS session token for temporary credentials.
|
|
36
|
+
*/
|
|
37
|
+
awsSessionToken?: string | null | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* AWS named profile for credential resolution.
|
|
40
|
+
*
|
|
41
|
+
* When set, credentials are loaded from the AWS credential chain
|
|
42
|
+
* using this profile.
|
|
43
|
+
*/
|
|
44
|
+
awsProfile?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Custom provider chain resolver for AWS credentials.
|
|
47
|
+
* Useful for non-Node environments, like edge workers, where the default
|
|
48
|
+
* credential provider chain may not work.
|
|
49
|
+
*/
|
|
50
|
+
providerChainResolver?: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
51
|
+
/**
|
|
52
|
+
* Workspace ID sent on every request as the `anthropic-workspace-id` header.
|
|
53
|
+
*
|
|
54
|
+
* Resolved by precedence: `workspaceId` arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
55
|
+
*/
|
|
56
|
+
workspaceId?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Skip authentication for requests. This is useful when you have a gateway
|
|
59
|
+
* or proxy that handles authentication on your behalf.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
skipAuth?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** API Client for interfacing with the Anthropic AWS API. */
|
|
66
|
+
export declare class AnthropicAws extends Anthropic {
|
|
67
|
+
awsRegion: string | undefined;
|
|
68
|
+
awsAccessKey: string | null;
|
|
69
|
+
awsSecretAccessKey: string | null;
|
|
70
|
+
awsSessionToken: string | null;
|
|
71
|
+
awsProfile: string | null;
|
|
72
|
+
providerChainResolver: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
73
|
+
workspaceId: string | undefined;
|
|
74
|
+
skipAuth: boolean;
|
|
75
|
+
private _useSigV4;
|
|
76
|
+
/**
|
|
77
|
+
* API Client for interfacing with the Anthropic AWS API.
|
|
78
|
+
*
|
|
79
|
+
* Auth is resolved by precedence: `apiKey` constructor arg > explicit AWS
|
|
80
|
+
* credentials > `awsProfile` > `ANTHROPIC_AWS_API_KEY` env var > default
|
|
81
|
+
* AWS credential chain.
|
|
82
|
+
*
|
|
83
|
+
* @param {string | undefined} [opts.apiKey] - API key for x-api-key authentication.
|
|
84
|
+
* @param {string | null | undefined} [opts.awsAccessKey] - AWS access key ID for SigV4 authentication.
|
|
85
|
+
* @param {string | null | undefined} [opts.awsSecretAccessKey] - AWS secret access key for SigV4 authentication.
|
|
86
|
+
* @param {string | null | undefined} [opts.awsSessionToken] - AWS session token for temporary credentials.
|
|
87
|
+
* @param {string | undefined} [opts.awsProfile] - AWS named profile for credential resolution.
|
|
88
|
+
* @param {string | undefined} [opts.awsRegion] - AWS region. Resolved by precedence: arg > `AWS_REGION` env > `AWS_DEFAULT_REGION` env.
|
|
89
|
+
* @param {(() => Promise<AwsCredentialIdentityProvider>) | null} [opts.providerChainResolver] - Custom provider chain resolver for AWS credentials.
|
|
90
|
+
* @param {string | undefined} [opts.workspaceId] - Workspace ID sent as `anthropic-workspace-id` header. Resolved by precedence: arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
91
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_AWS_BASE_URL'] ?? https://aws-external-anthropic.{awsRegion}.api.aws] - Override the default base URL for the API.
|
|
92
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
93
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
94
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
95
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
96
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
97
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
98
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
99
|
+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for requests. This is useful when you have a gateway or proxy that handles authentication on your behalf.
|
|
100
|
+
*/
|
|
101
|
+
constructor({ awsRegion, baseURL, apiKey, awsAccessKey, awsSecretAccessKey, awsSessionToken, awsProfile, providerChainResolver, workspaceId, skipAuth, ...opts }?: AwsClientOptions);
|
|
102
|
+
protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
|
|
103
|
+
protected validateHeaders(): void;
|
|
104
|
+
protected prepareRequest(request: FinalizedRequestInit, { url, options }: {
|
|
105
|
+
url: string;
|
|
106
|
+
options: FinalRequestOptions;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=client.d.mts.map
|
package/client.d.mts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.mts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,eAAe,EAAE;OAIxB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B;OAC5D,EAAE,aAAa,EAAE,MAAM,0BAA0B;OACjD,EAAE,6BAA6B,EAAE,MAAM,eAAe;OAEtD,EAAE,mBAAmB,EAAE;OACvB,EAAE,oBAAoB,EAAE;AAI/B,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAEzC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE/C;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM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CAAA;KAAE,GAC9D,OAAO,CAAC,IAAI,CAAC;CAwBjB"}
|
package/client.d.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import type { NullableHeaders } from "./internal/headers.js";
|
|
2
|
+
import { Anthropic, ClientOptions } from '@anthropic-ai/sdk/client';
|
|
3
|
+
export { BaseAnthropic } from '@anthropic-ai/sdk/client';
|
|
4
|
+
import { AwsCredentialIdentityProvider } from '@smithy/types';
|
|
5
|
+
import { FinalRequestOptions } from "./internal/request-options.js";
|
|
6
|
+
import { FinalizedRequestInit } from "./internal/types.js";
|
|
7
|
+
export interface AwsClientOptions extends ClientOptions {
|
|
8
|
+
/**
|
|
9
|
+
* AWS region for the API gateway.
|
|
10
|
+
*
|
|
11
|
+
* Resolved by precedence: `awsRegion` arg > `AWS_REGION` env var > `AWS_DEFAULT_REGION` env var.
|
|
12
|
+
*/
|
|
13
|
+
awsRegion?: string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* API key for x-api-key authentication.
|
|
16
|
+
*
|
|
17
|
+
* Takes precedence over AWS credential options. If neither `apiKey` nor
|
|
18
|
+
* AWS credentials are provided, falls back to the `ANTHROPIC_AWS_API_KEY`
|
|
19
|
+
* environment variable, then to the default AWS credential chain.
|
|
20
|
+
*/
|
|
21
|
+
apiKey?: string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* AWS access key ID for SigV4 authentication.
|
|
24
|
+
*
|
|
25
|
+
* Must be provided together with `awsSecretAccessKey`.
|
|
26
|
+
*/
|
|
27
|
+
awsAccessKey?: string | null | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* AWS secret access key for SigV4 authentication.
|
|
30
|
+
*
|
|
31
|
+
* Must be provided together with `awsAccessKey`.
|
|
32
|
+
*/
|
|
33
|
+
awsSecretAccessKey?: string | null | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* AWS session token for temporary credentials.
|
|
36
|
+
*/
|
|
37
|
+
awsSessionToken?: string | null | undefined;
|
|
38
|
+
/**
|
|
39
|
+
* AWS named profile for credential resolution.
|
|
40
|
+
*
|
|
41
|
+
* When set, credentials are loaded from the AWS credential chain
|
|
42
|
+
* using this profile.
|
|
43
|
+
*/
|
|
44
|
+
awsProfile?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Custom provider chain resolver for AWS credentials.
|
|
47
|
+
* Useful for non-Node environments, like edge workers, where the default
|
|
48
|
+
* credential provider chain may not work.
|
|
49
|
+
*/
|
|
50
|
+
providerChainResolver?: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
51
|
+
/**
|
|
52
|
+
* Workspace ID sent on every request as the `anthropic-workspace-id` header.
|
|
53
|
+
*
|
|
54
|
+
* Resolved by precedence: `workspaceId` arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
55
|
+
*/
|
|
56
|
+
workspaceId?: string | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* Skip authentication for requests. This is useful when you have a gateway
|
|
59
|
+
* or proxy that handles authentication on your behalf.
|
|
60
|
+
*
|
|
61
|
+
* @default false
|
|
62
|
+
*/
|
|
63
|
+
skipAuth?: boolean;
|
|
64
|
+
}
|
|
65
|
+
/** API Client for interfacing with the Anthropic AWS API. */
|
|
66
|
+
export declare class AnthropicAws extends Anthropic {
|
|
67
|
+
awsRegion: string | undefined;
|
|
68
|
+
awsAccessKey: string | null;
|
|
69
|
+
awsSecretAccessKey: string | null;
|
|
70
|
+
awsSessionToken: string | null;
|
|
71
|
+
awsProfile: string | null;
|
|
72
|
+
providerChainResolver: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
73
|
+
workspaceId: string | undefined;
|
|
74
|
+
skipAuth: boolean;
|
|
75
|
+
private _useSigV4;
|
|
76
|
+
/**
|
|
77
|
+
* API Client for interfacing with the Anthropic AWS API.
|
|
78
|
+
*
|
|
79
|
+
* Auth is resolved by precedence: `apiKey` constructor arg > explicit AWS
|
|
80
|
+
* credentials > `awsProfile` > `ANTHROPIC_AWS_API_KEY` env var > default
|
|
81
|
+
* AWS credential chain.
|
|
82
|
+
*
|
|
83
|
+
* @param {string | undefined} [opts.apiKey] - API key for x-api-key authentication.
|
|
84
|
+
* @param {string | null | undefined} [opts.awsAccessKey] - AWS access key ID for SigV4 authentication.
|
|
85
|
+
* @param {string | null | undefined} [opts.awsSecretAccessKey] - AWS secret access key for SigV4 authentication.
|
|
86
|
+
* @param {string | null | undefined} [opts.awsSessionToken] - AWS session token for temporary credentials.
|
|
87
|
+
* @param {string | undefined} [opts.awsProfile] - AWS named profile for credential resolution.
|
|
88
|
+
* @param {string | undefined} [opts.awsRegion] - AWS region. Resolved by precedence: arg > `AWS_REGION` env > `AWS_DEFAULT_REGION` env.
|
|
89
|
+
* @param {(() => Promise<AwsCredentialIdentityProvider>) | null} [opts.providerChainResolver] - Custom provider chain resolver for AWS credentials.
|
|
90
|
+
* @param {string | undefined} [opts.workspaceId] - Workspace ID sent as `anthropic-workspace-id` header. Resolved by precedence: arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
91
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_AWS_BASE_URL'] ?? https://aws-external-anthropic.{awsRegion}.api.aws] - Override the default base URL for the API.
|
|
92
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
93
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
94
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
95
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
96
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
97
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
98
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
99
|
+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for requests. This is useful when you have a gateway or proxy that handles authentication on your behalf.
|
|
100
|
+
*/
|
|
101
|
+
constructor({ awsRegion, baseURL, apiKey, awsAccessKey, awsSecretAccessKey, awsSessionToken, awsProfile, providerChainResolver, workspaceId, skipAuth, ...opts }?: AwsClientOptions);
|
|
102
|
+
protected authHeaders(opts: FinalRequestOptions): Promise<NullableHeaders | undefined>;
|
|
103
|
+
protected validateHeaders(): void;
|
|
104
|
+
protected prepareRequest(request: FinalizedRequestInit, { url, options }: {
|
|
105
|
+
url: string;
|
|
106
|
+
options: FinalRequestOptions;
|
|
107
|
+
}): Promise<void>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=client.d.ts.map
|
package/client.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OAAO,KAAK,EAAE,eAAe,EAAE;OAIxB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,0BAA0B;OAC5D,EAAE,aAAa,EAAE,MAAM,0BAA0B;OACjD,EAAE,6BAA6B,EAAE,MAAM,eAAe;OAEtD,EAAE,mBAAmB,EAAE;OACvB,EAAE,oBAAoB,EAAE;AAI/B,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE/B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAE5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAEzC;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE/C;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAE5C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;I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
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AnthropicAws = exports.BaseAnthropic = void 0;
|
|
37
|
+
const headers_1 = require("./internal/headers.js");
|
|
38
|
+
const Errors = __importStar(require("./core/error.js"));
|
|
39
|
+
const utils_1 = require("./internal/utils.js");
|
|
40
|
+
const client_1 = require("@anthropic-ai/sdk/client");
|
|
41
|
+
var client_2 = require("@anthropic-ai/sdk/client");
|
|
42
|
+
Object.defineProperty(exports, "BaseAnthropic", { enumerable: true, get: function () { return client_2.BaseAnthropic; } });
|
|
43
|
+
const auth_1 = require("./core/auth.js");
|
|
44
|
+
const DEFAULT_SERVICE_NAME = 'aws-external-anthropic';
|
|
45
|
+
/** API Client for interfacing with the Anthropic AWS API. */
|
|
46
|
+
class AnthropicAws extends client_1.Anthropic {
|
|
47
|
+
/**
|
|
48
|
+
* API Client for interfacing with the Anthropic AWS API.
|
|
49
|
+
*
|
|
50
|
+
* Auth is resolved by precedence: `apiKey` constructor arg > explicit AWS
|
|
51
|
+
* credentials > `awsProfile` > `ANTHROPIC_AWS_API_KEY` env var > default
|
|
52
|
+
* AWS credential chain.
|
|
53
|
+
*
|
|
54
|
+
* @param {string | undefined} [opts.apiKey] - API key for x-api-key authentication.
|
|
55
|
+
* @param {string | null | undefined} [opts.awsAccessKey] - AWS access key ID for SigV4 authentication.
|
|
56
|
+
* @param {string | null | undefined} [opts.awsSecretAccessKey] - AWS secret access key for SigV4 authentication.
|
|
57
|
+
* @param {string | null | undefined} [opts.awsSessionToken] - AWS session token for temporary credentials.
|
|
58
|
+
* @param {string | undefined} [opts.awsProfile] - AWS named profile for credential resolution.
|
|
59
|
+
* @param {string | undefined} [opts.awsRegion] - AWS region. Resolved by precedence: arg > `AWS_REGION` env > `AWS_DEFAULT_REGION` env.
|
|
60
|
+
* @param {(() => Promise<AwsCredentialIdentityProvider>) | null} [opts.providerChainResolver] - Custom provider chain resolver for AWS credentials.
|
|
61
|
+
* @param {string | undefined} [opts.workspaceId] - Workspace ID sent as `anthropic-workspace-id` header. Resolved by precedence: arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
62
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_AWS_BASE_URL'] ?? https://aws-external-anthropic.{awsRegion}.api.aws] - Override the default base URL for the API.
|
|
63
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
64
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
65
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
66
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
67
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
68
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
69
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
70
|
+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for requests. This is useful when you have a gateway or proxy that handles authentication on your behalf.
|
|
71
|
+
*/
|
|
72
|
+
constructor({ awsRegion, baseURL, apiKey, awsAccessKey = null, awsSecretAccessKey = null, awsSessionToken = null, awsProfile, providerChainResolver = null, workspaceId, skipAuth = false, ...opts } = {}) {
|
|
73
|
+
// Region resolution: arg > AWS_REGION env > AWS_DEFAULT_REGION env
|
|
74
|
+
const resolvedRegion = awsRegion ?? (0, utils_1.readEnv)('AWS_REGION') ?? (0, utils_1.readEnv)('AWS_DEFAULT_REGION');
|
|
75
|
+
const resolvedBaseURL = baseURL ??
|
|
76
|
+
(0, utils_1.readEnv)('ANTHROPIC_AWS_BASE_URL') ??
|
|
77
|
+
(resolvedRegion ? `https://aws-external-anthropic.${resolvedRegion}.api.aws` : undefined);
|
|
78
|
+
if (!resolvedBaseURL && !skipAuth) {
|
|
79
|
+
throw new Errors.AnthropicError('No AWS region or base URL found. Set `awsRegion` in the constructor, the `AWS_REGION` / `AWS_DEFAULT_REGION` environment variable, or provide a `baseURL` / `ANTHROPIC_AWS_BASE_URL` environment variable.');
|
|
80
|
+
}
|
|
81
|
+
// Precedence-based auth resolution:
|
|
82
|
+
// 1. apiKey constructor arg
|
|
83
|
+
// 2. awsAccessKey/awsSecretAccessKey constructor args (SigV4)
|
|
84
|
+
// 3. awsProfile constructor arg (SigV4)
|
|
85
|
+
// 4. ANTHROPIC_AWS_API_KEY env var
|
|
86
|
+
// 5. Default AWS credential chain (SigV4)
|
|
87
|
+
const hasExplicitApiKey = apiKey != null;
|
|
88
|
+
const hasPartialAwsCreds = (awsAccessKey != null) !== (awsSecretAccessKey != null);
|
|
89
|
+
if (hasPartialAwsCreds) {
|
|
90
|
+
throw new Errors.AnthropicError('`awsAccessKey` and `awsSecretAccessKey` must be provided together. You provided only one.');
|
|
91
|
+
}
|
|
92
|
+
const hasExplicitAwsCreds = awsAccessKey != null && awsSecretAccessKey != null;
|
|
93
|
+
const hasAwsProfile = awsProfile != null;
|
|
94
|
+
let resolvedApiKey;
|
|
95
|
+
if (hasExplicitApiKey) {
|
|
96
|
+
resolvedApiKey = apiKey;
|
|
97
|
+
}
|
|
98
|
+
else if (!hasExplicitAwsCreds && !hasAwsProfile) {
|
|
99
|
+
resolvedApiKey = (0, utils_1.readEnv)('ANTHROPIC_AWS_API_KEY') ?? undefined;
|
|
100
|
+
}
|
|
101
|
+
const resolvedWorkspaceId = workspaceId ?? (0, utils_1.readEnv)('ANTHROPIC_AWS_WORKSPACE_ID');
|
|
102
|
+
if (!resolvedWorkspaceId && !skipAuth) {
|
|
103
|
+
throw new Errors.AnthropicError('No workspace ID found. Set `workspaceId` in the constructor or the `ANTHROPIC_AWS_WORKSPACE_ID` environment variable.');
|
|
104
|
+
}
|
|
105
|
+
super({
|
|
106
|
+
apiKey: resolvedApiKey,
|
|
107
|
+
baseURL: resolvedBaseURL,
|
|
108
|
+
...opts,
|
|
109
|
+
defaultHeaders: (0, headers_1.buildHeaders)([{ 'anthropic-workspace-id': resolvedWorkspaceId }, opts.defaultHeaders]),
|
|
110
|
+
});
|
|
111
|
+
this.skipAuth = false;
|
|
112
|
+
this.awsRegion = resolvedRegion;
|
|
113
|
+
this.awsAccessKey = awsAccessKey;
|
|
114
|
+
this.awsSecretAccessKey = awsSecretAccessKey;
|
|
115
|
+
this.awsSessionToken = awsSessionToken;
|
|
116
|
+
this.awsProfile = awsProfile ?? null;
|
|
117
|
+
this.providerChainResolver = providerChainResolver;
|
|
118
|
+
this.workspaceId = resolvedWorkspaceId;
|
|
119
|
+
this.skipAuth = skipAuth;
|
|
120
|
+
this._useSigV4 = resolvedApiKey == null;
|
|
121
|
+
}
|
|
122
|
+
async authHeaders(opts) {
|
|
123
|
+
if (this.skipAuth) {
|
|
124
|
+
return undefined;
|
|
125
|
+
}
|
|
126
|
+
if (!this._useSigV4) {
|
|
127
|
+
// API key mode — use inherited x-api-key auth
|
|
128
|
+
return super.authHeaders(opts);
|
|
129
|
+
}
|
|
130
|
+
// SigV4 mode — auth is handled in prepareRequest since it needs the full request
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
validateHeaders() {
|
|
134
|
+
// Auth validation is handled in the constructor and prepareRequest
|
|
135
|
+
}
|
|
136
|
+
async prepareRequest(request, { url, options }) {
|
|
137
|
+
if (this.skipAuth || !this._useSigV4) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const regionName = this.awsRegion;
|
|
141
|
+
if (!regionName) {
|
|
142
|
+
throw new Errors.AnthropicError('No AWS region found. Set `awsRegion` in the constructor or the `AWS_REGION` / `AWS_DEFAULT_REGION` environment variable.');
|
|
143
|
+
}
|
|
144
|
+
const headers = await (0, auth_1.getAuthHeaders)(request, {
|
|
145
|
+
url,
|
|
146
|
+
regionName,
|
|
147
|
+
serviceName: DEFAULT_SERVICE_NAME,
|
|
148
|
+
awsAccessKey: this.awsAccessKey,
|
|
149
|
+
awsSecretAccessKey: this.awsSecretAccessKey,
|
|
150
|
+
awsSessionToken: this.awsSessionToken,
|
|
151
|
+
awsProfile: this.awsProfile,
|
|
152
|
+
providerChainResolver: this.providerChainResolver,
|
|
153
|
+
});
|
|
154
|
+
request.headers = (0, headers_1.buildHeaders)([headers, request.headers]).values;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
exports.AnthropicAws = AnthropicAws;
|
|
158
|
+
//# sourceMappingURL=client.js.map
|
package/client.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mDAAkD;AAClD,wDAAuC;AACvC,+CAA2C;AAC3C,qDAAoE;AACpE,mDAAyD;AAAhD,uGAAA,aAAa,OAAA;AAEtB,yCAA6C;AAI7C,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAqEtD,6DAA6D;AAC7D,MAAa,YAAa,SAAQ,kBAAS;IAYzC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,GAAG,IAAI,EACnB,kBAAkB,GAAG,IAAI,EACzB,eAAe,GAAG,IAAI,EACtB,UAAU,EACV,qBAAqB,GAAG,IAAI,EAC5B,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,GAAG,IAAI,KACa,EAAE;QACtB,mEAAmE;QACnE,MAAM,cAAc,GAAG,SAAS,IAAI,IAAA,eAAO,EAAC,YAAY,CAAC,IAAI,IAAA,eAAO,EAAC,oBAAoB,CAAC,CAAC;QAE3F,MAAM,eAAe,GACnB,OAAO;YACP,IAAA,eAAO,EAAC,wBAAwB,CAAC;YACjC,CAAC,cAAc,CAAC,CAAC,CAAC,kCAAkC,cAAc,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QAE5F,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,MAAM,IAAI,MAAM,CAAC,cAAc,CAC7B,4MAA4M,CAC7M,CAAC;QACJ,CAAC;QAED,oCAAoC;QACpC,4BAA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,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,GAAG,IAAA,sBAAY,EAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACF;AA7JD,oCA6JC"}
|
package/client.mjs
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { buildHeaders } from "./internal/headers.mjs";
|
|
2
|
+
import * as Errors from "./core/error.mjs";
|
|
3
|
+
import { readEnv } from "./internal/utils.mjs";
|
|
4
|
+
import { Anthropic } from '@anthropic-ai/sdk/client';
|
|
5
|
+
export { BaseAnthropic } from '@anthropic-ai/sdk/client';
|
|
6
|
+
import { getAuthHeaders } from "./core/auth.mjs";
|
|
7
|
+
const DEFAULT_SERVICE_NAME = 'aws-external-anthropic';
|
|
8
|
+
/** API Client for interfacing with the Anthropic AWS API. */
|
|
9
|
+
export class AnthropicAws extends Anthropic {
|
|
10
|
+
/**
|
|
11
|
+
* API Client for interfacing with the Anthropic AWS API.
|
|
12
|
+
*
|
|
13
|
+
* Auth is resolved by precedence: `apiKey` constructor arg > explicit AWS
|
|
14
|
+
* credentials > `awsProfile` > `ANTHROPIC_AWS_API_KEY` env var > default
|
|
15
|
+
* AWS credential chain.
|
|
16
|
+
*
|
|
17
|
+
* @param {string | undefined} [opts.apiKey] - API key for x-api-key authentication.
|
|
18
|
+
* @param {string | null | undefined} [opts.awsAccessKey] - AWS access key ID for SigV4 authentication.
|
|
19
|
+
* @param {string | null | undefined} [opts.awsSecretAccessKey] - AWS secret access key for SigV4 authentication.
|
|
20
|
+
* @param {string | null | undefined} [opts.awsSessionToken] - AWS session token for temporary credentials.
|
|
21
|
+
* @param {string | undefined} [opts.awsProfile] - AWS named profile for credential resolution.
|
|
22
|
+
* @param {string | undefined} [opts.awsRegion] - AWS region. Resolved by precedence: arg > `AWS_REGION` env > `AWS_DEFAULT_REGION` env.
|
|
23
|
+
* @param {(() => Promise<AwsCredentialIdentityProvider>) | null} [opts.providerChainResolver] - Custom provider chain resolver for AWS credentials.
|
|
24
|
+
* @param {string | undefined} [opts.workspaceId] - Workspace ID sent as `anthropic-workspace-id` header. Resolved by precedence: arg > `ANTHROPIC_AWS_WORKSPACE_ID` env var.
|
|
25
|
+
* @param {string} [opts.baseURL=process.env['ANTHROPIC_AWS_BASE_URL'] ?? https://aws-external-anthropic.{awsRegion}.api.aws] - Override the default base URL for the API.
|
|
26
|
+
* @param {number} [opts.timeout=10 minutes] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
27
|
+
* @param {MergedRequestInit} [opts.fetchOptions] - Additional `RequestInit` options to be passed to `fetch` calls.
|
|
28
|
+
* @param {Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
29
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
30
|
+
* @param {HeadersLike} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
31
|
+
* @param {Record<string, string | undefined>} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
32
|
+
* @param {boolean} [opts.dangerouslyAllowBrowser=false] - By default, client-side use of this library is not allowed, as it risks exposing your secret API credentials to attackers.
|
|
33
|
+
* @param {boolean} [opts.skipAuth=false] - Skip authentication for requests. This is useful when you have a gateway or proxy that handles authentication on your behalf.
|
|
34
|
+
*/
|
|
35
|
+
constructor({ awsRegion, baseURL, apiKey, awsAccessKey = null, awsSecretAccessKey = null, awsSessionToken = null, awsProfile, providerChainResolver = null, workspaceId, skipAuth = false, ...opts } = {}) {
|
|
36
|
+
// Region resolution: arg > AWS_REGION env > AWS_DEFAULT_REGION env
|
|
37
|
+
const resolvedRegion = awsRegion ?? readEnv('AWS_REGION') ?? readEnv('AWS_DEFAULT_REGION');
|
|
38
|
+
const resolvedBaseURL = baseURL ??
|
|
39
|
+
readEnv('ANTHROPIC_AWS_BASE_URL') ??
|
|
40
|
+
(resolvedRegion ? `https://aws-external-anthropic.${resolvedRegion}.api.aws` : undefined);
|
|
41
|
+
if (!resolvedBaseURL && !skipAuth) {
|
|
42
|
+
throw new Errors.AnthropicError('No AWS region or base URL found. Set `awsRegion` in the constructor, the `AWS_REGION` / `AWS_DEFAULT_REGION` environment variable, or provide a `baseURL` / `ANTHROPIC_AWS_BASE_URL` environment variable.');
|
|
43
|
+
}
|
|
44
|
+
// Precedence-based auth resolution:
|
|
45
|
+
// 1. apiKey constructor arg
|
|
46
|
+
// 2. awsAccessKey/awsSecretAccessKey constructor args (SigV4)
|
|
47
|
+
// 3. awsProfile constructor arg (SigV4)
|
|
48
|
+
// 4. ANTHROPIC_AWS_API_KEY env var
|
|
49
|
+
// 5. Default AWS credential chain (SigV4)
|
|
50
|
+
const hasExplicitApiKey = apiKey != null;
|
|
51
|
+
const hasPartialAwsCreds = (awsAccessKey != null) !== (awsSecretAccessKey != null);
|
|
52
|
+
if (hasPartialAwsCreds) {
|
|
53
|
+
throw new Errors.AnthropicError('`awsAccessKey` and `awsSecretAccessKey` must be provided together. You provided only one.');
|
|
54
|
+
}
|
|
55
|
+
const hasExplicitAwsCreds = awsAccessKey != null && awsSecretAccessKey != null;
|
|
56
|
+
const hasAwsProfile = awsProfile != null;
|
|
57
|
+
let resolvedApiKey;
|
|
58
|
+
if (hasExplicitApiKey) {
|
|
59
|
+
resolvedApiKey = apiKey;
|
|
60
|
+
}
|
|
61
|
+
else if (!hasExplicitAwsCreds && !hasAwsProfile) {
|
|
62
|
+
resolvedApiKey = readEnv('ANTHROPIC_AWS_API_KEY') ?? undefined;
|
|
63
|
+
}
|
|
64
|
+
const resolvedWorkspaceId = workspaceId ?? readEnv('ANTHROPIC_AWS_WORKSPACE_ID');
|
|
65
|
+
if (!resolvedWorkspaceId && !skipAuth) {
|
|
66
|
+
throw new Errors.AnthropicError('No workspace ID found. Set `workspaceId` in the constructor or the `ANTHROPIC_AWS_WORKSPACE_ID` environment variable.');
|
|
67
|
+
}
|
|
68
|
+
super({
|
|
69
|
+
apiKey: resolvedApiKey,
|
|
70
|
+
baseURL: resolvedBaseURL,
|
|
71
|
+
...opts,
|
|
72
|
+
defaultHeaders: buildHeaders([{ 'anthropic-workspace-id': resolvedWorkspaceId }, opts.defaultHeaders]),
|
|
73
|
+
});
|
|
74
|
+
this.skipAuth = false;
|
|
75
|
+
this.awsRegion = resolvedRegion;
|
|
76
|
+
this.awsAccessKey = awsAccessKey;
|
|
77
|
+
this.awsSecretAccessKey = awsSecretAccessKey;
|
|
78
|
+
this.awsSessionToken = awsSessionToken;
|
|
79
|
+
this.awsProfile = awsProfile ?? null;
|
|
80
|
+
this.providerChainResolver = providerChainResolver;
|
|
81
|
+
this.workspaceId = resolvedWorkspaceId;
|
|
82
|
+
this.skipAuth = skipAuth;
|
|
83
|
+
this._useSigV4 = resolvedApiKey == null;
|
|
84
|
+
}
|
|
85
|
+
async authHeaders(opts) {
|
|
86
|
+
if (this.skipAuth) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
if (!this._useSigV4) {
|
|
90
|
+
// API key mode — use inherited x-api-key auth
|
|
91
|
+
return super.authHeaders(opts);
|
|
92
|
+
}
|
|
93
|
+
// SigV4 mode — auth is handled in prepareRequest since it needs the full request
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
validateHeaders() {
|
|
97
|
+
// Auth validation is handled in the constructor and prepareRequest
|
|
98
|
+
}
|
|
99
|
+
async prepareRequest(request, { url, options }) {
|
|
100
|
+
if (this.skipAuth || !this._useSigV4) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const regionName = this.awsRegion;
|
|
104
|
+
if (!regionName) {
|
|
105
|
+
throw new Errors.AnthropicError('No AWS region found. Set `awsRegion` in the constructor or the `AWS_REGION` / `AWS_DEFAULT_REGION` environment variable.');
|
|
106
|
+
}
|
|
107
|
+
const headers = await getAuthHeaders(request, {
|
|
108
|
+
url,
|
|
109
|
+
regionName,
|
|
110
|
+
serviceName: DEFAULT_SERVICE_NAME,
|
|
111
|
+
awsAccessKey: this.awsAccessKey,
|
|
112
|
+
awsSecretAccessKey: this.awsSecretAccessKey,
|
|
113
|
+
awsSessionToken: this.awsSessionToken,
|
|
114
|
+
awsProfile: this.awsProfile,
|
|
115
|
+
providerChainResolver: this.providerChainResolver,
|
|
116
|
+
});
|
|
117
|
+
request.headers = buildHeaders([headers, request.headers]).values;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
//# sourceMappingURL=client.mjs.map
|
package/client.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.mjs","sourceRoot":"","sources":["src/client.ts"],"names":[],"mappings":"OACO,EAAE,YAAY,EAAE;OAChB,KAAK,MAAM;OACX,EAAE,OAAO,EAAE;OACX,EAAE,SAAS,EAAiB,MAAM,0BAA0B;OAC5D,EAAE,aAAa,EAAE,MAAM,0BAA0B;OAEjD,EAAE,cAAc,EAAE;AAIzB,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAqEtD,6DAA6D;AAC7D,MAAM,OAAO,YAAa,SAAQ,SAAS;IAYzC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,YAAY,EACV,SAAS,EACT,OAAO,EACP,MAAM,EACN,YAAY,GAAG,IAAI,EACnB,kBAAkB,GAAG,IAAI,EACzB,eAAe,GAAG,IAAI,EACtB,UAAU,EACV,qBAAqB,GAAG,IAAI,EAC5B,WAAW,EACX,QAAQ,GAAG,KAAK,EAChB,GAAG,IAAI,KACa,EAAE;QACtB,mEAAmE;QACnE,MAAM,cAAc,GAAG,SAAS,IAAI,OAAO,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAAC;QAE3F,MAAM,eAAe,GACnB,OAAO;YACP,OAAO,CAAC,wBAAwB,CAAC;YACjC,CAAC,cAAc,CAAC,CAAC,CAAC,kCAAkC,cAAc,UAAU,CAAC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AAO,EAAE;YAC5C,GAAG;YACH,UAAU;YACV,WAAW,EAAE,oBAAoB;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;YAC3C,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,qBAAqB,EAAE,IAAI,CAAC,qBAAqB;SAClD,CAAC,CAAC;QACH,OAAO,CAAC,OAAO,GAAG,YAAY,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACpE,CAAC;CACF"}
|
package/core/auth.d.mts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@smithy/types';
|
|
2
|
+
import { MergedRequestInit } from "../internal/types.mjs";
|
|
3
|
+
export type AuthProps = {
|
|
4
|
+
url: string;
|
|
5
|
+
regionName: string;
|
|
6
|
+
serviceName: string;
|
|
7
|
+
awsAccessKey: string | null | undefined;
|
|
8
|
+
awsSecretAccessKey: string | null | undefined;
|
|
9
|
+
awsSessionToken: string | null | undefined;
|
|
10
|
+
awsProfile?: string | null | undefined;
|
|
11
|
+
fetchOptions?: MergedRequestInit | undefined;
|
|
12
|
+
providerChainResolver?: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const getAuthHeaders: (req: RequestInit, props: AuthProps) => Promise<Record<string, string>>;
|
|
15
|
+
//# sourceMappingURL=auth.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.mts","sourceRoot":"","sources":["../src/core/auth.ts"],"names":[],"mappings":"OAIO,EAAE,6BAA6B,EAAE,MAAM,eAAe;OAEtD,EAAE,iBAAiB,EAAE;AAE5B,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC7C,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/E,CAAC;AA2BF,eAAO,MAAM,cAAc,GAAU,KAAK,WAAW,EAAE,OAAO,SAAS,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuDvG,CAAC"}
|
package/core/auth.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { AwsCredentialIdentityProvider } from '@smithy/types';
|
|
2
|
+
import { MergedRequestInit } from "../internal/types.js";
|
|
3
|
+
export type AuthProps = {
|
|
4
|
+
url: string;
|
|
5
|
+
regionName: string;
|
|
6
|
+
serviceName: string;
|
|
7
|
+
awsAccessKey: string | null | undefined;
|
|
8
|
+
awsSecretAccessKey: string | null | undefined;
|
|
9
|
+
awsSessionToken: string | null | undefined;
|
|
10
|
+
awsProfile?: string | null | undefined;
|
|
11
|
+
fetchOptions?: MergedRequestInit | undefined;
|
|
12
|
+
providerChainResolver?: (() => Promise<AwsCredentialIdentityProvider>) | null;
|
|
13
|
+
};
|
|
14
|
+
export declare const getAuthHeaders: (req: RequestInit, props: AuthProps) => Promise<Record<string, string>>;
|
|
15
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/core/auth.ts"],"names":[],"mappings":"OAIO,EAAE,6BAA6B,EAAE,MAAM,eAAe;OAEtD,EAAE,iBAAiB,EAAE;AAE5B,MAAM,MAAM,SAAS,GAAG;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACxC,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC9C,eAAe,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACvC,YAAY,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;IAC7C,qBAAqB,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,6BAA6B,CAAC,CAAC,GAAG,IAAI,CAAC;CAC/E,CAAC;AA2BF,eAAO,MAAM,cAAc,GAAU,KAAK,WAAW,EAAE,OAAO,SAAS,KAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAuDvG,CAAC"}
|