-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat: add delete/update CLI parity to managed agents (fixes #1430) #1441
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
0175c55
feat: add delete operations and envs update to managed CLI
praisonai-triage-agent[bot] d36aae5
test(cli): patch anthropic via sys.modules since _get_client imports …
MervinPraison aebff26
fix(cli): validate and sanitize env package list on managed env update
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -316,6 +316,32 @@ def sessions_resume( | |||||||||||||||||
| print(result) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @sessions_app.command("delete") | ||||||||||||||||||
| def sessions_delete( | ||||||||||||||||||
| session_id: str = typer.Argument(..., help="Session ID to delete (sesn_01...)"), | ||||||||||||||||||
| yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt"), | ||||||||||||||||||
| ): | ||||||||||||||||||
| """Delete a session. | ||||||||||||||||||
|
|
||||||||||||||||||
| Example: | ||||||||||||||||||
| praisonai managed sessions delete sesn_01AbCdEf | ||||||||||||||||||
| praisonai managed sessions delete sesn_01AbCdEf --yes | ||||||||||||||||||
| """ | ||||||||||||||||||
| if not yes: | ||||||||||||||||||
| confirm = typer.confirm(f"Are you sure you want to delete session {session_id}?") | ||||||||||||||||||
| if not confirm: | ||||||||||||||||||
| typer.echo("Deletion cancelled.") | ||||||||||||||||||
| raise typer.Exit(0) | ||||||||||||||||||
|
|
||||||||||||||||||
| client = _get_client() | ||||||||||||||||||
| try: | ||||||||||||||||||
| client.beta.sessions.delete(session_id) | ||||||||||||||||||
| typer.echo(f"Session {session_id} deleted successfully.") | ||||||||||||||||||
| except Exception as e: | ||||||||||||||||||
| typer.echo(f"Error deleting session: {e}") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
| # agents sub-commands | ||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
|
|
@@ -397,6 +423,32 @@ def agents_update( | |||||||||||||||||
| typer.echo(f"Updated agent: {updated.id} (v{getattr(updated,'version','')})") | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @agents_app.command("delete") | ||||||||||||||||||
| def agents_delete( | ||||||||||||||||||
| agent_id: str = typer.Argument(..., help="Agent ID to delete (agent_01...)"), | ||||||||||||||||||
| yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt"), | ||||||||||||||||||
| ): | ||||||||||||||||||
| """Delete an agent. | ||||||||||||||||||
|
|
||||||||||||||||||
| Example: | ||||||||||||||||||
| praisonai managed agents delete agent_01AbCdEf | ||||||||||||||||||
| praisonai managed agents delete agent_01AbCdEf --yes | ||||||||||||||||||
| """ | ||||||||||||||||||
| if not yes: | ||||||||||||||||||
| confirm = typer.confirm(f"Are you sure you want to delete agent {agent_id}?") | ||||||||||||||||||
| if not confirm: | ||||||||||||||||||
| typer.echo("Deletion cancelled.") | ||||||||||||||||||
| raise typer.Exit(0) | ||||||||||||||||||
|
|
||||||||||||||||||
| client = _get_client() | ||||||||||||||||||
| try: | ||||||||||||||||||
| client.beta.agents.delete(agent_id) | ||||||||||||||||||
| typer.echo(f"Agent {agent_id} deleted successfully.") | ||||||||||||||||||
| except Exception as e: | ||||||||||||||||||
| typer.echo(f"Error deleting agent: {e}") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
| # envs sub-commands | ||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
|
|
@@ -441,6 +493,72 @@ def envs_get( | |||||||||||||||||
| typer.echo(f"Config: {cfg}") | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @envs_app.command("update") | ||||||||||||||||||
| def envs_update( | ||||||||||||||||||
| env_id: str = typer.Argument(..., help="Environment ID (env_01...)"), | ||||||||||||||||||
| packages: Optional[str] = typer.Option(None, "--packages", "-p", help="Comma-separated pip packages"), | ||||||||||||||||||
| networking: Optional[str] = typer.Option(None, "--networking", help="Networking type: 'full' or 'limited'"), | ||||||||||||||||||
| ): | ||||||||||||||||||
| """Update an environment's configuration. | ||||||||||||||||||
|
|
||||||||||||||||||
| Example: | ||||||||||||||||||
| praisonai managed envs update env_01AbCdEf --packages "numpy,pandas" | ||||||||||||||||||
| praisonai managed envs update env_01AbCdEf --networking limited | ||||||||||||||||||
| """ | ||||||||||||||||||
| client = _get_client() | ||||||||||||||||||
| kwargs = {} | ||||||||||||||||||
|
|
||||||||||||||||||
| if packages: | ||||||||||||||||||
| pkg_list = [p.strip() for p in packages.split(",") if p.strip()] | ||||||||||||||||||
| if not pkg_list: | ||||||||||||||||||
| typer.echo("Error: --packages must include at least one package name") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
| kwargs["packages"] = {"pip": pkg_list} | ||||||||||||||||||
|
|
||||||||||||||||||
| if networking: | ||||||||||||||||||
| if networking not in ["full", "limited"]: | ||||||||||||||||||
| typer.echo("Error: --networking must be 'full' or 'limited'") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
| kwargs["networking"] = {"type": networking} | ||||||||||||||||||
|
Comment on lines
+519
to
+522
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| if not kwargs: | ||||||||||||||||||
| typer.echo("Nothing to update. Pass --packages or --networking.") | ||||||||||||||||||
| raise typer.Exit(0) | ||||||||||||||||||
|
|
||||||||||||||||||
| try: | ||||||||||||||||||
| updated = client.beta.environments.update(env_id, **kwargs) | ||||||||||||||||||
| typer.echo(f"Updated environment: {updated.id}") | ||||||||||||||||||
| except Exception as e: | ||||||||||||||||||
| typer.echo(f"Error updating environment: {e}") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| @envs_app.command("delete") | ||||||||||||||||||
| def envs_delete( | ||||||||||||||||||
| env_id: str = typer.Argument(..., help="Environment ID to delete (env_01...)"), | ||||||||||||||||||
| yes: bool = typer.Option(False, "--yes", "-y", help="Skip confirmation prompt"), | ||||||||||||||||||
| ): | ||||||||||||||||||
| """Delete an environment. | ||||||||||||||||||
|
|
||||||||||||||||||
| Example: | ||||||||||||||||||
| praisonai managed envs delete env_01AbCdEf | ||||||||||||||||||
| praisonai managed envs delete env_01AbCdEf --yes | ||||||||||||||||||
| """ | ||||||||||||||||||
| if not yes: | ||||||||||||||||||
| confirm = typer.confirm(f"Are you sure you want to delete environment {env_id}?") | ||||||||||||||||||
| if not confirm: | ||||||||||||||||||
| typer.echo("Deletion cancelled.") | ||||||||||||||||||
| raise typer.Exit(0) | ||||||||||||||||||
|
|
||||||||||||||||||
| client = _get_client() | ||||||||||||||||||
| try: | ||||||||||||||||||
| client.beta.environments.delete(env_id) | ||||||||||||||||||
| typer.echo(f"Environment {env_id} deleted successfully.") | ||||||||||||||||||
| except Exception as e: | ||||||||||||||||||
| typer.echo(f"Error deleting environment: {e}") | ||||||||||||||||||
| raise typer.Exit(1) | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
| # ids sub-commands (save / restore / show — no Anthropic IDs are user-defined) | ||||||||||||||||||
| # ───────────────────────────────────────────────────────────────────────────── | ||||||||||||||||||
|
|
||||||||||||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_client()is called before validating flags / checking the no-op case. As a result,praisonai managed envs update <id>(with no options) or with an invalid--networkingvalue will still require the anthropic package + API key, even though the command exits without making an API call. Move client creation to just beforeclient.beta.environments.update(...), after validation and theif not kwargsearly-exit.