@kensio/yulin 1.20.14 → 1.20.16

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 (154) hide show
  1. package/README.md +13 -0
  2. package/{dist/config/oxlint/cffjs2.oxlintrc.json → cffjs2.oxlintrc.json} +1 -1
  3. package/dist/config/oxlint/cffjs2.oxlint.config.js +4 -3
  4. package/dist/sdk/module/sim-sdk-module-client-interceptor.d.ts +5 -0
  5. package/dist/sdk/module/sim-sdk-module-client-interceptor.js +14 -0
  6. package/dist/sdk/module/sim-sdk-static-client-factory.d.ts +26 -0
  7. package/dist/sdk/module/sim-sdk-static-client-factory.js +59 -0
  8. package/dist/sdk/send-patch.d.ts +8 -0
  9. package/dist/sdk/send-patch.js +11 -0
  10. package/dist/service/aws/caller/sim-aws-caller-resolver.d.ts +28 -6
  11. package/dist/service/aws/caller/sim-aws-caller-resolver.js +18 -11
  12. package/dist/service/aws/caller/sim-aws-caller.d.ts +9 -0
  13. package/dist/service/aws/caller/sim-aws-resolved-caller.d.ts +19 -0
  14. package/dist/service/aws/caller/sim-aws-resolved-caller.js +26 -0
  15. package/dist/service/aws/factory/sim-aws-account-region-service-builder.d.ts +6 -0
  16. package/dist/service/aws/factory/sim-aws-account-region-service-builder.js +3 -0
  17. package/dist/service/aws/factory/sim-aws-account-service-cache.d.ts +6 -0
  18. package/dist/service/aws/factory/sim-aws-account-service-cache.js +5 -0
  19. package/dist/service/aws/factory/sim-aws-service-factory.d.ts +5 -0
  20. package/dist/service/aws/factory/sim-aws-service-factory.js +6 -0
  21. package/dist/service/aws/sim-aws-properties.d.ts +15 -0
  22. package/dist/service/aws/sim-aws.js +2 -1
  23. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.d.ts +11 -4
  24. package/dist/service/cloudformation/resource/resolve/property/sim-cfn-resource-property-resolver.js +21 -8
  25. package/dist/service/cloudformation/resource/sim-cfn-resource.type.d.ts +9 -0
  26. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.d.ts +2 -0
  27. package/dist/service/cloudformation/template/dynamic/make-sim-cfn-dynamic-references.js +2 -2
  28. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.d.ts +10 -0
  29. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-resolvers.js +4 -3
  30. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.d.ts +11 -0
  31. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-reference-scan.js +21 -0
  32. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.d.ts +24 -2
  33. package/dist/service/cloudformation/template/dynamic/sim-cfn-dynamic-references.js +50 -11
  34. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.d.ts +42 -0
  35. package/dist/service/cloudformation/template/dynamic/sim-cfn-prefetched-dynamic-references.js +80 -0
  36. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.d.ts +16 -0
  37. package/dist/service/eventbridge/delivery/sim-event-bridge-delivery-failures.js +19 -0
  38. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.d.ts +30 -7
  39. package/dist/service/iam/authorize/context/sim-iam-auth-z-caller-context-builder.js +20 -11
  40. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.d.ts +2 -1
  41. package/dist/service/iam/authorize/context/sim-iam-auth-z-context-builder.js +5 -1
  42. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.d.ts +10 -0
  43. package/dist/service/iam/authorize/match/sim-iam-policy-principal-matcher.js +15 -3
  44. package/dist/service/iam/authorize/sim-iam-account-auth-z.d.ts +11 -4
  45. package/dist/service/iam/authorize/sim-iam-account-auth-z.js +5 -3
  46. package/dist/service/iam/authorize/sim-iam-authorizer.d.ts +2 -1
  47. package/dist/service/iam/authorize/sim-iam-authorizer.js +1 -0
  48. package/dist/service/iam/command/policy/create-policy/create-policy-input-resolver.js +4 -1
  49. package/dist/service/iam/command/policy/put-role-policy/put-role-policy.handler.js +5 -1
  50. package/dist/service/iam/command/policy/put-user-policy/put-user-policy.handler.js +5 -1
  51. package/dist/service/iam/policy/parse/sim-iam-document-parser.d.ts +4 -1
  52. package/dist/service/iam/policy/parse/sim-iam-document-parser.js +13 -15
  53. package/dist/service/iam/policy/sim-iam-statement-label.d.ts +28 -0
  54. package/dist/service/iam/policy/sim-iam-statement-label.js +17 -0
  55. package/dist/service/iam/policy/sim-iam-statement-strings.d.ts +11 -0
  56. package/dist/service/iam/policy/sim-iam-statement-strings.js +27 -0
  57. package/dist/service/iam/role/sim-iam-role-with-policy.factory.d.ts +9 -0
  58. package/dist/service/iam/role/sim-iam-role-with-policy.factory.js +4 -2
  59. package/dist/service/iam/sim-iam-account-parts.d.ts +8 -0
  60. package/dist/service/iam/sim-iam-account-parts.js +1 -0
  61. package/dist/service/iam/validate/sim-iam-policy-document-validator.d.ts +9 -2
  62. package/dist/service/iam/validate/sim-iam-policy-document-validator.js +37 -19
  63. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.d.ts +7 -0
  64. package/dist/service/lambda/function/code/sim-lambda-vm-zip-function.factory.js +1 -0
  65. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.d.ts +19 -0
  66. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-provided-sdk-module.js +78 -0
  67. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.d.ts +15 -0
  68. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-sdk-packages-not-installed.error.js +27 -0
  69. package/dist/service/lambda/function/code/vm/sdk/sim-lambda-vm-sdk-module-provider.d.ts +9 -0
  70. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.d.ts +10 -0
  71. package/dist/service/lambda/function/code/vm/sdk/sim-sdk-lambda-vm-module-provider.js +28 -34
  72. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.d.ts +15 -0
  73. package/dist/service/lambda/function/code/vm/sim-lambda-host-modules.js +31 -0
  74. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.d.ts +7 -0
  75. package/dist/service/lambda/function/code/vm/sim-lambda-vm-module-resolver.js +15 -0
  76. package/dist/service/lambda/function/code/vm/sim-lambda-vm-modules.js +5 -4
  77. package/dist/service/s3/command/put-bucket-policy/put-bucket-policy.handler.js +4 -1
  78. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.d.ts +16 -0
  79. package/dist/service/scheduler/delivery/sim-scheduler-delivery-failures.js +19 -0
  80. package/dist/service/scheduler/index.d.ts +1 -1
  81. package/dist/service/scheduler/index.js +1 -1
  82. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.d.ts +13 -15
  83. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-dynamic-reference-resolver.js +22 -43
  84. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.d.ts +9 -0
  85. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-stand-in.js +14 -0
  86. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.d.ts +12 -0
  87. package/dist/service/secretsmanager/cfn/dynamic/sim-cfn-secrets-manager-reference-value.js +29 -0
  88. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.d.ts +22 -6
  89. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-dynamic-reference-resolver.js +39 -24
  90. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.d.ts +10 -5
  91. package/dist/service/ssm/cfn/dynamic/sim-cfn-ssm-secure-dynamic-reference-resolver.js +10 -8
  92. package/dist/service/ssm/sim-ssm.d.ts +10 -2
  93. package/dist/service/ssm/sim-ssm.js +12 -4
  94. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.d.ts +9 -2
  95. package/dist/service/sts/auth-z/assume-role-auth-z-coordinator.js +2 -2
  96. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.d.ts +10 -4
  97. package/dist/service/sts/auth-z/assume-role-source-account-auth-z.js +8 -7
  98. package/dist/service/sts/auth-z/assume-role-target-auth-z.d.ts +2 -2
  99. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.d.ts +6 -2
  100. package/dist/service/sts/auth-z/assume-role-trust-policy-authorizer.js +14 -11
  101. package/dist/service/sts/command/assume-role/assume-role.handler.d.ts +5 -1
  102. package/dist/service/sts/command/assume-role/assume-role.handler.js +5 -2
  103. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.d.ts +5 -1
  104. package/dist/service/sts/command/get-caller-identity/get-caller-identity.handler.js +4 -1
  105. package/dist/service/sts/service-role/sim-service-role.js +5 -1
  106. package/dist/service/sts/sim-sts.d.ts +9 -1
  107. package/dist/service/sts/sim-sts.js +4 -0
  108. package/docs/README.md +54 -0
  109. package/docs/ai-skill/README.md +69 -0
  110. package/docs/cli/README.md +284 -0
  111. package/docs/factories/README.md +140 -0
  112. package/docs/lint/README.md +176 -0
  113. package/docs/non-aws-dependencies/README.md +261 -0
  114. package/docs/sdk/README.md +272 -0
  115. package/docs/serve/README.md +1126 -0
  116. package/docs/services/acm/README.md +823 -0
  117. package/docs/services/apigateway/README.md +1919 -0
  118. package/docs/services/apigatewayv2/README.md +2678 -0
  119. package/docs/services/athena/README.md +1044 -0
  120. package/docs/services/bedrock/README.md +350 -0
  121. package/docs/services/cloudformation/README.md +3440 -0
  122. package/docs/services/cloudfront/README.md +2874 -0
  123. package/docs/services/cloudwatch/README.md +420 -0
  124. package/docs/services/cognito/README.md +4923 -0
  125. package/docs/services/dynamodb/README.md +3784 -0
  126. package/docs/services/ecr/README.md +302 -0
  127. package/docs/services/ecs/README.md +2010 -0
  128. package/docs/services/elbv2/README.md +1897 -0
  129. package/docs/services/eventbridge/README.md +1110 -0
  130. package/docs/services/firehose/README.md +805 -0
  131. package/docs/services/glue/README.md +501 -0
  132. package/docs/services/iam/README.md +1283 -0
  133. package/docs/services/kinesis/README.md +454 -0
  134. package/docs/services/kms/README.md +659 -0
  135. package/docs/services/lambda/README.md +3645 -0
  136. package/docs/services/logs/README.md +868 -0
  137. package/docs/services/organizations/README.md +574 -0
  138. package/docs/services/personalize/README.md +835 -0
  139. package/docs/services/rekognition/README.md +1070 -0
  140. package/docs/services/route53/README.md +1783 -0
  141. package/docs/services/s3/README.md +3024 -0
  142. package/docs/services/scheduler/README.md +806 -0
  143. package/docs/services/secretsmanager/README.md +667 -0
  144. package/docs/services/ses/README.md +1011 -0
  145. package/docs/services/sns/README.md +1904 -0
  146. package/docs/services/sqs/README.md +1185 -0
  147. package/docs/services/ssm/README.md +1072 -0
  148. package/docs/services/stepfunctions/README.md +1332 -0
  149. package/docs/services/sts/README.md +245 -0
  150. package/docs/services/wafv2/README.md +1378 -0
  151. package/docs/terraform/README.md +248 -0
  152. package/docs/time/README.md +284 -0
  153. package/llms.txt +59 -0
  154. package/package.json +9 -5
@@ -0,0 +1,350 @@
1
+ # Simulated Bedrock
2
+
3
+ Simulated Bedrock answers model invocations from responses declared against a prompt or a model. A
4
+ test says what the model says, and no model runs.
5
+
6
+ Bedrock-specific types are imported from the `@kensio/yulin/bedrock` subpath.
7
+
8
+ ## Answering a conversation
9
+
10
+ `Converse` answers with the response declared for the prompt it carries. The prompt is the text of
11
+ the last user message.
12
+
13
+ ```typescript sim-bedrock-converse
14
+ /**
15
+ * Declaring what a model answers one prompt with, and conversing with it.
16
+ */
17
+
18
+ import { ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
19
+
20
+ import { SimAws } from "@kensio/yulin";
21
+
22
+ const simAws = new SimAws();
23
+
24
+ simAws.bedrock().responses().onPrompt("Summarise entry 1042", {
25
+ text: "Entry 1042 covers the tone sandhi rules.",
26
+ });
27
+
28
+ const answered = await simAws.bedrock().converse(
29
+ new ConverseCommand({
30
+ modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
31
+ messages: [{ role: "user", content: [{ text: "Summarise entry 1042" }] }],
32
+ }),
33
+ );
34
+
35
+ console.log(answered.output.message.content.at(0)?.text);
36
+ // "Entry 1042 covers the tone sandhi rules."
37
+ console.log(answered.stopReason); // "end_turn"
38
+ ```
39
+
40
+ A conversation with several turns matches on its last user message, so a rule keeps matching as the
41
+ conversation grows.
42
+
43
+ ## Answering every call to one model
44
+
45
+ `onModel` covers every invocation of a model that no prompt rule matched first. This is the rule for
46
+ a test that cares about the code around the call rather than about one exchange.
47
+
48
+ ```typescript sim-bedrock-model-rule
49
+ /**
50
+ * Declaring one answer for every call to a model.
51
+ */
52
+
53
+ import { ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
54
+
55
+ import { SimAws } from "@kensio/yulin";
56
+
57
+ const simAws = new SimAws();
58
+
59
+ simAws
60
+ .bedrock()
61
+ .responses()
62
+ .onModel("amazon.nova-pro-v1:0", { text: "A short summary." });
63
+
64
+ const answered = await simAws.bedrock().converse(
65
+ new ConverseCommand({
66
+ modelId: "amazon.nova-pro-v1:0",
67
+ messages: [{ role: "user", content: [{ text: "Anything at all" }] }],
68
+ }),
69
+ );
70
+
71
+ console.log(answered.output.message.content.at(0)?.text); // "A short summary."
72
+ ```
73
+
74
+ `byDefault` covers everything else again. An invocation matching no rule at all answers with a
75
+ built-in line of text that says it is simulated.
76
+
77
+ ## Answering with a tool call
78
+
79
+ A declared response carries content blocks as they were written, so a tool call reaches the code
80
+ that handles one. The response stops for `tool_use` unless the declaration names another reason.
81
+
82
+ ```typescript sim-bedrock-tool-use
83
+ /**
84
+ * Declaring a tool call for the code under test to handle.
85
+ */
86
+
87
+ import { ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
88
+
89
+ import { SimAws } from "@kensio/yulin";
90
+
91
+ const simAws = new SimAws();
92
+
93
+ simAws
94
+ .bedrock()
95
+ .responses()
96
+ .onPrompt("What is in entry 1042?", {
97
+ content: [
98
+ {
99
+ toolUse: {
100
+ toolUseId: "tooluse-1",
101
+ name: "lookUpEntry",
102
+ input: { entryId: "1042" },
103
+ },
104
+ },
105
+ ],
106
+ });
107
+
108
+ const answered = await simAws.bedrock().converse(
109
+ new ConverseCommand({
110
+ modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
111
+ messages: [{ role: "user", content: [{ text: "What is in entry 1042?" }] }],
112
+ }),
113
+ );
114
+
115
+ console.log(answered.stopReason); // "tool_use"
116
+ console.log(answered.output.message.content.at(0)?.toolUse?.name);
117
+ // "lookUpEntry"
118
+ ```
119
+
120
+ ## Streaming a conversation
121
+
122
+ `ConverseStream` answers from the same rules, and sends the response as the events real Bedrock
123
+ sends. Declaring `chunks` says where the deltas fall.
124
+
125
+ ```typescript sim-bedrock-converse-stream
126
+ /**
127
+ * Declaring a response in chunks and accumulating the stream.
128
+ */
129
+
130
+ import { ConverseStreamCommand } from "@aws-sdk/client-bedrock-runtime";
131
+
132
+ import { SimAws } from "@kensio/yulin";
133
+
134
+ const simAws = new SimAws();
135
+
136
+ simAws
137
+ .bedrock()
138
+ .responses()
139
+ .onPrompt("Summarise entry 1042", {
140
+ chunks: ["Entry 1042 covers ", "the tone sandhi rules."],
141
+ });
142
+
143
+ const answered = await simAws.bedrock().converseStream(
144
+ new ConverseStreamCommand({
145
+ modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
146
+ messages: [{ role: "user", content: [{ text: "Summarise entry 1042" }] }],
147
+ }),
148
+ );
149
+
150
+ let accumulated = "";
151
+
152
+ for await (const event of answered.stream) {
153
+ accumulated += event.contentBlockDelta?.delta.text ?? "";
154
+ }
155
+
156
+ console.log(accumulated); // "Entry 1042 covers the tone sandhi rules."
157
+ ```
158
+
159
+ The events arrive in the order real Bedrock sends them. `messageStart`, then one
160
+ `contentBlockDelta` per chunk, then `contentBlockStop`, `messageStop` carrying the stop reason, and
161
+ `metadata` carrying the token counts. A tool call adds a `contentBlockStart` before its delta,
162
+ carrying the tool use id and name.
163
+
164
+ The same declaration serves both APIs. `Converse` answers with the chunks joined, and a response
165
+ declared as `text` streams as a single delta. A stream is readable once, and reading it again
166
+ raises.
167
+
168
+ `InvokeModelWithResponseStream` streams the declared body as a single `chunk`:
169
+
170
+ ```typescript
171
+ for await (const event of answered.body) {
172
+ accumulated += new TextDecoder().decode(event.chunk?.bytes);
173
+ }
174
+ ```
175
+
176
+ ## Invoking a model directly
177
+
178
+ `InvokeModel` answers with the body declared for the request, serialized as JSON. The body is the
179
+ shape the model behind the id uses, which is why there is no built-in default for it.
180
+
181
+ ```typescript sim-bedrock-invoke-model
182
+ /**
183
+ * Declaring a model-specific response body and invoking the model.
184
+ */
185
+
186
+ import { InvokeModelCommand } from "@aws-sdk/client-bedrock-runtime";
187
+
188
+ import { SimAws } from "@kensio/yulin";
189
+
190
+ const simAws = new SimAws();
191
+
192
+ simAws
193
+ .bedrock()
194
+ .responses()
195
+ .onModel("amazon.titan-text-express-v1", {
196
+ body: { results: [{ outputText: "Entry 1042 covers tone sandhi." }] },
197
+ });
198
+
199
+ const answered = await simAws.bedrock().invokeModel(
200
+ new InvokeModelCommand({
201
+ modelId: "amazon.titan-text-express-v1",
202
+ body: JSON.stringify({ inputText: "Summarise entry 1042" }),
203
+ }),
204
+ );
205
+
206
+ console.log(JSON.parse(new TextDecoder().decode(answered.body)));
207
+ // { results: [ { outputText: "Entry 1042 covers tone sandhi." } ] }
208
+ ```
209
+
210
+ An `InvokeModel` request matches a prompt rule on its request body decoded as UTF-8. A model rule is
211
+ usually the one to reach for.
212
+
213
+ ## Reporting token counts
214
+
215
+ `usage` comes from the declaration, and a response that declares none reports fixed counts.
216
+
217
+ ```typescript sim-bedrock-usage
218
+ /**
219
+ * Declaring what a response cost, for code that meters token spend.
220
+ */
221
+
222
+ import { ConverseCommand } from "@aws-sdk/client-bedrock-runtime";
223
+
224
+ import { SimAws } from "@kensio/yulin";
225
+
226
+ const simAws = new SimAws();
227
+
228
+ simAws
229
+ .bedrock()
230
+ .responses()
231
+ .byDefault({
232
+ text: "A short summary.",
233
+ usage: { inputTokens: 1400, outputTokens: 220 },
234
+ });
235
+
236
+ const answered = await simAws.bedrock().converse(
237
+ new ConverseCommand({
238
+ modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
239
+ messages: [{ role: "user", content: [{ text: "Summarise entry 1042" }] }],
240
+ }),
241
+ );
242
+
243
+ console.log(answered.usage.totalTokens); // 1620
244
+ ```
245
+
246
+ ## Authorizing an invocation
247
+
248
+ An invocation authorizes `bedrock:InvokeModel` against the model it names. A base model id becomes a
249
+ foundation model ARN for the Region the call was made in, and an inference profile ARN or a
250
+ provisioned model ARN is authorized against as it was written.
251
+
252
+ ## SDK interception
253
+
254
+ An intercepted `BedrockRuntimeClient` reaches the simulated Bedrock of the Account and Region the
255
+ client is configured for.
256
+
257
+ ```typescript sim-bedrock-sdk-interception
258
+ /**
259
+ * Answering production code that holds its own Bedrock Runtime client.
260
+ */
261
+
262
+ import {
263
+ BedrockRuntimeClient,
264
+ ConverseCommand,
265
+ } from "@aws-sdk/client-bedrock-runtime";
266
+
267
+ import { SimSdk } from "@kensio/yulin/sdk";
268
+
269
+ const simSdk = new SimSdk();
270
+ simSdk.intercept(BedrockRuntimeClient);
271
+
272
+ simSdk.simAws
273
+ .account()
274
+ .region("eu-west-2")
275
+ .bedrock()
276
+ .responses()
277
+ .byDefault({ text: "Entry 1042 covers the tone sandhi rules." });
278
+
279
+ const client = new BedrockRuntimeClient({ region: "eu-west-2" });
280
+
281
+ const answered = await client.send(
282
+ new ConverseCommand({
283
+ modelId: "anthropic.claude-3-5-sonnet-20241022-v2:0",
284
+ messages: [{ role: "user", content: [{ text: "Summarise entry 1042" }] }],
285
+ }),
286
+ );
287
+
288
+ console.log(answered.output?.message?.content?.at(0)?.text);
289
+ // "Entry 1042 covers the tone sandhi rules."
290
+
291
+ client.destroy();
292
+ simSdk.restoreAll();
293
+ ```
294
+
295
+ ## Available functionality
296
+
297
+ - `Converse`, `ConverseStream`, `InvokeModel` and `InvokeModelWithResponseStream`, through
298
+ `simAws.bedrock()` and through an intercepted `BedrockRuntimeClient`.
299
+ - Responses declared with `onPrompt`, `onModel` and `byDefault`. A prompt rule wins, then a model
300
+ rule, then the default.
301
+ - A declared response carries `text`, `chunks` or `content` blocks for `Converse`, a `body` for
302
+ `InvokeModel`, and optionally a `stopReason` and a `usage`.
303
+ - Streamed responses, with `chunks` deciding where the deltas fall and one declaration serving the
304
+ streaming and non-streaming APIs alike.
305
+ - Tool calls, as a declared `toolUse` content block.
306
+ - IAM authorization of `bedrock:InvokeModel` against the foundation model, inference profile or
307
+ provisioned model ARN the request names.
308
+ - Rules held per Account and Region, so two Regions answer the same prompt differently.
309
+
310
+ ## Limitations
311
+
312
+ - No model runs. A response is whatever the matching rule declared, and the prompt is read only as
313
+ a key to match on.
314
+ - Every event of a stream is ready as soon as the call returns. Real Bedrock sends them as the model
315
+ generates them. No simulated clock advance separates them here.
316
+ - A response is split into deltas only where the declaration says so. Text declared any other way
317
+ arrives in one delta. The split a real model streams comes from its own tokenizer.
318
+ - A streamed tool call sends its arguments in one delta. Real `ConverseStream` sends them as
319
+ fragments of JSON to be concatenated. A tool call with no declared arguments sends `{}`.
320
+ - `InvokeModelWithResponseStream` sends the declared body as a single chunk. Real Bedrock sends a
321
+ chunk per generated fragment, in the shape the model behind the id uses.
322
+ - A serialized Bedrock request is refused. Bedrock speaks REST-JSON, and the wire path answers only
323
+ the AWS JSON protocol services. A function bundling its own SDK reaches Bedrock through module
324
+ interception. S3 and every other non-JSON-protocol service are reached the same way.
325
+ - The Bedrock control plane is unsimulated. `ListFoundationModels`, guardrail management, inference
326
+ profile management and provisioned throughput all belong to `BedrockClient`.
327
+ - Bedrock Agents and knowledge bases are unsimulated. `InvokeAgent`, `Retrieve` and
328
+ `RetrieveAndGenerate` arrive on a client of their own.
329
+ - `ApplyGuardrail` is unsimulated, and a `guardrailConfig` or a `guardrailIdentifier` on an
330
+ invocation is refused outright. Answering without the guardrail would make one look applied here
331
+ and be applied in production.
332
+ - `system`, `inferenceConfig`, `toolConfig` and `additionalModelRequestFields` are accepted and
333
+ decide nothing. `maxTokens` truncates no declared response, and a `toolConfig` naming no tools
334
+ still gets a declared tool call.
335
+ - Token counts are fixed unless the declaration carries them. Counting them needs the tokenizer of
336
+ the model the request names. Declare a `usage` where the code under test meters spend.
337
+ - `metrics.latencyMs` is always zero. No time passes during an invocation.
338
+ - A `Converse` with no messages is refused. Real Bedrock accepts one where the `modelId` names a
339
+ prompt version from Prompt management, which is unsimulated.
340
+ - The model id goes unchecked. AWS publishes no enumerable table of model ids, so refusing one would
341
+ be failing closed against Yulin's own gaps.
342
+ - `InvokeModel` has no built-in default response body, and an invocation matching a rule that
343
+ declares none is refused. A response body is model-specific, and one family's shape served for
344
+ every other one would parse into something the caller cannot read.
345
+ - An `InvokeModel` body that arrives as a stream or a Blob matches no prompt rule. Reading it would
346
+ consume the caller's own request body, so such a request falls through to a model rule or to the
347
+ default.
348
+ - A `Converse` call matching a response declared only as a body is refused for the same reason. It
349
+ does not fall back to the default.
350
+ - There are no CloudFormation resource types for Bedrock, and Bedrock is absent from `serveSimAws`.