Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

docs: spend-controls consent/caps section; chat-connectors headless lane

garrytan49145df9bc20
diff --git a/docs/guides/chat-connectors.md b/docs/guides/chat-connectors.md
index 709f901233..4ec99423aa 100644
--- a/docs/guides/chat-connectors.md
+++ b/docs/guides/chat-connectors.md
@@ -37,6 +37,33 @@ gbrain autopilot --install
`gbrain connectors status` shows credential provenance/expiry and sync state
(never the secret). `gbrain connectors logout <provider>` removes a credential.
+### Headless lane (an agent without a terminal)
+
+The credential is the user's own browser session, so an agent cannot sign in
+for them. When `gbrain connectors auth <provider>` runs with no credential and
+nobody at the terminal (no TTY, `CI`, an agent process, or
+`GBRAIN_NON_INTERACTIVE=1`), it does not wait for a paste:
+
+- It prints an `[AGENT]` block (`actor: user`, `next: tell_user_to_run`) with
+ the provider's cookie checklist fenced in `[SHOW USER]` and the stdin command
+ to run, saves nothing, and exits 1.
+- `--try-oauth` never starts the loopback sign-in headless (it used to wait up
+ to 10 minutes for a browser redirect); it says OAuth needs a person at a
+ browser and hands over the same cookie checklist. With a person at the
+ terminal, `--no-browser` prints the sign-in URL instead of opening a browser.
+
+What the agent does: relay the `[SHOW USER]` text verbatim and ask the user to
+copy the cookie from a browser where they are logged in (never reuse, guess or
+search for one). The user can run `pbpaste | gbrain connectors auth <provider>
+--cookie -` themselves; if they hand the value over, pass it only on stdin
+(`printf '%s' "$COOKIE" | gbrain connectors auth <provider> --cookie -`), never
+in argv. A stdin that stays open without data ends after 30 seconds ("stdin
+was open but silent"; `GBRAIN_STDIN_TIMEOUT_MS` waits longer) and saves
+nothing. If the user would rather not share a session cookie, use the export
+lane (`gbrain transcripts ingest <export-file>`). Verify with
+`gbrain connectors status --json`. The full agent script lives in
+`skills/chat-connectors/SKILL.md`.
+
## How it works
```
@@ -165,6 +192,7 @@ the export-file lane (`conversation-archive`) — it always works.
|---|---|---|---|---|---|
| `forbidden` | Cloudflare/bot challenge on server-side fetch | Use the official export + `gbrain transcripts ingest` | user (downloads the export); agent ingests it | none | `gbrain connectors status --json` |
| `auth_required` | cookie expired/invalid | Re-copy a fresh Cookie header, `gbrain connectors auth` | user (copies a fresh Cookie header) | `credentials` | `gbrain connectors status --json` |
+| `connectors auth` exits 1 with an `[AGENT]` cookie checklist | no credential and nobody at the terminal ([headless lane](#headless-lane-an-agent-without-a-terminal)) | Relay the `[SHOW USER]` checklist; the user pipes the cookie into `gbrain connectors auth <provider> --cookie -` | user (copies the cookie) | `credentials` | `gbrain connectors status --json` |
| `partial` | some fetches failed | Watermark not advanced; just re-run | agent | `egress` (fetches from the provider again) | `gbrain connectors status --json` |
| receipt shows drift | provider API shape changed | Affected threads skipped (not lost); export lane still works | agent (reports it) | none | `gbrain connectors status --json` |
diff --git a/docs/operations/spend-controls.md b/docs/operations/spend-controls.md
index c933b78540..e832383422 100644
--- a/docs/operations/spend-controls.md
+++ b/docs/operations/spend-controls.md
@@ -34,6 +34,47 @@ pointing at this switch.
over posture. `tokenmax` only governs the default/absent case — it never overrides a
number you typed on the command line.
+## Consent and caps for paid commands (agent operator contract v1)
+
+Since v0.60.38.0 every command that spends money asks for authorization the
+same way ([protocol](../protocol/AGENT_OPERATOR_v1.md#consent-and-preapproval)).
+Without a terminal and without authorization, nothing runs: the command exits
+3 with a `confirmation_required` payload whose `user_message` the agent relays
+to the user, and whose `fix` is the exact command to run once they agree.
+`--json` never implies consent.
+
+What authorizes paid work, and the cap it runs under:
+
+| Authorization | Cap | `cap_source` |
+|---|---|---|
+| `--max-usd <n>` / `--max-cost <n>` | `<n>` | `user` |
+| a configured cap for the command (for example `embed.backfill_max_usd`) | that value | `user` |
+| the user's preapproval `consent.preapprove.paid.max_usd_per_run <usd>` (covers runs whose estimate is at or under it) | the preapproved limit | `user` |
+| `--yes` alone | the estimate × 1.5, floor $0.25, printed before the run | `derived` |
+| `--yes` alone, no estimate and no configured cap | the default cap ($5), printed | `default` |
+| `spend.posture=tokenmax` | the derived/default cap above, except `enrich` and `reindex-code` (below) | `derived` / `default` |
+
+- **`tokenmax` on `enrich` and `reindex-code` stays uncapped.** Those two
+ commands already ran without a ceiling under `spend.posture=tokenmax`
+ before the consent wave, so the posture keeps that meaning there: an
+ unattended run proceeds with no ceiling (spend still ledgered). Everywhere
+ else `tokenmax` authorizes the run under the derived cap. An explicit
+ `--max-usd` always wins.
+- **A derived cap that runs out** stops the command with exit 1, a checkpoint
+ and the exact resume command (`--max-usd <n>`); doctor's `agent_contract`
+ check then suggests the preapproval command. Raise the cap only with the
+ user's agreement.
+- **Unpriced models** (a model gbrain has no per-token rate for, for example
+ one released after this version): under a derived or default cap the run
+ **warns and proceeds** (`BUDGET_TRACKER_NO_PRICING` on stderr; the cap
+ cannot meter it). Under a cap the user set (`--max-usd`, a configured cap
+ or a preapproval) it **blocks** with `no_pricing` and nothing is spent: the
+ refusal's `fix` has `inputs` telling the agent to look up the model's
+ per-token rates (for example by web search on the provider's pricing page)
+ and register them with `gbrain pricing set` (see
+ [Registering a model price](#registering-a-model-price)), then retry the
+ same command.
+
## Off switches (`off` / `unlimited` / `none`)
The USD-limit knobs accept `off`, `unlimited`, or `none` (case-insensitive) to mean
@@ -58,9 +99,9 @@ The USD-limit knobs accept `off`, `unlimited`, or `none` (case-insensitive) to m
| Backfill 24h per-source spend cap | `embed.backfill_max_usd_per_source_24h` | `25` | refuses submission | `off` (`0` → default) | bypassed (still ledgered) |
| Backfill per-job budget | `embed.backfill_max_usd` | `10` | caps the job's tracker | `off` (`0`/garbage → default, fail-closed) | uncapped (still ledgered) |
| Backfill cooldown | `embed.backfill_cooldown_min` | `10` | skips re-submission inside window | — (latency knob, not spend) | **not** bypassed |
-| `reindex-code` cost gate | — (preview before re-embed) | — | TTY prompt / non-TTY refuse + exit 2 | `--max-cost off` | informational |
-| `migrate embeddings` consent gate | — (plan + estimate before provider migration) | — | TTY y/N prompt / non-TTY refuse + exit 2 | `--yes` | estimate marked informational, but **still prompts** (guards a destructive schema rebuild, not just spend) |
-| `enrich` / `onboard --auto` | `--max-usd` (per-call) | — | refuse without a cap (non-TTY) | `--max-usd off` | runs uncapped (still ledgered) |
+| `reindex-code` cost gate | — (preview before re-embed) | — | TTY prompt / non-TTY refuse + exit 3 (`confirmation_required`) | `--max-cost off` | runs uncapped (still ledgered) |
+| `migrate embeddings` consent gate | — (plan + estimate before provider migration) | — | TTY y/N prompt / non-TTY refuse + exit 3 (`confirmation_required`) | `--yes` | estimate marked informational, but **still prompts** (guards a destructive schema rebuild, not just spend) |
+| `enrich` / `onboard --auto` | `--max-usd` (per-call) | — | non-TTY without `--yes`/`--max-usd`: refuse + exit 3 (`confirmation_required`); `--yes` runs under the derived cap | `--max-usd off` | runs uncapped (still ledgered) |
| Image-OCR per-run ceiling | `embedding_image_ocr_max_images` / `embedding_image_ocr_max_usd` | `200` images / `$1.00` (estimated) | skips OCR over-cap (import continues; skips counted in `ocr_skipped_budget`, surfaced by doctor `ocr_health`) | `0` disables that cap | **not** bypassed (per-run cap, not a tracker gate) |
| Dream `extract_atoms` phase budget | `cycle.extract_atoms.budget_usd` | `0.30` | caps the phase's budget tracker (one tracker per drain attempt, across all its batches) | — | **not** consulted (phase budget enforces regardless) |
| Atom auto-drain daily cap | `autopilot.auto_drain.max_usd_per_day` | `2.00` | daily cap on drain **attempts** (`floor(max / 0.30)` = 6), not a dollar ledger | `gbrain config set autopilot.auto_drain.enabled false` | **not** consulted |