@cdklabs/cdk-appmod-catalog-blueprints 1.13.0 → 1.14.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.
- package/.jsii +573 -136
- package/lib/document-processing/adapter/queued-s3-adapter.js +1 -1
- package/lib/document-processing/agentic-document-processing.js +1 -1
- package/lib/document-processing/base-document-processing.js +1 -1
- package/lib/document-processing/bedrock-document-processing.js +1 -1
- package/lib/document-processing/default-document-processing-config.js +1 -1
- package/lib/document-processing/resources/default-image-validator/package-lock.json +45 -45
- package/lib/document-processing/resources/default-image-validator/package.json +1 -1
- package/lib/framework/agents/base-agent.js +1 -1
- package/lib/framework/agents/batch-agent.js +4 -2
- package/lib/framework/agents/default-agent-config.js +1 -1
- package/lib/framework/agents/interactive-agent.d.ts +159 -2
- package/lib/framework/agents/interactive-agent.js +139 -19
- package/lib/framework/agents/knowledge-base/base-knowledge-base.js +1 -1
- package/lib/framework/agents/knowledge-base/bedrock-knowledge-base.js +1 -1
- package/lib/framework/agents/resources/interactive-agent-handler/index.py +561 -52
- package/lib/framework/agents/resources/interactive-agent-handler/requirements.txt +1 -0
- package/lib/framework/bedrock/bedrock.js +1 -1
- package/lib/framework/custom-resource/default-runtimes.js +1 -1
- package/lib/framework/foundation/access-log.js +1 -1
- package/lib/framework/foundation/eventbridge-broker.js +1 -1
- package/lib/framework/foundation/network.js +1 -1
- package/lib/framework/tests/framework-nag.test.js +2 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/utilities/data-loader.js +1 -1
- package/lib/utilities/lambda-iam-utils.js +1 -1
- package/lib/utilities/observability/cloudfront-distribution-observability-property-injector.js +1 -1
- package/lib/utilities/observability/cloudwatch-transaction-search.js +1 -1
- package/lib/utilities/observability/default-observability-config.js +1 -1
- package/lib/utilities/observability/lambda-observability-property-injector.js +1 -1
- package/lib/utilities/observability/log-group-data-protection-utils.js +1 -1
- package/lib/utilities/observability/powertools-config.js +1 -1
- package/lib/utilities/observability/state-machine-observability-property-injector.js +1 -1
- package/lib/webapp/frontend-construct.js +1 -1
- package/package.json +4 -4
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Duration, RemovalPolicy } from 'aws-cdk-lib';
|
|
2
|
-
import { RestApi } from 'aws-cdk-lib/aws-apigateway';
|
|
2
|
+
import { CognitoUserPoolsAuthorizer, RestApi } from 'aws-cdk-lib/aws-apigateway';
|
|
3
3
|
import { CfnRuntime } from 'aws-cdk-lib/aws-bedrockagentcore';
|
|
4
4
|
import { UserPool, UserPoolClient } from 'aws-cdk-lib/aws-cognito';
|
|
5
|
-
import {
|
|
5
|
+
import { ITable } from 'aws-cdk-lib/aws-dynamodb';
|
|
6
|
+
import { IGrantable, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam';
|
|
6
7
|
import { IKey, Key } from 'aws-cdk-lib/aws-kms';
|
|
7
8
|
import { IFunction, Architecture, ILayerVersion } from 'aws-cdk-lib/aws-lambda';
|
|
8
9
|
import { IBucket } from 'aws-cdk-lib/aws-s3';
|
|
@@ -59,6 +60,14 @@ export interface StreamingHttpAdapterProps {
|
|
|
59
60
|
* @default Uses authenticator from InteractiveAgent
|
|
60
61
|
*/
|
|
61
62
|
readonly authenticator?: IAuthenticator;
|
|
63
|
+
/**
|
|
64
|
+
* HTTP methods to allow in CORS preflight responses.
|
|
65
|
+
* Use this to enable additional methods (GET, DELETE, PUT) for custom routes
|
|
66
|
+
* added to the REST API.
|
|
67
|
+
*
|
|
68
|
+
* @default ['POST', 'OPTIONS']
|
|
69
|
+
*/
|
|
70
|
+
readonly corsAllowMethods?: string[];
|
|
62
71
|
}
|
|
63
72
|
/**
|
|
64
73
|
* Streaming HTTP adapter for real-time agent communication via SSE.
|
|
@@ -106,6 +115,10 @@ export declare class StreamingHttpAdapter implements ICommunicationAdapter {
|
|
|
106
115
|
* The REST API Gateway.
|
|
107
116
|
*/
|
|
108
117
|
readonly restApi?: RestApi;
|
|
118
|
+
/**
|
|
119
|
+
* The Cognito User Pools authorizer (if Cognito authentication is enabled).
|
|
120
|
+
*/
|
|
121
|
+
readonly cognitoAuthorizer?: CognitoUserPoolsAuthorizer;
|
|
109
122
|
/**
|
|
110
123
|
* The API endpoint URL.
|
|
111
124
|
*/
|
|
@@ -426,6 +439,115 @@ export declare class CognitoAuthenticator implements IAuthenticator {
|
|
|
426
439
|
*/
|
|
427
440
|
_setScope(scope: Construct): void;
|
|
428
441
|
}
|
|
442
|
+
/**
|
|
443
|
+
* Strategy interface for session index storage.
|
|
444
|
+
*
|
|
445
|
+
* Session indexes provide fast user to session lookups for listing and managing sessions.
|
|
446
|
+
* The default implementation (DynamoDBSessionIndex) uses DynamoDB for efficient queries.
|
|
447
|
+
*/
|
|
448
|
+
export interface ISessionIndex {
|
|
449
|
+
/**
|
|
450
|
+
* Grant read/write permissions to a grantee.
|
|
451
|
+
*
|
|
452
|
+
* @param grantee - The principal that needs access to the session index
|
|
453
|
+
*/
|
|
454
|
+
grantReadWrite(grantee: IGrantable): void;
|
|
455
|
+
/**
|
|
456
|
+
* Get environment variables for Lambda configuration.
|
|
457
|
+
*
|
|
458
|
+
* @returns Environment variables to configure the session index
|
|
459
|
+
*/
|
|
460
|
+
environmentVariables(): Record<string, string>;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Configuration properties for DynamoDBSessionIndex.
|
|
464
|
+
*/
|
|
465
|
+
export interface DynamoDBSessionIndexProps {
|
|
466
|
+
/**
|
|
467
|
+
* Existing DynamoDB table to use.
|
|
468
|
+
* Table must have partition key 'user_id' (String) and sort key 'session_id' (String).
|
|
469
|
+
*
|
|
470
|
+
* @default Auto-created table
|
|
471
|
+
*/
|
|
472
|
+
readonly table?: ITable;
|
|
473
|
+
/**
|
|
474
|
+
* Time-to-live for session index records.
|
|
475
|
+
* When set, expired records are automatically removed by DynamoDB TTL.
|
|
476
|
+
*
|
|
477
|
+
* @default No TTL (sessions persist until explicitly deleted)
|
|
478
|
+
*/
|
|
479
|
+
readonly sessionTTL?: Duration;
|
|
480
|
+
/**
|
|
481
|
+
* KMS key for table encryption.
|
|
482
|
+
*
|
|
483
|
+
* @default AWS managed encryption
|
|
484
|
+
*/
|
|
485
|
+
readonly encryptionKey?: IKey;
|
|
486
|
+
/**
|
|
487
|
+
* Removal policy for the DynamoDB table.
|
|
488
|
+
*
|
|
489
|
+
* @default RemovalPolicy.DESTROY
|
|
490
|
+
*/
|
|
491
|
+
readonly removalPolicy?: RemovalPolicy;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* DynamoDB-based session index for fast user to session lookups.
|
|
495
|
+
*
|
|
496
|
+
* Creates a DynamoDB table indexed by user_id (partition key) and session_id (sort key)
|
|
497
|
+
* for efficient querying of a user's sessions. The table stores session metadata
|
|
498
|
+
* including creation time, last update time, and optional TTL for automatic cleanup.
|
|
499
|
+
*
|
|
500
|
+
* ## Table Schema
|
|
501
|
+
*
|
|
502
|
+
* - **Partition Key**: user_id (String) - User identifier from authentication
|
|
503
|
+
* - **Sort Key**: session_id (String) - Unique session identifier
|
|
504
|
+
* - **Attributes**: created_at, updated_at, last_message, expires_at (optional)
|
|
505
|
+
*
|
|
506
|
+
* ## Features
|
|
507
|
+
*
|
|
508
|
+
* - **Fast Lookups**: Query all sessions for a user in O(1) using partition key
|
|
509
|
+
* - **Automatic Expiration**: Optional TTL removes stale sessions automatically
|
|
510
|
+
* - **On-Demand Capacity**: Pay-per-request billing, no capacity planning needed
|
|
511
|
+
* - **Encryption**: AWS managed or customer-managed KMS encryption
|
|
512
|
+
*
|
|
513
|
+
* ## Usage
|
|
514
|
+
*
|
|
515
|
+
* ```typescript
|
|
516
|
+
* import { Asset } from 'aws-cdk-lib/aws-s3-assets';
|
|
517
|
+
* import { Duration } from 'aws-cdk-lib';
|
|
518
|
+
* import { InteractiveAgent, DynamoDBSessionIndex } from '@cdklabs/cdk-appmod-catalog-blueprints';
|
|
519
|
+
*
|
|
520
|
+
* const myPrompt = new Asset(this, 'Prompt', { path: './prompt.txt' });
|
|
521
|
+
* const sessionIndex = new DynamoDBSessionIndex(this, 'SessionIndex', {
|
|
522
|
+
* sessionTTL: Duration.days(7)
|
|
523
|
+
* });
|
|
524
|
+
*
|
|
525
|
+
* const agent = new InteractiveAgent(this, 'Agent', {
|
|
526
|
+
* agentName: 'ChatAgent',
|
|
527
|
+
* agentDefinition: { bedrockModel: {}, systemPrompt: myPrompt },
|
|
528
|
+
* sessionIndex
|
|
529
|
+
* });
|
|
530
|
+
* ```
|
|
531
|
+
*/
|
|
532
|
+
export declare class DynamoDBSessionIndex implements ISessionIndex {
|
|
533
|
+
/**
|
|
534
|
+
* The DynamoDB table used for session index storage.
|
|
535
|
+
*/
|
|
536
|
+
readonly table: ITable;
|
|
537
|
+
/**
|
|
538
|
+
* The session TTL duration (if configured).
|
|
539
|
+
*/
|
|
540
|
+
readonly sessionTTL?: Duration;
|
|
541
|
+
constructor(scope: Construct, id: string, props?: DynamoDBSessionIndexProps);
|
|
542
|
+
/**
|
|
543
|
+
* Grant read/write permissions to a grantee.
|
|
544
|
+
*/
|
|
545
|
+
grantReadWrite(grantee: IGrantable): void;
|
|
546
|
+
/**
|
|
547
|
+
* Get environment variables for Lambda configuration.
|
|
548
|
+
*/
|
|
549
|
+
environmentVariables(): Record<string, string>;
|
|
550
|
+
}
|
|
429
551
|
/**
|
|
430
552
|
* No-authentication authenticator for development and testing.
|
|
431
553
|
*
|
|
@@ -541,6 +663,14 @@ export interface LambdaHostingAdapterProps {
|
|
|
541
663
|
* @default CognitoAuthenticator
|
|
542
664
|
*/
|
|
543
665
|
readonly authenticator?: IAuthenticator;
|
|
666
|
+
/**
|
|
667
|
+
* HTTP methods to allow in CORS preflight responses.
|
|
668
|
+
* Use this to enable additional methods (GET, DELETE, PUT) for custom routes
|
|
669
|
+
* added to the REST API.
|
|
670
|
+
*
|
|
671
|
+
* @default ['POST', 'OPTIONS']
|
|
672
|
+
*/
|
|
673
|
+
readonly corsAllowMethods?: string[];
|
|
544
674
|
/**
|
|
545
675
|
* Lambda function memory size in MB.
|
|
546
676
|
*
|
|
@@ -731,6 +861,13 @@ export interface InteractiveAgentProps extends BaseAgentProps {
|
|
|
731
861
|
* @default Duration.hours(24)
|
|
732
862
|
*/
|
|
733
863
|
readonly sessionTTL?: Duration;
|
|
864
|
+
/**
|
|
865
|
+
* Session index for fast user to session lookups.
|
|
866
|
+
* Provides efficient querying of a user's sessions for listing and management.
|
|
867
|
+
*
|
|
868
|
+
* @default DynamoDBSessionIndex (auto-created)
|
|
869
|
+
*/
|
|
870
|
+
readonly sessionIndex?: ISessionIndex;
|
|
734
871
|
/**
|
|
735
872
|
* Context strategy for conversation history management.
|
|
736
873
|
*
|
|
@@ -755,6 +892,14 @@ export interface InteractiveAgentProps extends BaseAgentProps {
|
|
|
755
892
|
* @default CognitoAuthenticator
|
|
756
893
|
*/
|
|
757
894
|
readonly authenticator?: IAuthenticator;
|
|
895
|
+
/**
|
|
896
|
+
* HTTP methods to allow in CORS preflight responses.
|
|
897
|
+
* Use this to enable additional methods (GET, DELETE, PUT) for custom routes
|
|
898
|
+
* added to the REST API.
|
|
899
|
+
*
|
|
900
|
+
* @default ['POST', 'OPTIONS']
|
|
901
|
+
*/
|
|
902
|
+
readonly corsAllowMethods?: string[];
|
|
758
903
|
/**
|
|
759
904
|
* Lambda function memory size in MB.
|
|
760
905
|
*
|
|
@@ -840,6 +985,18 @@ export declare class InteractiveAgent extends BaseAgent {
|
|
|
840
985
|
readonly apiEndpoint: string;
|
|
841
986
|
readonly sessionBucket?: IBucket;
|
|
842
987
|
readonly cfnRuntime?: CfnRuntime;
|
|
988
|
+
/**
|
|
989
|
+
* The session index for fast user to session lookups.
|
|
990
|
+
*/
|
|
991
|
+
readonly sessionIndex?: ISessionIndex;
|
|
992
|
+
/**
|
|
993
|
+
* The REST API Gateway (only available when using LambdaHostingAdapter with StreamingHttpAdapter).
|
|
994
|
+
*/
|
|
995
|
+
readonly restApi?: RestApi;
|
|
996
|
+
/**
|
|
997
|
+
* The Cognito User Pools authorizer (only available when using LambdaHostingAdapter with CognitoAuthenticator).
|
|
998
|
+
*/
|
|
999
|
+
readonly cognitoAuthorizer?: CognitoUserPoolsAuthorizer;
|
|
843
1000
|
constructor(scope: Construct, id: string, props: InteractiveAgentProps);
|
|
844
1001
|
/**
|
|
845
1002
|
* Validates InteractiveAgent props.
|