@anyforge/control 0.2.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # @anyforge/control
2
2
 
3
- Governed LLM proxy for any agent. Use the AI tools you already use — Claude Code, Cursor, Cline, Continue, or your own SDK — and route every call through AnyForge for cost analytics, audit log, and policy enforcement.
3
+ Two things in one binary:
4
+
5
+ 1. **A governed LLM proxy** for any agent — Claude Code, Cursor, Cline, Continue, or your own SDK. Route their calls through AnyForge for cost analytics, audit log, and policy enforcement.
6
+ 2. **A scriptable AnyForge client** — approvals, crews, work items and workflows from a shell, with no browser and no agent in the loop.
7
+
8
+ The second half is what makes AnyForge usable from CI. Every command speaks the same `/api/v1/control/*` API the MCP server does, but without needing a language model to drive it.
4
9
 
5
10
  ## Install
6
11
 
@@ -50,12 +55,70 @@ Claude Code recognises both, but they behave differently. `ANTHROPIC_API_KEY` is
50
55
 
51
56
  ## Commands
52
57
 
58
+ ### Setup
59
+
53
60
  | | |
54
61
  |---|---|
55
62
  | `anyforge init` | Authorise this device and patch local agent configs |
56
- | `anyforge whoami` | Show the company tied to the saved key |
63
+ | `anyforge whoami` | Show the company, scopes and endpoint this key acts as (asks the server) |
57
64
  | `anyforge status` | Verify the proxy is reachable and your BYOK key is configured |
58
65
  | `anyforge logout` | Clear the local credential file **and revert patched configs** (does not revoke server-side) |
66
+ | `anyforge apply-patch` | Apply a unified diff from a file or stdin via `git apply` |
67
+
68
+ ### Scriptable
69
+
70
+ | | | Scope |
71
+ |---|---|---|
72
+ | `anyforge approvals` | List HIL approvals awaiting a decision | `read` |
73
+ | `anyforge approve <id>` | Approve one (`--notes` is recorded in the audit trail) | `approve` |
74
+ | `anyforge reject <id>` | Reject one | `approve` |
75
+ | `anyforge crews` | List crews (`--active` for non-terminal only) | `read` |
76
+ | `anyforge crew <id>` | Show one crew, its status and recent output | `read` |
77
+ | `anyforge crew start <item>` | Dispatch a crew on a work item (`--profile`, `--follow`) | `write` + a role that can dispatch |
78
+ | `anyforge crew follow <id>` | Watch a run until it needs a person or ends (`--interval`) | `read` |
79
+ | `anyforge halt <id>` / `resume <id>` | Stop or restart a crew | `approve` |
80
+ | `anyforge work` | List work items (`--status`, `--type`, `--priority`, `--search`, …) | `read` |
81
+ | `anyforge workflows` | List operator workflows | `read` |
82
+ | `anyforge run <id>` | Dispatch a run (`--input '{"repo":"acme/web"}'`) | `write` |
83
+ | `anyforge ask <question>` | Ask the Oracle one question | `read` |
84
+
85
+ Every command takes `--json`, which prints the API payload verbatim:
86
+
87
+ ```bash
88
+ anyforge approvals --json | jq 'length'
89
+ anyforge crews --active --json | jq -r '.[].id' | xargs -n1 anyforge halt
90
+ ```
91
+
92
+ ### Exit codes
93
+
94
+ CI gates on these, so they are a contract:
95
+
96
+ | | |
97
+ |---|---|
98
+ | `0` | Success — an empty list included |
99
+ | `1` | Network or unexpected failure (retryable) — and a `crew follow` whose run ended `HALTED` / `REJECTED` / `CANCELLED`, which is not |
100
+ | `2` | Usage error |
101
+ | `3` | Not authenticated — run `init`, or set `ANYFORGE_API_TOKEN` |
102
+ | `4` | The API refused; its error code prints to stderr |
103
+
104
+ Errors and progress go to stderr, so a `--json` pipe stays parseable under a failure.
105
+
106
+ `crew follow` is the one command whose exit code carries an OUTCOME rather than
107
+ a transport result, which is what makes it usable as the last step of a job:
108
+
109
+ ```bash
110
+ # Hand a ticket to a crew and fail the build if the work didn't land.
111
+ anyforge crew start "$ITEM" --follow
112
+ ```
113
+
114
+ It exits `0` when the run finishes or stops at a gate that needs a person, and
115
+ `1` when the run ended badly or was still going after 30 minutes. Under `--json`
116
+ its final line is `{ crewId, status, waiting, url }`, so a script can tell those
117
+ two `0`s apart.
118
+
119
+ ### Unattended use
120
+
121
+ Set `ANYFORGE_API_TOKEN` (and optionally `ANYFORGE_API_URL`) instead of running `init` — no browser, no credential file. Mint the key under **Settings → API keys** with the narrowest scope the job needs.
59
122
 
60
123
  ## Endpoints
61
124
 
@@ -63,8 +126,8 @@ The CLI defaults to `https://crew.anyforge.ai`. Override per-invocation with `--
63
126
 
64
127
  The proxy exposes:
65
128
 
66
- - `POST /v1/anthropic/messages` — drop-in for `https://api.anthropic.com/v1/messages`. Use `Authorization: Bearer sk_anyforge_…` instead of `x-api-key`.
67
- - `POST /v1/openai/chat/completions` — drop-in for `https://api.openai.com/v1/chat/completions`.
129
+ - `POST /v1/anthropic/v1/messages` — drop-in for `https://api.anthropic.com/v1/messages`. Use `Authorization: Bearer sk_anyforge_…` instead of `x-api-key`. The `/v1` repeats because you set `ANTHROPIC_BASE_URL` to `https://crew.anyforge.ai/v1/anthropic` and the Anthropic SDK appends `/v1/messages` to it.
130
+ - `POST /v1/openai/v1/chat/completions` — drop-in for `https://api.openai.com/v1/chat/completions`.
68
131
 
69
132
  Both validate your AnyForge API key, look up your company's BYOK provider key, forward the request, and stream the response back unchanged. Token counts and cost are logged to your usage dashboard.
70
133