Skip to content

Commit 8d5d097

Browse files
khaliqgantRicky Schema Cascadeclaude
authored
feat(cli): add destroy command for tearing down deployed agents (#107)
* feat(cli): add destroy command for tearing down deployed agents Closes the workforce half of the M3 destroy LOUD HOLE. The cloud-side endpoint lives in AgentWorkforce/cloud#578 (DELETE /api/v1/workspaces/:workspaceId/deployments/:agentId); this commit adds the matching `agentworkforce destroy <persona-or-agent-id>` command. Accepts either: * a persona JSON path -> reads slug/id and resolves the agent UUID via GET /api/v1/workspaces/:workspaceId/agents?persona_slug=<slug> * a literal agent UUID -> destroyed directly Exit codes: 0 destroyed 2 not found / already destroyed (idempotent script-friendly signal) 1 any other error 7 new node:test cases (parse + fetch-mocked happy path / 401 / 404 / 500 / missing workspace / persona-path resolution / no-deployed-agent). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(cli): ignore directories as destroy persona paths --------- Co-authored-by: Ricky Schema Cascade <ricky@agent-relay.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 525334b commit 8d5d097

4 files changed

Lines changed: 774 additions & 0 deletions

File tree

packages/cli/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ agentworkforce show <persona>[@<tier>]
1313
agentworkforce install [flags] <pkg|path>
1414
agentworkforce sources <list|add|remove>
1515
agentworkforce harness check
16+
agentworkforce destroy <persona-or-agent-id> [--workspace <id>] [--cloud-url <url>] [--no-prompt]
1617
agentworkforce --version
1718
```
1819

@@ -29,6 +30,11 @@ agentworkforce --version
2930
- `sources` — list, add, or remove persona source directories.
3031
- `harness check` — probe which harnesses (`claude`, `codex`, `opencode`)
3132
are installed. See [`## Harness check`](#harness-check) below.
33+
- `destroy` — tear down a deployed cloud agent: cancels all relaycron
34+
schedules and marks the agent as destroyed. Accepts either a persona
35+
JSON path (slug resolved via the workspace's agents index) or a literal
36+
agent UUID. Exits `0` on success, `2` when the agent is unknown or
37+
already destroyed, `1` for any other failure.
3238
- `--version` — print the installed package version.
3339

3440
## Install

packages/cli/src/cli.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ import {
5959
} from '@relayfile/local-mount';
6060
import ora, { type Ora } from 'ora';
6161
import { runDeploy, runLogin } from './deploy-command.js';
62+
import { runDestroy } from './destroy-command.js';
6263
import {
6364
startLaunchMetadataRecording,
6465
type LaunchMetadataRun
@@ -202,6 +203,19 @@ Commands:
202203
--cloud-url <url> override the workforce cloud URL
203204
--input KEY=value override a declared persona input
204205
(repeat for multiple)
206+
destroy <persona-or-agent-id> [flags]
207+
Tear down a deployed agent: cancel all schedules and
208+
mark the agent as destroyed in the workspace. Accepts
209+
either a persona JSON path (resolved to an agent id
210+
via the workspace's agents index) or a literal agent
211+
UUID.
212+
Flags:
213+
--workspace <id> pick a non-default workspace
214+
--cloud-url <url> override the workforce cloud URL
215+
--no-prompt fail instead of opening the
216+
browser login flow
217+
Exit codes: 0 destroyed, 2 not found / already
218+
destroyed, 1 any other error.
205219
login Connect this machine to a workforce workspace. The
206220
browser-based flow is rolling out; until then it prints
207221
the WORKFORCE_WORKSPACE_ID / WORKFORCE_WORKSPACE_TOKEN
@@ -234,6 +248,8 @@ Examples:
234248
agentworkforce agent "$(agentworkforce pick "fix the flaky test in foo.test.ts")"
235249
agentworkforce deploy ./personas/weekly-digest.json --mode cloud
236250
agentworkforce deploy ./personas/weekly-digest.json --mode sandbox --input TOPIC="Deploy v1"
251+
agentworkforce destroy ./personas/weekly-digest.json
252+
agentworkforce destroy 11111111-2222-4333-8444-555555555555
237253
agentworkforce login
238254
`;
239255

@@ -3773,6 +3789,11 @@ export async function main(): Promise<void> {
37733789
return;
37743790
}
37753791

3792+
if (subcommand === 'destroy') {
3793+
await runDestroy(rest);
3794+
return;
3795+
}
3796+
37763797
if (subcommand === 'login') {
37773798
await runLogin(rest);
37783799
return;

0 commit comments

Comments
 (0)