Skip to content

Commit 9a752a1

Browse files
notgitikatejaskash
andauthored
Schema change refactor big bang (#108)
* feat: remove attach command, add create/bind dialog to add wizards * feat: schema refactor with breaking changes Schema: Agent->AgentEnvSpec; version int; artifact->build; RuntimeVersion supports Python+Node; entrypoint supports .py/.ts/.js; remove EPISODIC memory strategy; remove mcp from project spec (separate mcp.json) Packaging: add Node/TypeScript packager; auto-select packager by runtime TUI: simplify memory/identity wizards (flat resource model, no owner/user bindings) CDK: update templates for mcpSpec as separate prop * feat: add InstrumentationSchema with enableOtel support Add InstrumentationSchema with enableOtel field (default true); Update llm-compacted schemas with Node runtimes and instrumentation * fix: fix build --------- Co-authored-by: Tejas Kashinath <42380254+tejaskash@users.noreply.github.com>
1 parent f810001 commit 9a752a1

74 files changed

Lines changed: 1448 additions & 3422 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/assets/cdk/bin/cdk.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env node
22
import { AgentCoreStack } from '../lib/cdk-stack';
3-
import { ConfigIO, type AwsDeploymentTarget } from '@aws/agentcore-l3-cdk-constructs';
3+
import { ConfigIO, type AgentCoreMcpSpec, type AwsDeploymentTarget } from '@aws/agentcore-l3-cdk-constructs';
44
import { App, type Environment } from 'aws-cdk-lib';
55
import * as path from 'path';
66

@@ -23,6 +23,12 @@ async function main() {
2323
const spec = await configIO.readProjectSpec();
2424
const targets = await configIO.readAWSDeploymentTargets();
2525

26+
// Read MCP spec if it exists (stored separately in mcp.json)
27+
let mcpSpec: AgentCoreMcpSpec | undefined;
28+
if (configIO.configExists('mcp')) {
29+
mcpSpec = await configIO.readMcpSpec();
30+
}
31+
2632
if (targets.length === 0) {
2733
throw new Error('No deployment targets configured. Please define targets in agentcore/aws-targets.json');
2834
}
@@ -35,6 +41,7 @@ async function main() {
3541

3642
new AgentCoreStack(app, stackName, {
3743
spec,
44+
mcpSpec,
3845
env,
3946
description: `AgentCore stack for ${spec.name} deployed to ${target.name} (${target.region})`,
4047
tags: {

src/assets/cdk/lib/cdk-stack.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
import { AgentCoreApplication, AgentCoreMcp, type AgentCoreProjectSpec } from '@aws/agentcore-l3-cdk-constructs';
1+
import {
2+
AgentCoreApplication,
3+
AgentCoreMcp,
4+
type AgentCoreProjectSpec,
5+
type AgentCoreMcpSpec,
6+
} from '@aws/agentcore-l3-cdk-constructs';
27
import { CfnOutput, Stack, type StackProps } from 'aws-cdk-lib';
38
import { Construct } from 'constructs';
49

510
export interface AgentCoreStackProps extends StackProps {
611
/**
7-
* The complete AgentCore workspace specification containing all agents and MCP config.
12+
* The AgentCore project specification containing agents, memories, and credentials.
813
*/
914
spec: AgentCoreProjectSpec;
15+
16+
/**
17+
* Optional MCP specification for gateways and runtime tools.
18+
* MCP is stored separately in mcp.json.
19+
*/
20+
mcpSpec?: AgentCoreMcpSpec;
1021
}
1122

1223
/**
@@ -25,17 +36,18 @@ export class AgentCoreStack extends Stack {
2536
constructor(scope: Construct, id: string, props: AgentCoreStackProps) {
2637
super(scope, id, props);
2738

28-
const { spec } = props;
39+
const { spec, mcpSpec } = props;
2940

3041
// Create AgentCoreApplication with all agents
3142
this.application = new AgentCoreApplication(this, 'Application', {
3243
spec,
3344
});
3445

35-
// Instantiate AgentCoreMcp if MCP is defined
36-
if (spec.mcp) {
46+
// Instantiate AgentCoreMcp if MCP spec is provided
47+
if (mcpSpec) {
3748
this.mcp = new AgentCoreMcp(this, 'Mcp', {
38-
spec,
49+
projectName: spec.name,
50+
mcpSpec,
3951
agentCoreApplication: this.application,
4052
});
4153
}

src/cli/commands/add/actions.ts

Lines changed: 60 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type {
44
DirectoryPath,
55
FilePath,
66
GatewayAuthorizerType,
7-
IdentityCredentialVariant,
87
MemoryStrategyType,
98
ModelProvider,
109
SDKFramework,
@@ -13,37 +12,25 @@ import type {
1312
import { getErrorMessage } from '../../errors';
1413
import { setupPythonProject } from '../../operations';
1514
import {
16-
mapGenerateConfigToAgentEnvSpec,
17-
mapModelProviderToIdentityProviders,
15+
mapGenerateConfigToRenderConfig,
16+
mapModelProviderToCredentials,
1817
writeAgentToProject,
1918
} from '../../operations/agent/generate';
20-
import {
21-
attachAgentToAgent,
22-
attachGatewayToAgent,
23-
attachIdentityToAgent,
24-
attachMemoryToAgent,
25-
bindMcpRuntimeToAgent,
26-
} from '../../operations/attach';
27-
import { computeDefaultIdentityEnvVarName, createIdentityFromWizard } from '../../operations/identity/create-identity';
19+
import { bindMcpRuntimeToAgent } from '../../operations/attach';
20+
import { computeDefaultCredentialEnvVarName, createCredential } from '../../operations/identity/create-identity';
2821
import { createGatewayFromWizard, createToolFromWizard } from '../../operations/mcp/create-mcp';
29-
import { createMemoryFromWizard } from '../../operations/memory/create-memory';
22+
import { createMemory } from '../../operations/memory/create-memory';
3023
import { createRenderer } from '../../templates';
3124
import type { MemoryOption } from '../../tui/screens/generate/types';
32-
import type { AddIdentityConfig } from '../../tui/screens/identity/types';
3325
import type { AddGatewayConfig, AddMcpToolConfig } from '../../tui/screens/mcp/types';
34-
import type { AddMemoryConfig, AddMemoryStrategyConfig } from '../../tui/screens/memory/types';
3526
import { DEFAULT_EVENT_EXPIRY } from '../../tui/screens/memory/types';
3627
import type {
3728
AddAgentResult,
3829
AddGatewayResult,
3930
AddIdentityResult,
4031
AddMcpToolResult,
4132
AddMemoryResult,
42-
BindAgentResult,
43-
BindGatewayResult,
44-
BindIdentityResult,
4533
BindMcpRuntimeResult,
46-
BindMemoryResult,
4734
} from './types';
4835
import { dirname, join } from 'path';
4936

@@ -82,19 +69,13 @@ export interface ValidatedAddMcpToolOptions {
8269

8370
export interface ValidatedAddMemoryOptions {
8471
name: string;
85-
description?: string;
8672
strategies: string;
8773
expiry?: number;
88-
owner: string;
89-
users?: string;
9074
}
9175

9276
export interface ValidatedAddIdentityOptions {
9377
name: string;
94-
type: string;
9578
apiKey: string;
96-
owner: string;
97-
users?: string;
9879
}
9980

10081
// Agent handlers
@@ -140,8 +121,8 @@ async function handleCreatePath(options: ValidatedAddAgentOptions, configBaseDir
140121

141122
const agentPath = join(projectRoot, APP_DIR, options.name);
142123

143-
const agentSpec = mapGenerateConfigToAgentEnvSpec(generateConfig);
144-
const renderer = createRenderer(agentSpec);
124+
const renderConfig = mapGenerateConfigToRenderConfig(generateConfig);
125+
const renderer = createRenderer(renderConfig);
145126
await renderer.render({ outputDir: projectRoot });
146127

147128
await writeAgentToProject(generateConfig, { configBaseDir });
@@ -151,7 +132,7 @@ async function handleCreatePath(options: ValidatedAddAgentOptions, configBaseDir
151132
}
152133

153134
if (options.apiKey && options.modelProvider !== 'Bedrock') {
154-
const envVarName = computeDefaultIdentityEnvVarName(options.modelProvider);
135+
const envVarName = computeDefaultCredentialEnvVarName(options.modelProvider);
155136
await setEnvVar(envVarName, options.apiKey, configBaseDir);
156137
}
157138

@@ -165,34 +146,28 @@ async function handleByoPath(
165146
): Promise<AddAgentResult> {
166147
const codeLocation = options.codeLocation!.endsWith('/') ? options.codeLocation! : `${options.codeLocation!}/`;
167148

168-
// Read project first to get project name for qualified identity provider names
169149
const project = await configIO.readProjectSpec();
170150

171-
const agentEnvSpec: AgentEnvSpec = {
151+
const agent: AgentEnvSpec = {
152+
type: 'AgentCoreRuntime',
172153
name: options.name,
173-
id: `${options.name}Agent`,
174-
sdkFramework: options.framework,
175-
targetLanguage: options.language,
176-
modelProvider: options.modelProvider,
177-
runtime: {
178-
artifact: 'CodeZip',
179-
name: options.name,
180-
entrypoint: (options.entrypoint ?? 'main.py') as FilePath,
181-
codeLocation: codeLocation as DirectoryPath,
182-
pythonVersion: 'PYTHON_3_12',
183-
networkMode: 'PUBLIC',
184-
},
185-
mcpProviders: [],
186-
memoryProviders: [],
187-
identityProviders: mapModelProviderToIdentityProviders(options.modelProvider, project.name),
188-
remoteTools: [],
154+
build: 'CodeZip',
155+
entrypoint: (options.entrypoint ?? 'main.py') as FilePath,
156+
codeLocation: codeLocation as DirectoryPath,
157+
runtimeVersion: 'PYTHON_3_12',
158+
networkMode: 'PUBLIC',
189159
};
190160

191-
project.agents.push(agentEnvSpec);
161+
project.agents.push(agent);
162+
163+
// Add credential for non-Bedrock providers
164+
const credentials = mapModelProviderToCredentials(options.modelProvider, project.name);
165+
project.credentials.push(...credentials);
166+
192167
await configIO.writeProjectSpec(project);
193168

194169
if (options.apiKey && options.modelProvider !== 'Bedrock') {
195-
const envVarName = computeDefaultIdentityEnvVarName(options.modelProvider);
170+
const envVarName = computeDefaultCredentialEnvVarName(options.modelProvider);
196171
await setEnvVar(envVarName, options.apiKey, configBaseDir);
197172
}
198173

@@ -283,74 +258,58 @@ export async function handleAddMcpTool(options: ValidatedAddMcpToolOptions): Pro
283258
}
284259
}
285260

286-
// Memory handler
287-
function buildMemoryConfig(options: ValidatedAddMemoryOptions): AddMemoryConfig {
288-
const userAgents = options.users
289-
? options.users
290-
.split(',')
291-
.map(s => s.trim())
292-
.filter(Boolean)
293-
: [];
261+
// Memory handler (v2: top-level resource, no owner/user)
262+
export async function handleAddMemory(options: ValidatedAddMemoryOptions): Promise<AddMemoryResult> {
263+
try {
264+
const strategies = options.strategies
265+
.split(',')
266+
.map(s => s.trim())
267+
.filter(Boolean)
268+
.map(type => ({ type: type as MemoryStrategyType }));
294269

295-
const strategies: AddMemoryStrategyConfig[] = options.strategies
296-
.split(',')
297-
.map(s => s.trim())
298-
.filter(Boolean)
299-
.map(type => ({ type: type as MemoryStrategyType }));
270+
const result = await createMemory({
271+
name: options.name,
272+
eventExpiryDuration: options.expiry ?? DEFAULT_EVENT_EXPIRY,
273+
strategies,
274+
});
300275

301-
return {
302-
name: options.name,
303-
description: options.description ?? `Memory for ${options.name}`,
304-
eventExpiryDuration: options.expiry ?? DEFAULT_EVENT_EXPIRY,
305-
strategies,
306-
ownerAgent: options.owner,
307-
userAgents,
308-
};
276+
return { success: true, memoryName: result.name };
277+
} catch (err) {
278+
return { success: false, error: getErrorMessage(err) };
279+
}
309280
}
310281

311-
export async function handleAddMemory(options: ValidatedAddMemoryOptions): Promise<AddMemoryResult> {
282+
// Identity handler (v2: top-level credential resource, no owner/user)
283+
export async function handleAddIdentity(options: ValidatedAddIdentityOptions): Promise<AddIdentityResult> {
312284
try {
313-
const config = buildMemoryConfig(options);
314-
const result = await createMemoryFromWizard(config);
315-
return {
316-
success: true,
317-
memoryName: result.name,
318-
ownerAgent: result.ownerAgent,
319-
userAgents: result.userAgents,
320-
};
285+
const result = await createCredential({
286+
name: options.name,
287+
apiKey: options.apiKey,
288+
});
289+
290+
return { success: true, credentialName: result.name };
321291
} catch (err) {
322292
return { success: false, error: getErrorMessage(err) };
323293
}
324294
}
325295

326-
// Identity handler
327-
function buildIdentityConfig(options: ValidatedAddIdentityOptions): AddIdentityConfig {
328-
const userAgents = options.users
329-
? options.users
330-
.split(',')
331-
.map(s => s.trim())
332-
.filter(Boolean)
333-
: [];
296+
// ─────────────────────────────────────────────────────────────────────────────
297+
// MCP Runtime Bind handler (still relevant in v2)
298+
// ─────────────────────────────────────────────────────────────────────────────
334299

335-
return {
336-
identityType: options.type as IdentityCredentialVariant,
337-
name: options.name,
338-
apiKey: options.apiKey,
339-
ownerAgent: options.owner,
340-
userAgents,
341-
};
300+
export interface ValidatedBindMcpRuntimeOptions {
301+
agent: string;
302+
runtime: string;
303+
envVar: string;
342304
}
343305

344-
export async function handleAddIdentity(options: ValidatedAddIdentityOptions): Promise<AddIdentityResult> {
306+
export async function handleBindMcpRuntime(options: ValidatedBindMcpRuntimeOptions): Promise<BindMcpRuntimeResult> {
345307
try {
346-
const config = buildIdentityConfig(options);
347-
const result = await createIdentityFromWizard(config);
348-
return {
349-
success: true,
350-
identityName: result.name,
351-
ownerAgent: result.ownerAgent,
352-
userAgents: result.userAgents,
353-
};
308+
await bindMcpRuntimeToAgent(options.runtime, {
309+
agentName: options.agent,
310+
envVarName: options.envVar,
311+
});
312+
return { success: true, runtimeName: options.runtime, targetAgent: options.agent };
354313
} catch (err) {
355314
return { success: false, error: getErrorMessage(err) };
356315
}
@@ -420,24 +379,6 @@ export async function handleBindGateway(options: ValidatedBindGatewayOptions): P
420379
}
421380
}
422381

423-
export interface ValidatedBindMcpRuntimeOptions {
424-
agent: string;
425-
runtime: string;
426-
envVar: string;
427-
}
428-
429-
export async function handleBindMcpRuntime(options: ValidatedBindMcpRuntimeOptions): Promise<BindMcpRuntimeResult> {
430-
try {
431-
await bindMcpRuntimeToAgent(options.runtime, {
432-
agentName: options.agent,
433-
envVarName: options.envVar,
434-
});
435-
return { success: true, runtimeName: options.runtime, targetAgent: options.agent };
436-
} catch (err) {
437-
return { success: false, error: getErrorMessage(err) };
438-
}
439-
}
440-
441382
export interface ValidatedBindAgentOptions {
442383
source: string;
443384
target: string;

0 commit comments

Comments
 (0)