@aws-sdk/client-bedrock-runtime 3.839.0 → 3.842.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 (40) hide show
  1. package/dist-cjs/auth/httpAuthSchemeProvider.js +17 -0
  2. package/dist-cjs/index.js +89 -5
  3. package/dist-cjs/runtimeConfig.browser.js +3 -3
  4. package/dist-cjs/runtimeConfig.js +23 -0
  5. package/dist-cjs/runtimeConfig.shared.js +6 -0
  6. package/dist-es/BedrockRuntimeClient.js +5 -2
  7. package/dist-es/auth/httpAuthExtensionConfiguration.js +8 -0
  8. package/dist-es/auth/httpAuthSchemeProvider.js +17 -0
  9. package/dist-es/commands/InvokeModelWithBidirectionalStreamCommand.js +4 -0
  10. package/dist-es/models/models_0.js +48 -0
  11. package/dist-es/protocols/Aws_restJson1.js +25 -0
  12. package/dist-es/runtimeConfig.browser.js +5 -5
  13. package/dist-es/runtimeConfig.js +24 -1
  14. package/dist-es/runtimeConfig.shared.js +6 -0
  15. package/dist-types/BedrockRuntimeClient.d.ts +3 -2
  16. package/dist-types/auth/httpAuthExtensionConfiguration.d.ts +4 -1
  17. package/dist-types/auth/httpAuthSchemeProvider.d.ts +9 -1
  18. package/dist-types/commands/ApplyGuardrailCommand.d.ts +6 -13
  19. package/dist-types/commands/ConverseCommand.d.ts +120 -44
  20. package/dist-types/commands/ConverseStreamCommand.d.ts +89 -48
  21. package/dist-types/commands/GetAsyncInvokeCommand.d.ts +4 -8
  22. package/dist-types/commands/InvokeModelCommand.d.ts +8 -30
  23. package/dist-types/commands/InvokeModelWithBidirectionalStreamCommand.d.ts +8 -18
  24. package/dist-types/commands/InvokeModelWithResponseStreamCommand.d.ts +8 -35
  25. package/dist-types/commands/ListAsyncInvokesCommand.d.ts +4 -8
  26. package/dist-types/commands/StartAsyncInvokeCommand.d.ts +7 -21
  27. package/dist-types/models/models_0.d.ts +432 -296
  28. package/dist-types/runtimeConfig.browser.d.ts +12 -3
  29. package/dist-types/runtimeConfig.d.ts +13 -1
  30. package/dist-types/runtimeConfig.native.d.ts +14 -2
  31. package/dist-types/runtimeConfig.shared.d.ts +12 -1
  32. package/dist-types/ts3.4/BedrockRuntimeClient.d.ts +6 -0
  33. package/dist-types/ts3.4/auth/httpAuthExtensionConfiguration.d.ts +5 -0
  34. package/dist-types/ts3.4/auth/httpAuthSchemeProvider.d.ts +4 -0
  35. package/dist-types/ts3.4/models/models_0.d.ts +192 -1
  36. package/dist-types/ts3.4/runtimeConfig.browser.d.ts +29 -5
  37. package/dist-types/ts3.4/runtimeConfig.d.ts +30 -1
  38. package/dist-types/ts3.4/runtimeConfig.native.d.ts +41 -3
  39. package/dist-types/ts3.4/runtimeConfig.shared.d.ts +27 -1
  40. package/package.json +16 -14
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveHttpAuthSchemeConfig = exports.defaultBedrockRuntimeHttpAuthSchemeProvider = exports.defaultBedrockRuntimeHttpAuthSchemeParametersProvider = void 0;
4
4
  const core_1 = require("@aws-sdk/core");
5
+ const core_2 = require("@smithy/core");
5
6
  const util_middleware_1 = require("@smithy/util-middleware");
6
7
  const defaultBedrockRuntimeHttpAuthSchemeParametersProvider = async (config, context, input) => {
7
8
  return {
@@ -28,20 +29,36 @@ function createAwsAuthSigv4HttpAuthOption(authParameters) {
28
29
  }),
29
30
  };
30
31
  }
32
+ function createSmithyApiHttpBearerAuthHttpAuthOption(authParameters) {
33
+ return {
34
+ schemeId: "smithy.api#httpBearerAuth",
35
+ propertiesExtractor: ({ profile, filepath, configFilepath, ignoreCache }, context) => ({
36
+ identityProperties: {
37
+ profile,
38
+ filepath,
39
+ configFilepath,
40
+ ignoreCache,
41
+ },
42
+ }),
43
+ };
44
+ }
31
45
  const defaultBedrockRuntimeHttpAuthSchemeProvider = (authParameters) => {
32
46
  const options = [];
33
47
  switch (authParameters.operation) {
34
48
  default: {
35
49
  options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
50
+ options.push(createSmithyApiHttpBearerAuthHttpAuthOption(authParameters));
36
51
  }
37
52
  }
38
53
  return options;
39
54
  };
40
55
  exports.defaultBedrockRuntimeHttpAuthSchemeProvider = defaultBedrockRuntimeHttpAuthSchemeProvider;
41
56
  const resolveHttpAuthSchemeConfig = (config) => {
57
+ const token = (0, core_2.memoizeIdentityProvider)(config.token, core_2.isIdentityExpired, core_2.doesIdentityRequireRefresh);
42
58
  const config_0 = (0, core_1.resolveAwsSdkSigV4Config)(config);
43
59
  return Object.assign(config_0, {
44
60
  authSchemePreference: (0, util_middleware_1.normalizeProvider)(config.authSchemePreference ?? []),
61
+ token,
45
62
  });
46
63
  };
47
64
  exports.resolveHttpAuthSchemeConfig = resolveHttpAuthSchemeConfig;
package/dist-cjs/index.js CHANGED
@@ -33,6 +33,9 @@ __export(index_exports, {
33
33
  BidirectionalInputPayloadPartFilterSensitiveLog: () => BidirectionalInputPayloadPartFilterSensitiveLog,
34
34
  BidirectionalOutputPayloadPartFilterSensitiveLog: () => BidirectionalOutputPayloadPartFilterSensitiveLog,
35
35
  CachePointType: () => CachePointType,
36
+ CitationGeneratedContent: () => CitationGeneratedContent,
37
+ CitationLocation: () => CitationLocation,
38
+ CitationSourceContent: () => CitationSourceContent,
36
39
  ConflictException: () => ConflictException,
37
40
  ContentBlock: () => ContentBlock,
38
41
  ContentBlockDelta: () => ContentBlockDelta,
@@ -51,6 +54,7 @@ __export(index_exports, {
51
54
  ConverseStreamOutputFilterSensitiveLog: () => ConverseStreamOutputFilterSensitiveLog,
52
55
  ConverseStreamRequestFilterSensitiveLog: () => ConverseStreamRequestFilterSensitiveLog,
53
56
  ConverseStreamResponseFilterSensitiveLog: () => ConverseStreamResponseFilterSensitiveLog,
57
+ DocumentContentBlock: () => DocumentContentBlock,
54
58
  DocumentFormat: () => DocumentFormat,
55
59
  DocumentSource: () => DocumentSource,
56
60
  GetAsyncInvokeCommand: () => GetAsyncInvokeCommand,
@@ -150,6 +154,7 @@ var import_middleware_host_header = require("@aws-sdk/middleware-host-header");
150
154
  var import_middleware_logger = require("@aws-sdk/middleware-logger");
151
155
  var import_middleware_recursion_detection = require("@aws-sdk/middleware-recursion-detection");
152
156
  var import_middleware_user_agent = require("@aws-sdk/middleware-user-agent");
157
+ var import_middleware_websocket = require("@aws-sdk/middleware-websocket");
153
158
  var import_config_resolver = require("@smithy/config-resolver");
154
159
  var import_core = require("@smithy/core");
155
160
  var import_eventstream_serde_config_resolver = require("@smithy/eventstream-serde-config-resolver");
@@ -187,6 +192,7 @@ var getHttpAuthExtensionConfiguration = /* @__PURE__ */ __name((runtimeConfig) =
187
192
  const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
188
193
  let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
189
194
  let _credentials = runtimeConfig.credentials;
195
+ let _token = runtimeConfig.token;
190
196
  return {
191
197
  setHttpAuthScheme(httpAuthScheme) {
192
198
  const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
@@ -210,6 +216,12 @@ var getHttpAuthExtensionConfiguration = /* @__PURE__ */ __name((runtimeConfig) =
210
216
  },
211
217
  credentials() {
212
218
  return _credentials;
219
+ },
220
+ setToken(token) {
221
+ _token = token;
222
+ },
223
+ token() {
224
+ return _token;
213
225
  }
214
226
  };
215
227
  }, "getHttpAuthExtensionConfiguration");
@@ -217,7 +229,8 @@ var resolveHttpAuthRuntimeConfig = /* @__PURE__ */ __name((config) => {
217
229
  return {
218
230
  httpAuthSchemes: config.httpAuthSchemes(),
219
231
  httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
220
- credentials: config.credentials()
232
+ credentials: config.credentials(),
233
+ token: config.token()
221
234
  };
222
235
  }, "resolveHttpAuthRuntimeConfig");
223
236
 
@@ -261,8 +274,9 @@ var BedrockRuntimeClient = class extends import_smithy_client.Client {
261
274
  const _config_7 = (0, import_eventstream_serde_config_resolver.resolveEventStreamSerdeConfig)(_config_6);
262
275
  const _config_8 = (0, import_httpAuthSchemeProvider.resolveHttpAuthSchemeConfig)(_config_7);
263
276
  const _config_9 = (0, import_middleware_eventstream.resolveEventStreamConfig)(_config_8);
264
- const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []);
265
- this.config = _config_10;
277
+ const _config_10 = (0, import_middleware_websocket.resolveWebSocketConfig)(_config_9);
278
+ const _config_11 = resolveRuntimeExtensions(_config_10, configuration?.extensions || []);
279
+ this.config = _config_11;
266
280
  this.middlewareStack.use((0, import_middleware_user_agent.getUserAgentPlugin)(this.config));
267
281
  this.middlewareStack.use((0, import_middleware_retry.getRetryPlugin)(this.config));
268
282
  this.middlewareStack.use((0, import_middleware_content_length.getContentLengthPlugin)(this.config));
@@ -273,7 +287,8 @@ var BedrockRuntimeClient = class extends import_smithy_client.Client {
273
287
  (0, import_core.getHttpAuthSchemeEndpointRuleSetPlugin)(this.config, {
274
288
  httpAuthSchemeParametersProvider: import_httpAuthSchemeProvider.defaultBedrockRuntimeHttpAuthSchemeParametersProvider,
275
289
  identityProviderConfigProvider: /* @__PURE__ */ __name(async (config) => new import_core.DefaultIdentityProviderConfig({
276
- "aws.auth#sigv4": config.credentials
290
+ "aws.auth#sigv4": config.credentials,
291
+ "smithy.api#httpBearerAuth": config.token
277
292
  }), "identityProviderConfigProvider")
278
293
  })
279
294
  );
@@ -607,6 +622,29 @@ var GuardrailTrace = {
607
622
  var CachePointType = {
608
623
  DEFAULT: "default"
609
624
  };
625
+ var CitationLocation;
626
+ ((CitationLocation3) => {
627
+ CitationLocation3.visit = /* @__PURE__ */ __name((value, visitor) => {
628
+ if (value.documentChar !== void 0) return visitor.documentChar(value.documentChar);
629
+ if (value.documentPage !== void 0) return visitor.documentPage(value.documentPage);
630
+ if (value.documentChunk !== void 0) return visitor.documentChunk(value.documentChunk);
631
+ return visitor._(value.$unknown[0], value.$unknown[1]);
632
+ }, "visit");
633
+ })(CitationLocation || (CitationLocation = {}));
634
+ var CitationSourceContent;
635
+ ((CitationSourceContent3) => {
636
+ CitationSourceContent3.visit = /* @__PURE__ */ __name((value, visitor) => {
637
+ if (value.text !== void 0) return visitor.text(value.text);
638
+ return visitor._(value.$unknown[0], value.$unknown[1]);
639
+ }, "visit");
640
+ })(CitationSourceContent || (CitationSourceContent = {}));
641
+ var CitationGeneratedContent;
642
+ ((CitationGeneratedContent3) => {
643
+ CitationGeneratedContent3.visit = /* @__PURE__ */ __name((value, visitor) => {
644
+ if (value.text !== void 0) return visitor.text(value.text);
645
+ return visitor._(value.$unknown[0], value.$unknown[1]);
646
+ }, "visit");
647
+ })(CitationGeneratedContent || (CitationGeneratedContent = {}));
610
648
  var DocumentFormat = {
611
649
  CSV: "csv",
612
650
  DOC: "doc",
@@ -618,11 +656,20 @@ var DocumentFormat = {
618
656
  XLS: "xls",
619
657
  XLSX: "xlsx"
620
658
  };
659
+ var DocumentContentBlock;
660
+ ((DocumentContentBlock3) => {
661
+ DocumentContentBlock3.visit = /* @__PURE__ */ __name((value, visitor) => {
662
+ if (value.text !== void 0) return visitor.text(value.text);
663
+ return visitor._(value.$unknown[0], value.$unknown[1]);
664
+ }, "visit");
665
+ })(DocumentContentBlock || (DocumentContentBlock = {}));
621
666
  var DocumentSource;
622
667
  ((DocumentSource2) => {
623
668
  DocumentSource2.visit = /* @__PURE__ */ __name((value, visitor) => {
624
669
  if (value.bytes !== void 0) return visitor.bytes(value.bytes);
625
670
  if (value.s3Location !== void 0) return visitor.s3Location(value.s3Location);
671
+ if (value.text !== void 0) return visitor.text(value.text);
672
+ if (value.content !== void 0) return visitor.content(value.content);
626
673
  return visitor._(value.$unknown[0], value.$unknown[1]);
627
674
  }, "visit");
628
675
  })(DocumentSource || (DocumentSource = {}));
@@ -718,6 +765,7 @@ var ContentBlock;
718
765
  if (value.guardContent !== void 0) return visitor.guardContent(value.guardContent);
719
766
  if (value.cachePoint !== void 0) return visitor.cachePoint(value.cachePoint);
720
767
  if (value.reasoningContent !== void 0) return visitor.reasoningContent(value.reasoningContent);
768
+ if (value.citationsContent !== void 0) return visitor.citationsContent(value.citationsContent);
721
769
  return visitor._(value.$unknown[0], value.$unknown[1]);
722
770
  }, "visit");
723
771
  })(ContentBlock || (ContentBlock = {}));
@@ -870,6 +918,7 @@ var ContentBlockDelta;
870
918
  if (value.text !== void 0) return visitor.text(value.text);
871
919
  if (value.toolUse !== void 0) return visitor.toolUse(value.toolUse);
872
920
  if (value.reasoningContent !== void 0) return visitor.reasoningContent(value.reasoningContent);
921
+ if (value.citation !== void 0) return visitor.citation(value.citation);
873
922
  return visitor._(value.$unknown[0], value.$unknown[1]);
874
923
  }, "visit");
875
924
  })(ContentBlockDelta || (ContentBlockDelta = {}));
@@ -1044,6 +1093,7 @@ var ContentBlockFilterSensitiveLog = /* @__PURE__ */ __name((obj) => {
1044
1093
  return { guardContent: GuardrailConverseContentBlockFilterSensitiveLog(obj.guardContent) };
1045
1094
  if (obj.cachePoint !== void 0) return { cachePoint: obj.cachePoint };
1046
1095
  if (obj.reasoningContent !== void 0) return { reasoningContent: import_smithy_client.SENSITIVE_STRING };
1096
+ if (obj.citationsContent !== void 0) return { citationsContent: obj.citationsContent };
1047
1097
  if (obj.$unknown !== void 0) return { [obj.$unknown[0]]: "UNKNOWN" };
1048
1098
  }, "ContentBlockFilterSensitiveLog");
1049
1099
  var MessageFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
@@ -1091,6 +1141,7 @@ var ContentBlockDeltaFilterSensitiveLog = /* @__PURE__ */ __name((obj) => {
1091
1141
  if (obj.text !== void 0) return { text: obj.text };
1092
1142
  if (obj.toolUse !== void 0) return { toolUse: obj.toolUse };
1093
1143
  if (obj.reasoningContent !== void 0) return { reasoningContent: import_smithy_client.SENSITIVE_STRING };
1144
+ if (obj.citation !== void 0) return { citation: obj.citation };
1094
1145
  if (obj.$unknown !== void 0) return { [obj.$unknown[0]]: "UNKNOWN" };
1095
1146
  }, "ContentBlockDeltaFilterSensitiveLog");
1096
1147
  var ContentBlockDeltaEventFilterSensitiveLog = /* @__PURE__ */ __name((obj) => ({
@@ -1976,6 +2027,7 @@ var se_BidirectionalInputPayloadPart = /* @__PURE__ */ __name((input, context) =
1976
2027
  var se_ContentBlock = /* @__PURE__ */ __name((input, context) => {
1977
2028
  return ContentBlock.visit(input, {
1978
2029
  cachePoint: /* @__PURE__ */ __name((value) => ({ cachePoint: (0, import_smithy_client._json)(value) }), "cachePoint"),
2030
+ citationsContent: /* @__PURE__ */ __name((value) => ({ citationsContent: (0, import_smithy_client._json)(value) }), "citationsContent"),
1979
2031
  document: /* @__PURE__ */ __name((value) => ({ document: se_DocumentBlock(value, context) }), "document"),
1980
2032
  guardContent: /* @__PURE__ */ __name((value) => ({ guardContent: se_GuardrailConverseContentBlock(value, context) }), "guardContent"),
1981
2033
  image: /* @__PURE__ */ __name((value) => ({ image: se_ImageBlock(value, context) }), "image"),
@@ -1994,6 +2046,8 @@ var se_ContentBlocks = /* @__PURE__ */ __name((input, context) => {
1994
2046
  }, "se_ContentBlocks");
1995
2047
  var se_DocumentBlock = /* @__PURE__ */ __name((input, context) => {
1996
2048
  return (0, import_smithy_client.take)(input, {
2049
+ citations: import_smithy_client._json,
2050
+ context: [],
1997
2051
  format: [],
1998
2052
  name: [],
1999
2053
  source: /* @__PURE__ */ __name((_) => se_DocumentSource(_, context), "source")
@@ -2002,7 +2056,9 @@ var se_DocumentBlock = /* @__PURE__ */ __name((input, context) => {
2002
2056
  var se_DocumentSource = /* @__PURE__ */ __name((input, context) => {
2003
2057
  return DocumentSource.visit(input, {
2004
2058
  bytes: /* @__PURE__ */ __name((value) => ({ bytes: context.base64Encoder(value) }), "bytes"),
2059
+ content: /* @__PURE__ */ __name((value) => ({ content: (0, import_smithy_client._json)(value) }), "content"),
2005
2060
  s3Location: /* @__PURE__ */ __name((value) => ({ s3Location: (0, import_smithy_client._json)(value) }), "s3Location"),
2061
+ text: /* @__PURE__ */ __name((value) => ({ text: value }), "text"),
2006
2062
  _: /* @__PURE__ */ __name((name, value) => ({ [name]: value }), "_")
2007
2063
  });
2008
2064
  }, "se_DocumentSource");
@@ -2210,6 +2266,11 @@ var de_ContentBlock = /* @__PURE__ */ __name((output, context) => {
2210
2266
  cachePoint: (0, import_smithy_client._json)(output.cachePoint)
2211
2267
  };
2212
2268
  }
2269
+ if (output.citationsContent != null) {
2270
+ return {
2271
+ citationsContent: (0, import_smithy_client._json)(output.citationsContent)
2272
+ };
2273
+ }
2213
2274
  if (output.document != null) {
2214
2275
  return {
2215
2276
  document: de_DocumentBlock(output.document, context)
@@ -2251,6 +2312,11 @@ var de_ContentBlock = /* @__PURE__ */ __name((output, context) => {
2251
2312
  return { $unknown: Object.entries(output)[0] };
2252
2313
  }, "de_ContentBlock");
2253
2314
  var de_ContentBlockDelta = /* @__PURE__ */ __name((output, context) => {
2315
+ if (output.citation != null) {
2316
+ return {
2317
+ citation: (0, import_smithy_client._json)(output.citation)
2318
+ };
2319
+ }
2254
2320
  if (output.reasoningContent != null) {
2255
2321
  return {
2256
2322
  reasoningContent: de_ReasoningContentBlockDelta((0, import_core2.awsExpectUnion)(output.reasoningContent), context)
@@ -2308,6 +2374,8 @@ var de_ConverseTrace = /* @__PURE__ */ __name((output, context) => {
2308
2374
  }, "de_ConverseTrace");
2309
2375
  var de_DocumentBlock = /* @__PURE__ */ __name((output, context) => {
2310
2376
  return (0, import_smithy_client.take)(output, {
2377
+ citations: import_smithy_client._json,
2378
+ context: import_smithy_client.expectString,
2311
2379
  format: import_smithy_client.expectString,
2312
2380
  name: import_smithy_client.expectString,
2313
2381
  source: /* @__PURE__ */ __name((_) => de_DocumentSource((0, import_core2.awsExpectUnion)(_), context), "source")
@@ -2319,11 +2387,19 @@ var de_DocumentSource = /* @__PURE__ */ __name((output, context) => {
2319
2387
  bytes: context.base64Decoder(output.bytes)
2320
2388
  };
2321
2389
  }
2390
+ if (output.content != null) {
2391
+ return {
2392
+ content: (0, import_smithy_client._json)(output.content)
2393
+ };
2394
+ }
2322
2395
  if (output.s3Location != null) {
2323
2396
  return {
2324
2397
  s3Location: (0, import_smithy_client._json)(output.s3Location)
2325
2398
  };
2326
2399
  }
2400
+ if ((0, import_smithy_client.expectString)(output.text) !== void 0) {
2401
+ return { text: (0, import_smithy_client.expectString)(output.text) };
2402
+ }
2327
2403
  return { $unknown: Object.entries(output)[0] };
2328
2404
  }, "de_DocumentSource");
2329
2405
  var de_GuardrailAssessment = /* @__PURE__ */ __name((output, context) => {
@@ -2657,11 +2733,15 @@ var InvokeModelCommand = class extends import_smithy_client.Command.classBuilder
2657
2733
 
2658
2734
 
2659
2735
 
2736
+
2660
2737
  var InvokeModelWithBidirectionalStreamCommand = class extends import_smithy_client.Command.classBuilder().ep(commonParams).m(function(Command, cs, config, o) {
2661
2738
  return [
2662
2739
  (0, import_middleware_serde.getSerdePlugin)(config, this.serialize, this.deserialize),
2663
2740
  (0, import_middleware_endpoint.getEndpointPlugin)(config, Command.getEndpointParameterInstructions()),
2664
- (0, import_middleware_eventstream.getEventStreamPlugin)(config)
2741
+ (0, import_middleware_eventstream.getEventStreamPlugin)(config),
2742
+ (0, import_middleware_websocket.getWebSocketPlugin)(config, {
2743
+ headerPrefix: "x-amz-bedrock-"
2744
+ })
2665
2745
  ];
2666
2746
  }).s("AmazonBedrockFrontendService", "InvokeModelWithBidirectionalStream", {
2667
2747
  /**
@@ -2805,7 +2885,11 @@ var paginateListAsyncInvokes = (0, import_core.createPaginator)(BedrockRuntimeCl
2805
2885
  GuardrailManagedWordType,
2806
2886
  GuardrailTrace,
2807
2887
  CachePointType,
2888
+ CitationLocation,
2889
+ CitationSourceContent,
2890
+ CitationGeneratedContent,
2808
2891
  DocumentFormat,
2892
+ DocumentContentBlock,
2809
2893
  DocumentSource,
2810
2894
  GuardrailConverseImageFormat,
2811
2895
  GuardrailConverseImageSource,
@@ -4,6 +4,7 @@ exports.getRuntimeConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
6
  const sha256_browser_1 = require("@aws-crypto/sha256-browser");
7
+ const middleware_websocket_1 = require("@aws-sdk/middleware-websocket");
7
8
  const util_user_agent_browser_1 = require("@aws-sdk/util-user-agent-browser");
8
9
  const config_resolver_1 = require("@smithy/config-resolver");
9
10
  const eventstream_serde_browser_1 = require("@smithy/eventstream-serde-browser");
@@ -27,12 +28,11 @@ const getRuntimeConfig = (config) => {
27
28
  credentialDefaultProvider: config?.credentialDefaultProvider ?? ((_) => () => Promise.reject(new Error("Credential is missing"))),
28
29
  defaultUserAgentProvider: config?.defaultUserAgentProvider ??
29
30
  (0, util_user_agent_browser_1.createDefaultUserAgentProvider)({ serviceId: clientSharedValues.serviceId, clientVersion: package_json_1.default.version }),
30
- eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ??
31
- (() => ({ handle: (0, invalid_dependency_1.invalidFunction)("event stream request is not supported in browser.") })),
31
+ eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? middleware_websocket_1.eventStreamPayloadHandlerProvider,
32
32
  eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventstream_serde_browser_1.eventStreamSerdeProvider,
33
33
  maxAttempts: config?.maxAttempts ?? util_retry_1.DEFAULT_MAX_ATTEMPTS,
34
34
  region: config?.region ?? (0, invalid_dependency_1.invalidProvider)("Region is missing"),
35
- requestHandler: fetch_http_handler_1.FetchHttpHandler.create(config?.requestHandler ?? defaultConfigProvider),
35
+ requestHandler: middleware_websocket_1.WebSocketFetchHandler.create(config?.requestHandler ?? defaultConfigProvider, fetch_http_handler_1.FetchHttpHandler.create(defaultConfigProvider)),
36
36
  retryMode: config?.retryMode ?? (async () => (await defaultConfigProvider()).retryMode || util_retry_1.DEFAULT_RETRY_MODE),
37
37
  sha256: config?.sha256 ?? sha256_browser_1.Sha256,
38
38
  streamCollector: config?.streamCollector ?? fetch_http_handler_1.streamCollector,
@@ -6,8 +6,10 @@ const package_json_1 = tslib_1.__importDefault(require("../package.json"));
6
6
  const core_1 = require("@aws-sdk/core");
7
7
  const credential_provider_node_1 = require("@aws-sdk/credential-provider-node");
8
8
  const eventstream_handler_node_1 = require("@aws-sdk/eventstream-handler-node");
9
+ const token_providers_1 = require("@aws-sdk/token-providers");
9
10
  const util_user_agent_node_1 = require("@aws-sdk/util-user-agent-node");
10
11
  const config_resolver_1 = require("@smithy/config-resolver");
12
+ const core_2 = require("@smithy/core");
11
13
  const eventstream_serde_node_1 = require("@smithy/eventstream-serde-node");
12
14
  const hash_node_1 = require("@smithy/hash-node");
13
15
  const middleware_retry_1 = require("@smithy/middleware-retry");
@@ -28,6 +30,7 @@ const getRuntimeConfig = (config) => {
28
30
  const loaderConfig = {
29
31
  profile: config?.profile,
30
32
  logger: clientSharedValues.logger,
33
+ signingName: "bedrock",
31
34
  };
32
35
  return {
33
36
  ...clientSharedValues,
@@ -41,6 +44,26 @@ const getRuntimeConfig = (config) => {
41
44
  (0, util_user_agent_node_1.createDefaultUserAgentProvider)({ serviceId: clientSharedValues.serviceId, clientVersion: package_json_1.default.version }),
42
45
  eventStreamPayloadHandlerProvider: config?.eventStreamPayloadHandlerProvider ?? eventstream_handler_node_1.eventStreamPayloadHandlerProvider,
43
46
  eventStreamSerdeProvider: config?.eventStreamSerdeProvider ?? eventstream_serde_node_1.eventStreamSerdeProvider,
47
+ httpAuthSchemes: config?.httpAuthSchemes ?? [
48
+ {
49
+ schemeId: "aws.auth#sigv4",
50
+ identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
51
+ signer: new core_1.AwsSdkSigV4Signer(),
52
+ },
53
+ {
54
+ schemeId: "smithy.api#httpBearerAuth",
55
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#httpBearerAuth") ||
56
+ (async (idProps) => {
57
+ try {
58
+ return await (0, token_providers_1.fromEnvSigningName)({ signingName: "bedrock" })();
59
+ }
60
+ catch (error) {
61
+ return await (0, token_providers_1.nodeProvider)(idProps)(idProps);
62
+ }
63
+ }),
64
+ signer: new core_2.HttpBearerAuthSigner(),
65
+ },
66
+ ],
44
67
  maxAttempts: config?.maxAttempts ?? (0, node_config_provider_1.loadConfig)(middleware_retry_1.NODE_MAX_ATTEMPT_CONFIG_OPTIONS, config),
45
68
  region: config?.region ??
46
69
  (0, node_config_provider_1.loadConfig)(config_resolver_1.NODE_REGION_CONFIG_OPTIONS, { ...config_resolver_1.NODE_REGION_CONFIG_FILE_OPTIONS, ...loaderConfig }),
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRuntimeConfig = void 0;
4
4
  const core_1 = require("@aws-sdk/core");
5
+ const core_2 = require("@smithy/core");
5
6
  const smithy_client_1 = require("@smithy/smithy-client");
6
7
  const url_parser_1 = require("@smithy/url-parser");
7
8
  const util_base64_1 = require("@smithy/util-base64");
@@ -23,6 +24,11 @@ const getRuntimeConfig = (config) => {
23
24
  identityProvider: (ipc) => ipc.getIdentityProvider("aws.auth#sigv4"),
24
25
  signer: new core_1.AwsSdkSigV4Signer(),
25
26
  },
27
+ {
28
+ schemeId: "smithy.api#httpBearerAuth",
29
+ identityProvider: (ipc) => ipc.getIdentityProvider("smithy.api#httpBearerAuth"),
30
+ signer: new core_2.HttpBearerAuthSigner(),
31
+ },
26
32
  ],
27
33
  logger: config?.logger ?? new smithy_client_1.NoOpLogger(),
28
34
  serviceId: config?.serviceId ?? "Bedrock Runtime",
@@ -3,6 +3,7 @@ import { getHostHeaderPlugin, resolveHostHeaderConfig, } from "@aws-sdk/middlewa
3
3
  import { getLoggerPlugin } from "@aws-sdk/middleware-logger";
4
4
  import { getRecursionDetectionPlugin } from "@aws-sdk/middleware-recursion-detection";
5
5
  import { getUserAgentPlugin, resolveUserAgentConfig, } from "@aws-sdk/middleware-user-agent";
6
+ import { resolveWebSocketConfig } from "@aws-sdk/middleware-websocket";
6
7
  import { resolveRegionConfig } from "@smithy/config-resolver";
7
8
  import { DefaultIdentityProviderConfig, getHttpAuthSchemeEndpointRuleSetPlugin, getHttpSigningPlugin, } from "@smithy/core";
8
9
  import { resolveEventStreamSerdeConfig, } from "@smithy/eventstream-serde-config-resolver";
@@ -30,8 +31,9 @@ export class BedrockRuntimeClient extends __Client {
30
31
  const _config_7 = resolveEventStreamSerdeConfig(_config_6);
31
32
  const _config_8 = resolveHttpAuthSchemeConfig(_config_7);
32
33
  const _config_9 = resolveEventStreamConfig(_config_8);
33
- const _config_10 = resolveRuntimeExtensions(_config_9, configuration?.extensions || []);
34
- this.config = _config_10;
34
+ const _config_10 = resolveWebSocketConfig(_config_9);
35
+ const _config_11 = resolveRuntimeExtensions(_config_10, configuration?.extensions || []);
36
+ this.config = _config_11;
35
37
  this.middlewareStack.use(getUserAgentPlugin(this.config));
36
38
  this.middlewareStack.use(getRetryPlugin(this.config));
37
39
  this.middlewareStack.use(getContentLengthPlugin(this.config));
@@ -42,6 +44,7 @@ export class BedrockRuntimeClient extends __Client {
42
44
  httpAuthSchemeParametersProvider: defaultBedrockRuntimeHttpAuthSchemeParametersProvider,
43
45
  identityProviderConfigProvider: async (config) => new DefaultIdentityProviderConfig({
44
46
  "aws.auth#sigv4": config.credentials,
47
+ "smithy.api#httpBearerAuth": config.token,
45
48
  }),
46
49
  }));
47
50
  this.middlewareStack.use(getHttpSigningPlugin(this.config));
@@ -2,6 +2,7 @@ export const getHttpAuthExtensionConfiguration = (runtimeConfig) => {
2
2
  const _httpAuthSchemes = runtimeConfig.httpAuthSchemes;
3
3
  let _httpAuthSchemeProvider = runtimeConfig.httpAuthSchemeProvider;
4
4
  let _credentials = runtimeConfig.credentials;
5
+ let _token = runtimeConfig.token;
5
6
  return {
6
7
  setHttpAuthScheme(httpAuthScheme) {
7
8
  const index = _httpAuthSchemes.findIndex((scheme) => scheme.schemeId === httpAuthScheme.schemeId);
@@ -27,6 +28,12 @@ export const getHttpAuthExtensionConfiguration = (runtimeConfig) => {
27
28
  credentials() {
28
29
  return _credentials;
29
30
  },
31
+ setToken(token) {
32
+ _token = token;
33
+ },
34
+ token() {
35
+ return _token;
36
+ },
30
37
  };
31
38
  };
32
39
  export const resolveHttpAuthRuntimeConfig = (config) => {
@@ -34,5 +41,6 @@ export const resolveHttpAuthRuntimeConfig = (config) => {
34
41
  httpAuthSchemes: config.httpAuthSchemes(),
35
42
  httpAuthSchemeProvider: config.httpAuthSchemeProvider(),
36
43
  credentials: config.credentials(),
44
+ token: config.token(),
37
45
  };
38
46
  };
@@ -1,4 +1,5 @@
1
1
  import { resolveAwsSdkSigV4Config, } from "@aws-sdk/core";
2
+ import { doesIdentityRequireRefresh, isIdentityExpired, memoizeIdentityProvider } from "@smithy/core";
2
3
  import { getSmithyContext, normalizeProvider } from "@smithy/util-middleware";
3
4
  export const defaultBedrockRuntimeHttpAuthSchemeParametersProvider = async (config, context, input) => {
4
5
  return {
@@ -24,18 +25,34 @@ function createAwsAuthSigv4HttpAuthOption(authParameters) {
24
25
  }),
25
26
  };
26
27
  }
28
+ function createSmithyApiHttpBearerAuthHttpAuthOption(authParameters) {
29
+ return {
30
+ schemeId: "smithy.api#httpBearerAuth",
31
+ propertiesExtractor: ({ profile, filepath, configFilepath, ignoreCache }, context) => ({
32
+ identityProperties: {
33
+ profile,
34
+ filepath,
35
+ configFilepath,
36
+ ignoreCache,
37
+ },
38
+ }),
39
+ };
40
+ }
27
41
  export const defaultBedrockRuntimeHttpAuthSchemeProvider = (authParameters) => {
28
42
  const options = [];
29
43
  switch (authParameters.operation) {
30
44
  default: {
31
45
  options.push(createAwsAuthSigv4HttpAuthOption(authParameters));
46
+ options.push(createSmithyApiHttpBearerAuthHttpAuthOption(authParameters));
32
47
  }
33
48
  }
34
49
  return options;
35
50
  };
36
51
  export const resolveHttpAuthSchemeConfig = (config) => {
52
+ const token = memoizeIdentityProvider(config.token, isIdentityExpired, doesIdentityRequireRefresh);
37
53
  const config_0 = resolveAwsSdkSigV4Config(config);
38
54
  return Object.assign(config_0, {
39
55
  authSchemePreference: normalizeProvider(config.authSchemePreference ?? []),
56
+ token,
40
57
  });
41
58
  };
@@ -1,4 +1,5 @@
1
1
  import { getEventStreamPlugin } from "@aws-sdk/middleware-eventstream";
2
+ import { getWebSocketPlugin } from "@aws-sdk/middleware-websocket";
2
3
  import { getEndpointPlugin } from "@smithy/middleware-endpoint";
3
4
  import { getSerdePlugin } from "@smithy/middleware-serde";
4
5
  import { Command as $Command } from "@smithy/smithy-client";
@@ -14,6 +15,9 @@ export class InvokeModelWithBidirectionalStreamCommand extends $Command
14
15
  getSerdePlugin(config, this.serialize, this.deserialize),
15
16
  getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
16
17
  getEventStreamPlugin(config),
18
+ getWebSocketPlugin(config, {
19
+ headerPrefix: "x-amz-bedrock-",
20
+ }),
17
21
  ];
18
22
  })
19
23
  .s("AmazonBedrockFrontendService", "InvokeModelWithBidirectionalStream", {
@@ -247,6 +247,34 @@ export const GuardrailTrace = {
247
247
  export const CachePointType = {
248
248
  DEFAULT: "default",
249
249
  };
250
+ export var CitationLocation;
251
+ (function (CitationLocation) {
252
+ CitationLocation.visit = (value, visitor) => {
253
+ if (value.documentChar !== undefined)
254
+ return visitor.documentChar(value.documentChar);
255
+ if (value.documentPage !== undefined)
256
+ return visitor.documentPage(value.documentPage);
257
+ if (value.documentChunk !== undefined)
258
+ return visitor.documentChunk(value.documentChunk);
259
+ return visitor._(value.$unknown[0], value.$unknown[1]);
260
+ };
261
+ })(CitationLocation || (CitationLocation = {}));
262
+ export var CitationSourceContent;
263
+ (function (CitationSourceContent) {
264
+ CitationSourceContent.visit = (value, visitor) => {
265
+ if (value.text !== undefined)
266
+ return visitor.text(value.text);
267
+ return visitor._(value.$unknown[0], value.$unknown[1]);
268
+ };
269
+ })(CitationSourceContent || (CitationSourceContent = {}));
270
+ export var CitationGeneratedContent;
271
+ (function (CitationGeneratedContent) {
272
+ CitationGeneratedContent.visit = (value, visitor) => {
273
+ if (value.text !== undefined)
274
+ return visitor.text(value.text);
275
+ return visitor._(value.$unknown[0], value.$unknown[1]);
276
+ };
277
+ })(CitationGeneratedContent || (CitationGeneratedContent = {}));
250
278
  export const DocumentFormat = {
251
279
  CSV: "csv",
252
280
  DOC: "doc",
@@ -258,6 +286,14 @@ export const DocumentFormat = {
258
286
  XLS: "xls",
259
287
  XLSX: "xlsx",
260
288
  };
289
+ export var DocumentContentBlock;
290
+ (function (DocumentContentBlock) {
291
+ DocumentContentBlock.visit = (value, visitor) => {
292
+ if (value.text !== undefined)
293
+ return visitor.text(value.text);
294
+ return visitor._(value.$unknown[0], value.$unknown[1]);
295
+ };
296
+ })(DocumentContentBlock || (DocumentContentBlock = {}));
261
297
  export var DocumentSource;
262
298
  (function (DocumentSource) {
263
299
  DocumentSource.visit = (value, visitor) => {
@@ -265,6 +301,10 @@ export var DocumentSource;
265
301
  return visitor.bytes(value.bytes);
266
302
  if (value.s3Location !== undefined)
267
303
  return visitor.s3Location(value.s3Location);
304
+ if (value.text !== undefined)
305
+ return visitor.text(value.text);
306
+ if (value.content !== undefined)
307
+ return visitor.content(value.content);
268
308
  return visitor._(value.$unknown[0], value.$unknown[1]);
269
309
  };
270
310
  })(DocumentSource || (DocumentSource = {}));
@@ -383,6 +423,8 @@ export var ContentBlock;
383
423
  return visitor.cachePoint(value.cachePoint);
384
424
  if (value.reasoningContent !== undefined)
385
425
  return visitor.reasoningContent(value.reasoningContent);
426
+ if (value.citationsContent !== undefined)
427
+ return visitor.citationsContent(value.citationsContent);
386
428
  return visitor._(value.$unknown[0], value.$unknown[1]);
387
429
  };
388
430
  })(ContentBlock || (ContentBlock = {}));
@@ -526,6 +568,8 @@ export var ContentBlockDelta;
526
568
  return visitor.toolUse(value.toolUse);
527
569
  if (value.reasoningContent !== undefined)
528
570
  return visitor.reasoningContent(value.reasoningContent);
571
+ if (value.citation !== undefined)
572
+ return visitor.citation(value.citation);
529
573
  return visitor._(value.$unknown[0], value.$unknown[1]);
530
574
  };
531
575
  })(ContentBlockDelta || (ContentBlockDelta = {}));
@@ -725,6 +769,8 @@ export const ContentBlockFilterSensitiveLog = (obj) => {
725
769
  return { cachePoint: obj.cachePoint };
726
770
  if (obj.reasoningContent !== undefined)
727
771
  return { reasoningContent: SENSITIVE_STRING };
772
+ if (obj.citationsContent !== undefined)
773
+ return { citationsContent: obj.citationsContent };
728
774
  if (obj.$unknown !== undefined)
729
775
  return { [obj.$unknown[0]]: "UNKNOWN" };
730
776
  };
@@ -785,6 +831,8 @@ export const ContentBlockDeltaFilterSensitiveLog = (obj) => {
785
831
  return { toolUse: obj.toolUse };
786
832
  if (obj.reasoningContent !== undefined)
787
833
  return { reasoningContent: SENSITIVE_STRING };
834
+ if (obj.citation !== undefined)
835
+ return { citation: obj.citation };
788
836
  if (obj.$unknown !== undefined)
789
837
  return { [obj.$unknown[0]]: "UNKNOWN" };
790
838
  };