@@ -83,26 +83,24 @@ def delete(
8383@agents .command ()
8484def cleanup_workflows (
8585 agent_name : str = typer .Argument (..., help = "Name of the agent to cleanup workflows for" ),
86- force : bool = typer .Option (False , help = "Force cleanup using direct Temporal termination (bypasses development check)" ),
86+ force : bool = typer .Option (
87+ False , help = "Force cleanup using direct Temporal termination (bypasses development check)"
88+ ),
8789):
8890 """
8991 Clean up all running workflows for an agent.
90-
92+
9193 By default, uses graceful cancellation via agent RPC.
9294 With --force, directly terminates workflows via Temporal client.
9395 This is a convenience command that does the same thing as 'agentex tasks cleanup'.
9496 """
9597 try :
9698 console .print (f"[blue]Cleaning up workflows for agent '{ agent_name } '...[/blue]" )
97-
98- cleanup_agent_workflows (
99- agent_name = agent_name ,
100- force = force ,
101- development_only = True
102- )
103-
99+
100+ cleanup_agent_workflows (agent_name = agent_name , force = force , development_only = True )
101+
104102 console .print (f"[green]✓ Workflow cleanup completed for agent '{ agent_name } '[/green]" )
105-
103+
106104 except Exception as e :
107105 console .print (f"[red]Cleanup failed: { str (e )} [/red]" )
108106 logger .exception ("Agent workflow cleanup failed" )
@@ -112,12 +110,8 @@ def cleanup_workflows(
112110@agents .command ()
113111def build (
114112 manifest : str = typer .Option (..., help = "Path to the manifest you want to use" ),
115- registry : str | None = typer .Option (
116- None , help = "Registry URL for pushing the built image"
117- ),
118- repository_name : str | None = typer .Option (
119- None , help = "Repository name to use for the built image"
120- ),
113+ registry : str | None = typer .Option (None , help = "Registry URL for pushing the built image" ),
114+ repository_name : str | None = typer .Option (None , help = "Repository name to use for the built image" ),
121115 platforms : str | None = typer .Option (
122116 None , help = "Platform to build the image for. Please enter a comma separated list of platforms."
123117 ),
@@ -126,9 +120,7 @@ def build(
126120 None ,
127121 help = "Docker build secret in the format 'id=secret-id,src=path-to-secret-file'" ,
128122 ),
129- tag : str | None = typer .Option (
130- None , help = "Image tag to use (defaults to 'latest')"
131- ),
123+ tag : str | None = typer .Option (None , help = "Image tag to use (defaults to 'latest')" ),
132124 build_arg : builtins .list [str ] | None = typer .Option ( # noqa: B008
133125 None ,
134126 help = "Docker build argument in the format 'KEY=VALUE' (can be used multiple times)" ,
@@ -143,7 +135,7 @@ def build(
143135 if push and not registry :
144136 typer .echo ("Error: --registry is required when --push is enabled" , err = True )
145137 raise typer .Exit (1 )
146-
138+
147139 # Only proceed with build if we have a registry (for now, to match existing behavior)
148140 if not registry :
149141 typer .echo ("No registry provided, skipping image build" )
@@ -175,10 +167,7 @@ def build(
175167@agents .command ()
176168def run (
177169 manifest : str = typer .Option (..., help = "Path to the manifest you want to use" ),
178- cleanup_on_start : bool = typer .Option (
179- False ,
180- help = "Clean up existing workflows for this agent before starting"
181- ),
170+ cleanup_on_start : bool = typer .Option (False , help = "Clean up existing workflows for this agent before starting" ),
182171 # Debug options
183172 debug : bool = typer .Option (False , help = "Enable debug mode for both worker and ACP (disables auto-reload)" ),
184173 debug_worker : bool = typer .Option (False , help = "Enable debug mode for temporal worker only" ),
@@ -190,26 +179,22 @@ def run(
190179 Run an agent locally from the given manifest.
191180 """
192181 typer .echo (f"Running agent from manifest: { manifest } " )
193-
182+
194183 # Optionally cleanup existing workflows before starting
195184 if cleanup_on_start :
196185 try :
197186 # Parse manifest to get agent name
198187 manifest_obj = AgentManifest .from_yaml (file_path = manifest )
199188 agent_name = manifest_obj .agent .name
200-
189+
201190 console .print (f"[yellow]Cleaning up existing workflows for agent '{ agent_name } '...[/yellow]" )
202- cleanup_agent_workflows (
203- agent_name = agent_name ,
204- force = False ,
205- development_only = True
206- )
191+ cleanup_agent_workflows (agent_name = agent_name , force = False , development_only = True )
207192 console .print ("[green]✓ Pre-run cleanup completed[/green]" )
208-
193+
209194 except Exception as e :
210195 console .print (f"[yellow]⚠ Pre-run cleanup failed: { str (e )} [/yellow]" )
211196 logger .warning (f"Pre-run cleanup failed: { e } " )
212-
197+
213198 # Create debug configuration based on CLI flags
214199 debug_config = None
215200 if debug or debug_worker or debug_acp :
@@ -224,19 +209,19 @@ def run(
224209 mode = DebugMode .ACP
225210 else :
226211 mode = DebugMode .NONE
227-
212+
228213 debug_config = DebugConfig (
229214 enabled = True ,
230215 mode = mode ,
231216 port = debug_port ,
232217 wait_for_attach = wait_for_debugger ,
233- auto_port = False # Use fixed port to match VS Code launch.json
218+ auto_port = False , # Use fixed port to match VS Code launch.json
234219 )
235-
220+
236221 console .print (f"[blue]🐛 Debug mode enabled: { mode .value } [/blue]" )
237222 if wait_for_debugger :
238223 console .print ("[yellow]⏳ Processes will wait for debugger attachment[/yellow]" )
239-
224+
240225 try :
241226 run_agent (manifest_path = manifest , debug_config = debug_config )
242227 except Exception as e :
@@ -247,30 +232,23 @@ def run(
247232
248233@agents .command ()
249234def deploy (
250- cluster : str = typer .Option (
251- ..., help = "Target cluster name (must match kubectl context)"
252- ),
235+ cluster : str = typer .Option (..., help = "Target cluster name (must match kubectl context)" ),
253236 manifest : str = typer .Option ("manifest.yaml" , help = "Path to the manifest file" ),
254237 namespace : str | None = typer .Option (
255238 None ,
256239 help = "Override Kubernetes namespace (defaults to namespace from environments.yaml)" ,
257240 ),
258241 environment : str | None = typer .Option (
259- None , help = "Environment name (dev, prod, etc.) - must be defined in environments.yaml. If not provided, the namespace must be set explicitly."
260- ),
261- tag : str | None = typer .Option (None , help = "Override the image tag for deployment" ),
262- repository : str | None = typer .Option (
263- None , help = "Override the repository for deployment"
264- ),
265- interactive : bool = typer .Option (
266- True , "--interactive/--no-interactive" , help = "Enable interactive prompts"
242+ None ,
243+ help = "Environment name (dev, prod, etc.) - must be defined in environments.yaml. If not provided, the namespace must be set explicitly." ,
267244 ),
245+ tag : str | None = typer .Option (None , help = "Override the image tag for deployment" ),
246+ repository : str | None = typer .Option (None , help = "Override the repository for deployment" ),
247+ interactive : bool = typer .Option (True , "--interactive/--no-interactive" , help = "Enable interactive prompts" ),
268248):
269249 """Deploy an agent to a Kubernetes cluster using Helm"""
270250
271- console .print (
272- Panel .fit ("🚀 [bold blue]Deploy Agent[/bold blue]" , border_style = "blue" )
273- )
251+ console .print (Panel .fit ("🚀 [bold blue]Deploy Agent[/bold blue]" , border_style = "blue" ))
274252
275253 try :
276254 # Validate manifest exists
@@ -281,17 +259,12 @@ def deploy(
281259
282260 # Validate manifest and environments configuration
283261 try :
284- if environment :
285- _ , environments_config = validate_manifest_and_environments (
286- str (manifest_path ),
287- required_environment = environment
288- )
289- agent_env_config = environments_config .get_config_for_env (environment )
290- console .print (f"[green]✓[/green] Environment config validated: { environment } " )
291- else :
292- agent_env_config = None
293- console .print (f"[yellow]⚠[/yellow] No environment provided, skipping environment-specific config" )
294-
262+ _ , environments_config = validate_manifest_and_environments (
263+ str (manifest_path ), required_environment = environment
264+ )
265+ agent_env_config = environments_config .get_config_for_env (environment )
266+ console .print (f"[green]✓[/green] Environment config validated: { environment } " )
267+
295268 except EnvironmentsValidationError as e :
296269 error_msg = generate_helpful_error_message (e , "Environment validation failed" )
297270 console .print (f"[red]Configuration Error:[/red]\n { error_msg } " )
@@ -310,9 +283,13 @@ def deploy(
310283 console .print (f"[blue]ℹ[/blue] Using namespace from environments.yaml: { namespace_from_config } " )
311284 namespace = namespace_from_config
312285 else :
313- raise DeploymentError (f"No namespace found in environments.yaml for environment: { environment } , and not passed in as --namespace" )
286+ raise DeploymentError (
287+ f"No namespace found in environments.yaml for environment: { environment } , and not passed in as --namespace"
288+ )
314289 elif not namespace :
315- raise DeploymentError ("No namespace provided, and not passed in as --namespace and no environment provided to read from an environments.yaml file" )
290+ raise DeploymentError (
291+ "No namespace provided, and not passed in as --namespace and no environment provided to read from an environments.yaml file"
292+ )
316293
317294 # Confirm deployment (only in interactive mode)
318295 console .print ("\n [bold]Deployment Summary:[/bold]" )
@@ -325,9 +302,7 @@ def deploy(
325302
326303 if interactive :
327304 proceed = questionary .confirm ("Proceed with deployment?" ).ask ()
328- proceed = handle_questionary_cancellation (
329- proceed , "deployment confirmation"
330- )
305+ proceed = handle_questionary_cancellation (proceed , "deployment confirmation" )
331306
332307 if not proceed :
333308 console .print ("Deployment cancelled" )
@@ -337,9 +312,7 @@ def deploy(
337312
338313 check_and_switch_cluster_context (cluster )
339314 if not validate_namespace (namespace , cluster ):
340- console .print (
341- f"[red]Error:[/red] Namespace '{ namespace } ' does not exist in cluster '{ cluster } '"
342- )
315+ console .print (f"[red]Error:[/red] Namespace '{ namespace } ' does not exist in cluster '{ cluster } '" )
343316 raise typer .Exit (1 )
344317
345318 deploy_overrides = InputDeployOverrides (repository = repository , image_tag = tag )
@@ -356,9 +329,7 @@ def deploy(
356329 # Use the already loaded manifest object
357330 release_name = f"{ manifest_obj .agent .name } -{ cluster } "
358331
359- console .print (
360- "\n [bold green]🎉 Deployment completed successfully![/bold green]"
361- )
332+ console .print ("\n [bold green]🎉 Deployment completed successfully![/bold green]" )
362333 console .print ("\n To check deployment status:" )
363334 console .print (f" kubectl get pods -n { namespace } " )
364335 console .print (f" helm status { release_name } -n { namespace } " )
0 commit comments