@aws-cdk/aws-bedrock-agentcore-alpha 2.250.0-alpha.0 → 2.252.0-alpha.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 (56) hide show
  1. package/.jsii +11883 -7285
  2. package/.jsii.tabl.json.gz +0 -0
  3. package/.warnings.jsii.js +4 -0
  4. package/README.md +405 -0
  5. package/lib/gateway/gateway-base.js +1 -1
  6. package/lib/gateway/gateway.d.ts +58 -0
  7. package/lib/gateway/gateway.js +46 -3
  8. package/lib/gateway/inbound-auth/authorizer.d.ts +27 -1
  9. package/lib/gateway/inbound-auth/authorizer.js +37 -5
  10. package/lib/gateway/inbound-auth/custom-claim.js +1 -1
  11. package/lib/gateway/interceptor.js +1 -1
  12. package/lib/gateway/outbound-auth/api-key.js +1 -1
  13. package/lib/gateway/outbound-auth/credential-provider.js +1 -1
  14. package/lib/gateway/protocol.js +2 -2
  15. package/lib/gateway/targets/schema/api-schema.js +4 -4
  16. package/lib/gateway/targets/schema/tool-schema.js +4 -4
  17. package/lib/gateway/targets/target-base.js +1 -1
  18. package/lib/gateway/targets/target-configuration.js +6 -6
  19. package/lib/gateway/targets/target.js +1 -1
  20. package/lib/index.d.ts +8 -0
  21. package/lib/index.js +13 -1
  22. package/lib/memory/memory-strategy.js +1 -1
  23. package/lib/memory/memory.js +2 -2
  24. package/lib/memory/strategies/managed-strategy.js +1 -1
  25. package/lib/memory/strategies/self-managed-strategy.js +1 -1
  26. package/lib/network/network-configuration.js +4 -4
  27. package/lib/policy/perms.d.ts +50 -0
  28. package/lib/policy/perms.js +62 -0
  29. package/lib/policy/policy-base.d.ts +194 -0
  30. package/lib/policy/policy-base.js +120 -0
  31. package/lib/policy/policy-engine-base.d.ts +260 -0
  32. package/lib/policy/policy-engine-base.js +193 -0
  33. package/lib/policy/policy-engine.d.ts +150 -0
  34. package/lib/policy/policy-engine.js +290 -0
  35. package/lib/policy/policy-statement.d.ts +518 -0
  36. package/lib/policy/policy-statement.js +927 -0
  37. package/lib/policy/policy-types.d.ts +66 -0
  38. package/lib/policy/policy-types.js +30 -0
  39. package/lib/policy/policy.d.ts +127 -0
  40. package/lib/policy/policy.js +225 -0
  41. package/lib/policy/validation-helpers.d.ts +139 -0
  42. package/lib/policy/validation-helpers.js +276 -0
  43. package/lib/runtime/inbound-auth/custom-claim.js +1 -1
  44. package/lib/runtime/inbound-auth/runtime-authorizer-configuration.js +1 -1
  45. package/lib/runtime/observability.d.ts +105 -0
  46. package/lib/runtime/observability.js +317 -0
  47. package/lib/runtime/runtime-artifact.js +1 -1
  48. package/lib/runtime/runtime-base.js +1 -1
  49. package/lib/runtime/runtime-endpoint-base.js +1 -1
  50. package/lib/runtime/runtime-endpoint.js +1 -1
  51. package/lib/runtime/runtime.d.ts +17 -0
  52. package/lib/runtime/runtime.js +10 -2
  53. package/lib/tools/browser.js +2 -2
  54. package/lib/tools/code-interpreter.js +2 -2
  55. package/package.json +9 -9
  56. package/rosetta/default.ts-fixture +2 -0
@@ -0,0 +1,518 @@
1
+ /**
2
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
5
+ * with the License. A copy of the License is located at
6
+ *
7
+ * http://www.apache.org/licenses/LICENSE-2.0
8
+ *
9
+ * or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES
10
+ * OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions
11
+ * and limitations under the License.
12
+ */
13
+ /**
14
+ * A single condition expression in Cedar policy language.
15
+ */
16
+ declare class ConditionExpression {
17
+ private readonly attribute;
18
+ private readonly operator;
19
+ private readonly value;
20
+ constructor(attribute: string, operator: string, value: string | number | boolean);
21
+ toCedar(): string;
22
+ }
23
+ /**
24
+ * Builder for condition expressions in Cedar policies.
25
+ *
26
+ * Conditions define when a policy statement should apply or not apply.
27
+ * Supports logical operators (AND, OR) and various comparison operators.
28
+ */
29
+ export declare class ConditionBuilder {
30
+ private conditions;
31
+ private operators;
32
+ /**
33
+ * Access a principal attribute for comparison.
34
+ *
35
+ * Principal attributes come from the authenticated user/service making the request.
36
+ * Common attributes: username, role, department, groups, etc.
37
+ *
38
+ * @param attribute - The attribute name (e.g., 'department', 'role', 'username')
39
+ */
40
+ principalAttribute(attribute: string): AttributeAccessor;
41
+ /**
42
+ * Access a resource attribute for comparison.
43
+ *
44
+ * Resource attributes come from the target resource being accessed.
45
+ * Common attributes: arn, type, tags, owner, etc.
46
+ *
47
+ * @param attribute - The attribute name (e.g., 'confidential', 'owner', 'classification')
48
+ */
49
+ resourceAttribute(attribute: string): AttributeAccessor;
50
+ /**
51
+ * Access a context attribute for comparison.
52
+ *
53
+ * Context attributes come from the request environment.
54
+ * Common attributes: sourceIp, timestamp, environment, region, etc.
55
+ *
56
+ * @param attribute - The attribute name (e.g., 'sourceIp', 'environment', 'timestamp')
57
+ */
58
+ contextAttribute(attribute: string): AttributeAccessor;
59
+ /**
60
+ * Logical AND operator - all conditions must be true.
61
+ */
62
+ and(): this;
63
+ /**
64
+ * Logical OR operator - at least one condition must be true.
65
+ */
66
+ or(): this;
67
+ /**
68
+ * Internal method to add a condition expression.
69
+ * @internal
70
+ */
71
+ _addCondition(condition: ConditionExpression): this;
72
+ /**
73
+ * Generate Cedar condition syntax.
74
+ * @internal
75
+ */
76
+ _toCedar(): string;
77
+ }
78
+ /**
79
+ * Wrapper class for conditionally building policy statements.
80
+ *
81
+ * This class allows chaining condition methods and returning to the parent
82
+ * PolicyStatement when done. It proxies condition building methods from
83
+ * ConditionBuilder.
84
+ */
85
+ export declare class ConditionalPolicyStatement {
86
+ private readonly policyStatement;
87
+ private readonly conditionBuilder;
88
+ constructor(policyStatement: PolicyStatement, conditionBuilder: ConditionBuilder);
89
+ /**
90
+ * Access a principal attribute for comparison.
91
+ *
92
+ * @param attribute - The attribute name (e.g., 'department', 'role', 'username')
93
+ */
94
+ principalAttribute(attribute: string): ConditionalAttributeAccessor;
95
+ /**
96
+ * Access a resource attribute for comparison.
97
+ *
98
+ * @param attribute - The attribute name (e.g., 'confidential', 'owner', 'classification')
99
+ */
100
+ resourceAttribute(attribute: string): ConditionalAttributeAccessor;
101
+ /**
102
+ * Access a context attribute for comparison.
103
+ *
104
+ * @param attribute - The attribute name (e.g., 'sourceIp', 'environment', 'timestamp')
105
+ */
106
+ contextAttribute(attribute: string): ConditionalAttributeAccessor;
107
+ /**
108
+ * Logical AND operator - all conditions must be true.
109
+ */
110
+ and(): this;
111
+ /**
112
+ * Logical OR operator - at least one condition must be true.
113
+ */
114
+ or(): this;
115
+ /**
116
+ * Complete condition building and return to the PolicyStatement.
117
+ *
118
+ * Use this to finish building when/unless conditions and continue
119
+ * configuring the policy statement.
120
+ */
121
+ done(): PolicyStatement;
122
+ /**
123
+ * Alias for done() to support fluent unless() chaining.
124
+ */
125
+ unless(): ConditionalPolicyStatement;
126
+ }
127
+ /**
128
+ * Accessor for building type-safe attribute comparisons within conditional statements.
129
+ *
130
+ * Returns ConditionalPolicyStatement to allow chaining back to policy building.
131
+ */
132
+ export declare class ConditionalAttributeAccessor {
133
+ private readonly path;
134
+ private readonly parent;
135
+ private readonly conditionBuilder;
136
+ constructor(path: string, parent: ConditionalPolicyStatement, conditionBuilder: ConditionBuilder);
137
+ /**
138
+ * Equality comparison (==)
139
+ */
140
+ equalTo(value: string | number | boolean): ConditionalPolicyStatement;
141
+ /**
142
+ * Inequality comparison (!=)
143
+ */
144
+ notEqualTo(value: string | number | boolean): ConditionalPolicyStatement;
145
+ /**
146
+ * Less than comparison (<)
147
+ */
148
+ lessThan(value: number): ConditionalPolicyStatement;
149
+ /**
150
+ * Less than or equals comparison (<=)
151
+ */
152
+ lessThanOrEqualTo(value: number): ConditionalPolicyStatement;
153
+ /**
154
+ * Greater than comparison (>)
155
+ */
156
+ greaterThan(value: number): ConditionalPolicyStatement;
157
+ /**
158
+ * Greater than or equals comparison (>=)
159
+ */
160
+ greaterThanOrEqualTo(value: number): ConditionalPolicyStatement;
161
+ /**
162
+ * IP range check - tests if IP address is in CIDR range.
163
+ *
164
+ * @param ipRange - CIDR notation (e.g., '192.168.1.0/24')
165
+ */
166
+ isInRange(ipRange: string): ConditionalPolicyStatement;
167
+ /**
168
+ * String contains check.
169
+ */
170
+ contains(value: string): ConditionalPolicyStatement;
171
+ /**
172
+ * Check if attribute is in a set/list.
173
+ */
174
+ isIn(values: (string | number)[]): ConditionalPolicyStatement;
175
+ }
176
+ /**
177
+ * Accessor for building type-safe attribute comparisons.
178
+ *
179
+ * Provides methods for common comparison operators with proper type checking.
180
+ */
181
+ export declare class AttributeAccessor {
182
+ private readonly path;
183
+ private readonly parent;
184
+ constructor(path: string, parent: ConditionBuilder);
185
+ /**
186
+ * Equality comparison (==)
187
+ */
188
+ equalTo(value: string | number | boolean): ConditionBuilder;
189
+ /**
190
+ * Inequality comparison (!=)
191
+ */
192
+ notEqualTo(value: string | number | boolean): ConditionBuilder;
193
+ /**
194
+ * Less than comparison (<)
195
+ */
196
+ lessThan(value: number): ConditionBuilder;
197
+ /**
198
+ * Less than or equals comparison (<=)
199
+ */
200
+ lessThanOrEqualTo(value: number): ConditionBuilder;
201
+ /**
202
+ * Greater than comparison (>)
203
+ */
204
+ greaterThan(value: number): ConditionBuilder;
205
+ /**
206
+ * Greater than or equals comparison (>=)
207
+ */
208
+ greaterThanOrEqualTo(value: number): ConditionBuilder;
209
+ /**
210
+ * IP range check - tests if IP address is in CIDR range.
211
+ *
212
+ * @param ipRange - CIDR notation (e.g., '192.168.1.0/24')
213
+ */
214
+ isInRange(ipRange: string): ConditionBuilder;
215
+ /**
216
+ * String contains check.
217
+ */
218
+ contains(value: string): ConditionBuilder;
219
+ /**
220
+ * Check if attribute is in a set/list.
221
+ */
222
+ isIn(values: (string | number)[]): ConditionBuilder;
223
+ }
224
+ /**
225
+ * Type-safe builder for creating Cedar authorization policy statements.
226
+ *
227
+ * This builder provides a fluent API for constructing Cedar policies without
228
+ * requiring knowledge of Cedar syntax. It supports:
229
+ * - Permit and forbid effects
230
+ * - Principal, action, and resource specifications
231
+ * - Conditional logic (when/unless clauses)
232
+ * - Raw Cedar for advanced cases
233
+ *
234
+ * The builder generates valid Cedar policy statements that can be used with
235
+ * the Policy construct.
236
+ *
237
+ * @example
238
+ * import { Policy, PolicyEngine, PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
239
+ * declare const engine: PolicyEngine;
240
+ *
241
+ * // Example 1: Simple permit policy
242
+ * // Builder format:
243
+ * new Policy(this, 'AllowAll', {
244
+ * policyEngine: engine,
245
+ * statement: PolicyStatement.permit()
246
+ * .forAllPrincipals()
247
+ * .onAllActions()
248
+ * .onAllResources(),
249
+ * });
250
+ *
251
+ * // Generated Cedar:
252
+ * // permit(
253
+ * // principal,
254
+ * // action,
255
+ * // resource
256
+ * // );
257
+ *
258
+ * @example
259
+ * import { Policy, PolicyEngine, PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
260
+ * declare const engine: PolicyEngine;
261
+ * declare const gatewayArn: string;
262
+ *
263
+ * // Example 2: Specific actions policy
264
+ * // Builder format:
265
+ * new Policy(this, 'AllowSpecificActions', {
266
+ * policyEngine: engine,
267
+ * statement: PolicyStatement.permit()
268
+ * .forPrincipalInGroup('Group', 'Engineers')
269
+ * .onActions([
270
+ * 'AgentCore::Action::exampleaction1',
271
+ * 'AgentCore::Action::exampleaction2',
272
+ * ])
273
+ * .onResource('AgentCore::Gateway', gatewayArn),
274
+ * });
275
+ *
276
+ * // Generated Cedar:
277
+ * // permit(
278
+ * // principal in Group::"Engineers",
279
+ * // action in [AgentCore::Action::"exampleaction1", AgentCore::Action::"exampleaction2"],
280
+ * // resource == AgentCore::Gateway::"arn:aws:bedrock:us-east-1:123:gateway/gw-123"
281
+ * // );
282
+ *
283
+ * @example
284
+ * import { Policy, PolicyEngine, PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
285
+ * declare const engine: PolicyEngine;
286
+ *
287
+ * // Example 3: Policy with conditions
288
+ * // Builder format:
289
+ * new Policy(this, 'ConditionalPolicy', {
290
+ * policyEngine: engine,
291
+ * statement: PolicyStatement.permit()
292
+ * .forAllPrincipals()
293
+ * .onAllActions()
294
+ * .onAllResources()
295
+ * .when()
296
+ * .principalAttribute('department').equalTo('Engineering')
297
+ * .and()
298
+ * .contextAttribute('sourceIp').isInRange('192.168.1.0/24')
299
+ * .done()
300
+ * .unless()
301
+ * .principalAttribute('suspended').equalTo(true)
302
+ * .done(),
303
+ * });
304
+ *
305
+ * // Generated Cedar:
306
+ * // permit(
307
+ * // principal,
308
+ * // action,
309
+ * // resource
310
+ * // )
311
+ * // when {
312
+ * // principal.department == "Engineering" && context.sourceIp isInRange ip("192.168.1.0/24")
313
+ * // }
314
+ * // unless {
315
+ * // principal.suspended == true
316
+ * // };
317
+ *
318
+ * @example
319
+ * import { Policy, PolicyEngine, PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
320
+ * declare const engine: PolicyEngine;
321
+ *
322
+ * // Example 4: Raw Cedar policy
323
+ * // For advanced Cedar features not supported by the builder
324
+ * new Policy(this, 'CustomPolicy', {
325
+ * policyEngine: engine,
326
+ * definition: 'permit(principal, action, resource) when { context.custom > 10 };',
327
+ * });
328
+ *
329
+ * // Or using fromCedar():
330
+ * new Policy(this, 'ImportedPolicy', {
331
+ * policyEngine: engine,
332
+ * statement: PolicyStatement.fromCedar(
333
+ * 'forbid(principal, action, resource) when { resource.confidential == true };'
334
+ * ),
335
+ * });
336
+ */
337
+ export declare class PolicyStatement {
338
+ /**
339
+ * Create a permit statement - allows the action if conditions are met.
340
+ *
341
+ * Permit statements grant access when their conditions evaluate to true.
342
+ * Multiple permit statements can apply; any matching permit allows access.
343
+ */
344
+ static permit(): PolicyStatement;
345
+ /**
346
+ * Create a forbid statement - denies the action if conditions are met.
347
+ *
348
+ * Forbid statements deny access when their conditions evaluate to true.
349
+ * Forbid always takes precedence over permit (explicit deny).
350
+ */
351
+ static forbid(): PolicyStatement;
352
+ /**
353
+ * Create from raw Cedar policy statement string.
354
+ *
355
+ * Use this for advanced Cedar features not supported by the builder,
356
+ * or when migrating existing Cedar policies.
357
+ *
358
+ * Validation is deferred to the Policy construct's validationMode setting.
359
+ *
360
+ * @param cedarStatement - Complete Cedar policy statement including effect, principal, action, resource, and conditions
361
+ */
362
+ static fromCedar(cedarStatement: string): PolicyStatement;
363
+ private effect;
364
+ private principalConfig?;
365
+ private actionConfig?;
366
+ private resourceConfig?;
367
+ private whenConditions?;
368
+ private unlessConditions?;
369
+ private rawCedar?;
370
+ private constructor();
371
+ /**
372
+ * Apply to all principals (any user, service, or entity).
373
+ *
374
+ * Generates: `principal` in Cedar
375
+ */
376
+ forAllPrincipals(): this;
377
+ /**
378
+ * Apply to a specific principal entity.
379
+ *
380
+ * Generates: `principal == EntityType::"entityId"` in Cedar
381
+ *
382
+ * @param entityType - The entity type (e.g., 'AgentCore::OAuthUser')
383
+ * @param entityId - Optional specific entity ID
384
+ */
385
+ forPrincipal(entityType: string, entityId?: string): this;
386
+ /**
387
+ * Apply to principals that are members of a specific group.
388
+ *
389
+ * Generates: `principal in Group::"groupId"` in Cedar
390
+ *
391
+ * @param groupType - The group entity type (e.g., 'Group')
392
+ * @param groupId - The group identifier (e.g., 'Admins', 'Engineers')
393
+ */
394
+ forPrincipalInGroup(groupType: string, groupId: string): this;
395
+ /**
396
+ * Apply to all actions (any operation).
397
+ *
398
+ * Generates: `action` in Cedar
399
+ */
400
+ onAllActions(): this;
401
+ /**
402
+ * Apply to specific action(s).
403
+ *
404
+ * Generates: `action == Action::"name"` or `action in [Action::"name1", Action::"name2"]` in Cedar
405
+ *
406
+ * @param actions - Array of action names (e.g., ['AgentCore::Action::InsuranceAPI__get_policy'])
407
+ */
408
+ onActions(actions: string[]): this;
409
+ /**
410
+ * Apply to a single specific action.
411
+ *
412
+ * Generates: `action == Action::"name"` in Cedar
413
+ *
414
+ * @param action - Action name (e.g., 'AgentCore::Action::InsuranceAPI__get_policy')
415
+ */
416
+ onAction(action: string): this;
417
+ /**
418
+ * Apply to all resources of a specific type.
419
+ *
420
+ * **AWS Requirement**: AWS Bedrock AgentCore Policy service does not allow wildcard
421
+ * resources (`resource`). This method provides type-constrained resources which are
422
+ * required for policy validation to succeed.
423
+ *
424
+ * Generates: `resource is EntityType` in Cedar
425
+ *
426
+ * @param entityType - The entity type (default: 'AgentCore::Gateway')
427
+ *
428
+ * @example
429
+ * import { PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
430
+ *
431
+ * // Constrain to Gateway resources (default)
432
+ * PolicyStatement.permit()
433
+ * .forAllPrincipals()
434
+ * .onAllActions()
435
+ * .onAllResources() // → "resource is AgentCore::Gateway"
436
+ *
437
+ * // Constrain to Runtime resources
438
+ * PolicyStatement.permit()
439
+ * .forAllPrincipals()
440
+ * .onAllActions()
441
+ * .onAllResources('AgentCore::Runtime') // → "resource is AgentCore::Runtime"
442
+ */
443
+ onAllResources(entityType?: string): this;
444
+ /**
445
+ * Apply to all resources of a specific type (explicit method).
446
+ *
447
+ * **AWS Requirement**: Resource type constraints are required by AWS Bedrock
448
+ * AgentCore when using wildcard principals or actions.
449
+ *
450
+ * Generates: `resource is EntityType` in Cedar
451
+ *
452
+ * @param entityType - The entity type (e.g., 'AgentCore::Gateway', 'AgentCore::Runtime')
453
+ *
454
+ * @example
455
+ * import { PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
456
+ *
457
+ * PolicyStatement.permit()
458
+ * .forAllPrincipals()
459
+ * .onAllActions()
460
+ * .onResourceType('AgentCore::Gateway') // → "resource is AgentCore::Gateway"
461
+ */
462
+ onResourceType(entityType: string): this;
463
+ /**
464
+ * Apply to a specific resource instance.
465
+ *
466
+ * **AWS Requirement**: When using specific actions (e.g., `action == Action::"Delete"`),
467
+ * you must constrain the resource to a specific instance, not just a type.
468
+ *
469
+ * Generates: `resource == EntityType::"arn"` in Cedar
470
+ *
471
+ * @param entityType - The entity type (e.g., 'AgentCore::Gateway')
472
+ * @param entityArn - The resource ARN or identifier
473
+ *
474
+ * @example
475
+ * import { PolicyStatement } from '@aws-cdk/aws-bedrock-agentcore-alpha';
476
+ * declare const gatewayArn: string;
477
+ *
478
+ * PolicyStatement.forbid()
479
+ * .forAllPrincipals()
480
+ * .onAction('AgentCore::Action::Delete')
481
+ * .onResource('AgentCore::Gateway', gatewayArn) // Must be specific resource
482
+ */
483
+ onResource(entityType: string, entityArn: string): this;
484
+ /**
485
+ * Add when conditions - policy applies only if these conditions are true.
486
+ *
487
+ * When conditions define positive requirements that must be met.
488
+ * Multiple conditions can be combined with AND/OR operators.
489
+ *
490
+ * Returns a ConditionBuilder that you can chain condition methods on.
491
+ * Call done() when finished to return to the PolicyStatement.
492
+ */
493
+ when(): ConditionalPolicyStatement;
494
+ /**
495
+ * Add unless conditions - policy applies only if these conditions are false.
496
+ *
497
+ * Unless conditions define negative requirements (exclusions).
498
+ * The policy applies when these conditions are NOT met.
499
+ *
500
+ * Returns a ConditionBuilder that you can chain condition methods on.
501
+ * Call done() when finished to return to the PolicyStatement.
502
+ */
503
+ unless(): ConditionalPolicyStatement;
504
+ /**
505
+ * Generate the Cedar policy statement string.
506
+ *
507
+ * Converts the builder state into valid Cedar policy syntax.
508
+ * This is called internally by the Policy construct.
509
+ *
510
+ * @returns Valid Cedar policy statement
511
+ */
512
+ toCedar(): string;
513
+ private principalToCedar;
514
+ private actionToCedar;
515
+ private resourceToCedar;
516
+ private validateNotRawCedar;
517
+ }
518
+ export {};