@wmaurer/effect-ai-amazon-bedrock 0.1.0 → 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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @wmaurer/effect-ai-amazon-bedrock
2
2
 
3
+ ## 0.2.0
4
+
5
+ `AmazonBedrockClient.layer`, `layerConfig`, and `make` take one of three ways to authenticate: the fixed keys of 0.1.0, a `credentialProvider`, or a Bedrock `apiKey`. Options that mix two ways, or give none, do not compile. Every 0.1.0 call compiles and runs unchanged.
6
+
7
+ - Add the `credentialProvider` option. It takes a function in the shape of the AWS SDK's credential providers, such as `fromNodeProviderChain()` from `@aws-sdk/credential-providers`, or an `Effect`. The package does not depend on the AWS SDK. The client runs the provider when a request needs credentials, runs it once for concurrent requests, and keeps the credentials until five minutes before their `expiration`, or for at least 10 seconds.
8
+ - Keep the last credentials while the provider fails and they have not expired. Ask the provider again after 30 seconds, or when the last credentials expire if that is sooner.
9
+ - Refresh credentials that Bedrock rejects. After an `AuthenticationError` of kind `ExpiredKey`, `InvalidKey`, or `MissingKey`, the next request gets new credentials, and a function provider gets `{ forceRefresh: true }`. The rejected request fails and is not sent again.
10
+ - Fail a request with an `AuthenticationError` of kind `Unknown` when the promise of a function provider rejects, and of kind `MissingKey` when a provider returns an empty key.
11
+ - An `Effect` provider fails with an `AiError`, which the request fails with unchanged, or with an `AiError` reason, which the client puts in an `AiError`. The services that it requires become requirements of the layer through a new type parameter. It runs with the services of the request first, and the services that the layer was built with fill in the rest, so a span that it opens is a child of the request's span.
12
+ - Add the `apiKey` option for Bedrock API keys. The client sends the key as `Authorization: Bearer <key>` in place of a SigV4 signature, and an `AiError` shows the header as `<redacted>`.
13
+ - AWS rejects an API key that it does not accept with `AccessDeniedException`, as it rejects a missing IAM permission, so the request fails with an `AuthenticationError` of kind `InsufficientPermissions`.
14
+ - Add the `Credentials`, `CredentialProvider`, and `ConfigOptions` types. `Options`, `ConfigOptions`, `CredentialProvider`, `make`, `layer`, and `layerConfig` take a type parameter `R` for the services of an `Effect` provider. It defaults to `never`.
15
+ - A retry policy in `transformClient` or `AmazonBedrockConfig.withClientTransform` signs each attempt again with the credentials of the request, and does not retry a provider that fails.
16
+
3
17
  ## 0.1.0
4
18
 
5
19
  The first release. It adds an Amazon Bedrock provider for `effect/ai`. The provider calls the Converse and ConverseStream APIs, signs requests with SigV4 through `aws4fetch`, and decodes the AWS event-stream framing without another dependency. `AmazonBedrockClient.layer` and `AmazonBedrockClient.layerConfig` take an access key and a secret key, and the optional `sessionToken`, `region`, `apiUrl`, and `transformClient`. The region defaults to `us-east-1`. `AmazonBedrockLanguageModel.Config` takes the Converse request fields other than `messages` and `system`.
package/README.md CHANGED
@@ -138,20 +138,88 @@ To run the program, do these steps:
138
138
 
139
139
  `AmazonBedrockClient` needs an `HttpClient`. The example above uses `FetchHttpClient.layer` from `effect/http`.
140
140
 
141
- The client takes explicit credentials. It does not read `~/.aws`, the AWS profile variables, or instance metadata. Give the credentials in one of two ways:
141
+ The client authenticates each request in one of three ways:
142
142
 
143
- - `AmazonBedrockClient.layerConfig` reads each option from a `Config`, as in the example above.
144
- - `AmazonBedrockClient.layer` takes plain values. Pass `secretAccessKey` and `sessionToken` as `Redacted` values.
143
+ - Fixed keys. `accessKeyId`, `secretAccessKey`, and an optional `sessionToken`. The client signs each request with SigV4.
144
+ - A credential provider. `credentialProvider` is a function or an `Effect` that returns credentials. The client signs each request with SigV4 and asks the provider for new credentials before the old ones expire.
145
+ - A Bedrock API key. `apiKey` is sent as `Authorization: Bearer <key>` in place of a SigV4 signature.
145
146
 
146
- `sessionToken` is optional, but `layerConfig` fails with a `ConfigError` if a `Config` that you give it finds no value. For that reason the example above gives `AWS_SESSION_TOKEN` an empty default with `Config.withDefault`. The client sends no session token when the token is empty, so the same program runs with temporary and long-lived keys.
147
+ Give exactly one of them. Options that mix two ways, or give none, do not compile. `AmazonBedrockClient.layerConfig` reads each value from a `Config`. `AmazonBedrockClient.layer` takes plain values, with the secrets as `Redacted` values. The client reads no environment variable and no file by itself.
147
148
 
148
- The client reads the credentials once, when the layer is built, and uses them for every request. Where you get them depends on where the program runs:
149
+ ### Use fixed keys
149
150
 
150
- - On a machine where the AWS CLI signs in through a profile or IAM Identity Center, run `eval "$(aws configure export-credentials --format env)"` in the shell before you start the program. The command needs AWS CLI version 2. It prints the profile's access key ID, secret access key, and session token, if the profile has one, as `export` lines. Add `--profile <name>` to choose a profile.
151
- - AWS Lambda sets `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` for the function's execution role, so the example above runs without changes.
152
- - On Amazon ECS, Amazon EKS, and Amazon EC2, the role's credentials are not in the environment. Get them yourself, for example with `fromNodeProviderChain()` from `@aws-sdk/credential-providers`, and pass them to `AmazonBedrockClient.layer`.
151
+ The example above reads fixed keys from the environment. `sessionToken` is optional, but `layerConfig` fails with a `ConfigError` if a `Config` that you give it finds no value. For that reason the example gives `AWS_SESSION_TOKEN` an empty default with `Config.withDefault`. The client sends no session token when the token is empty, so the same program runs with temporary and long-lived keys. AWS Lambda sets `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, and `AWS_SESSION_TOKEN` for the function's execution role, so the example runs there without changes.
153
152
 
154
- The client does not refresh temporary credentials. When the session ends, every request fails with an `AuthenticationError` of kind `ExpiredKey`. Restart the program with new credentials.
153
+ The client reads fixed keys once, when the layer is built. When temporary keys expire, every request fails with an `AuthenticationError` of kind `ExpiredKey`. A program that runs longer than its session needs a credential provider.
154
+
155
+ ### Use a credential provider
156
+
157
+ A function in the shape of the AWS SDK's credential providers fits `credentialProvider` without an adapter. `fromNodeProviderChain()` from `@aws-sdk/credential-providers` looks for credentials where the AWS CLI does, in the environment, in the profiles and IAM Identity Center sessions of `~/.aws`, and in the container credentials of Amazon ECS and Amazon EKS and the instance metadata of Amazon EC2. This package does not depend on the AWS SDK, so install `@aws-sdk/credential-providers` yourself.
158
+
159
+ ```ts
160
+ import { fromNodeProviderChain } from "@aws-sdk/credential-providers"
161
+ import { AmazonBedrockClient } from "@wmaurer/effect-ai-amazon-bedrock"
162
+ import { Layer } from "effect"
163
+ import { FetchHttpClient } from "effect/http"
164
+
165
+ const BedrockClient = AmazonBedrockClient.layer({
166
+ region: "eu-west-1",
167
+ credentialProvider: fromNodeProviderChain()
168
+ }).pipe(Layer.provide(FetchHttpClient.layer))
169
+ ```
170
+
171
+ The client runs the provider when a request needs credentials, and runs it once for requests that need them at the same time:
172
+
173
+ - It keeps the credentials until five minutes before their `expiration`. It keeps credentials that expire in less than five minutes for 10 seconds, and credentials without an `expiration` until Bedrock rejects them.
174
+ - If the provider fails while the last credentials have not expired, the client signs with the last credentials. It asks the provider again after 30 seconds, or when the last credentials expire if that is sooner.
175
+ - If Bedrock rejects the credentials with an `AuthenticationError` of kind `ExpiredKey`, `InvalidKey`, or `MissingKey`, the request fails, and the next request gets new credentials. The client calls a function provider with `{ forceRefresh: true }` for them. Kind `InsufficientPermissions` keeps the credentials, because new credentials for the same role have the same IAM policy.
176
+ - If the promise of a function provider rejects, the request fails with an `AuthenticationError` of kind `Unknown`. If the provider returns an empty access key ID or secret access key, the request fails with an `AuthenticationError` of kind `MissingKey`.
177
+
178
+ An `Effect` provider can load credentials from a service of your own. The layer then requires that service:
179
+
180
+ ```ts
181
+ import { AmazonBedrockClient } from "@wmaurer/effect-ai-amazon-bedrock"
182
+ import { Context, Effect } from "effect"
183
+ import type { AiError } from "effect/ai"
184
+
185
+ class Vault extends Context.Service<Vault, {
186
+ readonly bedrockCredentials: Effect.Effect<AmazonBedrockClient.Credentials, AiError.AiError>
187
+ }>()("Vault") {}
188
+
189
+ // Layer<AmazonBedrockClient, never, HttpClient | Vault>
190
+ export const BedrockClient = AmazonBedrockClient.layer({
191
+ region: "eu-west-1",
192
+ credentialProvider: Effect.gen(function*() {
193
+ const vault = yield* Vault
194
+ return yield* vault.bedrockCredentials
195
+ })
196
+ })
197
+ ```
198
+
199
+ The provider runs with the services of the request first, and the services that the layer was built with fill in the rest. A span that the provider opens is a child of the span of the request that runs the provider.
200
+
201
+ The `Effect` can fail with an `AiError`, which the request fails with unchanged, or with an `AiError` reason such as an `AuthenticationError`, which the client puts in an `AiError`.
202
+
203
+ A retry policy in `transformClient` does not retry a failed provider, because the client gets the credentials before it sends the request. Each retry of a request signs again with the credentials of the first attempt.
204
+
205
+ ### Use a Bedrock API key
206
+
207
+ ```ts
208
+ import { AmazonBedrockClient } from "@wmaurer/effect-ai-amazon-bedrock"
209
+ import { Config, Layer } from "effect"
210
+ import { FetchHttpClient } from "effect/http"
211
+
212
+ const BedrockClient = AmazonBedrockClient.layerConfig({
213
+ region: Config.String("AWS_REGION"),
214
+ apiKey: Config.Redacted("AWS_BEARER_TOKEN_BEDROCK")
215
+ }).pipe(Layer.provide(FetchHttpClient.layer))
216
+ ```
217
+
218
+ `AWS_BEARER_TOKEN_BEDROCK` is the variable that the AWS SDK for JavaScript reads the key from. The client reads it only through the `Config` that you give it. An `AiError` and an HTTP span that records headers show the `authorization` header as `<redacted>`.
219
+
220
+ AWS rejects an API key that it does not accept, such as an expired or revoked key, with `AccessDeniedException`, as it rejects a request that the IAM policy does not allow. The request then fails with an `AuthenticationError` of kind `InsufficientPermissions`, and the client cannot tell the two causes apart.
221
+
222
+ ### Set the other options
155
223
 
156
224
  The other options are these:
157
225
 
@@ -1,10 +1,27 @@
1
+ /**
2
+ * The `AmazonBedrockClient` module defines the low-level Effect service used to
3
+ * call Amazon Bedrock's Converse API. It wraps an `HttpClient` with SigV4
4
+ * request signing (via `aws4fetch`), request defaults, response decoding, and
5
+ * error mapping to the unified `AiError` type.
6
+ *
7
+ * **Mental model**
8
+ *
9
+ * `HttpClient.HttpClient` provides the transport. {@link make} turns explicit
10
+ * {@link Options} into an {@link AmazonBedrockClient} service, while
11
+ * {@link layer} and {@link layerConfig} provide that service as a layer. The
12
+ * service exposes handwritten helpers for the `converse` (non-streaming) and
13
+ * `converse-stream` (streaming) endpoints.
14
+ *
15
+ * @stability unstable
16
+ * @since 0.1.0
17
+ */
1
18
  import type * as AiError from "effect/ai/AiError";
2
19
  import type * as Config from "effect/Config";
3
20
  import * as Context from "effect/Context";
4
21
  import * as Effect from "effect/Effect";
5
22
  import * as HttpClient from "effect/http/HttpClient";
6
23
  import * as Layer from "effect/Layer";
7
- import * as Redacted from "effect/Redacted";
24
+ import type * as Redacted from "effect/Redacted";
8
25
  import * as Stream from "effect/Stream";
9
26
  import type { ConverseRequest } from "./AmazonBedrockSchema.ts";
10
27
  import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSchema.ts";
@@ -14,7 +31,7 @@ import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSc
14
31
  *
15
32
  * @stability unstable
16
33
  * @category models
17
- * @since 4.0.0
34
+ * @since 0.1.0
18
35
  */
19
36
  export interface Service {
20
37
  /**
@@ -38,18 +55,59 @@ declare const AmazonBedrockClient_base: Context.ServiceClass<AmazonBedrockClient
38
55
  *
39
56
  * @stability unstable
40
57
  * @category services
41
- * @since 4.0.0
58
+ * @since 0.1.0
42
59
  */
43
60
  export declare class AmazonBedrockClient extends AmazonBedrockClient_base {
44
61
  }
45
62
  /**
46
- * Configuration for creating an Amazon Bedrock client.
63
+ * SigV4 credentials as a {@link CredentialProvider} returns them. The shape is
64
+ * the AWS SDK's `AwsCredentialIdentity`, so the SDK's providers fit without an
65
+ * adapter.
47
66
  *
48
67
  * @stability unstable
49
68
  * @category options
50
- * @since 4.0.0
69
+ * @since 0.2.0
51
70
  */
52
- export type Options = {
71
+ export interface Credentials {
72
+ readonly accessKeyId: string;
73
+ readonly secretAccessKey: string;
74
+ /** An empty token is sent as no token. */
75
+ readonly sessionToken?: string | undefined;
76
+ /** The client asks the provider for new credentials five minutes before this time. */
77
+ readonly expiration?: Date | undefined;
78
+ }
79
+ /**
80
+ * Supplies SigV4 credentials that can change while the program runs.
81
+ *
82
+ * **Details**
83
+ *
84
+ * A provider is one of these:
85
+ *
86
+ * - A function in the shape of the AWS SDK's credential providers, such as
87
+ * `fromNodeProviderChain()` from `@aws-sdk/credential-providers`. A rejected
88
+ * promise fails the request with an `AuthenticationError` of kind
89
+ * `"Unknown"`. After Bedrock rejects the credentials, the client calls the
90
+ * function with `{ forceRefresh: true }`.
91
+ * - An `Effect`. It can fail with an `AiError`, which the request fails with
92
+ * unchanged, or with an `AiError` reason, such as an `AuthenticationError`,
93
+ * which the client wraps in an `AiError`. The services that it requires
94
+ * become requirements of the layer. It runs with the services of the
95
+ * request first, and the services that the layer was built with fill in the
96
+ * rest.
97
+ *
98
+ * The client runs the provider at most once at a time, and keeps the
99
+ * credentials until five minutes before their `expiration`. Credentials with
100
+ * no `expiration` are kept until Bedrock rejects them. Keys that are empty fail
101
+ * the request with an `AuthenticationError` of kind `"MissingKey"`.
102
+ *
103
+ * @stability unstable
104
+ * @category options
105
+ * @since 0.2.0
106
+ */
107
+ export type CredentialProvider<R = never> = ((options?: {
108
+ readonly forceRefresh?: boolean;
109
+ }) => PromiseLike<Credentials>) | Effect.Effect<Credentials, AiError.AiError | AiError.AiErrorReason, R>;
110
+ interface CommonOptions {
53
111
  /**
54
112
  * The base URL for the Bedrock runtime API. Override to use a proxy or a
55
113
  * different endpoint.
@@ -57,9 +115,6 @@ export type Options = {
57
115
  * @default `https://bedrock-runtime.${region}.amazonaws.com`
58
116
  */
59
117
  readonly apiUrl?: string | undefined;
60
- readonly accessKeyId: string;
61
- readonly secretAccessKey: Redacted.Redacted<string>;
62
- readonly sessionToken?: Redacted.Redacted<string> | undefined;
63
118
  /**
64
119
  * The AWS region.
65
120
  *
@@ -67,38 +122,95 @@ export type Options = {
67
122
  */
68
123
  readonly region?: string | undefined;
69
124
  readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
70
- };
125
+ }
126
+ interface StaticKeys {
127
+ readonly accessKeyId: string;
128
+ readonly secretAccessKey: Redacted.Redacted<string>;
129
+ readonly sessionToken?: Redacted.Redacted<string> | undefined;
130
+ readonly credentialProvider?: never;
131
+ readonly apiKey?: never;
132
+ }
133
+ interface ProvidedKeys<R> {
134
+ readonly credentialProvider: CredentialProvider<R>;
135
+ readonly accessKeyId?: never;
136
+ readonly secretAccessKey?: never;
137
+ readonly sessionToken?: never;
138
+ readonly apiKey?: never;
139
+ }
140
+ interface ApiKey {
141
+ /** A Bedrock API key, sent as `Authorization: Bearer <key>` in place of a SigV4 signature. */
142
+ readonly apiKey: Redacted.Redacted<string>;
143
+ readonly accessKeyId?: never;
144
+ readonly secretAccessKey?: never;
145
+ readonly sessionToken?: never;
146
+ readonly credentialProvider?: never;
147
+ }
148
+ /**
149
+ * Configuration for creating an Amazon Bedrock client.
150
+ *
151
+ * **Details**
152
+ *
153
+ * The options take exactly one way to authenticate:
154
+ *
155
+ * - `accessKeyId` and `secretAccessKey`, and an optional `sessionToken`.
156
+ * - `credentialProvider`, a {@link CredentialProvider}.
157
+ * - `apiKey`, a Bedrock API key.
158
+ *
159
+ * @stability unstable
160
+ * @category options
161
+ * @since 0.1.0
162
+ */
163
+ export type Options<R = never> = CommonOptions & (StaticKeys | ProvidedKeys<R> | ApiKey);
164
+ /**
165
+ * The {@link Options} of {@link layerConfig}, with a `Config` for each value.
166
+ * `credentialProvider` and `transformClient` are not configuration, so they
167
+ * take the same values as in {@link Options}.
168
+ *
169
+ * @stability unstable
170
+ * @category options
171
+ * @since 0.2.0
172
+ */
173
+ export type ConfigOptions<R = never> = {
174
+ readonly apiUrl?: Config.Config<string> | undefined;
175
+ readonly region?: Config.Config<string> | undefined;
176
+ readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
177
+ } & ({
178
+ readonly accessKeyId: Config.Config<string>;
179
+ readonly secretAccessKey: Config.Config<Redacted.Redacted<string>>;
180
+ readonly sessionToken?: Config.Config<Redacted.Redacted<string>> | undefined;
181
+ readonly credentialProvider?: never;
182
+ readonly apiKey?: never;
183
+ } | ProvidedKeys<R> | {
184
+ readonly apiKey: Config.Config<Redacted.Redacted<string>>;
185
+ readonly accessKeyId?: never;
186
+ readonly secretAccessKey?: never;
187
+ readonly sessionToken?: never;
188
+ readonly credentialProvider?: never;
189
+ });
71
190
  /**
72
191
  * Creates an Amazon Bedrock client service with the given options.
73
192
  *
74
193
  * @stability unstable
75
194
  * @category constructors
76
- * @since 4.0.0
195
+ * @since 0.1.0
77
196
  */
78
- export declare const make: (options: Options) => Effect.Effect<Service, never, HttpClient.HttpClient>;
197
+ export declare const make: <R = never>(options: Options<R>) => Effect.Effect<Service, never, HttpClient.HttpClient | R>;
79
198
  /**
80
199
  * Creates a layer for the Amazon Bedrock client with the given options.
81
200
  *
82
201
  * @stability unstable
83
202
  * @category layers
84
- * @since 4.0.0
203
+ * @since 0.1.0
85
204
  */
86
- export declare const layer: (options: Options) => Layer.Layer<AmazonBedrockClient, never, HttpClient.HttpClient>;
205
+ export declare const layer: <R = never>(options: Options<R>) => Layer.Layer<AmazonBedrockClient, never, HttpClient.HttpClient | R>;
87
206
  /**
88
207
  * Creates a layer for the Amazon Bedrock client, loading credentials and other
89
208
  * settings via Effect's `Config` module.
90
209
  *
91
210
  * @stability unstable
92
211
  * @category layers
93
- * @since 4.0.0
212
+ * @since 0.1.0
94
213
  */
95
- export declare const layerConfig: (options: {
96
- readonly apiUrl?: Config.Config<string> | undefined;
97
- readonly accessKeyId: Config.Config<string>;
98
- readonly secretAccessKey: Config.Config<Redacted.Redacted<string>>;
99
- readonly sessionToken?: Config.Config<Redacted.Redacted<string>> | undefined;
100
- readonly region?: Config.Config<string> | undefined;
101
- readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
102
- }) => Layer.Layer<AmazonBedrockClient, Config.ConfigError, HttpClient.HttpClient>;
214
+ export declare const layerConfig: <R = never>(options: ConfigOptions<R>) => Layer.Layer<AmazonBedrockClient, Config.ConfigError, HttpClient.HttpClient | R>;
103
215
  export {};
104
216
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G,CAAC,CAClB,CAAA;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,GAAG,KAAK,WAC1B,aAAa,CAAC,CAAC,CAAC,KACxB,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC,CAe9E,CAAA"}
@@ -1,21 +1,3 @@
1
- /**
2
- * The `AmazonBedrockClient` module defines the low-level Effect service used to
3
- * call Amazon Bedrock's Converse API. It wraps an `HttpClient` with SigV4
4
- * request signing (via `aws4fetch`), request defaults, response decoding, and
5
- * error mapping to the unified `AiError` type.
6
- *
7
- * **Mental model**
8
- *
9
- * `HttpClient.HttpClient` provides the transport. {@link make} turns explicit
10
- * {@link Options} into an {@link AmazonBedrockClient} service, while
11
- * {@link layer} and {@link layerConfig} provide that service as a layer. The
12
- * service exposes handwritten helpers for the `converse` (non-streaming) and
13
- * `converse-stream` (streaming) endpoints.
14
- *
15
- * @stability unstable
16
- * @since 4.0.0
17
- */
18
- import { AwsV4Signer } from "aws4fetch";
19
1
  import * as Array from "effect/Array";
20
2
  import * as Context from "effect/Context";
21
3
  import * as Effect from "effect/Effect";
@@ -26,12 +8,11 @@ import * as HttpClient from "effect/http/HttpClient";
26
8
  import * as HttpClientRequest from "effect/http/HttpClientRequest";
27
9
  import * as HttpClientResponse from "effect/http/HttpClientResponse";
28
10
  import * as Layer from "effect/Layer";
29
- import * as Predicate from "effect/Predicate";
30
- import * as Redacted from "effect/Redacted";
31
11
  import * as Stream from "effect/Stream";
32
12
  import { AmazonBedrockConfig } from "./AmazonBedrockConfig.js";
33
13
  import * as EventStream from "./AmazonBedrockEventStream.js";
34
14
  import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSchema.js";
15
+ import * as Authentication from "./internal/credentials.js";
35
16
  import * as Errors from "./internal/errors.js";
36
17
  // =============================================================================
37
18
  // Service Identifier
@@ -41,7 +22,7 @@ import * as Errors from "./internal/errors.js";
41
22
  *
42
23
  * @stability unstable
43
24
  * @category services
44
- * @since 4.0.0
25
+ * @since 0.1.0
45
26
  */
46
27
  export class AmazonBedrockClient extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockClient") {}
47
28
  // =============================================================================
@@ -57,48 +38,35 @@ const withRedactedHeaders = /*#__PURE__*/Effect.updateService(Headers.CurrentRed
57
38
  *
58
39
  * @stability unstable
59
40
  * @category constructors
60
- * @since 4.0.0
41
+ * @since 0.1.0
61
42
  */
62
- export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
43
+ export const make = options => makeUnsafe(options);
44
+ // Takes each authentication field as optional, as `layerConfig` reads them.
45
+ // `Authentication.make` dies on a mix of the ways to authenticate.
46
+ const makeUnsafe = options => Effect.gen(function* () {
63
47
  const region = options.region ?? "us-east-1";
48
+ const authenticator = yield* Authentication.make(options);
64
49
  const baseClient = yield* HttpClient.HttpClient;
65
- const httpClient = baseClient.pipe(HttpClient.mapRequest(request => request.pipe(HttpClientRequest.prependUrl(options.apiUrl ?? `https://bedrock-runtime.${region}.amazonaws.com`), HttpClientRequest.acceptJson)), HttpClient.mapRequestEffect(Effect.fnUntraced(function* (request) {
66
- const originalHeaders = request.headers;
67
- const signer = new AwsV4Signer({
68
- service: "bedrock",
69
- url: request.url,
70
- method: request.method,
71
- headers: Object.entries(originalHeaders),
72
- body: prepareBody(request.body),
73
- region,
74
- accessKeyId: options.accessKeyId,
75
- secretAccessKey: Redacted.value(options.secretAccessKey),
76
- ...(options.sessionToken ? {
77
- sessionToken: Redacted.value(options.sessionToken)
78
- } : {})
79
- });
80
- const {
81
- headers: signedHeaders
82
- } = yield* Effect.promise(() => signer.sign());
83
- const headers = Headers.merge(originalHeaders, Headers.fromInput(signedHeaders));
84
- return HttpClientRequest.setHeaders(request, headers);
85
- })), options.transformClient ? options.transformClient : identity);
50
+ const httpClient = baseClient.pipe(HttpClient.mapRequest(request => request.pipe(HttpClientRequest.prependUrl(options.apiUrl ?? `https://bedrock-runtime.${region}.amazonaws.com`), HttpClientRequest.acceptJson)), HttpClient.mapRequestEffect(Authentication.authenticateRequest(region)), options.transformClient ? options.transformClient : identity);
86
51
  const httpClientOk = HttpClient.filterStatusOk(httpClient);
87
52
  const withConfigClient = Effect.fnUntraced(function* () {
88
53
  const config = yield* AmazonBedrockConfig.getOrUndefined;
89
54
  return config?.transformClient ? config.transformClient(httpClientOk) : httpClientOk;
90
55
  });
56
+ const resolveCredentials = method => Effect.mapError(authenticator.resolve, Errors.mapCredentialProviderError(method));
91
57
  const converse = ({
92
58
  payload: {
93
59
  modelId,
94
60
  ...body
95
61
  }
96
- }) => Effect.flatMap(withConfigClient(), client => {
62
+ }) => Effect.gen(function* () {
63
+ const client = yield* withConfigClient();
64
+ const credentials = yield* resolveCredentials("converse");
97
65
  const request = HttpClientRequest.post(`/model/${modelId}/converse`, {
98
66
  body: HttpBody.jsonUnsafe(body)
99
67
  });
100
- return client.execute(request).pipe(Effect.flatMap(HttpClientResponse.schemaBodyJson(ConverseResponse)), Effect.catchTags({
101
- HttpClientError: error => Errors.mapHttpClientError(error, "converse"),
68
+ return yield* client.execute(request).pipe(Effect.provideService(Authentication.CurrentRequestCredentials, credentials), Effect.flatMap(HttpClientResponse.schemaBodyJson(ConverseResponse)), Effect.catchTags({
69
+ HttpClientError: error => Errors.mapHttpClientError(error, "converse").pipe(Effect.tapError(Authentication.invalidateIfRejected(authenticator, credentials))),
102
70
  SchemaError: error => Effect.fail(Errors.mapSchemaError(error, "converse"))
103
71
  }), withRedactedHeaders);
104
72
  });
@@ -111,17 +79,21 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
111
79
  const request = HttpClientRequest.post(`/model/${modelId}/converse-stream`, {
112
80
  body: HttpBody.jsonUnsafe(body)
113
81
  });
114
- return Stream.unwrap(Effect.map(withConfigClient(), client => client.execute(request).pipe(Effect.map(response => response.stream), Stream.unwrap, Stream.pipeThroughChannel(EventStream.makeChannel(ConverseResponseStreamEvent)), Stream.catchTags({
115
- HttpClientError: error => Stream.fromEffect(Errors.mapHttpClientError(error, "converseStream")),
116
- SchemaError: error => Stream.fail(Errors.mapSchemaError(error, "converseStream")),
117
- EventStreamError: error => Stream.fail(Errors.mapEventStreamError(error, "converseStream"))
118
- }), Stream.updateService(Headers.CurrentRedactedNames, appendRedactedHeaders))));
82
+ return Stream.unwrap(Effect.gen(function* () {
83
+ const client = yield* withConfigClient();
84
+ const credentials = yield* resolveCredentials("converseStream");
85
+ return client.execute(request).pipe(Effect.provideService(Authentication.CurrentRequestCredentials, credentials), Effect.map(response => response.stream), Stream.unwrap, Stream.pipeThroughChannel(EventStream.makeChannel(ConverseResponseStreamEvent)), Stream.catchTags({
86
+ HttpClientError: error => Stream.fromEffect(Errors.mapHttpClientError(error, "converseStream").pipe(Effect.tapError(Authentication.invalidateIfRejected(authenticator, credentials)))),
87
+ SchemaError: error => Stream.fail(Errors.mapSchemaError(error, "converseStream")),
88
+ EventStreamError: error => Stream.fail(Errors.mapEventStreamError(error, "converseStream"))
89
+ }), Stream.updateService(Headers.CurrentRedactedNames, appendRedactedHeaders));
90
+ }));
119
91
  };
120
92
  return AmazonBedrockClient.of({
121
93
  converse,
122
94
  converseStream
123
95
  });
124
- }, withRedactedHeaders);
96
+ }).pipe(withRedactedHeaders);
125
97
  // =============================================================================
126
98
  // Layers
127
99
  // =============================================================================
@@ -130,7 +102,7 @@ export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
130
102
  *
131
103
  * @stability unstable
132
104
  * @category layers
133
- * @since 4.0.0
105
+ * @since 0.1.0
134
106
  */
135
107
  export const layer = options => Layer.effect(AmazonBedrockClient, make(options));
136
108
  /**
@@ -139,47 +111,19 @@ export const layer = options => Layer.effect(AmazonBedrockClient, make(options))
139
111
  *
140
112
  * @stability unstable
141
113
  * @category layers
142
- * @since 4.0.0
114
+ * @since 0.1.0
143
115
  */
144
116
  export const layerConfig = options => Layer.effect(AmazonBedrockClient, Effect.gen(function* () {
145
- const apiUrl = Predicate.isNotUndefined(options.apiUrl) ? yield* options.apiUrl : undefined;
146
- const accessKeyId = yield* options.accessKeyId;
147
- const secretAccessKey = yield* options.secretAccessKey;
148
- const sessionToken = Predicate.isNotUndefined(options.sessionToken) ? yield* options.sessionToken : undefined;
149
- const region = Predicate.isNotUndefined(options.region) ? yield* options.region : undefined;
150
- return yield* make({
151
- apiUrl,
152
- accessKeyId,
153
- secretAccessKey,
154
- sessionToken,
155
- region,
117
+ return yield* makeUnsafe({
118
+ apiUrl: yield* readOptional(options.apiUrl),
119
+ region: yield* readOptional(options.region),
120
+ accessKeyId: yield* readOptional(options.accessKeyId),
121
+ secretAccessKey: yield* readOptional(options.secretAccessKey),
122
+ sessionToken: yield* readOptional(options.sessionToken),
123
+ apiKey: yield* readOptional(options.apiKey),
124
+ credentialProvider: options.credentialProvider,
156
125
  transformClient: options.transformClient
157
126
  });
158
127
  }));
159
- // =============================================================================
160
- // Utilities
161
- // =============================================================================
162
- const prepareBody = body => {
163
- switch (body._tag) {
164
- case "Empty":
165
- {
166
- return "";
167
- }
168
- case "Raw":
169
- case "Uint8Array":
170
- {
171
- if (typeof body.body === "string") {
172
- return body.body;
173
- }
174
- if (body.body instanceof Uint8Array) {
175
- return new TextDecoder().decode(body.body);
176
- }
177
- if (body.body instanceof ArrayBuffer) {
178
- return new TextDecoder().decode(body.body);
179
- }
180
- return JSON.stringify(body.body);
181
- }
182
- }
183
- throw new Error("Unsupported HttpBody: " + body._tag);
184
- };
128
+ const readOptional = config => config === undefined ? Effect.undefined : config;
185
129
  //# sourceMappingURL=AmazonBedrockClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AmazonBedrockClient.js","names":[],"sources":["../src/AmazonBedrockClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;AAiBA,SAAS,WAAW,QAAQ,WAAW;AAEvC,OAAO,KAAK,KAAK,MAAM,cAAc;AAErC,OAAO,KAAK,OAAO,MAAM,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,YAAY,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,YAAY,CAAC,GAC/D,OAAO,OAAO,CAAC,YAAY,GAC7B,SAAS;EACX,MAAM,MAAM,GAAG,SAAS,CAAC,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,GACnD,OAAO,OAAO,CAAC,MAAM,GACvB,SAAS;EACX,OAAO,OAAO,IAAI,CAAC;IACjB,MAAM;IACN,WAAW;IACX,eAAe;IACf,YAAY;IACZ,MAAM;IACN,eAAe,EAAE,OAAO,CAAC;GAC1B,CAAC;AACJ,CAAC,CAAC,CACH;AAEH;AACA;AACA;AAEA,MAAM,WAAW,GAAI,IAAuB,IAAY;EACtD,QAAQ,IAAI,CAAC,IAAI;IACf,KAAK,OAAO;MAAE;QACZ,OAAO,EAAE;MACX;IACA,KAAK,KAAK;IACV,KAAK,YAAY;MAAE;QACjB,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE;UACjC,OAAO,IAAI,CAAC,IAAI;QAClB;QACA,IAAI,IAAI,CAAC,IAAI,YAAY,UAAU,EAAE;UACnC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5C;QACA,IAAI,IAAI,CAAC,IAAI,YAAY,WAAW,EAAE;UACpC,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;QAC5C;QACA,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;MAClC;EACF;EACA,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,IAAI,CAAC,IAAI,CAAC;AACvD,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"AmazonBedrockClient.js","names":[],"sources":["../src/AmazonBedrockClient.ts"],"sourcesContent":[null],"mappings":"AAkBA,OAAO,KAAK,KAAK,MAAM,cAAc;AAErC,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,MAAM,MA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