1515 */
1616
1717import { Flags , SfCommand } from '@salesforce/sf-plugins-core' ;
18- import { Lifecycle , Messages } from '@salesforce/core' ;
18+ import { Lifecycle , Messages , SfError } from '@salesforce/core' ;
1919import { Agent , ProductionAgent , ScriptAgent } from '@salesforce/agents' ;
2020import { createCache } from '../../../previewSessionStore.js' ;
2121
@@ -38,26 +38,34 @@ export default class AgentPreviewStart extends SfCommand<AgentPreviewStartResult
3838 'api-name' : Flags . string ( {
3939 summary : messages . getMessage ( 'flags.api-name.summary' ) ,
4040 char : 'n' ,
41- exclusive : [ 'authoring-bundle' ] ,
41+ exactlyOne : [ 'api-name' , 'authoring-bundle' ] ,
4242 } ) ,
4343 'authoring-bundle' : Flags . string ( {
4444 summary : messages . getMessage ( 'flags.authoring-bundle.summary' ) ,
45- exclusive : [ 'api-name' ] ,
45+ exactlyOne : [ 'api-name' , 'authoring-bundle '] ,
4646 } ) ,
4747 'use-live-actions' : Flags . boolean ( {
4848 summary : messages . getMessage ( 'flags.use-live-actions.summary' ) ,
4949 exclusive : [ 'simulate-actions' ] ,
50- dependsOn : [ 'authoring-bundle' ] ,
5150 } ) ,
5251 'simulate-actions' : Flags . boolean ( {
5352 summary : messages . getMessage ( 'flags.simulate-actions.summary' ) ,
5453 exclusive : [ 'use-live-actions' ] ,
55- dependsOn : [ 'authoring-bundle' ] ,
5654 } ) ,
5755 } ;
5856
5957 public async run ( ) : Promise < AgentPreviewStartResult > {
6058 const { flags } = await this . parse ( AgentPreviewStart ) ;
59+
60+ // Validate: authoring-bundle requires exactly one mode flag
61+ // (mutual exclusion of mode flags handled by 'exclusive' in flag definitions)
62+ if ( flags [ 'authoring-bundle' ] && ! flags [ 'use-live-actions' ] && ! flags [ 'simulate-actions' ] ) {
63+ throw new SfError (
64+ 'When using --authoring-bundle, you must specify either --use-live-actions or --simulate-actions.' ,
65+ 'MissingModeFlag'
66+ ) ;
67+ }
68+
6169 const conn = flags [ 'target-org' ] . getConnection ( flags [ 'api-version' ] ) ;
6270 const useLiveActions = flags [ 'use-live-actions' ] ;
6371 const simulateActions = flags [ 'simulate-actions' ] ;
@@ -68,7 +76,7 @@ export default class AgentPreviewStart extends SfCommand<AgentPreviewStartResult
6876
6977 // Set mode for authoring bundles based on which flag was specified
7078 if ( agent instanceof ScriptAgent ) {
71- agent . preview . setMockMode ( useLiveActions ? 'Live Test ' : 'Mock ' ) ;
79+ agent . preview . setMockMode ( simulateActions ? 'Mock ' : 'Live Test ' ) ;
7280 }
7381
7482 // Warn if mode flags are used with published agents (they have no effect)
0 commit comments