@@ -49,6 +49,7 @@ func newAutomationCreateCmd() *cobra.Command {
4949 promptFile string
5050 environmentKind string
5151 environmentID string
52+ runIn string
5253 timezone string
5354 )
5455
@@ -58,8 +59,14 @@ func newAutomationCreateCmd() *cobra.Command {
5859 Long : curatedLong (`Create an AI SRE Automation.
5960
6061By default the rule is enabled. Use --disabled only when the user explicitly
61- asks to create it disabled. team_id=0 means personal scope; --team-id >0 creates
62- the rule under that team. The scope is immutable after creation.
62+ asks to create it disabled. Omit --team-id to let the server inherit the live
63+ IM conversation scope when available; --team-id 0 explicitly selects personal
64+ scope and --team-id >0 selects that team. The scope is immutable after creation.
65+
66+ When this command is invoked from a live IM conversation, omitting --run-in
67+ lets the server bind the Automation to that current chat. Use --run-in web to
68+ run it in the web console instead. Do not supply chat, platform, integration,
69+ or session identifiers: the server resolves and authorizes the current chat.
6370
6471 Schedule helpers build a 5-field cron expression evaluated in the rule's
6572 timezone. Pass --timezone when the user names one. When --timezone is
@@ -86,6 +93,12 @@ the rule under that team. The scope is immutable after creation.
8693 if strings .TrimSpace (taskPrompt ) == "" {
8794 return fmt .Errorf ("one of --prompt or --prompt-file is required" )
8895 }
96+ if cmd .Flags ().Changed ("run-in" ) {
97+ runIn = strings .TrimSpace (runIn )
98+ if runIn != "current-chat" && runIn != "web" {
99+ return fmt .Errorf ("--run-in must be current-chat or web" )
100+ }
101+ }
89102
90103 effectiveScheduleEnabled := scheduleEnabled
91104 cron , err := resolveAutomationCreateCron (cmd , schedule , at , weekday , cronExpr , httpPostTrigger , & effectiveScheduleEnabled )
@@ -95,7 +108,6 @@ the rule under that team. The scope is immutable after creation.
95108
96109 req := & flashduty.AutomationRuleCreateRequest {
97110 Name : name ,
98- TeamID : teamID ,
99111 CronExpr : cron ,
100112 Enabled : ! disabled ,
101113 ScheduleTriggerEnabled : flashduty .Bool (effectiveScheduleEnabled ),
@@ -104,6 +116,12 @@ the rule under that team. The scope is immutable after creation.
104116 EnvironmentKind : strings .TrimSpace (environmentKind ),
105117 EnvironmentID : strings .TrimSpace (environmentID ),
106118 }
119+ if cmd .Flags ().Changed ("team-id" ) {
120+ req .TeamID = flashduty .Int64 (teamID )
121+ }
122+ if cmd .Flags ().Changed ("run-in" ) {
123+ req .RunIn = flashduty .String (runIn )
124+ }
107125 if cmd .Flags ().Changed ("timezone" ) {
108126 req .Timezone = strings .TrimSpace (timezone )
109127 }
@@ -117,7 +135,8 @@ the rule under that team. The scope is immutable after creation.
117135 }
118136
119137 cmd .Flags ().StringVar (& name , "name" , "" , "Automation name" )
120- cmd .Flags ().Int64Var (& teamID , "team-id" , 0 , "Scope team ID; 0 means personal scope" )
138+ cmd .Flags ().Int64Var (& teamID , "team-id" , 0 , "Scope team ID; omit to inherit IM scope when available, or pass 0 for personal scope" )
139+ cmd .Flags ().StringVar (& runIn , "run-in" , "" , "Execution destination: current-chat or web; omit for the server default" )
121140 cmd .Flags ().StringVar (& schedule , "schedule" , "" , "Schedule helper: hourly, daily, weekly, or cron" )
122141 cmd .Flags ().StringVar (& at , "at" , "" , "Local time in HH:MM (rule's timezone); for hourly schedules, only the minute is used. " + automationTimezoneNote )
123142 cmd .Flags ().StringVar (& weekday , "weekday" , "" , "Weekday for weekly schedules: sun, mon, tue, wed, thu, fri, sat, or 0-7" )
@@ -132,6 +151,7 @@ the rule under that team. The scope is immutable after creation.
132151 cmd .Flags ().StringVar (& environmentID , "environment-id" , "" , "BYOC Runner ID when --environment-kind=byoc" )
133152 registerEnumFlag (cmd , "schedule" , "hourly" , "daily" , "weekly" , "cron" )
134153 registerEnumFlag (cmd , "environment-kind" , "cloud" , "byoc" )
154+ registerEnumFlag (cmd , "run-in" , "current-chat" , "web" )
135155 return cmd
136156}
137157
0 commit comments