@@ -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 {
1312import { getErrorMessage } from '../../errors' ;
1413import { setupPythonProject } from '../../operations' ;
1514import {
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' ;
2821import { createGatewayFromWizard , createToolFromWizard } from '../../operations/mcp/create-mcp' ;
29- import { createMemoryFromWizard } from '../../operations/memory/create-memory' ;
22+ import { createMemory } from '../../operations/memory/create-memory' ;
3023import { createRenderer } from '../../templates' ;
3124import type { MemoryOption } from '../../tui/screens/generate/types' ;
32- import type { AddIdentityConfig } from '../../tui/screens/identity/types' ;
3325import type { AddGatewayConfig , AddMcpToolConfig } from '../../tui/screens/mcp/types' ;
34- import type { AddMemoryConfig , AddMemoryStrategyConfig } from '../../tui/screens/memory/types' ;
3526import { DEFAULT_EVENT_EXPIRY } from '../../tui/screens/memory/types' ;
3627import type {
3728 AddAgentResult ,
3829 AddGatewayResult ,
3930 AddIdentityResult ,
4031 AddMcpToolResult ,
4132 AddMemoryResult ,
42- BindAgentResult ,
43- BindGatewayResult ,
44- BindIdentityResult ,
4533 BindMcpRuntimeResult ,
46- BindMemoryResult ,
4734} from './types' ;
4835import { dirname , join } from 'path' ;
4936
@@ -82,19 +69,13 @@ export interface ValidatedAddMcpToolOptions {
8269
8370export interface ValidatedAddMemoryOptions {
8471 name : string ;
85- description ?: string ;
8672 strategies : string ;
8773 expiry ?: number ;
88- owner : string ;
89- users ?: string ;
9074}
9175
9276export 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-
441382export interface ValidatedBindAgentOptions {
442383 source : string ;
443384 target : string ;
0 commit comments