feat(cli): add agent clear-error (#19382)

## Thinking Path

- The server already exposes a permission-checked agent clear-error
endpoint.
- The CLI previously required operators to call that endpoint manually.
- A thin CLI wrapper provides the same action without duplicating
lifecycle policy.

## Linked Issues or Issue Description

**Problem or motivation**
The CLI exposes pause and resume but not the existing `POST
/api/agents/:id/clear-error` action.

**Proposed solution**
Expose `paperclipai agent clear-error <agent-id>` with standard
authentication and output.

**Alternatives considered**
Direct REST calls work but bypass normal CLI ergonomics; generic agent
PATCH is not equivalent.

**Roadmap alignment**
This exposes an existing server capability rather than adding a new
lifecycle policy.

## What Changed

- Add `agent clear-error` to the CLI and usage documentation.
- Test the API path, JSON output, forbidden (403) and invalid-state
(409) replies without retries or extra actions.

## Verification

- CLI lifecycle tests **10/10 passed** and typecheck passed.
- GitHub CI: **55 passed, 3 skipped, 0 failed** on `3b8fd71739b8`;
Greptile **5/5**.

## Risks

- The endpoint remains subject to server authorization and agent-state
checks. Clearing an error does not cure its underlying cause.

## Model Used

PR history records Anthropic Claude Sonnet 5.5 and OpenAI GPT-6.1 Sol
with tool-assisted review.

## Checklist

- [x] Searched similar open and closed PRs; no duplicate was found.
- [x] Focused tests, changed behavior and risks are documented.
- [x] All required CI checks pass on the current head.
- [x] Greptile review is 5/5 with no open actionable findings.
- [ ] Upstream maintainer approval (not yet requested as a merge).

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
appleguyandClaude Sonnet 5.5 authored and GitHub committed 2026-11-24 20:32:48 -06:00
1 parent 81e2c50aa9
commit f961287949
3 files changed
+50

No files matched your search

+16
View File
@@ -405,6 +405,22 @@ export function registerAgentCommands(program: Command): void {
}),
);
addCommonClientOptions(
agent
.command("clear-error")
.description("Clear an agent's error status")
.argument("<agentId>", "Agent ID")
.action(async (agentId: string, opts: BaseClientOptions) => {
try {
const ctx = resolveCommandContext(opts);
const cleared = await ctx.api.post<Agent>(apiPath`/api/agents/${agentId}/clear-error`, {});
printOutput(cleared, { json: ctx.json });
} catch (err) {
handleCommandError(err);
}
}),
);
addCommonClientOptions(
agent
.command("delete")