@wmaurer/effect-ai-amazon-bedrock 0.0.0-stage → 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/LICENSE +22 -0
  3. package/README.md +429 -2
  4. package/dist/AmazonBedrockClient.d.ts +216 -0
  5. package/dist/AmazonBedrockClient.d.ts.map +1 -0
  6. package/dist/AmazonBedrockClient.js +129 -0
  7. package/dist/AmazonBedrockClient.js.map +1 -0
  8. package/dist/AmazonBedrockConfig.d.ts +59 -0
  9. package/dist/AmazonBedrockConfig.d.ts.map +1 -0
  10. package/dist/AmazonBedrockConfig.js +40 -0
  11. package/dist/AmazonBedrockConfig.js.map +1 -0
  12. package/dist/AmazonBedrockEventStream.d.ts +29 -0
  13. package/dist/AmazonBedrockEventStream.d.ts.map +1 -0
  14. package/dist/AmazonBedrockEventStream.js +197 -0
  15. package/dist/AmazonBedrockEventStream.js.map +1 -0
  16. package/dist/AmazonBedrockLanguageModel.d.ts +418 -0
  17. package/dist/AmazonBedrockLanguageModel.d.ts.map +1 -0
  18. package/dist/AmazonBedrockLanguageModel.js +1303 -0
  19. package/dist/AmazonBedrockLanguageModel.js.map +1 -0
  20. package/dist/AmazonBedrockSchema.d.ts +957 -0
  21. package/dist/AmazonBedrockSchema.d.ts.map +1 -0
  22. package/dist/AmazonBedrockSchema.js +775 -0
  23. package/dist/AmazonBedrockSchema.js.map +1 -0
  24. package/dist/index.d.ts +30 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +31 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/internal/credentials.d.ts +79 -0
  29. package/dist/internal/credentials.d.ts.map +1 -0
  30. package/dist/internal/credentials.js +241 -0
  31. package/dist/internal/credentials.js.map +1 -0
  32. package/dist/internal/errors.d.ts +32 -0
  33. package/dist/internal/errors.d.ts.map +1 -0
  34. package/dist/internal/errors.js +267 -0
  35. package/dist/internal/errors.js.map +1 -0
  36. package/dist/internal/utilities.d.ts +5 -0
  37. package/dist/internal/utilities.d.ts.map +1 -0
  38. package/dist/internal/utilities.js +18 -0
  39. package/dist/internal/utilities.js.map +1 -0
  40. package/package.json +66 -3
  41. package/src/AmazonBedrockClient.ts +386 -0
  42. package/src/AmazonBedrockConfig.ts +73 -0
  43. package/src/AmazonBedrockEventStream.ts +229 -0
  44. package/src/AmazonBedrockLanguageModel.ts +1746 -0
  45. package/src/AmazonBedrockSchema.ts +887 -0
  46. package/src/index.ts +36 -0
  47. package/src/internal/credentials.ts +319 -0
  48. package/src/internal/errors.ts +310 -0
  49. package/src/internal/utilities.ts +21 -0
@@ -0,0 +1,216 @@
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
+ */
18
+ import type * as AiError from "effect/ai/AiError";
19
+ import type * as Config from "effect/Config";
20
+ import * as Context from "effect/Context";
21
+ import * as Effect from "effect/Effect";
22
+ import * as HttpClient from "effect/http/HttpClient";
23
+ import * as Layer from "effect/Layer";
24
+ import type * as Redacted from "effect/Redacted";
25
+ import * as Stream from "effect/Stream";
26
+ import type { ConverseRequest } from "./AmazonBedrockSchema.ts";
27
+ import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSchema.ts";
28
+ /**
29
+ * Represents the Amazon Bedrock client service with methods for the Converse
30
+ * API, including regular and streaming message creation.
31
+ *
32
+ * @stability unstable
33
+ * @category models
34
+ * @since 0.1.0
35
+ */
36
+ export interface Service {
37
+ /**
38
+ * Creates a message using the Bedrock Converse API and maps all errors to the
39
+ * unified `AiError` type.
40
+ */
41
+ readonly converse: (options: {
42
+ readonly payload: typeof ConverseRequest.Encoded;
43
+ }) => Effect.Effect<ConverseResponse, AiError.AiError>;
44
+ /**
45
+ * Creates a streaming message using the Bedrock `converse-stream` API and maps
46
+ * all errors to the unified `AiError` type.
47
+ */
48
+ readonly converseStream: (options: {
49
+ readonly payload: typeof ConverseRequest.Encoded;
50
+ }) => Stream.Stream<ConverseResponseStreamEvent, AiError.AiError>;
51
+ }
52
+ declare const AmazonBedrockClient_base: Context.ServiceClass<AmazonBedrockClient, "@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockClient", Service>;
53
+ /**
54
+ * Service tag for the Amazon Bedrock client.
55
+ *
56
+ * @stability unstable
57
+ * @category services
58
+ * @since 0.1.0
59
+ */
60
+ export declare class AmazonBedrockClient extends AmazonBedrockClient_base {
61
+ }
62
+ /**
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.
66
+ *
67
+ * @stability unstable
68
+ * @category options
69
+ * @since 0.2.0
70
+ */
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 {
111
+ /**
112
+ * The base URL for the Bedrock runtime API. Override to use a proxy or a
113
+ * different endpoint.
114
+ *
115
+ * @default `https://bedrock-runtime.${region}.amazonaws.com`
116
+ */
117
+ readonly apiUrl?: string | undefined;
118
+ /**
119
+ * The AWS region.
120
+ *
121
+ * @default "us-east-1"
122
+ */
123
+ readonly region?: string | undefined;
124
+ readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
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
+ });
190
+ /**
191
+ * Creates an Amazon Bedrock client service with the given options.
192
+ *
193
+ * @stability unstable
194
+ * @category constructors
195
+ * @since 0.1.0
196
+ */
197
+ export declare const make: <R = never>(options: Options<R>) => Effect.Effect<Service, never, HttpClient.HttpClient | R>;
198
+ /**
199
+ * Creates a layer for the Amazon Bedrock client with the given options.
200
+ *
201
+ * @stability unstable
202
+ * @category layers
203
+ * @since 0.1.0
204
+ */
205
+ export declare const layer: <R = never>(options: Options<R>) => Layer.Layer<AmazonBedrockClient, never, HttpClient.HttpClient | R>;
206
+ /**
207
+ * Creates a layer for the Amazon Bedrock client, loading credentials and other
208
+ * settings via Effect's `Config` module.
209
+ *
210
+ * @stability unstable
211
+ * @category layers
212
+ * @since 0.1.0
213
+ */
214
+ export declare const layerConfig: <R = never>(options: ConfigOptions<R>) => Layer.Layer<AmazonBedrockClient, Config.ConfigError, HttpClient.HttpClient | R>;
215
+ export {};
216
+ //# sourceMappingURL=AmazonBedrockClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockClient.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAEjD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAA;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AAGpD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAChD,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAGvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC/D,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,0BAA0B,CAAA;AAQxF;;;;;;;GAOG;AACH,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,OAAO,EAAE;QAC3B,QAAQ,CAAC,OAAO,EAAE,OAAO,eAAe,CAAC,OAAO,CAAA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,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,CAAC,CACxF,CAAA;AA8FrB;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,CAAC,GAAG,KAAK,WACpB,OAAO,CAAC,CAAC,CAAC,KAClB,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,EAAE,UAAU,CAAC,UAAU,GAAG,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"}
@@ -0,0 +1,129 @@
1
+ import * as Array from "effect/Array";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import { identity } from "effect/Function";
5
+ import * as Headers from "effect/http/Headers";
6
+ import * as HttpBody from "effect/http/HttpBody";
7
+ import * as HttpClient from "effect/http/HttpClient";
8
+ import * as HttpClientRequest from "effect/http/HttpClientRequest";
9
+ import * as HttpClientResponse from "effect/http/HttpClientResponse";
10
+ import * as Layer from "effect/Layer";
11
+ import * as Stream from "effect/Stream";
12
+ import { AmazonBedrockConfig } from "./AmazonBedrockConfig.js";
13
+ import * as EventStream from "./AmazonBedrockEventStream.js";
14
+ import { ConverseResponse, ConverseResponseStreamEvent } from "./AmazonBedrockSchema.js";
15
+ import * as Authentication from "./internal/credentials.js";
16
+ import * as Errors from "./internal/errors.js";
17
+ // =============================================================================
18
+ // Service Identifier
19
+ // =============================================================================
20
+ /**
21
+ * Service tag for the Amazon Bedrock client.
22
+ *
23
+ * @stability unstable
24
+ * @category services
25
+ * @since 0.1.0
26
+ */
27
+ export class AmazonBedrockClient extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockClient") {}
28
+ // =============================================================================
29
+ // Constructor
30
+ // =============================================================================
31
+ const RedactedAmazonBedrockHeaders = {
32
+ AmzSecurityToken: "X-Amz-Security-Token"
33
+ };
34
+ const appendRedactedHeaders = /*#__PURE__*/Array.appendAll(/*#__PURE__*/Object.values(RedactedAmazonBedrockHeaders));
35
+ const withRedactedHeaders = /*#__PURE__*/Effect.updateService(Headers.CurrentRedactedNames, appendRedactedHeaders);
36
+ /**
37
+ * Creates an Amazon Bedrock client service with the given options.
38
+ *
39
+ * @stability unstable
40
+ * @category constructors
41
+ * @since 0.1.0
42
+ */
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* () {
47
+ const region = options.region ?? "us-east-1";
48
+ const authenticator = yield* Authentication.make(options);
49
+ const baseClient = yield* HttpClient.HttpClient;
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);
51
+ const httpClientOk = HttpClient.filterStatusOk(httpClient);
52
+ const withConfigClient = Effect.fnUntraced(function* () {
53
+ const config = yield* AmazonBedrockConfig.getOrUndefined;
54
+ return config?.transformClient ? config.transformClient(httpClientOk) : httpClientOk;
55
+ });
56
+ const resolveCredentials = method => Effect.mapError(authenticator.resolve, Errors.mapCredentialProviderError(method));
57
+ const converse = ({
58
+ payload: {
59
+ modelId,
60
+ ...body
61
+ }
62
+ }) => Effect.gen(function* () {
63
+ const client = yield* withConfigClient();
64
+ const credentials = yield* resolveCredentials("converse");
65
+ const request = HttpClientRequest.post(`/model/${modelId}/converse`, {
66
+ body: HttpBody.jsonUnsafe(body)
67
+ });
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))),
70
+ SchemaError: error => Effect.fail(Errors.mapSchemaError(error, "converse"))
71
+ }), withRedactedHeaders);
72
+ });
73
+ const converseStream = ({
74
+ payload: {
75
+ modelId,
76
+ ...body
77
+ }
78
+ }) => {
79
+ const request = HttpClientRequest.post(`/model/${modelId}/converse-stream`, {
80
+ body: HttpBody.jsonUnsafe(body)
81
+ });
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
+ }));
91
+ };
92
+ return AmazonBedrockClient.of({
93
+ converse,
94
+ converseStream
95
+ });
96
+ }).pipe(withRedactedHeaders);
97
+ // =============================================================================
98
+ // Layers
99
+ // =============================================================================
100
+ /**
101
+ * Creates a layer for the Amazon Bedrock client with the given options.
102
+ *
103
+ * @stability unstable
104
+ * @category layers
105
+ * @since 0.1.0
106
+ */
107
+ export const layer = options => Layer.effect(AmazonBedrockClient, make(options));
108
+ /**
109
+ * Creates a layer for the Amazon Bedrock client, loading credentials and other
110
+ * settings via Effect's `Config` module.
111
+ *
112
+ * @stability unstable
113
+ * @category layers
114
+ * @since 0.1.0
115
+ */
116
+ export const layerConfig = options => Layer.effect(AmazonBedrockClient, Effect.gen(function* () {
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,
125
+ transformClient: options.transformClient
126
+ });
127
+ }));
128
+ const readOptional = config => config === undefined ? Effect.undefined : config;
129
+ //# sourceMappingURL=AmazonBedrockClient.js.map
@@ -0,0 +1 @@
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,MAAM,eAAe;AACvC,SAAS,QAAQ,QAAQ,iBAAiB;AAC1C,OAAO,KAAK,OAAO,MAAM,qBAAqB;AAC9C,OAAO,KAAK,QAAQ,MAAM,sBAAsB;AAChD,OAAO,KAAK,UAAU,MAAM,wBAAwB;AACpD,OAAO,KAAK,iBAAiB,MAAM,+BAA+B;AAClE,OAAO,KAAK,kBAAkB,MAAM,gCAAgC;AACpE,OAAO,KAAK,KAAK,MAAM,cAAc;AAErC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,mBAAmB,QAAQ,0BAA0B;AAC9D,OAAO,KAAK,WAAW,MAAM,+BAA+B;AAE5D,SAAS,gBAAgB,EAAE,2BAA2B,QAAQ,0BAA0B;AACxF,OAAO,KAAK,cAAc,MAAM,2BAA2B;AAC3D,OAAO,KAAK,MAAM,MAAM,sBAAsB;AAgC9C;AACA;AACA;AAEA;;;;;;;AAOA,OAAM,MAAO,mBAAoB,sBAAQ,OAAO,CAAC,OAAO,EAAgC,CACtF,uDAAuD,CACxD;AAsJD;AAC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,mBAAmB,CAAC;AAE9B;AACA;AACA;AAEA;;;;;;;AAOA,OAAO,MAAM,KAAK,GAChB,OAAmB,IAEnB,KAAK,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;AAElD;;;;;;;;AAQA,OAAO,MAAM,WAAW,GACtB,OAAyB,IAEzB,KAAK,CAAC,MAAM,CACV,mBAAmB,EACnB,MAAM,CAAC,GAAG,CAAC,aAAS;EAClB,OAAO,OAAO,UAAU,CAAC;IACvB,MAAM,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3C,MAAM,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3C,WAAW,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC;IACrD,eAAe,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC;IAC7D,YAAY,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC;IACvD,MAAM,EAAE,OAAO,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC;IAC3C,kBAAkB,EAAE,OAAO,CAAC,kBAAkB;IAC9C,eAAe,EAAE,OAAO,CAAC;GAC1B,CAAC;AACJ,CAAC,CAAC,CACH;AAEH,MAAM,YAAY,GAAO,MAAoC,IAC3D,MAAM,KAAK,SAAS,GAAG,MAAM,CAAC,SAAS,GAAG,MAAM","ignoreList":[]}
@@ -0,0 +1,59 @@
1
+ /**
2
+ * The `AmazonBedrockConfig` module provides contextual configuration for the
3
+ * Amazon Bedrock AI provider integration. It is used to customize the
4
+ * underlying HTTP client without changing individual request code.
5
+ *
6
+ * @stability unstable
7
+ * @since 0.1.0
8
+ */
9
+ import * as Context from "effect/Context";
10
+ import * as Effect from "effect/Effect";
11
+ import type { HttpClient } from "effect/http/HttpClient";
12
+ declare const AmazonBedrockConfig_base: Context.ServiceClass<AmazonBedrockConfig, "@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockConfig", AmazonBedrockConfig.Service>;
13
+ /**
14
+ * Service tag for Amazon Bedrock client configuration overrides, such as
15
+ * transformations applied to the underlying HTTP client.
16
+ *
17
+ * @stability unstable
18
+ * @category services
19
+ * @since 0.1.0
20
+ */
21
+ export declare class AmazonBedrockConfig extends AmazonBedrockConfig_base {
22
+ /**
23
+ * Gets the configured Amazon Bedrock service from the current context when present.
24
+ *
25
+ * @since 0.1.0
26
+ */
27
+ static readonly getOrUndefined: Effect.Effect<typeof AmazonBedrockConfig.Service | undefined>;
28
+ }
29
+ /**
30
+ * Namespace containing types associated with the `AmazonBedrockConfig` service.
31
+ *
32
+ * @stability unstable
33
+ * @since 0.1.0
34
+ */
35
+ export declare namespace AmazonBedrockConfig {
36
+ /**
37
+ * Configuration provided through `AmazonBedrockConfig`.
38
+ *
39
+ * @category models
40
+ * @since 0.1.0
41
+ */
42
+ interface Service {
43
+ readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined;
44
+ }
45
+ }
46
+ /**
47
+ * Runs an effect with an `AmazonBedrockConfig` override that transforms the
48
+ * underlying `HttpClient` used by Amazon Bedrock requests.
49
+ *
50
+ * @stability unstable
51
+ * @category configuration
52
+ * @since 0.1.0
53
+ */
54
+ export declare const withClientTransform: {
55
+ (transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
56
+ <A, E, R>(self: Effect.Effect<A, E, R>, transform: (client: HttpClient) => HttpClient): Effect.Effect<A, E, R>;
57
+ };
58
+ export {};
59
+ //# sourceMappingURL=AmazonBedrockConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockConfig.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;;AAExD;;;;;;;GAOG;AACH,qBAAa,mBAAoB,SAAQ,wBAGmB;IAC1D;;;;OAIG;IACH,MAAM,CAAC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,mBAAmB,CAAC,OAAO,GAAG,SAAS,CAAC,CAG5F;CACF;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,WAAW,mBAAmB,CAAC;IAC3C;;;;;OAKG;IACH,UAAiB,OAAO;QACtB,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,CAAC,GAAG,SAAS,CAAA;KAC5E;CACF;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,EAAE;IAChC,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAClH,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CAQ5G,CAAA"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * The `AmazonBedrockConfig` module provides contextual configuration for the
3
+ * Amazon Bedrock AI provider integration. It is used to customize the
4
+ * underlying HTTP client without changing individual request code.
5
+ *
6
+ * @stability unstable
7
+ * @since 0.1.0
8
+ */
9
+ import * as Context from "effect/Context";
10
+ import * as Effect from "effect/Effect";
11
+ import { dual } from "effect/Function";
12
+ /**
13
+ * Service tag for Amazon Bedrock client configuration overrides, such as
14
+ * transformations applied to the underlying HTTP client.
15
+ *
16
+ * @stability unstable
17
+ * @category services
18
+ * @since 0.1.0
19
+ */
20
+ export class AmazonBedrockConfig extends /*#__PURE__*/Context.Service()("@wmaurer/effect-ai-amazon-bedrock/AmazonBedrockConfig") {
21
+ /**
22
+ * Gets the configured Amazon Bedrock service from the current context when present.
23
+ *
24
+ * @since 0.1.0
25
+ */
26
+ static getOrUndefined = /*#__PURE__*/Effect.map(/*#__PURE__*/Effect.context(), services => services.mapUnsafe.get(AmazonBedrockConfig.key));
27
+ }
28
+ /**
29
+ * Runs an effect with an `AmazonBedrockConfig` override that transforms the
30
+ * underlying `HttpClient` used by Amazon Bedrock requests.
31
+ *
32
+ * @stability unstable
33
+ * @category configuration
34
+ * @since 0.1.0
35
+ */
36
+ export const withClientTransform = /*#__PURE__*/dual(2, (self, transformClient) => Effect.flatMap(AmazonBedrockConfig.getOrUndefined, config => Effect.provideService(self, AmazonBedrockConfig, {
37
+ ...config,
38
+ transformClient
39
+ })));
40
+ //# sourceMappingURL=AmazonBedrockConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockConfig.js","names":[],"sources":["../src/AmazonBedrockConfig.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;AAQA,OAAO,KAAK,OAAO,MAAM,gBAAgB;AACzC,OAAO,KAAK,MAAM,MAAM,eAAe;AACvC,SAAS,IAAI,QAAQ,iBAAiB;AAGtC;;;;;;;;AAQA,OAAM,MAAO,mBAAoB,sBAAQ,OAAO,CAAC,OAAO,EAGrD,CAAC,uDAAuD,CAAC;EAC1D;;;;;EAKA,OAAgB,cAAc,gBAAkE,MAAM,CAAC,GAAG,cACxG,MAAM,CAAC,OAAO,EAAS,EACtB,QAAQ,IAAK,QAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAC9D;;AAqBH;;;;;;;;AAQA,OAAO,MAAM,mBAAmB,gBAG5B,IAAI,CAAC,CAAC,EAAE,CACV,IAA4B,EAC5B,eAAmD,KAEnD,MAAM,CAAC,OAAO,CACZ,mBAAmB,CAAC,cAAc,EACjC,MAAM,IAAK,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,EAAE;EAAE,GAAG,MAAM;EAAE;AAAe,CAAE,CAAC,CAC7F,CAAC","ignoreList":[]}
@@ -0,0 +1,29 @@
1
+ import type { NonEmptyReadonlyArray } from "effect/Array";
2
+ import * as Channel from "effect/Channel";
3
+ import * as Schema from "effect/Schema";
4
+ declare const EventStreamError_base: Schema.Class<EventStreamError, Schema.TaggedStruct<"EventStreamError", {
5
+ readonly code: Schema.optional<Schema.String>;
6
+ readonly message: Schema.optional<Schema.String>;
7
+ }>, import("effect/Cause").YieldableError>;
8
+ /**
9
+ * Raised when the event stream carries a transport-level error frame
10
+ * (`:message-type: error`). These frames have no JSON body; the error is
11
+ * described by the `:error-code` and `:error-message` headers.
12
+ *
13
+ * @stability unstable
14
+ * @category errors
15
+ * @since 0.1.0
16
+ */
17
+ export declare class EventStreamError extends EventStreamError_base {
18
+ }
19
+ /**
20
+ * Builds a channel that decodes AWS event-stream frames into values of the
21
+ * provided schema.
22
+ *
23
+ * @stability unstable
24
+ * @category constructors
25
+ * @since 0.1.0
26
+ */
27
+ export declare const makeChannel: <A, I, RD, IE, Done>(schema: Schema.Codec<A, I, RD>) => Channel.Channel<NonEmptyReadonlyArray<A>, IE | Schema.SchemaError | EventStreamError, Done, NonEmptyReadonlyArray<Uint8Array>, IE, Done, RD>;
28
+ export {};
29
+ //# sourceMappingURL=AmazonBedrockEventStream.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockEventStream.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockEventStream.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAA;AACzD,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AAGzC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;;;;;AAIvC;;;;;;;;GAQG;AACH,qBAAa,gBAAiB,SAAQ,qBAKpC;CAAG;AA0FL;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,UACpC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAC7B,OAAO,CAAC,OAAO,CAChB,qBAAqB,CAAC,CAAC,CAAC,EACxB,EAAE,GAAG,MAAM,CAAC,WAAW,GAAG,gBAAgB,EAC1C,IAAI,EACJ,qBAAqB,CAAC,UAAU,CAAC,EACjC,EAAE,EACF,IAAI,EACJ,EAAE,CA6ED,CAAA"}