@effect/ai-amazon-bedrock 0.17.0 → 4.1.4

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 (186) hide show
  1. package/AGENTS.md +434 -0
  2. package/CLAUDE.md +434 -0
  3. package/README.md +76 -3
  4. package/ai-docs/README.md +44 -0
  5. package/ai-docs/package.json +36 -0
  6. package/ai-docs/src/01_effect/01_basics/01_effect-gen.ts +30 -0
  7. package/ai-docs/src/01_effect/01_basics/02_effect-fn.ts +52 -0
  8. package/ai-docs/src/01_effect/01_basics/10_creating-effects.ts +74 -0
  9. package/ai-docs/src/01_effect/01_basics/index.md +7 -0
  10. package/ai-docs/src/01_effect/02_schema/10_schema-basics.ts +43 -0
  11. package/ai-docs/src/01_effect/02_schema/index.md +7 -0
  12. package/ai-docs/src/01_effect/03_services/01_service.ts +45 -0
  13. package/ai-docs/src/01_effect/03_services/10_reference.ts +10 -0
  14. package/ai-docs/src/01_effect/03_services/20_layer-composition.ts +70 -0
  15. package/ai-docs/src/01_effect/03_services/20_layer-unwrap.ts +66 -0
  16. package/ai-docs/src/01_effect/03_services/index.md +5 -0
  17. package/ai-docs/src/01_effect/04_errors/01_error-handling.ts +30 -0
  18. package/ai-docs/src/01_effect/04_errors/10_catch-tags.ts +24 -0
  19. package/ai-docs/src/01_effect/04_errors/20_reason-errors.ts +64 -0
  20. package/ai-docs/src/01_effect/04_errors/index.md +1 -0
  21. package/ai-docs/src/01_effect/05_resources/10_acquire-release.ts +105 -0
  22. package/ai-docs/src/01_effect/05_resources/20_layer-side-effects.ts +31 -0
  23. package/ai-docs/src/01_effect/05_resources/30_layer-map.ts +86 -0
  24. package/ai-docs/src/01_effect/05_resources/index.md +3 -0
  25. package/ai-docs/src/01_effect/06_running/10_run-main.ts +30 -0
  26. package/ai-docs/src/01_effect/06_running/20_layer-launch.ts +27 -0
  27. package/ai-docs/src/01_effect/06_running/index.md +1 -0
  28. package/ai-docs/src/01_effect/07_pubsub/10_pubsub.ts +56 -0
  29. package/ai-docs/src/01_effect/07_pubsub/index.md +3 -0
  30. package/ai-docs/src/03_stream/10_creating-streams.ts +103 -0
  31. package/ai-docs/src/03_stream/20_consuming-streams.ts +137 -0
  32. package/ai-docs/src/03_stream/30_encoding.ts +163 -0
  33. package/ai-docs/src/03_stream/index.md +4 -0
  34. package/ai-docs/src/04_integration/10_managed-runtime.ts +129 -0
  35. package/ai-docs/src/04_integration/index.md +5 -0
  36. package/ai-docs/src/05_batching/10_request-resolver.ts +89 -0
  37. package/ai-docs/src/05_batching/index.md +3 -0
  38. package/ai-docs/src/06_schedule/10_schedules.ts +111 -0
  39. package/ai-docs/src/06_schedule/index.md +3 -0
  40. package/ai-docs/src/07_datetime/10_creating-and-formatting.ts +30 -0
  41. package/ai-docs/src/07_datetime/20_time-zones.ts +44 -0
  42. package/ai-docs/src/07_datetime/index.md +5 -0
  43. package/ai-docs/src/08_observability/10_logging.ts +66 -0
  44. package/ai-docs/src/08_observability/20_otlp-tracing.ts +95 -0
  45. package/ai-docs/src/08_observability/index.md +7 -0
  46. package/ai-docs/src/09_testing/10_effect-tests.ts +55 -0
  47. package/ai-docs/src/09_testing/20_layer-tests.ts +138 -0
  48. package/ai-docs/src/09_testing/index.md +1 -0
  49. package/ai-docs/src/10_predicate/01_basics.ts +14 -0
  50. package/ai-docs/src/10_predicate/index.md +9 -0
  51. package/ai-docs/src/40_sql/10_basics.ts +175 -0
  52. package/ai-docs/src/40_sql/index.md +6 -0
  53. package/ai-docs/src/50_http-client/10_basics.ts +102 -0
  54. package/ai-docs/src/50_http-client/index.md +3 -0
  55. package/ai-docs/src/51_http-server/10_basics.ts +118 -0
  56. package/ai-docs/src/51_http-server/20_testing.ts +100 -0
  57. package/ai-docs/src/51_http-server/fixtures/api/Api.ts +14 -0
  58. package/ai-docs/src/51_http-server/fixtures/api/Authorization.ts +36 -0
  59. package/ai-docs/src/51_http-server/fixtures/api/System.ts +10 -0
  60. package/ai-docs/src/51_http-server/fixtures/api/Users.ts +107 -0
  61. package/ai-docs/src/51_http-server/fixtures/domain/User.ts +21 -0
  62. package/ai-docs/src/51_http-server/fixtures/domain/UserErrors.ts +22 -0
  63. package/ai-docs/src/51_http-server/fixtures/server/Authorization.ts +37 -0
  64. package/ai-docs/src/51_http-server/fixtures/server/Users/http.ts +80 -0
  65. package/ai-docs/src/51_http-server/fixtures/server/Users.ts +183 -0
  66. package/ai-docs/src/51_http-server/index.md +3 -0
  67. package/ai-docs/src/52_graphql/10_basics.ts +117 -0
  68. package/ai-docs/src/52_graphql/20_testing.ts +45 -0
  69. package/ai-docs/src/52_graphql/30_batching.ts +118 -0
  70. package/ai-docs/src/52_graphql/40_aliased-batching.ts +124 -0
  71. package/ai-docs/src/52_graphql/50_errors-and-retries.ts +74 -0
  72. package/ai-docs/src/52_graphql/index.md +6 -0
  73. package/ai-docs/src/60_child-process/10_working-with-child-processes.ts +117 -0
  74. package/ai-docs/src/60_child-process/index.md +3 -0
  75. package/ai-docs/src/70_cli/10_basics.ts +162 -0
  76. package/ai-docs/src/70_cli/index.md +5 -0
  77. package/ai-docs/src/71_ai/10_language-model.ts +156 -0
  78. package/ai-docs/src/71_ai/20_tools.ts +226 -0
  79. package/ai-docs/src/71_ai/30_chat.ts +158 -0
  80. package/ai-docs/src/71_ai/fixtures/domain/LaunchPlan.ts +9 -0
  81. package/ai-docs/src/71_ai/index.md +5 -0
  82. package/ai-docs/src/80_cluster/10_entities.ts +97 -0
  83. package/ai-docs/src/80_cluster/index.md +4 -0
  84. package/ai-docs/src/index.md +10 -0
  85. package/ai-docs/tsconfig.json +28 -0
  86. package/dist/AmazonBedrockClient.d.ts +227 -0
  87. package/dist/AmazonBedrockClient.d.ts.map +1 -0
  88. package/dist/AmazonBedrockClient.js +281 -0
  89. package/dist/AmazonBedrockClient.js.map +1 -0
  90. package/dist/AmazonBedrockConfig.d.ts +76 -0
  91. package/dist/AmazonBedrockConfig.d.ts.map +1 -0
  92. package/dist/AmazonBedrockConfig.js +41 -0
  93. package/dist/AmazonBedrockConfig.js.map +1 -0
  94. package/dist/AmazonBedrockLanguageModel.d.ts +315 -0
  95. package/dist/AmazonBedrockLanguageModel.d.ts.map +1 -0
  96. package/dist/AmazonBedrockLanguageModel.js +991 -0
  97. package/dist/AmazonBedrockLanguageModel.js.map +1 -0
  98. package/dist/AmazonBedrockSchema.d.ts +918 -0
  99. package/dist/AmazonBedrockSchema.d.ts.map +1 -0
  100. package/dist/AmazonBedrockSchema.js +536 -0
  101. package/dist/AmazonBedrockSchema.js.map +1 -0
  102. package/dist/index.d.ts +25 -0
  103. package/dist/index.d.ts.map +1 -0
  104. package/dist/{esm/index.js → index.js} +13 -12
  105. package/dist/index.js.map +1 -0
  106. package/dist/internal/errors.d.ts +2 -0
  107. package/dist/internal/errors.d.ts.map +1 -0
  108. package/dist/internal/errors.js +185 -0
  109. package/dist/internal/errors.js.map +1 -0
  110. package/dist/internal/eventStream.d.ts +2 -0
  111. package/dist/internal/eventStream.d.ts.map +1 -0
  112. package/dist/internal/eventStream.js +180 -0
  113. package/dist/internal/eventStream.js.map +1 -0
  114. package/dist/internal/sigv4.d.ts +2 -0
  115. package/dist/internal/sigv4.d.ts.map +1 -0
  116. package/dist/internal/sigv4.js +115 -0
  117. package/dist/internal/sigv4.js.map +1 -0
  118. package/dist/{dts/internal → internal}/utilities.d.ts.map +1 -1
  119. package/dist/internal/utilities.js +17 -0
  120. package/dist/internal/utilities.js.map +1 -0
  121. package/package.json +45 -84
  122. package/src/AmazonBedrockClient.ts +447 -263
  123. package/src/AmazonBedrockConfig.ts +55 -40
  124. package/src/AmazonBedrockLanguageModel.ts +950 -929
  125. package/src/AmazonBedrockSchema.ts +526 -970
  126. package/src/index.ts +15 -14
  127. package/src/internal/errors.ts +207 -0
  128. package/src/internal/eventStream.ts +208 -0
  129. package/src/internal/sigv4.ts +154 -0
  130. package/src/internal/utilities.ts +15 -17
  131. package/AmazonBedrockClient/package.json +0 -6
  132. package/AmazonBedrockConfig/package.json +0 -6
  133. package/AmazonBedrockLanguageModel/package.json +0 -6
  134. package/AmazonBedrockSchema/package.json +0 -6
  135. package/AmazonBedrockTool/package.json +0 -6
  136. package/EventStreamEncoding/package.json +0 -6
  137. package/dist/cjs/AmazonBedrockClient.js +0 -191
  138. package/dist/cjs/AmazonBedrockClient.js.map +0 -1
  139. package/dist/cjs/AmazonBedrockConfig.js +0 -30
  140. package/dist/cjs/AmazonBedrockConfig.js.map +0 -1
  141. package/dist/cjs/AmazonBedrockLanguageModel.js +0 -1051
  142. package/dist/cjs/AmazonBedrockLanguageModel.js.map +0 -1
  143. package/dist/cjs/AmazonBedrockSchema.js +0 -800
  144. package/dist/cjs/AmazonBedrockSchema.js.map +0 -1
  145. package/dist/cjs/AmazonBedrockTool.js +0 -53
  146. package/dist/cjs/AmazonBedrockTool.js.map +0 -1
  147. package/dist/cjs/EventStreamEncoding.js +0 -86
  148. package/dist/cjs/EventStreamEncoding.js.map +0 -1
  149. package/dist/cjs/index.js +0 -20
  150. package/dist/cjs/index.js.map +0 -1
  151. package/dist/cjs/internal/utilities.js +0 -27
  152. package/dist/cjs/internal/utilities.js.map +0 -1
  153. package/dist/dts/AmazonBedrockClient.d.ts +0 -95
  154. package/dist/dts/AmazonBedrockClient.d.ts.map +0 -1
  155. package/dist/dts/AmazonBedrockConfig.d.ts +0 -47
  156. package/dist/dts/AmazonBedrockConfig.d.ts.map +0 -1
  157. package/dist/dts/AmazonBedrockLanguageModel.d.ts +0 -147
  158. package/dist/dts/AmazonBedrockLanguageModel.d.ts.map +0 -1
  159. package/dist/dts/AmazonBedrockSchema.d.ts +0 -1875
  160. package/dist/dts/AmazonBedrockSchema.d.ts.map +0 -1
  161. package/dist/dts/AmazonBedrockTool.d.ts +0 -206
  162. package/dist/dts/AmazonBedrockTool.d.ts.map +0 -1
  163. package/dist/dts/EventStreamEncoding.d.ts +0 -16
  164. package/dist/dts/EventStreamEncoding.d.ts.map +0 -1
  165. package/dist/dts/index.d.ts +0 -25
  166. package/dist/dts/index.d.ts.map +0 -1
  167. package/dist/esm/AmazonBedrockClient.js +0 -179
  168. package/dist/esm/AmazonBedrockClient.js.map +0 -1
  169. package/dist/esm/AmazonBedrockConfig.js +0 -22
  170. package/dist/esm/AmazonBedrockConfig.js.map +0 -1
  171. package/dist/esm/AmazonBedrockLanguageModel.js +0 -1040
  172. package/dist/esm/AmazonBedrockLanguageModel.js.map +0 -1
  173. package/dist/esm/AmazonBedrockSchema.js +0 -731
  174. package/dist/esm/AmazonBedrockSchema.js.map +0 -1
  175. package/dist/esm/AmazonBedrockTool.js +0 -45
  176. package/dist/esm/AmazonBedrockTool.js.map +0 -1
  177. package/dist/esm/EventStreamEncoding.js +0 -78
  178. package/dist/esm/EventStreamEncoding.js.map +0 -1
  179. package/dist/esm/index.js.map +0 -1
  180. package/dist/esm/internal/utilities.js +0 -19
  181. package/dist/esm/internal/utilities.js.map +0 -1
  182. package/dist/esm/package.json +0 -4
  183. package/index/package.json +0 -6
  184. package/src/AmazonBedrockTool.ts +0 -273
  185. package/src/EventStreamEncoding.ts +0 -118
  186. /package/dist/{dts/internal → internal}/utilities.d.ts +0 -0
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
3
+ "extends": "../tsconfig.base.json",
4
+ "include": ["src/**/*.ts", "src/**/*.tsx"],
5
+ "compilerOptions": {
6
+ "rootDir": ".",
7
+ "noEmit": true,
8
+ "declaration": false,
9
+ "declarationMap": false,
10
+ "composite": false,
11
+ "incremental": false,
12
+ "types": ["node"],
13
+ "plugins": [
14
+ {
15
+ "name": "@effect/language-service",
16
+ "effectFn": ["untraced"],
17
+ "namespaceImportPackages": [],
18
+ "diagnosticSeverity": {
19
+ "floatingEffect": "off",
20
+ "globalJson": "off",
21
+ "globalJsonInEffect": "off",
22
+ "unstableApiUsage": "off",
23
+ "effectFnOpportunity": "error"
24
+ }
25
+ }
26
+ ]
27
+ }
28
+ }
@@ -0,0 +1,227 @@
1
+ /**
2
+ * The `AmazonBedrockClient` module defines the low-level Effect service used to
3
+ * call the Amazon Bedrock Runtime Converse API. It wraps an `HttpClient` with
4
+ * AWS Signature Version 4 signing or Bedrock API key authentication, request
5
+ * defaults, response decoding, event stream decoding and error mapping to the
6
+ * unified `AiError` type.
7
+ *
8
+ * **Mental model**
9
+ *
10
+ * `HttpClient.HttpClient` provides the transport, and the `Digest` and `Mac`
11
+ * services of `effect/crypto` provide the SHA-256 and HMAC that SigV4 signing
12
+ * runs on. {@link make} turns {@link Options} into an
13
+ * {@link AmazonBedrockClient} service, while {@link layer} and
14
+ * {@link layerConfig} provide that service as a layer. The service exposes
15
+ * helpers for the `converse` and `converse-stream` endpoints.
16
+ *
17
+ * @stability unstable
18
+ * @since 4.0.0
19
+ */
20
+ import * as AiError from "effect/ai/AiError";
21
+ import * as Config from "effect/Config";
22
+ import * as Context from "effect/Context";
23
+ import * as Digest from "effect/crypto/Digest";
24
+ import * as Mac from "effect/crypto/Mac";
25
+ import * as Effect from "effect/Effect";
26
+ import * as HttpClient from "effect/http/HttpClient";
27
+ import type * as HttpClientError from "effect/http/HttpClientError";
28
+ import * as Layer from "effect/Layer";
29
+ import * as Redacted from "effect/Redacted";
30
+ import * as Stream from "effect/Stream";
31
+ import type { ConverseRequest } from "./AmazonBedrockSchema.ts";
32
+ import { ConverseResponse, ConverseStreamEvent } from "./AmazonBedrockSchema.ts";
33
+ /**
34
+ * Represents the Amazon Bedrock client service with methods for the Converse
35
+ * API, including regular and streaming message creation.
36
+ *
37
+ * @stability unstable
38
+ * @category services
39
+ * @since 4.0.0
40
+ */
41
+ export interface Service {
42
+ /**
43
+ * The underlying `HttpClient`, with the base URL and authentication
44
+ * applied, for Bedrock Runtime operations this service does not model.
45
+ * Resolving the credentials can fail with an `AiError`.
46
+ */
47
+ readonly client: HttpClient.HttpClient.With<HttpClientError.HttpClientError | AiError.AiError>;
48
+ /**
49
+ * Calls the Converse operation and maps all errors to the unified `AiError`
50
+ * type. `modelId` names the model in the URL; the other fields form the
51
+ * request body.
52
+ */
53
+ readonly converse: (request: typeof ConverseRequest.Encoded) => Effect.Effect<ConverseResponse, AiError.AiError>;
54
+ /**
55
+ * Calls the ConverseStream operation and decodes the event stream, mapping
56
+ * all errors to the unified `AiError` type. An exception frame in the
57
+ * stream, such as a `throttlingException`, fails the stream.
58
+ */
59
+ readonly converseStream: (request: typeof ConverseRequest.Encoded) => Stream.Stream<ConverseStreamEvent, AiError.AiError>;
60
+ }
61
+ declare const AmazonBedrockClient_base: Context.ServiceClass<AmazonBedrockClient, "@effect/ai-amazon-bedrock/AmazonBedrockClient", Service>;
62
+ /**
63
+ * Service tag for the Amazon Bedrock client.
64
+ *
65
+ * @see {@link make} for constructing a client effectfully
66
+ * @see {@link layer} for providing a client from explicit options
67
+ * @see {@link layerConfig} for providing a client from `Config`
68
+ *
69
+ * @stability unstable
70
+ * @category services
71
+ * @since 4.0.0
72
+ */
73
+ export declare class AmazonBedrockClient extends AmazonBedrockClient_base {
74
+ }
75
+ /**
76
+ * AWS credentials, in the shape of the AWS SDK's `AwsCredentialIdentity`, so
77
+ * the SDK's credential providers fit without an adapter.
78
+ *
79
+ * @stability unstable
80
+ * @category models
81
+ * @since 4.0.0
82
+ */
83
+ export interface Credentials {
84
+ readonly accessKeyId: string;
85
+ readonly secretAccessKey: string;
86
+ /** An empty token is sent as no token. */
87
+ readonly sessionToken?: string | undefined;
88
+ }
89
+ /**
90
+ * Configuration for creating an Amazon Bedrock client.
91
+ *
92
+ * **Details**
93
+ *
94
+ * The client authenticates in one of three ways, in this order of precedence:
95
+ *
96
+ * - `apiKey`, a Bedrock API key, sent as `Authorization: Bearer <key>`.
97
+ * - `credentials`, an effect resolved before every request, signed with
98
+ * SigV4. This is where a credential provider such as `fromNodeProviderChain()`
99
+ * from `@aws-sdk/credential-providers` plugs in, wrapped in
100
+ * `Effect.promise`. To avoid resolving credentials on every request, build
101
+ * the layer inside `Layer.unwrap` and pass the effect that
102
+ * `Effect.cachedWithTTL` returns.
103
+ * - `accessKeyId` and `secretAccessKey`, with an optional `sessionToken`,
104
+ * signed with SigV4.
105
+ *
106
+ * Without any of them, every request fails with an `AuthenticationError` of
107
+ * kind `MissingKey`.
108
+ *
109
+ * @stability unstable
110
+ * @category options
111
+ * @since 4.0.0
112
+ */
113
+ export interface Options {
114
+ /**
115
+ * The AWS region.
116
+ *
117
+ * @default "us-east-1"
118
+ */
119
+ readonly region?: string | undefined;
120
+ /**
121
+ * The base URL for the Bedrock Runtime API. Override to use a proxy or a
122
+ * different endpoint.
123
+ *
124
+ * @default `https://bedrock-runtime.${region}.amazonaws.com`
125
+ */
126
+ readonly apiUrl?: string | undefined;
127
+ readonly accessKeyId?: string | undefined;
128
+ readonly secretAccessKey?: Redacted.Redacted<string> | undefined;
129
+ readonly sessionToken?: Redacted.Redacted<string> | undefined;
130
+ /**
131
+ * A Bedrock API key, sent as `Authorization: Bearer <key>` in place of a
132
+ * SigV4 signature.
133
+ */
134
+ readonly apiKey?: Redacted.Redacted<string> | undefined;
135
+ /**
136
+ * Resolves the AWS credentials of each request.
137
+ */
138
+ readonly credentials?: Effect.Effect<Credentials, AiError.AiError> | undefined;
139
+ /**
140
+ * Optional transformer for the underlying HTTP client, such as middleware,
141
+ * logging, or custom request/response handling.
142
+ */
143
+ readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
144
+ }
145
+ /**
146
+ * Creates an Amazon Bedrock client service with the given options.
147
+ *
148
+ * **Details**
149
+ *
150
+ * The client signs with the `Digest` and `Mac` services in its context, so
151
+ * the caller chooses their implementation: the WebCrypto layers of
152
+ * `effect/crypto`, or the layers of a platform package such as
153
+ * `NodeCrypto.layer` from `@effect/platform-node`. They are required for
154
+ * every way of authenticating, although a client with an `apiKey` never
155
+ * calls them. A `CryptoError` from the `Mac` service is a defect.
156
+ *
157
+ * @see {@link layer} for providing the client as a `Layer` from explicit options
158
+ * @see {@link layerConfig} for providing the client as a `Layer` with `Config`-based settings
159
+ *
160
+ * @stability unstable
161
+ * @category constructors
162
+ * @since 4.0.0
163
+ */
164
+ export declare const make: (options: Options) => Effect.Effect<Service, never, Digest.Digest | HttpClient.HttpClient | Mac.Mac>;
165
+ /**
166
+ * Creates a layer for the Amazon Bedrock client with the given options.
167
+ *
168
+ * **Example** (Providing the transport and the crypto services)
169
+ *
170
+ * ```ts
171
+ * import { AmazonBedrockClient } from "@effect/ai-amazon-bedrock"
172
+ * import { Layer, Redacted } from "effect"
173
+ * import { Digest, Mac, SecureRandom } from "effect/crypto"
174
+ * import { FetchHttpClient } from "effect/http"
175
+ *
176
+ * const BedrockClient = AmazonBedrockClient.layer({
177
+ * region: "eu-west-1",
178
+ * accessKeyId: "AKIAIOSFODNN7EXAMPLE",
179
+ * secretAccessKey: Redacted.make("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY")
180
+ * }).pipe(
181
+ * Layer.provide([
182
+ * FetchHttpClient.layer,
183
+ * Digest.layerWebCrypto,
184
+ * Mac.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))
185
+ * ])
186
+ * )
187
+ * ```
188
+ *
189
+ * @see {@link make} for constructing the client service effectfully
190
+ * @see {@link layerConfig} for loading client settings from `Config`
191
+ *
192
+ * @stability unstable
193
+ * @category layers
194
+ * @since 4.0.0
195
+ */
196
+ export declare const layer: (options: Options) => Layer.Layer<AmazonBedrockClient, never, HttpClient.HttpClient | Digest.Digest | Mac.Mac>;
197
+ /**
198
+ * Creates a layer for the Amazon Bedrock client, loading credentials and other
199
+ * settings via Effect's `Config` module.
200
+ *
201
+ * **Details**
202
+ *
203
+ * Each setting defaults to the environment variable that the AWS tools read:
204
+ * `AWS_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
205
+ * `AWS_SESSION_TOKEN` and, for a Bedrock API key, `AWS_BEARER_TOKEN_BEDROCK`.
206
+ * Every one of them is optional; see {@link Options} for which of them are
207
+ * used when several are set.
208
+ *
209
+ * @see {@link layer} for providing the client from explicit options instead of `Config`
210
+ * @see {@link make} for constructing the client service effectfully
211
+ *
212
+ * @stability unstable
213
+ * @category layers
214
+ * @since 4.0.0
215
+ */
216
+ export declare const layerConfig: (options?: {
217
+ readonly region?: Config.Config<string | undefined> | undefined;
218
+ readonly apiUrl?: Config.Config<string | undefined> | undefined;
219
+ readonly accessKeyId?: Config.Config<string | undefined> | undefined;
220
+ readonly secretAccessKey?: Config.Config<Redacted.Redacted<string> | undefined> | undefined;
221
+ readonly sessionToken?: Config.Config<Redacted.Redacted<string> | undefined> | undefined;
222
+ readonly apiKey?: Config.Config<Redacted.Redacted<string> | undefined> | undefined;
223
+ readonly credentials?: Effect.Effect<Credentials, AiError.AiError> | undefined;
224
+ readonly transformClient?: ((client: HttpClient.HttpClient) => HttpClient.HttpClient) | undefined;
225
+ }) => Layer.Layer<AmazonBedrockClient, Config.ConfigError, HttpClient.HttpClient | Digest.Digest | Mac.Mac>;
226
+ export {};
227
+ //# sourceMappingURL=AmazonBedrockClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockClient.d.ts","sourceRoot":"","sources":["../src/AmazonBedrockClient.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,KAAK,OAAO,MAAM,mBAAmB,CAAA;AAE5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAA;AACzC,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAC9C,OAAO,KAAK,GAAG,MAAM,mBAAmB,CAAA;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,UAAU,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAA;AAGnE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAE3C,O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A;IACpE,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;IAC3F,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;IACxF,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC,GAAG,SAAS,CAAA;IAClF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IAC9E,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,UAAU,KAAK,UAAU,CAAC,UAAU,CAAC,GAAG,SAAS,CAAA;CAClG,KAAG,KAAK,CAAC,KAAK,CAAC,mBAAmB,EAAE,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAerG,CAAA"}
@@ -0,0 +1,281 @@
1
+ /**
2
+ * The `AmazonBedrockClient` module defines the low-level Effect service used to
3
+ * call the Amazon Bedrock Runtime Converse API. It wraps an `HttpClient` with
4
+ * AWS Signature Version 4 signing or Bedrock API key authentication, request
5
+ * defaults, response decoding, event stream decoding and error mapping to the
6
+ * unified `AiError` type.
7
+ *
8
+ * **Mental model**
9
+ *
10
+ * `HttpClient.HttpClient` provides the transport, and the `Digest` and `Mac`
11
+ * services of `effect/crypto` provide the SHA-256 and HMAC that SigV4 signing
12
+ * runs on. {@link make} turns {@link Options} into an
13
+ * {@link AmazonBedrockClient} service, while {@link layer} and
14
+ * {@link layerConfig} provide that service as a layer. The service exposes
15
+ * helpers for the `converse` and `converse-stream` endpoints.
16
+ *
17
+ * @stability unstable
18
+ * @since 4.0.0
19
+ */
20
+ import * as AiError from "effect/ai/AiError";
21
+ import * as Array from "effect/Array";
22
+ import * as Config from "effect/Config";
23
+ import * as Context from "effect/Context";
24
+ import * as Digest from "effect/crypto/Digest";
25
+ import * as Mac from "effect/crypto/Mac";
26
+ import * as Effect from "effect/Effect";
27
+ import { identity } from "effect/Function";
28
+ import * as Headers from "effect/http/Headers";
29
+ import * as HttpBody from "effect/http/HttpBody";
30
+ import * as HttpClient from "effect/http/HttpClient";
31
+ import * as HttpClientRequest from "effect/http/HttpClientRequest";
32
+ import * as HttpClientResponse from "effect/http/HttpClientResponse";
33
+ import * as Layer from "effect/Layer";
34
+ import * as Predicate from "effect/Predicate";
35
+ import * as Redacted from "effect/Redacted";
36
+ import * as Schema from "effect/Schema";
37
+ import * as Stream from "effect/Stream";
38
+ import { AmazonBedrockConfig } from "./AmazonBedrockConfig.js";
39
+ import { ConverseResponse, ConverseStreamEvent, ConverseStreamException } from "./AmazonBedrockSchema.js";
40
+ import * as Errors from "./internal/errors.js";
41
+ import * as EventStream from "./internal/eventStream.js";
42
+ import * as SigV4 from "./internal/sigv4.js";
43
+ // =============================================================================
44
+ // Service Identifier
45
+ // =============================================================================
46
+ /**
47
+ * Service tag for the Amazon Bedrock client.
48
+ *
49
+ * @see {@link make} for constructing a client effectfully
50
+ * @see {@link layer} for providing a client from explicit options
51
+ * @see {@link layerConfig} for providing a client from `Config`
52
+ *
53
+ * @stability unstable
54
+ * @category services
55
+ * @since 4.0.0
56
+ */
57
+ export class AmazonBedrockClient extends /*#__PURE__*/Context.Service()("@effect/ai-amazon-bedrock/AmazonBedrockClient") {}
58
+ /**
59
+ * The credentials of the request in flight. The client resolves them before
60
+ * `HttpClient.execute` and provides them around it, so that a resolution
61
+ * failure is not an `HttpClientError` that a retry policy would retry, and so
62
+ * that every retry inside `execute` signs again with them.
63
+ */
64
+ const CurrentRequestCredentials = /*#__PURE__*/Context.Reference("@effect/ai-amazon-bedrock/AmazonBedrockClient/CurrentRequestCredentials", {
65
+ defaultValue: () => undefined
66
+ });
67
+ const appendRedactedHeaders = /*#__PURE__*/Array.append("x-amz-security-token");
68
+ const withRedactedHeaders = /*#__PURE__*/Effect.updateService(Headers.CurrentRedactedNames, appendRedactedHeaders);
69
+ const missingKey = (method, description) => Errors.make(method, new AiError.AuthenticationError({
70
+ kind: "MissingKey",
71
+ description
72
+ }));
73
+ const sigV4 = (accessKeyId, secretAccessKey, sessionToken) => ({
74
+ _tag: "SigV4",
75
+ credentials: {
76
+ accessKeyId,
77
+ secretAccessKey,
78
+ sessionToken: sessionToken === "" ? undefined : sessionToken
79
+ }
80
+ });
81
+ const makeResolveCredentials = options => {
82
+ if (options.apiKey !== undefined) {
83
+ const credentials = Effect.succeed({
84
+ _tag: "Bearer",
85
+ apiKey: options.apiKey
86
+ });
87
+ return () => credentials;
88
+ }
89
+ if (options.credentials !== undefined) {
90
+ const resolve = options.credentials;
91
+ return method => Effect.flatMap(resolve, credentials => credentials.accessKeyId === "" || credentials.secretAccessKey === "" ? Effect.fail(missingKey(method, "The credentials effect returned an empty access key ID or secret access key")) : Effect.succeed(sigV4(credentials.accessKeyId, credentials.secretAccessKey, credentials.sessionToken)));
92
+ }
93
+ if (options.accessKeyId !== undefined && options.secretAccessKey !== undefined) {
94
+ const credentials = Effect.succeed(sigV4(options.accessKeyId, Redacted.value(options.secretAccessKey), options.sessionToken === undefined ? undefined : Redacted.value(options.sessionToken)));
95
+ return () => credentials;
96
+ }
97
+ return method => Effect.fail(missingKey(method, "AmazonBedrockClient has no credentials: set `apiKey`, `credentials`, or `accessKeyId` with `secretAccessKey`"));
98
+ };
99
+ const authenticateRequest = signing => Effect.fnUntraced(function* (request) {
100
+ const credentials = yield* CurrentRequestCredentials;
101
+ if (Predicate.isUndefined(credentials)) {
102
+ return yield* Effect.die(new Error("AmazonBedrockClient sent a request without resolving its credentials"));
103
+ }
104
+ switch (credentials._tag) {
105
+ case "Bearer":
106
+ {
107
+ return HttpClientRequest.bearerToken(request, credentials.apiKey);
108
+ }
109
+ case "SigV4":
110
+ {
111
+ return yield* SigV4.sign(request, {
112
+ ...signing,
113
+ credentials: credentials.credentials
114
+ });
115
+ }
116
+ }
117
+ });
118
+ const decodeResponse = /*#__PURE__*/HttpClientResponse.schemaBodyJson(ConverseResponse);
119
+ const decodeStreamEvent = /*#__PURE__*/Schema.decodeUnknownEffect(ConverseStreamEvent);
120
+ const decodeStreamException = /*#__PURE__*/Schema.decodeUnknownEffect(ConverseStreamException);
121
+ /**
122
+ * Creates an Amazon Bedrock client service with the given options.
123
+ *
124
+ * **Details**
125
+ *
126
+ * The client signs with the `Digest` and `Mac` services in its context, so
127
+ * the caller chooses their implementation: the WebCrypto layers of
128
+ * `effect/crypto`, or the layers of a platform package such as
129
+ * `NodeCrypto.layer` from `@effect/platform-node`. They are required for
130
+ * every way of authenticating, although a client with an `apiKey` never
131
+ * calls them. A `CryptoError` from the `Mac` service is a defect.
132
+ *
133
+ * @see {@link layer} for providing the client as a `Layer` from explicit options
134
+ * @see {@link layerConfig} for providing the client as a `Layer` with `Config`-based settings
135
+ *
136
+ * @stability unstable
137
+ * @category constructors
138
+ * @since 4.0.0
139
+ */
140
+ export const make = /*#__PURE__*/Effect.fnUntraced(function* (options) {
141
+ const region = options.region ?? "us-east-1";
142
+ const apiUrl = options.apiUrl ?? `https://bedrock-runtime.${region}.amazonaws.com`;
143
+ const baseClient = yield* HttpClient.HttpClient;
144
+ const digest = yield* Digest.Digest;
145
+ const mac = yield* Mac.Mac;
146
+ const resolveCredentials = makeResolveCredentials(options);
147
+ // Resolves the credentials of one request before it executes, so that a
148
+ // credentials failure is not an `HttpClientError` a retry policy would
149
+ // retry, and provides them for `authenticateRequest` to sign each attempt.
150
+ const withCredentials = method => self => Effect.flatMap(resolveCredentials(method), credentials => Effect.provideService(self, CurrentRequestCredentials, credentials));
151
+ const httpClient = baseClient.pipe(HttpClient.mapRequest(request => request.pipe(HttpClientRequest.prependUrl(apiUrl), HttpClientRequest.acceptJson)), HttpClient.mapRequestEffect(authenticateRequest({
152
+ region,
153
+ digest,
154
+ mac
155
+ })), options.transformClient ?? identity);
156
+ // The exposed client resolves the credentials of each request itself and
157
+ // redacts the session token in header tracing, as the helpers do.
158
+ const client = HttpClient.makeWith(requestEffect => Effect.flatMap(requestEffect, request => httpClient.execute(request).pipe(withCredentials("execute"), withRedactedHeaders)), Effect.succeed);
159
+ const httpClientOk = HttpClient.filterStatusOk(httpClient);
160
+ const configClient = Effect.map(AmazonBedrockConfig.getOrUndefined, config => (config?.transformClient ?? identity)(httpClientOk));
161
+ const execute = (operation, method, {
162
+ modelId,
163
+ ...body
164
+ }) => configClient.pipe(Effect.flatMap(client => client.execute(HttpClientRequest.post(`/model/${encodeURIComponent(modelId)}/${operation}`, {
165
+ body: HttpBody.jsonUnsafe(body)
166
+ }))), withCredentials(method));
167
+ const converse = request => execute("converse", "converse", request).pipe(Effect.flatMap(decodeResponse), Effect.catchTags({
168
+ HttpClientError: error => Errors.mapHttpClientError(error, "converse"),
169
+ SchemaError: error => Effect.fail(Errors.mapSchemaError(error, "converse"))
170
+ }), withRedactedHeaders);
171
+ const decodeFrame = Effect.fnUntraced(function* (frame) {
172
+ const messageType = frame.headers[":message-type"];
173
+ switch (messageType) {
174
+ case "event":
175
+ {
176
+ const eventType = frame.headers[":event-type"];
177
+ if (Predicate.isUndefined(eventType)) {
178
+ return undefined;
179
+ }
180
+ const payload = yield* EventStream.parseJsonPayload(frame);
181
+ return yield* decodeStreamEvent({
182
+ [eventType]: payload
183
+ });
184
+ }
185
+ case "exception":
186
+ {
187
+ const payload = yield* EventStream.parseJsonPayload(frame);
188
+ const exception = yield* decodeStreamException(payload);
189
+ return yield* Errors.mapStreamException(frame.headers[":exception-type"] ?? "unknown exception", exception.message, "converseStream");
190
+ }
191
+ case "error":
192
+ {
193
+ return yield* Errors.make("converseStream", new AiError.InternalProviderError({
194
+ description: `Event stream error frame [${frame.headers[":error-code"] ?? "unknown"}]: ${frame.headers[":error-message"] ?? "no error message provided"}`
195
+ }));
196
+ }
197
+ default:
198
+ {
199
+ return undefined;
200
+ }
201
+ }
202
+ });
203
+ const converseStream = request => execute("converse-stream", "converseStream", request).pipe(HttpClientResponse.stream, EventStream.decode, Stream.mapEffect(decodeFrame), Stream.filter(Predicate.isNotUndefined), Stream.catchTags({
204
+ HttpClientError: error => Stream.fromEffect(Errors.mapHttpClientError(error, "converseStream")),
205
+ SchemaError: error => Stream.fail(Errors.mapSchemaError(error, "converseStream")),
206
+ EventStreamError: error => Stream.fail(Errors.mapEventStreamError(error, "converseStream"))
207
+ }), Stream.updateService(Headers.CurrentRedactedNames, appendRedactedHeaders));
208
+ return AmazonBedrockClient.of({
209
+ client,
210
+ converse,
211
+ converseStream
212
+ });
213
+ }, withRedactedHeaders);
214
+ // =============================================================================
215
+ // Layers
216
+ // =============================================================================
217
+ /**
218
+ * Creates a layer for the Amazon Bedrock client with the given options.
219
+ *
220
+ * **Example** (Providing the transport and the crypto services)
221
+ *
222
+ * ```ts
223
+ * import { AmazonBedrockClient } from "@effect/ai-amazon-bedrock"
224
+ * import { Layer, Redacted } from "effect"
225
+ * import { Digest, Mac, SecureRandom } from "effect/crypto"
226
+ * import { FetchHttpClient } from "effect/http"
227
+ *
228
+ * const BedrockClient = AmazonBedrockClient.layer({
229
+ * region: "eu-west-1",
230
+ * accessKeyId: "AKIAIOSFODNN7EXAMPLE",
231
+ * secretAccessKey: Redacted.make("wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY")
232
+ * }).pipe(
233
+ * Layer.provide([
234
+ * FetchHttpClient.layer,
235
+ * Digest.layerWebCrypto,
236
+ * Mac.layerWebCrypto.pipe(Layer.provide(SecureRandom.layerWebCrypto))
237
+ * ])
238
+ * )
239
+ * ```
240
+ *
241
+ * @see {@link make} for constructing the client service effectfully
242
+ * @see {@link layerConfig} for loading client settings from `Config`
243
+ *
244
+ * @stability unstable
245
+ * @category layers
246
+ * @since 4.0.0
247
+ */
248
+ export const layer = options => Layer.effect(AmazonBedrockClient, make(options));
249
+ /**
250
+ * Creates a layer for the Amazon Bedrock client, loading credentials and other
251
+ * settings via Effect's `Config` module.
252
+ *
253
+ * **Details**
254
+ *
255
+ * Each setting defaults to the environment variable that the AWS tools read:
256
+ * `AWS_REGION`, `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`,
257
+ * `AWS_SESSION_TOKEN` and, for a Bedrock API key, `AWS_BEARER_TOKEN_BEDROCK`.
258
+ * Every one of them is optional; see {@link Options} for which of them are
259
+ * used when several are set.
260
+ *
261
+ * @see {@link layer} for providing the client from explicit options instead of `Config`
262
+ * @see {@link make} for constructing the client service effectfully
263
+ *
264
+ * @stability unstable
265
+ * @category layers
266
+ * @since 4.0.0
267
+ */
268
+ export const layerConfig = options => Layer.effect(AmazonBedrockClient, Effect.gen(function* () {
269
+ return yield* make({
270
+ region: yield* options?.region ?? optional(Config.String("AWS_REGION")),
271
+ apiUrl: yield* options?.apiUrl ?? Effect.undefined,
272
+ accessKeyId: yield* options?.accessKeyId ?? optional(Config.String("AWS_ACCESS_KEY_ID")),
273
+ secretAccessKey: yield* options?.secretAccessKey ?? optional(Config.Redacted("AWS_SECRET_ACCESS_KEY")),
274
+ sessionToken: yield* options?.sessionToken ?? optional(Config.Redacted("AWS_SESSION_TOKEN")),
275
+ apiKey: yield* options?.apiKey ?? optional(Config.Redacted("AWS_BEARER_TOKEN_BEDROCK")),
276
+ credentials: options?.credentials,
277
+ transformClient: options?.transformClient
278
+ });
279
+ }));
280
+ const optional = config => Config.withDefault(config, undefined);
281
+ //# sourceMappingURL=AmazonBedrockClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AmazonBedrockClient.js","names":[],"sources":["../src/AmazonBedrockClient.ts"],"sourcesContent":[null],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;AAmBA,OAAO,KAAK,OAAO,M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C,eAAe,EAAE,OAAO,EAAE;GAC3B,CAAC;AACJ,CAAC,CAAC,CACH;AAEH,MAAM,QAAQ,GAAO,MAAwB,IAAmC,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC","ignoreList":[]}
@@ -0,0 +1,76 @@
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 4.0.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, "@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 4.0.0
20
+ */
21
+ export declare class AmazonBedrockConfig extends AmazonBedrockConfig_base {
22
+ /**
23
+ * Gets the configured Amazon Bedrock service from the current context when
24
+ * present.
25
+ *
26
+ * @since 4.0.0
27
+ */
28
+ static readonly getOrUndefined: Effect.Effect<typeof AmazonBedrockConfig.Service | undefined>;
29
+ }
30
+ /**
31
+ * Namespace containing types associated with the `AmazonBedrockConfig` service.
32
+ *
33
+ * @stability unstable
34
+ * @since 4.0.0
35
+ */
36
+ export declare namespace AmazonBedrockConfig {
37
+ /**
38
+ * Configuration provided through `AmazonBedrockConfig`.
39
+ *
40
+ * @category models
41
+ * @since 4.0.0
42
+ */
43
+ interface Service {
44
+ readonly transformClient?: ((client: HttpClient) => HttpClient) | undefined;
45
+ }
46
+ }
47
+ /**
48
+ * Runs an effect with an `AmazonBedrockConfig` override that transforms the
49
+ * underlying `HttpClient` used by Amazon Bedrock requests.
50
+ *
51
+ * @stability unstable
52
+ * @category configuration
53
+ * @since 4.0.0
54
+ */
55
+ export declare const withClientTransform: {
56
+ /**
57
+ * Runs an effect with an `AmazonBedrockConfig` override that transforms the
58
+ * underlying `HttpClient` used by Amazon Bedrock requests.
59
+ *
60
+ * @stability unstable
61
+ * @category configuration
62
+ * @since 4.0.0
63
+ */
64
+ (transform: (client: HttpClient) => HttpClient): <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
65
+ /**
66
+ * Runs an effect with an `AmazonBedrockConfig` override that transforms the
67
+ * underlying `HttpClient` used by Amazon Bedrock requests.
68
+ *
69
+ * @stability unstable
70
+ * @category configuration
71
+ * @since 4.0.0
72
+ */
73
+ <A, E, R>(self: Effect.Effect<A, E, R>, transform: (client: HttpClient) => HttpClient): Effect.Effect<A, E, R>;
74
+ };
75
+ export {};
76
+ //# 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,wBAGW;IAClD;;;;;OAKG;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;;;;;;;GAO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