Skip to content

Commit 4d42559

Browse files
committed
fix
1 parent 6b1a654 commit 4d42559

File tree

19 files changed

+184
-385
lines changed

19 files changed

+184
-385
lines changed

packages/cdk/lambda/agentBuilder/router.ts

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -61,28 +61,6 @@ export async function routeRequest(
6161
}
6262
}
6363

64-
// Public agents route
65-
if (resource === '/agents/public' && httpMethod === 'GET') {
66-
return await handleListPublicAgents(userId, exclusiveStartKey, limit);
67-
}
68-
69-
// Import agent route
70-
if (resource === '/agents/clone' && httpMethod === 'POST') {
71-
const parseResult = validateAndParseRequestBody(body);
72-
if (!parseResult.isValid) {
73-
return handleError(new Error(parseResult.error!));
74-
}
75-
return await handleCloneAgent(
76-
userId,
77-
parseResult.data as CloneAgentRequest
78-
);
79-
}
80-
81-
// Favorite agents route
82-
if (resource === '/agents/favorites' && httpMethod === 'GET') {
83-
return await handleListFavoriteAgents(userId, exclusiveStartKey, limit);
84-
}
85-
8664
// Individual agent routes and sub-routes
8765
if (resource === '/agents/{proxy+}') {
8866
const pathParts = (pathParameters?.proxy || '').split('/');
@@ -105,6 +83,17 @@ export async function routeRequest(
10583
return await handleListFavoriteAgents(userId, exclusiveStartKey, limit);
10684
}
10785

86+
if (agentId === 'clone' && httpMethod === 'POST') {
87+
const parseResult = validateAndParseRequestBody(body);
88+
if (!parseResult.isValid) {
89+
return handleError(new Error(parseResult.error!));
90+
}
91+
return await handleCloneAgent(
92+
userId,
93+
parseResult.data as CloneAgentRequest
94+
);
95+
}
96+
10897
if (agentId === 'import' && httpMethod === 'POST') {
10998
const parseResult = validateAndParseRequestBody(body);
11099
if (!parseResult.isValid) {

packages/cdk/lib/construct/generic-agent-core.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,8 @@ export class GenericAgentCore extends Construct {
112112
this._sharedAgentCoreRuntimeRole = this.createAgentCoreRuntimeRole();
113113

114114
// Deploy runtimes based on flags
115-
if (createGenericRuntime) {
116-
this.deployGenericRuntime();
117-
}
118-
if (createAgentBuilderRuntime) {
119-
this.deployAgentBuilderRuntime();
120-
}
115+
this.deployGenericRuntime();
116+
this.deployAgentBuilderRuntime();
121117
}
122118
}
123119

packages/cdk/lib/construct/use-case-builder.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ export interface UseCaseBuilderProps {
2121
readonly api: RestApi;
2222
readonly vpc?: IVpc;
2323
readonly securityGroups?: ISecurityGroup[];
24-
readonly createGenericAgentCoreRuntime?: boolean;
24+
readonly agentBuilderRuntimeArn?: string;
2525
}
2626
export class UseCaseBuilder extends Construct {
2727
constructor(scope: Construct, id: string, props: UseCaseBuilderProps) {
2828
super(scope, id);
2929

30-
const { userPool, api, createGenericAgentCoreRuntime } = props;
30+
const { userPool, api, agentBuilderRuntimeArn } = props;
3131

3232
const useCaseIdIndexName = 'UseCaseIdIndexName';
3333
const useCaseBuilderTable = new ddb.Table(this, 'UseCaseBuilderTable', {
@@ -243,7 +243,7 @@ export class UseCaseBuilder extends Construct {
243243
commonAuthorizerProps
244244
);
245245

246-
if (createGenericAgentCoreRuntime) {
246+
if (agentBuilderRuntimeArn) {
247247
// Add Agent Builder related APIs
248248
const agentBuilderFunction = new NodejsFunction(this, 'AgentBuilder', {
249249
...commonProperty,
@@ -276,30 +276,24 @@ export class UseCaseBuilder extends Construct {
276276
});
277277
agentBuilderFunction.role?.addToPrincipalPolicy(cognitoPolicyForAgent);
278278

279-
// Agent Builder API endpoints
279+
// Agent Builder API endpoints - all routes handled by proxy+ integration
280280
const agentsResource = api.root.addResource('agents');
281281

282-
// GET: /agents
282+
// Handle root /agents requests
283283
agentsResource.addMethod(
284-
'GET',
285-
new LambdaIntegration(agentBuilderFunction),
286-
commonAuthorizerProps
287-
);
288-
289-
// POST: /agents
290-
agentsResource.addMethod(
291-
'POST',
284+
'ANY',
292285
new LambdaIntegration(agentBuilderFunction),
293286
commonAuthorizerProps
294287
);
295288

296289
// All agent sub-routes handled by proxy+ integration
297-
const agentResource = agentsResource.addResource('{proxy+}');
298-
agentResource.addMethod(
299-
'ANY',
300-
new LambdaIntegration(agentBuilderFunction),
301-
commonAuthorizerProps
302-
);
290+
agentsResource
291+
.addResource('{proxy+}')
292+
.addMethod(
293+
'ANY',
294+
new LambdaIntegration(agentBuilderFunction),
295+
commonAuthorizerProps
296+
);
303297
}
304298
}
305299
}

packages/cdk/lib/construct/web.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export interface WebProps {
6666
readonly cognitoIdentityPoolProxyEndpoint?: string;
6767
readonly agentCoreEnabled: boolean;
6868
readonly agentCoreGenericRuntime?: AgentCoreConfiguration;
69+
readonly agentBuilderEnabled: boolean;
6970
readonly agentCoreAgentBuilderRuntime?: AgentCoreConfiguration;
7071
readonly agentCoreExternalRuntimes: AgentCoreConfiguration[];
7172
readonly agentCoreRegion?: string;
@@ -298,6 +299,8 @@ export class Web extends Construct {
298299
VITE_APP_AGENT_CORE_GENERIC_RUNTIME: JSON.stringify(
299300
props.agentCoreGenericRuntime
300301
),
302+
VITE_APP_AGENT_CORE_AGENT_BUILDER_ENABLED:
303+
props.agentBuilderEnabled.toString(),
301304
VITE_APP_AGENT_CORE_AGENT_BUILDER_RUNTIME: JSON.stringify(
302305
props.agentCoreAgentBuilderRuntime
303306
),

packages/cdk/lib/create-stacks.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,9 @@ export const createStacks = (app: cdk.App, params: ProcessedStackInput) => {
231231
// Agent
232232
agents: agentStack?.agents,
233233
// Agent Core
234-
agentCoreStack: agentCoreStack || undefined,
235234
createGenericAgentCoreRuntime: params.createGenericAgentCoreRuntime,
235+
agentBuilderEnabled: params.agentBuilderEnabled,
236+
agentCoreStack: agentCoreStack || undefined,
236237
// Video Generation
237238
videoBucketRegionMap,
238239
// Guardrail

packages/cdk/lib/generative-ai-use-cases-stack.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export interface GenerativeAiUseCasesStackProps extends StackProps {
4040
readonly agents?: Agent[];
4141
// Agent Core
4242
readonly createGenericAgentCoreRuntime?: boolean;
43+
readonly agentBuilderEnabled?: boolean;
4344
readonly agentCoreStack?: AgentCoreStack;
4445
// Video Generation
4546
readonly videoBucketRegionMap: Record<string, string>;
@@ -257,6 +258,7 @@ export class GenerativeAiUseCasesStack extends Stack {
257258
description: 'Generic Agent Core Runtime for custom agents',
258259
}
259260
: undefined,
261+
agentBuilderEnabled: params.agentBuilderEnabled,
260262
agentCoreAgentBuilderRuntime: agentBuilderRuntimeArn
261263
? {
262264
name: agentBuilderRuntimeName || 'AgentBuilderAgentCoreRuntime',
@@ -353,7 +355,7 @@ export class GenerativeAiUseCasesStack extends Stack {
353355
api: api.api,
354356
vpc: props.vpc,
355357
securityGroups,
356-
createGenericAgentCoreRuntime: props.createGenericAgentCoreRuntime,
358+
agentBuilderRuntimeArn,
357359
});
358360
}
359361

@@ -505,6 +507,10 @@ export class GenerativeAiUseCasesStack extends Stack {
505507
: 'null',
506508
});
507509

510+
new CfnOutput(this, 'AgentCoreAgentBuilderEnabled', {
511+
value: params.agentBuilderEnabled.toString(),
512+
});
513+
508514
new CfnOutput(this, 'AgentCoreAgentBuilderRuntime', {
509515
value: agentBuilderRuntimeArn
510516
? JSON.stringify({

0 commit comments

Comments
 (0)