@@ -72,6 +72,14 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
7272 const targetOrg = flags [ 'target-org' ] ;
7373 const conn = targetOrg . getConnection ( flags [ 'api-version' ] ) ;
7474
75+ // First compile the AF script to get the Agent JSON
76+ const agentJson = await Agent . compileAfScript (
77+ conn ,
78+ readFileSync ( join ( authoringBundleDir , `${ flags [ 'api-name' ] } .afscript` ) , 'utf8' )
79+ ) ;
80+ mso . skipTo ( 'Publish Agent' ) ;
81+
82+ // Then publish the Agent JSON to create the agent
7583 // Set up lifecycle listeners for retrieve events
7684 Lifecycle . getInstance ( ) . on ( 'scopedPreRetrieve' , ( ) => {
7785 mso . skipTo ( 'Retrieve Metadata' ) ;
@@ -83,28 +91,20 @@ export default class AgentPublishAuthoringBundle extends SfCommand<AgentPublishA
8391 mso . stop ( ) ;
8492 } else {
8593 const errorMessage = `Metadata retrieval failed: ${ ensureArray (
86- result ?. retrieveResult . response ?. messages
94+ // @ts -expect-error I saw errorMessages populated with useful information during testing
95+ result ?. retrieveResult . response ?. messages ?? result ?. retrieveResult ?. response ?. errorMessage
8796 ) . join ( EOL ) } `;
8897 mso . error ( ) ;
8998 throw new SfError ( errorMessage ) ;
9099 }
91100 return Promise . resolve ( ) ;
92101 } ) ;
93-
94- // First compile the AF script to get the Agent JSON
95- const agentJson = await Agent . compileAfScript (
96- conn ,
97- readFileSync ( join ( authoringBundleDir , `${ flags [ 'api-name' ] } .afscript` ) , 'utf8' )
98- ) ;
99- mso . skipTo ( 'Publish Agent' ) ;
100-
101- // Then publish the Agent JSON to create the agent
102102 const result = await Agent . publishAgentJson ( conn , this . project ! , agentJson ) ;
103103 mso . stop ( ) ;
104104
105105 return {
106106 success : true ,
107- botDeveloperName : result . botDeveloperName ,
107+ botDeveloperName : result . developerName ,
108108 } ;
109109 } catch ( error ) {
110110 // Handle validation errors
0 commit comments